This file is indexed.

/usr/share/gap/lib/idealalg.gi is in gap-libs 4r7p9-1.

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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
#############################################################################
##
#W  idealalg.gi                 GAP library                     Thomas Breuer
##
##
#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 methods for (left/right/two-sided) ideals
##  in algebras and algebras-with-one.
##


#############################################################################
##
#F  IsLeftIdealFromGenerators( <AsStructA>, <AsStructS>, <GensA>, <GensS> )
##
BindGlobal( "IsLeftIdealFromGenerators",
    function( AsStructA, AsStructS, GeneratorsA, GeneratorsS )
    return function( A, S )

    local inter,   # intersection of left acting domains
          gensS,   # suitable generators of `S'
          a,       # loop over suitable generators of `A'
          i;       # loop over `gensS'

    if not IsSubset( A, S ) then
      return false;
    elif LeftActingDomain( A ) <> LeftActingDomain( S ) then
      inter:= Intersection2( LeftActingDomain( A ), LeftActingDomain( S ) );
      return IsLeftIdeal( AsStructA( inter, A ), AsStructS( inter, S ) );
    fi;

    gensS:= GeneratorsS( S );
    for a in GeneratorsA( A ) do
      for i in gensS do
        if not a * i in S then
          return false;
        fi;
      od;
    od;
    return true;
    end;
end );


#############################################################################
##
#F  IsRightIdealFromGenerators( <AsStructA>, <AsStructS>, <GensA>, <GensS> )
##
BindGlobal( "IsRightIdealFromGenerators",
    function( AsStructA, AsStructS, GeneratorsA, GeneratorsS )
    return function( A, S )

    local inter,   # intersection of left acting domains
          gensS,   # suitable generators of `S'
          a,       # loop over suitable generators of `A'
          i;       # loop over `gensS'

    if not IsSubset( A, S ) then
      return false;
    elif LeftActingDomain( A ) <> LeftActingDomain( S ) then
      inter:= Intersection2( LeftActingDomain( A ), LeftActingDomain( S ) );
      return IsRightIdeal( AsStructA( inter, A ), AsStructS( inter, S ) );
    fi;

    gensS:= GeneratorsS( S );
    for a in GeneratorsA( A ) do
      for i in gensS do
        if not i * a in S then
          return false;
        fi;
      od;
    od;
    return true;
    end;
end );


#############################################################################
##
#M  IsLeftIdealOp( <A>, <S> )
##
##  Check whether the subalgebra <S> is a left ideal in <A>,
##  i.e., whether <S> is contained in <A> and $a * i$ lies in <S>
##  for all basis vectors $a$ of <A> and $s$ of <S>.
##
##  For associative algebras(-with-one), we need to check only the products
##  of algebra(-with-one) generators.
##
InstallOtherMethod( IsLeftIdealOp,
    "for FLMLOR and free left module",
    IsIdenticalObj,
    [ IsFLMLOR, IsFreeLeftModule ], 0,
    IsLeftIdealFromGenerators( AsFLMLOR, AsLeftModule,
                               GeneratorsOfLeftModule,
                               GeneratorsOfLeftModule ) );

InstallOtherMethod( IsLeftIdealOp,
    "for associative FLMLOR and free left module",
    IsIdenticalObj,
    [ IsFLMLOR and IsAssociative, IsFreeLeftModule ], 0,
    IsLeftIdealFromGenerators( AsFLMLOR, AsLeftModule,
                               GeneratorsOfLeftOperatorRing,
                               GeneratorsOfLeftModule ) );

InstallOtherMethod( IsLeftIdealOp,
    "for associative FLMLOR-with-one and free left module",
    IsIdenticalObj,
    [ IsFLMLORWithOne and IsAssociative, IsFreeLeftModule ], 0,
    IsLeftIdealFromGenerators( AsFLMLOR, AsLeftModule,
                               GeneratorsOfLeftOperatorRingWithOne,
                               GeneratorsOfLeftModule ) );

InstallMethod( IsLeftIdealOp,
    "for associative FLMLOR and FLMLOR",
    IsIdenticalObj,
    [ IsFLMLOR and IsAssociative, IsFLMLOR ], 0,
    IsLeftIdealFromGenerators( AsFLMLOR, AsFLMLOR,
                               GeneratorsOfLeftOperatorRing,
                               GeneratorsOfLeftOperatorRing ) );


#############################################################################
##
#M  IsRightIdealOp( <A>, <S> )
##
##  Check whether the subalgebra <S> is a right ideal in <A>,
##  i.e., whether <S> is contained in <A> and $s * a$ lies in <S>
##  for all basis vectors $a$ of <A> and $s$ of <S>.
##
##  For associative algebras(-with-one), we need to check only the products
##  of algebra(-with-one) generators.
##
InstallOtherMethod( IsRightIdealOp,
    "for FLMLOR and free left module",
    IsIdenticalObj,
    [ IsFLMLOR, IsFreeLeftModule ], 0,
    IsRightIdealFromGenerators( AsFLMLOR, AsLeftModule,
                                GeneratorsOfLeftModule,
                                GeneratorsOfLeftModule ) );

InstallOtherMethod( IsRightIdealOp,
    "for associative FLMLOR and free left module",
    IsIdenticalObj,
    [ IsFLMLOR and IsAssociative, IsFreeLeftModule ], 0,
    IsRightIdealFromGenerators( AsFLMLOR, AsLeftModule,
                                GeneratorsOfLeftOperatorRing,
                                GeneratorsOfLeftModule ) );

InstallOtherMethod( IsRightIdealOp,
    "for associative FLMLOR-with-one and free left module",
    IsIdenticalObj,
    [ IsFLMLORWithOne and IsAssociative, IsFreeLeftModule ], 0,
    IsRightIdealFromGenerators( AsFLMLOR, AsLeftModule,
                                GeneratorsOfLeftOperatorRingWithOne,
                                GeneratorsOfLeftModule ) );

InstallMethod( IsRightIdealOp,
    "for associative FLMLOR and FLMLOR",
    IsIdenticalObj,
    [ IsFLMLOR and IsAssociative, IsFLMLOR ], 0,
    IsRightIdealFromGenerators( AsFLMLOR, AsFLMLOR,
                                GeneratorsOfLeftOperatorRing,
                                GeneratorsOfLeftOperatorRing ) );


#############################################################################
##
#M  IsTwoSidedIdealOp( <A>, <S> )
##
##  Check whether the subspace or subalgebra $S$ is an ideal in $A$,
##  i.e., whether $a s \in S$ and $s a \in S$
##  for all basis vectors $a$ of $A$ and $s$ of $S$.
##
InstallOtherMethod( IsTwoSidedIdealOp,
    "for commutative FLMLOR and free left module",
    IsIdenticalObj,
    [ IsFLMLOR and IsCommutative, IsFreeLeftModule ], 0,
    IsLeftIdeal );

InstallOtherMethod( IsTwoSidedIdealOp,
    "for anti-commutative FLMLOR and free left module",
    IsIdenticalObj,
    [ IsFLMLOR and IsAnticommutative, IsFreeLeftModule ], 0,
    IsLeftIdeal );

InstallOtherMethod( IsTwoSidedIdealOp,
    "for FLMLOR and free left module",
    IsIdenticalObj,
    [ IsFLMLOR, IsFreeLeftModule ], 0,
    function( A, S )
    return IsLeftIdeal( A, S ) and IsRightIdeal( A, S );
#T Check containment only once!
    end );


#############################################################################
##
#M  TwoSidedIdealByGenerators( <A>, <gens> ) .  create an ideal in an algebra
#M  LeftIdealByGenerators( <A>, <gens> ) .  create a left ideal in an algebra
#M  RightIdealByGenerators( <A>, <gens> )  . create right ideal in an algebra
##
##  We need special methods to make ideals in algebras themselves algebras.
##
InstallMethod( TwoSidedIdealByGenerators,
    "for FLMLOR and collection",
    IsIdenticalObj,
    [ IsFLMLOR, IsCollection ], 0,
    function( A, gens )
    local I, lad;
    I:= Objectify( NewType( FamilyObj( A ),
                                IsFLMLOR
                            and IsAttributeStoringRep ),
                   rec() );
    lad:= LeftActingDomain( A );
    SetLeftActingDomain( I, lad );
    SetGeneratorsOfTwoSidedIdeal( I, gens );
    SetLeftActingRingOfIdeal( I, A );
    SetRightActingRingOfIdeal( I, A );

    CheckForHandlingByNiceBasis( lad, gens, I, false );
    return I;
    end );

InstallMethod( LeftIdealByGenerators,
    "for FLMLOR and collection",
    IsIdenticalObj,
    [ IsFLMLOR, IsCollection ], 0,
    function( A, gens )
    local I, lad;
    I:= Objectify( NewType( FamilyObj( A ),
                                IsFLMLOR
                            and IsAttributeStoringRep ),
                   rec() );
    lad:= LeftActingDomain( A );
    SetLeftActingDomain( I, lad );
    SetGeneratorsOfLeftIdeal( I, gens );
    SetLeftActingRingOfIdeal( I, A );

    CheckForHandlingByNiceBasis( lad, gens, I, false );
    return I;
    end );

InstallMethod( RightIdealByGenerators,
    "for FLMLOR and collection",
    IsIdenticalObj,
    [ IsFLMLOR, IsCollection ], 0,
    function( A, gens )
    local I, lad;
    I:= Objectify( NewType( FamilyObj( A ),
                                IsFLMLOR
                            and IsAttributeStoringRep ),
                   rec() );
    lad:= LeftActingDomain( A );
    SetLeftActingDomain( I, lad );
    SetGeneratorsOfRightIdeal( I, gens );
    SetRightActingRingOfIdeal( I, A );

    CheckForHandlingByNiceBasis( lad, gens, I, false );
    return I;
    end );


InstallMethod( TwoSidedIdealByGenerators,
    "for FLMLOR and empty list",
    true,
    [ IsFLMLOR, IsList and IsEmpty ], 0,
    function( A, gens )
    local I, lad;
    I:= Objectify( NewType( FamilyObj( A ),
                                IsFLMLOR
                            and IsTrivial
                            and IsAttributeStoringRep ),
                   rec() );
    lad:= LeftActingDomain( A );
    SetLeftActingDomain( I, lad );
    SetGeneratorsOfTwoSidedIdeal( I, gens );
    SetGeneratorsOfLeftModule( I, gens );
    SetLeftActingRingOfIdeal( I, A );
    SetRightActingRingOfIdeal( I, A );

    CheckForHandlingByNiceBasis( lad, gens, I, false );
    return I;
    end );

InstallMethod( LeftIdealByGenerators,
    "for FLMLOR and empty list",
    true,
    [ IsFLMLOR, IsList and IsEmpty ], 0,
    function( A, gens )
    local I, lad;
    I:= Objectify( NewType( FamilyObj( A ),
                                IsFLMLOR
                            and IsTrivial
                            and IsAttributeStoringRep ),
                   rec() );
    lad:= LeftActingDomain( A );
    SetLeftActingDomain( I, lad );
    SetGeneratorsOfLeftIdeal( I, gens );
    SetGeneratorsOfLeftModule( I, gens );
    SetLeftActingRingOfIdeal( I, A );

    CheckForHandlingByNiceBasis( lad, gens, I, false );
    return I;
    end );

InstallMethod( RightIdealByGenerators,
    "for FLMLOR and empty list",
    true,
    [ IsFLMLOR, IsList and IsEmpty ], 0,
    function( A, gens )
    local I, lad;
    I:= Objectify( NewType( FamilyObj( A ),
                                IsFLMLOR
                            and IsTrivial
                            and IsAttributeStoringRep ),
                   rec() );
    lad:= LeftActingDomain( A );
    SetLeftActingDomain( I, lad );
    SetGeneratorsOfRightIdeal( I, gens );
    SetGeneratorsOfLeftModule( I, gens );
    SetRightActingRingOfIdeal( I, A );

    CheckForHandlingByNiceBasis( lad, gens, I, false );
    return I;
    end );


#############################################################################
##
#M  GeneratorsOfLeftModule( <I> ) . . . . . . . . . . . . . . .  for an ideal
#M  GeneratorsOfLeftOperatorRing( <I> ) . . . . . . . . . . . .  for an ideal
##
##  We need methods to compute algebra or left module generators from the
##  known (left/right/two-sided) ideal generators.
##  For that, we use `MutableBasisOfClosureUnderAction' in the case that the
##  acting algebra is known to be associative,
##  and `MutableBasisOfIdealInNonassociativeAlgebra' otherwise.
##
##  Note that by the call to `UseBasis', afterwards left module generators
##  are known, also if `GeneratorsOfLeftOperatorRing' had been called.
##
LeftModuleGeneratorsForIdealFromGenerators := function( I, Igens, R, side )

    local F,        # left acting domain of `I'
          maxdim,   # upper bound for the dimension of `I'
          mb,       # mutable basis of `I'
          gens;     # left module generators of `I', result

    F:= LeftActingDomain( I );
    if not IsFLMLOR( R ) then
      TryNextMethod();
    elif not IsSubset( F, LeftActingDomain( R ) ) then
      R:= AsFLMLOR( Intersection( F, LeftActingDomain( R ) ), R );
    fi;

    # Get an upper bound for the dimension of the ideal.
    if HasDimension( R ) then
      maxdim:= Dimension( R );
    else
      maxdim:= infinity;
    fi;

    if HasIsAssociative( R ) and IsAssociative( R ) then

      # We may use `MutableBasisOfClosureUnderAction'.
      mb:= MutableBasisOfClosureUnderAction(
               F,
               GeneratorsOfLeftOperatorRing( R ),
               side,
               Igens,
               \*,
               Zero( I ),
               maxdim );

    else

      # We must use `MutableBasisOfIdealInNonassociativeAlgebra'.
      mb:= MutableBasisOfIdealInNonassociativeAlgebra(
               F,
               GeneratorsOfLeftModule( R ),
               Igens,
               Zero( I ),
               side,
               maxdim );

    fi;

    gens:= BasisVectors( mb );
    UseBasis( I, gens );

    return gens;
end;


InstallMethod( GeneratorsOfLeftModule,
    "for FLMLOR with known ideal generators",
    true,
    [ IsFLMLOR and HasGeneratorsOfTwoSidedIdeal ], 0,
    I -> LeftModuleGeneratorsForIdealFromGenerators( I,
             GeneratorsOfTwoSidedIdeal( I ),
             LeftActingRingOfIdeal( I ), "both" ) );

InstallMethod( GeneratorsOfLeftModule,
    "for FLMLOR with known left ideal generators",
    true,
    [ IsFLMLOR and HasGeneratorsOfLeftIdeal ],
    RankFilter( HasGeneratorsOfTwoSidedIdeal ),
    I -> LeftModuleGeneratorsForIdealFromGenerators( I,
             GeneratorsOfLeftIdeal( I ),
             LeftActingRingOfIdeal( I ), "left" ) );

InstallMethod( GeneratorsOfLeftModule,
    "for FLMLOR with known right ideal generators",
    true,
    [ IsFLMLOR and HasGeneratorsOfRightIdeal ],
    RankFilter( HasGeneratorsOfTwoSidedIdeal ),
    I -> LeftModuleGeneratorsForIdealFromGenerators( I,
             GeneratorsOfRightIdeal( I ),
             RightActingRingOfIdeal( I ), "right" ) );


InstallMethod( GeneratorsOfLeftOperatorRing,
    "for FLMLOR with known ideal generators",
    true,
    [ IsFLMLOR and HasGeneratorsOfTwoSidedIdeal ], 0,
    I -> LeftModuleGeneratorsForIdealFromGenerators( I,
             GeneratorsOfTwoSidedIdeal( I ),
             LeftActingRingOfIdeal( I ), "both" ) );

InstallMethod( GeneratorsOfLeftOperatorRing,
    "for FLMLOR with known left ideal generators",
    true,
    [ IsFLMLOR and HasGeneratorsOfLeftIdeal ],
    RankFilter( HasGeneratorsOfTwoSidedIdeal ),
    I -> LeftModuleGeneratorsForIdealFromGenerators( I,
             GeneratorsOfLeftIdeal( I ),
             LeftActingRingOfIdeal( I ), "left" ) );

InstallMethod( GeneratorsOfLeftOperatorRing,
    "for FLMLOR with known right ideal generators",
    true,
    [ IsFLMLOR and HasGeneratorsOfRightIdeal ],
    RankFilter( HasGeneratorsOfTwoSidedIdeal ),
    I -> LeftModuleGeneratorsForIdealFromGenerators( I,
             GeneratorsOfRightIdeal( I ),
             RightActingRingOfIdeal( I ), "right" ) );


#############################################################################
##
#M  AsLeftIdeal( <R>, <S> ) . . . . . . . . . . . . . . . . . for two FLMLORs
#M  AsRightIdeal( <R>, <S> )  . . . . . . . . . . . . . . . . for two FLMLORs
#M  AsTwoSidedIdeal( <R>, <S> ) . . . . . . . . . . . . . . . for two FLMLORs
##
##  The difference to the generic methods for two rings is that we need only
##  algebra generators and not ring generators of <S>.
##
InstallMethod( AsLeftIdeal,
    "for two FLMLORs",
    IsIdenticalObj,
    [ IsFLMLOR, IsFLMLOR ], 0,
    function( R, S )
    local I, gens;
    if not IsLeftIdeal( R, S ) then
      I:= fail;
    else
      gens:= GeneratorsOfLeftOperatorRing( S );
      I:= LeftIdealByGenerators( R, gens );
      SetGeneratorsOfLeftOperatorRing( I, gens );
    fi;
    return I;
    end );

InstallMethod( AsRightIdeal,
    "for two FLMLORs",
    IsIdenticalObj,
    [ IsRing, IsRing ], 0,
    function( R, S )
    local I, gens;
    if not IsRightIdeal( R, S ) then
      I:= fail;
    else
      gens:= GeneratorsOfLeftOperatorRing( S );
      I:= RightIdealByGenerators( R, gens );
      SetGeneratorsOfLeftOperatorRing( I, gens );
    fi;
    return I;
    end );

InstallMethod( AsTwoSidedIdeal,
    "for two FLMLORs",
    IsIdenticalObj,
    [ IsRing, IsRing ], 0,
    function( R, S )
    local I, gens;
    if not IsTwoSidedIdeal( R, S ) then
      I:= fail;
    else
      gens:= GeneratorsOfLeftOperatorRing( S );
      I:= TwoSidedIdealByGenerators( R, gens );
      SetGeneratorsOfLeftOperatorRing( I, gens );
    fi;
    return I;
    end );


#############################################################################
##
#M  IsFiniteDimensional( <I> ). . . . . . . . . .  for an ideal in an algebra
##
InstallMethod( IsFiniteDimensional,
    "for an ideal in an algebra",
    true,
    [ IsFLMLOR and HasLeftActingRingOfIdeal ], 0,
    function( I )
    if IsFiniteDimensional( LeftActingRingOfIdeal( I ) ) then
      return true;
    else
      TryNextMethod();
    fi;
    end );

InstallMethod( IsFiniteDimensional,
    "for an ideal in an algebra",
    true,
    [ IsFLMLOR and HasRightActingRingOfIdeal ], 0,
    function( I )
    if IsFiniteDimensional( RightActingRingOfIdeal( I ) ) then
      return true;
    else
      TryNextMethod();
    fi;
    end );


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