Skip to content

Commit

Permalink
Alternative proposal sketch.
Browse files Browse the repository at this point in the history
  • Loading branch information
tscrim committed Apr 12, 2023
1 parent f20f087 commit 95bd489
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
36 changes: 19 additions & 17 deletions src/sage/rings/lazy_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,21 +923,21 @@ def _richcmp_(self, other, op):
False
sage: fz = L(lambda n: 0, valuation=0)
sage: L.zero() == fz
False
sage: fz == L.zero()
False
sage: (L.zero() == fz) is None
True
sage: (fz == L.zero()) is None
True
With using :class:`Unknown`::
sage: L.options.use_unknown = True
sage: fz = L(lambda n: 0, valuation=0)
sage: L.zero() == fz
Unknown
sage: fz == L.zero()
Unknown
sage: fz != L.zero()
Unknown
sage: (L.zero() == fz) is None
True
sage: (fz == L.zero()) is None
True
sage: (fz != L.zero()) is None
True
With using finite halting precision::
Expand Down Expand Up @@ -993,7 +993,8 @@ def _richcmp_(self, other, op):
# undecidable otherwise
prec = self.parent().options['halting_precision']
if prec is None:
return Unknown
return None
#return Unknown
# raise UnknownError("undecidable")
# at least one of the approximate orders is not infinity
m = min(self._coeff_stream._approximate_order,
Expand All @@ -1002,7 +1003,7 @@ def _richcmp_(self, other, op):

if op is op_NE:
ret = (self == other)
if ret is Unknown:
if ret is None:
return ret
return not ret

Expand Down Expand Up @@ -1140,7 +1141,8 @@ def __bool__(self):
return True

if prec is None:
raise UnknownError("undecidable")
return True
#raise UnknownError("undecidable")
v = self._coeff_stream._approximate_order
return any(self[i] for i in range(v, v + prec))

Expand Down Expand Up @@ -1884,12 +1886,12 @@ def _acted_upon_(self, scalar, self_on_left):
Different scalars potentially give different series::
sage: 2 * M == 3 * M
False
sage: (2 * M == 3 * M) is None
True
sage: L.options.use_unknown = True
sage: 2 * M == 3 * M
Unknown
sage: (2 * M == 3 * M) is None
True
sage: L.options.halting_precision = 30
sage: 2 * M == 3 * M
Expand Down
26 changes: 12 additions & 14 deletions src/sage/rings/lazy_series_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ class options(GlobalOptions):
- constant_length: 3
- display_length: 7
- halting_precision: None
- use_unknown: False
- use_unknown: True
sage: LLS.options.display_length
7
Expand Down Expand Up @@ -713,7 +713,7 @@ class options(GlobalOptions):
halting_precision = dict(default=None,
description='the number of coefficients, beginning with the approximate valuation, to check in equality tests',
checker=lambda x: x is None or x in ZZ and x > 0)
use_unknown = dict(default=False,
use_unknown = dict(default=True,
description='whether to raise an error when a comparison is unknown',
checker=lambda x: x is True or x is False)

Expand Down Expand Up @@ -1160,8 +1160,8 @@ class LazyLaurentSeriesRing(LazySeriesRing):
be equal are considered to be different::
sage: f = L(lambda n: 0, valuation=0)
sage: f == 0
False
sage: (f == 0) is None
True
.. WARNING::
Expand All @@ -1170,7 +1170,7 @@ class LazyLaurentSeriesRing(LazySeriesRing):
series are actually different::
sage: g = L.zero()
sage: f != g
sage: (f != g) is None
True
This can be verified by :meth:`~sage.rings.lazy_series.is_nonzero()`,
Expand Down Expand Up @@ -1205,27 +1205,25 @@ class LazyLaurentSeriesRing(LazySeriesRing):
z^-1 - 1 + z - z^2 + z^3 - z^4 + z^5 + O(z^6)
sage: f2 = f * 2 # currently no coefficients computed
sage: f3 = f * 3 # currently no coefficients computed
sage: f2 == f3
Unknown
sage: (f2 == f3) is None
True
sage: f2 # computes some of the coefficients of f2
2*z^-1 - 2 + 2*z - 2*z^2 + 2*z^3 - 2*z^4 + 2*z^5 + O(z^6)
sage: f3 # computes some of the coefficients of f3
3*z^-1 - 3 + 3*z - 3*z^2 + 3*z^3 - 3*z^4 + 3*z^5 + O(z^6)
sage: f2 == f3
False
sage: f2a = f + f
sage: f2 == f2a
Unknown
sage: (f2 == f2a) is None
True
sage: zf = L(lambda n: 0, valuation=0)
sage: zf == 0
Unknown
sage: (zf == 0) is None
True
For boolean checks, an error is raised when it is not known to be nonzero::
sage: bool(zf)
Traceback (most recent call last):
...
UnknownError: undecidable
True
If the halting precision is set to a finite number `p` (for unlimited
precision, it is set to ``None``), then it will check up to `p` values
Expand Down

0 comments on commit 95bd489

Please sign in to comment.