Opened 6 years ago

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

Reported by: Owned by: tmonteil major sage-6.10 coercion N/A #23719

### Description

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
```

### comment:1 Changed 4 years ago by jdemeyer

• Dependencies set to #23719
Note: See TracTickets for help on using tickets.