Free abelian monoids#
AUTHORS:
David Kohel (2005-09)
Sage supports free abelian monoids on any prescribed finite number
\(n\geq 0\) of generators. Use the
FreeAbelianMonoid
function to create a free abelian
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
FreeAbelianMonoid
function.
EXAMPLE 1: It is possible to create an abelian monoid in zero or more variables; the syntax T(1) creates the monoid identity element even in the rank zero case.
sage: T = FreeAbelianMonoid(0, '')
sage: T
Free abelian monoid on 0 generators ()
sage: T.gens()
()
sage: T(1)
1
>>> from sage.all import *
>>> T = FreeAbelianMonoid(Integer(0), '')
>>> T
Free abelian monoid on 0 generators ()
>>> T.gens()
()
>>> T(Integer(1))
1
EXAMPLE 2: A free abelian monoid uses a multiplicative representation of elements, but the underlying representation is lists of integer exponents.
sage: F = FreeAbelianMonoid(5,names='a,b,c,d,e')
sage: (a,b,c,d,e) = F.gens()
sage: a*b^2*e*d
a*b^2*d*e
sage: x = b^2*e*d*a^7
sage: x
a^7*b^2*d*e
sage: x.list()
[7, 2, 0, 1, 1]
>>> from sage.all import *
>>> F = FreeAbelianMonoid(Integer(5),names='a,b,c,d,e')
>>> (a,b,c,d,e) = F.gens()
>>> a*b**Integer(2)*e*d
a*b^2*d*e
>>> x = b**Integer(2)*e*d*a**Integer(7)
>>> x
a^7*b^2*d*e
>>> x.list()
[7, 2, 0, 1, 1]
- sage.monoids.free_abelian_monoid.FreeAbelianMonoid(index_set=None, names=None, **kwds)[source]#
Return a free abelian monoid on \(n\) generators or with the generators indexed by a set \(I\).
We construct free abelian monoids by specifing either:
the number of generators and/or the names of the generators
the indexing set for the generators (this ignores the other two inputs)
INPUT:
index_set
– an indexing set for the generators; if an integer, then this becomes \(\{0, 1, \ldots, n-1\}\)names
– names of generators
OUTPUT:
A free abelian monoid.
EXAMPLES:
sage: F.<a,b,c,d,e> = FreeAbelianMonoid(); F Free abelian monoid on 5 generators (a, b, c, d, e) sage: FreeAbelianMonoid(index_set=ZZ) Free abelian monoid indexed by Integer Ring sage: FreeAbelianMonoid(names='x,y') Free abelian monoid on 2 generators (x, y)
>>> from sage.all import * >>> F = FreeAbelianMonoid(names=('a', 'b', 'c', 'd', 'e',)); (a, b, c, d, e,) = F._first_ngens(5); F Free abelian monoid on 5 generators (a, b, c, d, e) >>> FreeAbelianMonoid(index_set=ZZ) Free abelian monoid indexed by Integer Ring >>> FreeAbelianMonoid(names='x,y') Free abelian monoid on 2 generators (x, y)
- class sage.monoids.free_abelian_monoid.FreeAbelianMonoidFactory[source]#
Bases:
UniqueFactory
Create the free abelian monoid in \(n\) generators.
INPUT:
n
– integernames
– names of generators
OUTPUT: free abelian monoid
EXAMPLES:
sage: FreeAbelianMonoid(0, '') Free abelian monoid on 0 generators () sage: F = FreeAbelianMonoid(5,names = list("abcde")) sage: F Free abelian monoid on 5 generators (a, b, c, d, e) sage: F(1) 1 sage: (a, b, c, d, e) = F.gens() sage: mul([ a, b, a, c, b, d, c, d ], F(1)) a^2*b^2*c^2*d^2 sage: a**2 * b**3 * a**2 * b**4 a^4*b^7
>>> from sage.all import * >>> FreeAbelianMonoid(Integer(0), '') Free abelian monoid on 0 generators () >>> F = FreeAbelianMonoid(Integer(5),names = list("abcde")) >>> F Free abelian monoid on 5 generators (a, b, c, d, e) >>> F(Integer(1)) 1 >>> (a, b, c, d, e) = F.gens() >>> mul([ a, b, a, c, b, d, c, d ], F(Integer(1))) a^2*b^2*c^2*d^2 >>> a**Integer(2) * b**Integer(3) * a**Integer(2) * b**Integer(4) a^4*b^7
sage: loads(dumps(F)) is F True
>>> from sage.all import * >>> loads(dumps(F)) is F True
- class sage.monoids.free_abelian_monoid.FreeAbelianMonoid_class(n, names)[source]#
Bases:
Parent
Free abelian monoid on \(n\) generators.
- Element[source]#
alias of
FreeAbelianMonoidElement
- cardinality()[source]#
Return the cardinality of
self
, which is \(\infty\).EXAMPLES:
sage: F = FreeAbelianMonoid(3000, 'a') sage: F.cardinality() +Infinity
>>> from sage.all import * >>> F = FreeAbelianMonoid(Integer(3000), 'a') >>> F.cardinality() +Infinity
- gen(i=0)[source]#
The \(i\)-th generator of the abelian monoid.
EXAMPLES:
sage: F = FreeAbelianMonoid(5,'a') sage: F.gen(0) a0 sage: F.gen(2) a2
>>> from sage.all import * >>> F = FreeAbelianMonoid(Integer(5),'a') >>> F.gen(Integer(0)) a0 >>> F.gen(Integer(2)) a2
- sage.monoids.free_abelian_monoid.is_FreeAbelianMonoid(x)[source]#
Return True if \(x\) is a free abelian monoid.
EXAMPLES:
sage: from sage.monoids.free_abelian_monoid import is_FreeAbelianMonoid sage: is_FreeAbelianMonoid(5) doctest:warning... DeprecationWarning: the function is_FreeAbelianMonoid is deprecated; use 'isinstance(..., FreeAbelianMonoid_class)' instead See https://github.com/sagemath/sage/issues/37897 for details. False sage: is_FreeAbelianMonoid(FreeAbelianMonoid(7,'a')) True sage: is_FreeAbelianMonoid(FreeMonoid(7,'a')) False sage: is_FreeAbelianMonoid(FreeMonoid(0,'')) False
>>> from sage.all import * >>> from sage.monoids.free_abelian_monoid import is_FreeAbelianMonoid >>> is_FreeAbelianMonoid(Integer(5)) doctest:warning... DeprecationWarning: the function is_FreeAbelianMonoid is deprecated; use 'isinstance(..., FreeAbelianMonoid_class)' instead See https://github.com/sagemath/sage/issues/37897 for details. False >>> is_FreeAbelianMonoid(FreeAbelianMonoid(Integer(7),'a')) True >>> is_FreeAbelianMonoid(FreeMonoid(Integer(7),'a')) False >>> is_FreeAbelianMonoid(FreeMonoid(Integer(0),'')) False