Mireille Bousquet-Mélou
email: mireille.bousquet@labri.fr

Guillaume Chapuy
email: guillaume.chapuy@liafa.jussieu.fr

THE VERTICAL PROFILE OF EMBEDDED TREES

Keywords: Mathematics Subject Classification, 05A15, Enumeration -Embedded trees

Consider a rooted binary tree with n nodes. Assign with the root the abscissa 0, and with the left (resp. right) child of a node of abscissa i the abscissa i -1 (resp. i + 1). We prove that the number of binary trees of size n having exactly n i nodes at abscissa i, for

The sequence (n ℓ , . . . , n -1 ; n 0 , . . . , nr) is called the vertical profile of the tree. The vertical profile of a uniform random tree of size n is known to converge, in a certain sense and after normalization, to a random mesure called the integrated superbrownian excursion, which motivates our interest in the profile. We prove similar looking formulas for other families of trees whose nodes are embedded in Z. We also refine these formulas by taking into account the number of nodes at abscissa j whose parent lies at abscissa i, and/or the number of vertices at abscissa i having a prescribed number of children at abscissa j, for all i and j.

Our proofs are bijective.

Introduction

Consider a rooted binary tree: each node has a left child and/or a right child. The height of a node is its distance to the root. The horizontal profile of the tree is (h 0 , h 1 , . . . , h k ), where h i is the number of nodes at height i and k is the maximal height of a node (Figure 1, left). It is easy to see that the number of trees with horizontal profile (1, h 1 , . . . , h k ) is

k-1 i=0 2h i h i+1 , (1)
with h 0 = 1. Indeed, the binomial coefficient 2hi hi+1 describes how to spread h i+1 nodes of height i + 1 in the 2h i slots created by the h i nodes lying at height i. The horizontal profile of trees has been much studied in the literature and is very well understood [START_REF] Aldous | The continuum random tree. II. An overview[END_REF][START_REF] Drmota | On the profile of random trees[END_REF][START_REF] Flajolet | Level number sequences for trees[END_REF][START_REF] Meir | On the altitude of nodes in random trees[END_REF][START_REF] Takács | Conditional limit theorems for branching processes[END_REF]. Expression [START_REF] Aldous | The continuum random tree. II. An overview[END_REF] appears for instance in [START_REF] Brown | On random binary trees[END_REF]. Now, assign to each node, instead of an ordinate (its height), an abscissa: the root lies at abscissa 0, and the abscissa of the right (resp. left) child of a node of abscissa i is i + 1 (resp. i -1). We say that the tree is (canonically) embedded in Z. The vertical profile of the tree is (n ℓ , . . . , n -1 ; n 0 , n 1 , . . . , n r ), where n i is the number of nodes at abscissa i, and ℓ (resp. r) is the smallest (resp. largest) abscissa occurring in the tree (Figure 1, right). We prove in this paper that the number of trees with a prescribed vertical profile is given by a formula that is as compelling as [START_REF] Aldous | The continuum random tree. II. An overview[END_REF], but, we believe, far less obvious. A rooted binary tree having horizontal profile (1, 2, 4, 3, 2) and vertical profile (2, 2; 4, 2, 1, 1).

Theorem 1. Let ℓ ≤ 0 ≤ r, and let (n i ) ℓ≤i≤r be a sequence of positive integers. The number of binary trees having vertical profile (n ℓ , . . . , n -1 ; n 0 , n 1 , . . . , n r ) is

n 0 n ℓ n r n -1 + n 1 n 0 -1 ℓ≤i≤r i =0 n i-1 + n i+1 -1 n i -1 ,
with n ℓ-1 = n r+1 = 0.

For instance, the number of binary trees having vertical profile (2; 2, 1) is

2 2 × 1 3 1 1 1 1 0 = 3,
and these trees are shown in Figure 2. This unexpected formula has first an obvious combinatorial interest: its proof -especially a bijective proof -has to shed a new light on the combinatorics of binary trees, which are of course eminently classical objects. But our original motivation lies in the link between the vertical profile of binary trees and a certain random probability measure, called the integrated superbrownian excursion, or ISE. The ISE is the limit, as n increases, of the (normalized) occupation measure of a uniform random tree T having n vertices [START_REF] Marckert | The rotation correspondence is asymptotically a dilatation[END_REF]. The normalized occupation measure of T is defined to be

µ n = 1 n v∈T δ a(v)n -1/4 ,
where δ x is the Dirac measure at x and a(v) denotes the abscissa of the vertex v. Note the double normalization, first by 1/n (to obtain a probability distribution) and then by n -1/4 (which is known to be the correct scaling to obtain a non-trivial limit). Theorem 1 thus describes explicitly the law of µ n : indeed, the probability that µ n (i n -1/4 ) = n i n for all i ∈ ℓ, r

(and µ n (in -1/4 ) = 0 for other values of i), with n = i n i , is the number of Theorem 1, divided by C n = 2n n /(n + 1), the number of binary trees of size n.

The ISE is not only related to binary trees. In fact, it appears to be a "universal" measure associated with numerous embedded branching structures [START_REF] Aldous | Tree-based models for random distribution of mass[END_REF][START_REF] Derbez | The scaling limit of lattice trees in high dimensions[END_REF][START_REF] Janson | Convergence of discrete snakes[END_REF][START_REF] Gall | Spatial branching processes, random snakes and partial differential equations[END_REF][START_REF] Marckert | States spaces of the snake and its tour-convergence of the discrete snake[END_REF][START_REF] Miermont | Invariance principles for spatial multitype Galton-Watson trees[END_REF]. Due to the existence of bijections between certain families of rooted planar maps and embedded trees, it also describes (up to a translation) the limiting distribution of distances to the root vertex in planar maps of large size [START_REF] Bouttier | Geodesic distance in planar graphs[END_REF][START_REF] Bouttier | Statistics of planar graphs viewed from a vertex: a study via labeled trees[END_REF][START_REF] Chassaing | Random planar lattices and integrated superBrownian excursion[END_REF][START_REF] Cori | Planar maps are well labeled trees[END_REF][START_REF] Miermont | Radius and profile of random planar maps with faces of arbitrary degrees[END_REF][START_REF] Marckert | Invariance principles for random bipartite planar maps[END_REF]. Similar connections actually exist for maps on any orientable surface, for which the limiting distribution of distances is explicitly related to the ISE [START_REF] Chapuy | The structure of unicellular maps, and a connection between maps of positive genus and planar labelled trees[END_REF]. The law of the ISE is the subject of a very active research [START_REF] Bousquet-Mélou | Limit results for embedded trees. Applications to the integrated super-Brownian excursion[END_REF][START_REF] Bousquet-Mélou | The density of the ISE and local limit laws for embedded trees[END_REF][START_REF] Delmas | Computation of moments for the length of the one dimensional ISE support[END_REF][START_REF] Devroye | Distances between pairs of vertices and vertical profile in conditioned Galton-Watson trees[END_REF][START_REF] Chassaing | The center of mass of the ISE and the Wiener index of trees[END_REF][START_REF] Janson | Left and right pathlengths in random binary trees[END_REF][START_REF] Gall | Spatial branching processes, random snakes and partial differential equations[END_REF][START_REF] Gall | Conditioned Brownian trees[END_REF], and we hope that knowing explicitly the law of µ n will eventually yield a better understanding of the law of the ISE. For instance, the law of the support of the ISE, and the law of its density at one point, have already been determined though the study of embedded binary trees [START_REF] Bousquet-Mélou | Limit results for embedded trees. Applications to the integrated super-Brownian excursion[END_REF][START_REF] Bousquet-Mélou | The density of the ISE and local limit laws for embedded trees[END_REF].

Let us now return to Theorem 1. This theorem is not isolated: for instance, we prove a similar formula for embedded ternary trees. But our results also deal with embedded Cayley trees. Recall that a (rooted) Cayley tree of size n is a tree (in the graph-theoretic sense) on the vertex set V = {1, 2, . . . , n}, with a distinguished vertex ρ called the root. An embedding of such a tree in Z is a map a : V → Z such that a(ρ) = 0 and |a(v) -a(v ′ )| = 1 if v and v ′ are neighbours. We call a(v) the abscissa of v. The vertical profile of this embedded tree is (n ℓ , . . . , n -1 ; n 0 , n 1 , . . . , n r ), where n i is the number of vertices at abscissa i, and ℓ (resp. r) is the smallest (resp. largest) abscissa occurring in the tree. The counterpart of Theorem 1 for Cayley trees reads as follows.

Theorem 2. Let ℓ ≤ 0 ≤ r, and let (n i ) ℓ≤i≤r be a sequence of positive integers. The number of embedded rooted Cayley trees having vertical profile (n ℓ , . . . , n -1 ; n 0 , n 1 , . . . , n r ) is

n 0 n ℓ n r n! r i=ℓ (n i -1)! r i=ℓ (n i-1 + n i+1 ) ni-1 ,
where n = i n i is the number of vertices and n ℓ-1 = n r+1 = 0.

For example, the number of Cayley trees having vertical profile (2; 2, 1) is

2 2 × 1 5! 1! × 1! × 0! 2 1 × 3 1 × 2 0 = 5! × 6.
The shapes of these trees are shown in Figure 3. The positions of the vertices indicate their abscissas, but the labels of the nodes (in the interval 1, 5 ) are not indicated. To each of the first 5 shapes there corresponds 5! Cayley trees. To each of the last 2 shapes there corresponds 5!/2 Cayley trees.

Figure 3. The shapes of the rooted Cayley trees having vertical profile (2; 2, 1).

Theorems 1 and 2 can be proved using the multivariate Lagrange inversion formula, as will be shown in Section 7. Theorem 2 can also be proved using the matrix-tree theorem. However, non-trivial cancellations occur during the calculation, and the simple product forms remain mysterious. This is why we focus in the paper on bijective proofs, which explain directly the product forms. Moreover, these proofs allow us to consider other abscissa increments than ±1 (with the condition that the largest increment is 1). They also allow us to refine the enumeration, by taking into account the number of vertices at abscissa j whose parent lies at abscissa i, and/or the number of vertices at abscissa i having a prescribed number of children at abscissa j, for all i and j. In particular, we can impose that each vertex has at most one child of each abscissa, and the binary trees of Theorem 1 will in fact be seen (up to a symmetry factor of n!, where n is the number of vertices) as rooted Cayley trees such that each vertex of abscissa i has at most one child at abscissa i + 1 and at most one child at abscissa i -1.

Our enumerative results are presented in the next section. We describe in Section 3 a first, basic bijection. It transforms certain functions into embedded trees, and is close to a bijection constructed by Joyal to count Cayley trees [START_REF]Une théorie combinatoire des séries formelles[END_REF]. Section 4 collects simple enumerative results on functions, and converts them, via our bijection, into results on trees. Unfortunately, this basic bijection only proves the results of Section 2 for trees with non-negative labels. In Section 5, we design a much more involved variant of the basic bijection, which proves the remaining results (in Section 6). Finally, we discuss in Section 7 two other approaches to count embedded trees, namely functional equations coupled with the multivariate Lagrange inversion formula, and the matrix-tree theorem. These approaches require less invention, but they do not explain the product forms, and they prove only part of our results.

Main results

Embedded trees: definitions

A rooted Cayley tree of size n is a tree (that is, an acyclic connected graph) on the vertex set V = {1, . . . , n}, with a distinguished vertex called the root.

Let S ⊂ Z be a set of integers. An S-embedded Cayley tree is a rooted Cayley tree in which every vertex v is assigned an abscissa a(v) ∈ Z in such a way:

• the abscissa of the root vertex is 0,

• if v ′ is a child of v, then a(v ′ ) -a(v) ∈ S.
The vertical profile of the tree is (n ℓ , . . . , n -1 ; n 0 , n 1 , . . . , n r ), where n i is the number of nodes at abscissa i, and ℓ (resp. r) is the smallest (resp. largest) abscissa found in the tree. The tree is non-negative if all vertices lie at a non-negative abscissa. Equivalently, ℓ = 0.

Let m = min S and M = max S. The type of a vertex v is (i; s; c m , . . . , c M ), where i = a(v) is the abscissa of v, i -s is the abscissa of its parent (if v is the root, we take s = ε), and for m ≤ k ≤ M , c k is the number of children of v at abscissa i + k. Note that s ∈ S ∪ {ε}. We often denote c := (c m , . . . , c M ) ∈ N M+1-m . The out-type of v is simply (i; s). Its in-type is (i; c). The reason for this terminology is that the edges are considered to be oriented towards the root. We sometimes call (i; s; c) the complete type of v.

An embedded Cayley tree is injective if two distinct vertices lying at the same abscissa have different parents. Equivalently, every vertex v has at most one child at abscissa a(v) + s, for all s ∈ S. Two embedded Cayley T and T ′ trees are equivalent if they only differ by a renaming of the vertices. More precisely, if T and T ′ have size n, they are equivalent if there exists a bijection f on 1, n that

• respects the tree: if w is the parent of v in T , then f (w) is the parent of f (v) in T ′ ,

• respects abscissas: the abscissas of v in T and f (v) in T ′ are the same. An example in shown in Figure 4. Finally, an S-ary tree is an equivalence class of S-embedded injective Cayley trees. Thus an S-ary tree can be seen as an (unlabelled) rooted plane tree, drawn in the plane is such a way the root lies at abscissa 0, and each vertex v has at most one child at abscissa a(v) + s, for all s ∈ S. For instance, a {-1, 1}-ary tree is a binary tree that is canonically embedded, as shown in Figure 2. Similarly, a {-1, 0, 1}-ary tree is a canonically embedded ternary tree [START_REF] Kuba | A note on naturally embedded ternary trees[END_REF]. Since injective trees have no symmetry, the n! ways one can label the vertices of a given S-ary tree of size n give rise to exactly n! distinct injective S-embedded Cayley trees.

The vertical profile

Our first results deal with the number of embedded trees having a prescribed profile. As all results in this paper, they require the largest element of S to be 1. This condition is reminiscent of the enumeration of lattice paths in the half-line N, for which simple formulas exist provided the set S of allowed steps satisfies max S = 1; see for instance [20, p. 75].

Theorem 3 (Embedded Cayley trees). Let S ⊂ Z such that max S = 1. Let ℓ ≤ 0 ≤ r, and let (n i ) ℓ≤i≤r be a sequence of positive integers. If min S = -1 or ℓ = 0, the number of S-embedded Cayley trees having vertical profile (n ℓ , . . . , n -1 ; n 0 , n 1 , . . . , n r ) is

n 0 n ℓ n r n! r i=ℓ (n i -1)! r i=ℓ s∈S n i-s ni-1
, where n = i n i is the number of vertices and n i = 0 if i < ℓ or i > r.

When S = {-1, 1}, this theorem specializes to Theorem 2.

Remarks

1. This formula has several interesting specializations. When 0 ∈ S and ℓ = r = 0, every vertex lies at abscissa 0 and we are just counting rooted Cayley trees of size n = n 0 . Accordingly, the above formula is n n-1 . If S = {1}, each rooted Cayley tree has a unique S-embedding, and a vertex at distance i from the root lies at abscissa i. Hence the vertical profile of the tree coincides with its horizontal profile. The above theorem thus gives the number of rooted Cayley trees with horizontal profile

(1, n 1 , . . . , n r ) as n! n 1 ! • • • n r ! r-1 i=1 n ni+1 i with n = 1 + n 1 + • • • + n r .
This formula has a straightforward explanation: the multinomial coefficient describes the choice of the vertices lying at height i, for all i, and the factor n ni+1 i describes how to choose a parent for each vertex lying at height i + 1.

If S = {-1, 1} and ℓ = 0, r = 1, the above theorem gives the number of bicolored Cayley trees, rooted at a white vertex, having n 0 white vertices and n 1 black vertices:

n 0 n 0 + n 1 n 0 n n0-1 1 n n1-1 0 .
Equivalently, the number of spanning trees of the complete bipartite graph K n0,n1 is n n0-1

1 n n1-1 0
(for references on this result, see the solution of Exercise 5.30 in [START_REF] Stanley | Enumerative combinatorics[END_REF]).

2.

The assumption that the numbers n i are positive is not restrictive. Indeed, if (n ℓ , . . . ; n 0 , . . . , n r ) is the profile of an S-embedded tree, and the above conditions on S and ℓ hold, then n ℓ , . . . , n r are positive. Indeed, by definition of the profile, n ℓ > 0 and n r > 0. Moreover, the fact that the root lies at abscissa 0, and the condition max S = 1, imply that n 0 , n 1 , . . . , n r-1 are also positive. Finally, if ℓ < 0, then we are assuming that min S = -1, so that, symmetrically, n ℓ+1 , . . . , n -1 are positive.

3. It seems that no simple product formula exists 1 when ℓ < 0 and min S < -1. For instance, when S = {-2, -1, 1}, the number of S-embedded trees with vertical profile (1, 1, 1, 2, 1; 1) is 1 See however the note at the end of this paper and the more recent paper [START_REF] Bernardi | Counting trees using symmetries[END_REF] for a (less explicit) formula that applies more generally. S-embedded trees with vertical profile (1, 1, 2, 1, 1, 1), which shows that the assumption max S = 1 is also needed, even when ℓ = 0.

6!

4. It suffices to prove the theorem when ℓ = 0. Indeed, assume ℓ < 0 and min S = -1. We claim that the number of S-embedded trees having profile (n ℓ , . . . ; n 0 , . . . , n r ) and a marked vertex v at abscissa ℓ equals the number of S-embedded trees with profile (m 0 , . . . , m r-ℓ ) := (n ℓ , . . . , n 0 , . . . , n r ) (no semi-colon!) having a marked vertex at abscissa -ℓ. This follows from re-rooting the tree at v (that is, choosing the vertex v as the new root of the tree), marking the former root and then translating the abscissas by -ℓ. The resulting tree is a Sembedded tree because, when min S = -1, the set of increments is symmetric. Thus, the number T (n ℓ , . . . ; n 0 , . . . , n r ) of trees having profile (n ℓ , . . . ; n 0 , . . . , n r ) satisfies

n ℓ T (n ℓ , . . . ; n 0 , . . . , n r ) = m -ℓ T (m 0 , . . . , m r-ℓ ) = m -ℓ m r-ℓ r-ℓ i=0 s∈S m i-s mi-1 (case ℓ = 0 of Theorem 3) = n 0 n r r i=ℓ s∈S n i-s ni-1 (because m i = n i+ℓ ),
which gives the announced expression of T (n ℓ , . . . ; n 0 , . . . , n r ).

Let us now state the counterpart of Theorem 3 for S-ary trees.

Theorem 4 (S-ary trees). Let S ⊂ Z such that max S = 1. Let ℓ ≤ 0 ≤ r, and let (n i ) ℓ≤i≤r be a sequence of positive integers. If min S = -1 or ℓ = 0, the number of S-ary trees having vertical profile (n ℓ , . . . , n -1 ; n 0 , n 1 , . . . , n r ) is

n 0 n ℓ n r s∈S n -s n 0 -1 ℓ≤i≤r i =0 s∈S n i-s -1 n i -1 , with n i = 0 if i < ℓ or i > r.
When S = {-1, 1}, this theorem specializes to Theorem 1.

Remarks

1. It seems that no simple product formula exists2 when ℓ < 0 and min S < -1. For instance, when S = {-2, -1, 1}, the number of S-ary trees with vertical profile (1, 1, 1, 2, 1; 1) is 107, which is prime. Symmetrically, if S = {-1, 1, 2}, there are 107 S-ary trees with vertical profile (1, 1, 2, 1, 1, 1), which shows that the assumption max S = 1 is also needed, even when ℓ = 0.

2. Rerooting an S-ary tree does not always give an S-ary tree, even if min S = -1 (think of re-rooting the first tree of Figure 2 at the lowest vertex of abscissa -1). Thus the case ℓ < 0 of Theorem 4 does not follow from the case ℓ = 0, at least in an obvious way. It would be interesting to explore the combinatorial connection between these two cases.

The out-types

We now prescribe the number n(i, s) of vertices of out-type (i; s), for all i ∈ Z and s ∈ S. In particular, the number n i of vertices at abscissa i is determined, equal to 1 i=0 + s n(i, s). In other words, the profile is fixed.

Theorem 5 (Embedded Cayley trees). Let S ⊂ Z such that max S = 1. Let n(i, s) be nonnegative integers, for i ∈ Z and s ∈ S, and assume that either min S = -1, or n(i, s) = 0 for all i < 0 and s ∈ S. The number of S-embedded Cayley trees in which, for all i ∈ Z and s ∈ S, exactly n(i, s) non-root vertices have out-type

(i; s) is n! r i=ℓ n c(i)-1 i -1 i=ℓ n(i, -1) r i=1 n(i, 1) i,s n(i, s)! ,
where n is the number of vertices, (n ℓ , . . . , n -1 ; n 0 , . . . , n r ) is the profile corresponding to the numbers n(i, s), and c(i) is the number of vertices whose parent lies at abscissa i:

n = i n i , n i = s n(i, s) + 1 i=0 , c(i) = s n(i + s, s).
When the range of a product or sum is not indicated, it is the 'natural' one (s ∈ S, i ∈ Z). It is assumed that n i > 0 for ℓ ≤ i ≤ r.

Remarks

1. An equivalent formulation consists in giving the generating function of S-embedded Cayley trees of vertical profile (n ℓ , . . . ; n 0 , . . . , n r ), where a variable x i,s keeps track of the number of vertices of out-type (i; s). One easily checks that the above theorem boils down to saying that this generating function is

n 0 n ℓ n r n! r i=ℓ (n i -1)! -1 i=ℓ x i,-1 r i=1 x i,1 r i=ℓ s∈S n i-s x i,s ni-1 . (2)
This formula refines of course Theorem 3, obtained by setting x i,s = 1 for all i and s.

2. As pointed out in [START_REF] Bernardi | Counting trees using symmetries[END_REF], this theorem follows from [5, Eq. ( 23)], upon identifying the cofactor that occurs in that formula as a number of trees (which is simple to determine).

Let us now state the counterpart of Theorem 5 for S-ary trees.

Theorem 6 (S-ary trees). Let S ⊂ Z such that max S = 1. Let n(i, s) be non-negative integers, for i ∈ Z and s ∈ S, and assume that either min S = -1, or n(i, s) = 0 for all i < 0 and s ∈ S.

The number of S-ary trees in which, for all i ∈ Z and s ∈ S, exactly n(i, s) non-root vertices have out-type (i; s) is

-1 i=ℓ n(i, -1) r i=1 n(i, 1) r i=ℓ n i i,s n i-s n(i, s) ,
where (n ℓ , . . . , n -1 ; n 0 , . . . , n r ) is the profile corresponding to the numbers n(i, s). Again, it is assumed that n i > 0 for ℓ ≤ i ≤ r.

Remark. It seems that no simple counterpart of (2) exists. That is, the generating function of S-ary trees of vertical profile (n ℓ , . . . ; n 0 , . . . , n r ), taking into account the out-types of the vertices, does not factor nicely.

The in-types

We now prescribe the number n(i, c) of vertices of in-type (i; c), for all i and c = (c m , . . . , c M ), with m = min S and M = max S. By definition of the in-types, it suffices to study the case where S = m, M .

Note that the number n i of vertices at abscissa i is determined, equal to c n(i, c). Hence the profile (n ℓ , . . . ; n 0 , . . . , n r ) is fixed. The number n(i, s) of vertices of out-type (i; s) is also determined by the choice of the numbers n(i, c). Indeed, n(i, s) is the number of edges going from a vertex of abscissa i to its parent of abscissa i -s, so that

n(i, s) = c c s n(i -s, c).
Since we can express n i in terms of the numbers n(i, s) or in terms of the numbers n(i, c), the following compatibility condition is required: for ℓ ≤ i ≤ r,

1 i=0 + s,c c s n(i -s, c) = c n(i, c).
We will also assume, as before, that n ℓ , . . . , n r are positive.

Theorem 7. Let m ≤ 1 and S = m, 1 . Let n(i, c) be non-negative integers, for i ∈ Z and c ∈ N 2-m , satisfying the above compatibility condition. Assume moreover that either m = -1, or n(i, c) = 0 for all i < 0 and c ∈ N 2-m . The number of S-embedded Cayley trees in which, for all i ∈ Z and c ∈ N 2-m , exactly n(i, c) vertices have in-type

(i; c) is n! r i=ℓ (n i -1)! i,c n(i, c)! b≥0,s b! ns(b) -1 i=ℓ n(i, -1) r i=1 n(i, 1),
where n is the number of vertices, (n ℓ , . . . , n -1 ; n 0 , . . . , n r ) is the profile corresponding to the numbers n(i, c), n s (b) is the number of vertices v that have exactly b children at abscissa a(v)+s, and n(i, s) is the number of vertices of out-type (i, s). Equivalently,

n = i n i , n i = c n(i, c), n s (b) = i c:c s =b n(i, c), n(i, s) = c c s n(i -s, c).
Remarks 1. Again, this theorem has interesting specilizations. Assume for instance that n(i, c) = 0 as soon as i = 0, and m = 0. Then the only non-zero numbers n(i, c) are of the form n(0, i, 0) := k i , giving the number of vertices of the tree having i children. In particular, n 0 = n. The above formula reads n!(n -1)! i k i ! i i! ki , and gives the number of rooted Cayley trees having k i vertices of in-degree i [START_REF] Stanley | Enumerative combinatorics[END_REF]Corollary 5.3.5].

If S = {1}, each rooted Cayley tree has a unique S-embedding, and a vertex at distance i from the root lies at abscissa i. The above theorem gives the number of rooted Cayley trees in which k(i, c) vertices have height i and (in-)degree c, for all i and c:

n! i,c k(i, c)! r i=1 n i ! c c! k(i-1,c) .
This formula has a direct explanation: the multinomial coefficient describes the choice of the vertices of indegree c lying at height i, for all i and c and the multinomial

ni! c c! k(i-1,c) how to assign children to vertices of height i -1.
If S = {-1, 1} and ℓ = 0, r = 1, the above theorem gives the number of bicolored Cayley trees, rooted at a white vertex, having k(0, c) white vertices of (in-)degree c and k(1, c) black vertices of (in-)degree c for all c:

(n 0 + n 1 )!(n 0 -1)!n 1 ! i,c k(i, c)! c c! k(0,c)+k(1,c) , (3)
with n i = c k(i, c). This is related to a known formula that gives the number of spanning trees of the complete bipartite graph K m0,m1 (with white vertices labelled u 1 , . . . , u m0 and black vertices labelled v 1 , . . . , v m1 ) in which each vertex has a prescribed degree:

(m 0 -1)!(m 1 -1)! c ! k(0,c)+k(1,c) , (4)
where k(0, c) (resp. k(1, c)) is the number of white (resp. black) vertices of total degree c + 1 (see [START_REF] Stanley | Enumerative combinatorics[END_REF]Exercise 5.30] and [START_REF] Bacher | On the enumeration of labelled hypertrees and of labelled bipartite trees[END_REF]). Indeed, (3) can be derived from (4), taken with m 0 = n 0 and m 1 = 1 + n 1 , when v 1 has degree 1. Conversely, our results actually allow us to prescribe the in-type of the root and the number of white and black vertices of fixed in-type (see Section 4.5), and this refined formula implies (4).

2.

If n(i, c) = 0 as soon as one of the components of c is larger than 1, then the trees counted by the above formula are injective. Thus it suffices to divide this formula by n! to obtain the number of S-ary trees having n(i, c) vertices of in-type (i; c) for all i and c.

The complete types

We finally prescribe the in-type (0; c 0 ) of the root and the number n(i, s, c) of (non-root) vertices of (complete) type (i; s; c), for all i, s and c. In particular, the number of vertices of out-type (i, s) is fixed, and can be expressed in terms of the numbers n(i, s, c) in two different ways. This yields the following compatibility condition, for all i and s:

1 i=s c s 0 + t,c c s n(i -s, t, c) = c n(i, s, c).
We also assume, as before, that n ℓ , . . . , n r are positive.

We have only obtained a formula when ℓ = 0 and 0 ∈ S (plus the usual condition max S = 1). We thus focus on the case S = m, -1 ∪ {1}.

Theorem 8. Let m ≤ 1 and S = m, -1 ∪ {1}. Let c 0 = (0, . . . , 0, c 1 0 ) ∈ N 2-m . Let n(i, s, c) be non-negative integers, for i ∈ Z, s ∈ S and c ∈ N 2-m , such that n(i, s, c) = 0 if i < 0 or c 0 > 0.
Assume that the above compatibility condition holds. The number of S-embedded Cayley trees in which the root has in-type (0; c 0 ) and for all i ∈ Z, s ∈ S and c ∈ N 2-m , exactly n(i, s, c) non-root vertices have type (i; s; c) is

c 1 0 n! i,s n(i, s)! i,s,c n(i, s, c)! r i=1 n(i, 1) b≥0,s b! ns(b) r-1 i=1 b>0 b n 1 (i, 1, b) ,
where n is the number of vertices, r is the maximal abscissa, n(i, s) is the number of vertices of out-type (i; s), n s (b) is the number of vertices v that have exactly b children at abscissa a(v) + s, and n 1 (i, 1, b) is the number of vertices of out-type (i; 1) that have exactly b children at abscissa i + 1. That is,

n(i, s) = c n(i, s, c), n s (b) = i,t c:c s =b n(i, t, c) + 1 s=1,b=c 1 0 , n 1 (i, 1, b) = c:c 1 =b n(i, 1, c).

A bijection for non-negative trees

Let n 0 , . . . , n r be a sequence of positive integers. Let V = ∪ r i=0 V i with V i = {i 1 , . . . , i ni }. The elements of V are called vertices, and the vertices of V i are said to have abscissa i. The abscissa of a vertex v is denoted by a(v). The vertices are totally ordered as follows:

i k ≤ j p ⇐⇒ (i < j) or (i = j and k ≤ p).

We consider partial functions f on V , which we regard as digraphs on the vertex set V : for each vertex v such that f (v) is defined, an arc joins v to f (v).

Let S ⊂ Z with min S = m and max S = 1. A partial function f on V is an S-function if for all v = i k such that f (v) is defined,

f (i k ) ∈ ∪ s∈S V i-s .
The type (or: complete type) of the vertex v is (i; s; c m , . . . , c 1 ), where i is the abscissa of v, i -s is the abscissa of f (v) (or ε if f (v) is not defined), and for m ≤ k ≤ 1, c k is the number of pre-images of v at abscissa i + k. We often denote c = (c m , . . . , c 1 ). The out-type of v is (i; s). Its in-type is (i; c). In the function shown in Figure 5, which is an S-function for S = -2, 1 , the vertex 0 1 has type (0; ε; 0, 0, 0, 1), and the vertex 2 1 has type (2; 1; 1, 0, 0, 1). An edge of a digraph is an S-edge if it joins a vertex of abscissa i to a vertex of abscissa i -s, for s ∈ S.

2 5 2 4 3 2 2 2 2 3 0 3 0 5 0 4 1 4 2 8 1 2 2 10 2 9 2 6 3 3 2 7 1 3 3 4 3 5 1 1 2 1 3 1 0 1 0 2 3 6 Figure 5. A {-2, -1, 0, 1}-function on V = {0 1 , . . . , 0 5 , 1 1 , . . . , 1 4 , 2 1 , . . . , 2 10 , 3 1 , . . . , 3 6 }.
Consider now a rooted tree T on the vertex set V . We say that T is an S-tree if the parent of any (non-root) vertex of V i belongs to ∪ s∈S V i-s . We orient the edges of T towards the root: then V can be seen as an S-function. This allows us to define the type, in-type and out-type of a vertex. A marked S-tree is a pair (T, r q ) consisting of an S-tree and a marked vertex r q ∈ V r . There is a simple connection between S-trees and S-embedded Cayley trees, which will be made explicit in the next section. We focus for the moment on S-trees. Theorem 9. Let n 0 , . . . , n r , V and S be as above. There exists a bijection Φ between S-functions

f : V \ {0 1 } → V satisfying (F) for 1 ≤ i ≤ r, f (i 1 ) = (i -1) 1 ,
and marked S-trees (T, r q ) on the vertex set V , rooted at the vertex 0 1 and satisfying (T) on the path going from r q to 0 1 , the first vertex belonging to V i-1 is preceded by i 1 , for all i ∈ 1, r . (The condition max S = 1 implies that this path contains a vertex of V i-1 for all i.) Moreover, the bijection Φ (a) preserves the out-type of every vertex;

(b) preserves the number of vertices of in-type (i; c), for all i and c; (c) preserves the complete type of each vertex if 0 ∈ S. Of course, this implies (a) and (b).

Proof. The bijection Φ is the composition of two bijections Φ 1 and Φ 2 . The first bijection, Φ 1 , transforms an S-function into an S-tree. It is a simple adaptation of a construction designed by Joyal to count Cayley trees [25, p. 16]. It satisfies Properties (a) and (c). However, if 0 ∈ S, it does not satisfy (b). The second bijection, Φ 2 , remedies this problem by performing a simple re-arrangement of subtrees. If 0 ∈ S, then Φ 2 is the identity, so that Φ = Φ 1 .

• The map Φ 1 : from functions to trees Let us describe the construction Φ 1 . It is illustrated in Figure 6, where we construct the tree associated with the function of Figure 5 (which satisfies indeed Condition (F)). Let f : V \ {0 1 } → V be a function satisfying (F), and consider the associated digraph G f . One of its connected components contains the path r 1 → (r -1) 1 → • • • → 1 1 → 0 1 . Split each of the r edges of this path into two half-edges (one in-going, one out-going), thus forming r + 1 pieces. Each piece is of the form We say that i 1 (or r 1 , or 0 1 ) is the source (and also the sink) of this piece. Each of the other components of G f contains exactly one cycle. In each of them, split into two half-edges the edge that goes into the smallest vertex, say i k , of the cycle. The vertices that formed the cycle now form a distinguished path in the resulting piece, starting from i k . Trees are attached to the vertices of this path, as shown below:

1 1 0 3 0 5 2 8 1 4 0 4 0 1 2 6 2 4 2 5 3 2 2 2 2 3 2 1 0 2 1 3 3 5 3 1 3 6 3 3 2 7 3 4 2 9
• • • i k j p .
We say that i k is the source of this piece. The endpoint of the distinguished path is the sink of the piece. We say that the piece has type (i, j).

Lemma 10. If i k and j p are respectively the source and the sink of a piece and k = 1, then j = i + 1, or j = i with p ≥ k. The latter case only occurs if 0 ∈ S.

Proof. We have j p ≥ i k (since i k was minimal in its cycle). Given that f (j p ) = i k , and max S = 1, this means that either j = i + 1, or j = i with p ≥ k. Now, order the pieces from left to right by decreasing source: the first (leftmost) piece has source r q , for some q ∈ {1, . . . , n r }, and the last (rightmost) piece has source 0 1 . Concatenate them to form a single path going from r q to 0 1 , keeping in place the attached trees. Note that there is a piece of source i 1 , for all i ∈ 0, r . A typical path from r q to 0 1 is shown in Figure 7. The resulting graph is a tree rooted at 0 1 . In this tree, we mark the vertex r q . We define this marked tree to be Φ 1 (f ).

Proposition 11. The map Φ 1 satisfies all properties stated in Theorem 9, apart from (b).

Proof. Let us first prove that Φ 1 is injective. Observe that the sources of the pieces are the lower records met on the path from r q to 0 1 . This allows us to recover the collection of pieces by splitting into two half-edges each edge of this path that goes into a lower record. From the pieces, it is easy to reconstruct the function f : one adds an edge from i 1 to (i -1) 1 for i ∈ 1, r , and then connects the two extremal half-edges in each remaining piece to form a cycle. Thus Φ 1 is injective.

It is clear from the construction (and its illustration in Figure 7) that the out-types are preserved. In particular, Φ 1 (f ) is an S-tree. It satisfies (T) by construction. Note that the in-type of vertices may change. However, this only happens for source vertices. In the example of Figure 6, the in-type of each source other than 1 1 has changed.

Let us now prove (c). Assume 0 ∈ S. By Lemma 10, a piece of source i k and sink j p satisfies j = i + 1, provided k > 1. Thus the path going from r q to 0 1 in Φ 1 (f ) has a simpler form:

(r -1) 1 1 1 0 1 (r -1) n1 • • • r * (r -1) n2 • • • r * (r -1) n3 • • • r * r 1 • • • 0 m3 • • • 1 * 0 m2 • • • 1 * 0 m1 • • • 1 *
In particular, the marked vertex is r 1 . It is now easy to check that each vertex has the same type in Φ 1 (f ) as in f , so that (c) holds. It remains to prove that Φ 1 is surjective. Take a marked S-tree (T, r q ), rooted at 0 1 and satisfying (T). Let us call the path going from r q to 0 1 the distinguished path of T . Each lower record of this path is called a source. Each vertex that precedes a source (plus the vertex 0 1 ) is called a sink. In the distinguished path, split into two half-edges each edge that goes into a source. This gives a number of pieces, formed of a distinguished path starting at a source and ending at a sink, to which trees are attached. By Condition (T), each vertex i 1 is a lower record, followed (when i > 0) by another one. Thus there is a piece of source and sink i 1 , for all i ∈ 0, r . Concatenate the pieces of source i 1 to form a path r 1 → • • • → 0 1 . In each of the other pieces, close the distinguished path to form a cycle. The resulting graph G is the graph of a function g : V \ {0 1 } → V . It satisfies (F) by construction. As observed when proving injectivity, if (T, r q ) = Φ 1 (f ), where f is an S-function satisfying (F), then f and g coincide.

We claim that g is always an S-function. We only need to check that each edge of G that was not in the tree is an S-edge. Since 1 ∈ S, the edges r 1 → • • • → 0 1 are S-edges. Now consider a piece of source i k , with k > 1. Its sink j p is followed in T by a lower record that has also abscissa i (because one of the lower records is i 1 ), say i m . The edge we add to form a cycle is j p → i k , and it is an S-edge since the edge j p → i m was an S-edge of T . Proposition 11 says that Φ 1 fulfills almost all requirements of Theorem 9, apart from Condition (b). More specifically, the in-types of sources may change, and this only happens if 0 ∈ S.

(r -1) n3 • • • (r -1) * (r -1) n2 • • • r * (r -1) n1 • • • (r -1) * (r -1) 1 1 1 0 m3 • • • 1 * 0 m2 • • • 0 * 0 m1 • • • 0 * 0 1 • • • r p1 • • • r * r 1 r q • • • r * Figure 7.
A typical path from r q to 0 1 , after concatenation of the pieces. It is assumed that q > p 1 , n 3 > n 2 > n 1 and m 3 > m 2 > m 1 . The boxes show the distinguished paths of the pieces. The edges that join the boxes were not in the graph of the function f , unless they are of the form (i + 1) 1 → i 1 . The dashed edges that are not of the form (i + 1) 1 → i 1 were in the graph of f , but are not in the final tree.

Our second transformation, Φ 2 , performs on the tree (T, r q ) := Φ 1 (f ) a little surgery that remedies this problem.

• The map Φ 2 : rearranging subtrees Let (T, r q ) be a marked tree satisfying the conditions of Theorem 9. Let f = Φ -1 1 (T, r q ). Consider the section of the distinguished path of T comprised between the vertices (i + 1) 1 and i 1 (we assume for the moment that i < r). The first piece of this section has source and sink (i + 1) 1 , while all other pieces, including the final one with source i 1 , have type (i, i) or (i, i + 1):

! ! ! ! i 1 (i + 1) 1 i n2 • • • i * i n6 • • • (i + 1) * i n1 • • • (i + 1) * i n3 • • • (i + 1) * i n4 • • • i * i n5 • • • i *
We say that a source v of abscissa i is frustrated if its in-type is not the same in T and f . The above figure, in which frustrated sources are indicated with an exclamation mark, shows that this happens in two cases.

Observation 12. A source v of abscissa i < r is frustrated if and only if one of the following conditions holds:

• the sink of the piece containing v has abscissa i, but the sink of piece that precedes v has abscissa i + 1, • the sink of the piece containing v has abscissa i + 1, but the sink of piece that precedes v has abscissa i.

In the former (resp. latter) case, we say that v is i-frustrated (resp. (i + 1)-frustrated). The key observation that will allow us to preserve in-types after a small surgery is the following.

Observation 13. Consider the frustrated vertices of abscissa i met on the distinguished path of T . Then i-frustrated vertices and (i+1)-frustrated vertices alternate, starting with an i-frustrated vertex, and ending with an (i + 1)-frustrated vertex.

Recall that the marked tree (T, r q ) consists of subtrees attached to a distinguished path. If there are 2m frustrated vertices of abscissa i, say i k1 , . . . , i k2m , to which the subtrees τ 1 , . . . , τ 2m are attached, exchange the subtrees τ 2p-1 and τ 2p for all p ∈ 1, m (leaving their roots i k1 , . . . , i k2m in place). In the resulting tree, i k2p-1 inherits the in-type that i k2p has in the function f , and vice-versa. The in-type of non-frustrated vertices has not changed.

The surgery is simpler for frustrated vertices of abscissa r, because there are no pieces of type (r, r + 1). Observation 14. If the marked vertex is r q = r 1 , there are no frustrated vertices at abscissa r. Otherwise, the only two frustrated vertices at abscissa r are r 1 and the marked vertex r q .

In the latter case we simply exchange the subtrees attached to r 1 and r q , so that r q inherits the in-type that r 1 has in f , and vice-versa.

We define Φ 2 (T, r q ) to be the marked tree obtained after rearranging the subtrees of (T, r q ), and Φ := Φ 2 • Φ 1 . An example is shown in Figure 8, where we rearrange the subtrees of the tree (T, r q ) = Φ 1 (f ) shown in Figure 6.

We claim that Φ satisfies Theorem 9. Of course, the proof of this fact uses the properties of Φ 1 stated in Proposition 11.

First, observe that the out-types are the same in T and Φ 2 (T, r q ) (because vertices pointing to a frustrated source of abscissa i in T also point to a source of abscissa i in Φ 2 (T, r q )). Hence Φ

! ! ! ! ! ! ! ! 1 1 0 3 0 5 2 8 1 4 0 4 0 1 2 6 2 4 2 5 3 2 2 3 2 1 3 5 3 1 3 3 2 7 3 4 2 9
2 10

1 2 1 3 3 6 0 2 2 2 Figure 8.
The map Φ 2 applied to the tree (T, r q ) of Figure 6 (with r q = 3 4 ).

The frustrated vertices are the same in (T, r q ) and Φ 2 (T ), and are indicated by "!".

satisfies (a). It also satisfies (c), because there are no frustrated vertices if 0 ∈ S, so that Φ 2 leaves all trees unchanged. Finally, the surgery performed by Φ 2 is precisely designed to "correct" the in-types of frustrated vertices, while leaving unchanged the in-types of non-frustrated vertices. Hence Φ satisfies (b).

It remains to prove that Φ 2 is bijective. A stronger property actually holds: Φ 2 is an involution. Indeed, the distinguished paths of (T, r q ) and Φ 2 (T, r q ) coincide, and Observations 12 and 14 imply that the frustrated vertices of (T, r q ) and Φ 2 (T, r q ) are the same. Applying Φ 2 to Φ 2 (T, r q ) just restores the marked tree (T, r q ).

Enumeration of non-negative embedded trees

In this section, we prove the enumerative results of Section 2 in the case ℓ = 0, that is, for non-negative trees. These results follow from the bijection of Theorem 9, combined with the enumeration of S-functions (which, as we shall see, is an elementary exercise). We also need to relate the S-trees occurring in Theorem 9 to the S-embedded Cayley trees of Section 2. This is done in the following lemma. We adopt the same notation as in the previous section: V = ∪ r i=0 V i with V i = {i 1 , . . . , i ni }, and S ⊂ Z satisfies min S = m and max S = 1. The type distribution of a tree is the collection of numbers n(i, s, c) (with i ∈ 0, r , s ∈ S and c ∈ N -m+2 ) giving the number of vertices of type (i; s; c).

Lemma 15. The number of non-negative S-embedded Cayley trees having a prescribed type distribution is

1 n r n! r i=0 (n i -1)
! times the number of marked S-trees satisfying Condition (T) of Theorem 9 and having the same type distribution (as always, (n 0 , . . . , n r ) denotes the profile of the tree, and n its size).

Proof. Equivalently, we want to prove that the number of non-negative S-embedded Cayley trees having a prescribed type distribution and a marked vertex at abscissa r is n! i (n i -1)! times the number of marked S-trees satisfying (T) and having the same type distribution. We will construct a 1-to-n!/ i (n i -1)! correspondence between marked S-trees satisfying (T) and marked S-embedded Cayley trees, preserving the type distribution.

Let (T, r q ) be a marked S-tree on V satisfying (T). On the path going from r q to 0 1 , the first vertex of V i-1 is preceded by i 1 , for 1 ≤ i ≤ r. Let us rename the vertex i 1 by i k , for a k chosen in {1, . . . , n i }; conversely, let us rename i k by i 1 . Let us also exchange the names of the vertices 0 1 and 0 p , for a p chosen in {1, . . . , n 0 }. This gives an arbitrary S-tree T 1 , rooted at 0 p , with a marked vertex at abscissa r. This tree may or may not satisfy (T). The number of different trees T 1 that can be constructed from T in such a way is r i=0 n i . The marked tree (T, r q ) can be recovered from (T 1 , r q ) by restoring vertex names, since we know that T is rooted at 0 1 and satisfies (T).

Let us now assign labels from {1, . . . , n}, with n = i n i , to the vertices of T 1 , in such a way that the labels a and b assigned to i k and i p satisfy a < b if k < p. There are n!/ i n i ! ways to do so. Finally, erase all names i k from the tree, for all i and k. This gives an arbitrary rooted S-embedded Cayley tree T 2 , with a marked vertex at abscissa r. The tree T 1 can be recovered from T 2 by renaming the vertices of abscissa i with i 1 , . . . , i ni in the unique way that is consistent with the order on labels: if two vertices of labels a and b, with a < b, lie at abscissa i, then their names i k and i p must satisfy k < p.

The marked S-tree T has given rise to n!/ i (n i -1)! marked embedded trees T 2 . Moreover, T 2 , T 1 and T have the same type distribution. The result follows.

In what follows, we will count trees by counting functions, using the correspondence of Theorem 9. We will sometimes prescribe the type (or in-type, or out-type) of every vertex of V , or just the number of vertices of each type (or in-type, or out-type). We will always assume that these type distributions are compatible with the conditions required for the function (by writing "assuming compatibility..."). For instance,

• if we fix the type (i v ; s v ; c v ) of each vertex v ∈ V (or just the in-type or out-type), we assume that

-i v = i if v ∈ V i , -s v ∈ S and i v -s v ∈ 0, r , -s v = 1 if v = i 1 with i > 0, and s v = ε if v = 0 1 , • if the number n(i, s) of vertices of V of out-type (i; s)
, for all i ∈ 0, r and s ∈ S, is prescribed, we assume that n(i, s) = 0 if i -s ∈ 0, r , and that

n i = s n(i, s) + 1 i=0 ,
• if the number n(i, c) of vertices of V of in-type (i; c), for all i ∈ 0, r and c ∈ N 2-m is fixed (whether we prescribe it directly, or whether we prescribe the in-type of each vertex), we assume that n(i, c) = 0 if c s > 0 for some s ∈ S, that

n i = c n(i, c),
and also that the following condition, obtained by counting in two different ways the vertices of V i , holds:

1 i=0 + s,c c s n(i -s, c) = c n(i, c),
• finally, if we fix the out-type c 0 of the vertex 0 1 , and if the number n(i, s, c) of vertices of V of type (i; s; c), for all i ∈ 0, r , s ∈ S and c ∈ N 2-m , is also fixed (whether we prescribe it directly, or whether we prescribe the type of each vertex), we assume that n(i, t, c) = 0 if c s > 0 for some s ∈ S, that

n i = s,c n(i, s, c),
and also that the following condition, obtained by counting in two different ways the vertices of out-type (i, s), holds:

1 i=s c s 0 + t,c c s n(i -s, t, c) = c n(i, s, c).

The profile of S-embedded Cayley trees: proof of Theorem 3

By Lemma 15, the number of S-embedded Cayley trees having vertical profile (n 0 , . . . , n r ) is n!/n r / i (n i -1)! times the number of marked S-trees satisfying (T) and having the same profile. By Theorem 9, the number of such marked trees is also the number of S-functions from V \ {0 1 } to V satisfying (F). This number is given by the following lemma. Theorem 3 follows, in the case ℓ = 0. As explained in the remarks that follow Theorem 3, this suffices to prove this theorem in full generality (that is, also when ℓ < 0 and min S = -1).

Lemma 16. The number of S-functions from V \ {0 1 } to V satisfying (F) is r i=0 s∈S n i-s ni-1
,

where n i = 0 if i < 0 or i > r.
Proof. We choose the image of each vertex of V i \ {i 1 } in the set ∪ s V i-s , for i = 0, . . . , r.

The profile of S-ary trees: proof of Theorem 4

As discussed at the end of Section 2.1, the number of S-ary trees having vertical profile (n 0 , . . . , n r ) is obtained by dividing by n! the number of injective S-embedded Cayley trees having this profile. Whether an S-embedded Cayley tree is injective can be decided from its type distribution, and more precisely from its distribution of in-types. Hence by Lemma 15, the number of injective S-embedded Cayley trees having vertical profile (n 0 , . . . , n r ) is n!/n r / i (n i -1)! times the number of marked injective S-trees satisfying (T) and having the same profile (by injective, we mean again that distinct vertices that lie at the same abscissa have different parents). By Theorem 9 (and particularly Property (b) of this theorem), the number of such marked trees is also the number of S-functions from V \ {0 1 } to V satisfying (F) that are injective on each V i . This number is given by the following lemma. Theorem 4 follows, in the case ℓ = 0. Lemma 17. The number of S-functions from V \ {0 1 } to V , injective on each V i and satisfying

(F) is s∈S n -s n 0 -1 r i=1 s∈S n i-s -1 n i -1 r i=0 (n i -1)!,
where

n i = 0 if i < 0 or i > r.
Proof. For i = 0, we choose the (distinct) images of the vertices of

V 0 \ {0 1 } in the set ∪ s V -s .
There are s∈S n-s n0-1

(n 0 -1)! ways to do so.

For i ≥ 1, we choose the (distinct) images of the vertices of

V i \{i 1 } in the set ∪ s V i-s \{(i-1) 1 }. There are s∈S ni-s-1 ni-1
(n i -1)! ways to do so. The lemma follows.

The out-types of S-embedded Cayley trees: proof of Theorem 5

We argue as in Section 4.1. By Lemma 15 and Theorem 9 (in particular Property (a) of this theorem), the number of S-embedded Cayley trees having n(i, s) non-root vertices of out-type (i; s) is n!/n r / i (n i -1)! times the number of S-functions from V \ {0 1 } to V satisfying (F) and having the same distribution of out-types. This number is given by the second part of the following lemma. Theorem 5 follows, in the case ℓ = 0.

Lemma 18. 1. The number of S-functions from V \ {0 1 } to V satisfying (F) and in which each v ∈ V has a prescribed out-type

(i v ; s v ) is, assuming compatibility, n r r i=0 n c(i)-1 i
, where c(i) is the number of vertices whose image lies in V i :

c(i) = ♯{v ∈ V : i v -s v = i}.

2.

Let n(i, s) be non-negative integers, for i ∈ 0, r and s ∈ S, satisfying the compatibility conditions of an out-type distribution. The number of S-functions from V \ {0 1 } to V satisfying (F) and in which, for all i ∈ 0, r and s ∈ S, exactly n(i, s) vertices have out-type

(i; s) is n r r i=0 (n i -1)! r i=0 n c(i)-1 i r i=1 n(i, 1) i,s n(i, s)! ,
where c(i) is the number of vertices whose image lies in V i :

c(i) = s n(i + s, s).
Proof. 1. We first choose the images of the c(r) vertices that have their image in V r . There are n c(r) r possible choices. For i < r, we only choose in V i the images of the c(i) -1 vertices distinct from (i + 1) 1 that have their image in V i . There are n c(i)-1 i possible choices. 2. We first choose the out-type of every vertex, and then apply the previous result. For all i and s, we must choose the n(i, s) vertices of V i that have out-type (i; s), keeping in mind that i 1 has out-type (i; 1) when i > 0 and (0; ε) when i = 0. Thus the number of ways to assign the out-types is

(n 0 -1)! s n(0, s)! r i=1 (n i -1)! (n(i, 1) -1)! s =1 n(i, s)! .
The lemma follows.

The out-types of S-ary trees: proof of Theorem 6

We argue as in Section 4.2. By Lemma 15 and Theorem 9 (in particular Properties (a) and (b) of this theorem), the number of S-ary trees having n(i, s) non-root vertices of out-type (i; s) is 1/n r / i (n i -1)! times the number of S-functions from V \ {0 1 } to V satisfying (F) that are injective on each V i and have the same distribution of out-types. This number is given by the second part of the following lemma. Theorem 6 follows, in the case ℓ = 0.

Lemma 19. 1. The number of S-functions from V \ {0 1 } to V , injective on each V i , satisfying (F), and in which each v ∈ V has a prescribed out-type

(i v ; s v ) is, assuming compatibility, 1 r-1 i=0 n i i,s n(i, s)! n i-s n(i, s) ,
where n(i, s) is the number of vertices of out-type (i, s).

2.

Let n(i, s) be non-negative integers, for i ∈ 0, r and s ∈ S, satisfying the compatibility conditions of an out-type distribution. The number of S-functions from V \ {0 1 } to V , injective on each V i , satisfying (F) and in which, for all i ∈ 0, r and s ∈ S, exactly n(i, s) vertices have out-type (i; s) is r i=0

(n i -1)! r i=1 n(i, 1) r-1 i=0 n i i,s n i-s n(i, s) .
Proof. 1. For any i ∈ 0, r , and s = 1, we choose in V i-s the (distinct) images of the n(i, s) vertices having out-type (i, s). There are ni-s n(i,s) n(i, s)! ways to do so.

When i ∈ 1, r and s = 1, we choose in V i-1 \ {(i -1) 1 } the images of the n(i, s) -1 vertices different from i 1 having out-type (i, 1). There are

n i-1 -1 n(i, 1) -1 (n(i, 1) -1)! = n i-1 n(i, 1) n(i, 1)! n i-1
ways to do so. Since there is no vertex of out-type (0; 1), this concludes the proof of the first result.

2. The argument used to prove the second part of Lemma 18 can be copied verbatim.

The in-types: proof of Theorem 7

Assume S = m, 1 . We argue as in Section 4.1. By Lemma 15 and Theorem 9 (in particular Property (b) of this theorem), the number of S-embedded Cayley trees having n(i, c) vertices of in-type (i; c) is n!/n r / i (n i -1)! times the number of S-functions from V \ {0 1 } to V satisfying (F) and having the same distribution of in-types. This number is given by the second part of the following lemma. Theorem 7 follows, in the case ℓ = 0 (that is,

n(i, c) = 0 if i < 0). Lemma 20. Let S = m, 1 , with m ≤ 1. 1. The number of S-functions from V \ {0 1 } to V satisfying (F) and in which each v ∈ V has a prescribed in-type (i v ; c v ) is, assuming compatibility, r i=0 (n i -1)! b≥0,s b! ns(b) r-1 i=0 c 1 i 1 ,
where n s (b) is the number of vertices v that have exactly b pre-images at abscissa a(v) + s:

n s (b) = ♯{v ∈ V : c s v = b}. 2.
Let n(i, c) be non-negative integers, for i ∈ 0, r and c ∈ N 2-m , satisfying the compatibility conditions of an in-type distribution. The number of S-functions from V \ {0 1 } to V satisfying (F) and in which, for all i ∈ 0, r and c ∈ N 2-m , exactly n(i, c) vertices have in-type

(i; c) is n r r i=0 (n i -1)! 2 i,c n(i, c)! b≥0,s b! ns(b) r i=1 n(i, 1),
where n s (b) is the number of vertices v that have exactly b pre-images at abscissa a(v) + s, and n(i, 1) is the number of vertices of out-type (i; 1). Equivalently,

n s (b) = i c:c s =b n(i, c), n(i, 1) = c c 1 n(i -1, c). Proof. 1. For 0 ≤ i ≤ r, let us choose the images of the n i -1 vertices of V i \ {i 1 }. Exactly c s (i-s) k -1 s=1=k,i>0 of them have image (i -s) k
, for all j and k. Thus the number of S-functions satisfying the required properties is

(n 0 -1)! s,k c s (-s) k ! r i=1 (n i -1)! c 1 (i-1) 1 s,k c s (i-s) k ! ,
which is equivalent to the first result.

2. As an intermediate problem, let us prescribe the in-type (i; c i 1 ) of all vertices of the form i 1 , and the number ñ(i; c) of vertices of V i \ {i 1 } having in-type (i; c), for all c ∈ N 2-m . Clearly,

ñ(i, c) = n(i, c) -1 c=c i 1 .
The number of ways to assign types to vertices of

V i \ {i 1 } is (n i -1)! c ñ(i, c)! = (n i -1)! c n(i, c)! n(i, c i 1 ).
Using the first result, we conclude that the number of functions such that i 1 has in-type (i; c i 1 ) and ñ(i; c) of vertices of

V i \ {i 1 } having in-type (i; c) is r i=0 (n i -1)! 2 i,c n(i; c)! b≥0,s b! ns(b) r-1 i=0 c 1 i 1 r i=0 n(i, c i 1 ) .
Finally, let us only prescribe the values n(i, c). That is, we want to sum the above formula over all possible in-types of the vertices i 1 , for i = 0, . . . , r. Note that only the two rightmost products depend on the choice of these types. We are thus led to evaluate

r i=0 c i 1 ∈N 2-m r-1 i=0 c 1 i 1 r i=0 n(i, c i 1 ) =   c r 1 n(r, c r 1 )   r-1 i=0   c i 1 c 1 i 1 n(i, c i 1 )   .
The first sum, over c r 1 , is n r . For i ≤ r -1, the sum over c i 1 is the number n(i + 1, 1) of vertices of out-type (i + 1; 1). This gives the second result of the lemma.

The complete types: proof of Theorem 8

Assume S = m, -1 ∪ {1}. We argue as in Section 4.1. By Lemma 15 and Theorem 9 (in particular Property (c) of this theorem), the number of S-embedded Cayley trees having n(i, s, c) vertices of type (i; s; c) is n!/n r / i (n i -1)! times the number of S-functions from V \ {0 1 } to V satisfying (F) and having the same type distribution. This number is given by the second part of the following lemma. Theorem 8 follows.

Lemma 21. Let S = m, -1 ∪ {1}. 1. The number of S-functions from V \ {0 1 } to V satisfying (F) and in which each v ∈ V has a prescribed type (i v ; s v ; c v ) is, assuming compatibility, i,s n(i, s)! b≥0,s b! ns(b) r i=1 n(i, 1) r-1 i=0 c 1 i 1 ,
where n(i, s) is the number of vertices of out-type (i; s) and n s (b) is the number of vertices v that have exactly b pre-images at abscissa a(v) + s. That is,

n(i, s) = ♯{v ∈ V : i v = i and s v = s}, n s (b) = ♯{v ∈ V : c s v = b}. 2. Let c 0 = (0, . . . , 0, c 1 0 ) ∈ N 2-m .
Let n(i, s, c) be non-negative integers, for i ∈ 0, r , s ∈ S and c ∈ N 2-m , satisfying the compatibility conditions of a type distribution. The number of S-functions from V \ {0 1 } to V satisfying (F) and in which 0 1 has in-type (0; c 0 ) and for all i ∈ 0, r , s ∈ S and c ∈ N 2-m , exactly n(i, s, c) vertices have type (i; s; c) is

c 1 0 1 n r r i=0 (n i -1)! i,s n(i, s)! i,s,c n(i, s, c)! b≥0,s b! ns(b) r i=1 n(i, 1) r-1 i=1 b>0 bn 1 (i, 1, b) ,
where n(i, s) is the number of vertices of out-type (i; s), n s (b) is the number of vertices v that have exactly b pre-images at abscissa a(v) + s, and n 1 (i, 1, b) is the number of vertices having out-type (i, 1) and b pre-images in V i+1 . Equivalently,

n(i, s) = c n(i, s, c), n s (b) = i,t c:c s =b n(i, t, c) + 1 s=1,b=c 1 0 , n 1 (i, 1, b) = c:c 1 =b n(i, 1, c).
Proof. 1. For 0 ≤ i ≤ r and s = 1, let us choose the images of the n(i, s) vertices of out-type (i, s). Exactly c s (i-s) k of them have image (i -s) k , for all k. For s = 1 and i ≥ 1, one vertex of out-type (i; 1), namely i 1 , has image (i -1) 1 by Condition (F). Thus the number of S-functions satisfying the required properties is

  r i=0 s =1 n(i, s)! k c s (i-s) k !   r i=1 (n(i, 1) -1)! c 1 (i-1) 1 k c 1 (i-1) k ! ,
which is equivalent to the first result.

2. As an intermediate problem, let us prescribe the in-type (i; c i 1 ) of all vertices of the form i 1 (their out-type is forced), and the number ñ(i, s, c) of vertices of

V i \ {i 1 } having type (i; s; c). Clearly, ñ(i, s, c) = n(i, s, c) -1 i≥1,s=1,c=c i 1 .
The number of ways to assign types to vertices of

V i \ {i 1 } is (n i -1)! s,c ñ(i, s, c)! =        (n i -1)! s,c n(i, s, c)! n(i, 1, c i 1 ), if i ≥ 1; (n 0 -1)! s,c n(0, s, c)! , otherwise.
Using the first result, we conclude that the number of functions such that i 1 has in-type (i; c i 1 ) and ñ(i, s, c) of vertices of

V i \ {i 1 } have in-type (i; s; c) is r i=0 (n i -1)! i,s n(i, s)! i,s,c n(i, s, c)! b≥0,s b! ns(b) r i=1 n(i, 1) r-1 i=0 c 1 i 1 r i=1 n(i, 1, c i 1 ).
Finally, let us only prescribe the in-type of 0 1 and the values n(i, s, c). That is, we need to sum the above formula over all possible in-types of the vertices i 1 , for i = 1, . . . , r. Note that only the rightmost two products depend on the choice of these types. We are thus led to evaluate

r i=1 c i 1 ∈N 2-m r-1 i=0 c 1 i 1 r i=1 n(i, 1, c i 1 ) = c 1 0 1   c r 1 n(r, 1, c r 1 )   r-1 i=1   c i 1 c 1 i 1 n(i, 1, c i 1 )   .
Given that the sum over c r 1 is n r = n(r, 1), this gives the second result of the lemma.

A bijection for general embedded trees

In this section we adapt the bijection of Section 3 to the case where ℓ < 0 and min S = -1. The main ideas of the bijection are similar: given a function in an appropriate class, we cut its cycles where they reach their minima, and connect the resulting pieces together to construct a tree; finally, we rearrange some subtrees so as to ensure the conservation of types.

This bijection is however more intricate that the previous one. In particular, it is twofold: we split our class of functions into two subsets, and use a different construction on each of them (Propositions 25 and 26). The (disjoint) union of the images of the two bijections forms a set of trees which will be related to S-embedded trees in the next section. Moreover, our bijection lacks the right/left symmetry one could expect from the symmetry of S. The trees we consider have a marked vertex r q at abscissa r, but no marked vertex at abscissa ℓ. The vertex ℓ 1 , however, plays a role similar to r q , but the conditions satisfied by the vertices on the path from r q to the root, or on the path from ℓ 1 to the root, are not symmetric.

In the rest of this section, ℓ < 0 and r ≥ 0 are integers and n ℓ , . . . , n r is a sequence of positive integers. Let V = ∪ r i=ℓ V i with V i = {i 1 , . . . , i ni }. We extend the notation and definitions of Section 3. In particular v ∈ V is a vertex and a(v) ∈ ℓ, r is its abscissa. We equip V with the same total order as before:

i k ≤ j p ⇐⇒ (i < j) or (i = j and k ≤ p).
The notions of S-function, of in/out/complete/types are defined as before. Also, a rooted tree T on the vertex set V is an S-tree if the parent of any (non-root) vertex of V i belongs to ∪ s∈S V i-s .

Definition 22. A marked S-tree is a pair (T, r q ) where T is an S-tree on the vertex set V , rooted at a vertex of V 0 , and r q a distinguished vertex in V r .

Definition 23. Let (T, r q ) be a marked S-tree. Let ℓ 1 ∧ r q denote the meet of ℓ 1 and r q in T , that is, the common ancestor of ℓ 1 and r q that is the farthest from the root. We consider the following properties.

(T 1 ) On the path going from r q to the root, the first vertex belonging to V i-1 is preceded by

i 1 , for all i ∈ 1, r . (T ′
2 ) On the path going from r q to root, the vertex 1 1 appears strictly before ℓ 1 ∧ r q . Moreover, on the path going from ℓ 1 to the root, the last vertex belonging to V i-1 is followed by i 1 , for all i ∈ ℓ + 1, 0 . (T ′′

2 ) On the path going from r q to the root, the vertex 1 1 appears weakly after ℓ 1 ∧r q . Moreover, ℓ 1 ∧ r q lies at a positive abscissa, and on the path going from ℓ 1 to ℓ p ∧ r q , the last vertex of V i-1 is followed by i 1 , for all i ∈ ℓ + 1, -1 . Finally, on the path from r q to the root, 0 1 precedes the first vertex of V -1 , if such a vertex exists; otherwise, 0 1 is the root of the tree.

(T 2 ) Either (T ′
2 ) or (T ′′ 2 ) holds. We now state our main result, which is the counterpart of Theorem 9 for negative trees. As will be shown in the next section, it implies all the enumerative results stated in Section 2 in the case ℓ < 0.

Theorem 24. Let n ℓ , . . . , n r , V and S be as above. There exists a bijection Φ between S-

functions f : V \ {0 1 } → V satisfying (F) f (i 1 ) =    (i + 1) 1 if ℓ ≤ i ≤ -2, v 0 ∈ V 0 if i = -1, (i -1) 1 if 1 ≤ i ≤ r,
and marked S-trees on the vertex set V satisfying (T 1 ) and (T 2 ). Moreover, this bijection (a) preserves the number of vertices of out-type (j; s), for all j and s, (b) preserves the number of vertices of in-type (i; c), for all i and c.

Remark. Property (a) follows from (b). Indeed, as already explained in the case of embedded trees, the number of vertices of out-type (j; s) is completely determined if we know the number of vertices of in-type (i; c), for all i and c. This is why we will focus on (b) in the proof. We have not found any way of preserving the complete types, and this is why Theorem 8 only deals with non-negative trees.

Setup of the bijection, and the main two cases

We now start describing the bijection. Let f be a function from V \ {0 1 } to V satisfying (F). As before, our bijection transforms the digraph G f representing f . First, for each i ∈ ℓ, r \ {0}, we split the edge going from i 1 to f (i 1 ) into two half-edges. We let Gf be the digraph thus obtained, which contains vertices, edges and half-edges.

It follows from (F) that the connected component of Gf containing the vertex i 1 , for i ∈ ℓ, r , is of the form:

i 1 or or or r 1 0 1 ℓ 1
We call piece each of these components, and we say that i 1 is the source of its piece. Each of the remaining components of Gf contains exactly one cycle. We say that the smallest vertex in this cycle is the source of this connected component. We now define a partition

V = r i=ℓ W i
of the vertex set V as follows: v ∈ W i if and only if the source of the connected component of Gf containing v belongs to V i .

Recall that v 0 := f (-1 1 ) belongs to V 0 . We will prove the two following propositions, which, taken together, imply Theorem 24.

Proposition 25. There exists a bijection between S-functions f satisfying (F) and such that v 0 belongs to 0 i=ℓ W i , and marked S-trees satisfying conditions (T 1 ) and (T ′ 2 ). This bijection satisfies (b).

Proposition 26. There exists a bijection between S-functions f satisfying (F) and such that v 0 belongs to r i=1 W i , and marked S-trees satisfying conditions (T 1 ) and (T ′′ 2 ). This bijection satisfies (b).

Two kinds of concatenations: the graphs L(i), R(i).

We will prove the above two propositions separately, but two basic constructions are used in both cases. Each of them produces a tree, denoted L(i) or R(i), from the subgraph Gf ∩ W i (the restriction of Gf to the vertex set W i ). Both constructions are based on the concatenation of certain elementary pieces of graphs by decreasing minima: in the case of L(i) this concatenation is performed from left to right, whereas for R(i) it is performed from right to left. The first kind of concatenation was used in Section 3 to describe the bijection Ψ 1 . Here, depending on the case (Proposition 25 or 26), and on the value of i ∈ ℓ, r , we will use one concatenation or the other.

• The left concatenation L(i). This construction is used only for i ∈ 0, r , and it is similar to the one used in Section 3. Consider all the connected components of Gf whose source belongs to V i \ {i 1 }. In each of them, split the edge entering the source into two half-edges. As in Section 3, one obtains a piece of the form:

• • • i k j p
with j = i + 1, or j = i and p ≥ k. As before i k and j p are called the source and the sink of the piece, respectively. Then order the pieces by decreasing sources, including the piece rooted at i 1 , and concatenate them to form a path (Figure 9). We denote by L(i) the tree on the vertex set W i consisting of this path and all the subtrees that are attached to it. This tree has a distinguished vertex a i ∈ V i (the leftmost source, that is, the greatest one) and it is rooted at the smallest source, i 1 . Note that the sources of the pieces are the lower records encountered on the path going from a i to i 1 .

The following fact is obvious by construction.

Observation 27. All the vertices belonging to W i that are not lower records on the path from a i to i 1 have the same in-type in the function f and in the graph L(i).

only if i = r only if i = 0 (i+1) * (i+1) * (i+1) * . . . . . . a i . . . i * . . . i 1 i * i * or . . . i * or i * or Figure 9.
The graph L(i). Pieces are ordered by decreasing source from left to right. The leftmost and rightmost half-edges are present only if i = r and i = 0, respectively. The vertex a i belongs to V i .

• The right concatenation R(i). This construction is used only for i ∈ ℓ, 0 . Consider all the connected components of Gf whose source belongs to V i \ {i 1 }. In each of them, split the edge leaving the source into two half-edges. One obtains a piece of the form

• • • j p i k
with j = i + 1 or j = i with p ≥ k. We call i k and j p the sink and the source of the piece, respectively (even though i k was called the source before splitting the edge!). Note that the minimum vertex now lies to the right of the piece. Then order the pieces, including the piece containing i 1 , by increasing sinks, and concatenate them to form a path (Figure 10). We denote by R(i) the tree on the vertex set W i consisting of this path and all the subtrees that are attached to it. This tree is rooted at a vertex b i ∈ V i (the rightmost sink, that is, the greatest one) and it contains the vertex i 1 . Note that the sinks of the pieces are the lower records encountered on the path that goes from b i to i 1 (and thus in the direction opposite to edges). We now observe an important property of the right-to-left concatenation. First, when opening the cycles to form the pieces, the source j p of each piece is disconnected from one of its pre-images i k , which belongs to V i . Then, during the concatenation of pieces, the source j p is reconnected to the sink of the piece on its left, which is also an element of V i . Therefore the in-type of each source distinct from i 1 is preserved by the construction. The in-types of all other vertices are clearly preserved as well.

only if i = ℓ only if i = 0 (i+1) * (i+1) * (
Observation 28. All the vertices belonging to W i , distinct from i 1 , have the same in-type in the function f and in the graph R(i).

We now prove Propositions 25 and 26 separately. The bijection of Proposition 25 is actually split into three closely related bijections. In each case the bijection reads Ψ = Ψ 2 • Ψ 1 where Ψ 1 is a bijection between the desired set of functions and the desired set of trees, but does not satisfy Property (b). As in Section 3, the second bijection Ψ 2 is a simple re-arrangement of subtrees designed in such a way that Ψ 2 • Ψ 1 satisfies (b).

Proof of Proposition 25

Given a marked S-tree (T, r q ) satisfying (T 1 ), we denote by w 0 the vertex following 1 1 on the path from r q to the root. This vertex has abscissa 0. To prove Proposition 25 we distinguish three cases, discussed in the following three lemmas. Lemma 29. There exists a bijection between S-functions f satisfying (F) such that • v 0 := f (-1 1 ) belongs to 0 i=ℓ W i but neither to a cycle of the graph Gf nor to the connected component of Gf containing 0 1 , and marked S-trees (T, r q ) satisfying (T 1 ) and (T ′

2 ) such that • ℓ 1 ∧ r q is neither 0 1 nor w 0 . This bijection satisfies Property (b) of Theorem 24.

Lemma 30. There exists a bijection between S-functions f satisfying (F) such that

• v 0 := f (-1 1 ) belongs to 0 i=ℓ W i and to a cycle of the graph Gf , and marked S-trees (T, r q ) satisfying conditions (T 1 ) and (T ′

2 ) such that • ℓ 1 ∧ r q is equal to 0 1 but distinct from w 0 . This bijection satisfies Property (b) of Theorem 24.

Lemma 31. There exists a bijection between S-functions f satisfying (F) such that

• v 0 := f (-1 1 ) belongs to the connected component of Gf containing 0 1 (and hence to 0 i=ℓ W i ), and marked S-trees (T, r q ) satisfying conditions (T 1 ) and (T ′

2 ) such that • ℓ 1 ∧ r q is equal to w 0 . This bijection satisfies Property (b) of Theorem 24.

Since the connected component of Gf containing 0 1 contains no cycle, Proposition 25 follows immediately from Lemmas 29, 30, and 31, by case disjunction.

5.3.1.

Proof of Lemma 29. Let f be as in the statement of the lemma. We first construct a marked tree Ψ 1 (f ) from Gf . The construction is depicted in Figure 11. A second transformation Ψ 2 will the rearrange certain subtrees of Ψ 1 (f ).

• For i ∈ 1, r construct the left concatenation L(i). Concatenate all these pieces, by decreasing value of i, to obtain a path from the vertex a r ∈ V r to the vertex 1 1 . • For i ∈ ℓ, 0 construct the right concatenation R(i). Concatenate all these pieces, by increasing value of i, to obtain a path from ℓ to the vertex b 0 ∈ V 0 . • Add an edge from 1 1 to v 0 . Since v 0 ∈ 0 i=ℓ W i , this connects the two previously constructed components. We let (T, a r ) := Ψ 1 (f ) be the marked tree thus obtained. It is rooted at b 0 . It is clearly an S-tree.

The marked tree (T, a r ) satisfies Properties (T 1 ) and (T ′ 2 ). Let i ∈ 1, r . Along the distinguished path of L(i), all vertices have abscissa at least i, and the rightmost vertex is i 1 . The vertex that follows i 1 on the path from a r to b 0 is a

i-1 ∈ V i-1 if i > 1, or v 0 ∈ V 0 if i = 1.
This implies that (T 1 ) holds. Now let i ∈ ℓ + 1, 0 . Along the distinguished path of R(i), all vertices have abscissa at least i, and the leftmost vertex is i 1 . The vertex that precedes i 1 on the path from ℓ 1 to b 0 is b i-1 ∈ V i-1 . This implies that the second part of (T ′ 2 ) holds. Finally, since v 0 ∈ 0 i=ℓ W i , it is clear by construction that 1 1 appears strictly before ℓ 1 ∧ a r on the path from a r to b 0 . Hence the first part of (T ′ 2 ) holds. The meet ℓ 1 ∧ a r is neither w 0 nor 0 1 . Observe that the vertex v 0 follows 1 1 on the path from a r to the root. Hence:

a r . . . r * . . . . . . r 1 L(r) a 2 . . . 2 * . . . . . . 2 1 L(2) a 1 . . . 1 * . . . . . . 1 1 L(1) . . . ℓ * . . . . . . ℓ 1 R(ℓ) R(-1) . . . b ℓ . . . . . . . . . -1 1 . . . -1 * b -1 R(0) . . . . . . . . . 0 * b 0 0 1 T (v 0 ) v 0 T (0 1 )
Figure 11. The bijection Ψ 1 of Lemma 29. In this example, the vertex v 0 belongs to one of the subtrees of R(-1). In general, v 0 could belong to any subtree attached to the path ℓ 1 → b 0 , except the subtree T (0 1 ). The tree T (v 0 ), attached to v 0 on the path from a r to the root, will be exchanged with T (0 1 ) in the construction Ψ 2 .

Observation 32. In the marked tree Ψ 1 (f ) = (T, a r ), the vertex w 0 is v 0 = f (-1 1 ).

The meet ℓ 1 ∧ a r belongs to the path going from ℓ 1 to b 0 . By assumption, w 0 ≡ v 0 is not on a cycle of Gf , and is not 0 1 . Hence v 0 does not belong to the path going from ℓ 1 to b 0 , and thus cannot be equal to ℓ 1 ∧ a r . Moreover, the fact that v 0 does not belong to the component of Gf containing 0 1 implies that ℓ 1 ∧ a r = 0 1 .

The map Ψ 1 is injective. Let us start from the marked tree (T, a r ) and reconstruct the function f . First, for i ∈ 1, r , the graph L(i) and the pieces that constitute it can be recovered by splitting into two half-edges each edge that enters a lower record on the path from a r to w 0 . Similarly, on the path that goes from b 0 to ℓ 1 (visited in this direction), we split into two half-edges all edges that leave a lower record to recover the graphs R(i), for i ∈ ℓ, 0 , and their pieces. Then we close each piece that does not contain a vertex of the form i 1 to form a cycle. One thus recovers the graph Gf . Finally, we add an edge from i 1 to (i + 1) 1 for i ∈ ℓ, -2 , an edge from i 1 to (i -1) 1 for i ∈ 1, r , and an edge from -1 1 to w 0 to recover the graph G f . The map Ψ 1 is surjective. Let (T, r q ) be a marked S-tree rooted at ρ ∈ V 0 , satisfying (T 1 ) and (T ′ 2 ). Let w 0 be the vertex that follows 1 1 on the path from r q to ρ. Assume that the meet ℓ 1 ∧ r q is distinct from 0 1 and w 0 . We first split the edge 1 1 → w 0 into two half-edges, thus creating two connected components: one of them contains r q and 1 1 , while the other contains w 0 , ρ, and ℓ 1 (by (T ′ 2 )). We first consider the path going from r q to 1 1 in the first component. Lower records on this path are called sources, and vertices preceding the sources are called sinks (we consider 1 1 as a sink). We now split into two half-edges each edge that enters a source on the path. This gives a number of pieces, each of them carrying a distinguished path going from a source to a sink. By (T 1 ), each vertex i 1 for i ∈ 1, r is the source and the sink of a piece. Take all the pieces containing a vertex of the form i 1 , for i ≥ 1, and concatenate them by adding an edge from i 1 to (i -1) 1 for i ∈ 2, r . Transform each of the other pieces into a cycle by connecting its sink to its source.

We now visit the path going from the root ρ to ℓ 1 (in this direction). Lower records on this path are called sinks, and vertices preceding a sink (in the same "wrong" direction) are called sources (we consider ℓ 1 as a source). We now split all the edges between sinks and sources, and thus obtain a collection of pieces. By (T ′ 2 ), there is a piece of source and sink i 1 for i ∈ ℓ, 0 . Take all the pieces containing a vertex of the form i 1 , for i ≤ -1, and concatenate them by adding an edge from i 1 to (i + 1) 1 for i ∈ ℓ, -2 . In all the remaining pieces, merge the two extremal half-edges to form a cycle. Finally, add an edge from 1 1 to 0 1 , from -1 1 to the vertex w 0 , and let H be the graph thus obtained. By construction, H is the graph G h of a function h : V \ {0 1 } → V satisfying (F).

Let us prove that h is an S-function. It suffices to check that the edges we have created are S-edges. Since 1 and -1 belong to S, this is clear for the edges that start from a vertex i 1 , for i ∈ ℓ, r \ {0}. Consider a piece of source i k , with i ∈ 1, r and k = 1. Its sink j p is followed, on the path from r q to 1 1 , by a lower record of abscissa i (because by (T 1 ), i 1 is one of the lower records), say i m . Since the edge j p → i m was an S-edge of T , the edge j m → i k that we create to construct H is also an S-edge. In brief, the out-type of the sink j p has not changed. A similar result holds for pieces of sink i k , with i ∈ ℓ, 0 and k > 1: when we close them to form a cycle, the in-type of the source does not change. Therefore h is a S-function.

It remains to prove that h satisfies the three statements of Lemma 29 dealing with h(-1 1 ) = w 0 . By construction, w 0 belongs in Gh to a component whose source lies at a nonpositive abscissa. That is, h(-1 1 ) ∈ ∪ 0 i=ℓ W i (the sets W i 's being understood with respect to the function h). Given that ℓ 1 ∧ r q = w 0 by assumption, the vertex w 0 does not belong to the path of T going from ℓ 1 to the root ρ. Hence it cannot be found in a cycle of G h . The vertex of the path of T going from ℓ 1 to the root ρ to which w 0 is attached is ℓ 1 ∧ r q , which by assumption is different from 0 1 . Hence h(-1 1 ) does not belong to the component of source 0 1 in Gh .

Finally, it is clear by construction that Ψ 1 (h) = (T, r q ), so Ψ 1 is surjective.

• Re-arranging subtrees: the bijection Ψ 2 . We say as before that a vertex v ∈ V is frustrated if its in-type is not the same in f and in (T, r q ) = Ψ 1 (f ). We that the vertices of ∪ 0 i=ℓ W i \ {0 1 , v 0 } are not frustrated. This is a direct consequence of Observation 28 and of the fact that to concatenate R(i -1) to R(i), for i ∈ ℓ + 1, -1 we add a new incoming edge to the vertex i 1 coming from V i-1 , which compensates the deletion of the edge (i -1) 1 → i 1 in the construction of Gf from f . Together with Observation 27, this implies: Observation 33. Any vertex distinct from v 0 , 0 1 and from the lower records of the path from r q to 1 1 is not frustrated.

We first "correct" simultaneously the in-types of 0 1 and v 0 . Let us denote by T (0 1 ) the subtree attached to the vertex 0 1 on the path from ℓ 1 to the root in T , and by T (w 0 ) the subtree attached to the vertex v 0 = w 0 on the path from r q to the root in T . By assumption, v 0 does not belong to T (0 1 ). Moreover, 0 1 cannot belong to T (w 0 ) (it has no image by f , and is by assumption distinct from v 0 ). Hence the subtrees T (0 1 ) and T (w 0 ) are disjoint. Let us exchange them, and denote by T the resulting tree. Then the in-type of 0 1 in T equals the in-type of v 0 in the function f : indeed, edges contributing to these in-types are in both cases the edges coming from T (v 0 ), plus an edge coming from V -1 (this edge joins b -1 to 0 1 in T and -1 1 to v 0 in f ). Similarly, the in-type of v 0 in T equals the in-type of 0 1 in f , since the edges contributing to these in-types are in both cases the edges coming from T (0 1 ) and the edge coming from 1 1 . Finally, note that the operation (T, r q ) → ( T , r q ) is an involution since the exchange of subtrees does not modify the marked vertex of the tree.

It remains to correct the in-types of the lower records of the path going from r q to 1 1 in T . We proceed as in the proof of Theorem 9 in Section 3. First, clearly, Observations 12 and 13 hold for i ∈ 1, r -1 , as does Observation 14. As in Section 3, we exchange the subtrees attached to adjacent frustrated sources of abscissa i ∈ 1, r . This corrects the in-type of all of them. Let Ψ 2 (T, r q ) be the tree obtained after performing these exchanges, and let Ψ(f ) = Ψ 2 •Ψ 1 (f ). Since we have corrected all in-types, Ψ satisfies Property (b). Moreover Ψ 2 is again an involution (the lower records on the path from r q to 1 1 do not change when exchanging subtrees). In particular Ψ is a bijection, and Lemma 29 is proved.

Remark. The above construction Ψ 1 could be applied just as well to functions f such that v 0 is on a cycle of Gf or in the component of 0 1 . However, we have not been able (and we believe that it is not possible) to define the "re-arranging" bijection Ψ 2 in these two cases. This is why we had to split Proposition 25 into three separate lemmas, based on three slightly different constructions.

5.3.2.

Proof of Lemma 30. The bijection and the proof are very close to those of Lemma 29, but we need to introduce a variant of the right concatenation. We assume that v 0 belongs to a cycle of the graph Gf . Let i 0 ≤ 0 be the abscissa of its source.

• A variation on R(i 0 ): the graphs R(i 0 ) and C(i 0 ). Instead of constructing R(i 0 ) as before, from all components of Gf having their source in V i0 , we ignore the component containing v 0 , and form a smaller right concatenation R(i 0 ) with the remaining components (Figure 12). Then, we open the cycle containing v 0 at the edge entering v 0 . This gives a tree, denoted by C(i 0 ). This tree has a distinguished path from v 0 to a vertex u ∈ V -1 ∪ V 0 ∪ V 1 (and u ∈ V 0 happens only if 0 ∈ S). The following analogue of Observation 28 holds.

Observation 34. All the vertices belonging to W i0 \{i 1 0 , v 0 } have the same in-type in the function f and in the graph With this construction at hand, wee are now ready to prove Lemma 30. We construct a tree Ψ 1 (f ) from Gf , as depicted in Figure 13.

R(i 0 ) ∪ C(i 0 ). v 0 u . . . cycle of Gf containing v 0 component C(i 0 ) v 0 u R(i 0 ) i 1 0 . . . b i0 . . . (piece containing v 0 omitted) . . . . . .
• For i ∈ 1, r construct the left concatenation L(i). Concatenate all these pieces, by decreasing value of i, to obtain a path from the vertex a r ∈ V r to the vertex 1 1 . • For i ∈ ℓ, 0 \ {i 0 } construct the right concatenation R(i). Construct also the components R(i 0 ) and C(i 0 ). Concatenate R(ℓ), . . . , R(i 0 ), . . . , R(0), by increasing value of i, to obtain a path from ℓ 1 to a vertex b 0 ∈ V 0 . • Consider the distinguished path of C(i 0 ), which goes from v 0 to u. Add an edge from 1 1 to v 0 , and an edge from u to 0 1 . This connects the previously constructed components. Let (T, a r ) := Ψ 1 (f ) the marked tree thus obtained. It is rooted at b 0 . It is clearly an S-tree (the edge that goes from u to 0 1 is an S-edge since there was in G f an S-edge going from u to v 0 ∈ V 0 ).

The marked tree (T, a r ) satisfies Properties (T 1 ) and (T ′

2 ). The proof can be copied verbatim from the proof of Lemma 29. As before, the vertex w 0 of the marked tree

Ψ 1 (f ) = (T, a r ) is v 0 = f (-1 1 ).
The meet ℓ 1 ∧ a r is equal to 0 1 and distinct from w 0 . This is clear by construction. . . .

ℓ * . . . . . . ℓ 1 R(ℓ) R(-1) . . . b ℓ . . . . . . . . . -1 1 . . . -1 * b -1 R(0) . . . . . . . . . 0 * b 0 0 1 T (0 1 ) u . . . C(i0) R(i0) T (v 0 ) v 0 Figure 13.
The bijection Ψ 1 of Lemma 30. The subtrees T (0 1 ) and T (v 0 ) will be exchanged by the construction Ψ 2 .

The map Ψ 1 is injective. Given (T, a r ), one recovers the graph C(i 0 ) by cutting the edge entering w 0 and the one entering 0 1 on the path from a r to the root. Closing this piece restores a cycle of the function f . Then, as in the proof of Lemma 29, we recover the remaining pieces by locating the lower records of the path from r q to 1 1 , and of the path from the root to ℓ 1 . Given the pieces, one recovers the graph Gf by closing each piece containing no vertex of the form i 1 . Finally, one adds an edge from i 1 to (i + 1) 1 for i ∈ ℓ, -2 , an edge from i 1 to (i -1) 1 for i ∈ r, 1 , and an edge from -1 1 to w 0 to recover the graph G f . This shows that Ψ 1 is injective.

The map Ψ 1 is surjective. Let (T, r q ) be a marked S-tree rooted at ρ ∈ V 0 , satisfying (T 1 ) and (T ′ 2 ). As above, let w 0 be the vertex that follows 1 1 on the path from r q to the root. Assume that the meet ℓ 1 ∧ r q is equal to 0 1 but distinct from w 0 .

On the path from r q to ρ, one first meets w 0 and, strictly later, the meet of ℓ 1 and r q , namely 0 1 . We split the edge entering w 0 and the one entering 0 1 , thus creating three connected components. One of them contains the path from r q to 1 1 , another one contains the path from ℓ 1 to ρ, and the third one contains the vertex w 0 . We transform the latter into a cycle by merging the two half-edges inherited from the splitting. We call C the component thus obtained.

We now consider the path going from r q to 1 1 in the first component. We treat this part as in the proof of Lemma 29: we obtain a graph which consists of a collection of cycles and a component containing the path r 1 → (r -1) 1 → • • • → 1 1 . On each cycle, the smallest vertex lies at a positive abscissa.

We now consider the path going from ℓ 1 to the root ρ. We treat this part as in the proof of Lemma 29: we obtain a graph which consists of a collection of cycles and a component containing the path

ℓ 1 → (ℓ + 1) 1 → • • • → -1 1 .
On each cycle, the smallest vertex lies at a non-positive abscissa.

Finally, add an edge from 1 1 to 0 1 , from -1 1 to w 0 , and let H be the graph thus obtained. By construction, H is the graph G h of a function h : V \ {0 1 } → V satisfying (F). We check as in the proof of Lemma 29 that h is an S-function.

By construction v 0 := h(-1 1 ) = w 0 belongs to a cycle of the function h, namely the unique cycle of the component C, the source of which has abscissa at most 0. Thus h belongs to the set of S-functions considered in Lemma 30.

Finally, it is clear by construction that Ψ 1 (h) = (T, r q ), so Ψ 1 is surjective.

Re-arranging subtrees: the bijection Ψ 2 . We say that a vertex v ∈ V is frustrated if its in-type is not the same in f and in (T, r q ) = Ψ 1 (f ). Note that Observation 33 still holds (since Observation 34 is the analogue of Observation 28 for the components R(i 0 ) and C(i 0 )).

We first correct the in-types of 0 1 and v 0 by exchanging the subtrees T (0 1 ) and T (v 0 ) that are attached to them in the pieces R(0) and C(i 0 ), respectively (0 1 is an ancestor of v 0 , and these subtrees are disjoint). Let T be the tree thus obtained. Then the in-type of 0 1 in T equals the in-type of v 0 in the function f : indeed the edges contributing to these in-types are, in both cases, the edges coming from T (v 0 ), plus an edge coming from u, plus an edge coming from V -1 (this edge joins b -1 to 0 1 in T , and -1 1 to v 0 in f ). Similarly, the in-type of v 0 in T equals the in-type of 0 1 in f , since the edges contributing to these in-types are in both cases all edges coming from T (0 1 ) and the edge coming from 1 1 . Finally, the operation (T, r q ) → ( T , r q ) is an involution since the exchange of subtrees does not change the marked vertex.

We treat the path going from r q to 1 1 in T as in the proof of Lemma 29. That is, we exchange pairwise the trees attached to successive frustrated vertices along this path. Let Ψ 2 (T ) be the marked tree obtained after performing these exchanges for all i ∈ 1, r , and let Ψ(f ) = Ψ 2 • Ψ 1 (f ). Since we have corrected all types, Ψ satisfies Property (b). Moreover Ψ 2 is again an involution. In particular Ψ is bijection, and Lemma 30 is proved.

5.3.3.

Proof of Lemma 31. We assume that v 0 = f (-1 1 ) belongs to the connected component of Gf of source 0 1 . • A variation of Gf : the graph Ĝf . Recall from Section 5.3.1 the construction of the graph Gf , obtained by cutting into two half-edges all edges that leave a vertex of the form i 1 . If v 0 = 0 1 , we create a new graph Ĝf having one more cycle than Gf , as follows. Let u be the vertex preceding 0 1 on the path that goes in Gf from v 0 to 0 1 . Replace the edge u → 0 1 by an edge u → v 0 , thus creating a new S-edge, a new cycle, and a new graph Ĝf . If i 0 is the smallest abscissa occurring on this cycle, then i 0 ≤ 0.

If v 0 = 0 1 , we let Ĝf = Gf . T (v 0 ) T (0 1 ) T (v 0 ) T (0 1 ) u u . . . v 0 . . . v 0 0 1 0 1 Figure 14.
The component containing 0 1 in Gf gives rise, in Ĝf , to two components. One of them is a cycle containing v 0 . Now apply to Ĝf all the transformations applied to Gf in Section 5.3.1, that led to the definition of Ψ 1 : open the cycles before or after their source (depending on the abscissa of the source), connect the resulting pieces by decreasing or increasing minima (depending again on the abscissas of the sources), and finally add an edge from 1 1 to v 0 . We call the piece containing v 0 the special piece. Let (T, a r ) := Ψ 1 (f ) be the marked tree thus obtained. It is rooted at b 0 . It is clearly a marked S-tree.

On checks as in Section 5.3.1 that the tree (T, r q ) satisfies (T 1 ) and (T ′ 2 ). Moreover, w 0 = v 0 = ℓ 1 ∧ r q , and thus the condition of Lemma 31 holds.

The map Ψ 1 is injective. One recovers the graph Ĝf in the same way one recovers Gf in Section 5.3.1. If w 0 = 0 1 , the edge that enters v 0 in the cycle containing v 0 is then cut into two half-edges, and the outgoing half-edge is re-directed to 0 1 . This gives the graph Gf , from which one reconstructs f easily.

The map Ψ 1 is surjective. Let (T, r q ) be a marked S-tree rooted at ρ ∈ V 0 , satisfying (T 1 ) and (T ′ 2 ). Let w 0 be the vertex that follows 1 1 on the path from r q to the root. Assume that w 0 is the meet ℓ 1 ∧ r q . In particular, it lies on the path from ℓ 1 to the root.

a r . . . r * . . . . . . r 1 L(r) a 2 . . . 2 * . . . . . . 2 1 L(2) a 1 . . . 1 * . . . . . . 1 1 L(1) . . . ℓ * . . . . . . ℓ 1 R(ℓ) b ℓ . . . R(0) . . . . . . . . . 0 * b 0 0 1 T (0 1 ) T (v 0 ) i 1 0 R(i0) b i0 . . . . . . . . . . . . . . . v 0 Figure 15.
The bijection Ψ 1 of Lemma 31. The special piece containing v 0 is shaded. The smallest abscissa of the cycle containing v 0 is denoted i 0 . The subtrees T (0 1 ) and T (v 0 ) will be exchanged by the construction Ψ 2 .

We first construct from (T, r p ) a functional graph Ĥ in the same way we constructed H in the proof of Lemma 29. If w 0 is distinct from 0 1 , it belongs to a cycle of Ĥ: we cut the edge of this cycle entering w 0 into two half-edges, and redirect the outgoing half-edge onto 0 1 .

The graph H thus obtained is the graph G h of a function h : V \ {0 1 } → V satisfying (F), which is checked as before to be an S-function.

By construction h(-1 1 ) = w 0 belongs to the connected component containing 0 1 in Gh , so that h belongs to the set of S-functions considered in Lemma 31.

Finally, it is clear by construction that Ψ 1 (h) = (T, r q ), so Ψ 1 is surjective.

• Re-arranging subtrees: the bijection Ψ 2 . The only vertices that are likely to be frustrated are the lower records of the path going from a r to 1 1 , and the vertices 0 1 and v 0 . These two vertices belong to the path going from ℓ 1 to the root. We first correct their in-types by swapping the subtrees T (0 1 ) and T (v 0 ) that are attached to them in their respective pieces. Let T be the tree thus obtained. Then the in-type of 0 1 in T equals the in-type of v 0 in the function f : indeed the edges contributing to these in-types are, in both cases, the edges coming from T (v 0 ), plus an edge coming from V -1 (this edge joins b -1 to 0 1 in T , and -1 1 to v 0 in f ). Similarly, the in-type of v 0 in T equals the in-type of 0 1 in f , since edges contributing to these in-types are, in both cases, the edges coming from T (0 1 ), plus an edge coming from 1 1 , plus an edge coming from a vertex having the same asbcissa as u (this edge joins u to 0 1 in f ; in T , it joins u to v 0 , unless u is the minimum on the cycle containing v 0 . In this case, the abscissa of u is i 0 , v 0 is a source in T , and is the endpoint of another sink of abscissa i 0 ). Finally, the map (T, a r ) → ( T , a r ) is again an involution. The frustrated vertices lying on the path going from a r to 1 1 in T are treated as before, by exchanging the trees attached to successive frustrated vertices. Let Ψ 2 (T ) be the marked tree obtained after performing these exchanges for all i ∈ 1, r . As before Ψ 2 is an involution, so that Ψ := Ψ 2 • Ψ 1 is a bijection. It satisfies Property (b), and Lemma 31 is proved.

Proof of Proposition 26

We now assume that v 0 = f (-1 1 ) belongs to W i0 , with i 0 ≥ 1. We first perform some surgery on the piece L(i 0 ) containing v 0 . • Surgery on L(i 0 ): the graphs L(i 0 ), A(i 0 ) and B(i 0 ).

Recall that L(i 0 ) consists of a path going from the vertex a i0 to the vertex i 1 0 , to which trees are attached. One of these trees contains the vertex v 0 , and we let v be the attachment point of this tree on the path. Note that we have a(v) ≥ i 0 ≥ 1, and in particular v = v 0 since v 0 ∈ V 0 .

We now define two other vertices x 0 , y 0 as follows (Figure 16). Consider the path of L(i 0 ) going from v 0 to v, and let us distinguish two cases. If there exists a vertex of negative abscissa along this path, we let x -1 (resp. y -1 ) be the first (resp. last) vertex of V -1 encountered on the path from v 0 to v, and we let x 0 (resp. y 0 ) be the vertex preceding x -1 (resp. following y -1 ) on the path. Note that since max S = 1 and min S = -1, the vertices x -1 and y -1 are well defined; moreover, x 0 and y 0 belong to V 0 . Now, cut the edge between x 0 and x -1 , and the edge between y -1 and y 0 . Among the three connected components thus created, we call L(i 0 ) the one containing v, we call A(i 0 ) the one containing x -1 , and we call B(i 0 ) the one containing v 0 . If all the vertices on the path from v 0 to v have a nonnegative abscissa, we let L(i 0 ) := L(i 0 ), A(i 0 ) := B(i 0 ) := ∅, and y 0 := x 0 := v 0 . In this case, the vertices x -1 and y -1 are not defined.

A(i 0 ) B(i 0 ) L(i 0 )
first negative abscissa last negative abscissa y 0 . . .

x -1 . . . y -1 v 0 . . . x 0 a i0 . . . v Figure 16.
The graphs L(i 0 ), A(i 0 ), and B(i 0 ), in the case where there is a vertex of negative abscissa between v 0 and v. Otherwise, L(i 0 ) = L(i 0 ), and A(i 0 ) = B(i 0 ) = ∅. The subtrees attached to the paths are not represented.

By construction, we have the following analogue of Observation 27.

Observation 35. Any vertex of the graph L(i 0 ) ∪ A(i 0 ) ∪ B(i 0 ), distinct from v 0 , y 0 and x -1 and from the lower records of the path going from a i0 to i 1 0 , has the same in-type in this graph and in the function f . We now proceed with the description of the bijection, depicted in Figure 17. We perform the following operations.

• For i ∈ 0, r , construct the left concatenation L(i). Construct the graph L(i 0 ) from L(i 0 ), and concatenate the pieces

L(r), L(r -1), . . . , L(i 0 -1), L(i 0 ), L(i 0 + 1), . . . , L(1), L (0)
to obtain a path from the vertex a r ∈ V r to the vertex 0 1 . Note that y 0 belongs to a subtree attached to this path. • For i ∈ ℓ, -1 construct the right concatenation R(i). Concatenate all these pieces by increasing value of i, to obtain a path from ℓ 1 to the vertex b -1 ∈ V -1 . • Add an edge from b -1 to y 0 . This connects the two previously constructed components.

• If A(i 0 ) = ∅ (equivalently, if B(i 0 ) = ∅), add an edge from 0 1 to x -1 , and an edge from y -1 to v 0 . This connects the components A(i 0 ) and B(i 0 ) to the previously constructed tree.

L(0) ℓ * . . . . . . ℓ 1 R(ℓ) R(-1) . . . b ℓ . . . . . . . . . -1 1 . . . -1 * b -1 A(i 0 ) B(i 0 ) . . . x -1 y -1 a i0. . . i 1 0 . . . y 0 L(i0) . . . v 0 x 0 v Figure 17. The bijection Ψ 1 of Proposition 26.
Let Ψ 1 (f ) := (T, a r ) be the marked tree thus obtained. It is rooted at x 0 if A(i 0 ) = ∅ and at 0 1 otherwise. It is easily checked to be an S-tree.

As in the previous proofs, we are first going to show that the mapping Ψ 1 is a bijection between the sets described in Proposition 26. Then we will describe another bijection, Ψ 2 , such that Ψ 2 • Ψ 1 satisfies Property (b), which Ψ 1 lacks.

The marked tree (T, a r ) satisfies Properties (T 1 ) and (T ′′ 2 ). The fact that T satisfies (T 1 ) is proved as in the proof of Lemma 29. The meet ℓ 1 ∧a r is equal to v, and since i 0 ≥ 1, it appears weakly before the vertex 1 1 on the path from a r to the root. Hence the first part of (T ′′ 2 ) holds. As underlined above, the abscissa of v, being at least i 0 , is positive. The arguments proving the second part of (T ′′ 2 ) are the same as those proving (T ′ 2 ) in Lemma 29 (the concatenation of R(ℓ), . . . , R(-1) is the same in both proofs). Finally, all vertices on the path from a r to 0 1 have a nonnegative abscissa. Hence either 0 1 is the root of the tree, and there are no vertices of negative abscissa on the path joining a r to the root, or 0 1 is not the root, in which case there are such vertices, and 0 1 precedes the first of them (which is x -1 ). This establishes the last part of (T ′′ 2 ). The map Ψ 1 is injective. Let us start from the marked tree Ψ 1 (f ) = (T, a r ) and reconstruct f . First, on the path going from ℓ 1 to the root, we cut the edge that leaves the last vertex of abscissa -1, denoted b -1 . The other endpoint of this edge is y 0 . By cutting the path that goes from a r to 0 1 after each vertex of the form i 1 , we recover the graphs L(i), for i ∈ 0, r \ {i 0 }, and the graph L(i 0 ). Similarly, by cutting, in the path that goes from ℓ 1 to b -1 , each edge that enters a vertex of the form i 1 , we recover the graphs R(i), for i ∈ ℓ, -1 . If 0 1 is not the root of the tree, we recover moreover the vertices x -1 (it follows 0 1 on its path to the root) and y -1 (the last vertex of negative abscissa on this path), so that we can reconstruct the graphs A(i 0 ) and B(i 0 ). In all cases, we can then reconstruct the graph L(i 0 ). We then proceed as in the proof of Lemma 29: in each L(i) (resp R(i)), locate each left-to-right (resp. right-to-left) lower record, and split the edges entering (resp. leaving) each of them. Then close the pieces whose root is not of the form i 1 to recover a cycle of the original function f . One thus recovers the graph Gf . Finally, add an edge from i 1 to (i + 1) 1 for i ∈ ℓ, -2 , an edge from i 1 to (i -1) 1 for i ∈ r, 1 , and an edge from -1 1 to v 0 (the vertex that follows y -1 on its path to the root) to recover the graph G f . The map Ψ 1 is surjective. Let (T, r q ) be a marked S-tree rooted at ρ ∈ V 0 , satisfying (T 1 ) and (T ′′ 2 ). Denote v := ℓ 1 ∧ r q . By (T ′′ 2 ), we have a(v) ≥ 1. Consider the path going from ℓ 1 to v in T , and let b -1 be the last vertex of negative abscissa on this path, and y 0 the next vertex on this path. Note that b -1 (resp. y 0 ) has abcissa -1 (resp. 0). Split the edge joining b -1 to y 0 . This gives two connected components, one containing the path from r q to the root (including the vertex v), the other the path from ℓ 1 to b -1 . Now visit the path going b -1 to ℓ 1 (in this "wrong" direction). Lower records on this path are called sinks, and vertices preceding the sinks (in the same "wrong" direction) are called sources (we consider ℓ 1 as a source). We now split all edges between sinks and sources, and thus obtain a number of pieces. By (T ′′ 2 ), each vertex i 1 for i ∈ ℓ, -1 is the source and the sink of a piece. Take all the pieces containing a vertex i 1 , for i ≤ -1, and concatenate them by adding an edge from i 1 to (i + 1) 1 for i ∈ ℓ, -2 . In the remaining pieces, merge the two extremal half-edges to form a cycle.

We now describe a step of the reverse bijection that applies only if 0 1 is not the root of T . In that case, (T ′′ 2 ) implies that the vertex 0 1 belongs to the path from r q to the root, and is followed by a vertex of V -1 , say x -1 . Let y -1 be the last vertex of V -1 on the path from 0 1 to the root, and let v 0 ∈ V 0 be the vertex following it. We now split the edge between 0 1 and x -1 , and the edge between y -1 and v 0 . We call à and B the connected components containing x -1 and v 0 after the splitting, respectively. We re-connect the components à and B to the connected component of r q by adding an edge from x 0 to x -1 and from y -1 to y 0 . This concludes the step that is specific to the case where 0 1 is not the root of T . Otherwise, we denote à := B := ∅, and y 0 = x 0 := v 0 .

We now consider the path going from r q to 0 1 . Lower records on this path are called sources, and vertices preceding the sources are called sinks (we consider 0 1 as a sink). We now split each edge that enters a source of the path, and thus obtain a number of pieces. By (T 1 ) and (T ′′ 2 ), each vertex i 1 for i ∈ 0, r is the source and the sink of a piece. Take all the pieces containing a vertex of the form i 1 , for i ≥ 0, and concatenate them by adding an edge from i 1 to (i -1) 1 for i ∈ 1, r . Transform each of the remaining pieces into a cycle by merging the two extremal half-edges. Finally, add an edge from -1 1 to v 0 .

Let H be the graph thus obtained. By construction, H is the graph G h of a function h : V \{0 1 } → V satisfying (F). One easily checks that h is an S-function, using the same arguments as in the proof of Lemma 29, plus the facts that h(y -1 ) = y 0 ∈ V 0 and h(x 0 ) = x -1 ∈ V -1 .

Let us now prove that h satisfies the condition of Proposition 26. By construction, the source of the component of Gh containing v 0 = h(-1 1 ) is the last lower record encountered (weakly) before v on the path from r q to v in T . By (T ′′ 2 ) this source appears (weakly) before 1 1 , and since 1 1 is a lower record by (T 1 ), the abscissa of this source is at least 1. In other words, we have v 0 ∈ ∪ r i=1 W i , the sets W i being understood with respect with the function h. Finally, note that all abscissas are nonnegative on the paths from y 0 to v and from v 0 to x 0 . This implies that à and B coincide with the pieces A(i 0 ) and B(i 0 ) which one would build from the function h. From that it is clear that Ψ 1 (h) = (T, r q ), so that Ψ 1 is surjective.

• Re-arranging subtrees: the bijection Ψ 2 . We say that a vertex v ∈ V is frustrated if its in-type is not the same in f and in (T, a r ) = Ψ 1 (f ). We claim that the vertices belonging to ∪ -1 i=ℓ W i are not frustrated. This is a direct consequence of Observation 28 and of the fact that to concatenate R(i -1) to R(i), for i ∈ ℓ + 1, -1 , we add a new incoming edge to the vertex i 1 coming from V i-1 , which compensates the deletion of the edge (i -1) 1 → i 1 in the construction of Gf from f . Similarly, Observations 27 and 35 give: Observation 36. Any vertex of ∪ r i=0 W i distinct from v 0 , y 0 , x -1 , and from the lower records of the path from r q to 0 1 is not frustrated.

In fact, y 0 is not frustrated: indeed, the edge coming from b -1 in T compensates either the loss of the edge coming from y -1 in L(i 0 ) (if y 0 = v 0 ) or the loss of the edge coming from -1 1 in f (if y 0 = v 0 ), and since y 0 does not belong to the distinguished path of L(i 0 ), Observation 27 enables us to conclude. Similarly, x -1 (if it exists) is not frustrated, since the edge coming from 0 1 in T compensates the edge coming from x 0 in L(i 0 ). Finally, v 0 is not frustrated either: either it is equal to y 0 (if 0 1 is the root of T ), or the edge coming from y -1 in T compensates the loss of the edge coming from -1 1 in f . Therefore, we can strengthen our previous observation as follows.

Observation 37. Any vertex of ∪ r i=0 W i distinct from the lower records of the path from r q to 0 1 is not frustrated.

We correct the in-types of these sources by a second map Ψ 2 . We proceed as in the proof of Theorem 9 in Section 3, by exchanging the subtrees attached to adjacent frustrated vertices. Let Ψ 2 (T, r q ) be the tree thus obtained, and Ψ(f ) = Ψ 2 • Ψ 1 (f ). One again, Ψ 2 is an involution. In particular Ψ is bijection, which satisfies Property (b) thanks to the construction Ψ 2 . Proposition 26 is proved.

Enumeration of general embedded trees

In this section, we prove the enumerative results of Section 2 in the case ℓ < 0. These results follow from the bijection of Theorem 24, combined with the of S-functions (which remains an elementary exercise). We also need to relate the S-trees occurring in Theorem 24 to the S-embedded Cayley trees of Section 2. This is done in the following lemma. We adopt the same notation as in the previous section: V = ∪ r i=ℓ V i with V i = {i 1 , . . . , i ni }, and S ⊂ Z satisfies min S = -1 and max S = 1. The type distribution of a tree is the collection of numbers n(i, s, c) (with i ∈ 0, r , s ∈ S and c ∈ N 3 ) giving the number of vertices of type (i; s; c).

Lemma 38. The number of S-embedded Cayley trees having a prescribed type distribution is 1 n ℓ n r n! r i=ℓ (n i -1)! times the number of marked S-trees satisfying Conditions (T 1 ) and (T 2 ) of Theorem 24 and having the same type distribution (as always, (n ℓ , . . . , n r ) denotes the profile of the tree, and n its size).

Proof. Equivalently, we want to prove that the number of S-embedded Cayley trees having a prescribed type distribution and two marked vertices, one at abscissa ℓ and the other at abscissa r, is n! i (n i -1)! times the number of marked S-trees satisfying (T 1 ) and (T 2 ) and having the same type distribution. We will construct a 1-to-n!/ i (n i -1)! correspondence between marked S-trees satisfying (T 1 ) and (T 2 ) and doubly marked S-embedded Cayley trees, preserving the type distribution.

Let (T, r q ) be a marked S-tree on V satisfying (T 1 ) and (T 2 ). Let us mark, in addition, the vertex ℓ 1 . For ℓ ≤ i ≤ r, let us rename the vertex i 1 by i k , for a k chosen in {1, . . . , n i }; conversely, let us rename i k by i 1 . This gives an arbitrary S-tree T 1 , rooted at a vertex of V 0 , with two marked vertices, one at abscissa ℓ and one at abscissa r. This tree may or may not satisfy (T 1 ) and (T 2 ). The number of different trees T 1 that can be constructed from T in such a way is r i=ℓ n i . The tree T can be recovered from T 1 by restoring vertex names: indeed, the vertex ℓ 1 in T is at the position of the marked vertex of abscissa ℓ in T 1 , and the position of i 1 in T , for i > ℓ, is prescribed by (T 1 ) and (T 2 ).

Let us now assign labels from {1, . . . , n}, with n = i n i , to the vertices of T 1 , in such a way that the labels a and b assigned to i k and i p satisfy a < b if k < p. There are n!/ i n i ! ways to do so. Finally, erase all names i k from the tree, for all i and k. This gives an arbitrary rooted 2. Let n(i, s) be non-negative integers, for i ∈ ℓ, r and s ∈ S, satisfying the compatibility conditions of an out-type distribution. The number of S-functions from V \ {0 1 } to V satisfying (F) and in which, for all i ∈ ℓ, r and s ∈ S, exactly n(i, s) vertices have out-type (i; s) is

n ℓ n r r i=ℓ (n i -1)! r i=ℓ n c(i)-1 i -1 i=ℓ n(i, -1) r i=1 n(i, 1) i,s n(i, s)! ,
where c(i) is the number of vertices whose image lies in V i :

c(i) = s n(i + s, s).
Proof. We proceed as in the proof of Lemma 18.

1. We first choose the images of the c(i) vertices whose image is in V i , for i ∈ {ℓ, r}. There are n c(i) i possible choices. For i ∈ 0, r -1 (resp. i ∈ ℓ + 1, -1 ) we only choose in V i the images of the vertices different from (i + 1) 1 (resp. (i -1) 1 ). There are n c(i)-1 i possible choices. 2. We first choose the out-type of every vertex, and then apply the previous result. For all i and s, we must choose the n(i, s) vertices of V i that have out-type (i; s), keeping in mind that i 1 has out-type (i; 1) for i ≥ 1, out-type (i; -1) for i ≤ -1, and out-type (0; ε) for i = 0. Thus the number of ways to assign the out-types is

(n 0 -1)! s n(0, s)! -1 i=ℓ (n i -1)! (n(i, -1) -1)! s =-1 n(i, s)! r i=1 (n i -1)! (n(i, 1) -1)! s =1 n(i, s)! .
The lemma follows.

6.3. The out-types of S-ary trees: Proof of Theorem 6

We argue as in Section 4.4. By Lemma 38 and Theorem 24, the number of S-ary trees having n(i, s) non-root vertices of out-type (i; s) is 1/n ℓ /n r / i (n i -1)! times the number of S-functions from V \ {0 1 } to V satisfying (F) that are injective on each V i and have the same distribution of out-types. This number is given by the second part of the following lemma. Theorem 6 follows, in the case ℓ < 0.

Lemma 41. 1. The number of S-functions from V \ {0 1 } to V , injective on each V i , satisfying (F), and in which each v ∈ V has a prescribed out-type (i v ; s v ) is, assuming compatibility,

1 r-1 i=ℓ+1 n i i,s n(i, s)! n i-s n(i, s) ,
where n(i, s) is the number of vertices of out-type (i, s).

2.

Let n(i, s) be non-negative integers, for i ∈ ℓ, r and s ∈ S, satisfying the compatibility conditions of an out-type distribution. The number of S-functions from V \ {0 1 } to V , injective on each V i , satisfying (F) and in which, for all i ∈ ℓ, r and s ∈ S, exactly n(i, s) vertices have out-type (i; s) is r i=ℓ

(n i -1)! -1 i=ℓ n(i, -1) r i=1 n(i, 1) r-1 i=ℓ+1 n i i,s n i-s n(i, s) .
Proof. We proceed as in the proof of Lemma 19. 1. For • i ∈ -1, 0 and s ∈ S,

• or i ∈ ℓ, -2 , and s ∈ S \ {-1},

• or i ∈ 1, r , and s ∈ S \ {1}, we choose in V i-s the (distinct) images of the n(i, s) vertices having out-type (i, s). There are ni-s n(i,s) n(i, s)! ways to do so.

When i ∈ 1, r and s = 1, we choose in V i-1 \ {(i -1) 1 } the images of the n(i, s) -1 vertices different from i 1 having out-type (i, 1). There are

n i-1 -1 n(i, 1) -1 (n(i, 1) -1)! = n i-1 n(i, 1) n(i, 1)! n i-1
ways to do so. When i ∈ ℓ, -2 and s = -1, we choose in V i+1 \ {(i + 1) 1 } the images of the n(i, s) -1 vertices different from i 1 having out-type (i, -1). There are

n i+1 -1 n(i, -1) -1 (n(i, -1) -1)! = n i+1 n(i, -1) n(i, -1)! n i+1
ways to do so. This concludes the proof of the first result.

2. The argument used to prove the second part of Lemma 40 can be copied verbatim.

6.4. The in-types: Proof of Theorem 7

Assume S = -1, 1 . We argue as in Section 4.5. By Lemma 38 and Theorem 24 (in particular Property (b) of this theorem), the number of S-embedded Cayley trees having n(i, c) vertices of in-type (i; c) is n!/n ℓ /n r / i (n i -1)! times the number of S-functions from V \ {0 1 } to V satisfying (F) and having the same distribution of in-types. This number is given by the second part of the following lemma. Theorem 7 follows, in the case ℓ < 0.

Lemma 42. Let S = -1, 1 . 1. The number of S-functions f from V \ {0 1 } to V satisfying Conditions (F), except maybe the condition f (-1 1 ) ∈ V 0 , and in which each v ∈ V has a prescribed in-type (i v ; c v ) is, assuming compatibility,

n -1 r i=ℓ (n i -1)! b≥0,s b! ns(b) -1 i=ℓ+1 c -1 i 1 r-1 i=0 c 1 i 1 ,
where n s (b) is the number of vertices v that have exactly b pre-images at abscissa a(v) + s:

n s (b) = ♯{v ∈ V : c s v = b}. 2.
Let n(i, c) be non-negative integers, for i ∈ ℓ, r and c ∈ N 3 , satisfying the compatibility conditions of an in-type distribution. The number of S-functions from V \ {0 1 } to V satisfying (F) and in which, for all i ∈ ℓ, r and c ∈ N 3 , exactly n(i, c) vertices have in-type (i; c) is

n ℓ n r r i=ℓ (n i -1)! 2 i,c n(i, c)! b≥0,s b! ns(b) -1 i=ℓ n(i, -1) r i=1 n(i, 1),
where n s (b) is the number of vertices v that have exactly b pre-images at abscissa a(v) + s, and n(i, 1) is the number of vertices of out-type (i; 1). Equivalently,

n s (b) = i c:c s =b n(i, c), n(i, 1) = c c 1 n(i -1, c).
Proof. We proceed as in the proof of Lemma 20.

1. Let us first choose the images of the n -1 vertices of V -1 . Exactly c s (-1-s) k of them have image (-1 -s) k , for all s and k. For i ∈ ℓ, r \ {-1}, let us choose the images of the n i -1

vertices of V i \ {i 1 }. Exactly c s (i-s) k -1 s=1=k=1,i>0 -1 s=-1,k=1
,i<-1 of them have image (i -s) k , for all s and k. The first result follows.

2. We first focus on functions that satisfy Conditions (F), except maybe the condition f (-1 1 ) ∈ V 0 . Let us first prescribe the in-type (i; c i 1 ) of all vertices of the form i 1 , for all i, and the number ñ(i; c) of vertices of V i \ {i 1 } having in-type (i; c), for all c ∈ N 3 . Clearly,

ñ(i, c) = n(i, c) -1 c=c i 1 .
The number of ways to assign types to vertices of V i \ {i 1 } is

(n i -1)! c ñ(i, c)! = (n i -1)! c n(i, c)! n(i, c i 1 ).
Using the first result, we conclude that the number of functions such that i 1 has in-type (i; c i 1 ) and ñ(i; c) of vertices of

V i \ {i 1 } having in-type (i; c) is n -1 r i=ℓ (n i -1)! 2 i,c n(i; c)! b! ns(b) -1 i=ℓ+1 c -1 i 1 r-1 i=0 c 1 i 1 r i=ℓ n(i, c i 1 ) .
Let us now only prescribe the values n(i, c) (still focussing on functions that may not satisfy f (-1 1 ) ∈ V 0 ). That is, we need to sum the above formula over all possible in-types of the vertices i 1 , for i = ℓ, . . . , r. Note that only the three rightmost products depend on the choice of these types. We are thus led to evaluate

r i=ℓ c i 1 ∈N 3 -1 i=ℓ+1 c -1 i 1 r-1 i=0 c 1 i 1 r i=ℓ n(i, c i 1 ) =   c ℓ 1 n(ℓ, c ℓ 1 )   -1 i=ℓ+1   c i 1 c -1 i 1 n(i, c i 1 )   r-1 i=0   c i 1 c 1 i 1 n(i, c i 1 )     c r 1 n(r, c r 1 )   = n ℓ n r -2 i=ℓ n(i, -1) r i=1 n(i, 1).
Thus the number of functions that satisfy Conditions (F), except maybe the condition f (-1 1 ) ∈ V 0 , and have n(i; c) vertices on in-type (i; c) for all i and c is

n ℓ n -1 n r r i=ℓ (n i -1)! 2 i,c n(i, c)! b≥0,s b! ns(b) -2 i=ℓ n(i, -1) r i=1 n(i, 1).
It remains to prove that the proportion of these functions that also satisfy f (-1 1 ) ∈ V 0 is n(-1, -1)/n -1 . This follows from the existence of an in-type preserving bijection between functions f that satisfy all conditions of (F) and have a marked vertex v in V -1 , and functions g that satisfy (F), with the possible exception of g(-1 1 ) ∈ V 0 , and have a marked vertex w in V -1 ∩g -1 (V 0 ) (that is, a vertex of out-type (-1, -1)). This bijection sends (f, v) to (g, w), where w = v, g(-

1 1 ) = f (v), g(v) = f (-1 1 ) and g(x) = f (x) if x ∈ {-1 1 , v}.
As there are n -1 choices for the vertex v in f , and n(-1, -1) choices for the vertex w in g, this completes the proof of the second part of the lemma.

Other approaches

We now present two other approaches for counting embedded trees: the first one combines recursive descriptions of trees, functional equations and the Lagrange inversion formula; the second one is based on the matrix-tree theorem. The first approach proves the results on the profile and on the out-types, both for S-embedded Cayley trees and for S-ary trees. The second one proves the results on the profile and on the out-types of S-embedded Cayley trees only.

These methods are of course more routine, but not bijective. They involve computing certain determinants that factor for reasons that are not clear combinatorially. To our knowledge, they do not prove the other results of this paper.

Functional equations and the Lagrange inversion formula

One can prove the results that deal with the vertical profile (Theorems 3 and 4) and with the out-type (Theorems 5 and 6) via elementary recursive descriptions of trees and the Lagrange inversion formula (LIF). We give the details of the proof of Theorem 3, and sketch the other three, which are similar.

We have been unable to reprove in this way the results that deal with the in-type or the complete type. 7.1.1. The vertical profile of S-embedded Cayley trees. Let x = (x i ) i∈Z be a sequence of indeterminates, and let A 0 ≡ A 0 (x) be the exponential generating function of S-embedded Cayley trees, where x i keeps track of the number of vertices lying at abscissa i, for all i ∈ Z. That is,

A 0 = T 1 |T |! v∈V x a(v) ,
where |T | is the size of the tree T (the number of vertices) and V the vertex set of T . For j ∈ Z, let A j be the series obtained from A 0 by replacing each x i by x i+j . An S-embedded Cayley tree is obtained by attaching to a root vertex (lying at abscissa 0) a set of Cayley trees whose roots lie in S. Hence

A 0 = x 0 exp s∈S A s .
Consequently, for all i ∈ Z,

A i = x i exp s∈S A i+s . (5)
Let now n ≡ (n i ) ℓ≤i≤r be a sequence of positive integers. The number of S-embedded Cayley trees of vertical profile n is |n|![x n ]A 0 , where |n| = i n i and [x n ]A 0 stands for the coefficient of

x n ℓ ℓ • • • x nr r in A 0 .
We use the following version of the Lagrange-Good inversion formula [START_REF] Gessel | A combinatorial proof of the multivariable Lagrange inversion formula[END_REF][START_REF] Good | Generalizations to several variables of Lagrange's expansion, with applications to stochastic processes[END_REF]: if for all ℓ ≤ i ≤ r,

F i = x i g i (F ℓ , . . . , F r ), then [x n ]F 0 = [x n ] x 0 r i=ℓ g i (x) ni det δ ij - x i g j (x) ∂g j (x) ∂x i ℓ≤i,j≤r .
Hence, it follows from (5) that

[x n ]A 0 = [x n ] x 0 r i=ℓ exp n i s∈S x i+s det (δ ij -x i 1 i-j∈S ) ℓ≤i,j≤r ,
where by convention x i = 0 if i < ℓ or i > r.

We find convenient to use the following classical expression of the above determinant in terms of configuration of cycles. Let G ≡ G ℓ,r (S) be the digraph with vertices {ℓ, . . . , r} and with an arc from i to j if and only if i -j ∈ S. A cycle of G is elementary if it never visits the same vertex twice. A configuration of cycles if a set C of elementary cycles such that each vertex i ∈ ℓ, r is contained in at most one cycle of C. We loosely write i ∈ C when i is contained in a cycle of C. Then, by expanding the determinant, one finds

det (δ ij -x j 1 i-j∈S ) ℓ≤i,j≤r = C (-1) |C| i∈C x i ,
where |C| denotes the number of elementary cycles of C. Hence we can now rewrite

[x n ]A 0 = [x n ] x 0 r i=ℓ exp x i s∈S n i-s C (-1) |C| i∈C x i , = C (-1) |C| r i=ℓ [x ni i ] x 1i=0+1i∈C i exp x i s∈S n i-s = C (-1) |C| r i=ℓ s∈S n i-s ni-1i=0-1i∈C (n i -1 i=0 -1 i∈C )! = r i=ℓ s∈S n i-s ni-1i=0-1 (n i -1 i=0 )! C (-1) |C| r i=ℓ   s∈S n i-s 1 i ∈C (n i -1 i=0 ) 1i∈C   (6)
where now n i = 0 if i < ℓ or i > r.

The following lemma shows that, under the hypotheses of Theorem 3, the sum over C factors nicely. Theorem 3 follows at once. Lemma 43. Let S ⊂ Z such that max S = 1. For ℓ ≤ 0 ≤ r, let G ℓ,r (S) be the above defined digraph. Define the following polynomial in the indeterminates y ℓ , . . . , y r :

P ℓ,r = C (-1) |C| r i=ℓ   s∈S y i-s i ∈C (y i -1 i=0 ) 1i∈C   ,
where the sum runs over configurations of cycles C on the graph G ℓ,r (S), |C| stands for the number of elementary cycles in C and y i = 0 if i < ℓ or i > r. Clearly, P 0,0 = 1 0∈S . Assume now |ℓ| + r > 0. If min S = -1 or ℓ = 0, then

P ℓ,r = s∈S y -s r-1 i=ℓ+1 y i .
Proof. We first assume that ℓ = 0. Define the auxilliary polynomial Q r (y 0 , y 1 , . . . , y r ) by Q 0 (y 0 ) = 1 and for r > 0,

Q r (y 0 , y 1 , . . . , y r ) = C (-1) |C| r i=1   s∈S y i-s 1 i ∈C (y i ) 1i∈C   ,
where the sum now runs over configurations of cycles on the graph G 1,r (S), and y i = 0 if i < 0 or i > r.

Given that max S = 1, an elementary cycle necessarily consists of the vertices i -s, i -s -1, . . . , i + 1, i (visited in this order), where s ∈ S \ {1}. In particular, two elementary cycles having no vertex in common occupy disjoint intervals of vertices. This allows us to write a recurrence relation for the polynomials Q r , by considering whether the vertex 1 belongs to the configuration C or not. For r > 0,

Q r (y 0 , . . . , y r ) = s∈S y 1-s Q r-1 (y 1 , . . . , y r ) - s∈S\{1} Q r+s-1 (y 1-s , . . . , y r ) 1-s i=1 y i .
The first term corresponds to configurations not containing 1. The sum over s ∈ S \ {1} corresponds to the choice of the size of the cycle containing 1, which contains 1 -s vertices. It follows by induction on r that Q r (y 0 , . . . , y r ) = r-1 i=0 y i .

Similarly,

P 0,r = s∈S y -s Q r (y 0 , . . . , y r ) -(y 0 -1) s∈S\{1} Q r+s (y -s , . . . , y r ) -s i=1 y i .
It then follows from [START_REF] Bousquet-Mélou | The density of the ISE and local limit laws for embedded trees[END_REF] that

P 0,r = s∈S y -s r-1 i=1 y i ,
as announced in the lemma. We now assume that ℓ < 0 and that min S = -1. That is, S = {±1} or S = {±1, 0}, and in particular S is symmetric. There are now two types of elementary cycles, those reduced to a loop (if 0 ∈ S) and those consisting of two neighbour vertices i and i + 1. By considering whether the vertex 0 belongs to the configuration C or not, and whether this cycle consists solely of the vertex 0, or of the vertices 0 and 1, or of the vertices 0 and -1, one obtains

P ℓ,r = s∈S y -s Q r (y 0 , . . . , y r )Q |ℓ| (y 0 , y -1 , . . . , y ℓ ) -(y 0 -1)Q r (y 0 , . . . , y r )Q |ℓ| (y 0 , y -1 , . . . , y ℓ )1 0∈S -(y 0 -1)y 1 Q r-1 (y 1 , . . . , y r )Q |ℓ| (y 0 , y -1 , . . . , y ℓ ) -(y 0 -1)y -1 Q r (y 0 , . . . , y r )Q |ℓ| (y -1 , . . . , y ℓ )
with Q -1 = 0. The announced expression of P ℓ,r now follows from [START_REF] Bousquet-Mélou | The density of the ISE and local limit laws for embedded trees[END_REF]. This concludes the proof of the lemma, and our first alternative proof of Theorem 3. 7.1.2. The vertical profile of S-ary trees. The proof of Theorem 4, which deals with the profile of S-ary trees, is very similar. One starts from the system of equations

A i = x i s∈S (1 + A i+s ),
for all i ∈ Z. The LIF now gives

[x n ]A 0 = [x n ] x 0 r i=ℓ s∈S (1 + x i+s ) ni det δ ij - x i 1 + x i 1 i-j∈S ℓ≤i,j≤r .
Again, we express the determinant as a sum over configurations of cycles. This yields

[x n ]A 0 = C (-1) |C| r i=ℓ [x ni i ] x 1i=0+1i∈C i (1 + x i ) s ni-s-1i∈C = r i=ℓ ( s∈S n i-s -1)! (n i -1 i=0 )!( s∈S n i-s -n i + 1 i=0 )! C (-1) |C| r i=ℓ   s∈S n i-s 1 i ∈C (n i -1 i=0 ) 1i∈C  
where by convention x i = n i = 0 if i < ℓ or i > r. We recognize the same sum over C as in [START_REF] Bousquet-Mélou | Limit results for embedded trees. Applications to the integrated super-Brownian excursion[END_REF], and Lemma 43 then yields Theorem 4. 7.1.3. The out-type of S-embedded Cayley trees. In order to prove Theorem 5, we start from the system

A i = x i exp s∈S x i+s,s A i+s , (8)
which is a refined version of [START_REF] Bousquet | Two bijective proofs for the arborescent form of the Good-Lagrange formula and some applications to colored rooted trees and cacti[END_REF] where for each (j, s) ∈ Z × S the indeterminate x j,s keeps track of the number of vertices of out-type (j; s).

We first apply the LIF with respect to the variables x i :

[x n ]A 0 = [x n ] x 0 r i=ℓ exp n i s
x i+s,s x i+s det(δ ij -x i x i,i-j 1 i-j∈S ) ℓ≤i,j≤r .

The expansion of the determinant now reads C (-1) |C| (i,i-s)∈C

x i x i,s ,

where we write (i, i -s) ∈ C when the arc (i, i -s) belongs to one of the cycles of C. This gives

[x n ]A 0 = C (-1) |C|   (i,i-s)∈C x i,s   r i=ℓ [x ni i ] x 1i=0+1i∈C i exp x i s n i-s x i,s . (9)
We now extract the coefficient of i,s x n(i,s) i,s

, with

n i = 1 i=0 + s∈S n(i, s).
We obtain for this coefficient the following expression

where n i = 1 i=0 + s n(i, s). The proof of this identity is similar to the proof of Lemma 43. One proceeds by induction on r + |ℓ|, first for ℓ = 0 and then for ℓ < 0, after introducing the following auxilliary polynomial:

Q r = C (-1) |C| r i=1 n 1 i ∈C i (i,i-s)∈C n(i, s),
where the sum now runs over configurations of cycles on the graph G 1,r (S). A recurrence relation on Q r implies that Q r = r i=1 n(i, 1). Expressing P ℓ,r in terms of the Q i 's, as in the proof of Lemma 43, finally establishes (10). 7.1.4. The out-type of S-ary trees. In order to prove Theorem 6, we start from

A i = x i s∈S (1 + x i+s,s A i+s ). ( 11
)
The calculation is similar to the previous one. In particular, one uses again [START_REF] Brown | On random binary trees[END_REF].

7.1.5. A variant for the out-type of S-ary trees. One can also enrich the first calculation of this section by adding weights x i,s on vertices of out-type (i; s), and thus prove directly Theorem 5, in the form (2). One starts again from [START_REF] Bouttier | Geodesic distance in planar graphs[END_REF]. Extracting the coefficient of x n gives (9).

Then, one does not extract the coefficient of i,s x n(i,s) i,s

, but uses instead the following refinement of Lemma 43: where the sum over C is over configurations of cycles of G 1,r (S).

Application of the matrix-tree theorem

We now apply the matrix-tree theorem to prove that the generating function of S-embedded trees of vertical profile (n ℓ , . . . , n r ), counted by the number of vertices of out-type (i; s), for all i and s, is given by ( 2). This proves Theorems 3 and 5 simultaneously.

We consider as before the vertex set V = ∪ r i=ℓ V i , with V i = {i 1 , i 2 , . . . , i ni }, and we consider the digraph K on V where an arc joins i p to j q if and only if i p = j q and j = i -s for some s ∈ S. This arc receives the weight x i,s . Recall that, on a digraph, a spanning tree is always rooted, with all edges of the tree pointing towards the root vertex. Thus a spanning tree of K is precisely an S-tree, as defined in Section 5. The out-type is defined as before. It is easy to see that the generating function of S-embedded Cayley trees of profile (n ℓ , . . . , n r ) is n 0 n!/ r i=0 n i ! times the generating function of spanning trees of K rooted at 0 n0 . Hence (2) is equivalent to the following proposition.

Proposition 44. The generating function of spanning trees of K rooted at 0 n0 equals: Proof. We apply the weighted version of the matrix-tree theorem (see [START_REF] Tutte | The dissection of equilateral triangles into equilateral triangles[END_REF]Thm. 3.6] or [START_REF] Stanley | Enumerative combinatorics[END_REF]Thm. 5.6.8]). The (weighted) Laplacian matrix M of K has its rows and columns indexed by elements of V , and coefficients given by: M (i p , j q ) =    -x i,0 1 0∈S + s∈S x i,s n i-s if i p = j q , -x i,i-j 1 i-j∈S otherwise.

In this matrix, the diagonal coefficient s∈S x i,s n i-s -x i,0 1 0∈S is the (weighted) out-degree of any vertex of the form i p . By the matrix-tree theorem, the generating function of spanning trees of K rooted at 0 n0 is the determinant of the matrix M obtained from M by removing the line and column indexed by 0 n0 .

We consider M as a linear operator acting on the vector space on C spanned by V \ {0 n0 }. We will first identify a number of eigenvectors and eigenvalues of M , and then describe the action of M on the orthogonal complement of the subspace spanned by these eigenvectors.

Let ℓ ≤ j ≤ r, α = (α 1 , . . . , α ñj ) ∈ C ñj , and denote

V j (α) = α 1 j 1 + α 2 j 2 + • • • + α ñj j ñj ,
where ñi = n i -1 i=0 . Denote also W j = V j (1, . . . , 1). Using the definition of M , one computes:

M V j (α) = V j (α) s∈S x j,s n j-s -   ñj q=1 α q   r i=ℓ x i,i-j 1 i-j∈S W i . (13)
Consequently, for ℓ ≤ j ≤ r, the vector space formed of the V j (α) such that ñj q=1 α q = 0 is an eigenspace of dimension ñj -1, associated with the eigenvalue s∈S x j,s n j-s . If n = j n j denotes the size of the trees we are counting, we have thus identified an eigenspace of M of dimension j (ñ j -1) = n -1 -(r -ℓ + 1), and found in det( M ) a factor r j=ℓ s∈S x j,s n j-s ñj -1 .

The vectors W j , for ℓ ≤ j ≤ r, span the orthogonal complement of this eigenspace, and by [START_REF] Chassaing | Random planar lattices and integrated superBrownian excursion[END_REF], M W j = W j s∈S x j,s n j-s -ñj r i=ℓ x i,i-j 1 i-j∈S W i . Therefore, det( M ) = det(N ) r j=ℓ s∈S x j,s n j-s ñj -1 [START_REF] Cori | Planar maps are well labeled trees[END_REF] where N = (N (i, j)) ℓ≤i,j≤r is the square matrix of size (r -ℓ + 1) with coefficients N (i, j) =    -ñ i x i,0 1 0∈S + s∈S x i,s n i-s if i = j, -ñ j x i,i-j 1 i-j∈S otherwise.

We expand det(N ) first as a sum over permutations σ of {ℓ, . . . , r}, and then as a sum over configurations of cycles C on the graph G ℓ,r (S) (a fixed point i of σ gives rise either to a loop of weight -ñ i x i,0 1 0∈S or to a point not belonging to C, with weight s∈S x i,s n i-s ). The resulting expression coincides with the left-hand side of (12) (with y i = n i ), and the identity (12) thus gives: Together with [START_REF] Cori | Planar maps are well labeled trees[END_REF], this completes the proof of the proposition.

det(N ) =

Final comments

Simpler proofs?

The bijection of Section 5 is fairly complicated. Can one find simpler proofs of our results, for trees with negative labels? Many proofs of Cayley's formula exist, beyond the three that we have adapted in this paper (namely, Joyal's bijective proof, functional equations and Lagrange's formula, and the matrix-tree theorem). It is possible that other proofs may be adapted to provide simpler proofs of our results, especially for trees with negative labels and for the distribution of in-types (which we can only address via the bijection of Section 5). Finding such a proof could also enlighten the questions raised in the following subsections.

The complete type

Is Theorem 8, which deals with the complete type of S-embedded trees, as general as it could? Does one really need to assume that the trees are non-negative, and that 0 ∈ S?

We do not know how to answer this question, but is it easy to see that, if there exists a more general formula, the sets of functions considered in Theorem 9 (for non-negative trees) and in Theorem 24 (for trees with negative abscissas) will not allow us to prove it. More precisely, when 0 ∈ S, or when the trees have negative abscissas, there exists no bijection between the functions and the S-trees of Theorem 9 (or Theorem 24) that would preserve the distribution of complete types. Here are two simple counterexamples. For non-negative trees first, take V = {0 1 , 0 2 , 1 1 }, and define the function f by f (1 1 ) = 0 1 and f (0 2 ) = 0 2 . This function satisfies Condition (F) of Theorem 9 as soon as {0, 1} ⊂ S, but there exists no S-tree with the same type distribution. Now for trees with negative abscissas, take V = {-1 1 , -1 2 , 0 1 , 0 2 , 1 1 } and consider the following tree:

1 1 -1 2 0 2 0 1 -1 1
It satisfies Conditions (T 1 ) and (T 2 ) of Theorem 24, but there exists no S-function satisfying (F) with the same type distribution.

Trees embedded in trees

Following a seminar presenting this work in December 2011, Andrea Sportiello discovered a remarkable formula that generalizes Theorem 2, and added evidence that more factorization results exist for embeddings of trees in general graphs.

Let T be a finite rooted tree with vertex set A (called the set of abscissas) and root ρ. Let T be a Cayley tree with vertices labelled 1, 2, . . . , n. By a T -embedding of T , we mean an assignment of abscissas to vertices of T , that is, a map a : 1, n → A such that

• the abscissa of the root of T is ρ, • if v and v ′ are neighbours in T , then a(v) and a(v ′ ) are neighbours in T . In graph theoretic terms, we have a root preserving morphism of T to T . The profile of this T -embedded tree is the collection (n i ) i∈A , where n i is the number of vertices of T of abscissa i. The embedding is surjective if n i > 0 for all i. Then the number of surjective T -embedded Cayley trees having profile (n i ) i∈A is

n ρ n! i∈A n i ! i∈A      j∼i n j   ni-1 n deg(i)-1 i    ,
where n = i n i is the size of the trees, deg(i) is the degree of i in T and j ∼ i means that i and j are neighbours in T . It is easily checked that this gives Theorem 2 when T is the tree on the vertex set ℓ, r with an edge between i and i + 1 for all i ∈ ℓ, r -1 . Andrea Sportiello proved the above formula using the matrix-tree theorem. We do not know of any bijective proof.

(Important) note added to the proof (September 2012). After publication of this paper on ArXiv, our results have been reproved and generalized by Bernardi and Morales [START_REF] Bernardi | Counting trees using symmetries[END_REF]. Their proof is very elegant, combinatorial but not bijective. Their formulas are valid for any set S,

Figure 1 .

 1 Figure 1. A rooted binary tree having horizontal profile (1, 2, 4, 3, 2) and vertical profile (2, 2; 4, 2, 1, 1).

Figure 2 .

 2 Figure 2. The three rooted binary trees having vertical profile (2; 2, 1).

Figure 4 .

 4 Figure 4. Two equivalent embedded Cayley trees (the positions of the vertices indicate their abscissas).

2 10 1 2 Figure 6 .

 26 Figure 6. The map Φ 1 applied to the function of Figure 5. The marked vertex is 3 4 .

Figure 10 .

 10 Figure 10. The graph R(i). Pieces are ordered by decreasing sink from right to left. The leftmost and rightmost half-edges are present only if i = ℓ and i = 0, respectively. The vertex b i belongs to V i .

Figure 12 .

 12 Figure 12. The component C(i 0 ) is obtained by cutting the cycle of Gf containing v 0 at the edge entering v 0 . The small right concatenation R(i 0 ) is constructed in a similar way as R(i 0 ), but omitting the piece that would have contained v 0 . The subtrees attached to the distinguished paths of the pieces are not represented.

1 L( 2 ) 1 L

 121 a r . . . r * . . . . . . r 1 L(r) a 2 . . . 2 * . . . . . . 2 a 1 . . . 1 * . . . . . . 1

a 1 L

 1 r . . . r * . . . . . . r . . 0 * . . . . . . 0 1

  s)-1 (i,i-s)∈C i-s (n(i, s) -1 (i,i-s)∈C )! .After a few simple reductions, this gives Theorem 5, provided the following counterpart of Lemma 43 holds:

  a straightforward extension of the proof of Lemma 43, using Q r (y 0 , y 1 , . . . , y r ) :=

  3•107 2 , and 107 is prime (this number can be easily obtained from a recursive description of trees, as discussed in Section 7.1). Symmetrically, if S = {-1, 1, 2}, there are 6!

We refer again to the more recent paper[START_REF] Bernardi | Counting trees using symmetries[END_REF] for a (less explicit) formula that applies more generally.

Acknowlegements. We thank Philippe Marchal, Jean-François Marckert and Andrea Sportiello for interesting discussions about this work, some of which led to the results of Section 8.3.

Key words and phrasesGC was partially supported by the ERC grant StG 208471 -ExploreMaps, and thanks the LaBRI for a "Junior Invitation" in September 2010.

MBM was partially supported by the French "Agence Nationale de la Recherche", project A3 ANR-08-BLAN-0190.

S-embedded Cayley tree T 2 , with a marked vertex at abscissa ℓ and one at abscissa r. The tree T 1 can be recovered from T 2 by renaming the vertices of abscissa i with i 1 , . . . , i ni in the unique way that is consistent with the order on labels: if two vertices of labels a and b, with a < b, lie at abscissa i, then their names i k and i p must satisfy k < p.

The marked S-tree T has given rise to n!/ i (n i -1)! doubly marked embedded trees T 2 . Moreover, T 2 , T 1 and T have the same type distribution. The result follows.

In what follows, we count trees by counting functions, using the correspondence of Theorem 24. When we prescribe the types of vertices, or the number of vertices of a certain type, we assume as in Section 4 that the natural compatibility conditions hold.

Recall that Theorem 3 is already proved, even when ℓ < 0, thanks to the fourth remark that follows its statement.

The profile of S-ary trees: proof of Theorem 4

We argue as in Section 4.2. The number of S-ary trees of vertical profile (n ℓ , . . . , n r ) is obtained by divising by n! the number of injective S-embedded Cayley trees with the same profile. By Lemma 38, the number of injective S-embedded Cayley trees having vertical profile (n ℓ , . . . , n r ) is n!/n ℓ /n r / i (n i -1)! times the number of marked injective S-trees satisfying (T 1 ) and (T 2 ). By Theorem 24 (and in particular Property (b)), the number of such trees is also the number of S-functions from V \ {0 1 } satisfying (F) that are injective on each V i . This number is given by the following lemma. Theorem 4 follows, in the case ℓ < 0.

Lemma 39. The number of S-functions from V \ {0}, injective on each V i and satisfying (F) is

Proof. We proceed as in the proof of Lemma 17. For i ∈ {0, -1}, we choose the (distinct) images of the elements of V i \ {i 1 } in the set ∪ s V i-s \ {f (i 1 )}, where f (i 1 ) = (i -1) 1 if i > 1 and f (i 1 ) = (i + 1) 1 if i < 0. There are

(n i -1)! ways to do so. For i = 0, we choose the (distinct) images of the elements of V 0 \ {0 1 } in the set ∪ s V -s . There are s n-s n0-1 (n 0 -1)! ways to do so. For i = -1, we first choose the image v 0 of -1 1 in the set V 0 : there are n 0 ways to do so. Then, we choose the (distinct) images of elements of

(n -1 -1)! ways to do so.

The out-types of S-embedded Cayley trees: proof of Theorem 5

We argue as in Section 4.3. By Lemma 38 and Theorem 24 (in particular Property (a)), the number of S-embedded Cayley trees having n(i, s) non-root vertices of out-type (i; s) is n!/n ℓ /n r / i (n i -1)! times the number of S-functions from V \ {0 1 } to V satisfying (F) and having the same distribution of out-types. This number is given by the following lemma. Theorem 5 follows, in the case ℓ < 0.

Lemma 40. 1. The number of S-functions from V \ {0 1 } to V satisfying (F) and in which each v ∈ V has a prescribed out-type (i v ; s v ) is, assuming compatibility,

, where c(i) is the number of vertices whose image lies in V i :

and for general embedded trees -but of course they do not always simplify into product forms. These formulas involve a non-explicit sum over a family of trees, which simplifies in some cases. Let us give an example. Assume max S = 1, and take an integer sequence (n ℓ , . . . ; n 0 , . . . , n r ). If ℓ = 0, the number of S-embedded Cayley trees having vertical profile (n ℓ , . . . ; n 0 , . . . , n r ) is given by Theorem 3, which we rewrite as

The formula becomes more and more complex as ℓ decreases. If ℓ = -2 and n

Bernardi and Morales also answer the question raised in Section 8.2 on the generality of Theorem 8 (the complete type). For non-negative trees with max S = 1 and 0 ∈ S, they find an explicit, but complicated, expression. In the other cases, the sum over trees does not seem to simplify.