# Indexed Monoids¶

AUTHORS:

• Travis Scrimshaw (2013-10-15)
class sage.monoids.indexed_free_monoid.IndexedFreeAbelianMonoid(indices, prefix, category=None, names=None, **kwds)

Free abelian monoid with an indexed set of generators.

INPUT:

• indices – the indices for the generators

For the optional arguments that control the printing, see IndexedGenerators.

EXAMPLES:

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: F.gen(15)^3 * F.gen(2) * F.gen(15)
F[2]*F[15]^4
sage: F.gen(1)
F[1]


Now we examine some of the printing options:

sage: F = FreeAbelianMonoid(index_set=Partitions(), prefix='A', bracket=False, scalar_mult='%')
sage: F.gen([3,1,1]) * F.gen([2,2])
A[2, 2]%A[3, 1, 1]

Element
gen(x)

The generator indexed by x of self.

EXAMPLES:

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: F.gen(0)
F[0]
sage: F.gen(2)
F[2]

one()

Return the identity element of self.

EXAMPLES:

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: F.one()
1

class sage.monoids.indexed_free_monoid.IndexedFreeAbelianMonoidElement(F, x)

An element of an indexed free abelian monoid.

dict()

Return self as a dictionary.

EXAMPLES:

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
sage: (a*c^3).dict()
{0: 1, 2: 3}

length()

Return the length of self.

EXAMPLES:

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
sage: elt = a*c^3*b^2*a
sage: elt.length()
7
sage: len(elt)
7

class sage.monoids.indexed_free_monoid.IndexedFreeMonoid(indices, prefix, category=None, names=None, **kwds)

Free monoid with an indexed set of generators.

INPUT:

• indices – the indices for the generators

For the optional arguments that control the printing, see IndexedGenerators.

EXAMPLES:

sage: F = FreeMonoid(index_set=ZZ)
sage: F.gen(15)^3 * F.gen(2) * F.gen(15)
F[15]^3*F[2]*F[15]
sage: F.gen(1)
F[1]


Now we examine some of the printing options:

sage: F = FreeMonoid(index_set=ZZ, prefix='X', bracket=['|','>'])
sage: F.gen(2) * F.gen(12)
X|2>*X|12>

Element
gen(x)

The generator indexed by x of self.

EXAMPLES:

sage: F = FreeMonoid(index_set=ZZ)
sage: F.gen(0)
F[0]
sage: F.gen(2)
F[2]

one()

Return the identity element of self.

EXAMPLES:

sage: F = FreeMonoid(index_set=ZZ)
sage: F.one()
1

class sage.monoids.indexed_free_monoid.IndexedFreeMonoidElement(F, x)

An element of an indexed free abelian monoid.

length()

Return the length of self.

EXAMPLES:

sage: F = FreeMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
sage: elt = a*c^3*b^2*a
sage: elt.length()
7
sage: len(elt)
7

class sage.monoids.indexed_free_monoid.IndexedMonoid(indices, prefix, category=None, names=None, **kwds)

Base class for monoids with an indexed set of generators.

INPUT:

• indices – the indices for the generators

For the optional arguments that control the printing, see IndexedGenerators.

cardinality()

Return the cardinality of self, which is $$\infty$$ unless this is the trivial monoid.

EXAMPLES:

sage: F = FreeMonoid(index_set=ZZ)
sage: F.cardinality()
+Infinity
sage: F = FreeMonoid(index_set=())
sage: F.cardinality()
1

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: F.cardinality()
+Infinity
sage: F = FreeAbelianMonoid(index_set=())
sage: F.cardinality()
1

gens()

Return the monoid generators of self.

EXAMPLES:

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: F.monoid_generators()
Lazy family (Generator map from Integer Ring to
Free abelian monoid indexed by Integer Ring(i))_{i in Integer Ring}
sage: F = FreeAbelianMonoid(index_set=tuple('abcde'))
sage: sorted(F.monoid_generators())
[F['a'], F['b'], F['c'], F['d'], F['e']]

monoid_generators()

Return the monoid generators of self.

EXAMPLES:

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: F.monoid_generators()
Lazy family (Generator map from Integer Ring to
Free abelian monoid indexed by Integer Ring(i))_{i in Integer Ring}
sage: F = FreeAbelianMonoid(index_set=tuple('abcde'))
sage: sorted(F.monoid_generators())
[F['a'], F['b'], F['c'], F['d'], F['e']]

class sage.monoids.indexed_free_monoid.IndexedMonoidElement(F, x)

An element of an indexed monoid.

This is an abstract class which uses the (abstract) method _sorted_items() for all of its functions. So to implement an element of an indexed monoid, one just needs to implement _sorted_items(), which returns a list of pairs (i, p) where i is the index and p is the corresponding power, sorted in some order. For example, in the free monoid there is no such choice, but for the free abelian monoid, one could want lex order or have the highest powers first.

Indexed monoid elements are ordered lexicographically with respect to the result of _sorted_items() (which for abelian free monoids is influenced by the order on the indexing set).

leading_support()

Return the support of the leading generator of self.

EXAMPLES:

sage: F = FreeMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
1

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
0

support()

Return a list of the objects indexing self with non-zero exponents.

EXAMPLES:

sage: F = FreeMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
sage: (b*a*c^3*b).support()
[0, 1, 2]

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
sage: (a*c^3).support()
[0, 2]

to_word_list()

Return self as a word represented as a list whose entries are indices of self.

EXAMPLES:

sage: F = FreeMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
sage: (b*a*c^3*a).to_word_list()
[1, 0, 2, 2, 2, 0]

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
sage: (b*c^3*a).to_word_list()
[0, 1, 2, 2, 2]

trailing_support()

Return the support of the trailing generator of self.

EXAMPLES:

sage: F = FreeMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
sage: (b*a*c^3*a).trailing_support()
0

sage: F = FreeAbelianMonoid(index_set=ZZ)
sage: a,b,c,d,e = [F.gen(i) for i in range(5)]
sage: (b*c^3*a).trailing_support()
2