Indexed Monoids¶
AUTHORS:
Travis Scrimshaw (2013-10-15)
- class sage.monoids.indexed_free_monoid.IndexedFreeAbelianMonoid(indices, prefix, category=None, names=None, **kwds)[source]¶
Bases:
IndexedMonoidFree 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]
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> F.gen(Integer(15))**Integer(3) * F.gen(Integer(2)) * F.gen(Integer(15)) F[2]*F[15]^4 >>> F.gen(Integer(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]
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=Partitions(), prefix='A', bracket=False, scalar_mult='%') >>> F.gen([Integer(3),Integer(1),Integer(1)]) * F.gen([Integer(2),Integer(2)]) A[2, 2]%A[3, 1, 1]
Todo
Implement a subclass when the index sets is finite that utilizes vectors or the polydict monomials with the index order fixed.
- Element[source]¶
alias of
IndexedFreeAbelianMonoidElement
- class sage.monoids.indexed_free_monoid.IndexedFreeAbelianMonoidElement(F, x)[source]¶
Bases:
IndexedMonoidElementAn element of an indexed free abelian monoid.
- dict()[source]¶
Return
selfas 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}
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (a*c**Integer(3)).dict() {0: 1, 2: 3}
- divides(m)[source]¶
Return whether
selfdividesm.EXAMPLES:
sage: F = FreeAbelianMonoid(index_set=ZZ) sage: a,b,c,d,e = [F.gen(i) for i in range(5)] sage: elt = a*b*c^3*d^2 sage: a.divides(elt) True sage: c.divides(elt) True sage: (a*b*d^2).divides(elt) True sage: (a^4).divides(elt) False sage: e.divides(elt) False
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> elt = a*b*c**Integer(3)*d**Integer(2) >>> a.divides(elt) True >>> c.divides(elt) True >>> (a*b*d**Integer(2)).divides(elt) True >>> (a**Integer(4)).divides(elt) False >>> e.divides(elt) False
- length()[source]¶
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
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> elt = a*c**Integer(3)*b**Integer(2)*a >>> elt.length() 7 >>> len(elt) 7
- class sage.monoids.indexed_free_monoid.IndexedFreeMonoid(indices, prefix, category=None, names=None, **kwds)[source]¶
Bases:
IndexedMonoidFree 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]
>>> from sage.all import * >>> F = FreeMonoid(index_set=ZZ) >>> F.gen(Integer(15))**Integer(3) * F.gen(Integer(2)) * F.gen(Integer(15)) F[15]^3*F[2]*F[15] >>> F.gen(Integer(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>
>>> from sage.all import * >>> F = FreeMonoid(index_set=ZZ, prefix='X', bracket=['|','>']) >>> F.gen(Integer(2)) * F.gen(Integer(12)) X|2>*X|12>
- Element[source]¶
alias of
IndexedFreeMonoidElement
- class sage.monoids.indexed_free_monoid.IndexedFreeMonoidElement(F, x)[source]¶
Bases:
IndexedMonoidElementAn element of an indexed free abelian monoid.
- length()[source]¶
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
>>> from sage.all import * >>> F = FreeMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> elt = a*c**Integer(3)*b**Integer(2)*a >>> elt.length() 7 >>> len(elt) 7
- class sage.monoids.indexed_free_monoid.IndexedMonoid(indices, prefix, category=None, names=None, **kwds)[source]¶
Bases:
Parent,IndexedGenerators,UniqueRepresentationBase 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()[source]¶
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
>>> from sage.all import * >>> F = FreeMonoid(index_set=ZZ) >>> F.cardinality() +Infinity >>> F = FreeMonoid(index_set=()) >>> F.cardinality() 1 >>> F = FreeAbelianMonoid(index_set=ZZ) >>> F.cardinality() +Infinity >>> F = FreeAbelianMonoid(index_set=()) >>> F.cardinality() 1
- gens()[source]¶
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']]
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> F.monoid_generators() Lazy family (Generator map from Integer Ring to Free abelian monoid indexed by Integer Ring(i))_{i in Integer Ring} >>> F = FreeAbelianMonoid(index_set=tuple('abcde')) >>> sorted(F.monoid_generators()) [F['a'], F['b'], F['c'], F['d'], F['e']]
- monoid_generators()[source]¶
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']]
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> F.monoid_generators() Lazy family (Generator map from Integer Ring to Free abelian monoid indexed by Integer Ring(i))_{i in Integer Ring} >>> F = FreeAbelianMonoid(index_set=tuple('abcde')) >>> sorted(F.monoid_generators()) [F['a'], F['b'], F['c'], F['d'], F['e']]
- class sage.monoids.indexed_free_monoid.IndexedMonoidElement(F, x)[source]¶
Bases:
MonoidElementAn 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)whereiis the index andpis 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).- is_one()[source]¶
Return if
selfis the identity element.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).is_one() False sage: F.one().is_one() True
>>> from sage.all import * >>> F = FreeMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (b*a*c**Integer(3)*a).is_one() False >>> F.one().is_one() True
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).is_one() False sage: F.one().is_one() True
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (b*c**Integer(3)*a).is_one() False >>> F.one().is_one() True
- leading_support()[source]¶
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
>>> from sage.all import * >>> F = FreeMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (b*a*c**Integer(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
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (b*c**Integer(3)*a).leading_support() 0
- support()[source]¶
Return a list of the objects indexing
selfwith nonzero 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]
>>> from sage.all import * >>> F = FreeMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (b*a*c**Integer(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]
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (a*c**Integer(3)).support() [0, 2]
- to_word_list()[source]¶
Return
selfas a word represented as a list whose entries are indices ofself.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]
>>> from sage.all import * >>> F = FreeMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (b*a*c**Integer(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]
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (b*c**Integer(3)*a).to_word_list() [0, 1, 2, 2, 2]
- trailing_support()[source]¶
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
>>> from sage.all import * >>> F = FreeMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (b*a*c**Integer(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
>>> from sage.all import * >>> F = FreeAbelianMonoid(index_set=ZZ) >>> a,b,c,d,e = [F.gen(i) for i in range(Integer(5))] >>> (b*c**Integer(3)*a).trailing_support() 2