On Wednesday, April 30, 2014 8:28:24 AM UTC+2, Charles Bouillaguet wrote:
>
> Hi all, 
>
> I just noticed that we carefully check that Sage computes something 
> completely wrong. From sage/structure/element.pyx, line 2052 : 
>
> -------------------------- 
>       When little is implemented about a given ring, then mod may 
>         return simply return `f`.  For example, reduction is not 
>         implemented for `\ZZ[x]` yet. (TODO!) 
>
>             sage: R.<x> = PolynomialRing(ZZ) 
>             sage: f = x^3 + x + 1 
>             sage: f.mod(x + 1) 
>             x^3 + x + 1 
> ---------------------- 
>
> The problem is that mod() does the following : 
>
>      from sage.rings.ideal import is_Ideal 
>         if not is_Ideal(I) or not I.ring() is self._parent: 
>             I = self._parent.ideal(I) 
>             #raise TypeError, "I = %s must be an ideal in %s"%(I, 
> self.parent()) 
>         return I.reduce(self) 
>
> So, mod relies on Ideal.reduce, which by default does nothing and returns 
> its argument. As such, mod is badly broken. 
>
> What seems reasonable is to make Ideal.reduce() raise a 
> NotImplementedError by default instead of doing nothing, by this breaks a 
> lot of other stuff (because Ideal.reduce() is called a lot). 
>
> What do you think is right ? 
>
> *) Go with NotImplementedError and fix 30+ doctests? 
> *) create a StopGap that warn the user that mod may be complete rubbish? 
>
> Cheers, 
> --- 
> Charles Bouillaguet 
> http://www.lifl.fr/~bouillaguet/ 
>
> Wouldn't modify the mod method for polynomial rings over ZZ be enough? 

In a similar way, the pow (python?) function accepts an optional "modulus" 
third args, but Sage just ignores it over a bunch of rings.
For example, over QQ, pow(x,100,x+1) yields x^100.
For non euclidean rings that might be a sensible default choice but for 
euclidean rings or even just univariate polynomial rings over fields we 
might want to modify that (maybe something for the category framework as 
Luca De Feo suggested).

-- 
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 post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to