Indexed Monoids

AUTHORS:

  • Travis Scrimshaw (2013-10-15)
sage.monoids.indexed_free_monoid.IndexedFreeAbelianMonoid

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]
class sage.monoids.indexed_free_monoid.IndexedFreeAbelianMonoidElement(F, x)

Bases: sage.monoids.indexed_free_monoid.IndexedMonoidElement

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
sage.monoids.indexed_free_monoid.IndexedFreeMonoid

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>
class sage.monoids.indexed_free_monoid.IndexedFreeMonoidElement(F, x)

Bases: sage.monoids.indexed_free_monoid.IndexedMonoidElement

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
sage.monoids.indexed_free_monoid.IndexedMonoid

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.

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

Bases: sage.structure.element.MonoidElement

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)]
sage: (b*a*c^3*a).leading_support()
1
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).leading_support()
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