Free Monoids

AUTHORS:

  • David Kohel (2005-09)
  • Simon King (2011-04): Put free monoids into the category framework

Sage supports free monoids on any prescribed finite number \(n\geq 0\) of generators. Use the FreeMonoid function to create a free monoid, and the gen and gens functions to obtain the corresponding generators. You can print the generators as arbitrary strings using the optional names argument to the FreeMonoid function.

class sage.monoids.free_monoid.FreeMonoidFactory

Bases: sage.structure.factory.UniqueFactory

Returns a free monoid on \(n\) generators.

INPUT:

  • n - integer
  • names - names of generators

OUTPUT: free abelian monoid

EXAMPLES:

sage: FreeMonoid(0,'')
Free monoid on 0 generators ()
sage: F.<a,b,c,d,e> = FreeMonoid(5); F
Free monoid on 5 generators (a, b, c, d, e)
sage: F(1)
1
sage: mul([ a, b, a, c, b, d, c, d ], F(1))
a*b*a*c*b*d*c*d
create_key(n, names)

x.__init__(...) initializes x; see help(type(x)) for signature

create_object(version, key)

x.__init__(...) initializes x; see help(type(x)) for signature

class sage.monoids.free_monoid.FreeMonoid_class(n, names=None)

Bases: sage.monoids.monoid.Monoid_class

The free monoid on \(n\) generators.

Element

alias of FreeMonoidElement

gen(i=0)

The \(i\)-th generator of the monoid.

INPUT:

  • i - integer (default: 0)

EXAMPLES:

sage: F = FreeMonoid(3, 'a')
sage: F.gen(1)
a1
sage: F.gen(2)
a2
sage: F.gen(5)
Traceback (most recent call last):
...
IndexError: Argument i (= 5) must be between 0 and 2.
ngens()

The number of free generators of the monoid.

EXAMPLES:

sage: F = FreeMonoid(2005, 'a')
sage: F.ngens()
2005
one_element()

Returns the identity element in this monoid.

EXAMPLES:

sage: F = FreeMonoid(2005, 'a')
sage: F.one_element()
1
sage.monoids.free_monoid.is_FreeMonoid(x)

Return True if \(x\) is a free monoid.

EXAMPLES:

sage: from sage.monoids.free_monoid import is_FreeMonoid
sage: is_FreeMonoid(5)
False
sage: is_FreeMonoid(FreeMonoid(7,'a'))
True
sage: is_FreeMonoid(FreeAbelianMonoid(7,'a'))
False
sage: is_FreeMonoid(FreeAbelianMonoid(0,''))
False

Previous topic

Monoids

Next topic

Monoid Elements

This Page