Skip to content

Commit

Permalink
Make category(GF(3)[x]) enumerated
Browse files Browse the repository at this point in the history
  • Loading branch information
user202729 committed Feb 3, 2025
1 parent 72cee9e commit 443dd01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/polynomial_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def __init__(self, base_ring, name=None, sparse=False, implementation=None,
and Category of commutative algebras over
(finite enumerated fields and subquotients of monoids
and quotients of semigroups)
and Category of infinite sets
and Category of infinite enumerated sets
TESTS:
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def __iter__(self):
sage: [*R]
[0]
sage: R.<x> = QQ[]
sage: list(islice(iter(R), 10))
sage: list(islice(iter(R), 10)) # when this is implemented add Enumerated() to category(R)
Traceback (most recent call last):
...
NotImplementedError: iteration over infinite base ring not yet implemented
Expand Down
16 changes: 16 additions & 0 deletions src/sage/rings/polynomial/polynomial_ring_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ def _multi_variate(base_ring, names, sparse=None, order='degrevlex', implementat
from sage import categories
from sage.categories.algebras import Algebras
# Some fixed categories, in order to avoid the function call overhead
_EnumeratedSets = categories.sets_cat.Sets().Enumerated()
_FiniteSets = categories.sets_cat.Sets().Finite()
_InfiniteSets = categories.sets_cat.Sets().Infinite()
_EuclideanDomains = categories.euclidean_domains.EuclideanDomains()
Expand Down Expand Up @@ -938,12 +939,27 @@ def polynomial_default_category(base_ring_category, n_variables):
True
sage: QQ['s']['t'].category() is UniqueFactorizationDomains() & CommutativeAlgebras(QQ['s'].category()).WithBasis().Infinite()
True
TESTS::
sage: category(GF(7)['x'])
Join of Category of euclidean domains
and Category of algebras with basis over
(finite enumerated fields and subquotients of monoids
and quotients of semigroups)
and Category of commutative algebras over
(finite enumerated fields and subquotients of monoids
and quotients of semigroups)
and Category of infinite enumerated sets
"""
category = Algebras(base_ring_category).WithBasis()

if n_variables:
# here we assume the base ring to be nonzero
category = category.Infinite()
if base_ring_category.is_subcategory(_FiniteSets) and n_variables == 1:
# base_ring_category.is_subcategory(_EnumeratedSets) suffices but this is not yet implemented
category = category.Enumerated()
else:
if base_ring_category.is_subcategory(_Fields):
category = category & _Fields
Expand Down

0 comments on commit 443dd01

Please sign in to comment.