% generated by GAPDoc2LaTeX from XML source (Frank Luebeck)
\documentclass[a4paper,11pt]{report}

\usepackage{a4wide}
\sloppy
\pagestyle{myheadings}
\usepackage{amssymb}
\usepackage[latin1]{inputenc}
\usepackage{makeidx}
\makeindex
\usepackage{color}
\definecolor{FireBrick}{rgb}{0.5812,0.0074,0.0083}
\definecolor{RoyalBlue}{rgb}{0.0236,0.0894,0.6179}
\definecolor{RoyalGreen}{rgb}{0.0236,0.6179,0.0894}
\definecolor{RoyalRed}{rgb}{0.6179,0.0236,0.0894}
\definecolor{LightBlue}{rgb}{0.8544,0.9511,1.0000}
\definecolor{Black}{rgb}{0.0,0.0,0.0}

\definecolor{linkColor}{rgb}{0.0,0.0,0.554}
\definecolor{citeColor}{rgb}{0.0,0.0,0.554}
\definecolor{fileColor}{rgb}{0.0,0.0,0.554}
\definecolor{urlColor}{rgb}{0.0,0.0,0.554}
\definecolor{promptColor}{rgb}{0.0,0.0,0.589}
\definecolor{brkpromptColor}{rgb}{0.589,0.0,0.0}
\definecolor{gapinputColor}{rgb}{0.589,0.0,0.0}
\definecolor{gapoutputColor}{rgb}{0.0,0.0,0.0}

%%  for a long time these were red and blue by default,
%%  now black, but keep variables to overwrite
\definecolor{FuncColor}{rgb}{0.0,0.0,0.0}
%% strange name because of pdflatex bug:
\definecolor{Chapter }{rgb}{0.0,0.0,0.0}
\definecolor{DarkOlive}{rgb}{0.1047,0.2412,0.0064}


\usepackage{fancyvrb}

\usepackage{mathptmx,helvet}
\usepackage[T1]{fontenc}
\usepackage{textcomp}


\usepackage[
            pdftex=true,
            bookmarks=true,        
            a4paper=true,
            pdftitle={Written with GAPDoc},
            pdfcreator={LaTeX with hyperref package / GAPDoc},
            colorlinks=true,
            backref=page,
            breaklinks=true,
            linkcolor=linkColor,
            citecolor=citeColor,
            filecolor=fileColor,
            urlcolor=urlColor,
            pdfpagemode={UseNone}, 
           ]{hyperref}

\newcommand{\maintitlesize}{\fontsize{50}{55}\selectfont}

% write page numbers to a .pnr log file for online help
\newwrite\pagenrlog
\immediate\openout\pagenrlog =\jobname.pnr
\immediate\write\pagenrlog{PAGENRS := [}
\newcommand{\logpage}[1]{\protect\write\pagenrlog{#1, \thepage,}}
%% were never documented, give conflicts with some additional packages

\newcommand{\GAP}{\textsf{GAP}}

%% nicer description environments, allows long labels
\usepackage{enumitem}
\setdescription{style=nextline}

%% depth of toc
\setcounter{tocdepth}{1}





%% command for ColorPrompt style examples
\newcommand{\gapprompt}[1]{\color{promptColor}{\bfseries #1}}
\newcommand{\gapbrkprompt}[1]{\color{brkpromptColor}{\bfseries #1}}
\newcommand{\gapinput}[1]{\color{gapinputColor}{#1}}


\begin{document}

\logpage{[ 0, 0, 0 ]}
\begin{titlepage}
\mbox{}\vfill

\begin{center}{\maintitlesize \textbf{\textsf{Congruence}\mbox{}}}\\
\vfill

\hypersetup{pdftitle=\textsf{Congruence}}
\markright{\scriptsize \mbox{}\hfill \textsf{Congruence} \hfill\mbox{}}
{\Huge \textbf{Congruence subgroups of $SL_2({\ensuremath{\mathbb Z}})$\mbox{}}}\\
\vfill

{\Huge Version 1.1.1\mbox{}}\\[1cm]
{28 October 2014\mbox{}}\\[1cm]
\mbox{}\\[2cm]
{\Large \textbf{Ann Dooms    \mbox{}}}\\
{\Large \textbf{Eric Jespers    \mbox{}}}\\
{\Large \textbf{Alexander Konovalov    \mbox{}}}\\
{\Large \textbf{Helena Verrill    \mbox{}}}\\
\hypersetup{pdfauthor=Ann Dooms    ; Eric Jespers    ; Alexander Konovalov    ; Helena Verrill    }
\end{center}\vfill

\mbox{}\\
{\mbox{}\\
\small \noindent \textbf{Ann Dooms    }  Email: \href{mailto://andooms@vub.ac.be} {\texttt{andooms@vub.ac.be}}\\
  Homepage: \href{http://homepages.vub.ac.be/~andooms} {\texttt{http://homepages.vub.ac.be/\texttt{\symbol{126}}andooms}}\\
  Address: \begin{minipage}[t]{8cm}\noindent
 Department of Mathematics, Vrije Universiteit Brussel\\
 Pleinlaan 2, Brussels, B-1050 Belgium \end{minipage}
}\\
{\mbox{}\\
\small \noindent \textbf{Eric Jespers    }  Email: \href{mailto://efjesper@vub.ac.be} {\texttt{efjesper@vub.ac.be}}\\
  Homepage: \href{http://homepages.vub.ac.be/~efjesper} {\texttt{http://homepages.vub.ac.be/\texttt{\symbol{126}}efjesper}}\\
  Address: \begin{minipage}[t]{8cm}\noindent
 Department of Mathematics, Vrije Universiteit Brussel\\
 Pleinlaan 2, Brussels, B-1050 Belgium \end{minipage}
}\\
{\mbox{}\\
\small \noindent \textbf{Alexander Konovalov    }  Email: \href{mailto://alexk@mcs.st-andrews.ac.uk} {\texttt{alexk@mcs.st-andrews.ac.uk}}\\
  Homepage: \href{http://www.cs.st-andrews.ac.uk/~alexk/} {\texttt{http://www.cs.st-andrews.ac.uk/\texttt{\symbol{126}}alexk/}}\\
  Address: \begin{minipage}[t]{8cm}\noindent
 School of Computer Science\\
 University of St Andrews\\
 Jack Cole Building, North Haugh,\\
 St Andrews, Fife, KY16 9SX, Scotland \end{minipage}
}\\
{\mbox{}\\
\small \noindent \textbf{Helena Verrill    }  Email: \href{mailto://verrill@math.lsu.edu} {\texttt{verrill@math.lsu.edu}}\\
  Homepage: \href{http://www.math.lsu.edu/~verrill/} {\texttt{http://www.math.lsu.edu/\texttt{\symbol{126}}verrill/}}\\
  Address: \begin{minipage}[t]{8cm}\noindent
 Department of Mathematics\\
 Louisiana State University\\
 Baton Rouge, Louisiana, 70803-4918\\
 USA \end{minipage}
}\\
\end{titlepage}

\newpage\setcounter{page}{2}
{\small 
\section*{Abstract}
\logpage{[ 0, 0, 1 ]}
 \index{Congruence package@\textsf{Congruence} package} The \textsf{GAP} package \textsf{Congruence} provides functionality to work with congruence subgroups of $SL_2({\ensuremath{\mathbb Z}})$. \mbox{}}\\[1cm]
{\small 
\section*{Copyright}
\logpage{[ 0, 0, 2 ]}
 {\copyright} 2006-2014 by Ann Dooms, Eric Jespers, Alexander Konovalov and
Helena Verrill.

 \textsf{Congruence} is free software; you can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version. For
details, see the FSF's own site \href{http://www.gnu.org/licenses/gpl.html} {\texttt{http://www.gnu.org/licenses/gpl.html}}.

 If you obtained \textsf{Congruence}, we would be grateful for a short notification sent to one of the authors.

 If you publish a result which was partially obtained with the usage of \textsf{Congruence}, please cite it in the following form:

 A. Dooms, E. Jespers, A. Konovalov and H. Verrill. \emph{Congruence --- Congruence subgroups of $SL_2({\ensuremath{\mathbb Z}})$, Version 1.1.1;} 2014 (\href{http://www.cs.st-andrews.ac.uk/~alexk/congruence/} {\texttt{http://www.cs.st-andrews.ac.uk/\texttt{\symbol{126}}alexk/congruence/}}). \mbox{}}\\[1cm]
{\small 
\section*{Acknowledgements}
\logpage{[ 0, 0, 3 ]}
 We are very grateful to Mong-Lung Lang, Chong-Hai Lim and Ser Peow Tan for
their comments provided while implementing algorithms from \cite{LLT-Algorithm} and \cite{LLT-Hecke}, and to Francqui Stichting (Belgium) for the support of the third author. \mbox{}}\\[1cm]
\newpage

\def\contentsname{Contents\logpage{[ 0, 0, 4 ]}}

\tableofcontents
\newpage

 
\chapter{\textcolor{Chapter }{Introduction}}\label{Intro}
\logpage{[ 1, 0, 0 ]}
\hyperdef{L}{X7DFB63A97E67C0A1}{}
{
  
\section{\textcolor{Chapter }{General aims of \textsf{Congruence} package}}\label{IntroAims}
\logpage{[ 1, 1, 0 ]}
\hyperdef{L}{X7D14F5C18621348C}{}
{
  \index{IsCongruenceSubgroup@\texttt{IsCongruenceSubgroup}} The \textsf{GAP} package \textsf{Congruence} provides functions to construct several types of canonical congruence
subgroups in $SL_2({\ensuremath{\mathbb Z}})$, and also intersections of a finite number of such subgroups. 

 Furthermore, it implements the algorithm for generating Farey symbols for
congruence subgroups and using them to produce a system of independent
generators for these subgroups. 

 Using the package, one can also determine indices of congruence subgroups and
their intersections in $SL_2({\ensuremath{\mathbb Z}})$ and in other congruence subgroups, generate their random elements and check
element memberships. Success of other group theoretical constructions mostly
depends on whether they could be expressed in terms of group generators or
not. 

 For the theoretical backround, we refer to \cite{LLT-Hecke}, \cite{LLT-Algorithm}, \cite{CLT} and \cite{Kulkarni}. }

  
\section{\textcolor{Chapter }{Installation and system requirements}}\label{IntroInstall}
\logpage{[ 1, 2, 0 ]}
\hyperdef{L}{X7DB566D5785B7DBC}{}
{
  \textsf{Congruence} is distributed in standard formats (\texttt{tar.gz}, \texttt{tar.bz2}, \texttt{-win.zip}) and can be obtained from \href{http://www.cs.st-andrews.ac.uk/~alexk/congruence/} {\texttt{http://www.cs.st-andrews.ac.uk/\texttt{\symbol{126}}alexk/congruence/}}. 

 \textsf{Congruence} does not use external binaries and, therefore, works without restrictions on
the operating system. It requires at least version \textsf{GAP}{\nobreakspace}4.5, and no compatibility with previous releases of \textsf{GAP}{\nobreakspace}4 is guaranteed. 

 Installation of the package is standard and follows the guidelines from the \textsf{GAP} manual (see  (\textbf{Reference: Installing a GAP Package}). After the package is installed, you can start \textsf{GAP} and load the \textsf{Congruence} package using the command: 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@LoadPackage("congruence");|
  
\end{Verbatim}
 }

 }

 
\chapter{\textcolor{Chapter }{Construction of congruence subgroups}}\label{CongruenceSubgroups}
\logpage{[ 2, 0, 0 ]}
\hyperdef{L}{X7B010EE67FACF45E}{}
{
  \index{IsCongruenceSubgroup@\texttt{IsCongruenceSubgroup}} The package \textsf{Congruence} provides functions to construct several types of canonical congruence
subgroups in $SL_2({\ensuremath{\mathbb Z}})$, and also intersections of a finite number of such subgroups. They will
return a matrix group in the category \texttt{IsCongruenceSubgroup}, which is defined as a subcategory of \texttt{IsMatrixGroup}, and which will have a distinguishing property determining whether it is a
congruence subgroup of one of the canonical types, or an intersection of such
congruence subgroups (if it can not be reduced to one of the canonical
congruence subgroups). To start to work with the package, you need first to
load it as follows: 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@LoadPackage("congruence");|
  -----------------------------------------------------------------------------
  Loading  Congruence 1.1.0 (Congruence subgroups of SL(2,Integers))
  by Ann Dooms (http://homepages.vub.ac.be/~andooms),
     Eric Jespers (http://homepages.vub.ac.be/~efjesper),
     Alexander Konovalov (http://www.cs.st-andrews.ac.uk/~alexk/), and
     Helena Verrill (http://www.math.lsu.edu/~verrill).
  -----------------------------------------------------------------------------
  true
  
\end{Verbatim}
 
\section{\textcolor{Chapter }{Construction of congruence subgroups}}\label{CongConstr}
\logpage{[ 2, 1, 0 ]}
\hyperdef{L}{X7B010EE67FACF45E}{}
{
  

\subsection{\textcolor{Chapter }{PrincipalCongruenceSubgroup}}
\logpage{[ 2, 1, 1 ]}\nobreak
\hyperdef{L}{X7A61F693873F7136}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{PrincipalCongruenceSubgroup({\mdseries\slshape N})\index{PrincipalCongruenceSubgroup@\texttt{PrincipalCongruenceSubgroup}}
\label{PrincipalCongruenceSubgroup}
}\hfill{\scriptsize (operation)}}\\


 Returns the principal congruence subgroup $\Gamma(N)$ of level \mbox{\texttt{\mdseries\slshape N}} in $SL_2({\ensuremath{\mathbb Z}})$.

 This subgroup consists of all matrices of the form  
\[ \left( \begin{array}{rr} 1+N a & N b \\ N c & 1+N d \end{array} \right) \]
   where $a$,$b$,$c$,$d$ are integers. The returned group will have the property \texttt{IsPrincipalCongruenceSubgroup} (\ref{IsPrincipalCongruenceSubgroup}). }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@G_8:=PrincipalCongruenceSubgroup(8);|
  <principal congruence subgroup of level 8 in SL_2(Z)>
  !gapprompt@gap>| !gapinput@IsGroup(G_8);|
  true
  !gapprompt@gap>| !gapinput@IsMatrixGroup(G_8);|
  true
  !gapprompt@gap>| !gapinput@DimensionOfMatrixGroup(G_8);|
  2
  !gapprompt@gap>| !gapinput@MultiplicativeNeutralElement(G_8);|
  [ [ 1, 0 ], [ 0, 1 ] ]
  !gapprompt@gap>| !gapinput@One(G);|
  [ [ 1, 0 ], [ 0, 1 ] ]
  !gapprompt@gap>| !gapinput@[[1,2],[3,4]] in G_8;|
  false
  !gapprompt@gap>| !gapinput@[[1,8],[8,65]] in G_8;|
  true
  !gapprompt@gap>| !gapinput@SL_2:=SL(2,Integers);|
  SL(2,Integers)
  !gapprompt@gap>| !gapinput@IsSubgroup(SL_2,G_8);|
  true
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{CongruenceSubgroupGamma0}}
\logpage{[ 2, 1, 2 ]}\nobreak
\hyperdef{L}{X7B8DB77B81BE58D7}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{CongruenceSubgroupGamma0({\mdseries\slshape N})\index{CongruenceSubgroupGamma0@\texttt{CongruenceSubgroupGamma0}}
\label{CongruenceSubgroupGamma0}
}\hfill{\scriptsize (operation)}}\\


 Returns the congruence subgroup $\Gamma_0(N)$ of level \mbox{\texttt{\mdseries\slshape N}} in $SL_2({\ensuremath{\mathbb Z}})$.

 This subgroup consists of all matrices of the form  
\[ \left( \begin{array}{rr} a & b \\ N c & d \end{array} \right) \]
   where $a$,$b$,$c$,$d$ are integers. The returned group will have the property \texttt{IsCongruenceSubgroupGamma0} (\ref{IsCongruenceSubgroupGamma0}). }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@G0_4:=CongruenceSubgroupGamma0(4);|
  <congruence subgroup CongruenceSubgroupGamma_0(4) in SL_2(Z)>
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{CongruenceSubgroupGammaUpper0}}
\logpage{[ 2, 1, 3 ]}\nobreak
\hyperdef{L}{X7B4FBED17ECE2A7F}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{CongruenceSubgroupGammaUpper0({\mdseries\slshape N})\index{CongruenceSubgroupGammaUpper0@\texttt{CongruenceSubgroupGammaUpper0}}
\label{CongruenceSubgroupGammaUpper0}
}\hfill{\scriptsize (operation)}}\\


 Returns the congruence subgroup $\Gamma^0(N)$ of level \mbox{\texttt{\mdseries\slshape N}} in $SL_2({\ensuremath{\mathbb Z}})$.

 This subgroup consists of all matrices of the form  
\[ \left( \begin{array}{rr} a & N b \\ c & d \end{array} \right) \]
   where $a$,$b$,$c$,$d$ are integers. The returned group will have the property \texttt{IsCongruenceSubgroupGammaUpper0} (\ref{IsCongruenceSubgroupGammaUpper0}). }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@GU0_2:=CongruenceSubgroupGammaUpper0(2);|
  <congruence subgroup CongruenceSubgroupGamma^0(2) in SL_2(Z)>
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{CongruenceSubgroupGamma1}}
\logpage{[ 2, 1, 4 ]}\nobreak
\hyperdef{L}{X7CFDC47279AC0E85}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{CongruenceSubgroupGamma1({\mdseries\slshape N})\index{CongruenceSubgroupGamma1@\texttt{CongruenceSubgroupGamma1}}
\label{CongruenceSubgroupGamma1}
}\hfill{\scriptsize (operation)}}\\


 Returns the congruence subgroup $\Gamma_1(N)$ of level \mbox{\texttt{\mdseries\slshape N}} in $SL_2({\ensuremath{\mathbb Z}})$.

 This subgroup consists of all matrices of the form  
\[ \left( \begin{array}{rr} 1+N a & b \\ N c & 1+N d \end{array} \right) \]
   where $a$,$b$,$c$,$d$ are integers. The returned group will have the property \texttt{IsCongruenceSubgroupGamma1} (\ref{IsCongruenceSubgroupGamma1}). }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@G1_6:=CongruenceSubgroupGamma1(6);|
  <congruence subgroup CongruenceSubgroupGamma_1(6) in SL_2(Z)>
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{CongruenceSubgroupGammaUpper1}}
\logpage{[ 2, 1, 5 ]}\nobreak
\hyperdef{L}{X7C3FCDD878FE57ED}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{CongruenceSubgroupGammaUpper1({\mdseries\slshape N})\index{CongruenceSubgroupGammaUpper1@\texttt{CongruenceSubgroupGammaUpper1}}
\label{CongruenceSubgroupGammaUpper1}
}\hfill{\scriptsize (operation)}}\\


 Returns the congruence subgroup $\Gamma^1(N)$ of level \mbox{\texttt{\mdseries\slshape N}} in $SL_2({\ensuremath{\mathbb Z}})$.

 This subgroup consists of all matrices of the form  
\[ \left( \begin{array}{rr} 1+N a & N b \\ c & 1+N d \end{array} \right) \]
   where $a$,$b$,$c$,$d$ are integers. The returned group will have the property \texttt{IsCongruenceSubgroupGammaUpper1} (\ref{IsCongruenceSubgroupGammaUpper1}). }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@GU1_4:=CongruenceSubgroupGammaUpper1(4);|
  <congruence subgroup CongruenceSubgroupGamma^1(4) in SL_2(Z)>
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{IntersectionOfCongruenceSubgroups}}
\logpage{[ 2, 1, 6 ]}\nobreak
\hyperdef{L}{X7FE839377D7F45EB}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IntersectionOfCongruenceSubgroups({\mdseries\slshape G1, G2, ..., GN})\index{IntersectionOfCongruenceSubgroups@\texttt{IntersectionOfCongruenceSubgroups}}
\label{IntersectionOfCongruenceSubgroups}
}\hfill{\scriptsize (function)}}\\
\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{Intersection({\mdseries\slshape G1, G2, ..., GN})\index{Intersection@\texttt{Intersection}}
\label{Intersection}
}\hfill{\scriptsize (function)}}\\


 Returns the intersection of its arguments, which can be congruence subgroups
or their intersections, constructed with the same function. It is not
necessary for the user to use \texttt{IntersectionOfCongruenceSubgroups}, since it will be called automatically from \texttt{Intersection}.

 The returned group will have the property \texttt{IsIntersectionOfCongruenceSubgroups} (\ref{IsIntersectionOfCongruenceSubgroups}).

 The list of congruence subgroups that form the intersection can be obtained
using \texttt{DefiningCongruenceSubgroups} (\ref{DefiningCongruenceSubgroups}). Note, that when the intersection appears to be one of the canonical
congruence subgroups, the package will recognize this and will return a
canonical subgroup of the appropriate type. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@I:=IntersectionOfCongruenceSubgroups(G0_4,GU1_4);|
  <principal congruence subgroup of level 4 in SL_2(Z)>
  !gapprompt@gap>| !gapinput@J:=IntersectionOfCongruenceSubgroups(G0_4,G1_6);|
  <intersection of congruence subgroups of resulting level 12 in SL_2(Z)>
  
\end{Verbatim}
 }

  
\section{\textcolor{Chapter }{Properties of congruence subgroups}}\label{CongProperties}
\logpage{[ 2, 2, 0 ]}
\hyperdef{L}{X8267F261874959E5}{}
{
  A congruence subgroup constructed by one of the five above listed functions
will have certain properties determining its type. These properties will be
used for method selection by \textsf{Congruence} algorithms. Note that they do not provide an actual test whether a certain
matrix group is a congruence subgroup or not. 

\subsection{\textcolor{Chapter }{IsPrincipalCongruenceSubgroup}}
\logpage{[ 2, 2, 1 ]}\nobreak
\hyperdef{L}{X828F7E08787650DC}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsPrincipalCongruenceSubgroup({\mdseries\slshape G})\index{IsPrincipalCongruenceSubgroup@\texttt{IsPrincipalCongruenceSubgroup}}
\label{IsPrincipalCongruenceSubgroup}
}\hfill{\scriptsize (property)}}\\


 For a congruence subgroup \mbox{\texttt{\mdseries\slshape G}} in the category \texttt{IsCongruenceSubgroup}, returns \texttt{true} if \mbox{\texttt{\mdseries\slshape G}} was constructed by \texttt{PrincipalCongruenceSubgroup} (\ref{PrincipalCongruenceSubgroup}) (or reduced to one as a result of an intersection) and returns \texttt{false} otherwise. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@IsPrincipalCongruenceSubgroup(G_8);|
  true
  !gapprompt@gap>| !gapinput@IsPrincipalCongruenceSubgroup(G0_4);|
  false
  !gapprompt@gap>| !gapinput@IsPrincipalCongruenceSubgroup(I);|
  true
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{IsCongruenceSubgroupGamma0}}
\logpage{[ 2, 2, 2 ]}\nobreak
\hyperdef{L}{X85124A697E826AB4}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsCongruenceSubgroupGamma0({\mdseries\slshape G})\index{IsCongruenceSubgroupGamma0@\texttt{IsCongruenceSubgroupGamma0}}
\label{IsCongruenceSubgroupGamma0}
}\hfill{\scriptsize (property)}}\\


 For a congruence subgroup \mbox{\texttt{\mdseries\slshape G}} in the category \texttt{IsCongruenceSubgroup}, returns \texttt{true} if \mbox{\texttt{\mdseries\slshape G}} was constructed by \texttt{CongruenceSubgroupGamma0} (\ref{CongruenceSubgroupGamma0}) (or reduced to one as a result of an intersection) and returns \texttt{false} otherwise. }

 

\subsection{\textcolor{Chapter }{IsCongruenceSubgroupGammaUpper0}}
\logpage{[ 2, 2, 3 ]}\nobreak
\hyperdef{L}{X7A03633C83A286F5}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsCongruenceSubgroupGammaUpper0({\mdseries\slshape G})\index{IsCongruenceSubgroupGammaUpper0@\texttt{IsCongruenceSubgroupGammaUpper0}}
\label{IsCongruenceSubgroupGammaUpper0}
}\hfill{\scriptsize (property)}}\\


 For a congruence subgroup \mbox{\texttt{\mdseries\slshape G}} in the category \texttt{IsCongruenceSubgroup}, returns \texttt{true} if \mbox{\texttt{\mdseries\slshape G}} was constructed by \texttt{CongruenceSubgroupGammaUpper0} (\ref{CongruenceSubgroupGammaUpper0}) (or reduced to one as a result of an intersection) and returns \texttt{false} otherwise. }

 

\subsection{\textcolor{Chapter }{IsCongruenceSubgroupGamma1}}
\logpage{[ 2, 2, 4 ]}\nobreak
\hyperdef{L}{X8262396080F3B0DD}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsCongruenceSubgroupGamma1({\mdseries\slshape G})\index{IsCongruenceSubgroupGamma1@\texttt{IsCongruenceSubgroupGamma1}}
\label{IsCongruenceSubgroupGamma1}
}\hfill{\scriptsize (property)}}\\


 For a congruence subgroup \mbox{\texttt{\mdseries\slshape G}} in the category \texttt{IsCongruenceSubgroup}, returns \texttt{true} if \mbox{\texttt{\mdseries\slshape G}} was constructed by \texttt{CongruenceSubgroupGamma1} (\ref{CongruenceSubgroupGamma1}) (or reduced to one as a result of an intersection) and returns \texttt{false} otherwise. }

 

\subsection{\textcolor{Chapter }{IsCongruenceSubgroupGammaUpper1}}
\logpage{[ 2, 2, 5 ]}\nobreak
\hyperdef{L}{X7D731035834CF878}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsCongruenceSubgroupGammaUpper1({\mdseries\slshape G})\index{IsCongruenceSubgroupGammaUpper1@\texttt{IsCongruenceSubgroupGammaUpper1}}
\label{IsCongruenceSubgroupGammaUpper1}
}\hfill{\scriptsize (property)}}\\


 For a congruence subgroup \mbox{\texttt{\mdseries\slshape G}} in the category \texttt{IsCongruenceSubgroup}, returns \texttt{true} if \mbox{\texttt{\mdseries\slshape G}} was constructed by \texttt{CongruenceSubgroupGammaUpper1} (\ref{CongruenceSubgroupGammaUpper1}) (or reduced to one as a result of an intersection) and returns \texttt{false} otherwise. }

 

\subsection{\textcolor{Chapter }{IsIntersectionOfCongruenceSubgroups}}
\logpage{[ 2, 2, 6 ]}\nobreak
\hyperdef{L}{X83B4E4FA7F4DFB97}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsIntersectionOfCongruenceSubgroups({\mdseries\slshape G})\index{IsIntersectionOfCongruenceSubgroups@\texttt{IsIntersectionOfCongruenceSubgroups}}
\label{IsIntersectionOfCongruenceSubgroups}
}\hfill{\scriptsize (property)}}\\


 For a congruence subgroup \mbox{\texttt{\mdseries\slshape G}} in the category \texttt{IsCongruenceSubgroup}, returns \texttt{true} if \mbox{\texttt{\mdseries\slshape G}} was constructed by \texttt{IntersectionOfCongruenceSubgroups} (\ref{IntersectionOfCongruenceSubgroups}) and without being one of the canonical congruence subgroups, otherwise it
returns \texttt{false}. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@IsIntersectionOfCongruenceSubgroups(I);|
  false
  !gapprompt@gap>| !gapinput@IsIntersectionOfCongruenceSubgroups(J);|
  true
  
\end{Verbatim}
 }

  
\section{\textcolor{Chapter }{Attributes of congruence subgroups}}\label{CongAttributes}
\logpage{[ 2, 3, 0 ]}
\hyperdef{L}{X8664A60E875EA5DE}{}
{
  The next three attributes store key properties of congruence subgroups. 

\subsection{\textcolor{Chapter }{LevelOfCongruenceSubgroup}}
\logpage{[ 2, 3, 1 ]}\nobreak
\hyperdef{L}{X7D5696F584970D21}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{LevelOfCongruenceSubgroup({\mdseries\slshape G})\index{LevelOfCongruenceSubgroup@\texttt{LevelOfCongruenceSubgroup}}
\label{LevelOfCongruenceSubgroup}
}\hfill{\scriptsize (attribute)}}\\


 Stores the level of the congruence subgroup \mbox{\texttt{\mdseries\slshape G}}. The (arithmetic) level of a congruence subgroup G is the smallest positive
number N such that G contains the principal congruence subgroup of level N. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@LevelOfCongruenceSubgroup(G_8);|
  8
  !gapprompt@gap>| !gapinput@LevelOfCongruenceSubgroup(G1_6);|
  6
  !gapprompt@gap>| !gapinput@LevelOfCongruenceSubgroup(I);|
  4
  !gapprompt@gap>| !gapinput@LevelOfCongruenceSubgroup(J);|
  12
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{IndexInSL2Z}}
\logpage{[ 2, 3, 2 ]}\nobreak
\hyperdef{L}{X87302F8A7E44D67B}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IndexInSL2Z({\mdseries\slshape G})\index{IndexInSL2Z@\texttt{IndexInSL2Z}}
\label{IndexInSL2Z}
}\hfill{\scriptsize (attribute)}}\\


 Stores the index of the congruence subgroup \mbox{\texttt{\mdseries\slshape G}} in $SL_2({\ensuremath{\mathbb Z}})$. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@IndexInSL2Z(G_8);|
  384
  !gapprompt@gap>| !gapinput@G_2:=PrincipalCongruenceSubgroup(2);|
  <principal congruence subgroup of level 2 in SL_2(Z)>
  !gapprompt@gap>| !gapinput@IndexInSL2Z(G_2);|
  12
  !gapprompt@gap>| !gapinput@IndexInSL2Z(GU1_4);|
  12
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{DefiningCongruenceSubgroups}}
\logpage{[ 2, 3, 3 ]}\nobreak
\hyperdef{L}{X7BF57D157824FFC8}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DefiningCongruenceSubgroups({\mdseries\slshape G})\index{DefiningCongruenceSubgroups@\texttt{DefiningCongruenceSubgroups}}
\label{DefiningCongruenceSubgroups}
}\hfill{\scriptsize (attribute)}}\\
\textbf{\indent Returns:\ }
 list of congruence subgroups 



 For an intersection of congruence subgroups, returns the list of congruence
subgroups forming this intersection. For a canonical congruence subgroup
returns a list of length one containing that subgroup. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@DefiningCongruenceSubgroups(J);|
  [ <congruence subgroup CongruenceSubgroupGamma_0(4) in SL_2(Z)>,
    <congruence subgroup CongruenceSubgroupGamma_1(6) in SL_2(Z)> ]
  !gapprompt@gap>| !gapinput@P:=PrincipalCongruenceSubgroup(6);|
  <principal congruence subgroup of level 6 in SL_2(Z)>
  !gapprompt@gap>| !gapinput@Q:=PrincipalCongruenceSubgroup(10); |
  <principal congruence subgroup of level 10 in SL_2(Z)>
  !gapprompt@gap>| !gapinput@G:=IntersectionOfCongruenceSubgroups(Q,P);  |
  <principal congruence subgroup of level 30 in SL_2(Z)>
  !gapprompt@gap>| !gapinput@DefiningCongruenceSubgroups(G);|
  [ <principal congruence subgroup of level 30 in SL_2(Z)> ] 
  
\end{Verbatim}
 }

  
\section{\textcolor{Chapter }{Operations for congruence subgroups}}\label{CongMethods}
\logpage{[ 2, 4, 0 ]}
\hyperdef{L}{X7B15B49583DC9EF5}{}
{
  \textsf{Congruence} installs several special methods for operations already available in \textsf{GAP}. 

\subsection{\textcolor{Chapter }{Random (one and two argument versions)}}
\logpage{[ 2, 4, 1 ]}\nobreak
\hyperdef{L}{X8146AC8587C65DEE}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{Random({\mdseries\slshape G})\index{Random@\texttt{Random}!one and two argument versions}
\label{Random:one and two argument versions}
}\hfill{\scriptsize (operation)}}\\
\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{Random({\mdseries\slshape G, m})\index{Random@\texttt{Random}}
\label{Random}
}\hfill{\scriptsize (operation)}}\\


 For a congruence subgroup \mbox{\texttt{\mdseries\slshape G}} in the category \texttt{IsCongruenceSubgroup}, returns random element. In the two-argument form, the second parameter will
control the absolute value of randomly selected entries of the matrix. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@Random(G_2) in G_2;|
  true
  !gapprompt@gap>| !gapinput@Random(G_8,2) in G_8;|
  true
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{\texttt{\symbol{92}}in}}
\logpage{[ 2, 4, 2 ]}\nobreak
\hyperdef{L}{X87BDB89B7AAFE8AD}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{\texttt{\symbol{92}}in({\mdseries\slshape m, G})\index{in@\texttt{\texttt{\symbol{92}}in}}
\label{in}
}\hfill{\scriptsize (operation)}}\\


 It is easy to implement the membership test for congruence subgroups and their
intersections. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@\in([ [ 21, 10 ], [ 2, 1 ] ],G_2);|
  true
  !gapprompt@gap>| !gapinput@\in([ [ 21, 10 ], [ 2, 1 ] ],G_8);|
  false
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{CanEasilyCompareCongruenceSubgroups}}
\logpage{[ 2, 4, 3 ]}\nobreak
\hyperdef{L}{X7FC5BF527931FF4C}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{CanEasilyCompareCongruenceSubgroups({\mdseries\slshape G, H})\index{CanEasilyCompareCongruenceSubgroups@\texttt{CanEasilyCompareCongruenceSubgroups}}
\label{CanEasilyCompareCongruenceSubgroups}
}\hfill{\scriptsize (operation)}}\\


 For congruence subgroups \mbox{\texttt{\mdseries\slshape G,H}} in the category \texttt{IsCongruenceSubgroup}, returns \texttt{true} if \mbox{\texttt{\mdseries\slshape G}} and \mbox{\texttt{\mdseries\slshape H}} are of the same type listed in \texttt{PrincipalCongruenceSubgroup} (\ref{PrincipalCongruenceSubgroup}) --{\textgreater} \texttt{CongruenceSubgroupGammaUpper1} (\ref{CongruenceSubgroupGammaUpper1}) and have the same \texttt{LevelOfCongruenceSubgroup} (\ref{LevelOfCongruenceSubgroup}) or if \mbox{\texttt{\mdseries\slshape G}} and \mbox{\texttt{\mdseries\slshape H}} are of the type \texttt{IntersectionOfCongruenceSubgroups} (\ref{IntersectionOfCongruenceSubgroups}) and the groups from \texttt{DefiningCongruenceSubgroups} (\ref{DefiningCongruenceSubgroups}) are in one to one correspondence, otherwise it returns \texttt{false}. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@CanEasilyCompareCongruenceSubgroups(G_8,I);|
  false
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{IsSubset}}
\logpage{[ 2, 4, 4 ]}\nobreak
\hyperdef{L}{X79CA175481F8105F}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsSubset({\mdseries\slshape G, H})\index{IsSubset@\texttt{IsSubset}}
\label{IsSubset}
}\hfill{\scriptsize (operation)}}\\


 \textsf{Congruence} provides methods for \texttt{IsSubset} for congruence subgroups. \texttt{IsSubset} returns \texttt{true} if \mbox{\texttt{\mdseries\slshape H}} is a subset of \mbox{\texttt{\mdseries\slshape G}}. These methods make it possible to use \texttt{IsSubgroup} operation for congruence subgroups. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@IsSubset(G_2,G_8);|
  true
  !gapprompt@gap>| !gapinput@IsSubset(G_8,G_2);|
  false
  !gapprompt@gap>| !gapinput@f:=[PrincipalCongruenceSubgroup,CongruenceSubgroupGamma1,CongruenceSubgroupGammaUpper1,CongruenceSubgroupGamma0,CongruenceSubgroupGammaUpper0];;|
  !gapprompt@gap>| !gapinput@g1:=List(f, t -> t(2));;|
  !gapprompt@gap>| !gapinput@g2:=List(f, t -> t(4));;|
  !gapprompt@gap>| !gapinput@for g in g2 do|
  !gapprompt@>| !gapinput@Print( List( g1, x -> IsSubgroup(x,g) ), "\n");|
  !gapprompt@>| !gapinput@od;|
  [ true, true, true, true, true ]
  [ false, true, false, true, false ]
  [ false, false, true, false, true ]
  [ false, false, false, true, false ]
  [ false, false, false, false, true ]
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{Index}}
\logpage{[ 2, 4, 5 ]}\nobreak
\hyperdef{L}{X83A0356F839C696F}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{Index({\mdseries\slshape G, H})\index{Index@\texttt{Index}}
\label{Index}
}\hfill{\scriptsize (operation)}}\\


 If a congruence subgroup \mbox{\texttt{\mdseries\slshape H}} is a subgroup of a congruence subgroup \mbox{\texttt{\mdseries\slshape G}}, we can easily compute the index of \mbox{\texttt{\mdseries\slshape H}} in \mbox{\texttt{\mdseries\slshape G}}, since we know the index of both subgroups in $SL_2({\ensuremath{\mathbb Z}})$. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@Index(G_2,G_8);|
  32
  
\end{Verbatim}
 }

 }

 
\chapter{\textcolor{Chapter }{Farey symbols and their properties}}\label{Farey}
\logpage{[ 3, 0, 0 ]}
\hyperdef{L}{X85CABB30818CD99C}{}
{
  \index{IsFareySymbol@\texttt{IsFareySymbol}} \index{IsFareySymbolDefaultRep@\texttt{IsFareySymbolDefaultRep}} A Farey symbol is a compact and useful way to represent a subgroup of finite
index in $SL_2({\ensuremath{\mathbb Z}})$ from which one can deduce independent generators for this subgroup. It
consists of two components, namely a so-called generalised Farey sequence (\mbox{\texttt{\mdseries\slshape gfs}}) and an ordered list of labels, giving additional structure to the \mbox{\texttt{\mdseries\slshape 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 \in Z$, and some $x_i = 0$;

 3. we define $x_{-1}=-infinity=-1/0$ and $x_{n+1}=infinity=1/0$;

 4. $a_{i+1}b_{i}-a_{i}b_{i+1}=1$ for $i=-1, ... ,n$.

 The ordered list of labels of a Farey symbol gives an additional structure to
the \mbox{\texttt{\mdseries\slshape 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 \textsf{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 \texttt{IsFareySymbol} and will have the representation \texttt{IsFareySymbolDefaultRep}. 
\section{\textcolor{Chapter }{Construction of Farey symbols}}\label{FareyConstr}
\logpage{[ 3, 1, 0 ]}
\hyperdef{L}{X7B7B81E584CCA30C}{}
{
  

\subsection{\textcolor{Chapter }{FareySymbolByData}}
\logpage{[ 3, 1, 1 ]}\nobreak
\hyperdef{L}{X7F8F5919870A46FE}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FareySymbolByData({\mdseries\slshape gfs, labels})\index{FareySymbolByData@\texttt{FareySymbolByData}}
\label{FareySymbolByData}
}\hfill{\scriptsize (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 \texttt{GeneralizedFareySequence} (\ref{GeneralizedFareySequence}) and \texttt{LabelsOfFareySymbol} (\ref{LabelsOfFareySymbol}). }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@fs:=FareySymbolByData([infinity,0,1,2,infinity],[1,2,2,1]);                         |
  [ infinity, 0, 1, 2, infinity ]
  [ 1, 2, 2, 1 ]
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{IsValidFareySymbol}}
\logpage{[ 3, 1, 2 ]}\nobreak
\hyperdef{L}{X845F9BA182F4E73B}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsValidFareySymbol({\mdseries\slshape fs})\index{IsValidFareySymbol@\texttt{IsValidFareySymbol}}
\label{IsValidFareySymbol}
}\hfill{\scriptsize (function)}}\\


 This function is used in \texttt{FareySymbolByData} (\ref{FareySymbolByData}) to validate its output. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@IsValidFareySymbol(fs);|
  true
  
\end{Verbatim}
 }

  
\section{\textcolor{Chapter }{Properties of Farey symbols}}\label{FareyProperties}
\logpage{[ 3, 2, 0 ]}
\hyperdef{L}{X8016C45082AEC784}{}
{
  

\subsection{\textcolor{Chapter }{GeneralizedFareySequence}}
\logpage{[ 3, 2, 1 ]}\nobreak
\hyperdef{L}{X8245766978F02751}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{GeneralizedFareySequence({\mdseries\slshape fs})\index{GeneralizedFareySequence@\texttt{GeneralizedFareySequence}}
\label{GeneralizedFareySequence}
}\hfill{\scriptsize (attribute)}}\\


 Returns the generalized Farey sequence \mbox{\texttt{\mdseries\slshape gfs}} of the Farey symbol. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@GeneralizedFareySequence(fs);|
  [ infinity, 0, 1, 2, infinity ]
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{NumeratorOfGFSElement}}
\logpage{[ 3, 2, 2 ]}\nobreak
\hyperdef{L}{X80BB58E58492D103}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{NumeratorOfGFSElement({\mdseries\slshape gfs, i})\index{NumeratorOfGFSElement@\texttt{NumeratorOfGFSElement}}
\label{NumeratorOfGFSElement}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 integer 



 Returns the numerator of the i-th term of the generalised Farey sequence \mbox{\texttt{\mdseries\slshape gfs}}: for the 1st infinite entry returns -1, for the last one returns 1, for all
other entries returns the usual numerator. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@List([1..5], i -> NumeratorOfGFSElement(GeneralizedFareySequence(fs),i));|
  [ -1, 0, 1, 2, 1 ]
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{DenominatorOfGFSElement}}
\logpage{[ 3, 2, 3 ]}\nobreak
\hyperdef{L}{X87477604878BCD42}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DenominatorOfGFSElement({\mdseries\slshape gfs, i})\index{DenominatorOfGFSElement@\texttt{DenominatorOfGFSElement}}
\label{DenominatorOfGFSElement}
}\hfill{\scriptsize (function)}}\\
\textbf{\indent Returns:\ }
 integer 



 Returns the denominator of the i-th term of the generalised Farey sequence \mbox{\texttt{\mdseries\slshape gfs}}: for both infinite entries returns 0, for the other ones returns the usual
denominator. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@List([1..5], i -> DenominatorOfGFSElement(GeneralizedFareySequence(fs),i));         |
  [ 0, 1, 1, 1, 0 ]
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{LabelsOfFareySymbol}}
\logpage{[ 3, 2, 4 ]}\nobreak
\hyperdef{L}{X83C941047D486000}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{LabelsOfFareySymbol({\mdseries\slshape fs})\index{LabelsOfFareySymbol@\texttt{LabelsOfFareySymbol}}
\label{LabelsOfFareySymbol}
}\hfill{\scriptsize (attribute)}}\\


 Returns the list of labels of the Farey symbol. This list has "odd", "even"
and paired integers as entries. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@LabelsOfFareySymbol(fs);|
  [ 1, 2, 2, 1 ]
  
\end{Verbatim}
 }

 }

 
\chapter{\textcolor{Chapter }{Farey symbols for congruence subgroups}}\label{Gens}
\logpage{[ 4, 0, 0 ]}
\hyperdef{L}{X831C60277F7D80B2}{}
{
  The package \textsf{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({\ensuremath{\mathbb Z}})$ 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({\ensuremath{\mathbb Z}})$ was started by Ravi Kulkarni in \cite{Kulkarni} and later it was improved by Mong-Lung Lang, Chong-Hai Lim and Ser-Peow Tan in \cite{LLT-Hecke}, \cite{LLT-Algorithm}. 
\section{\textcolor{Chapter }{Computation of the Farey symbol for a finite index subgroup}}\label{CompFarey}
\logpage{[ 4, 1, 0 ]}
\hyperdef{L}{X7F43DB8B803F313F}{}
{
  

\subsection{\textcolor{Chapter }{FareySymbol}}
\logpage{[ 4, 1, 1 ]}\nobreak
\hyperdef{L}{X8594896287DCFE8D}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FareySymbol({\mdseries\slshape G})\index{FareySymbol@\texttt{FareySymbol}}
\label{FareySymbol}
}\hfill{\scriptsize (attribute)}}\\


 For a subgroup of a finite index G, this attribute stores one of the Farey
symbols corresponding to the congruence subgroup \mbox{\texttt{\mdseries\slshape G}}. The algorithm for its computation will work for any matrix group for which a
membership test is available. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@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 ]
  !gapprompt@gap>| !gapinput@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 ]  
  
\end{Verbatim}
 }

  
\section{\textcolor{Chapter }{Computation of generators of a finite index subgroup from its Farey symbol}}\label{CompGens}
\logpage{[ 4, 2, 0 ]}
\hyperdef{L}{X80AE179D869BEE90}{}
{
  If \mbox{\texttt{\mdseries\slshape 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=\left( \begin{array}{rr} 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 \end{array} \right) \]
   

 for each odd interval $[x_j,x_{j+1}]$, take the matrix  
\[ B=\left( \begin{array}{rr} 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 \end{array} \right) \]
   

 for each pair of free intervals $[x_k,x_{k+1}]$ and $[x_s,x_{s+1}]$, take the matrix  
\[ \left( \begin{array}{rr} 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} & -a_{k+1} b_{s+1} - a_k b_s \end{array}
\right) \]
   

\subsection{\textcolor{Chapter }{MatrixByEvenInterval}}
\logpage{[ 4, 2, 1 ]}\nobreak
\hyperdef{L}{X8790C1498107A39A}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{MatrixByEvenInterval({\mdseries\slshape gfs, i})\index{MatrixByEvenInterval@\texttt{MatrixByEvenInterval}}
\label{MatrixByEvenInterval}
}\hfill{\scriptsize (function)}}\\


 Returns the matrix corresponding to the even interval i in the generalized
Farey sequence \mbox{\texttt{\mdseries\slshape gfs}}. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@H:=CongruenceSubgroupGamma0(5); |
  <congruence subgroup CongruenceSubgroupGamma_0(5) in SL_2(Z)>
  !gapprompt@gap>| !gapinput@fs:=FareySymbol(H);|
  [ infinity, 0, 1/2, 1, infinity ]
  [ 1, "even", "even", 1 ]
  !gapprompt@gap>| !gapinput@gfs:=GeneralizedFareySequence(fs);|
  [ infinity, 0, 1/2, 1, infinity ]
  !gapprompt@gap>| !gapinput@MatrixByEvenInterval(gfs,2);      |
  [ [ 2, -1 ], [ 5, -2 ] ]
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{MatrixByOddInterval}}
\logpage{[ 4, 2, 2 ]}\nobreak
\hyperdef{L}{X78779BDF7A1DB4AE}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{MatrixByOddInterval({\mdseries\slshape gfs, i})\index{MatrixByOddInterval@\texttt{MatrixByOddInterval}}
\label{MatrixByOddInterval}
}\hfill{\scriptsize (function)}}\\


 Returns the matrix corresponding to the odd interval i in the generalized
Farey sequence \mbox{\texttt{\mdseries\slshape gfs}}. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@fs_oo:=FareySymbolByData([infinity,0,infinity],["odd","odd"]);;|
  !gapprompt@gap>| !gapinput@gfs_oo:=GeneralizedFareySequence(fs_oo);|
  [ infinity, 0, infinity ]
  !gapprompt@gap>| !gapinput@MatrixByOddInterval(gfs_oo,1);|
  [ [ -1, -1 ], [ 1, 0 ] ]
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{MatrixByFreePairOfIntervals}}
\logpage{[ 4, 2, 3 ]}\nobreak
\hyperdef{L}{X7F792846795E3A63}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{MatrixByFreePairOfIntervals({\mdseries\slshape gfs, k, kp})\index{MatrixByFreePairOfIntervals@\texttt{MatrixByFreePairOfIntervals}}
\label{MatrixByFreePairOfIntervals}
}\hfill{\scriptsize (function)}}\\


 Returns the matrix corresponding to the pair of free intervals k and kp in the
generalized Farey sequence \mbox{\texttt{\mdseries\slshape gfs}}. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@fs_free:=FareySymbolByData([infinity,0,1,2,infinity],[1,2,2,1]);;|
  !gapprompt@gap>| !gapinput@gfs_free:=GeneralizedFareySequence(fs_free);;|
  !gapprompt@gap>| !gapinput@MatrixByFreePairOfIntervals(gfs_free,2,3);                                                        |
  [ [ 3, -2 ], [ 2, -1 ] ]
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{GeneratorsByFareySymbol}}
\logpage{[ 4, 2, 4 ]}\nobreak
\hyperdef{L}{X7905B050800E4416}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{GeneratorsByFareySymbol({\mdseries\slshape fs})\index{GeneratorsByFareySymbol@\texttt{GeneratorsByFareySymbol}}
\label{GeneratorsByFareySymbol}
}\hfill{\scriptsize (function)}}\\


 Returns a set of matrices constructed as above. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@fs_eo:=FareySymbolByData([infinity,0,infinity],["even","odd"]);;|
  !gapprompt@gap>| !gapinput@GeneratorsByFareySymbol(last);                                  |
  [ [ [ 0, -1 ], [ 1, 0 ] ], [ [ 0, -1 ], [ 1, -1 ] ] ]
  !gapprompt@gap>| !gapinput@GeneratorsByFareySymbol(fs); |
  [ [ [ 1, 1 ], [ 0, 1 ] ], [ [ 2, -1 ], [ 5, -2 ] ], [ [ 3, -2 ], [ 5, -3 ] ] ]
  !gapprompt@gap>| !gapinput@GeneratorsByFareySymbol(fs_oo);|
  [ [ [ -1, -1 ], [ 1, 0 ] ], [ [ 0, -1 ], [ 1, -1 ] ] ]
  !gapprompt@gap>| !gapinput@GeneratorsByFareySymbol(fs_free);                                                        |
  [ [ [ 1, 2 ], [ 0, 1 ] ], [ [ 3, -2 ], [ 2, -1 ] ] ]
  
\end{Verbatim}
 

\subsection{\textcolor{Chapter }{GeneratorsOfGroup}}
\logpage{[ 4, 2, 5 ]}\nobreak
\hyperdef{L}{X79C44528864044C5}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{GeneratorsOfGroup({\mdseries\slshape G})\index{GeneratorsOfGroup@\texttt{GeneratorsOfGroup}}
\label{GeneratorsOfGroup}
}\hfill{\scriptsize (function)}}\\


 Returns a set of generators for the finite index group G in $SL_2(Z)$. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@G:=PrincipalCongruenceSubgroup(2);|
  <principal congruence subgroup of level 2 in SL_2(Z)>
  !gapprompt@gap>| !gapinput@FareySymbol(G);|
  [ infinity, 0, 1, 2, infinity ]
  [ 2, 1, 1, 2 ]
  !gapprompt@gap>| !gapinput@GeneratorsOfGroup(G);|
  #I  Using the Congruence package for GeneratorsOfGroup ...
  [ [ [ 1, 2 ], [ 0, 1 ] ], [ [ 3, -2 ], [ 2, -1 ] ] ]
  !gapprompt@gap>| !gapinput@H:=CongruenceSubgroupGamma0(5);        |
  <congruence subgroup CongruenceSubgroupGamma_0(5) in SL_2(Z)>
  !gapprompt@gap>| !gapinput@GeneratorsOfGroup(H);|
  #I  Using the Congruence package for GeneratorsOfGroup ...
  [ [ [ 1, 1 ], [ 0, 1 ] ], [ [ 2, -1 ], [ 5, -2 ] ], [ [ 3, -2 ], [ 5, -3 ] ] ]
  !gapprompt@gap>| !gapinput@I:=IntersectionOfCongruenceSubgroups(PrincipalCongruenceSubgroup(2),CongruenceSubgroupGamma0(3));|
  <intersection of congruence subgroups of resulting level 6 in SL_2(Z)>
  !gapprompt@gap>| !gapinput@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 ]
  !gapprompt@gap>| !gapinput@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 ] ] ]
  
\end{Verbatim}
 }

  
\section{\textcolor{Chapter }{Other properties derived from Farey symbols}}\label{CompOther}
\logpage{[ 4, 3, 0 ]}
\hyperdef{L}{X7C5AB1D786207745}{}
{
  

\subsection{\textcolor{Chapter }{IndexInPSL2ZByFareySymbol}}
\logpage{[ 4, 3, 1 ]}\nobreak
\hyperdef{L}{X80EED34183408106}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IndexInPSL2ZByFareySymbol({\mdseries\slshape fs})\index{IndexInPSL2ZByFareySymbol@\texttt{IndexInPSL2ZByFareySymbol}}
\label{IndexInPSL2ZByFareySymbol}
}\hfill{\scriptsize (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. }

 
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
  
  !gapprompt@gap>| !gapinput@IndexInPSL2ZByFareySymbol(fs);|
  6
  !gapprompt@gap>| !gapinput@IndexInPSL2ZByFareySymbol(fs_oo);|
  2
  !gapprompt@gap>| !gapinput@IndexInPSL2ZByFareySymbol(fs_free);|
  6
  
\end{Verbatim}
 }

 }

 
\chapter{\textcolor{Chapter }{Service functions of the \textsf{Congruence} package}}\label{Service}
\logpage{[ 5, 0, 0 ]}
\hyperdef{L}{X7D7997F3819EFFE1}{}
{
  
\section{\textcolor{Chapter }{Additional information displayed by \textsf{Congruence} algorithms}}\label{CongruenceInfoClass}
\logpage{[ 5, 1, 0 ]}
\hyperdef{L}{X786810B87D441B1E}{}
{
  

\subsection{\textcolor{Chapter }{InfoCongruence}}
\logpage{[ 5, 1, 1 ]}\nobreak
\hyperdef{L}{X83B2A8607C2E6A38}{}
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{InfoCongruence\index{InfoCongruence@\texttt{InfoCongruence}}
\label{InfoCongruence}
}\hfill{\scriptsize (info class)}}\\


 \texttt{InfoCongruence} is a special Info class for \textsf{Congruence} algorithms. It has 3 levels: 0, 1 (default) and 2. To change the info level to \texttt{k}, use the command \texttt{SetInfoLevel(InfoCongruence, k)}. 

 In the example below we use this mechanism to see more details during the
Farey symbol construction for a congruence subgroup. }

  }

 }

 \def\bibname{References\logpage{[ "Bib", 0, 0 ]}
\hyperdef{L}{X7A6F98FD85F02BFE}{}
}

\bibliographystyle{alpha}
\bibliography{manual}

\addcontentsline{toc}{chapter}{References}

\def\indexname{Index\logpage{[ "Ind", 0, 0 ]}
\hyperdef{L}{X83A0356F839C696F}{}
}

\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Index}


\printindex

\newpage
\immediate\write\pagenrlog{["End"], \arabic{page}];}
\immediate\closeout\pagenrlog
\end{document}
