Bases: sage.categories.category_singleton.Category_singleton
The category of (multiplicative) magmas.
A magma is a set with a binary operation .
EXAMPLES:
sage: Magmas()
Category of magmas
sage: Magmas().super_categories()
[Category of sets]
sage: Magmas().all_super_categories()
[Category of magmas, Category of sets,
Category of sets with partial maps, Category of objects]
The following axioms are defined by this category:
sage: Magmas().Associative()
Category of semigroups
sage: Magmas().Unital()
Category of unital magmas
sage: Magmas().Commutative()
Category of commutative magmas
sage: Magmas().Unital().Inverse()
Category of inverse unital magmas
sage: Magmas().Associative()
Category of semigroups
sage: Magmas().Associative().Unital()
Category of monoids
sage: Magmas().Associative().Unital().Inverse()
Category of groups
TESTS:
sage: C = Magmas()
sage: TestSuite(C).run()
Bases: sage.categories.algebra_functor.AlgebrasCategory
TESTS:
sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
... _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()
EXAMPLES:
sage: Magmas().Commutative().Algebras(QQ).extra_super_categories() [Category of commutative magmas]
This implements the fact that the algebra of a commutative magma is commutative:
sage: Magmas().Commutative().Algebras(QQ).super_categories()
[Category of magma algebras over Rational Field, Category of commutative magmas]
In particular, commutative monoid algebras are commutative algebras:
sage: Monoids().Commutative().Algebras(QQ).is_subcategory(Algebras(QQ).Commutative())
True
alias of Semigroups
Bases: sage.categories.cartesian_product.CartesianProductsCategory
TESTS:
sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
... _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()
EXAMPLES:
sage: C = Magmas().CartesianProducts().example(); C
The cartesian product of (Rational Field, Integer Ring, Integer Ring)
sage: x = C.an_element(); x
(1/2, 1, 1)
sage: x * x
(1/4, 1, 1)
sage: A = SymmetricGroupAlgebra(QQ, 3);
sage: x = cartesian_product([A([1,3,2]), A([2,3,1])])
sage: y = cartesian_product([A([1,3,2]), A([2,3,1])])
sage: cartesian_product([A,A]).product(x,y)
B[(0, [1, 2, 3])] + B[(1, [3, 1, 2])]
sage: x*y
B[(0, [1, 2, 3])] + B[(1, [3, 1, 2])]
Returns an example of cartesian product of magmas
EXAMPLES:
sage: C = Magmas().CartesianProducts().example(); C
The cartesian product of (Rational Field, Integer Ring, Integer Ring)
sage: C.category()
Join of Category of rings ...
sage: sorted(C.category().axioms())
['AdditiveAssociative', 'AdditiveCommutative', 'AdditiveInverse', 'AdditiveUnital', 'Associative', 'Distributive', 'Unital']
sage: TestSuite(C).run()
EXAMPLES:
sage: Semigroups().CartesianProducts().extra_super_categories()
[Category of semigroups]
sage: Semigroups().CartesianProducts().super_categories()
[Category of semigroups, Category of Cartesian products of magmas]
Bases: sage.categories.category_with_axiom.CategoryWithAxiom_singleton
TESTS:
sage: C = Sets.Finite(); C
Category of finite sets
sage: type(C)
<class 'sage.categories.finite_sets.FiniteSets_with_category'>
sage: type(C).__base__.__base__
<class 'sage.categories.category_with_axiom.CategoryWithAxiom_singleton'>
sage: TestSuite(C).run()
Bases: sage.categories.algebra_functor.AlgebrasCategory
TESTS:
sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
... _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()
EXAMPLES:
sage: Magmas().Commutative().Algebras(QQ).extra_super_categories() [Category of commutative magmas]
This implements the fact that the algebra of a commutative magma is commutative:
sage: Magmas().Commutative().Algebras(QQ).super_categories()
[Category of magma algebras over Rational Field,
Category of commutative magmas]
In particular, commutative monoid algebras are commutative algebras:
sage: Monoids().Commutative().Algebras(QQ).is_subcategory(Algebras(QQ).Commutative())
True
Test whether self is idempotent.
EXAMPLES:
sage: S = Semigroups().example("free"); S
An example of a semigroup: the free semigroup generated by ('a', 'b', 'c', 'd')
sage: a = S('a')
sage: a^2
'aa'
sage: a.is_idempotent()
False
sage: L = Semigroups().example("leftzero"); L
An example of a semigroup: the left zero semigroup
sage: x = L('x')
sage: x^2
'x'
sage: x.is_idempotent()
True
Returns a table describing the multiplication operation.
Note
The order of the elements in the row and column headings is equal to the order given by the table’s list() method. The association can also be retrieved with the dict() method.
INPUTS:
OUTPUT: The multiplication table as an object of the class OperationTable which defines several methods for manipulating and displaying the table. See the documentation there for full details to supplement the documentation here.
EXAMPLES:
The default is to represent elements as lowercase ASCII letters.
sage: G=CyclicPermutationGroup(5)
sage: G.multiplication_table()
* a b c d e
+----------
a| a b c d e
b| b c d e a
c| c d e a b
d| d e a b c
e| e a b c d
All that is required is that an algebraic structure has a multiplication defined. A LeftRegularBand is an example of a finite semigroup. The names argument allows displaying the elements in different ways.
sage: from sage.categories.examples.finite_semigroups import LeftRegularBand
sage: L=LeftRegularBand(('a','b'))
sage: T=L.multiplication_table(names='digits')
sage: T.column_keys()
('a', 'b', 'ab', 'ba')
sage: T
* 0 1 2 3
+--------
0| 0 2 2 2
1| 3 1 3 3
2| 2 2 2 2
3| 3 3 3 3
Specifying the elements in an alternative order can provide more insight into how the operation behaves.
sage: L=LeftRegularBand(('a','b','c'))
sage: elts = sorted(L.list())
sage: L.multiplication_table(elements=elts)
* a b c d e f g h i j k l m n o
+------------------------------
a| a b c d e b b c c c d d e e e
b| b b c c c b b c c c c c c c c
c| c c c c c c c c c c c c c c c
d| d e e d e e e e e e d d e e e
e| e e e e e e e e e e e e e e e
f| g g h h h f g h i j i j j i j
g| g g h h h g g h h h h h h h h
h| h h h h h h h h h h h h h h h
i| j j j j j i j j i j i j j i j
j| j j j j j j j j j j j j j j j
k| l m m l m n o o n o k l m n o
l| l m m l m m m m m m l l m m m
m| m m m m m m m m m m m m m m m
n| o o o o o n o o n o n o o n o
o| o o o o o o o o o o o o o o o
The elements argument can be used to provide a subset of the elements of the structure. The subset must be closed under the operation. Elements need only be in a form that can be coerced into the set. The names argument can also be used to request that the elements be represented with their usual string representation.
sage: L=LeftRegularBand(('a','b','c'))
sage: elts=['a', 'c', 'ac', 'ca']
sage: L.multiplication_table(names='elements', elements=elts)
* 'a' 'c' 'ac' 'ca'
+--------------------
'a'| 'a' 'ac' 'ac' 'ac'
'c'| 'ca' 'c' 'ca' 'ca'
'ac'| 'ac' 'ac' 'ac' 'ac'
'ca'| 'ca' 'ca' 'ca' 'ca'
The table returned can be manipulated in various ways. See the documentation for OperationTable for more comprehensive documentation.
sage: G=AlternatingGroup(3)
sage: T=G.multiplication_table()
sage: T.column_keys()
((), (1,2,3), (1,3,2))
sage: sorted(T.translation().items())
[('a', ()), ('b', (1,2,3)), ('c', (1,3,2))]
sage: T.change_names(['x', 'y', 'z'])
sage: sorted(T.translation().items())
[('x', ()), ('y', (1,2,3)), ('z', (1,3,2))]
sage: T
* x y z
+------
x| x y z
y| y z x
z| z x y
The binary multiplication of the magma.
INPUT:
OUTPUT:
EXAMPLES:
sage: S = Semigroups().example("free")
sage: x = S('a'); y = S('b')
sage: S.product(x, y)
'ab'
A parent in Magmas() must either implement product() in the parent class or _mul_ in the element class. By default, the addition method on elements x._mul_(y) calls S.product(x,y), and reciprocally.
As a bonus, S.product models the binary function from S to S:
sage: bin = S.product
sage: bin(x,y)
'ab'
Currently, S.product is just a bound method:
sage: bin
<bound method FreeSemigroup_with_category.product of An example of a semigroup: the free semigroup generated by ('a', 'b', 'c', 'd')>
When Sage will support multivariate morphisms, it will be possible, and in fact recommended, to enrich S.product with extra mathematical structure. This will typically be implemented using lazy attributes.:
sage: bin # todo: not implemented
Generic binary morphism:
From: (S x S)
To: S
The binary multiplication of the magma.
INPUT:
OUTPUT:
EXAMPLES:
sage: S = Semigroups().example("free")
sage: x = S('a'); y = S('b')
sage: S.product(x, y)
'ab'
A parent in Magmas() must either implement product() in the parent class or _mul_ in the element class. By default, the addition method on elements x._mul_(y) calls S.product(x,y), and reciprocally.
As a bonus, S.product models the binary function from S to S:
sage: bin = S.product
sage: bin(x,y)
'ab'
Currently, S.product is just a bound method:
sage: bin
<bound method FreeSemigroup_with_category.product of An example of a semigroup: the free semigroup generated by ('a', 'b', 'c', 'd')>
When Sage will support multivariate morphisms, it will be possible, and in fact recommended, to enrich S.product with extra mathematical structure. This will typically be implemented using lazy attributes.:
sage: bin # todo: not implemented
Generic binary morphism:
From: (S x S)
To: S
Bases: sage.categories.realizations.RealizationsCategory
TESTS:
sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
... _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()
Default implementation of product for realizations.
This method coerces to the realization specified by self.realization_of().a_realization(), computes the product in that realization, and then coerces back.
EXAMPLES:
sage: Out = Sets().WithRealizations().example().Out(); Out
The subset algebra of {1, 2, 3} over Rational Field in the Out basis
sage: Out.product
<bound method SubsetAlgebra.Out_with_category.product_by_coercion of The subset algebra of {1, 2, 3} over Rational Field in the Out basis>
sage: Out.product.__module__
'sage.categories.magmas'
sage: x = Out.an_element()
sage: y = Out.an_element()
sage: Out.product(x, y)
Out[{}] + 4*Out[{1}] + 9*Out[{2}] + Out[{1, 2}]
Return the full subcategory of the associative objects of self.
A (multiplicative) magma Magmas is
associative if, for all
,
EXAMPLES:
sage: Magmas().Associative()
Category of semigroups
TESTS:
sage: TestSuite(Magmas().Associative()).run()
sage: Rings().Associative.__module__
'sage.categories.magmas'
Return the full subcategory of the commutative objects of self.
A (multiplicative) magma Magmas is
commutative if, for all
,
EXAMPLES:
sage: Magmas().Commutative()
Category of commutative magmas
sage: Monoids().Commutative()
Category of commutative monoids
TESTS:
sage: TestSuite(Magmas().Commutative()).run()
sage: Rings().Commutative.__module__
'sage.categories.magmas'
Return the full subcategory of the objects of self
where is distributive on
.
INPUT:
Given that Sage does not yet know that the category MagmasAndAdditiveMagmas is the intersection of the categories Magmas and AdditiveMagmas, the method MagmasAndAdditiveMagmas.SubcategoryMethods.Distributive() is not available, as would be desirable, for this intersection.
This method is a workaround. It checks that self is a subcategory of both Magmas and AdditiveMagmas and upgrades it to a subcategory of MagmasAndAdditiveMagmas before applying the axiom. It complains overwise, since the Distributive axiom does not make sense for a plain magma.
EXAMPLES:
sage: (Magmas() & AdditiveMagmas()).Distributive()
Category of distributive magmas and additive magmas
sage: (Monoids() & CommutativeAdditiveGroups()).Distributive()
Category of rings
sage: Magmas().Distributive()
Traceback (most recent call last):
...
ValueError: The distributive axiom only makes sense on a magma which is simultaneously an additive magma
sage: Semigroups().Distributive()
Traceback (most recent call last):
...
ValueError: The distributive axiom only makes sense on a magma which is simultaneously an additive magma
TESTS:
sage: Semigroups().Distributive.__module__
'sage.categories.magmas'
sage: Rings().Distributive.__module__
'sage.categories.magmas_and_additive_magmas'
Return the subcategory of the unital objects of self.
A (multiplicative) magma Magmas is unital
if it admits an element
, called unit, such that for
all
,
This element is necessarily unique, and should be provided as M.one().
EXAMPLES:
sage: Magmas().Unital()
Category of unital magmas
sage: Semigroups().Unital()
Category of monoids
sage: Monoids().Unital()
Category of monoids
sage: from sage.categories.associative_algebras import AssociativeAlgebras
sage: AssociativeAlgebras(QQ).Unital()
Category of algebras over Rational Field
TESTS:
sage: TestSuite(Magmas().Unital()).run()
sage: Semigroups().Unital.__module__
'sage.categories.magmas'
Bases: sage.categories.subquotients.SubquotientsCategory
The category of subquotient magmas.
See Sets.SubcategoryMethods.Subquotients() for the
general setup for subquotients. In the case of a subquotient
magma of a magma
, the condition that
be a
morphism in As can be rewritten as follows:
- for any two
the identity
holds.
This is used by this category to implement the product
of
from
and
and the product of
.
EXAMPLES:
sage: Semigroups().Subquotients().all_super_categories()
[Category of subquotients of semigroups, Category of semigroups,
Category of subquotients of magmas, Category of magmas,
Category of subquotients of sets, Category of sets,
Category of sets with partial maps,
Category of objects]
Bases: sage.categories.category_with_axiom.CategoryWithAxiom_singleton
TESTS:
sage: C = Sets.Finite(); C
Category of finite sets
sage: type(C)
<class 'sage.categories.finite_sets.FiniteSets_with_category'>
sage: type(C).__base__.__base__
<class 'sage.categories.category_with_axiom.CategoryWithAxiom_singleton'>
sage: TestSuite(C).run()
Bases: sage.categories.algebra_functor.AlgebrasCategory
TESTS:
sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
... _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()
EXAMPLES:
sage: Magmas().Commutative().Algebras(QQ).extra_super_categories() [Category of commutative magmas]
This implements the fact that the algebra of a commutative magma is commutative:
sage: Magmas().Commutative().Algebras(QQ).super_categories()
[Category of magma algebras over Rational Field,
Category of commutative magmas]
In particular, commutative monoid algebras are commutative algebras:
sage: Monoids().Commutative().Algebras(QQ).is_subcategory(Algebras(QQ).Commutative())
True
Bases: sage.categories.cartesian_product.CartesianProductsCategory
TESTS:
sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
... _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()
Return the unit of this cartesian product.
It is built from the units for the cartesian factors of self.
EXAMPLES:
sage: cartesian_product([QQ, ZZ, RR]).one()
(1, 1, 1.00000000000000)
Implement the fact that a cartesian product of unital magmas is a unital magma
EXAMPLES:
sage: C = Magmas().Unital().CartesianProducts()
sage: C.extra_super_categories();
[Category of unital magmas]
sage: C.axioms()
frozenset(['Unital'])
sage: Monoids().CartesianProducts().is_subcategory(Monoids())
True
Bases: sage.categories.category_with_axiom.CategoryWithAxiom_singleton
TESTS:
sage: C = Sets.Finite(); C
Category of finite sets
sage: type(C)
<class 'sage.categories.finite_sets.FiniteSets_with_category'>
sage: type(C).__base__.__base__
<class 'sage.categories.category_with_axiom.CategoryWithAxiom_singleton'>
sage: TestSuite(C).run()
Bases: sage.categories.cartesian_product.CartesianProductsCategory
TESTS:
sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
... _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()
Implement the fact that a cartesian product of magmas with inverses is a magma with inverse.
EXAMPLES:
sage: C = Magmas().Unital().Inverse().CartesianProducts()
sage: C.extra_super_categories();
[Category of inverse unital magmas]
sage: sorted(C.axioms())
['Inverse', 'Unital']
Return the unit of the monoid, that is the unique neutral
element for .
Note
The default implementation is to coerce into self.
It is recommended to override this method because the
coercion from the integers:
- is not always meaningful (except for
);
- often uses self.one().
EXAMPLES:
sage: M = Monoids().example(); M
An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd')
sage: M.one()
''
Return the full subcategory of the inverse objects of self.
An inverse :class:` (multiplicative) magma <Magmas>` is a unital magma such that every element admits both an inverse on the left and on the right. Such a magma is also called a loop.
EXAMPLES:
sage: Magmas().Unital().Inverse()
Category of inverse unital magmas
sage: Monoids().Inverse()
Category of groups
TESTS:
sage: TestSuite(Magmas().Unital().Inverse()).run()
sage: Algebras(QQ).Inverse.__module__
'sage.categories.magmas'
EXAMPLES:
sage: Magmas().super_categories()
[Category of sets]