#15348: "R.<a> =" syntactic sugar incorrect for EquationOrder and ZZ.extension
---------------------------------+-------------------
Reporter: emassop | Owner:
Type: defect | Status: new
Priority: minor | Milestone:
Component: number fields | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
---------------------------------+-------------------
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 uniquitious support,
> about which I am unsure. I think way (3) might be achieved by renaming
> the argument {{{names}}} of {{{EquationOrder}}} to {{{field_names}}} or
> somesuch. (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]
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.)
--
Comment (by emassop):
Changing {{{gens()}}} would definitely also be my preferred solution. My
concern is that there might be code that assumes that {{{gens()}}} returns
a list of module generators, which would no longer be the case.
--
Ticket URL: <http://trac.sagemath.org/ticket/15348#comment:3>
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/d/optout.