This file is indexed.

/usr/share/gap/lib/mgmadj.gi is in gap-libs 4r7p5-2.

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
#############################################################################
##
#W  mgmadj.gi                    GAP library                  Andrew Solomon
##
##
#Y  Copyright (C)  1997,  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 magmas with zero adjoined.
##

InstallMethod( IsMultiplicativeZero,
"for magma with multiplicative zero and multiplicative element",
IsCollsElms,
[ IsMagma and HasMultiplicativeZero, IsMultiplicativeElement],
function( M, z )
  return z = MultiplicativeZero(M);
end);

#

InstallMethod( IsMultiplicativeZero,
"for a magma and multiplicative element",
IsCollsElms,
[ IsMagma, IsMultiplicativeElement],
function(M, z)
  local i, en, x;

  i := 1;
  en := Enumerator(M);
  while IsBound(en[i]) do
    x := en[i];
    if x*z <> z or z*x <> z then	
      return false;
    fi;
    i := i +1;
  od;
  SetMultiplicativeZero(M,Immutable(z));
  return true;
end);

#

InstallMethod( IsMultiplicativeZero,
"for a semigroup with generators and multiplicative element",
IsCollsElms, 
[IsSemigroup and HasGeneratorsOfSemigroup, IsMultiplicativeElement],
function(S, z)
  if HasMultiplicativeZero(S) then 
    return z=MultiplicativeZero(S);
  elif ForAll(GeneratorsOfSemigroup(S), x->x*z=z and z*x=z) then
    SetMultiplicativeZero(S, Immutable(z));
    return true;
  fi;
  return false;
end);

#

InstallOtherMethod( MultiplicativeZero, "for a magma",
[ IsMagma ],
function( M )
  local en, i;

  en := Enumerator(M);
  i := 1;
  while (IsBound(en[i])) do
    if IsMultiplicativeZero(M, en[i]) then
      return en[i];
    fi;
    i := i +1;
  od;
  return fail;
end );

# MagmaWithZeroAdjoined

InstallMethod(MagmaWithZeroAdjoined, "for a magma with 0 adjoined element",
[IsMagmaWithZeroAdjoinedElementRep],
function( elm )
  return FamilyObj(elm)!.MagmaWithZeroAdjoined;
end);

#

InstallMethod(MagmaWithZeroAdjoined, "for a magma", 
[IsMagma], m-> Range(InjectionZeroMagma(m)));

#

InstallMethod( OneMutable, "for an element of a magma with zero adjoined",
[IsMultiplicativeElementWithOne and IsMagmaWithZeroAdjoinedElementRep],
x-> One(MagmaWithZeroAdjoined(x)));

#

InstallMethod( MultiplicativeZeroOp,
"for an element of a magma with zero adjoined",
[ IsMagmaWithZeroAdjoinedElementRep], 
function( elm )
  return MultiplicativeZero(MagmaWithZeroAdjoined(elm));  
end );

#

InstallMethod(InjectionZeroMagma, "for a magma",
[IsMagma],
function(m)
  local filts, fam, type, inj, zero, gens, out;
  
  if Length(GeneratorsOfMagma(m))=0 then
    Error("usage: it is only possible to adjoin a zero to a magma",  
    " with generators,");
    return;
  fi;
 
  # filters for the elements
  filts := IsMultiplicativeElementWithZero;

  if IsMultiplicativeElementWithOne(Representative(m)) then
    filts := filts and IsMultiplicativeElementWithOne;
  fi;

  if IsAssociativeElement(Representative(m)) then
    filts := filts and IsAssociativeElement;
  fi;

  fam:=NewFamily( "FamilyOfElementOfMagmaWithZeroAdjoined", filts);
  type:=NewType(fam, filts and IsMagmaWithZeroAdjoinedElementRep);
  
  #the injection
  inj:=function(elt)
    local new;
    new:=Objectify(type, rec(elt:=elt));
    return new;
  end;
  
  # set the one
  if IsMagmaWithOne(m) then
    SetOne(fam, inj(One(m)));
  fi;
 
  #filters for the magma with 0 adjoined
  filts:=IsAttributeStoringRep and IsMagmaWithZeroAdjoined;

  if IsSemigroup(m) then
    filts:=filts and IsAssociative;
  fi;

  if IsMagmaWithOne(m) then 
    filts:=filts and IsMagmaWithOne;
  fi;

  zero := Objectify(type, rec(elt:=fail));;
  gens:=Concatenation(List(GeneratorsOfMagma(m), g-> inj(g)), [zero]);
  out:=Objectify( NewType( FamilyObj( gens ), filts), rec());

  # store the magma in the family so that it can be recovered from an element
  fam!.MagmaWithZeroAdjoined:=out;

  if IsGroup(m) then
    SetIsZeroGroup(out, true);
  fi;

  SetMultiplicativeZero(out, zero); 
  
  if IsMagmaWithOne(out) then 
    SetGeneratorsOfMagmaWithOne(out, gens);
  fi;
  SetGeneratorsOfMagma(out, gens);

  inj:=MappingByFunction(m, out, inj, x-> x!.elt);
  SetUnderlyingInjectionZeroMagma(out, inj);
  
  return inj;
end);

#

InstallMethod(PrintObj, "for a magma with zero adjoined",
[IsMagmaWithZeroAdjoined and IsMagma and HasGeneratorsOfMagma], 10 ,
function(m) 
  Print("<");
  PrintObj(Source(UnderlyingInjectionZeroMagma(m)));
  Print(" with 0 adjoined>");
  return;
end);  

#

InstallMethod(ViewObj, "for a zero group",
[IsMagmaWithZeroAdjoined and IsMagma and HasGeneratorsOfMagma], 10, 
function(m)  
  Print("<");
  ViewObj(Source(UnderlyingInjectionZeroMagma(m)));
  Print(" with 0 adjoined>");
  return; 
end);

#

InstallMethod( Size, "for a magma with a zero adjoined",
[IsMagmaWithZeroAdjoined], 
function(m)
  return Size(Source(UnderlyingInjectionZeroMagma(m)))+1;
end);

#

InstallMethod( \*, "for two elements of a magma with zero adjoined",
IsIdenticalObj,
[ IsMagmaWithZeroAdjoinedElementRep, IsMagmaWithZeroAdjoinedElementRep ],
function(x, y)

  if x!.elt=fail then 
    return x;
  elif y!.elt=fail then	
    return y;
  fi;
  return (x!.elt*y!.elt)^UnderlyingInjectionZeroMagma(
   MagmaWithZeroAdjoined(x)); 
end );

#

InstallMethod( \=, "for two elements of a magma with zero adjoined",
IsIdenticalObj,
[IsMagmaWithZeroAdjoinedElementRep, IsMagmaWithZeroAdjoinedElementRep ],
function(x, y)
  return x!.elt=y!.elt;
end);

#  ordering of the underlying magma with zero less than everything else

InstallMethod(\<, "for two elements of magmas with zero adjoined", 
IsIdenticalObj,
[ IsMagmaWithZeroAdjoinedElementRep, IsMagmaWithZeroAdjoinedElementRep ],
function(x, y)
  local xx, yy;
 
  xx:=x!.elt; yy:=y!.elt;
    
  if xx=fail then 
    return not yy=fail;
  elif yy=fail then 
    return false;
  fi;
  return xx<yy;
end);

#

InstallMethod(PrintObj, "for an element of a magma with zero adjoined", 
[IsMagmaWithZeroAdjoinedElementRep],
function(x) 
  local m;
 
  m:=FamilyObj(x)!.MagmaWithZeroAdjoined;
  Print("<");
  if IsGroup(Source(UnderlyingInjectionZeroMagma(m))) then 
    Print("group ");
  elif IsMonoid(Source(UnderlyingInjectionZeroMagma(m))) then
    Print("monoid ");
  elif IsSemigroup(Source(UnderlyingInjectionZeroMagma(m))) then 
    Print("semigroup ");
  else 
    Print("magma ");
  fi;

  Print("with 0 adjoined elt: ");
  if x!.elt=fail then 
    Print("0");
  else 
    PrintObj(x!.elt);
  fi;
  Print(">");
  return;
end);