Skip to content

Commit 4922c8c

Browse files
Release Managervbraun
Release Manager
authored andcommitted
Trac #17160: Finitely generated axiom for (mutiplicative) magmas, semigroups, monoids, groups
This introduce an axiom FinitelyGeneratedAsMagma, as well as related categories with axioms for magmas, semigroups and groups:: {{{ sage: Groups().FinitelyGeneratedAsMagma() Category of finitely generated groups }}} For ease of notations, when there is no ambiguity, one can do:: {{{ sage: Groups().FinitelyGenerated() Category of finitely generated groups }}} One motivation for this change (for #8678) is that finite semigroups in Sage used to be automatically endowed with an `EnumeratedSets` structure; the default enumeration is then obtained by iteratively multiplying the semigroup generators. This forced any finite semigroup to either implement an enumeration, or provide semigroup generators; this was often inconvenient. Instead, finite semigroups that provide a distinguished finite set of generators with `semigroup_generators` should now explicitly declare themselves in the category of `FinitelyGeneratedSemigroups`: {{{ sage: Semigroups().FinitelyGenerated() Category of finitely generated semigroups }}} This is a backward incompatible change. TODO: - Use the occasion to migrate TransitiveIdeal to RecursivelyEnumeratedSet URL: http://trac.sagemath.org/17160 Reported by: nthiery Ticket author(s): Nicolas M. Thiéry Reviewer(s): Travis Scrimshaw
2 parents 8019549 + 19ceb81 commit 4922c8c

24 files changed

+545
-218
lines changed

src/doc/en/thematic_tutorials/coercion_and_categories.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ And indeed, ``MS2`` has *more* methods than ``MS1``::
461461
sage: len([s for s in dir(MS1) if inspect.ismethod(getattr(MS1,s,None))])
462462
57
463463
sage: len([s for s in dir(MS2) if inspect.ismethod(getattr(MS2,s,None))])
464-
82
464+
83
465465

466466
This is because the class of ``MS2`` also inherits from the parent
467467
class for algebras::

src/sage/categories/category.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2625,7 +2625,7 @@ def category_graph(categories = None):
26252625
Graphics object consisting of 20 graphics primitives
26262626
26272627
sage: sage.categories.category.category_graph().plot()
2628-
Graphics object consisting of 310 graphics primitives
2628+
Graphics object consisting of ... graphics primitives
26292629
"""
26302630
from sage import graphs
26312631
if categories is None:

src/sage/categories/category_with_axiom.py

+27-16
Original file line numberDiff line numberDiff line change
@@ -1675,13 +1675,14 @@ class ``Sets.Finite``), or in a separate file (typically in a class
16751675

16761676
all_axioms = AxiomContainer()
16771677
all_axioms += ("Flying", "Blue",
1678-
"Facade", "Finite", "Infinite",
1679-
"FiniteDimensional", "Connected", "WithBasis",
1680-
"Irreducible",
1681-
"Commutative", "Associative", "Inverse", "Unital", "Division", "NoZeroDivisors",
1682-
"AdditiveCommutative", "AdditiveAssociative", "AdditiveInverse", "AdditiveUnital",
1683-
"Distributive",
1684-
"Endset"
1678+
"FinitelyGeneratedAsMagma",
1679+
"Facade", "Finite", "Infinite",
1680+
"FiniteDimensional", "Connected", "WithBasis",
1681+
"Irreducible",
1682+
"Commutative", "Associative", "Inverse", "Unital", "Division", "NoZeroDivisors",
1683+
"AdditiveCommutative", "AdditiveAssociative", "AdditiveInverse", "AdditiveUnital",
1684+
"Distributive",
1685+
"Endset"
16851686
)
16861687

16871688
def uncamelcase(s,separator=" "):
@@ -2129,25 +2130,27 @@ def super_categories(self):
21292130
``self``, as per :meth:`Category.super_categories`.
21302131
21312132
This implements the property that if ``As`` is a subcategory
2132-
of ``Bs``, then the intersection of As with ``FiniteSets()``
2133+
of ``Bs``, then the intersection of ``As`` with ``FiniteSets()``
21332134
is a subcategory of ``As`` and of the intersection of ``Bs``
21342135
with ``FiniteSets()``.
21352136
2136-
EXAMPLES::
2137-
2138-
sage: FiniteSets().super_categories()
2139-
[Category of sets]
2140-
2141-
sage: FiniteSemigroups().super_categories()
2142-
[Category of semigroups, Category of finite enumerated sets]
2143-
21442137
EXAMPLES:
21452138
21462139
A finite magma is both a magma and a finite set::
21472140
21482141
sage: Magmas().Finite().super_categories()
21492142
[Category of magmas, Category of finite sets]
21502143
2144+
Variants::
2145+
2146+
sage: Sets().Finite().super_categories()
2147+
[Category of sets]
2148+
2149+
sage: Monoids().Finite().super_categories()
2150+
[Category of monoids, Category of finite semigroups]
2151+
2152+
EXAMPLES:
2153+
21512154
TESTS::
21522155
21532156
sage: from sage.categories.category_with_axiom import TestObjects
@@ -2232,7 +2235,12 @@ def _repr_object_names_static(category, axioms):
22322235
sage: from sage.categories.homsets import Homsets
22332236
sage: CategoryWithAxiom._repr_object_names_static(Homsets(), ["Endset"])
22342237
'endsets'
2238+
sage: CategoryWithAxiom._repr_object_names_static(PermutationGroups(), ["FinitelyGeneratedAsMagma"])
2239+
'finitely generated permutation groups'
2240+
sage: CategoryWithAxiom._repr_object_names_static(Rings(), ["FinitelyGeneratedAsMagma"])
2241+
'finitely generated as magma rings'
22352242
"""
2243+
from sage.categories.additive_magmas import AdditiveMagmas
22362244
axioms = canonicalize_axioms(all_axioms,axioms)
22372245
base_category = category._without_axioms(named=True)
22382246
if isinstance(base_category, CategoryWithAxiom): # Smelly runtime type checking
@@ -2254,6 +2262,9 @@ def _repr_object_names_static(category, axioms):
22542262
elif axiom == "Endset" and "homsets" in result:
22552263
# Without the space at the end to handle Homsets().Endset()
22562264
result = result.replace("homsets", "endsets", 1)
2265+
elif axiom == "FinitelyGeneratedAsMagma" and \
2266+
not base_category.is_subcategory(AdditiveMagmas()):
2267+
result = "finitely generated " + result
22572268
else:
22582269
result = uncamelcase(axiom) + " " + result
22592270
return result

src/sage/categories/coxeter_groups.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CoxeterGroups(Category_singleton):
3939
sage: C = CoxeterGroups(); C
4040
Category of coxeter groups
4141
sage: C.super_categories()
42-
[Category of groups, Category of enumerated sets]
42+
[Category of finitely generated groups]
4343
4444
sage: W = C.example(); W
4545
The symmetric group on {0, ..., 3}
@@ -117,9 +117,9 @@ def super_categories(self):
117117
EXAMPLES::
118118
119119
sage: CoxeterGroups().super_categories()
120-
[Category of groups, Category of enumerated sets]
120+
[Category of finitely generated groups]
121121
"""
122-
return [Groups(), EnumeratedSets()]
122+
return [Groups().FinitelyGenerated()]
123123

124124
Finite = LazyImport('sage.categories.finite_coxeter_groups', 'FiniteCoxeterGroups')
125125
Algebras = LazyImport('sage.categories.coxeter_group_algebras', 'CoxeterGroupAlgebras')

src/sage/categories/examples/finite_monoids.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from sage.structure.parent import Parent
1414
from sage.structure.unique_representation import UniqueRepresentation
1515
from sage.structure.element_wrapper import ElementWrapper
16-
from sage.categories.all import FiniteMonoids
16+
from sage.categories.all import Monoids
1717
from sage.rings.integer import Integer
1818
from sage.rings.integer_ring import ZZ
1919

@@ -29,7 +29,7 @@ class IntegerModMonoid(UniqueRepresentation, Parent):
2929
An example of a finite multiplicative monoid: the integers modulo 12
3030
3131
sage: S.category()
32-
Category of finite monoids
32+
Category of finitely generated finite monoids
3333
3434
We conclude by running systematic tests on this monoid::
3535
@@ -72,7 +72,7 @@ def __init__(self, n = 12):
7272
7373
"""
7474
self.n = n
75-
Parent.__init__(self, category = FiniteMonoids())
75+
Parent.__init__(self, category = Monoids().Finite().FinitelyGenerated())
7676

7777
def _repr_(self):
7878
r"""

src/sage/categories/examples/finite_semigroups.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from sage.misc.cachefunc import cached_method
1212
from sage.sets.family import Family
13-
from sage.categories.all import FiniteSemigroups
13+
from sage.categories.semigroups import Semigroups
1414
from sage.structure.parent import Parent
1515
from sage.structure.unique_representation import UniqueRepresentation
1616
from sage.structure.element_wrapper import ElementWrapper
@@ -114,7 +114,7 @@ def __init__(self, alphabet=('a','b','c','d')):
114114
sage: TestSuite(S).run()
115115
"""
116116
self.alphabet = alphabet
117-
Parent.__init__(self, category = FiniteSemigroups())
117+
Parent.__init__(self, category = Semigroups().Finite().FinitelyGenerated())
118118

119119
def _repr_(self):
120120
r"""

src/sage/categories/examples/semigroups.py

+2-20
Original file line numberDiff line numberDiff line change
@@ -173,25 +173,7 @@ class FreeSemigroup(UniqueRepresentation, Parent):
173173
174174
TESTS::
175175
176-
sage: TestSuite(S).run(verbose = True)
177-
running ._test_an_element() . . . pass
178-
running ._test_associativity() . . . pass
179-
running ._test_category() . . . pass
180-
running ._test_elements() . . .
181-
Running the test suite of self.an_element()
182-
running ._test_category() . . . pass
183-
running ._test_eq() . . . pass
184-
running ._test_not_implemented_methods() . . . pass
185-
running ._test_pickling() . . . pass
186-
pass
187-
running ._test_elements_eq_reflexive() . . . pass
188-
running ._test_elements_eq_symmetric() . . . pass
189-
running ._test_elements_eq_transitive() . . . pass
190-
running ._test_elements_neq() . . . pass
191-
running ._test_eq() . . . pass
192-
running ._test_not_implemented_methods() . . . pass
193-
running ._test_pickling() . . . pass
194-
running ._test_some_elements() . . . pass
176+
sage: TestSuite(S).run()
195177
"""
196178
def __init__(self, alphabet=('a','b','c','d')):
197179
r"""
@@ -214,7 +196,7 @@ def __init__(self, alphabet=('a','b','c','d')):
214196
215197
"""
216198
self.alphabet = alphabet
217-
Parent.__init__(self, category = Semigroups())
199+
Parent.__init__(self, category = Semigroups().FinitelyGenerated())
218200

219201
def _repr_(self):
220202
r"""

src/sage/categories/finite_coxeter_groups.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class FiniteCoxeterGroups(CategoryWithAxiom):
2323
sage: FiniteCoxeterGroups()
2424
Category of finite coxeter groups
2525
sage: FiniteCoxeterGroups().super_categories()
26-
[Category of finite groups, Category of coxeter groups]
26+
[Category of coxeter groups,
27+
Category of finite groups,
28+
Category of finite finitely generated semigroups]
2729
2830
sage: G = FiniteCoxeterGroups().example()
2931
sage: G.cayley_graph(side = "right").plot()

src/sage/categories/finite_fields.py

+22-6
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,24 @@
1212
#******************************************************************************
1313

1414
from sage.categories.category_with_axiom import CategoryWithAxiom
15+
from sage.categories.enumerated_sets import EnumeratedSets
1516

1617
class FiniteFields(CategoryWithAxiom):
1718
"""
1819
The category of finite fields.
1920
2021
EXAMPLES::
2122
22-
sage: K = FiniteFields()
23-
sage: K
23+
sage: K = FiniteFields(); K
2424
Category of finite fields
2525
26-
A finite field is a finite monoid with the structure of a field::
26+
A finite field is a finite monoid with the structure of a field;
27+
it is currently assumed to be enumerated::
2728
2829
sage: K.super_categories()
29-
[Category of fields, Category of finite commutative rings]
30+
[Category of fields,
31+
Category of finite commutative rings,
32+
Category of finite enumerated sets]
3033
3134
Some examples of membership testing and coercion::
3235
@@ -41,11 +44,24 @@ class FiniteFields(CategoryWithAxiom):
4144
4245
TESTS::
4346
44-
sage: TestSuite(FiniteFields()).run()
45-
sage: FiniteFields().is_subcategory(FiniteEnumeratedSets())
47+
sage: K is Fields().Finite()
4648
True
49+
sage: TestSuite(K).run()
4750
"""
4851

52+
def extra_super_categories(self):
53+
r"""
54+
Any finite field is assumed to be endowed with an enumeration.
55+
56+
TESTS::
57+
58+
sage: Fields().Finite().extra_super_categories()
59+
[Category of finite enumerated sets]
60+
sage: FiniteFields().is_subcategory(FiniteEnumeratedSets())
61+
True
62+
"""
63+
return [EnumeratedSets().Finite()]
64+
4965
def __contains__(self, x):
5066
"""
5167
EXAMPLES::

src/sage/categories/finite_permutation_groups.py

+26-5
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,36 @@
99
# http://www.gnu.org/licenses/
1010
#******************************************************************************
1111

12+
from sage.categories.magmas import Magmas
1213
from sage.categories.category_with_axiom import CategoryWithAxiom
14+
from sage.categories.permutation_groups import PermutationGroups
1315

1416
class FinitePermutationGroups(CategoryWithAxiom):
1517
r"""
1618
The category of finite permutation groups, i.e. groups concretely
1719
represented as groups of permutations acting on a finite set.
1820
21+
It is currently assumed that any finite permutation group comes
22+
endowed with a distinguished finite set of generators (method
23+
``group_generators``); this is the case for all the existing
24+
implementations in Sage.
25+
1926
EXAMPLES::
2027
21-
sage: FinitePermutationGroups()
28+
sage: C = PermutationGroups().Finite(); C
2229
Category of finite permutation groups
23-
sage: FinitePermutationGroups().super_categories()
24-
[Category of permutation groups, Category of finite groups]
30+
sage: C.super_categories()
31+
[Category of permutation groups,
32+
Category of finite groups,
33+
Category of finite finitely generated semigroups]
2534
26-
sage: FinitePermutationGroups().example()
35+
sage: C.example()
2736
Dihedral group of order 6 as a permutation group
2837
2938
TESTS::
3039
31-
sage: C = FinitePermutationGroups()
40+
sage: C is FinitePermutationGroups()
41+
True
3242
sage: TestSuite(C).run()
3343
3444
sage: G = FinitePermutationGroups().example()
@@ -72,6 +82,17 @@ def example(self):
7282
from sage.groups.perm_gps.permgroup_named import DihedralGroup
7383
return DihedralGroup(3)
7484

85+
def extra_super_categories(self):
86+
"""
87+
Any permutation group is assumed to be endowed with a finite set of generators.
88+
89+
TESTS:
90+
91+
sage: PermutationGroups().Finite().extra_super_categories()
92+
[Category of finitely generated magmas]
93+
"""
94+
return [Magmas().FinitelyGenerated()]
95+
7596
class ParentMethods:
7697
# TODO
7798
# - Port features from MuPAD-Combinat, lib/DOMAINS/CATEGORIES/PermutationGroup.mu

0 commit comments

Comments
 (0)