††footnotetext:  File: main.tex, printed: 2024-8-27, 19.47

# Geometric deduction of the solutions to modular equations

Md. Shafiul Alam  Graduate School of Information Sciences, Tohoku University,
Aoba-ku, Sendai 980-8579, Japan $-$ and $-$ Department of Mathematics,
University of Barishal, Barishal-8254, Bangladesh<EMAIL_ADDRESS><EMAIL_ADDRESS>and  Toshiyuki Sugawa  Graduate School of Information
Sciences, Tohoku University, Aoba-ku, Sendai 980-8579, Japan
<EMAIL_ADDRESS>
###### Abstract.

In his notebooks, Ramanujan presented without proof many remarkable formulae
for the solutions to generalized modular equations. Much later, proofs of the
formulae were provided by making use of highly nontrivial identities for theta
series and hypergeometric functions. We offer a geometric approach to the
proof of those formulae. We emphasize that our proofs are geometric and
independent of such identities.

###### Key words and phrases:

modular equation, hypergeometric function, Fuchsian group, generalized
complete elliptic integral

###### 2020 Mathematics Subject Classification:

Primary 30F35; Secondary 33C05, 33E05, 30F10.

The first author was supported by Data Sciences Program II of Graduate School
of Information Sciences, Tohoku University. The authors were supported in part
by JSPS KAKENHI Grant Number JP17H02847.

##  1\. Introduction

For given integers $p\geq 2,$ Ramanujan, an Indian mathematical genius,
considered the equation

(1.1)
$\frac{{{}_{2}F_{1}}(a,1-a;1;1-\beta)}{{{}_{2}F_{1}}(a,1-a;1;\beta)}=p\frac{{{}_{2}F_{1}}(a,1-a;1;1-\alpha)}{{{}_{2}F_{1}}(a,1-a;1;\alpha)},$

known as the generalized modular equation of degree $p$ and signature $1/a.$
He left many formulae describing relations between $\alpha$ and $\beta$ in his
unpublished notebooks but he did not record any proof of those formulae (see
[9] and [23]). Here, ${{}_{2}F_{1}}(a,b;c;z)$ denotes the hypergeometric
function whose definition will be given in Section 2. The case when $1/a=2$
corresponds to the classical modular equation. Indeed, the complete elliptic
integral of the first kind is described by

${\mathbf{K}}(r)=\int_{0}^{1}\frac{dx}{\sqrt{(1-x^{2})(1-r^{2}x^{2})}}=\frac{\pi}{2}{{}_{2}F_{1}}(\tfrac{1}{2},\tfrac{1}{2};1;r^{2})$

and the function

$\mu(r)=\frac{\pi}{2}\cdot\frac{{\mathbf{K}}(\sqrt{1-r^{2}})}{{\mathbf{K}}(r)}=\frac{\pi}{2}\cdot\frac{{{}_{2}F_{1}}(\tfrac{1}{2},\tfrac{1}{2};1;1-r^{2})}{{{}_{2}F_{1}}(\tfrac{1}{2},\tfrac{1}{2};1;r^{2})}$

is known to be the modulus of the Grötzsch ring
$\\{z\in{\mathbb{C}}:|z|<1\\}\setminus[0,r]$ for $0<r<1$ and plays an
important role in the theory of plane quasiconformal mappings (see, for
instance, [21] or [5]). The modular equation (1.1) for $1/a=2$ now takes the
form $\mu(s)=p\mu(r)$ with $\alpha=r^{2}$ and $\beta=s^{2}.$ When $p=2,$ the
solution to this modular equation is given by

(1.2)
$s=\frac{1-\sqrt{1-r^{2}}}{1+\sqrt{1-r^{2}}}=\left(\frac{1-\sqrt{1-r^{2}}}{r}\right)^{2}$

(see [21, (2.4) in p. 60] or [5, (5.4)]).

Ramanujan mainly considered the case when the signature $1/a$ is 3, 4 or 6.
See [7], [8], [9], [10], [12] and [22] for his work in relation with the
modular equations. Berndt, Bhargava and Garvan [11] gave proofs for those
formulae of Ramanujan (see also [3]). Their proofs make use of highly
nontrivial identities for Jacobi’s theta functions and hypergeometric
functions in addition to a number of ingeneous ideas. For example, they gave
rigorous proofs for the following results.

######  Theorem 1.3 ([11, Theorem 7.1]).

When $p=2$ and $q=3,$ the solutions $\alpha$ and $\beta$ to the equation (1.1)
are related by

(1.4) $(\alpha\beta)^{1/3}+\big{\\{}(1-\alpha)(1-\beta)\big{\\}}^{1/3}=1.$

######  Theorem 1.5 ([11, Lemma 7.4]).

When $p=3$ and $q=3,$ the solutions $\alpha$ and $\beta$ to the equation (1.1)
are related by

(1.6) $(1-\alpha)^{1/3}=\frac{1-\beta^{1/3}}{1+2\beta^{1/3}}.$

We note that the above relations can be transformed to polynomial equations.
For instance, (1.4) may be transformed to

(1.7)
$(2\alpha-1)^{3}\beta^{3}-3\alpha(4\alpha^{2}-13\alpha+10)\beta^{2}+3\alpha(2\alpha^{2}-10\alpha+9)\beta-\alpha^{3}=0.$

In particular, we observe that there are at most three values of $\beta$
satisfying the modular equation (1.4) for each $\alpha.$ We can say that
$\alpha$ and $\beta$ satisfy a polynomial equation of degree 3 in this case.
It is rather surprising that $\alpha$ and $\beta$ are related algebraically,
because the hypergeometric function is transcendental for the corresponding
parameters. For instance, we do not have a complete answer to the question for
which $p$ and $a$ the solutions to the modular equation (1.1) is algebraic. In
this note, we propose a geometric approach to this problem. In particular, the
geometric observation suggests that it is more natural to look at $q=1/(1-2a)$
rather than the signature $1/a.$ We will call $q$ the _order_ of the modular
equation (1.1). For instance, the signatures $1/a=2,3,4,6$ correspond to
$q=\infty,3,2,3/2,$ respectively. Though our approach does not cover the case
$1/a=6,$ it may allow us to approach other cases when $q$ are integers $>3.$
Let $G_{q}=\langle T,W\rangle$ be the Fuchsian group generated by
$T\tau=\tau+\lambda$ and $W\tau=\tau/(1+\lambda\tau),$ where
$\lambda=2\cos\frac{\pi}{2q}$ and let $M_{p}$ be the Möbius transformation
defined by $M_{p}\tau=p\tau.$ To speak about the solutions to (1.1), we have
to clarify the range of the solutions. Originally, the range of $\alpha$ and
$\beta$ was the interval $[0,1].$ However, in our setting, it is natural to
choose the quotient Riemann surface $X=G_{q}\backslash{\mathbb{H}}$ as the
range of the solutions. Here, we take
$X={\widehat{\mathbb{C}}}\setminus\\{0,1\\}$ for finite $q$ and
$X={\mathbb{C}}\setminus\\{0,1\\}$ for $q=\infty.$ Then we have the following
result.

######  Theorem 1.8.

Let $n,\,p$ and $q$ be integers with $n,\,p,\,q\geq 2$ $($possibly $q=\infty)$
and set $a=(q-1)/(2q).$ Then, the solutions $(\alpha,\beta)$ to the equation
(1.1) in $X=G_{q}\backslash{\mathbb{H}}$ satisfy the equation
$P(\alpha,\beta)=0$ for an irreducible polynomial $P(x,y)$ of degree $n$ if
and only if $G_{q}\cap G_{q}^{M_{p}}$ is a subgroup of $G_{q}$ of index $n,$
where $G_{q}^{M_{p}}=M_{p}^{-1}G_{q}M_{p}.$

As we will see in the proof, the solutions $\alpha$ and $\beta$ are
parametrized as $\alpha=\varphi(z)$ and $\beta=\psi(z)$ on the Riemann surface
$Z=(G_{q}\cap G_{q}^{M_{p}})\backslash{\mathbb{H}}$ and they satisfy the
polynomial equation $P(\alpha,\beta)=0$ of order $n.$ More precisely, $P(x,y)$
has the forms

$\displaystyle P(x,y)$
$\displaystyle=a_{0}(x)y^{n}+a_{1}(x)y^{n-1}+\cdots+a_{n-1}(x)y+a_{n}(x)$
$\displaystyle=b_{0}(y)x^{n}+b_{1}(y)x^{n-1}+\cdots+b_{n-1}(y)x+b_{n}(y),$

where
$a_{j}(x)\in{\mathbb{C}}[x],b_{j}(y)\in{\mathbb{C}}[y]~{}(j=0,1,\dots,n),$
such that $P(x,y)$ is irreducible as an element of ${\mathbb{C}}(x)[y]$ and
${\mathbb{C}}(y)[x],$ respectively. (Recall that ${\mathbb{C}}[x]$ and
${\mathbb{C}}(x)$ stand for the ${\mathbb{C}}$-algebra of polynomials in $x$
and the field of rational functions of $x$ with coefficients in
${\mathbb{C}},$ respectively.)

As applications of it, we will show (1.2) and Theorems 1.3 and 1.5 in Sections
4 and 5. In Section 2, we recall basic facts about hypergeometric functions
and Hecke groups and its subgroup of index 2. Section 3 is devoted to the
statement of our main lemma and its proof. Theorem 1.8 is also proved in
Section 3 with the help of the main lemma. We emphasize that our approach does
not need ingenious ideas as in [11]. Without knowledge about Ramanujan’s
formulae, we can deduce those formulae possibly with laborious computations
only. In this paper, we treat only the case when the Riemann surface $Z$ is
planar. When $Z$ is non-planar, it is technically difficult to find an
explicit form of the polynomial $P(x,y).$ Let $\hat{Z}$ be the
compactification of $Z.$ Since the parametrizations
$\varphi,\psi:\hat{Z}\to{\widehat{\mathbb{C}}}$ are $n$-sheeted covering maps
with critical values contained in $\\{0,1,\infty\\}$ if $|G_{q}:G_{q}\cap
G_{q}^{M_{p}}|=n,$ Belyi’s theorem implies that the compact Riemann surface
$\hat{Z}$ is an algebraic curve defined over $\overline{{\mathbb{Q}}}$ (see
[19]). Therefore, in principle, we could determine the surface $Z$ and maps
$\varphi,\psi$ by the combinatorial information about the coverings. We hope
to give further examples when $Z$ is non-planar in the future work.

Acknowledgement. The authors would like to thank Professor Hiroshige Shiga for
suggestions which simplified the proof of Lemma 3.2 in the early version of
the manuscript. They also thank Professor Matti Vuorinen for many suggestions.

##  2\. Hypergeometric functions and Hecke groups

The hypergeometric function ${{}_{2}F_{1}}(a,b;c;z)$ is defined by

${{}_{2}F_{1}}(a,b;c;z)=\sum_{n=0}^{\infty}\frac{(a)_{n}(b)_{n}}{(c)_{n}n!}z^{n},\quad|z|<1,$

for parameters $a,b,c\in{\mathbb{C}}$ with $c\neq 0,-1,-2,\dots.$ By Euler’s
integral representation formula, we know that ${{}_{2}F_{1}}(a,b;c;z)$
analytically extends to the slit domain ${\mathbb{C}}\setminus[1,+\infty).$
Let $0<a\leq 1/2.$ Then it is classically known [13] that the function

$\tau=f_{a}(z)=i\cdot\frac{{{}_{2}F_{1}}(a,1-a;1;1-z)}{{{}_{2}F_{1}}(a,1-a;1;z)}$

maps the upper half-plane
${\mathbb{H}}=\\{z\in{\mathbb{C}}:{\operatorname{Im}\,}z>0\\}$ onto the domain
$\Delta_{a}=\\{\tau\in{\mathbb{H}}:0<{\operatorname{Re}\,}\tau<\sin\pi
a,|2\tau\sin\pi a-1|>1\\}$ and that $\Delta_{a}$ is the hyperbolic triangle
with vertices at $0,\infty$ and $ie^{-\pi ai}$ of interior angles $0,0$ and
$(1-2a)\pi,$ respectively (see also [4, Lemma 4.1]). Note also that $f_{a}$
extends homeomorphically to the boundary and

(2.1) $f_{a}(0)=\infty,\quad f_{a}(1)=0,\quad f_{a}(\infty)=ie^{-\pi
ai}=e^{\pi i(1-2a)/2}.$

Suppose now that $q=1/(1-2a)$ is an integer or $\infty.$ Let
$\pi_{q}:\Delta_{a}\to{\mathbb{H}}$ be the inverse map $z=f_{a}^{-1}(\tau)$ of
$\tau=f_{a}(z).$ Then, by repeated applications of the Schwarz reflection
principle, $\pi_{q}$ extends to a holomorphic map from ${\mathbb{H}}$ into
${\widehat{\mathbb{C}}}\setminus\\{0,1\\}.$ Here, we note that $\pi_{q}$ is
locally $q$ to 1 at the point $ie^{-\pi ai}.$ By construction, the covering
group
$G_{q}=\\{\gamma\in{\operatorname{Aut}}({\mathbb{H}}):\pi_{q}\circ\gamma=\pi_{q}\\}$
is the triangle group of signature $(q,\infty,\infty)$ arising from the
hyperbolic triangle $\Delta_{a},~{}q=1/(1-2a).$ Here, the group
${\operatorname{Aut}}({\mathbb{H}})$ of analytic automorphism of
${\mathbb{H}}$ is identified with
${\operatorname{PSL}}(2,{\mathbb{R}})={\operatorname{SL}}(2,{\mathbb{R}})/\\{\pm
I\\}.$ Since $G_{q}$ is a subgroup of the Hecke group $H_{2q}$ of index 2, we
recall basics of Hecke groups. See [14] for details about the Hecke groups.
Moreover, we refer to [6] and [20] as general references for Fuchsian groups.

By its form, the function $f_{a}$ satisfies the relation
$f_{a}(1-z)=-1/f_{a}(z).$ Since $\pi_{q}=f_{a}^{-1}$ on $\Delta_{a},$ the
following result follows.

######  Lemma 2.2.

The covering map $\pi_{q}$ satisfies the functional equation

$\pi_{q}(\tau)+\pi_{q}(-1/\tau)=1,\quad\tau\in{\mathbb{H}}.$

For an integer $k\geq 3,$ the Hecke group $H_{k}$ is defined as the discrete
subgroup of ${\operatorname{PSL}}(2,{\mathbb{R}})$ generated by the two
elements $\pm S$ and $\pm T_{k},$ where

$S=\begin{pmatrix}0&-1\\\ 1&0\end{pmatrix},\quad
T_{k}=\begin{pmatrix}1&\lambda_{k}\\\
0&1\end{pmatrix}{\quad\text{and}\quad}\lambda_{k}=2\cos\frac{\pi}{k}.$

See [6] or [14]. Here and in what follows, we often identify a matrix
$A=\begin{pmatrix}a&b\\\ c&d\end{pmatrix}$ with the Möbius transformation
$\tau\mapsto A\tau=(a\tau+b)/(c\tau+d)$ so that $S,T_{k}$ are regarded as
elements of
${\operatorname{Aut}}({\mathbb{H}})={\operatorname{PSL}}(2,{\mathbb{R}}).$
Note that $H_{3}$ is the classical modular group
${\operatorname{PSL}}(2,{\mathbb{Z}}).$ We put

$U_{k}=T_{k}S=\begin{pmatrix}\lambda_{k}&-1\\\ 1&0\end{pmatrix}.$

Then $U_{k}$ is an elliptic element of order $k$ with fixed point at $e^{\pi
i/k}.$ Let $F_{k}$ be the set of points $\tau\in{\mathbb{H}}$ with
$|{\operatorname{Re}\,}\tau|\leq\cos\frac{\pi}{k},|\tau|\geq 1.$ Then $F_{k}$
is a fundamental domain for $H_{k}$ with side pairing transformations
$S,T_{k}.$ (Note that $S$ has a fixed point at $\tau=i.$) In particular, we
see that $H_{k}$ is a triangle group of signature $(2,k,\infty).$

From now on, we restrict ourselves on the case when $k=2q$ is an even number
with $q\geq 2.$ Then $\hat{F}_{q}=F_{2q}\cup S(F_{2q})$ is a fundamental
domain for the (normal) subgroup $G$ of $H_{2q}$ of index 2 generated by

$T_{2q}=\begin{pmatrix}1&\lambda_{2q}\\\
0&1\end{pmatrix}{\quad\text{and}\quad}W_{2q}=S^{-1}T_{2q}^{-1}S=\begin{pmatrix}1&0\\\
\lambda_{2q}&1\end{pmatrix}.$

To adapt with our aim, we modify the fundamental domain as follows. For
$a=(q-1)/(2q),$ let $\tilde{F}_{q}=\Delta_{a}\cup\Delta_{a}^{\prime}$, where
$\Delta_{a}^{\prime}$ is the reflection of $\Delta_{a}$ across the line
${\operatorname{Re}\,}\tau=\sin{\pi a}$. Then, $\tilde{F}_{q}$ serves as a
fundamental domain of $G$, which is the same as $G_{q}$ introduced in
Introduction and the above-defined covering group of $\pi_{q}.$ (This appears
in Example 1.3 of [14].) Note that the element

$V_{q}:=T_{2q}W_{2q}^{-1}=U_{2q}^{2}=\begin{pmatrix}\lambda_{2q}^{2}-1&-\lambda_{2q}\\\
\lambda_{2q}&-1\end{pmatrix}=\begin{pmatrix}\lambda_{q}+1&-\lambda_{2q}\\\
\lambda_{2q}&-1\end{pmatrix}$

is elliptic of order $q$ and that $G_{q}$ is generated by $T_{2q}$ and $V_{q}$
(see Figure 1 and Figure 2). Here, we note the following property.

Figure 1. Fundamental domains of $H_{2q}=\langle T_{2q},S\rangle$ and
$G=\langle T_{2q},W_{2q}\rangle$. Figure 2. Fundamental domain $\tilde{F}_{q}$
of $G_{q}=\langle T_{2q},V_{q}\rangle$.

######  Lemma 2.3.

Let $p,q$ be integers with $p,q\geq 2~{}($where $q$ may be $\infty)$ and let
$K=G_{q}\cap G_{q}^{M_{p}},$ where $M_{p}\tau=p\tau.$ Then
$|G_{q}:K|=|G_{q}^{M_{p}}:K|.$

Proof. If both of the indices are infinite, there is nothing to show. Assume
$n=|G_{q}:K|<\infty.$ Then the hyperbolic area ${\,\operatorname{Area}}(Z)$ of
the Riemann orbifold $Z=K\backslash{\mathbb{H}}$ is computed as (see [6, p.
150] or [20, p. 13])

${\,\operatorname{Area}}(Z)=n{\,\operatorname{Area}}(G_{q}\backslash{\mathbb{H}})=n{\,\operatorname{Area}}(\tilde{F}_{q})=2n(\pi-\pi/q).$

Since $G_{q}^{M_{p}}\backslash{\mathbb{H}}$ has the same hyperbolic area as
$G_{q}\backslash{\mathbb{H}},$ we have

$|G_{q}^{M_{p}}:K|=\frac{{\,\operatorname{Area}}(K\backslash{\mathbb{H}})}{{\,\operatorname{Area}}(G_{q}^{M_{p}}\backslash{\mathbb{H}})}=\frac{{\,\operatorname{Area}}(Z)}{{\,\operatorname{Area}}(G_{q}\backslash{\mathbb{H}})}=n$

as required. When $|G_{q}^{M_{p}}:K|<\infty,$ the same argument works for the
proof. ∎

######  Remark 2.4.

In view of the proof, one can also show that the formula $|G:G\cap
G^{M}|=|G^{M}:G\cap G^{M}|$ holds for a cofinite Fuchsian group $G;$ namely,
if the surface $G\backslash{\mathbb{H}}$ has finite hyperbolic area. However,
this formula is not true in general. For instance, Jørgensen, Marden and
Pommerenke [18] constructed a Fuchsian group $\Gamma$ and its subgroup $G$ of
index 2 such that $G^{M}=M^{-1}GM$ is a proper subgroup of $G$ for some
$M\in\Gamma$ so that $G\cap G^{M}=G^{M}.$ In particular, $|G:G\cap
G^{M}|>|G^{M}:G\cap G^{M}|=1.$

The index $|G_{q}:K|$ can be computed explicitly when $q=3,4,\infty$ (see
[2]). In the present paper, our main concerns are about the limiting case as
$q\to\infty$ and the case of $q=3.$ Those cases will be discussed in Sections
4 and 5, respectively.

##  3\. A result on Fuchsian groups

Let $\Gamma$ be a Fuchsian group acting on the upper half-plane ${\mathbb{H}}$
and $X$ be the quotient Riemann surface $\Gamma\backslash{\mathbb{H}}.$ We
denote by $\pi$ the canonical projection $\pi:{\mathbb{H}}\to X.$ When
$\gamma\in\Gamma$ is a parabolic element with fixed point at
$\tau_{0}\in\partial{\mathbb{H}},$ it is known that $\pi(\tau)$ tends to a
puncture, say $P,$ of $X$ as $\tau\to\tau_{0}$ nontangentially. As a
convention, we will write $\pi(\tau_{0})=P$ in the sequel. A point
$\tau_{0}\in{\mathbb{H}}$ is called a fixed point of an element $\gamma$ of
${\operatorname{PSL}}(2,{\mathbb{R}})$ if $\gamma\tau_{0}=\tau_{0}$ and the
set of fixed points of $\gamma$ in ${\mathbb{H}}$ is denoted by
${\operatorname{Fix}}(\gamma).$ A non-identity element $\gamma$ is called
elliptic if ${\operatorname{Fix}}(\gamma)\neq\emptyset.$ Let
$M\in{\operatorname{PSL}}(2,{\mathbb{R}})={\operatorname{Aut}}({\mathbb{H}})$
such that $M\notin\Gamma.$ Then we consider the number (possibly $\infty$)
defined by

(3.1) $N_{X_{0}}(M,\Gamma)=\sup_{x\in
X_{0}}\\#\\{\pi(M\tau):\tau\in\pi^{-1}(x)\\}.$

for $X_{0}\subset X.$ The next result is our main lemma and it gives a
criterion for finiteness of $N_{X_{0}}(M,\Gamma).$

######  Lemma 3.2.

Let $\Gamma$ be a Fuchsian group and
$M\in{\operatorname{PSL}}(2,{\mathbb{R}})\setminus\Gamma.$ Suppose that
$X_{0}$ is an uncountable subset of the quotient Riemann surface
$X=\Gamma\backslash{\mathbb{H}}.$ Then $N_{X_{0}}(M,\Gamma)<\infty$ if and
only if $\Gamma^{M}:=M^{-1}\Gamma M$ is commensurable with $\Gamma$ in the
sense that $|\Gamma:G|<\infty$ for $G=\Gamma\cap\Gamma^{M}.$ Moreover, in this
case, $N_{X_{0}}(M,\Gamma)=|\Gamma:G|.$

Proof. The “if ” part is almost trivial. Let $N:=|\Gamma:G|<\infty.$ Then we
take $\gamma_{1},\dots,\gamma_{N}\in\Gamma$ so that
$\Gamma=G\gamma_{1}\cup\dots\cup G\gamma_{N}.$ For $x\in X$ and
$\tau_{0}\in\pi^{-1}(x),$ we observe

$M(\pi^{-1}(x))=M\Gamma\tau_{0}=\bigcup_{j=1}^{N}MG\gamma_{j}\tau_{0}=\bigcup_{j=1}^{N}MGM^{-1}\cdot
M\gamma_{j}\tau_{0}.$

Since $MGM^{-1}\subset\Gamma,$ the set $MGM^{-1}\cdot M\gamma_{j}\tau_{0}$ is
projected to the point $\pi(M\gamma_{j}\tau_{0})$ by $\pi.$ Therefore,
$\\#(\pi(M(\pi^{-1}(x))))\leq N.$ Hence, we conclude that

(3.3) $N_{X_{0}}(M,\Gamma)\leq|\Gamma:G|.$

To show the “only if ” part, we assume that $N:=N_{X_{0}}(M,\Gamma)$ is
finite. Let

$E_{1}=\bigcup_{\gamma,\delta}{\operatorname{Fix}}(\gamma^{-1}\delta),$

where $\gamma$ and $\delta$ range over $\gamma\in\Gamma$ and
$\delta\in\Gamma^{M}$ with $\gamma\neq\delta.$ Since each
${\operatorname{Fix}}(\gamma^{-1}\delta)$ contains at most one point, the set
$E_{1}$ is at most countable. Moreover, the set $E=\Gamma\cdot
E_{1}=\\{\gamma\tau:\gamma\in\Gamma,\tau\in E_{1}\\}$ is also at most
countable. Take a point $\tau_{0}$ from the uncountable subset
$\pi^{-1}(X_{0})\setminus E$ of ${\mathbb{H}}$ and fix it. We regard
$G\backslash\Gamma$ as the set of right cosets
$\\{G\gamma:\gamma\in\Gamma\\}.$ As we saw above, each set
$G\gamma\cdot\tau_{0}$ projects to one point $\pi(M\gamma\tau_{0})$ under the
mapping $\pi\circ M:{\mathbb{H}}\to X.$ We now show that the mapping
$\phi:G\backslash\Gamma\to X$ defined by $\phi(G\gamma)=\pi(M\gamma\tau_{0})$
is injective. To this end, we suppose that
$\phi(G\gamma_{1})=\phi(G\gamma_{2})$ for some
$\gamma_{1},\gamma_{2}\in\Gamma.$ Then $M\gamma_{2}\tau_{0}=\gamma
M\gamma_{1}\tau_{0}$ for some $\gamma\in\Gamma.$ It says that
$\gamma_{1}\tau_{0}$ is a fixed point of
$(\gamma_{2}\gamma_{1}^{-1})^{-1}\delta,$ where $\delta=M^{-1}\gamma
M\in\Gamma^{M}.$ Since $\gamma_{1}\tau_{0}\notin E,$ the element
$(\gamma_{2}\gamma_{1}^{-1})^{-1}\delta$ must be the identity, which implies
$\gamma_{2}\gamma_{1}^{-1}=\delta\in\Gamma\cap\Gamma^{M}=G.$ Hence
$G\gamma_{1}=G\gamma_{2}.$

We have seen that $\phi:G\backslash\Gamma\to X$ is injective. On the other
hand, the image $\phi(G\backslash\Gamma)=\pi(M\Gamma\tau_{0})$ consists of at
most $N$ points. Therefore, we obtain

$|\Gamma:G|=\\#(G\backslash\Gamma)\leq N.$

Combining with (3.3), we obtain $|\Gamma:G|=N_{X_{0}}(M,\Gamma)$ as required.
∎

In particular, we see that $N_{X_{0}}(M,\Gamma)$ does not depend on the
uncountable set $X_{0}\subset X.$ Thus we denote by $N(M,\Gamma)$ the common
number $N_{X_{0}}(M,\Gamma).$

We are now ready to prove Theorem 1.8.

Proof of Theorem 1.8. Recall that $a=(q-1)/(2q)$ and $M_{p}\tau=p\tau.$ In
this proof, we will use the notation introduced in Section 2. By definition,
the generalized modular equation (1.1) may be expressed by
$f_{a}(\beta)=pf_{a}(\alpha).$ Therefore, $\alpha$ and $\beta$ in
${\widehat{\mathbb{C}}}\setminus\\{0,1\\}$ satisfy (1.1) if and only if
$\alpha=\pi_{q}(\tau),\beta=\pi_{q}(p\tau)$ for some $\tau\in{\mathbb{H}}.$

First we assume that $\alpha$ and $\beta$ in (1.1) satisfy the algebraic
equation $P(\alpha,\beta)=0,$ where

$P(x,y)=\sum_{j=0}^{n}a_{j}(x)y^{j},\quad
a_{j}(x)\in{\mathbb{C}}[x]~{}(j=0,1,\dots,n),$

is an irreducible polynomial of degree $n$ in ${\mathbb{C}}(x)[y].$ Let
$X_{0}$ be the set of those points $x\in X$ for which $a_{k}(x)\neq 0$ for
some $k.$ Then for a fixed $x_{0}\in X_{0},$ the algebraic equation
$P(x_{0},y)=0$ in $y$ has at most $n$ solutions. Thus we conclude that
$N_{X_{0}}(M_{p},G_{q})\leq n.$ The previous lemma now implies that
$|G_{q}:G_{q}\cap G_{q}^{M_{p}}|\leq n.$ By the irreducibility of $P(x,y),$ we
see that equality holds.

Conversely, we assume that the equality $|G_{q}:K|=n$ holds, where
$K=G_{q}\cap G_{q}^{M_{p}}.$ Note that $|G_{q}^{M_{p}}:K|=n$ by Lemma 2.3. We
denote by $Z$ the quotient Riemann surface $K\backslash{\mathbb{H}}.$ Let
$\rho:{\mathbb{H}}\to Z$ be the canonical projection and let $\varphi:Z\to X$
and $\psi:Z\to X$ be the induced mappings satisfying the relations
$\pi_{q}=\varphi\circ\rho$ and $\pi_{q}\circ M_{p}=\psi\circ\rho,$
respectively. Thus we have the following commutative diagram:

${{\mathbb{H}}}$${{\mathbb{H}}}$${X}$${Z}$${X.}$$\scriptstyle{M_{p}}$$\scriptstyle{\rho}$$\scriptstyle{\pi_{q}}$$\scriptstyle{\pi_{q}}$$\scriptstyle{\psi}$$\scriptstyle{\varphi}$

Note that the solution $(\alpha,\beta)$ to the modular equation (1.1) is now
parametrized by $\alpha=\varphi(z)$ and $\beta=\psi(z)$ for $z\in Z.$ We
denote by $\hat{X}$ and $\hat{Z}$ the compact Riemann surfaces obtained by
filling in the punctures of $X$ and $Z,$ respectively. Note that
${\widehat{\mathbb{C}}}$ can be taken as $\hat{X}.$ Then $\varphi$ and $\psi$
extend to $n$-sheeted branched covering maps of $\hat{Z}$ onto
$\hat{X}={\widehat{\mathbb{C}}}.$ In particular, $\psi$ may be regarded as a
meromorphic function on $\hat{Z}.$ Let $X_{0}$ denote $X$ minus the set of
critical values of $\varphi:Z\to X;$ indeed
$X_{0}={\widehat{\mathbb{C}}}\setminus\\{0,1,\infty\\}$ in this case.
Similarly, $X_{1}$ is defined for $\psi:Z\to X.$ For a point $x_{0}\in X_{0}$
we choose a small disk $U=U(x_{0})$ with $x_{0}\in U\subset X_{0}.$ Let
$s_{j}$ be the elementary symmetric functions of
$\psi\circ\eta_{1},\dots,\psi\circ\eta_{n}$ of degree $j,$ where
$\eta_{1},\dots,\eta_{n}$ are local inverses of $\varphi$ of $U.$ Then for
each $j=1,2,\dots,n,$ all $s_{j}:U(x_{0})\to X$ piece together to one function
and it extends meromorphically to $\hat{X}={\widehat{\mathbb{C}}}$ and $\psi$
satisfies the equation

$\psi^{n}-s_{1}\circ\varphi\cdot\psi^{n-1}+\dots+(-1)^{n-1}s_{n-1}\circ\varphi\cdot\psi+(-1)^{n}s_{n}\circ\varphi=0$

(see [16, Theorem 8.3] for details). Note that each
$s_{j}:{\widehat{\mathbb{C}}}\to{\widehat{\mathbb{C}}}$ is a rational
function. By writing $(-1)^{j}s_{j}(x)=a_{j}(x)/a_{0}(x)$ for polynomials
$a_{0}(x),\dots,a_{n}(x)\in{\mathbb{C}}[x]$ without non-trivial common factor,
we define

$P(x,y)=a_{0}(x)y^{n}+a_{1}(x)y^{n-1}+\dots+a_{n-1}(x)y+a_{n}(x).$

Then $P(\alpha,\beta)=P(\varphi(z),\psi(z))=0$ for $z\in Z.$ Conversely,
suppose that $x_{0}\in X_{0}$ with $a_{0}(x_{0})\neq 0$ and $y_{0}\in X_{1}$
satisfy $P(x_{0},y_{0})=0.$ Let $\varphi^{-1}(x_{0})=\\{z_{1},\dots,z_{n}\\}$
and let $\sigma_{1},\dots,\sigma_{n}$ be the elementary symmetric functions of
$\psi(z_{1}),\dots,\psi(z_{n}).$ Note that $\sigma_{j}=s_{j}(x_{0})$ for
$j=1,\dots,n.$ Then,

$\displaystyle
a_{0}(x_{0})\big{(}y_{0}-\psi(z_{1})\big{)}\cdots\big{(}y_{0}-\psi(z_{n})\big{)}$
$\displaystyle=a_{0}(x_{0})\big{(}y_{0}^{n}-\sigma_{1}y_{0}^{n-1}+\cdots+(-1)^{n}\sigma_{n}\big{)}$
$\displaystyle=\sum_{j=0}^{n}a_{j}(x_{0})y_{0}^{n-j}=P(x_{0},y_{0})=0.$

Hence, $y_{0}=\psi(z_{k})$ for some $k.$ Since
$x_{0}=\varphi(z_{k}),y_{0}=\psi(z_{k}),$ we have shown that the converse is
true. We next show that the polynomial $P(x,y)$ is irreducible in $y$ with
coefficients in ${\mathbb{C}}[x].$ Suppose, on the contrary, that $P(x,y)$
reduces to the product $P_{1}(x,y)P_{2}(x,y)$ of nonconstant polynomials
$P_{1},P_{2}.$ Let $Y_{l}=\\{(x,y)\in X_{0}\times X_{1}:P_{l}(x,y)=0\\}$ for
$l=1,2.$ We claim that $Y_{1}\cap Y_{2}=\emptyset.$ Indeed, if
$(x_{0},y_{0})\in Y_{1}\cap Y_{2},$ then the polynomial
$P(x_{0},y)=P_{1}(x_{0},y)P_{2}(x_{0},y)$ has a multiple zero at $y=y_{0},$
which is impossible because the set $\psi^{-1}(y_{0})$ consists of $n$ points
for $y_{0}\in X_{1}.$ Since $\varphi\times\psi:Z_{0}\to X_{0}\times X_{1}$ is
continuous, where $Z_{0}=\varphi^{-1}(X_{0})\cap\psi^{-1}(X_{1}),$ and $Z_{0}$
is connected, the image $(\varphi\times\psi)(Z_{0})$ is contained in either
$Y_{1}$ or $Y_{2}.$ However, this is impossible. The claim has been shown.

Finally, consider the polynomial $P(x,y)$ in ${\mathbb{C}}(y)[x]$. Then,
$P(x,y)$ is a polynomial in $x$ with coefficients in ${\mathbb{C}}[y],$ and we
may write

$P(x,y)=b_{0}(y)x^{m}+b_{1}(y)x^{m-1}+\cdots+b_{m-1}(y)x+b_{m}(y),\quad
b_{j}[y]\in{\mathbb{C}}[y],$

where $\displaystyle m=\max_{0\leq j\leq n}\deg a_{j}(x).$ Note that
$b_{0}\neq 0.$ Since $\psi:Z\to X$ is $n$-sheeted, as in the case of
$\varphi:Z\to X,$ we can see that $m=n$ and $P(x,y)$ is irreducible in
${\mathbb{C}}(y)[x].$ ∎

Let us summarize the above observations for later use. Suppose that
$K=G_{q}\cap G_{q}^{M_{p}}$ is a subgroup of $G_{q}$ of finite index $n.$ The
intermediate Riemann surface $Z=K\backslash{\mathbb{H}}$ may be used as a
parameter space of the solutions $(\alpha,\beta)$ to (1.1). Indeed, the
solutions are given by $\alpha=\varphi(z),\beta=\psi(z)$ for $z\in Z,$ where
$\varphi,\psi:Z\to X=G_{q}\backslash{\mathbb{H}}$ are (possibly branched)
covering maps satisfying the relations $\varphi(\rho(\tau))=\pi_{q}(\tau)$ and
$\psi(\rho(\tau))=\pi_{q}(p\tau)$ for $\tau\in{\mathbb{H}}.$ Note that
$\varphi$ and $\psi$ extend to the compactifications $\hat{Z}$ to
$\hat{X}={\widehat{\mathbb{C}}}$ as $n$-sheeted branched (analytic) covering
maps. The polynomial $P(x,y)$ whose zero set describes the solutions
$(\alpha,\beta)$ can be computed as in the above proof. The following lemma
helps us to compute $\psi$ when we know about $\varphi.$

######  Lemma 3.4.

Under the assumption of Theorem 1.8, the Möbius transformation
$SM_{p}\tau=-1/(p\tau)$ induces an analytic involution $\omega:Z\to Z$ which
satisfies the relation $\rho\circ SM_{p}=\omega\circ\rho$ and the functional
equation

$\psi=1-\varphi\circ\omega.$

Proof. Let $K=G_{q}\cap G_{q}^{M_{p}}.$ We first note that the Möbius
transformations $S$ and $M_{p}$ satisfy the relation $SM_{p}=M_{p}^{-1}S$ and
thus $M_{p}SM_{p}=S.$ Recall that $S$ normalizes $G_{q};$ namely,
$G_{q}^{S}:=S^{-1}G_{q}S=G_{q}.$ Therefore,

$K^{SM_{p}}=G_{q}^{SM_{p}}\cap(G_{q}^{M_{p}})^{SM_{p}}=G_{q}^{M_{p}}\cap
G_{q}^{M_{p}SM_{p}}=G_{q}^{M_{p}}\cap G_{q}^{S}=K,$

which means that $SM_{p}:{\mathbb{H}}\to{\mathbb{H}}$ descends to an
automorphism $\omega:Z\to Z$ such that $\rho\circ SM_{p}=\omega\circ\rho.$
Since $(SM_{p})^{2}=I,$ we see that $\omega\circ\omega={\operatorname{id}}.$
We recall Lemma 2.2 which says that $\pi_{q}\circ S=1-\pi_{q}.$ Then we
compute

$\psi\circ\omega\circ\rho=\psi\circ\rho\circ SM_{p}=(\pi_{q}\circ M_{p})\circ
SM_{p}=\pi_{q}\circ S=1-\pi_{q}=1-\varphi\circ\rho$

and therefore we have $\psi\circ\omega=1-\varphi.$ Since $\omega$ is an
involution, we obtain the required relation. ∎

######  Remark 3.5.

Since $\omega$ comes from the normalizer of $K,$ $\omega$ is indeed an
automorphism of the Riemann _orbifold_ $K\backslash{\mathbb{H}}.$ In
particular, $\omega$ maps a cone point of angle $2\pi/m$ to another (possibly
the same) cone point of the same angle for an integer $m\geq 2.$

##  4\. Applications to the classical case $q=\infty$

As $q\to\infty,$ the Hecke group $H_{2q}$ converges to the group
$H_{\infty}=\langle S,T_{\infty}\rangle,$ which is a subgroup of the modular
group ${\operatorname{PSL}}(2,{\mathbb{Z}})$ of index 3, where
$T_{\infty}z=z+2.$ At the same time, the subgroup $G_{q}$ converges to the
principal congruence subgroup $\Gamma(2)$ of level 2, which will be denoted by
$G_{\infty}$ in this section. That is to say,

$G_{\infty}=\\{A\in{\operatorname{SL}}(2,{\mathbb{Z}}):A\equiv
I\,{\operatorname{mod}\,}2\\}/\\{\pm I\\}.$

This corresponds to the case when $a=1/2$ in the modular equation (1.1). The
fundamental domain $\tilde{F}_{\infty}$ is described by
$0\leq{\operatorname{Re}\,}\tau\leq 2,|\tau-1/2|\geq 1/2,|\tau-3/2|\geq 1/2$
for $\tau\in{\mathbb{H}}.$ A pair of generators of $G_{\infty}$ are given by

$T=T_{\infty}=\begin{pmatrix}1&2\\\
0&1\end{pmatrix}{\quad\text{and}\quad}V=\begin{pmatrix}3&-2\\\
2&-1\end{pmatrix}.$

Note that $V$ is a parabolic element with fixed point at $\tau=1$ and that
$V(0)=2.$ Also, let

$W=-V^{-1}T=\begin{pmatrix}1&0\\\ 2&1\end{pmatrix}.$

It is well known that $\Gamma(2)=G_{\infty}$ is a Fuchsian group uniformizing
the thrice punctured sphere ${\widehat{\mathbb{C}}}\setminus\\{0,1,\infty\\}$
(see §§3.4-5 in Chapter 7 of [1] and §§4.3 in Chapter 1 of [15], where the
symbol $\lambda$ is used for $\pi_{\infty}$). The canonical projection
$\pi_{\infty}:{\mathbb{H}}\to X$ may be considered to be
$\pi_{\infty}:{\mathbb{H}}\to{\widehat{\mathbb{C}}}\setminus\\{0,1,\infty\\}={\mathbb{C}}\setminus\\{0,1\\}$
with

(4.1)
$\pi_{\infty}(0)=1,\quad\pi_{\infty}(\infty)=0{\quad\text{and}\quad}\pi_{\infty}(1)=\infty$

by (2.1). Let $\rho:{\mathbb{H}}\to Z,\varphi,\psi:Z\to X$ be as in the proof
of Theorem 1.8. Here is a simple but useful observation. The conjugation of a
matrix by the Möbius transformation $M_{p}$ is computed by

$M_{p}^{-1}\begin{pmatrix}a&b\\\ c&d\end{pmatrix}M_{p}=\begin{pmatrix}a&b/p\\\
pc&d\end{pmatrix}.$

Hence, an element $A=\begin{pmatrix}a&b\\\ c&d\end{pmatrix}$ of $G_{\infty}$
is a member of $G_{\infty}^{M_{p}}$ precisely if $c\equiv
0\,(\,{\operatorname{mod}\,}2p).$

###  4.1. Case $p=2$

We first look at the most classical case when $p=2.$ Let $K=G_{\infty}\cap
G_{\infty}^{M_{2}}.$ Then

$A_{1}:=T=\begin{pmatrix}1&2\\\ 0&1\end{pmatrix},\quad
A_{2}:=V^{2}=\begin{pmatrix}5&-4\\\ 4&-3\end{pmatrix},\quad
A_{3}:=V^{-1}TV=\begin{pmatrix}-3&2\\\ -8&5\end{pmatrix}$

are side-paring transformations of the hyperbolic polygon
$F=\tilde{F}_{\infty}\cup V^{-1}(\tilde{F}_{\infty})$ (see Figure 3).

Figure 3. Fundamental domain $F$ of $K=G_{\infty}\cap G_{\infty}^{M_{2}}$.

Therefore, the elements $A_{1},A_{2},A_{3}$ generate a subgroup of
$G_{\infty}$ of index 2. In view of the forms of $A_{j},$ we see that
$A_{j}\in K$ for $j=1,2,3$ and thus we have $K=\langle
A_{1},A_{2},A_{3}\rangle$ and $|G_{\infty}:K|=2.$ It is easy to observe that
the quotient surface $Z=K\backslash{\mathbb{H}}$ is conformally equivalent to
a four-times punctured sphere. Thus we can assume that
$Z={\widehat{\mathbb{C}}}\setminus\\{0,\infty,1,b\\},$ where
$\rho(0)=0,\rho(1)=\infty,\rho(\infty)=1,\rho(1/2)=b.$ In view of (4.1), we
have the conditions
$\varphi(0)=1,\varphi(\infty)=\infty,\varphi(1)=\varphi(b)=0.$ Here we used
the fact that $1/2$ is conjugate to $\infty$ under the action of $G_{\infty}.$
We note that the extension
$\varphi:\hat{Z}={\widehat{\mathbb{C}}}\to\hat{X}={\widehat{\mathbb{C}}}$ is a
rational map of degree 2. Since
$\varphi^{-1}(1)=\\{0\\},\varphi^{-1}(\infty)=\\{\infty\\},$ we see that
$\varphi$ takes the values $0$ and $\infty$ with multiplicity 2. Therefore,
$\varphi$ should have the form $\varphi(z)=cz^{2}+1$ for a constant $c\neq 0.$
Since $\varphi(1)=0,$ we conclude that $c=-1$ and $b=-1.$ Hence,
$\varphi(z)=1-z^{2}$ under the above normalization.

Next we determine the form of $\psi:Z\to X.$ By the relation
$\pi_{\infty}(2\tau)=\psi(\rho(\tau)),$ we have the necessary conditions
$\psi(0)=\pi_{\infty}(0)=1,\psi(\infty)=\pi_{\infty}(2)=\pi_{\infty}(0)=1,\psi(1)=\pi_{\infty}(\infty)=0$
and $\psi(-1)=\pi_{\infty}(1)=\infty.$ In particular,
$\psi^{-1}(0)=\\{1\\},\psi^{-1}(\infty)=\\{-1\\}.$ Since
$\psi:\hat{Z}={\widehat{\mathbb{C}}}\to\hat{X}={\widehat{\mathbb{C}}}$ is a
rational map of degree 2, $\psi$ has the form

$\psi(z)=\frac{c(z-1)^{2}}{(z+1)^{2}}$

for a constant $c\neq 0.$ Since $\psi(0)=1,$ we have $c=1.$ We note that
$\psi(\infty)=1$ is also satisfied. In this way, the solution $(\alpha,\beta)$
of the modular equation (1.1) with $a=1/2,p=2$ is parametrized by

$\alpha=\varphi(z)=1-z^{2}{\quad\text{and}\quad}\beta=\psi(z)=\frac{(z-1)^{2}}{(z+1)^{2}}.$

Eliminating the variable $z,$ we see that

$\beta=\left(\frac{1-\sqrt{1-\alpha}}{1+\sqrt{1-\alpha}}\right)^{2},$

which is equivalent to (1.2) with $\alpha=r^{2}$ and $\beta=s^{2}.$ The
polynomial in Theorem 1.8 is given by

$P(x,y)=x^{2}y^{2}-2(x^{2}-8x+8)y+x^{2}.$

In this case, the polynomial is not symmetric in $x$ and $y.$

###  4.2. Case $p=3$

Next we consider the case when $p=3.$ We now consider the hyperbolic 10-gon
$F=\tilde{F}_{\infty}\cup V(\tilde{F}_{\infty})\cup
V^{-1}(\tilde{F}_{\infty})\cup W(\tilde{F}_{\infty})$ with vertices at
$0,1/3,2/5,1/2,2/3,1,4/3,$ $3/2,2,\infty$ in the counterclockwise order. Then
the elements

$\displaystyle A_{1}$ $\displaystyle:=T,\quad
A_{2}:=V^{-1}T^{2}V^{-1}=\begin{pmatrix}5&-8\\\ 12&-19\end{pmatrix},\quad
A_{3}:=V^{-1}T^{-1}V^{-1}=\begin{pmatrix}-7&10\\\ -12&17\end{pmatrix},\quad$
$\displaystyle A_{4}$ $\displaystyle:=V^{-3}=\begin{pmatrix}-5&6\\\
-6&7\end{pmatrix},\quad A_{5}:=V^{-1}TV^{-1}T^{-1}V=\begin{pmatrix}-5&2\\\
-18&7\end{pmatrix}$

form side-pairing transformations of $F$ (see Figure 4).

Figure 4. Fundamental domain $F$ of $K=G_{\infty}\cap G_{\infty}^{M_{3}}$.

Therefore, $K=\langle A_{1},A_{2},A_{3},A_{4},A_{5}\rangle$ is a subgroup of
$G_{\infty}$ for which $F$ is a fundamental domain. In view of the forms of
$A_{j},$ we observe that $K\subset G_{\infty}\cap G_{\infty}^{M_{3}}.$ On the
other hand, the elements $V,V^{-1},W$ are not contained in
$G_{\infty}^{M_{3}},$ therefore $K=G_{\infty}\cap G_{\infty}^{M_{3}}$ and
$|G_{\infty}:K|=4.$ It is a simple task to see that the quotient surface
$Z=K\backslash{\mathbb{H}}$ is a six-times punctured sphere. Recall that
$\varphi,\psi:Z\to X$ extend to rational functions of degree 4. We may
normalize the punctures so that
$\rho(\infty)=0,\rho(0)=\rho(2/5)=\rho(2)=1,\rho(1/3)=\infty,\rho(1/2)=\rho(3/2)=b,\rho(1)=c,\rho(2/3)=\rho(4/3)=d.$
Thus $\varphi(0)=\pi_{\infty}(\infty)=0.$ Similarly, we obtain
$\varphi(1)=1,\varphi(\infty)=\infty,\varphi(b)=0,\varphi(c)=\infty,\varphi(d)=1.$
We have to compute multiplicities of these values. For instance, we have
$\varphi^{-1}(\infty)=\\{\infty,c\\}.$ The part of the basic fundamental
domain $\tilde{F}_{\infty}$ corresponding to $\infty$ under $\pi_{\infty}$ is
the cusp neighbourhood
$D=\tilde{F}_{\infty}\cap\\{\tau\in{\mathbb{H}}:|\tau-1|<{\varepsilon}\\}$ for
a small enough ${\varepsilon}>0.$ Since $V$ and $V^{-1}$ fix $1$ while $W$
sends $1$ to $1/3,$ the multiplicity of $\varphi$ at $\rho(1)=c$ is 3 and that
is 1 at $\rho(1/3)=\infty.$ We write $(\varphi)_{\infty}=3\cdot
c+1\cdot\infty$ as a divisor for short111When the equation $\varphi(z)=w$ has
solutions $z_{j}$ with multiplicities $m_{j}$ for $j=1,2,\dots,N,$ we write
$(\varphi)_{w}=m_{1}\cdot z_{1}+m_{2}\cdot z_{2}+\cdots+m_{N}\cdot z_{N}$ as a
divisor on $Z$.. In the same way, we have $(\varphi)_{0}=3\cdot b+1\cdot 0$
and $(\varphi)_{1}=1\cdot d+3\cdot 1.$ In particular, $\varphi$ may be
expressed by

$\varphi(z)=e\frac{z(z-b)^{3}}{(z-c)^{3}}{\quad\text{and}\quad}\varphi(z)-1=e^{\prime}\frac{(z-d)(z-1)^{3}}{(z-c)^{3}}$

for constants $e$ and $e^{\prime}.$ Since $b,c,d$ are different from $1,$ we
have the unique solution $b=-2,c=-1/2,d=-1$ and $e=e^{\prime}=1/8.$ Hence,

$\alpha=\varphi(z)=\frac{z(z+2)^{3}}{(2z+1)^{3}}.$

Next we determine the form of $\omega$ given in Lemma 3.4. Since $SM_{3}$
swaps $0$ and $\infty$ (respectively $1/3$ and $-1$), $\omega$ swaps
$\rho(0)=1$ and $\rho(\infty)=0$ (respectively, $\rho(1/3)=\infty$ and
$\rho(-1)=\rho(1)=-1/2$). Hence, $\omega(z)=(1-z)/(1+2z).$ By Lemma 3.4, we
obtain

$\beta=\psi(z)=1-\varphi(\omega(z))=\frac{z^{3}(z+2)}{2z+1}.$

We compute

$\alpha\beta=\frac{z^{4}(z+2)^{4}}{(2z+1)^{4}}{\quad\text{and}\quad}(1-\alpha)(1-\beta)=\frac{(1-z^{2})^{4}}{(2z+1)^{4}}.$

Note that $\varphi$ and $\psi$ both map the interval $[0,1]$ onto itself
homeomorphically. Hence, for $\alpha,\beta\in[0,1],$ we obtain the relation

(4.2) $(\alpha\beta)^{1/4}+\big{\\{}(1-\alpha)(1-\beta)\big{\\}}^{1/4}=1.$

This is known as Legendre’s modular equation (see (5.37) in [5] and (4.1.16)
in [12]). Formula (4.2) may be transformed to the polynomial equation
$P(\alpha,\beta)=0$ as in Theorem 1.8, where

$P(x,y)=y^{4}+2x^{3}y^{3}-2xy-x^{4}.$

This is known as the modular equation of third order in Jacobi’s form (see
(3.42) in [24]).

##  5\. Case of degree $3$ in the theory of signature $3$

When $q=3,$ the standard generators of $G_{3}$ are

$T:=T_{6}=\begin{pmatrix}1&\sqrt{3}\\\
0&1\end{pmatrix}{\quad\text{and}\quad}V:=V_{3}=\begin{pmatrix}2&-\sqrt{3}\\\
\sqrt{3}&-1\end{pmatrix}.$

Recall that $V$ is an elliptic element of order 3 with fixed point at
$\tau_{0}:=e^{\pi i/6}=(\sqrt{3}+i)/2.$ Recall also that the canonical
projection $\pi_{3}:{\mathbb{H}}\to
X={\widehat{\mathbb{C}}}\setminus\\{0,1\\}$ satisfies

(5.1)
$\pi_{3}(0)=1,\quad\pi_{3}(\infty)=0{\quad\text{and}\quad}\pi_{3}(\tau_{0})=\infty$

by (2.1). The following result is useful.

######  Lemma 5.2.

$A\in{\operatorname{PSL}}(2,{\mathbb{R}})$ belongs to $G_{3}$ precisely when
$A$ is represented by a matrix of the form

(5.3) $\begin{pmatrix}a&b\sqrt{3}\\\ c\sqrt{3}&d\end{pmatrix},\quad
a,b,c,d\in{\mathbb{Z}},~{}ad-3bc=1.$

Proof. We denote by $G$ the Möbius transformations represented by the matrices
in (5.3). Then it is well known that $G$ is a proper subgroup of $H_{6}$ (see
[17]). On the other hand, it is obvious that $G_{3}$ is contained in $G.$
Since $|H_{6}:G_{3}|=2,$ we have $G=G_{3}$ as required. ∎

###  5.1. Case $p=3$

Since the case of $p=3$ is simpler than that of $p=2,$ we start with this
case. Let $F=\tilde{F}_{3}\cup V(\tilde{F}_{3})\cup V^{2}(\tilde{F}_{3}).$
Then $F$ is a hyperbolic polygon with six vertices at
$0,\sqrt{3}/3,\sqrt{3}/2,2\sqrt{3}/3,\sqrt{3},\infty.$ Let $K$ be the group
generated by the side pairing transformations

$A_{1}=T,\quad A_{2}=VTV^{-1}=\begin{pmatrix}-5&4\sqrt{3}\\\
-3\sqrt{3}&7\end{pmatrix},\quad A_{3}=V^{-1}TV=\begin{pmatrix}-2&\sqrt{3}\\\
-3\sqrt{3}&4\end{pmatrix}$

of $F$ (see Figure 5).

Figure 5. Fundamental domain $F$ of $K=G_{3}\cap G_{3}^{M_{3}}$.

It is easy to see that $K=G_{3}\cap G_{3}^{M_{3}}$ by Lemma 5.2 and that $K$
is torsion-free and satisfies $|G_{3}:K|=3.$ Since the quotient surface
$Z=K\backslash{\mathbb{H}}$ is a four-times punctured sphere, we may normalize
$\rho:{\mathbb{H}}\to Z$ so that
$\rho(\infty)=1,\rho(\sqrt{3}/3)=a,\rho(2\sqrt{3}/3)=b,\rho(0)=\rho(\sqrt{3}/2)=\rho(\sqrt{3})=0$
and $\rho(\tau_{0})=\infty.$ By the form of $K,$ the element $V$ normalizes
$K;$ that is, $V^{-1}KV=K.$ Thus $V$ induces an analytic automorphism $v:Z\to
Z.$ We recall that $V$ is a rotation about $\tau_{0}$ of angle $-2\pi/3.$ It
is clear that $v(0)=0$ and $v(\infty)=\infty.$ Since $V$ satisfies
$V(\infty)=2\sqrt{3}/3,V(2\sqrt{3}/3)=\sqrt{3}/3$ and $V(\sqrt{3}/3)=\infty,$
the map $v$ should have the form $v(z)=e^{-2\pi i/3}z.$ Hence, $b=e^{-2\pi
i/3}=-(1+i\sqrt{3})/2$ and $a=\bar{b}=(-1+i\sqrt{3})/2.$ We will determine the
forms of rational maps
$\varphi,\psi:\hat{Z}={\widehat{\mathbb{C}}}\to\hat{X}={\widehat{\mathbb{C}}}$
of degree 3. Since $\varphi$ has a branch point at $\infty$ of order 3, we
have $\varphi^{-1}(\infty)=\\{\infty\\}.$ In particular, $\varphi$ is a
polynomial of degree 3. We also have $\varphi^{-1}(1)=\\{0\\}.$ Therefore,
$\varphi$ should be of the form $1+cz^{3}$ for a constant $c.$ Since
$\varphi(1)=\pi_{3}(\infty)=0,$ we obtain $c=-1.$ Next we determine $\omega$
in Lemma 3.4. Since $SM_{3}$ swaps $0$ and $\infty$ (respectively $\sqrt{3}/3$
and $-\sqrt{3}/3\equiv 2\sqrt{3}/3~{}(\,{\operatorname{mod}\,}K),$ $\omega$
swaps $1$ and $0$ (respectively, $a$ and $b$), Hence, after some computations,
we get the form $\omega(z)=(1-z)/(1+2z).$ We now apply Lemma 3.4 to obtain
$\psi(z)=1-\varphi(\omega(z))=\omega(z)^{3}=(1-z)^{3}/(1+2z)^{3}.$ In summary,
we have

$\alpha=\varphi(z)=1-z^{3}{\quad\text{and}\quad}\beta=\psi(z)=\frac{(1-z)^{3}}{(1+2z)^{3}}.$

We are now able to show Theorem 1.5 easily. The polynomial $P(x,y)$ in Theorem
1.8 is computed as

$\displaystyle P(x,y)$
$\displaystyle=(8x-9)^{3}y^{3}+3\left(64x^{3}+504x^{2}-1053x+486\right)y^{2}$
$\displaystyle\quad+3\left(8x^{3}-171x^{2}+405x-243\right)y+x^{3}.$

###  5.2. Case $p=2$

Let $F$ be the same as in the previous subsection. We choose side-pairing
transformations $A_{1},A_{2},A_{3}$ of $F$ at this time as follows:

$A_{1}=T,\quad A_{2}=V^{2}TV^{2}=\begin{pmatrix}1&-\sqrt{3}\\\
2\sqrt{3}&-5\end{pmatrix},\quad
A_{3}=(SV)^{-1}TSV=\begin{pmatrix}5&-3\sqrt{3}\\\ 4\sqrt{3}&-7\end{pmatrix}.$

Then $A_{1},A_{2}$ and $A_{3}$ generate the torsion-free group $K=G_{3}\cap
G_{3}^{M_{2}}$ and the relation $|G_{3}:K|=3$ follows (see Figure 6).

Figure 6. Fundamental domain $F$ of $K=G_{3}\cap G_{3}^{M_{2}}$.

We also see that $Z=K\backslash{\mathbb{H}}$ is a four-times punctured sphere.
We normalize the map $\rho:{\mathbb{H}}\to Z$ so that
$\rho(\infty)=0,\rho(0)=\rho(\sqrt{3})=1$ and $\rho(\tau_{0})=-1.$ Let
$b=\rho(\sqrt{3}/3)=\rho(2\sqrt{3}/3)$ and $c=\rho(\sqrt{3}/2).$ Since
$\pi_{3}(\tau)=\varphi(\rho(\tau))$ has a branch point of order 3 at
$\tau=\tau_{0},$ the map $\varphi(z)$ has a branch point of order 3 at $z=-1;$
that is, $\varphi^{-1}(\infty)=\\{-1\\}.$ Since
$V(\infty)=2\sqrt{3}/3,V^{2}(\infty)=\sqrt{3}/3,$ we have
$(\varphi)_{0}=1\cdot 0+2\cdot b.$ Therefore, the rational map $\varphi$ of
degree $3$ should have the form

$\varphi(z)=\frac{mz(z-b)^{2}}{(z+1)^{3}}$

for a constant $m\neq 0.$ Observe that $V(\tilde{F}_{3})$ and
$V^{2}(\tilde{F}_{3})$ share the cusps at $\sqrt{3}$ and $0,$ respectively,
with $\tilde{F}_{3}.$ Hence, we see that $(\varphi)_{1}=2\cdot 1+1\cdot c$ and

$\varphi(z)-1=\frac{m^{\prime}(z-c)(z-1)^{2}}{(z+1)^{3}}$

for a constant $m^{\prime}\neq 0.$ Then we have $b=-3,c=-2,m=1/2$ and
$m^{\prime}=-1/2$ so that $\varphi(z)=z(z+3)^{2}/[2(z+1)^{3}].$ Next we will
determine $\omega$ in Lemma 3.4. Since $SM_{2}$ swaps $0$ and $\infty$
(respectively, $\sqrt{3}/3$ and
$-\sqrt{3}/2\equiv\sqrt{3}/2\,{\operatorname{mod}\,}K$), $\omega$ swaps $1$
and $0$ (respectively, $b=-3$ and $c=-2$), the form of $\omega$ is
$(1-z)/(1+z).$ Now Lemma 3.4 yields
$\psi(z)=1-\varphi(\omega(z))=z^{2}(z+3)/4.$ We summarize the results as

$\alpha=\varphi(z)=\frac{z(z+3)^{2}}{2(z+1)^{3}}{\quad\text{and}\quad}\beta=\psi(z)=\frac{z^{2}(z+3)}{4}.$

We remark that these expressions of $\alpha$ and $\beta$ are found in
Ramanujan’s notebook (see [11, Theorem 6.1]). Since

$\alpha\beta=\frac{z^{3}(z+3)^{3}}{8(z+1)^{3}}{\quad\text{and}\quad}(1-\alpha)(1-\beta)=\frac{(1-z)^{3}(z+2)^{3}}{8(z+1)^{3}},$

it is now easy to obtain the formula in Theorem 1.3. We also obtain the
polynomial $P(x,y)$ in Theorem 1.8 as

$P(x,y)=(2x-1)^{3}y^{3}-3x(4x^{2}-13x+10)y^{2}+3x(2x^{2}-10x+9)y-x^{3},$

which is equivalent to (1.4).

## References

  * [1] L. V. Ahlfors, _Complex Analysis, 3rd ed._ , McGraw Hill, New York, 1979.
  * [2] Md. S. Alam, _On Ramanujan’s modular equations and Hecke groups_ , Preprint (2021).
  * [3] G. D. Anderson, S.-L. Qiu, M. K. Vamanamurthy, and M. Vuorinen, _Generalized elliptic integrals and modular equations_ , Pacific J. Math. 192 (2000), 1–37.
  * [4] G. D. Anderson, T. Sugawa, M. K. Vamanamurthy, and M. Vuorinen, _Hyperbolic metric on the twice punctured sphere with one conic singularity_ , Math. Z. 266 (2010), 181–191.
  * [5] G. D. Anderson, M. K. Vamanamurthy, and M. K. Vuorinen, _Conformal Invariants, Inequalities, and Quasiconformal Maps_ , Wiley-Interscience, 1997.
  * [6] A. F. Beardon, _The Geometry of Discrete Groups_ , Graduate Texts in Mathematics 91, Springer-Verlag, New York, 1983.
  * [7] B. C. Berndt, _Ramanujan’s Notebooks, Part I_ , Springer-Verlag, New York, 1985\.
  * [8] B. C. Berndt, _Ramanujan’s Notebooks, Part II_ , Springer-Verlag, New York, 1989\.
  * [9] B. C. Berndt, _Ramanujan’s Notebooks, Part III_ , Springer-Verlag, New York, 1991\.
  * [10] B. C. Berndt, _Ramanujan’s Notebooks, Part V_ , Springer-Verlag, New York, 1998\.
  * [11] B. C. Berndt, S. Bhargava, and F. G. Garvan, _Ramanujan’s theories of elliptic functions to alternative bases_ , Trans. Amer. Math. Soc. 347 (1995), 4163–4244.
  * [12] J. M. Borwein and P. B. Borwein, _Pi and the AGM_ , Wiley, New York, 1987\.
  * [13] C. Carathéodory, _Funktionentheorie. Band II_ , Birkhäuser Verlag, Basel, 1950.
  * [14] İ. N. Cangül and D. Singerman, _Normal subgroups of Hecke groups and regular maps_ , Math. Proc. Camb. Phil. Soc. 123 (1998), 59–74.
  * [15] H. M. Farkas and I. Kra, _Theta Constants, Riemann Surfaces and the Modular Group_ , Graduate Studies in Mathematics, vol. 37, American Mathematical Society, 2001.
  * [16] O. Forster, _Lectures on Riemann Surfaces_ , Springer-Verlag, New York, 1981\.
  * [17] J. I. Hutchinson, _On a class of automorphic functions_ , Trans. Amer. Math. Soc. 3 (1902), 1–11.
  * [18] T. Jørgensen, A. Marden, and C. Pommerenke, _Two examples of covering surfaces_ , Riemann surfaces and related topics: Proceedings of the 1978 Stony Brook Conference (State Univ. New York, Stony Brook, N.Y., 1978), Ann. of Math. Stud., vol. 97, Princeton Univ. Press, Princeton, N.J., 1981, pp. 305–317.
  * [19] G. A. Jones and J. Wolfart, _Dessins d’Enfants on Riemann Surfaces_ , Springer, New York, 2016.
  * [20] S. Katok, _Fuchsian Groups_ , The University of Chicago Press, Chicago and London, 1992.
  * [21] O. Lehto and K. I. Virtanen, _Quasiconformal Mappings in the Plane, 2nd Ed._ , Springer-Verlag, 1973.
  * [22] S. Ramanujan, _Notebooks (2 volumes)_ , Tata Institute of Fundamental Research, Bombay, 1957.
  * [23] S. Ramanujan, _The lost notebook and other unpublished papers_ , Narosa, New Delhi, 1988.
  * [24] R. Roy, _Elliptic and Modular Functions from Gauss to Dedekind to Hecke_ , Cambridge University Press, 2017.


# Understanding Game-Playing Agents with Natural Language Annotations

Nicholas Tomlin Andre He Dan Klein
Computer Science Division, University of California, Berkeley
{nicholas_tomlin, andre.he<EMAIL_ADDRESS>
###### Abstract

We present a new dataset containing 10K human-annotated games of Go and show
how these natural language annotations can be used as a tool for model
interpretability. Given a board state and its associated comment, our approach
uses linear probing to predict mentions of domain-specific terms (e.g., ko,
atari) from the intermediate state representations of game-playing agents like
AlphaGo Zero. We find these game concepts are nontrivially encoded in two
distinct policy networks, one trained via imitation learning and another
trained via reinforcement learning. Furthermore, mentions of domain-specific
terms are most easily predicted from the later layers of both models,
suggesting that these policy networks encode high-level abstractions similar
to those used in the natural language annotations.

##  1 Introduction

Figure 1: Example comment from our dataset, with domain-specific keywords
(shape, sente) highlighted. Although this comment is from a 9 $\times$ 9 game
for illustrative purposes, our dataset primarily focuses on annotations from
19 $\times$ 19 games.

(a) Cut

(b) Eyes

(c) Ladder

(d) Wall

Figure 2: Example Go patterns and associated terminology. (a) Cuts are moves
that separate two groups of stones. (b) Eyes are empty squares surrounded by
stones of the same color. (c) Ladders are capturing races which may span the
entire board. (d) Walls are lines of adjacent stones of the same color. These
terms appear frequently in our dataset of natural language annotations and are
further defined in the appendix.

Go is fundamentally a game of pattern recognition: from ladders and walls to
sente and shape, professional players rely on a rich set of concepts to
communicate about structures on the game board. Some patterns are relatively
simple: walls are lines of adjacent stones, and an atari is a threat to
capture stones on the next move; other patterns are less clearly defined: hane
refers to any move that “goes around” the opponent’s stones, and sente
describes a general state of influence or tempo. Despite the nebulous
definitions of some of these terms, human players use them productively.
Beginners learn about eyes that determine when groups of stones are alive or
dead and are given guidelines for when they should play a cut or extend a
ladder; more advanced players learn sequences of joseki and tesuji and are
taught to distinguish good shape from bad shape. Figures 1-2 depict some
example concepts.

Computers have recently surpassed human performance at Go (Silver et al.,
2016), but relatively little is known about why these programs perform so well
and whether they rely on similar representational units to choose the moves
they play. While post-hoc behavioral analyses suggest that AlphaGo and its
successor AlphaGo Zero (Silver et al., 2017) can process complex game
situations involving shape, capturing races, sente, tesuji, and even ladders,
existing interpretability work has focused on the moves that agents play,
rather than the internal computations responsible for those moves. Our work
instead proposes a structural analysis by correlating the internal
representations of game-playing agents with information from a naturally-
occurring dataset of move-by-move annotations.

In this paper, we use linear probing to explore how domain-specific concepts
are represented by game-playing agents. Because we do not have ground-truth
labels explaining which concepts are relevant to a given game state, we
collect a dataset of 10K annotated Go games (§2.1). Given a board state and
its associated comment, we produce binary feature vectors summarizing which
game phenomena (e.g., ko, atari) are mentioned in the comment and use pattern-
based feature extractors to determine which phenomena are actually present on
the board (§2.2). We then feed board states into two policy networks with
disparate architectures and training methods (§3.1) to obtain intermediate
representations. Finally, we use linear probes (§3.2) to predict the binary
feature vectors from our policy networks. Generally, we find that pattern-
based features are encoded in the early layers of policy networks, while
natural language features are most easily extracted from the later layers of
both models. We release our code and data at https://github.com/andrehe02/go.

##  2 Dataset

Figure 3: Results for the imitation learning and reinforcement learning agents
are highly correlated. (Left) Scatterplot of ROC AUC values for linear probes
trained to predict the presence of domain-specific keywords in move-by-move
annotations. Keywords but not control words are predictable from the
intermediate layers of both models. Words to the left of the solid line
($y=x$) are better predicted from the reinforcement learning model. (Right)
Kernel density estimates showing where information is best represented in the
policy networks (cf. §3.3). For both policy networks, pattern-based features
are encoded in early layers, while keyword-based features are most easily
extracted from later layers. Layer 0 denotes the input board representation
for both models.

###  2.1 Annotated Games

We collect 10K games with move-by-move English annotations from the Go
Teaching Ladder (GTL).111https://gtl.xmp.net The GTL was created by Jean-loup
Gailly and Bill Hosken in 1994 and maintained until 2016 and permits non-
commercial digital redistribution. Until 2016, members of the GTL could submit
games for review by volunteers, who ranged from amateur to professional
strength. Reviewers were given annotation guidelines and required to have a
higher rating than their assigned reviewees, resulting in high quality natural
language data. Of the collected games, we focus on 9524 which were played on
classical $19\times 19$ boards; many games also include unplayed analysis
variations which we do not use in this work. These 9524 games contain 458,182
total comments, with a median length of 14 words.

###  2.2 Feature Extraction

We convert board states and comments into binary feature vectors using two
methods: (1) pattern-based feature extraction, which checks for the ground
truth presence of features from the board state, and (2) keyword-based feature
extraction, which converts comments into bag-of-words representations based on
domain-specific keywords.

#### Pattern-Based

We define a set of rules to determine which game phenomena are present in a
given board state, including: cuts, eyes, ladders, and walls. For example, we
decide that a wall is present when four stones of the same color are placed in
a row adjacent to one another. Because patterns like wall and cut are often
imprecisely defined, these definitions may not align perfectly with player
intuitions; we therefore provide additional details for each phenomena in the
appendix. We do not attempt to write rule-based definitions of vaguer concepts
like sente and influence.

#### Keyword-Based

We scrape an online vocabulary of domain-specific
terminology222https://senseis.xmp.net/?GoTerms and find the 30 most common
terms in our natural language annotations. We then convert each comment into a
30-dimensional binary feature vector representing whether or not it contains
these keywords; we additionally include features based on 60 control words,
chosen according to frequency statistics, which are further subdivided into
function and content words. Our wordlist and details about our selection of
control words can be found in the appendix.

Having both pattern-based and keyword-based features captures a trade-off
between precision and coverage. Writing rules for pattern-based features is
labor-intensive and essentially impossible for many game concepts. Meanwhile,
keyword-based features are inherently noisy: comments often mention phenomena
which didn’t actually occur in the game, and common structures like atari and
eyes are frequently left unmentioned because the annotator and players already
know they exist. Nonetheless, we find that probes are capable of predicting
the presence of domain-specific keywords with significantly better-than-chance
accuracy.

##  3 Methods

###  3.1 Policy Networks

We analyze two agents: (1) an imitation learning agent using the architecture
described in Clark and Storkey (2015), and (2) a pre-trained ELF OpenGo model
(Tian et al., 2017, 2019), which is an open-source, reinforcement learning
agent similar to AlphaGo Zero (Silver et al., 2017). Our imitation learning
model was trained on 228,000 games and achieved a rating of 1K ($\approx$ 1900
ELO) on the Online Go Server (OGS),333https://online-go.com where it played
against a combination of humans and computers until its rating stabilized. ELF
OpenGo reports a self-play ELO over 5000, but this metric is inflated (Tian et
al., 2019). Although we refer to these agents by their training procedure
(i.e., imitation vs. reinforcement), there are several other differences
between the models. One possible source of variance between agents involves
the format of the board state representation. Following Clark and Storkey
(2015), our imitation learning model takes as input a $19\times 19\times 7$
binary matrix. Of the seven planes, six represent the positions of stones,
divided by color and the number of liberties; the seventh plane represents ko
information. Meanwhile, the reinforcement learning model’s $19\times 19\times
17$ input contains a partial history of the game state.

###  3.2 Linear Probes

Given a board state and paired feature vector as described in Section 2.2, we
compute intermediate representations by feeding the board state into frozen
policy networks. To predict each feature of interest, we run logistic
regression independently on each layer of each policy network, including the
raw board state. In other words, for each policy network, we train $F\times
L\times k$ classifiers, where $F$ is the number of features, $L$ is the number
of layers, and $k$ is the parameter for $k$-fold cross-validation, as
discussed in the following section.

Domain Word | Imitation | Reinforcement | Rough Definition
---|---|---|---
Pincer | 0.91 | 0.91 | attack on a corner approach
Joseki | 0.87 | 0.87 | fixed local sequences of moves
Fuseki | 0.85 | 0.84 | opening
Ko | 0.80 | 0.86 | repetitive capture sequence
Wall | 0.70 | 0.74 | sequence of stones in a row
Atari | 0.69 | 0.73 | threat to capture
Eye | 0.67 | 0.73 | surrounded empty space
Cut | 0.64 | 0.65 | block two groups from connecting
Me | 0.60 | 0.62 | another word for eye
Down | 0.60 | 0.60 | toward the edge of the board
Point | 0.59 | 0.61 | specific locations on the board; or, the score
Force | 0.58 | 0.58 | requiring immediate response
Up | 0.56 | 0.58 | toward the center of the board
Table 1: ROC AUC values for a subset of domain words in both the imitation
learning and reinforcement learning models. Higher values correspond to more
predictable words. Domain words with the highest values represent relatively
straightforward corner patterns (pincer), while keywords with the lowest
values (force, up) are polysemous with commonly used non-domain-specific
meanings. See Table 2 in the appendix for additional ROC AUC values.

###  3.3 Metrics

We seek to answer two questions: (1) what information is represented in the
policy networks, and (2) where is this information represented? To answer the
first question, we compute the area under the receiver operating
characteristic curve (ROC AUC) for each linear probe. Specifically, for each
layer, we compute the average ROC AUC after $10$-fold cross-validation and
then take the maximum average value across layers. Features with high ROC AUC
are said to be represented by a model, because they are linearly extractible
from some intermediate layer of its policy network. To answer the second
question, we compute the layer at which each feature has its highest ROC AUC
value; we then apply $10$-fold cross-validation, summarize the counts for each
feature in a histogram, and compute a kernel density estimate (KDE) for
visualization.

##  4 Results

We find that domain-specific keywords are significantly more predictable than
control words, with $p=1.8\times 10^{-5}$ under the Wilcoxon signed-rank test.
As shown in Figure 3 (Left) and Table 1, the keyword with the highest ROC AUC
value across both models is pincer, which denotes a relatively straightforward
corner pattern. Meanwhile, low-valued domain words like me and up are
polysemous with non-domain-specific meanings and therefore difficult to
predict. While content and function control words have roughly similar
distributions, some content words are noticeably more predictable; for
example, opponents is the highest-valued control word with ROC AUC values of
$(0.85,0.89)$ as seen in Figure 3 (Left). Such control words are likely
predictable due to correlations with certain domain-specific concepts.

ROC AUC values for the two models are strongly correlated, with Pearson’s
coefficient $\rho=0.97$. Figure 3 (Left) shows that for most keywords, the
reinforcement learning model slightly outperforms the imitation learning
model. Furthermore, keywords are significantly more predictable from the
imitation learning model than from a randomly initialized baseline with
identical architecture ($p=5.6\times 10^{-16}$). Some words like ko are
noticeably more predictable from the reinforcement learning model, possibly
due to differences in input board state representations (cf. §3.1); further
discussion of this point can be found in the appendix.

Consistent with our knowledge that pattern-based features can be obtained by
applying simple rules to the raw board state, we find that pattern-based
features are encoded in early layers of both models, as shown in Figure 3
(Right). Meanwhile, keyword-based features are most easily extracted from
later layers, suggesting that they correlate with high-level abstractions in
the policy network. Generally, pattern-based features are much more
predictable than keyword-based features, with average ROC AUC values of
$(0.96,0.98)$ and $(0.68,0.70)$, respectively. As discussed in Section 2.2,
this discrepancy can largely be attributed to the noisiness inherent in
natural language data.

##  5 Related Work

Jhamtani et al. (2018) propose a similarly-sized dataset of move-by-move chess
commentary. Rather than using this commentary for model interpretability,
though, Jhamtani et al. (2018) attempt to predict whole comments from raw
board states. Zang et al. (2019) use the same dataset to jointly train a
policy network and language generation model with a shared neural encoder, but
again focus on the pedagogical application of commentary generation rather
than interpretation of the policy network. Similar work has focused on
generating sportscasts in the Robocup domain (Chen and Mooney, 2008; Liang et
al., 2009; Mei et al., 2016).

Our primary methodology is linear probing (Ettinger et al., 2016; Manning et
al., 2020), which has commonly been used to study the intermediate
representations of language models like ELMo (Peters et al., 2018) and BERT
(Devlin et al., 2019). One classic result in this area shows that early layers
of contextual language models correlate best with lexical-syntactic
information such as part of speech, while later layers correlate with semantic
information like proto-roles and coreference (Tenney et al., 2019). Recent
work on control tasks (Hewitt and Liang, 2019), minimum description length
(Voita and Titov, 2020), and Pareto probing (Pimentel et al., 2020) has
focused on improving the methodological rigor of this paradigm. Although
linear probing is fundamentally a correlational method, other recent work has
focused on whether information which is easily extractable from intermediate
layers of a deep network is causally used during inference (Elazar et al.,
2021; Lovering et al., 2021).

Most related to our work are contemporary studies by McGrath et al. (2021) and
Forde et al. (2022), which apply probing techniques to the games of chess and
Hex, respectively. McGrath et al. (2021) use linear probes to predict a large
number of pattern-based features throughout the training of an AlphaZero agent
for chess. Meanwhile, Forde et al. (2022) train linear probes for pattern-
based features on an AlphaZero agent for Hex and run behavioral tests to
measure whether the agent “understands” these concepts. Comparatively, our
work uses fewer features than McGrath et al. (2021) and does not make causal
claims about how representations are used during inference, as in Forde et al.
(2022); however, to the best of our knowledge, our work is the first of its
kind to use features derived from natural language in conjunction with probing
techniques for policy interpretability.

##  6 Conclusion

We presented a new dataset of move-by-move annotations for the game of Go and
showed how it can be used to interpret game-playing agents via linear probes.
We observed large differences in the predictability of pattern-based features,
which are extracted from the board state, and keyword-based features, which
are extracted from comments. In particular, pattern-based features were easily
extracted from lower layers of the policy networks we studied, while keyword-
based features were most predictable from later layers. At a high level, this
finding reinforces the intuition that written annotations describe high-level,
abstract patterns that cannot easily be described by a rule-based approach.
Accordingly, we argue there is much to learn from this annotation data: future
work might attempt to correlate policy network representations with richer
representations of language, such as those provided by a large language model.
Future work might also explore whether similar approaches could be used to
improve game-playing agents, either by exposing their weaknesses or providing
an auxiliary training signal. We also expect similar approaches may be viable
in other reinforcement learning domains with existing natural language data.

## Acknowledgements

We are grateful to Kevin Yang for his work on the imitation learning model,
and to Rodolfo Corona and Ruiqi Zhong for their contributions to an early
version of this project. We thank Roma Patel, the members of the Berkeley NLP
Group, and our anonymous reviewers for helpful suggestions and feedback. This
work was supported by the DARPA XAI and LwLL programs and a National Science
Foundation Graduate Research Fellowship.

## References

  * Chen and Mooney (2008) David L Chen and Raymond J Mooney. 2008.  Learning to sportscast: a test of grounded language acquisition.  In _Proceedings of the 25th international conference on Machine learning_ , pages 128–135.
  * Clark and Storkey (2015) Christopher Clark and Amos Storkey. 2015.  Training deep convolutional neural networks to play Go.  In _International conference on machine learning_ , pages 1766–1774. PMLR.
  * Devlin et al. (2019) Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019.  BERT: Pre-training of deep bidirectional transformers for language understanding.  In _Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers)_ , pages 4171–4186.
  * Elazar et al. (2021) Yanai Elazar, Shauli Ravfogel, Alon Jacovi, and Yoav Goldberg. 2021.  Amnesic probing: Behavioral explanation with amnesic counterfactuals.  _Transactions of the Association for Computational Linguistics_ , 9:160–175.
  * Ettinger et al. (2016) Allyson Ettinger, Ahmed Elgohary, and Philip Resnik. 2016.  Probing for semantic evidence of composition by means of simple classification tasks.  In _Proceedings of the 1st workshop on evaluating vector-space representations for nlp_ , pages 134–139.
  * Forde et al. (2022) Jessica Zosa Forde, Charles Lovering, George Konidaris, Ellie Pavlick, and Michael L. Littman. 2022.  Where, when & which concepts does AlphaZero learn? lessons from the game of Hex.  In _AAAI Workshop on Reinforcement Learning in Games_.
  * Hewitt and Liang (2019) John Hewitt and Percy Liang. 2019.  Designing and interpreting probes with control tasks.  In _Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)_ , pages 2733–2743.
  * Jhamtani et al. (2018) Harsh Jhamtani, Varun Gangal, Eduard Hovy, Graham Neubig, and Taylor Berg-Kirkpatrick. 2018.  Learning to generate move-by-move commentary for chess games from large-scale social forum data.  In _Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)_ , pages 1661–1671.
  * Liang et al. (2009) Percy Liang, Michael I Jordan, and Dan Klein. 2009.  Learning semantic correspondences with less supervision.  In _Proceedings of the Joint Conference of the 47th Annual Meeting of the ACL and the 4th International Joint Conference on Natural Language Processing of the AFNLP_ , pages 91–99.
  * Lovering et al. (2021) Charles Lovering, Rohan Jha, Tal Linzen, and Ellie Pavlick. 2021.  Predicting inductive biases of pre-trained models.  In _International Conference on Learning Representations_.
  * Manning et al. (2020) Christopher D Manning, Kevin Clark, John Hewitt, Urvashi Khandelwal, and Omer Levy. 2020.  Emergent linguistic structure in artificial neural networks trained by self-supervision.  _Proceedings of the National Academy of Sciences_ , 117(48):30046–30054.
  * McGrath et al. (2021) Thomas McGrath, Andrei Kapishnikov, Nenad Tomašev, Adam Pearce, Demis Hassabis, Been Kim, Ulrich Paquet, and Vladimir Kramnik. 2021.  Acquisition of chess knowledge in alphazero.  _arXiv preprint arXiv:2111.09259_.
  * Mei et al. (2016) Hongyuan Mei, TTI UChicago, Mohit Bansal, and Matthew R Walter. 2016.  What to talk about and how? selective generation using lstms with coarse-to-fine alignment.  In _Proceedings of NAACL-HLT_ , pages 720–730.
  * Peters et al. (2018) Matthew Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee, and Luke Zettlemoyer. 2018.  Deep contextualized word representations.  In _Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers)_ , pages 2227–2237.
  * Pimentel et al. (2020) Tiago Pimentel, Naomi Saphra, Adina Williams, and Ryan Cotterell. 2020.  Pareto probing: Trading off accuracy for complexity.  In _Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)_ , pages 3138–3153. Association for Computational Linguistics.
  * Silver et al. (2016) David Silver, Aja Huang, Chris J Maddison, Arthur Guez, Laurent Sifre, George Van Den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, et al. 2016.  Mastering the game of Go with deep neural networks and tree search.  _Nature_ , 529(7587):484–489.
  * Silver et al. (2017) David Silver, Julian Schrittwieser, Karen Simonyan, Ioannis Antonoglou, Aja Huang, Arthur Guez, Thomas Hubert, Lucas Baker, Matthew Lai, Adrian Bolton, et al. 2017.  Mastering the game of Go without human knowledge.  _Nature_ , 550(7676):354–359.
  * Tenney et al. (2019) Ian Tenney, Dipanjan Das, and Ellie Pavlick. 2019.  BERT rediscovers the classical NLP pipeline.  In _Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics_ , pages 4593–4601.
  * Tian et al. (2017) Yuandong Tian, Qucheng Gong, Wenling Shang, Yuxin Wu, and C. Lawrence Zitnick. 2017\.  Elf: An extensive, lightweight and flexible research platform for real-time strategy games.  In _Advances in Neural Information Processing Systems_ , pages 2656–2666.
  * Tian et al. (2019) Yuandong Tian, Jerry Ma, Qucheng Gong, Shubho Sengupta, Zhuoyuan Chen, James Pinkerton, and Larry Zitnick. 2019.  ELF OpenGo: An analysis and open reimplementation of alphazero.  In _International Conference on Machine Learning_ , pages 6244–6253. PMLR.
  * Voita and Titov (2020) Elena Voita and Ivan Titov. 2020.  Information-theoretic probing with minimum description length.  In _Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)_ , pages 183–196.
  * Zang et al. (2019) Hongyu Zang, Zhiwei Yu, and Xiaojun Wan. 2019.  Automated chess commentator powered by neural chess engine.  In _Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics_ , pages 5952–5961.

##  Appendix A Dataset Statistics

The most common domain-specific terms appear in more than 15K comments, as
shown in Figure 4.

Figure 4: Histogram showing the number of comments that contain each of the
ten most common domain-specific words.

##  Appendix B Pattern-Based Feature Extraction

As described in Section 2.2, we extract features from the board state using a
set of hand-crafted rules. These rules may not align perfectly with player
intuitions, which can be hard to formulate concisely, and so are presented
here for full detail.

#### Cut

We define cuts as moves that prevent the opponent from connecting two
disconnected groups on their next move. To avoid labelling squares where a
play would be immediately capturable, we also require that a cut have at least
two liberties. Note that this definition permits non-diagonal cuts.

#### Eye

We define eyes as connected groups of empty squares that are completely
surrounded by stones of the same color. We require there be no enemy stones in
the same surrounded region, so this definition fails to capture eyes that
surround dead stones.

#### Ladder

The term ladder describes the formation shown in Figure 2(c). Since human
players can usually predict who wins a ladder, they rarely play out the
capturing race. For this reason, we do not look for ladder formations, but
instead label moves that would start or continue a ladder. Specifically, we
label a square for the ladder feature if it is the singular liberty of a
friendly group of stones and a play at the square results in the group having
exactly two liberties. We do not count trivial ladders that lie at the edge of
the board.

#### Wall

We define a wall as a connected row or column with four or more stones of the
same color.

##  Appendix C Keywords and Control Words

#### Keywords

We choose the first thirty most frequent terms (cf. Table 1) from our
vocabulary of domain-specific terminology as keywords: territory, point, cut,
sente, up, me, moyo, shape, ko, invasion, influence, wall, joseki, eye, alive,
gote, life, pincer, aji, thickness, base, atari, connected, hane, tenuki,
down, overplay, force, reading, fuseki.

#### Control Words

Our control words consist of the thirty most frequent words in our dataset, as
well as thirty words uniformly distributed according to the same frequency as
the keywords: the, is, to, this, white, black, and, you, at, for, in, move,
it, of, but, not, be, have, play, that, on, good, here, if, better, can,
would, now, should, stones, looking, wanted, opponents, wasnt, defending,
save, youre, answer, three, fine, feel, place, lose, bit, possibility,
attacking, likely, leaves, shouldnt, question, lost, threat, almost, theres,
continue, trying, hope, just, exchange, before. We further subdivide the
control words based on whether or not they appear in the NLTK stopword
list,444https://gist.github.com/sebleier/554280 which we use as a rough proxy
for distinguishing between function and content words.

##  Appendix D Additional Results

We additionally report de-aggregated ROC AUC values for each keyword across
layers, as shown in Figures 5-7. These figures show the raw data used to
compute the kernel density estimates in Figure 3, which show that natural
language features are most easily extracted from later layers of both models.
We note in Figure 5 that ladders are the most difficult pattern-based feature
to predict, which is consistent with our knowledge that many Go-playing agents
fail to correctly handle ladders without special feature engineering (Tian et
al., 2019). Anecdotally, our imitation learning model often failed to play
ladders correctly; this is consistent with the finding that ladders are more
predictable from the reinforcement learning model. Future work might
investigate whether this probing framework could be used to effectively
predict model behavior in situations like these, as in Forde et al. (2022) for
the game of Hex.

Figure 5: Plots of ROC AUC values for pattern-based features in the imitation
learning model (top) and the reinforcment learning model (bottom). Among the
four pattern-based features we consider, ladders have by far the lowest ROC
AUC values. As noted in Tian et al. (2019), ladders are a known challenge for
Go agents, requiring special feature engineering in Silver et al. (2016).
Therefore, perhaps it is unsurprising that ladders were the most difficult
pattern-based feature to predict.

##  Appendix E Major Differences Between Imitation and Reinforcement Learning
Models

While most keywords have similar ROC AUC values across models, ko, eye, atari,
and overplay have a noticeably higher ROC AUC values under the reinforcement
learning model (cf. Table 1). However, this discrepancy is not obviously
attributable to the difference in training procedures (i.e., imitation vs.
reinforcement). As described in Section 3.1, the two models use different
input state representations, which differ in their encoding of ko and liberty
information, which is used to determine whether eyes and atari exist. Such
architectural differences may explain discrepancies across models, but do not
account for words like overplay; playing strength is another possible (but not
confirmed) source of these discrepancies.

Figure 6: Plots of centered ROC AUC values for keywords in the imitation learning model. For most keywords, linear probe performance peaks at mid-to-late layers of the imitation learning model. Figure 7: Plots of centered ROC AUC values for keywords in the reinforcement learning (RL) model. While noisier than the imitation learning model, probe performance still tends to peak at mid-to-late layers of the RL model and declines at the final layers. Figure 3 aggregates these results alongside pattern-based feature classifiers. Domain Word | Imitation | Reinforcement | Rough Definition
---|---|---|---
Pincer | 0.91 | 0.91 | attack on a corner approach
Joseki | 0.87 | 0.87 | fixed local sequences of moves
Fuseki | 0.85 | 0.84 | opening
Ko | 0.80 | 0.86 | repetitive capture sequence
Base | 0.76 | 0.77 | starter eye space
Moyo | 0.74 | 0.77 | sphere of influence
Influence | 0.72 | 0.74 | long-range effect of stones
Reading | 0.72 | 0.70 | calculating an upcoming sequence
Wall | 0.70 | 0.74 | sequence of stones in a row
Thickness | 0.70 | 0.74 | strength of a group of stones
Invasion | 0.70 | 0.72 | attack on enemy territory
Atari | 0.69 | 0.73 | threat to capture
Eye | 0.67 | 0.73 | surrounded empty space
Gote | 0.67 | 0.69 | loss of initiative
Tenuki | 0.66 | 0.68 | non-local response
Hane | 0.66 | 0.70 | move that “reaches around” or bends
Overplay | 0.64 | 0.70 | overly aggressive move
Cut | 0.64 | 0.65 | block two groups from connecting
Alive | 0.63 | 0.67 | cannot be captured
Territory | 0.63 | 0.66 | controlled empty space
Aji | 0.63 | 0.66 | possibilities left in a position
Sente | 0.63 | 0.66 | initiative
Shape | 0.62 | 0.64 | quality of a group of stones
Life | 0.62 | 0.63 | inability to be captured
Connected | 0.61 | 0.62 | adjacent or nearby stones
Me | 0.60 | 0.62 | another word for eye
Down | 0.60 | 0.60 | toward the edge of the board
Point | 0.59 | 0.61 | specific locations on the board; or, the score
Force | 0.58 | 0.58 | requiring immediate response
Up | 0.56 | 0.58 | toward the center of the board
Table 2: ROC AUC values for all domain words in both the imitation learning
and reinforcement learning models. Domain words with the highest values
represent relatively straightforward corner patterns (pincer), while keywords
with the lowest values (force, up) are polysemous with commonly used non-
domain-specific meanings.