Possible bug regarding the mod() method for multi-variable polynomials

131 views
Skip to first unread message

Yang Zhou

unread,
Apr 6, 2020, 3:46:26 AM4/6/20
to sage-devel
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

Sebastian Oehms

unread,
Apr 9, 2020, 2:41:24 AM4/9/20
to sage-devel
I consider this as a bug, too. My guess is, that it comes from the Singular interface:

sage: R.<x,y> = PolynomialRing(QQ, order='negdeglex')
sage
: f = 1 + x
sage
: I = R.ideal(x^2)
sage
: import sage.libs.singular.function_factory
sage
: reduce = sage.libs.singular.function_factory.ff.reduce
sage
: reduce(f, I)
1

but:

                     SINGULAR                                 /  Development
 A
Computer Algebra System for Polynomial Computations       /   version 4.1.1
                                                           
0<
 
by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \   Feb 2018
FB
Mathematik der Universitaet, D-67653 Kaiserslautern        \
> ring r = 0,(x, y),lp;
> poly f,g = 1+x, x^2;
> ideal I = (g);
> reduce(f,I);
x
+1

Note, that in Sage f.reduce(I) returns 1, as well, even though is not implemented as above, but using the Singular kernel function kNF. Anyway, this seems to be a task for Singular experts.

Enrique Artal

unread,
Apr 9, 2020, 3:28:07 AM4/9/20
to sage-devel
HI,
I think it is related with ticket #17638. There is a mathematical origin in this situation. When considering a non local ordering, one is working in a localized ideal, where any polynomial whose leading term is a non-zero constant is invertible. Singular works silently in this new ring without explicit declaration. I think that for Sage, a new structure should be constructed, but I do not know how. Best, Enrique.

Sebastian Oehms

unread,
Apr 9, 2020, 7:37:49 AM4/9/20
to sage-devel
Enrique, you are right, that doesn't come from the interface, but directely from Singular. Above, I took the wrong ordering. Here the correction:

sage: R.<x,y>=PolynomialRing(QQ,order='neglex')
sage
: R._singular_init_()
polynomial ring
, over a field, local ordering
// coefficients: QQ
// number of vars : 2
//        block   1 : ordering ls
//                  : names    x y
//        block   2 : ordering C

                     SINGULAR                                 /  Development
 A
Computer Algebra System for Polynomial Computations       /   version 4.1.1
                                                           
0<
 
by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \   Feb 2018
FB
Mathematik der Universitaet, D-67653 Kaiserslautern        \
> ring r = 0,(x, y),ls;

> poly f,g = 1+x, x^2;
> ideal I = (g);
> reduce(f,I);
1

BTW: The ticket you mentioned doesn't seem to adress that problem properly. The example which Simon inserted is now working. Therefore the ticket just consists of a doctest for that (I guess that has been made on the Sage Days in Zaragozza). The only reason that it isn't closed has been a merge confict, which has disappeared in the meantime.

Markus Wageringel

unread,
Apr 9, 2020, 1:20:06 PM4/9/20
to sage-devel
There is also #27508 about this problem. It looks like a possible solution was suggested by upstream, but has not been implemented in Sage yet.

Dima Pasechnik

unread,
Apr 9, 2020, 1:32:43 PM4/9/20
to sage-devel
On Fri, Apr 10, 2020 at 1:20 AM Markus Wageringel
<markus.w...@gmail.com> wrote:
>
> There is also #27508 about this problem. It looks like a possible solution was suggested by upstream, but has not been implemented in Sage yet.
>
IMHO #27508 is a different issue - that the reductions (for some
orders/cases) are not always done,
whereas here reductions are done.

> --
> 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+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/a68ce5c3-abec-4ad3-bd49-2c505851696d%40googlegroups.com.

Markus Wageringel

unread,
Apr 9, 2020, 1:56:02 PM4/9/20
to sage-...@googlegroups.com
Oh, you are right. Sorry for the noise.
> You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/nDoUXqpJ6OU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAAWYfq2pzwhGSDL6C4%2BeguBibPEj2GgykAenFG84G9TPbGcEJg%40mail.gmail.com.

Sebastian Oehms

unread,
Apr 13, 2020, 3:07:04 AM4/13/20
to sage-devel
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 = 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:
Reply all
Reply to author
Forward
0 new messages