#1396: Ideal.groebner_basis should accept keyword arguments for strategy
parameters
-----------------------------------+----------------------------------------
   Reporter:  malb                 |       Owner:  malb               
       Type:  enhancement          |      Status:  needs_review       
   Priority:  minor                |   Milestone:  sage-4.5           
  Component:  commutative algebra  |    Keywords:  libSingular options
     Author:  Simon King           |    Upstream:  N/A                
   Reviewer:                       |      Merged:                     
Work_issues:                       |  
-----------------------------------+----------------------------------------
Changes (by newvalueoldvalue):

  * keywords:  => libSingular options
  * status:  needs_work => needs_review
  * upstream:  => N/A
  * author:  => Simon King


Comment:

 This patch extends Martin's work on libSingular options. Now, the options
 {{{degBound}}} and {{{multBound}}} can be used. A decorator, applied to
 all relevant methods, ensures that standard options are used unless
 explicitly requested by setting named arguments -- even if outside the
 methods other options are set.

 The options can be named in Python style (deg_bound) or in Singular style
 ({{{degBound}}}), at the user's choice.

 Examples:

 1. Degree bound

 {{{
 sage: R.<x,y> = QQ[]
 sage: I = R*[x^3+y^2,x^2*y+1]
 sage: from sage.libs.singular.option import opt
 # Use prot and deg_bound
 sage: I.groebner_basis(prot=True, deg_bound=2)
 std in (0),(x,y),(dp(2),C)
 [4294967295:2]3ss
 (S:1)-
 product criterion:0 chain criterion:0
 [x^3 + y^2, x^2*y + 1]

 # Set prot and degBound outside the method
 sage: opt['prot'] = True
 # Singular style name
 sage: opt['degBound'] = 2
 # ... but inside the method, standard options are used:
 sage: I.groebner_basis()
 [x^3 + y^2, x^2*y + 1, y^3 - x]
 sage: opt['prot']
 True
 # Python style name
 sage: opt['deg_bound']
 2

 # similarly in Singular, rather than libSingular
 sage: I.groebner_basis(algorithm='singular',deg_bound=2)
 [x^3 + y^2, x^2*y + 1]
 sage: singular.eval('degBound=2')
 'degBound=2;'
 sage: I.groebner_basis(algorithm='singular')
 [x^3 + y^2, x^2*y + 1, y^3 - x]
 sage: singular.eval('degBound')
 '2'
 }}}

 2. Multiplicity bound

 {{{
 sage: Rlocal.<x,y,z> = PolynomialRing(QQ, order='ds')
 sage: J = [x^7+y^7+z^6,x^6+y^8+z^7,x^7+y^5+z^8,
 x^2*y^3+y^2*z^3+x^3*z^2,x^3*y^2+y^3*z^2+x^2*z^3]*Rlocal
 # prot:
 sage: J.groebner_basis(prot=True)
 std in basering
 [1048575:2]5(4)s(3)s6s7s8s(4)s(5)sH(13)9(3)sH(12)8(4)s(5).s.s9....sH(11)8.10
 (S:10)-----------
 product criterion:9 chain criterion:30
 [x^3*y^2 + y^3*z^2 + x^2*z^3, x^2*y^3 + x^3*z^2 + y^2*z^3, y^5, x^6,
 x^4*z^2 - y^4*z^2 - x^2*y*z^3 + x*y^2*z^3, z^6, y^4*z^3 - y^3*z^4 -
 x^2*z^5, x^3*y*z^4 - x^2*y^2*z^4 + x*y^3*z^4, x^3*z^5, x^2*y*z^5 +
 y^3*z^5, x*y^3*z^5]
 # bounding the multiplicity
 sage: J.groebner_basis(prot=True,mult_bound=100)
 std in basering
 [1048575:2]5(4)s(3)s6s7s8s(4)s(5)sH(13)
 (S:5)------
 product criterion:7 chain criterion:7
 [x^3*y^2 + y^3*z^2 + x^2*z^3, x^2*y^3 + x^3*z^2 + y^2*z^3, y^5, x^6 +
 x*y^4*z^5, x^4*z^2 - y^4*z^2 - x^2*y*z^3 + x*y^2*z^3, z^6 - x*y^4*z^4 -
 x^3*y*z^5]

 # Set the multBound in Singular
 sage: singular.eval('multBound=100')
 'multBound=100;'
 # ... nevertheless, the default multBound=0 is used:
 sage: J.groebner_basis(algorithm='singular')
 [x^3*y^2 + y^3*z^2 + x^2*z^3, x^2*y^3 + x^3*z^2 + y^2*z^3, y^5, x^6,
 x^4*z^2 - y^4*z^2 - x^2*y*z^3 + x*y^2*z^3, z^6, y^4*z^3 - y^3*z^4 -
 x^2*z^5, x^3*y*z^4 - x^2*y^2*z^4 + x*y^3*z^4, x^3*z^5, x^2*y*z^5 +
 y^3*z^5, x*y^3*z^5]
 sage: singular.eval('multBound')
 '100'
 # ... unless requested otherwise
 sage: J.groebner_basis(algorithm='singular',mult_bound=100)
 [x^3*y^2 + y^3*z^2 + x^2*z^3, x^2*y^3 + x^3*z^2 + y^2*z^3, y^5, x^6 +
 x*y^4*z^5, x^4*z^2 - y^4*z^2 - x^2*y*z^3 + x*y^2*z^3, z^6 - x*y^4*z^4 -
 x^3*y*z^5]
 }}}

 I just verified that {{{sage -testall}}} passes. So, ready for review!

 One remark: It turned out to be impossible to doctest {{{libSingular's}}}
 protocol output. I inserted examples with protocol in the documentation,
 for illustration, but don't test these. Of course, deg_bound and
 mult_bound is doctested.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/1396#comment:7>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to