Coverage for local/lib/python2.7/site-packages/sage/groups/indexed_free_group.py : 93%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Indexed Free Groups
Free groups and free abelian groups implemented using an indexed set of generators.
AUTHORS:
- Travis Scrimshaw (2013-10-16): Initial version """
############################################################################## # Copyright (C) 2013 Travis Scrimshaw <tscrim at ucdavis.edu> # # Distributed under the terms of the GNU General Public License (GPL) # # The full text of the GPL is available at: # # http://www.gnu.org/licenses/ ##############################################################################
IndexedMonoidElement, IndexedFreeMonoidElement, IndexedFreeAbelianMonoidElement)
""" Base class for free (abelian) groups whose generators are indexed by a set.
TESTS:
We check finite properties::
sage: G = Groups().free(index_set=ZZ) sage: G.is_finite() False sage: G = Groups().free(index_set='abc') sage: G.is_finite() False sage: G = Groups().free(index_set=[]) sage: G.is_finite() True
::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: G.is_finite() False sage: G = Groups().Commutative().free(index_set='abc') sage: G.is_finite() False sage: G = Groups().Commutative().free(index_set=[]) sage: G.is_finite() True """ r""" Return the number of elements of ``self``, which is `\infty` unless this is the trivial group.
EXAMPLES::
sage: G = Groups().free(index_set=ZZ) sage: G.order() +Infinity sage: G = Groups().Commutative().free(index_set='abc') sage: G.order() +Infinity sage: G = Groups().Commutative().free(index_set=[]) sage: G.order() 1 """
""" Return the rank of ``self``.
This is the number of generators of ``self``.
EXAMPLES::
sage: G = Groups().free(index_set=ZZ) sage: G.rank() +Infinity sage: G = Groups().free(index_set='abc') sage: G.rank() 3 sage: G = Groups().free(index_set=[]) sage: G.rank() 0
::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: G.rank() +Infinity sage: G = Groups().Commutative().free(index_set='abc') sage: G.rank() 3 sage: G = Groups().Commutative().free(index_set=[]) sage: G.rank() 0 """
def group_generators(self): """ Return the group generators of ``self``.
EXAMPLES::
sage: G = Groups.free(index_set=ZZ) sage: G.group_generators() Lazy family (Generator map from Integer Ring to Free group indexed by Integer Ring(i))_{i in Integer Ring} sage: G = Groups().free(index_set='abcde') sage: sorted(G.group_generators()) [F['a'], F['b'], F['c'], F['d'], F['e']] """
""" An indexed free group.
EXAMPLES::
sage: G = Groups().free(index_set=ZZ) sage: G Free group indexed by Integer Ring sage: G = Groups().free(index_set='abcde') sage: G Free group indexed by {'a', 'b', 'c', 'd', 'e'} """ """ Initialize ``self``.
TESTS::
sage: G = Groups().free(index_set=ZZ) sage: TestSuite(G).run() sage: G = Groups().free(index_set='abc') sage: TestSuite(G).run() """
""" Return a string representation of ``self``
TESTS::
sage: Groups().free(index_set=ZZ) # indirect doctest Free group indexed by Integer Ring """
def one(self): """ Return the identity element of ``self``.
EXAMPLES::
sage: G = Groups().free(ZZ) sage: G.one() 1 """
""" The generator indexed by ``x`` of ``self``.
EXAMPLES::
sage: G = Groups().free(index_set=ZZ) sage: G.gen(0) F[0] sage: G.gen(2) F[2] """ raise IndexError("{} is not in the index set".format(x)) except TypeError: # Backup (if it is a string) return self.element_class(self, ((x,1),))
""" Return the length of ``self``.
EXAMPLES::
sage: G = Groups().free(index_set=ZZ) sage: a,b,c,d,e = [G.gen(i) for i in range(5)] sage: elt = a*c^-3*b^-2*a sage: elt.length() 7 sage: len(elt) 7
sage: G = Groups().free(index_set=ZZ) sage: a,b,c,d,e = [G.gen(i) for i in range(5)] sage: elt = a*c^-3*b^-2*a sage: elt.length() 7 sage: len(elt) 7 """
""" Multiply ``self`` by ``other``.
EXAMPLES::
sage: G = Groups().free(index_set=ZZ) sage: a,b,c,d,e = [G.gen(i) for i in range(5)] sage: a*b^2*e*d F[0]*F[1]^2*F[4]*F[3] sage: (a*b^2*d^2) * (d^-4*b*e) F[0]*F[1]^2*F[3]^-2*F[1]*F[4] sage: (a*b^-2*d^2) * (d^-2*b^2*a^-1) 1 """
""" Return the inverse of ``self``.
EXAMPLES::
sage: G = Groups().free(index_set=ZZ) sage: a,b,c,d,e = [G.gen(i) for i in range(5)] sage: x = a*b^2*e^-1*d; ~x F[3]^-1*F[4]*F[1]^-2*F[0]^-1 sage: x * ~x 1 """ tuple((x[0], -x[1]) for x in reversed(self._monomial)))
""" Return ``self`` as a word represented as a list whose entries are the pairs ``(i, s)`` where ``i`` is the index and ``s`` is the sign.
EXAMPLES::
sage: G = Groups().free(index_set=ZZ) sage: a,b,c,d,e = [G.gen(i) for i in range(5)] sage: x = a*b^2*e*a^-1 sage: x.to_word_list() [(0, 1), (1, 1), (1, 1), (4, 1), (0, -1)] """ for dummy in range(abs(e))]
""" An indexed free abelian group.
EXAMPLES::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: G Free abelian group indexed by Integer Ring sage: G = Groups().Commutative().free(index_set='abcde') sage: G Free abelian group indexed by {'a', 'b', 'c', 'd', 'e'} """ """ Initialize ``self``.
TESTS::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: TestSuite(G).run() sage: G = Groups().Commutative().free(index_set='abc') sage: TestSuite(G).run() """
""" TESTS::
sage: Groups.Commutative().free(index_set=ZZ) Free abelian group indexed by Integer Ring """
""" Create an element of ``self`` from ``x``.
EXAMPLES::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: G(G.gen(2)) F[2] sage: G([[1, 3], [-2, 12]]) F[-2]^12*F[1]^3 sage: G({1: 3, -2: 12}) F[-2]^12*F[1]^3 sage: G(-5) Traceback (most recent call last): ... TypeError: unable to convert -5, use gen() instead
TESTS::
sage: G([(1, 3), (1, -5)]) F[1]^-2
sage: G([(42, 0)]) 1 sage: G([(42, 3), (42, -3)]) 1 sage: G({42: 0}) 1 """ else:
def one(self): """ Return the identity element of ``self``.
EXAMPLES::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: G.one() 1 """
""" The generator indexed by ``x`` of ``self``.
EXAMPLES::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: G.gen(0) F[0] sage: G.gen(2) F[2] """ raise IndexError("{} is not in the index set".format(x)) except TypeError: # Backup (if it is a string) return self.element_class(self, {x:1})
""" Multiply ``self`` by ``other``.
EXAMPLES::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: a,b,c,d,e = [G.gen(i) for i in range(5)] sage: a*b^2*e^-1*d F[0]*F[1]^2*F[3]*F[4]^-1 sage: (a*b^2*d^2) * (d^-4*b^-2*e) F[0]*F[3]^-2*F[4] sage: (a*b^-2*d^2) * (d^-2*b^2*a^-1) 1 """ blas.add(self._monomial, other._monomial))
""" Return the inverse of ``self``.
EXAMPLES::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: a,b,c,d,e = [G.gen(i) for i in range(5)] sage: x = a*b^2*e^-1*d; ~x F[0]^-1*F[1]^-2*F[3]^-1*F[4] sage: x * ~x 1 """
""" Return the division of ``self`` by ``a``.
EXAMPLES::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: a,b,c,d,e = [G.gen(i) for i in range(5)] sage: elt = a*b*c^3*d^2; elt F[0]*F[1]*F[2]^3*F[3]^2 sage: elt // a F[1]*F[2]^3*F[3]^2 sage: elt // c F[0]*F[1]*F[2]^2*F[3]^2 sage: elt // (a*b*d^2) F[2]^3 sage: elt // a^4 F[0]^-3*F[1]*F[2]^3*F[3]^2 """
""" Raise ``self`` to the power of ``n``.
EXAMPLES::
sage: G = Groups().Commutative().free(index_set=ZZ) sage: a,b,c,d,e = [G.gen(i) for i in range(5)] sage: x = a*b^2*e^-1*d; x F[0]*F[1]^2*F[3]*F[4]^-1 sage: x^3 F[0]^3*F[1]^6*F[3]^3*F[4]^-3 sage: x^0 1 sage: x^-3 F[0]^-3*F[1]^-6*F[3]^-3*F[4]^3 """ raise TypeError("Argument n (= {}) must be an integer".format(n))
|