#14367: RuntimeError: There is a bug in the coercion code in Sage
------------------------+---------------------------------------------------
Reporter: lftabera | Owner: robertwb
Type: defect | Status: new
Priority: major | Milestone: sage-5.9
Component: coercion | Keywords: coercion, number field, p-adic
Work issues: | Report Upstream: N/A
Reviewers: | Authors:
Merged in: | Dependencies:
Stopgaps: |
------------------------+---------------------------------------------------
I have found what Sage claims is a bug in the coercion code.
{{{
sage: Q7 = Qp(7)
sage: r1 = 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 +\
6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17 +\
4*7^18 + 6*7^19 + O(7^20)
sage: N.<b> = NumberField(x^2-2, embedding = r1)
sage: K.<t> = N[]
sage: f = t^3-2*t+1
sage: f(r1)
RuntimeError: There is a bug in the coercion code in Sage.
Both x (=1 + O(7^20)) and y (=3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 +
2*7^7 + 4*7^8 + 6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 +
7^17 + 4*7^18 + 6*7^19 + O(7^20)) are supposed to have identical parents
but they don't.
In fact, x has parent '7-adic Field with capped relative precision 20'
whereas y has parent '7-adic Ring with capped relative precision 20'
Original elements 1 (parent Number Field in b with defining polynomial x^2
- 2) and 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 + 6*7^9
+ 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17 + 4*7^18 + 6*7^19 +
O(7^20) (parent 7-adic Ring with capped relative precision 20) and maps
<type
'sage.rings.number_field.number_field_morphisms.NumberFieldEmbedding'>
Generic morphism:
From: Number Field in b with defining polynomial x^2 - 2
To: 7-adic Ring with capped relative precision 20
Defn: b -> 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 +
6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17 + 4*7^18 +
6*7^19 + O(7^20)
<type 'NoneType'> None
}}}
Note that here the embedding of N is into Qp(7) and that r1 is an element
of Zp(7). If I define r1 as an element of Qp(7) then the evaluation of f
works.
If I now do
{{{
sage: Z7 = Zp(7)
sage: r1 = Z7(3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 +\
....: 6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17
+\
....: 4*7^18 + 6*7^19)
sage: M.<b> = NumberField(x^2-2, embedding = r1)
sage: K.<t> = M[]
sage: f = t^3-2*t+1
sage: f(r1)
RuntimeError
...
}}}
I see here two problems. The most obvious is that I would expect f(r1) to
work. The second one is in the latter.
{{{
sage: M.coerce_embedding()
Generic morphism:
From: Number Field in b with defining polynomial x^2 - 2
To: 7-adic Ring with capped relative precision 20
Defn: b -> 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 +
6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17 + 4*7^18 +
6*7^19 + O(7^20)
}}}
This morphism should NOT be an embedding. It is not defined for 1/7
{{{
sage: phi = M.coerce_embedding()
sage: phi(M(1/7))
7^-1 + O(7^19)
sage: phi(M(1/7)) in phi.codomain()
False
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14367>
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.