ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 14 Apr 2021 11:26:33 +0200Power Series Ring over p-adics: TypeError: unhashablehttps://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/I'm trying to construct a power series with coefficients in an Eisenstein extension of Qq, the unramified extension of the p-adic rationals. The following code works when a=1, but when a=2, I get the error: "TypeError: unhashable type: 'sage.rings.padics.qadic_flint_CR.qAdicCappedRelativeElement'".
p = 3
a = 2
ZZq.<xi> = Qq(p^a)
R.<x_pi> = ZZq[]
Zpi.<pi> = QuotientRing(R, R.ideal(x_pi^(p-1)+p))
L.<x> = PowerSeriesRing(Zpi)
Does anyone know a way to fix this for a>1?
Thank you!Fri, 09 Apr 2021 22:05:41 +0200https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/Answer by caruso for <p>I'm trying to construct a power series with coefficients in an Eisenstein extension of Qq, the unramified extension of the p-adic rationals. The following code works when a=1, but when a=2, I get the error: "TypeError: unhashable type: 'sage.rings.padics.qadic_flint_CR.qAdicCappedRelativeElement'".</p>
<pre><code>p = 3
a = 2
ZZq.<xi> = Qq(p^a)
R.<x_pi> = ZZq[]
Zpi.<pi> = QuotientRing(R, R.ideal(x_pi^(p-1)+p))
L.<x> = PowerSeriesRing(Zpi)
</code></pre>
<p>Does anyone know a way to fix this for a>1? </p>
<p>Thank you!</p>
https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/?answer=56653#post-id-56653Depending on what you want to do, you can maybe also consider using the constructor `TateAlgebra` (it is not exactly the same than power series but much effort is done to handle precision correctly):
sage: K.<u> = Qq(3^2)
sage: L.<pi> = K.extension(x^2 - 3)
sage: L
3-adic Eisenstein Extension Field in pi defined by x^2 - 3 over its base field
sage: A.<x> = TateAlgebra(L)
sage: (1 - pi*x).inverse_of_unit()
(1 + O(pi^40)) + (pi + O(pi^40))*x + ... + O(pi^40 * <x>)
Wed, 14 Apr 2021 11:26:33 +0200https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/?answer=56653#post-id-56653Answer by vdelecroix for <p>I'm trying to construct a power series with coefficients in an Eisenstein extension of Qq, the unramified extension of the p-adic rationals. The following code works when a=1, but when a=2, I get the error: "TypeError: unhashable type: 'sage.rings.padics.qadic_flint_CR.qAdicCappedRelativeElement'".</p>
<pre><code>p = 3
a = 2
ZZq.<xi> = Qq(p^a)
R.<x_pi> = ZZq[]
Zpi.<pi> = QuotientRing(R, R.ideal(x_pi^(p-1)+p))
L.<x> = PowerSeriesRing(Zpi)
</code></pre>
<p>Does anyone know a way to fix this for a>1? </p>
<p>Thank you!</p>
https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/?answer=56599#post-id-56599(Not a solution). The problem comes from the fact that sage is not able to derive enough information on `Zpi`
sage: ZZq.<xi> = Qq(3^1)
sage: R.<x_pi> = ZZq[]
sage: Zpi.<pi> = QuotientRing(R, R.ideal(x_pi^(p-1)+p))
sage: print(Zpi.is_field())
True
sage: ZZq.<xi> = Qq(3^2)
sage: R.<x_pi> = ZZq[]
sage: Zpi.<pi> = QuotientRing(R, R.ideal(x_pi^(p-1)+p))
sage: print(Zpi.is_field())
Traceback (most recent call last):
...
NotImplementedError
Sat, 10 Apr 2021 19:58:01 +0200https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/?answer=56599#post-id-56599Comment by saraedum for <p>(Not a solution). The problem comes from the fact that sage is not able to derive enough information on <code>Zpi</code></p>
<pre><code>sage: ZZq.<xi> = Qq(3^1)
sage: R.<x_pi> = ZZq[]
sage: Zpi.<pi> = QuotientRing(R, R.ideal(x_pi^(p-1)+p))
sage: print(Zpi.is_field())
True
sage: ZZq.<xi> = Qq(3^2)
sage: R.<x_pi> = ZZq[]
sage: Zpi.<pi> = QuotientRing(R, R.ideal(x_pi^(p-1)+p))
sage: print(Zpi.is_field())
Traceback (most recent call last):
...
NotImplementedError
</code></pre>
https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/?comment=56630#post-id-56630Implementing `_cache_key` does not help here unfortunately. `polynomial_ring_constructor.py` uses an (old?) cache that does not know about the `_cache_key` machinery.
If you can use `ZqFM` instead of `QqFM`, then the elements become hashable and your example works.Mon, 12 Apr 2021 23:18:09 +0200https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/?comment=56630#post-id-56630Comment by Alboin.matt@gmail.com for <p>(Not a solution). The problem comes from the fact that sage is not able to derive enough information on <code>Zpi</code></p>
<pre><code>sage: ZZq.<xi> = Qq(3^1)
sage: R.<x_pi> = ZZq[]
sage: Zpi.<pi> = QuotientRing(R, R.ideal(x_pi^(p-1)+p))
sage: print(Zpi.is_field())
True
sage: ZZq.<xi> = Qq(3^2)
sage: R.<x_pi> = ZZq[]
sage: Zpi.<pi> = QuotientRing(R, R.ideal(x_pi^(p-1)+p))
sage: print(Zpi.is_field())
Traceback (most recent call last):
...
NotImplementedError
</code></pre>
https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/?comment=56606#post-id-56606Do you know if there's a way I can supply sage with more information? In particular, how would I make it hashable by implementing _cache_key()?Sun, 11 Apr 2021 00:14:34 +0200https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/?comment=56606#post-id-56606Answer by saraedum for <p>I'm trying to construct a power series with coefficients in an Eisenstein extension of Qq, the unramified extension of the p-adic rationals. The following code works when a=1, but when a=2, I get the error: "TypeError: unhashable type: 'sage.rings.padics.qadic_flint_CR.qAdicCappedRelativeElement'".</p>
<pre><code>p = 3
a = 2
ZZq.<xi> = Qq(p^a)
R.<x_pi> = ZZq[]
Zpi.<pi> = QuotientRing(R, R.ideal(x_pi^(p-1)+p))
L.<x> = PowerSeriesRing(Zpi)
</code></pre>
<p>Does anyone know a way to fix this for a>1? </p>
<p>Thank you!</p>
https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/?answer=56629#post-id-56629In this case there is a specialized type for this p-adic base field which is called a "relative extension" in SageMath, i.e., an Eisenstein extension put on top of an unramified extension:
sage: K.<u> = Qq(3^2)
sage: R.<x> = K[]
sage: L.<pi> = R.extension(x^2 - 3)
sage: R.<x> = L[[]]
sage: R
Power Series Ring in x over 3-adic Eisenstein Extension Field in w defined by x^2 + 3 over its base field
When you used `QuotientRing`, it only gives you the formal quotient but does not understand enough about the underlying structure, e.g., that this is a field (which I suspect is because the base ring is not exact.) In any case, the above construction might also not prove too useful. It's tricky to get the interplay between the non-exact p-adic base and the non-exact power series ring right and SageMath is (last time I checked) not particularly good about it; but it depends a lot on your application. I don't know what's your application, but sometimes one can replace the base ring by an exact ring, e.g., a [Henselization](https://github.com/MCLF/henselization) or some other number field based approach.
PS: If you want to discuss your application, some of the people who care about p-adics in SageMath are meeting most Thursdays at 11pm CET at https://sagemath.zulipchat.com/#narrow/stream/271072-padics/topic/meeting.Mon, 12 Apr 2021 23:07:02 +0200https://ask.sagemath.org/question/56581/power-series-ring-over-p-adics-typeerror-unhashable/?answer=56629#post-id-56629