{'fraction_non_alphanumeric': 0.05235772781805852, 'fraction_numerical': 0.01813937718428877, 'mean_word_length': 3.7269309005732603, 'pattern_counts': {'":': 0, '<': 70, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 55, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Cutting Sequences for Geodesic Flow on the Modular Surface and Continued Fractions

This paper describes the cutting sequences of geodesic flow on the modular surface H/PSL(2,Z) with respect to the standard fundamental domain F = {z=x+iy: -1/2<= x<= 1/2 and |z|>=1} of PSL(2,Z). The cutting sequence for a vertical geodesic {\theta+it: t>0} is related to a one-dimensional continued fraction expansion for \theta, called the one-dimensional Minkowski geodesic continued fraction (MGCF) expansion, which is associated to a parametrized family of reduced bases of a family of 2-dimensional lattices. The set of cutting sequences for all geodesics forms a two-sided shift in a symbol space {L,R,J} which has the same set of forbidden blocks as for vertical geodesics. We show that this shift is not a sofic shift, and that it characterizes the fundamental domain F up to an isometry of the hyperbolic plane H. We give conversion methods between the cutting sequence for the vertical geodesic {\theta+it: t>0}, the MGCF expansion of \theta and the additive ordinary continued fraction (ACF) expansion of \theta. We show that the cutting sequence and MGCF expansions can each be computed from the other by a finite automaton, and the ACF expansion of \theta can be computed from the cutting sequence for the vertical geodesic \theta+it by a finite automaton. However, the cutting sequence for a vertical geodesic cannot be computed from the ACF expansion by any finite automaton, but there is an algorithm to compute its first l symbols when given as input the first O(l) symbols of the ACF expansion, which takes time O(l^2) and space O(l).


Introduction
This paper describes the symbolic dynamics of cutting sequences of geodesics for the standard fundamental domain F = {z = x + iy : − 1 2 ≤ x < 1 2 , |z| ≥ 1} of the modular group P SL(2, Z) acting on the upper half plane H = {z ∈ C : Im(z) > 0}.
We study in particular the cutting sequences of vertical geodesics {θ + it : t > 0} for θ ∈ R. These particular geodesics are related to a continued fraction expansion introduced in 1850 by Hermite [20] in terms of quadratic forms, and studied by Humbert [22,23]. Our motivation for studying them was that they appear in the one-dimensional case of a multidimensional continued fraction introduced in Lagarias [30]. This expansion, called the Minkowski geodesic continued fraction expansion (MGCF expansion), is based on following a parametrized family of lattice bases in GL(d + 1, Z)\GL(d + 1, R) as the parameter t varies; in the one-dimensional case the family associated to θ is 1 0 −θ t . The MGCF expansion has the merit that it finds good Diophantine approximations in all dimensions. However, the one-dimensional case of this expansion does not coincide with the ordinary continued fraction expansion. We show in §3.4 that the one-dimensional MGCF expansion of θ is essentially equivalent to the cutting sequence expansion of the vertical geodesic {θ + it : 0 < t < ∞}. We use this connection to determine the precise relation of the MGCF expansion of θ to the additive continued fraction expansion of θ; the additive continued fraction is the variant of the ordinary continued fraction which includes all intermediate convergents.
A second motivation for studying cutting sequences on H/P SL(2, Z) arises from their use as symbolic codings of geodesics in the study of geodesic flow on constant negative curvature surfaces of finite volume; we give more background on this at the end of the introduction. Cutting sequence encodings are of special interest because they apparently encode more information about the geodesic flow on a Riemann surface than other symbolic encodings of geodesics, which have a simple description (shift of finite type) but only retain topological and not conformal information about the Riemann surface. Adler and Flatto [3, §10] raised the question whether cutting sequence encodings preserve conformal information about the Riemann surface and also retain information about the lines on the Riemann surface used to define the cuts, i.e. the shape of the fundamental domain in the universal cover. Consider any hyperbolic polygon P in H which is a fundamental domain for a properly discontinuous group Γ acting on H, such that H/Γ has finite volume, and suppose that P has |P| sides. Let Σ P denote the closed subshift of the shift on |P| letters generated by the cutting sequences for P for geodesic flow on general H/Γ, as defined in §2.2. Adler and Flatto [3, p. 300] 1 ask: does Σ P determine P up to conformal isometry and Γ up to hyperbolic conjugacy? We show here that this is the case for the standard fundamental domain F of P SL(2, Z).
Our main results on cutting sequence encodings are as follows.
(1) The set of cutting sequence expansions for (irrational) vertical geodesics Π 0 F is characterized in terms of forbidden blocks (Theorem 6.1). A generating set of forbidden blocks is enumerated. (Theorems 5.1 and 6.2.). The number of minimal forbidden blocks of length at most k grows exponentially in k. (Theorem 6.3).
(2) The cutting sequence expansions for all geodesics comprise (essentially) a closed two-sided subshift Σ F of the full shift on three symbols {L,R,J}. The set of forbidden blocks of Σ F is the same as that for Π 0 F . (Theorem 7.1). Each symbol sequence in F corresponds to a unique oriented geodesic on H/P SL(2, Z), with the exception of the two sequencesL (3) The shift Σ F characterizes F up to an isometry of H. If P is a hyperbolic polygon of finite area (possibly with some ideal vertices) which is a fundamental domain of a discrete subgroup Γ of P SL(2, R) and if the subshift Σ P is isomorphic to Σ F by a permutation of symbols, then there is a hyperbolic isometry g ∈ P SL(2, R) such that F = gP and P SL(2, Z) = gΓg −1 . (Theorem 8.1).
In obtaining result (1) we show in §5 that vertical geodesics have special features (not shared by general geodesics) that facilitate characterizing forbidden blocks: any vertical geodesic that hits a P SL(2, Z)-translate of a corner of the fundamental domain must have rational θ, and each such geodesic hits at most one such corner, with the exception of those θ ≡ 1 2 (mod 1), which hits two corners. Furthermore, the continued fraction expansion of any rational θ such that {θ + it : t > 0} hits a corner has a symmetry which can be described in terms of the linear fractional transformation z → Nz with N = 1 2 2 1 ; see Theorem 5.1. In formulating result (3) we define cutting sequence expansions for geodesics that hit a corner of the fundamental domain F of H/P SL(2, Z) to be limits of general-position geodesics that hit no corner. This procedure assigns infinitely many different cutting sequences to certain periodic geodesics. We interpret result (3) as showing that the shift Σ F encodes conformal information about F. As a preliminary to obtaining the above results, in §2- §5 we determine precise relations of the cutting sequence of the geodesic θ + it to the Minkowski geodesic continued fraction expansion of θ and to the additive version of the ordinary continued fraction expansion of θ, which we call the ACF expansion. (The ACF expansion, which is described in §3.1, includes all intermediate convergents.) These give algorithms for converting between the symbolic expansions, and obtain results on how hard it is computationally to convert between these different symbolic expansions, as follows. The notion of finite automaton (finite state machine) is described in §3. 5. The key feature of a finite automaton is that it has a fixed finite amount of memory. Result (1) requires that given the successive symbols in the input expansion there is a an absolute bound B so that after scanning B consecutive input symbols at least one new output symbol is determined. This property may be called bounded look-ahead. Result (2) comes from the fact that the amount of look-ahead needed to compute one MGCF symbol from the ordinary continued fraction expansion can be unbounded. Result (3) is based on a conversion algorithm given in Theorem 5.1. To compute a given output symbol it potentially requires remembering the entire input string of symbols to that point, which is the source of the linear space requirement. This computation can be carried out in the given time and space in the random access machine(RAM) model for computation, which allows unbounded storage. It can also be carried out on a one-tape Turing machine using O(ℓ) space with a time bound polynomial in ℓ on a one-tape Turing machine. For the random access machine (RAM) and Turing machine models of computation, see Aho, Hopcroft and Ullman [4]. Results (1)-(3) delineate the computational relations between the ordinary continued fraction expansion, the MGCF expansion and the cutting sequence expansion. Result (2), which is the significant result here, shows that cutting sequences encode information more concisely than the additive ordinary continued fraction expansion.
To conclude this introduction, and to put the results above in a more general context, we recall background on symbolic codings of geodesic flow on a compact Riemann surface with a finite number of punctures. If Γ is a finitely generated discrete group of conformal isometries of the hyperbolic plane H, such that H/Γ has finite volume, then H/Γ is a compact Riemann surface 2 minus a finite number of punctures, and geodesic flow on H/Γ contains both topological and conformal information about this Riemann surface. Symbolic codings of geodesics were introduced by Hadamard [16] in 1898 as a way of understanding the complicated motions on geodesics on such surfaces. E. Artin [6] showed in 1924 that there exist dense geodesics on the modular surface H/P SL(2, Z), using symbolic encodings with continued fractions, and in 1935 G. Hedlund [18] used Artin's coding to show that geodesic flow on this surface was ergodic. Some other symbolic encodings were "boundary expansions" by Nielsen [41] and cutting sequences with respect to a fundamental domain of Γ by Koebe [27] and Morse [39]. Cutting sequence expansions can be viewed as a generalization of the reduction theory of indefinite binary quadratic forms to arbitrary finitely-generated Fuchsian groups, see Katok [24]. More recently Bowen and Series [9] and Series [46,47] used "modified boundary expansions" to obtain a particularly simple symbolic expansion from which strong forms of ergodicity could be deduced; their codings are sofic systems. Adler and Flatto [2,3] used "rectilinear map" codings of geodesic flow on H/Γ to explain why certain specific maps of the interval, such as the continued fraction map and backwards continued fraction map, have invariant measures of a simple form. They showed that these invariant measures are inherited from the invariant measure on geodesic flow (Liouville measure) using a cross-section map followed by a factor map. The codings of Adler and Flatto [3] have a particularly simple structure -they are shifts of finite type -and they preserve topological information about the Riemann surface, but they lose conformal information, for they are identical for all Riemann surfaces of the same genus g ≥ 2. (See [3,Theorem 8.4 and Section 10].) In this respect it is of interest whether cutting sequence encodings preserve conformal information. Besides all these encodings, two other encodings of geodesic flow on the modular surface H/P SL(2, Z) with interesting Diophantine approximation properties appear in Arnoux [5] and Lagarias and Pollington [31].
With regard to this general framework, we note that the proofs in this paper heavily rely on specific facts about P SL(2, Z). The methods used may extend in some form to congruence subgroups of P SL(2, Z), i.e. arithmetic Fuchsian groups, but do not appear likely to apply to general finitely generated Fuchsian groups Γ.
For general terminology in symbolic dynamics we follow Adler and Flatto [3] and Lind and Marcus [34]. From the viewpoint of symbolic dynamics, the associated shift Σ F studied in this paper is an example of a naturally occurring shift more complicated than the ones currently having a well-developed theory, cf. [34].

Cutting Sequences
We describe cutting sequences for finite-sided hyperbolic polygons that are the fundamental domain of a given discrete subgroup Γ of P SL(2, R) that acts discontinuously on H, and then specialize to the standard fundamental domain F of the modular group P SL(2, Z). General references for geodesic flow and for cutting sequences are Adler and Flatto [3] and Series [49].
Let Γ be a finitely generated discrete subgroup of P SL(2, R) which acts properly discontinuously on the upper half-plane H = {x+iy : y > 0} as a group of linear fractional transformations. We suppose that H/Γ has finite volume with respect to the hyperbolic volume on H. Let P be any finite-sided convex hyperbolic polygon which is a fundamental domain for Γ, i.e. P is such that the set of Γ-translates {gP : g ∈ Γ} tessellates H, and no element g ∈ Γ sends P to itself except the identity. We allow polygons P to have one or more ideal vertices ("cusps"), and they may also have extra vertices, called elliptic vertices, which have an angle of π and which fall in the middle of a side of P regarded as a geometric object, as discussed below. Fundamental domains exist for each such finitely generated Γ, cf. [4,Theorem 10.1.4]. Such polygons P necessarily have an even number of "sides," where by convention each elliptic vertex divides a side of the geometric object P into two "sides." If P is to be a fundamental domain for Γ, the "sides" of P must be identified under the action of Γ. Specifically, there is a pairing of the "sides" of P which assigns to each "side" s of P a "side" s ′ and an isometry g(s, s ′ ) ∈ Γ such that g(s, s ′ ) maps s to s ′ . Furthermore (s ′ ) ′ = s and while if s = s ′ then g(s, s) is the identity on s. The pairing indicates how P tessellates H. For g = g(s, s ′ ), the domain of P is adjacent to P in such a way that the "side" labeled s of gP coincides with the "side" labeled s ′ of P, while g(Int(P)) ∩ Int(P) = ∅. If s = s ′ then necessarily g 2 is the identity on H, and g is a hyperbolic reflection. The neighborhood set of P N Γ (P) := {g ∈ Γ : g = g(s, s ′ ) for some side s of P} . (2.1) is a set of generators of the group Γ. It will comprise the set of symbols used in the cutting sequence encodings of geodesics described below. The number of elements of N Γ (P) is generally equal to the number of "sides" of P, but can be less if there are two or more elements g(s, s ′ ) that are equal. For convex polygons P this situation can only arise when there are hyperbolic reflections g = g(s, s ′ ) with s = s ′ , in which case g(s, s ′ ) = g(s ′ , s). In such a case the "sides" s and s ′ must lie on a common geodesic of H and share a common endpoint, 3 which is then a vertex of P having an angle of π. We call any such vertex an elliptic vertex. These two "sides" s and s ′ are then assigned the same generator, so if we erase the elliptic vertex and glue them together, we get a single geometric side of the polygon P regarded as a geometric object. We therefore have: For a convex fundamental domain P of a finitely generated group Γ, the number of elements of N Γ (P ) is equal to the number of geometric sides of P. In particular, the number of elements of N Γ (P ) may be odd.
As an example, the standard fundamental domain F of Γ = P SL(2, Z), is geometrically a triangle with one ideal vertex, but as a fundamental domain for Γ is a quadrilateral having an elliptic vertex at z = i. In this case N Γ (F) has three elements.
We associate to geodesic flow on H/Γ the (two-sided) cutting sequence subshift Σ P,Γ which is a closed subshift of the full shift on |N Γ (P)| letters.
Definition 2.1. The set G 0 P,Γ of general position geodesics for P consists of those geodesics γ on H which intersect the interior of P, and which are transverse to all {g(P) : g ∈ Γ} in the sense that γ contain no vertex nor part of any side of positive length of any translated polygon 3 For non-convex P this may fail to hold.
{gP : g ∈ Γ}. If P contains ideal vertices ("cusps"), then the endpoints of γ must not coincide with any Γ-translate of any such vertex.
To each γ ∈ G 0 P,Γ , we assign the doubly-infinite cutting sequence in which all g i ∈ N Γ (P), as follows. We first label each "side" s of the fundamental domain P with the label g(s, s ′ ) on its "inside" edge in P. We similarly label all the sides of the translated domain {hP : h ∈ Γ}, so that the edge of hP which is hs has the label g(s, s ′ ). Every "side" is now assigned two labels, on its "inside" edge and "outside" edge, because it abuts two copies of a fundamental domain. (Figure 2.1 below indicates such labels.) The geodesic γ = θ 1 , θ 2 visits in order a sequence of translates {h i P; i ∈ Z} in which h i ∈ Γ and h 0 is the identity. At a crossing of the edge from h i−1 P to h i P we assign the symbol g i on the side of the domain that the geodesic enters. (This is the convention of Katok [26]; and opposite to that of Adler and Flatto [3, p. 243], who use the symbol g i on the exit edge.) This convention yields: Lemma 2.1. The cutting sequence (g 1 , . . . , g j ) follows a geodesic from P to the translated domain P j = h j P with h j = g 1 g 2 · · · g j . The transversality hypothesis says that if γ intersects some translate g(P) for g ∈ Γ, then γ intersects the interior of g(P), which implies that the expansion (2.2) is well-defined and unique. If γ −1 = θ 2 , θ 1 denotes the reversed geodesic, then γ −1 ∈ G 0 P,Γ has the cutting sequence P,Γ denote the set of all cutting sequences C(γ) for γ ∈ G 0 P,Γ . This set is invariant under the (forward) shift operator σ({g i }) = {g i+1 } since σ(C(γ)) = C(g 0 γ) , and the geodesic g 0 γ is in G 0 P,Γ . i.e., it is the smallest shift-invariant set containing C.
Thus [C(γ)] is contained in Σ 0 P , but is generally not a closed set. The geodesics on the surface H/Γ are projections of geodesics on H. Since the shift operator on cutting sequences corresponds to a motion of the geodesic by an element of Γ, the orbit [C] is an invariant of the projected geodesic.
We now extend the definition of cutting sequences to apply to all geodesics γ that hit the interior of P. The set of cutting sequences C(γ) for a general geodesic γ = θ ′ , θ consists of all symbol sequences that can be obtained as a limit point (in the sequence topology) of a sequence of C(γ j ) having γ j ∈ G 0 P,Γ such that γ j = θ ′ j , θ j with θ ′ j → θ ′ and θ j → θ as j → ∞. There always exist such convergent sequences {γ j : j ≥ 1}, because Σ P,Γ is compact in the symbol topology; hence C(γ) = ∅. The set C(γ) may be infinite for some geodesics γ. All cutting sequences in C(γ) are contained in Σ P,Γ ; however, the closure operation used in defining Σ P,Γ allows the possibility that Σ P,Γ contains some symbol sequences not coming from any geodesic. We show in the specific case Γ = P SL(2, Z) and fundamental domain F that each [C(γ)] is a union of a finite number of orbits of individual cutting sequences (Theorem 7.2).
The totality of all possible convex polygons P that are fundamental domains of some group Γ has an explicit characterization. A general treatment appears in Maskit [35], which covers non-convex fundamental domains, and also covers groups of isometries of H, which may include orientation-reversing isometries. Maskit [35, section 2] gives a sufficient condition for P to be a fundamental domain, but for finitely-generated groups where H/Γ has finite volume and P is hyperbolically convex it is a necessary condition as well.

Cutting Sequences for the Modular Surface
We now specialize to cutting sequence expansions for geodesics on the modular surface H/P SL(2, Z). The modular group P SL(2, Z) = SL(2, Z)/ ± I has many different convex fundamental domains P that are hyperbolic quadrilaterals; see Beardon [7,Example 9.4.4]. The standard fundamental domain for the modular group acting on H is the hyperbolic triangle which has one ideal vertex ("cusp") at i∞. When regarded as a fundamental domain, it is a quadrilateral having an elliptic vertex added at z = i, see The "sides" s 3 and s 4 containing the elliptic vertex together make up one side of F, and the three sides are labeled inside the fundamental domain as follows: These matrices represent the P SL(2, Z)-motions needed to move a neighboring fundamental domain F ′ in H to F. These neighboring fundamental domains are labeled with the appropriate symbol in Figure 2.2. The action of P SL(2, Z) tiles H with copies of F, and the boundaries of all tiles fit together to cover a countable collection of geodesics of H, which are exactly those geodesics having two rational endpoints a b , c d such that where we adopt the convention that the cusp i∞ is the rational 1 0 . The resulting labeling of the tiles with the labels {L,R,J} is indicated in Figure 2.3.
The cutting sequence shift Σ F := Σ F ,P SL(2,Z) is defined by the method of section 2.1, and is a closed subshift of the shift on three letters {L,R,J}. For this special case, we present some additional cutting sequence labelings that keep track of corners, which we call generalized cutting sequences. We label the two finite corners of F symbolically bȳ General geodesics on the modular surface H/P SL(2, Z) are given by geodesics on H that pass through the fundamental domain. A representative set of lifts covering every geodesic in the modular surface consists of all vertical geodesics with − 1 2 < θ < 1 2 , plus all semicircular geodesics in H whose maximum point lies in the interior of the fundamental domain. The latter must necessarily hit the vertical line {it : t > 0} and have endpoints (θ 1 , θ 2 ) satisfying These conditions imply that θ 1 θ 2 < 0. A generalized cutting sequence for a general geodesic γ is the sequence of symbols from {L,R,J,C 1 ,C 2 } that describe the successive sides of the images of the fundamental domains that it hits.  Finally, for the domain F we define a set of vertical cutting sequences which are one-sided cutting sequences associated to the set of oriented geodesics of H that emanate from the cusp {i∞} of F and pass through F, which are exactly the set of vertical geodesics {(∞, θ) : − 1 2 < θ < 1 2 }.
An important result for our analysis is the following simple fact.
2. An irrational vertical geodesic cannot hit any finite corner of a P SL(2, Z)translate of F.
Proof. The generators of P SL(2, Z) acting on the upper half-plane are z → z + 1 and z → −1/z. Both generators preserve the field Q( √ −3), in which every element has rational real part. The finite corners ±1/2 + √ −3/2, and thus all of their images, are in this field. Thus the cutting sequences in Π 0 F are one-sided infinite sequences which contain no symbol C 1 orC 2 , hence they are all of the form: (2.12) The expansion C + (θ) is a kind of continued fraction of θ, and we call it the cutting sequence expansion of θ. Note that, for a given point θ + it corresponding to a fundamental domain h i F, that there is some point z ∈ F such that according to Lemma 2.1.
Definition 2.6. The vertical cutting sequence space Π F is the closure of Π 0 F in the one-sided sequence topology on the one-sided shift space on three symbols {L,R,J}.
Note that the set Π 0 F is not closed under the one-sided shift operator σ + , because the first symbol of every element of Π 0 F is J. We can now define cutting sequences C(θ) for rational θ with − 1 2 < θ < 1 2 in Π F as limits of cutting sequences C(θ i ) of irrational θ i → θ, as described earlier; in this case C(θ) is a set of one-sided infinite cutting sequences.
We define generalized cutting sequence expansions for vertical geodesics, drawn from the alphabet {L,R,J,C 1 ,C 2 }, similarly to the case of general geodesics.

Continued Fraction Expansions and Cutting Sequence Expansions
This section describes symbolic dynamics for vertical cutting sequences associated to additive continued fraction (ACF) expansions, and for Minkowski geodesic continued fraction expansions (MGCF) for vertical geodesics. It shows that the cutting sequence expansion and MGCF expansions for a geodesic can each be computed from the other using a finite automaton.

Additive Continued Fraction Expansions
The ordinary continued fraction (OCF) expansion for a real θ, written θ = [a 0 , a 1 , a 2 , · · ·], can be represented using 2 × 2 matrices. The use of such matrices to represent continued fractions appears in Frame [13] and Kolden [28], and is described in Stark [51]. Namely, one has a 0 1 1 0 . . . a n 1 1 0 = p n p n−1 q n q n−1 , where pn qn = [a 0 , a 1 , . . . ,a n ] is the n-th convergent of θ. The ordinary continued fraction expansion for θ > 0 has a symbolic dynamics which is a one-sided shift on infinitely many symbols, using the alphabet The additive continued fraction (ACF) expansion of θ > 0 is a symbolic expansion using the two symbols which is obtained from (3.2) by expanding the symbol L k as The additive continued fraction expansion of θ > 0 is thus We next construct a related continued fraction for real θ > 0 which uses the symbols The Farey tree expansion of a real number θ > 0 that has OCF expansion θ = [a 0 , a 1 , a 2 , . . .] is: regarded as a sequence of letters in the alphabet {R, D}. This sequence encodes the steps of subtraction needed in the division process to encode the ordinary continued fraction of θ; it also essentially gives all the intermediate convergents to θ, cf. Richards [44], Theorem 2.1. For θ > 0 the set of allowable symbol sequences for the additive expansion is the full one-sided shift on two letters {R, D}.
A relation of this expansion to paths in the Farey tree is described in Lagarias [29] and Lagarias and Tresser [32]. We start with the interval [ 0 1 , 1 0 ], represented as the matrix 0 1 1 0 .
At each step, we multiply our current matrix p 1 q 1 p 2 q 2 on the left by R or D, as appropriate.
The matrix R causes our current matrix p 1 q 1 p 2 q 2 to be replaced by p 1 + p 2 q 1 + q 2 p 2 q 2 ; the matrix D causes it to be replaced by p 1 q 1 p 1 + p 2 q 1 + q 2 , Thus, in either case, the next term in the Farey tree is (p 1 + p 2 )/(q 1 + q 2 ), and we continue with the interval on the side of this approximation which contains θ. The symbolic expansions (3.5) and (3.7) are equivalent in the sense that each is convertible to the other using a finite automaton; see section 3.5.

Cutting Sequences and Minkowski lattice basis reduction
We now develop a correspondence between the cutting sequence expansion of the geodesic θ + it for − 1 2 < θ < 1 2 and the construction of a Minkowski-reduced lattice basis for the parametrized series of lattice bases To demonstrate the equivalence, we first transform lattice bases in GL(2, R) to the cone of positive definite symmetric matrices P 2 (equivalently, to positive definite quadratic forms), and then we relate these to elements of H.
is a shortest vector in the lattice, and v 2 is a shortest vector not a multiple of v 1 .
For each t, there is a matrix P = P t (possibly several) for which PB t (θ) is Minkowskireduced. General properties of Minkowski-reduction can be found in Cassels [10] and Gruber and Lekkerkerker [15, pp. 149ff].
A basis B ∈ GL(2, R) corresponds to the positive definite symmetric matrix M = BB T ∈ P 2 with associated quadratic form For the basis matrix B t (θ) in (3.8) this gives with associated quadratic form The action of P ∈ GL(2, Z) which sends the matrix B t (θ) to PB t (θ) is transformed to the GL(2, Z)-action on P 2 that takes M to PMP T , and this takes the associated quadratic form The Minkowski reduction domainM for GL(2, Z)\P 2 (see Cassels [10]) is the set of quadratic forms (3.9) such that This is equivalent to the conditions (3.14) on the form Q in (3.9). The subgroup  Z). A natural canonical choice is to require det P = 1; this still leaves two choices for P, but multiplying P by −1 will not change the quadratic form and can be done arbitrarily. A different choice will be made by the Minkowski geodesic continued fraction of the next section. For the second transformation from P to H, note that a positive definite quadratic form can be uniquely written with θ andθ complex conjugates and Im(θ) > 0. We map P to H by sending the quadratic form Q to the unordered pair of roots {θ,θ} and then identify this with θ ∈ H = {z : Im(z) > 0}. If P ∈ GL(2, Z) sends Q to Q ′ given by (3.14), then a calculation yields with a ′ = Q(p 11 , p 12 ) and with a root φ given by The mapping from GL(2, R) to H obtained by composing these two transformations sends the set of matrices {B t (θ) : t > 0} in GL(2, R) to the geodesic {θ + it : t > 0} in H. Since the H 2 \GL(2, Z) action on GL(2, R) is equivalent to the P SL(2, Z) action on H and the reduction domains correspond, the sequence of Minkowski-reduced lattice bases for θ is essentially the same as the cutting sequence expansion for θ. In the reverse direction, θ ∈ H determines a positive ray {aQ : a > 0} in the cone P 2 , i.e. an element of P 2 /R + , and this in term determines a family {aBQ : a ∈ R + , Q ∈ O(n, R)} in GL(2, R), i.e. an element of GL(2, R)/R + O(2, R). This does not affect the symbolic dynamics because the Minkowski domainM is invariant under the R + -action, and because the Minkowski reduction domain M is invariant under the R * O(2, R)-action.

Minkowski Geodesic Continued Fraction Expansions
The Minkowski geodesic multidimensional continued fraction (MGCF) expansion is introduced in Lagarias [30]. We consider here the one-dimensional case. This is a specific algorithm for Minkowski-reduction of the lattice bases There exists a sequence of critical values with lim n→∞ t n = 0, and an associated sequence of convergent matrices {P (n) : n = 0, 1, 2, · · ·} in GL(2, Z) such that P (n) B t (θ) is a Minkowski-reduced lattice basis of the lattice when t n > t > t n+1 . We write so that This motivates the name "continued fraction"; as t goes to zero, the approximations p i θ must also go to zero, and thus the p i /q i play the role of convergents.
Changing the sign of one or both basis vectors does not affect Minkowski-reduction, so we have four choices of P (n) . For defining the MGCF as a continued fraction, it is natural to require positive denominators; that is, we require that q > 0. For lattice basis reduction, it is natural to require det P (n) = 1; multiplying by ±I is still possible but will not affect the process.
We now show that the partial quotient matrices A (n) are drawn from a finite set.
Lemma 3.1 (Minkowski partial quotient set) . The allowed partial quotients for the onedimensional Minkowski geodesic continued fraction algorithm are Proof. Let M = v 1 v 2 be a 2 × 2 matrix with det(M) > 0, and associate to it the positive definite quadratic form with coefficient matrix The Minkowski-reduction conditions for the quadratic form see Cassels [10, p. 257].
We must now choose our algorithm; we will describe both the natural algorithm for Minkowski lattice basis reduction and the Minkowski geodesic continued fraction algorithm.
For lattice basis reduction, it is natural to apply a new matrix A (n) of determinant 1. At any critical time t n , all of the above inequalities are satisfied with the current matrix P (n−1) for t n−1 > t > t n , and at least one holds with equality at t = t n , We first consider "generic" convergents which occur when exactly two of v 1 (t) , v 2 (t) , v 1 (t) + v 2 (t) and v 1 (t) − v 2 (t) become equal at t = t n .
If at t = t n we have v 1 (t) = v 2 (t) then the partial quotient matrix isJ = 0 1 −1 0 ; it exchanges v 1 and v 2 and changes the sign of the new v 2 to keep determinant 1. If v 2 (t) = v 1 (t) + v 2 (t) then the partial quotient matrix isR = 1 0 We might also have more than one of the inequalities (3.23)- (3.25) holding with equality at the same t.
In that case, for t < t n , we would have v 1 (t) > v 2 (t) > v 1 (t) + v 2 (t) , and to correct these inequalities, we must replace v 1 by v 1 + v 2 ; we can take partial quotient matrixC 1 = These five matrices (generated from just three) give the natural algorithm for Minkowski lattice basis reduction.
For the Minkowski geodesic continued fraction, we follow a similar process except that we choose signs to keep the q i positive. We use the fact that all vectors in the lattice Λ t (θ) have the special form Whenever a critical value t n occurs with (p − qθ, qt n ) = (p ′ − q ′ θ, q ′ t c ) , then the inequality holds exactly when |q ′ | > |q|. Thus when the shortest vector in the basis P (n−1) is replaced by a vector in P (n) the associated denominator must increase. Again, we first consider "generic" convergents. Suppose first that q 1 < q 2 . If at t = t n we have v 1 (t) = v 2 (t) then the partial quotient Suppose next that q 1 ≥ q 2 . At t = t n we cannot have v 1 (t) = v 2 (t) since an exchange of v 1 and v 2 would not increase the denominator. We may have v 1 (t) + v 2 (t) = v 2 (t) , giving the partial quotient 1 0 1 1 . If q 1 > 2q 2 then q ′ = q 1 − q 2 > q 2 hence the partial quotient There remain situations in which three or more of v 1 (t) , v 2 (t) , v 1 (t) + v 2 (t) and v 1 (t) − v 2 (t) simultaneously becoming equal at t = t c . Only one case is possible; it is which can only occur when q 1 < q 2 . In this case the partial quotient is 1 1 0 1 . The other case consistent with an increasing denominator is v 2 (t) = v 1 (t) + v 2 (t) = v 1 (t) − v 2 (t) , but this implies v 1 (t) = 0, which is impossible unless t = 0. We define the Minkowski geodesic continued fraction expansion of any real θ satisfying − 1 2 < θ < 1 2 to be the symbol sequence We write this sequence left-to-right, although the matrix product in (3.20) runs right-to-left. The associated Minkowski geodesic symbol set is The symbol C occurs only for "exceptional" geodesics, and we will usually be concerned with symbolic expansions drawn from the smaller symbol set {L, R, J}.
The Minkowski geodesic continued fraction expansion corresponding to a general geodesic on F is the expansion attached to Minkowski reduction of the parametrized lattice bases The associated quadratic form is 29) and the partial quotients are obtained by the same formula.

Correspondence between the continued fraction and cutting sequence
We will now give a correspondence between the symbol sequences for θ given by cutting sequences, the natural Minkowski lattice basis reduction algorithm, and the Minkowski geodesic continued fraction algorithm. The precise correspondence between the symbol sequences involves specifying the relation among the four elements of the H 2 -coset in H 2 \GL(2, Z) for the Minkowski geodesic continued fraction expansion and the two elements in the {±I}-coset in P SL(2, Z) for the cutting sequence expansion. (3.30) We obtain: Theorem 3.1. For irrational θ with − 1 2 < θ < 1 2 , the one-sided cutting sequence expansion of the vertical geodesic ∞, θ = {θ + it : t > 0} in Π 0 F is obtained from the Minkowski geodesic continued fraction expansion of θ by the following procedure: If the current initial word of the MGCF expansion has even parity, on the next symbol make the letter replacement L →L, R →R and J →J; if it has odd parity, make the letter replacement L →R, R →L and J →J. The MGCF can be obtained from the cutting sequence by the reverse process, in which the parity is determined by the current symbols of the MGCF expansion. so H 2 is {I, K, −K, −I}. We first arrange for matrices to multiply in the same direction. The matrices in the MGCF are chosen so that P (n) B t (θ) ∈ F for a given t, while the matrices in the cutting sequence are chosen so that the cutting sequence product h n = S 1 . . . S n has γ(t) ∈ h n F. Therefore, we have h n = (P (n) ) −1 . We expand (P (n) ) −1 in terms of symbols L, R, J, K using the relations L −1 = L, R −1 = KRK and J −1 = J to obtain an expansion which proceeds left to right. To convert this expansion to the cutting sequence expansion, we must convert to symbolsL,R,J and remove the symbols K, which encode the parity. We first convert to the symbols of the natural Minkowski basis reduction algorithm of Section 3.3. Thus the conversion fromL,R,J toL,R,J interchanges R with L.

Finite Automata
By a finite automaton we mean a deterministic finite-state automaton, as defined in Hopcroft and Ullman [21] or [43], used as a transducer. Such an automaton is a finite directed graph with labeled edges, which may contain loops and several edges exiting from each vertex. The states are the vertices of the graph, and the edges give rules to move from one state to the next. Each edge has two labels, an input label and an output label. If the symbol alphabet has s letters, then from each vertex there exit exactly s edges whose input labels are exactly the s allowed symbols. The output labels are finite strings of symbols, possibly empty. The machine starts in a given state. It reads an input symbol, which tells it which exit edge to follow, prints the specified output string of letters as output, and moves to the new state specified by the edge. Then it proceeds to the next input symbol. In this paper we present a number of results asserting the existence of finite automata to convert one-sided infinite symbol sequences of one form to another form. In the proofs we only indicate the "finite-state" character of the conversion process, and generally omit details of the (routine but sometimes involved) construction of the automaton.
A finite automaton which converts the additive continued fraction expansion (3.5) to the Farey tree expansion (3.7) must keep two states to keep track of the sign ±1 of det(S 1 · · · S m ) of the symbols S i = F or R examined so far. The initial state is +1.
The discussion in section 3.4 yields: Theorem 3.3. For irrational θ with − 1 2 < θ < 1 2 there exists a finite automaton to convert the Minkowski geodesic continued fraction expansion of θ to that of the vertical cutting sequence expansion of ∞, θ and vice-versa.
Proof. This follows from Theorem 3.1. For each direction, the finite automaton constructed needs two states, to keep track of whether there a factor of K present; i.e., to keep track of the sign of det(S 1 · · · S n ). The initial state is +1.
We illustrate two of these automata in Figure 3.1. The edge symbol S : W specifies that this edge is taken if the current input symbol is S, and W denotes a symbol sequence to be output. The initial states are the vertices labeled +1.

Vertical Cutting Sequences to Additive Continued Fractions
The ordinary continued fraction expansion of an irrational real number − 1 2 < θ < 1 2 is easily determined from either its cutting sequence expansion or its Minkowski geodesic continued fraction expansion. We begin with the latter case. Theorem 4.1. Given θ with − 1 2 < θ < 1 2 , with ordinary continued fraction expansion θ = [a 0 ; a 1 , a 2 , a 3 , · · ·], let S 0 S 1 S 2 · · · be the Minkowski geodesic continued fraction expansion of θ in the alphabet {L, R, J, C}. The MGCF expansion can be uniquely factored into segments B 0 B 1 · · · where B 0 = J or JL and each B i for i ≥ 1 is R k J for some k ≥ 1, R k+1 JL for some k ≥ 1, or R k C for some k ≥ 1. Each segment encodes exactly one or two partial quotients of the OCF expansion. For general segments, R k J encodes a partial quotient a n = k, while R k+1 JL or R k C encode two partial quotients a n = k, a n+1 = 1. For the segment B 0 , the symbol J encodes a 0 = 0, while JL encodes the partial quotients a 0 = −1, a 1 = 1. The case R k C can only occur when θ is rational.
Proof. We say that p/q is a best approximation to θ if |qθ − p| < |q ′ θ − p ′ | for 0 < q ′ < q. Using this definition, it is a basic result about ordinary continued fractions that the convergents are the complete set of best approximations; see Hardy and Wright [17,Theorem 182]. We say that p/q is a better approximation to θ than p ′ /q ′ if |qθ − p| < |q ′ θ − p ′ |. The best approximation property thus proves that p n /q n is a better approximation than any fraction with denominator less than q n+1 .
In either case, after the first step, we have encoded all coefficients through a n−1 , and our current matrix is The rest of the theorem is proved by induction, with the induction hypothesis that after each segment B k , the matrix P (j) is in the form (4.1), with the coefficients through a n−1 encoded.
Since q n−1 > q n−2 , the requirement of an increasing denominator makes J impossible for the next partial quotient. The Minkowski inequality for R is and for L, it is By the best approximation condition, p n−1 /q n−1 is a better approximation to θ than (p n−1 − p n−2 )/(q n−1 −q n−2 ). Thus (4.3) is satisfied for small t, and thus for all t < t j , so we cannot have L next. If θ is rational and a n−1 is the last term, then (4.2) is satisfied for all t; thus the MGCF terminates. Otherwise, since every even convergent is less than θ, and every odd convergent is greater, p n−1 − q n−1 θ and p n−2 − q n−2 θ have opposite signs, and the absolute value of their sum is less than the absolute value of p n−2 − q n−2 θ. Thus (4.2) is not satisfied for sufficiently small t, and t j+1 is the value of t at which it holds with equality. Thus the next matrix is R; hence P (j+1) = RP (j) = p n−1 q n−1 p n−2 + p n−1 q n−2 + q n−1 .
The remainder of the proof considers the case where P (j) is of the form P (j) = p n−1 q n−1 p n−2 + mp n−1 q n−2 + mq n−1 , (4.4) which can be reached after m applications of R to the form (4.1). Now we have .
Since q n−2 + mq n−1 > q n−1 , the next symbol A (j+1) cannot be L. The other two Minkowski inequalities, for J and R, are Thus the next symbol is A (j+1) = J if (4.5) holds with equality for a larger t < t j than (4.6), A (j+1) = R if (4.6) holds with equality for a larger t < t j , and A (j+1) = C if both hold with equality at the same t. Recall that we have, for 0 ≤ m ≤ a n , and n even, p n−1 + p n q n−1 + q n = (a n + 1)p n−1 + p n−2 (a n + 1)q n−1 + q n−2 > θ ≥ mp n−1 + p n−2 mq n−1 + q n−2 , (4.7) with the reverse inequalities holding for n odd. The last inequality holds with equality only if θ = p n /q n and m = a n . If m < a n , then mq n−1 + q n−2 < q n , so we must have and thus the left-hand side of (4.5) is positive for small t, so A (j+1) cannot be J or C. Thus, if m < a n , the only possible case is R, and the matrix P (j+1) is still of the form (4.4), with m replaced by m + 1. We next consider the case when m = a n in (4.4). In this case, the next symbol A (j+1) may be any of R, J, and C. First suppose A (j+1) = J. If so, we have finished our segment B k = R an J, and P (j+1) is now in the correct form (4.1), since it is p n q n p n−1 q n−1 .
Next suppose that m = a n and A (j+1) = R. For this to happen, we need (4.6) to be true only for t ≥ t c . Since m = a n , we have mq n−1 + q n−2 = q n , and similarly for p n . For (4.6) to be true only for sufficiently large t, (p n−1 + p n )/(q n−1 + q n ) must be a better approximation to θ than p n /q n . This cannot happen if θ = p n /q n , hence a n+1 is defined. By the best approximation property, we must have q n−1 + q n ≥ q n+1 , and it follows that a n+1 = 1, p n+1 = p n + p n−1 , and q n+1 = q n + q n−1 , so that in this case This matrix is in the form (4.4) but with m = a n + 1. Now A (j+2) cannot be R or C, because the left-hand side of (4.6) is positive for small t, so A (j+2) must be J, which gives This gives The following symbol A (j+3) cannot be J, because q n+1 > q n−1 and we must have an increasing denominator. The Minkowski inequality for R is The constant term here is positive because p n+1 − q n+1 θ and p n−1 − q n−1 θ have the same sign, so this inequality holds for all t. The Minkowski inequality for L is which is not satisfied for small enough t because (p n+1 − q n+1 θ) − (p n−1 − q n−1 θ) = p n − q n θ, and thus its constant term is negative. Thus A (j+3) = L, so that This matrix has the form (4.1), and we have encoded the two coefficients, a n and a n+1 = 1, with a segment B k = R an+1 JL.
Finally, suppose that m = a n and A (j+1) = C. Again, (4.6) must fail to hold for sufficiently small t, and it follows that a n+1 = 1. Thus, since q n+1 = q n + q n−1 and p n+1 = p n + p n−1 , we have Here P (j+1) is in the form (4.1), and we have again encoded the two coefficients, a n and a n+1 = 1 as R an C. This completes the induction step. Lemma 2.2 shows that the last case R k C can occur only for rational θ.
There is an analogous conversion method from the cutting sequence expansion to the additive ordinary continued fraction expansion, as follows.
Proof. This follows from Theorem 4.1 by noticing that the parity of the initial word W i = B 0 . . . B i changes after each segment B i encoding one term, and does not change after any segment B i encoding two terms, while the segment B 0 has odd parity if it encodes no terms, and even parity if it encodes a 1 .
An immediate consequence of Theorem 4.1 and 4.2 is the following result.
There exists a finite automaton which converts the Minkowski geodesic continued fraction expansion of each irrational θ with − 1 2 < θ < 1 2 to the additive continued fraction expansion of θ. There exists a finite automaton that converts the vertical cutting sequence expansion of ∞, θ to the additive ordinary continued fraction expansion of θ.
Proof. The segment-partition of the MGCF expansion given in Theorem 4.1 permits the Farey tree expansion (3.7) to be computed by a finite automaton, because the necessary information to decide on the symbol R versus L depends only on the determinant ±1 of the product of the MGCF matrices scanned plus the values of the last four MGCF symbols in the expansion. Next, Theorem 4.2 guarantees that a finite automaton exists to convert the cutting sequence expansion as well. Finally, Theorem 3.2 applies to give the additive continued fraction from the Farey tree expansion. with the change that each symbol 1 in the OCF expansion is to be replaced by one of three possible symbols 1 h , 1 m and 1 c . Here 1 h means that the continued fraction partial quotient a n = 1 begins a new segment RJ or RRJL in the MGCF expansion (so that the previous convergent p n−1 /q n−1 was "hit" at the end of a segment), 1 m means that it combines with the previous partial quotient in a block R k+1 JL (so that p n−1 /q n−1 was "missed"), and 1 c means that it combines with the previous partial quotient in a block with a C-symbol (a "corner"). However it does not specify which sequence of symbols actually occur as legal expansions. We study this next.

Additive Continued Fractions to Vertical Cutting Sequences
In this section, we show how to construct the Minkowski geodesic continued fraction expansion of θ given the additive continued fraction expansion of θ. Let θ have the ordinary continued fraction expansion θ = [a 0 ; a 1 , a 2 , a 3 , · · ·], in which a 0 = 0 or −1. In view of the results of section 4, it suffices to determine for each a n = 1 whether or not it has label 1 h , 1 m or 1 c in the partition of the MGCF expansion given in Theorem 4.1.
By the argument in the proof of Theorem 4.1, whether a n+1 becomes 1 h , 1 c , or 1 m depends on which of (4.5) and (4.6) holds with equality for a larger value of t; we have 1 m if it is (4.6), and 1 c if both hold with equality for the same t. Since a n+1 = 1, we have The condition for 1 m is thus 4) or, equivalently, 5) and the condition for 1 c is equality. Putting everything in terms of p n−1 , p n , q n−1 , and q n gives (p n−1 − q n−1 θ) 2 + 2 (p n−1 − q n−1 θ) (p n − q n θ) (p n−1 − q n−1 θ) 2 − (p n − q n θ) 2 > q 2 n−1 + 2q n−1 q n q 2 n−1 − q 2 n .
Theorem 5.1 suffices to classify all θ containing the symbol 1 c , i.e. all vertical geodesics that hit a corner of a translate of a fundamental domain.
These results give a bound on the computational complexity of computing the MGCF expansion from the additive continued fraction expansion.
Theorem 5.2. The Minkowski geodesic continued fraction expansion of θ can be computed from the additive continued fraction expansion in quadratic time using linear space. That is, there are absolute constants c 1 , c 2 , c 3 such that for any θ with − 1 2 < θ < 1 2 , the first ℓ symbols of the MGCF expansion of θ can be computed using the first c 1 ℓ symbols of the additive continued fraction expansion of θ using at most c 2 ℓ 2 time steps and c 3 ℓ space locations.
Proof. Theorem 4.1 shows that the main problem is to resolve whether a given symbol a n+1 = 1 which appears as the ℓth symbol in the ordinary continued fraction expansion of θ is to be 1 m , 1 h , or 1 c in the MGCF expansion. For this, we use Theorem 5.1. At worst, we must look all the way back to the beginning of the MGCF expansion. Corollary 5.1 shows that the ACF expansion for N(α n ) is of length at most c 0 ℓ, and thus comparing it to β n requires looking at no more than c 0 ℓ + 1 symbols, and this uses O(ℓ) time and O(ℓ) space. Since there may be O(ℓ) different 1's to be resolved, the total time required is O(ℓ 2 ). Note that we test the inequalities (5.2) by comparing symbol sequences for N(α n ) with the initial part of that for β n . This algorithm can easily be implemented on a random access machine with the given time and space bounds. It can also be implemented on a one-tape Turing machine with the same space bound and a time bound polynomial in ℓ. We omit details. For these two standard computational machine models, see Aho, Hopcroft and Ullman [4].
There are examples which do require Ω(ℓ 2 ) time steps; for example, has this property. For this θ, it is necessary to backtrack all the way to the first symbol to determine that each 1 is 1 h , because the sequence [0, (2, 1 h ) j , 2, 1 c , (2, 1 m ) j , 4] is a 1 c -sequence for each j ≥ 1.
In the next section, we will show that the MGCF expansion cannot be computed from the additive continued fraction expansion using a finite automaton, or even using a pushdown automaton with one stack, as defined in Hopcroft and Ullman [21].

Vertical Geodesics: Forbidden Blocks
In this section, we characterize the allowable cutting sequences of Π 0 F . Definition 6.1. A finite word W in the symbol set {L,R,J} is a forbidden block of Π 0 F if it occurs in no cutting sequence of Π 0 F ; otherwise, it is an admissible block. It is an excluded initial block of Π 0 F if does not occur as an initial segment of any cutting sequence of Π 0 F ; otherwise, it is an included initial block.
It is easy to see that excluded initial blocks alone can be used to characterize any subset of the one-sided shift on {L,R,J}. We show that Π 0 F has the stronger property that it is determined by its set of forbidden blocks, as follows. Proof. We prove the contrapositive. First, we show that for every included initial block W, bothR n W andL n W are admissible blocks of Π 0 F for all n ≥ 1. Geometrically, this encodes the fact that the geodesic ∞, θ is a limit of geodesics θ ′ , θ as |θ ′ | → ∞, where θ ′ → −∞ is associated toR nW and θ → +∞ is associated toL nW . The block W corresponds to a finite initial segment of the cutting sequence of θ + it for some irrational θ, say for t 0 ≤ t ≤ ∞ and it has first symbolJ. By Lemma 2.2, this geodesic cannot hit a corner of any translate of F, hence there is some positive ǫ such that it is at distance at least ǫ from any corner for t 0 ≤ t ≤ θ. Pick p/q a large negative rational number, and observe that the geodesic θ ′ , θ contains the word R n W in its one-sided infinite cutting sequence, in which it enters the domain F just after theR n .
Here we require that the radius r = θ − p/q is at least n + 2 so that it produces the sequenceR n , and satisfies r − √ r 2 − 1 < ǫ so that the geodesic is within ǫ of ∞, θ over the range t 0 ≤ t < 1 and thus produces the sequence W. Now take a matrix M = q ′ p ′ q −p ∈ SL(2, Z), so that M(γ) = ∞, θ ′ with θ ′ = M(θ), and note that θ ′ is necessarily irrational. The P SL(2, Z)-action doesn't affect cutting sequences, so the cutting sequence of M(γ) still contains the wordR n W.
There is a unique choice of q ′ and p ′ such that − 1 2 < θ ′ < 1 2 . This vertical geodesic has the same cutting sequence as γ. ThusR n W and likewiseL n W are admissible blocks of Π 0 F for all n ≥ 1.
Second, we prove that if W = S 1 · · · S n is a word inL,R,J for whichRW andLW are both admissible blocks of Π 0 F , there is a vertical geodesic whose cutting sequence has W as an initial segment. To show this, note that the first symbol in W is necessarilyJ, sinceLR andRL are forbidden blocks. Let γ 1 and γ 2 be irrational vertical geodesics whose cutting sequences contain the wordsRW andLW, respectively. Translate each of them by the appropriate elements of P SL(2, Z) to geodesics γ ′ 1 = p 1 /q 1 , θ ′ 1 and γ ′ 2 = p 2 /q 2 , θ ′ 2 in such a way that the translated geodesics enter the fundamental domain F at the symbol immediately preceding W in their cutting sequences. Since the cutting sequence of γ ′ 1 has the letterR as it enters F, it is oriented in the direction of increasing real part and has p 1 /q 1 < −1/2, while γ ′ 2 is oriented in the direction of decreasing real part and has p 2 /q 2 > 1/2. The first symbol in W isJ, hence each geodesic exits F through its bottom edge at a point with real part between −1/2 and 1/2. If γ ′ 1 and γ ′ 2 do not intersect, that is if θ ′ 1 < θ ′ 2 , then pick any irrational θ between θ ′ 1 and θ ′ 2 , say θ = θ ′ 1 , and let γ = ∞, θ . If γ ′ 1 and γ ′ 2 do intersect, let θ be the real part of their intersection and let γ = ∞, θ . In either case, γ passes through F since − 1 2 < θ ′ 1 ≤ θ ≤ θ ′ 2 < 1 2 . Thus the intersection must have real part θ with − 1 2 < θ < 1 2 . In either case, we show that γ has initial word W in its cutting sequence. After leaving F, both γ ′ 1 and γ ′ 2 pass through the same sequence of translated fundamental domains F 1 , . . . , F n , entering along the same edge of each, corresponding to the symbols in W. The vertical geodesic γ must then enter F j on the same edge at a point z j between the points z 1,j and z 2,j where γ ′ 1 and γ ′ 2 hit it, because the domains F j are hyperbolically convex; see Figure 6.1. Also, it cannot hit any other fundamental domain between z j−1 and z j , because every point in that interval on γ is on a geodesic between points of γ ′ 1 and γ ′ 2 which are in F. Thus the initial cutting sequence of γ is W. Finally, if the finite endpoint θ of γ is rational, then since γ hits no corners up to hitting the edge W n , it is a Euclidean distance at least ǫ away from every corner on the W-edges. For every irrational θ ′ with |θ ′ − θ| < ǫ, the irrational vertical geodesic γ ′ = {θ ′ + it : t > 0} has the same initial segment W.
There are two main types of forbidden blocks (including initial blocks). Some blocks are edge-forbidden; they cannot occur in a cutting sequence because they correspond to a geodesic hitting two edges which are part of the same hyperbolic line. Others are whole-forbidden because a geodesic can hit any pair of edges in the sequence, but no geodesic can hit the whole sequence.
Series [48,Theorem 3.1] shows that any minimal edge-forbidden block for any geodesic flow must correspond to geodesic hitting a sequence of domains which are all adjacent to the same boundary line, crossing that line as the first and last step. This allows us to find the edgeforbidden blocks from Figure 2.3; without loss of generality, we can let the boundary line be the  unit circle, with the forbidden block starting inside the unit circle, going outside, and coming back inside. Since the unit circle has three segments, there are nine such blocks:JJ,LR,RL, LJLJ,RJRJ,JLJL,JRJR,LJLLJL,RJRRJR. These also lead to excluded initial blocks. Since the edgesR andL meet at infinity, any forbidden block beginning with either one corresponds to an excluded initial block. These blocks are exactly those which are forbidden by Theorem 4.2. We next obtain from Theorem 5.1 a characterization of the the whole-forbidden blocks and whole-excluded initial blocks in Π 0 F . These conditions involve a critical symbol 1 h or 1 m which is mislabeled in a cutting sequence expansion. Here int[δ 0 , δ 1 ] denotes the closed interval determined by δ 0 and δ 1 with any ordering of the endpoints, i.e. δ 1 < δ 0 may occur.
Note that the interval int[N(δ 0 ), N(δ 1 )] contains all real numbers whose continued-fraction expansions begin with the same partial quotients as δ 0 . ] is a 1 c sequence. We say that p/q is the rational number associated to this central sequence.
We use the following definition to designate initial words of Π 0 F using the initial symbol d 1 = ∞ to indicate that there is no preceding term in the cutting sequence but that the geodesic comes from ∞.
We define ambiguous initial sequences as in Definition 6.2. If we set with ad − bc = ±1 are inconsistent. There is one such inequality for each symbol 1 h or 1 m in the block, which encodes the condition that [α, a 1 , . . . , a m , β] produces the correct symbol 1 h or 1 m . There may also be one or two inequalities on α alone (or on β alone) if there is an incomplete segment at that end, and one more condition (6.6) if the possible encoding of that segment includes another symbol 1 h or 1 m . The total number of inequalities is linear in m. Tables 6.1, 6.2, and 6.3 below list some central sequences, ambiguous sequences and forbidden blocks, respectively; these were obtained by applying the transformation N to simple δ i . Table 6.3 illustrates the computation of forbidden sequences from a central sequence; any change to the terms in a central sequence which increases either α n (and thus decreases N(α n )) or β n forces the 1 to be 1 h , and conversely for 1 m . Theorem 6.2 implies that Π 0 F is complicated in the sense that its set of minimal forbidden blocks is very large.  Proof. We will show that each central sequence associated to a rational p/q = 1/2 yields two minimal forbidden blocks. The forbidden blocks are produced by adding one symbol to each end of the central sequence, and by replacing the central 1 c with a three-symbol word. All these forbidden blocks are distinct. Assuming these facts are proved, consider the central sequences In obtaining forbidden blocks, the 1 c term is encoded by three symbols, and one symbol is added at each end, hence all resulting forbidden blocks contain at most 12n + 5 symbols. We conclude that there are at least 2 n+1 minimal forbidden blocks of length at most 12n + 5, which proves (6.7). We now construct the minimal forbidden blocks. We use the result of Appendix A, which shows that any vertical geodesic for θ = p/q with − 1 2 < θ < 1 2 hits at most one corner of a fundamental domain. This fact implies that each of the central sequences (6.8) contains only one symbol 1 c , and thus each p/q comes from at most one central sequence. Associated to the central sequence is a word W 1 SW 2 in which S =C 1 orC 2 is a corner symbol. For the corner symbol, there are two choices of three symbols in {R,L,J}, which replace the 1 c by 1 h or 1 m ; forC 1 , the choices areJRJ orLJL. We consider the eight words obtained from W 1 SW 2 by replacing S by either choice of a three-symbol block, and by adding a prefix symbol and a suffix symbol, each of which may be eitherL orR. The continued fraction for p/q can be recovered from any one of these eight blocks, and since it has only a single 1 c , the critical 1 c in the central sequence is also uniquely determined.
We claim that six of these eight blocks are admissible blocks for Π 0 F and the other two are forbidden blocks. The vertical geodesic γ = ∞, p/q corresponding to can be approximated by geodesics in the symbol topology in six different ways. Two of these consist of approximating geodesics which do not cross γ at all but approach it from the left and right, respectively. The other four consist of approximating geodesics which cross γ, either crossing above or below the corner that γ hits at the 1 c , and initially approaching γ either from the left or from the right. For sufficiently good approximations, these produce the admissible blocks. (Here we again use the fact that the geodesic γ hits exactly one corner, which implies that all geodesics sufficiently close to γ have the same sequences W 1 and W 2 .) The other two blocks are forbidden by condition (ii) of Theorem 6.2. They encode cutting sequences for a geodesic that would have to approach γ from the left, pass to the right of the corner, and then return to the left of γ, or vice versa; such a geodesic would have to cross γ twice, which is impossible. LetC a andC b denote the two possible three-symbol encodings of S. Of the four blocks exactly three are admissible and one is forbidden. Every sub-block of the forbidden block appears in one of the three admissible blocks, hence the forbidden block is minimal. The same argument applies to the other four blocks containingC b , and produces a second minimal forbidden block.
Theorem 6.4. There does not exist a finite automaton which, when given the additive continued fraction expansion of an irrational number θ with 0 < θ < 1 2 as its input sequence, computes the Minkowski geodesic continued fraction expansion of θ, or, equivalently, the cutting sequence expansion of the geodesic ∞, θ .
Proof. Any finite automaton that would compute the Minkowski geodesic expansion of θ must output the n-th term of this expansion after seeing at most a bounded number of symbols following the n-th symbol of the ACF expansion of θ. However the forbidden block criteria of Theorem 6.2 show that it is sometimes necessary to see an arbitrarily large string of symbols after the n-th symbol, to decide if 1 h or 1 m should be used. For example, for each j ≥ 1, the sequence [2 4j+2 , 1 c , 3, (8, 4) j ] (6.9) is a central sequence. Adding some later terms decreases β 4j+2 , and thus changes the 1 c to 1 m , while decreasing the final 4 in (8, 4) j to a 3 and then adding some further terms increases β 4j+2 and thus changes the 1 c to 1 h . A finite automaton cannot look ahead through the 14j + 6 terms which are necessary, since j can be any integer. In fact, even a pushdown automaton (with one stack) cannot correctly compute all such cutting sequences, because it must look 14j + 6 steps ahead, but also 12j + 6 steps back to distinguish [a 0 ; 2 4j , 1 m , 3, (8,4)  We now use the information on vertical cutting sequences Π 0 F to characterize the two-sided cutting sequences Σ F . Theorem 7.1. The cutting sequence shift Σ F for the fundamental domain F of P SL(2, Z) is the closed subshift whose forbidden blocks coincide with the set of forbidden blocks of Π 0 F .
Proof. This result follows from the fact that the set of images of the set of irrational vertical geodesics under P SL(2, Z) is dense in the space of all geodesics of H/P SL(2, Z).
Let S 0 Π and S 0 Σ and S Σ denote the complete sets of forbidden blocks of Π 0 F , Σ 0 F , and Σ F , respectively. Since Σ F is the closure of Σ 0 F , we have S 0 Σ = S Σ . We first show that For this it suffices to show that every admissible word W in Π 0 F is an admissible word in Σ 0 F . Suppose that the word W appears in the cutting sequence of the irrational vertical geodesic ∞, θ = {θ + it : t > 0}. This geodesic is a limit of geodesics φ i , θ where φ i → ∞ through a sequence of values such that φ i , θ hits no corner of an image of F. The word W = S 1 . . . S r corresponds to a specific set of edges of translated fundamental domains {g j F : 0 ≤ j ≤ r} with g j ∈ SL(2, Z). For all sufficiently large φ i , the geodesic φ i , θ passes through the same sequence of fundamental domains {g j F : 0 ≤ j ≤ r}, hitting the same sequence of edges in the same order. Thus W occurs in the two-sided cutting sequence of φ i , θ , so it is an admissible is proved similarly. Let W be an admissible word in some general position geodesic γ = φ, θ .
There is a sequence of translated fundamental domains {F j : 0 ≤ j ≤ r} which φ passes through that corresponds to W. Since γ hits no corners, we can choose a rational number p/q sufficiently close to φ such that the geodesic γ ′ = p/q, θ passes through the same set of fundamental domains {F j : 0 ≤ j ≤ r}, hitting the same sequence of edges in the same order, hence its cutting sequence (which is only one-sided infinite) contains the word W. Now apply to γ ′ the transformation M in P SL(2, Z) which takes p/q to ∞, and θ to some θ ′ in (− 1 2 , 1 2 ). For this choice, the cutting sequence of M(γ ′ ) is in Π 0 F , and (7.2) follows.
Theorem 7.2. Every element in Σ F is a cutting sequence for a unique oriented geodesic on H/P SL(2, Z) which hits F, except for the two sequencesR ∞ orL ∞ . Every oriented geodesic γ on H/P SL(2, Z) has at least one and at most finitely many shift-equivalence classes of cutting sequences in Σ F . If γ is not periodic then it has at most eight shift-equivalence classes of cutting sequences in Σ F .
To establish this result, we first prove a preliminary lemma.
We next observe that sinceRL andLR are forbidden blocks, if S + is notR ∞ orL ∞ it must contain a symbolJ. Let the initial segment of S + up to the first such symbol beR nJ (resp. L nJ ). Any geodesic γ j which matches these symbols necessarily has θ j ≤ n + 1 since it crosses the semicircle with endpoints n − 1 and n + 1 (resp. θ j ≥ −n − 1) and is positively oriented (resp. negatively oriented), hence θ j ≥ −1/2 (resp. θ j ≤ 1/2). In either case, if a limit (7.3) exists it must be finite. Similar reasoning applies to S i to show that lim j→∞ θ ′ j is infinite if and only if S − does not contain a symbolJ.
We now suppose that S + contains a symbolJ, and claim that lim j→∞ θ j exists and is finite. The argument above shows that {θ j } is bounded, so to prove this claim it suffices to show that if {θ j } is not a Cauchy sequence then the one-sided sequences {S (j) i : i > 0} cannot converge in the symbol topology. If it is not a Cauchy sequence, there is some ǫ > 0 such that for any N , we have j, k ≥ N with |θ j −θ k | > ǫ. The general-position geodesics γ j and γ k enter F and thus have radius at least √ 3/2. Consequently, any point z = x + iy on the geodesic γ j with |x − θ j | < 1/4 and 0 < y < ǫ ′ for ǫ ′ < ǫ 2 /36 will actually have |x − θ j | < ǫ/3, and thus |x − θ k | > 2ǫ/3; similarly, points on γ k with 0 < y < ǫ ′ and |x − θ k | < 1/4 must have |x − θ k | > 2ǫ/3. This implies an upper bound N ǫ on the number of fundamental domains which γ j and γ k both hit somewhere inside the box |Re(z)− (θ j + θ k )/2| ≤ 2ǫ, Im(z) ≤ ǫ. We may assume ǫ < 1/2, hence any such fundamental domain has a cusp at a finite rational point p/q. The rosette R(p/q) of all translated fundamental domains that touch p/q has Euclidean diameter less than 4/q 2 . Thus any translated fundamental domain F ′ which is hit by both γ j and γ k inside the box must have two points whose real parts differ by at least ǫ/3, hence q < 12/ǫ. In addition, p/q must lie within Euclidean distance 4/q 2 of both θ j and θ k , hence there are only finitely many such rational p/q. Finally, there is a finite bound depending only on q and ǫ on the number of fundamental domains in each rosette R(p/q) which have Euclidean diameter exceeding ǫ/3. Together this yields a finite upper bound N ǫ on the number of common fundamental domains F ′ between γ j and γ k in the box. Outside the box, after exiting F the geodesics γ j and γ k traverse the strip ǫ ′ ≤ Im(z) ≤ 1, and thus can hit at most N ′ ǫ translated fundamental domains F ′ in that strip, because there are only finitely many geodesics with Euclidean radius at least ǫ ′ which intersect the region − 1 2 < Re(z) < 1 2 . We conclude that the positive cutting sequences γ j and γ k cannot agree on all of their first N ǫ + N ′ ǫ + n + 1 symbols. Thus the sequences S (j) i : j > 0} cannot converge in the symbol topology, which proves the claim. A similar argument applies to the limit sequence S − if it contains the symbolJ, to prove that lim j→∞ θ ′ j = θ ′ exists and is finite. The geodesic γ = θ ′ , θ is encoded as a limit of the sequence of geodesics γ i . If all of the γ i for i ≥ N intersect a particular domain F ′ , then since the endpoints θ ′ i and θ i converge to θ ′ and θ, and F is closed, γ also intersects F, at least on the boundary. If no γ i for i ≥ N intersect a domain F ′ , then γ does not intersect the interior of F ′ . Thus, if we consider γ to hit a domain if either it passes through the interior, or it intersects the boundary and all γ i for sufficiently large i intersect the interior, we can define a cutting sequence as the set of edges which separate these domains, and this sequence is the limit in the symbol topology of the cutting sequences of γ i .
Proof of Theorem 7.2. Since Σ F is a compact set, every oriented geodesic γ = θ ′ , θ which hits the interior of F has at least one cutting sequence in C(γ) by taking the limit point of cutting sequences from a family γ j = θ ′ j , θ j with θ ′ j → θ ′ and θ j → θ as j → ∞. It remains to show that each oriented geodesic in H which hits F has only a finite number of shift-equivalence classes of cutting sequences in [C(γ)]. The simplest cases are general position geodesics, for which C(γ) is a single cutting sequence, and [C(γ)] consists of a single shiftequivalence class.
We determine how many shift-equivalence classes of cutting sequences are possible for a limiting geodesic. First, consider the limiting geodesics with exactly one rational endpoint (considering ∞ as rational). These correspond to vertical geodesics under the P SL(2, Z) action, so by Lemma 2.2, such geodesics cannot hit any internal corners, and thus have two possible encodings; either can be obtained by using approximating geodesics which approach the rational endpoint from either side. Thus [C(γ)] contains two shift-equivalence classes.
Next, consider those geodesics which have two rational endpoints. Without loss of generality, we can move one endpoint to ∞ and so have a vertical geodesic γ = ∞, p/q . Such a geodesic hits only finitely many corners of fundamental domains. If it hits n corners at finite values of t, then C(γ) contains exactly 2n + 4 cutting sequences. Two of them come from geodesics approximating γ from either side without crossing it, and the other 2n + 2 result from approximating geodesics which cross γ between the kth and (k + 1)st corners with 0 ≤ k ≤ n, either from left to right or from right to left. (Here the 0th corner is ∞, and the (n + 1)st corner is p/q.) In Appendix A, we prove that n ≤ 1 for all rational p/q, except those p/q ≡ 1 2 (mod 1), which have n = 2. Thus [C(γ)] contains at most eight shift-equivalence classes.
It remains to bound the number of shift-equivalence classes of cutting sequences for geodesics which have two irrational endpoints. If such a geodesic hits no corners, then it has only one cutting sequence in C(γ). If it hits exactly one corner, then it has exactly two cutting sequences, which are obtained using geodesics which approach it while staying on opposite sides of the corner. The difficult case occurs with geodesics that hit at least two corners. We show that all such geodesics hit infinitely many corners and are periodic. In this case, C(γ) will be an infinite set. To show periodicity, we observe that a corner in the upper half-plane is the intersection of two circles with centers at rational points on the x-axis and rational radii, so its x-coordinate is rational and its y-coordinate is the square root of a rational number. Thus, if the circle with radius r and center (x 0 , 0) passes through two such points (x 1 , y 1 ) and (x 2 , y 2 ), then it satisfies the equations (x 1 − x 0 ) 2 + y 2 1 = r 2 , (x 2 − x 0 ) 2 + y 2 2 = r 2 .
Since y 2 1 and y 2 2 are rational, so is r 2 ; also, equating the left sides gives a linear equation for x 0 with rational coefficients. Thus the circle intersects the x-axis in two algebraically conjugate real quadratic surds. Pell's equation allows us to find M ∈ SL(2, Z) which preserves one endpoint (and thus its conjugate). Applying this transformation to our geodesic re-scales it while preserving the orientation; hence the geodesic necessarily is a periodic geodesic on H/P SL(2, Z). The set C(γ) is then infinite because we can choose a set of approximating geodesics which cross between any pair of consecutive corners of γ, and the resulting limit cutting sequences are all distinct.
We complete this case by showing that if a periodic geodesic γ on H/P SL(2, Z) hits exactly n corners of translates of fundamental domains in its period, then there are exactly 2n + 2 shift-equivalence classes in [C(γ)]. Label the corners which are hit in one period c 1 , . . . , c n . The approximating geodesics γ i can only be close in the symbol topology if they all cross γ between the same pair of corners, or if none cross γ at all. If they cross, then we can use the periodicity of γ's cutting sequence to shift the crossing point between c 1 and c n+1 . With n possible crossing regions, and crossing possible either from inside to outside or vice versa, there are 2n encodings; we get two more from approximating geodesics which are completely inside or outside γ, for a total of exactly 2n + 2 shift-equivalence classes.
Theorem 7.2 gives no uniform upper bound on the number of shift-equivalence classes of cutting sequences that correspond to periodic geodesics. We formulate the question whether a uniform upper bound exists as open problem (3) in the concluding section. There are periodic geodesics which correspond to 10 cutting sequence shift-equivalence classes because they hit four corners in one period, such as − √ 13, √ 13 and − √ 133, √ 133 . Could this be the maximal number that occurs? Theorem 7.1 implies that the shift Σ F is a relatively complicated set. Indeed Theorem 6.3 showed that the set of minimal forbidden blocks is very large. We now show that Σ F is not a sofic shift. A sofic shift is any shift that is a factor of a shift of finite type (see Marcus and Lind [34].) Alternatively, it is the set of possible bi-infinite walks on an edge-labeled finite graph. We show that Σ F has infinitely many follower sets. The sequences [3, 2 4j+2 , 1 c , 3, (8, 4) j , 10] and [4, 2 4j+2 , 1 c , (8, 4) j , 13] are central. Thus, in [. . . , 3, 2 4j+2 , 1 * , 3, (8, 4) k , 13, . . .], the 1 * is 1 h if j ≥ k but 1 m if j < k, regardless of the symbols on either side. Thus the follower sets of one-sided words which end [3, 2 4j+2 ] are different for all j.

The Shift Σ F Determines F up to Isometry
Our object is to prove the following result.
Theorem 8.1. Let Γ be a finitely generated discrete subgroup of P SL(2, R) that acts properly discontinuously on H, and which has a polygonal fundamental domain P which is hyperbolically convex. Suppose that the cutting sequence shift Σ P is isomorphic to Σ F ,P SL(2,Z) by a permutation of symbol alphabets. Then there is an element g ∈ P SL(2, R) such that F = gP and P SL(2, R) = gΓg −1 .

A. A Bound on the Number of Corners on a Vertical Geodesic
Lemma A.1. For a rational θ, the vertical geodesic γ = {θ + it : t > 0} has at most one value of t such that θ + it is a corner of a P SL(2, Z)-translate of F, unless θ ≡ 1 2 (mod 1), in which case it has exactly two such values, which are t = √ 3/2 and √ 3/6.
Proof. Since the corner −1/2 + √ −3/2 of F is obtained from the corner 1/2 + √ −3/2 by the transformation z → z − 1, every corner is a P SL(2, Z)-translate of 1/2 + (2ac + ad + bc + 2bd) + √ −3 2(c 2 + cd + d 2 ) . (A.1) Let N = 2ac + ad + bc + 2bd and D = c 2 + cd + d 2 , so that the real part of (A.1) is N/2D. We will show that N/2D is either in lowest terms or can be reduced to lowest terms by dividing both N and D by 3. (The factor 3 can occur; for example, take a = 2, b = 1, c = 1, d = 1.) Since ad − bc = 1, ad + bc is odd and thus N is not divisible by 2. Suppose the geodesic is θ + it with θ = v/w. There are only two possible values of (A.1) on this geodesic; N/2D can only equal v/w in lowest terms if w = 2D or w = 2D/3. The imaginary part of (A.1) is either √ −3/w or √ −3/3w. However, these two points are separated by a hyperbolic distance of ln 3, the length of the finite side of the domain F; therefore, they can both be P SL(2, Z)-translates of corners only if they are connected by a P SL(2, Z)-translate of an edge. This edge is the geodesic θ + it itself, and the only vertical edges of translates gF occur when θ = (n + 1/2) for n ∈ Z.