Ordering multivariate polynomials (AbstractAlgebra)

Bonjour à tous !
I’m working now with multivariate polynomials of the AbstractAlgebra package
Everything works well, but I have a problem with ordering.
To make simple let’s consider the case of only 2 variables say ‘X’ and ‘Y’ as in textbooks.
I see 3 natural (usual) ways of ordering such polynomials given that such ordering affects only presentation of objects (printing - displaying, etc).

  1. Decreasing powers of the first indeterminate which means that if A is the base ring we consider any p in A[X,Y] to be an element of A[Y] that is a polynomial in the single variable X with coefficients in A[Y]
  2. Second way consists in exchanging the roles of X and Y so that our objects are elements of A[Y] and ordering is according decreasing powers of Y
  3. Third way consists in ordering monomial components according their total degree.
    Now the package doc specifies that ordering is controlled by a parameter ‘ordering’ with three possible values listed as :lex :deglex :degrevlex
    Although I can suppose that lex is short for lexical deg shot for degree and rev short for reverse I don’t see very well the meaning, and my test simply do not work printing is done according my case n°1 whatever I try for a dynamic change of ordering.
    Here’s my code :
using AbstractAlgebra
R, (X, Y) = QQ["X", "Y"] #polynômes à deux variables à coeff. rationnels
g = X^2*Y + 3X*Y^5 + 1
X^2*Y + 3*X*Y^5 + 1
X^2*Y + 3*X*Y^5 + 1
X^2*Y + 3*X*Y^5 + 1

I would be pleased if somebody can to me the meaning of the three symbols and the correct way to fix the ordering parameter (dynamically if possible). With the above code I have no compilation error but no result …
Thank you.

The call ordering(R) = :degrevlex is not doing what you think it is. You are just defining a function ordering with one argument called R.

One has to supply the ordering when creating the polynomial ring:

julia> R, (X, Y) = PolynomialRing(QQ, ["X", "Y"], ordering = :deglex)
(Multivariate Polynomial Ring in X, Y over Rationals, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}[X, Y])

julia> g = X^2*Y + 3X*Y^5 + 1
3*X*Y^5 + X^2*Y + 1

Edit: :lex is lexicographical ordering. :deglex is first by degree and then lexicographical. For :degrevlex I refer you to Wikipedia.

Thank you thofma for answering !
And by the way you give me the reason why I don’t have any compilation error. I didn’t think about this at all.
But you confirm what I suspected, there’s no possibility of changing the order dynamically. Order is fixed once for all at creation time.
Thanks again for precisions and examples concerning the various symbols.

You can do R.ord = :lex if you feel adventurous. This is not part of the official interface, so it can break with any update of AA. But it is helpful for playing around when comparing the different orderings. Note that you can assign any symbol to R.ord (you will get a weird error when printing a variable).

It’s mainly for educational purpose. So in fact it’s not so important, I can in a separate example redefine the polynomial ring, and mention that order should be specified at creation time. No need to live dangerously.