#5618: Cyclotomic field elements are not converted to Gap correctly
-----------------------+----------------------------------------------------
   Reporter:  saliola  |       Owner:  tbd     
       Type:  defect   |      Status:  new     
   Priority:  major    |   Milestone:  sage-4.5
  Component:  algebra  |    Keywords:          
     Author:           |    Upstream:  N/A     
   Reviewer:           |      Merged:          
Work_issues:           |  
-----------------------+----------------------------------------------------
Changes (by SimonKing):

  * upstream:  => N/A


Comment:

 Here is some problem analysis:
 {{{
 sage: K = CyclotomicField(3)
 sage: z = K.an_element(); z
 zeta3
 sage: gap(z)
 zeta3
 sage: K(gap(z))
 zeta3
 sage: gap.E(3)
 E(3)
 sage: gap.E(3) == gap(z)
 False
 sage: K(gap.E(3)) == K(gap(z)) == z
 True
 }}}

 So, apparently GAP treats "the same" elements of a cyclotomic field
 differently if they have different names. But this isn't particularly
 surprising, since the two cyclotomic fields seem to have a totaly
 different representation in GAP:
 {{{
 sage: ZFgap = gap('CyclotomicField(3)')
 sage: Kgap = gap(K)
 sage: Kgap
 <algebraic extension over the Rationals of degree 2>
 sage: ZFgap
 CF(3)
 sage: ZFgap.GeneratorsOfField()
 [ E(3) ]
 sage: Kgap.GeneratorsOfField()
 [ zeta3 ]
 }}}

 Note that comparison of the two field in the GAP interface results in an
 error:

 {{{
 sage: Kgap == ZFgap
 ERROR: An unexpected error occurred while tokenizing input
 The following traceback may be corrupted or invalid
 The error message is: ('EOF in multi-line statement', (47, 0))

 ---------------------------------------------------------------------------
 RuntimeError                              Traceback (most recent call
 last)

 /home/king/<ipython console> in <module>()

 /home/king/SAGE/sage-4.4.2/local/lib/python2.6/site-
 packages/sage/structure/element.so in
 sage.structure.element.Element.__richcmp__
 (sage/structure/element.c:7061)()

 /home/king/SAGE/sage-4.4.2/local/lib/python2.6/site-
 packages/sage/structure/element.so in
 sage.structure.element.Element._richcmp (sage/structure/element.c:6943)()

 /home/king/SAGE/sage-4.4.2/local/lib/python2.6/site-
 packages/sage/interfaces/expect.pyc in __cmp__(self, other)
    1527                                  other.name())) ==
 P._true_symbol():
    1528             return 0
 -> 1529         elif P.eval("%s %s %s"%(self.name(), P._lessthan_symbol(),
 other.name())) == P._true_symbol():
    1530             return -1
    1531         elif P.eval("%s %s %s"%(self.name(),
 P._greaterthan_symbol(), other.name())) == P._true_symbol():

 /home/king/SAGE/sage-4.4.2/local/lib/python2.6/site-
 packages/sage/interfaces/gap.pyc in eval(self, x, newlines, strip, **kwds)
     478             input_line += ';'
     479
 --> 480         result = Expect.eval(self, input_line, **kwds)
     481
     482         if not newlines:

 /home/king/SAGE/sage-4.4.2/local/lib/python2.6/site-
 packages/sage/interfaces/expect.pyc in eval(self, code, strip,
 synchronize, locals, **kwds)
     981         try:
     982             with gc_disabled():
 --> 983                 return '\n'.join([self._eval_line(L, **kwds) for L
 in code.split('\n') if L != ''])
     984         except KeyboardInterrupt:
     985             # DO NOT CATCH KeyboardInterrupt, as it is being
 caught

 /home/king/SAGE/sage-4.4.2/local/lib/python2.6/site-
 packages/sage/interfaces/gap.pyc in _eval_line(self, line, allow_use_file,
 wait_for_prompt)
     720                         return ''
     721                 else:
 --> 722                     raise RuntimeError, message
     723
     724         except KeyboardInterrupt:

 RuntimeError: Gap produced error output
 Error, no 1st choice method found for `LT' on 2 arguments

    executing $sage2 < $sage8;
 }}}

 But GAP indeed considers the two fields to be different:
 {{{
 sage: gap.eval(Kgap.name() + ' = ' + ZFgap.name())
 'false'
 }}}

 So, what does all this mean?

  1. The {{{__cmp__}}} method of the GAP interface has a bug. An error
 raised by GAP when attempting "<" or ">" should be caught and then "="
 should be tried.
  2. A GAP cyclotomic field is different from the GAP version of a Sage
 cyclotomic field. This is since the GAP version of a Sage cyclotomic field
 is a number field. It could be solved by providing a genuine
 {{{_gap_init_}}} method for Sage cyclotomic fields (currently, it is
 inherited from number fields).

 It seems likely to me that after implementing 2., things will already
 work. But 1. should be fixed as well.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5618#comment:2>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to