#14982: Coercion from rings with coerce_embedding into constructions over those
rings is broken
-------------------------------------+-------------------------------------
Reporter: mmezzarobba | Owner:
Type: defect | Status: needs_review
Priority: major | Milestone: sage-6.1
Component: coercion | Resolution:
Keywords: embedding | Merged in:
Authors: Marc Mezzarobba | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/mmezzarobba/14982-coerce_embeddings|
2fcc47300d619cd8c0c96ab57686096993e64e5d
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Changes (by mmezzarobba):
* commit: 7e8d4aa5ad04fa2b6536508efefcf69776d6d160 =>
2fcc47300d619cd8c0c96ab57686096993e64e5d
* branch: u/mmezzarobba/coerce_embeddings =>
u/mmezzarobba/14982-coerce_embeddings
Old description:
> {{{
> sage: K.<a> = NumberField(x^2+1/2, embedding=CC(0,1))
> sage: L = NumberField(x^2+2, 'b', embedding=1/a)
> sage: R = PolynomialRing(L, 'x')
> sage: R.coerce_map_from(R.base_ring())
> ---------------------------------------------------------------------------
> AttributeError Traceback (most recent call
> last)
> <ipython-input-8-fb89bb074d92> in <module>()
> ----> 1 R.coerce_map_from(R.base_ring())
>
> /home/marc/co/sage/local/lib/python2.7/site-
> packages/sage/structure/parent.so in
> sage.structure.parent.Parent.coerce_map_from
> (sage/structure/parent.c:14807)()
>
> /home/marc/co/sage/local/lib/python2.7/site-
> packages/sage/structure/parent.so in
> sage.structure.parent.Parent.coerce_map_from
> (sage/structure/parent.c:14563)()
>
> /home/marc/co/sage/local/lib/python2.7/site-
> packages/sage/structure/parent.so in
> sage.structure.parent.Parent.discover_coerce_map_from
> (sage/structure/parent.c:14932)()
>
> /home/marc/co/sage/local/lib/python2.7/site-
> packages/sage/structure/parent.so in
> sage.structure.parent.Parent.coerce_map_from
> (sage/structure/parent.c:14563)()
>
> /home/marc/co/sage/local/lib/python2.7/site-
> packages/sage/structure/parent.so in
> sage.structure.parent.Parent.discover_coerce_map_from
> (sage/structure/parent.c:14985)()
>
> /home/marc/co/sage/local/lib/python2.7/site-
> packages/sage/structure/parent_old.so in
> sage.structure.parent_old.Parent._coerce_map_from_
> (sage/structure/parent_old.c:6658)()
>
> /home/marc/co/sage/local/lib/python2.7/site-
> packages/sage/rings/polynomial/polynomial_ring.pyc in
> _coerce_map_from_(self, P)
> 560 connecting = base_ring.coerce_map_from(P)
> 561 if connecting is not None:
> --> 562 return self.coerce_map_from(base_ring) *
> connecting
> 563 except TypeError:
> 564 pass
>
> /home/marc/co/sage/local/lib/python2.7/site-
> packages/sage/categories/map.so in sage.categories.map.Map.__mul__
> (sage/categories/map.c:4796)()
>
> AttributeError: 'NoneType' object has no attribute 'domain'
> }}}
>
> Note that apparently P is K (not L) in the call to `_coerce_map_from_` at
> the end of the backtrace.
New description:
`Parent.discover_coerce_map_from` used to always give priority to
coercions that start with applying an embedding over those provided by
`_coerce_map_from_`. This leads to coercion failures such as the
following:
{{{
sage: K.<a> = NumberField(x^2+1/2, embedding=CC(0,1))
sage: L = NumberField(x^2+2, 'b', embedding=1/a)
sage: R = PolynomialRing(L, 'x')
sage: R.coerce_map_from(R.base_ring())
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
<ipython-input-8-fb89bb074d92> in <module>()
----> 1 R.coerce_map_from(R.base_ring())
...
AttributeError: 'NoneType' object has no attribute 'domain'
}}}
This patch series modifies the coercion discovery algorithm to fix the
issue, and fixes or works around a few weaknesses in existing code exposed
by the change.
--
Comment:
(git-)Rebased on top of 61.rc0, removed dependency on #15303.
----
New commits:
||[http://git.sagemath.org/sage.git/commit/?id=0faffde6f7c72bb7a3f3f34b17bae97ef4039c59
0faffde]||{{{Cleanup after querying the coercion system with a temporary
element_class in NumberField_cyclotomic}}}||
||[http://git.sagemath.org/sage.git/commit/?id=bd4f772d2296b9071895eece52172318b96de677
bd4f772]||{{{Make coercions that go through lazy fields more robust}}}||
||[http://git.sagemath.org/sage.git/commit/?id=2fcc47300d619cd8c0c96ab57686096993e64e5d
2fcc473]||{{{14982: consider coercions of parents with embeddings that do
not use the embedding}}}||
--
Ticket URL: <http://trac.sagemath.org/ticket/14982#comment:22>
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.