71
71
from sage .rings .integer_ring import ZZ
72
72
73
73
74
- def CyclicPresentation (n ):
74
+ def CyclicPresentation (n ) -> FinitelyPresentedGroup :
75
75
r"""
76
76
Build cyclic group of order `n` as a finitely presented group.
77
77
@@ -195,15 +195,18 @@ def FinitelyGeneratedAbelianPresentation(int_list):
195
195
invariants = FGP_Module (ZZ ** (len (int_list )), col_sp ).invariants ()
196
196
name_gen = _lexi_gen ()
197
197
F = FreeGroup ([next (name_gen ) for i in invariants ])
198
- ret_rls = [F ([i + 1 ])** invariants [i ] for i in range (len (invariants )) if invariants [i ] != 0 ]
198
+ ret_rls = [F ([i + 1 ])** invariants [i ] for i in range (len (invariants ))
199
+ if invariants [i ] != 0 ]
199
200
200
201
# Build commutator relations
201
- gen_pairs = [[F .gen (i ),F .gen (j )] for i in range (F .ngens ()- 1 ) for j in range (i + 1 ,F .ngens ())]
202
- ret_rls = ret_rls + [x [0 ]** (- 1 )* x [1 ]** (- 1 )* x [0 ]* x [1 ] for x in gen_pairs ]
202
+ gen_pairs = [[F .gen (i ), F .gen (j )] for i in range (F .ngens () - 1 )
203
+ for j in range (i + 1 , F .ngens ())]
204
+ ret_rls = ret_rls + [x [0 ]** (- 1 ) * x [1 ]** (- 1 ) * x [0 ] * x [1 ]
205
+ for x in gen_pairs ]
203
206
return FinitelyPresentedGroup (F , tuple (ret_rls ))
204
207
205
208
206
- def FinitelyGeneratedHeisenbergPresentation (n = 1 , p = 0 ):
209
+ def FinitelyGeneratedHeisenbergPresentation (n = 1 , p = 0 ) -> FinitelyPresentedGroup :
207
210
r"""
208
211
Return a finite presentation of the Heisenberg group.
209
212
@@ -265,14 +268,14 @@ def FinitelyGeneratedHeisenbergPresentation(n=1, p=0):
265
268
raise ValueError ('n must be a positive integer' )
266
269
267
270
# generators' names are x1, .., xn, y1, .., yn, z
268
- vx = ['x' + str (i ) for i in range (1 ,n + 1 )]
269
- vy = ['y' + str (i ) for i in range (1 ,n + 1 )]
271
+ vx = ['x' + str (i ) for i in range (1 , n + 1 )]
272
+ vy = ['y' + str (i ) for i in range (1 , n + 1 )]
270
273
str_generators = ', ' .join (vx + vy + ['z' ])
271
274
272
275
F = FreeGroup (str_generators )
273
- x = F .gens ()[0 :n ] # list of generators x1, x2, ..., xn
274
- y = F .gens ()[n :2 * n ] # list of generators x1, x2, ..., xn
275
- z = F .gen (n * 2 )
276
+ x = F .gens ()[0 :n ] # list of generators x1, x2, ..., xn
277
+ y = F .gens ()[n :2 * n ] # list of generators x1, x2, ..., xn
278
+ z = F .gen (n * 2 )
276
279
277
280
def commutator (a , b ):
278
281
return a * b * a ** - 1 * b ** - 1
@@ -294,7 +297,7 @@ def commutator(a, b):
294
297
return FinitelyPresentedGroup (F , tuple (rls ))
295
298
296
299
297
- def DihedralPresentation (n ):
300
+ def DihedralPresentation (n ) -> FinitelyPresentedGroup :
298
301
r"""
299
302
Build the Dihedral group of order `2n` as a finitely presented group.
300
303
@@ -322,15 +325,15 @@ def DihedralPresentation(n):
322
325
...
323
326
ValueError: finitely presented group order must be positive
324
327
"""
325
- n = Integer ( n )
328
+ n = Integer (n )
326
329
if n < 1 :
327
330
raise ValueError ('finitely presented group order must be positive' )
328
- F = FreeGroup ([ 'a' , 'b' ])
329
- rls = F ([1 ])** n , F ([2 ])** 2 , (F ([1 ])* F ([2 ]))** 2
330
- return FinitelyPresentedGroup ( F , rls )
331
+ F = FreeGroup (['a' , 'b' ])
332
+ rls = F ([1 ])** n , F ([2 ])** 2 , (F ([1 ]) * F ([2 ]))** 2
333
+ return FinitelyPresentedGroup (F , rls )
331
334
332
335
333
- def DiCyclicPresentation (n ):
336
+ def DiCyclicPresentation (n ) -> FinitelyPresentedGroup :
334
337
r"""
335
338
Build the dicyclic group of order `4n`, for `n \geq 2`, as a finitely
336
339
presented group.
@@ -376,12 +379,12 @@ def DiCyclicPresentation(n):
376
379
if n < 2 :
377
380
raise ValueError ('input integer must be greater than 1' )
378
381
379
- F = FreeGroup (['a' ,'b' ])
380
- rls = F ([1 ])** (2 * n ), F ([2 ,2 ])* F ([- 1 ])** n , F ([- 2 ,1 , 2 , 1 ])
382
+ F = FreeGroup (['a' , 'b' ])
383
+ rls = F ([1 ])** (2 * n ), F ([2 , 2 ]) * F ([- 1 ])** n , F ([- 2 , 1 , 2 , 1 ])
381
384
return FinitelyPresentedGroup (F , rls )
382
385
383
386
384
- def SymmetricPresentation (n ):
387
+ def SymmetricPresentation (n ) -> FinitelyPresentedGroup :
385
388
r"""
386
389
Build the Symmetric group of order `n!` as a finitely presented group.
387
390
@@ -432,7 +435,7 @@ def SymmetricPresentation(n):
432
435
return FinitelyPresentedGroup (F , ret_rls )
433
436
434
437
435
- def QuaternionPresentation ():
438
+ def QuaternionPresentation () -> FinitelyPresentedGroup :
436
439
r"""
437
440
Build the Quaternion group of order 8 as a finitely presented group.
438
441
@@ -453,12 +456,12 @@ def QuaternionPresentation():
453
456
sage: Q.is_isomorphic(groups.presentation.DiCyclic(2))
454
457
True
455
458
"""
456
- F = FreeGroup (['a' ,'b' ])
457
- rls = F ([1 ])** 4 , F ([2 ,2 , - 1 ,- 1 ]), F ([1 ,2 , 1 , - 2 ])
459
+ F = FreeGroup (['a' , 'b' ])
460
+ rls = F ([1 ])** 4 , F ([2 , 2 , - 1 , - 1 ]), F ([1 , 2 , 1 , - 2 ])
458
461
return FinitelyPresentedGroup (F , rls )
459
462
460
463
461
- def AlternatingPresentation (n ):
464
+ def AlternatingPresentation (n ) -> FinitelyPresentedGroup :
462
465
r"""
463
466
Build the Alternating group of order `n!/2` as a finitely presented group.
464
467
@@ -509,7 +512,7 @@ def AlternatingPresentation(n):
509
512
return FinitelyPresentedGroup (F , ret_rls )
510
513
511
514
512
- def KleinFourPresentation ():
515
+ def KleinFourPresentation () -> FinitelyPresentedGroup :
513
516
r"""
514
517
Build the Klein group of order `4` as a finitely presented group.
515
518
@@ -520,12 +523,12 @@ def KleinFourPresentation():
520
523
sage: K = groups.presentation.KleinFour(); K
521
524
Finitely presented group < a, b | a^2, b^2, a^-1*b^-1*a*b >
522
525
"""
523
- F = FreeGroup (['a' ,'b' ])
524
- rls = F ([1 ])** 2 , F ([2 ])** 2 , F ([- 1 ])* F ([- 2 ])* F ([1 ])* F ([2 ])
526
+ F = FreeGroup (['a' , 'b' ])
527
+ rls = F ([1 ])** 2 , F ([2 ])** 2 , F ([- 1 ]) * F ([- 2 ]) * F ([1 ]) * F ([2 ])
525
528
return FinitelyPresentedGroup (F , rls )
526
529
527
530
528
- def BinaryDihedralPresentation (n ):
531
+ def BinaryDihedralPresentation (n ) -> FinitelyPresentedGroup :
529
532
r"""
530
533
Build a binary dihedral group of order `4n` as a finitely presented group.
531
534
@@ -555,12 +558,12 @@ def BinaryDihedralPresentation(n):
555
558
....: assert P.is_isomorphic(M)
556
559
"""
557
560
F = FreeGroup ('x,y,z' )
558
- x ,y , z = F .gens ()
559
- rls = (x ** - 2 * y ** 2 , x ** - 2 * z ** n , x ** - 2 * x * y * z )
561
+ x , y , z = F .gens ()
562
+ rls = (x ** - 2 * y ** 2 , x ** - 2 * z ** n , x ** - 2 * x * y * z )
560
563
return FinitelyPresentedGroup (F , rls )
561
564
562
565
563
- def CactusPresentation (n ):
566
+ def CactusPresentation (n ) -> FinitelyPresentedGroup :
564
567
r"""
565
568
Build the `n`-fruit cactus group as a finitely presented group.
566
569
@@ -579,11 +582,11 @@ def CactusPresentation(n):
579
582
rls = [g ** 2 for g in gens ]
580
583
Gg = G .group_generators ()
581
584
K = Gg .keys ()
582
- for i ,key in enumerate (K ):
583
- for j ,key2 in enumerate (K ):
585
+ for i , key in enumerate (K ):
586
+ for j , key2 in enumerate (K ):
584
587
if i == j :
585
588
continue
586
- x ,y = (Gg [key ] * Gg [key2 ])._data
589
+ x , y = (Gg [key ] * Gg [key2 ])._data
587
590
if key == x and key2 == y :
588
591
continue
589
592
elt = gens [i ] * gens [j ] * ~ gens [K .index (y )] * ~ gens [K .index (x )]
0 commit comments