This file is indexed.

/usr/share/gap/lib/semicong.gi 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
#############################################################################
##
#W  semicong.gi                  GAP library   	               Andrew Solomon
##
##
#Y  Copyright (C)  1996,  Lehrstuhl D für Mathematik,  RWTH Aachen,  Germany
#Y  (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y  Copyright (C) 2002 The GAP Group
##
##  This file contains generic methods for semigroup congruences.
##
##  Maintenance and further development by:
##  Robert F. Morse
##  Andrew Solomon
##

######################################################################
##
##
#P  LeftSemigroupCongruenceByGeneratingPairs( <semigroup>, <gens> )
#P  RightSemigroupCongruenceByGeneratingPairs( <semigroup>, <gens> )
#P  SemigroupCongruenceByGeneratingPairs( <semigroup>, <gens> )
##
##
######################################################################

InstallMethod( LeftSemigroupCongruenceByGeneratingPairs,
    "for a Semigroup  and a list of pairs of its elements",
    IsElmsColls,
    [ IsSemigroup, IsList ], 0,
    function( M, gens )
        local cong;
        cong := LR2MagmaCongruenceByGeneratingPairsCAT(M, gens, 
                    IsLeftMagmaCongruence);
        SetIsLeftSemigroupCongruence(cong,true);
        return cong;
    end );

InstallMethod( LeftSemigroupCongruenceByGeneratingPairs,
    "for a Semigroup and an empty list",
    true,
    [ IsSemigroup, IsList and IsEmpty ], 0,
    function( M, gens )
        local cong;
        cong := LR2MagmaCongruenceByGeneratingPairsCAT(M, gens, 
                    IsLeftMagmaCongruence);
        SetIsLeftSemigroupCongruence(cong,true);
        SetEquivalenceRelationPartition(cong,[]);
        return cong;
    end );

InstallMethod( RightSemigroupCongruenceByGeneratingPairs,
    "for a Semigroup and a list of pairs of its elements",
    IsElmsColls,
    [ IsSemigroup, IsList ], 0,
    function( M, gens )
        local cong;
        cong := LR2MagmaCongruenceByGeneratingPairsCAT(M, gens, 
                    IsRightMagmaCongruence);
        SetIsRightSemigroupCongruence(cong,true);
        return cong;
    end );

InstallMethod( RightSemigroupCongruenceByGeneratingPairs,
    "for a Semigroup and an empty list",
    true,
    [ IsSemigroup, IsList and IsEmpty ], 0,
    function( M, gens )
        local cong;
        cong := LR2MagmaCongruenceByGeneratingPairsCAT(M, gens, 
                    IsRightMagmaCongruence);
        SetIsRightSemigroupCongruence(cong,true);
        SetEquivalenceRelationPartition(cong,[]);
        return cong;
    end );

InstallMethod( SemigroupCongruenceByGeneratingPairs,
    "for a semigroup and a list of pairs of its elements",
    IsElmsColls,
    [ IsSemigroup, IsList ], 0,
    function( M, gens )
        local cong;
        cong := LR2MagmaCongruenceByGeneratingPairsCAT(M, gens, 
                    IsMagmaCongruence);
        SetIsSemigroupCongruence(cong,true);
        return cong;
    end );

InstallMethod( SemigroupCongruenceByGeneratingPairs,
    "for a semigroup and an empty list",
    true,
    [ IsSemigroup, IsList and IsEmpty], 0,
    function( M, gens )
        local cong;
        cong := LR2MagmaCongruenceByGeneratingPairsCAT(M, gens, 
                    IsMagmaCongruence);
        SetIsSemigroupCongruence(cong,true);
        SetEquivalenceRelationPartition(cong,[]);
        return cong;
    end );

#############################################################################
##
#P  IsLeftSemigroupCongruence(<c>)
#P  IsRightSemigroupCongruence(<c>)
#P  IsSemigroupCongruence(<c>)
##
InstallMethod( IsLeftSemigroupCongruence, 
    "test whether a left magma congruence is a semigroup a congruence", 
    true,
    [ IsLeftMagmaCongruence ], 0,
    function(c)
        return IsSemigroup(Source(c)); 
    end);            

InstallMethod( IsRightSemigroupCongruence, 
    "test whether a right magma congruence is a semigroup a congruence",
    true,
    [ IsRightMagmaCongruence ], 0,
    function(c)
        return IsSemigroup(Source(c)); 
    end);            

InstallMethod( IsSemigroupCongruence, 
    "test whether a magma congruence is a semigroup a congruence",
    true,
    [ IsMagmaCongruence ], 0,
    function(c)
        return IsSemigroup(Source(c)); 
    end);            

#############################################################################
##
#M  IsReesCongruence(<c>)
##
##  True when the congruence has at most one
##  nonsingleton congruence class and that equivalence
##  class forms an ideal of the semigroup.
##  A special check is needed if the congruence is the
##  diagonal congruence -- as this congruence is a Rees
##  congruence only if the semigroup contains a zero element.
##
InstallMethod( IsReesCongruence,
    "for a semigroup congruence",
    true,
    [ IsSemigroupCongruence ], 0,
    function( cong )
        local part,  # partition
              id,    # ideal generated by non singleton block
              it,    # iterator of id
              s,     # underlying semigroup 
              i;     # index variable

        part := EquivalenceRelationPartition(cong);

        # Determine if the congruence is Green's relation
        #    we have slightly different attributes as the 
        #    relation is represented on points.
        #
        if IsGreensRelation(cong) then
            s := AssociatedSemigroup(cong);
            part := List(part, x->List(x,y->AsSortedList(s)[y]));
        else 
            s := Source(cong);
        fi; 


        if Length(part)=0 then
            # if all blocks are singletons we must check to see
            # if the semigroup contains a zero otherwise return false.
            #
            # See if it already has one -- if so return true
            #
            if HasMultiplicativeZero(s) then return true; fi;

            # The semigroup might have a zero it just isn't identified
            # yet.
            #
            # Using the IsMultiplicativeZero method for semigroups
            # is the most efficient which only checks with the
            # generators of the semigroup. We prune our search to the 
            # idempotents.

            return ForAny(Idempotents(s), x->IsMultiplicativeZero(s,x));

        elif Length(part)=1 then
            # if there is one non singletion block
            # check that it forms an ideal
            id := MagmaIdealByGenerators(s,part[1]);

            # loop through the elements of the ideal id
            # until you find an element not in the non singleton block
            it := Iterator(id);
            while not IsDoneIterator(it) do
                if not NextIterator(it) in part[1] then
                    return false;
                fi;
            od;
            # here we know that the block forms an ideal
            # hence the congruence is Rees
            return true;
        else
            # if the partition has more than one non singleton class
            # then it is not a Rees congruence
            return false;
        fi;
    end);


#############################################################################
##
#M  PrintObj( <smg cong> ) 
##
##  left semigroup congruence
##
InstallMethod( PrintObj,
    "for a left semigroup congruence",
    true,
    [ IsLeftSemigroupCongruence ], 0,
    function( S )
        Print( "LeftSemigroupCongruence( ... )" );
    end );

InstallMethod( PrintObj,
    "for a left semigroup congruence with known generating pairs",
    true,
    [ IsLeftSemigroupCongruence and HasGeneratingPairsOfMagmaCongruence ], 0,
    function( S )
        Print( "LeftSemigroupCongruence( ", 
               GeneratingPairsOfMagmaCongruence( S ), " )" );
    end );

##  right semigroup congruence

InstallMethod( PrintObj,
    "for a right semigroup congruence",
    true,
    [ IsRightSemigroupCongruence ], 0,
    function( S )
        Print( "RightSemigroupCongruence( ... )" );
    end );

InstallMethod( PrintObj,
    "for a right semigroup congruence with known generating pairs",
    true,
    [ IsRightSemigroupCongruence and HasGeneratingPairsOfMagmaCongruence ], 0,
    function( S )
        Print( "RightSemigroupCongruence( ", 
                   GeneratingPairsOfMagmaCongruence( S ), " )" );
    end );

##  two sided semigroup congruence

InstallMethod( PrintObj,
    "for a semigroup congruence",
    true,
    [ IsSemigroupCongruence ], 0,
    function( S )
        Print( "SemigroupCongruence( ... )" );
    end );

InstallMethod( PrintObj,
    "for a semigroup Congruence with known generating pairs",
    true,
    [ IsSemigroupCongruence and HasGeneratingPairsOfMagmaCongruence ], 0,
    function( S )
        Print( "SemigroupCongruence( ",
               GeneratingPairsOfMagmaCongruence( S ), " )" );
    end );


#############################################################################
##
#M  ViewObj( <smg cong> ) 
##

##  left semigroup congruence

InstallMethod( ViewObj,
    "for a LeftSemigroupCongruence",
    true,
    [ IsLeftSemigroupCongruence ], 0,
    function( S )
        Print( "<LeftSemigroupCongruence>" );
    end );

InstallMethod( ViewObj,
    "for a LeftSemigroupCongruence with known generating pairs",
    true,
    [ IsLeftSemigroupCongruence and HasGeneratingPairsOfMagmaCongruence ], 0,
    function( S )
        Print( "<LeftSemigroupCongruence with ", 
               Length( GeneratingPairsOfMagmaCongruence( S ) ), 
               " generating pairs>" );
    end );

##  right semigroup congruence

InstallMethod( ViewObj,
    "for a RightSemigrouCongruence",
    true,
    [ IsRightSemigroupCongruence ], 0,
    function( S )
        Print( "<RightSemigroupCongruence>" );
    end );

InstallMethod( ViewObj,
    "for a RightSemigroupCongruence with generators",
    true,
    [ IsRightSemigroupCongruence and HasGeneratingPairsOfMagmaCongruence ], 0,
    function( S )
        Print( "<RightSemigroupCongruence with ", 
               Length( GeneratingPairsOfMagmaCongruence( S ) ), 
               " generating pairs>" );
    end );

## two sided semigroup congruence

InstallMethod( ViewObj,
    "for a semigroup congruence",
    true,
    [ IsSemigroupCongruence ], 0,
    function( S )
        Print( "<semigroup congruence>" );
    end );

InstallMethod( ViewObj,
    "for a semigroup Congruence with known generating pairs",
    true,
    [ IsSemigroupCongruence and HasGeneratingPairsOfMagmaCongruence ], 0,
    function( S )
        Print( "<semigroup congruence with ",
               Length(GeneratingPairsOfMagmaCongruence( S )), 
               " generating pairs>" );
    end );

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