#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            |  e857c9a484132348092e21cd1de0711686b8b7f0
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by emassop):

 My point about wanting `O.<foo> = K.order(-i+1)` to work is moot, because
 `.order` doesn't take a names argument, so that the syntactic sugar
 doesn't work in this case anyway.

 As far as I can tell these patches indeed fix `R.<a> = EquationOrder(f)`
 and `R.<a> = ZZ.extension(f)`, where `f` is a polynomial. Also AFAICT,
 this is by virtue of `NumberField` using `1, a, a^2, ...` as basis, and
 other things normalizing to that basis.

 I tried for instance the following to make sure `ring_generators` could
 not be distracted:
 {{{
 from sage.rings.number_field.order import AbsoluteOrder
 K.<i> = NumberField(x^2+1)
 V, from_v, to_v = K.vector_space()
 O = AbsoluteOrder(K, span([to_v(1), to_v(-i)], ZZ))
 print O.ring_generators() == [i]  # True, so the ring generator is i, not
 -i.
 }}}

 However, these patches do not fix the case of `R<several letters> = ...`.
 For instance
 {{{
 O.<a,b> = EquationOrder([x^2+1, x^2+2])
 print O.ring_generators()
 }}}
 prints `[-b*a - 1, -3*a + 2*b]` which for this patch to work should be
 `[a,b]`. (Incidentally, that first and confusing line is used in the
 docstring of `EquationOrder`. Can you get rid of that, or comment on its
 unexpected consequences for variables `a` and `b`?)

 Replying to [comment:17 jdemeyer]:
 > Replying to [comment:12 emassop]:
 > > I don't really like unconditionally preferring `ring_generators()` in
 such a general place as `_first_n_gens()` is. Perhaps this should be
 something like `defining_generators()` instead of `ring_generators()`.
 This would be set when defining something by generators, and always refer
 to the generators from the definition.
 >
 > Done.

 Changing `defining_generators` is indeed dangerous. Perhaps there could be
 `defining_generators.set(...)` that would
 * populate the cache if it has no value,
 * do nothing if the cache and the argument agree,
 * populate the cache with an invalid value when the argument and the cache
 disagree.
 The invalid value would make a call to `defining_generators` raise an
 exception. Also, how does the cache behaving with pickling? Does a cache
 override get saved?

 Finally, does it make sense to define `defining_generators` in
 `category_object.pyx` as simply `gens()`, and put the override to
 `ring_generators` in `class Order`?

 Pain, pain, pain. I think it's okay to pragmatically go with this approach
 now.

 Some speculation, since my ideas keep changing about this: Perhaps the
 preparser should translate `a.<b> = c(d)` to `a,(b,) =
 c._call_and_also_return_names(d, names=('b',))`. Then
 `_call_and_also_return_names` gets responsible for calling `c` and making
 sure the returned generators are the right ones. When `c` is a function,
 this can be implemented using a decorator, or next to `c` itself. For
 classes `c`, `_call_and_also_return_names` can be a class method of
 `CategoryObject` which calls instantiates an object and calls
 `_first_n_gens` on it. This would also circumvent the hack of
 prepopulating and having to change the cache of `defining_generators`. Of
 course this seems like a bigger change than this bug, so let's do the
 pragmatic thing first.

--
Ticket URL: <http://trac.sagemath.org/ticket/15348#comment:19>
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