libSingular: Options#

Singular uses a set of global options to determine verbosity and the behavior of certain algorithms. We provide an interface to these options in the most ‘natural’ python-ic way. Users who do not wish to deal with Singular functions directly usually do not have to worry about this interface or Singular options in general since this is taken care of by higher level functions.

We compute a Groebner basis for Cyclic-5 in two different contexts:

sage: P.<a,b,c,d,e> = PolynomialRing(GF(127))
sage: I = sage.rings.ideal.Cyclic(P)
sage: import sage.libs.singular.function_factory
sage: std = sage.libs.singular.function_factory.ff.std
>>> from sage.all import *
>>> P = PolynomialRing(GF(Integer(127)), names=('a', 'b', 'c', 'd', 'e',)); (a, b, c, d, e,) = P._first_ngens(5)
>>> I = sage.rings.ideal.Cyclic(P)
>>> import sage.libs.singular.function_factory
>>> std = sage.libs.singular.function_factory.ff.std

By default, tail reductions are performed:

sage: from sage.libs.singular.option import opt, opt_ctx
sage: opt['red_tail']
True
sage: std(I)[-1]
d^2*e^6 + 28*b*c*d + ...
>>> from sage.all import *
>>> from sage.libs.singular.option import opt, opt_ctx
>>> opt['red_tail']
True
>>> std(I)[-Integer(1)]
d^2*e^6 + 28*b*c*d + ...

If we don’t want this, we can create an option context, which disables this:

sage: with opt_ctx(red_tail=False, red_sb=False):
....:    std(I)[-1]
d^2*e^6 + 8*c^3 + ...
>>> from sage.all import *
>>> with opt_ctx(red_tail=False, red_sb=False):
...    std(I)[-Integer(1)]
d^2*e^6 + 8*c^3 + ...

However, this does not affect the global state:

sage: opt['red_tail']
True
>>> from sage.all import *
>>> opt['red_tail']
True

On the other hand, any assignment to an option object will immediately change the global state:

sage: opt['red_tail'] = False
sage: opt['red_tail']
False
sage: opt['red_tail'] = True
sage: opt['red_tail']
True
>>> from sage.all import *
>>> opt['red_tail'] = False
>>> opt['red_tail']
False
>>> opt['red_tail'] = True
>>> opt['red_tail']
True

Assigning values within an option context, only affects this context:

sage: with opt_ctx:
....:    opt['red_tail'] = False

sage: opt['red_tail']
True
>>> from sage.all import *
>>> with opt_ctx:
...    opt['red_tail'] = False

>>> opt['red_tail']
True

Option contexts can also be safely stacked:

sage: with opt_ctx:
....:     opt['red_tail'] = False
....:     print(opt)
....:     with opt_ctx:
....:         opt['red_through'] = False
....:         print(opt)
general options for libSingular (current value 0x00000082)
general options for libSingular (current value 0x00000002)

sage: print(opt)
general options for libSingular (current value 0x02000082)
>>> from sage.all import *
>>> with opt_ctx:
...     opt['red_tail'] = False
...     print(opt)
...     with opt_ctx:
...         opt['red_through'] = False
...         print(opt)
general options for libSingular (current value 0x00000082)
general options for libSingular (current value 0x00000002)

>>> print(opt)
general options for libSingular (current value 0x02000082)

Furthermore, the integer valued options deg_bound and mult_bound can be used:

sage: R.<x,y> = QQ[]
sage: I = R*[x^3+y^2,x^2*y+1]
sage: opt['deg_bound'] = 2
sage: std(I)
[x^2*y + 1, x^3 + y^2]
sage: opt['deg_bound'] = 0
sage: std(I)
[y^3 - x, x^2*y + 1, x^3 + y^2]
>>> from sage.all import *
>>> R = QQ['x, y']; (x, y,) = R._first_ngens(2)
>>> I = R*[x**Integer(3)+y**Integer(2),x**Integer(2)*y+Integer(1)]
>>> opt['deg_bound'] = Integer(2)
>>> std(I)
[x^2*y + 1, x^3 + y^2]
>>> opt['deg_bound'] = Integer(0)
>>> std(I)
[y^3 - x, x^2*y + 1, x^3 + y^2]

The same interface is available for verbosity options:

sage: from sage.libs.singular.option import opt_verb
sage: opt_verb['not_warn_sb']
False
sage: opt.reset_default()  # needed to avoid side effects
sage: opt_verb.reset_default()  # needed to avoid side effects
>>> from sage.all import *
>>> from sage.libs.singular.option import opt_verb
>>> opt_verb['not_warn_sb']
False
>>> opt.reset_default()  # needed to avoid side effects
>>> opt_verb.reset_default()  # needed to avoid side effects

AUTHOR:

  • Martin Albrecht (2009-08): initial implementation

  • Martin Albrecht (2010-01): better interface, verbosity options

  • Simon King (2010-07): Python-ic option names; deg_bound and mult_bound

class sage.libs.singular.option.LibSingularOptions[source]#

Bases: LibSingularOptions_abstract

Pythonic Interface to libSingular’s options.

Supported options are:

  • return_sb or returnSB – the functions syz, intersect, quotient, modulo return a standard base instead of a generating set if return_sb is set. This option should not be used for lift.

  • fast_hc or fastHC – tries to find the highest corner of the staircase (HC) as fast as possible during a standard basis computation (only used for local orderings).

  • int_strategy or intStrategy – avoids division of coefficients during standard basis computations. This option is ring dependent. By default, it is set for rings with characteristic 0 and not set for all other rings.

  • lazy – uses a more lazy approach in std computations, which was used in SINGULAR version before 2-0 (and which may lead to faster or slower computations, depending on the example).

  • length – select shorter reducers in std computations.

  • not_regularity or notRegularity – disables the regularity bound for res and mres.

  • not_sugar or notSugar – disables the sugar strategy during standard basis computation.

  • not_buckets or notBuckets – disables the bucket representation of polynomials during standard basis computations. This option usually decreases the memory usage but increases the computation time. It should only be set for memory-critical standard basis computations.

  • old_std or oldStd – uses a more lazy approach in std computations, which was used in SINGULAR version before 2-0 (and which may lead to faster or slower computations, depending on the example).

  • prot – shows protocol information indicating the progress during the following computations: facstd, fglm, groebner, lres, mres, minres, mstd, res, slimgb, sres, std, stdfglm, stdhilb, syz.

  • red_sb or redSB – computes a reduced standard basis in any standard basis computation.

  • red_tail or redTail – reduction of the tails of polynomials during standard basis computations. This option is ring dependent. By default, it is set for rings with global degree orderings and not set for all other rings.

  • red_through or redThrough – for inhomogeneous input, polynomial reductions during standard basis computations are never postponed, but always finished through. This option is ring dependent. By default, it is set for rings with global degree orderings and not set for all other rings.

  • sugar_crit or sugarCrit – uses criteria similar to the homogeneous case to keep more useless pairs.

  • weight_m or weightM – automatically computes suitable weights for the weighted ecart and the weighted sugar method.

In addition, two integer valued parameters are supported, namely:

  • deg_bound or degBound – The standard basis computation is stopped if the total (weighted) degree exceeds deg_bound. deg_bound should not be used for a global ordering with inhomogeneous input. Reset this bound by setting deg_bound to 0. The exact meaning of “degree” depends on the ring ordering and the command: slimgb uses always the total degree with weights 1, std does so for block orderings, only.

  • mult_bound or multBound – The standard basis computation is stopped if the ideal is zero-dimensional in a ring with local ordering and its multiplicity is lower than mult_bound. Reset this bound by setting mult_bound to 0.

EXAMPLES:

sage: from sage.libs.singular.option import LibSingularOptions
sage: libsingular_options = LibSingularOptions()
sage: libsingular_options
general options for libSingular (current value 0x06000082)
>>> from sage.all import *
>>> from sage.libs.singular.option import LibSingularOptions
>>> libsingular_options = LibSingularOptions()
>>> libsingular_options
general options for libSingular (current value 0x06000082)

Here we demonstrate the intended way of using libSingular options:

sage: R.<x,y> = QQ[]
sage: I = R*[x^3+y^2,x^2*y+1]
sage: I.groebner_basis(deg_bound=2)
[x^3 + y^2, x^2*y + 1]
sage: I.groebner_basis()
[x^3 + y^2, x^2*y + 1, y^3 - x]
>>> from sage.all import *
>>> R = QQ['x, y']; (x, y,) = R._first_ngens(2)
>>> I = R*[x**Integer(3)+y**Integer(2),x**Integer(2)*y+Integer(1)]
>>> I.groebner_basis(deg_bound=Integer(2))
[x^3 + y^2, x^2*y + 1]
>>> I.groebner_basis()
[x^3 + y^2, x^2*y + 1, y^3 - x]

The option mult_bound is only relevant in the local case:

sage: from sage.libs.singular.option import opt
sage: Rlocal.<x,y,z> = PolynomialRing(QQ, order='ds')
sage: x^2<x
True
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
sage: J.groebner_basis(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]
sage: opt['red_tail'] = True # the previous commands reset opt['red_tail'] to False
sage: J.groebner_basis()
[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]
>>> from sage.all import *
>>> from sage.libs.singular.option import opt
>>> Rlocal = PolynomialRing(QQ, order='ds', names=('x', 'y', 'z',)); (x, y, z,) = Rlocal._first_ngens(3)
>>> x**Integer(2)<x
True
>>> J = [x**Integer(7)+y**Integer(7)+z**Integer(6),x**Integer(6)+y**Integer(8)+z**Integer(7),x**Integer(7)+y**Integer(5)+z**Integer(8), x**Integer(2)*y**Integer(3)+y**Integer(2)*z**Integer(3)+x**Integer(3)*z**Integer(2),x**Integer(3)*y**Integer(2)+y**Integer(3)*z**Integer(2)+x**Integer(2)*z**Integer(3)]*Rlocal
>>> J.groebner_basis(mult_bound=Integer(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]
>>> opt['red_tail'] = True # the previous commands reset opt['red_tail'] to False
>>> J.groebner_basis()
[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]
reset_default()[source]#

Reset libSingular’s default options.

EXAMPLES:

sage: from sage.libs.singular.option import opt
sage: opt['red_tail']
True
sage: opt['red_tail'] = False
sage: opt['red_tail']
False
sage: opt['deg_bound']
0
sage: opt['deg_bound'] = 2
sage: opt['deg_bound']
2
sage: opt.reset_default()
sage: opt['red_tail']
True
sage: opt['deg_bound']
0
>>> from sage.all import *
>>> from sage.libs.singular.option import opt
>>> opt['red_tail']
True
>>> opt['red_tail'] = False
>>> opt['red_tail']
False
>>> opt['deg_bound']
0
>>> opt['deg_bound'] = Integer(2)
>>> opt['deg_bound']
2
>>> opt.reset_default()
>>> opt['red_tail']
True
>>> opt['deg_bound']
0
class sage.libs.singular.option.LibSingularOptionsContext[source]#

Bases: object

Option context

This object localizes changes to options.

EXAMPLES:

sage: from sage.libs.singular.option import opt, opt_ctx
sage: opt
general options for libSingular (current value 0x06000082)
>>> from sage.all import *
>>> from sage.libs.singular.option import opt, opt_ctx
>>> opt
general options for libSingular (current value 0x06000082)
sage: with opt_ctx(redTail=False):
....:     print(opt)
....:     with opt_ctx(redThrough=False):
....:         print(opt)
general options for libSingular (current value 0x04000082)
general options for libSingular (current value 0x04000002)

sage: print(opt)
general options for libSingular (current value 0x06000082)
>>> from sage.all import *
>>> with opt_ctx(redTail=False):
...     print(opt)
...     with opt_ctx(redThrough=False):
...         print(opt)
general options for libSingular (current value 0x04000082)
general options for libSingular (current value 0x04000002)

>>> print(opt)
general options for libSingular (current value 0x06000082)
opt[source]#
class sage.libs.singular.option.LibSingularOptions_abstract[source]#

Bases: object

Abstract Base Class for libSingular options.

load(value=None)[source]#

EXAMPLES:

sage: from sage.libs.singular.option import opt as sopt
sage: bck = sopt.save(); hex(bck[0]), bck[1], bck[2]
('0x6000082', 0, 0)
sage: sopt['redTail'] = False
sage: hex(int(sopt))
'0x4000082'
sage: sopt.load(bck)
sage: sopt['redTail']
True
>>> from sage.all import *
>>> from sage.libs.singular.option import opt as sopt
>>> bck = sopt.save(); hex(bck[Integer(0)]), bck[Integer(1)], bck[Integer(2)]
('0x6000082', 0, 0)
>>> sopt['redTail'] = False
>>> hex(int(sopt))
'0x4000082'
>>> sopt.load(bck)
>>> sopt['redTail']
True
save()[source]#

Return a triple of integers that allow reconstruction of the options.

EXAMPLES:

sage: from sage.libs.singular.option import opt
sage: opt['deg_bound']
0
sage: opt['red_tail']
True
sage: s = opt.save()
sage: opt['deg_bound'] = 2
sage: opt['red_tail'] = False
sage: opt['deg_bound']
2
sage: opt['red_tail']
False
sage: opt.load(s)
sage: opt['deg_bound']
0
sage: opt['red_tail']
True
sage: opt.reset_default()  # needed to avoid side effects
>>> from sage.all import *
>>> from sage.libs.singular.option import opt
>>> opt['deg_bound']
0
>>> opt['red_tail']
True
>>> s = opt.save()
>>> opt['deg_bound'] = Integer(2)
>>> opt['red_tail'] = False
>>> opt['deg_bound']
2
>>> opt['red_tail']
False
>>> opt.load(s)
>>> opt['deg_bound']
0
>>> opt['red_tail']
True
>>> opt.reset_default()  # needed to avoid side effects
class sage.libs.singular.option.LibSingularVerboseOptions[source]#

Bases: LibSingularOptions_abstract

Pythonic Interface to libSingular’s verbosity options.

Supported options are:

  • mem – shows memory usage in square brackets.

  • yacc – Only available in debug version.

  • redefine – warns about variable redefinitions.

  • reading – shows the number of characters read from a file.

  • loadLib or load_lib – shows loading of libraries.

  • debugLib or debug_lib – warns about syntax errors when loading a library.

  • loadProc or load_proc – shows loading of procedures from libraries.

  • defRes or def_res – shows the names of the syzygy modules while converting resolution to list.

  • usage – shows correct usage in error messages.

  • Imap or imap – shows the mapping of variables with the fetch and imap commands.

  • notWarnSB or not_warn_sb – do not warn if a basis is not a standard basis

  • contentSB or content_sb – avoids to divide by the content of a polynomial in std and related algorithms. Should usually not be used.

  • cancelunit – avoids to divide polynomials by non-constant units in std in the local case. Should usually not be used.

EXAMPLES:

sage: from sage.libs.singular.option import LibSingularVerboseOptions
sage: libsingular_verbose = LibSingularVerboseOptions()
sage: libsingular_verbose
verbosity options for libSingular (current value 0x00002851)
>>> from sage.all import *
>>> from sage.libs.singular.option import LibSingularVerboseOptions
>>> libsingular_verbose = LibSingularVerboseOptions()
>>> libsingular_verbose
verbosity options for libSingular (current value 0x00002851)
reset_default()[source]#

Return to libSingular’s default verbosity options

EXAMPLES:

sage: from sage.libs.singular.option import opt_verb
sage: opt_verb['not_warn_sb']
False
sage: opt_verb['not_warn_sb'] = True
sage: opt_verb['not_warn_sb']
True
sage: opt_verb.reset_default()
sage: opt_verb['not_warn_sb']
False
>>> from sage.all import *
>>> from sage.libs.singular.option import opt_verb
>>> opt_verb['not_warn_sb']
False
>>> opt_verb['not_warn_sb'] = True
>>> opt_verb['not_warn_sb']
True
>>> opt_verb.reset_default()
>>> opt_verb['not_warn_sb']
False