This file is indexed.

/usr/share/gap/pkg/Polycyclic/gap/cohom/twocohom.gi is in gap-polycyclic 2.11-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
#############################################################################
##
#F CollectedTwoCR( A, u, v )
##
InstallGlobalFunction( CollectedTwoCR, function( A, u, v )
    local n, word, tail, rels, wstack, tstack, p, c, l, g, e, mat, s, t, r, i;

    # set up and push u into result
    n    := Length( A.mats );
    word := ShallowCopy( u.word );
    tail := ShallowCopy( u.tail );
    rels := RelativeOrdersOfPcp( A.factor );

    # catch a trivial case
    if v.word = 0 * v.word then
        AddTailVectorsCR( tail, v.tail );
        return rec( word := word, tail := tail );
    fi;

    # create stacks and put v onto stack
    wstack := [WordOfVectorCR( v.word )];
    tstack := [v.tail];
    p := [1];
    c := [1];

    # run until stacks are empty
    l := 1;
    while l > 0 do

        # take a generator and its exponent
        g := wstack[l][p[l]][1];
        e := wstack[l][p[l]][2];

        # take operation mat
        if e < 0 then
            mat := A.invs[g];
        else
            mat := A.mats[g];
        fi;

        # push g through module tail
        for i in [1..Length(tail)] do
            if IsBound( tail[i] ) then
                tail[i] := tail[i] * mat;
            fi;
        od;

        # correct the stacks
        c[l] := c[l] + 1;
        if AbsInt(e) < c[l] then                # exponent overflow
            c[l] := 1;
            p[l] := p[l] + 1;
            if Length(wstack[l]) < p[l]  then   # word overflow - add tail
                AddTailVectorsCR( tail, tstack[l] );
                tstack[l] := 0;
                l := l - 1;
            fi;
        fi;

        # push g through word
        for i  in [ n, n-1 .. g+1 ]  do

            if word[i] <> 0 then

                # get relator and tail
                t := [];
                if e > 0 then
                    s := Position( A.enumrels, [i, g] );
                    r := PowerWord( A, A.relators[i][g], word[i] );
                    t[s] := PowerTail( A, A.relators[i][g], word[i] );
                elif e < 0 then
                    s := Position( A.enumrels, [i, i+g] );
                    r := PowerWord( A, A.relators[i][i+g], word[i] );
                    t[s] := PowerTail( A, A.relators[i][i+g], word[i] );
                fi;

                # add to stacks
                AddTailVectorsCR( tail, t );
                l := l+1;
                wstack[l] := r;
                tstack[l] := tail;
                tail := [];
                c[l] := 1;
                p[l] := 1;
            fi;

            # reset
            word[i] := 0;
        od;

        # increase exponent
        if e < 0 then
            word[g] := word[g] - 1;
        else
            word[g] := word[g] + 1;
        fi;

        # insert power relators if exponent has reached rel order
        if rels[g] > 0 and word[g] = rels[g]  then
            word[g] := 0;
            r := A.relators[g][g];
            s := Position( A.enumrels, [g, g] );
            for i  in [1..Length(r)] do
                word[r[i][1]] := r[i][2];
            od;
            t := []; t[s] := A.one;
            AddTailVectorsCR( tail, t );

        # insert power relators if exponent is negative
        elif rels[g] > 0 and word[g] < 0 then
            word[g] := rels[g] + word[g];
            if Length(A.relators[g][g]) <= 1 then
                r := A.relators[g][g];
                for i  in [1..Length(r)] do
                    word[r[i][1]] := -r[i][2];
                od;
                s := Position( A.enumrels, [g, g] );
                t := []; t[s] := - MappedWordCR( r, A.mats, A.invs );
                AddTailVectorsCR( tail, t );

            else
                r := InvertWord( A.relators[g][g] );
                s := Position( A.enumrels, [g, g] );
                t := []; t[s] := - MappedWordCR( r, A.mats, A.invs );
                AddTailVectorsCR( tail, t );
                l := l+1;
                wstack[l] := r;
                tstack[l] := tail;
                tail := [];
                c[l] := 1;
                p[l] := 1;
            fi;
        fi;
    od;

    return rec( word := word,  tail := tail );
end );

#############################################################################
##
#F TwoCocyclesCR( A )
##
InstallGlobalFunction( TwoCocyclesCR, function( A )
    local C, n, e, id, l, gn, gp, gi, eq, pairs, i, j, k, w1, w2, d, sys, h;

    # set up system of length d
    n := Length( A.mats );
    e := RelativeOrdersOfPcp( A.factor );
    l := Length( A.enumrels );

    if IsBound(A.endosys) then
        sys := List( A.endosys, x -> CRSystem( x[2], l, 0 ) );
        for i in [1..Length(sys)] do sys[i].full := true; od;
    else
        sys := CRSystem( A.dim, l, A.char );
    fi;

    # set up for equations
    id := IdentityMat(n);
    gn := List( id, x -> rec( word := x, tail := [] ) );

    # precompute (ij) for i > j
    pairs := List( [1..n], x -> [] );
    for i  in [1..n]  do
        if e[i] > 0 then
            h := rec( word := (e[i] - 1) * id[i], tail := [] );
            pairs[i][i] := CollectedTwoCR( A, h, gn[i] );
        fi;
        for j  in [1..i-1]  do
            pairs[i][j] := CollectedTwoCR( A, gn[i], gn[j] );
        od;
    od;

    # consistency 1:  k(ji) = (kj)i
    for i  in [ n, n-1 .. 1 ]  do
        for j  in [ n, n-1 .. i+1 ]  do
            for k  in [ n, n-1 .. j+1 ]  do
                w1 := CollectedTwoCR( A, gn[k], pairs[j][i] );
                w2 := CollectedTwoCR( A, pairs[k][j], gn[i] );
                if w1.word <> w2.word  then
                    Error( "k(ji) <> (kj)i" );
                else
                    AddEquationsCR( sys, w1.tail, w2.tail, true );
                fi;
            od;
        od;
    od;

    # consistency 2: j^(p-1) (ji) = j^p i
    for i  in [n,n-1..1]  do
        for j  in [n,n-1..i+1]  do
            if e[j] > 0 then
                h := rec( word := (e[j] - 1) * id[j], tail := [] );
                w1 := CollectedTwoCR( A, h, pairs[j][i]);
                w2 := CollectedTwoCR( A, pairs[j][j], gn[i]);
                if w1.word <> w2.word  then
                    Error( "j^(p-1) (ji) <> j^p i" );
                else
                    AddEquationsCR( sys, w1.tail, w2.tail, true );
                fi;
            fi;
        od;
    od;

    # consistency 3: k (i i^(p-1)) = (ki) i^p-1
    for i  in [n,n-1..1]  do
        if e[i] > 0 then
            h := rec( word := (e[i] - 1) * id[i], tail := [] );
            l := CollectedTwoCR( A, gn[i], h );
            for k  in [n,n-1..i+1]  do
                w1 := CollectedTwoCR( A, gn[k], l );
                w2 := CollectedTwoCR( A, pairs[k][i], h );
                if w1.word <> w2.word  then
                    Error( "k i^p <> (ki) i^(p-1)" );
                else
                    AddEquationsCR( sys, w1.tail, w2.tail, true );
                fi;
            od;
        fi;
    od;

    # consistency 4: (i i^(p-1)) i = i (i^(p-1) i)
    for i  in [ n, n-1 .. 1 ]  do
        if e[i] > 0 then
            h := rec( word := (e[i] - 1) * id[i], tail := [] );
            l := CollectedTwoCR( A, gn[i], h );
            w1 := CollectedTwoCR( A, l, gn[i] );
            w2 := CollectedTwoCR( A, gn[i], pairs[i][i] );
            if w1.word <> w2.word  then
                Error( "i i^p-1 <> i^p" );
            else
                AddEquationsCR( sys, w1.tail, w2.tail, true );
            fi;
         fi;
    od;

    # consistency 5: j = (j -i) i
    gi := List( id, x -> rec( word := -x, tail := [] ) );
    for i  in [n,n-1..1]  do
        for j  in [n,n-1..i+1]  do
            if e[i] = 0 then
                w1 := CollectedTwoCR( A, gn[j], gi[i] );
                w2 := CollectedTwoCR( A, w1, gn[i] );
                if w2.word <> id[j] then
                    Error( "j <> (j -i) i" );
                else
                    AddEquationsCR( sys, w2.tail, [], true );
                fi;
            fi;
        od;
    od;

    # consistency 6: i = -j (j i)
    for i  in [n,n-1..1]  do
        for j  in [n,n-1..i+1]  do
            if e[j] = 0 then
                w1 := CollectedTwoCR( A, gi[j], pairs[j][i] );
                if w1.word <> id[i] then
                    Error( "i <> -j (j i)" );
                else
                    AddEquationsCR( sys, w1.tail, [], true );
                fi;
            fi;
        od;
    od;

    # consistency 7: -i = -j (j -i)
    for i  in [n,n-1..1]  do
        for j  in [n,n-1..i+1]  do
            if e[i] = 0 and e[j] = 0 then
                w1 := CollectedTwoCR( A, gn[j], gi[i] );
                w1 := CollectedTwoCR( A, gi[j], w1 );
                if w1.word <> -id[i] then
                    Error( "-i <> -j (j -i)" );
                else
                    AddEquationsCR( sys, w1.tail, [], true );
                fi;
            fi;
        od;
    od;

    # add a check ((j ^ i) ^-i ) = j
    for i in [1..n] do
        for j in [1..i-1] do
            w1 := CollectedTwoCR( A, gi[j], pairs[i][j] );
            w1 := CollectedTwoCR( A, gn[j], w1 );
            w1 := CollectedTwoCR( A, w1, gi[j] );
            if w1.word <> id[i] then
                Error("in rel check ");
            elif not IsZeroTail( w2.tail ) then
               # Error("relations bug");
                AddEquationsCR( sys, w1.tail, [], true );
            fi;
        od;
    od;

    # and return solution
    return KernelCR( A, sys );
end );

#############################################################################
##
#F TwoCoboundariesCR( A )
##
InstallGlobalFunction( TwoCoboundariesCR, function( A )
    local n, e, l, sys, R, c, tail, i, t, j;

    # set up system of length d
    n := Length( A.mats );
    e := RelativeOrdersOfPcp( A.factor );
    l := Length( A.enumrels );

    if IsBound(A.endosys) then
        sys := List( A.endosys, x -> CRSystem( x[2], l, 0 ) );
        for i in [1..Length(sys)] do sys[i].full := true; od;
    else
        sys := CRSystem( A.dim, l, A.char );
    fi;

    # loop over relators
    R := [];
    for c in A.enumrels do
        tail := CollectedRelatorCR( A, c[1], c[2] );
        SubtractTailVectors( tail[1], tail[2] );
        Add( R, tail[1] );
    od;

    # shift into system
    for i in [1..n] do
        t := [];
        for j in [1..l] do
            if IsBound(R[j][i]) then t[j] := TransposedMat(R[j][i]); fi;
        od;
        if IsList(sys) then
            AddEquationsCREndo( sys, t );
        else
            AddEquationsCRNorm( sys, t, true );
        fi;
    od;

    # return
    return ImageCR( A, sys ).basis;
end );

#############################################################################
##
#F TwoCohomologyCR( A )
##
InstallGlobalFunction( TwoCohomologyCR, function( A )
    local cc, cb, exp, l, B, b, Q, U, V, i;
    cc := TwoCocyclesCR( A );
    cb := TwoCoboundariesCR( A );
    if not IsBound(A.endosys) then
        return rec( gcc := cc, gcb := cb,
                    factor := AdditiveFactorPcp( cc, cb, A.char ));
    fi;

    Q := [];
    for i in [1..Length(cc)] do
        if Length(cc[i]) = 0 then Add( Q, AbelianPcpGroup([])); fi;
        exp := A.mats[1][i]!.exp;
        l := Length(cc[i][1])/Length(exp);
        B := AbelianPcpGroup( Concatenation(List([1..l], x -> exp)) );
        b := Igs(B);
        U := Subgroup( B, List(cc[i], x -> MappedVector(x,b)));
        V := Subgroup( B, List(cb[i], x -> MappedVector(x,b)));
        Add(Q, U/V);
     od;
     return Q;
end );

#############################################################################
##
#F TwoCohomologyTrivialModule( G, d[, p] )
##
TwoCohomologyTrivialModule := function(arg)
    local G, d, m, C, c;

    # catch arguments
    G := arg[1];
    d := arg[2];
    if Length(arg)=2 then
        m := List(Igs(G), x -> IdentityMat(d));
    elif Length(arg)=3 then
        m := List(Igs(G), x -> IdentityMat(d,arg[3]));
    fi;

    # construct H^2
    C := CRRecordByMats(G, m);
    c := TwoCohomologyCR(C);

    return c.factor.rels;
end;

#############################################################################
##
#F CheckTrivialCohom( G )
##
CheckTrivialCohom := function(G)
    local mats, C, cb, cc, c, E;

    # compute cohom
    Print("compute cohomology \n");
    mats := List( Pcp(G), x -> IdentityMat( 1 ) );
    C := CRRecordByMats( G, mats );
    cb := TwoCoboundariesCR( C );
    Print("cb has length ", Length(cb)," \n");
    cc := TwoCocyclesCR( C );
    Print("cc has length ", Length(cc)," \n");

    # first check
    Print("check cb in cc \n");
    c  := First( cb, x -> IsBool( SolutionMat( cc,x ) ) );
    if not IsBool( c ) then
        Print("  coboundary is not contained in cc \n");
        return c;
    fi;

    # second check
    Print("check cc \n");
    for c in cc do
        E := ExtensionCR( C, c );
    od;
end;