sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 481 forks source link

Broken coercion between MatrixSpace and polynomial Ring when this latter has an ordering set to 'lex'. #19669

Open edd8e884-f507-429a-b577-5d554626c0fe opened 8 years ago

edd8e884-f507-429a-b577-5d554626c0fe commented 8 years ago

As reported on this ask question:

sage: F = GF(17)
sage: R.<x, y> = PolynomialRing(F)
sage: MS = MatrixSpace(F, 5, 4)
sage: cm = sage.structure.element.get_coercion_model()
sage: cm.explain(R,MS)
Action discovered.
    Left scalar multiplication by Multivariate Polynomial Ring in x, y over Finite Field of size 17 on Full MatrixSpace of 5 by 4 dense matrices over Finite Field of size 17
Result lives in Full MatrixSpace of 5 by 4 dense matrices over Multivariate Polynomial Ring in x, y over Finite Field of size 17
Full MatrixSpace of 5 by 4 dense matrices over Multivariate Polynomial Ring in x, y over Finite Field of size 17

but it does not work anymore if we specify the 'lex' ordering for monomials of R:

sage: R.<x, y> = PolynomialRing(F, order='lex')
sage: cm.explain(R,MS)
Will try _r_action and _l_action
Unknown result parent.

However it works if we specify the 'degrevlex' ordering for monomials of R:

sage: R.<x, y> = PolynomialRing(F, order='degrevlex')
sage: cm.explain(R,MS)
Action discovered.
    Left scalar multiplication by Multivariate Polynomial Ring in x, y over Finite Field of size 17 on Full MatrixSpace of 5 by 4 dense matrices over Finite Field of size 17
Result lives in Full MatrixSpace of 5 by 4 dense matrices over Multivariate Polynomial Ring in x, y over Finite Field of size 17
Full MatrixSpace of 5 by 4 dense matrices over Multivariate Polynomial Ring in x, y over Finite Field of size 17

And it works with the 'lex' ordering for monomials of R if the matrix space is "square" (through a different path however):

sage: MS = MatrixSpace(F, 5, 5)
sage: R.<x, y> = PolynomialRing(F, order='lex')
sage: cm.explain(R,MS)
Coercion on left operand via
    Call morphism:
      From: Multivariate Polynomial Ring in x, y over Finite Field of size 17
      To:   Full MatrixSpace of 5 by 5 dense matrices over Multivariate Polynomial Ring in x, y over Finite Field of size 17
Coercion on right operand via
    Call morphism:
      From: Full MatrixSpace of 5 by 5 dense matrices over Finite Field of size 17
      To:   Full MatrixSpace of 5 by 5 dense matrices over Multivariate Polynomial Ring in x, y over Finite Field of size 17
Arithmetic performed after coercions.
Result lives in Full MatrixSpace of 5 by 5 dense matrices over Multivariate Polynomial Ring in x, y over Finite Field of size 17
Full MatrixSpace of 5 by 5 dense matrices over Multivariate Polynomial Ring in x, y over Finite Field of size 17

Depends on #23719

Component: coercion

Issue created by migration from https://trac.sagemath.org/ticket/19669

jdemeyer commented 6 years ago

Dependencies: #23719