Magmas

class sage.categories.magmas.Magmas[source]

Bases: 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]
>>> from sage.all import *
>>> Magmas()
Category of magmas
>>> Magmas().super_categories()
[Category of sets]
>>> 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
>>> from sage.all import *
>>> Magmas().Associative()
Category of semigroups
>>> Magmas().Unital()
Category of unital magmas
>>> Magmas().Commutative()
Category of commutative magmas
>>> Magmas().Unital().Inverse()
Category of inverse unital magmas
>>> Magmas().Associative()
Category of semigroups
>>> Magmas().Associative().Unital()
Category of monoids
>>> Magmas().Associative().Unital().Inverse()
Category of groups
class Algebras(category, *args)[source]

Bases: AlgebrasCategory

class ParentMethods[source]

Bases: object

is_field(proof=True)[source]

Return True if self is a field.

For a magma algebra \(RS\) this is always false unless \(S\) is trivial and the base ring \(R\) is a field.

EXAMPLES:

sage: SymmetricGroup(1).algebra(QQ).is_field()                      # needs sage.combinat sage.groups
True
sage: SymmetricGroup(1).algebra(ZZ).is_field()                      # needs sage.combinat sage.groups
False
sage: SymmetricGroup(2).algebra(QQ).is_field()                      # needs sage.combinat sage.groups
False
>>> from sage.all import *
>>> SymmetricGroup(Integer(1)).algebra(QQ).is_field()                      # needs sage.combinat sage.groups
True
>>> SymmetricGroup(Integer(1)).algebra(ZZ).is_field()                      # needs sage.combinat sage.groups
False
>>> SymmetricGroup(Integer(2)).algebra(QQ).is_field()                      # needs sage.combinat sage.groups
False
extra_super_categories()[source]

EXAMPLES:

sage: MCA = Magmas().Commutative().Algebras(QQ)
sage: MCA.extra_super_categories()
[Category of commutative magmas]
>>> from sage.all import *
>>> MCA = Magmas().Commutative().Algebras(QQ)
>>> MCA.extra_super_categories()
[Category of commutative magmas]

This implements the fact that the algebra of a commutative magma is commutative:

sage: MCA.super_categories()
[Category of magma algebras over Rational Field,
 Category of commutative magmas]
>>> from sage.all import *
>>> MCA.super_categories()
[Category of magma algebras over Rational Field,
 Category of commutative magmas]

In particular, commutative monoid algebras are commutative algebras:

sage: MoCA = Monoids().Commutative().Algebras(QQ)
sage: MoCA.is_subcategory(Algebras(QQ).Commutative())
True
>>> from sage.all import *
>>> MoCA = Monoids().Commutative().Algebras(QQ)
>>> MoCA.is_subcategory(Algebras(QQ).Commutative())
True
Associative[source]

alias of Semigroups

class CartesianProducts(category, *args)[source]

Bases: CartesianProductsCategory

class ParentMethods[source]

Bases: object

product(left, right)[source]

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: # needs sage.groups sage.modules
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])]
>>> from sage.all import *
>>> C = Magmas().CartesianProducts().example(); C
The Cartesian product of (Rational Field, Integer Ring, Integer Ring)
>>> x = C.an_element(); x
(1/2, 1, 1)
>>> x * x
(1/4, 1, 1)

>>> # needs sage.groups sage.modules
>>> A = SymmetricGroupAlgebra(QQ, Integer(3))
>>> x = cartesian_product([A([Integer(1),Integer(3),Integer(2)]), A([Integer(2),Integer(3),Integer(1)])])
>>> y = cartesian_product([A([Integer(1),Integer(3),Integer(2)]), A([Integer(2),Integer(3),Integer(1)])])
>>> cartesian_product([A,A]).product(x,y)
B[(0, [1, 2, 3])] + B[(1, [3, 1, 2])]
>>> x*y
B[(0, [1, 2, 3])] + B[(1, [3, 1, 2])]
example()[source]

Return 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 Cartesian products of commutative rings and
Category of Cartesian products of metric spaces
sage: sorted(C.category().axioms())
['AdditiveAssociative', 'AdditiveCommutative', 'AdditiveInverse',
 'AdditiveUnital', 'Associative', 'Commutative',
 'Distributive', 'Unital']

sage: TestSuite(C).run()
>>> from sage.all import *
>>> C = Magmas().CartesianProducts().example(); C
The Cartesian product of (Rational Field, Integer Ring, Integer Ring)
>>> C.category()
Join of Category of Cartesian products of commutative rings and
Category of Cartesian products of metric spaces
>>> sorted(C.category().axioms())
['AdditiveAssociative', 'AdditiveCommutative', 'AdditiveInverse',
 'AdditiveUnital', 'Associative', 'Commutative',
 'Distributive', 'Unital']

>>> TestSuite(C).run()
extra_super_categories()[source]

This implements the fact that a subquotient (and therefore a quotient or subobject) of a finite set is finite.

EXAMPLES:

sage: Semigroups().CartesianProducts().extra_super_categories()
[Category of semigroups]
sage: Semigroups().CartesianProducts().super_categories()
[Category of semigroups, Category of Cartesian products of magmas]
>>> from sage.all import *
>>> Semigroups().CartesianProducts().extra_super_categories()
[Category of semigroups]
>>> Semigroups().CartesianProducts().super_categories()
[Category of semigroups, Category of Cartesian products of magmas]
class Commutative(base_category)[source]

Bases: CategoryWithAxiom_singleton

class Algebras(category, *args)[source]

Bases: AlgebrasCategory

extra_super_categories()[source]

EXAMPLES:

sage: MCA = Magmas().Commutative().Algebras(QQ)
sage: MCA.extra_super_categories()
[Category of commutative magmas]
>>> from sage.all import *
>>> MCA = Magmas().Commutative().Algebras(QQ)
>>> MCA.extra_super_categories()
[Category of commutative magmas]

This implements the fact that the algebra of a commutative magma is commutative:

sage: MCA.super_categories()
[Category of magma algebras over Rational Field,
 Category of commutative magmas]
>>> from sage.all import *
>>> MCA.super_categories()
[Category of magma algebras over Rational Field,
 Category of commutative magmas]

In particular, commutative monoid algebras are commutative algebras:

sage: MoCA = Monoids().Commutative().Algebras(QQ)
sage: MoCA.is_subcategory(Algebras(QQ).Commutative())
True
>>> from sage.all import *
>>> MoCA = Monoids().Commutative().Algebras(QQ)
>>> MoCA.is_subcategory(Algebras(QQ).Commutative())
True
class CartesianProducts(category, *args)[source]

Bases: CartesianProductsCategory

extra_super_categories()[source]

Implement the fact that a Cartesian product of commutative additive magmas is still a commutative additive magmas.

EXAMPLES:

sage: C = Magmas().Commutative().CartesianProducts()
sage: C.extra_super_categories()
[Category of commutative magmas]
sage: C.axioms()
frozenset({'Commutative'})
>>> from sage.all import *
>>> C = Magmas().Commutative().CartesianProducts()
>>> C.extra_super_categories()
[Category of commutative magmas]
>>> C.axioms()
frozenset({'Commutative'})
class ParentMethods[source]

Bases: object

is_commutative()[source]

Return True, since commutative magmas are commutative.

EXAMPLES:

sage: Parent(QQ, category=CommutativeRings()).is_commutative()
True
>>> from sage.all import *
>>> Parent(QQ, category=CommutativeRings()).is_commutative()
True
class ElementMethods[source]

Bases: object

is_idempotent()[source]

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
>>> from sage.all import *
>>> S = Semigroups().example("free"); S
An example of a semigroup:
 the free semigroup generated by ('a', 'b', 'c', 'd')
>>> a = S('a')
>>> a**Integer(2)
'aa'
>>> 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
>>> from sage.all import *
>>> L = Semigroups().example("leftzero"); L
An example of a semigroup: the left zero semigroup
>>> x = L('x')
>>> x**Integer(2)
'x'
>>> x.is_idempotent()
True
FinitelyGeneratedAsMagma[source]

alias of FinitelyGeneratedMagmas

class JTrivial(base_category)[source]

Bases: CategoryWithAxiom

class ParentMethods[source]

Bases: object

multiplication_table(names='letters', elements=None)[source]

Return 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.

INPUT:

  • names – the type of names used

    • 'letters' – lowercase ASCII letters are used for a base 26 representation of the elements’ positions in the list given by column_keys(), padded to a common width with leading ‘a’s.

    • 'digits' – base 10 representation of the elements’ positions in the list given by column_keys(), padded to a common width with leading zeros.

    • 'elements' – the string representations of the elements themselves.

    • a list - a list of strings, where the length of the list equals the number of elements.

  • elements – (default: None) a list of elements of the magma, in forms that can be coerced into the structure, eg. their string representations. This may be used to impose an alternate ordering on the elements, perhaps when this is used in the context of a particular structure. The default is to use whatever ordering the S.list method returns. Or the elements can be a subset which is closed under the operation. In particular, this can be used when the base set is infinite.

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)                                     # needs sage.groups
sage: G.multiplication_table()                                          # needs sage.groups
*  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
>>> from sage.all import *
>>> G = CyclicPermutationGroup(Integer(5))                                     # needs sage.groups
>>> G.multiplication_table()                                          # needs sage.groups
*  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')                        # needs sage.modules
sage: T.column_keys()                                                   # needs sage.modules
('a', 'ab', 'b', 'ba')
sage: T                                                                 # needs sage.modules
*  0 1 2 3
 +--------
0| 0 1 1 1
1| 1 1 1 1
2| 3 3 2 3
3| 3 3 3 3
>>> from sage.all import *
>>> from sage.categories.examples.finite_semigroups import LeftRegularBand
>>> L = LeftRegularBand(('a', 'b'))
>>> T = L.multiplication_table(names='digits')                        # needs sage.modules
>>> T.column_keys()                                                   # needs sage.modules
('a', 'ab', 'b', 'ba')
>>> T                                                                 # needs sage.modules
*  0 1 2 3
 +--------
0| 0 1 1 1
1| 1 1 1 1
2| 3 3 2 3
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)                             # needs sage.modules
*  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
>>> from sage.all import *
>>> L = LeftRegularBand(('a', 'b', 'c'))
>>> elts = sorted(L.list())
>>> L.multiplication_table(elements=elts)                             # needs sage.modules
*  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)           # needs sage.modules
   *   'a'  'c' 'ac' 'ca'
    +--------------------
 'a'|  'a' 'ac' 'ac' 'ac'
 'c'| 'ca'  'c' 'ca' 'ca'
'ac'| 'ac' 'ac' 'ac' 'ac'
'ca'| 'ca' 'ca' 'ca' 'ca'
>>> from sage.all import *
>>> L = LeftRegularBand(('a','b','c'))
>>> elts=['a', 'c', 'ac', 'ca']
>>> L.multiplication_table(names='elements', elements=elts)           # needs sage.modules
   *   '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: # needs sage.groups sage.modules
sage: G = AlternatingGroup(3)
sage: T = G.multiplication_table()
sage: T.column_keys()
((), (1,2,3), (1,3,2))
sage: T.translation()
{'a': (), 'b': (1,2,3), 'c': (1,3,2)}
sage: T.change_names(['x', 'y', 'z'])
sage: T.translation()
{'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
>>> from sage.all import *
>>> # needs sage.groups sage.modules
>>> G = AlternatingGroup(Integer(3))
>>> T = G.multiplication_table()
>>> T.column_keys()
((), (1,2,3), (1,3,2))
>>> T.translation()
{'a': (), 'b': (1,2,3), 'c': (1,3,2)}
>>> T.change_names(['x', 'y', 'z'])
>>> T.translation()
{'x': (), 'y': (1,2,3), 'z': (1,3,2)}
>>> T
*  x y z
 +------
x| x y z
y| y z x
z| z x y
product(x, y)[source]

The binary multiplication of the magma.

INPUT:

  • x, y – elements of this magma

OUTPUT:

  • an element of the magma (the product of x and y)

EXAMPLES:

sage: S = Semigroups().example("free")
sage: x = S('a'); y = S('b')
sage: S.product(x, y)
'ab'
>>> from sage.all import *
>>> S = Semigroups().example("free")
>>> x = S('a'); y = S('b')
>>> 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'
>>> from sage.all import *
>>> bin = S.product
>>> bin(x,y)
'ab'

Currently, S.product is just a bound method:

sage: bin
<bound method FreeSemigroup.product of An example of a semigroup:
 the free semigroup generated by ('a', 'b', 'c', 'd')>
>>> from sage.all import *
>>> bin
<bound method FreeSemigroup.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
>>> from sage.all import *
>>> bin                 # todo: not implemented
Generic binary morphism:
From: (S x S)
To:   S
product_from_element_class_mul(x, y)[source]

The binary multiplication of the magma.

INPUT:

  • x, y – elements of this magma

OUTPUT:

  • an element of the magma (the product of x and y)

EXAMPLES:

sage: S = Semigroups().example("free")
sage: x = S('a'); y = S('b')
sage: S.product(x, y)
'ab'
>>> from sage.all import *
>>> S = Semigroups().example("free")
>>> x = S('a'); y = S('b')
>>> 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'
>>> from sage.all import *
>>> bin = S.product
>>> bin(x,y)
'ab'

Currently, S.product is just a bound method:

sage: bin
<bound method FreeSemigroup.product of An example of a semigroup:
 the free semigroup generated by ('a', 'b', 'c', 'd')>
>>> from sage.all import *
>>> bin
<bound method FreeSemigroup.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
>>> from sage.all import *
>>> bin                 # todo: not implemented
Generic binary morphism:
From: (S x S)
To:   S
class Realizations(category, *args)[source]

Bases: RealizationsCategory

class ParentMethods[source]

Bases: object

product_by_coercion(left, right)[source]

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: # needs sage.combinat sage.modules
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 Magmas.Realizations.ParentMethods.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}]
>>> from sage.all import *
>>> # needs sage.combinat sage.modules
>>> Out = Sets().WithRealizations().example().Out(); Out
The subset algebra of {1, 2, 3} over Rational Field
 in the Out basis
>>> Out.product
<bound method Magmas.Realizations.ParentMethods.product_by_coercion
 of The subset algebra of {1, 2, 3} over Rational Field
  in the Out basis>
>>> Out.product.__module__
'sage.categories.magmas'
>>> x = Out.an_element()
>>> y = Out.an_element()
>>> Out.product(x, y)
Out[{}] + 4*Out[{1}] + 9*Out[{2}] + Out[{1, 2}]
class SubcategoryMethods[source]

Bases: object

Associative()[source]

Return the full subcategory of the associative objects of self.

A (multiplicative) magma Magmas \(M\) is associative if, for all \(x,y,z\in M\),

\[x * (y * z) = (x * y) * z\]

EXAMPLES:

sage: Magmas().Associative()
Category of semigroups
>>> from sage.all import *
>>> Magmas().Associative()
Category of semigroups
Commutative()[source]

Return the full subcategory of the commutative objects of self.

A (multiplicative) magma Magmas \(M\) is commutative if, for all \(x,y\in M\),

\[x * y = y * x\]

EXAMPLES:

sage: Magmas().Commutative()
Category of commutative magmas
sage: Monoids().Commutative()
Category of commutative monoids
>>> from sage.all import *
>>> Magmas().Commutative()
Category of commutative magmas
>>> Monoids().Commutative()
Category of commutative monoids
Distributive()[source]

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 otherwise, 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
>>> from sage.all import *
>>> (Magmas() & AdditiveMagmas()).Distributive()
Category of distributive magmas and additive magmas
>>> (Monoids() & CommutativeAdditiveGroups()).Distributive()
Category of rings

>>> Magmas().Distributive()
Traceback (most recent call last):
...
ValueError: The distributive axiom only makes sense on a magma
which is simultaneously an additive magma
>>> Semigroups().Distributive()
Traceback (most recent call last):
...
ValueError: The distributive axiom only makes sense on a magma
which is simultaneously an additive magma
FinitelyGenerated()[source]

Return the subcategory of the objects of self that are endowed with a distinguished finite set of (multiplicative) magma generators.

EXAMPLES:

This is a shorthand for FinitelyGeneratedAsMagma(), which see:

sage: Magmas().FinitelyGenerated()
Category of finitely generated magmas
sage: Semigroups().FinitelyGenerated()
Category of finitely generated semigroups
sage: Groups().FinitelyGenerated()
Category of finitely generated enumerated groups
>>> from sage.all import *
>>> Magmas().FinitelyGenerated()
Category of finitely generated magmas
>>> Semigroups().FinitelyGenerated()
Category of finitely generated semigroups
>>> Groups().FinitelyGenerated()
Category of finitely generated enumerated groups

An error is raised if this is ambiguous:

sage: (Magmas() & AdditiveMagmas()).FinitelyGenerated()
Traceback (most recent call last):
...
ValueError: FinitelyGenerated is ambiguous for
Join of Category of magmas and Category of additive magmas.
Please use explicitly one of the FinitelyGeneratedAsXXX methods
>>> from sage.all import *
>>> (Magmas() & AdditiveMagmas()).FinitelyGenerated()
Traceback (most recent call last):
...
ValueError: FinitelyGenerated is ambiguous for
Join of Category of magmas and Category of additive magmas.
Please use explicitly one of the FinitelyGeneratedAsXXX methods

Note

Checking that there is no ambiguity currently assumes that all the other “finitely generated” axioms involve an additive structure. As of Sage 6.4, this is correct.

The use of this shorthand should be reserved for casual interactive use or when there is no risk of ambiguity.

FinitelyGeneratedAsMagma()[source]

Return the subcategory of the objects of self that are endowed with a distinguished finite set of (multiplicative) magma generators.

A set \(S\) of elements of a multiplicative magma form a set of generators if any element of the magma can be expressed recursively from elements of \(S\) and products thereof.

It is not imposed that morphisms shall preserve the distinguished set of generators; hence this is a full subcategory.

EXAMPLES:

sage: Magmas().FinitelyGeneratedAsMagma()
Category of finitely generated magmas
>>> from sage.all import *
>>> Magmas().FinitelyGeneratedAsMagma()
Category of finitely generated magmas

Being finitely generated does depend on the structure: for a ring, being finitely generated as a magma, as an additive magma, or as a ring are different concepts. Hence the name of this axiom is explicit:

sage: Rings().FinitelyGeneratedAsMagma()
Category of finitely generated as magma enumerated rings
>>> from sage.all import *
>>> Rings().FinitelyGeneratedAsMagma()
Category of finitely generated as magma enumerated rings

On the other hand, it does not depend on the multiplicative structure: for example a group is finitely generated if and only if it is finitely generated as a magma. A short hand is provided when there is no ambiguity, and the output tries to reflect that:

sage: Semigroups().FinitelyGenerated()
Category of finitely generated semigroups
sage: Groups().FinitelyGenerated()
Category of finitely generated enumerated groups

sage: Semigroups().FinitelyGenerated().axioms()
frozenset({'Associative', 'Enumerated', 'FinitelyGeneratedAsMagma'})
>>> from sage.all import *
>>> Semigroups().FinitelyGenerated()
Category of finitely generated semigroups
>>> Groups().FinitelyGenerated()
Category of finitely generated enumerated groups

>>> Semigroups().FinitelyGenerated().axioms()
frozenset({'Associative', 'Enumerated', 'FinitelyGeneratedAsMagma'})

Note that the set of generators may depend on the actual category; for example, in a group, one can often use less generators since it is allowed to take inverses.

JTrivial()[source]

Return the full subcategory of the \(J\)-trivial objects of self.

This axiom is in fact only meaningful for semigroups. This stub definition is here as a workaround for Issue #20515, in order to define the \(J\)-trivial axiom as the intersection of the \(L\) and \(R\)-trivial axioms.

Unital()[source]

Return the subcategory of the unital objects of self.

A (multiplicative) magma Magmas \(M\) is unital if it admits an element \(1\), called unit, such that for all \(x\in M\),

\[1 * x = x * 1 = x\]

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
>>> from sage.all import *
>>> Magmas().Unital()
Category of unital magmas
>>> Semigroups().Unital()
Category of monoids
>>> Monoids().Unital()
Category of monoids
>>> from sage.categories.associative_algebras import AssociativeAlgebras
>>> AssociativeAlgebras(QQ).Unital()
Category of algebras over Rational Field
class Subquotients(category, *args)[source]

Bases: SubquotientsCategory

The category of subquotient magmas.

See Sets.SubcategoryMethods.Subquotients() for the general setup for subquotients. In the case of a subquotient magma \(S\) of a magma \(G\), the condition that \(r\) be a morphism in As can be rewritten as follows:

  • for any two \(a,b \in S\) the identity \(a \times_S b = r(l(a) \times_G l(b))\) holds.

This is used by this category to implement the product \(\times_S\) of \(S\) from \(l\) and \(r\) and the product of \(G\).

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]
>>> from sage.all import *
>>> 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]
class ParentMethods[source]

Bases: object

product(x, y)[source]

Return the product of two elements of self.

EXAMPLES:

sage: S = Semigroups().Subquotients().example()
sage: S
An example of a (sub)quotient semigroup:
a quotient of the left zero semigroup
sage: S.product(S(19), S(3))
19
>>> from sage.all import *
>>> S = Semigroups().Subquotients().example()
>>> S
An example of a (sub)quotient semigroup:
a quotient of the left zero semigroup
>>> S.product(S(Integer(19)), S(Integer(3)))
19

Here is a more elaborate example involving a sub algebra:

sage: Z = SymmetricGroup(5).algebra(QQ).center()                    # needs sage.combinat sage.groups
sage: B = Z.basis()                                                 # needs sage.combinat sage.groups
sage: B[3] * B[2]                                                   # needs sage.combinat sage.groups
4*B[2] + 6*B[3] + 5*B[6]
>>> from sage.all import *
>>> Z = SymmetricGroup(Integer(5)).algebra(QQ).center()                    # needs sage.combinat sage.groups
>>> B = Z.basis()                                                 # needs sage.combinat sage.groups
>>> B[Integer(3)] * B[Integer(2)]                                                   # needs sage.combinat sage.groups
4*B[2] + 6*B[3] + 5*B[6]
class Unital(base_category)[source]

Bases: CategoryWithAxiom_singleton

class Algebras(category, *args)[source]

Bases: AlgebrasCategory

extra_super_categories()[source]

EXAMPLES:

sage: MCA = Magmas().Commutative().Algebras(QQ)
sage: MCA.extra_super_categories()
[Category of commutative magmas]
>>> from sage.all import *
>>> MCA = Magmas().Commutative().Algebras(QQ)
>>> MCA.extra_super_categories()
[Category of commutative magmas]

This implements the fact that the algebra of a commutative magma is commutative:

sage: MCA.super_categories()
[Category of magma algebras over Rational Field,
 Category of commutative magmas]
>>> from sage.all import *
>>> MCA.super_categories()
[Category of magma algebras over Rational Field,
 Category of commutative magmas]

In particular, commutative monoid algebras are commutative algebras:

sage: MoCA = Monoids().Commutative().Algebras(QQ)
sage: MoCA.is_subcategory(Algebras(QQ).Commutative())
True
>>> from sage.all import *
>>> MoCA = Monoids().Commutative().Algebras(QQ)
>>> MoCA.is_subcategory(Algebras(QQ).Commutative())
True
class CartesianProducts(category, *args)[source]

Bases: CartesianProductsCategory

class ElementMethods[source]

Bases: object

class ParentMethods[source]

Bases: object

one()[source]

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()                     # needs sage.rings.real_mpfr
(1, 1, 1.00000000000000)
>>> from sage.all import *
>>> cartesian_product([QQ, ZZ, RR]).one()                     # needs sage.rings.real_mpfr
(1, 1, 1.00000000000000)
extra_super_categories()[source]

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
>>> from sage.all import *
>>> C = Magmas().Unital().CartesianProducts()
>>> C.extra_super_categories()
[Category of unital magmas]
>>> C.axioms()
frozenset({'Unital'})

>>> Monoids().CartesianProducts().is_subcategory(Monoids())
True
class ElementMethods[source]

Bases: object

class Inverse(base_category)[source]

Bases: CategoryWithAxiom_singleton

class CartesianProducts(category, *args)[source]

Bases: CartesianProductsCategory

extra_super_categories()[source]

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']
>>> from sage.all import *
>>> C = Magmas().Unital().Inverse().CartesianProducts()
>>> C.extra_super_categories()
[Category of inverse unital magmas]
>>> sorted(C.axioms())
['Inverse', 'Unital']
class ParentMethods[source]

Bases: object

is_empty()[source]

Return whether self is empty.

Since this set is a unital magma it is not empty and this method always return False.

EXAMPLES:

sage: S = SymmetricGroup(2)                                         # needs sage.groups
sage: S.is_empty()                                                  # needs sage.groups
False

sage: M = Monoids().example()
sage: M.is_empty()
False
>>> from sage.all import *
>>> S = SymmetricGroup(Integer(2))                                         # needs sage.groups
>>> S.is_empty()                                                  # needs sage.groups
False

>>> M = Monoids().example()
>>> M.is_empty()
False
one()[source]

Return the unit of the monoid, that is the unique neutral element for \(*\).

Note

The default implementation is to coerce \(1\) into self. It is recommended to override this method because the coercion from the integers:

  • is not always meaningful (except for \(1\));

  • 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()
''
>>> from sage.all import *
>>> M = Monoids().example(); M
An example of a monoid:
 the free monoid generated by ('a', 'b', 'c', 'd')
>>> M.one()
''
class Realizations(category, *args)[source]

Bases: RealizationsCategory

class ParentMethods[source]

Bases: object

one()[source]

Return the unit element of self.

EXAMPLES:

sage: # needs sage.combinat sage.groups
sage: from sage.combinat.root_system.extended_affine_weyl_group import ExtendedAffineWeylGroup
sage: PvW0 = ExtendedAffineWeylGroup(['A',2,1]).PvW0()
sage: PvW0 in Magmas().Unital().Realizations()
True
sage: PvW0.one()
1
>>> from sage.all import *
>>> # needs sage.combinat sage.groups
>>> from sage.combinat.root_system.extended_affine_weyl_group import ExtendedAffineWeylGroup
>>> PvW0 = ExtendedAffineWeylGroup(['A',Integer(2),Integer(1)]).PvW0()
>>> PvW0 in Magmas().Unital().Realizations()
True
>>> PvW0.one()
1
class SubcategoryMethods[source]

Bases: object

Inverse()[source]

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
>>> from sage.all import *
>>> Magmas().Unital().Inverse()
Category of inverse unital magmas
>>> Monoids().Inverse()
Category of groups
additional_structure()[source]

Return self.

Indeed, the category of unital magmas defines an additional structure, namely the unit of the magma which shall be preserved by morphisms.

EXAMPLES:

sage: Magmas().Unital().additional_structure()
Category of unital magmas
>>> from sage.all import *
>>> Magmas().Unital().additional_structure()
Category of unital magmas
super_categories()[source]

EXAMPLES:

sage: Magmas().super_categories()
[Category of sets]
>>> from sage.all import *
>>> Magmas().super_categories()
[Category of sets]