This file is indexed.

/usr/share/gap/lib/domain.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
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
#############################################################################
##
#W  domain.gi                   GAP library                  Martin Schönert
##
##
#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 the generic methods for domains.
##


#############################################################################
##
#M  \=( <C>, <D> )  . . . . . . . . . . . . . . . . . . . for list and domain
##
##  A domain is equal to the strictly sorted list of its elements.
##
InstallMethod( \=,
    "for a list and a domain",
    IsIdenticalObj,
    [ IsCollection and IsList, IsDomain ],
    function( C, D )
    return IsSSortedList( C ) and AsSSortedList( D ) = C;
    end );


#############################################################################
##
#M  \=( <D>, <C> )  . . . . . . . . . . . . . . . . . . . for domain and list
##
##  A domain is equal to the strictly sorted list of its elements.
##
InstallMethod( \=,
    "for a domain and a list",
    IsIdenticalObj,
    [ IsDomain, IsCollection and IsList ],
    function( D, C )
    return IsSSortedList( C ) and AsSSortedList( D ) = C;
    end );


#############################################################################
##
#M  \=( <D1>, <D2> ) . . . . . . . . . . . . . . . . . . . .  for two domains
##
##  Two domains are equal if their elements lists are equal.
##
InstallMethod( \=,
    "for two domains",
    IsIdenticalObj,
    [ IsDomain, IsDomain ],
    function( D1, D2 )
    return AsSSortedList( D1 ) = AsSSortedList( D2 );
    end );


#############################################################################
##
#M  \<( <C>, <D> )  . . . . . . . . . . . . . . . . . . . for list and domain
##
InstallMethod( \<,
    "for a list and a domain",
    IsIdenticalObj,
    [ IsCollection and IsList, IsDomain ],
    function( C, D )
    return C < AsSSortedList( D );
    end );


#############################################################################
##
#M  \<( <D>, <C> )  . . . . . . . . . . . . . . . . . . . for domain and list
##
InstallMethod( \<,
    "for a domain and a list",
    IsIdenticalObj,
    [ IsDomain, IsCollection and IsList ],
    function( D, C )
    return AsSSortedList( D ) < C;
    end );


#############################################################################
##
#M  SetParent( <D>, <P> ) . . . . . . . method to run the subset implications
##
InstallMethod( SetParent,
    "method that calls 'UseSubsetRelation'",
    IsIdenticalObj,
    [ IsDomain, IsDomain ],
    function( D, P )
    UseSubsetRelation( P, D );
    TryNextMethod();
    end );


#############################################################################
##
#F  Domain( [<Fam>, ]<generators> )
##
InstallGlobalFunction( Domain, function( arg )
    if   Length( arg ) = 1 and IsHomogeneousList( arg[1] )
                           and not IsEmpty( arg[1] ) then
      return DomainByGenerators( FamilyObj( arg[1][1] ), arg[1] );
    elif     Length( arg ) = 2 and IsFamily( arg[1] )
         and IsHomogeneousList( arg[2] )
         and ( IsEmpty( arg[2] ) or
               FamilyObj(arg[2]) = CollectionsFamily( arg[1] ) ) then

      return DomainByGenerators( arg[1], arg[2] );
    else
      Error( "usage: Domain( [<Fam>, ]<generators> )" );
    fi;
    end );


#############################################################################
##
#M  DomainByGenerators( <F>, <empty> )  . . . . . . for family and empty list
##
InstallMethod( DomainByGenerators,
    "for family and empty list",
    [ IsFamily, IsList and IsEmpty ],
    function ( F, generators )
    local   D;
    D := Objectify( NewType( CollectionsFamily( F ),
                             IsDomain and IsAttributeStoringRep ),
                    rec() );
    SetGeneratorsOfDomain( D, AsList( generators ) );
    return D;
    end );


#############################################################################
##
#M  DomainByGenerators( <F>, <generators> ) . . . . for family and collection
##
InstallMethod( DomainByGenerators,
    "for family and list & collection",
    [ IsFamily, IsCollection and IsList ],
    function ( F, generators )
    local   D;
    if IsNotIdenticalObj( CollectionsFamily(F), FamilyObj(generators) ) then
        Error( "each element in <generators> must lie in <F>" );
    fi;
    D := Objectify( NewType( FamilyObj( generators ),
                             IsDomain and IsAttributeStoringRep ),
                    rec() );
    SetGeneratorsOfDomain( D, AsList( generators ) );
    return D;
    end );


#############################################################################
##
#M  DomainByGenerators( <generators> )  . . . . . . . . . . .  for collection
##
InstallOtherMethod( DomainByGenerators,
    "for a collection",
    [ IsCollection ],
    function ( generators )
    local   D;
    D := Objectify( NewType( FamilyObj( generators ),
                             IsDomain and IsAttributeStoringRep ),
                    rec() );
    SetGeneratorsOfDomain( D, AsList( generators ) );
    return D;
    end );


#############################################################################
##
#M  GeneratorsOfDomain( <D> )
##
##  `GeneratorsOfDomain' delegates to `AsList'.
##
InstallImmediateMethod( GeneratorsOfDomain,
    IsDomain and HasAsList and IsAttributeStoringRep, 0,
    AsList );

InstallMethod( GeneratorsOfDomain,
    "for a domain (delegate to `AsList')",
    [ IsDomain ],
    AsList );


#############################################################################
##
#M  AsList( <D> ) . . . . . . . . . . . . . . .  list of elements of a domain
#M  Enumerator( <D> ) . . . . . . . . . . . . .  list of elements of a domain
##
##  A domain contains no duplicates, so the sorted list can be taken for both
##  `AsList' and `Enumerator' if it is already known.
##  Note, however, that `AsSSortedList' resp. `EnumeratorSorted' cannot be the
##  default method of `AsList' resp. `Enumerator' for domains,
##  since `EnumeratorSorted' is allowed to call `Enumerator'.
##
##  If domain generators of <D> are stored then `AsList' and `Enumerator'
##  may return a duplicate-free list of domain generators.
##
InstallImmediateMethod( AsList,
    IsDomain and HasAsSSortedList and IsAttributeStoringRep,
    0,
    AsSSortedList );

InstallImmediateMethod( Enumerator,
    IsDomain and HasEnumeratorSorted and IsAttributeStoringRep,
    0,
    EnumeratorSorted );

InstallMethod( AsList,
    "for a domain with stored domain generators",
    [ IsDomain and HasGeneratorsOfDomain ],
    D -> DuplicateFreeList( GeneratorsOfDomain( D ) ) );

InstallMethod( Enumerator,
    "for a domain with stored domain generators",
    [ IsDomain and HasGeneratorsOfDomain ],
    D -> DuplicateFreeList( GeneratorsOfDomain( D ) ) );


#############################################################################
##
#M  EnumeratorSorted( <D> ) . . . . . . . . . . . set of elements of a domain
##
InstallMethod( EnumeratorSorted,
    "for a domain",
    [ IsDomain ],
    D -> EnumeratorSorted( Enumerator( D )  ));


#############################################################################
##
#M  \in( <elm>, <D> ) . . . . . . . . . . . . . . membership test for domains
##
##  The default method for domain membership tests computes the set of
##  elements of the domain with the function 'Enumerator' and tests whether
##  <elm> lies in this set.
##
InstallMethod( \in,
    "for a domain, and an element",
    IsElmsColls,
    [ IsObject, IsDomain ],
    function( elm, D )
    return elm in Enumerator( D );
    end );


#############################################################################
##
#M  Representative( <D> ) . . . . . . . . . . . .  representative of a domain
##
InstallMethod( Representative,
    "for a domain with known elements list",
    [ IsDomain and HasAsList ],
    RepresentativeFromGenerators( AsList ) );

InstallMethod( Representative,
    "for a domain with known domain generators",
    [ IsDomain and HasGeneratorsOfDomain ],
    RepresentativeFromGenerators( GeneratorsOfDomain ) );


#############################################################################
##
#M  Size( <D> ) . . . . . . . . . . . . . . . . . . . .  for a trivial domain
##
InstallMethod( Size,
    "for a trivial domain",
    [ IsDomain and IsTrivial ],
    D -> 1 );


#############################################################################
##
#M  IsSubset( <D>, <E> )  . . . . . . . . . . . . . . . . for <E> with parent
##
InstallMethod( IsSubset,
    "test whether domain is parent of the other",
    IsIdenticalObj,
    [ IsDomain, IsDomain and HasParent ],
    SUM_FLAGS, # should be done before everything else
    function ( D, E )
    if not IsIdenticalObj( D, Parent( E ) ) then
        TryNextMethod();
    fi;
    return true;
    end );

InstallMethod( CanComputeIsSubset,
    "default for domains: no unless identical",
    [ IsDomain, IsDomain ],
    function( a, b )
    return IsIdenticalObj( a, b )
           or ( HasParent( b ) and CanComputeIsSubset( a, Parent( b ) ) );
    end );


#############################################################################
##
#M  Intersection2( <D1>, <D2> )
##
##  We cannot install this for arbitrary collections since the intersection
##  must be duplicate free (and sorted in the case of a list).
##
InstallMethod( Intersection2,
    "whole family and domain",
    IsIdenticalObj,
    [ IsCollection and IsWholeFamily, IsDomain ],
    SUM_FLAGS, # this is better than everything else
    function( D1, D2 )
    return D2;
    end );

InstallMethod( Intersection2,
    "domain and whole family",
    IsIdenticalObj,
    [ IsDomain, IsCollection and IsWholeFamily ],
    SUM_FLAGS, # this is better than everything else
    function( D1, D2 )
    return D1;
    end );


#############################################################################
##
#F  InstallAccessToGenerators( <required>, <infotext>, <generators> )
##
InstallGlobalFunction( InstallAccessToGenerators,
    function( required, infotext, generators )

    InstallMethod( \.,
        Concatenation( "generators of a ", infotext ),
        true,
        [ required and Tester( generators ), IsPosInt ], 0,
        function( D, n )

        local gens, nr, names;

        # Get the appropriate generators and the component name string.
        gens:= generators( D );
        n:= NameRNam( n );

        # If the component name stands for an integer,
        # return the generator at this position.
        nr:= Int( n );
        if IsPosInt( nr ) then
          if nr <= Length( gens ) then
            return gens[ nr ];
          else
            Error("Generator number ", nr, " does not exist\n");
          fi;
        fi;

        # I the component name is the name itself,
        # return the corresponding generator.
        names:= ElementsFamily( FamilyObj( D ) );
        if IsBound( names!.names ) then
          names:= names!.names;
          nr:= Position( names, n );
          if nr <> fail then
            return gens[ nr ];
          fi;
        fi;

        # Give up.
        TryNextMethod();
        end );

    end );


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