Abelian Monoid Elements - Monoids

Skip to content
Back to top
View this page
Edit this page

# Abelian Monoid Elements

AUTHORS:

- David Kohel (2005-09)

EXAMPLES:

Recall the example from abelian monoids:

Sage

    sage: F = FreeAbelianMonoid(5,names = list("abcde"))
    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]

Python

    >>> from sage.all import *
    >>> F = FreeAbelianMonoid(Integer(5),names = list("abcde"))
    >>> (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]

The list is a copy, so changing the list does not change the element:

Sage

    sage: x.list()[0] = 0
    sage: x
    a^7*b^2*d*e

[Python]

    >>> from sage.all import *
    >>> x.list()[Integer(0)] = Integer(0)
    >>> x
    a^7*b^2*d*e

class sage.monoids.free_abelian_monoid_element.FreeAbelianMonoidElement

  Bases: `MonoidElement`

  Create the element `x` of the FreeAbelianMonoid `parent`.

  EXAMPLES:

  Sage

      sage: F = FreeAbelianMonoid(5, 'abcde')
      sage: F
      Free abelian monoid on 5 generators (a, b, c, d, e)
      sage: F(1)
      1
      sage: F(2)
      Traceback (most recent call last):
      ...
      TypeError: argument x (= 2) is of the wrong type
      sage: F(int(1))
      1
      sage: a, b, c, d, e = F.gens()
      sage: a^2 * b^3 * a^2 * b^4
      a^4*b^7
      sage: F = FreeAbelianMonoid(5, 'abcde')
      sage: a, b, c, d, e = F.gens()
      sage: a in F
      True
      sage: a*b in F
      True

  Python

      >>> from sage.all import *
      >>> F = FreeAbelianMonoid(Integer(5), 'abcde')
      >>> F
      Free abelian monoid on 5 generators (a, b, c, d, e)
      >>> F(Integer(1))
      1
      >>> F(Integer(2))
      Traceback (most recent call last):
      ...
      TypeError: argument x (= 2) is of the wrong type
      >>> F(int(Integer(1)))
      1
      >>> a, b, c, d, e = F.gens()
      >>> a**Integer(2) * b**Integer(3) * a**Integer(2) * b**Integer(4)
      a^4*b^7
      >>> F = FreeAbelianMonoid(Integer(5), 'abcde')
      >>> a, b, c, d, e = F.gens()
      >>> a in F
      True
      >>> a*b in F
      True

  list()

    Return the underlying list used to represent `self`.

    If this is a monoid in an abelian monoid on \(n\) generators, then this is a list of nonnegative integers of length \(n\).

    EXAMPLES:

    Sage

        sage: F = FreeAbelianMonoid(5, 'abcde')
        sage: (a, b, c, d, e) = F.gens()
        sage: a.list()
        [1, 0, 0, 0, 0]

    Python

        >>> from sage.all import *
        >>> F = FreeAbelianMonoid(Integer(5), 'abcde')
        >>> (a, b, c, d, e) = F.gens()
        >>> a.list()
        [1, 0, 0, 0, 0]