3 Farey symbols and their properties A Farey symbol is a compact and useful way to represent a subgroup of finite index in SL_2(ℤ) from which one can deduce independent generators for this subgroup. It consists of two components, namely a so-called generalised Farey sequence (gfs) and an ordered list of labels, giving additional structure to the gfs. A generalised Farey sequence (g.F.S.) is an ordered list of the form -infinity, x_0, x_1, ... , x_n, infinity, where 1. the x_i = a_i/b_i are rational numbers in reduced form arranged in increasing order for i = 0, ... , n; 2. x_0, ... , x_n ∈ Z, and some x_i = 0; 3. we define x_-1=-infinity=-1/0 and x_n+1=infinity=1/0; 4. a_i+1b_i-a_ib_i+1=1 for i=-1, ... ,n. The ordered list of labels of a Farey symbol gives an additional structure to the gfs. The labels correspond to each consecutive pair of x_i's and are of the following types: 1. even, 2. odd, 3. a natural number, which occurs in the list of labels exactly twice or not at all. Note that the actual values of numerical labels are not important; it is the pairing of two intervals that matters. The package Congruence provides functions to construct Farey symbols by the given generalised Farey sequence and corresponding list of labels. The returned Farey symbol will belong to the category IsFareySymbol and will have the representation IsFareySymbolDefaultRep. 3.1 Construction of Farey symbols 3.1-1 FareySymbolByData FareySymbolByData( gfs, labels )  function This constructor creates the Farey symbol with the given generalized Farey sequence and list of labels. It also checks conditions from the definition of Farey symbol and returns an error if they are not satisfied. The data used to create the Farey symbol are stored as its attributes GeneralizedFareySequence (3.2-1) and LabelsOfFareySymbol (3.2-4).  Example   gap> fs:=FareySymbolByData([infinity,0,1,2,infinity],[1,2,2,1]);  [ infinity, 0, 1, 2, infinity ] [ 1, 2, 2, 1 ]   3.1-2 IsValidFareySymbol IsValidFareySymbol( fs )  function This function is used in FareySymbolByData (3.1-1) to validate its output.  Example   gap> IsValidFareySymbol(fs); true   3.2 Properties of Farey symbols 3.2-1 GeneralizedFareySequence GeneralizedFareySequence( fs )  attribute Returns the generalized Farey sequence gfs of the Farey symbol.  Example   gap> GeneralizedFareySequence(fs); [ infinity, 0, 1, 2, infinity ]   3.2-2 NumeratorOfGFSElement NumeratorOfGFSElement( gfs, i )  function Returns: integer Returns the numerator of the i-th term of the generalised Farey sequence gfs: for the 1st infinite entry returns -1, for the last one returns 1, for all other entries returns the usual numerator.  Example   gap> List([1..5], i -> NumeratorOfGFSElement(GeneralizedFareySequence(fs),i)); [ -1, 0, 1, 2, 1 ]   3.2-3 DenominatorOfGFSElement DenominatorOfGFSElement( gfs, i )  function Returns: integer Returns the denominator of the i-th term of the generalised Farey sequence gfs: for both infinite entries returns 0, for the other ones returns the usual denominator.  Example   gap> List([1..5], i -> DenominatorOfGFSElement(GeneralizedFareySequence(fs),i));  [ 0, 1, 1, 1, 0 ]   3.2-4 LabelsOfFareySymbol LabelsOfFareySymbol( fs )  attribute Returns the list of labels of the Farey symbol. This list has "odd", "even" and paired integers as entries.  Example   gap> LabelsOfFareySymbol(fs); [ 1, 2, 2, 1 ]