[sage-devel] Re: Possible bug regarding the mod() method for multi-variable polynomials

2020-04-13 Thread Sebastian Oehms
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. = PolynomialRing(QQ, order='negdeglex'); R
Multivariate Polynomial Ring in u, v over Rational Field
sage: type(R)

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. = 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

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. = 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.


Re: [sage-devel] Re: Possible bug regarding the mod() method for multi-variable polynomials

2020-04-09 Thread Markus Wageringel
Oh, you are right. Sorry for the noise.


> Am 09.04.2020 um 19:32 schrieb Dima Pasechnik :
> 
> On Fri, Apr 10, 2020 at 1:20 AM Markus Wageringel
>  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+unsubscr...@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.
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-devel/CAAWYfq2pzwhGSDL6C4%2BeguBibPEj2GgykAenFG84G9TPbGcEJg%40mail.gmail.com.

-- 
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/C8890659-3860-4EC6-86B6-F363C61006DA%40gmail.com.


Re: [sage-devel] Re: Possible bug regarding the mod() method for multi-variable polynomials

2020-04-09 Thread Dima Pasechnik
On Fri, Apr 10, 2020 at 1:20 AM Markus Wageringel
 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+unsubscr...@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.

-- 
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/CAAWYfq2pzwhGSDL6C4%2BeguBibPEj2GgykAenFG84G9TPbGcEJg%40mail.gmail.com.


[sage-devel] Re: Possible bug regarding the mod() method for multi-variable polynomials

2020-04-09 Thread Markus Wageringel
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.

-- 
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/a68ce5c3-abec-4ad3-bd49-2c505851696d%40googlegroups.com.


[sage-devel] Re: Possible bug regarding the mod() method for multi-variable polynomials

2020-04-09 Thread Sebastian Oehms
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.=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
//  : namesx 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.



On Thursday, April 9, 2020 at 9:28:07 AM UTC+2, Enrique Artal wrote:
>
> 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.
>
> El lunes, 6 de abril de 2020, 9:46:26 (UTC+2), Yang Zhou escribió:
>>
>> 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. = 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/2d4fa6e0-d819-4c9b-bd19-c73910096779%40googlegroups.com.


[sage-devel] Re: Possible bug regarding the mod() method for multi-variable polynomials

2020-04-09 Thread Enrique Artal
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.

El lunes, 6 de abril de 2020, 9:46:26 (UTC+2), Yang Zhou escribió:
>
> 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. = 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/593546a3-8c04-471f-a78f-3ff9400e9b03%40googlegroups.com.


[sage-devel] Re: Possible bug regarding the mod() method for multi-variable polynomials

2020-04-09 Thread Sebastian Oehms
I consider this as a bug, too. My guess is, that it comes from the Singular 
interface:

sage: R. = 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.


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. = 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/f1c2216c-23d9-438c-a587-7f4b92848974%40googlegroups.com.