Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Path: gap4r8 / doc / ref / chap13.txt
Views: 415153
1
2
13 Types of Objects
3
4
Every GAP object has a type. The type of an object is the information which
5
is used to decide whether an operation is admissible or possible with that
6
object as an argument, and if so, how it is to be performed (see
7
Chapter 78).
8
9
For example, the types determine whether two objects can be multiplied and
10
what function is called to compute the product. Analogously, the type of an
11
object determines whether and how the size of the object can be computed. It
12
is sometimes useful in discussing the type system, to identify types with
13
the set of objects that have this type. Partial types can then also be
14
regarded as sets, such that any type is the intersection of its parts.
15
16
The type of an object consists of two main parts, which describe different
17
aspects of the object.
18
19
The family determines the relation of the object to other objects. For
20
example, all permutations form a family. Another family consists of all
21
collections of permutations, this family contains the set of permutation
22
groups as a subset. A third family consists of all rational functions with
23
coefficients in a certain family.
24
25
The other part of a type is a collection of filters (actually stored as a
26
bit-list indicating, from the complete set of possible filters, which are
27
included in this particular type). These filters are all treated equally by
28
the method selection, but, from the viewpoint of their creation and use,
29
they can be divided (with a small number of unimportant exceptions) into
30
categories, representations, attribute testers and properties. Each of these
31
is described in more detail below.
32
33
This chapter does not describe how types and their constituent parts can be
34
created. Information about this topic can be found in Chapter 79.
35
36
Note: Detailed understanding of the type system is not required to use GAP.
37
It can be helpful, however, to understand how things work and why GAP
38
behaves the way it does.
39
40
A discussion of the type system can be found in [BL98].
41
42
43
13.1 Families
44
45
The family of an object determines its relationship to other objects.
46
47
More precisely, the families form a partition of all GAP objects such that
48
the following two conditions hold: objects that are equal w.r.t. = lie in
49
the same family; and the family of the result of an operation depends only
50
on the families of its operands.
51
52
The first condition means that a family can be regarded as a set of elements
53
instead of a set of objects. Note that this does not hold for categories and
54
representations (see below), two objects that are equal w.r.t. = need not
55
lie in the same categories and representations. For example, a sparsely
56
represented matrix can be equal to a densely represented matrix. Similarly,
57
each domain is equal w.r.t. = to the sorted list of its elements, but a
58
domain is not a list, and a list is not a domain.
59
60
13.1-1 FamilyObj
61
62
FamilyObj( obj )  function
63
64
returns the family of the object obj.
65
66
The family of the object obj is itself an object, its family is
67
FamilyOfFamilies.
68
69
It should be emphasized that families may be created when they are needed.
70
For example, the family of elements of a finitely presented group is created
71
only after the presentation has been constructed. Thus families are the
72
dynamic part of the type system, that is, the part that is not fixed after
73
the initialisation of GAP.
74
75
Families can be parametrized. For example, the elements of each finitely
76
presented group form a family of their own. Here the family of elements and
77
the finitely presented group coincide when viewed as sets. Note that
78
elements in different finitely presented groups lie in different families.
79
This distinction allows GAP to forbid multiplications of elements in
80
different finitely presented groups.
81
82
As a special case, families can be parametrized by other families. An
83
important example is the family of collections that can be formed for each
84
family. A collection consists of objects that lie in the same family, it is
85
either a nonempty dense list of objects from the same family or a domain.
86
87
Note that every domain is a collection, that is, it is not possible to
88
construct domains whose elements lie in different families. For example, a
89
polynomial ring over the rationals cannot contain the integer 0 because the
90
family that contains the integers does not contain polynomials. So one has
91
to distinguish the integer zero from each zero polynomial.
92
93
Let us look at this example from a different viewpoint. A polynomial ring
94
and its coefficients ring lie in different families, hence the coefficients
95
ring cannot be embedded naturally into the polynomial ring in the sense that
96
it is a subset. But it is possible to allow, e.g., the multiplication of an
97
integer and a polynomial over the integers. The relation between the
98
arguments, namely that one is a coefficient and the other a polynomial, can
99
be detected from the relation of their families. Moreover, this analysis is
100
easier than in a situation where the rationals would lie in one family
101
together with all polynomials over the rationals, because then the relation
102
of families would not distinguish the multiplication of two polynomials, the
103
multiplication of two coefficients, and the multiplication of a coefficient
104
with a polynomial. So the wish to describe relations between elements can be
105
taken as a motivation for the introduction of families.
106
107
108
13.2 Filters
109
110
A filter is a special unary GAP function that returns either true or false,
111
depending on whether or not the argument lies in the set defined by the
112
filter. Filters are used to express different aspects of information about a
113
GAP object, which are described below (see 13.3, 13.4, 13.5, 13.6, 13.7,
114
13.8).
115
116
Presently any filter in GAP is implemented as a function which corresponds
117
to a set of positions in the bitlist which forms part of the type of each
118
GAP object, and returns true if and only if the bitlist of the type of the
119
argument has the value true at all of these positions.
120
121
The intersection (or meet) of two filters filt1, filt2 is again a filter, it
122
can be formed as
123
124
filt1 and filt2
125
126
See 20.4 for more details.
127
128
For example, IsList and IsEmpty is a filter that returns true if its
129
argument is an empty list, and false otherwise. The filter IsGroup (39.2-7)
130
is defined as the intersection of the category IsMagmaWithInverses (35.1-4)
131
and the property IsAssociative (35.4-7).
132
133
A filter that is not the meet of other filters is called a simple filter.
134
For example, each attribute tester (see 13.6) is a simple filter. Each
135
simple filter corresponds to a position in the bitlist currently used as
136
part of the data structure representing a type.
137
138
Every filter has a rank, which is used to define a ranking of the methods
139
installed for an operation, see Section 78.2. The rank of a filter can be
140
accessed with RankFilter (13.2-1).
141
142
13.2-1 RankFilter
143
144
RankFilter( filt )  function
145
146
For simple filters, an incremental rank is defined when the filter is
147
created, see the sections about the creation of filters: 79.1, 79.2, 79.3,
148
79.4. For an arbitrary filter, its rank is given by the sum of the
149
incremental ranks of the involved simple filters; in addition to the implied
150
filters, these are also the required filters of attributes (again see the
151
sections about the creation of filters). In other words, for the purpose of
152
computing the rank and only for this purpose, attribute testers are treated
153
as if they would imply the requirements of their attributes.
154
155
13.2-2 NamesFilter
156
157
NamesFilter( filt )  function
158
159
NamesFilter returns a list of names of the implied simple filters of the
160
filter filt, these are all those simple filters imp such that every object
161
in filt also lies in imp. For implications between filters, see
162
ShowImpliedFilters (13.2-3) as well as sections 78.7, 79.1, 79.2, 79.3.
163
164
13.2-3 ShowImpliedFilters
165
166
ShowImpliedFilters( filter )  function
167
168
Displays information about the filters that may be implied by filter. They
169
are given by their names. ShowImpliedFilters first displays the names of all
170
filters that are unconditionally implied by filter. It then displays
171
implications that require further filters to be present (indicating by + the
172
required further filters). The function displays only first-level
173
implications, implications that follow in turn are not displayed (though GAP
174
will do these).
175
176
 Example 
177
gap> ShowImpliedFilters(IsMatrix);
178
Implies:
179
 IsGeneralizedRowVector
180
 IsNearAdditiveElementWithInverse
181
 IsAdditiveElement
182
 IsMultiplicativeElement
183

184

185
May imply with:
186
+IsGF2MatrixRep
187
 IsOrdinaryMatrix
188

189
+CategoryCollections(CategoryCollections(IsAdditivelyCommutativeElement))
190
 IsAdditivelyCommutativeElement
191

192
+IsInternalRep
193
 IsOrdinaryMatrix
194

195

196
197
198
13.3 Categories
199
200
The categories of an object are filters (see 13.2) that determine what
201
operations an object admits. For example, all integers form a category, all
202
rationals form a category, and all rational functions form a category. An
203
object which claims to lie in a certain category is accepting the
204
requirement that it should have methods for certain operations (and perhaps
205
that their behaviour should satisfy certain axioms). For example, an object
206
lying in the category IsList (21.1-1) must have methods for Length
207
(21.17-5), IsBound\[\] (21.2-1) and the list element access operation \[\]
208
(21.2-1).
209
210
An object can lie in several categories. For example, a row vector lies in
211
the categories IsList (21.1-1) and IsVector (31.14-14); each list lies in
212
the category IsCopyable (12.6-1), and depending on whether or not it is
213
mutable, it may lie in the category IsMutable (12.6-2). Every domain lies in
214
the category IsDomain (31.9-1).
215
216
Of course some categories of a mutable object may change when the object is
217
changed. For example, after assigning values to positions of a mutable
218
non-dense list, this list may become part of the category IsDenseList
219
(21.1-2).
220
221
However, if an object is immutable then the set of categories it lies in is
222
fixed.
223
224
All categories in the library are created during initialization, in
225
particular they are not created dynamically at runtime.
226
227
The following list gives an overview of important categories of arithmetic
228
objects. Indented categories are to be understood as subcategories of the
229
non indented category listed above it.
230
231
 Example 
232
 IsObject
233
 IsExtLElement
234
 IsExtRElement
235
 IsMultiplicativeElement
236
 IsMultiplicativeElementWithOne
237
 IsMultiplicativeElementWithInverse
238
 IsExtAElement
239
 IsAdditiveElement
240
 IsAdditiveElementWithZero
241
 IsAdditiveElementWithInverse
242

243
244
Every object lies in the category IsObject (12.1-1).
245
246
The categories IsExtLElement (31.14-8) and IsExtRElement (31.14-9) contain
247
objects that can be multiplied with other objects via * from the left and
248
from the right, respectively. These categories are required for the operands
249
of the operation *.
250
251
The category IsMultiplicativeElement (31.14-10) contains objects that can be
252
multiplied from the left and from the right with objects from the same
253
family. IsMultiplicativeElementWithOne (31.14-11) contains objects obj for
254
which a multiplicatively neutral element can be obtained by taking the 0-th
255
power obj^0. IsMultiplicativeElementWithInverse (31.14-13) contains objects
256
obj for which a multiplicative inverse can be obtained by forming obj^-1.
257
258
Likewise, the categories IsExtAElement (31.14-1), IsAdditiveElement
259
(31.14-3), IsAdditiveElementWithZero (31.14-5) and
260
IsAdditiveElementWithInverse (31.14-7) contain objects that can be added via
261
+ to other objects, objects that can be added to objects of the same family,
262
objects for which an additively neutral element can be obtained by
263
multiplication with zero, and objects for which an additive inverse can be
264
obtained by multiplication with -1.
265
266
So a vector lies in IsExtLElement (31.14-8), IsExtRElement (31.14-9) and
267
IsAdditiveElementWithInverse (31.14-7). A ring element must additionally lie
268
in IsMultiplicativeElement (31.14-10).
269
270
As stated above it is not guaranteed by the categories of objects whether
271
the result of an operation with these objects as arguments is defined. For
272
example, the category IsMatrix (24.2-1) is a subcategory of
273
IsMultiplicativeElementWithInverse (31.14-13). Clearly not every matrix has
274
a multiplicative inverse. But the category IsMatrix (24.2-1) makes each
275
matrix an admissible argument of the operation Inverse (31.10-8), which may
276
sometimes return fail. Likewise, two matrices can be multiplied only if they
277
are of appropriate shapes.
278
279
Analogous to the categories of arithmetic elements, there are categories of
280
domains of these elements.
281
282
 Example 
283
 IsObject
284
 IsDomain
285
 IsMagma
286
 IsMagmaWithOne
287
 IsMagmaWithInversesIfNonzero
288
 IsMagmaWithInverses
289
 IsAdditiveMagma
290
 IsAdditiveMagmaWithZero
291
 IsAdditiveMagmaWithInverses
292
 IsExtLSet
293
 IsExtRSet
294

295
296
Of course IsDomain (31.9-1) is a subcategory of IsObject (12.1-1). A domain
297
that is closed under multiplication * is called a magma and it lies in the
298
category IsMagma (35.1-1). If a magma is closed under taking the identity,
299
it lies in IsMagmaWithOne (35.1-2), and if it is also closed under taking
300
inverses, it lies in IsMagmaWithInverses (35.1-4). The category
301
IsMagmaWithInversesIfNonzero (35.1-3) denotes closure under taking inverses
302
only for nonzero elements, every division ring lies in this category.
303
304
Note that every set of categories constitutes its own notion of generation,
305
for example a group may be generated as a magma with inverses by some
306
elements, but to generate it as a magma with one it may be necessary to take
307
the union of these generators and their inverses.
308
309
13.3-1 CategoriesOfObject
310
311
CategoriesOfObject( object )  operation
312
313
returns a list of the names of the categories in which object lies.
314
315
 Example 
316
gap> g:=Group((1,2),(1,2,3));;
317
gap> CategoriesOfObject(g);
318
[ "IsListOrCollection", "IsCollection", "IsExtLElement",
319
 "CategoryCollections(IsExtLElement)", "IsExtRElement",
320
 "CategoryCollections(IsExtRElement)",
321
 "CategoryCollections(IsMultiplicativeElement)",
322
 "CategoryCollections(IsMultiplicativeElementWithOne)",
323
 "CategoryCollections(IsMultiplicativeElementWithInverse)",
324
 "CategoryCollections(IsAssociativeElement)",
325
 "CategoryCollections(IsFiniteOrderElement)", "IsGeneralizedDomain",
326
 "CategoryCollections(IsPerm)", "IsMagma", "IsMagmaWithOne",
327
 "IsMagmaWithInversesIfNonzero", "IsMagmaWithInverses" ]
328

329
330
331
13.4 Representation
332
333
The representation of an object is a set of filters (see 13.2) that
334
determines how an object is actually represented. For example, a matrix or a
335
polynomial can be stored sparsely or densely; all dense polynomials form a
336
representation. An object which claims to lie in a certain representation is
337
accepting the requirement that certain fields in the data structure be
338
present and have specified meanings.
339
340
GAP distinguishes four essentially different ways to represent objects.
341
First there are the representations IsInternalRep for internal objects such
342
as integers and permutations, and IsDataObjectRep for other objects that are
343
created and whose data are accessible only by kernel functions. The data
344
structures underlying such objects cannot be manipulated at the GAP level.
345
346
All other objects are either in the representation IsComponentObjectRep or
347
in the representation IsPositionalObjectRep, see 79.10 and 79.11.
348
349
An object can belong to several representations in the sense that it lies in
350
several subrepresentations of IsComponentObjectRep or of
351
IsPositionalObjectRep. The representations to which an object belongs should
352
form a chain and either two representations are disjoint or one is contained
353
in the other. So the subrepresentations of IsComponentObjectRep and
354
IsPositionalObjectRep each form trees. In the language of Object Oriented
355
Programming, we support only single inheritance for representations.
356
357
These trees are typically rather shallow, since for one representation to be
358
contained in another implies that all the components of the data structure
359
implied by the containing representation, are present in, and have the same
360
meaning in, the smaller representation (whose data structure presumably
361
contains some additional components).
362
363
Objects may change their representation, for example a mutable list of
364
characters can be converted into a string.
365
366
All representations in the library are created during initialization, in
367
particular they are not created dynamically at runtime.
368
369
Examples of subrepresentations of IsPositionalObjectRep are IsModulusRep,
370
which is used for residue classes in the ring of integers, and
371
IsDenseCoeffVectorRep, which is used for elements of algebras that are
372
defined by structure constants.
373
374
An important subrepresentation of IsComponentObjectRep is
375
IsAttributeStoringRep, which is used for many domains and some other
376
objects. It provides automatic storing of all attribute values (see below).
377
378
13.4-1 RepresentationsOfObject
379
380
RepresentationsOfObject( object )  operation
381
382
returns a list of the names of the representations object has.
383
384
 Example 
385
gap> g:=Group((1,2),(1,2,3));;
386
gap> RepresentationsOfObject(g);
387
[ "IsComponentObjectRep", "IsAttributeStoringRep" ]
388

389
390
391
13.5 Attributes
392
393
The attributes of an object describe knowledge about it.
394
395
An attribute is a unary operation without side-effects.
396
397
An object may store values of its attributes once they have been computed,
398
and claim that it knows these values. Note that store and know have to be
399
understood in the sense that it is very cheap to get such a value when the
400
attribute is called again.
401
402
The stored value of an attribute is in general immutable (see 12.6), except
403
if the attribute had been specially constructed as mutable attribute.
404
405
It depends on the representation of an object (see 13.4) which attribute
406
values it stores. An object in the representation IsAttributeStoringRep
407
stores all attribute values once they are computed. Moreover, for an object
408
in this representation, subsequent calls to an attribute will return the
409
same object; this is achieved via a special method for each attribute setter
410
that stores the attribute value in an object in IsAttributeStoringRep, and a
411
special method for the attribute itself that fetches the stored attribute
412
value. (These methods are called the system setter and the system getter of
413
the attribute, respectively.)
414
415
Note also that it is impossible to get rid of a stored attribute value
416
because the system may have drawn conclusions from the old attribute value,
417
and just removing the value might leave the data structures in an
418
inconsistent state. If necessary, a new object can be constructed.
419
420
Several attributes have methods for more than one argument. For example
421
IsTransitive (41.10-1) is an attribute for a G-set that can also be called
422
for the two arguments, being a group G and its action domain. If attributes
423
are called with more than one argument then the return value is not stored
424
in any of the arguments.
425
426
Properties are a special form of attributes that have the value true or
427
false, see section 13.7.
428
429
Examples of attributes for multiplicative elements are Inverse (31.10-8),
430
One (31.10-2), and Order (31.10-10). Size (30.4-6) is an attribute for
431
domains, Centre (35.4-5) is an attribute for magmas, and DerivedSubgroup
432
(39.12-3) is an attribute for groups.
433
434
13.5-1 KnownAttributesOfObject
435
436
KnownAttributesOfObject( object )  operation
437
438
returns a list of the names of the attributes whose values are known for
439
object.
440
441
 Example 
442
gap> g:=Group((1,2),(1,2,3));;Size(g);;
443
gap> KnownAttributesOfObject(g);
444
[ "Size", "OneImmutable", "NrMovedPoints", "MovedPoints", 
445
 "GeneratorsOfMagmaWithInverses", "MultiplicativeNeutralElement", 
446
 "HomePcgs", "Pcgs", "GeneralizedPcgs", "StabChainMutable", 
447
 "StabChainOptions" ]
448

449
450
451
13.6 Setter and Tester for Attributes
452
453
For every attribute, the attribute setter and the attribute tester are
454
defined.
455
456
To check whether an object belongs to an attribute attr, the tester of the
457
attribute is used, see Tester (13.6-1). To store a value for the attribute
458
attr in an object, the setter of the attribute is used, see Setter (13.6-2).
459
460
13.6-1 Tester
461
462
Tester( attr )  function
463
464
For an attribute attr, Tester(attr) is a filter (see 13.2) that returns true
465
or false, depending on whether or not the value of attr for the object is
466
known. For example, Tester( Size )( obj ) is true if the size of the object
467
obj is known.
468
469
13.6-2 Setter
470
471
Setter( attr )  function
472
473
For an attribute attr, Setter(attr) is called automatically when the
474
attribute value has been computed for the first time. One can also call the
475
setter explicitly, for example, Setter( Size )( obj, val ) sets val as size
476
of the object obj if the size was not yet known.
477
478
For each attribute attr that is declared with DeclareAttribute (79.18-3)
479
resp. DeclareProperty (79.18-4) (see 79.18), tester and setter are
480
automatically made accessible by the names Hasattr and Setattr,
481
respectively. For example, the tester for Size (30.4-6) is called HasSize,
482
and the setter is called SetSize.
483
484
 Example 
485
gap> g:=Group((1,2,3,4),(1,2));;Size(g);
486
24
487
gap> HasSize(g);
488
true
489
gap> SetSize(g,99);
490
gap> Size(g);
491
24
492

493
494
For two properties prop1 and prop2, the intersection prop1 and prop2
495
(see 13.2) is again a property for which a setter and a tester exist.
496
Setting the value of this intersection to true for a GAP object means to set
497
the values of prop1 and prop2 to true for this object.
498
499
 Example 
500
gap> prop:= IsFinite and IsCommutative;
501
<Property "<<and-filter>>">
502
gap> g:= Group( (1,2,3), (4,5) );;
503
gap> Tester( prop )( g );
504
false
505
gap> Setter( prop )( g, true );
506
gap> Tester( prop )( g ); prop( g );
507
true
508
true
509

510
511
It is not allowed to set the value of such an intersection to false for an
512
object.
513
514
 Example 
515
gap> Setter( prop )( Rationals, false );
516
You cannot set an "and-filter" except to true
517
not in any function
518
Entering break read-eval-print loop ...
519
you can 'quit;' to quit to outer loop, or
520
you can type 'return true;' to set all components true
521
(but you might really want to reset just one component) to continue
522
brk> 
523

524
525
13.6-3 AttributeValueNotSet
526
527
AttributeValueNotSet( attr, obj )  function
528
529
If the value of the attribute attr is already stored for obj,
530
AttributeValueNotSet simply returns this value. Otherwise the value of attr(
531
obj ) is computed and returned without storing it in obj. This can be useful
532
when large attribute values (such as element lists) are needed only once and
533
shall not be stored in the object.
534
535
 Example 
536
gap> HasAsSSortedList(g);
537
false
538
gap> AttributeValueNotSet(AsSSortedList,g);
539
[ (), (4,5), (1,2,3), (1,2,3)(4,5), (1,3,2), (1,3,2)(4,5) ]
540
gap> HasAsSSortedList(g);
541
false
542

543
544
The normal behaviour of attributes (when called with just one argument) is
545
that once a method has been selected and executed, and has returned a value
546
the setter of the attribute is called, to (possibly) store the computed
547
value. In special circumstances, this behaviour can be altered dynamically
548
on an attribute-by-attribute basis, using the functions
549
DisableAttributeValueStoring and EnableAttributeValueStoring.
550
551
In general, the code in the library assumes, for efficiency, but not for
552
correctness, that attribute values will be stored (in suitable objects), so
553
disabling storing may cause substantial computations to be repeated.
554
555
13.6-4 InfoAttributes
556
557
InfoAttributes info class
558
559
This info class (together with InfoWarning (7.4-7) is used for messages
560
about attribute storing being disabled (at level 2) or enabled (level 3). It
561
may be used in the future for other messages concerning changes to attribute
562
behaviour.
563
564
13.6-5 DisableAttributeValueStoring
565
566
DisableAttributeValueStoring( attr )  function
567
568
disables the usual call of Setter( attr ) when a method for attr returns a
569
value. In consequence the values will never be stored. Note that attr must
570
be an attribute and not a property.
571
572
13.6-6 EnableAttributeValueStoring
573
574
EnableAttributeValueStoring( attr )  function
575
576
enables the usual call of Setter( attr ) when a method for attr returns a
577
value. In consequence the values may be stored. This will usually have no
578
effect unless DisableAttributeValueStoring has previously been used for
579
attr. Note that attr must be an attribute and not a property.
580
581
 Example 
582
gap> g := Group((1,2,3,4,5),(1,2,3));
583
Group([ (1,2,3,4,5), (1,2,3) ])
584
gap> KnownAttributesOfObject(g);
585
[ "LargestMovedPoint", "GeneratorsOfMagmaWithInverses", 
586
 "MultiplicativeNeutralElement" ]
587
gap> SetInfoLevel(InfoAttributes,3);
588
gap> DisableAttributeValueStoring(Size);
589
#I Disabling value storing for Size
590
gap> Size(g);
591
60
592
gap> KnownAttributesOfObject(g);
593
[ "OneImmutable", "LargestMovedPoint", "NrMovedPoints", 
594
 "MovedPoints", "GeneratorsOfMagmaWithInverses", 
595
 "MultiplicativeNeutralElement", "StabChainMutable", 
596
 "StabChainOptions" ]
597
gap> Size(g);
598
60
599
gap> EnableAttributeValueStoring(Size);
600
#I Enabling value storing for Size
601
gap> Size(g);
602
60
603
gap> KnownAttributesOfObject(g);
604
[ "Size", "OneImmutable", "LargestMovedPoint", "NrMovedPoints", 
605
 "MovedPoints", "GeneratorsOfMagmaWithInverses", 
606
 "MultiplicativeNeutralElement", "StabChainMutable", 
607
 "StabChainOptions" ]
608

609
610
611
13.7 Properties
612
613
The properties of an object are those of its attributes (see 13.5) whose
614
values can only be true or false.
615
616
The main difference between attributes and properties is that a property
617
defines two sets of objects, namely the usual set of all objects for which
618
the value is known, and the set of all objects for which the value is known
619
to be true.
620
621
(Note that it makes no sense to consider a third set, namely the set of
622
objects for which the value of a property is true whether or not it is
623
known, since there may be objects for which the containment in this set
624
cannot be decided.)
625
626
For a property prop, the containment of an object obj in the first set is
627
checked again by applying Tester( prop ) to obj, and obj lies in the second
628
set if and only if Tester( prop )( obj ) and prop( obj ) is true.
629
630
If a property value is known for an immutable object then this value is also
631
stored, as part of the type of the object. To some extent, property values
632
of mutable objects also can be stored, for example a mutable list all of
633
whose entries are immutable can store whether it is strictly sorted. When
634
the object is mutated (for example by list assignment) the type may need to
635
be adjusted.
636
637
Important properties for domains are IsAssociative (35.4-7), IsCommutative
638
(35.4-9), IsAnticommutative (56.4-6), IsLDistributive (56.4-3) and
639
IsRDistributive (56.4-4), which mean that the multiplication of elements in
640
the domain satisfies ( a * b ) * c = a * ( b * c ), a * b = b * a, a * b = -
641
( b * a ), a * ( b + c ) = a * b + a * c, and ( a + b ) * c = a * c + b * c,
642
respectively, for all a, b, c in the domain.
643
644
13.7-1 KnownPropertiesOfObject
645
646
KnownPropertiesOfObject( object )  operation
647
648
returns a list of the names of the properties whose values are known for
649
object.
650
651
13.7-2 KnownTruePropertiesOfObject
652
653
KnownTruePropertiesOfObject( object )  operation
654
655
returns a list of the names of the properties known to be true for object.
656
657
 Example 
658
gap> g:=Group((1,2),(1,2,3));;
659
gap> KnownPropertiesOfObject(g);
660
[ "IsFinite", "CanEasilyCompareElements", "CanEasilySortElements", 
661
 "IsDuplicateFree", "IsGeneratorsOfMagmaWithInverses", 
662
 "IsAssociative", "IsGeneratorsOfSemigroup", "IsSimpleSemigroup", 
663
 "IsRegularSemigroup", "IsInverseSemigroup", 
664
 "IsCompletelyRegularSemigroup", "IsCompletelySimpleSemigroup", 
665
 "IsGroupAsSemigroup", "IsMonoidAsSemigroup", "IsOrthodoxSemigroup", 
666
 "IsFinitelyGeneratedGroup", "IsSubsetLocallyFiniteGroup", 
667
 "KnowsHowToDecompose", "IsNilpotentByFinite" ]
668
gap> Size(g);
669
6
670
gap> KnownPropertiesOfObject(g);
671
[ "IsEmpty", "IsTrivial", "IsNonTrivial", "IsFinite", 
672
 "CanEasilyCompareElements", "CanEasilySortElements", 
673
 "IsDuplicateFree", "IsGeneratorsOfMagmaWithInverses", 
674
 "IsAssociative", "IsGeneratorsOfSemigroup", "IsSimpleSemigroup", 
675
 "IsRegularSemigroup", "IsInverseSemigroup", 
676
 "IsCompletelyRegularSemigroup", "IsCompletelySimpleSemigroup", 
677
 "IsGroupAsSemigroup", "IsMonoidAsSemigroup", "IsOrthodoxSemigroup", 
678
 "IsFinitelyGeneratedGroup", "IsSubsetLocallyFiniteGroup", 
679
 "KnowsHowToDecompose", "IsPerfectGroup", "IsSolvableGroup", 
680
 "IsPolycyclicGroup", "IsNilpotentByFinite", "IsTorsionFree", 
681
 "IsFreeAbelian" ]
682
gap> KnownTruePropertiesOfObject(g);
683
[ "IsNonTrivial", "IsFinite", "CanEasilyCompareElements", 
684
 "CanEasilySortElements", "IsDuplicateFree", 
685
 "IsGeneratorsOfMagmaWithInverses", "IsAssociative", 
686
 "IsGeneratorsOfSemigroup", "IsSimpleSemigroup", 
687
 "IsRegularSemigroup", "IsInverseSemigroup", 
688
 "IsCompletelyRegularSemigroup", "IsCompletelySimpleSemigroup", 
689
 "IsGroupAsSemigroup", "IsMonoidAsSemigroup", "IsOrthodoxSemigroup", 
690
 "IsFinitelyGeneratedGroup", "IsSubsetLocallyFiniteGroup", 
691
 "KnowsHowToDecompose", "IsSolvableGroup", "IsPolycyclicGroup", 
692
 "IsNilpotentByFinite" ]
693

694
695
696
13.8 Other Filters
697
698
There are situations where one wants to express a kind of knowledge that is
699
based on some heuristic.
700
701
For example, the filters (see 13.2) CanEasilyTestMembership (39.25-1) and
702
CanEasilyComputePcgs (45.2-3) are defined in the GAP library. Note that such
703
filters do not correspond to a mathematical concept, contrary to properties
704
(see 13.7). Also it need not be defined what easily means for an arbitrary
705
GAP object, and in this case one cannot compute the value for an arbitrary
706
GAP object. In order to access this kind of knowledge as a part of the type
707
of an object, GAP provides filters for which the value is false by default,
708
and it is changed to true in certain situations, either explicitly (for the
709
given object) or via a logical implication (see 78.7) from other filters.
710
711
For example, a true value of CanEasilyComputePcgs (45.2-3) for a group means
712
that certain methods are applicable that use a pcgs (see 45.1) for the
713
group. There are logical implications to set the filter value to true for
714
permutation groups that are known to be solvable, and for groups that have
715
already a (sufficiently nice) pcgs stored. In the case one has a solvable
716
matrix group and wants to enable methods that use a pcgs, one can set the
717
CanEasilyComputePcgs (45.2-3) value to true for this particular group.
718
719
A filter filt of the kind described here is different from the other filters
720
introduced in the previous sections. In particular, filt is not a category
721
(see 13.3) or a property (see 13.7) because its value may change for a given
722
object, and filt is not a representation (see 13.4) because it has nothing
723
to do with the way an object is made up from some data. filt is similar to
724
an attribute tester (see 13.6), the only difference is that filt does not
725
refer to an attribute value; note that filt is also used in the same way as
726
an attribute tester; namely, the true value may be required for certain
727
methods to be applicable.
728
729
730
13.9 Types
731
732
We stated above (see 13) that, for an object obj, its type is formed from
733
its family and its filters. There is a also a third component, used in a few
734
situations, namely defining data of the type.
735
736
13.9-1 TypeObj
737
738
TypeObj( obj )  function
739
740
returns the type of the object obj.
741
742
The type of an object is itself an object.
743
744
Two types are equal if and only if the two families are identical, the
745
filters are equal, and, if present, also the defining data of the types are
746
equal.
747
748
13.9-2 DataType
749
750
DataType( type )  function
751
752
The last part of the type, defining data, has not been mentioned before and
753
seems to be of minor importance. It can be used, e.g., for cosets U g of a
754
group U, where the type of each coset may contain the group U as defining
755
data. As a consequence, two such cosets mod U and V can have the same type
756
only if U = V. The defining data of the type type can be accessed via
757
DataType.
758
759
760