4 Farey symbols for congruence subgroups The package Congruence provides functions to construct Farey symbols for finite index subgroups. The algorithm used in the package allows to construct a Farey symbol for any finite index subgroup of SL_2(ℤ) for which it is possible to check whether a given matrix belongs to this subgroup or not. The development of an algorithm to determine the Farey symbol for a subgroup G of a finite index in SL_2(ℤ) was started by Ravi Kulkarni in [Kul91] and later it was improved by Mong-Lung Lang, Chong-Hai Lim and Ser-Peow Tan in [LLT95b], [LLT95a]. 4.1 Computation of the Farey symbol for a finite index subgroup 4.1-1 FareySymbol FareySymbol( G )  attribute For a subgroup of a finite index G, this attribute stores one of the Farey symbols corresponding to the congruence subgroup G. The algorithm for its computation will work for any matrix group for which a membership test is available.  Example   gap> FareySymbol(PrincipalCongruenceSubgroup(8)); [ infinity, 0, 1/4, 1/3, 3/8, 2/5, 1/2, 3/5, 5/8, 2/3, 3/4, 1, 5/4, 4/3,   11/8, 7/5, 3/2, 8/5, 13/8, 5/3, 7/4, 2, 9/4, 7/3, 19/8, 12/5, 5/2, 13/5,   21/8, 8/3, 11/4, 3, 13/4, 10/3, 27/8, 17/5, 7/2, 18/5, 29/8, 11/3, 15/4, 4,   17/4, 13/3, 9/2, 14/3, 19/4, 5, 21/4, 16/3, 11/2, 17/3, 23/4, 6, 25/4,   19/3, 13/2, 20/3, 27/4, 7, 29/4, 22/3, 15/2, 23/3, 31/4, 8, infinity ] [ 1, 17, 10, 26, 32, 18, 19, 27, 30, 5, 2, 2, 13, 28, 26, 20, 21, 29, 27, 7,   3, 3, 16, 31, 28, 22, 23, 33, 29, 9, 4, 4, 5, 30, 31, 24, 25, 32, 33, 12,   6, 6, 7, 19, 18, 15, 8, 8, 9, 21, 20, 10, 11, 11, 12, 23, 22, 13, 14, 14,   15, 25, 24, 16, 17, 1 ] gap> FareySymbol(CongruenceSubgroupGamma0(20)); [ infinity, 0, 1/5, 1/4, 2/7, 3/10, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 1,   infinity ] [ 1, 3, 4, 6, 7, 7, 5, 2, 2, 3, 6, 4, 5, 1 ]    4.2 Computation of generators of a finite index subgroup from its Farey symbol If fs is the Farey symbol for a group G with r_1 even labels, r_2 odd labels and r_3 pairs of intervals, then G is generated by r_1+r_2+r_3 matrices, which form a set of independent generators for G. These matrices are constructed as follows: for each even interval [x_i, x_i+1], take the matrix A= [a_{i+1} b_{i+1} + a_i b_i -a_i^2 - a_{i+1}^2 ] [b_i^2 +b_{i+1}^2 -a_{i+1} b_{i+1} - a_i b_i] for each odd interval [x_j,x_j+1], take the matrix B= [a_{j+1} b_{j+1} + a_j b_{j+1} + a_j b_j -a_j^2 - a_j a_{j+1} -a_{j+1}^2] [ b_j^2 + b_j b_{j+1} + b_{j+1}^2 -a_{j+1} b_{j+1} - a_{j+1} b_j - a_j b_j] for each pair of free intervals [x_k,x_k+1] and [x_s,x_s+1], take the matrix C= [a_{s+1} b_{k+1} + a_s b_k -a_s a_k - a_{s+1} a_{k+1}] [b_s b_k- b_{s+1} b_{k+1}c -a_{k+1} b_{s+1} - a_k b_s] 4.2-1 MatrixByEvenInterval MatrixByEvenInterval( gfs, i )  function Returns the matrix corresponding to the even interval i in the generalized Farey sequence gfs.  Example   gap> H:=CongruenceSubgroupGamma0(5);   gap> fs:=FareySymbol(H); [ infinity, 0, 1/2, 1, infinity ] [ 1, "even", "even", 1 ] gap> gfs:=GeneralizedFareySequence(fs); [ infinity, 0, 1/2, 1, infinity ] gap> MatrixByEvenInterval(gfs,2);  [ [ 2, -1 ], [ 5, -2 ] ]   4.2-2 MatrixByOddInterval MatrixByOddInterval( gfs, i )  function Returns the matrix corresponding to the odd interval i in the generalized Farey sequence gfs.  Example   gap> fs_oo:=FareySymbolByData([infinity,0,infinity],["odd","odd"]);; gap> gfs_oo:=GeneralizedFareySequence(fs_oo); [ infinity, 0, infinity ] gap> MatrixByOddInterval(gfs_oo,1); [ [ -1, -1 ], [ 1, 0 ] ]   4.2-3 MatrixByFreePairOfIntervals MatrixByFreePairOfIntervals( gfs, k, kp )  function Returns the matrix corresponding to the pair of free intervals k and kp in the generalized Farey sequence gfs.  Example   gap> fs_free:=FareySymbolByData([infinity,0,1,2,infinity],[1,2,2,1]);; gap> gfs_free:=GeneralizedFareySequence(fs_free);; gap> MatrixByFreePairOfIntervals(gfs_free,2,3);  [ [ 3, -2 ], [ 2, -1 ] ]   4.2-4 GeneratorsByFareySymbol GeneratorsByFareySymbol( fs )  function Returns a set of matrices constructed as above.  Example   gap> fs_eo:=FareySymbolByData([infinity,0,infinity],["even","odd"]);; gap> GeneratorsByFareySymbol(last);  [ [ [ 0, -1 ], [ 1, 0 ] ], [ [ 0, -1 ], [ 1, -1 ] ] ] gap> GeneratorsByFareySymbol(fs);  [ [ [ 1, 1 ], [ 0, 1 ] ], [ [ 2, -1 ], [ 5, -2 ] ], [ [ 3, -2 ], [ 5, -3 ] ] ] gap> GeneratorsByFareySymbol(fs_oo); [ [ [ -1, -1 ], [ 1, 0 ] ], [ [ 0, -1 ], [ 1, -1 ] ] ] gap> GeneratorsByFareySymbol(fs_free);  [ [ [ 1, 2 ], [ 0, 1 ] ], [ [ 3, -2 ], [ 2, -1 ] ] ]   4.2-5 GeneratorsOfGroup GeneratorsOfGroup( G )  function Returns a set of generators for the finite index group G in SL_2(Z).  Example   gap> G:=PrincipalCongruenceSubgroup(2);  gap> FareySymbol(G); [ infinity, 0, 1, 2, infinity ] [ 2, 1, 1, 2 ] gap> GeneratorsOfGroup(G); #I Using the Congruence package for GeneratorsOfGroup ... [ [ [ 1, 2 ], [ 0, 1 ] ], [ [ 3, -2 ], [ 2, -1 ] ] ] gap> H:=CongruenceSubgroupGamma0(5);   gap> GeneratorsOfGroup(H); #I Using the Congruence package for GeneratorsOfGroup ... [ [ [ 1, 1 ], [ 0, 1 ] ], [ [ 2, -1 ], [ 5, -2 ] ], [ [ 3, -2 ], [ 5, -3 ] ] ] gap> I:=IntersectionOfCongruenceSubgroups(PrincipalCongruenceSubgroup(2),CongruenceSubgroupGamma0(3));  gap> FareySymbol(I); [ infinity, 0, 1/3, 1/2, 2/3, 1, 4/3, 3/2, 5/3, 2, infinity ] [ 1, 5, 4, 3, 2, 2, 3, 4, 5, 1 ] gap> GeneratorsOfGroup(I);  #I Using the Congruence package for GeneratorsOfGroup ... [ [ [ 1, 2 ], [ 0, 1 ] ], [ [ 11, -2 ], [ 6, -1 ] ],   [ [ 19, -8 ], [ 12, -5 ] ], [ [ 17, -10 ], [ 12, -7 ] ],   [ [ 7, -6 ], [ 6, -5 ] ] ]   4.3 Other properties derived from Farey symbols 4.3-1 IndexInPSL2ZByFareySymbol IndexInPSL2ZByFareySymbol( fs )  function By Proposition 7.2 in [Kulkarni], for the Farey symbol with underlying generalized Farey sequence [infinity, x0, x1, ..., xn, infinity], the index in PSL_2(Z) is given by the formula d = 3*n + e3, where e3 is the number of odd intervals.  Example   gap> IndexInPSL2ZByFareySymbol(fs); 6 gap> IndexInPSL2ZByFareySymbol(fs_oo); 2 gap> IndexInPSL2ZByFareySymbol(fs_free); 6