Examples of magmas#

sage.categories.examples.magmas.Example#

alias of FreeMagma

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

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')

This is the free magma generated by:

sage: M.magma_generators()
Family ('a', 'b', 'c', 'd')
sage: 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
class Element#

Bases: ElementWrapper

The class for elements of the free magma.

wrapped_class#

alias of str

an_element()#

Return an element of the magma.

EXAMPLES:

sage: F = Magmas().example()
sage: F.an_element()
'(((a*b)*c)*d)'
magma_generators()#

Return the generators of the magma.

EXAMPLES:

sage: F = Magmas().example()
sage: F.magma_generators()
Family ('a', 'b', 'c', 'd')
product(x, y)#

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))'