This file is indexed.

/usr/share/gap/grp/imf.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
#############################################################################
##
#W  imf.gi                      GAP group library              Volkmar Felsch
##
##
#Y  Copyright (C)  1995,  Lehrstuhl D für Mathematik,  RWTH Aachen,  Germany
#Y  (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
##
##  This  file  contains  the  library  functions  for  the  GAP  library  of
##  irreducible maximal finite integral matrix groups.
##


#############################################################################
##
#F  BaseShortVectors( <orbit> ) . . . . . . . . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "BaseShortVectors", function ( orbit )

    local base, count, dim, i, j, nums, vector;

    dim := Length( orbit[1] );
    base := ListWithIdenticalEntries( dim, 0 );
    nums := ListWithIdenticalEntries( dim, 0 );
    count := 0;
    i := 0;

    while count < dim do
        i := i + 1;
        vector := orbit[i];
        j := 0;
        while j < dim do
            j := j + 1;
            if vector[j] <> 0 then
                if nums[j] <> 0 then
                    vector := vector - vector[j] * base[j];
                else
                    base[j] := vector / vector[j];
                    nums[j] := i;
                    count := count + 1;
                    j := dim;
                fi;
            fi;
        od;
    od;

    base := List( nums, i -> orbit[i] );
    return [ nums, base^-1 ];
end );


#############################################################################
##
#F  DisplayImfInvariants( <dim>, <q> )  . . . . . . . . . . . . . . . . . . .
#F  DisplayImfInvariants( <dim>, <q>, <z> ) . . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "DisplayImfInvariants", function ( arg )

    local dim, dims, hyphens, linelength, q, qq, z;

    # load the imf main list if it is not yet available
    if not IsBound( IMFList ) then
        IMFLoad( 0 );
    fi;

    # get the arguments
    dim := arg[1];
    q := arg[2];
    if Length( arg ) > 2 then
        z := arg[3];
    else
        z := 1;
    fi;

    # get the range of dimensions to be handled
    if dim = 0 then
        dims := [ 1 .. IMFRec.maximalDimension ];
    else
        # check the given dimension for being in range
        if dim < 0 or IMFRec.maximalDimension < dim then
            Error( "dimension out of range" );
        fi;
        dims := [ dim ];
    fi;

    # loop over all dimensions in that range
    for dim in dims do

        # handle the cases q = 0 and q > 0 differently
        if q = 0 then

            linelength := Minimum( SizeScreen()[1], 76 );
            hyphens := Concatenation( List( [ 1 .. linelength - 5 ],
                i -> "-" ) );

            # loop over the Q-classes of dimension dim
            for qq in [ 1 .. IMFRec.numberQClasses[dim] ] do

                # print a line of separators
                Print( "#I ", hyphens, "\n" );

                # check the Z-class number for being in range
                if z < 0 or Length( IMFRec.bNumbers[dim][qq] ) < z then
                    Error( "Z-class number out of range" );
                fi;

                # display the specified Z-classes in the Q-class
                DisplayImfReps( dim, qq, z );
            od;

            # print a line of separators
            Print( "#I ", hyphens, "\n" );

        else

            # check the given Q-class number for being in range
            if q < 1 or IMFRec.numberQClasses[dim] < q then
                Error( "Q-class number out of range" );
            fi;

            # check the Z-class number for being in range
            if z < 0 or Length( IMFRec.bNumbers[dim][q] ) < z then
                Error( "Z-class number out of range" );
            fi;

            # display the specified Z-classes in the Q-class
            DisplayImfReps( dim, q, z );

        fi;
    od;

end );


#############################################################################
##
#F  DisplayImfReps( <dim>, <q>, <z> ) . . . . . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "DisplayImfReps", function ( dim, q, z )

    local bound, degree, degs, eldivs, i, leng, mult, n, norm, qmax, size,
          solvable, type, znums;

    # get the position numbers of the groups to be handled
    znums := IMFRec.bNumbers[dim][q];
    if z = 0 then
        z := 1;
        bound := Length( znums );
    else
        bound := z;
    fi;

    # loop over the classes to be displayed
    while z <= bound do

        n := znums[z];
        type := IMFList[dim].isomorphismType[n];
        size := IMFList[dim].size[n];
        solvable := IMFList[dim].isSolvable[n];
        eldivs := IMFList[dim].elementaryDivisors[n];
        degs := IMFList[dim].degrees[n];
        norm := IMFList[dim].minimalNorm[n];

        # print a class number
        if IMFRec.repsAreZReps[dim] then
            Print( "#I Z-class ", dim, ".", q, ".", z );
        else
            Print( "#I Q-class ", dim, ".", q );
        fi;

        # print solvability and group size
        if solvable then
            Print( ":  Solvable, size = " );
        else
            Print( ":  Size = " );
        fi;
        PrintFactorsInt( size );
        Print( "\n" );

        # print the isomorphism type
        Print( "#I   isomorphism type = " );
        Print( type, "\n" );

        # print the elementary divisors
        Print( "#I   elementary divisors = " );
        Print( eldivs[1] );
        if eldivs[2] > 1 then
            Print( "^", eldivs[2] );
        fi;
        leng := Length( eldivs );
        i := 3;
        while i < leng do
            Print( "*", eldivs[i] );
            if eldivs[i+1] > 1 then
                Print( "^", eldivs[i+1] );
            fi;
            i := i + 2;
        od;
        Print( "\n" );

        # print the orbit size
        Print( "#I   orbit size = " );
        if IsInt( degs ) then
            Print( degs );
            leng := 1;
        else
            leng := Length( degs );
            i := 0;
            while i < leng do
                i := i + 1;
                degree := degs[i];
                mult := 1;
                while i < leng and degs[i+1] = degree do
                    mult := mult + 1;
                    i := i + 1;
                od;
                if mult > 1 then  Print( mult, "*" );  fi;
                Print( degree );
                if i < leng then  Print( " + " );  fi;
            od;
        fi;

        # print the minimal norm
        Print( ", minimal norm = ", norm, "\n" );

        # print a message if the group is not imf in Q
        qmax := IMFRec.maximalQClasses[dim][q];
        if qmax <> q then
            Print( "#I   not maximal finite in GL(", dim,
                ",Q), rational imf class is ", dim, ".", qmax, "\n" );
        fi;

        z := z + 1;
    od;

end );


#############################################################################
##
#F  ImfInvariants( <dim>, <q> ) . . . . . . . . . . . . . . . . . . . . . . .
#F  ImfInvariants( <dim>, <q>, <z> )  . . . . . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "ImfInvariants", function ( arg )

    local dim, eldivs, flat, i, infrec, j, leng, n, q, qmax, sizes;

    # check the arguments and get the position number of the class to be
    # handled
    n := ImfPositionNumber( arg );
    dim := arg[1];
    q := arg[2];

    # get the size of the orbits of short vectors
    sizes := IMFList[dim].degrees[n];
    if IsInt( sizes ) then
        sizes := [ sizes ];
    fi;

    # get the elementary divisors
    flat := IMFList[dim].elementaryDivisors[n];
    leng := Length( flat );
    eldivs := [ ];
    i := 1;
    while i < leng do
        for j in [ 1 .. flat[i+1] ] do
            Add( eldivs, flat[i] );
        od;
        i := i + 2;
    od;

    # get the Q-class number of the corresponding rational imf class
    qmax := IMFRec.maximalQClasses[dim][q];

    # create the information record and return it
    infrec := rec(
        size := IMFList[dim].size[n],
        isSolvable := IMFList[dim].isSolvable[n],
        isomorphismType := IMFList[dim].isomorphismType[n],
        elementaryDivisors := eldivs,
        minimalNorm := IMFList[dim].minimalNorm[n],
        sizesOrbitsShortVectors := sizes );
    if qmax <> q then
        infrec.maximalQClass := qmax;
    fi;

    return infrec;
end );


#############################################################################
##
#F  IMFLoad( <dim> ) . . . . . . . . load a secondary file of the imf library
##
InstallGlobalFunction( "IMFLoad", function ( dim )

    local d, maxdim, name;

    # initialize the imf main list if it is not yet available
    if not IsBound( IMFList ) then
        name := "imf.grp";
        Info( InfoImf, 2, "loading secondary file ", name );
        if not ReadGrp( name, "imf" )  then
            Error( "cannot load secondary file ", name );
        fi;
    fi;

    # check whether we actually need to load a matrix file
    if dim > 0 and not IsBound( IMFList[dim].matrices ) then

        # load the file
        if dim < 10 then
            name := "imf1to9.grp";
        else
            name := Concatenation( "imf", String( dim ), ".grp" );
        fi;
        Info( InfoImf, 2, "loading secondary file ", name );
        if not ReadGrp( name, "imf" )  then
            Error( "cannot load secondary file ", name );
        fi;
    fi;

    return;
end );


#############################################################################
##
#F  ImfMatrixGroup( <dim>, <q> )  . . . . . . . . . . . . . . . . . . . . . .
#F  ImfMatrixGroup( <dim>, <q>, <z> ) . . . . . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "ImfMatrixGroup", function ( arg )

    local degrees, dim, form, gens, i, imfM, j, M, mats, n, name, q, qmax,
          reps, z;

    # check the arguments and get the position number of the class to be
    # handled
    n := ImfPositionNumber( arg );

    # get dimension, Q-class number, and Z-class number
    dim := arg[1];
    q := arg[2];
    z := arg[3];

    # load the appropriate imf matrix file if it is not yet available
    if not IsBound( IMFList[dim].matrices ) then
        IMFLoad( dim );
    fi;

    # construct the matrix group
    mats := IMFList[dim].matrices[n];
    gens := mats[2];
    M := Group( gens, gens[1] * gens[1]^-1 );

    # construct the group name
    if IMFRec.repsAreZReps[dim] then
        name := Concatenation( "ImfMatrixGroup(", String( dim ), ",",
            String( q ), ",", String( z ), ")" );
    else
        name := Concatenation( "ImfMatrixGroup(", String( dim ), ",",
            String( q ), ")" );
    fi;

    # get the associated Gram matrix
    form := List( mats[1], ShallowCopy );
    for i in [ 1 .. dim - 1 ] do
        for j in [ i + 1 .. dim ] do
            form[i][j] := form[j][i];
        od;
    od;

    # get the representatives and sizes of the orbits of short vectors
    reps := IMFList[dim].orbitReps[n];
    degrees := IMFList[dim].degrees[n];
    if IsInt( degrees ) then
        degrees := [ degrees ];
        reps := [ reps ];
    fi;

    # get the Q-class number of the corresponding rational imf class
    qmax := IMFRec.maximalQClasses[dim][q];

    # define an approriate imf record
    imfM := rec( );
    imfM.isomorphismType := IMFList[dim].isomorphismType[n];
    imfM.elementaryDivisors := ElementaryDivisorsMat( form );
    imfM.form := form;
    imfM.minimalNorm := IMFList[dim].minimalNorm[n];
    imfM.repsOrbitsShortVectors := reps;
    imfM.sizesOrbitsShortVectors := degrees;
    if qmax <> q then
        imfM.maximalQClass := qmax;
    fi;

    # define some approriate group attributes
    SetFilterObj( M, IsImfMatrixGroup );
    SetName( M, name );
    SetSize( M, IMFList[dim].size[n] );
    SetIsSolvableGroup( M, IMFList[dim].isSolvable[n] );
    SetImfRecord( M, imfM );

    return M;
end );


#############################################################################
##
#F  ImfNumberQClasses( <dim> )  . . . . . . . . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "ImfNumberQClasses", function ( dim )

    # load the imf main list if it is not yet available
    if not IsBound( IMFList ) then
        IMFLoad( 0 );
    fi;

    # check the given dimension for being in range
    if dim < 0 or IMFRec.maximalDimension < dim then
        Error( "dimension out of range" );
    fi;

    return IMFRec.numberQClasses[dim];
end );


#############################################################################
##
#F  ImfNumberQQClasses( <dim> ) . . . . . . . . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "ImfNumberQQClasses", function ( dim )

    # load the imf main list if it is not yet available
    if not IsBound( IMFList ) then
        IMFLoad( 0 );
    fi;

    # check the given dimension for being in range
    if dim < 0 or IMFRec.maximalDimension < dim then
        Error( "dimension out of range" );
    fi;

    return IMFRec.numberQQClasses[dim];
end );


#############################################################################
##
#F  ImfNumberZClasses( <dim>, <q> ) . . . . . . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "ImfNumberZClasses", function ( dim, q )

    local num;

    # load the imf main list if it is not yet available
    if not IsBound( IMFList ) then
        IMFLoad( 0 );
    fi;

    # check the dimension for being in range
    if dim < 1 or IMFRec.maximalDimension < dim then
        Error( "dimension out of range" );
    fi;

    # check the Q-class number for being in range
    if q < 1 or IMFRec.numberQClasses[dim] < q then
        Error( "Q-class number out of range" );
    fi;

    # return the number of class representatives in the given Q-class
    return Length( IMFRec.bNumbers[dim][q] );

end );


#############################################################################
##
#F  ImfPositionNumber( [ <dim>, <q> ] ) . . . . . . . . . . . . . . . . . . .
#F  ImfPositionNumber( [ <dim>, <q>, <z> ] )  . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "ImfPositionNumber", function ( args )

    local dim, n, q, z, znums;

    # load the imf main list if it is not yet available
    if not IsBound( IMFList ) then
        IMFLoad( 0 );
    fi;

    # check the dimension for being in range
    dim := args[1];
    if dim < 1 or IMFRec.maximalDimension < dim then
        Error( "dimension out of range" );
    fi;

    # check the Q-class number for being in range
    q := args[2];
    if q < 1 or IMFRec.numberQClasses[dim] < q then
        Error( "Q-class number out of range" );
    fi;
    znums := IMFRec.bNumbers[dim][q];

    # get the Z-class number and check it for being in range
    if Length( args ) = 2 then
        z := 1;
        args[3] := 1;
    else
        z := args[3];
        if z < 1 or Length( znums ) < z then
            Error( "Z-class number out of range" );
        fi;
    fi;

    # return the position number of the class to be handled
    return znums[z];

end );


#############################################################################
##
#F  IsomorphismPermGroupImfGroup( <M> ) . . . . . . . . . . . . . . . . . . .
#F  IsomorphismPermGroupImfGroup( <M>, <n> )  . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "IsomorphismPermGroupImfGroup", function ( arg )

    local base, degrees, gens, id, imfM, imfP, M, n, orbit, P, perms, phi,
          reps, vec;

    # check the given group for being an imf matrix group
    M := arg[1];
    if not IsImfMatrixGroup( M ) then
        Error( "the given group is not an imf matrix group" );
    fi;
    imfM := ImfRecord( M );

    # check the given orbit number for being in range
    degrees := imfM.sizesOrbitsShortVectors;
    reps := imfM.repsOrbitsShortVectors;
    if Length( arg ) = 1 then
        n := 1;
    else
        n := arg[2];
        if not n in [ 1 .. Length( reps ) ] then
            Error( "orbit number out of range" );
        fi;
    fi;

    # compute the specified orbit of short vectors
    gens := GeneratorsOfGroup( M );
    orbit := OrbitShortVectors( gens, reps[n] );

    # check the orbit size
    if Length( orbit ) <> degrees[n] then
        Error( "inconsistent orbit size" );
    fi;

    # construct the associated permutation group
    perms := List( gens, g -> PermList(
        List( orbit, vec -> PositionSorted( orbit, vec * g ) ) ) );
    id := perms[1]^0;
    P := Group( perms, id );

    # define an approriate imf record
    imfP := rec( );

    # define some appropriate group attributes
    SetSize( P, Size( M ) );
    SetIsSolvableGroup( P, IsSolvableGroup( M ) );
    SetLargestMovedPoint( P, degrees[n] );
    SetImfRecord( P, imfP );
#   if IsBound( imfM.isomorphismType ) then
#       imfP.isomorphismType := imfM.isomorphismType;
#   fi;
#   imfP.matGroup := M;

    # compute the information which will be needed to reconvert permutations
    # to matrices
    base := BaseShortVectors( orbit );
    imfP.orbitShortVectors := orbit;
    imfP.baseVectorPositions := base[1];
    imfP.baseChangeMatrix := base[2];

    # construct the associated isomorphism from M to P
    phi := GroupHomomorphismByFunction(
        M,
        P,
        function ( mat )
            local imf;
            imf := ImfRecord( P );
            return PermList( List( imf.orbitShortVectors, v ->
                PositionSorted( imf.orbitShortVectors, v*mat ) ) );
        end,
        function ( perm )
            local imf;
            imf := ImfRecord( P );
            return imf.baseChangeMatrix * List( imf.baseVectorPositions, i ->
                imf.orbitShortVectors[i^perm] );
        end );
    SetIsBijective( phi, true );

    # if n = 1, save a nice monomorphism of M
    if n = 1 and not HasNiceMonomorphism( M ) then
         SetNiceMonomorphism( M, phi );
    fi;

    return phi;
end );


#############################################################################
##
#M  IsomorphismPermGroup( <M> )
##
InstallMethod( IsomorphismPermGroup,
    "imf matrix groups",
    [IsMatrixGroup and IsFinite and IsImfMatrixGroup],
    IsomorphismPermGroupImfGroup );


#############################################################################
##
#F  OrbitShortVectors( <gens>, <rep> )  . . . . . . . . . . . . . . . . . . .
##
InstallGlobalFunction( "OrbitShortVectors", function ( gens, rep )

    local generator, images, new, nextvec, null, orbit, vector;

    orbit := [ ];
    null := ListWithIdenticalEntries( Length( rep ), 0 );
    if rep > null then
        images := [ Immutable( rep ) ];
    else
        images := [ Immutable( -rep ) ];
    fi;
    while images <> [ ] do
        Append( orbit, images );
        new := [ ];
        for generator in gens do
            for vector in images do
                nextvec := vector * generator;
                if nextvec > null then
                    Add( new, nextvec );
                else
                    Add( new, -nextvec );
                fi;
            od;
        od;
        new := Set( new );
        SubtractSet( new, orbit );
        images := new;
    od;

    Append( orbit, -orbit );
    # The function Immutable in the following statement essentially speeds
    # up the function PositionSorted in IsomorphismPermGroupImfGroup.  
    return Immutable( Set( orbit ) );
end );


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