The history of discussions about this issue reaches back over many years, see #10708 <https://trac.sagemath.org/ticket/10708> and this sage-devel thread <https://groups.google.com/forum/#!searchin/sage-devel/artal/sage-devel/JQlb4bbBXjQ/7OgkbYIVNJQJ> and it seems that they all broke down even though good suggestions where made. So let me do another attempt by gathering and rephrasing those suggestions, which I think should be realizable with a manageable effort. May we can do that in three steps:
1. Change the default implementation if the user chooses a *local term order*. The default implementation can't be longer *Singular* in this case, since *Singular *operates on a different mathematical object (which is not a polynomial ring), here. For example, this could be done in the following way (shown relative to 9.1.beta9): diff --git a/src/sage/rings/polynomial/polynomial_ring_constructor.py b/src/ sage/rings/polynomial/polynomial_ring_constructor.py index 98af2c4..afe6720 100644 --- a/src/sage/rings/polynomial/polynomial_ring_constructor.py +++ b/src/sage/rings/polynomial/polynomial_ring_constructor.py @@ -772,7 +772,7 @@ def _multi_variate(base_ring, names, sparse=None, order= "degrevlex", implementat # yield the same implementation. We need this for caching. implementation_names = set([implementation]) - if implementation is None or implementation == "singular": + if implementation is None and order.is_global() or implementation == "singular": from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomialRing_libsingular try: R = MPolynomialRing_libsingular(base_ring, n, names, order) diff --git a/src/sage/rings/polynomial/polynomial_singular_interface.py b/ src/sage/rings/polynomial/polynomial_singular_interface.py index 74b8b82..8736c77 100644 --- a/src/sage/rings/polynomial/polynomial_singular_interface.py +++ b/src/sage/rings/polynomial/polynomial_singular_interface.py @@ -384,6 +384,10 @@ def can_convert_to_singular(R): if R.ngens() == 0: return False; + if hasattr(R, 'term_order'): + if R.term_order().is_local(): + return False; + base_ring = R.base_ring() if (base_ring is ZZ or sage.rings.finite_rings.finite_field_constructor.is_FiniteField( base_ring) In the example of this thread, this would mean that an instance of MPolynomialRing_polydict_domain will be created: sage: R.<x,y> = PolynomialRing(QQ, order='negdeglex'); R Multivariate Polynomial Ring in u, v over Rational Field sage: type(R) <class 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain_with_category' > sage: f = 1 + x sage: I = R.ideal(x^2) sage: f.mod(I) Traceback (most recent call last): ... TypeError: Local/unknown orderings not supported by 'toy_buchberger' implementation. If a user still likes to work over the localization of the polynomial ring via *Singular*, he has to give a corresponding *term order* and implementation='singular' explicitly (so that we can assume, that he knows what he is doing). In this case the representation string should make clear that this instance does not represent a polynomial ring: sage: S.<u,v> = PolynomialRing(QQ, order='neglex', implementation='singular' ); S Multivariate Polynomial Ring in u, v over Rational Field localized at the maximal idead centered at the origin <class 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular' > sage: g = 1 + u sage: J = S.ideal(u^2) sage: g.mod(J) 1 2. Deprecate implementation='singular' for *local term orders* and replace it by a new construction function together with a new class inherited from MPolynomialRing_libsingular with an appropriate name (LocalPolynomialRing for instance). 3. Try to find a way, to use *Singular* again for applications according to 1. I'm not sure if this will be possible, but maybe this can be done using a corresponding global order with *Singular* and perform transitions in _richcmp_, __reps__.... On Monday, April 6, 2020 at 9:46:26 AM UTC+2, Yang Zhou wrote: > > Hi, > > I am trying to truncate a multi-variable polynomial by moding out higher > order term and found > the following (simplified) example. I am wondering if it is a bug. > > > *Reproducible Example: * > >> R.<x,y> = PolynomialRing(QQ, order='negdeglex') >> > f = 1 + x >> I = R.ideal(x^2) >> f.mod(I) >> > *Expected output:* > >> 1 + x >> > *Actual output:* > >> 1 >> > > > *Note: * > The actual output will be 1+x when I omit the "order='negdeglex" parameter. > > *SageMath version:* > SageMath version 9.0, Release Date: 2020-01-01 > > *Operating system:* > OS: Ubuntu 19.10 x86_64 > Kernel: 5.3.0-45-generic > > Best regards, > Yang > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/a1c669d3-86da-4825-863a-4c1a9386c4a0%40googlegroups.com.