AUTHORS:
Sage supports free monoids on any prescribed finite number
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.
Return a free monoid on generators or with the generators indexed by
a set
.
We construct free monoids by specifing either:
INPUT:
OUTPUT:
A free monoid.
EXAMPLES:
sage: F.<a,b,c,d,e> = FreeMonoid(); F
Free monoid on 5 generators (a, b, c, d, e)
sage: FreeMonoid(index_set=ZZ)
Free monoid indexed by Integer Ring
sage: F.<x,y,z> = FreeMonoid(abelian=True); F
Free abelian monoid on 3 generators (x, y, z)
sage: FreeMonoid(index_set=ZZ, commutative=True)
Free abelian monoid indexed by Integer Ring
Bases: sage.structure.factory.UniqueFactory
Create the free monoid in generators.
INPUT:
OUTPUT: free 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
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
Bases: sage.monoids.monoid.Monoid_class
The free monoid on generators.
alias of FreeMonoidElement
Return the cardinality of self, which is .
EXAMPLES:
sage: F = FreeMonoid(2005, 'a')
sage: F.cardinality()
+Infinity
The -th generator of the monoid.
INPUT:
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.
The number of free generators of the monoid.
EXAMPLES:
sage: F = FreeMonoid(2005, 'a')
sage: F.ngens()
2005
Returns the identity element in this monoid.
EXAMPLES:
sage: F = FreeMonoid(2005, 'a')
sage: F.one_element()
1
Return True if 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
sage: is_FreeMonoid(FreeMonoid(index_set=ZZ))
True
sage: is_FreeMonoid(FreeAbelianMonoid(index_set=ZZ))
False