Term orders

Sage supports the following term orders:

Lexicographic (lex)

\(x^a < x^b\) if and only if there exists \(1 \le i \le n\) such that \(a_1 = b_1, \dots, a_{i-1} = b_{i-1}, a_i < b_i\). This term order is called ‘lp’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order='lex')
sage: x > y
True
sage: x > y^2
True
sage: x > 1
True
sage: x^1*y^2 > y^3*z^4
True
sage: x^3*y^2*z^4 < x^3*y^2*z^1
False
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order='lex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
True
>>> x > y**Integer(2)
True
>>> x > Integer(1)
True
>>> x**Integer(1)*y**Integer(2) > y**Integer(3)*z**Integer(4)
True
>>> x**Integer(3)*y**Integer(2)*z**Integer(4) < x**Integer(3)*y**Integer(2)*z**Integer(1)
False
Degree reverse lexicographic (degrevlex)

Let \(\deg(x^a) = a_1 + a_2 + \dots + a_n\), then \(x^a < x^b\) if and only if \(\deg(x^a) < \deg(x^b)\) or \(\deg(x^a) = \deg(x^b)\) and there exists \(1 \le i \le n\) such that \(a_n = b_n, \dots, a_{i+1} = b_{i+1}, a_i > b_i\). This term order is called ‘dp’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order='degrevlex')
sage: x > y
True
sage: x > y^2*z
False
sage: x > 1
True
sage: x^1*y^5*z^2 > x^4*y^1*z^3
True
sage: x^2*y*z^2 > x*y^3*z
False
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order='degrevlex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
True
>>> x > y**Integer(2)*z
False
>>> x > Integer(1)
True
>>> x**Integer(1)*y**Integer(5)*z**Integer(2) > x**Integer(4)*y**Integer(1)*z**Integer(3)
True
>>> x**Integer(2)*y*z**Integer(2) > x*y**Integer(3)*z
False
Degree lexicographic (deglex)

Let \(\deg(x^a) = a_1 + a_2 + \dots + a_n\), then \(x^a < x^b\) if and only if \(\deg(x^a) < \deg(x^b)\) or \(\deg(x^a) = \deg(x^b)\) and there exists \(1 \le i \le n\) such that \(a_1 = b_1, \dots, a_{i-1} = b_{i-1}, a_i < b_i\). This term order is called ‘Dp’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order='deglex')
sage: x > y
True
sage: x > y^2*z
False
sage: x > 1
True
sage: x^1*y^2*z^3 > x^3*y^2*z^0
True
sage: x^2*y*z^2 > x*y^3*z
True
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order='deglex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
True
>>> x > y**Integer(2)*z
False
>>> x > Integer(1)
True
>>> x**Integer(1)*y**Integer(2)*z**Integer(3) > x**Integer(3)*y**Integer(2)*z**Integer(0)
True
>>> x**Integer(2)*y*z**Integer(2) > x*y**Integer(3)*z
True
Inverse lexicographic (invlex)

\(x^a < x^b\) if and only if there exists \(1 \le i \le n\) such that \(a_n = b_n, \dots, a_{i+1} = b_{i+1}, a_i < b_i\). This order is called ‘rp’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order='invlex')
sage: x > y
False
sage: y > x^2
True
sage: x > 1
True
sage: x*y > z
False
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order='invlex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
False
>>> y > x**Integer(2)
True
>>> x > Integer(1)
True
>>> x*y > z
False

This term order only makes sense in a non-commutative setting because if P is the ring \(k[x_1, \dots, x_n]\) and term order ‘invlex’ then it is equivalent to the ring \(k[x_n, \dots, x_1]\) with term order ‘lex’.

Negative lexicographic (neglex)

\(x^a < x^b\) if and only if there exists \(1 \le i \le n\) such that \(a_1 = b_1, \dots, a_{i-1} = b_{i-1}, a_i > b_i\). This term order is called ‘ls’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order='neglex')
sage: x > y
False
sage: x > 1
False
sage: x^1*y^2 > y^3*z^4
False
sage: x^3*y^2*z^4 < x^3*y^2*z^1
True
sage: x*y > z
False
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order='neglex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
False
>>> x > Integer(1)
False
>>> x**Integer(1)*y**Integer(2) > y**Integer(3)*z**Integer(4)
False
>>> x**Integer(3)*y**Integer(2)*z**Integer(4) < x**Integer(3)*y**Integer(2)*z**Integer(1)
True
>>> x*y > z
False
Negative degree reverse lexicographic (negdegrevlex)

Let \(\deg(x^a) = a_1 + a_2 + \dots + a_n\), then \(x^a < x^b\) if and only if \(\deg(x^a) > \deg(x^b)\) or \(\deg(x^a) = \deg(x^b)\) and there exists \(1 \le i \le n\) such that \(a_n = b_n, \dots, a_{i+1} = b_{i+1}, a_i > b_i\). This term order is called ‘ds’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order='negdegrevlex')
sage: x > y
True
sage: x > x^2
True
sage: x > 1
False
sage: x^1*y^2 > y^3*z^4
True
sage: x^2*y*z^2 > x*y^3*z
False
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order='negdegrevlex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
True
>>> x > x**Integer(2)
True
>>> x > Integer(1)
False
>>> x**Integer(1)*y**Integer(2) > y**Integer(3)*z**Integer(4)
True
>>> x**Integer(2)*y*z**Integer(2) > x*y**Integer(3)*z
False
Negative degree lexicographic (negdeglex)

Let \(\deg(x^a) = a_1 + a_2 + \dots + a_n\), then \(x^a < x^b\) if and only if \(\deg(x^a) > \deg(x^b)\) or \(\deg(x^a) = \deg(x^b)\) and there exists \(1 \le i \le n\) such that \(a_1 = b_1, \dots, a_{i-1} = b_{i-1}, a_i < b_i\). This term order is called ‘Ds’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order='negdeglex')
sage: x > y
True
sage: x > x^2
True
sage: x > 1
False
sage: x^1*y^2 > y^3*z^4
True
sage: x^2*y*z^2 > x*y^3*z
True
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order='negdeglex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
True
>>> x > x**Integer(2)
True
>>> x > Integer(1)
False
>>> x**Integer(1)*y**Integer(2) > y**Integer(3)*z**Integer(4)
True
>>> x**Integer(2)*y*z**Integer(2) > x*y**Integer(3)*z
True
Weighted degree reverse lexicographic (wdegrevlex), positive integral weights

Let \(\deg_w(x^a) = a_1w_1 + a_2w_2 + \dots + a_nw_n\) with weights \(w\), then \(x^a < x^b\) if and only if \(\deg_w(x^a) < \deg_w(x^b)\) or \(\deg_w(x^a) = \deg_w(x^b)\) and there exists \(1 \le i \le n\) such that \(a_n = b_n, \dots, a_{i+1} = b_{i+1}, a_i > b_i\). This term order is called ‘wp’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order=TermOrder('wdegrevlex',(1,2,3)))
sage: x > y
False
sage: x > x^2
False
sage: x > 1
True
sage: x^1*y^2 > x^2*z
True
sage: y*z > x^3*y
False
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order=TermOrder('wdegrevlex',(Integer(1),Integer(2),Integer(3))), names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
False
>>> x > x**Integer(2)
False
>>> x > Integer(1)
True
>>> x**Integer(1)*y**Integer(2) > x**Integer(2)*z
True
>>> y*z > x**Integer(3)*y
False
Weighted degree lexicographic (wdeglex), positive integral weights

Let \(\deg_w(x^a) = a_1w_1 + a_2w_2 + \dots + a_nw_n\) with weights \(w\), then \(x^a < x^b\) if and only if \(\deg_w(x^a) < \deg_w(x^b)\) or \(\deg_w(x^a) = \deg_w(x^b)\) and there exists \(1 \le i \le n\) such that \(a_1 = b_1, \dots, a_{i-1} = b_{i-1}, a_i < b_i\). This term order is called ‘Wp’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order=TermOrder('wdeglex',(1,2,3)))
sage: x > y
False
sage: x > x^2
False
sage: x > 1
True
sage: x^1*y^2 > x^2*z
False
sage: y*z > x^3*y
False
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order=TermOrder('wdeglex',(Integer(1),Integer(2),Integer(3))), names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
False
>>> x > x**Integer(2)
False
>>> x > Integer(1)
True
>>> x**Integer(1)*y**Integer(2) > x**Integer(2)*z
False
>>> y*z > x**Integer(3)*y
False
Negative weighted degree reverse lexicographic (negwdegrevlex), positive integral weights

Let \(\deg_w(x^a) = a_1w_1 + a_2w_2 + \dots + a_nw_n\) with weights \(w\), then \(x^a < x^b\) if and only if \(\deg_w(x^a) > \deg_w(x^b)\) or \(\deg_w(x^a) = \deg_w(x^b)\) and there exists \(1 \le i \le n\) such that \(a_n = b_n, \dots, a_{i+1} = b_{i+1}, a_i > b_i\). This term order is called ‘ws’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order=TermOrder('negwdegrevlex',(1,2,3)))
sage: x > y
True
sage: x > x^2
True
sage: x > 1
False
sage: x^1*y^2 > x^2*z
True
sage: y*z > x^3*y
False
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order=TermOrder('negwdegrevlex',(Integer(1),Integer(2),Integer(3))), names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
True
>>> x > x**Integer(2)
True
>>> x > Integer(1)
False
>>> x**Integer(1)*y**Integer(2) > x**Integer(2)*z
True
>>> y*z > x**Integer(3)*y
False
Degree negative lexicographic (degneglex)

Let \(\deg(x^a) = a_1 + a_2 + \dots + a_n\), then \(x^a < x^b\) if and only if \(\deg(x^a) < \deg(x^b)\) or \(\deg(x^a) = \deg(x^b)\) and there exists \(1 \le i \le n\) such that \(a_1 = b_1, \dots, a_{i-1} = b_{i-1}, a_i > b_i\). This term order is called ‘dp_asc’ in PolyBoRi. Singular has the extra weight vector ordering (a(1:n),ls) for this purpose.

EXAMPLES:

sage: t = TermOrder('degneglex')
sage: P.<x,y,z> = PolynomialRing(QQ, order=t)
sage: x*y > y*z # indirect doctest
False
sage: x*y > x
True
>>> from sage.all import *
>>> t = TermOrder('degneglex')
>>> P = PolynomialRing(QQ, order=t, names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x*y > y*z # indirect doctest
False
>>> x*y > x
True
Negative weighted degree lexicographic (negwdeglex), positive integral weights

Let \(\deg_w(x^a) = a_1w_1 + a_2w_2 + \dots + a_nw_n\) with weights \(w\), then \(x^a < x^b\) if and only if \(\deg_w(x^a) > \deg_w(x^b)\) or \(\deg_w(x^a) = \deg_w(x^b)\) and there exists \(1 \le i \le n\) such that \(a_1 = b_1, \dots, a_{i-1} = b_{i-1}, a_i < b_i\). This term order is called ‘Ws’ in Singular.

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQ, 3, order=TermOrder('negwdeglex',(1,2,3)))
sage: x > y
True
sage: x > x^2
True
sage: x > 1
False
sage: x^1*y^2 > x^2*z
False
sage: y*z > x^3*y
False
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(3), order=TermOrder('negwdeglex',(Integer(1),Integer(2),Integer(3))), names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> x > y
True
>>> x > x**Integer(2)
True
>>> x > Integer(1)
False
>>> x**Integer(1)*y**Integer(2) > x**Integer(2)*z
False
>>> y*z > x**Integer(3)*y
False

Of these, only ‘degrevlex’, ‘deglex’, ‘degneglex’, ‘wdegrevlex’, ‘wdeglex’, ‘invlex’ and ‘lex’ are global orders.

Sage also supports matrix term order. Given a square matrix \(A\),

\(x^a <_A x^b\) if and only if \(Aa < Ab\)

where \(<\) is the lexicographic term order.

EXAMPLES:

sage: # needs sage.modules
sage: m = matrix(2, [2,3,0,1]); m
[2 3]
[0 1]
sage: T = TermOrder(m); T
Matrix term order with matrix
[2 3]
[0 1]
sage: P.<a,b> = PolynomialRing(QQ, 2, order=T)
sage: P
Multivariate Polynomial Ring in a, b over Rational Field
sage: a > b
False
sage: a^3 < b^2
True
sage: S = TermOrder('M(2,3,0,1)')
sage: T == S
True
>>> from sage.all import *
>>> # needs sage.modules
>>> m = matrix(Integer(2), [Integer(2),Integer(3),Integer(0),Integer(1)]); m
[2 3]
[0 1]
>>> T = TermOrder(m); T
Matrix term order with matrix
[2 3]
[0 1]
>>> P = PolynomialRing(QQ, Integer(2), order=T, names=('a', 'b',)); (a, b,) = P._first_ngens(2)
>>> P
Multivariate Polynomial Ring in a, b over Rational Field
>>> a > b
False
>>> a**Integer(3) < b**Integer(2)
True
>>> S = TermOrder('M(2,3,0,1)')
>>> T == S
True

Additionally all these monomial orders may be combined to product or block orders, defined as:

Let \(x = (x_1, x_2, \dots, x_n)\) and \(y = (y_1, y_2, \dots, y_m)\) be two ordered sets of variables, \(<_1\) a monomial order on \(k[x]\) and \(<_2\) a monomial order on \(k[y]\).

The product order (or block order) \(<\) \(:=\) \((<_1,<_2)\) on \(k[x,y]\) is defined as: \(x^a y^b < x^A y^B\) if and only if \(x^a <_1 x^A\) or (\(x^a =x^A\) and \(y^b <_2 y^B\)).

These block orders are constructed in Sage by giving a comma separated list of monomial orders with the length of each block attached to them.

EXAMPLES:

As an example, consider constructing a block order where the first four variables are compared using the degree reverse lexicographical order while the last two variables in the second block are compared using negative lexicographical order.

sage: P.<a,b,c,d,e,f> = PolynomialRing(QQ, 6, order='degrevlex(4),neglex(2)')
sage: a > c^4
False
sage: a > e^4
True
sage: e > f^2
False
>>> from sage.all import *
>>> P = PolynomialRing(QQ, Integer(6), order='degrevlex(4),neglex(2)', names=('a', 'b', 'c', 'd', 'e', 'f',)); (a, b, c, d, e, f,) = P._first_ngens(6)
>>> a > c**Integer(4)
False
>>> a > e**Integer(4)
True
>>> e > f**Integer(2)
False

The same result can be achieved by:

sage: T1 = TermOrder('degrevlex',4)
sage: T2 = TermOrder('neglex',2)
sage: T = T1 + T2
sage: P.<a,b,c,d,e,f> = PolynomialRing(QQ, 6, order=T)
sage: a > c^4
False
sage: a > e^4
True
>>> from sage.all import *
>>> T1 = TermOrder('degrevlex',Integer(4))
>>> T2 = TermOrder('neglex',Integer(2))
>>> T = T1 + T2
>>> P = PolynomialRing(QQ, Integer(6), order=T, names=('a', 'b', 'c', 'd', 'e', 'f',)); (a, b, c, d, e, f,) = P._first_ngens(6)
>>> a > c**Integer(4)
False
>>> a > e**Integer(4)
True

If any other unsupported term order is given the provided string can be forced to be passed through as is to Singular, Macaulay2, and Magma. This ensures that it is for example possible to calculate a Groebner basis with respect to some term order Singular supports but Sage doesn’t:

sage: T = TermOrder("royalorder")
Traceback (most recent call last):
...
ValueError: unknown term order 'royalorder'
sage: T = TermOrder("royalorder", force=True)
sage: T
royalorder term order
sage: T.singular_str()
'royalorder'
>>> from sage.all import *
>>> T = TermOrder("royalorder")
Traceback (most recent call last):
...
ValueError: unknown term order 'royalorder'
>>> T = TermOrder("royalorder", force=True)
>>> T
royalorder term order
>>> T.singular_str()
'royalorder'

AUTHORS:

  • David Joyner and William Stein: initial version of multi_polynomial_ring

  • Kiran S. Kedlaya: added macaulay2 interface

  • Martin Albrecht: implemented native term orders, refactoring

  • Kwankyu Lee: implemented matrix and weighted degree term orders

  • Simon King (2011-06-06): added termorder_from_singular

class sage.rings.polynomial.term_order.TermOrder(name='lex', n=0, force=False)[source]

Bases: SageObject

A term order.

See sage.rings.polynomial.term_order for details on supported term orders.

blocks()[source]

Return the term order blocks of self.

NOTE:

This method has been added in Issue #11316. There used to be an attribute of the same name and the same content. So, it is a backward incompatible syntax change.

EXAMPLES:

sage: t = TermOrder('deglex',2) + TermOrder('lex',2)
sage: t.blocks()
(Degree lexicographic term order, Lexicographic term order)
>>> from sage.all import *
>>> t = TermOrder('deglex',Integer(2)) + TermOrder('lex',Integer(2))
>>> t.blocks()
(Degree lexicographic term order, Lexicographic term order)
property greater_tuple

The default greater_tuple method for this term order.

EXAMPLES:

sage: O = TermOrder()
sage: O.greater_tuple.__func__ is O.greater_tuple_lex.__func__
True
sage: O = TermOrder('deglex')
sage: O.greater_tuple.__func__ is O.greater_tuple_deglex.__func__
True
>>> from sage.all import *
>>> O = TermOrder()
>>> O.greater_tuple.__func__ is O.greater_tuple_lex.__func__
True
>>> O = TermOrder('deglex')
>>> O.greater_tuple.__func__ is O.greater_tuple_deglex.__func__
True
greater_tuple_block(f, g)[source]

Return the greater exponent tuple with respect to the block order as specified when constructing this element.

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: P.<a,b,c,d,e,f> = PolynomialRing(QQbar, 6,                            # needs sage.rings.number_field
....:                                  order='degrevlex(3),degrevlex(3)')
sage: f = a + c^4; f.lm()  # indirect doctest                               # needs sage.rings.number_field
c^4
sage: g = a + e^4; g.lm()                                                   # needs sage.rings.number_field
a
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(6),                            # needs sage.rings.number_field
...                                  order='degrevlex(3),degrevlex(3)', names=('a', 'b', 'c', 'd', 'e', 'f',)); (a, b, c, d, e, f,) = P._first_ngens(6)
>>> f = a + c**Integer(4); f.lm()  # indirect doctest                               # needs sage.rings.number_field
c^4
>>> g = a + e**Integer(4); g.lm()                                                   # needs sage.rings.number_field
a
greater_tuple_deglex(f, g)[source]

Return the greater exponent tuple with respect to the total degree lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order='deglex')                  # needs sage.rings.number_field
sage: f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
x
sage: f = x + y^2*z; f.lm()                                                 # needs sage.rings.number_field
y^2*z
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(3), order='deglex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)# needs sage.rings.number_field
>>> f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
x
>>> f = x + y**Integer(2)*z; f.lm()                                                 # needs sage.rings.number_field
y^2*z

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

greater_tuple_degneglex(f, g)[source]

Return the greater exponent tuple with respect to the degree negative lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order='degneglex')               # needs sage.rings.number_field
sage: f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
y
sage: f = x + y^2*z; f.lm()                                                 # needs sage.rings.number_field
y^2*z
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(3), order='degneglex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)# needs sage.rings.number_field
>>> f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
y
>>> f = x + y**Integer(2)*z; f.lm()                                                 # needs sage.rings.number_field
y^2*z

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

greater_tuple_degrevlex(f, g)[source]

Return the greater exponent tuple with respect to the total degree reversed lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order='degrevlex')               # needs sage.rings.number_field
sage: f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
x
sage: f = x + y^2*z; f.lm()                                                 # needs sage.rings.number_field
y^2*z
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(3), order='degrevlex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)# needs sage.rings.number_field
>>> f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
x
>>> f = x + y**Integer(2)*z; f.lm()                                                 # needs sage.rings.number_field
y^2*z

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

greater_tuple_invlex(f, g)[source]

Return the greater exponent tuple with respect to the inversed lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order='invlex')                  # needs sage.rings.number_field
sage: f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
y
sage: f = y + x^2; f.lm()                                                   # needs sage.rings.number_field
y
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(3), order='invlex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)# needs sage.rings.number_field
>>> f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
y
>>> f = y + x**Integer(2); f.lm()                                                   # needs sage.rings.number_field
y

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

greater_tuple_lex(f, g)[source]

Return the greater exponent tuple with respect to the lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order='lex')                     # needs sage.rings.number_field
sage: f = x + y^2; f.lm()  # indirect doctest                               # needs sage.rings.number_field
x
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(3), order='lex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)# needs sage.rings.number_field
>>> f = x + y**Integer(2); f.lm()  # indirect doctest                               # needs sage.rings.number_field
x

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

greater_tuple_matrix(f, g)[source]

Return the greater exponent tuple with respect to the matrix term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: P.<x,y> = PolynomialRing(QQbar, 2, order='m(1,3,1,0)')                # needs sage.rings.number_field
sage: y > x^2  # indirect doctest                                           # needs sage.rings.number_field
True
sage: y > x^3                                                               # needs sage.rings.number_field
False
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(2), order='m(1,3,1,0)', names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> y > x**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
True
>>> y > x**Integer(3)                                                               # needs sage.rings.number_field
False
greater_tuple_negdeglex(f, g)[source]

Return the greater exponent tuple with respect to the negative degree lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: # needs sage.rings.number_field
sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order='negdeglex')
sage: f = x + y; f.lm() # indirect doctest
x
sage: f = x + x^2; f.lm()
x
sage: f = x^2*y*z^2 + x*y^3*z; f.lm()
x^2*y*z^2
>>> from sage.all import *
>>> # needs sage.rings.number_field
>>> P = PolynomialRing(QQbar, Integer(3), order='negdeglex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> f = x + y; f.lm() # indirect doctest
x
>>> f = x + x**Integer(2); f.lm()
x
>>> f = x**Integer(2)*y*z**Integer(2) + x*y**Integer(3)*z; f.lm()
x^2*y*z^2

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

greater_tuple_negdegrevlex(f, g)[source]

Return the greater exponent tuple with respect to the negative degree reverse lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: # needs sage.rings.number_field
sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order='negdegrevlex')
sage: f = x + y; f.lm() # indirect doctest
x
sage: f = x + x^2; f.lm()
x
sage: f = x^2*y*z^2 + x*y^3*z; f.lm()
x*y^3*z
>>> from sage.all import *
>>> # needs sage.rings.number_field
>>> P = PolynomialRing(QQbar, Integer(3), order='negdegrevlex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> f = x + y; f.lm() # indirect doctest
x
>>> f = x + x**Integer(2); f.lm()
x
>>> f = x**Integer(2)*y*z**Integer(2) + x*y**Integer(3)*z; f.lm()
x*y^3*z

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

greater_tuple_neglex(f, g)[source]

Return the greater exponent tuple with respect to the negative lexicographical term order.

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: P.<a,b,c,d,e,f> = PolynomialRing(QQbar, 6,                            # needs sage.rings.number_field
....:                                  order='degrevlex(3),degrevlex(3)')
sage: f = a + c^4; f.lm()  # indirect doctest                               # needs sage.rings.number_field
c^4
sage: g = a + e^4; g.lm()                                                   # needs sage.rings.number_field
a
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(6),                            # needs sage.rings.number_field
...                                  order='degrevlex(3),degrevlex(3)', names=('a', 'b', 'c', 'd', 'e', 'f',)); (a, b, c, d, e, f,) = P._first_ngens(6)
>>> f = a + c**Integer(4); f.lm()  # indirect doctest                               # needs sage.rings.number_field
c^4
>>> g = a + e**Integer(4); g.lm()                                                   # needs sage.rings.number_field
a
greater_tuple_negwdeglex(f, g)[source]

Return the greater exponent tuple with respect to the negative weighted degree lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: # needs sage.rings.number_field
sage: t = TermOrder('negwdeglex',(1,2,3))
sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order=t)
sage: f = x + y; f.lm() # indirect doctest
x
sage: f = x + x^2; f.lm()
x
sage: f = x^3 + z; f.lm()
x^3
>>> from sage.all import *
>>> # needs sage.rings.number_field
>>> t = TermOrder('negwdeglex',(Integer(1),Integer(2),Integer(3)))
>>> P = PolynomialRing(QQbar, Integer(3), order=t, names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> f = x + y; f.lm() # indirect doctest
x
>>> f = x + x**Integer(2); f.lm()
x
>>> f = x**Integer(3) + z; f.lm()
x^3

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

greater_tuple_negwdegrevlex(f, g)[source]

Return the greater exponent tuple with respect to the negative weighted degree reverse lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: # needs sage.rings.number_field
sage: t = TermOrder('negwdegrevlex',(1,2,3))
sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order=t)
sage: f = x + y; f.lm() # indirect doctest
x
sage: f = x + x^2; f.lm()
x
sage: f = x^3 + z; f.lm()
x^3
>>> from sage.all import *
>>> # needs sage.rings.number_field
>>> t = TermOrder('negwdegrevlex',(Integer(1),Integer(2),Integer(3)))
>>> P = PolynomialRing(QQbar, Integer(3), order=t, names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)
>>> f = x + y; f.lm() # indirect doctest
x
>>> f = x + x**Integer(2); f.lm()
x
>>> f = x**Integer(3) + z; f.lm()
x^3

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

greater_tuple_wdeglex(f, g)[source]

Return the greater exponent tuple with respect to the weighted degree lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: t = TermOrder('wdeglex',(1,2,3))
sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order=t)                         # needs sage.rings.number_field
sage: f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
y
sage: f = x*y + z; f.lm()                                                   # needs sage.rings.number_field
x*y
>>> from sage.all import *
>>> t = TermOrder('wdeglex',(Integer(1),Integer(2),Integer(3)))
>>> P = PolynomialRing(QQbar, Integer(3), order=t, names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)# needs sage.rings.number_field
>>> f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
y
>>> f = x*y + z; f.lm()                                                   # needs sage.rings.number_field
x*y

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

greater_tuple_wdegrevlex(f, g)[source]

Return the greater exponent tuple with respect to the weighted degree reverse lexicographical term order.

INPUT:

  • f – exponent tuple

  • g – exponent tuple

EXAMPLES:

sage: t = TermOrder('wdegrevlex',(1,2,3))
sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order=t)                         # needs sage.rings.number_field
sage: f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
y
sage: f = x + y^2*z; f.lm()                                                 # needs sage.rings.number_field
y^2*z
>>> from sage.all import *
>>> t = TermOrder('wdegrevlex',(Integer(1),Integer(2),Integer(3)))
>>> P = PolynomialRing(QQbar, Integer(3), order=t, names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)# needs sage.rings.number_field
>>> f = x + y; f.lm()  # indirect doctest                                 # needs sage.rings.number_field
y
>>> f = x + y**Integer(2)*z; f.lm()                                                 # needs sage.rings.number_field
y^2*z

This method is called by the lm/lc/lt methods of MPolynomial_polydict.

is_block_order()[source]

Return True if self is a block term order.

EXAMPLES:

sage: t = TermOrder('deglex',2) + TermOrder('lex',2)
sage: t.is_block_order()
True
>>> from sage.all import *
>>> t = TermOrder('deglex',Integer(2)) + TermOrder('lex',Integer(2))
>>> t.is_block_order()
True
is_global()[source]

Return True if this term order is definitely global. Return false otherwise, which includes unknown term orders.

EXAMPLES:

sage: T = TermOrder('lex')
sage: T.is_global()
True
sage: T = TermOrder('degrevlex', 3) + TermOrder('degrevlex', 3)
sage: T.is_global()
True
sage: T = TermOrder('degrevlex', 3) + TermOrder('negdegrevlex', 3)
sage: T.is_global()
False
sage: T = TermOrder('degneglex', 3)
sage: T.is_global()
True
sage: T = TermOrder('invlex', 3)
sage: T.is_global()
True
>>> from sage.all import *
>>> T = TermOrder('lex')
>>> T.is_global()
True
>>> T = TermOrder('degrevlex', Integer(3)) + TermOrder('degrevlex', Integer(3))
>>> T.is_global()
True
>>> T = TermOrder('degrevlex', Integer(3)) + TermOrder('negdegrevlex', Integer(3))
>>> T.is_global()
False
>>> T = TermOrder('degneglex', Integer(3))
>>> T.is_global()
True
>>> T = TermOrder('invlex', Integer(3))
>>> T.is_global()
True
is_local()[source]

Return True if this term order is definitely local. Return false otherwise, which includes unknown term orders.

EXAMPLES:

sage: T = TermOrder('lex')
sage: T.is_local()
False
sage: T = TermOrder('negdeglex', 3) + TermOrder('negdegrevlex', 3)
sage: T.is_local()
True
sage: T = TermOrder('degrevlex', 3) + TermOrder('negdegrevlex', 3)
sage: T.is_local()
False
>>> from sage.all import *
>>> T = TermOrder('lex')
>>> T.is_local()
False
>>> T = TermOrder('negdeglex', Integer(3)) + TermOrder('negdegrevlex', Integer(3))
>>> T.is_local()
True
>>> T = TermOrder('degrevlex', Integer(3)) + TermOrder('negdegrevlex', Integer(3))
>>> T.is_local()
False
is_weighted_degree_order()[source]

Return True if self is a weighted degree term order.

EXAMPLES:

sage: t = TermOrder('wdeglex',(2,3))
sage: t.is_weighted_degree_order()
True
>>> from sage.all import *
>>> t = TermOrder('wdeglex',(Integer(2),Integer(3)))
>>> t.is_weighted_degree_order()
True
macaulay2_str()[source]

Return a Macaulay2 representation of self.

Used to convert polynomial rings to their Macaulay2 representation.

EXAMPLES:

sage: P = PolynomialRing(GF(127), 8, names='x', order='degrevlex(3),lex(5)')
sage: T = P.term_order()
sage: T.macaulay2_str()
'{GRevLex => 3,Lex => 5}'
sage: P._macaulay2_().options()['MonomialOrder']    # optional - macaulay2
{MonomialSize => 16  }
{GRevLex => {1, 1, 1}}
{Lex => 5            }
{Position => Up      }
>>> from sage.all import *
>>> P = PolynomialRing(GF(Integer(127)), Integer(8), names='x', order='degrevlex(3),lex(5)')
>>> T = P.term_order()
>>> T.macaulay2_str()
'{GRevLex => 3,Lex => 5}'
>>> P._macaulay2_().options()['MonomialOrder']    # optional - macaulay2
{MonomialSize => 16  }
{GRevLex => {1, 1, 1}}
{Lex => 5            }
{Position => Up      }
magma_str()[source]

Return a MAGMA representation of self.

Used to convert polynomial rings to their MAGMA representation.

EXAMPLES:

sage: P = PolynomialRing(GF(127), 10, names='x', order='degrevlex')
sage: magma(P)                                      # optional - magma
Polynomial ring of rank 10 over GF(127)
Order: Graded Reverse Lexicographical
Variables: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9
>>> from sage.all import *
>>> P = PolynomialRing(GF(Integer(127)), Integer(10), names='x', order='degrevlex')
>>> magma(P)                                      # optional - magma
Polynomial ring of rank 10 over GF(127)
Order: Graded Reverse Lexicographical
Variables: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9

sage: T = P.term_order()
sage: T.magma_str()
'"grevlex"'
>>> from sage.all import *
>>> T = P.term_order()
>>> T.magma_str()
'"grevlex"'
matrix()[source]

Return the matrix defining matrix term order.

EXAMPLES:

sage: t = TermOrder("M(1,2,0,1)")                                           # needs sage.modules
sage: t.matrix()                                                            # needs sage.modules
[1 2]
[0 1]
>>> from sage.all import *
>>> t = TermOrder("M(1,2,0,1)")                                           # needs sage.modules
>>> t.matrix()                                                            # needs sage.modules
[1 2]
[0 1]
name()[source]

EXAMPLES:

sage: TermOrder('lex').name()
'lex'
>>> from sage.all import *
>>> TermOrder('lex').name()
'lex'
singular_moreblocks()[source]

Return a the number of additional blocks SINGULAR needs to allocate for handling non-native orderings like degneglex.

EXAMPLES:

sage: P = PolynomialRing(GF(127), 10, names='x',
....:                    order='lex(3),deglex(5),lex(2)')
sage: T = P.term_order()
sage: T.singular_moreblocks()
0
sage: P = PolynomialRing(GF(127), 10, names='x',
....:                    order='lex(3),degneglex(5),lex(2)')
sage: T = P.term_order()
sage: T.singular_moreblocks()
1
sage: P = PolynomialRing(GF(127), 10, names='x',
....:                    order='degneglex(5),degneglex(5)')
sage: T = P.term_order()
sage: T.singular_moreblocks()
2
>>> from sage.all import *
>>> P = PolynomialRing(GF(Integer(127)), Integer(10), names='x',
...                    order='lex(3),deglex(5),lex(2)')
>>> T = P.term_order()
>>> T.singular_moreblocks()
0
>>> P = PolynomialRing(GF(Integer(127)), Integer(10), names='x',
...                    order='lex(3),degneglex(5),lex(2)')
>>> T = P.term_order()
>>> T.singular_moreblocks()
1
>>> P = PolynomialRing(GF(Integer(127)), Integer(10), names='x',
...                    order='degneglex(5),degneglex(5)')
>>> T = P.term_order()
>>> T.singular_moreblocks()
2
singular_str()[source]

Return a SINGULAR representation of self.

Used to convert polynomial rings to their SINGULAR representation.

EXAMPLES:

sage: P = PolynomialRing(GF(127), 10, names='x',
....:                    order='lex(3),deglex(5),lex(2)')
sage: T = P.term_order()
sage: T.singular_str()
'(lp(3),Dp(5),lp(2))'
sage: P._singular_()                                                        # needs sage.libs.singular
polynomial ring, over a field, global ordering
//   coefficients: ZZ/127
//   number of vars : 10
//        block   1 : ordering lp
//                  : names    x0 x1 x2
//        block   2 : ordering Dp
//                  : names    x3 x4 x5 x6 x7
//        block   3 : ordering lp
//                  : names    x8 x9
//        block   4 : ordering C
>>> from sage.all import *
>>> P = PolynomialRing(GF(Integer(127)), Integer(10), names='x',
...                    order='lex(3),deglex(5),lex(2)')
>>> T = P.term_order()
>>> T.singular_str()
'(lp(3),Dp(5),lp(2))'
>>> P._singular_()                                                        # needs sage.libs.singular
polynomial ring, over a field, global ordering
//   coefficients: ZZ/127
//   number of vars : 10
//        block   1 : ordering lp
//                  : names    x0 x1 x2
//        block   2 : ordering Dp
//                  : names    x3 x4 x5 x6 x7
//        block   3 : ordering lp
//                  : names    x8 x9
//        block   4 : ordering C

The degneglex ordering is somehow special, it looks like a block ordering in SINGULAR:

sage: T = TermOrder("degneglex", 2)
sage: P = PolynomialRing(QQ,2, names='x', order=T)
sage: T = P.term_order()
sage: T.singular_str()
'(a(1:2),ls(2))'

sage: T = TermOrder("degneglex", 2) + TermOrder("degneglex", 2)
sage: P = PolynomialRing(QQ,4, names='x', order=T)
sage: T = P.term_order()
sage: T.singular_str()
'(a(1:2),ls(2),a(1:2),ls(2))'
sage: P._singular_()                                                        # needs sage.libs.singular
polynomial ring, over a field, global ordering
//   coefficients: QQ
//   number of vars : 4
//        block   1 : ordering a
//                  : names    x0 x1
//                  : weights   1  1
//        block   2 : ordering ls
//                  : names    x0 x1
//        block   3 : ordering a
//                  : names    x2 x3
//                  : weights   1  1
//        block   4 : ordering ls
//                  : names    x2 x3
//        block   5 : ordering C
>>> from sage.all import *
>>> T = TermOrder("degneglex", Integer(2))
>>> P = PolynomialRing(QQ,Integer(2), names='x', order=T)
>>> T = P.term_order()
>>> T.singular_str()
'(a(1:2),ls(2))'

>>> T = TermOrder("degneglex", Integer(2)) + TermOrder("degneglex", Integer(2))
>>> P = PolynomialRing(QQ,Integer(4), names='x', order=T)
>>> T = P.term_order()
>>> T.singular_str()
'(a(1:2),ls(2),a(1:2),ls(2))'
>>> P._singular_()                                                        # needs sage.libs.singular
polynomial ring, over a field, global ordering
//   coefficients: QQ
//   number of vars : 4
//        block   1 : ordering a
//                  : names    x0 x1
//                  : weights   1  1
//        block   2 : ordering ls
//                  : names    x0 x1
//        block   3 : ordering a
//                  : names    x2 x3
//                  : weights   1  1
//        block   4 : ordering ls
//                  : names    x2 x3
//        block   5 : ordering C

The position of the ordering C block can be controlled by setting _singular_ringorder_column attribute to an integer:

sage: T = TermOrder("degneglex", 2) + TermOrder("degneglex", 2)
sage: T._singular_ringorder_column = 0
sage: P = PolynomialRing(QQ, 4, names='x', order=T)
sage: P._singular_()                                                        # needs sage.libs.singular
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 4
//        block   1 : ordering C
//        block   2 : ordering a
//                  : names    x0 x1
//                  : weights   1  1
//        block   3 : ordering ls
//                  : names    x0 x1
//        block   4 : ordering a
//                  : names    x2 x3
//                  : weights   1  1
//        block   5 : ordering ls
//                  : names    x2 x3

sage: T._singular_ringorder_column = 1
sage: P = PolynomialRing(QQ, 4, names='y', order=T)
sage: P._singular_()                                                        # needs sage.libs.singular
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 4
//        block   1 : ordering c
//        block   2 : ordering a
//                  : names    y0 y1
//                  : weights   1  1
//        block   3 : ordering ls
//                  : names    y0 y1
//        block   4 : ordering a
//                  : names    y2 y3
//                  : weights   1  1
//        block   5 : ordering ls
//                  : names    y2 y3

sage: T._singular_ringorder_column = 2
sage: P = PolynomialRing(QQ, 4, names='z', order=T)
sage: P._singular_()                                                        # needs sage.libs.singular
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 4
//        block   1 : ordering a
//                  : names    z0 z1
//                  : weights   1  1
//        block   2 : ordering C
//        block   3 : ordering ls
//                  : names    z0 z1
//        block   4 : ordering a
//                  : names    z2 z3
//                  : weights   1  1
//        block   5 : ordering ls
//                  : names    z2 z3
>>> from sage.all import *
>>> T = TermOrder("degneglex", Integer(2)) + TermOrder("degneglex", Integer(2))
>>> T._singular_ringorder_column = Integer(0)
>>> P = PolynomialRing(QQ, Integer(4), names='x', order=T)
>>> P._singular_()                                                        # needs sage.libs.singular
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 4
//        block   1 : ordering C
//        block   2 : ordering a
//                  : names    x0 x1
//                  : weights   1  1
//        block   3 : ordering ls
//                  : names    x0 x1
//        block   4 : ordering a
//                  : names    x2 x3
//                  : weights   1  1
//        block   5 : ordering ls
//                  : names    x2 x3

>>> T._singular_ringorder_column = Integer(1)
>>> P = PolynomialRing(QQ, Integer(4), names='y', order=T)
>>> P._singular_()                                                        # needs sage.libs.singular
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 4
//        block   1 : ordering c
//        block   2 : ordering a
//                  : names    y0 y1
//                  : weights   1  1
//        block   3 : ordering ls
//                  : names    y0 y1
//        block   4 : ordering a
//                  : names    y2 y3
//                  : weights   1  1
//        block   5 : ordering ls
//                  : names    y2 y3

>>> T._singular_ringorder_column = Integer(2)
>>> P = PolynomialRing(QQ, Integer(4), names='z', order=T)
>>> P._singular_()                                                        # needs sage.libs.singular
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 4
//        block   1 : ordering a
//                  : names    z0 z1
//                  : weights   1  1
//        block   2 : ordering C
//        block   3 : ordering ls
//                  : names    z0 z1
//        block   4 : ordering a
//                  : names    z2 z3
//                  : weights   1  1
//        block   5 : ordering ls
//                  : names    z2 z3
property sortkey

The default sortkey method for this term order.

EXAMPLES:

sage: O = TermOrder()
sage: O.sortkey.__func__ is O.sortkey_lex.__func__
True
sage: O = TermOrder('deglex')
sage: O.sortkey.__func__ is O.sortkey_deglex.__func__
True
>>> from sage.all import *
>>> O = TermOrder()
>>> O.sortkey.__func__ is O.sortkey_lex.__func__
True
>>> O = TermOrder('deglex')
>>> O.sortkey.__func__ is O.sortkey_deglex.__func__
True
sortkey_block(f)[source]

Return the sortkey of an exponent tuple with respect to the block order as specified when constructing this element.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: P.<a,b,c,d,e,f> = PolynomialRing(QQbar, 6,                            # needs sage.rings.number_field
....:                                  order='degrevlex(3),degrevlex(3)')
sage: a > c^4  # indirect doctest                                           # needs sage.rings.number_field
False
sage: a > e^4                                                               # needs sage.rings.number_field
True
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(6),                            # needs sage.rings.number_field
...                                  order='degrevlex(3),degrevlex(3)', names=('a', 'b', 'c', 'd', 'e', 'f',)); (a, b, c, d, e, f,) = P._first_ngens(6)
>>> a > c**Integer(4)  # indirect doctest                                           # needs sage.rings.number_field
False
>>> a > e**Integer(4)                                                               # needs sage.rings.number_field
True
sortkey_deglex(f)[source]

Return the sortkey of an exponent tuple with respect to the degree lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: P.<x,y> = PolynomialRing(QQbar, 2, order='deglex')                    # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
False
sage: x > 1                                                                 # needs sage.rings.number_field
True
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(2), order='deglex', names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
False
>>> x > Integer(1)                                                                 # needs sage.rings.number_field
True
sortkey_degneglex(f)[source]

Return the sortkey of an exponent tuple with respect to the degree negative lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: P.<x,y,z> = PolynomialRing(QQbar, 3, order='degneglex')               # needs sage.rings.number_field
sage: x*y > y*z  # indirect doctest                                         # needs sage.rings.number_field
False
sage: x*y > x                                                               # needs sage.rings.number_field
True
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(3), order='degneglex', names=('x', 'y', 'z',)); (x, y, z,) = P._first_ngens(3)# needs sage.rings.number_field
>>> x*y > y*z  # indirect doctest                                         # needs sage.rings.number_field
False
>>> x*y > x                                                               # needs sage.rings.number_field
True
sortkey_degrevlex(f)[source]

Return the sortkey of an exponent tuple with respect to the degree reversed lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: P.<x,y> = PolynomialRing(QQbar, 2, order='degrevlex')                 # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
False
sage: x > 1                                                                 # needs sage.rings.number_field
True
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(2), order='degrevlex', names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
False
>>> x > Integer(1)                                                                 # needs sage.rings.number_field
True
sortkey_invlex(f)[source]

Return the sortkey of an exponent tuple with respect to the inversed lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: P.<x,y> = PolynomialRing(QQbar, 2, order='invlex')                    # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
False
sage: x > 1                                                                 # needs sage.rings.number_field
True
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(2), order='invlex', names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
False
>>> x > Integer(1)                                                                 # needs sage.rings.number_field
True
sortkey_lex(f)[source]

Return the sortkey of an exponent tuple with respect to the lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: P.<x,y> = PolynomialRing(QQbar, 2, order='lex')                       # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
True
sage: x > 1                                                                 # needs sage.rings.number_field
True
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(2), order='lex', names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
True
>>> x > Integer(1)                                                                 # needs sage.rings.number_field
True
sortkey_matrix(f)[source]

Return the sortkey of an exponent tuple with respect to the matrix term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: P.<x,y> = PolynomialRing(QQbar, 2, order='m(1,3,1,0)')                # needs sage.rings.number_field
sage: y > x^2  # indirect doctest                                           # needs sage.rings.number_field
True
sage: y > x^3                                                               # needs sage.rings.number_field
False
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(2), order='m(1,3,1,0)', names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> y > x**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
True
>>> y > x**Integer(3)                                                               # needs sage.rings.number_field
False
sortkey_negdeglex(f)[source]

Return the sortkey of an exponent tuple with respect to the negative degree lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: P.<x,y> = PolynomialRing(QQbar, 2, order='negdeglex')                 # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
True
sage: x > 1                                                                 # needs sage.rings.number_field
False
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(2), order='negdeglex', names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
True
>>> x > Integer(1)                                                                 # needs sage.rings.number_field
False
sortkey_negdegrevlex(f)[source]

Return the sortkey of an exponent tuple with respect to the negative degree reverse lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: P.<x,y> = PolynomialRing(QQbar, 2, order='negdegrevlex')              # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
True
sage: x > 1                                                                 # needs sage.rings.number_field
False
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(2), order='negdegrevlex', names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
True
>>> x > Integer(1)                                                                 # needs sage.rings.number_field
False
sortkey_neglex(f)[source]

Return the sortkey of an exponent tuple with respect to the negative lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: P.<x,y> = PolynomialRing(QQbar, 2, order='neglex')                    # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
False
sage: x > 1                                                                 # needs sage.rings.number_field
False
>>> from sage.all import *
>>> P = PolynomialRing(QQbar, Integer(2), order='neglex', names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
False
>>> x > Integer(1)                                                                 # needs sage.rings.number_field
False
sortkey_negwdeglex(f)[source]

Return the sortkey of an exponent tuple with respect to the negative weighted degree lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: t = TermOrder('negwdeglex',(3,2))
sage: P.<x,y> = PolynomialRing(QQbar, 2, order=t)                           # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
True
sage: x^2 > y^3                                                             # needs sage.rings.number_field
True
>>> from sage.all import *
>>> t = TermOrder('negwdeglex',(Integer(3),Integer(2)))
>>> P = PolynomialRing(QQbar, Integer(2), order=t, names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
True
>>> x**Integer(2) > y**Integer(3)                                                             # needs sage.rings.number_field
True
sortkey_negwdegrevlex(f)[source]

Return the sortkey of an exponent tuple with respect to the negative weighted degree reverse lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: t = TermOrder('negwdegrevlex',(3,2))
sage: P.<x,y> = PolynomialRing(QQbar, 2, order=t)                           # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
True
sage: x^2 > y^3                                                             # needs sage.rings.number_field
True
>>> from sage.all import *
>>> t = TermOrder('negwdegrevlex',(Integer(3),Integer(2)))
>>> P = PolynomialRing(QQbar, Integer(2), order=t, names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
True
>>> x**Integer(2) > y**Integer(3)                                                             # needs sage.rings.number_field
True
sortkey_wdeglex(f)[source]

Return the sortkey of an exponent tuple with respect to the weighted degree lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: t = TermOrder('wdeglex',(3,2))
sage: P.<x,y> = PolynomialRing(QQbar, 2, order=t)                           # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
False
sage: x > y                                                                 # needs sage.rings.number_field
True
>>> from sage.all import *
>>> t = TermOrder('wdeglex',(Integer(3),Integer(2)))
>>> P = PolynomialRing(QQbar, Integer(2), order=t, names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
False
>>> x > y                                                                 # needs sage.rings.number_field
True
sortkey_wdegrevlex(f)[source]

Return the sortkey of an exponent tuple with respect to the weighted degree reverse lexicographical term order.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: t = TermOrder('wdegrevlex',(3,2))
sage: P.<x,y> = PolynomialRing(QQbar, 2, order=t)                           # needs sage.rings.number_field
sage: x > y^2  # indirect doctest                                           # needs sage.rings.number_field
False
sage: x^2 > y^3                                                             # needs sage.rings.number_field
True
>>> from sage.all import *
>>> t = TermOrder('wdegrevlex',(Integer(3),Integer(2)))
>>> P = PolynomialRing(QQbar, Integer(2), order=t, names=('x', 'y',)); (x, y,) = P._first_ngens(2)# needs sage.rings.number_field
>>> x > y**Integer(2)  # indirect doctest                                           # needs sage.rings.number_field
False
>>> x**Integer(2) > y**Integer(3)                                                             # needs sage.rings.number_field
True
tuple_weight(f)[source]

Return the weight of tuple f.

INPUT:

  • f – exponent tuple

EXAMPLES:

sage: t = TermOrder('wdeglex',(1,2,3))
sage: P.<a,b,c> = PolynomialRing(QQbar, order=t)                            # needs sage.rings.number_field
sage: P.term_order().tuple_weight([3,2,1])                                  # needs sage.rings.number_field
10
>>> from sage.all import *
>>> t = TermOrder('wdeglex',(Integer(1),Integer(2),Integer(3)))
>>> P = PolynomialRing(QQbar, order=t, names=('a', 'b', 'c',)); (a, b, c,) = P._first_ngens(3)# needs sage.rings.number_field
>>> P.term_order().tuple_weight([Integer(3),Integer(2),Integer(1)])                                  # needs sage.rings.number_field
10
weights()[source]

Return the weights for weighted term orders.

EXAMPLES:

sage: t = TermOrder('wdeglex',(2,3))
sage: t.weights()
(2, 3)
>>> from sage.all import *
>>> t = TermOrder('wdeglex',(Integer(2),Integer(3)))
>>> t.weights()
(2, 3)
sage.rings.polynomial.term_order.termorder_from_singular(S)[source]

Return the Sage term order of the basering in the given Singular interface.

INPUT:

An instance of the Singular interface.

EXAMPLES:

sage: from sage.rings.polynomial.term_order import termorder_from_singular
sage: singular.eval('ring r1 = (9,x),(a,b,c,d,e,f),(M((1,2,3,0)),wp(2,3),lp)')  # needs sage.libs.singular
''
sage: termorder_from_singular(singular)                                         # needs sage.libs.singular
Block term order with blocks:
(Matrix term order with matrix
   [1 2]
   [3 0],
 Weighted degree reverse lexicographic term order with weights (2, 3),
 Lexicographic term order of length 2)
>>> from sage.all import *
>>> from sage.rings.polynomial.term_order import termorder_from_singular
>>> singular.eval('ring r1 = (9,x),(a,b,c,d,e,f),(M((1,2,3,0)),wp(2,3),lp)')  # needs sage.libs.singular
''
>>> termorder_from_singular(singular)                                         # needs sage.libs.singular
Block term order with blocks:
(Matrix term order with matrix
   [1 2]
   [3 0],
 Weighted degree reverse lexicographic term order with weights (2, 3),
 Lexicographic term order of length 2)

A term order in Singular also involves information on orders for modules. This information is reflected in _singular_ringorder_column attribute of the term order.

sage: # needs sage.libs.singular
sage: singular.ring(0, '(x,y,z,w)', '(C,dp(2),lp(2))')
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 4
//        block   1 : ordering C
//        block   2 : ordering dp
//                  : names    x y
//        block   3 : ordering lp
//                  : names    z w
sage: T = termorder_from_singular(singular)
sage: T
Block term order with blocks:
(Degree reverse lexicographic term order of length 2,
 Lexicographic term order of length 2)
sage: T._singular_ringorder_column
0

sage: # needs sage.libs.singular
sage: singular.ring(0, '(x,y,z,w)', '(c,dp(2),lp(2))')
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 4
//        block   1 : ordering c
//        block   2 : ordering dp
//                  : names    x y
//        block   3 : ordering lp
//                  : names    z w
sage: T = termorder_from_singular(singular)
sage: T
Block term order with blocks:
(Degree reverse lexicographic term order of length 2,
 Lexicographic term order of length 2)
sage: T._singular_ringorder_column
1
>>> from sage.all import *
>>> # needs sage.libs.singular
>>> singular.ring(Integer(0), '(x,y,z,w)', '(C,dp(2),lp(2))')
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 4
//        block   1 : ordering C
//        block   2 : ordering dp
//                  : names    x y
//        block   3 : ordering lp
//                  : names    z w
>>> T = termorder_from_singular(singular)
>>> T
Block term order with blocks:
(Degree reverse lexicographic term order of length 2,
 Lexicographic term order of length 2)
>>> T._singular_ringorder_column
0

>>> # needs sage.libs.singular
>>> singular.ring(Integer(0), '(x,y,z,w)', '(c,dp(2),lp(2))')
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 4
//        block   1 : ordering c
//        block   2 : ordering dp
//                  : names    x y
//        block   3 : ordering lp
//                  : names    z w
>>> T = termorder_from_singular(singular)
>>> T
Block term order with blocks:
(Degree reverse lexicographic term order of length 2,
 Lexicographic term order of length 2)
>>> T._singular_ringorder_column
1