sagemath / sage

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

reduce in quotient rings is broken #37370

Open yyyyx4 opened 7 months ago

yyyyx4 commented 7 months ago

Sage 10.3.beta8:

sage: R.<x,y> = GF(11)[]
sage: I = [x^2+1, x+y]
sage: J = [x]
sage: 1 in R.ideal(I + J)
True
sage: 1 in R.quotient(I).ideal(J)
False

See also #33217.

yyyyx4 commented 7 months ago

@mwageringel This seems related to some code you touched in #33217; could you maybe have a look? I don't know much about this topic.

mwageringel commented 7 months ago

Uh oh, the problem is that the quotient ideal I is not a Gröbner basis, but that is required by the Singular backend:

4.19.1 qring SINGULAR offers the opportunity to calculate in quotient rings (factor rings), i.e., rings modulo an ideal. The ideal has to be given as a standard basis.

Indeed:

sage: 1 in R.quotient(R.ideal(I).groebner_basis()).ideal(J)
True   # correct

The relevant implementation is https://github.com/sagemath/sage/blob/30b3d78fac8d4a015ad2641cad44c3d530f4c10c/src/sage/rings/polynomial/multi_polynomial_ideal.py#L5648-L5655 where already line 5649 does not yield a meaningful result in this case.

I do not see a simple fix other than to throw an error if the defining ideal of the quotient ring is not already a Gröbner basis. Otherwise, one would have to replace the quotient ring by one that is defined in terms of a Gröbner basis, but that would be an awkward thing to do in the reduce method unless some caching mechanism is used.

yyyyx4 commented 7 months ago

Why can't it just compute a Gröbner basis on demand when needed and cache it after the first time? I was under the impression that this is how things are done all over the multivariate codebase, is it not?

maxale commented 7 months ago

Issue #33982 may be related. Both issues may have caused by buggy implementation of ideals over non-fields.