Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/groups/finitely_presented_named.py
8814 views
1
r"""
2
Named Finitely Presented Groups
3
4
Construct groups of small order and "named" groups as quotients of free groups. These
5
groups are available through tab completion by typing ``groups.presentation.<tab>``
6
or by importing the required methods. Tab completion is made available through
7
Sage's :ref:`group catalog <sage.groups.groups_catalog>`. Some examples are engineered
8
from entries in [THOMAS-WOODS]_.
9
10
Groups available as finite presentations:
11
12
- Alternating group, `A_n` of order `n!/2` --
13
:func:`groups.presentation.Alternating <sage.groups.finitely_presented_named.AlternatingPresentation>`
14
15
- Cyclic group, `C_n` of order `n` --
16
:func:`groups.presentation.Cyclic <sage.groups.finitely_presented_named.CyclicPresentation>`
17
18
- Dicyclic group, nonabelian groups of order `4n` with a unique element of
19
order 2 --
20
:func:`groups.presentation.DiCyclic <sage.groups.finitely_presented_named.DiCyclicPresentation>`
21
22
- Dihedral group, `D_n` of order `2n` --
23
:func:`groups.presentation.Dihedral <sage.groups.finitely_presented_named.DihedralPresentation>`
24
25
- Finitely generated abelian group, `\ZZ_{n_1} \times \ZZ_{n_2} \times \cdots \times \ZZ_{n_k}` --
26
:func:`groups.presentation.FGAbelian <sage.groups.finitely_presented_named.FinitelyGeneratedAbelianPresentation>`
27
28
- Klein four group, `C_2 \times C_2` --
29
:func:`groups.presentation.KleinFour <sage.groups.finitely_presented_named.KleinFourPresentation>`
30
31
- Quaternion group of order 8 --
32
:func:`groups.presentation.Quaternion <sage.groups.finitely_presented_named.QuaternionPresentation>`
33
34
- Symmetric group, `S_n` of order `n!` --
35
:func:`groups.presentation.Symmetric <sage.groups.finitely_presented_named.SymmetricPresentation>`
36
37
AUTHORS:
38
39
- Davis Shurbert (2013-06-21): initial version
40
41
EXAMPLES::
42
43
sage: groups.presentation.Cyclic(4)
44
Finitely presented group < a | a^4 >
45
46
You can also import the desired functions::
47
48
sage: from sage.groups.finitely_presented_named import CyclicPresentation
49
sage: CyclicPresentation(4)
50
Finitely presented group < a | a^4 >
51
"""
52
#*****************************************************************************
53
# Copyright (C) 2013 Davis Shurbert <[email protected]>
54
#
55
# Distributed under the terms of the GNU General Public License (GPL)
56
# http://www.gnu.org/licenses/
57
#*****************************************************************************
58
59
from sage.rings.all import Integer
60
from sage.groups.free_group import FreeGroup
61
from sage.groups.finitely_presented import FinitelyPresentedGroup
62
from sage.libs.gap.libgap import libgap
63
from sage.matrix.constructor import diagonal_matrix
64
from sage.modules.fg_pid.fgp_module import FGP_Module
65
from sage.rings.integer_ring import ZZ
66
from sage.sets.set import Set
67
68
def CyclicPresentation(n):
69
r"""
70
Build cyclic group of order `n` as a finitely presented group.
71
72
INPUT:
73
74
- ``n`` -- The order of the cyclic presentation to be returned.
75
76
OUTPUT:
77
78
The cyclic group of order `n` as finite presentation.
79
80
EXAMPLES::
81
82
sage: groups.presentation.Cyclic(10)
83
Finitely presented group < a | a^10 >
84
sage: n = 8; C = groups.presentation.Cyclic(n)
85
sage: C.as_permutation_group().is_isomorphic(CyclicPermutationGroup(n))
86
True
87
88
TESTS::
89
90
sage: groups.presentation.Cyclic(0)
91
Traceback (most recent call last):
92
...
93
ValueError: finitely presented group order must be positive
94
"""
95
n = Integer(n)
96
if n < 1:
97
raise ValueError('finitely presented group order must be positive')
98
F = FreeGroup( 'a' )
99
rls = F([1])**n,
100
return FinitelyPresentedGroup( F, rls )
101
102
def FinitelyGeneratedAbelianPresentation(int_list):
103
r"""
104
Return canonical presentation of finitely generated abelian group.
105
106
INPUT:
107
108
- ``int_list`` -- List of integers defining the group to be returned, the defining list
109
is reduced to the invariants of the input list before generating the corresponding
110
group.
111
112
OUTPUT:
113
114
Finitely generated abelian group, `\ZZ_{n_1} \times \ZZ_{n_2} \times \cdots \times \ZZ_{n_k}`
115
as a finite presentation, where `n_i` forms the invariants of the input list.
116
117
EXAMPLES::
118
119
sage: groups.presentation.FGAbelian([2,2])
120
Finitely presented group < a, b | a^2, b^2, a^-1*b^-1*a*b >
121
sage: groups.presentation.FGAbelian([2,3])
122
Finitely presented group < a | a^6 >
123
sage: groups.presentation.FGAbelian([2,4])
124
Finitely presented group < a, b | a^2, b^4, a^-1*b^-1*a*b >
125
126
You can create free abelian groups::
127
128
sage: groups.presentation.FGAbelian([0])
129
Finitely presented group < a | >
130
sage: groups.presentation.FGAbelian([0,0])
131
Finitely presented group < a, b | a^-1*b^-1*a*b >
132
sage: groups.presentation.FGAbelian([0,0,0])
133
Finitely presented group < a, b, c | a^-1*c^-1*a*c, a^-1*b^-1*a*b, c^-1*b^-1*c*b >
134
135
And various infinite abelian groups::
136
137
sage: groups.presentation.FGAbelian([0,2])
138
Finitely presented group < a, b | a^2, a^-1*b^-1*a*b >
139
sage: groups.presentation.FGAbelian([0,2,2])
140
Finitely presented group < a, b, c | a^2, b^2, a^-1*c^-1*a*c, a^-1*b^-1*a*b, c^-1*b^-1*c*b >
141
142
Outputs are reduced to minimal generators and relations::
143
144
sage: groups.presentation.FGAbelian([3,5,2,7,3])
145
Finitely presented group < a, b | a^3, b^210, a^-1*b^-1*a*b >
146
sage: groups.presentation.FGAbelian([3,210])
147
Finitely presented group < a, b | a^3, b^210, a^-1*b^-1*a*b >
148
149
The trivial group is an acceptable output::
150
151
sage: groups.presentation.FGAbelian([])
152
Finitely presented group < | >
153
sage: groups.presentation.FGAbelian([1])
154
Finitely presented group < | >
155
sage: groups.presentation.FGAbelian([1,1,1,1,1,1,1,1,1,1])
156
Finitely presented group < | >
157
158
Input list must consist of positive integers::
159
160
sage: groups.presentation.FGAbelian([2,6,3,9,-4])
161
Traceback (most recent call last):
162
...
163
ValueError: input list must contain nonnegative entries
164
sage: groups.presentation.FGAbelian([2,'a',4])
165
Traceback (most recent call last):
166
...
167
TypeError: unable to convert x (=a) to an integer
168
169
TESTS::
170
171
sage: ag = groups.presentation.FGAbelian([2,2])
172
sage: ag.as_permutation_group().is_isomorphic(groups.permutation.KleinFour())
173
True
174
sage: G = groups.presentation.FGAbelian([2,4,8])
175
sage: C2 = CyclicPermutationGroup(2)
176
sage: C4 = CyclicPermutationGroup(4)
177
sage: C8 = CyclicPermutationGroup(8)
178
sage: gg = (C2.direct_product(C4)[0]).direct_product(C8)[0]
179
sage: gg.is_isomorphic(G.as_permutation_group())
180
True
181
sage: all([groups.presentation.FGAbelian([i]).as_permutation_group().is_isomorphic(groups.presentation.Cyclic(i).as_permutation_group()) for i in [2..35]])
182
True
183
"""
184
from sage.groups.free_group import _lexi_gen
185
check_ls = [Integer(x) for x in int_list if Integer(x) >= 0]
186
if len(check_ls) != len(int_list):
187
raise ValueError('input list must contain nonnegative entries')
188
189
col_sp = diagonal_matrix(int_list).column_space()
190
invariants = FGP_Module(ZZ**(len(int_list)), col_sp).invariants()
191
name_gen = _lexi_gen()
192
F = FreeGroup([name_gen.next() for i in invariants])
193
ret_rls = [F([i+1])**invariants[i] for i in range(len(invariants)) if invariants[i]!=0]
194
195
# Build commutator relations
196
gen_pairs = list(Set(F.gens()).subsets(2))
197
ret_rls = ret_rls + [x[0]**(-1)*x[1]**(-1)*x[0]*x[1] for x in gen_pairs]
198
return FinitelyPresentedGroup(F, tuple(ret_rls))
199
200
def DihedralPresentation(n):
201
r"""
202
Build the Dihedral group of order `2n` as a finitely presented group.
203
204
INPUT:
205
206
- ``n`` -- The size of the set that `D_n` is acting on.
207
208
OUTPUT:
209
210
Dihedral group of order `2n`.
211
212
EXAMPLES::
213
214
sage: D = groups.presentation.Dihedral(7); D
215
Finitely presented group < a, b | a^7, b^2, (a*b)^2 >
216
sage: D.as_permutation_group().is_isomorphic(DihedralGroup(7))
217
True
218
219
TESTS::
220
221
sage: n = 9
222
sage: D = groups.presentation.Dihedral(n)
223
sage: D.ngens() == 2
224
True
225
sage: groups.presentation.Dihedral(0)
226
Traceback (most recent call last):
227
...
228
ValueError: finitely presented group order must be positive
229
"""
230
n = Integer( n )
231
if n < 1:
232
raise ValueError('finitely presented group order must be positive')
233
F = FreeGroup([ 'a', 'b' ])
234
rls = F([1])**n, F([2])**2, (F([1])*F([2]))**2
235
return FinitelyPresentedGroup( F, rls )
236
237
def DiCyclicPresentation(n):
238
r"""
239
Build the dicyclic group of order `4n`, for `n \geq 2`, as a finitely
240
presented group.
241
242
INPUT:
243
244
- ``n`` -- positive integer, 2 or greater, determining the order of
245
the group (`4n`).
246
247
OUTPUT:
248
249
The dicyclic group of order `4n` is defined by the presentation
250
251
.. MATH::
252
253
\langle a, x \mid a^{2n}=1, x^{2}=a^{n}, x^{-1}ax=a^{-1} \rangle
254
255
.. NOTE::
256
257
This group is also available as a permutation group via
258
:class:`groups.permutation.DiCyclic <sage.groups.perm_gps.permgroup_named.DiCyclicGroup>`.
259
260
EXAMPLES::
261
262
sage: D = groups.presentation.DiCyclic(9); D
263
Finitely presented group < a, b | a^18, b^2*a^-9, b^-1*a*b*a >
264
sage: D.as_permutation_group().is_isomorphic(groups.permutation.DiCyclic(9))
265
True
266
267
TESTS::
268
269
sage: Q = groups.presentation.DiCyclic(2)
270
sage: Q.as_permutation_group().is_isomorphic(QuaternionGroup())
271
True
272
sage: all([groups.presentation.DiCyclic(i).as_permutation_group(
273
....: ).is_isomorphic(groups.permutation.DiCyclic(i)) for i in [5,8,12,2^5]])
274
True
275
sage: groups.presentation.DiCyclic(1)
276
Traceback (most recent call last):
277
...
278
ValueError: input integer must be greater than 1
279
"""
280
n = Integer(n)
281
if n < 2:
282
raise ValueError('input integer must be greater than 1')
283
284
F = FreeGroup(['a','b'])
285
rls = F([1])**(2*n), F([2,2])*F([-1])**n, F([-2,1,2,1])
286
return FinitelyPresentedGroup(F, rls)
287
288
def SymmetricPresentation(n):
289
r"""
290
Build the Symmetric group of order `n!` as a finitely presented group.
291
292
INPUT:
293
294
- ``n`` -- The size of the underlying set of arbitrary symbols being acted
295
on by the Symmetric group of order `n!`.
296
297
OUTPUT:
298
299
Symmetric group as a finite presentation, implementation uses GAP to find an
300
isomorphism from a permutation representation to a finitely presented group
301
representation. Due to this fact, the exact output presentation may not be
302
the same for every method call on a constant ``n``.
303
304
EXAMPLES::
305
306
sage: S4 = groups.presentation.Symmetric(4)
307
sage: S4.as_permutation_group().is_isomorphic(SymmetricGroup(4))
308
True
309
310
TESTS::
311
312
sage: S = [groups.presentation.Symmetric(i) for i in range(1,4)]; S[0].order()
313
1
314
sage: S[1].order(), S[2].as_permutation_group().is_isomorphic(DihedralGroup(3))
315
(2, True)
316
sage: S5 = groups.presentation.Symmetric(5)
317
sage: perm_S5 = S5.as_permutation_group(); perm_S5.is_isomorphic(SymmetricGroup(5))
318
True
319
sage: groups.presentation.Symmetric(8).order()
320
40320
321
"""
322
from sage.groups.perm_gps.permgroup_named import SymmetricGroup
323
from sage.groups.free_group import _lexi_gen
324
325
n = Integer(n)
326
perm_rep = SymmetricGroup(n)
327
GAP_fp_rep = libgap.Image(libgap.IsomorphismFpGroupByGenerators(perm_rep, perm_rep.gens()))
328
image_gens = GAP_fp_rep.FreeGeneratorsOfFpGroup()
329
name_itr = _lexi_gen() # Python generator object for variable names
330
F = FreeGroup([name_itr.next() for x in perm_rep.gens()])
331
ret_rls = tuple([F(rel_word.TietzeWordAbstractWord(image_gens).sage())
332
for rel_word in GAP_fp_rep.RelatorsOfFpGroup()])
333
return FinitelyPresentedGroup(F,ret_rls)
334
335
def QuaternionPresentation():
336
r"""
337
Build the Quaternion group of order 8 as a finitely presented group.
338
339
OUTPUT:
340
341
Quaternion group as a finite presentation.
342
343
EXAMPLES::
344
345
sage: Q = groups.presentation.Quaternion(); Q
346
Finitely presented group < a, b | a^4, b^2*a^-2, a*b*a*b^-1 >
347
sage: Q.as_permutation_group().is_isomorphic(QuaternionGroup())
348
True
349
350
TESTS::
351
352
sage: Q = groups.presentation.Quaternion()
353
sage: Q.order(), Q.is_abelian()
354
(8, False)
355
sage: Q.is_isomorphic(groups.presentation.DiCyclic(2))
356
True
357
"""
358
F = FreeGroup(['a','b'])
359
rls = F([1])**4, F([2,2,-1,-1]), F([1,2,1,-2])
360
return FinitelyPresentedGroup(F, rls)
361
362
def AlternatingPresentation(n):
363
r"""
364
Build the Alternating group of order `n!/2` as a finitely presented group.
365
366
INPUT:
367
368
- ``n`` -- The size of the underlying set of arbitrary symbols being acted
369
on by the Alternating group of order `n!/2`.
370
371
OUTPUT:
372
373
Alternating group as a finite presentation, implementation uses GAP to find an
374
isomorphism from a permutation representation to a finitely presented group
375
representation. Due to this fact, the exact output presentation may not be
376
the same for every method call on a constant ``n``.
377
378
EXAMPLES::
379
380
sage: A6 = groups.presentation.Alternating(6)
381
sage: A6.as_permutation_group().is_isomorphic(AlternatingGroup(6)), A6.order()
382
(True, 360)
383
384
TESTS::
385
386
sage: #even permutation test..
387
sage: A1 = groups.presentation.Alternating(1); A2 = groups.presentation.Alternating(2)
388
sage: A1.is_isomorphic(A2), A1.order()
389
(True, 1)
390
sage: A3 = groups.presentation.Alternating(3); A3.order(), A3.as_permutation_group().is_cyclic()
391
(3, True)
392
sage: A8 = groups.presentation.Alternating(8); A8.order()
393
20160
394
"""
395
from sage.groups.perm_gps.permgroup_named import AlternatingGroup
396
from sage.groups.free_group import _lexi_gen
397
398
n = Integer(n)
399
perm_rep = AlternatingGroup(n)
400
GAP_fp_rep = libgap.Image(libgap.IsomorphismFpGroupByGenerators(perm_rep, perm_rep.gens()))
401
image_gens = GAP_fp_rep.FreeGeneratorsOfFpGroup()
402
name_itr = _lexi_gen() # Python generator object for variable names
403
F = FreeGroup([name_itr.next() for x in perm_rep.gens()])
404
ret_rls = tuple([F(rel_word.TietzeWordAbstractWord(image_gens).sage())
405
for rel_word in GAP_fp_rep.RelatorsOfFpGroup()])
406
return FinitelyPresentedGroup(F,ret_rls)
407
408
def KleinFourPresentation():
409
r"""
410
Build the Klein group of order `4` as a finitely presented group.
411
412
OUTPUT:
413
414
Klein four group (`C_2 \times C_2`) as a finitely presented group.
415
416
EXAMPLES::
417
418
sage: K = groups.presentation.KleinFour(); K
419
Finitely presented group < a, b | a^2, b^2, a^-1*b^-1*a*b >
420
"""
421
F = FreeGroup(['a','b'])
422
rls = F([1])**2, F([2])**2, F([-1])*F([-2])*F([1])*F([2])
423
return FinitelyPresentedGroup(F, rls)
424
425