#15348: "R.<a> =" syntactic sugar incorrect for EquationOrder and ZZ.extension
-------------------------------------+-------------------------------------
       Reporter:  emassop            |        Owner:
           Type:  defect             |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-7.0
      Component:  number fields      |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Jeroen Demeyer     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/jdemeyer/ticket/15348            |  dac0a4cdb957393b282619213dc231f55cf55cc4
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------
Changes (by jdemeyer):

 * status:  new => needs_review
 * commit:   => dac0a4cdb957393b282619213dc231f55cf55cc4


Old description:

> After typing
> {{{
> sage: f = x^2+1
> sage: R.<i> = ZZ.extension(f)
> }}}
> I expect variable {{{i}}} to be the element of {{{R}}} named {{{'i'}}}.
> However, it is not. It is the element 1.
>
> This is due to the generators of an order in Sage being its //module//
> generators (as noted by {{{EquationOrder?}}}):
> {{{
> sage: R.gens()
> [1, i]
> sage: preparse("R.<i> = ZZ.extension(f)")
> "R = ZZ.extension(f, names=('i',)); (i,) = R._first_ngens(1)"
> }}}
>
> I see three ways of fixing this:
> 1) redefine {{{AbsoluteOrder.gens()}}},
> 2) make {{{preparse(...)}}} output {{{i = R._element_constructor('i')}}}
> instead of {{{(i,) = R._first_ngens(1)}}},
> 3) disallow {{{R.<i> = }}} for {{{EquationOrder}}}.
>
> Way (1) might make previously good code produce wrong results, so it is
> not a good idea.
> For way (2), {{{_element_constructor}}} should have ubiquitous support,
> about which I am unsure. I think way (3) might be achieved by renaming
> the argument {{{names}}} of {{{EquationOrder}}} to {{{field_names}}} or
> some such. (For the short term I think {{{names}}} should still be
> accepted, but with a warning.)

New description:

 After typing
 {{{
 sage: f = x^2+1
 sage: R.<i> = ZZ.extension(f)
 }}}
 I expect variable {{{i}}} to be the element of {{{R}}} named {{{'i'}}}.
 However, it is not. It is the element 1.

 This is due to the generators of an order in Sage being its //module//
 generators (as noted by {{{EquationOrder?}}}):
 {{{
 sage: R.gens()
 [1, i]
 }}}

 We fix this by redefining `_first_ngens()` (which is what the preparser
 uses to implement the `R.<x> =` syntax) to use `ring_generators()` if such
 an attribute exists.

--

Comment:

 New commits:
 
||[http://git.sagemath.org/sage.git/commit/?id=dac0a4cdb957393b282619213dc231f55cf55cc4
 dac0a4c]||{{{Let "R.<x> =" syntax use ring_generators if possible}}}||

--
Ticket URL: <http://trac.sagemath.org/ticket/15348#comment:11>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to