# Identifying finite-index subgroups of $SL_2(\mathbb Z)$ from generators

Suppose I have a finite set of elements of the modular group $\operatorname{SL}_2(\mathbf{Z})$. Is there a finite procedure that will determine whether or not the group they generate has finite index, and if so, calculate this index?

Similarly, if the group they generate does have finite index, is there a finite procedure to determine whether some $g \in \operatorname{SL}_2(\mathbf{Z})$ lies in this group?

(Note: This question has been reposted at MathOverflow.)

-
This question seem to be answered at MathOverflow. May we post a CW answer here with a link to MO to remove this question from the unanswered queue? –  Alexander Konovalov Jul 4 '13 at 14:32

Yes, there is an algorithm. First find the intersection $U$ of $H=\langle x_1,..., x_n\rangle$ with the free subgroup of index 12 in $SL_2(\mathbb{Z})$ (the free group has two generators $a,b$). Let it be generated by words $u_1,...,u_m$. Consider the Stallings graph associated with $U$. It is a finite labeled graph where every edge is labeled by $a,b,a^{-1}$ or $b^{-1}$ and no two edges sharing the initial/termnal vertex have the same label. The index is finite if and only if every vertex of that graph has degree 4. See, for example: