Sage: Ticket #12236: random element madness
https://trac.sagemath.org/ticket/12236
<p>
The following output is generated by the code below using
sage-4.7.2:
</p>
<pre class="wiki">R: Univariate Quotient Polynomial Ring in xbar over Ring of integers modulo 2 with modulus x^4 + 1
S: Quotient of Univariate Quotient Polynomial Ring in xbar over Integer Ring with modulus x^4 + 1 by the ideal (2)
Now these two rings are isomorphic, but constructed in different orders, so it is not that surprising that SAGE considers them to be different:
R == S: False
And random_element on R seems sensible:
[xbar^3 + xbar + 1, xbar^3 + xbar^2 + 1, xbar^2 + xbar, xbar^2, 1, xbar^2 + xbar, xbar^3, xbar^3, xbar^3 + xbar^2, xbar^2 + xbar + 1]
But random_element on S just doesn't make sense on several levels:
[2, 1, -2, 2, 2, 0, 1, 0, 2, -2]
1) Why are there no polynomial powers?
2) Why are the integers not reduced modulo 2?
</pre><p>
Here is the code:
</p>
<pre class="wiki">def print_random_elements(R, num_elts=10):
R_elts = [R.random_element() for i in range(num_elts)]
print R_elts
def madness():
U.<x> = ZZ[]
f = x^4 + 1
p = 2
num_elts = 10
S = U.quotient(f).quotient(p)
#S.<x> = Integers(p)[]
#S1 = S.quotient(f)
R = (Integers(p)['x']).quotient(f)
print 'R:', R
print 'S:', S
print '''Now these two rings are isomorphic, but constructed in different
orders, so it is not that surprising that SAGE considers them to
be different:'''
print "R == S:", R == S
print 'And random_element on R seems sensible:'
print_random_elements(R)
print "But random_element on S just doesn't make sense on several levels:"
print_random_elements(S)
print "1) Why are there no polynomial powers?"
print "2) Why are the integers not reduced modulo %s?" % p
madness()
</pre>en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/12236
Trac 1.1.6swensonSun, 22 Jan 2012 03:59:41 GMTowner changed
https://trac.sagemath.org/ticket/12236#comment:1
https://trac.sagemath.org/ticket/12236#comment:1
<ul>
<li><strong>owner</strong>
changed from <em>AlexGhitza</em> to <em>swenson</em>
</li>
</ul>
<p>
I have a patch to address some of this that I will post as soon as I can, but there are two issues here, which are identified above.
</p>
<p>
Issue 1 is a "feature" of QuotientRing_generic that I am still getting to the bottom of, but notice, here
</p>
<p>
This appears to be related to the following error:
</p>
<pre class="wiki">sage: ZZ['x'].quotient(2 * ZZ)
...
TypeError: polynomial must have unit leading coefficient
</pre><p>
i.e., polynomial rings seem to expect that, if you mod out by an ideal, it should be a polynomial, which isn't the case if you are trying to mod out by an ideal in the base ring.
</p>
<p>
This seems to raise other issues with integer ideals interacting with polynomials rings, e.g.,
</p>
<pre class="wiki">sage: ZZ['x'].quotient(ZZ['x'].ideal([x^4 + 1, 2])).quotient(2)
Quotient of Univariate Polynomial Ring in x over Integer Ring by the ideal (2, x^4 + 1, 2)
sage: ZZ['x'].quotient(ZZ['x'].ideal([x^4 + 1, 2])).quotient(2)(2)
2
</pre><p>
:(
</p>
<p>
Issue 2 raised above has to do with ideal.reduce(): the default implementation is being called, which just gives a pass-through, i.e.,
</p>
<pre class="wiki">sage: Integers(2).ideal().reduce(2)
2
</pre><p>
At the very least, this should be coercing its argument into its base ring.
</p>
TicketswensonSun, 22 Jan 2012 04:00:32 GMTowner changed
https://trac.sagemath.org/ticket/12236#comment:2
https://trac.sagemath.org/ticket/12236#comment:2
<ul>
<li><strong>owner</strong>
changed from <em>swenson</em> to <em>AlexGhitza</em>
</li>
</ul>
<p>
Sorry -- didn't mean to steal this from <a class="missing wiki">AlexGhitza?</a>
</p>
TicketmhansenMon, 28 May 2012 18:37:52 GMT
https://trac.sagemath.org/ticket/12236#comment:3
https://trac.sagemath.org/ticket/12236#comment:3
<p>
I think that, at least for now, we should just throw an error if you try to quotient out a polynomial ring by an ideal of the base ring since you get a "broken" object.
</p>
TicketjdemeyerTue, 13 Aug 2013 15:35:53 GMTmilestone changed
https://trac.sagemath.org/ticket/12236#comment:4
https://trac.sagemath.org/ticket/12236#comment:4
<ul>
<li><strong>milestone</strong>
changed from <em>sage-5.11</em> to <em>sage-5.12</em>
</li>
</ul>
Ticketvbraun_spamThu, 30 Jan 2014 21:20:52 GMTmilestone changed
https://trac.sagemath.org/ticket/12236#comment:5
https://trac.sagemath.org/ticket/12236#comment:5
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.1</em> to <em>sage-6.2</em>
</li>
</ul>
Ticketvbraun_spamTue, 06 May 2014 15:20:58 GMTmilestone changed
https://trac.sagemath.org/ticket/12236#comment:6
https://trac.sagemath.org/ticket/12236#comment:6
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.2</em> to <em>sage-6.3</em>
</li>
</ul>
Ticketvbraun_spamSun, 10 Aug 2014 16:51:03 GMTmilestone changed
https://trac.sagemath.org/ticket/12236#comment:7
https://trac.sagemath.org/ticket/12236#comment:7
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.3</em> to <em>sage-6.4</em>
</li>
</ul>
TicketjakobkroekerTue, 25 Aug 2015 16:38:06 GMTstopgaps set
https://trac.sagemath.org/ticket/12236#comment:8
https://trac.sagemath.org/ticket/12236#comment:8
<ul>
<li><strong>stopgaps</strong>
set to <em>todo</em>
</li>
</ul>
Ticket