29.6 Parents

  • Parent( D ) F
  • SetParent( D, P ) O
  • HasParent( D ) F

    It is possible to assign to a domain D one other domain P containing D as a subset, in order to exploit this subset relation between D and P. Note that P need not have the same operational structure as D, for example P may be a magma and D a field.

    The assignment is done by calling SetParent, and P is called the parent of D. If D has already a parent, calls to SetParent will be ignored.

    If D has a parent P --this can be checked with HasParent-- then P can be used to gain information about D. First, the call of SetParent causes UseSubsetRelation (see UseSubsetRelation) to be called. Second, for a domain D with parent, information relative to the parent can be stored in D; for example, there is an attribute NormalizerInParent for storing Normalizer( P, D ) in the case that D is a group. (More about such parent dependent attributes can be found in In Parent Attributes in ``Extending GAP''.) Note that because of this relative information, one cannot change the parent; that is, one can set the parent only once, subsequent calls to SetParent for the same domain D are ignored. Further note that contrary to UseSubsetRelation (see UseSubsetRelation), also knowledge about the parent P might be used that is discovered after the SetParent call.

    A stored parent can be accessed using Parent. If D has no parent then Parent returns D itself, and HasParent will returns false also after a call to Parent. So Parent is not an attribute, the underlying attribute to store the parent is ParentAttr.

    Certain functions that return domains with parent already set, for example Subgroup, are described in Section Constructing Subdomains. Whenever a function has this property, the Reference Manual states this explicitly. Note that these functions do not guarantee a certain parent, for example DerivedSubgroup (see DerivedSubgroup) for a perfect group G may return G itself, and if G had already a parent then this is not replaced by G. As a rule of thumb, GAP avoids to set a domain as its own parent, which is consistent with the behaviour of Parent, at least until a parent is set explicitly with SetParent.

    gap> g:= Group( (1,2,3), (1,2) );; h:= Group( (1,2) );;
    gap> HasParent( g );  HasParent( h );
    false
    false
    gap> SetParent( h, g );
    gap> Parent( g );  Parent( h );
    Group([ (1,2,3), (1,2) ])
    Group([ (1,2,3), (1,2) ])
    gap> HasParent( g );  HasParent( h );
    false
    true
    

    [Top] [Previous] [Up] [Next] [Index]

    GAP 4 manual
    February 2000