  
  [1X4 [33X[0;0YFarey symbols for congruence subgroups[133X[101X
  
  [33X[0;0YThe  package  [5XCongruence[105X  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 [22XSL_2(ℤ)[122X for which
  it  is  possible to check whether a given matrix belongs to this subgroup or
  not.[133X
  
  [33X[0;0YThe development of an algorithm to determine the Farey symbol for a subgroup
  G  of  a finite index in [22XSL_2(ℤ)[122X 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].[133X
  
  
  [1X4.1 [33X[0;0YComputation of the Farey symbol for a finite index subgroup[133X[101X
  
  [1X4.1-1 FareySymbol[101X
  
  [33X[1;0Y[29X[2XFareySymbol[102X( [3XG[103X ) [32X attribute[133X
  
  [33X[0;0YFor  a  subgroup of a finite index G, this attribute stores one of the Farey
  symbols  corresponding  to  the congruence subgroup [3XG[103X. The algorithm for its
  computation  will  work  for any matrix group for which a membership test is
  available.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XFareySymbol(PrincipalCongruenceSubgroup(8));[127X[104X
    [4X[28X[ 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, [128X[104X
    [4X[28X  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, [128X[104X
    [4X[28X  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, [128X[104X
    [4X[28X  17/4, 13/3, 9/2, 14/3, 19/4, 5, 21/4, 16/3, 11/2, 17/3, 23/4, 6, 25/4, [128X[104X
    [4X[28X  19/3, 13/2, 20/3, 27/4, 7, 29/4, 22/3, 15/2, 23/3, 31/4, 8, infinity ][128X[104X
    [4X[28X[ 1, 17, 10, 26, 32, 18, 19, 27, 30, 5, 2, 2, 13, 28, 26, 20, 21, 29, 27, 7, [128X[104X
    [4X[28X  3, 3, 16, 31, 28, 22, 23, 33, 29, 9, 4, 4, 5, 30, 31, 24, 25, 32, 33, 12, [128X[104X
    [4X[28X  6, 6, 7, 19, 18, 15, 8, 8, 9, 21, 20, 10, 11, 11, 12, 23, 22, 13, 14, 14, [128X[104X
    [4X[28X  15, 25, 24, 16, 17, 1 ][128X[104X
    [4X[25Xgap>[125X [27XFareySymbol(CongruenceSubgroupGamma0(20));[127X[104X
    [4X[28X[ 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, [128X[104X
    [4X[28X  infinity ][128X[104X
    [4X[28X[ 1, 3, 4, 6, 7, 7, 5, 2, 2, 3, 6, 4, 5, 1 ]  [128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  
  [1X4.2  [33X[0;0YComputation  of  generators  of  a finite index subgroup from its Farey[101X
  [1Xsymbol[133X[101X
  
  [33X[0;0YIf [3Xfs[103X is the Farey symbol for a group [22XG[122X with [22Xr_1[122X even labels, [22Xr_2[122X odd labels
  and  [22Xr_3[122X  pairs  of  intervals, then [22XG[122X is generated by [22Xr_1+r_2+r_3[122X matrices,
  which  form  a  set  of  independent  generators  for  [22XG[122X. These matrices are
  constructed as follows:[133X
  
  [33X[0;0Yfor each even interval [22X[x_i, x_i+1][122X, take the matrix[133X
  
                         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]
  
  [33X[0;0Yfor each odd interval [22X[x_j,x_j+1][122X, take the matrix[133X
  
                          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]
  
  [33X[0;0Yfor each pair of free intervals [22X[x_k,x_k+1][122X and [22X[x_s,x_s+1][122X, take the matrix[133X
  
                          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]
  
  [1X4.2-1 MatrixByEvenInterval[101X
  
  [33X[1;0Y[29X[2XMatrixByEvenInterval[102X( [3Xgfs[103X, [3Xi[103X ) [32X function[133X
  
  [33X[0;0YReturns  the  matrix corresponding to the even interval i in the generalized
  Farey sequence [3Xgfs[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XH:=CongruenceSubgroupGamma0(5); [127X[104X
    [4X[28X<congruence subgroup CongruenceSubgroupGamma_0(5) in SL_2(Z)>[128X[104X
    [4X[25Xgap>[125X [27Xfs:=FareySymbol(H);[127X[104X
    [4X[28X[ infinity, 0, 1/2, 1, infinity ][128X[104X
    [4X[28X[ 1, "even", "even", 1 ][128X[104X
    [4X[25Xgap>[125X [27Xgfs:=GeneralizedFareySequence(fs);[127X[104X
    [4X[28X[ infinity, 0, 1/2, 1, infinity ][128X[104X
    [4X[25Xgap>[125X [27XMatrixByEvenInterval(gfs,2);      [127X[104X
    [4X[28X[ [ 2, -1 ], [ 5, -2 ] ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X4.2-2 MatrixByOddInterval[101X
  
  [33X[1;0Y[29X[2XMatrixByOddInterval[102X( [3Xgfs[103X, [3Xi[103X ) [32X function[133X
  
  [33X[0;0YReturns  the  matrix  corresponding to the odd interval i in the generalized
  Farey sequence [3Xgfs[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xfs_oo:=FareySymbolByData([infinity,0,infinity],["odd","odd"]);;[127X[104X
    [4X[25Xgap>[125X [27Xgfs_oo:=GeneralizedFareySequence(fs_oo);[127X[104X
    [4X[28X[ infinity, 0, infinity ][128X[104X
    [4X[25Xgap>[125X [27XMatrixByOddInterval(gfs_oo,1);[127X[104X
    [4X[28X[ [ -1, -1 ], [ 1, 0 ] ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X4.2-3 MatrixByFreePairOfIntervals[101X
  
  [33X[1;0Y[29X[2XMatrixByFreePairOfIntervals[102X( [3Xgfs[103X, [3Xk[103X, [3Xkp[103X ) [32X function[133X
  
  [33X[0;0YReturns  the  matrix corresponding to the pair of free intervals k and kp in
  the generalized Farey sequence [3Xgfs[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xfs_free:=FareySymbolByData([infinity,0,1,2,infinity],[1,2,2,1]);;[127X[104X
    [4X[25Xgap>[125X [27Xgfs_free:=GeneralizedFareySequence(fs_free);;[127X[104X
    [4X[25Xgap>[125X [27XMatrixByFreePairOfIntervals(gfs_free,2,3);                                                        [127X[104X
    [4X[28X[ [ 3, -2 ], [ 2, -1 ] ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X4.2-4 GeneratorsByFareySymbol[101X
  
  [33X[1;0Y[29X[2XGeneratorsByFareySymbol[102X( [3Xfs[103X ) [32X function[133X
  
  [33X[0;0YReturns a set of matrices constructed as above.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xfs_eo:=FareySymbolByData([infinity,0,infinity],["even","odd"]);;[127X[104X
    [4X[25Xgap>[125X [27XGeneratorsByFareySymbol(last);                                  [127X[104X
    [4X[28X[ [ [ 0, -1 ], [ 1, 0 ] ], [ [ 0, -1 ], [ 1, -1 ] ] ][128X[104X
    [4X[25Xgap>[125X [27XGeneratorsByFareySymbol(fs); [127X[104X
    [4X[28X[ [ [ 1, 1 ], [ 0, 1 ] ], [ [ 2, -1 ], [ 5, -2 ] ], [ [ 3, -2 ], [ 5, -3 ] ] ][128X[104X
    [4X[25Xgap>[125X [27XGeneratorsByFareySymbol(fs_oo);[127X[104X
    [4X[28X[ [ [ -1, -1 ], [ 1, 0 ] ], [ [ 0, -1 ], [ 1, -1 ] ] ][128X[104X
    [4X[25Xgap>[125X [27XGeneratorsByFareySymbol(fs_free);                                                        [127X[104X
    [4X[28X[ [ [ 1, 2 ], [ 0, 1 ] ], [ [ 3, -2 ], [ 2, -1 ] ] ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X4.2-5 GeneratorsOfGroup[101X
  
  [33X[1;0Y[29X[2XGeneratorsOfGroup[102X( [3XG[103X ) [32X function[133X
  
  [33X[0;0YReturns a set of generators for the finite index group G in [22XSL_2(Z)[122X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XG:=PrincipalCongruenceSubgroup(2);[127X[104X
    [4X[28X<principal congruence subgroup of level 2 in SL_2(Z)>[128X[104X
    [4X[25Xgap>[125X [27XFareySymbol(G);[127X[104X
    [4X[28X[ infinity, 0, 1, 2, infinity ][128X[104X
    [4X[28X[ 2, 1, 1, 2 ][128X[104X
    [4X[25Xgap>[125X [27XGeneratorsOfGroup(G);[127X[104X
    [4X[28X#I  Using the Congruence package for GeneratorsOfGroup ...[128X[104X
    [4X[28X[ [ [ 1, 2 ], [ 0, 1 ] ], [ [ 3, -2 ], [ 2, -1 ] ] ][128X[104X
    [4X[25Xgap>[125X [27XH:=CongruenceSubgroupGamma0(5);        [127X[104X
    [4X[28X<congruence subgroup CongruenceSubgroupGamma_0(5) in SL_2(Z)>[128X[104X
    [4X[25Xgap>[125X [27XGeneratorsOfGroup(H);[127X[104X
    [4X[28X#I  Using the Congruence package for GeneratorsOfGroup ...[128X[104X
    [4X[28X[ [ [ 1, 1 ], [ 0, 1 ] ], [ [ 2, -1 ], [ 5, -2 ] ], [ [ 3, -2 ], [ 5, -3 ] ] ][128X[104X
    [4X[25Xgap>[125X [27XI:=IntersectionOfCongruenceSubgroups(PrincipalCongruenceSubgroup(2),CongruenceSubgroupGamma0(3));[127X[104X
    [4X[28X<intersection of congruence subgroups of resulting level 6 in SL_2(Z)>[128X[104X
    [4X[25Xgap>[125X [27XFareySymbol(I);[127X[104X
    [4X[28X[ infinity, 0, 1/3, 1/2, 2/3, 1, 4/3, 3/2, 5/3, 2, infinity ][128X[104X
    [4X[28X[ 1, 5, 4, 3, 2, 2, 3, 4, 5, 1 ][128X[104X
    [4X[25Xgap>[125X [27XGeneratorsOfGroup(I);                                                          [127X[104X
    [4X[28X#I  Using the Congruence package for GeneratorsOfGroup ...[128X[104X
    [4X[28X[ [ [ 1, 2 ], [ 0, 1 ] ], [ [ 11, -2 ], [ 6, -1 ] ], [128X[104X
    [4X[28X  [ [ 19, -8 ], [ 12, -5 ] ], [ [ 17, -10 ], [ 12, -7 ] ], [128X[104X
    [4X[28X  [ [ 7, -6 ], [ 6, -5 ] ] ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  
  [1X4.3 [33X[0;0YOther properties derived from Farey symbols[133X[101X
  
  [1X4.3-1 IndexInPSL2ZByFareySymbol[101X
  
  [33X[1;0Y[29X[2XIndexInPSL2ZByFareySymbol[102X( [3Xfs[103X ) [32X function[133X
  
  [33X[0;0YBy  Proposition  7.2  in  [Kulkarni],  for  the Farey symbol with underlying
  generalized  Farey sequence [infinity, x0, x1, ..., xn, infinity], the index
  in  [22XPSL_2(Z)[122X is given by the formula d = 3*n + e3, where e3 is the number of
  odd intervals.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XIndexInPSL2ZByFareySymbol(fs);[127X[104X
    [4X[28X6[128X[104X
    [4X[25Xgap>[125X [27XIndexInPSL2ZByFareySymbol(fs_oo);[127X[104X
    [4X[28X2[128X[104X
    [4X[25Xgap>[125X [27XIndexInPSL2ZByFareySymbol(fs_free);[127X[104X
    [4X[28X6[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
