13.2 Filters

A filter is a special unary GAP function that returns either true or false, depending on whether or not the argument lies in the set defined by the filter. Filters are used to express different aspects of information about a GAP object, which are described below (see Categories, Representation, Attributes, Setter and Tester for Attributes, Properties, Other Filters).

Presently any filter in GAP is implemented as a function which corresponds to a set of positions in the bitlist which forms part of the type of each GAP object, and returns true if and only if the bitlist of the type of the argument has the value true at all of these positions.

The intersection (or meet) of two filters filt1, filt2 is again a filter, it can be formed as

  • filt1 and filt2

    For example, IsList and IsEmpty is a filter that returns true if its argument is an empty list, and false otherwise. The filter IsGroup is defined as the intersection of the category IsMagmaWithInverses and the property IsAssociative.

    A filter that is not the meet of other filters is called a simple filter. For example, each attribute tester (see Setter and Tester for Attributes) is a simple filter. Each simple filter corresponds to a position in the bitlist currently used as part of the data structure representing a type.

    Every filter filt has a rank, which is used to define a ranking of the methods installed for an operation, see Section Method Installation in ``Programming in GAP''. The rank of a filter can be accessed as

  • RankFilter( filt ) F

    For simple filters, an incremental rank is defined when the filter is created, see the sections about the creation of filters Creating Categories, Creating Representations, Creating Attributes and Properties, Creating Other Filters; all in ``Programming in GAP''. For an arbitrary filter, its rank is given by the sum of the incremental ranks of the involved simple filters; in addition to the implied filters, these are also the required filters of attributes (again see the sections about the creation of filters). In other words, for the purpose of computing the rank and only for this purpose, attribute testers are treated as if they would imply the requirements of their attributes.

  • NamesFilter( filt ) F

    NamesFilter returns a list of names of the implied simple filters of the filter filt, these are all those simple filters imp such that every object in filt also lies in imp. For implications between filters, see ShowImpliedFilters as well as sections Logical Implications, Creating Categories, Creating Representations, Creating Attributes and Properties in ``Programming in GAP''

  • ShowImpliedFilters( filter ) F

    Displays information about the filters that may be implied by filter. They are given by their names. ShowImpliedFilters first displays the names of all filters that are unconditionally implied by filter. It then displays implications that require further filters to be present (indicating by + the required further filters). The function displays only first-level implications, implications that follow in turn are not displayed (though GAP will do these).

    gap> ShowImpliedFilters(IsRationalFunction);
    Implies:
       IsNearAdditiveElementWithInverse
       IsAdditiveElement
       IsMultiplicativeElementWithInverse
    
    
    May imply with:
    +IsZero
    +Tester(IsZero)
       IsConstantRationalFunction
       Tester(IsConstantRationalFunction)
    

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

    GAP 4 manual
    February 2000