Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/groups/abelian_gps/abelian_group_element.py
8815 views
1
"""
2
Abelian group elements
3
4
AUTHORS:
5
6
- David Joyner (2006-02); based on free_abelian_monoid_element.py, written by David Kohel.
7
8
- David Joyner (2006-05); bug fix in order
9
10
- David Joyner (2006-08); bug fix+new method in pow for negatives+fixed corresponding examples.
11
12
- David Joyner (2009-02): Fixed bug in order.
13
14
- Volker Braun (2012-11) port to new Parent base. Use tuples for immutables.
15
16
17
EXAMPLES:
18
19
Recall an example from abelian groups::
20
21
sage: F = AbelianGroup(5,[4,5,5,7,8],names = list("abcde"))
22
sage: (a,b,c,d,e) = F.gens()
23
sage: x = a*b^2*e*d^20*e^12
24
sage: x
25
a*b^2*d^6*e^5
26
sage: x = a^10*b^12*c^13*d^20*e^12
27
sage: x
28
a^2*b^2*c^3*d^6*e^4
29
sage: y = a^13*b^19*c^23*d^27*e^72
30
sage: y
31
a*b^4*c^3*d^6
32
sage: x*y
33
a^3*b*c*d^5*e^4
34
sage: x.list()
35
[2, 2, 3, 6, 4]
36
"""
37
38
###########################################################################
39
# Copyright (C) 2006 William Stein <[email protected]>
40
# Copyright (C) 2006 David Joyner <[email protected]>
41
# Copyright (C) 2012 Volker Braun <[email protected]>
42
#
43
# Distributed under the terms of the GNU General Public License (GPL)
44
# http://www.gnu.org/licenses/
45
###########################################################################
46
47
48
from sage.rings.integer import Integer
49
from sage.rings.infinity import infinity
50
from sage.rings.arith import LCM, GCD
51
from sage.groups.abelian_gps.element_base import AbelianGroupElementBase
52
53
def is_AbelianGroupElement(x):
54
"""
55
Return true if x is an abelian group element, i.e., an element of
56
type AbelianGroupElement.
57
58
EXAMPLES: Though the integer 3 is in the integers, and the integers
59
have an abelian group structure, 3 is not an AbelianGroupElement::
60
61
sage: from sage.groups.abelian_gps.abelian_group_element import is_AbelianGroupElement
62
sage: is_AbelianGroupElement(3)
63
False
64
sage: F = AbelianGroup(5, [3,4,5,8,7], 'abcde')
65
sage: is_AbelianGroupElement(F.0)
66
True
67
"""
68
return isinstance(x, AbelianGroupElement)
69
70
71
class AbelianGroupElement(AbelianGroupElementBase):
72
"""
73
Elements of an
74
:class:`~sage.groups.abelian_gps.abelian_group.AbelianGroup`
75
76
INPUT:
77
78
- ``x`` -- list/tuple/iterable of integers (the element vector)
79
80
- ``parent`` -- the parent
81
:class:`~sage.groups.abelian_gps.abelian_group.AbelianGroup`
82
83
EXAMPLES::
84
85
sage: F = AbelianGroup(5, [3,4,5,8,7], 'abcde')
86
sage: a, b, c, d, e = F.gens()
87
sage: a^2 * b^3 * a^2 * b^-4
88
a*b^3
89
sage: b^-11
90
b
91
sage: a^-11
92
a
93
sage: a*b in F
94
True
95
"""
96
97
def as_permutation(self):
98
r"""
99
Return the element of the permutation group G (isomorphic to the
100
abelian group A) associated to a in A.
101
102
EXAMPLES::
103
104
sage: G = AbelianGroup(3,[2,3,4],names="abc"); G
105
Multiplicative Abelian group isomorphic to C2 x C3 x C4
106
sage: a,b,c=G.gens()
107
sage: Gp = G.permutation_group(); Gp
108
Permutation Group with generators [(6,7,8,9), (3,4,5), (1,2)]
109
sage: a.as_permutation()
110
(1,2)
111
sage: ap = a.as_permutation(); ap
112
(1,2)
113
sage: ap in Gp
114
True
115
"""
116
from sage.groups.perm_gps.permgroup import PermutationGroup
117
from sage.interfaces.all import gap
118
G = self.parent()
119
invs = list(G.gens_orders())
120
s1 = 'A:=AbelianGroup(%s)'%invs
121
gap.eval(s1)
122
s2 = 'phi:=IsomorphismPermGroup(A)'
123
gap.eval(s2)
124
s3 = "gens := GeneratorsOfGroup(A)"
125
gap.eval(s3)
126
L = self.list()
127
gap.eval("L1:="+str(L))
128
s4 = "L2:=List([1..%s], i->gens[i]^L1[i]);"%len(L)
129
gap.eval(s4)
130
pg = gap.eval("Image(phi,Product(L2))")
131
Gp = G.permutation_group()
132
gp = Gp(pg)
133
return gp
134
135
def word_problem(self, words):
136
"""
137
TODO - this needs a rewrite - see stuff in the matrix_grp
138
directory.
139
140
G and H are abelian groups, g in G, H is a subgroup of G generated
141
by a list (words) of elements of G. If self is in H, return the
142
expression for self as a word in the elements of (words).
143
144
This function does not solve the word problem in Sage. Rather
145
it pushes it over to GAP, which has optimized (non-deterministic)
146
algorithms for the word problem.
147
148
.. warning::
149
150
Don't use E (or other GAP-reserved letters) as a generator
151
name.
152
153
EXAMPLE::
154
155
sage: G = AbelianGroup(2,[2,3], names="xy")
156
sage: x,y = G.gens()
157
sage: x.word_problem([x,y])
158
[[x, 1]]
159
sage: y.word_problem([x,y])
160
[[y, 1]]
161
sage: v = (y*x).word_problem([x,y]); v #random
162
[[x, 1], [y, 1]]
163
sage: prod([x^i for x,i in v]) == y*x
164
True
165
"""
166
from sage.groups.abelian_gps.abelian_group import AbelianGroup, word_problem
167
return word_problem(words,self)
168
169