Families are probably the least obvious part of the GAP type system, so some remarks about the role of families are necessary. When one uses GAP as it is, one will (better: should) not meet families at all. The two situations where families come into play are the following.
First, since families are used to describe relations between arguments of
operations in the method selection mechanism
(see Chapter Method Selection,
and also Types of Objects in the Reference Manual),
one has to prescribe such a relation in each method installation
(see Method Installation);
usual relations are ReturnTrue (which means that any relation of the
actual arguments is admissible), IsIdenticalObj (which means that
there are two arguments that lie in the same family),
and IsCollsElms (which means that there are two arguments,
the first being a collection of elements that lie in the same family
as the second argument).
Second ---and this is the more complicated situation--- whenever one creates a new kind of objects, one has to decide what its family shall be. If the new object shall be equal to existing objects, for example if it is just represented in a different way, there is no choice: The new object must lie in the same family as all objects that shall be equal to it. So only if the new object is different (w.r.t. the equality ``='') from all other GAP objects, we are likely to create a new family for it. Note that enlarging an existing family by such new objects may be problematic because of implications that have been installed for all objects of the family in question. The choice of families depends on the applications one has in mind. For example, if the new objects in question are not likely to be arguments of operations for which family relations are relevant (for example binary arithmetic operations), one could create one family for all such objects, and regard it as ``the family of all those GAP objects that would in fact not need a family''. On the other extreme, if one wants to create domains of the new objects then one has to choose the family in such a way that all intended elements of a domain do in fact lie in the same family. (Remember that a domain is a collection, see Chapter Domains in the Reference Manual, and that a collection consists of elements in the same family, see Collections and Families in the Reference Manual.)
Let us look at an example.
Suppose that no permutations are available in GAP,
and that we want to implement permutations.
Clearly we want to support permutation groups,
but it is not a priori clear how to distribute the new permutations
into families.
We can put all permutations into one family;
this is how in fact permutations are implemented in GAP.
But it would also be possible to put all permutations of a given degree
into a family of their own;
this would for example mean that for each degree,
there would be distinguished trivial permutations,
and that the stabilizer of the point 5 in the symmetric group on the
points 1, 2, ¼, 5 is not regarded as equal to the
symmetric group on 1, 2, 3, 4.
Note that the latter approach would have the advantage that it is
no problem to construct permutations and permutation groups acting on
arbitrary (finite) sets,
for example by constructing first the symmetric group on the set
and then generating any desired permutation group as a subgroup of this
symmetric group.
So one aspect concerning a reasonable choice of families is to make the families large enough for being able to form interesting domains of elements in the family. But on the other hand, it is useful to choose the families small enough for admitting meaningful relations between objects. For example, the elements of different free groups in GAP lie in different families; the multiplication of free group elements is installed only for the case that the two operands lie in the same family, with the effect that one cannot erroneously form the product of elements from different free groups. In this case, families appear as a tool for providing useful restrictions.
As another example, note that an element and a collection containing this element never lie in the same family, by the general implementation of collections; namely, the family of a collection of elements in the family Fam is the collections family of Fam (see CollectionsFamily). This means that for a collection, we need not (because we cannot) decide about its family.
NewFamily( name )
NewFamily( name, req )
NewFamily( name, req, imp )
NewFamily( name, req, imp, famfilter )
NewFamily returns a new family fam with name name.
The argument req, if present, is a filter of which fam shall be a
subset.
If one tries to create an object in fam that does not lie in the filter
req, an error message is printed.
Also the argument imp, if present,
is a filter of which fam shall be a subset.
Any object that is created in the family fam will lie automatically in
the filter imp.
The filter famfilter, if given, specifies a filter that will hold for the family fam (not for objects in fam).
Families are always represented as component objects (see Component Objects). This means that components can be used to store and access useful information about the family.
There are a few functions in GAP that construct families. As an example, consider (see also Collection Families in the Reference Manual)
CollectionsFamily( fam )
CollectionsFamily is an attribute that takes a family fam as
argument, and returns the family of all collections over fam,
that is, of all dense lists and domains that consist of objects in
fam.
The NewFamily call in the standard method of CollectionsFamily
is executed with second argument IsCollection,
since every object in the collections family must be a collection,
and with third argument the collections categories of the involved
categories in the implied filter of fam.
If fam is a collections family then
ElementsFamily( fam )
returns the unique family with collections family fam;
note that by definition,
all elements in a collection lie in the same family,
so ElementsFamily( fam ) is the family of each element
in any collection that has the family fam.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual