Skip to content
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

moving "is_integrally_closed" to the category setup. #38927

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
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
1 change: 0 additions & 1 deletion src/doc/en/thematic_tutorials/coercion_and_categories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ This base class provides a lot more methods than a general parent::
'integral_closure',
'is_commutative',
'is_field',
'is_integrally_closed',
'krull_dimension',
'localization',
'ngens',
Expand Down
11 changes: 7 additions & 4 deletions src/sage/categories/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,12 @@ def is_field(self, proof=True):
"""
return True

def is_integrally_closed(self):
def is_integrally_closed(self) -> bool:
r"""
Return ``True``, as per :meth:`IntegralDomain.is_integrally_closed`:
for every field `F`, `F` is its own field of fractions,
hence every element of `F` is integral over `F`.
Return whether ``self`` is integrally closed.

For every field `F`, `F` is its own field of fractions.
Therefore every element of `F` is integral over `F`.

EXAMPLES::

Expand All @@ -222,6 +223,8 @@ def is_integrally_closed(self):
Finite Field of size 5
sage: Z5.is_integrally_closed()
True
sage: Frac(ZZ['x,y']).is_integrally_closed()
True
"""
return True

Expand Down
21 changes: 21 additions & 0 deletions src/sage/categories/integral_domains.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# sage_setup: distribution = sagemath-categories
r"""
Integral domains

TEST:

A few tests for the method ``is_integrally_closed``::

sage: ZZ.is_integrally_closed()
True
sage: QQ.is_integrally_closed()
True
sage: QQbar.is_integrally_closed() # needs sage.rings.number_field
True
sage: GF(5).is_integrally_closed()
True
sage: Z5 = Integers(5); Z5
Ring of integers modulo 5
sage: Z5.is_integrally_closed()
Traceback (most recent call last):
...
NotImplementedError

Note that this raises a :exc:`NotImplementedError` if the answer is not known.
"""
# ****************************************************************************
# Copyright (C) 2008 Teresa Gomez-Diaz (CNRS) <[email protected]>
Expand Down
23 changes: 23 additions & 0 deletions src/sage/categories/rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,29 @@ def is_integral_domain(self, proof=True) -> bool:

return False

def is_integrally_closed(self) -> bool:
r"""
Return whether this ring is integrally closed.

This is the default implementation that
raises a :exc:`NotImplementedError`.

EXAMPLES::

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^2 + 189*x + 394)
sage: R = K.order(2*a)
sage: R.is_integrally_closed()
False
sage: R
Order of conductor 2 generated by 2*a in Number Field in a with defining polynomial x^2 + 189*x + 394
sage: S = K.maximal_order(); S
Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 189*x + 394
sage: S.is_integrally_closed()
True
"""
raise NotImplementedError

def is_noetherian(self):
"""
Return ``True`` if this ring is Noetherian.
Expand Down
16 changes: 0 additions & 16 deletions src/sage/rings/integer_ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1142,22 +1142,6 @@ cdef class IntegerRing_class(CommutativeRing):
"""
return 1

def is_integrally_closed(self):
"""
Return that the integer ring is, in fact, integrally closed.

.. NOTE::

This should rather be inherited from the category
of ``DedekindDomains``.

EXAMPLES::

sage: ZZ.is_integrally_closed()
True
"""
return True

def completion(self, p, prec, extras = {}):
r"""
Return the metric completion of the integers at the prime `p`.
Expand Down
6 changes: 4 additions & 2 deletions src/sage/rings/number_field/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,11 @@ def is_noetherian(self):
"""
return True

def is_integrally_closed(self):
def is_integrally_closed(self) -> bool:
r"""
Return ``True`` if this ring is integrally closed, i.e., is equal
Return whether this ring is integrally closed.

This is true if and only if it is equal
to the maximal order.

EXAMPLES::
Expand Down
43 changes: 0 additions & 43 deletions src/sage/rings/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1018,37 +1018,6 @@ cdef class IntegralDomain(CommutativeRing):
CommutativeRing.__init__(self, base_ring, names=names, normalize=normalize,
category=category)

def is_integrally_closed(self):
r"""
Return ``True`` if this ring is integrally closed in its field of
fractions; otherwise return ``False``.

When no algorithm is implemented for this, then this
function raises a :exc:`NotImplementedError`.

Note that ``is_integrally_closed`` has a naive implementation
in fields. For every field `F`, `F` is its own field of fractions,
hence every element of `F` is integral over `F`.

EXAMPLES::

sage: ZZ.is_integrally_closed()
True
sage: QQ.is_integrally_closed()
True
sage: QQbar.is_integrally_closed() # needs sage.rings.number_field
True
sage: GF(5).is_integrally_closed()
True
sage: Z5 = Integers(5); Z5
Ring of integers modulo 5
sage: Z5.is_integrally_closed()
Traceback (most recent call last):
...
AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
"""
raise NotImplementedError

def is_field(self, proof=True):
r"""
Return ``True`` if this ring is a field.
Expand Down Expand Up @@ -1228,18 +1197,6 @@ cdef class Field(CommutativeRing):
"""
return True

def is_integrally_closed(self):
"""
Return ``True`` since fields are trivially integrally closed in
their fraction field (since they are their own fraction field).

EXAMPLES::

sage: Frac(ZZ['x,y']).is_integrally_closed()
True
"""
return True

def krull_dimension(self):
"""
Return the Krull dimension of this field, which is 0.
Expand Down
Loading