5.1 Key Dependent Operations

There are several functions that require as first argument a domain, e.g., a group, and as second argument something much simpler, e.g., a prime. SylowSubgroup is an example. Since its value depends on two arguments, it cannot be an attribute, yet one would like to store Sylow subgroups once they have been computed.

The idea is to provide an attribute of the group, called ComputedSylowSubgroups, and to store the groups in this list. The name implies that the value of this attribute may change in the course of a GAP session, whenever a newly-computed Sylow subgroup is put into the list. Therefore, this is a mutable attribute (see Creating Attributes and Properties in ``Programming in GAP''). The list contains primes in each bound odd position and a corresponding Sylow subgroup in the following even position. More precisely, if p = ComputedSylowSubgroups( G )[ even - 1 ] then ComputedSylowSubgroups( G )[ even ] holds the value of SylowSubgroup( G, p ). The pairs are sorted in increasing order of p, in particular at most one Sylow p subgroup of G is stored for each prime p. This attribute value is maintained by the operation SylowSubgroup, which calls the operation SylowSubgroupOp( G, p ) to do the real work, if the prime p cannot be found in the list. So methods that do the real work should be installed for SylowSubgroupOp and not for SylowSubgroup.

The same mechanism works for other functions as well, e.g., for PCore, but also for HallSubgroup, where the second argument is not a prime but a set of primes.

  • KeyDependentOperation( name, dom-req, key-req, key-test )

    declares at the same time all three: two operations with names name and nameOp, respectively, and an attribute with name and the attribute as described above, with names name, nameOp, and Computednames. dom-req and key-req specify the required filters for the first and second argument of the operation nameOp, which are needed to create this operation with NewOperation (see NewOperation). dom-req is also the required filter for the corresponding attribute Computednames. The fourth argument key-test is in general a function to which the second argument info of name( D, info ) will be passed. This function can perform tests on info, and raise an error if appropriate.

    For example, to set up the three objects SylowSubgroup, SylowSubgroupOp, and ComputedSylowSubgroups together, the declaration file ``lib/grp.gd'' contains the following line of code.

    KeyDependentOperation( "SylowSubgroup", IsGroup, IsPosInt, "prime" );
    
    In this example, key-test has the value "prime", which is silently replaced by a function that tests whether its argument is a prime.

    gap> s4 := Group((1,2,3,4),(1,2));;
    gap> SylowSubgroup( s4, 5 );;  ComputedSylowSubgroups( s4 );
    [ 5, Group(()) ]
    gap> SylowSubgroup( s4, 2 );;  ComputedSylowSubgroups( s4 );
    [ 2, Group([(3,4),(1,4)(2,3),(1,3)(2,4)]), 5, Group(()) ]
    
    gap> SylowSubgroup( s4, 6 );                                
    Error SylowSubgroup: <p> must be a prime at
    Error( name, ": <p> must be a prime" );
    keytest( key ); called from
    <function>( <arguments> ) called from read-eval-loop
    Entering break read-eval-print loop, you can 'quit;' to quit to outer \
    loop,
    or you can return to continue
    brk> quit;
    

    Thus the prime test need not be repeated in the methods for the operation SylowSubgroupOp (which are installed to do the real work). Note that no methods need be installed for SylowSubgroup and ComputedSylowSubgroups. If a method is installed with InstallMethod for a wrapper operation such as SylowSubgroup then a warning is signalled provided the InfoWarning level is at least 1. (Use InstallOtherMethod in order to suppress the warning.)

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

    GAP 4 manual
    February 2000