This file is indexed.

/usr/share/gap/grp/perf.grp is in gap-libs 4r6p5-3.

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
#############################################################################
##
#W  perf.grp              GAP Groups Library                 Alexander Hulpke
##                                                             Volkmar Felsch
##
##
#Y  Copyright (C)  1997,  Lehrstuhl D für Mathematik,  RWTH Aachen,  Germany
##
##  This file contains the access functions for the Holt/Plesken library
##

#############################################################################
##
#F  PerfGrpLoad(<size>)  force loading of secondary files, return index
##
InstallGlobalFunction( PerfGrpLoad, function(sz)
local p,sel,i,pos;
  if PERFRec=fail then
    ReadGrp("perf0.grp");
  fi;
  # get the index
  pos:=PositionSet(PERFRec.sizes,sz);
  if pos=fail then
    return fail;
  fi;
  if PERFSELECT[pos] then
    return pos;
  fi;
  # get the file number
  p:=PositionSorted(PERFRec.covered,pos);
  if SizeBlist(PERFSELECT)>50 then
    # throw away old to free memory
    sel:=Filtered([1..PERFRec.length],i->PERFSELECT[i]);
    sel:=sel{[1..Length(sel)-25]};
    for i in sel do
      Unbind(PERFGRP[i]);
      PERFSELECT[i]:=false;
    od;
  fi;
  ReadGrp(Concatenation("perf",String(p),".grp"));
  # store loaded info
  if p=1 then
    p:=[0,PERFRec.covered[p]];
  else
    p:=PERFRec.covered{[p-1,p]};
  fi;
  for i in [p[1]+1..p[2]] do
    PERFSELECT[i]:=true;
  od;
  return pos;
end );


#############################################################################
##
#F  SizesPerfectGroups( )
##
##  `SizesPerfectGroups'  returns an ordered list of all integers  that occur
##  as group sizes in the library of perfect groups.
##
InstallGlobalFunction( SizesPerfectGroups, function ( )

    PerfGrpLoad(0);
    # return the requested list.
    return ShallowCopy( PERFRec.sizes );

end );


#############################################################################
##
#F  NumberPerfectGroups( size )
##
##  `NumberPerfectGroups'  returns the number of nonisomorphic perfect groups
##  of size size for 1 <= size <= 1 000 000.
##
##  Exception:  The number of  perfect groups  is not yet known for the eight
##  sizes  61440, 122880, 172032, 245760, 344064, 491520, 688128, and 983040.
##
##  If size is one of these exceptions or if size is out of range,  the value
##  fail will be returned.
##
InstallGlobalFunction( NumberPerfectGroups, function ( size )

    PerfGrpLoad(0);

    # get the number and return it.
    if not size in [ 1 .. 1000000 ] or size in PERFRec.notKnown then
      return fail;
    elif not size in PERFRec.sizes then
      return 0;
    else
      return PERFRec.number[ PositionSorted( PERFRec.sizes, size ) ];
    fi;
end );


#############################################################################
##
#F  NumberPerfectLibraryGroups( size )
##
##  `NumberPerfectLibraryGroups'  returns the number of nonisomorphic perfect
##  groups of size size for 1 <= size <= 1 000 000 which are available in the
##  perfect groups library.
##
InstallGlobalFunction( NumberPerfectLibraryGroups, function ( size )
local sizenum;

    # get the number and return it.
    sizenum := PerfGrpLoad( size );
    if sizenum = fail or size in PERFRec.notAvailable or size = 1 then
        return 0;
    else
        return PERFRec.number[sizenum];
    fi;

end );

#############################################################################
##
#F  PerfectCentralProduct( <grpdata> ) . . . . . . . . . . . . . . local
##
##  `PerfectCentralProduct'  returns, generators, relators and subgroup
##  information for 
##  the direct product of two perfect groups  or their central product modulo
##  some given central element.
##
##  It is expected that grpdata[1] is either of the form
##      [ 2, <size1>, <n1>, <size2>, <n2> ]
##  or  [ 3, <size1>, <n1>, <size2>, <n2>, <string1>, <string2> ... ]
##
##  In the first case,  the resulting group G is just the direct product D of
##  the n1-th group of size size1, G1, and the n2-th group of size size2, G2,
##  from the perfect groups library.
##
##  In the second case,  the string entries  are expected  to be the names of
##  suitable generators of D  such that their product  is the central element
##  to be factored out in D to contain G.
##
##  Note:  This function is an internal function, hence the arguments are not
##  checked to be in range.  In particular,  the first source entry  which is
##  expected to be 2 or 3 is neither checked nor used.  Moreover, the perfect
##  groups record PERFRec is expected to be already loaded.
##
PerfectCentralProduct := function ( grpdata )
local source,orbsize,nargs,grp1,grp2,names1,names2,names,F,fgens,
      gens1,ngens1,gens2,words1,words2,rels,sub,i,j;

  # get the arguments.
  source:=grpdata[1];
  orbsize:=grpdata[6];
  nargs := Length( source );
  grp1:=PERFGRP[PerfGrpLoad(source[2])][source[3]];
  grp2:=PERFGRP[PerfGrpLoad(source[4])][source[5]];
  # construct names for the generators of the group G to be constructed.
  names1:=List(grp1[1][2],i->Concatenation([i],"1"));
  names2:=List(grp2[1][2],i->Concatenation([i],"2"));
  names := Concatenation( names1, names2 );

  # get the associated free group generators.
  F := FreeGroup( names );
  fgens:=GeneratorsOfGroup(F);
  ngens1 := Length( names1 );
  gens1 := fgens{[1..ngens1]};
  gens2 := fgens{[ngens1+1..Length(names)]};

  # get relators and subgroup words
  words1:=CallFuncList(grp1[1][3],gens1);
  words2:=CallFuncList(grp2[1][3],gens2);

  # common relations
  rels:=Concatenation(words1[1],words2[1]);

  # commuting relations
  for i in gens1 do
    for j in gens2 do
      Add(rels,Comm(i,j));
    od;
  od;

  sub:=[];
  # in case of a central product compute additional relations and store
  # suitable subgroups for a faithful permutation representation.
  if Length(source)>5 then
    Add(rels,Product(List(source{[6..Length(source)]},
        i->fgens[Position(names,i)])));
    for i in words1[2] do
      for j in words2[2] do
        Add(sub,Concatenation(i,j));
      od;
    od;
  fi;

  # return the result
  return [F,fgens,rels,sub];
end;


#############################################################################
##
#F  PerfectSubdirectProduct( <source> ) . . . . . . . . . . . . . . . . local
##
##  `PerfectSubdirectProduct' returns, in form of a finitely presented group,
##  the subdirect product of two perfect groups.
##
##  It expects the associated source entry to be of the form
##      [ 4, <size1>, <n1>, <size2>, <n2>, <over> ]
##  or  [ 4, <size1>, <n1>, <size2>, <n2>, <over>, <n1'>, <n2'> ]
##
##  The resulting group G is the subdirect product of the n1-th group of size
##  size1, G1, and the n2-th group of size size2, G2, from the perfect groups
##  library over the perfect group G0 of size over.
##
##  Note:  This function is an internal function, hence the arguments are not
##  checked to be in range.  In particular,  the first source entry  which is
##  expected  to be  4  is neither  checked nor used.  Moreover,  the perfect
##  groups record PERFRec is expected to be already loaded.
##
##  Warning:  The method used here is   n o t   a general method to construct
##  subdirect products. It is only guaranteed that it works correctly for the
##  given set of examples.
##
PerfectSubdirectProduct := function (grpdata)
local source,grp1,grp2,grp0,ngens0,ngens1,ngens2,gens0,gens1,gens2,nrels0,
      names0,names1,names2,names,F,fgens,ngens,rels,rels0,rels1,rels2,i,j;

  # get the arguments.
  source:=grpdata[1];
  grp1:=PERFGRP[PerfGrpLoad(source[2])][source[3]];
  grp2:=PERFGRP[PerfGrpLoad(source[4])][source[5]];
  grp0:=PERFGRP[PerfGrpLoad(source[6])][1];

  # construct names for the generators of the group G to be constructed.
  ngens0:=Length(grp0[1][2]);
  ngens1:=Length(grp1[1][2]);
  ngens2:=Length(grp2[1][2]);
  names0:=List(grp0[1][2],i->[i]);
  names1:=List(grp1[1][2]{[ngens0+1..ngens1]},i->Concatenation([i],"1"));
  names2:=List(grp2[1][2]{[ngens0+1..ngens2]},i->Concatenation([i],"2"));
  names := Concatenation(names0,names1,names2);

  # get the associated free group generators.
  F := FreeGroup( names );
  fgens:=GeneratorsOfGroup(F);
  ngens:=Length(fgens);
  gens0 := fgens{[1..ngens0]};
  gens1 := fgens{[ngens0+1..ngens1]};
  gens2 := fgens{[ngens1+1..ngens]};

  # initialize relations
  rels:=[];
  for i in gens1 do
    for j in gens2 do
      Add(rels,Comm(i,j));
    od;
  od;

  gens1:=Concatenation(gens0,gens1);
  gens2:=Concatenation(gens0,gens2);

  # get relators
  rels0:=CallFuncList(grp0[1][3],gens0)[1];
  rels1:=CallFuncList(grp1[1][3],gens1)[1];
  rels2:=CallFuncList(grp2[1][3],gens2)[1];

  # construct defining relators for G.
  nrels0:=Length(rels0);
  rels:=Concatenation(rels,rels1{[nrels0+1..Length(rels1)]});
  rels:=Concatenation(rels,rels2{[nrels0+1..Length(rels2)]});

  for i in [ 1 .. ngens0 ] do
    gens1[i] := One(F);
    gens2[i] := One(F);
  od;
  rels1:=CallFuncList(grp1[1][3],gens1)[1];
  rels2:=CallFuncList(grp2[1][3],gens2)[1];

  for i in [ 1 .. nrels0 ] do
    Add(rels,rels0[i]*rels1[i]*rels2[i]);
  od;

  return [F,fgens,rels];
end;

#############################################################################
##
#M  PerfGrpConst(<IsSubgroupFpGroup>,<descript>)
##
InstallMethod(PerfGrpConst,"fp grp",true,[IsSubgroupFpGroup,IsList],0,
function(filter,l)
local G,n;
  if Length(l)=0 then 
    G:=FreeGroup(1);
    return G/GeneratorsOfGroup(G);
  fi;
  n:=l[1][1];
  if n=1 then
    G:=FreeGroup(List(l[1][2],i->[i]));
    G:=Concatenation([G,GeneratorsOfGroup(G)],
                     CallFuncList(l[1][3],GeneratorsOfGroup(G)));
  elif n in [2,3] then
    G:=PerfectCentralProduct(l);
  elif n=4 then
    G:=PerfectSubdirectProduct(l);
  else
    Error("not supported");
  fi;
  G:=G[1]/G[3];
  if Length(l)>1 then
    SetName(G,l[2]);
  fi;
  return G;
end);

#############################################################################
##
#M  PerfGrpConst(<IsPermGroup>,<descript>)
##
InstallMethod(PerfGrpConst,"perm grp",true,[IsPermGroup,IsList],0,
function(filter,l)
local G,i,j,g1,g2,gl,e1,e2,gens,rels,subs,pgens,deg,ind,ct,fp,extend,num;
  if Length(l)=0 then
    # special treatment for the trivial group
    G:= GroupByGenerators( [], () );
    return G;
  fi;
  if l[1][1]=1 then
    gl:=List(l[1][2],i->[i]);
    if Length(l[1])>4 then
      # we have auxiliary generators
      extend:=l[1][5];
      for i in [1..Length(extend)] do
        if extend[i]<>0 then
	  Add(gl,Concatenation("aux",String(i)));
	fi;
      od;
    else
      extend:=false;
    fi;
    gens:=GeneratorsOfGroup(FreeGroup(gl));
    num:=Length(l[1][2]);
    rels:=CallFuncList(l[1][3],gens{[1..num]});
    subs:=rels[2];
    rels:=rels[1];
    if extend<>false then
      # add the further generators in the `auxiliary' component.
      for i in [1..Length(extend)] do
        if extend[i]<>0 then
	  num:=num+1;
	  if IsInt(extend[i]) then
	    Add(rels,gens[i]^extend[i]/gens[num]);
	  else
	    g1:=One(gens[1]);
	    for j in extend[i] do
	      if j>0 then g1:=g1*gens[j];
	      else g1:=g1/gens[-j];fi;
	    od;
	    Add(rels,g1/gens[num]);
	  fi;
	fi;
      od;

      # Tietze
      extend:=PresentationFpGroup(Group(gens)/rels);
      TzOptions(extend).generatorsLimit:=Length(gens);
      TzOptions(extend).printLevel:=0;
      TzGo(extend);
      G:=FpGroupPresentation(extend);
      gl:=gens;
      gens:=FreeGeneratorsOfFpGroup(G);
      rels:=RelatorsOfFpGroup(G);
      subs:=List(subs,i->List(i,j->MappedWord(j,gl,gens)));

    fi;
  elif l[1][1] in [2,4] then
    g1:=PerfGrpConst(IsPermGroup,PERFGRP[PerfGrpLoad(l[1][2])][l[1][3]]);
    g2:=PerfGrpConst(IsPermGroup,PERFGRP[PerfGrpLoad(l[1][4])][l[1][5]]);
    G:=DirectProduct(g1,g2);
    if Length(l[1])>5 then
      gl:=Length(PERFGRP[PerfGrpLoad(l[1][6])][1][1][2]);
      e1:=Embedding(G,1);
      e2:=Embedding(G,2);
      g1:=GeneratorsOfGroup(g1);
      g2:=GeneratorsOfGroup(g2);
      gens:=List([1..gl],i->Image(e1,g1[i])*Image(e2,g2[i]));
      for i in [gl+1..Length(g1)] do
        Add(gens,Image(e1,g1[i]));
      od;
      for i in [gl+1..Length(g2)] do
        Add(gens,Image(e2,g2[i]));
      od;
      G:=Subgroup(G,gens);
    fi;
    if Length(l)>1 then
      SetName(G,l[2]);
    fi;
    return G;
  elif l[1][1]=3 then
    gens:=PerfectCentralProduct(l);
    rels:=gens[3];
    subs:=gens[4];
    gens:=gens[2];
  else
    Error("not supported");
  fi;

  pgens:=List(gens,i->());
  deg:=0;
  if IsBound(l[6]) then
    ind:=l[6];
  else
    ind:=l[1][4];
  fi;
  if not IsList(ind) then
    ind:=[ind];
  fi;
  for i in [1..Length(subs)] do
    ct:=CosetTableFromGensAndRels(gens,rels,subs[i]);
    ct:=ct{[1,3..Length(ct)-1]}; # avoid inverses
    if Length(ct[1])<>ind[i] then
      Error("index!");
    fi;
    ct:=List(ct,i->Concatenation([1..deg],i+deg)); #shift
    ct:=List(ct,PermList); # make perms
    pgens:=List([1..Length(gens)],i->pgens[i]*ct[i]);
    deg:=deg+ind[i];
  od;
  G:= GroupByGenerators( pgens, () );

#  # store the presentation
#  fp:=Group(gens,gens[1]^0)/rels;
#  SetIsomorphismFpGroup(G,GroupHomomorphismByImages(G,fp,pgens,
#                        GeneratorsOfGroup(fp)));
#  SetIsomorphismPermGroup(fp,GroupHomomorphismByImages(fp,G,
#                          GeneratorsOfGroup(fp),pgens));

  if Length(l)>1 then
    SetName(G,l[2]);
  fi;

  return G;
end);

#############################################################################
##
#F  PerfectGroup([<filter>,]<sz>,<nr>) . . . .  Access perfect groups library
##
InstallGlobalFunction( PerfectGroup, function(arg)
local func,sz,p;
  PerfGrpLoad(0); # force loading
  if not IsFunction(arg[1]) then 
    func:=IsSubgroupFpGroup;
    sz:=arg;
  else
    func:=arg[1];
    sz:=arg{[2..Length(arg)]};
  fi;
  # list given
  if Length(sz)=1 then
    if not IsList(sz[1]) then
      sz:=[sz[1],1];
    else
      sz:=sz[1];
    fi;
  fi;
  if sz[1] in PERFRec.notKnown then
    Error("Perfect groups of size ",sz[1]," not known");
  elif sz[1] in PERFRec.notAvailable then
    Error("Perfect groups of size ",sz[1]," not available");
  elif sz[1]=1 then
    Error("The trivial group is not considered to be part of this library");
  fi;
  p:=PerfGrpLoad(sz[1]);
  if p=fail or sz[2]>PERFRec.number[p] then
    Error("PerfectGroup(",sz[1],",",sz[2],") does not exist !");
  fi;
  p:=PerfGrpConst(func,PERFGRP[p][sz[2]]);
  SetSize(p,sz[1]);
  SetPerfectIdentification(p,ShallowCopy(sz));
  SetIsPerfectGroup(p,true);
  SetFilterObj(p,IsPerfectLibraryGroup);
  return p;
end );


#############################################################################
##
#F  DisplayInformationPerfectGroups( <size> ) . . . . . . . . . . . . . . . .
#F  DisplayInformationPerfectGroups( <size>, <n> )  . . . . . . . . . . . . .
#F  DisplayInformationPerfectGroups( [ <size>, <n> ] )  . . . . . . . . . . .
##
##  `DisplayInformationPerfectGroups'  displays  some invariants  of the n-th
##  group of size size from the perfect groups library.
##
##  If no value of n has been specified, the invariants will be displayed for
##  all groups of size size available in the library.
##
InstallGlobalFunction( DisplayInformationPerfectGroups,
    function ( arg )
local size,i,nr,n,leng,sizenum,hpnum,description,centre,orbsize;

  if IsInt(arg[1]) then
    size:=arg[1];
    if Length(arg)=1 then
      nr:=[1..NumberPerfectLibraryGroups(size)];
    else
      nr:=arg[2];
    fi;
  else
    size:=arg[1][1];
    nr:=arg[1][2];
  fi;

  if IsInt(nr) then
    nr:=[nr];
  fi;

  sizenum:=PerfGrpLoad(size);
  if size in PERFRec.notAvailable then
    Print("#I  no information available about size ",size,"\n");
    return;
  elif size in PERFRec.notKnown then
    Print("#I  no information known about size ",size,"\n");
    return;
  fi;

  # loop over the given range.
  for n in nr do

    # get the required data from main list.
    description := PERFGRP[sizenum][n][2];
    hpnum := PERFGRP[sizenum][n][3];
    centre := PERFGRP[sizenum][n][4];
    orbsize := PERFGRP[sizenum][n][6];

    # print the group number.
    Print( "#I Perfect group ", size );
    if Length(nr) > 1 then
	Print( ".", n );
    fi;
    Print( ":  " );

    # print a message if the group is simple or quaqsisimple.
    if centre = -1 then
	if size = 1 then
	    Print( "trivial group  " );
	else
	    Print( "simple group  " );
	fi;
    elif centre < -1 then
	Print( "quasisimple group  " );
	centre := -centre;
    fi;

    # print the Holt-Plesken description.
    Print( description, "\n#I " );

    # print the size of the centre.
    if centre > 1 then
	Print( "  centre = ", centre );
    fi;

    # print the group size.
    Print( "  size = " );
    PrintFactorsInt( size );

    # print the orbit sizes of the available permutation representations.
    if IsInt( orbsize ) then
	Print( "  orbit size = ", orbsize, "\n" );
    else
	orbsize := ShallowCopy( orbsize );
	Sort( orbsize );
	Print( "  orbit sizes = ", orbsize[1] );
	for i in [ 2 .. Length( orbsize ) ] do
	    Print( " + ", orbsize[i] );
	od;
	Print( "\n" );
    fi;

    # print the Holt-Plesken classes and numbers.
    if IsInt( hpnum ) then
	Print( "#I   Holt-Plesken class ", hpnum );
    else
	Print( "#I   Holt-Plesken class ", hpnum[1] );
	Print( " (", hpnum[2], ",", hpnum[3], ")" );
	leng := Length( hpnum );
	if leng > 3 then
	    if leng = 4 then
		Print( " (occurs also in class ", hpnum[4] );
	    else
		Print( " (occurs also in classes ", hpnum[4] );
		for i in [ 5 .. leng ] do
		    Print( ", ", hpnum[i] );
		od;
	    fi;
	    Print( ")" );
	fi;
    fi;
    Print( "\n" );
  od;

end );


#############################################################################
##
#F  SizeNumbersPerfectGroups( <factor>, ..., <factor> ) . . . . . . . . . . .
##
##  `SizeNumbersPerfectGroups'  returns  a list  of the  size numbers  of all
##  perfect library groups whose composition factors cover the given factors.
##  Each  argument  must be  one of the  valid names  of simple factors  or a
##  positive integer.
##
##  The  size number  of a group from the perfect groups library is a pair of
##  the form [ size, n ], where size is the group size and n is the number of
##  the group within the list of all library groups of that size.
##
InstallGlobalFunction( SizeNumbersPerfectGroups, function ( arg )
local a6a6, a6a6a6, empty, factor, minsize, minsizenum, n, nn, num, pos,
      simple, simple2, size, sizenum, sizenums;

    # load the perfect groups record PERFRec if it is not yet available.
    PerfGrpLoad( 0 );

    # get and check the arguments, and get the minimal group size.
    simple := [ ];
    minsize := 1;
    for factor in arg do
        if IsInt( factor ) then
            if factor < 1 then
                Error( "illegal order of abelian factor" );
            fi;
            minsize := minsize * factor;
        else
            pos := Position( PERFRec.nameSimpleGroup, factor );
            if pos = fail then
                Error( "illegal name of simple factor" );
            fi;
            num := PERFRec.numberSimpleGroup[pos];
            sizenum := PERFRec.sizeNumberSimpleGroup[num];
            minsize := minsize * sizenum[1];
            Add( simple, num );
        fi;
    od;
    empty := simple = [ ];
    if not empty then
        if Length( simple ) = 1 then
            simple := simple[1];
        else
            Sort( simple );
        fi;
    fi;

    # initialize the resulting list of size numbers;
    sizenums := [ ];
    a6a6 := [1,1];
    a6a6a6 := [1,1,1];

    # get the first size to be handled.
    minsizenum := Maximum(2,PositionSorted( PERFRec.sizes, minsize ));

    # loop over all library groups of size >= minsize.
    for sizenum in [ minsizenum .. Length( PERFRec.sizes ) ] do

        # check the size for being a multiple of minsize.
        if PERFRec.sizes[sizenum] mod minsize = 0 then

            # loop over the library groups of size size.
            size := PERFRec.sizes[sizenum];
	    PerfGrpLoad(size);
            nn := PERFRec.number[sizenum];
            for n in [ 1 .. nn ] do
	      if PERFGRP[sizenum][n]<>fail then
                simple2 := PERFGRP[sizenum][n][5];
                if simple = simple2 or empty or
                    IsList( simple2 ) and ( simple in simple2 or
                    ( simple2 = a6a6 and simple = a6a6a6 ) ) then
                    # add the pair [size,n] to the list of size numbers.
                    Add( sizenums, [ size, n ] );
                fi;
	      fi;
            od;
        fi;
    od;

    # return the list of size numbers.
    return sizenums;
end );


#############################################################################
##
#M  PerfectIdentification(<G>) . . . . . . . . . . . . id. for perfect groups
##
InstallMethod(PerfectIdentification,"id. for perfect groups",true,
  [IsGroup],0,
function(G)
local s,l;
  if not IsPerfectGroup(G) then
    return fail;
  fi;
  s:=Size(G);
  PerfGrpLoad(0);
  if s>=10^6 or s in PERFRec.notAvailable or s in PERFRec.notKnown then
    Print("#W  No information about size ",s," available\n");
    return fail;
  fi;
  l:=NumberPerfectLibraryGroups(s);
  while l>1 do
    if IsomorphismGroups(G,PerfectGroup(IsPermGroup,s,l))<>fail then
      return [s,l];
    fi;
    l:=l-1;
  od;
  return [s,1];
end);


#############################################################################
##
#M  IsomorphismFpGroup   for perfect library groups
##
InstallMethod(IsomorphismFpGroup,"perfect library groups",true,
  [IsPerfectLibraryGroup],100,
function(G)
local H,hom,permgens,fpgens;
  H:=PerfectGroup(IsSubgroupFpGroup,PerfectIdentification(G));
  permgens:=GeneratorsOfGroup(G);
  fpgens:=GeneratorsOfGroup(H);
  if Length(permgens)<>Length(fpgens) then
    # remove auxiliary gens
    hom:=GroupHomomorphismByImagesNC(G,H,permgens{[1..Length(fpgens)]},fpgens);
  else
    hom:=GroupHomomorphismByImagesNC(G,H,permgens,fpgens);
  fi;
  SetIsInjective(hom,true);
  SetIsSurjective(hom,true);
  return hom;
end);

#############################################################################
##
#M  IsomorphismPermGroup   for perfect library groups
##
InstallMethod(IsomorphismPermGroup,"perfect library groups",true,
  [IsPerfectLibraryGroup],100,
function(G)
local H,hom,permgens,fpgens;
  H:=PerfectGroup(IsPermGroup,PerfectIdentification(G));
  fpgens:=GeneratorsOfGroup(G);
  permgens:=GeneratorsOfGroup(H);
  if Length(permgens)<>Length(fpgens) then
    # remove auxiliary gens
    hom:=GroupHomomorphismByImagesNC(G,H,fpgens,permgens{[1..Length(fpgens)]});
  else
    hom:=GroupHomomorphismByImagesNC(G,H,fpgens,permgens);
  fi;
  SetIsInjective(hom,true);
  SetIsSurjective(hom,true);
  return hom;
end);

#############################################################################
##
#E  perf.grp . . . . . . . . . . . . . . . . . . . . . . . . . ends here
##