Skip to content

get rid of CommutativeRing in p-adics #40160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/sage/rings/padics/local_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
from sage.rings.infinity import Infinity
from sage.rings.ring import CommutativeRing
from sage.structure.parent import Parent


class LocalGeneric(CommutativeRing):
class LocalGeneric(Parent):
def __init__(self, base, prec, names, element_class, category=None):
r"""
Initialize ``self``.
Expand Down Expand Up @@ -74,10 +74,10 @@ def __init__(self, base, prec, names, element_class, category=None):
category = category.Metric().Complete().Infinite()
if default_category is not None:
category = check_default_category(default_category, category)
CommutativeRing.__init__(self, base, names=(names,),
normalize=False, category=category)
Parent.__init__(self, base=base, names=(names,),
normalize=False, category=category)

def is_capped_relative(self):
def is_capped_relative(self) -> bool:
r"""
Return whether this `p`-adic ring bounds precision in a capped
relative fashion.
Expand All @@ -102,7 +102,7 @@ def is_capped_relative(self):
"""
return False

def is_capped_absolute(self):
def is_capped_absolute(self) -> bool:
r"""
Return whether this `p`-adic ring bounds precision in a
capped absolute fashion.
Expand All @@ -127,7 +127,7 @@ def is_capped_absolute(self):
"""
return False

def is_fixed_mod(self):
def is_fixed_mod(self) -> bool:
r"""
Return whether this `p`-adic ring bounds precision in a fixed
modulus fashion.
Expand All @@ -154,7 +154,7 @@ def is_fixed_mod(self):
"""
return False

def is_floating_point(self):
def is_floating_point(self) -> bool:
r"""
Return whether this `p`-adic ring bounds precision in a floating
point fashion.
Expand All @@ -179,7 +179,7 @@ def is_floating_point(self):
"""
return False

def is_lattice_prec(self):
def is_lattice_prec(self) -> bool:
r"""
Return whether this `p`-adic ring bounds precision using
a lattice model.
Expand Down Expand Up @@ -208,7 +208,7 @@ def is_lattice_prec(self):
"""
return False

def is_relaxed(self):
def is_relaxed(self) -> bool:
r"""
Return whether this `p`-adic ring bounds precision in a relaxed
fashion.
Expand All @@ -224,7 +224,7 @@ def is_relaxed(self):
"""
return False

def _latex_(self):
def _latex_(self) -> str:
r"""
Latex.

Expand Down
57 changes: 29 additions & 28 deletions src/sage/rings/padics/witt_vector_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************


from itertools import product
from typing import Iterator

from sage.categories.commutative_rings import CommutativeRings
from sage.categories.fields import Fields
Expand All @@ -42,15 +41,14 @@
from sage.rings.polynomial.polynomial_element import Polynomial
from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.ring import CommutativeRing
from sage.structure.parent import Parent
from sage.sets.primes import Primes
from sage.structure.unique_representation import UniqueRepresentation


def fast_char_p_power(x, n, p=None):
r"""
Return `x^n` assuming that `x` lives in a ring of
characteristic `p`.
Return `x^n` assuming that `x` lives in a ring of characteristic `p`.

If `x` is not an element of a ring of characteristic `p`,
this throws an error.
Expand Down Expand Up @@ -120,7 +118,7 @@ def fast_char_p_power(x, n, p=None):
return xn


class WittVectorRing(CommutativeRing, UniqueRepresentation):
class WittVectorRing(Parent, UniqueRepresentation):
r"""
Return the appropriate `p`-typical truncated Witt vector ring.

Expand Down Expand Up @@ -263,14 +261,13 @@ def __classcall_private__(cls, coefficient_ring, prec=1, p=None, algorithm=None)

return child.__classcall__(child, coefficient_ring, prec, p)

def __init__(self, coefficient_ring, prec, prime):
def __init__(self, coefficient_ring, prec, prime) -> None:
r"""
Initialises ``self``.
Initialise ``self``.

EXAMPLES::

sage: W = WittVectorRing(PolynomialRing(GF(5), 't'), prec=4)
sage: W
sage: W = WittVectorRing(PolynomialRing(GF(5), 't'), prec=4); W
Ring of truncated 5-typical Witt vectors of length 4 over Univariate Polynomial Ring in t over Finite Field of size 5
sage: type(W)
<class 'sage.rings.padics.witt_vector_ring.WittVectorRing_phantom_with_category'>
Expand All @@ -281,9 +278,10 @@ def __init__(self, coefficient_ring, prec, prime):
self._prec = prec
self._prime = prime

CommutativeRing.__init__(self, self)
Parent.__init__(self, base=coefficient_ring,
category=CommutativeRings())

def __iter__(self):
def __iter__(self) -> Iterator:
"""
Iterator for truncated Witt vector rings.

Expand Down Expand Up @@ -347,7 +345,7 @@ def _coerce_map_from_(self, S):
if (isinstance(S, WittVectorRing)
and S.precision() >= self._prec and S.prime() == self._prime
and self._coefficient_ring.has_coerce_map_from(
S.coefficient_ring())):
S.coefficient_ring())):
return (any(isinstance(S, rng) for rng in self._always_coerce)
or (S.precision() != self._prec
or S.coefficient_ring() is not self._coefficient_ring)
Expand All @@ -358,7 +356,7 @@ def _coerce_map_from_(self, S):

def _generate_sum_and_product_polynomials(self, coefficient_ring, prec, p):
"""
Generates the sum and product polynomials defining the ring laws of
Generate the sum and product polynomials defining the ring laws of
truncated Witt vectors for the ``standard`` algorithm.

EXAMPLES::
Expand Down Expand Up @@ -421,7 +419,7 @@ def _generate_sum_and_product_polynomials(self, coefficient_ring, prec, p):
self._sum_polynomials[n] = S(self._sum_polynomials[n])
self._prod_polynomials[n] = S(self._prod_polynomials[n])

def _latex_(self):
def _latex_(self) -> str:
r"""
Return a `\LaTeX` representation of ``self``.

Expand All @@ -439,7 +437,7 @@ def _latex_(self):
return "W_{%s}\\left(%s\\right)" % (latex(self._prec),
latex(self._coefficient_ring))

def _repr_(self):
def _repr_(self) -> str:
"""
Return a string representation of the ring.

Expand Down Expand Up @@ -498,7 +496,7 @@ def coefficient_ring(self):
"""
return self._coefficient_ring

def is_finite(self):
def is_finite(self) -> bool:
"""
Return whether ``self`` is a finite ring.

Expand Down Expand Up @@ -572,7 +570,9 @@ def prod_polynomials(self, variables=None):

def random_element(self, *args, **kwds):
"""
Return a random truncated Witt vector. Extra arguments are passed to
Return a random truncated Witt vector.

Extra arguments are passed to
the random generator of the coefficient ring.

EXAMPLES::
Expand Down Expand Up @@ -621,8 +621,9 @@ def sum_polynomials(self, variables=None):

def teichmuller_lift(self, x):
"""
Return the Teichmüller lift of ``x`` in ``self``. This lift is
sometimes known as the multiplicative lift of ``x``.
Return the Teichmüller lift of ``x`` in ``self``.

This lift is sometimes known as the multiplicative lift of ``x``.

EXAMPLES::

Expand Down Expand Up @@ -656,9 +657,9 @@ class WittVectorRing_finotti(WittVectorRing):
"""
Element = WittVector_finotti

def __init__(self, coefficient_ring, prec, prime):
def __init__(self, coefficient_ring, prec, prime) -> None:
r"""
Initialises ``self``.
Initialise ``self``.

EXAMPLES::

Expand Down Expand Up @@ -798,9 +799,9 @@ class WittVectorRing_phantom(WittVectorRing):
"""
Element = WittVector_phantom

def __init__(self, coefficient_ring, prec, prime):
def __init__(self, coefficient_ring, prec, prime) -> None:
r"""
Initialises ``self``.
Initialise ``self``.

EXAMPLES::

Expand Down Expand Up @@ -859,9 +860,9 @@ class WittVectorRing_pinvertible(WittVectorRing):
"""
Element = WittVector_pinvertible

def __init__(self, coefficient_ring, prec, prime):
def __init__(self, coefficient_ring, prec, prime) -> None:
r"""
Initialises ``self``.
Initialise ``self``.

EXAMPLES::

Expand Down Expand Up @@ -901,9 +902,9 @@ class WittVectorRing_standard(WittVectorRing):
"""
Element = WittVector_standard

def __init__(self, coefficient_ring, prec, prime):
def __init__(self, coefficient_ring, prec, prime) -> None:
r"""
Initialises ``self``.
Initialise ``self``.

EXAMPLES::

Expand Down
Loading