7171from sage .rings .integer_ring import ZZ
7272
7373
74- def CyclicPresentation (n ):
74+ def CyclicPresentation (n ) -> FinitelyPresentedGroup :
7575 r"""
7676 Build cyclic group of order `n` as a finitely presented group.
7777
@@ -195,15 +195,18 @@ def FinitelyGeneratedAbelianPresentation(int_list):
195195 invariants = FGP_Module (ZZ ** (len (int_list )), col_sp ).invariants ()
196196 name_gen = _lexi_gen ()
197197 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 ]
199200
200201 # 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 ]
203206 return FinitelyPresentedGroup (F , tuple (ret_rls ))
204207
205208
206- def FinitelyGeneratedHeisenbergPresentation (n = 1 , p = 0 ):
209+ def FinitelyGeneratedHeisenbergPresentation (n = 1 , p = 0 ) -> FinitelyPresentedGroup :
207210 r"""
208211 Return a finite presentation of the Heisenberg group.
209212
@@ -265,14 +268,14 @@ def FinitelyGeneratedHeisenbergPresentation(n=1, p=0):
265268 raise ValueError ('n must be a positive integer' )
266269
267270 # 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 )]
270273 str_generators = ', ' .join (vx + vy + ['z' ])
271274
272275 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 )
276279
277280 def commutator (a , b ):
278281 return a * b * a ** - 1 * b ** - 1
@@ -294,7 +297,7 @@ def commutator(a, b):
294297 return FinitelyPresentedGroup (F , tuple (rls ))
295298
296299
297- def DihedralPresentation (n ):
300+ def DihedralPresentation (n ) -> FinitelyPresentedGroup :
298301 r"""
299302 Build the Dihedral group of order `2n` as a finitely presented group.
300303
@@ -322,15 +325,15 @@ def DihedralPresentation(n):
322325 ...
323326 ValueError: finitely presented group order must be positive
324327 """
325- n = Integer ( n )
328+ n = Integer (n )
326329 if n < 1 :
327330 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 )
331334
332335
333- def DiCyclicPresentation (n ):
336+ def DiCyclicPresentation (n ) -> FinitelyPresentedGroup :
334337 r"""
335338 Build the dicyclic group of order `4n`, for `n \geq 2`, as a finitely
336339 presented group.
@@ -376,12 +379,12 @@ def DiCyclicPresentation(n):
376379 if n < 2 :
377380 raise ValueError ('input integer must be greater than 1' )
378381
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 ])
381384 return FinitelyPresentedGroup (F , rls )
382385
383386
384- def SymmetricPresentation (n ):
387+ def SymmetricPresentation (n ) -> FinitelyPresentedGroup :
385388 r"""
386389 Build the Symmetric group of order `n!` as a finitely presented group.
387390
@@ -432,7 +435,7 @@ def SymmetricPresentation(n):
432435 return FinitelyPresentedGroup (F , ret_rls )
433436
434437
435- def QuaternionPresentation ():
438+ def QuaternionPresentation () -> FinitelyPresentedGroup :
436439 r"""
437440 Build the Quaternion group of order 8 as a finitely presented group.
438441
@@ -453,12 +456,12 @@ def QuaternionPresentation():
453456 sage: Q.is_isomorphic(groups.presentation.DiCyclic(2))
454457 True
455458 """
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 ])
458461 return FinitelyPresentedGroup (F , rls )
459462
460463
461- def AlternatingPresentation (n ):
464+ def AlternatingPresentation (n ) -> FinitelyPresentedGroup :
462465 r"""
463466 Build the Alternating group of order `n!/2` as a finitely presented group.
464467
@@ -509,7 +512,7 @@ def AlternatingPresentation(n):
509512 return FinitelyPresentedGroup (F , ret_rls )
510513
511514
512- def KleinFourPresentation ():
515+ def KleinFourPresentation () -> FinitelyPresentedGroup :
513516 r"""
514517 Build the Klein group of order `4` as a finitely presented group.
515518
@@ -520,12 +523,12 @@ def KleinFourPresentation():
520523 sage: K = groups.presentation.KleinFour(); K
521524 Finitely presented group < a, b | a^2, b^2, a^-1*b^-1*a*b >
522525 """
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 ])
525528 return FinitelyPresentedGroup (F , rls )
526529
527530
528- def BinaryDihedralPresentation (n ):
531+ def BinaryDihedralPresentation (n ) -> FinitelyPresentedGroup :
529532 r"""
530533 Build a binary dihedral group of order `4n` as a finitely presented group.
531534
@@ -555,12 +558,12 @@ def BinaryDihedralPresentation(n):
555558 ....: assert P.is_isomorphic(M)
556559 """
557560 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 )
560563 return FinitelyPresentedGroup (F , rls )
561564
562565
563- def CactusPresentation (n ):
566+ def CactusPresentation (n ) -> FinitelyPresentedGroup :
564567 r"""
565568 Build the `n`-fruit cactus group as a finitely presented group.
566569
@@ -579,11 +582,11 @@ def CactusPresentation(n):
579582 rls = [g ** 2 for g in gens ]
580583 Gg = G .group_generators ()
581584 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 ):
584587 if i == j :
585588 continue
586- x ,y = (Gg [key ] * Gg [key2 ])._data
589+ x , y = (Gg [key ] * Gg [key2 ])._data
587590 if key == x and key2 == y :
588591 continue
589592 elt = gens [i ] * gens [j ] * ~ gens [K .index (y )] * ~ gens [K .index (x )]
0 commit comments