Open remyoudompheng opened 1 year ago
Here is where it fails:
sage: x = polygen(QQ)
sage: K.<a> = NumberField(x**3-5)
sage: L.<b> = K.extension(x^2+26)
sage: OL = L.ring_of_integers()
sage: IL = OL.ideal(7).factor()[0][0]
sage: kL = OL.residue_field(IL)
sage: R = kL["x"]
sage: coercion_model.get_action(R, kL, operator.mul)
Right scalar multiplication by Residue field in bbar of Fractional ideal (7, (3*a^2 + 3*a + 1)*b + 2*a^2 + 2*a + 3) on Univariate Polynomial Ring in x over Residue field in bbar of Fractional ideal (7, (3*a^2 + 3*a + 1)*b + 2*a^2 + 2*a + 3)
sage: coercion_model.get_action(kL, R, operator.mul)
...
IndexError: the number of names must equal the number of generators
I reproduced the same failure in a different way. I had a typo
sage: x = polygen(QQ)
sage: K.<a> = NumberField(x^3-5)
sage: L.<b> = K.extension(x^2+36) # Note the slight difference
sage: OL = L.ring_of_integers()
sage: IL = OL.ideal(7).factor()[0][0]
sage: kL = OL.residue_field(IL)
sage: R = kL['x']
sage: R.an_element()^2
<repr(<sage.rings.polynomial.polynomial_zz_pex.Polynomial_ZZ_pEX at 0x7fc972cad9c0>) failed: IndexError: the number of names must equal the number of generators>
Interestingly, multiplying on the right by elements in the base ring works, and the coercions all seem to be in place:
sage: lc = ~poly.leading_coefficient()
sage: poly * lc
x + 4
sage: R(lc) * poly
x + 4
sage: phi = R.coerce_map_from(lc.parent())
sage: phi(lc) * poly
x + 4
From this and the error messages, predicably it fails when trying to find a left action of the base ring:
sage: coercion_model.discover_action(kL, R, operator.mul)
BOOM
even though it discovers the right action just fine. Perhaps something is going wrong with the pushout computation? I would need to trace through things more at this point...
I believe the fix is to catch IndexError
along with ValueError
and TypeError
in sage.categories.pushout.pushout
: it seems already very liberal in which exception types to catch, and the contract is to raise a CoercionException
whenever something doesn't make sense.
Another possible cause is that ResidueField have very special construction properties: if k
is a ResidueField, usually pushout(k, k.base())
will fail.
Perhaps, although it seems like it would cover up some mismatch that feels like a real error that could appear elsewhere. Do you have an idea about how to isolate this error? I can do some digging to see, but before I spend time doing that, I wanted to see if you already had or knew where to start.
Another possibility is to catch the case of multiple variables in the FiniteFieldConstructor
and raise a NotImplementedError
because multiple extensions of finite fields are not supported (which is true, there is no mathematical obstruction to doing that). It will be properly recast as a CoercionException,
Is there an existing issue for this?
Did you read the documentation and troubleshoot guide?
Environment
Steps To Reproduce
Run the following sequence: instantiate a double extension of QQ, and select an ideal such that the residue field has degree > 1.
Expected Behavior
poly.monic()
should divide the polynomial by 2 andrandom_element
select a random polynomialFor example, if the residue field is a prime field (degree 1):
If we don't do the extension of K, there is no issue:
Actual Behavior
An exception is raised:
Additional Information
This was discovered while working on an unrelated patch (trigggering a failure in
ell_curve_isogeny.py
in test for isogenies over relative number fields)