#15223: Let the `TestSuite` test that the construction of a parent returns the
parent
-------------------------------------+-------------------------------------
       Reporter:  SimonKing          |        Owner:
           Type:  defect             |       Status:  new
       Priority:  major              |    Milestone:  sage-5.12
      Component:  coercion           |   Resolution:
       Keywords:                     |    Merged in:
        Authors:                     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/SimonKing/ticket/15223           |  a81fcc1072df88cc369d7aa0b7ae423fd97d7f02
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by SimonKing):

 Hm. But the more I think about it...:

 In the `__cmp__` method of `IntegerModRing`, it is said:
 {{{
         if type(other) is not type(self):   # so that GF(p) =/= Z/pZ
             return cmp(type(self), type(other))
         return cmp(self.__order, other.__order)
 }}}

 Note the comment: The aim is to let `GF(p)` and `Z/pZ` evaluate unequal.
 This gives rise to two questions:

 1. Do we really want that the evaluate unequal?

    We have
    {{{
 sage: GF(5).has_coerce_map_from(IntegerModRing(5))
 True
 sage: IntegerModRing(5).has_coerce_map_from(GF(5))
 False
    }}}
    Since there is no coercion in both directions, the two rings can not be
 equal. So, I'd say `GF(5)!=IntegerModRing(5)` is correct

 2. Do we really want that `IntegerModRing(5)` and
 `IntegerModRing(5,category=Fields())` evaluate unequal?

    This time, the coercions exist in both directions:
    {{{
 sage: IntegerModRing(5).has_coerce_map_from(IntegerModRing(5,
 category=Fields()))
 True
 sage: IntegerModRing(5,
 category=Fields()).has_coerce_map_from(IntegerModRing(5))
 True
    }}}
    Hence, we might want to let them evaluate equal.

 I see the following options:

 - Make it so that integer mod rings with the same modulus evaluate equal,
 regardless of their type and category. This would be in spite of the
 comment in the code of `__cmp__`.
 - Change `__cmp__` so that integer mod rings evaluate equal if and only if
 there is a coercion in both directions. Hence, `GF(5)` and `ZZ.quo(5)`
 would evaluate unequal, but `IntegerModRing(5, category=...)` would all
 evaluate equal, independent of the category.
 - Change `_coerce_map_from_`, so that there is a coercion in both
 directions if and only if the two integer mod rings evaluate equal. Hence,
 `IntegerModRing(5, category=...)` would all be distinct, for different
 categories.
 - Do not allow to put in a "category" argument. But then, we might want to
 learn the rationale of introducing the argument in the first place. After
 all, if the modulus of integer mod ring R is a prime number, then asking
 `R in Fields()` will return true. So, if one knows during creation of the
 ring that the modulus is prime, one might use `GF(p)` instead of
 `IntegerModRing(p,category=Fields())`.

 Further ways to go? In any case, there should be a new ticket.

--
Ticket URL: <http://trac.sagemath.org/ticket/15223#comment:21>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to