On the Number of Unary-Binary Tree-Like Structures with Restrictions on the Unary Height

We investigate various classes of Motzkin trees as well as lambda-terms for which we derive asymptotic enumeration results. These classes are defined through various restrictions concerning the unary nodes or abstractions, respectively: we either bound their number or the allowed levels of nesting. The enumeration is done by means of a generating function approach and singularity analysis. The generating functions are composed of nested square roots and exhibit unexpected phenomena in some of the cases. Furthermore, we present some observations obtained from generating such terms randomly and explain why usually powerful tools for random generation, such as Boltzmann samplers, face serious difficulties in generating lambda-terms.


Introduction
This paper is mainly devoted to the asymptotic enumeration of lambda-terms belonging to a certain subclass of the class of all lambda-terms.Roughly speaking, a lambda-term is a formal expression built of variables and a quantifier λ which in general occurs more than once and acts on one of the free variables of the subsequent sub-term.Lambda calculus is a set of rules for manipulating lambda-terms and was invented by Church and Kleene in the 30ies (see [35,36,16]) in order to investigate decision problems.It plays an important rôle in computability theory, for automatic theorem proving or as a basis for some programming languages, e.g.LISP.Due to its flexibility it can be used for a formal description of programming in general and is therefore an essential tool for analyzing programming languages (cf.[37,38]) and is now widely used in artificial intelligence.Furthermore, in typed lambda calculus types can be interpreted as logical propositions and lambda-terms of a given type as proofs of the corresponding proposition.This is known as the Curry-Howard isomorphism (see [45]) and constitutes in view of the above-mentioned link to programming a direct relationship between computer programs and mathematical proofs.
Although lambda-terms are related to Motzkin trees, the counting sequences of these two objects have widely different behaviours.In this paper, a tree-like behaviour is meant to be that the counting sequence asymptotically behaves as is typical for trees with average height asymptotically proportional to the root of the tree size.See [20] for numerous results on such trees as well as many other classes of trees.For analyzing the structure of random lambda-terms it is important to know the number of lambda-terms of a given size.It turns out that this is a very hard problem.The reason is that there are many degrees of freedom for assigning variables to a given abstraction.This leads to a large number of lambda-terms of fixed size.If we translate the counting problem into generating functions, then the resulting generating function has radius of convergence equal to zero.Thus none of the classical methods of analytic combinatorics (see [25]) is applicable.Therefore, in this paper we study simpler structures, obtained by bounding either the total number of abstractions or by introducing bounds on the levels of nesting (either globally or locally, to be formally defined in the next section) of lambda-terms.Note that the number of nesting levels of abstraction or even the number of abstractions in lambda-terms which occur in computer programming is in general assumed low compared to their size.E.g., for implementing lambda-calculus we need to bound the height of the underlying stack, which is determined by the maximal allowed number of nested abstractions.Even more, Yang et al. [47], who developed the very successful software Csmith for finding bugs in real programs like the gcc compiler, write on [47, p. 3]: "Csmith begins by randomly creating a collection of struct type declarations.For each, it randomly decides on a number of members and the type of each member.The type of a member may be a (possibly qualified) integral type, a bit-field, or a previously generated struct type."A declaration in a C program corresponds to an abstraction in a lambda-term, and the engineers chose the number of abstractions before randomly generating the rest of the program.That means that they expect the number of abstractions to be independent of the size of the lambda-term which corresponds to their program.Thus, requiring bounds like those mentioned above seems not to be a severe restriction from a practical point of view.
Preliminary results on the enumeration of lambda-terms with bounded unary height appeared in [5].
The plan of the paper is as follows: We present all the formal definitions of the objects of our interest in Section 2 and then, in Section 3, some results on restricted classes of Motzkin trees for comparison purposes.The enumeration of lambda-terms with a fixed or bounded number of unary nodes is done in Section 4. Sections 5 and 6 contain the main results of our paper.They are devoted to the enumeration of lambda-terms where all bindings have bounded unary length and lambda-terms with bounded unary height, respectively.In order to achieve our results, we first derive generating functions for the associated counting problems, which are expressed as a finite nesting of radicals.Then we study the radii of convergence and the type of their singularities.This will eventually allows us to determine their number asymptotically, as their size tends to infinity.A comparison of the two classes of lambda-terms is discussed in Section 7. Finally, we investigate how our theoretical results fit with simulations and discover some challenging facts on the average behaviour of a random lambda-term in Section 8.

Representation as directed acyclic graphs
A lambda-term is a formal expression which is described by the context-free grammar where a is a variable.The operation (T * T ) is called application.Using the quantifier λ is called abstraction.Furthermore, each abstraction binds a variable and each variable can be bound by at most one abstraction.A variable which is not bound by an abstraction is called free.A lambda-term without free variables is called closed, otherwise open.
In this paper we deal with the enumeration of α-equivalence classes of closed lambda-terms: Two terms are α-equivalent if one term can be transformed into the other one by a sequence of α-conversions.An α-conversion is the renaming of a bound variable in the whole term (cf.[3]).Since the lambda-terms we consider are closed, this means that the actual variable names are unimportant; only the structure of the bindings is relevant.E.g., we consider the terms λx.x and λy.y to be identical.
Furthermore, note that neither application nor iterated abstraction is commutative, i.e., in particular, the terms λx.λy.T and λy.λx.T are different (if and only if at least one variable x or y appears in T ).
A lambda-term can be represented as an enriched tree, i.e., a graph built from a rooted tree by adding certain directed edges (pointers).First we construct a Motzkin tree, i.e., a plane rooted tree where each node has out-degree 0, 1, or 2, if the edges were directed away from the root.We denote by the terms leaves, unary nodes, and binary nodes, the nodes with out-degree 0, 1, and 2, respectively.In this tree each application corresponds to a binary node, each abstraction to a unary node, and each variable to a leaf.The fact that an abstraction λ binds a variable v is represented by adding a directed edge from the unary node corresponding to the particular abstraction λ to the leaf labelled by v. Therefore, each unary node x of the Motzkin tree is carrying (zero, one or more) pointers to leaves taken from the subtree rooted at x; all leaves receiving a pointer from x correspond to the same variable, and each leaf can receive at most one pointer.The Motzkin tree obtained from a lambda-term t by removing all pointers (variable bindings) is called the underlying tree of t.
For instance, the terms (λx.(x * x) * λy.y) and λy.(λx.x* λx.y) correspond to the enriched trees T 0 and T 1 in Fig. 1, respectively.In particular, these terms are closed lambda-terms, because every variable is bound by an abstraction, i.e., every leaf receives exactly one pointer.Binary nodes correspond to applications merging their two subtrees t 1 and t 2 into the more complex structure t 1 * t 2 .
As mentioned in the introduction, our interest in the present paper is in lambda-terms with restrictions on the number of abstractions and on the number of nesting levels of abstraction, either locally or globally.The following definitions will allow us to state our restrictions more precisely.
Definition 1.Consider a lambda-term and its associated enriched tree T .The unary length of the binding of a leaf e by some abstraction v in T (directed edge from v to e), denoted by l u (e), is defined as a number of unary nodes on the path connecting v and e in the underlying Motzkin tree.
Definition 2. Consider a lambda-term and its associated enriched tree T .The unary height of a vertex v of T , denoted by h u (v), is defined as number of unary nodes on the path from the root to v in the underlying Motzkin tree.The unary height of T , h u (T ), is defined by max We use the same notions for Motzkin trees as well.
In this paper we will enumerate lambda-terms with a fixed number of unary nodes, with bounded unary length of the bindings, or with bounded unary height.Of course, other simplifications are possible, such as bounding the number of pointers for each unary node.Such terms are related to linear (terms where each abstraction binds at most one variable, also called BCI terms) and affine (terms where each abstraction binds at most one variables, also called BCK terms) logics as introduced in [3,33,32,34], and their enumeration was treated in [7] and generalizations can be found in [6] and [9].For their relations to lambda-calculus see for instance [31].

Generating functions associated with lambda-terms
For each class of lambda-terms we will enumerate the terms of a given size.The size of a lambdaterm is the number of nodes in the corresponding enriched tree.It is defined recursively by In order to count α-equivalence classes of lambda-terms of a given size we set up a formal equation which is then translated into a functional equation for generating functions using the well-known symbolic method (cf.[25]).
Let us introduce the following atomic classes: the class of application nodes A, the class of abstraction nodes U, the class of free leaves F , and the class of bound leaves D. Then the class L of equivalence classes of lambda-terms can be described by the specification where the substitution operator subs(F → F + D, L) corresponds to replacing some free leaves in L by bound leaves.
Remark 1.Note that the lambda-terms specified by L are not necessarily closed.Since αconversion concerns only the bound variables, the equivalence here is w.r.t.α-conversion and substitution of a free variable by another free variable which is not already present in the term.
The specification (1) gives rise to a functional equation for the bivariate generating function which reads as follows: In particular, the formal generating function for lambda-terms without free variables is Note that these functional equations have to be considered in the framework of formal power series since the fast growth of the coefficients of the generating function implies that the radius of convergence of L(z, 0) is zero (see Corollary 3 below).Furthermore note, that the problem of counting closed or open lambda-terms is essentially the same.Indeed, the formal generating function for open lambda-terms can be derived from Eq. ( 2) the formula . Consequently, the problems of enumerating lambda-terms with or without free variables are of the same difficulty and the solution for one of them yields the solution for the other one.
Before we start with the analysis of the generating functions associated with the considered combinatorial structures let us introduce a few further notions.Definition 3. We say that a function f : C → C has a singularity of type α at z = ρ if there is a constant c such that as z → ρ inside the domain of analyticity of f .Definition 4. If f : C → C is a function which is analytic at 0. Then let S denote the set of all singularities of f which lie on the circle of convergence of the Taylor series of f (expanded at z = 0).Those singularities in S which are of smallest type are called the dominant singularities of f .Remark 2. It is well-known since Darboux [17] that the singularities on the circle of convergence determine the asymptotic behaviour of the coefficients of a series.The transfer theorems of Flajolet and Odlyzko [24] make this much more precise and show that indeed only the dominant singularity in the sense of the definition above and its type yield the (main term of the) asymptotic behaviour.

Restricted Motzkin trees
Before considering restricted lambda-terms, we present results on classes of restricted Motzkin trees.We shall consider classes of Motzkin trees with restrictions analogous to those for lambdaterms, namely a fixed or bounded number of unary nodes, and a fixed or bounded unary height, where the unary height of a leaf is the number of unary nodes on the path from the root to that leaf, and the unary height of a tree is the maximal unary height of a leaf.The size of a Motzkin tree is defined as the total number of nodes.The generating function associated with Motzkin trees satisfies the functional equation M (z) = z + zM (z) + zM 2 (z).Solving this equation shows that the only power series solution is The roots of the radicand are −1 and 1/3, the latter being the dominant singularity of M (z) and of type 1 2 .Applying a transfer theorem from [24] yields that the number of Motzkin trees of size n is asymptotically

Restrictions on the total number of unary nodes
Let M q be the class of Motzkin trees with exactly q unary nodes.We point out that a Motzkin tree with exactly q unary nodes has a total size n equal to q + 1 + 2m, where m is the number of binary nodes and m + 1 the number of leaves.
Proposition 1.The number of Motzkin trees of size n with exactly q unary nodes is 0 if n ≡ q mod 2; otherwise it is asymptotically equivalent to 2 π 1 2 q q! 2 n n q− 3 2 , as n → ∞ and for fixed q.
Proof.The assertion is an immediate consequence of Tutte's theorem [46] which implies directly that the number of Motzkin trees of size n with exactly q unary nodes is For self-containedness and as it is in the flavour of this paper, we offer a proof of Proposition 1 based on analytic combinatorics.
Obviously M 0 = C is the class of binary Catalan trees and its generating function is . For q ≥ 1 we have This equation translates into a functional equation for the generating functions and we get (after solving w.r.t.M q (z)) Lemma 1.There exists a sequence of polynomials sequence (P q (z)) q≥2 such that The polynomials P q (z) are given by the recurrence relation P 2 (z) = 1; P q (z) = P q−1 (z) + z q−2 l=2 P l (z)P q−l (z) (q ≥ 3). (5) From (3) one easily derives that M 2 = z 3 /∆ 3 which fits with the assertion (4).We assume that the assumption M ℓ = z ℓ+1 P ℓ (z 2 ) ∆ 2ℓ−1 holds for ℓ = 2, . . ., q − 1; Eq. ( 3) then gives From the last formula we read off the recurrence relation (5) and get the assertion after all.
The asymptotic behaviour of the coefficients of M q (z) is now readily obtained (recall that n = q + 1 + 2m, with m being the number of binary nodes): 2 ) , we get 2 n n q− 3 2 .
Set a q = P q (1/4); then a 2 = a 3 = 1 and a q = a q−1 + 1 4 2≤ℓ≤q−2 a ℓ a q−ℓ for q ≥ 4.This implies a q = 2 2−q C q−1 where C q denotes the qth Catalan number.Plugging this into the asymptotic expression for [z n ]M q (z) gives immediately Proposition 1.
Next we consider the number of Motzkin trees with at most q unary nodes.Then we have Hence the last term of the sum gives the asymptotic main term which is [z n ]M q if n ≡ q mod 2, and [z n ]M q−1 otherwise.

Restrictions on the unary height
Define B k as the set of Motzkin trees such that all leaves are at the same unary height k and B ≤k as the set of Motzkin trees where leaves have unary height at most equal to k.

All leaves at the same unary height
Again, we start with setting up the specification and translating them into functional equations for the generating functions.
where the second expression has k + 1 nested square roots.
Now we turn to the asymptotic behaviour of such bounded unary height trees.For k = 1, the dominant singularity of B 1 (z) is at z = 1/2 and of type 1  4 .The other singularity is at z = −1/2, but of type 1  2 and gives therefore an asymptotically negligible contribution.We obtain .
Likewise, for k ≥ 2, the singularities of B k (z) are ±1/2, which can easily be seen by induction.The singularity at z = −1/2 originates from the innermost radical only and is therefore of type 1/2.At z = 1/2 all radicals vanish at once and hence the singularity is of type 1/2 k+1 .Consequently, as z → 1/2, we have Determining the asymptotic behaviour is now straightforward.
Proposition 2. The number of Motzkin trees in which all leaves have exactly unary height k is Remark 3.This is another of the rather rare examples where the generating function of a recursively specified combinatorial structure does not have a dominant singularity of type 1/2 (or multiple of 1/2).A general discussion of possible singularity types of generating functions given by systems of functional equations was recently given by Banderier and Drmota [2].

Motzkin trees of bounded unary height
The case k = 0 again corresponds to binary Catalan trees and for larger k a similar recursive specification as in the previous subsection holds.
where the second expression has k + 1 nested square roots.
Again, the first function B ≤0 (z) has the two singularities ±1/2, but the next ones have different singularities.Indeed, the innermost square root The following few values are ρ2 = 0.3759923651, ρ3 = 0.3617581845, ρ4 = 0.3538076738.
Then the values ρk , defined as the smallest real positive root of Rk (z) = 0, form a decreasing sequence.
Proof.An easy inductive argument shows that the functions Rk (z) are decreasing functions on the positive real line (of course, only up to their first singularity) and smaller than 1 there: Note that for positive z we get Notice that the class of Motzkin trees of bounded unary height is a subclass of the class of unrestricted Motzkin trees.The generating function of the latter one has dominant singularity equals to 1  3 .Hence, for any fixed k, we must have ρk ≥ 1 3 .Now, suppose that ρk−1 ≤ ρk .Then, since Rk (z) is decreasing for positive real z and and < 1/3 which contradicts the fact that ρk ≥ 1 3 for all k.
Remark 4. Since the sequence (ρ k ) k≥0 is decreasing and bounded from below by 1  3 , one can try to prove that ρk → 1 3 as k → ∞.Though numerical evidence supports this, it seems not obvious at all.Since it is not the key point of our paper we decided to skip it.
As B ≤k (z) = 1 − Rk (z) /(2z) and each radical has a different dominant singularity, the dominant singularity of B ≤k is at z = ρk and of type 1/2.Here the dominant singularity always comes from the outermost radical.Thus, we obtain the following result: Proposition 3. The number of Motzkin trees with unary height at most equal to k is where ρk is defined in Lemma 4 and C is a suitable constant.
4 Enumeration of lambda-terms with prescribed number of unary nodes

Recurrence for the generating functions
We consider here the set S q of lambda-terms that have exactly q unary nodes.As a consequence their unary height is obviously bounded.We shall set up recurrence relations for the generating functions S q .Let z mark the total size and f mark the number of free leaves.The objects in S 0 are again binary Catalan trees and all the leaves are free (since there is no unary node).Thus For q = 1 either the unique unary node is equal to the root -each leaf of the whole tree then either becomes bound or stays free -or the root is a binary node and the unique unary node appears either in the left or the right subtree.This yields the specification and a recurrence relation for the generating function: Solving, we get For general q ≥ 1 a term has either a unary node as root and q − 1 unary nodes below or a binary node as root, and the q unary nodes are split into ℓ nodes assigned to the left subtree, and q − ℓ nodes assigned to the right subtree.Hence we obtain which gives We can easily solve it and obtain S q (z, f ) in terms of the S ℓ (z, f ) for ℓ < q: The number of closed lambda-terms, which we are interested in, is then
Proof.The proof is based on induction on q.To start the induction observe that S 0 (z, f ) = and R 0 = 0. Now assume that ( 9) is true for S 0 (z, f ), . . ., S q (z, f ).Then by (7) and By observing that σ q (f + 1) = σ q+1 (f ) we obtain The induction hypothesis implies that each The expression of the denominator of the R q comes readily from the recurrence expression.
By setting f = 0, we obtain the following lemma: Lemma 6.The generating function enumerating all closed terms with exactly q unary nodes is where the rational function R q comes from Lemma 5. Its dominant singularities are z = ± 1 2 √ q .

Asymptotics
A lambda-term with exactly q unary nodes and i leaves has i−1 binary nodes and size n = q+2i−1.
From Lemma 5, the term R q will have singularities at z = ±1/(2 √ ℓ) for 1 ≤ ℓ < q.The first term in the right-hand side of (10) has singularities of smaller type at z = 1/(2 √ q) than the second term.Hence it gives the dominant contribution to the asymptotics of [z n ]S q (z, 0): The denominator and we obtain: The number of closed lambda-terms with exactly q unary nodes and size n is 0 if n = q mod 2; otherwise its asymptotic value is Remark 5. Though (3) and ( 7) have a very similar shape, the results of Propositions 1 and 4 are rather different.But note that even though (7) was the starting point, we eventually use (8) instead.Thus the resonance-like behaviour induced by (3) and leading to the singularity of lower-order type described in Lemma 1 disappears.

Lambda-terms with at most q unary nodes
We denote by S ≤q (z, f ) the generating function for lambda-terms with at most q unary nodes, where again z marks the nodes, and f the free leaves.If q = 0 we get once more the generating function for binary Catalan trees: S ≤0 (z) = S 0 (z) = C(z).Otherwise, S ≤q (z) = q ℓ=0 S ℓ (z) and hence we can apply the results we obtained for a fixed number of unary nodes.The dominant singularity of S ≤q (z) comes from S q (z), whereas the terms S ℓ (z) for ℓ < q give negligible contributions to the asymptotics: The terms with exactly q unary nodes outnumber those with at most q − 1 such nodes and determine the asymptotic behaviour of the number of terms, which is the same for a fixed or bounded number of unary nodes.

Enumeration of lambda-terms with bounded unary length of bindings
Now we turn our attention to the problem of enumerating lambda-terms with bounded unary length of their bindings (for the definition see Def. 1).
Let G ≤k denote the class of closed lambda-terms where all bindings have unary length less than or equal to k.Our goal is to set up an equation specifying G ≤k .
Define P(i,k) as the class of unary-binary trees such that every leaf e can be labelled in min{h u (e) + i, k} ways.The classes P(i,k) can be recursively specified, starting from a class Z of atoms, by for i < k.Using again the traditional correspondence between specifications and generating functions we obtain and for i < k.
Note that for every positive integer k, the class P(k,k) consists of all Motzkin trees with k types of leaves.Moreover, the class P(0,k) is isomorphic to the class G ≤k and thus the recursive specification gives directly the generating function G ≤k (z) = P (0,k) (z) associated with G ≤k .
We can rewrite ( 12) and ( 11) in the form where for

Analysis of the radicands
Let us now introduce the definition of a dominant radicand.
Definition 5. Consider a function f (z) which is analytic at z = 0, but not entire, and of the form 2z where p i (z) (i = 1, . . ., k) and q i (z) (i = 2, . . ., k) are polynomials in z.We call its j-th radicand, which is p 1 (z) if j = 1 and p j (z) + q j (z) √ . . .otherwise, a dominant radicand if it has a zero at a dominant singularity of f (z).
In order to proceed, we need to know the location and type of the dominant singularity ρ of the "global" generating function G ≤k (z).This means actually that we need to know which radicands are dominant.
Nested structures appear frequently in combinatorial objects.Often these structures lead to generating functions of the form of continued fractions (see for example [22,15]).Nested radicals are less frequent.They occur for example when enumerating binary non-plane trees [42,25,14], where there appears an "iterated square-root" expansion.Lemma 7.For every k > 0 and 1 ≤ j ≤ k + 1, the function Rj,k (z) is strictly decreasing on the positive real line (in the interval where it is defined as a real-valued function).
Proof.We proceed by induction on j: R1,k (z) = (1 − z) 2 − 4kz 2 is clearly decreasing for z real positive and k > 0. Now assume Rj−1,k (z) is decreasing for z > 0. Thus, for positive z we have

The induction hypothesis implies
Observe that the function Rk,k+1 has the same dominant singularity as the function G ≤k (z).
Lemma 8. Assume k > 0 and that the radical Rj,k (z) has a positive singularity and let z 0 denote the smallest one.Then there are no complex singularities having the same modulus as z 0 .
Proof.From Eq. ( 13) we know that Rj,k (z If there were another (complex) root x = z 0 e iθ of the same modulus, then we would have Since P (k−j+1,k) (z) = n âj,k,n z n can be viewed as the generating function of some suitable class of lambda terms, for all sufficiently large n we have âj,k,n > 0. But this implies that 2z 0 e iθ P (k−j+1,k) (z 0 e iθ ) + 1 j=k z 0 e iθ < 1 whenever θ = 0, which leads to a contradiction.If z 0 is not a root of Rj,k (z), then z 0 must be a zero of some Rj−ℓ,k (z) with suitable ℓ > 0. This follows from the nested structure ( 14) of the radicals.But then we can apply the arguments above to Rj−ℓ,k (z) and arrive again at a contradiction.
Let us now study the exact location and type of the dominant singularity of the functions G ≤k (z).The next lemma will also prove that the singularity in the assumption of the previous lemma indeed exists.Proof.If a positive root of the radicand Ri,k (z) exists, denote its smallest one as ρi,k .Let us consider the roots of the innermost radicand R1,k (z).Since R1,k (z) is a quadratic equation, we know that it has two roots: is the dominant singularity of the generating function P (1,k) (z) and of type 1 2 .Let us now prove that none of the radicands Rj,k (z), 2 ≤ j ≤ k + 1, has a positive root which is smaller than or equal to ρ1,k .By induction on j, using the formula ρ1,k = 1 (for some j ≥ 2) does not have any positive root smaller than or equal to ρ1,k .Then we get Rj+1,k (ρ 1,k ) = (4j − 1)ρ 2  1,k + 2 ρ1,k Rj,k (ρ 1,k ) > 0 and again using the argument that Rj+1,k (z) is decreasing on the positive real line, we obtain that ρ1,k is the dominant singularity of Rj+1,k (z) and of type 1  2 .Thus, ρ1,k is a dominant singularity of G ≤k (z), and Lemma 8 implies that it is the only one.
The following proposition will be useful to derive the asymptotic behaviour of the number of lambda-terms in the considered class of terms.
Proposition 5. Let ρk be the root of the innermost radicand R1,k (z).Then and Proof.Using the Taylor expansion of R1,k (z) around ρk we obtain Knowing that R1,k (z) has a zero at z = ρk and setting z = ρk (1 − ǫ) we obtain the first claim (15).The next step is computing an expansion of Rj,k (z) around ρk , where 2 and from the recursive relation (14) for Rj,k (z) we have Using the formula ρk = 1 1+2 √ k and simplifying we get We just checked that this . Now, we proceed by induction: Observe that Expanding, using the formula ρk = 1 1+2 √ k , and simplifying we obtain . Expanding d j+1 using its recursive relation and We are now in the position to give the asymptotic behaviour of the number of lambda-terms having only bindings of bounded unary length.
Theorem 1.Let for any fixed k, G ≤k (z) denote the generating function of lambda-terms where all bindings have unary lengths not larger than k.Then where Proof.Lemma 9 tells us that the dominant singularity ρk = k is algebraic and of type 1 2 .Hence, we get the factor n − 3 2 (1 + 2 √ k) n in Eq. ( 16).Let us now consider the constant (w.r.t.n) term of Eq. ( 16).We have seen in Proposition 5 that for z close to ρk , and with the notations used in its proof, which gives Using the formulas k and then simplifying, we obtain the formula for the constant term.
The proof of Proposition 6 is focused on obtaining the asymptotic expansion of the product where C is a suitable constant.
Proof.From the recursive relation (17) and by bootstrapping we obtain the asymptotic expansion , as j → ∞, which we can rewrite as c j = (4j + 4 . Consider now the product M j=2 c j for M large -we shall take M = k + 1 later on.We write it as (1 + ω j ) and consider each of the products separately.
• M j=2 (1 + ω j ): This product has a finite limit ω if the series j ω j is convergent, which is indeed the case.This limit can be computed numerically as lim M→∞ 2≤j≤M cj 4j+4 √ j−3 .However, the convergence is slow.The best we have got from the numerical studies is ω = 0.118 . . .
This product gives us the asymptotic behaviour.Let us rewrite it as , we can compute our sum as where H M is the M th harmonic number and γ = 0.57721 . . . is the Euler-Mascheroni constant.We finally obtain where Putting all pieces together we get the following formula for the constant term of Eq. ( 16) (k + 1) where D = πωe 1 4 − 5 4 γ+ζ( 12 ) .

Enumeration of lambda-terms of bounded unary height
We now turn to the enumeration of lambda-terms with bounded unary height.Let H ≤k denote the class of closed lambda-terms with unary height less than or equal to k.Our first goal is to set up an equation for the H ≤k .Define the class P (i,k) as the class of unary-binary trees such that i + h u (e) ≤ k for every leaf e (i.e. the unary height of every leaf e is at most k − i) and every leaf e is colored with one out of i + h u (e) colors.
As in the previous section, we observe that P (k,k) is the class of all Motzkin tree with k types of leaves and P (0,k) is isomorphic to the class H ≤k .The class P (1,k) is isomorphic to the class obtained from H ≤k by allowing free leaves.This class in turn is isomorphic to the class of closed lambda-terms with a unary root: Just add a unary node as new root to a term of the previous class and bind all free leaves by this newly added abstraction.
For general i, P (i,k) is isomorphic to the class of closed lambda-terms built as follows: Consider a path of i unary nodes to which we append a Motzkin tree with unary height less than or equal to k − i and call this structure the skeleton.Then, for each leaf e there are i + h u (e) way to bind it in order to make a closed lambda-term out of the skeleton.
The classes P (i,k) can be recursively specified, starting from a class Z of atoms, by and, for i < k, by Translating into generating functions we obtain and for i < k.
Due to the remarks above, the recursive specification gives directly the generating function H ≤k (z) = P (0,k) (z) associated with H ≤k .We get an expression involving k + 1 nested radicals: Note that for n ≤ k we have ) and thus H ≤k (z) converges to L(z, 1) in the sense of formal convergence of power series (cf.[25, p. 731]).
In the next subsection we consider the singularities of this generating function and determine its dominant one together with its type -we shall see that the location and the number of the dominant radicands changes with k.Then we use this information to obtain the asymptotic behaviour of its coefficients.In Sections 3 and 5 we have seen examples where the dominant radicand is either the innermost one, the outermost one, or all radicands together.We know of no previous example where the position of the dominant radicand changes depending on the number of levels of nesting.

Analysis of the radicands
We now consider how to determine the dominant singularity of the function H ≤k (z): It is again built of nested radicals, hence its singularities are the values where at least one of the radicands vanishes.
Theorem 2 below gives the dominant radicand in H ≤k (z), i.e., the radicand whose zero is the dominant singularity of H ≤k (z).But first, we introduce two auxiliary sequences which prove to be important in the sequel.Definition 6.Let (u i ) i≥0 be the integer sequence defined by Corollary 1.The sequence (N i ) i≥0 can be written without reference to the sequence (u i ) i≥0 by Proof.Solve the equation N i = u 2 i − u i + i, considered as a quadratic equation in u i , then plug its solution into the recursive definition for u i+1 .This requires a little care, as the choice of the solution for expressing u i in terms of N i differs for i = 0 and in the case i ≥ 1. Remark 6. Obviously, the two sequences (u i ) i≥0 and (N i ) i≥0 are strictly increasing and have super-exponential growth.Since the growth rate will be important for our analysis, we will turn to it later.Theorem 2. Let (N i ) i≥0 be the sequence defined in Def.6 and k be an integer.Define j as the integer such that k ∈ [N j , N j+1 ).If k = N j , then the dominant radicand of H ≤k (z) is the j-th radicand (counted from the innermost one outwards), and the dominant singularity ρ k is of type 1  2 .Otherwise, the j-th and the (j + 1)-st radicand vanish simultaneously at the dominant singularity of H ≤k (z), which is equal to 1/(2u j ) and of type 1  4 .The rest of this section is devoted to the proof of Theorem 2.

The radicands R i,k
Let us denote by R i,k (z) the ith radicand (1 ≤ i ≤ k + 1) of H ≤k (z), according to the numbering from the innermost outwards as adopted in the assertion of Theorem 2, i.e., we have We can write the radicands recursively as follows: for As H ≤k (z) = P (0,k) (z) = (1 − R k+1,k (z) )/(2z), the dominant singularity of H ≤k (z) is the dominant singularity of R k+1,k (z) as well.

The dominant singularity of a radicand
We show below that, for any fixed k and for any i, 1 ≤ i ≤ k + 1, the ith radicand R i,k , when restricted to the real part of its definition domain, is decreasing and use this to determine the interval where it is positive and to prove that it has a single real positive root, which turns out to be the dominant singularity.Lemma 11.For every k > 0 and 1 ≤ i ≤ k + 1, the real function R i,k (z) is strictly decreasing on the positive real line (up to its first singularity).
Proof.The proof is a simple inductive argument like in Lemma 7.
Corollary 2. For every k > 0 and 1 ≤ i ≤ k + 1, the real function R i,k (z) has at most one real positive root.Remark 7. If j and k are such that k ∈ [N j , N j+1 ), then it will turn out that only the j + 1 first radicands R 1,k (z), . . ., R j+1,k (z) will be relevant for our investigations.All of them have a real positive root.This holds due to the fact that R j+1,k (z) is a dominant radicand of H ≤k (z), which we shall prove later on.Definition 7. Let j ≥ 1 and k be integers such that k ∈ [N j , N j+1 ).For i = 1, . . ., j + 1 let σ i,k denote the smallest positive root of the radicand R i,k (z).Lemma 16.If the values j and k are such that there exists a value z cancelling both radicands R j+1,k and R j,k , then we must have k = N j where (N j ) j≥0 is defined by N 0 = 0 and N i := α i −α i−1 for i ≥ 1, with (α i ) i≥0 being the sequence defined in Lemma 15.
Remark 9.The sequence (N j ) j≥0 in Lemma 16 is precisely the sequence defined in Def. 6.
Proof.From Lemma 15, simultaneous vanishing of both radicands implies that z = σ j,k .Then we know the values of the R j−p,k (σ j,k ) for all p = 0, . . ., j − 1; in particular, taking . But we also know that a suitable value z = σ j,k must be equal to , which gives an equation for the integers k and j involving also the sequence (α j ) j≥0 defined in Lemma 15: Setting ℓ = k−j and solving gives ℓ = (j+α j−1 )(j+α j−1 −1), which leads to k = (j+α j−1 )2 −α j−1 .
Finally, the recurrence for the α i (see Lemma 15) gives The first values of the N j are given by the table of Figure 1.For each value k = N j , the two radicands that vanish are those numbered by j and j + 1.

Lemma 17.
No more than two radicands can vanish at the same positive value.If so, then these two radicands are consecutive ones.
Proof.Assume that two non-consecutive radicands R i,k and R j,k vanish simultaneously.From Lemma 13, we know that the zeroes of the radicands decrease.Therefore, all the radicands R ℓ,k for i ≤ ℓ ≤ j would vanish simultaneously.But it is not possible that more than two successive nested radicands R i,k , . . ., R i+p,k have a common positive zero: This can only happen for z = σ i,k , but then the polynomial part 1 − 4(k − j + 1)z 2 − 2z can be simplified into 4(j − i − 1)z 2 , hence it is strictly positive as soon as j > i + 1.

The sequence (N i ) i≥1
We establish here results about the growth of the sequence (N i ) i≥1 .
Lemma 18.The sequence (u i ) i≥0 defined in Def.6 satisfies u i = α i + i.Moreover, the limit exists.Furthermore, we have u i = ⌊χ 2 i ⌋ for sufficiently large i.As a consequence, both sequences (u i ) i≥0 and (N i ) i≥1 have doubly exponential growth.
Proof.The recurrence relation on the u i is clear from the definition of the α i in Lemma 15.
Aho and Sloane [1] study doubly exponential integer sequences x = (x i ) i≥0 of the form x i+1 = x 2 i +g i with |g i | < x i /4 for i sufficiently large.They show there that for any such sequence x = (x i ) the limit χ x := lim i→∞ x In our case it is easy to check that, for i ≥ 4, g i = i + 1 < u i /4.Hence the sequence (u i ) i≥0 is of a form such that the result of [1] applies, and lim i→∞ u 1/2 i i can be numerically approximated by χ ≈ 1.36660956 . . .Finally, the relation is doubly exponential as well.Of course, since α i = u j+1 − j − 1, the sequence (α i ) i≥0 is also doubly exponential.
Remark 10.Note, however, that for neither of the sequences (N i ) i≥1 and (α i ) i≥0 the result of Aho and Sloane [1] can be applied (see the recurrences they satisfy, given by Corollary 1 and Lemma 15).

The singularities
The following proposition sums up the properties of the singularities.Proposition 7. (i) Let ρ k be the dominant singularity of H ≤k (z) for k = 0, 1, 2, . . .Then the sequence (ρ k ) k≥0 is strictly decreasing.
(ii) If there exists a j ≥ 1 such that k = N j , then the dominant singularity is a root of both radicands R j,k and R j+1,k , and it is of type 1

4
(iii) For k ∈ (N j , N j+1 ), the dominant singularity is ρ k is a root of the single radicand R j,k ; it is of type 1 2 and lies in the interval and therefore ρ k+1 < ρ k , since the radicands are strictly decreasing functions by Lemma 11.
(ii) If there exists a j such that k = N j , then the pair (j, k) = (j, N j ) is a solution of ( 23).
If we set σ j,Nj = , use (23), and then go backwards the steps in the proof of Lemma 16, we eventually arrive at R j,k (σ j,Nj ) = R j+1,k (σ j,Nj ) = 0.The type of the singularity is an immediate consequence of the fact that the two dominant radicands are consecutive ones.
(iii) For N j < k < N j+1 , Lemmas 16 and 17 tell us that no two radicands vanish simultaneously; only the jth radicand is the dominant one and the singularity is therefore of type 1/2.The bounds for σ j,k follow from the fact that for any given value of j the sequence of zeroes of R j,k (z) is decreasing (see Lemma 14 and Remark 8).
Corollary 3. The radius of convergence of the generating function L(z, 0) enumerating all lambdaterms is zero.
Proof.The number of lambda-terms of given size n being greater than the number of lambdaterms of size n and unary height p (for any p), the radius of convergence of the global generating function L(z, 0) must be smaller than (or equal to) the radius of convergence ρ k of the function H ≤N k (z), for any k.But the sequence of these radii is the sequence ( 1 2u k ) and converges to 0.

Behaviour of the radicands
In order to proceed, we need some information on the behaviour of the radicands in a neighbourhood of the dominant singularity.This is done in the two propositions that follow: Proposition 8 gives the exact values and Proposition 9 their expansions at the singularity.
Proof.(i) The first assertion comes from Lemma 15, which gives R s,j (σ j,Nj ) = 4α j−s σ 2 j,Nj , and from Lemma 18, from which we have α j−s = u 2 j−s .(ii) The second assertion is simply the definition of σ j,Nj .
Proof.We know that R j−1,Nj (σ j,Nj ) > 0 and that the function R j−1,Nj (z) is analytic up to some value z > ρ.Hence R j,Nj (z) itself has a Taylor expansion around ρ which yields (24).Using the recurrence relation ( 14) for R j,k (z) we immediately obtain (25).The next step is computing the expansion of R j+2,Nj around ρ where it has a singularity of type 1  4 .We obtain . Now consider the radicands R j+p,Nj (z) for p ≥ 2 and proceed by induction: They have a common dominant singularity at z = ρ, which is of type 1  4 .Thus, for all p ≥ 2, there exist a p = 0 and b p such that R j+p,Nj (ρ − ǫ) = a p + b p ǫ . We already know that a 2 = 4ρ 2 and b 2 = 2ρ 2ρ √ γ j .By the recurrence relation (14) for the radicands we get Plugging in the expansion a p + b p ǫ for R j+p,Nj (ρ − ǫ), expanding and simplifying the . Setting .
-By dividing the recurrence for a p by 4ρ 2 , we see that j .

Asymptotic number of lambda-terms of bounded height
We are now in the position to give the asymptotic behaviour of the number of lambda-terms with bounded unary height.
Theorem 3. Let (N i ) i≥0 and (u i ) i≥0 be as in Def. 6.
(i) If there exists j ≥ 0 such that N j < k < N j+1 , then there exists a constant h k such that (ii) If there exists j such that k = N j , then the following asymptotic relation holds: where with γ j and the sequence (λ i ) i≥0 as defined in Proposition 8.
Thus, we can finish the proof with the following calculations: Proposition 12.If j is such that R j,k (z) is a dominant radicand of the generating function H ≤k (z), then j = O (log log k).
Proof.Let us first consider the case where both the jth and the (j + 1)st radicand are dominant.
From Theorem 2 we know that in that case k = N j = u j+1 − u j − 1.Moreover, from Lemma 18 we have u i = ⌊C 2 i ⌋ for sufficiently large i and with C ≈ 1.36660956 . . .
and applying the logarithm twice on both sides of this equation we get j = O (log log k).
In the case where R j,k (z) is the only dominant radicand we have Proceeding like in the previous case we get j = O (log log k) .
We are now in the position to give the asymptotic behaviour of ρ k .Theorem 4. Let ρ k be the dominant singularity of H ≤k (z), then the asymptotic behaviour of ρ k can be described as follows: Proof.Let us first consider the case where k = N j .From Lemma 15 and Proposition 7 we know that . Proposition 12 tells us that j = O(log log k) and thus expanding as desired.Proving the result for the case where N j−1 < k < N j is less straightforward.Let us recall the result of Proposition 10: . So, what is left is proving an upper bound.
We have Unfortunately, this upper bound is too weak to be used in this proof.
In order to improve the upper bound for . This inequality can be seen as follows: The weak inequality follows from Lemma 13.But it is even strict, because no two successive radicands can be zero.Thus the zeros σ j−1,k and σ j,k of the two respective radicands must be different.
Furthermore, we know that R j−1,k (z) is decreasing on the positive real axis (see Lemma 11) and that One can easily check that R j,k (z) is decreasing for z > 0 and thus its positive root This inequality together with , where we used Proposition 11 for the asymptotic expansion of κ as k → ∞, completes the proof.

Exponential decrease of the constant
Numerical computations for the coefficients of asymptotic expansions when k = 1, 8, 135 give In Theorem 3 we presented an expression for these constants (see Eq. ( 28)) involving the quantities γ j and (λ i ) i≥0 which were defined in Proposition 9. We now prove that the constant h Nj decreases exponentially fast as j → ∞.
Proposition 13.The constant h Nj satisfies, as j → ∞, where The proof of Proposition 13 starts from the value given in Eq. ( 28) and has two main parts: proving that γ j is of order u j and dealing with the product Nj −j i=1 λ i .

The derivative of R j,k (z)
Maple computations show that γj uj seems to converge quickly (with a precision of 10 −10 for j = 7) to a constant value, approximately equal to 6.347269145.We will show that this indeed holds. .
Taking z = ρ = 1 2uj , we get Now we are computing γ j = w j,Nj , i.e., we are interested in the w p,Nj for p ≤ j.In this range, R p−1,Nj (ρ) = and we can now turn to γ j = −w j,Nj : We write E s,j,j − 4 j s=1 sE s,j,j − 2 u j j s=1 u j−s+1 E s,j,j .
and consider each term in turn.
Lemma 20.The sums j s=1 E s,j,j , j s=1 sE s,j,j and j s=1 uj−s+1 uj E s,j,j all have a finite limit when j → ∞.
Proof.It suffices to write, e.g., the first sum as j s=1 1 2 j−s j−s ℓ=1 u ℓ and to remember the exponential growth of the sequence (u i ) i≥0 .The same argument holds for the second sum.Finally, since u j−s+1 < u j , the first sum is an upper bound of the last sum.This shows that γ j ∼ 4 N j u j s≥1 E s,j,j when j → ∞.The relation N j = u 2 j − u j + j then gives readily the following lemma, where the value of the constant has been computed numerically.

Bounded unary height vs. bounded unary length of bindings
In Table 2 we give numerical results of the constant and exponential terms for the number of lambda-terms of bounded unary height and the number of terms where all bindings have bounded unary length.We can see that the exponential terms for growing k are quite similar in both cases.Note that in case II the unary height is not bounded.Thus one might expect that bounding the unary height is a much stronger restriction and that therefore the exponential growth rates should exhibit a larger difference than they actually do.However, there is still a difference in the exponential growth rates, which makes it appear reasonable.The quotient of the exponential growth rates seems to tend to one which is as expected.
Case The constant factors differ significantly in both cases, but still they share a common behaviour: They tend quite quickly to 0 as k → ∞.One can also observe that for lambda-terms with bounded unary height in the cases where k = N j not only the term n − 5 4 appears (instead of n − 3 2 ), but also the constant factor behaves in a little different way: It is indeed smaller than one could expect.So far, we have no explanation for this behaviour.

Random generation of lambda-terms
To get a feeling of the "average" behaviour of a combinatorial object, a method of choice is the random generation of terms of large size.We considered two methods to try to generate a random lambda-term of bounded unary height: the recursive method [26] and Boltzmann sampling.Boltzmann samplers are powerful tools to generate objects in specified combinatorial classes uniformly at random.They were introduced in [21] and extended furthermore by numerous authors (see e.g.[12,13,23,44]).Note that, theoretically, a Boltzmann sampler can generate a tree of size close to n on average in linear time.
We considered Boltzmann sampling of a closed term, with different success depending on the unary height: The efficiency decreases very quickly as the maximal unary height grows.When Figure 2: A random lambda-term of size 30, with the edges from unary nodes to leaves.k = 8, we can generate terms of size 10000 in a few seconds on a standard personal computer.Figure 3 presents a term of size 6853 with unary height bounded by 8.However, if we consider lambda terms with a maximal unary height of 135, a Boltzmann sampler is not able to produce objects of size larger than 200 in a "reasonable" time (less than one day).The explanation of the phenomenon is as follows: An "average" random lambda-term begins with a large number of unary nodes; cf. Figure 5 (see also [18] for a result in the same vein for a related model).Drawing the sufficient number of unary nodes has very low probability in the Boltzmann process.Figure 4 gives the various probabilities of drawing a leaf, a unary node, or a binary node, plotted against the unary height (actually the number of recursive calls to the generator, but the design of the generator is such that a call is done if the unary height changes).After a (long!) starting phase, where the probability of stopping is larger than 0.9, the Boltzmann sampler becomes efficient.In other words, Boltzmann sampling is linear, but with a constant depending on the maximum unary height which grows very quickly: The recursive form of the specification of lambda-terms and their varying behaviour makes them not well amenable to random generation with a Boltzmann sampler.
We have thus turned to the recursive method.Using the Maple package Combstruct, we have been able to generate quickly enough lambda-terms of size 200 and unary height bounded by 200-which means that there is de facto no restriction on the unary height of the lambda-term.Figure 5 shows what can be considered as a "generic" lambda-term for this size.Both classes, the one with bounded unary height and the one where all bindings have bounded unary length, can be used to approximate generic lambda-terms.But unfortunately, also in the case of bounded unary length of bindings we are facing the same difficulties when trying to generate them with a Boltzmann sampler.The probabilities for generating leaves, unary and binary nodes looks very similar to Figure 4.This fact can be explained as follows: For both classes of restricted lambda terms, the dominant radicand is either close or equal to the innermost radicand.But the Boltzmann sampler generates these from outside inwards.That is meant in the following sense: Each square-root is the analytical analogue of the lifting from one unary level to the next one (cf.( 18) and (19) in order to see this).The Boltzmann sampler builds an object by starting from the root and attaching more and more nodes.So, the head of the term, i.e. the subtree comprising all nodes of unary height zero, is precisely the object corresponding to the outermost root; and this is generated before the nodes with larger unary height.But note that the generating function of the class of heads has a larger dominant singularity.Hence the tuning parameter of the Boltzmann sampler is far away from this singularity, thus giving the sampler a strong bias towards stopping.On the other hand, moving the parameter into an interval where the sampler works efficiently means that it is outside the domain of analyticity of the generating function associated with lambda-terms.This implies that we have a positive probability that the sampling process never stops.So the sampler becomes even more inefficient than with the badly chosen tuning we had before moving it to the allegedly better region.Bodini et al. [11] developed a general framework for Boltzmann sampling for which tuning parameters outside the region of convergence of the associated generating function can be used.This relies on anticipated rejection and might help to improve the Boltzmann samplers for generating random lambda-terms.
For restricted Motkzin trees the situation is totally different, because the dominant singularity comes from the outermost radicand.Thus the Boltzmann sampler starts to generate the object by generating subobjects corresponding to the root which determines the singularity, and we can choose the tuning parameter so that it in the optimal region.

Shape of a typical lambda-term
Being able to draw repeatedly random lambda-terms allows us to make tentative conjectures on their various parameters: profile, height, etc.We have plotted in Figure 6 the ratio between the number of lambda-terms with unary height exactly k and size n, and the number of lambda-terms of size n (without restriction on the height).The figure suggests that, for any given size n, the unary height is close to a Gaussian distribution.In particular, this gives some experimental explanation to the change of difficulty which we encountered when generating terms of small unary height (size about 10 000, unary height bounded by 8) and terms of fairly large unary height (size about 10 000, unary height bounded by 135): The wave indicates the "good" estimate for the number of abstractions in a lambda-term; for instance, if we consider lambda-terms of size 198, then the vast majority of these terms has a unary height between 25 and 50.
Figure 5 shows a generic lambda-term, its profile (number of nodes at each level) and the profile averaged on 500 random lambda-terms, together with the average profile of a plane binary tree, which is up to scaling identical with that of Motzkin trees since both tree classes are simply generated.From our simulations we can make several empirical observations: • The distribution of the profiles is poorly concentrated (this is also the case for plane binary trees).
• The levels containing the larger number of nodes are much farther from the root than in plane binary trees.
• A simulation of the distribution for the total (unary) height also shows a clear difference to plane binary trees: The average (unary) height seems to grow almost linearly (actually proportional to n/ log n), not proportional to √ n as the height of binary trees or the unary height (and also the height) of Motzkin trees.Accordingly, the width of lambda-terms appears to grow as log n.
• A random lambda-term usually begins with a large number of successive unary nodes interspersed with a few binary nodes; most binary nodes appear further down.
Figure 3 shows the underlying Motzkin tree of a large lambda term of bounded unary height (the bound is 8) and its profile.Simulations for the case of bounded unary length of binding lead to similar pictures.Certainly, one of the reasons is that the bound 8 is still very small to exhibit a visible qualitative difference between the two classes of lambda-terms.On the other hand, it is also possible that the shape of the underlying Motzkin tree is too similar in both models if k is relatively small.In contrast to this is the behaviour of Motzkin trees of bounded unary height.As Figure 7 shows, the position of most of the unary nodes seems to be near the leaves whereas in a random lambda-term of bounded unary height most the unary nodes form a string starting at the root (cf. Figure 5).

Conclusion and perspectives
In this paper we have studied several classes of lambda-terms; see also [6] for further classes.It is clear that allowing pointers from unary nodes to leaves is the main factor that determines the complexity of such structures, and the more unary nodes we allow, the farther we are from trees.Indeed, allowing pointers from internal nodes to leaves amounts to leaving the realm of trees for that of directed acyclic graphs.As regards the enumeration of restricted classes, bounding the number of unary nodes as well as bounding the unary length of bindings (which is locally bounding the number of levels of nesting for abstractions) leads to an asymptotic behaviour that resembles that of trees (of type n −3/2 ρ n ), even though the latter is already of considerable combinatorial complexity.In contrast, bounding the unary height (which means globally bounding the number of levels of nesting for abstractions) exhibits an unusual behaviour.
Among other facts, we have discovered the unexpected behaviour of the position of the dominant radicand, which jumps according to some function behaving as log(log(k)), with k being the bound for the unary height of a lambda-term.Theorem 3 characterizes precisely these jumps and the asymptotic number of lambda-terms with bounded unary height.The enumerative result looks tree-like unless the bound for the unary height belongs to the special sequence (N j ) j≥1 .
The fact that the generating function has a nested square-root representation, but the position of the dominant radicand depends on the specific restriction appeared also in our studies of Motzkin.We studied them for comparison reasons since they form the underlying structure of lambda-terms.Regarding the asymptotic enumeration results, they exhibit the tree-like pattern, except if we impose a very unnatural shape: In the case where all leaves have to be at the same unary height we observe a different singularity of different type.In this case all radicands are dominant, as opposed to the other cases where either the innermost or the outermost radicand is dominant.
In contrast to this stands the behaviour of lambda terms of bounded unary height where the position of the dominant radicand is depending on the bound for the unary height.This phenomenon requires further explanation.
Further investgations indicate that the strange jumps in the behaviour are related to the distribution of the leaves in a lambda-term with bounded unary height.It seems that they are concentrated in the last few levels (level counting w.r.t.unary height) while the lower levels contain almost no leaves.The number of these levels seems to be doubly logarithmic in the size of the terms and whenever k = N j for some j, then a new level "enters", meaning that it contains then a significant number of leaves.So, the special values of k are those where a transition takes place from ℓ to ℓ + 1 levels, filled with almost all the leaves of the lambda-term.In lambdaterms belonging to the class where all bindings have bounded unary length we expect that the distribution of the different types of nodes (unary, binary and leaves) is more uniformly distributed within their underlying Motzkin trees than in the bounded unary height case.This is indicated by generation of small objects (size 100-200, cf. Figure 9).
A byproduct of our work concerns Boltzmann samplers: By trying to use them for the random generation of lambda-terms, we have pushed them to their limit.It turned out that Boltzmann samplers have serious difficulties to generate generic lambda-terms of large size.The same is true if the unary height or the length of the bindings is bounded.From an analytic view point, the reason is certainly that the dominant singularity does come from radicands lying in a deep level of nestings.Another reason might be that the multiplicative constants in the asymptotic main terms decrease so rapidly with growing k.We analyzed these constants exhaustively for the case with bounds on the binding length, and for k = N j in the bounded unary height case.It remains an open problem to carry out a precise analysis for all k and to understand those irregularities discussed in Section 7. We feel that it might be also possible to improve Boltzmann random generation, when we wish to apply it to combinatorial structures for which Boltzmann samplers mostly produce either small or infinite objects.Recently, a framework for Boltzmann sampling has been developed by Bodini et al. [11] which generalizes the existing one in a direction which might help to overcome some of the difficulties we are facing in the generation of lamda-terms.
We next mention that our approach can be extended to study formulas of quantified logic: Instead of a single type of unary nodes, we have as many types as different quantifiers (usually two: ∀ and ∃; l in general).We also have as many types of binary nodes as there are binary connectors (e.g., two when we consider the connectors ∧ and ∨; h in general); here we have studied the case l = h = 1.We expect that allowing different types of unary nodes will introduce only a multiplicative coefficient in our results, whereas allowing different types of binary nodes will change the singularities and thus the exponential growth.
Finally, in terms of average properties and growth, lambda-terms widely differ from the usual models for trees such as simple families [40] or increasing trees [4], for which we know the behaviour of classical parameters: number of trees of given size, profile, etc. Indeed they seem to behave, in some sense, like "ornamented" paths, i.e. long strings onto which relatively small subterms are grafted.
Of course, such results need to be explained and quantified more rigorously.Let us also mention that the enumeration of (unrestricted) lambda-terms is still an open problem, which has to be solved in order to study such parameters as the (average) unary height, the profile, etc.
An interesting question is the probability that a random lambda-term is in normal form.We are currently studying this problem for restricted classes of lambda-terms and hope to give results in a forthcoming paper.

1 Figure 1 :
Figure1: Two examples of lambda-terms (or α-equivalence classes if the labels of the leaves are removed): Each unary node corresponds to an abstraction λx binding all leaves below it which are labelled by x.Binary nodes correspond to applications merging their two subtrees t 1 and t 2 into the more complex structure t 1 * t 2 .

Lemma 2 .
The class B 0 is equal to that of binary Catalan trees.Thus B 0

Lemma 3 .
The class B ≤k is equal to that of binary Catalan trees.For k ≥ 1 we have the recursive specificationB ≤k = Z + U × B ≤k−1 + A × B ≤k × B ≤k .Thus the generating function associated with B ≤k satisfies

Lemma 9 .
Let ρk be the dominant singularity of the function G ≤k (z).Then ρk = 1 1+2 √ k comes from the innermost radicand and is of type1  2 . j

2
and the definition of the λ i , this gives a p = 4ρ 2 λ p−1 .-Plugging the expression for a p that we have just obtained into the recurrence for the b p gives b p+1 =

Figure 3 :
Figure 3: The underlying Motzkin tree of a random lambda-term of size 6853 and unary height ≤ 8 and its profile.

Figure 5 :
Figure 5: Left: a lambda-term of size 200.Middle: its profile.Right: the average profile (red) computed over 500 random lambda-terms, compared with the average profile for plane binary trees (blue: the Airy function)

Figure 7 :
Figure 7: A random Motzkin tree of size 8368 and unary height ≤ 8 and its profile.

Figure 8 :
Figure 8: A random Motzkin tree of size 11995 and unary height ≤ 100 and its profile.

Figure 9 :
Figure 9: Left: an underlying Motzkin tree of a lambda-term with bounded unary height, Right: an underlying Motzkin tree of a lambda-term bounded unary length of bindings.

Table 1 :
The first values N j and u j .

Table 2 :
Comparison of the constant terms and exponential terms values for the bounded unary height lambda-terms and bounded unary length of abstractions pointers lambda-terms.