Division In Z/10Z Oddity

4 views
Skip to first unread message

Chris Swierczewski

unread,
Mar 14, 2008, 4:38:08 PM3/14/08
to sage-devel
Hello,

While writing up doctests for rings/quotient_ring_element.py, I came
across the following oddity: in the ring Z/10Z, some elements have
multiplicative inverses. In particular, 3^{-1} = 7 and 4*7 = 8 in Z/
10Z. (See below.) However, it seems that it depends on how I define R
= Z/10Z in Sage in order for it to correctly compute the inverse:


**************************************************
sage: R = QuotientRing(ZZ,10*ZZ)
sage: S = ZZ.quotient(10*ZZ)
sage: T = ZZ.quotient(ZZ.ideal(10))
sage: S(4)/S(3)
8
sage: T(4)/T(3)
8
sage: R(4)/R(3)
---------------------------------------------------------------------------
<type 'exceptions.NotImplementedError'> Traceback (most recent call
last)
/home/cswiercz/<ipython console> in <module>()
/home/cswiercz/element.pyx in
sage.structure.element.RingElement.__div__()
/home/cswiercz/coerce.pxi in sage.structure.element._div_c()
/home/cswiercz/sage/local/lib/python2.5/site-packages/sage/rings/
quotient_ring_element.py in _div_(self, right)
110
111 def _div_(self, right):
--> 112 if not right.is_unit():
113 raise ZeroDivisionError
114 raise NotImplementedError
/home/cswiercz/sage/local/lib/python2.5/site-packages/sage/rings/
quotient_ring_element.py in is_unit(self)
88 if self.__rep.is_unit():
89 return True
---> 90 raise NotImplementedError
91
92 def _repr_(self):
<type 'exceptions.NotImplementedError'>:


sage: ~R(3)
---------------------------------------------------------------------------
<type 'exceptions.TypeError'> Traceback (most recent call
last)
/home/cswiercz/<ipython console> in <module>()
/home/cswiercz/sage/local/lib/python2.5/site-packages/sage/rings/
quotient_ring_element.py in __invert__(self)
142
143 def __invert__(self):
--> 144 inv =
self.__rep.inverse_mod(self.parent().defining_ideal())
145 return QuotientRingElement(self.parent(), inv)
146
/home/cswiercz/integer.pyx in sage.rings.integer.Integer.inverse_mod()
/home/cswiercz/integer.pyx in sage.rings.integer.Integer.__init__()
<type 'exceptions.TypeError'>: unable to coerce element to an integer
**************************************************


I was working on the _div_ function for the class QuotientRing_element
at the time when I ran into this issue. It seems to me that this
implies QuotientRing(<ring>,<ideal>) and <ring>.quotient(<ideal>) have
slightly different class structures. Any comments? I just thought I'd
bring it attention. Not sure if I know enough about how the classes
are organized to be able to fix it myself without some serious help.

--
Chris Swierczewski
email: cswi...@gmail.com
mobile: (broken)

Chris Swierczewski

unread,
Mar 14, 2008, 4:56:28 PM3/14/08
to sage-devel
Hello again,

I looked a little bit closer and they are indeed different classes:


**************************************************
sage: R
Quotient of Integer Ring by the ideal (10)
sage: S
Ring of integers modulo 10
sage: T
Ring of integers modulo 10
sage: a = R(3); type(a)
<class 'sage.rings.quotient_ring_element.QuotientRingElement'>
sage: b = S(3); type(b)
<type 'sage.rings.integer_mod.IntegerMod_int'>
sage: c = T(3); type(c)
<type 'sage.rings.integer_mod.IntegerMod_int'>
**************************************************


So I guess my question is: why the distinction? Thanks in advance for
any comments!

Robert Bradshaw

unread,
Mar 14, 2008, 5:18:11 PM3/14/08
to sage-...@googlegroups.com

QuotientRing is a class that is made to handle generic quotient rings
(not an actual constructor). It probably shouldn't be exported to the
global namespace, or made into a constructor (that, by default, calls
R.quotient(I).

- Robert

William Stein

unread,
Mar 14, 2008, 5:33:53 PM3/14/08
to sage-...@googlegroups.com

You would think. That's exactly what I was about to say until I
looked at the source code. In fact, QuotientRing *is* a function
meant to be called. And I think Chris is pointing out a valid bug.

File: /Users/was/build/sage-2.10.3.rc3/local/lib/python2.5/site-packages/sage/rings/quotient_ring.py
Source Code (starting at line 36):
def QuotientRing(R, I, names=None):
r"""
Creates a quotient ring of the ring R by the ideal I. Variables are
labeled by names. (If the quotient ring is a quotient of a polynomial
ring.). If names isn't given, 'bar' will be appended to the variable names
in R.

INPUTS:
R -- a commutative ring
I -- and ideal of R
names -- a list of strings to be used as names for the variables in
the quotient ring R/I

OUTPUTS:
R/I -- the quotient ring R mod the ideal I

Reply all
Reply to author
Forward
0 new messages