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

move krull_dimension to the category framework #39311

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',
'krull_dimension',
'ngens',
'one',
'order',
Expand Down
61 changes: 61 additions & 0 deletions src/sage/categories/commutative_rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,67 @@ class CommutativeRings(CategoryWithAxiom):
True
"""
class ParentMethods:
def krull_dimension(self):
"""
Return the Krull dimension of this commutative ring.

The Krull dimension is the length of the longest ascending chain
of prime ideals.

This raises :exc:`NotImplementedError` by default
for generic commutative rings.

Fields and PIDs, with Krull dimension equal to 0 and 1,
respectively, have naive implementations of ``krull_dimension``.
Orders in number fields also have Krull dimension 1.

EXAMPLES:

Some polynomial rings::

sage: T.<x,y> = PolynomialRing(QQ,2); T
Multivariate Polynomial Ring in x, y over Rational Field
sage: T.krull_dimension()
2
sage: U.<x,y,z> = PolynomialRing(ZZ,3); U
Multivariate Polynomial Ring in x, y, z over Integer Ring
sage: U.krull_dimension()
4

All orders in number fields have Krull dimension 1, including
non-maximal orders::

sage: # needs sage.rings.number_field
sage: K.<i> = QuadraticField(-1)
sage: R = K.order(2*i); R
Order of conductor 2 generated by 2*i
in Number Field in i with defining polynomial x^2 + 1 with i = 1*I
sage: R.is_maximal()
False
sage: R.krull_dimension()
1
sage: R = K.maximal_order(); R
Gaussian Integers generated by i in Number Field in i
with defining polynomial x^2 + 1 with i = 1*I
sage: R.krull_dimension()
1

TESTS::

sage: R = CommutativeRing(ZZ)
sage: R.krull_dimension()
Traceback (most recent call last):
...
NotImplementedError

sage: R = GF(9).galois_group().algebra(QQ)
sage: R.krull_dimension()
Traceback (most recent call last):
...
NotImplementedError
"""
raise NotImplementedError

def is_commutative(self) -> bool:
"""
Return whether the ring is commutative.
Expand Down
24 changes: 0 additions & 24 deletions src/sage/categories/dedekind_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,6 @@ def krull_dimension(self):
sage: OK = K.ring_of_integers() # needs sage.rings.number_field
sage: OK.krull_dimension() # needs sage.rings.number_field
1

The following are not Dedekind domains but have
a ``krull_dimension`` function::

sage: QQ.krull_dimension()
0
sage: T.<x,y> = PolynomialRing(QQ,2); T
Multivariate Polynomial Ring in x, y over Rational Field
sage: T.krull_dimension()
2
sage: U.<x,y,z> = PolynomialRing(ZZ,3); U
Multivariate Polynomial Ring in x, y, z over Integer Ring
sage: U.krull_dimension()
4

sage: # needs sage.rings.number_field
sage: K.<i> = QuadraticField(-1)
sage: R = K.order(2*i); R
Order of conductor 2 generated by 2*i
in Number Field in i with defining polynomial x^2 + 1 with i = 1*I
sage: R.is_maximal()
False
sage: R.krull_dimension()
1
"""
from sage.rings.integer_ring import ZZ
return ZZ.one()
Expand Down
12 changes: 12 additions & 0 deletions src/sage/categories/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ def _call_(self, x):
Finite = LazyImport('sage.categories.finite_fields', 'FiniteFields', at_startup=True)

class ParentMethods:
def krull_dimension(self):
"""
Return the Krull dimension of this field, which is 0.

EXAMPLES::

sage: QQ.krull_dimension()
0
sage: Frac(QQ['x,y']).krull_dimension()
0
"""
return 0

def is_field(self, proof=True):
r"""
Expand Down
9 changes: 7 additions & 2 deletions src/sage/misc/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import math

from sage.misc.lazy_import import lazy_import
from sage.misc.superseded import deprecation

lazy_import('sage.rings.complex_double', 'CDF')
lazy_import('sage.rings.real_double', ['RDF', 'RealDoubleElement'])
Expand Down Expand Up @@ -918,16 +919,20 @@ def krull_dimension(x):
EXAMPLES::

sage: krull_dimension(QQ)
doctest:warning...:
DeprecationWarning: please use the krull_dimension method
See https://github.com/sagemath/sage/issues/39311 for details.
0
sage: krull_dimension(ZZ)
sage: ZZ.krull_dimension()
1
sage: krull_dimension(ZZ[sqrt(5)]) # needs sage.rings.number_field sage.symbolic
sage: ZZ[sqrt(5)].krull_dimension() # needs sage.rings.number_field sage.symbolic
1
sage: U.<x,y,z> = PolynomialRing(ZZ, 3); U
Multivariate Polynomial Ring in x, y, z over Integer Ring
sage: U.krull_dimension()
4
"""
deprecation(39311, "please use the krull_dimension method")
return x.krull_dimension()


Expand Down
61 changes: 0 additions & 61 deletions src/sage/rings/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -847,54 +847,6 @@ cdef class CommutativeRing(Ring):
"""
return True

def krull_dimension(self):
"""
Return the Krull dimension of this commutative ring.

The Krull dimension is the length of the longest ascending chain
of prime ideals.

TESTS:

``krull_dimension`` is not implemented for generic commutative
rings. Fields and PIDs, with Krull dimension equal to 0 and 1,
respectively, have naive implementations of ``krull_dimension``.
Orders in number fields also have Krull dimension 1::

sage: R = CommutativeRing(ZZ)
sage: R.krull_dimension()
Traceback (most recent call last):
...
NotImplementedError
sage: QQ.krull_dimension()
0
sage: ZZ.krull_dimension()
1
sage: type(R); type(QQ); type(ZZ)
<class 'sage.rings.ring.CommutativeRing'>
<class 'sage.rings.rational_field.RationalField_with_category'>
<class 'sage.rings.integer_ring.IntegerRing_class'>

All orders in number fields have Krull dimension 1, including
non-maximal orders::

sage: # needs sage.rings.number_field
sage: K.<i> = QuadraticField(-1)
sage: R = K.maximal_order(); R
Gaussian Integers generated by i in Number Field in i
with defining polynomial x^2 + 1 with i = 1*I
sage: R.krull_dimension()
1
sage: R = K.order(2*i); R
Order of conductor 2 generated by 2*i in Number Field in i
with defining polynomial x^2 + 1 with i = 1*I
sage: R.is_maximal()
False
sage: R.krull_dimension()
1
"""
raise NotImplementedError

def extension(self, poly, name=None, names=None, **kwds):
"""
Algebraically extend ``self`` by taking the quotient
Expand Down Expand Up @@ -1116,19 +1068,6 @@ cdef class Field(CommutativeRing):
"""
return True

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

EXAMPLES::

sage: QQ.krull_dimension()
0
sage: Frac(QQ['x,y']).krull_dimension()
0
"""
return 0

def prime_subfield(self):
"""
Return the prime subfield of ``self``.
Expand Down
Loading