sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.34k stars 452 forks source link

Polynomials over p-adics and power series are wrong #34024

Open videlec opened 2 years ago

videlec commented 2 years ago

The design choice made for p-adics and power series is that O(p^n) and O(x^n) behave similarly to zero in comparisons. All of

sage: a = O(2^3)
sage: a.is_zero()
True
sage: a.is_zero() and not a and a == a.parent().zero() and not (a != a.parent().zero())
True
sage: R.<x> = PowerSeriesRing(QQ)
sage: a = O(x^3)
sage: a.is_zero() and not a and a == a.parent().zero() and not (a != a.parent().zero())
True

As a consequence, the generic implementation of uni-variate and multi-variate polynomials are broken on those rings (as it does remove terms whose coefficients are zero).

sage: Z2 = Zp(2)
sage: R.<x,y> = Z2[]
sage: R(1) - R(1)
0
sage: Z2(1) - Z2(1)
O(2^20)

Depends on #34000

Component: algebra

Issue created by migration from https://trac.sagemath.org/ticket/34024

videlec commented 2 years ago
comment:1

My personal feeling is that bool(a) should be equivalent to "a is not exact zero".