1 Introduction

Let \(\varSigma \) be a compact, orientable surface of negative Euler characteristic. Recall, a curve \(\gamma : S^1 \rightarrow \varSigma \) is said to be in minimal position, if it is self-transverse, and the number of self-intersections is minimal over all curves freely homotopic to \(\gamma \). A curve \(\gamma \) in minimal position is filling if \(\varSigma \, - \gamma \) is a collection of topological disks and annuli, such that each annulus is homotopic to a boundary component of \(\varSigma \). The main result of this note is the following:

Theorem 1.1

There exists a polynomial time algorithm to determine whether a curve \(\gamma \) in \(\varSigma \) is filling.

The input of the algorithm in Theorem 1.1 is a word of length L in some fixed generating set X of \(\pi _1(\varSigma )\). We show that our algorithm terminates in \(O(L^{2N + 2})\) time, where N denotes the complexity of the surface \(\varSigma \). If \(\varSigma \) has genus g and n boundary components, recall that its complexity is defined to be \(N= 3g - 3 + n\).

We point out that there exists another algorithm for determining whether a curve is filling, as given in the PhD thesis [1]. The basic idea of [1] is to construct a curve with minimal self-intersection, corresponding to a word in a generating set of \(\pi _1(\varSigma )\). The algorithm then gives a way of detecting whether the complementary regions of the curve are (possibly punctured) disks. As will be explained in the following paragraph, our approach is much different and unlike the above, we get estimates for the running time of our algorithm.

Let us fix a complete hyperbolic metric on \(\varSigma \). From here on, we identify each curve \(\gamma \) in \(\varSigma \) with its free homotopy class in \(\varSigma \), and define its length \(l(\gamma )\) to be the length of the unique geodesic in that class. The intersection between two curves \(\gamma \) and \(\gamma '\) is taken to be the minimum number of transverse intersections between any two curves homotopic to \(\gamma \) and \(\gamma '\), respectively. One can easily see that a curve is filling, if and only if it intersects every simple curve in \(\varSigma \). In fact, a sufficient condition for \(\gamma \) to be filling is that it intersects every simple curve of length at most twice the length of itself (Lemma 4.1).

Our strategy to prove Theorem 1.1 will thus be as follows. Given a curve \(\gamma \), we will construct a set containing all words in some generating set X of \(\pi _1(\varSigma )\) corresponding to simple curves of length bounded by \(2l(\gamma )\). We will then check whether each curve in our set intersects \(\gamma \), thus determining whether \(\gamma \) is filling. To that end, there exists a number of algorithms for calculating the intersection number of curves represented as words in X, see [4, 7] and [9]. Most recently, Despré and Lazarus [5] have given an algorithm which runs in \(O(L^2)\) time, where L is a bound on the length of the words representing the curves.

In order to construct a set containing all simple words in X, we recall the Dehn–Thurston parametrisation of simple curves. For a fixed pants decomposition \({\mathcal {K}} = \{K_i\}_{i=1}^{N}\) of \(\varSigma \), the Dehn–Thurston coordinate of a simple curve \(\alpha \) is defined to be the vector

$$\begin{aligned} p(\alpha ) := (m_1, \ldots , m_N)\times (t_1, \ldots , t_N) \in {\mathbb {Z}}_{\ge 0}^N \times {\mathbb {Z}}^N, \end{aligned}$$

where each \(m_i\) is the intersection number of \(\alpha \) with the pants curve \(K_i\), and each \(t_i\) is a ‘twisting parameter’ which counts the number of times \(\alpha \) traverses each curve \(K_i\). We define the combinatorial length of a simple geodesic \(\alpha \), to be the sum

$$\begin{aligned} l_p(\alpha ) := \sum _{i=1}^N m_i + \sum _{i=1}^N \left| t_i\right| . \end{aligned}$$

Although it is easy to see that the combinatorial length of a curve is comparable to its hyperbolic length, our algorithm requires calculation of explicit bounds. We note that there exist various methods for obtaining such bounds, for instance by quantifying the proof of the Milnor-Sv̀arc Lemma. Here we use a more direct approach:

Proposition 1.2

Fix a complete hyperbolic metric on \(\varSigma \) to be so that each pants curve has length \(\frac{9}{10}\). For any simple geodesic \(\alpha \) in \(\varSigma \), the combinatorial length of \(\alpha \) satisfies

$$\begin{aligned} l_p(\alpha ) \le 4l_h(\alpha ). \end{aligned}$$

The final step of our algorithm is to write the curves as words in a generating set X of \(\pi _1(\varSigma )\). We construct a specific generating set X which fits our purpose well, and which is closely related to the Dehn–Thurston coordinates (see Sect. 2.3). Given the bound from Proposition 1.2, we can then construct the required set of simple words of bounded length, thus also proving the following proposition. We say a hyperbolic metric on \(\varSigma \) is admissible, if each pants curve in \({\mathcal {K}}\) has length at most \(\frac{9}{10}\).

Proposition 1.3

Let \(\varSigma \) be a compact, orientable hyperbolic surface with an admissible hyperbolic metric. For any \(L > 0\), there exists an explicit method of constructing the set \({\mathcal {W}}(L)\), which contains all words corresponding to simple curves of hyperbolic length at most L, and satisfies \(\left| {\mathcal {W}}(L)\right| \le 2^N {4L + 2N \atopwithdelims ()2N}\).

This paper is organised as follows. In Sect. 2 we review the relevant background material, including the Dehn–Thurston coordinates, and explain the dictionary between the coordinates and word representation of curves. In Sect. 3 we prove the bound between hyperbolic and combinatorial lengths of simple curves from Proposition 1.2. Finally in Sect. 4 we collect results about filling curves and prove Theorem 1.1.

2 Background

We describe the Dehn–Thurston coordinates of multiarcs in \(\varSigma \). Originally attributed to Dehn, the parametrisation was rediscovered by Thurston [10]. We present here a brief overview of the coordinates. For a more detailed account see [8].

2.1 Preliminaries

Throughout this paper we let \(\varSigma = \varSigma _{g,n}\) be a compact, oriented surface with genus g, and n boundary components. Let \(\partial \varSigma \) denote the boundary of \(\varSigma \), and let \(\{ \delta _1, \ldots , \delta _n\}\) be the set of connected components of \(\partial \varSigma \). We assume that \(\varSigma \) has negative Euler characteristic, and we equip \(\varSigma \) with a complete hyperbolic metric h such that the connected components of \(\partial \varSigma \) (if any) are geodesics. We let \(\tilde{\varSigma }\) denote the universal cover of \(\varSigma \) which, as usual, we identify with a subset of the hyperbolic plane \({\mathbb {H}} = \left\{ z \in {\mathbb {C}} \mid \text {Im}(z) > 0\right\} \). We will use the term curve to mean an immersion \(\gamma : S^1 \rightarrow \varSigma \), and arc an immersion \(\alpha : [0,1] \rightarrow \varSigma \) such that \(\alpha (0), \alpha (1) \in \partial \varSigma \). We say a curve in \(\varSigma \) is \(essential \) if it is not homotopic to a boundary component, nor to a point in \(\varSigma \). An arc is essential if it cannot be homotoped into the boundary, relative its endpoints. We define a multiarc in \(\varSigma \) to be a finite collection of homotopy classes of simple curves and simple arcs in \(\varSigma \), which are essential and pairwise disjoint. A multicurve is a multiarc with no arc components. Recall that the homotopy class of any curve \(\gamma \) in \(\varSigma \) contains a unique geodesic. We let \(l_h{(\gamma )}\) denote the length of that unique geodesic. If \(\alpha \) is an arc, we write \(l_h(\alpha )\) to mean the length of a shortest representative in the homotopy class, where the homotopy is relative to \(\partial \varSigma \). For a multiarc \(\varGamma = \sum _{i=1}^n{\gamma _i}\), we define its length \(l_h{(\varGamma )}\) to be the sum \(l_h{(\varGamma )} = \sum _{i=1}^n{l_h(\gamma _i)}.\) We define the (geometric) intersection number of two curves \(\alpha \) and \(\beta \) to be

$$\begin{aligned} \iota (\alpha , \beta ) = \text {min}\{|\alpha ' \cap \beta '| \mid \alpha ' \sim \alpha , \beta ' \sim \beta \}, \end{aligned}$$

Here \(\alpha \sim \beta \) denotes the existence of homotopy between \(\alpha \) and \(\beta \), where the homotopy is relative to the boundary \(\partial \varSigma \) if \(\alpha \) and \(\beta \) are arcs. Note that this definition extends naturally to multiarcs.

We will need the following standard result from hyperbolic geometry (see [6] and [2]). If \(\gamma \) is a simple geodesic curve in a hyperbolic surface \(\varSigma \), a collar of width w around \(\gamma \) is the set \(C(w) = \left\{ x \in \varSigma \mid d_h(x,\gamma ) \le w \right\} \). Let \(w_{\gamma }\) be the largest w for which the collar C(w) is an embedded annulus in \(\varSigma \). The \(Collar Lemma \) states that

$$\begin{aligned} \sinh (w_{\gamma }) \ge 1\, \big / \sinh \left( \frac{l_h(\gamma )}{2}\right) . \end{aligned}$$

Moreover, for any collection of simple, pairwise disjoint geodesic curves \(\{\gamma _i\}\) in \(\varSigma \), the corresponding collars \(C(\gamma _i, w_{\gamma _i})\) are pairwise disjoint [3, Theorem 4.1.1].

Let P denote a surface homeomorphic to a sphere with three disks removed, which we will refer to as a pair of pants. For the remainder of this note, we fix a complete hyperbolic metric h on P to be such that each boundary component has length \(\frac{9}{10}\). Elementary hyperbolic computations show that the length of each seam s, (the shortest arc joining any two distinct boundary components), in our metric on P satisfies \(l_h(s) \approx 3.06\) and the length of each mid \(\nu \), (the shortest essential arc joining a boundary component to itself), satisfies \(l_h(\nu ) \approx 4.57\). We record these here for later. In what follows, we will refer to the two hexagonal regions in P bounded by the seams and the boundary curves, as faces of P.

2.2 Dehn–Thurston coordinates

Fix a pants decomposition \({\mathcal {K}} = \{K_i\}_{i=1}^N\) of \(\varSigma \), and let \({\mathcal {P}} = \{P_k\}_{k=1}^M\) be the corresponding set of pairs of pants. For each pants curve \(K_i\), pick a closed subarc \(w_i \subset K_i\) called the window of the pants curve, and a point \(p_i \in w_i\) called the marked point. For each pair of pants \(P_k \in {\mathcal {P}}\), and for every pair of (not necessarily distinct) marked points in the boundary of \(P_k\), fix a shortest simple oriented arc that is essential in \(P_k\), and whose endpoints are the marked points. The resulting set of arcs is called the set of canonical arcs of \(\varSigma \). For each index k, let \(A_k\) denote the set of canonical arcs in the pair of pants \(P_k\).

Given a multiarc C in \(\varSigma \), the Dehn–Thurston parameter \((m_1, \ldots , m_N)\times (t_1, \ldots , t_N) \in {\mathbb {Z}}^N_{\ge 0} \times {\mathbb {Z}}^N\) of C is defined as follows. For each index i, let \(m_i = \iota (C, K_i)\) be the intersection of C with \(K_i\). Consider the connected 1-complex in \(\varSigma \) consisting of the pants curves and the canonical arcs. Fix \(\epsilon > 0\), and isotope C so that it is contained in the \(\epsilon \)-neighbourhood of the 1-complex. If C does not intersect the pants curve \(K_i\), set \(t_i\) to be the number of components of C in the \(\epsilon \)-neighbourhood of \(K_i\). For each index i fix the rectangle \(R_i = w_i \times [-\epsilon , \epsilon ]\), and let \(C'\) be a representative of C which satisfies \(C' \cap \left( w_i \times \{t\}\right) = m_i\), for every \(t\in [-\epsilon , \epsilon ]\). If \(m_i > 0\), let c be the multiarc segment of \(C'\) contained in the \(\epsilon \)-neighbourhood of \(K_i\) . The parameter \(\left| t_i\right| \) is defined to be half the minimum intersection of \(c'\) with the two edges of \(R_i\) perpendicular to \(w_i\), over all arcs \(c'\) homotopic to c, fixing endpoints. We set the sign of \(t_i\) to be positive if some strand of C travels to the right of the \(\epsilon \)-neighbourhood of \(K_i\) (treated as an oriented annulus, with orientation induced from \(\varSigma \)), and negative otherwise.

It follows that every simple curve can be identified with a point in \({\mathbb {Z}}^N_{\ge 0} \times {\mathbb {Z}}^N\), and one can show that this point is unique. Conversely, a point in \({\mathbb {Z}}^N_{\ge 0} \times {\mathbb {Z}}^N\) corresponds to a Dehn–Thurston coordinate of a multicurve, provided that it satisfies a set of simple conditions. We will not need these here, however the interested reader is referred to [8]. We only note that it follows that the number of multicurves of combinatorial length at most L is bounded by \(2^N { 2N + L \atopwithdelims ()L}\), which grows like \(O(L^{2N})\).

2.3 Dictionary between coordinates and words

Let \(\pi _1(\varSigma ,p)\) denote the fundamental group of \(\varSigma \) based at p, and without loss of generality pick p to be a point from the set \(\{p_i\}\) of marked points of the pants curves in \(\varSigma \). Let T be a spanning tree of the 1-complex in \(\varSigma \) consisting of pants curves and canonical arcs (as above). Fix an orientation for each of the pants curve in \({\mathcal {K}}\). For each index i, let \(a_i\) be the unique oriented path in the in the spanning tree T from p to \(p_i \in K_i\). Define the oriented loop \(\tilde{K_i} \mathrel {\mathop :}=a_iK_i a_i^{-1}\) based at p. For each k and every \(l \in A_k\), let \({\tilde{l}}\) denote the corresponding oriented loop based at p, for some fixed orientation, and write \({\tilde{A}}_k = \{{\tilde{l}} \mid l\in A_k \}.\) Let \(X = \{{\tilde{K}}_i\} \cup \bigcup {\tilde{A}}_k\), and note that this set generates \(\pi _1(\varSigma ,p)\).

Suppose C is a multiarc in \(\varSigma \). Recall that the Dehn–Thurston coordinate of C is obtained by homotoping C so that it is carried by the 1-complex consisting of pants curves and canonical arcs in \(\varSigma \). Thus, given the Dehn–Thurston coordinate of C, it is possible to represent C as a concatenation of canonical arcs and pants curves, that is \(C = u_1\cdots u_n\) where each \(u_l \in \{K_i\} \cup \bigcup A_k\). For each \(u_l\) in the decomposition of C, let \({\tilde{u}}_l\) be the corresponding loop at p (as defined above) and let \({\tilde{C}} = \tilde{u_1} \cdots \tilde{u_n}\) be the concatenation of these loops. Since the endpoints of consecutive arcs \(u_l, u_{l+1}\) in C coincide, we must have that the arc which connects the endpoint of \(u_l\) to p and the arc which connects p to the start point of \(u_{l+1}\) cancel out. Thus,

$$\begin{aligned} {\tilde{C}} = \tilde{u_1} \cdots \tilde{u_k} = (a_{i_1}u_1a_{j_1}^{-1})(a_{i_2}u_2a_{j_2}^{-1}) \cdots (a_{i_k}u_ka_{j_k}^{-1}) = a_{i_1}(u_1u_2 \cdots u_k)a_{j_k}^{-1}. \end{aligned}$$

Hence, we can identify C with the conjugacy class \( [ \tilde{u_1} \cdots \tilde{u_k}]\) in \(\pi _1(\varSigma ,p)\), and thus write it as a word in X of length \(l_p(C)\). As a result, we obtain a dictionary between the Dehn–Thurston coordinates, and words in generators X of \(\pi _1(\varSigma ,p).\)

For later use, we record here a bound for the hyperbolic length of a curve, in terms of the length of a word in X which represents it. As before, we fix the hyperbolic metric on \(\varSigma \) to be so that each pants curve has length \(\frac{9}{10}\). From the calculations at the end of Sect. 2.1, it follows that the length of each canonical arc joining two distinct pants curves is bounded by \(3.1 + 2\frac{9}{10} < 5\), and the length of canonical arc joining the same boundary component is bounded by \(5 + \frac{9}{10} < 6\). Recall that each edge of the spanning tree T is a canonical arc of \(\varSigma \). We define the length of T to be the sum of the lengths of the canonical arcs which constitute its edges. It is clear that the spanning tree T can only contain canonical arcs with distinct endpoints, and furthermore T can contain at most 2 arcs from each pair of pants. Thus the length of T is bounded by 10M, where \(M = 2g - 2 + n\) is the number of pairs of pants in \(\varSigma \). Each generator in X has length at most twice the length of T, plus the length of the longest canonical arc, or pants curve. Hence, the length of each generator is bounded by \(20M + 6 \le 26M\). It follows that if \(\gamma \) is any curve in \(\varSigma \) which can be represented as a word of length L in X, then \(l_h(\gamma ) \le 26ML.\)

3 Bound for the combinatorial length of geodesics

In this section we prove Proposition 1.2 which relates the combinatorial length of a simple curve to its hyperbolic length. The main idea is to first prove bounds relating the combinatorial and hyperbolic lengths of a multiarc in a pair of pants. By applying the bound to segments of the curve in each pair of pants of the pants decomposition of \(\varSigma \), we extend the result to a bound for a curve in the whole surface.

3.1 Multiarcs in pairs of pants

Fix a basis for the Dehn–Thurston parameters by taking the marked points \(\{p_i\}_{i=1}^3\) in the boundary of P to be such that they are contained in the same face of P, and the canonical arcs to be the shortest essential arcs joining each pair of marked points. Given a multiarc A and its Dehn–Thurston parametrisation \((m_1,\ldots , m_N) \times (t_1, \ldots , t_N) \in {\mathbb {Z}}_{\ge 0}^N \times {\mathbb {Z}}^N\), recall that we defined the combinatorial length of A to be the sum

$$\begin{aligned} l_p(A) = \sum _{i=1}^Nm_i + \sum _{j=1}^N\left| t_j\right| . \end{aligned}$$

Proposition 3.1

For any simple connected arc a in a pair of pants P with endpoints contained in the set of marked points \(\{p_i\}_{i=1}^3 \subset \partial P\),

$$\begin{aligned} l_p{(a)} \le \frac{20}{9}l_h(a). \end{aligned}$$
(3.1)

Let a be a simple, geodesic arc in P with endpoints which coincide with the marked points \(\{p_i\}_{i=1}^3\). Let \(p(a) = (m_1, m_2, m_3) \times (t_1, t_2, t_3)\) be the Dehn–Thurston parametrisation of a. When a is a canonical arc in P, we have that \(t_i = 0\) for each i, and \(\sum m_i = 2\). Thus \(l_p(a) = 2 \le l_h(s) \le l_h(\nu )\), where s is a seam of P and \(\nu \) a mid of P. Hence \(l_p(a) \le l_h(a)\).

Claim 1

The bound (3.1) holds for any simple, non-canonical arc a in P with distinct endpoints contained in the set \(\{p_i\}_{i=1}^3 \subset \partial P\).

Proof

Assume that a has endpoints \(a(0) = p_1 \in \delta _1\) and \(a(1) = p_2 \in \delta _2\), the other cases can be treated analogously. Let \(a^*\) be the shortest arc that is homotopic to a (fixing endpoints), and which traverses only the boundary components \(\delta _1\), \(\delta _2\) and the seam s connecting them. For each index i, let \(\left| \tau _i \right| \) be the length of the subarc of \(a^{*}\) which traverses the boundary \(\delta _i\). We set \(\tau _i\) to be positive if \(a^{*}\) travels to the right of the boundary component, and negative otherwise.

We first observe that

$$\begin{aligned} \left| \tau _1 \right| + \left| \tau _2 \right| \ge \left| t_1\right| + \left| t_2 \right| - 1, \end{aligned}$$
(3.2)

where \(t_1, t_2\) are the twisting parameters from the Dehn–Thurston parametrisation of a. Indeed, the distance between the marked \(p_i\) and the endpoint of the seam s in \(\delta _i\) is at most half the length of \(\delta _i\), for \(i=1,2\), and so (3.2) follows from the definition of the twisting parameter.

Next, we show that

$$\begin{aligned} 2l_h(a) \ge l_h(s) + \left| \tau _1\right| l_h(\delta _1) + \left| \tau _2\right| l_h(\delta _2). \end{aligned}$$
(3.3)

Since \(l_h(\delta _1) = l_h(\delta _2) = \frac{9}{10}\) and \(l_h(s) > 3l_h(\delta _1),\) we have that

$$\begin{aligned} l_h(s) + \left| \tau _1\right| l_h(\delta _1) + \left| \tau _2\right| l_h(\delta _2) \ge l_h(\delta _1)(3 + \left| \tau _1\right| + \left| \tau _2 \right| ) = \frac{9}{10}(3 + \left| \tau _1\right| + \left| \tau _2 \right| ), \end{aligned}$$

and so by (3.2) we have that \(2l_h(a) \ge \frac{9}{10}(2 + \left| t_1\right| + \left| t_2 \right| ) = \frac{9}{10}l_p(a)\), as required.

In order to prove (3.3) one considers three cases, depending on whether \(\tau _1\tau _2\) is positive, negative or zero. All three follow from elementary hyperbolic geometry computations. We prove one of the three cases below, leaving the details of the remaining cases to the reader.

Fig. 1
figure 1

Schematic picture of lifts of the arcs a and \(a^{*}\) to the universal cover of a pair of pants

Assume \(\tau _1\tau _2 > 0\), and choose lifts of the arcs \(a, a^{*}\) to the universal cover of P to be such that the endpoints of the lift of a coincide with the endpoints of the lift of \(a^{*}\). By abuse of notation, we write \(a, a^{*}\) to also denote the lifts of the corresponding arcs. Since the seam \(s_{12}\) intersects the boundary components at right angles, we have that \(a, a^{*}\) form the sides of two right triangles. We split \(a = a_1 + a_2\) into two sub-arcs, each of which is the hypotenuse of one of the triangles, see Fig. 1. Using elementary result from hyperbolic geometry, we have that \(l_h{(a_1)} \ge \left| \tau _1 \right| l_h{(\delta _1)} \) and \(l_h{(a_2)} \ge \left| \tau _2 \right| l_h{(\delta _2)} .\) Furthermore, by definition of the seam we must have that \(l_h{(a)\ge l_h{(s_{12})} }.\) The bound in (3.3) follows. \(\square \)

Claim 2

Let \(p \in \{p_i\}_{i=1}^3\). The bound in (3.1) holds for any simple loop a in P based at p.

Proof

Let \(\delta \) denote the boundary component of P which contains the endpoints of a, and let \(\nu \) be the mid of P with endpoints in \(\delta \), i.e. the the shortest essential arc joining \(\delta \) to itself. Set \(a^{*}\) to be the unique arc of shortest length which is homotopic to a and which traverses only the boundary \(\delta \) and the mid \(\nu \). Since a is simple, it must be that when \(a^{*}\) traverses \(\delta \) for the second time, it is travelling in the opposite direction to the first time. Let \(\left| \tau ^{+} \right| , \left| \tau ^{-} \right| \) be the length of the subarc of \(a^{*}\) which traverses \(\delta \) in the positive and negative directions, respectively. Let t denote the twisting parameter a corresponding to the boundary component \(\delta \). Clearly,

$$\begin{aligned} \left| \tau ^{+} \right| + \left| \tau ^{-} \right| \ge \left| t \right| - 2. \end{aligned}$$
(3.4)

By lifting the arcs a and \(a^{*}\) to the universal cover of P as in proof of Claim 1, we get that

$$\begin{aligned} 2l_h{(a)} \ge \frac{9}{10} (\left| \tau ^{+} \right| + \left| \tau ^{-} \right| + 4) , \end{aligned}$$
(3.5)

this time using the fact that the length of the mid satisfies \(l_h{(\nu )} \approx 4.57 \ge 4l_h(\delta ).\) The required result follows by combining (3.4) and (3.5). \(\square \)

The generalisation of Lemma 3.1 to multiarcs in P follows directly by the definition of Dehn–Thurston coordinates:

Corollary 3.2

If C is a multiarc in P with endpoints coinciding with the marked points \(\{p_i\}_{i=1}^3 \subset \partial P\), then

$$\begin{aligned} l_p{(C)} \le \frac{20}{9}l_h{(C)}. \end{aligned}$$

3.2 Proof of Proposition 1.2

Let \({\mathcal {P}} = \{P_i\}_{i=1}^M\) denote the collection of pairs of pants in the pants decomposition \({\mathcal {K}} = \{K_1, \ldots , K_N\}\) of \(\varSigma \) from before. Fix a complete hyperbolic metric h on \(\varSigma \) to be such that the length of each pants curve is \(\frac{9}{10}\). Fix the set of marked points \(\{p_i\}_{i=1}^N\) in the pants curves, and the set of canonical arcs connecting them, as before.

Proof of Proposition 1.2

Let \(\alpha \) be a simple geodesic curve. For each j such that \(\iota (\alpha , K_j) \ne 0\), homotope \(\alpha \) in a small neighbourhood of \(K_j\) so that it intersects \(K_j\) exactly at the marked point \(p_j\), and so that the resulting curve only self-intersects at the marked points. Let \(\alpha ^{*}\) be the curve obtained via this homotopy, and for every j let \(\alpha _j = \alpha ^{*} \cap P_j\). We define the pants length of \(\alpha ^{*}\) to be

$$\begin{aligned} l_{h,{\mathcal {K}}}(\alpha ^{*}) \mathrel {\mathop :}=\sum _{j=1}^Ml_h({\alpha _j}), \end{aligned}$$

where each \(l_h(\alpha _j)\) is understood to be the hyperbolic length of the multiarc \(\alpha _j\) in \(P_j\). We aim to find a constant \(c > 0\) such that \(l_{h,{\mathcal {K}}}(\alpha ^{*}) \le c\, l_h(\alpha )\).

By the triangle inequality, \(l_h(\alpha _j) \le l_h(\alpha \cap P_j) + l_h(K)\iota (\alpha , \partial P_j)\) for every j, where K is any pants curve in \({\mathcal {K}}\) (the pants curves all have the same length). Also \(\sum _{j=1}^M \iota (\alpha , \partial P_j) = 2\iota (\alpha , {\mathcal {K}}),\) and \(\sum _{j=1}^Ml_h(\alpha \cap P_j) \le l_h(\alpha )\), since \(\alpha \) is a geodesic. Hence \(l_{h,{\mathcal {K}}}(\alpha ^{*}) \le l_h(\alpha ) + 2l_h(K)\iota (\alpha , {\mathcal {K}})\). By the Collar Lemma, there exists a constant \(w(K) = \text {arcsinh}(1 / \sinh (\frac{l_h(K)}{2}))\), such that we can embed an annulus of width 2w around every pants curve in \(\varSigma ,\) with the property that the annuli are pairwise disjoint. Thus, at each intersection of \(\alpha \) with some pants curve \(K_j\), we must have that \(\alpha \) traverses at least the width of the annular neighbourhood around \(K_j\). Hence, we have that \(\iota {(\alpha , {\mathcal {K}})} \le \frac{l_h{(\alpha )}}{2w}\). Putting everything together,

$$\begin{aligned} l_{h, {\mathcal {K}}}{(\alpha ^{*})} \le l_h{(\alpha )} \left( 1 + \frac{l_h(K)}{w}\right) \le \frac{8}{5}l_h(\alpha ), \end{aligned}$$
(3.6)

where the second inequality follows from noting that \(l_h(K) = \frac{9}{10}\), so \(w(K) = \text {arcsinh}(1 / \sinh (\frac{l_h(K)}{2})) \ge 3/2\) and thus \(1 + \frac{l_h(K)}{w} \le \frac{8}{5}\).

Finally, we relate the combinatorial length of \(\alpha \) to the sum of the combinatorial lengths of the multiarcs \(\alpha _j \subset P_j\) for \(1 \le j \le M\). Let \(p(\alpha _j) = (m^j_1, m^j_2, m^j_3) \times (t^j_1, t^j_2, t^j_3)\) be the Dehn–Thurston coordinate for the multiarc \(\alpha _j\) in \(P_j\). If we cut \(\alpha ^{*}\) and consider the intersections of the multiarcs \(\{\alpha _1, \ldots , \alpha _M\}\) with the boundaries of the pairs of pants they’re contained in, each intersection of \(\alpha ^{*}\) with a pants curve in \({\mathcal {K}}\) gives rise to exactly two intersections, and conversely every intersection of \(\alpha _i\) with the boundary of a pair of pants arises in this way. (Note that this is because \(\alpha ^{*}\) does not intersect the boundary curves of \(\varSigma \).) Furthermore, suppose two pairs of pants \(P_{j}, P_{k}\) intersect at a common boundary which corresponds to the pants curve \(K_i\), and \(t_i\) is the twisting parameter of \(\alpha \) around \(K_i\). Take \(\alpha _j \subset P_{j}, \alpha _k \subset P_k\), and let \(t_j, t_k\) be their respective twisting parameters around the pants legs corresponding to \(K_i.\) Then the twisting parameters satisfy \( \left| t_i\right| = \left| t_j + t_k \right| \le \left| t_j \right| + \left| t_k \right| \). It follows that \(l_p(\alpha ^{*}) \le \sum _{i=1}^Ml_p(\alpha _j)\).

By the above remarks and Corollary 3.2,

$$\begin{aligned} l_p{(\alpha )} \le \sum _{l=1}^M{l_p{(\alpha _l})} \le \frac{20}{9}\sum _{l=1}^Ml_h{(\alpha _l)} = \frac{20}{9}l_{h,{\mathcal {K}}}(\alpha ^{*}). \end{aligned}$$

Combining this with (3.6), we get that

$$\begin{aligned} l_p{(\alpha )} \le \frac{20}{9}l_{h,{\mathcal {K}}}(\alpha ^{*}) \le 4l_h(\alpha ). \end{aligned}$$

\(\square \)

4 Algorithm for filling curves

4.1 Filling curves

Recall that a curve \(\gamma \subset \varSigma \) in minimal position is filling, if the components of \(\varSigma - \gamma \) are topological disks and annuli, such that each annulus is homotopic to a boundary component of \(\varSigma \). Equivalently, \(\gamma \) is filling if and only if it intersects every essential simple curve in \(\varSigma \). In fact the following stronger result holds, whose proof we include below for completeness.

Lemma 4.1

Fix a hyperbolic metric h on \(\varSigma \), and let \(\gamma \) be a non-peripheral closed geodesic in \(\varSigma \). Then, the geodesic \(\gamma \) is filling if and only if it intersects every essential simple closed curve \(\alpha \) in \(\varSigma \), with \(l_h{(\alpha )} \le 2 \ell _h{(\gamma )}.\)

We define an essential subsurface of a curve \(\gamma \), denoted \(\varSigma _{\gamma }\), to be the smallest subsurface of \(\varSigma \) which contains \(\gamma \), such that every component of \(\partial \varSigma _{\gamma }\) is either contained in \(\partial \varSigma \), or is an essential, simple curve in \(\varSigma \).

Proof of Lemma 4.1

The forward direction is clear.

For the other direction, let \(\gamma \) be a closed geodesic in \(\varSigma \) and suppose \(\gamma \) does not fill \(\varSigma \). Let \(\{\gamma _1, \ldots , \gamma _k\}\) be the geodesic boundary curves of the essential surface \(\varSigma _{\gamma }\). We claim that \(\sum _{i=1}^kl_h{(\gamma _i)} \le 2l_h(\gamma )\). Indeed, since \(\gamma \) fills \(\varSigma _{\gamma }\) the complement \(\varSigma _{\gamma } - \gamma \) is a set of pairwise-disjoint disks and annuli. Each \(\gamma _i\) acts as a boundary component of exactly one annulus in the decomposition, whilst the other boundary is a concatenation of segments of \(\gamma \) which are homotopic to \(\gamma _i\). The segments of \(\gamma \) can act as the boundary of at must two annuli, and thus the bound of the claim follows. Since \(\gamma \) does not intersect any of the curves in \(\{\gamma _1, \ldots , \gamma _k\}\), the result follows from the claim. \(\square \)

4.2 Algorithm for curve intersection

By Lemma 4.1, in order to determine whether a curve \(\gamma \) is filling, one needs to compute the intersection number of \(\gamma \) with a finite collection of curves. There exists a number of algorithms for computing intersection numbers, taking as input curves in various combinatorial representations. The work of Tan [9], and Cohen and Lustig [4] gives algorithms for curves represented as words in a generating set of the fundamental group, for surfaces with nonempty boundary. The latter algorithm was extended by Lustig [7] to also deal with the closed surface case.

More recently, Despré and Lazarus [5] have constructed another such algorithm, which is of particular interest to us as it gives estimates for its running time. Given two curves represented as walks of length at most L in an embedded graph in the surface \(\varSigma \), the algorithm computes their intersection number in \(O(L^2)\) time. We note that given our generating set X (see Sect. 2.3), we can construct an embedded graph in \(\varSigma \) in the following way. The set X gives rise to an immersed graph with a single vertex p, and an edge for each generator. Homotoping each generator curve (fixing base point p) so that the curves are in minimal position, we add a vertex at each intersection point. Now each generator in X corresponds to a walk of length at most c, where c is some fixed constant depending only on the complexity of the surface. Thus a word in X of length bounded by L corresponds to a closed walk of length bounded by cL.

We summarise the preceding discussion with the following theorem:

Theorem 4.2

(Cohen-Lustig [4], Lustig [7], Tan [9], Despré-Lazarus [5]) Let \(\varSigma \) be a surface of negative Euler characteristic. There exists an algorithm to determine whether two curves represented as words have non-zero geometric intersection. Furthermore, if the words which represent the curves have length at most L, the algorithm terminates in \(O(L^2)\) time.

4.3 Proof of the main result

We now prove the main results of the paper. Along the way we also prove Proposition 1.3.

Proof of Theorem 1.1

Fix a pants decomposition of \(\varSigma \), and a complete hyperbolic metric h where each pants curve has length \(\frac{9}{10}\). Fix the generating set X of \(\pi _1(\varSigma )\), as before. Let \(\gamma \) be a curve in \(\varSigma \), represented as a word \(x_{\gamma }\) in X of length L. From the calculations in Sect. 2.3, \(l_h(\gamma ) \le 26ML = L'\), where \(M = 2g - 2 +n \) is the number of pairs of pants in \(\varSigma \).

Let \({\mathcal {C}} = {\mathcal {C}}(8L')\) denote the set of Dehn–Thurston coordinates of curves of combinatorial length bounded by \(8L'\). By Theorem 1.2, \({\mathcal {C}}\) contains all simple curves of hyperbolic length bounded by \(2L'\). Using the dictionary given in Sect. 2.3, translate the Dehn–Thurston coordinates into words in X, and let \({\mathcal {W}}(L')\) denote the resulting set of words. Using Theorem 4.2, one checks the geometric intersection number of \(x_{\gamma }\) with each of the words in \({\mathcal {W}}(L')\). If there exists a word in \({\mathcal {W}}(L')\) which does not intersect \(x_{\gamma }\), then by Lemma 4.1\(\gamma \) is not filling. Otherwise, \(\gamma \) is filling.

To see that this procedure terminates in polynomial time, note that \({\mathcal {W}}(L')\) contains at most \(2^N{8L' + 2N \atopwithdelims ()2N} = O(L'^{2N}) = O(L^{2N})\) words, where \(N = 3g - 3 + n\) is the number of pants curves in \(\varSigma \). Since the intersection algorithm gives us a running time of \(O(L^2)\), our algorithm terminates in \(O(L^{2N + 2})\) steps. \(\square \)