This file is indexed.

/usr/share/gap/pkg/Polycyclic/gap/cohom/solcohom.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
#############################################################################
##
#W  solcohom.gi                  Polycyc                         Bettina Eick
##

#############################################################################
##
#F CRSystem( d, l, c )
##
CRSystem := function( d, l, c )
    local null, zero;
    null := List( [1..d*l], x -> 0 );
    if c <> 0 then null := null * One(GF(c)); fi;
    zero := List( [1..d], x -> 0 );
    if c <> 0 then zero := zero * One(GF(c)); fi;
    return rec( null := null, zero := zero, dim := d, len := l, base := [] );
end;

#############################################################################
##
#F AddToCRSystem( sys, mat )
##
AddToCRSystem := function( sys, mat )
    local v;
    for v in mat do
        if IsBound( sys.full ) and sys.full then
            Add( sys.base, v );
        elif not v = sys.null and not v in sys.base then
            Add( sys.base, v );
        fi;
    od;
end;

#############################################################################
##
#F SubtractTailVectors( t1, t2 )
##
SubtractTailVectors := function( t1, t2 )
    local i;
    for i  in [ 1 .. Length(t2) ]  do
        if IsBound(t2[i])  then
            if IsBound(t1[i])  then
                t1[i] := t1[i] - t2[i];
            else
                t1[i] := - t2[i];
            fi;
        fi;
    od;
end;

#############################################################################
##
#F IsZeroTail( t )
##
IsZeroTail := function( t )
    local i;
    for i  in [ 1 .. Length(t) ]  do
        if IsBound(t[i]) and t[i] <> 0 * t[i] then
            return false;
        fi;
    od;
    return true;
end;

#############################################################################
##
#F AddEquationsCR( sys, t1, t2, flag )
##
AddEquationsCRNorm := function( sys, t, flag  )
    local i, j, v, mat;

    # create a matrix
    mat := [];
    for j in [1..sys.dim] do
        v := [];
        for i in [1..sys.len] do
            if IsBound( t[i] ) then
                Append( v, t[i]{[1..sys.dim]}[j] );
            else
                Append( v, sys.zero );
            fi;
        od;
        Add( mat, v );
    od;

    # finally add it
    if flag then
        AddToCRSystem( sys, mat );
    else
        Append( sys.base, mat );
    fi;
end;

AddEquationsCREndo := function( sys, t )
    local i, l;
    for i in [1..Length(sys)] do
        l := List(t, x -> x[i]);
        AddEquationsCRNorm( sys[i], l, true );
    od;
end;

AddEquationsCR := function( sys, t1, t2, flag  )
    local t;

    # the trivial case
    if t1 = t2 and flag then return; fi;

    # subtract t1 - t2 into t
    t := ShallowCopy(t1);
    SubtractTailVectors( t, t2 );

    # check case
    if IsList(sys) then
        AddEquationsCREndo( sys, t );
    else
        AddEquationsCRNorm( sys, t, flag );
    fi;
end;

#############################################################################
##
## Some small helpers
##
MatPerm := function( d, e )
    local k, t, l, i, f, n, r;
    if d = 1 then return (); fi;
    k := Length(e);
    t := Set(SeriesSteps(e)); Add(t, k);
    l := [];
    for i in [1..Length(t)-1] do
        f := t[i]+1;
        n := t[i+1];
        r := List([1..d], x -> (x-1)*k+[f..n]);
        Append(l, Concatenation(r));
    od;
    return PermListList([1..d*k], l)^-1;
end;

PermuteMat := function( M, rho, sig )
    local N, i, j;
    N := MutableCopyMat(M);
    for i in [1..Length(M)] do
        for j in [1..Length(M[1])] do
            N[i][j] := M[i^sig][j^rho];
        od;
    od;
    return N;
end;

PermuteVec := function( v, rho )
    return List([1..Length(v)], i -> v[i^rho]);
end;

#############################################################################
##
## ImageCR( A, sys )
##
## returns a basis of the image of sys. Additionally, it returns the
## transformation from the given generating set and the nullspace of the
## given generating set.
##
ImageCRNorm := function( A, sys )
    local mat, new, tmp;

    mat := sys.base;

    # if mat is empty
    if mat = 0 * mat then
        tmp := rec( basis := [],
                    transformation := [],
                    relations := A.one );

    # if mat is integer
    elif A.char = 0 then
        tmp := LLLReducedBasis( mat, "linearcomb" );

    # if mat is ffe
    elif A.char > 0 then
       new := SemiEchelonMatTransformation( mat );
       tmp := rec( basis := new.vectors,
                   transformation := new.coeffs,
                   relations := ShallowCopy(new.relations) );
       TriangulizeMat(tmp.relations);
    fi;

    # return
    return rec( basis := tmp.basis,
                transf := tmp.transformation,
                fixpts := tmp.relations );
end;

ImageCREndo := function( A, sys )
    local i, mat, K, e, p, n, m, rho, sig;
    K := [];
    for i in [1..Length(sys)] do
        mat := sys[i].base;
        p := A.endosys[i][1];
        e := A.mats[1][i]!.exp;
        n := Length(mat)/Length(e);
        m := Length(mat[1])/Length(e);
        rho := MatPerm(m, e)^-1;
        sig := MatPerm(n, e)^-1;
        mat := PermuteMat( mat, rho, sig );
        K[i] := KernelSystemGauss( mat, e, p );
        K[i] := ImageSystemGauss( mat, K[i], e, p );
        K[i] := List(K[i], x -> PermuteVec( x, rho^-1));
    od;
    return K;
end;

ImageCR := function( A, sys )
    if IsList(sys) then
        return ImageCREndo( A, sys );
    else
        return ImageCRNorm( A, sys );
    fi;
end;

#############################################################################
##
## KernelCR( A, sys )
##
## returns the kernel of the system
##
KernelCRNorm := function( A, sys )
    local mat, null;

    if sys.len = 0 then return []; fi;

    # we want the kernel of the transposed
    mat := TransposedMat( sys.base );

    # the nullspace
    if Length( mat ) = 0 then
        null := IdentityMat( sys.dim * sys.len );
        if A.char > 0 then null := null * One( A.field ); fi;
    elif A.char > 0 then
        null := TriangulizedNullspaceMat( mat );
    else
        null := PcpNullspaceIntMat( mat );
        null := TriangulizedIntegerMat( null );
    fi;

    return null;
end;


KernelCREndo := function( A, sys )
    local i, mat, K, e, p, n, m, rho, sig;
    K := [];
    for i in [1..Length(sys)] do
        mat := TransposedMat( sys[i].base );
        p := A.endosys[i][1];
        e := A.mats[1][i]!.exp;
        n := Length(mat)/Length(e);
        m := Length(mat[1])/Length(e);
        rho := MatPerm(m, e);
        sig := MatPerm(n, e);
        mat := PermuteMat( mat, rho, sig );
        K[i] := KernelSystemGauss( mat, e, p );
        K[i] := List(K[i], x -> PermuteVec( x, rho^-1));
    od;
    return K;
end;

KernelCR := function( A, sys )
    if IsList(sys) then
        return KernelCREndo( A, sys );
    else
        return KernelCRNorm( A, sys );
    fi;
end;

#############################################################################
##
## SpecialSolutionCR( A, sys )
##
## returns a special solution of the system corresponding to A.extension
##
SpecialSolutionCR := function( A, sys )
    local mat, sol, vec;

    if sys.len = 0 then return []; fi;

    if Length( sys.base ) = 0 or not IsBound( A.extension ) then
        sol := List( [1..sys.dim * sys.len], x -> 0 );
        if A.char > 0 then sol := sol * One( A.field ); fi;
    else
		mat := TransposedMat( sys.base );
        vec := Concatenation( A.extension );
        if A.char > 0 then
            sol := SolutionMat( mat, vec );
        else
            sol := PcpSolutionIntMat( mat, vec );
        fi;
    fi;

    # return with special solution
    return sol;
end;