Examples of magmas

sage.categories.examples.magmas.Example[source]

alias of FreeMagma

class sage.categories.examples.magmas.FreeMagma(alphabet=('a', 'b', 'c', 'd'))[source]

Bases: UniqueRepresentation, Parent

An example of magma.

The purpose of this class is to provide a minimal template for implementing a magma.

EXAMPLES:

sage: M = Magmas().example(); M
An example of a magma: the free magma generated by ('a', 'b', 'c', 'd')
>>> from sage.all import *
>>> M = Magmas().example(); M
An example of a magma: the free magma generated by ('a', 'b', 'c', 'd')

This is the free magma generated by:

sage: M.magma_generators()
Family ('a', 'b', 'c', 'd')
sage: a, b, c, d = M.magma_generators()
>>> from sage.all import *
>>> M.magma_generators()
Family ('a', 'b', 'c', 'd')
>>> a, b, c, d = M.magma_generators()

and with a non-associative product given by:

sage: a * (b * c) * (d * a * b)
'((a*(b*c))*((d*a)*b))'
sage: a * (b * c) == (a * b) * c
False
>>> from sage.all import *
>>> a * (b * c) * (d * a * b)
'((a*(b*c))*((d*a)*b))'
>>> a * (b * c) == (a * b) * c
False
class Element[source]

Bases: ElementWrapper

The class for elements of the free magma.

wrapped_class

alias of str

an_element()[source]

Return an element of the magma.

EXAMPLES:

sage: F = Magmas().example()
sage: F.an_element()
'(((a*b)*c)*d)'
>>> from sage.all import *
>>> F = Magmas().example()
>>> F.an_element()
'(((a*b)*c)*d)'
magma_generators()[source]

Return the generators of the magma.

EXAMPLES:

sage: F = Magmas().example()
sage: F.magma_generators()
Family ('a', 'b', 'c', 'd')
>>> from sage.all import *
>>> F = Magmas().example()
>>> F.magma_generators()
Family ('a', 'b', 'c', 'd')
product(x, y)[source]

Return the product of x and y in the magma, as per Magmas.ParentMethods.product().

EXAMPLES:

sage: F = Magmas().example()
sage: F('a') * F.an_element()
'(a*(((a*b)*c)*d))'
>>> from sage.all import *
>>> F = Magmas().example()
>>> F('a') * F.an_element()
'(a*(((a*b)*c)*d))'