Reductions of Binary Trees and Lattice Paths induced by the Register Function

The register function (or Horton-Strahler number) of a binary tree is a well-known combinatorial parameter. We study a reduction procedure for binary trees which offers a new interpretation for the register function as the maximal number of reductions that can be applied to a given tree. In particular, the precise asymptotic behavior of the number of certain substructures ("branches") that occur when reducing a tree repeatedly is determined. In the same manner we introduce a reduction for simple two-dimensional lattice paths from which a complexity measure similar to the register function can be derived. We analyze this quantity, as well as the (cumulative) size of an (iteratively) reduced lattice path asymptotically.


INTRODUCTION
The aim of this paper is to investigate local substructures that appear within discrete objects after reducing according to, in some sense, intrinsic rules. In particular, there are two reductions we focus on: a reduction for binary trees, as well as a reduction for simple two-dimensional lattice paths.
In order to give a summary of our results we will briefly sketch both reductions and explain the nature of the local structures emerging when applying the reduction repeatedly.
On a general note, we made heavy use of the open-source mathematics software system SageMath [1] in order to perform the computationally intensive parts of the asymptotic analysis for all of the parameters investigated in this paper. Files containing these computations as well as instructions on how to run them with SageMath can be found at https://benjamin-hackl.at/publications/register-reduction/. This means that the number of binary trees with n inner nodes is given by the nth Catalan number C n = 1 n+1 2n n . By simple algebraic manipulations, it is easy to verify that the generating function B(z) satisfies the identity However, as we will see in Section 2, we can justify this identity from a combinatorial point of view as well, and the most important part of this combinatorial interpretation is a reduction procedure for binary trees.
Essentially, this procedure first removes all leaves from the tree and then "repairs" the resulting object by collapsing chains of nodes with only one child into one node. More details on this reduction are provided in Section 2.
With the help of this reduction we can assign labels to all nodes in a given tree by tracking how many iterated tree reductions it takes until the node is deleted. Note that collapsing some nodes into one node does not count as deleting the node. In Section 2 we prove that these labels are intimately linked with a very well-known and well-studied branching complexity measure of binary trees: the register function.
The local structures we are interested in also become visible after labeling a tree as described above: the so-called r-branches of a binary tree are the connected subgraphs of nodes with label r. The number of these r-branches in a random tree of size n is modeled by the random variable X n;r : n → 0 , where n is the set of all binary trees of size n. A proper definition as well as results on r-branches can be found in Section 2.2.
In the context of binary tree reductions we are interested in precise analyses of the random variables X n;r as well as X n := r≥0 X n;r , which models the total number of branches in a random tree of size n. This quantity is investigated closely in Section 2. 3. Table 1 gives an overview of the results of our investigation. The results for the register function are well-known, which is why we refer to external literature instead. Additionally, Theorem 2 proves asymptotic normality for the number of r-branches X n;r .
Register function r-branches (X n;r ) branches total (X n ) range [ Let be the combinatorial class of simple two-dimensional lattice paths, i.e., the set of all nonempty sequences over {↑, →, ↓, ←}. It is easy to see that the corresponding generating function is Similarly to before, it is easy to check by algebraic manipulation that L(z) satisfies the functional equation However, as in the case of binary trees, we will see in Section 3 that the combinatorial interpretation of this equation is much more fruitful and gives rise to a reduction procedure for lattice paths.
In this case it takes a bit more to fully describe the reduction. The core idea is to reduce a given path by collapsing an entire horizontal-vertical segment (i.e. a path segment that consists of a sequence of horizontal movements followed by a sequence of vertical movements) into a single step.
The first parameter of interest in this context is the reduction degree of a random path of length n, which is the number of repeated reductions that it takes until the entire path is reduced to a single step. We will model this parameter with the random variable D n : n → 0 , where n consists of all simple two-dimensional lattice paths of length n.
As an analogue to the number of r-branches in a given binary tree we consider the length of the rth fringe, i.e., the rth reduction of a given lattice path. This quantity is modeled by the random variable X L n;r : → 0 . By summation of the length of the rth fringe for r ≥ 0 we obtain the total fringe size X L n := r≥0 X L n;r . In some sense, the total fringe size measures the complexity of horizontalvertical direction changes of a given lattice path. Both, the rth fringe size as well as the total fringe size are analyzed in Section 3.2. Table 2 gives an overview of the results of our investigation.

TREE REDUCTIONS AND THE REGISTER FUNCTION
2.1. Motivation and Preliminaries. As mentioned in the introduction, we want to find a combinatorial proof of the following proposition.
Reduction degree (D n ) r-fringes (X L n;r ) total fringe size (X L n ) range Proposition  , satisfies the identity (1) Proof. We consider the following reduction of a binary tree t, which we write as Φ(t): First, all leaves of t are erased. Then, if a node has only one child, these two nodes are merged; this operation will be repeated as long as there are such nodes. The leaves of the reduced tree are precisely the nodes without children.
This operation was introduced in [32]. The various steps of the reduction are depicted in Figure 1. The numbers attached to the nodes will be explained later.
Note that Φ( ) is undefined, so this is a partial function. Of course, many different trees are mapped to the same binary tree. However, they can all be obtained from a given reduced tree by the following operations: All leaves and all internal nodes in the tree are replaced by chains of internal nodes. In such a chain, there has to be at least one leaf attached to every internal node; the symbolic equation for chains is Obviously, these substitutions do not only restore the (previously deleted) leaves, but can also "unmerge" previously merged nodes. Thus, all trees that reduce to some tree t can be reconstructed from t . From the symbolic equation of chains above, we find that the generating function C(z) counting chains with respect to their size (i.e. number of internal nodes) satisfies the equation C(z) = z + 2zC(z) and thus, we obtain Finally, if F (z) is a generating function counting some family of binary trees, then the bivariate generating function vF (zv) counts the same family with respect to size (variable z) and number of leaves (variable v). This is a direct consequence of the fact that binary trees with n inner nodes have n + 1 leaves. Therefore, replacing all nodes of a binary tree with chains corresponds to the substitutions v → z 1−2z and z → z 1−2z in the language of generating functions. Therefore, all binary trees that can be reconstructed from a reduced version of itself are counted by By all these considerations, (1) can be interpreted combinatorially as the following statement: a binary tree is either just , or it can be reconstructed from another binary tree where all nodes are replaced by chains.
Remark. Note that (1) can be used to find a very simple proof for a well-known identity for Catalan numbers: Comparing the coefficients of z n+1 , (1) leads to which is known as Touchard's identity [23,26].
With this interpretation in mind, (1) can also be seen as a recursive process to generate binary trees by repeated substitution of chains. This process can be modeled by the generating functions (2) By construction, B r (z) is the generating function of all binary trees that can be constructed from with up to r expansions-or, equivalently-all binary trees that can be reduced to by applying Φ up to r times.
The register function is recursively defined: for the binary tree consisting of only a leaf we have Reg( ) = 0, and if a binary tree t has subtrees t 1 and t 2 , then the register function is defined to be In particular, the numbers attached to the nodes in Figure 1 represent the values of the register function of the subtree rooted at the respective node. Historically, the idea of the register function originated (as the Horton-Strahler numbers) in [13,25] in the study of the complexity of river networks. However, the very same concept also occurs within a computer science context: arithmetic expressions with binary operators can be expressed as a binary tree with data in the leaves and operators in the internal nodes. Then, the register function of this binary expression tree corresponds to the minimal number of registers needed to evaluate the expression.
There are several publications in which the register function and related concepts are investigated in great detail, for example Flajolet, Raoult, and Vuillemin [9], Kemp [15], Flajolet and Prodinger [8], Nebel [18], Drmota and Prodinger [4], and Viennot [27]. For a detailed survey on the register function and related topics see [22].
We continue by observing that the tree reduction Φ is a very natural operation regarding the register function: Proposition 2.2. Let t be a binary tree with Reg(t) = r ≥ 1. Then Φ(t) is well-defined and the register function of the reduced tree is Reg(Φ(t)) = r − 1.
Proof. First, observe that all trees with at least one internal node have a node with two leaves attached. Therefore, this node has register function 1-and thus, only has register function 0. Consequently, if we have Reg(t) ≥ 1, t cannot be , meaning that Φ(t) is well-defined. Now take an arbitrary binary tree t with at least one internal node and assume that we have Reg(Φ(t)) = r. As described above, the tree t can be reconstructed from Φ(t) by replacing all nodes (i.e. leaves and internal nodes) by chains of internal nodes.
When replacing internal nodes with chains of internal nodes, nothing changes for the register function: the value is just propagated up along the chain. However, if all leaves are replaced by chains, the register function of all subtrees that are rooted at a internal node increases by 1, resulting in Reg(t) = r + 1. This proves the proposition.
As an immediate consequence of Proposition 2.2 we find that Φ can be applied r times repeatedly to some binary tree t if and only if Reg(t) ≥ r holds. In particular, we obtain With (3), the link between the generating functions B r (z) from above and the register function becomes clear: B r (z) is exactly the generating function of binary trees with register function ≤ r.
In order to analyze these recursively defined generating functions an explicit representation is convenient. As it turns out, the substitution z = u (1+u) 2 =: Z(u) is a helpful tool in this context.

Proposition 2.3. Consider the complex functions
where the principal branch of the square root function is chosen as usual, i.e., as a holomorphic function on \ ≤0 such that 1 = 1. Then the following properties hold: (1 + u) 3 and (a) We first note that Z is well-defined and holomorphic on with Z (u) = 0 for all u ∈ . If |u| = 1, then Thus, the image of the unit circle without u = −1 is the interval [1/4, ∞). For every z ∈ \ {0}, z = Z(u) is equivalent to which has two not necessarily distinct solutions u 1 , u 2 ∈ with u 1 u 2 = 1. W.l.o.g., |u 1 | ≤ |u 2 |. Thus either u 1 ∈ and |u 2 | > 1 or |u 1 | = |u 2 | = 1. In the latter case, we have z ∈ [1/4, ∞). For z = 0, z = Z(u) is equivalent to u = 0. This implies that Z : → is bijective.
Furthermore, Z : → has a holomorphic inverse Z −1 defined on the simply connected region . Solving (4) explicitly yields In a neighborhood of zero, we must have Z −1 (z) = U(z), because has a pole at z = 0. Altogether this proves that U is the inverse of Z. (b) For z ∈ [1/4, ∞), we know that U(z) is on the unit circle. It is easily checked that Im U(z) = − |1 − 4z|/(2z) for these z, thus Im U(z) ∈ . (c) The two relations follow directly from the definition of Z. (d) This can be shown by straightforward computation: we obtain where (c) is used. (e) By writing (4) as In a nutshell, the fact that σ • Z = Z • (u → u 2 ) means that applying σ in the "z-world" corresponds to squaring in the "u-world". As we will see in a moment, this is very useful for expressing recursively defined generating functions like the one encountered above explicitly.
Proposition 2.4. Let F 0 , D, and E be complex functions that are analytic in a neighborhood of 0. Then the recursively defined functions F r (z) = D(z) + E(z)F r−1 (σ(z)), r ≥ 1 (5) can be written explicitly by means of the substitution z = u (1+u) 2 as Proof. Let j ∈ . Observe that by repeated application of Property (d) of Proposition 2.3 we can write u 2 j (1 + u 2 j ) 2 = Z(u 2 j ) = σ(Z(u 2 j−1 )) = · · · = σ j (Z(u)) = σ j (z), where σ j (z) denotes the j-fold application of σ to z. This lets us write (6) as This expression follows from (5) by induction over r.
With Proposition 2.4 we have an appropriate tool for analyzing B r (z), the generating function enumerating binary trees with register function ≤ r. With D(z) = 1, E(z) = z 1−2z , and Property (c) of Proposition 2.3 the recurrence in (2) yields Note that at this point, we can determine the generating function B = r (z) counting binary trees with register function equal to r with respect to their size as This explicit representation of B = r (z) could be used to determine the asymptotic behavior of the register function. However, as these properties are well-known (cf. [9]), we will continue in a different direction by studying the number of so-called r-branches-where we will also encounter the generating function B = r (z) again. 2.2. r-branches. The register function associates a value to each node (internal nodes as well as leaves), and the value at the root is the value of the register function of the tree. An r-branch is a maximal chain of nodes labeled r. This must be a chain, since the merging of two such chains would already result in the higher value r + 1. The nodes of the tree are partitioned into such chains, from r = 0, 1, . . .. Figure 2 illustrates this situation for a tree of size 13.
The goal of this section is the study of the parameter "number of r-branches", in particular, the average number of them, assuming that all binary trees of size n are equally likely.
Formally, we investigate this parameter via the family of random variables (X n;r )n≥0 r≥0 where X n;r : n → 0 counts the number of r-branches in binary trees of size n. This parameter was the main object of the paper [32], and some partial results were given that we are now going to extend. In contrast to this paper, our approach relies heavily on generating functions which, besides allowing us to verify the results in a relatively straightforward way, also enables us to extract explicit formulae for the expectation (and, in principle, also for higher moments).
A parameter that was not investigated in [32] is the total number of r-branches, for any r, i.e., the sum over r ≥ 0. Here, asymptotics are trickier, and the basic approach from [32] cannot be applied. However, in this paper we use the Mellin transform, combined with singularity analysis of generating functions, a multi-layer approach that also allowed one of us several years ago to solve a problem by Yekutieli and Mandelbrot, cf. [20]. The origins of singularity analysis can be found in [7], and for a detailed survey see [10].
For reasons of comparisons, let us mention that the value of register function in [32] are one higher than here, and that n generally refers there to the number of leaves, not nodes as here.
According to our previous considerations, after r iterations of Φ, the r-branches become leaves (or, equivalently, 0-branches).

. Binary tree with colored r-branches
We begin our detailed analysis of the random variables enumerating r-branches by studying sharp bounds for this parameter.
Proof. First, recall that r-branches are nothing else than leaves in the r-fold reduced tree. Thus, X n;0 counts the number of leaves in a binary tree with n inner nodes-and it is a well-known fact that binary trees with n inner nodes always have n + 1 leaves.
For the lower bound we observe that in every tree with at least one inner node, there is a node to which two leaves are attached. This node is part of a (possibly larger) 1branch. Therefore, 1 is a lower bound for X n;1 where n > 0. Chains are an example for arbitrarily large binary trees where the lower bounds 1 and 0 are attained for r = 1 and r > 1, respectively.
As there are finitely many binary trees of size n, there is a tree t for which X n;r attains its maximum value M ∈ 0 , meaning that the r-fold reduced tree Φ r (t) has M leaves. In order to obtain an estimate between M and n we expand the reduced tree r-times by successively replacing leaves by cherries, which are chains of size one. By doing so, the number of leaves doubles after every iteration, which means that our new tree has M · 2 r leaves-or, equivalently, M · 2 r − 1 inner nodes. Because t cannot be smaller than the tree we have just constructed, the inequality M · 2 r − 1 ≤ n has to hold. This proves the upper bound in the statement above.
In order to show that the upper bound is sharp as well, we consider the family of binary trees (B m ) m≥1 , where B m denotes the unique almost complete binary tree with m leaves, which is constructed by adding the nodes layer-to-layer from left to right. For these trees, Almost complete binary trees we can prove that Φ(B m ) = B m/2 : in case m is even, reducing the tree is equivalent to replacing all cherries on the lower levels by leaves, effectively halving the number of leaves. If m = 2k + 1 is odd, there is a node whose left and right child is an inner node and a leaf, respectively. In particular, the subtree in question looks like B 3 illustrated in Figure 3b. When reducing this tree, the left child has to be merged with its parent. This shows that in total, Φ(B 2k+1 ) has k leaves. By applying Φ(B m ) = B m/2 iteratively, and by m 2 r = 1 2 m 2 r−1 we see that B n+1 , which is a binary tree of size n, attains the upper bound for the number of r-branches.
Next we analyze the asymptotic behavior of the expectation and variance of X n;r . Theorem 1. Let r ∈ 0 be fixed. The expected number X n;r of r-branches in binary trees of size n and the corresponding variance X n;r have the asymptotic expansions X n;r = n 4 r + 1 6 1 + 5 Remark. The main terms (without error terms) of the asymptotic expansions for the expectation and the variance of the number of r-branches have already been determined in [17].
Proof. We begin our asymptotic analysis by constructing the generating function of the total number of leaves in all trees of size n. First, observe that the bivariate generating function allowing us to count the leaves of the binary trees is vB(zv). Hence, the generating function counting the total number of leaves among all trees of size n is given by Following the same recursive procedure as described in the proof of Proposition 2.1 and replacing all nodes of a given tree by chains, the leaves become 1-branches. Generally speaking, expanding a tree lets the r-branches become (r + 1)-branches. In particular, this means that after r iterations of the tree expansion, the leaves have become r-branches.
With this in mind, we want to construct the generating function F (1) r (z) that enumerates the sum of the number of r-branches over all trees with the same size, which is marked by z. As 0-branches are leaves, the expression determined above is precisely F . This is justified by the argument where |t| denotes the size of a tree t ∈ .
Altogether, we obtain the recursion , which is the expected number of r-branches in a random tree of size n.
In order to analyze F (1) r (z) we rewrite it using Proposition 2.4 and the fact that D(z) = 0 and E(z) = z 1−2z . Thus, we obtain The generating function F (1) r (z) has a singularity at z = 1/4, so we have to locally expand the function in terms of 1 − 4z such that the methods of singularity analysis can be applied.
Expansion yields Singularity analysis [10, Chapter VI] guarantees that one can read off coefficients in this expansion: The asymptotics of C n are straightforward, especially for a computer. By performing singularity analysis on the generating function B(z) we obtain Division of the two expansions yields (9). In principle, any number of terms would be available.
We also determine the variance by virtually the same approach. In this case we determine the variance using the second factorial moment. Let F (2) r (z) be the generating function of the unnormalized second factorial moment of the number of r-branches, i.e., By analogous argumentation as before we know that F (2) 0 (z) can be obtained by differentiating the bivariate generating function vB(vz) two times with respect to v and setting v = 1. This gives has to hold. Again, with the help of Proposition 2.4, we find which can be locally expanded to After determining the asymptotic contribution of these coefficients by means of singularity analysis and dividing the result by the asymptotic expansion of the Catalan numbers, we arrive at an expansion for the second factorial moment: By an elementary property of the second factorial moment, the variance can be computed by means of X n;r = X n;r (X n;r −1)+ X n;r −( X n;r ) 2 . Doing so yields (10) and thus, concludes the proof.
Of course, the expected number of r-branches can also be computed explicitly by using Cauchy's integral formula. This yields the following result: Proposition 2.6. The expected number X n;r of r-branches in binary trees of size n is given by the explicit formula Proof. Note that all of the following integration contours are small closed curves that wind around the origin once; the substitution does not change that. Applying Cauchy's integral formula and using the substitution z = u (1+u) 2 we obtain Then, interchanging summation and integration and applying Cauchy's integral formula once again yields which, after extracting the coefficient and dividing by C n = 1 n+1 2n n , proves the statement.
We are also interested in the limiting distribution of X n;r for fixed r ∈ 0 and n → ∞. Note that as X n;0 = n + 1 is a deterministic quantity, we focus on the case that r ≥ 1.
Theorem 2. Let r ∈ be fixed. Then X n;r , the random variable modeling the number of r-branches in a binary tree of size n, is asymptotically normally distributed for n → ∞. In particular, for x ∈ we have X n;r − X n;r Remark. For the special case of 1-branches, i.e., r = 1, a central limit theorem has been proved in [29]. Additionally, numerical evidence for the validity of a general central limit theorem like the one we obtained above has been provided in [31].
Proof of Theorem 2. The central idea behind this proof is that X n;r can be interpreted as an additive tree parameter, meaning that the parameter can be evaluated as the sum of the parameters corresponding to the subtrees rooted at the children of the root of the original tree and an additional so-called toll function. In our case, it is straightforward to see that the number of r-branches in a binary tree of size n can be computed as the sum of the number of r-branches in the left and right subtree. Only in the case where both subtrees have register function r − 1, the root itself is an r-branch that is not accounted for in the subtrees.
Hence, the random variable X n;r satisfies the distributional recurrence relation X n;r = X I n ;r + X * n−1−I n ;r + T n;r , where X * n;r is an independent copy of X n;r , I n;r is a random variable modeling the size of the left subtree with and where T n;r is a toll function depending on X n;r satisfying T n;r = 1 if the register function of both rooted subtrees is r − 1, 0 otherwise.
Asymptotic normality of X n;r can now be obtained by showing that the expectation of the toll function decays exponentially, according to [28].
In order to show that this condition is satisfied we consider B = r (z), the generating function for binary trees with register function equal to r. By (8) we have By means of Property (e) in Proposition 2.3 we can write where ω k := exp(2πik/2 r+1 ). In particular, this proves that B = r (z) is a rational function. As we have Z(ω k ) = 1 2+2 cos(πk/2 r ) , the dominant singularity of B = r (z) can uniquely be identified as Z(ω 1 ) = 1 2+2 cos(π/2 r ) > 1/4, which proves that the ratio of trees with register function r among all binary trees of size n decays exponentially.
The exponential decay of the expected value of the toll function T n;r now follows from the fact that T n;r equals the ratio of the trees whose children both have register function r − 1 among all trees of size n. These trees form a subset of those counted by B = r (z), which means that their ratio has to decay exponentially as well.
The asymptotic normality of X n;r now follows from [28, Theorem 2.1]. All that remains to show is that the speed of convergence is O(n −1/2 ). In order to do so, we observe that the proof for asymptotic normality in Wagner's theorem basically relies on [3, Theorem 2.23], which uses a formulation of Hwang's Quasi-Power Theorem without quantification of the speed of convergence (cf. [3, Theorem 2.22]). By replacing this argument with a quantified version (cf. [14] or [12] for a generalization to higher dimensions) of the Quasi-Power Theorem, we find that the speed of convergence in Wagner's result-and therefore, in our result as well-is O(n −1/2 ).
2.3. The total number of branches. So far, we were dealing with fixed r, and the number of r-branches in trees of size n, for large n. Now we consider the total number of such branches, i.e., the sum over r ≥ 0, which was not considered in [32]. Formally, this corresponds to the analysis of the random variable X n : n → 0 where X n := r≥0 X n;r .
By definition, X n enumerates the total number of branches in binary trees of size n.
With the help of the bounds for the number of r-branches obtained in Proposition 2.5 we can characterize the range of X n as well.
Proposition 2.7. Let n ∈ 0 and let w 2 (n) denote the binary weight, i.e. the number of nonzero digits in the binary expansion of n. Then the bound n + 1 + n > 0 ≤ X n ≤ 2n + 2 − w 2 (n + 1) ≤ 2n + 1 holds for the random variable X n and is sharp.
Proof. We begin by observing that for fixed n ∈ , the random variable X n;r vanishes for sufficiently large r. As the bounds from Proposition 2.5 are sharp, we are allowed to sum up the inequalities in order to obtain This immediately proves the lower bound from the statement. In order to prove the upper bound we investigate the sum r≥0 m/2 r for m ∈ . Consider the binary digit expansion of m, denoted by (x k . . . x 1 x 0 ) 2 . In this context, the sum can be written as By setting m = n + 1 we see that the upper bound holds as well. The fact that 2n + 2 − w 2 (n + 1) ≤ 2n + 1 is a direct consequence of w 2 (n + 1) ≥ 1 for all n ∈ 0 .
It is easy to see that the bounds are sharp for n = 0. For n > 0, the lower bound is attained by any chain of size n: they consist of n + 1 leaves (which are 0-branches) and exactly one additional 1-branch which connects all the leaves. The upper bound is attained by the family of almost complete binary trees constructed in the proof of Proposition 2.5, which follows from the fact that X n;r attains its maximum in the tree B n+1 , which does not depend on the value of r.
First, to get an explicit formula, the results from Proposition 2.6 can be summed.
Corollary 2.8. The expected number of branches in binary trees of size n is given by the explicit formula where v 2 (k) is the dyadic valuation of k, i.e., the highest exponent ν such that 2 ν divides k.
Proof. To simplify the double summation, we consider This sum can be simplified to some degree. We write k = 2 v 2 (k) (2 j + 1), such that we have which proves the result.
While it is absolutely possible to work out the asymptotic growth from this explicit formula, at it was done in earlier papers [9,15], we choose a faster method, like in [8]. It works on the level of generating functions and uses the Mellin transform together with singularity analysis of generating functions [10,21].
The following theorem describes the asymptotic behavior for the expected number of branches in a binary tree.
is a 1-periodic function of mean zero, given by its Fourier series expansion with χ k = 2πik log 2 .
Remark. Note that the value of the derivative of the zeta function is given by ζ (−1) = − 1 12 − log A ≈ −0.1654211437, where A is the Glaisher-Kinkelin constant (cf. [5, Section 2.15]).  Remark. The occurrence of the periodic fluctuation δ where the argument is logarithmic in n is actually not surprising: while this phenomenon is already very common in the context of the register function, fluctuations appear very often in the asymptotic analysis of sums.
Proof. By using (11) and (13), the generating function of interest can be written as To find the asymptotic behavior of the sum, we set u = e −t , consider the function which is valid for real, positive t → 0, which gives an expansion for u → 1 − , or, equivalently z → (1/4) − . In order to use this representation of f (t) for our purposes (i.e. in order to apply singularity analysis), we need to have analyticity in a larger region (cf. [7]), e.g. in a complex punctured neighborhood of 1/4 with 1 |arg(z − 1/4)| > 2π/5. In particular, the expansion implies such that we have the bound |arg t| < 2π/5 for t → 0, given that the restriction on the argument in the z-world is satisfied. Then, given that Re(s) = 5 or Re(s) = −3 holds we find that we have the estimate for the integrand in (14). The very same estimate also holds for −3 ≤ Re(s) ≤ 5 where Im(s) = 2πi log 2 k + 1 2 and k ∈ tends towards ∞ or −∞. This is a consequence of the behavior of Γ(s) as given in [2, 5.11.3], estimates for ζ(s) as given in [30, 13.51], and the fact that 1 1−2 −s is bounded for s in the given ranges. Together with the identity theorem for analytic functions (cf. [8] for a similar argumentation) this means that the inverse Mellin transform remains valid for complex z in a neighborhood of 1/4 with |arg(1 − 4z)| > 2π/5, which justifies the following approach.
We can evaluate (14) by shifting the line of integration from Re(s) = 5 to Re(s) = −3 and collecting the residues of the poles we cross. This yields where P = {−2, 0, 2} ∪ {χ k | k ∈ \ {0}} and χ k := 2πik log 2 . Multiplying this representation of f (t) with 1−u 2 u and expanding everything locally for z → 1/4 yields a singular expansion from which coefficient growth can be extracted by means of singularity analysis.
For the error term we use the estimate above and find However, for the sake of simplicity we want to use the contribution of the residue collected from the pole at s = −2 as the error term. We immediately find Res s=−2 ( f * (s)t −s ) = O(|t| 2 ). 1 Note that the bound 2π/5 is somewhat arbitrary: the argument just needs to be less than π/2. We compute the remaining singularities explicitly with the help of SageMath [1] and obtain where we used the Laurent expansion for the gamma function at s = 0 (cf. . When translating this expansion in terms of t → 0 to an expansion in terms of z → 1/4, we have to be particularly careful with respect to the sum of the residues at s = χ k as we have to check that the sum of the errors is still controllable. We do so by considering the expansion With the well-known inequality This proves that the errors we sum up are of order O(|k|(1 − 4z) exp(|k|O(1 − 4z))). Thus, if z is chosen sufficiently close to 1/4, this exponential growth is slow enough to vanish within the exponential decay established in (16). Finally, by considering Applying singularity analysis, normalizing the result by C n and rewriting the coefficients of the contributions from the poles at χ k via the duplication formula for the Gamma function (cf. [2, 5.5.5]) then proves the asymptotic expansion for X n .
While this multi-layer approach enabled us to analyze the expected value of the number of branches in binary trees of size n, the same strategy fails for computing the variance. This is because the random variables modeling the number of r-branches are correlated for different values of r-and thus, the sum of the variances (which we compute by our approach) differs from the variance of the sum.
This concludes our study of the number of branches per binary tree. In the next section, we analyze a quantity that has similar properties as the register function, but is defined on simple two-dimensional lattice paths.

Iterative Reductions and an Analogue to the Register Function.
Recall that the register function describes the number of reductions of a binary tree required in order to reduce the tree to a leaf. By defining a similar process for simple two-dimensional lattice paths, a function that plays a similar role as the register function is obtained.
Simple two-dimensional lattice paths are sequences of the symbols {↑, →, ↓, ←}. It is easy to see that the generating function counting these paths (without the path of length 0) is Proposition 3.1. The generating function L(z) = 4z 1−4z satisfies the functional equation Remark. It is easy to verify this result by means of substitution and expansion. However, we want to give a combinatorial proof-this approach also motivates the definition of a recursive generation process for lattice paths, similar to the process for binary trees from above. Proof. We show that the right-hand side of (18) counts simple two-dimensional lattice paths (excluding the path of length 0) as well. In order to do so, we introduce a reduction of lattice paths denoted by Φ L , that works on a given path with length ≥ 2 as follows: First, if starts vertically (i.e. with ↑ or ↓), rotate the entire path clockwise such that it starts horizontally.
Second, if the (possibly rotated) path ends horizontally, rotate the very last step (which has to be → or ←) once again clockwise. Now, the path can be reduced by collapsing each pair of horizontal-vertical path segments into a path of length 1 as follows: • If a segment starts with → and the first vertical step is ↑, replace it by , • if a segment starts with → and the first vertical step is ↓, replace it by , • if a segment starts with ← and the first vertical step is ↓, replace it by , • and if a segment starts with ← and the first vertical step is ↑, replace it by . Finally, rotate the obtained path with the diagonal steps by 45 • clockwise such that becomes → and so on. The resulting path is the reduction Φ L ( ). This process is visualized in Figure 5.
As it is the case with the reduction Φ of binary trees, Φ L is a partial function as well: Φ L (s) is undefined for s ∈ {↑, →, ↓, ←}. Furthermore, a reduced path can be expanded (although not uniquely) to its original path again by rotating a given path to the left such that it is given in diagonal steps, reading the replacements from above from right to left, and then optionally rotating the very last step and/or the entire path to the left again.
We find that the generating function for lattice paths consisting of sequences of horizontalvertical segments is given by L z 2 (1−2z) 2 . In order to see this, consider the expansion of a path of length 1, for example → =⇒ =⇒ →(→ + ←) * ↑(↑ + ↓) * , where the regular expression describes a sequence of horizontal steps starting with →, followed by a sequence of vertical steps starting with ↑. As path length is marked by z, the expansion above translates to the substitution As all four expansion variants lead to the same variable substitution, L z 2 (1−2z) 2 precisely enumerates all lattice paths consisting of sequences of horizontal-vertical segments.
The factor 4 in (18) is explained by the four path variants obtained by either rotating just the last step and/or the entire path.
Putting all of this together, (18) can be interpreted combinatorially as the following statement: a simple two-dimensional lattice path is either a simple step, or can be obtained by expanding another simple two-dimensional lattice path. This proves the proposition.
The process described in the proof of Proposition 3.1 allows us to assign a unique number to each lattice path: Definition. Let be a simple two-dimensional lattice path consisting of at least one step. We define the reduction degree of , denoted as rdeg( ) as rdeg( ) = n ⇐⇒ Φ n L ( ) ∈ {↑, →, ↓, ←}. Remark. The parallels between the reduction degree and the register function are obvious: both count the number of times some given mathematical object can be reduced according to some rules until an atomic form of the respective object is obtained. Therefore, both functions describe, in some sense, the complexity of a given structure.
In the remainder of this section we want to derive some asymptotic results for the reduction degree, namely the expected degree of a lattice path of given length as well as the corresponding variance.
By using Proposition 2.4 with D(z) = 4z and E(z) = 4, the generating functions L r (z) can be written explicitly in terms of u as The generating function L = r (z) of lattice paths with reduction degree equal to r can then be found by considering the difference L r (z) − L r−1 (z), or, alternatively, by dropping the summand 4z in the recursion above. Both approaches lead to The coefficients of this function can be extracted explicitly by applying Cauchy's integral formula.

Proposition 3.2. The number of two-dimensional simple lattice paths of length n that have reduction degree r is given by
Proof. The proof is straightforward and uses the same approach as the proof of Proposition 2.6.
In fact, by studying the substitution z = Z(u) closely, the asymptotic behavior of the coefficients of L = r (z) can be extracted as well. Proposition 3.3. Let r ≥ 1 be fixed. Then L = r (z) is a rational function in z with poles at with singular expansions Proof. First note that all of the following estimates are not uniform w.r.t. r, meaning that the constant in the O-term depends heavily on r. From (19) and Proposition 2.3(e), it is immediately clear that L = r (z) is a rational function in z with poles at Z(ω) where ω runs through the 2 r th roots of −1. By symmetry, we restrict ourselves to ω with Im ω ≤ 0.
We now fix such an ω = exp(−kπi2 −r ) for some 1 ≤ k < 2 r , k odd. By expansion around ω, we get 4 r+1 u 2 r We know that L = r (z) has a pole of order 2 at z k = Z(ω), implying that expanding L = r (z) for z → z k yields an expansion of the form where A and B are some constants depending on k and r. With the help of Cauchy's integral formula, the substitution u = U(z), and the expansion from above we can determine the constants A and B and find Rewriting all complex exponentials in terms of trigonometric functions then yields the result.
With the help of this characterization of the poles of L = r the asymptotic behavior of the number of lattice paths with reduction degree equal to r can be obtained. + O (4 cos 2 (3π2 −r−1 )) n n , (20) where the constant in the O-term depends on r.
Proof. We use the notation of Proposition 3.3. By means of singularity analysis and by considering that L = r is a rational function, we find that the pole at z k (for odd k) yields a contribution of (up to simplification) for sufficiently large n.
We turn to the investigation of the expected reduction degree. Let n denote the set of simple two-dimensional lattice paths of size n. Consider the family of random variables D n : n → 0 modeling the reduction degree of the lattice paths of length n under the assumption that all paths are equally likely.
Similar to the investigations we have conducted for the random variables in Sections 2.2 and 2.3, we want to characterize the range of the reduction degree for lattice paths of given length n as well.
Proposition 3.5. Let n ∈ . Then the reduction degree for any simple two-dimensional lattice path of length n satisfies n > 1 ≤ D n ≤ log 2 n , and these bounds are sharp.
Proof. First, observe that for n = 1, we only have the atomic steps {↑, →, ↓, ←}, and all of them have reduction degree 0, which the lower and upper bound given above agree upon. For n > 1 we find that, e.g., the path (→) n has reduction degree 1. In combination with the fact that there are no paths of length greater than 1 with reduction degree 0, this establishes the lower bound and proves that it is sharp.
In order to prove the upper bound, we consider M to be the maximal reduction degree among all lattice paths of length n, i.e. the corresponding path can be obtained from one of the steps (of length 1) by expanding the path M times.
The shortest possible path after M expansions can be obtained by replacing every step of the path iteratively by a segment of length 2, meaning that the length doubles after every expansion. Thus, a minimally expanded path has length 2 M .
As the minimally expanded path has to be at most equally long as the original path, the inequality 2 M ≤ n and therefore M ≤ log 2 n holds, which proves the upper bound.
In order to construct a path of length n with reduction degree equal to log 2 n , we consider the binary digit expansion (x k . . . x 1 x 0 ) 2 of n. Reading this expansion from left to right, starting at x k−1 , we construct the path as follows: we start with →, if the current digit is 0 then we expand the path minimally, and otherwise we expand all but the last step of the path minimally; the last step is expanded by replacing it by a corresponding segment of length 3 (i.e. one additional step is added in contrast to minimal expansion). The digit x k = 1 is not relevant for this construction, thus it is ignored.
It is easy to see that the length of the resulting path is n, as our construction corresponds to the "double-and-add"-strategy used to determine the value of the binary expansion. Furthermore, for each of the digits in x k−1 . . . x 1 x 0 we have expanded our path once, which produces a path with reduction degree k. Finally, from the binary expansion it is easy to see that k = log 2 n holds, which proves that for all n ∈ , the upper bound above is attained for some lattice path of length n.
The following results are immediate consequences of Proposition 3.2.
Corollary 3.6. The probability that a lattice path of length n has reduction degree r is given by the explicit formula and the expected reduction degree for paths of length n is given by Proof. Analogously to our approach in Section 2.3, the double sum can be simplified by considering We find which proves (21).
Remark. The formula for (D n = r) is very similar to the results for the classical register function obtained by Flajolet (cf. [6]). It is likely that applying the techniques that were used in [16] could be used to determine expansions for arbitrary moments.
The following theorem characterizes the asymptotic behavior of the expected reduction degree and the corresponding variance.
and for the corresponding variance we have where δ 1 (x) and δ 2 (x) are 1-periodic fluctuations of mean zero which are defined as and with χ k = 2πik log 2 and constants Proof. In order to analyze the expected value D n asymptotically, we study the corresponding generating function G (1) (z) = r≥0 r L = r (z), for which we have D n = 1 4 n [z n ]G (1) (z), with an approach that is similar to the one in Theorem 3.
With the substitution u = e −t , we find where we used (13). Thus, the Mellin transform g (1) (s) = (G (1) )(s) of G (1) (which is a function in t) is given by which is analytic for Re(s) > 2. Observe that g (1) (s) has a pole of order two at s = 2, simple poles at s = 2 + χ k for k ∈ \ {0} and further simple poles at s ∈ −2 0 . As the fundamental strip of g (1) (s) is given by 〈2, ∞〉, the Mellin inversion formula yields and we compute this integral by shifting the line of integration to Re(s) = −3.
Note that analogously to the argumentation in the proof of Theorem 3, the Mellin inversion formula above is also valid for complex z in a punctured neighborhood of 1/4 where |arg(4z − 1)| > 2π/5, which allows us to apply singularity analysis.
We compute the contributions of the singularities with the help of SageMath [1]. With an analogous estimation as in the proof of Theorem 3 we find that the integral (after the shift) contributes an error of O(|t| 3 ). Again, for the sake of simplicity we take the contribution of the residue at −2 as the error term: Substituting back, controlling the error analogously to (17), applying singularity analysis, normalizing by 4 n , and rewriting the coefficients of the terms of growth n χ k /2 with the duplication formula for the gamma function (cf. [2, 5.5.5]) then proves (22) and (24).
For the analysis of the variance we turn our attention to the second moments, D 2 n . The related generating function is given by It is easy to check that the corresponding Mellin transform g (2) (s) is with a pole of order 3 at s = 2, and poles of order two at s = 2 + χ k for k ∈ \ {0}, as well as simple poles at s ∈ −2 0 . Analogously to above, the inversion formula is also valid for complex z in a punctured neighborhood around 1/4 with |arg(1 − 4z)| > 2π/5. We shift the line of integration to Re(s) = −3, which yields an error term of and collect residues. We find that Res s=0 (g (2) (s)t −s ) does not yield a contribution in terms of z. The pole at s = −2 is the leftmost pole we shift the line of integration over. For the sake of simplicity, we use the contribution of the residue at this pole as the error term, which we find to be Furthermore, the pole at s = 2 yields a residue of which translates into a local expansion of 1 4 log 2 2 log 2 (1 − 4z) and, after applying singularity analysis and dividing by 4 n , into an asymptotic contribution of log 2 4 n + γ + 2 − 3 log 2 log 2 log 4 n + 6γ 2 + π 2 − 24 log 2 π + 24γ − 48ζ (0) Observe that the logarithmic terms in this expansion cancel against the square of the expansion for D n as given in (22)-which is a common phenomenon. Next we determine the contribution of the remaining poles. Locally expanding the sum of the corresponding residues in terms of z → 1/4 and controlling the resulting error analogously to (17) where the coefficients c k and d k are defined as in the theorem. Note that all estimates still work out as the product of the gamma and the digamma function decays exponentially and the derivative of the zeta function grows at most polynomially, which is easy to see by considering the derivative by means of Cauchy's integral formula.
Putting everything together we find D 2 n = log 2 4 n + γ + 2 − 3 log 2 log 2 log 4 n + 2δ 1 (log 4 n) log 4 n + 6γ 2 + π 2 − 24 log 2 π + 24γ − 48ζ (0) 24 log 2 2 − 3γ + 4 log π + 6 2 log 2 + 4 With this result, we are able to find an expansion of the variance D n by considering the difference D 2 n − ( D n ) 2 , which yields the expansion given in (23). 3.2. Fringes. We define the rth fringe of a given lattice path of length ≥ 1 to be Φ r L ( ), i.e. the rth fringe is given by the rth reduction of the path. In particular, if can be reduced r times, we call the length of Φ r L ( ) the size of the rth fringe. Otherwise, we say that this size is 0. We model the size of the rth fringe with the random variable X L n;r : n → 0 . The rth fringes of positive size can then be enumerated by the bivariate generating function where | | denotes the length of a lattice path. Deriving a recursion for these generating functions is pretty straightforward: first, observe that for r = 0, the exponent of v always coincides with the exponent of z as Φ 0 L ( ) = for all lattice paths of length ≥ 1. Thus where L(z) is the generating function counting all paths of length ≥ 1.
The recursion itself follows from the fact that rth fringes of a path are (r − 1)th fringes of its reduction Φ L ( ). Thus, by the same argument that was used in the proof of Proposition 3.1, we have In this recursion the second parameter, v, does not change. This justifies the application of Proposition 2.4 in order to rewrite H r (z, v) by means of the substitution z = Z(u). We obtain The generating function H r (z, v) can now be used to derive the asymptotic behavior of the expectation X L n;r and the variance X L n;r of the size of the rth fringe, where all paths of length n arise with the same probability.
Proof. The proof follows the same idea as the proof of Proposition 2.5. In particular, the concept of "minimal expansion" of binary trees corresponds to expanding single steps into segments of length 2. Furthermore, an appropriate family of lattice paths can be constructed from the steps {↑, →, ↓, ←} by iteratively expanding the path either minimally, or expanding the first step into a segment of length 3 and the rest minimally.
and X L n;r = 4 r − 1 where θ r = 4 2+2 cos(2π/2 r ) > 1. If additionally r > 0, then for the random variables X L n;r modeling the rth fringe size of lattice paths of length n we have X L n;r − X L n;r X L n;r i.e. the random variables X L n;r are asymptotically normally distributed. Proof. The generating function H r (z, v) only sums over all lattice paths with reduction degree ≥ r. In a first step we show that the number of excluded paths is exponentially small when compared with the number of all paths.
In order to do so, we consider the generating function (26) we know that H r (z, 1) is a meromorphic function, i.e. all its singularities are poles and no square-root singularities can occur. In the u-world the singularities can be expressed as the 2 r th roots of unity. From the proof of Proposition 2.3 we also know that on the unit circle, Z(u) = 1 2 + 2 Re u holds, such that with Property (e) of Proposition 2.3 we know that the dominant singularity (in terms of z = Z(u)) is a simple pole at z = Z(1) = 1/4, and the next singularity is a pole of order two at θ r 4 := Z(e −2πi/2 r ) = 1 2 + 2 cos(2π/2 r ) , which translates into a contribution of O(n4 n θ −n r ).

Together with the local expansion
for z → 1/4, and with the fact that H r (z, 1) is meromorphic, we find that [z n ]H r (z, 1) = 4 n + O(n(2 + 2 cos(2π/2 r )) n ), as claimed. For determining the moments, fringes of size 0 do not yield a contribution (as they are weighted with 0), such that we can use the generating function H r (z, v).
It is easy to see that X L n;r can be obtained by dividing the coefficient of z n in ∂ H r ∂ v (z, v) v=1 by the normalization factor. In particular, we find Applying singularity analysis to this meromorphic function and dividing by 4 n yields (27). For the variance we compute asymptotic expansions for the second moment by considering the generating function In this case, singularity analysis and normalization leads to a contribution of n 2 16 r + 4 r − 1 16 r n + 16 r − 5 · 4 r + 4 15 · 16 r + O(n 5 θ r ) −n for the second moment. Subtracting ( X L n;r ) 2 from this expansion results in (28). For the limiting distribution we restrict our model to lattice paths admitting r reductions and study the corresponding random variableX L n;r . By (29) this induces an exponentially small error in the sense that (X L n;r ∈ A) = (X L n;r ∈ A) 1 + O(θ −n r ) for all A ⊆ 0 .
By singularity perturbation of meromorphic functions (cf. [10, Theorem IX.9]) we immediately find thatX L n;r is asymptotically normally distributed-and as a direct consequence of the exponentially small error observed above, X L n;r is asymptotically normally distributed as well.
As we have the generating function H r (z, v) in an explicit form, the expected value can also be extracted explicitly by means of Cauchy's integral formula. where the last step is justified by The statement of the theorem then follows by extracting the coefficients by means of the binomial theorem.
Analogously to our investigations concerning branches in binary trees, we also study the behavior of the overall fringe size, i.e. the sum over the size of the rth fringes for r ≥ 0. Like the reduction degree, this parameter can also be interpreted as a complexity measure for lattice paths. We will model this quantity with the random variable X L n := r≥0 X L n;r . A first observation regarding the behavior of X L n can be followed directly from Proposition 3.7. Proposition 3.9. Let n ∈ 0 and let w 2 (n) denote the binary weight, i.e. the number of nonzero digits in the binary expansion of n. Then the bound n + n > 1 ≤ X L n ≤ 2n − w 2 (n) ≤ 2n − 1 holds and is sharp.
Proof. Analogously to the proof of Proposition 2.7.
Furthermore, summing the explicit expressions for X L n;r obtained in Proposition 3.8 yields an explicit formula for X L n , the expected fringe size for lattice paths of length n. Corollary 3.10. The expected fringe size X L n of a random path of length n can be computed as Proof. Analogously to the proof of Corollary 2.8.
The following theorem quantifies the asymptotic behavior of X L n . Theorem 6. Asymptotically, the behavior of the expected fringe size X L n for a random path of length n is given by X L n = where δ(x) is a 1-periodic fluctuation of mean zero with Fourier series expansion δ(x) = 2 3 π log 2 k =0 Γ 3 + χ k 2 2ζ(χ k − 1) + ζ(χ k + 1) e 2kπi x .  (1 − 4z)). Analogously to the previous theorems, the remaining integral is absorbed by this error term.
By shifting the line of integration we cross a simple pole at s = 4, a pole of order two at s = 2, infinitely many simple poles at s = 2 + χ k , k ∈ \ {0}, and a simple pole in s = 0.
With P = {−2, 0, 2, 4} ∪ {2 + χ k | k ∈ \ {0}} we find that from which the statement of the theorem follows after extracting the coefficient growth of this expansion by means of singularity analysis, dividing by 4 n , and applying the duplication formula for the gamma function.