From 0692cba65733f621970c497128f368aa4a1b5bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 10 Jan 2025 10:12:17 +0100 Subject: [PATCH 1/4] move krull_dimension to the category framework --- src/sage/categories/commutative_rings.py | 61 ++++++++++++++++++++++++ src/sage/categories/dedekind_domains.py | 24 ---------- src/sage/categories/fields.py | 12 +++++ src/sage/misc/functional.py | 9 +++- src/sage/rings/ring.pyx | 61 ------------------------ 5 files changed, 80 insertions(+), 87 deletions(-) diff --git a/src/sage/categories/commutative_rings.py b/src/sage/categories/commutative_rings.py index 6c47efacfe0..72d9e42c39a 100644 --- a/src/sage/categories/commutative_rings.py +++ b/src/sage/categories/commutative_rings.py @@ -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. = PolynomialRing(QQ,2); T + Multivariate Polynomial Ring in x, y over Rational Field + sage: T.krull_dimension() + 2 + sage: U. = 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. = 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. diff --git a/src/sage/categories/dedekind_domains.py b/src/sage/categories/dedekind_domains.py index ae4a198423b..3be25caea61 100644 --- a/src/sage/categories/dedekind_domains.py +++ b/src/sage/categories/dedekind_domains.py @@ -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. = PolynomialRing(QQ,2); T - Multivariate Polynomial Ring in x, y over Rational Field - sage: T.krull_dimension() - 2 - sage: U. = 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. = 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() diff --git a/src/sage/categories/fields.py b/src/sage/categories/fields.py index 98251904607..84450cca97b 100644 --- a/src/sage/categories/fields.py +++ b/src/sage/categories/fields.py @@ -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""" diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py index 4399007c91d..803535d2592 100644 --- a/src/sage/misc/functional.py +++ b/src/sage/misc/functional.py @@ -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']) @@ -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/44444 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. = PolynomialRing(ZZ, 3); U Multivariate Polynomial Ring in x, y, z over Integer Ring sage: U.krull_dimension() 4 """ + deprecation(44444, "please use the krull_dimension method") return x.krull_dimension() diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx index 0891853efba..66b5cd24b5c 100644 --- a/src/sage/rings/ring.pyx +++ b/src/sage/rings/ring.pyx @@ -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) - - - - - All orders in number fields have Krull dimension 1, including - non-maximal orders:: - - sage: # needs sage.rings.number_field - sage: K. = 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 @@ -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``. From 4002f278765926b8504ab416247520b4431f5702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 10 Jan 2025 10:14:49 +0100 Subject: [PATCH 2/4] fix deprecation number --- src/sage/misc/functional.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py index 803535d2592..40fc5630d40 100644 --- a/src/sage/misc/functional.py +++ b/src/sage/misc/functional.py @@ -921,7 +921,7 @@ def krull_dimension(x): sage: krull_dimension(QQ) doctest:warning...: DeprecationWarning: please use the krull_dimension method - See https://github.com/sagemath/sage/issues/44444 for details. + See https://github.com/sagemath/sage/issues/39311 for details. 0 sage: ZZ.krull_dimension() 1 @@ -932,7 +932,7 @@ def krull_dimension(x): sage: U.krull_dimension() 4 """ - deprecation(44444, "please use the krull_dimension method") + deprecation(39311, "please use the krull_dimension method") return x.krull_dimension() From 6f62d3dea1c213d924a2b057423a70b7b6c78e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 10 Jan 2025 10:27:24 +0100 Subject: [PATCH 3/4] fix doc --- src/sage/categories/commutative_rings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/categories/commutative_rings.py b/src/sage/categories/commutative_rings.py index 72d9e42c39a..0750edf50fa 100644 --- a/src/sage/categories/commutative_rings.py +++ b/src/sage/categories/commutative_rings.py @@ -60,7 +60,7 @@ def krull_dimension(self): 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:: + Orders in number fields also have Krull dimension 1. EXAMPLES: From 35251f2b59098f5aaa256df65bf2a23e9fa82f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 10 Jan 2025 13:18:46 +0100 Subject: [PATCH 4/4] fix doctest in src/doc --- src/doc/en/thematic_tutorials/coercion_and_categories.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst index 2339cc57f26..ff800007752 100644 --- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst +++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst @@ -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',