Skip to content

Commit dbf5dac

Browse files
author
Release Manager
committed
gh-39115: first step of removal of IntegralDomain another good step towards the removal of the auld category `IntegralDomain` It seems reasonable to do this by chunks. ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. URL: #39115 Reported by: Frédéric Chapoton Reviewer(s): Martin Rubey
2 parents e2604e8 + 52bb268 commit dbf5dac

File tree

8 files changed

+60
-58
lines changed

8 files changed

+60
-58
lines changed

src/doc/en/thematic_tutorials/coercion_and_categories.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ This base class provides a lot more methods than a general parent::
133133
'is_commutative',
134134
'is_field',
135135
'krull_dimension',
136-
'localization',
137136
'ngens',
138137
'one',
139138
'order',

src/sage/categories/integral_domains.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,37 @@ def is_integral_domain(self, proof=True):
143143
"""
144144
return True
145145

146+
def is_field(self, proof=True):
147+
r"""
148+
Return ``True`` if this ring is a field.
149+
150+
EXAMPLES::
151+
152+
sage: ZZ['x'].is_field()
153+
False
154+
"""
155+
if self.is_finite():
156+
return True
157+
if proof:
158+
raise NotImplementedError(f"unable to determine whether or not {self} is a field.")
159+
return False
160+
161+
def localization(self, additional_units, names=None, normalize=True, category=None):
162+
"""
163+
Return the localization of ``self`` at the given additional units.
164+
165+
EXAMPLES::
166+
167+
sage: R.<x, y> = GF(3)[]
168+
sage: R.localization((x*y, x**2 + y**2)) # needs sage.rings.finite_rings
169+
Multivariate Polynomial Ring in x, y over Finite Field of size 3
170+
localized at (y, x, x^2 + y^2)
171+
sage: ~y in _ # needs sage.rings.finite_rings
172+
True
173+
"""
174+
from sage.rings.localization import Localization
175+
return Localization(self, additional_units, names=names, normalize=normalize, category=category)
176+
146177
def _test_fraction_field(self, **options):
147178
r"""
148179
Test that the fraction field, if it is implemented, works

src/sage/categories/rings.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,22 @@ def is_subring(self, other):
554554
except (TypeError, AttributeError):
555555
return False
556556

557+
def localization(self, *args, **kwds):
558+
"""
559+
Return the localization of ``self``.
560+
561+
This only works for integral domains.
562+
563+
EXAMPLES::
564+
565+
sage: R = Zmod(6)
566+
sage: R.localization((4))
567+
Traceback (most recent call last):
568+
...
569+
TypeError: self must be an integral domain
570+
"""
571+
raise TypeError("self must be an integral domain")
572+
557573
def bracket(self, x, y):
558574
"""
559575
Return the Lie bracket `[x, y] = x y - y x` of `x` and `y`.

src/sage/rings/abc.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Abstract base classes for rings
33
"""
4-
from sage.rings.ring import IntegralDomain
54

65

76
class NumberField_quadratic(Field):
@@ -419,7 +418,7 @@ class Order:
419418
pass
420419

421420

422-
class pAdicRing(IntegralDomain):
421+
class pAdicRing(CommutativeRing):
423422
r"""
424423
Abstract base class for :class:`~sage.rings.padics.generic_nodes.pAdicRingGeneric`.
425424

src/sage/rings/localization.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180

181181
from sage.structure.unique_representation import UniqueRepresentation
182182
from sage.categories.integral_domains import IntegralDomains
183-
from sage.rings.ring import IntegralDomain
183+
from sage.structure.parent import Parent
184184
from sage.structure.element import IntegralDomainElement
185185

186186

@@ -193,7 +193,7 @@ def normalize_extra_units(base_ring, add_units, warning=True):
193193
194194
INPUT:
195195
196-
- ``base_ring`` -- an instance of :class:`IntegralDomain`
196+
- ``base_ring`` -- a ring in the category of :class:`IntegralDomains`
197197
- ``add_units`` -- list of elements from base ring
198198
- ``warning`` -- boolean (default: ``True``); to suppress a warning which
199199
is thrown if no normalization was possible
@@ -561,7 +561,7 @@ def _integer_(self, Z=None):
561561
return self._value._integer_(Z=Z)
562562

563563

564-
class Localization(IntegralDomain, UniqueRepresentation):
564+
class Localization(Parent, UniqueRepresentation):
565565
r"""
566566
The localization generalizes the construction of the field of fractions of
567567
an integral domain to an arbitrary ring. Given a (not necessarily
@@ -580,21 +580,18 @@ class Localization(IntegralDomain, UniqueRepresentation):
580580
this class relies on the construction of the field of fraction and is
581581
therefore restricted to integral domains.
582582
583-
Accordingly, this class is inherited from :class:`IntegralDomain` and can
584-
only be used in that context. Furthermore, the base ring should support
583+
Accordingly, the base ring must be in the category of ``IntegralDomains``.
584+
Furthermore, the base ring should support
585585
:meth:`sage.structure.element.CommutativeRingElement.divides` and the exact
586586
division operator ``//`` (:meth:`sage.structure.element.Element.__floordiv__`)
587587
in order to guarantee a successful application.
588588
589589
INPUT:
590590
591-
- ``base_ring`` -- an instance of :class:`Ring` allowing the construction
592-
of :meth:`fraction_field` (that is an integral domain)
591+
- ``base_ring`` -- a ring in the category of ``IntegralDomains``
593592
- ``extra_units`` -- tuple of elements of ``base_ring`` which should be
594593
turned into units
595-
- ``names`` -- passed to :class:`IntegralDomain`
596-
- ``normalize`` -- boolean (default: ``True``); passed to :class:`IntegralDomain`
597-
- ``category`` -- (default: ``None``) passed to :class:`IntegralDomain`
594+
- ``category`` -- (default: ``None``) passed to :class:`Parent`
598595
- ``warning`` -- boolean (default: ``True``); to suppress a warning which
599596
is thrown if ``self`` cannot be represented uniquely
600597
@@ -712,7 +709,7 @@ def __init__(self, base_ring, extra_units, names=None, normalize=True, category=
712709
# since by construction the base ring must contain non units self must be infinite
713710
category = IntegralDomains().Infinite()
714711

715-
IntegralDomain.__init__(self, base_ring, names=names, normalize=normalize, category=category)
712+
Parent.__init__(self, base=base_ring, names=names, normalize=normalize, category=category)
716713
self._extra_units = tuple(extra_units)
717714
self._fraction_field = base_ring.fraction_field()
718715
self._populate_coercion_lists_()

src/sage/rings/number_field/number_field_base.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ cdef class NumberField(Field):
6565
+Infinity
6666
"""
6767
# This token docstring is mostly there to prevent Sphinx from pasting in
68-
# the docstring of the __init__ method inherited from IntegralDomain, which
68+
# the docstring of the __init__ method inherited from Field, which
6969
# is rather confusing.
7070
def _pushout_(self, other):
7171
r"""

src/sage/rings/power_series_ring.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,9 @@ def laurent_series_ring(self):
13231323
return self.__laurent_series_ring
13241324

13251325

1326-
class PowerSeriesRing_domain(PowerSeriesRing_generic, ring.IntegralDomain):
1326+
class PowerSeriesRing_domain(PowerSeriesRing_generic):
1327+
_default_category = _IntegralDomains
1328+
13271329
def fraction_field(self):
13281330
"""
13291331
Return the Laurent series ring over the fraction field of the base

src/sage/rings/ring.pyx

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -773,25 +773,6 @@ cdef class CommutativeRing(Ring):
773773
Ring.__init__(self, base_ring, names=names, normalize=normalize,
774774
category=category)
775775

776-
def localization(self, additional_units, names=None, normalize=True, category=None):
777-
"""
778-
Return the localization of ``self`` at the given additional units.
779-
780-
EXAMPLES::
781-
782-
sage: R.<x, y> = GF(3)[]
783-
sage: R.localization((x*y, x**2 + y**2)) # needs sage.rings.finite_rings
784-
Multivariate Polynomial Ring in x, y over Finite Field of size 3
785-
localized at (y, x, x^2 + y^2)
786-
sage: ~y in _ # needs sage.rings.finite_rings
787-
True
788-
"""
789-
if not self.is_integral_domain():
790-
raise TypeError("self must be an integral domain.")
791-
792-
from sage.rings.localization import Localization
793-
return Localization(self, additional_units, names=names, normalize=normalize, category=category)
794-
795776
def fraction_field(self):
796777
"""
797778
Return the fraction field of ``self``.
@@ -1018,29 +999,6 @@ cdef class IntegralDomain(CommutativeRing):
1018999
CommutativeRing.__init__(self, base_ring, names=names, normalize=normalize,
10191000
category=category)
10201001

1021-
def is_field(self, proof=True):
1022-
r"""
1023-
Return ``True`` if this ring is a field.
1024-
1025-
EXAMPLES::
1026-
1027-
sage: GF(7).is_field()
1028-
True
1029-
1030-
The following examples have their own ``is_field`` implementations::
1031-
1032-
sage: ZZ.is_field(); QQ.is_field()
1033-
False
1034-
True
1035-
sage: R.<x> = PolynomialRing(QQ); R.is_field()
1036-
False
1037-
"""
1038-
if self.is_finite():
1039-
return True
1040-
if proof:
1041-
raise NotImplementedError("unable to determine whether or not is a field.")
1042-
else:
1043-
return False
10441002

10451003
cdef class NoetherianRing(CommutativeRing):
10461004
_default_category = NoetherianRings()

0 commit comments

Comments
 (0)