The history of discussions about this issue reaches back over many years, see
#10708 and
this sage-devel thread 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.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__....