Skip to content

Commit

Permalink
sagemathgh-37719: Refactor ring categories
Browse files Browse the repository at this point in the history
    
A somewhat large refactoring of some of the auld classes for rings, and
related categories

- introducing a new category of Noetherian rings
- moving some methods in appropriate categories
- fixing necessary details

### 📝 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.
- [ ] I have updated the documentation accordingly.

Depends on sagemath#37778
    
URL: sagemath#37719
Reported by: Frédéric Chapoton
Reviewer(s): Matthias Köppe, Travis Scrimshaw
  • Loading branch information
Release Manager committed May 12, 2024
2 parents 595f826 + eb758e6 commit 3c2b482
Show file tree
Hide file tree
Showing 46 changed files with 653 additions and 525 deletions.
6 changes: 5 additions & 1 deletion pkgs/sagemath-categories/known-test-failures.json
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,10 @@
"failed": true,
"ntests": 126
},
"sage.categories.noetherian_rings": {
"failed": true,
"ntests": 19
},
"sage.categories.number_fields": {
"failed": true,
"ntests": 41
Expand Down Expand Up @@ -1428,4 +1432,4 @@
"sage.typeset.unicode_characters": {
"ntests": 27
}
}
}
9 changes: 3 additions & 6 deletions src/doc/en/thematic_tutorials/coercion_and_categories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ This base class provides a lot more methods than a general parent::
'_coerce_impl',
'_default_category',
'_gens',
'_ideal_class_',
'_ideal_monoid',
'_latex_names',
'_list',
Expand All @@ -127,24 +126,20 @@ This base class provides a lot more methods than a general parent::
'_zero_ideal',
'algebraic_closure',
'base_extend',
'class_group',
'content',
'derivation',
'derivation_module',
'divides',
'epsilon',
'extension',
'fraction_field',
'frobenius_endomorphism',
'gcd',
'gen',
'gens',
'ideal',
'ideal_monoid',
'integral_closure',
'is_commutative',
'is_field',
'is_integral_domain',
'is_integrally_closed',
'is_noetherian',
'is_prime_field',
Expand Down Expand Up @@ -858,7 +853,9 @@ The four axioms requested for coercions
rational field is a homomorphism of euclidean domains::

sage: QQ.coerce_map_from(ZZ).category_for()
Join of Category of euclidean domains and Category of infinite sets
Join of Category of euclidean domains
and Category of noetherian rings
and Category of infinite sets
and Category of metric spaces

.. end of output
Expand Down
1 change: 1 addition & 0 deletions src/doc/en/tutorial/tour_coercion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ implemented in Sage as well:
sage: ZZ.category()
Join of Category of Dedekind domains
and Category of euclidean domains
and Category of noetherian rings
and Category of infinite enumerated sets
and Category of metric spaces
sage: ZZ.category().is_subcategory(Rings())
Expand Down
1 change: 1 addition & 0 deletions src/doc/fr/tutorial/tour_coercion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ par ailleurs les catégories en tant que telles :
sage: ZZ.category()
Join of Category of Dedekind domains
and Category of euclidean domains
and Category of noetherian rings
and Category of infinite enumerated sets
and Category of metric spaces
sage: ZZ.category().is_subcategory(Rings())
Expand Down
1 change: 1 addition & 0 deletions src/doc/ja/tutorial/tour_coercion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Sageのクラス階層と圏の階層構造にはそれなりに類似が見ら
sage: ZZ.category()
Join of Category of Dedekind domains
and Category of euclidean domains
and Category of noetherian rings
and Category of infinite enumerated sets
and Category of metric spaces
sage: ZZ.category().is_subcategory(Rings())
Expand Down
1 change: 1 addition & 0 deletions src/doc/pt/tutorial/tour_coercion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ categorias matemáticas também são implementadas no Sage:
sage: ZZ.category()
Join of Category of Dedekind domains
and Category of euclidean domains
and Category of noetherian rings
and Category of infinite enumerated sets
and Category of metric spaces
sage: ZZ.category().is_subcategory(Rings())
Expand Down
3 changes: 3 additions & 0 deletions src/sage/algebras/clifford_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ def __init__(self, Q, names, category=None):
sage: Cl.category()
Category of finite dimensional super algebras with basis over
(Dedekind domains and euclidean domains
and noetherian rings
and infinite enumerated sets and metric spaces)
sage: TestSuite(Cl).run()
Expand Down Expand Up @@ -1093,6 +1094,7 @@ def lift_module_morphism(self, m, names=None):
sage: phi.category_for()
Category of finite dimensional super algebras with basis over
(Dedekind domains and euclidean domains
and noetherian rings
and infinite enumerated sets and metric spaces)
sage: phi.matrix()
[ 1 0 0 0 7 -3 -7 0]
Expand Down Expand Up @@ -1177,6 +1179,7 @@ def lift_isometry(self, m, names=None):
sage: phi.category_for()
Category of finite dimensional super algebras with basis over
(Dedekind domains and euclidean domains
and noetherian rings
and infinite enumerated sets and metric spaces)
sage: phi.matrix()
[ 1 0 0 0 1 2 5 0]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/quatalg/quaternion_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def is_integral_domain(self, proof=True) -> bool:

def is_noetherian(self) -> bool:
"""
Return ``True`` always, since any quaternion algebra is a noetherian
Return ``True`` always, since any quaternion algebra is a Noetherian
ring (because it is a finitely generated module over a field).
EXAMPLES::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/steenrod/steenrod_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3054,7 +3054,7 @@ def is_integral_domain(self, proof=True):

def is_noetherian(self):
"""
This algebra is noetherian if and only if it is finite.
This algebra is Noetherian if and only if it is finite.
EXAMPLES::
Expand Down
2 changes: 2 additions & 0 deletions src/sage/categories/bimodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def _make_named_class_key(self, name):
and Category of metric spaces,
Join of Category of Dedekind domains
and Category of euclidean domains
and Category of noetherian rings
and Category of infinite enumerated sets
and Category of metric spaces)
Expand All @@ -85,6 +86,7 @@ def _make_named_class_key(self, name):
(Category of fields,
Join of Category of Dedekind domains
and Category of euclidean domains
and Category of noetherian rings
and Category of infinite enumerated sets
and Category of metric spaces)
Expand Down
5 changes: 4 additions & 1 deletion src/sage/categories/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ def structure(self):
sage: structure(Rings())
(Category of unital magmas, Category of additive unital additive magmas)
sage: structure(Fields())
(Category of euclidean domains,)
(Category of euclidean domains, Category of noetherian rings)
sage: structure(Algebras(QQ))
(Category of unital magmas,
Category of right modules over Rational Field,
Expand Down Expand Up @@ -2840,6 +2840,7 @@ def _make_named_class_key(self, name):
sage: Algebras(ZZ)._make_named_class_key("parent_class")
Join of Category of Dedekind domains
and Category of euclidean domains
and Category of noetherian rings
and Category of infinite enumerated sets
and Category of metric spaces
Expand All @@ -2852,6 +2853,7 @@ def _make_named_class_key(self, name):
and Category of metric spaces,
Join of Category of Dedekind domains
and Category of euclidean domains
and Category of noetherian rings
and Category of infinite enumerated sets
and Category of metric spaces)
Expand Down Expand Up @@ -2979,6 +2981,7 @@ def _make_named_class_key(self, name):
sage: Modules(ZZ)._make_named_class_key('element_class')
Join of Category of Dedekind domains
and Category of euclidean domains
and Category of noetherian rings
and Category of infinite enumerated sets
and Category of metric spaces
sage: Modules(QQ)._make_named_class_key('parent_class')
Expand Down
3 changes: 2 additions & 1 deletion src/sage/categories/category_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ def _make_named_class_key(self, name):
sage: Modules(ZZ)._make_named_class_key('element_class')
Join of Category of Dedekind domains
and Category of euclidean domains
and Category of euclidean domains
and Category of noetherian rings
and Category of infinite enumerated sets
and Category of metric spaces
sage: Modules(QQ)._make_named_class_key('parent_class')
Expand Down
49 changes: 47 additions & 2 deletions src/sage/categories/commutative_rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,39 @@ def is_commutative(self) -> bool:
"""
return True

def _ideal_class_(self, n=0):
r"""
Return a callable object that can be used to create ideals in this
commutative ring.
This class can depend on `n`, the number of generators of the ideal.
The default input of `n=0` indicates an unspecified number of generators,
in which case a class that works for any number of generators is returned.
EXAMPLES::
sage: ZZ._ideal_class_()
<class 'sage.rings.ideal.Ideal_pid'>
sage: RR._ideal_class_()
<class 'sage.rings.ideal.Ideal_pid'>
sage: R.<x,y> = GF(5)[]
sage: R._ideal_class_(1)
<class 'sage.rings.polynomial.multi_polynomial_ideal.MPolynomialIdeal'>
sage: S = R.quo(x^3 - y^2)
sage: S._ideal_class_(1)
<class 'sage.rings.quotient_ring.QuotientRingIdeal_principal'>
sage: S._ideal_class_(2)
<class 'sage.rings.quotient_ring.QuotientRingIdeal_generic'>
sage: T.<z> = S[] # needs sage.libs.singular
sage: T._ideal_class_(5) # needs sage.libs.singular
<class 'sage.rings.ideal.Ideal_generic'>
sage: T._ideal_class_(1) # needs sage.libs.singular
<class 'sage.rings.ideal.Ideal_principal'>
"""
# One might need more than just n
from sage.rings.ideal import Ideal_generic, Ideal_principal
return Ideal_principal if n == 1 else Ideal_generic

def _test_divides(self, **options):
r"""
Run generic tests on the method :meth:`divides`.
Expand Down Expand Up @@ -248,6 +281,18 @@ class Finite(CategoryWithAxiom):
....: GF(5)]) in Rings().Commutative().Finite()
True
"""
def extra_super_categories(self):
r"""
Let Sage know that finite commutative rings are Noetherian.
EXAMPLES::
sage: CommutativeRings().Finite().extra_super_categories()
[Category of noetherian rings]
"""
from sage.categories.noetherian_rings import NoetherianRings
return [NoetherianRings()]

class ParentMethods:
def cyclotomic_cosets(self, q, cosets=None):
r"""
Expand Down Expand Up @@ -367,7 +412,7 @@ def cyclotomic_cosets(self, q, cosets=None):
try:
~q
except ZeroDivisionError:
raise ValueError("%s is not invertible in %s" % (q,self))
raise ValueError("%s is not invertible in %s" % (q, self))

if cosets is None:
rest = set(self)
Expand All @@ -378,7 +423,7 @@ def cyclotomic_cosets(self, q, cosets=None):
while rest:
x0 = rest.pop()
o = [x0]
x = q*x0
x = q * x0
while x != x0:
o.append(x)
rest.discard(x)
Expand Down
14 changes: 9 additions & 5 deletions src/sage/categories/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from sage.categories.category_singleton import Category_contains_method_by_parent_class
from sage.categories.euclidean_domains import EuclideanDomains
from sage.categories.division_rings import DivisionRings
from sage.categories.noetherian_rings import NoetherianRings

from sage.structure.element import coerce_binop

Expand All @@ -33,7 +34,9 @@ class Fields(CategoryWithAxiom):
sage: K
Category of fields
sage: Fields().super_categories()
[Category of euclidean domains, Category of division rings]
[Category of euclidean domains,
Category of division rings,
Category of noetherian rings]
sage: K(IntegerRing())
Rational Field
Expand All @@ -54,10 +57,9 @@ def extra_super_categories(self):
EXAMPLES::
sage: Fields().extra_super_categories()
[Category of euclidean domains]
[Category of euclidean domains, Category of noetherian rings]
"""
return [EuclideanDomains()]
return [EuclideanDomains(), NoetherianRings()]

def __contains__(self, x):
"""
Expand Down Expand Up @@ -165,7 +167,9 @@ def _call_(self, x):
sage: K
Category of fields
sage: Fields().super_categories()
[Category of euclidean domains, Category of division rings]
[Category of euclidean domains,
Category of division rings,
Category of noetherian rings]
sage: K(IntegerRing()) # indirect doctest
Rational Field
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/group_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def is_integral_domain(self, proof=True):
return ans

# I haven't written is_noetherian(), because I don't know when group
# algebras are noetherian, and I haven't written is_prime_field(), because
# algebras are Noetherian, and I haven't written is_prime_field(), because
# I don't know if that means "is canonically isomorphic to a prime field"
# or "is identical to a prime field".

Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ def reversed(self):
the principal ideal domain Integer Ring to Ambient free module
of rank 3 over the principal ideal domain Integer Ring in
Category of finite dimensional modules with basis over (Dedekind
domains and euclidean domains
domains and euclidean domains and noetherian rings
and infinite enumerated sets and metric spaces)
sage: type(H)
<class 'sage.modules.free_module_homspace.FreeModuleHomspace_with_category'>
Expand All @@ -1254,7 +1254,7 @@ def reversed(self):
the principal ideal domain Integer Ring to Ambient free module
of rank 2 over the principal ideal domain Integer Ring in
Category of finite dimensional modules with basis over (Dedekind
domains and euclidean domains
domains and euclidean domains and noetherian rings
and infinite enumerated sets and metric spaces)
sage: type(H.reversed())
<class 'sage.modules.free_module_homspace.FreeModuleHomspace_with_category'>
Expand Down
5 changes: 5 additions & 0 deletions src/sage/categories/integral_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def is_integral_domain(self, proof=True):
EXAMPLES::
sage: ZZ.is_integral_domain()
True
sage: QQ.is_integral_domain()
True
sage: Parent(QQ, category=IntegralDomains()).is_integral_domain()
Expand All @@ -113,6 +115,9 @@ def is_integral_domain(self, proof=True):
True
sage: L.is_integral_domain(proof=True) # needs sage.combinat
True
sage: ZZ['x'].is_integral_domain()
True
"""
return True

Expand Down
3 changes: 2 additions & 1 deletion src/sage/categories/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,8 @@ def __init_extra__(self):
sage: M.category() # needs sage.modules
Category of Cartesian products of modules with basis
over (Dedekind domains and euclidean domains
and infinite enumerated sets and metric spaces)
and noetherian rings
and infinite enumerated sets and metric spaces)
sage: M.base_ring() # needs sage.modules
Integer Ring
Expand Down
7 changes: 5 additions & 2 deletions src/sage/categories/morphism.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,12 @@ cdef class Morphism(Map):
sage: f.category()
Category of endsets of unital magmas and right modules over
(Dedekind domains and euclidean domains
and noetherian rings
and infinite enumerated sets and metric spaces)
and left modules over
(Dedekind domains and euclidean domains
and noetherian rings
and infinite enumerated sets and metric spaces)
and left modules over (Dedekind domains and euclidean domains
and infinite enumerated sets and metric spaces)
sage: # needs sage.rings.number_field
sage: K = CyclotomicField(12)
Expand Down
Loading

0 comments on commit 3c2b482

Please sign in to comment.