Monoid Elements

AUTHORS:

  • David Kohel (2005-09-29)

Elements of free monoids are represented internally as lists of pairs of integers.

class sage.monoids.free_monoid_element.FreeMonoidElement(F, x, check=True)

Element of a free monoid.

EXAMPLES:

sage: a = FreeMonoid(5, 'a').gens()
sage: x = a[0]*a[1]*a[4]**3
sage: x**3
a0*a1*a4^3*a0*a1*a4^3*a0*a1*a4^3
sage: x**0
1
sage: x**(-1)
...
TypeError: bad operand type for unary ~: 'FreeMonoidElement'
__call__(*x, **kwds)

EXAMPLES:

sage: M.<x,y,z>=FreeMonoid(3)
sage: (x*y).subs(x=1,y=2,z=14)
2
sage: (x*y).subs({x:z,y:z})
z^2
sage: M1=MatrixSpace(ZZ,1,2)
sage: M2=MatrixSpace(ZZ,2,1)
sage: (x*y).subs({x:M1([1,2]),y:M2([3,4])})
[11]

AUTHORS:

  • Joel B. Mohler (2007-10-27)
__cmp__(y)
__init__(F, x, check=True)

Create the element x of the FreeMonoid F.

This should typically be called by a FreeMonoid.

__len__()

Return the number of products that occur in this monoid element. For example, the length of the identity is 0, and the length of the monoid x_0^2x_1 is three.

EXAMPLES:

sage: F = FreeMonoid(3, 'a')
sage: z = F(1)
sage: len(z)
0
sage: a = F.gens()
sage: len(a[0]**2 * a[1])
3
__mul__(y)

Multiply 2 free monoid elements.

EXAMPLES:

sage: a = FreeMonoid(5, 'a').gens()
sage: x = a[0] * a[1] * a[4]**3
sage: y = a[4] * a[0] * a[1]
sage: x*y
a0*a1*a4^4*a0*a1
__weakref__
list of weak references to the object (if defined)
_latex_()

Return latex representation of self.

EXAMPLES:

sage: F = FreeMonoid(3, 'a')
sage: z = F([(0,5),(1,2),(0,10),(0,2),(1,2)])
sage: z._latex_()
'a_{0}^{5}a_{1}^{2}a_{0}^{12}a_{1}^{2}'
sage: F, (alpha,beta,gamma) = FreeMonoid(3, 'alpha,beta,gamma').objgens()
sage: latex(alpha*beta*gamma)
\alpha\beta\gamma
_repr_()
sage.monoids.free_monoid_element.is_FreeMonoidElement(x)

Previous topic

Free Monoids

Next topic

Free abelian monoids

This Page