This file is indexed.

/usr/share/gap/lib/schursym.gi is in gap-libs 4r7p9-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
#############################################################################
##
#W  schursym.gi              GAP library                           Lukas Maas
#W                                                             & Jack Schmidt
##
#Y  Copyright (C) 2009, The GAP group
##
##  This file contains the implementation for Schur covers of symmetric and
##  alternating groups on Coxeter or standard generators.
##

#############################################################################
##
##  Faithful, irreducible representations of minimal degree of the double
##  covers of symmetric groups can be constructed inductively using the 
##  methods of http://arxiv.org/abs/0911.3794
##
##  The inductive formulation uses a number of helper routines which are
##  wrapped inside a function call to keep from declaring a large number
##  of (private) global variables.
##

Perform( [1], function(x)
  local S, S1, coeffS2, S2, coeffS3, S3, bmat, spinsteps, SpinDimSym,
    BasicSpinRepSymPos, BasicSpinRepSymNeg, BasicSpinRepSym,
    SanityCheckPos, SanityCheckNeg, BasicSpinRepSymTest;


##  let 2S+(n) = < t_1, ..., t_(n-1) > subject to the relations
##    (t_i)^2 = z for 1 <= i <= n-1, 
##    z^2 = 1,
##    ( t_i*t_(i+1) )^3 = z for 1 <= i <= n-2,
##    t_i*t_j = z*t_j*t_i for 1 <= i, j <= n-1 with | i - j | > 1.
##
##  The following functions allow the construction of basic spin
##  representations of 2S+(n) over fields of any characteristic.

##  SpinDimSym
##  IN   integers n >= 4, p >= 0
##  OUT  the degree of a basic spin repr. of 2S(n) over a field of
##       characteristic p
SpinDimSym:= function( n, p )
    local r;
    r:= n mod 2;
    if r = 0 then
        return 2^((n-2)/2);
    elif p = 0 then
        return 2^((n-1)/2);
    elif r = 1 and n mod p = 0 then
        return 2^((n-3)/2);
    else
        return 2^((n-1)/2);
    fi;
end;
    
##  SanityCheckPos
##  IN  A record containing the matrices in T, the degree of the symmetric
##      group n, and the characteristic f the field p
##  OUT true if the matrices in T are the right size, over the right field, and
##      satisfy the presentation for 2S(n) given above.  Also checks the
##      components Sym and Alt if present.
SanityCheckPos := function( input )
  local i, j;

    if input.n <> Length( input.T ) + 1 then
      Print("#I SanityCheckPos: Wrong degree: ",input.n," vs. ",Length(input.T)+1,"\n");
      return false;
    fi;

    if input.p <> Characteristic( input.T[1] ) then
      Print("#I SanityCheckPos: Wrong characteristic: ",input.p," vs. ",Characteristic(input.T[1]),"\n");
      return false;
    fi;
  
    if SpinDimSym( input.n, input.p ) <> Length( input.T[1] ) then
        Print( "#I SanityCheckPos: Wrong degree: ",SpinDimSym( input.n, input.p )," vs. ",Length( input.T[1] ),"\n" );
        return false;
    fi;

    if not ForAll( input.T, mat -> Size(mat) = Size(mat[1]) and Size(mat)=Size(input.T[1])) then
      Print("#I SanityCheckPos: Matrices not all same size\n");
      return false;
    fi;

    for i in [ 1 .. input.n-1 ] do
        if not IsOne(-input.T[i]^2) then
            Print( "#I SanityCheckPos: Wrong order for T[",i,"]\n");
            return false;
        fi; 
    od;
    for i in [ 1 .. input.n-2 ] do
        if not IsOne( -( input.T[i]*input.T[i+1] )^3 ) then
            Print( "#I SanityCheckPos: Braid relation failed at position ", i, "\n" );
            return false;
        fi;
        for j in [ i+2 .. input.n-1 ] do
            if not IsOne( - ( input.T[i]*input.T[j] )^2 ) then
                Print( "#I SanityCheckPos: Commutator relation failed for ( ", i, ", ", j ," )\n" );
                return false;
            fi;
        od;
    od;

    if IsBound( input.Sym ) then
      if not input.Sym[1] = Product( Reversed( input.T ) ) then
        Print( "SanityCheckPos: Wrong Sym[1]\n" );
        return false;
      fi;

      if not input.Sym[2] = input.T[1] then
        Print( "SanityCheckPos: Wrong Sym[2]\n" );
        return false;
      fi;
    fi;

    if IsBound( input.Alt ) then
      if not input.Alt[1] = Product( Reversed( input.T{[1..2*Int((input.n-1)/2)]} ) ) then
        Print( "SanityCheckPos: Wrong Alt[1]\n" );
        return false;
      fi;

      if not input.Alt[2] = input.T[input.n-1]*input.T[input.n-2] then
        Print( "SanityCheckPos: Wrong Alt[2]\n" );
        return false;
      fi;
    fi;

    return true; 
end;

##  SanityCheckNeg
##  IN  A record containing the matrices in T, the degree of the symmetric
##      group n, and the characteristic f the field p
##  OUT true if the matrices in T are the right size, over the right field, and
##      satisfy the presentation for 2S-(n) given above.  Also checks the
##      components Sym and Alt if present.
SanityCheckNeg := function( S, p )
    local d, deg, z, t, i, j;
  
    d:= Length( S );
    deg:= Length( S[1] );
    if SpinDimSym( d+1, p ) <> deg then
        Print( "#I SanityCheckNeg: wrong degree!\n" );
        return false;
    fi;
    #Print( "#I SanityCheckNeg: degree: ", deg , "\n" );
    for i in [ 1 .. d ] do
        if not IsOne( S[i]^2 ) then
            Print( "#I SanityCheckNeg: order failed at position ", i, "\n" );
            return false;
        fi; 
    od;
    for i in [ 1 .. d-1 ] do
        if not IsOne( ( S[i]*S[i+1] )^3 ) then
            Print( "#I SanityCheckNeg: braid relation failed at position ", i, "\n" );
            return false;
        fi;
        for j in [ i+2 .. d ] do
            if S[i]*S[j] <> -S[j]*S[i] then
                Print( "#I SanityCheckNeg: commuting relation failed for ( ", i, ", ", j ," )\n" );
                return false;
            fi;
        od;
    od;
    #Print( "#I SanityCheckNeg: all relations satisfied\n" );
    return true; 
end;
        
##  bmat -- blck matrix maker
##  IN  the blocks a,b,c,d of the matrix [[a,b],[c,d]]
##  OUT a normal matrix with the same entries as the corresponding block
##      matrix.
bmat := function(a,b,c,d)
  local mat;
  mat := DirectSumMat( a, d );
  if b <> 0 then mat{[1..Length(a)]}{[1+Length(a[1])..Length(mat[1])]} := b; fi;
  if c <> 0 then mat{[1+Length(a)..Length(mat)]}{[1..Length(a[1])]} := c; fi;
  return mat;
end;

##  construction S of Definition 4 / Lemma 5
##  IN  an input record with n,p,T and optionally Sym and/or Alt,
##      where n,p satisfy the hypothesis of Def 4 / Lemma 5
##  OUT the same, but for 2S(n+1)
S:= function( old )
  local new, I, z, i;

  #Print("S from ",old.n," to ",new.n,"\n");
  new := rec( n := old.n+1, p:=old.p, T:=[] );

  for i in [ 1 .. new.n-3 ] do
    new.T[i] := DirectSumMat( old.T[i], -old.T[i] );
  od;
  I := old.T[1]^0;
  z := 0*old.T[1];
  new.T[new.n-2] := bmat( old.T[new.n-2], -I, 0, -old.T[new.n-2] );
  new.T[new.n-1] := bmat( z, I, -I, z );

  if IsBound( old.Sym ) then
    new.Sym := [];
    if new.n < 5
    then new.Sym[1] := Product(Reversed(new.T)); 
    else new.Sym[1] := bmat( 0*old.Sym[1], (-1)^new.n*old.Sym[1], -old.Sym[1], (-1)^new.n*old.T[new.n-2]*old.Sym[1] );
    fi;
    new.Sym[2] := new.T[1];
  fi;

  if IsBound( old.Alt ) then
    new.Alt := [];
    if IsOddInt(new.n)
    then new.Alt[1] := new.Sym[1]; 
    else new.Alt[1] := -new.T[new.n-1]*new.Sym[1];
    fi;
    new.Alt[2] := new.T[new.n-1]*new.T[new.n-2];
  fi;

  Assert( 1, SanityCheckPos( new ) );
  return new;
end;

##  construction S1 of Lemma 7
##  IN  an input record with n,p,T and optionally Sym and/or Alt,
##      where n,p satisfy the hypothesis of Lemma 7
##  OUT the same, but for 2S(n+1)
S1:= function( old )
  local new, J;

  #Print("S1 from ",old.n," to ",new.n,"\n");
  new := rec( n := old.n + 1, p := old.p, T := ShallowCopy( old.T ) );

  J := Sum( [1..new.n-2], k -> k*old.T[k] );
  if new.p = 2 and 2 = new.n mod 4 then
    new.T[new.n-1] := J + J^0;
  else
    new.T[new.n-1] := J;
  fi;

  if IsBound( old.Sym ) then
    new.Sym := [];
    new.Sym[1] := new.T[new.n-1]*old.Sym[1];
    new.Sym[2] := old.Sym[2];
  fi;

  if IsBound( old.Alt ) then
    new.Alt := [];
    if IsOddInt(new.n)
    then new.Alt[1] := new.Sym[1];
    else new.Alt[1] := old.Alt[1];
    fi;
    new.Alt[2] := new.T[new.n-1]*new.T[new.n-2];
  fi;

  Assert( 1, SanityCheckPos( new ) );
  return new;
end;

## return alpha ( = alpha^+ ) and beta as in Lemma 10
## here n(n-1)(n-2) must not be divisible by p
coeffS2:= function( n, p )
    local one, a, b, c, alpha;
    if p = 0 then
        c:= n-2;
        alpha:= (n-1)^-1*( 1 + Sqrt( -n*c^-1 ) );
    else
        one:= Z( p )^0;
        c:= (n-2) mod p;
        a:= -n*c^-1 mod p;
        a:= LogFFE( a*one, Z(p^2) ) / 2;
        b:= (n-1)^-1 mod p;
        alpha:= b*(one+Z(p^2)^a);
    fi;
    return rec( alpha:= alpha, beta:= alpha*c );
end;

##  construction S2 of Lemma 10
##  IN  an input record with n,p,T and optionally Sym and/or Alt,
##      where n,p satisfy the hypothesis of Lemma 10
##  OUT the same, but for 2S(n+2)
S2:= function( old )
  local mid, new, coeffs, a, b, J, I;

  #Print("S2 from ",old.n," to ",old.n+2," via S\n");

  mid := S( old );

  new := rec( n := mid.n + 1, p := mid.p, T := ShallowCopy( mid.T ) );

  coeffs:= coeffS2( new.n, new.p );
  a := coeffs.alpha;
  b := coeffs.beta;
  J := Sum( [ 1 .. new.n-3 ], k-> k*old.T[k] );
  I := old.T[1]^0;
  new.T[new.n-1] := bmat( -a*J, (b-1)*I, b*I, a*J );

  if IsBound( old.Sym ) then
    new.Sym := [];
    new.Sym[1] := new.T[new.n-1]*mid.Sym[1];
    new.Sym[2] := mid.Sym[2];
  fi;

  if IsBound( old.Alt ) then
    new.Alt := [];
    if IsOddInt( new.n )
    then new.Alt[1] := new.Sym[1];
    else new.Alt[1] := mid.Sym[1];
    fi;
    new.Alt[2] := new.T[new.n-1]*new.T[new.n-2];
  fi;

  Assert( 1, SanityCheckPos( new ) );
  return  new;
end;

##  coeffS3 - a needed coefficient
##  IN  A prime p, or p = 0
##  OUT Sqrt(-1) in GF(p^2) or CF(4)
coeffS3:= function( p )
  if 0 = p then return E(4);
  elif 2 = p then return Z(2);
  elif 1 = p mod 4 then return Z(p)^((p-1)/4); 
  else return Z(p^2)^((p^2-1)/4);
  fi;
end;

##  construction S3 of Lemma 11
##  IN  an input record with n,p,T and optionally Sym and/or Alt,
##      where n,p satisfy the hypothesis of Lemma 11
##  OUT the same, but for 2S(n+4)
S3:= function( old )
  local mid, new, a, J0, I, J;
  #Print("S3 from ",old.n," to ",old.n+4," via S,S1,S\n");

  mid := S( S1( S( old ) ) ); # now at n-1

  new := rec( n := mid.n + 1, p := mid.p, T := ShallowCopy( mid.T ) );

  a := coeffS3( old.p );
  J0:= Sum( [1..new.n-5], k-> k*old.T[k] );
  I := old.T[1]^0;
  J := a*bmat(J0, 2*I, 2*I, -J0);
  new.T[new.n-1] := bmat( J, -J^0, 0, -J );

  if IsBound( old.Sym ) then
    new.Sym := [];
    new.Sym[1] := new.T[new.n-1]*mid.Sym[1];
    new.Sym[2] := mid.Sym[2];
  fi;

  if IsBound( old.Alt ) then
    new.Alt := [];
    if IsOddInt( new.n ) 
    then new.Alt[1] := new.Sym[1];
    else new.Alt[1] := mid.Alt[1];
    fi;
    new.Alt[2] := new.T[new.n-1]*new.T[new.n-2];
  fi;

  Assert( 1, SanityCheckPos( new ) );
  return new;
end;

##  spinsteps
##  IN  the degree n and characteristic p > 2
##  OUT a list which describes the steps of construction 
spinsteps:= function( n, p )
  local d, k, kmodp, parity;
  d:= [];
  k:= n;
  while k > 4 do
    kmodp:= k mod p;
    parity:= k mod 2;
    if kmodp > 2 then
      if parity = 1 then
        Add( d, 0 );
        k:= k-1;
      else
        Add( d, 2 );
        k:= k-2;
      fi;
    elif kmodp = 0 then
      Add( d, 1 );
      k:= k-1;
    elif kmodp = 1 then
      Add( d, 0 );
      k:= k-1;
    else
      if parity = 1 then
        Add( d, 0 );
        k:= k-1;
      else
        Add( d, 3 );
        k:= k-4;
      fi;
    fi;
  od;
  return Reversed( d );
end;

##  construction of a basic spin rep. of 2S+(n) in characteristic p
BasicSpinRepSymPos := function( n, p )
    local z, M, k, i, kmodp, steps;
    if not IsPosInt(n) or not IsInt(p) or n < 4 or not ( p = 0 or IsPrime( p ) ) then
        return fail;
    fi;
    ## get the spin reps for 2S(4)
    z := coeffS3(p);
    if p = 0 then
        M:= rec( 
          n := 2,
          p := 0,
          T := [ [ [ z ] ] ], 
          Sym := [~.T[1]], 
          Alt :=[]
        ); 
        M:= S2( M );
    elif p = 2 then
        M:= rec( 
          n := 2,
          p := 2,
          T := [ [ [ z ] ] ],
          Sym := [~.T[1]],
          Alt :=[]
        );
        M:= S1( S( M ) );
    elif p = 3 then
        M:= rec( 
          n := 3,
          p := 3,
          T := [ [ [ z ] ], [ [ z ] ] ],
          Sym := [ [ [ z^2 ] ], ~.T[1] ],
          Alt:=[ ~.Sym[1] ]
        );
        M:= S( M );
    else # p>3
        M:= rec( 
           n := 2,
           p := p,
           T := [ [ [ z ] ] ],
           Sym := [ ~.T[1]],
           Alt:=[]
        );
        M:= S2( M );
    fi;
    if n = 4 then return M; fi;
    if ValueOption("Sym") <> true and ValueOption("Alt")<>true then Unbind(M.Sym); fi;
    if ValueOption("Alt") <> true then Unbind(M.Alt); fi;
    if p = 0 then
        if n mod 2 = 0 then
            k:= (n-4)/2;
            for i in [ 1 .. k ] do
                M:= S2( M );
            od;
        else 
            k:= (n-5)/2;
            for i in [ 1 .. k ] do
                M:= S2( M );
            od;
            # now M is a b.s.r. of 2S( n-1 )
            M:= S( M );
        fi;
    elif p = 2 then
        k:= 5;
        while k <= n do
            if k mod 2 = 1 then
                M:= S( M );
            else
                M:= S1( M );
            fi;
            k:= k+1;
        od;
    else # p >= 3
        steps:= spinsteps( n, p );
        for k in steps do
            if k = 0 then
                M := S( M );
            elif k = 1 then
                M := S1( M );
            elif k = 2 then
                M := S2( M );
            else
                M := S3( M );
            fi;
        od;
    fi;
    Assert( 1, SanityCheckPos( M ) );
    return M;
end;

BasicSpinRepSymNeg := function( n, p )
  local T, S;
  T := BasicSpinRepSymPos( n, p );
  S := rec( n := T.n, p := T.p, T := coeffS3( p ) * T.T );
  if IsBound( T.Sym ) then S.Sym := [ coeffS3( p )^(n-1) * T.Sym[1], S.T[1] ]; fi;
  if IsBound( T.Alt ) then S.Alt := [ (-1)^Int((n-1)/2)*T.Alt[1], -T.Alt[2] ]; fi;
  Assert( 1, SanityCheckNeg( S.T, p ) );
  return S;
end;

BasicSpinRepSym := function( n, p, sign )
  if sign in [ 1, '+', "+", 4 ] then return BasicSpinRepSymPos(n,p);
  elif sign in [ -1, '-', "-", 2 ] then return BasicSpinRepSymNeg(n,p);
  else Error("<sign> should be +1 or -1");
  fi;
end;

##########################################################################
##
##  Method Installations
##
     
InstallGlobalFunction( BasicSpinRepresentationOfSymmetricGroup,
function(arg)
  local n, p, s, mats;
  if Length(arg) < 1 then Error("Usage: BasicSpinRepresentationOfSymmetricGroup( <n>, <p>, <sign> );"); fi;
  n := arg[1];
  if Length(arg) < 2 then p := 3; else p := arg[2]; fi;
  if Length(arg) < 3 then s := 1; else s := arg[3]; fi;
  mats := BasicSpinRepSym(n,p,s).T;
  if p = 2 then return List( mats, mat -> ImmutableMatrix( GF(p), mat ) );
  elif p > 0 then return List( mats, mat -> ImmutableMatrix( GF(p^2), mat ) ); fi;
  return mats;
end );

InstallMethod( SchurCoverOfSymmetricGroup, 
  "Use Lukas Maas's inductive construction of a basic spin rep",
  [ IsPosInt, IsInt, IsInt ],
function( n, p, s )
  local mats, grp;

  if p = 2 then return fail; fi; # need a faithful rep

  if n < 4 then TryNextMethod(); fi;

  mats := BasicSpinRepSym(n,p,s:Sym);

  mats.Z := -mats.T[1]^0;

  grp := Group( mats.Sym );

  Assert( 3, Size( grp ) = 2*Factorial( n ) );
  SetSize( grp, 2*Factorial(n) );

  Assert( 3, Center( grp ) = Subgroup( grp, [ mats.Z ] ) );
  SetCenter( grp, SubgroupNC( grp, [ mats.Z ] ) );

  Assert( 3, IsAbelian( Center( grp ) ) );
  SetIsAbelian( Center( grp ), true );

  Assert( 3, Size( Center( grp ) ) = 2 );
  SetSize( Center( grp ), 2 );

  Assert( 3, AbelianInvariants( Center( grp ) ) = [ 2 ] );
  SetAbelianInvariants( Center( grp ), [ 2 ] );

  return grp;
end );
  
InstallMethod( DoubleCoverOfAlternatingGroup,
  "Use Lukas Maas's inductive construction of a basic spin rep",
  [ IsPosInt, IsInt ],
function( n, p )
  local mats, grp;

  if p = 2 then return fail; fi; # need a faithful rep

  mats := BasicSpinRepSym(n,p,1:Alt);

  mats.Z := -mats.T[1]^0;

  grp := Group( mats.Alt );

  Assert( 3, Size( grp ) = Factorial( n ) );
  SetSize( grp, Factorial(n) );

  Assert( 3, Center( grp ) = Subgroup( grp, [ mats.Z ] ) );
  SetCenter( grp, SubgroupNC( grp, [ mats.Z ] ) );

  Assert( 3, IsAbelian( Center( grp ) ) );
  SetIsAbelian( Center( grp ), true );

  Assert( 3, Size( Center( grp ) ) = 2 );
  SetSize( Center( grp ), 2 );

  Assert( 3, AbelianInvariants( Center( grp ) ) = [ 2 ] );
  SetAbelianInvariants( Center( grp ), [ 2 ] );

  if n >= 5 then
    Assert( 3, IsPerfectGroup( grp ) );
    SetIsPerfectGroup( grp, true );
  fi;

  return grp;
end );

BasicSpinRepSymTest := function(n,p)
  local mats, smtx, grp, sign;
  for sign in [1,-1] do
    mats := BasicSpinRepSym(n,p,sign).T;
    if p > 0 then
      smtx := GModuleByMats( mats, Field(Flat(mats)) );
      Assert( 0, SMTX.IsAbsolutelyIrreducible( smtx ) );
    fi;
    grp := Group( mats.Sym );
    if n > 4 or p <> 2 then
    Assert( 0, Size( grp ) = 2*Factorial(n)/GcdInt(p,2) );
    Assert( 0, Size( Center( grp ) ) = 2/GcdInt(p,2) );
    Assert( 0, Size( DerivedSubgroup( grp ) ) = Factorial(n)/GcdInt(p,2) );
    Assert( 0, IsSubgroup( DerivedSubgroup( grp ), Center( grp ) ) );
    Assert( 0, AbelianInvariants( grp ) = [ 2 ] );
    if n > 4 then Assert( 0, IsSimpleGroup( DerivedSubgroup( grp ) / Center( grp ) ) ); fi;
    fi;
    grp := Group( mats.Alt );
    if n > 4 or p <> 2 then
    Assert( 0, Size( grp ) = Factorial(n)/GcdInt(p,2) );
    Assert( 0, Size( Center( grp ) ) = 2/GcdInt(p,2) );
    Assert( 0, Size( DerivedSubgroup( grp ) ) = Factorial(n)/GcdInt(p,2) );
    if n > 4 then Assert( 0, IsSimpleGroup( DerivedSubgroup( grp ) / Center( grp ) ) ); fi;
    fi;
  od;
  return true;
end;

end );


#############################################################################
##
##  Other method installations that do not require direct access to the
##  inductive procedure.
##


#############################################################################
##
##  Convenience routines that supply default values.
##

InstallOtherMethod( SchurCoverOfSymmetricGroup,
  "Sign=+1 by default",
  [ IsPosInt, IsInt ],
function( n, p )
  return SchurCoverOfSymmetricGroup( n, p, 1 );
end );

InstallOtherMethod( SchurCoverOfSymmetricGroup,
  "P=3, Sign=+1 by default",
  [ IsPosInt ],
function( n )
  return SchurCoverOfSymmetricGroup( n, 3, 1 );
end );

InstallOtherMethod( DoubleCoverOfAlternatingGroup,
  "P=3 by default",
  [ IsPosInt ],
function( n )
  return DoubleCoverOfAlternatingGroup( n, 3 );
end );

#############################################################################
##
##  Quickly setup the standard epimorphisms
##

InstallMethod( EpimorphismSchurCover,
  "Use library copy of double cover",
  [ IsNaturalSymmetricGroup ],
function( sym )
  local dom, deg, cox, chr, grp, hom, img;
  dom := MovedPoints( sym );
  deg := Size( dom );
  if deg < 4 then return IdentityMapping( sym ); fi;
  cox := List( [1..deg-1], i -> (dom[i],dom[i+1]) );
  Assert( 1, ForAll( cox, gen -> gen in sym ) );
  #chr := First( [3,5,7], p -> 0 = deg mod p );
  #if chr = fail then chr := 3; fi;
  chr := 3; # appears to be the best choice regardless of deg
  grp := SchurCoverOfSymmetricGroup( deg, chr, 1 );
  img := [ Product( Reversed( cox ) ), cox[1] ];
  if AssertionLevel() > 2 then
    hom := GroupHomomorphismByImages( grp, sym, GeneratorsOfGroup( grp ), img );
    Assert( 3, KernelOfMultiplicativeGeneralMapping( hom ) = Center( grp ) );
  else
    dom := RUN_IN_GGMBI; RUN_IN_GGMBI := true;
    hom := GroupHomomorphismByImagesNC( grp, sym, GeneratorsOfGroup( grp ), img );
    RUN_IN_GGMBI := dom;
    SetKernelOfMultiplicativeGeneralMapping( hom, Center( grp ) );
  fi;
  return hom;
end );

InstallMethod( EpimorphismSchurCover,
  "Use library copy of double cover",
  [ IsNaturalAlternatingGroup ],
function( alt )
  local dom, deg, cox, chr, grp, hom, img;
  dom := MovedPoints( alt );
  deg := Size( dom );
  if deg < 4 then return IdentityMapping( alt ); fi;
  if deg in [6,7] then TryNextMethod(); fi;
  cox := List( [1..deg-1], i -> (dom[i],dom[i+1]) );
  Assert( 1, ForAll( [1..deg-2], i -> cox[i]*cox[i+1] in alt ) );
  chr := 3;
  grp := DoubleCoverOfAlternatingGroup( deg, chr );
  img := [ Product( Reversed( cox{[1..2*Int((deg-1)/2)]} ) ), cox[deg-1]*cox[deg-2] ];
  if AssertionLevel() > 2 then
    hom := GroupHomomorphismByImages( grp, alt, GeneratorsOfGroup( grp ), img );
    Assert( 3, KernelOfMultiplicativeGeneralMapping( hom ) = Center( grp ) );
  else
    dom := RUN_IN_GGMBI; RUN_IN_GGMBI := true;
    hom := GroupHomomorphismByImagesNC( grp, alt, GeneratorsOfGroup( grp ), img );
    RUN_IN_GGMBI := dom;
    SetKernelOfMultiplicativeGeneralMapping( hom, Center( grp ) );
  fi;
  return hom;
end );

###########################################################################
##
##   Special cases just handled explicitly
##

InstallMethod( SchurCoverOfSymmetricGroup,
  "Use explicit matrix reps for degrees 1,2,3",
  [ IsPosInt, IsInt, IsInt ],
  1,
function( n, p, ignored )
  local R;
  if p = 0 then R := Integers; else R:=GF(p); fi;
  if n = 1 then return TrivialSubgroup( GL(1,R) );
  elif n = 2 and p<>2 then return Group( -One(GL(1,R)) );
  elif n = 3 and p<>3 then return Group( [ [[0,1],[-1,-1]], [[0,1],[1,0]] ]*One(R) );
  elif n = 2 and p = 2 then return Group( [[1,1],[0,1]]*One(R) ); # indecomposable, not irreducible
  elif n = 3 and p = 3 then return Group( [ [[0,1],[-1,-1]], [[0,1],[1,0]] ]*One(R) ); # indecomposable, not irreducible
  else TryNextMethod();
  fi;
end );

InstallMethod( EpimorphismSchurCover,
  "Use copy of AtlasRep's 6-fold cover",
  [ IsNaturalAlternatingGroup ],
  1,
function( alt )
  local dom, deg, cox, img, z, gen, grp, cen, hom;
  dom := MovedPoints( alt );
  deg := Size( dom );
  if deg = 6 then
    z := Z(25);
    gen := [
      [ [ z^ 0, z^16, z^22, z^ 8, z^ 8, z^13 ],
        [ z^ 0, z^22, z^ 0, z^ 7, z^11, z^16 ], 
        [ z^11, z^ 7, z^ 0, z^ 6, z^10, z^ 7 ],
        [ z^ 2, z^ 0, z^ 3, z* 0, z^18, z^21 ], 
        [ z^21, z^ 9, z^ 2, z^12, z^ 5, z^20 ],
        [ z   , z^ 5, z^ 2, z^ 4, z^16, z^ 6 ] ],
      [ [ z^18, z^23, z^ 0, z^ 2, z^23, z^17 ], 
        [ z^ 2, z^10, z^17, z* 0, z^ 0, z^18 ], 
        [ z^17, z^ 4, z^12, z^23, z^22, z^ 4 ], 
        [ z   , z^12, z   , z^18, z^11, z^ 2 ], 
        [ z^21, z^ 4, z^15, z^ 8, z^19, z* 0 ], 
        [ z^ 8, z^ 6, z^14, z^18, z^18, z^ 9 ] ] ];
    grp := Group( gen );

    Assert( 2, Size( grp ) = 6*5*4*3*2/2 * 6 );
    SetSize( grp, 6*5*4*3*2/2 * 6 );

    cen := SubgroupNC( grp, [ DiagonalMat( [ z^4, z^4, z^4, z^4, z^4, z^4 ] ) ] );

    Assert( 1, Size( cen ) = 6 );
    SetSize( cen, 6 );

    Assert( 1, IsAbelian( cen ) );
    SetIsAbelian( cen, true );

    Assert( 1, AbelianInvariants( cen ) = [ 2, 3 ] );
    SetAbelianInvariants( cen, [ 2, 3 ] );

    Assert( 2, Center(grp) = cen );
    SetCenter( grp, cen );
  elif deg = 7 then
    z := Z(25);
    gen := [
      [ [ z* 0, z^14, z^10, z^19, z^11, z^ 6 ], 
        [ z^19, z^12, z^ 9, z   , z^ 0, z    ], 
        [ z^ 8, z^18, z^10, z^ 2, z^20, z^15 ], 
        [ z^ 2, z^ 0, z^23, z^ 0, z^12, z^ 5 ], 
        [ z^20, z^ 8, z^20, z^23, z^16, z^ 0 ], 
        [ z^10, z^ 2, z^13, z^ 5, z^20, z^11 ] ],
      [ [ z^ 7, z^ 6, z^10, z^23, z^ 6, z^ 0 ], 
        [ z^14, z^19, z^ 9, z^22, z^ 2, z^ 0 ], 
        [ z^10, z^16, z^17, z^15, z^17, z^14 ], 
        [ z^ 0, z^17, z^10, z^13, z   , z^ 6 ], 
        [ z^13, z^ 9, z^ 2, z^12, z^ 8, z^ 7 ], 
        [ z^ 8, z^ 8, z^16, z^23, z^ 4, z^19 ] ] ];

    grp := Group( gen );

    Assert( 2, Size( grp ) = 7*6*5*4*3*2/2 * 6 );
    SetSize( grp, 7*6*5*4*3*2/2 * 6 );

    cen := SubgroupNC( grp, [ DiagonalMat( [ z^4, z^4, z^4, z^4, z^4, z^4 ] ) ] );

    Assert( 1, Size( cen ) = 6 );
    SetSize( cen, 6 );

    Assert( 1, IsAbelian( cen ) );
    SetIsAbelian( cen, true );

    Assert( 1, AbelianInvariants( cen ) = [ 2, 3 ] );
    SetAbelianInvariants( cen, [ 2, 3 ] );

    Assert( 2, Center(grp) = cen );
    SetCenter( grp, cen );

  else TryNextMethod();
  fi;
  cox := List( [1..deg-1], i -> (dom[i],dom[i+1]) );
  img := [ Product( Reversed( cox{[1..2*Int((deg-1)/2)]} ) ), cox[deg-1]*cox[deg-2] ];
  Assert( 1, ForAll( img, i -> i in alt ) );
  if AssertionLevel() > 1 then
    hom := GroupHomomorphismByImages( grp, alt, gen, img );
    Assert( 2, KernelOfMultiplicativeGeneralMapping( hom ) = Center( grp ) );
  else
    hom := GroupHomomorphismByImagesNC( grp, alt, gen, img );
    SetKernelOfMultiplicativeGeneralMapping( hom, Center( grp ) );
  fi;
  return hom;
end );

#############################################################################
##
#E