Phylogenetic trees, augmented perfect matchings, and a Thron-type continued fraction (T-fraction) for the Ward polynomials

We find a Thron-type continued fraction (T-fraction) for the ordinary generating function of the Ward polynomials, as well as for some generalizations employing a large (indeed infinite) family of independent indeterminates. Our proof is based on a bijection between super-augmented perfect matchings and labeled Schr\"oder paths, which generalizes Flajolet's bijection between perfect matchings and labeled Dyck paths.


Introduction
If (a n ) n≥0 is a sequence of combinatorial numbers or polynomials with a 0 = 1, it is often fruitful to seek to express its ordinary generating function as a continued fraction. The most commonly studied types of continued fractions are Stieltjes-type (S-fractions), ∞ n=0 a n t n = 1 (1.1) and Jacobi-type (J-fractions), ∞ n=0 a n t n = 1 (1.2) (Both sides of these expressions are to be interpreted as formal power series in the indeterminate t.) This line of investigation goes back at least to Euler [16,17], but it gained impetus following Flajolet's [18] seminal discovery that any S-fraction (resp. J-fraction) can be interpreted combinatorially as a generating function for Dyck (resp. Motzkin) paths with suitable weights for each rise and fall (resp. each rise, fall and level step). There are now literally dozens of sequences (a n ) n≥0 of combinatorial numbers or polynomials for which a continued-fraction expansion of the type (1.1) or (1.2) is explicitly known. A less commonly studied type of continued fraction is the Thron-type (T-fraction): ∞ n=0 a n t n = 1 (1.3) Clearly the T-fractions are a generalization of the S-fractions, and reduce to them when δ i = 0 for all i. Besides the S-fractions, there are four special types of T-fractions that are comparatively simple: 1) Euler [15,Chapter 18] (see also [44, pp. 17-18]) showed that an arbitrary sequence of nonzero real numbers (or finite sequence of nonzero real numbers followed by zeroes) can be written as a special type of T-fraction, namely, one in which δ 1 = 0 and δ i = −α i−1 for i ≥ 2: 1 + α 2 t − α 3 t 1 − · · · = ∞ n=0 α 1 α 2 · · · α n t n . (1.4) 2) If δ n = 0 for all even n, then the T-fraction reduces to a J-fraction via the contraction formula [39] γ 0 = α 1 + δ 1 (1.5a) γ n = α 2n + α 2n+1 + δ 2n+1 for n ≥ 1 (1.5b) β n = α 2n−1 α 2n (1.5c) (which generalizes a well-known contraction formula [44, p. 21] [43, p. V-31] for S-fractions).
3) If δ is periodic of period 2 -that is, δ 2k−1 = x and δ 2k = y -then the sequence (a n ) n≥0 generated by the T-fraction is a linear transform of the sequence generated by the S-fraction with the same coefficients α: see [3,Propositions 3 and 15] for some special cases, and [39] for the general case.
4) If δ n = 0 for all n ≥ 2, then the sequence (a n ) n≥0 generated by the T-fraction is a fairly simple nonlinear transform of the sequence generated by the S-fraction with the same coefficients α (or alternatively the one with shifted coefficients (α n+1 ) n≥1 ): this is a kind of "renewal theory" (see [39]).
But T-fractions not of these four special types are comparatively rare in the combinatorial literature. It is our purpose here to provide a nontrivial example. Two decades ago, Roblet and Viennot [36] showed that the general T-fraction (1.3) can be interpreted combinatorially as a generating function for Dyck paths in which falls from peaks and non-peaks get different weights. When δ = 0 these two weights coincide, and the Roblet-Viennot formula reduces to Flajolet's interpretation of S-fractions in terms of Dyck paths. More recently, several authors [21,27,31,39] have independently found an alternate (and simpler) combinatorial interpretation of the general T-fraction (1.3): namely, as a generating function for Schröder paths with suitable weights for each rise, fall and long level step. When δ = 0 the long level steps get zero weight, and this formula again reduces to Flajolet's interpretation of S-fractions in terms of Dyck paths. We will review this Schröder-path representation in Section 3.1 below.
Our combinatorial example concerns the Ward polynomials W n (x), which are defined as follows. Firstly, the Ward numbers W (n, k) [45] [30, A134991/A181996/A269939] are defined by the linear recurrence W (n, k) = (n + k − 1) W (n − 1, k − 1) + k W (n − 1, k) (1. 6) with initial condition W (0, k) = δ 0k . The triangular array of Ward numbers begins as The row sums are [30, A000311]. It is easy to see that W (n, n) = (2n − 1)!! and that for n ≥ 1 we have W (n, 0) = 0, W (n, 1) = 1 and W (n, 2) = 2 n+1 − n − 3. We then define the Ward polynomials to be the row-generating polynomials of this triangular array: For some purposes it is convenient to use instead the reversed Ward polynomials W n (x) = x n W n (1/x), which satisfy W n (0) = (2n − 1)!!. See [1,2,8,45] for further information on the Ward numbers and Ward polynomials. Our first result is: with coefficients α i = ix and δ i = i−1. Equivalently, the ordinary generating function of the reversed Ward polynomials can be expressed by the T-fraction For the special case x = 1, this T-fraction was known previously, at least empirically [24]. As preparation for the proof of Theorem 1.1, let us mention two different combinatorial interpretations of the Ward numbers. The first one, which is fairly well known, is in terms of phylogenetic trees [42] 1 , the study of which goes back to Schröder's fourth problem [37]. A phylogenetic tree of type (n, k) is a rooted tree that has n + 1 labeled leaves (numbered 1, . . . , n + 1) and k unlabeled internal vertices, in which every internal vertex has at least two children. Thus, a phylogenetic tree of type (0, 0) is just a single vertex labeled 1, which is both the root and a leaf; and it is easy to see that in all other cases we must have 1 ≤ k ≤ n. In fact, it is not difficult to see that the number of phylogenetic trees of type (n, k) is precisely the Ward number W (n, k). 2 [Proof. The claim is clear for n = 0 and n = 1; now we use induction. Leaf number n + 1 can be connected either to an internal vertex on a phylogenetic tree of type (n − 1, k), hence in kW (n − 1, k) ways; or to an edge on a phylogenetic tree of type (n − 1, k − 1), creating a new internal vertex of out-degree 2, hence in (n+k −2)W (n−1, k −1) ways; or to a new root, having the old root of a phylogenetic tree of type (n−1, k −1) as its other child, hence in W (n−1, k −1) ways. This proves (1.6).] So the Ward polynomial W n (x) is the generating polynomial for phylogenetic trees on n + 1 labeled leaves in which each internal vertex gets a weight x.
The second interpretation, which seems to be new, is in terms of what we shall call augmented perfect matchings. Recall first that a perfect matching of [2n] def = {1, . . . , 2n} is simply a partition of [2n] into n pairs. We call the smaller (resp. larger) element of each pair an opener (resp. closer). An augmented perfect matching is then a perfect matching in which we may optionally also draw a wiggly line on an edge (i, i+1) whenever i is a closer and i+1 is an opener [see Figure 1(a)]. Then the number of augmented perfect matchings of [2n] with n − k wiggly lines (or equivalently, k closers that are not followed by a wiggly line) is precisely the Ward number W (n, k).
[Proof. Let M(n, ℓ) be the the number of augmented perfect matchings of [2n] with ℓ wiggly lines. The number of ways that the vertex 2n can be connected to a vertex i ∈ [2n − 1] that is not incident on a wiggly line is (2n − 1 − ℓ)M(n − 1, ℓ), because the vertex i can be inserted in any of the gaps of an augmented perfect matching of [2n−2] with ℓ wiggly lines, where "gap" means a space between adjacent vertices that are not joined by a wiggly line, or a space at the start or end. The number of ways that the vertex 2n can be connected to a vertex i ∈ [2n−1] that is incident on a wiggly line is (n − ℓ)M(n − 1, ℓ − 1), because the vertex i together with its incident wiggly line (pointing to the left) can be inserted after any closer of an augmented perfect matching of [2n − 2] with ℓ − 1 wiggly lines that is not incident on a wiggly line. Comparing the recurrence M(n, ℓ) = (2n − 1 − ℓ)M(n − 1, ℓ) + (n − ℓ)M(n − 1, ℓ − 1) with (1.6), we see that M(n, ℓ) = W (n, n − ℓ).] So the reversed Ward polynomial W n (x) is the generating polynomial for augmented perfect matchings of [2n] in which each wiggly line gets a weight x. Equivalently, the Ward polynomial W n (x) is the generating polynomial for augmented perfect matchings of [2n] in which each closer that is not incident on a wiggly line gets a weight x.
In Appendix A we construct a bijection between augmented perfect matchings of [2n] with ℓ wiggly lines and phylogenetic trees of type (n, n − ℓ).
But we can go farther: let us define a super-augmented perfect matching of [2n] to be a perfect matching of [2n] in which we may optionally draw a wiggly line on an edge (i, i + 1) whenever i is a closer and i + 1 is an opener, and also optionally draw a dashed line on an edge (i, i + 1) whenever i is an opener and i + 1 is a closer; however, it is not allowed for a wiggly line and a dashed line to be incident on the same vertex. Please note that for a pair (i, i + 1) connected by a dashed line, there are two possibilities [see Figure 1(b)]: the opener i and the closer i + 1 could belong to different arches (which necessarily cross), or they could belong to the same arch.
Let us now say that a vertex i is a pure closer if it is a closer that is not incident on any wiggly or dashed line. And let us say that a closer i has crossing number k if the arch ending at i is crossed by k other arches (k ≥ 0). Now let W n (x, u, z, w ′ , w ′′ ) be the generating polynomial for super-augmented perfect matchings of [2n] in which each pure closer with crossing number 0 gets a weight x, each pure closer with crossing number ≥ 1 gets a weight u, each dashed line for which the two endpoints belong to the same arch gets a weight z, each other dashed line gets a weight w ′′ , and each wiggly line gets a weight w ′ . Since each closer corresponds to precisely one of these five categories, W n is a homogeneous polynomial of degree n. These five-variable polynomials have a T-fraction that generalizes (1.8): Theorem 1.2. The ordinary generating function of the polynomials W n (x, u, z, w ′ , w ′′ ) can be expressed by the T-fraction (1.10) with coefficients α i = x + (i − 1)u and δ i = z + (i − 1)(w ′ + w ′′ ).
In Appendix B we will show that the sequence of four-variable polynomials W n (x, u, z, w) satisfies a nonlinear differential recurrence, and that the specialization to x = u satisfies a linear differential recurrence.
But we can go much farther: the main result of this paper is a "master T-fraction" that enumerates super-augmented perfect matchings with an infinite set of independent statistics (Theorem 2.1). This master T-fraction includes many combinatorially interesting polynomials as special cases: see Corollary 2.2 and the specializations (2.27)-(2.29), (2.30) and (2.31). By further specialization of (2.30), we obtain Theorem 1.2, which in turn implies Theorem 1.1.
Let us conclude this introduction by mentioning briefly the connection of the Ward numbers and Ward polynomials with other combinatorial objects and problems: 1) The 2-associated Stirling subset number n k ≥2 is the number of partitions of an n-element set into k blocks, each of which has at least two elements; by convention we set 0 k ≥2 = δ 0k . It is easy to see that these numbers satisfy the recurrence Comparing (1.6) with (1.11), it is easy to see that W (n, k) = n+k k ≥2 [9] [7, eqns. (1.7) and (3.6)] [35, pp. 6-7]. This also has a nice bijective proof [9]: given a phylogenetic tree of type (n, k), partition its n+k non-root vertices into blocks consisting of the sets of children of each of the k internal vertices. 3 Note also that, under this bijection, the number of internal vertices with i children in the phylogenetic tree equals the number of blocks of size i in the partition, as observed in [ 2) A Stirling permutation [23] of order n is a permutation σ 1 · · · σ 2n of the multiset {1, 1, 2, 2, . . . , n, n} in which, for all m ∈ [n], all numbers between the two occurrences of m are larger than m. We say that an index j ∈ [2n] is a descent if σ j > σ j+1 or j = 2n (so by our definition the last index is always a descent). The second-order Eulerian number n k is the number of Stirling permutations of order n with exactly k descents; by convention we set 0 k = δ 0k . 4 It is not difficult to see [23, p. 27] that these numbers satisfy the recurrence It is easy to see from (1.12) that n n = n! and n k=0 n k = (2n − 1)!!. Define now the second-order Eulerian polynomials E [2] n (x) = and the reversed polynomials E [2] n (x) = x n E [2] n (1/x); note that E [2] n (0) = n! and E [2] n (1) = (2n − 1)!!. By manipulating the recurrences (1.6) and (1.12), it is not difficult to show that W n (x) = E [2] n (1 + x) (1.14) or equivalently In particular we have W n (−1) = n! [6, Theorem 3.1 and Section 4]. The identity (1.14) also has a nice combinatorial interpretation and proof. In a perfect matching of [2n], let us say that a pair (i, i + 1) is a closer/opener pair if i is a closer and i + 1 is an opener. Note that counting augmented perfect matchings with a weight x for each wiggly line -as W n (x) does -is equivalent to counting perfect matchings with a weight 1 + x for each closer/opener pair. Now let M ′ (n, ℓ) be the number of perfect matchings of [2n] with ℓ closer/opener pairs. We claim that M ′ (n, ℓ) = n n−ℓ . [Proof. Write clop(π) for the number of closer/opener pairs in a perfect matching π. Now consider a perfect matching π of [2n], and suppose that the vertex 2n is paired with i ∈ [2n − 1]; let π ′ be the perfect matching of [2n − 2] obtained from π by deleting the arch (i, 2n) and renumbering vertices. If i = 1 or i − 1 is an opener, then clop(π ′ ) = clop(π). If i ≥ 2 and i − 1 is a closer, then (i − 1, i) is a closer/opener pair; if also i + 1 is an opener, then clop(π ′ ) = clop(π), otherwise clop(π ′ ) = clop(π) − 1. If clop(π) = ℓ, these insertions can be done in n, ℓ and n − ℓ ways, respectively. So M ′ (n, ℓ) = (n + ℓ)M ′ (n − 1, ℓ) + (n − ℓ)M ′ (n − 1, ℓ − 1), which is equivalent to (1.12).] 5 So the reversed second-order Eulerian polynomial E [2] n (x) is the generating polynomial for perfect matchings of [2n] in which each closer/opener pair gets a weight x. This interpretation seems to be new.
3) There is also a very interesting multivariate generalization of the Ward polynomials. As explained above, the Ward polynomial W n (x) is the generating polynomial for phylogenetic trees on n + 1 labeled leaves in which each internal vertex gets a weight x. Now let x = (x i ) i≥1 be an infinite collection of indeterminates, and let W n (x) = W n (x 1 , . . . , x n ) be the generating polynomial for phylogenetic trees on n + 1 labeled leaves in which each internal vertex with i (≥ 2) children gets a weight x i−1 . We call this the multivariate Ward polynomial ; it is quasi-homogeneous of degree n when x i is given weight i. Thus W n (x) = W n (x, . . . , x); and from the quasi-homogeneity one deduces W n (x) = W n (1, x, x 2 , . . . , x n−1 ). The first few W n are [30, A134685] satisfies the functional equation where the term n in the sum corresponds to the case in which the root has n children.
In other words, W(t; x) is the compositional inverse of the generic power series (1.20) In this context of series inversion, the polynomials W n (x 1 , . . . , x n ) can be found in the books of Riordan [ Since W n (x 1 , . . . , x n ) = x n + a polynomial with integer coefficients in x 1 , . . . , x n−1 , any sequence a = (a n ) n≥0 with a 0 = 1 in any commutative ring R can be written as a specialization of W n (x 1 , . . . , x n ) with suitable coefficients (x i ) i≥1 in R. For instance, we have It will be observed that this is identical to (1.16) with some sign changes (namely, a minus sign on each monomial with an even number of factors a i ): that is, −x n = W n (−a 1 , . . . , −a n ). This is in fact easy to prove: if we write then setting a n = W n (x 1 , . . . , x n ) in (1.18) yields the functional equation 20) and recalling that W n−1 (x) = a n−1 , we see that they are related by (a n , x n ) → (−x n , −a n ), which proves the claim.
In particular, taking a n equal to the generalized Ward polynomial W n (x, u, z, w), we have We have not yet succeeded in guessing the general formula for these x i ; but in the special case u = x we conjecture (note that this is a polynomial in x, z, w since the terms in 1/w cancel), corresponding to We have confirmed this conjecture for n ≤ 10. When z = 0 and w = 1 this reduces to It is curious that the x i in (1.24) and (1. 25) are not all nonnegative (even pointwise in x, u, z, w ≥ 0), even though the output polynomials W n (x 1 , . . . , x n ) = W n (x, u, z, w) are of course coefficientwise nonnegative in x, u, z, w. It would be interesting to extend our work on the Ward polynomials to this multivariate generalization. 4) Finally, let us comment on the implications of our results for the theory of Hankel-total positivity [38,39], which was in fact our original motivation for studying these T-fractions. If P = (P n (x)) n≥0 is a sequence of polynomials with real coefficients in one or more indeterminates x, we say that this sequence is coefficientwise Hankeltotally positive if every minor of the infinite Hankel matrix H ∞ (P ) = (P i+j (x)) i,j≥0 is a polynomial with nonnegative coefficients. One fundamental result of this theory is [39]: whenever the ordinary generating function ∞ n=0 P n (x) t n is given by a Tfraction (1.3) where all the coefficients α i and δ i are polynomials in x with nonnegative coefficients, the sequence P = (P n (x)) n≥0 is coefficientwise Hankel-totally positive. It follows from this that all the T-fractions derived in this paper -including the most general one, Theorem 2.1 -are coefficientwise Hankel-totally positive in the appropriate variables. In particular, the Ward polynomials W n (x) and the generalized Ward polynomials W n (x, u, z, w) are coefficientwise Hankel-totally positive.
But now a mystery arises from the relation (1.14) that connects the (reversed) Ward polynomials with the (reversed) second-order Eulerian polynomials. It follows from (1.14) and (1.9) that the ordinary generating function of the reversed secondorder Eulerian polynomials is given by a T-fraction with coefficients δ i = (i−1)(x−1) and α i = i. 7 Here δ i is not coefficientwise nonnegative (or even pointwise nonnegative when 0 ≤ x < 1), so the general theory [39] says nothing about the Hankeltotal positivity of the reversed second-order Eulerian polynomials. And yet, we find empirically that the sequence of reversed second-order Eulerian polynomials is coefficientwise Hankel-totally positive: we have tested this through the 13 × 13 Hankel matrix. This total positivity (if indeed it is true) is, alas, completely unexplained. By (1.14) it implies the coefficientwise Hankel-total positivity of the reversed Ward polynomials -which we know to be true -but not conversely. In our opinion, proving the coefficientwise Hankel-total positivity of the (reversed) second-order Eulerian polynomials is the major problem left open by our work.
Note added: This mystery has now been resolved [32]. The reversed secondorder Eulerian polynomials E [2] n (x) are also given by a 2-branched S-fraction [32] with coefficients α = (α i ) i≥2 = 1, 1, x, 2, 2, 2x, 3, 3, 3x, . . .. Since these α i are coefficientwise nonnegative, the general theory of branched S-fractions [32] implies the coefficientwise Hankel-total positivity. The plan of this paper is as follows: In Section 2 we state our results on the enumeration of super-augmented perfect matchings: these include a very general T-fraction with infinitely many indeterminates (Theorem 2.1) as well as numerous special cases that count statistics of combinatorial interest. In Section 3 we recall some basic facts concerning the combinatorial interpretation of continued fractions and the concept of labeled Schröder paths. In Section 4 we prove Theorem 2.1 by constructing a bijection from the set of super-augmented perfect matchings onto a set of labeled 2-colored Schröder paths. In Appendix A we construct a bijection between augmented perfect matchings and phylogenetic trees. In Appendix B we show that the generalized Ward polynomials W n (x, u, z, w) satisfy a nonlinear differential recurrence.

Statement of results
We begin by reviewing some S-fractions for perfect matchings that were recently obtained by Zeng and one of us [40]. We then state our generalizations, which are T-fractions for super-augmented perfect matchings.

S-fractions for perfect matchings
Euler showed [16, section 29] that the generating function of the odd semifactorials can be represented as an S-type continued fraction with coefficients α n = n. 8 Since (2n − 1)!! enumerates perfect matchings of a 2nelement set, it is natural to seek polynomial refinements of this sequence that enumerate perfect matchings of [2n] according to some natural statistic(s). Note that we can regard a perfect matching either as a special type of set partition (namely, one in which all blocks are of size 2) or as a special type of permutation (namely, a fixed-point-free involution). We will adopt here the former interpretation, and write π ∈ M 2n ⊆ Π 2n . If i, j ∈ [2n] are paired in the perfect matching π, we write i ∼ π j (or just i ∼ j if π is clear from the context).
Inspired by (2.1), let us introduce [40] the polynomials M n (x, y, u, v) defined by the continued fraction with coefficients Clearly M n (x, y, u, v) is a homogeneous polynomial of degree n. Since M n (1, 1, 1, 1) = (2n − 1)!!, it is natural to expect that M n (x, y, u, v) enumerates perfect matchings of [2n] according to some natural trivariate statistic. Let us now explain, following [40], what this statistic is. Let π be a perfect matching of [2n]. We recall that a vertex i ∈ [2n] is called an opener (resp. closer) if it is the smaller (resp. larger) element of its pair. Let us say that an opener j (with corresponding closer k) is a record if there does not exist an opener i < j that is paired with a closer l > k. In other words, j is a record if there does not exist an arch (i, l) that nests above the arch (j, k). Similarly, let us say that a closer k (with corresponding opener j) is an antirecord if there does not exist a closer l > k that is paired with an opener i < j. In other words, k is an antirecord if and only if j is a record. 9 Let us now classify the closers of π into four types: • even closer antirecord (ecar) [i.e. i is even and is an antirecord]; • odd closer antirecord (ocar) [i.e. i is odd and is an antirecord]; • even closer non-antirecord (ecnar) [i.e. i is even and is not an antirecord]; • odd closer non-antirecord (ocnar) [i.e. i is odd and is not an antirecord].
Similarly, we classify the openers of π into four types: • even opener record (eor) [i.e. i is even and is a record]; • odd opener record (oor) [i.e. i is odd and is a record]; • even opener non-record (eonr) [i.e. i is even and is not a record]; • odd opener non-record (oonr) [i.e. i is odd and is not a record].
Sokal and Zeng [40] also generalized the four-variable polynomial M n (x, y, u, v) by adding weights for crossings and nestings. Given a perfect matching π ∈ M 2n , we say that a quadruplet i < j < k < l forms a crossing if i ∼ π k and j ∼ π l, and a nesting if i ∼ π l and j ∼ π k. We write cr(π) and ne(π) for the numbers of crossings and nestings of π. We now define the six-variable polynomial M n (x, y, u, v, p, q) = π∈M 2n x ecar(π) y ocar(π) u ecnar(π) v ocnar(π) p cr(π) q ne(π) (2.5a) = π∈M 2n x oor(π) y eor(π) u oonr(π) v eonr(π) p cr(π) q ne(π) . (2.5b) Here the equality of (2.5a) and (2.5b) follows again from the involution i → 2n+ 1 −i, which preserves the numbers of crossings and nestings. Sokal and Zeng [40] showed that the ordinary generating function of the polynomials M n (x, y, u, v, p, q) has an S-fraction that generalizes with coefficients for an integer n ≥ 0. When p = q = 1 this reduces to (2.2)/(2.3). Note that if u = x and/or v = y, then the weights (2.7) simplify to α 2k−1 = [2k − 1] p,q x and α 2k = [2k] p,q y, respectively. For the special case x = y = u = v, the S-fraction (2.6) was obtained previously by Kasraoui and Zeng [28] (see also [4, p. 3280]). But Sokal and Zeng [40] went even farther, by defining statistics that count the number of quadruplets i < j < k < l that form crossings or nestings with a particular vertex k in third position: cr(k, π) = #{i < j < k < l : i ∼ π k and j ∼ π l} (2.9) ne(k, π) = #{i < j < k < l : i ∼ π l and j ∼ π k} (2.10) Note that cr(k, π) and ne(k, π) can be nonzero only when k is a closer (and k ≥ 3); in geometrical terms, cr(k, π) [resp. ne(k, π)] is the number of arches of π that cross (resp. nest over) the arch whose right endpoint is k. We obviously have cr(π) = k∈closers cr(k, π) (2.11a) ne(π) = k∈closers ne(k, π) (2.11b) Sokal and Zeng [40] also defined qne(k, π) = #{i < k < l : i ∼ π l} (2.12) (they call this a quasi-nesting of the vertex k). We will use this statistic only when k is an opener: in this case qne(k, π) counts the number of times that the opener k occurs in second position in a crossing or nesting: when (i, l) ∈ G π is a pair contributing to qne(k, π), the quadruplet i < k < l, m [where (k, m) ∈ G π ] must be either a crossing or nesting (according as m > l or m < l), but we do not keep track of which one it is. Now introduce two infinite families of indeterminates a = (a ℓ ) ℓ≥0 and b = (b ℓ,ℓ ′ ) ℓ,ℓ ′ ≥0 , and define the polynomials M n (a, b) by M n (a, b) = π∈M 2n i∈openers a qne(i,π) i∈closers b cr(i,π), ne(i,π) .

T-fractions for super-augmented perfect matchings
Recall that a super-augmented perfect matching of [2n] is a perfect matching of [2n] in which we may optionally draw a wiggly line on an edge (i, i + 1) whenever i is a closer and i + 1 is an opener, and also optionally draw a dashed line on an edge (i, i + 1) whenever i is an opener and i + 1 is a closer; however, it is not allowed for a wiggly line and a dashed line to be incident on the same vertex. We denote a super-augmented perfect matching of [2n] by τ ∈ M ⋆ 2n , and we write π(τ ) ∈ M 2n for the underlying perfect matching. Of course, we say that i is an opener (resp. closer) in τ in case it is an opener (resp. closer) in π(τ ).
For τ ∈ M ⋆ 2n , we call a vertex i a • pure opener if it is an opener and not incident on any wiggly or dashed line; • pure closer if it is a closer and not incident on any wiggly or dashed line; • wiggly closer if it is a closer that is incident on a wiggly line; • dashed closer if it is a closer that is incident on a dashed line.
We also call a pair (i, i + 1) a • wiggly pair if i is a closer, i + 1 is an opener, and they are connected by a wiggly line; • dashed pair if i is an opener, i + 1 is a closer, and they are connected by a dashed line.
When f = g = 0, wiggly and dashed lines are forbidden, and Theorem 2.1 reduces to the S-fraction (2.14)/(2.15). We will prove Theorem 2.1 in Section 4. Let us now show some specializations of Theorem 2.1 that generalize the Sfractions shown in the preceding subsection. We begin by defining a 18-variable polynomial M n (x, y, u, v, x ′ , y ′ , u ′ , v ′ , x ′′ , y ′′ , u ′′ , v ′′ , p, q, p ′ , q ′ , p ′′ , q ′′ ) that generalizes (2.5a) by distinguishing the three types of closers: pure, wiggly and dashed. We let ecar • (τ ), ecar ′ (τ ) and ecar ′′ (τ ) be the number of even closer antirecords in each of these three classes, and likewise for ocar, ecnar and ocnar. We also distinguish three types of crossings and nestings, according to the nature of the closer that occurs in third position: we thus let cr • (τ ), cr ′ (τ ) and cr ′′ (τ ) be the sum of cr(k, π) over vertices k that are, respectively, pure closers, wiggly closers and dashed closers. We then define: We have: Corollary 2.2. The ordinary generating function of the polynomials (2.21) has the T-type continued fraction with coefficients
(b) k is an antirecord if and only if ne(k, π) = 0.
Proof. (a) Let j be the opener that is paired with the closer k. For each i < k, let σ(i) ( = i) be the element with which it is paired. Then the set {i : i < k}, which has cardinality k − 1, can be partitioned as The first of these sets has cardinality 1; the second has even cardinality; the third has cardinality ne(k, π); and the fourth has cardinality cr(k, π).
(b) As explained earlier, a closer k (with corresponding opener j) is an antirecord if and only if there does not exist a closer l > k that is paired with an opener i < j. But this is precisely the statement that ne(k, π) = 0.
Proof of Corollary 2.2. In (2.17) we set a ℓ = 1 for all ℓ ≥ 0 and x if ℓ ′ = 0 and ℓ is even y if ℓ ′ = 0 and ℓ is odd u if ℓ ′ ≥ 1 and ℓ + ℓ ′ is even v if ℓ ′ ≥ 1 and ℓ + ℓ ′ is odd and similarly for f and g. The result then follows from Theorem 2.1.
If we further specialize (2.21) by setting x = y, u = v, x ′ = y ′ , u ′ = v ′ , x ′′ = y ′′ , u ′′ = v ′′ , we obtain 12-variable polynomials that count closers of each of three types (pure, wiggly or dashed) according to whether they are antirecords or not -but now forgetting whether they are even or odd -and also count crossings and nestings of each of three types (pure, wiggly or dashed): Their T-fraction is with coefficients Note that the forms of the coefficients (2.29) are no longer alternating between even and odd, because we are no longer distinguishing even closers from odd closers. If we further specialize this to u ′ = x ′ , then the coefficients (2.29) simplify to And if we specialize (2.29) or (2.30) to u = x and/or u ′′ = x ′′ , then the combinations involving those variables simplify as well: When the three specializations u = x, u ′ = x ′ , u ′′ = x ′′ are made, we are no longer distinguishing antirecords from non-antirecords.
It is now an easy matter to deduce Theorem 1.2. We recall that the polynomial W n (x, u, z, w ′ , w ′′ ) was defined in the Introduction to be the generating polynomial for super-augmented perfect matchings of [2n] in which each pure closer with crossing number 0 gets a weight x, each pure closer with crossing number ≥ 1 gets a weight u, each dashed line for which the two endpoints belong to the same arch gets a weight z, each other dashed line gets a weight w ′′ , and each wiggly line gets a weight w ′ . We now observe that whenever i is an opener and i + 1 is a closer, we have cr(i + 1, π) = 0 if and only if there is an arch from i to i+ 1: for if there is an arch from i to i+ 1, then obviously it is not crossed by any other arch; and if there is not an arch from i to i+1, then there must exist j < i < i + 1 < k such that there are arches (j, i + 1) and (i, k). This applies in particular whenever there is a dashed line from i to i+1. So saying that each dashed line for which the two endpoints belong to the same arch gets a weight z and each other dashed line gets a weight w ′′ is equivalent to saying that each dashed closer with crossing number 0 (resp. ≥ 1) gets a weight z (resp. w ′′ ). Comparing this with (2.25), it follows that the polynomial W n (x, u, z, w ′ , w ′′ ) is obtained from (2.21) by setting as claimed in Theorem 1.2.

Preliminaries
Our proof of Theorem 2.1 will be based on Flajolet's [18] combinatorial interpretation of continued fractions in terms of Dyck and Motzkin paths, adapted slightly to handle Schröder paths, together with a bijection that maps super-augmented perfect matchings to labeled Schröder paths. We begin by reviewing briefly these two ingredients.

Combinatorial interpretation of continued fractions
Recall that a Motzkin path of length n ≥ 0 is a path ω = (ω 0 , . . . , ω n ) in the right quadrant N × N, starting at ω 0 = (0, 0) and ending at ω n = (n, 0), whose steps s j = ω j − ω j−1 are (1, 1) ["rise"], (1, −1) ["fall"] or (1, 0) ["level"]. We write M n for the set of Motzkin paths of length n, and M = ∞ n=0 M n . A Motzkin path is called a Dyck path if it has no level steps. A Dyck path always has even length; we write D 2n for the set of Dyck paths of length 2n, and D = ∞ n=0 D 2n . Let a = (a i ) i≥0 , b = (b i ) i≥1 and c = (c i ) i≥0 be indeterminates; we will work in the ring Z[[a, b, c]] of formal power series in these indeterminates. To each Motzkin path ω we assign a weight W (ω) ∈ Z[a, b, c] that is the product of the weights for the individual steps, where a rise starting at height i gets weight a i , a fall starting at height i gets weight b i , and a level step at height i gets weight c i . Flajolet [18] showed that the generating function of Motzkin paths can be expressed as a continued fraction: as an identity in Z[[a, b, c]].
In particular, if a i−1 b i = β i t 2 and c i = γ i t (note that the parameter t is conjugate to the length of the Motzkin path), we have so that the generating function of Motzkin paths with height-dependent weights is given by the J-type continued fraction (1.2). Similarly, if a i−1 b i = α i t and c i = 0 (note that t is now conjugate to the semi-length of the Dyck path), we have so that the generating function of Dyck paths with height-dependent weights is given by the S-type continued fraction (1.1).
Let us now show how to handle Schröder paths within this framework. A Schröder path of length 2n (n ≥ 0) is a path ω = (ω 0 , . . . , ω 2n ) in the right quadrant N × N, starting at ω 0 = (0, 0) and ending at ω 2n = (2n, 0), whose steps are (1, 1) ["rise"], (1, −1) ["fall"] or (2, 0) ["long level"]. We write s j for the step starting at abscissa j − 1. If the step s j is a rise or a fall, we set s j = ω j − ω j−1 as before. If the step s j is a long level step, we set s j = ω j+1 − ω j−1 and leave ω j undefined; furthermore, in this case there is no step s j+1 . We write h j for the height of the Schröder path at abscissa j whenever this is defined, i.e. ω j = (j, h j ). Please note that ω 2n = (2n, 0) and h 2n = 0 are always well-defined, because there cannot be a long level step starting at abscissa 2n − 1. We write S 2n for the set of Schröder paths of length 2n, and S = ∞ n=0 S 2n . There is an obvious bijection between Schröder paths and Motzkin paths: namely, every long level step is mapped onto a level step. If we apply Flajolet's master theorem with a i−1 b i = α i t and c i = δ i+1 t to the resulting Motzkin path (note that t is now conjugate to the semi-length of the underlying Schröder path), we obtain ∞ n=0 t n ω∈S 2n (3.4) so that the generating function of Schröder paths with height-dependent weights is given by the T-type continued fraction (1.3). More precisely, every rise gets a weight 1, every fall starting at height i gets a weight α i , and every long level step at height i gets a weight δ i+1 . This combinatorial interpretation of T-fractions in terms of Schröder paths was found recently by several authors [21,27,31,39].

Labelled Schröder paths
Many authors, starting with Flajolet [18], have used bijections from combinatorial objects onto labeled Motzkin or Dyck paths in order to prove J-fraction or S-fraction expansions for the (weighted) ordinary generating functions of those objects. Here we will do the same with labeled Schröder paths in order to prove T-fraction expansions. The definitions are as follows: Let A = (A k ) k≥0 , B = (B k ) k≥1 and C = (C k ) k≥0 be sequences of nonnegative integers. An (A, B, C)-labeled Schröder path of length 2n is a pair (ω, ξ) where ω = (ω 0 , . . . , ω 2n ) is a Schröder path of length 2n, and ξ = (ξ 1 , . . . , ξ 2n ) is a sequence of integers satisfying [For typographical clarity we have here written A(k) as a synonym for A k , etc.] If step s i is undefined (because step s i−1 was a long level step), then ξ i is also undefined. We denote by S 2n (A, B, C) the set of (A, B, C)-labeled Schröder paths of length 2n.
Let us stress that the numbers A k , B k and C k are allowed to take the value 0. Whenever this happens, the path ω is forbidden to take a step of the specified kind at the specified height.
We shall also make use of multicolored Schröder paths. A k-colored Schröder path is simply a Schröder path in which each long level step has been given a "color" from the set {1, 2, . . . , k}. In other words, we distinguish k different types of long level steps. An (A, B, C (1) , . . . , C (k) )-labeled k-colored Schröder path of length 2n is then defined in the obvious way, where we use the sequence C (j) to bound the label ξ i when step i is a long level step of type j. We denote by S 2n (A, B, C (1) , . . . , C (k) ) the set of (A, B, C (1) , . . . , C (k) )-labeled k-colored Schröder paths of length 2n.

Proof of Theorem 2.1
We will prove Theorem 2.1 by constructing a bijection from the set M ⋆ 2n of super-augmented perfect matchings of [2n] onto the set of (A, B, C (1) , C (2) )-labeled 2-colored Schröder paths of length 2n, where When restricted to ordinary perfect matchings of [2n] (i.e. super-augmented perfect matchings with no wiggly or dashed lines), our bijection maps onto labeled Dyck paths and coincides with the bijection used by Flajolet [18] and Kasraoui-Zeng [28]. 10 We will begin by explaining how the Schröder path ω is defined; then we will explain how the labels ξ are defined; next we will prove that the mapping is indeed a bijection; next we will translate the various statistics from M ⋆ 2n to our labeled Schröder paths; and finally we will sum over labels ξ to obtain the weight W (ω) associated to a Schröder path ω, which upon applying (3.4) will yield Theorem 2.1.
• If i is a pure closer, then s i is a fall, so that h i = h i−1 − 1.
• If (i, i + 1) is a wiggly pair, then s i is a long level step of type 1 (and s i+1 is undefined). In this case the height h i is undefined, but we have h i+1 = h i−1 .
• If (i, i + 1) is a dashed pair, then s i is a long level step of type 2 (and s i+1 is undefined). In this case the height h i is undefined, but we have h i+1 = h i−1 .
(See Figure 2 for an example.) The interpretation of the heights h i is almost immediate from this definition: Lemma 4.1. For i ∈ {0, . . . , 2n}, whenever the height h i is defined it equals the number of arches that are "started but unfinished" after stage i (or equivalently, before In particular, it follows that ω is indeed a Schröder path, i.e. all the heights h i are nonnegative (when they are defined) and h 2n = 0. Step 2: Definition of the labels ξ i .
• If i is a pure opener, we set ξ i = 1 as required by (4.1).
• If i is a pure closer, we look at the h i−1 arches that are "started but unfinished" after stage i − 1 (note that we must have h i−1 ≥ 1); let the openers of these arches be x 1 < x 2 < . . . < x h i−1 . Then the vertex i is paired with precisely one of these openers; if it is x j , we set ξ i = j. Obviously 1 ≤ ξ i ≤ h i−1 as required by (4.1).
• If (i, i + 1) is a wiggly pair, then we look at the h i−1 arches that are "started but unfinished" after stage i − 1, and we define ξ i exactly as in the preceding case. Again 1 ≤ ξ i ≤ h i−1 .
• If (i, i+1) is a dashed pair, then there are two possibilities [see Figure 1(b)]: the opener i and the closer i + 1 could belong to different arches (which necessarily cross), or they could belong to the same arch. In the former case we look at the h i−1 arches that are "started but unfinished" after stage i − 1, and we define ξ i as before (except that it is now vertex i + 1 rather than i that is paired with one of these openers). In the latter case we set ξ i = h i−1 + 1. Obviously 1 ≤ ξ i ≤ h i−1 + 1 as required by (4.1).
See again Figure 2.
Step 3: Proof of bijection. It is easy to describe the inverse map from labeled Schröder paths (ω, ξ) to super-augmented perfect matchings. Successively for i = 1, . . . , n, we use the 2-colored Schröder path ω to read off the type associated to step s i (opener with no wiggly or dashed line, etc.). 11 And then, if step s i corresponds to anything other than an opener with no wiggly or dashed line attached, we use the label ξ i to decide to which opener the vertex i (or i + 1) should be attached.
Step 4: Translation of the statistics. (a) If i is a pure opener, then is a wiggly pair, then also (4.4) holds.
(d) If (i, i + 1) is a dashed pair, then Proof. (a) Each of the h i−1 arches that are "started but unfinished" after stage i − 1 will either cross or nest the arch that starts at i; so this is an immediate consequence of the definition (2.12).
(b,c) Look at the h i−1 arches that are "started but unfinished" after stage i − 1, and let the openers of these arches be x 1 < x 2 < . . . < x h i−1 ; by definition the vertex i is paired with x ξ i . Then each arch starting at a point x j with j < ξ i must nest with (and lie above) the arch from x ξ i to i, while each arch starting at a point x j with j > ξ i must cross the arch from x ξ i to i.
(d) Let x 1 < x 2 < . . . < x h i−1 be as before; and let x h i−1 +1 = i. By definition the vertex i + 1 is paired with x ξ i . Then the counting of nestings and crossings is exactly as in (b,c), but with h i−1 replaced by h i−1 + 1.
Step 5: Computation of the weights (2.19). Using the bijection, we transfer the weights (2.17) from the super-augmented perfect matching τ to the labeled Schröder path (ω, ξ) and then sum over ξ to obtain the weight W (ω). This weight is factorized over the individual steps s i , as follows: • If s i is a rise starting at height h i−1 = k (so that i is a pure opener), then from (4.3) the weight is a k = a k . (4.6) • If s i is a fall starting at height h i−1 = k (so that i is a pure closer), then from (4.4) the weight is where b ⋆ k−1 was defined in (2.20).
• If s i is a long level step of type 1 at height h i−1 = k (so that (i, i + 1) is a wiggly pair and k ≥ 1), then from (4.4) the weight is • If s i is a long level step of type 2 at height h i−1 = k (so that (i, i + 1) is a dashed pair), then from (4.5) the weight is (4.9) i−1 as instructed in (3.4), we obtain the weights (2.19). This completes the proof of Theorem 2.1.

A Bijection between augmented perfect matchings and phylogenetic trees
We will now describe a bijection between augmented perfect matchings of [2n] containing ℓ wiggly lines and phylogenetic trees with n + 1 leaves and n − ℓ internal vertices. This bijection is illustrated in Figure 3.
Given an augmented perfect matching P of [2n], we construct an arch system P ′ on [2n + 1] as follows: For each arch (i, j) in P , we draw the arch (i, j + 1) in P ′ as well as a horizontal line (i, i + 1). If j and j + 1 are joined by a wiggly line in P , we make the arch (i, j + 1) wiggly in P ′ . Now each vertex i ≥ 2 in P ′ is joined to exactly one vertex on its left: if i − 1 is an opener in P , then i is joined to i − 1 by a horizontal line; whereas if i − 1 is a closer in P , then i is the closer of an arch in P ′ . Hence the graph formed by P ′ is a tree. Moreover, each opener in P ′ is joined to exactly two vertices on its right: one by an arch and one by a horizontal edge. And each non-opener in P ′ is not joined to any vertices on its right.
We now label the vertices in P ′ that are not openers by using the numbers 1, . . . , n + 1 in order from left to right (shown in black roman font in Figure 3). Each labeled vertex in P ′ is not joined to any vertices on its right. Hence we can define a planar rooted binary tree T 2 that is isomorphic as a labeled graph to P ′ , such that horizontal edges in P ′ correspond to left edges in T 2 , while arches in P ′ correspond to right edges of T 2 (which are wiggly whenever the corresponding arch is wiggly). Since wiggly edges in the perfect matching join closers to openers, the child of a wiggly edge in T 2 cannot be a leaf.
Finally, to construct the phylogenetic tree T , we simply contract all wiggly edges of T 2 . Since the child of a wiggly edge in T 2 cannot be a leaf, each internal vertex in T has at least two children, so T is indeed a phylogenetic tree.
To show that this is a bijection, we will describe the reverse transformation. Given a phylogenetic tree T , we start by labeling each internal vertex of T with the minimum label amongst its descendants (shown in red italic in Figure 3). We then order the children of each vertex from left to right in increasing order of their label. It is easy to see that the tree T constructed from an augmented perfect matching will always be drawn in this way. Now we will describe how to construct the tree T 2 from T . For each vertex v with degree at least 3, let c 1 , c 2 , . . . , c k be the children of v in order from left to right (that is, in increasing order of labels). Then we split v into a sequence of vertices v 1 , . . . , v k−1 of out-degree 2 so that the left child of v i is c i and the right child of v i is v i+1 if i < k − 1, while the right child of v k−1 is c k . Moreover, each edge joining v i to its right child v i+1 is wiggly. We then label each new vertex with the same label as its left child. To construct P ′ from T 2 , we just have to order the vertices from left to right. If u and v are vertices of T 2 such that u has a lower label than v, then we say u < v, and if v is the left child of u (so they have the same label) then we also say u < v. We construct P ′ by placing the vertices in increasing order according to <. Finally P is constructed from P ′ by creating an arch (i, j) for each arch (i, j + 1) in P ′ , and a wiggly line (j, j + 1) for each wiggly arch (i, j + 1) in P ′ .
Since the transformations between P and T are inverses, each transformation is a bijection.

B Recurrence for polynomials defined by the general linear T-fraction
Consider the T-fraction with coefficients α i = x + (i − 1)u and δ i = z + (i − 1)w, and let W n (x, u, z, w) be the polynomials that it generates: We will prove: Proposition B.1. The ordinary generating function f (t; x, u, z, w) satisfies the nonlinear partial differential equation Equivalently, the polynomials W n (x, u, z, w) satisfy the nonlinear differential recurrence W n = δ n0 + (z + nu)W n−1 + (u + w) u ∂W n−1 ∂u + x ∂W n−1 ∂x In particular, when we restrict to u = x, we obtain a linear partial differential equation and a linear differential recurrence: Corollary B.2. The ordinary generating function g(t; x, z, w) def = f (t; x, x, z, w) satisfies the linear partial differential equation g = 1 + (x + z)tg + ut 2 g t + (u + w)t(ug u + xg x ) . (B.4) Equivalently, the polynomials P n (x, z, w) def = W n (x, x, z, w) satisfy the linear differential recurrence P n = δ n0 + (z + nx)P n−1 + x(x + w) ∂P n−1 ∂x (B.5) where P −1 def = 0. Equivalently, if we write W n (x, x, z, w) = n k=0 W n,k (z, w) x k , then the polynomials W n,k (z, w) satisfy the linear recurrence W n,k = (n + k − 1) W n−1,k−1 + (z + kw) W n−1,k for n ≥ 1 (B.6) with initial condition W 0,k = δ k0 .
On the other hand, when we restrict to w = −u, the ordinary generating function satisfies a nonlinear ordinary differential equation of Riccati type: where ′ denotes ∂/∂t. Equivalently, the polynomials Q n (x, u, z) def = W n (x, u, z, −u) satisfy the nonlinear recurrence Q n = δ n0 + (z + nu)Q n−1 + (x − u) And finally, when we restrict to u = 0, the ordinary generating function satisfies a nonlinear ordinary differential equation of Riccati type, but in the variable x rather than t: Corollary B.4. The ordinary generating function H(x; t, z, w) def = f (t; x, 0, z, w) satisfies the Riccati equation Proof of Proposition B.1. A combinatorial interpretation of the polynomials W n (x, u, z, w) was given in Theorem 1.2: namely, W n (x, u, z, w) is the generating polynomial for super-augmented perfect matchings of [2n] in which each pure closer with crossing number 0 gets a weight x, each pure closer with crossing number ≥ 1 gets a weight u, each dashed line for which the two endpoints belong to the same arch gets a weight z, each other dashed line gets a weight w ′′ , and each wiggly line gets a weight w ′ , whenever w = w ′ + w ′′ . Here we use the interpretation with w ′ = 0, so that wiggly lines are forbidden.
The contribution to f from the case with no arches (n = 0) is clearly 1. Otherwise, let the arch whose opener is vertex 1 be called α, and call the closer of this arch c α . Let A ′ be the perfect matching that remains when α, its incident vertices and their incident dashed lines are removed, and let t a+b+c+d x a u b z c w d be the contribution of A ′ to f . We will proceed by considering five cases for the type of α, as illustrated in Figure 4.
Case (i) is when vertex 1 is incident on a dashed line. Then vertex 2 is a closer, so it must close α, i.e. c α = 2. Then A ′ can be any dash-augmented arch system, so the contribution from this case is ztf .
In the remaining four cases, vertex 1 is a pure opener. Case (ii) is when c α is incident on a dashed line. Then α contributes the weight wt. The closer c α can be placed immediately after any pure opener in A ′ , of which there are a + b. Hence the contribution to f from arch systems corresponding to the smaller arch system A ′ is (a + b)t a+b+c+d+1 x a u b z c w d+1 . Summing this over all possible arch systems A ′ yields the contribution wt(uf u + xf x ) from this case.
In the remaining three cases, c α is a pure closer. Case (iii) is when c α immediately follows the opener of a different arch (then c α necessarily has crossing number ≥ 1). This is identical to Case (ii) except that we do not attach a dashed line to c α , so α contributes the weight ut instead of wt. Hence the contribution from this case is ut(uf u + xf x ). Case (iv) is when α has crossing number 0. Then the arch system A ′ separates into two sections A ′ 1 and A ′ 2 , as shown in Figure 4, where A ′ 1 is the section contained under α and A ′ 2 is the section which follows c α . The arch α contributes the weight xt, so the contribution from this case is xtf 2 .
Case (v) is when α has crossing number ≥ 1 and c α immediately follows another closer. If we remove the condition that α has crossing number ≥ 1, then c α can follow any closer in A ′ , so there are a + b + c + d possible positions for c α . Ignoring the weight contributed by α, these are counted by tf t . Now we subtract f 2 from this to remove the cases where α has crossing number 0 (namely, Case (iv)); however, we add back f to account for the case in which c α is vertex 2. Multiplying all this by the weight ut of α yields the contribution ut(tf t − f 2 + f ) for this case.
Adding the contributions from all five cases yields the desired result.