Julien Courtiel

Andrew Elvey Price

Irène Marcovici

Andrew Elvey Price

Bijections between walks inside a triangular domain and Motzkin paths of bounded amplitude

published or not. The documents may come   L'archive ouverte pluridisciplinaire

Introduction

In part due to the ubiquity of random walks in probability theory, lattice walks are extensively studied in enumerative combinatorics [START_REF] Mohanty | Lattice Path Counting and Applications[END_REF][START_REF] Humphreys | A history and a survey of lattice path enumeration[END_REF][START_REF] Bousquet | Walks with small steps in the quarter plane[END_REF]. In this context, it is frequently discovered that two families of walks, which seem to be very different, are in fact counted by the same numbers. The initial proof is often not combinatorial, and finding an explicit bijection between such families can prove to be a difficult task (see for example [START_REF] Sergi Elizalde | Bijections for pairs of non-crossing lattice paths and walks in the plane[END_REF][START_REF] Bettinelli | A bijective study of basketball walks[END_REF]).

In this spirit, this paper answers a 5 year old open question from Mortimer and Prellberg [START_REF] Paul | On the number of walks in a triangular domain[END_REF]Section 4.3]. By solving a functional equation satisfied by the generating function, the two authors realized that the number of walks in a triangular domain starting from a corner of this domain is equal to the number of Motkzin paths of bounded height -we will give precise definitions of these families in the following subsections. Their proof was purely analytic and, consequently, it raised the issue of finding an explanatory bijection. This gave rise to an open question, which became rather famous in the community, since Prellberg, one of the authors of [START_REF] Paul | On the number of walks in a triangular domain[END_REF], regularly asked for a bijection in open problems sessions during combinatorics conferences. The current paper solves this question, in several manners.

In the rest of this section, we introduce the notions of triangular paths, Motzkin paths and Motzkin meanders, which will be our objects of study, and we present more formally Mortimer and Prellberg's problem. Then, in the last subsection, we give a detailed outline of the present paper.

Triangular paths

Let (e 1 , e 2 , e 3 ) denote the standard basis of R 3 . For some L ∈ N, we define the subset T L of N 3 as the triangular section of side length L of the integer lattice:

T L = {x 1 e 1 + x 2 e 2 + x 3 e 3 : x 1 , x 2 , x 3 ∈ N, x 1 + x 2 + x 3 = L}.
An example of such lattice is shown by Figure 1 (left).

We also introduce the notation s 1 = e 1 -e 3 , s 2 = e 2 -e 1 , s 3 = e 3 -e 2 , and for i ∈ {1, 2, 3}, we set s i = -s i . We will interpret the vectors s i as forward steps and the vectors s i as backward steps. We denote by F = {s 1 , s 2 , s 3 } and B = {s 1 , s 2 , s 3 } the set of forward and backward steps, respectively.

For convenience, we define the indices modulo 3, thus s 0 = s 3 and s 4 = s 1 . The triangular lattice T L can be naturally drawn in the plane, as an equilateral triangle of side length L, subdivided in smaller equilateral triangles of side length 1 (see Figure 1 right). We will use this planar representation for the remainder of the document.

We define O as the bottom left corner of T L , that is to say O = Le 3 . In some sense, it denotes an origin for the lattice T L .

Definition 1 (Forward paths, triangular paths). Given an integer L ∈ N, and a point z ∈ T L , a forward (triangular) path of length n starting from z is a sequence (σ 1 , . . . , σ n ) ∈ F n satisfying ∀k ∈ {0, . . . , n}, z

+ k i=1 σ i ∈ T L .
A (generic) (triangular) path of length n starting from z is a sequence (ω 1 , . . . , ω n ) ∈ (F ∪ B) n satisfying ∀k ∈ {0, . . . , n}, z

+ k i=1 ω i ∈ T L .
If L ≥ 2, there are 2 forward paths of length 2 and 8 generic paths of length 2 starting from O, as shown by Figure 2.

For those who are familiar with the enumeration of walks in the quarter of plane, forward paths can be seen as a subfamily of tandem walks [START_REF] Fayolle | Random Walks in the Quarter Plane: Algebraic Methods, Boundary Value Problems, Applications to Queueing Systems and Analytic Combinatorics[END_REF]Section 4.7]. Tandem walks are walks on N 2 using steps (1, 0), (-1, 1), (0, -1) (East, North-West, South steps). Their name comes from the fact that in queuing theory, they model the behavior of two queues in series.

To be precise, forward paths of T L are equivalent to tandem walks confined in the part of the positive quarter plane below the anti-diagonal x + y = L. In terms of queues, . Equivalent definitions of the same object: forward paths of T 3 (left); tandem walks in the positive quarter of plane and below the antidiagonal x + y = 3 (middle); standard Young tableaux with three rows or less such that the label of the ith cell of the bottom row must be less than the label of (i + 3)th cell of the top row (right). forward paths can be represented by two queues in series where the total number of jobs (or customers) in both queues is never greater than L.

Since tandem walks are also described by standard Young tableaux [START_REF] Young | On Quantitative Substitutional Analysis[END_REF] with three rows or less, forward paths on T L form a particular subfamily of standard Young tableaux: they must have 3 rows or less, and for every k > L, if there is a kth cell in the top row of the tableau, then its label must be greater than the label of the (k -L)th cell of the third row (which must exist). The three equivalent definitions of forward paths are illustrated by Figure 3.

As for generic triangular paths, they are naturally encoded by double-tandem walks, which are walks on N 2 using steps (1, 0), (-1, 1), (0, -1), (-1, 0), (1-, 1), (0, 1) (we add to the base step set of the tandem walks the opposite steps).

Motzkin paths and meanders

A Motzkin path is a path using up, horizontal and down steps, respectively denoted , → and , such that:

• it starts at height 0;

• it remains at height ≥ 0 (i.e. inside any prefix of a Motzkin path, the number of steps is greater or equal to the number of steps); • it ends at height 0 (i.e. in total, there are as many steps as steps).

The following definition refines the notion of maximum height for a Motzkin path.

Definition 2 (Amplitude). Let M be a Motzkin path and H its maximum height (i.e the maximal difference between the number of steps and the number of steps in a prefix of M ).

The amplitude of M is defined as

2H + 1 if a horizontal step → is performed at height H, 2H otherwise.
For example, all the Motzkin paths of length 4 are listed by Figure 4: there is one such path with amplitude 1, four with amplitude 2, three with amplitude 3 and one with amplitude 4.

A Motzkin meander is a suffix1 of a Motzkin path. A Motzkin meander can thus start at any height, but must end at height 0.

Mortimer and Prellberg's open question

We now state Mortimer and Prellberg's enumerative result (reformulated in terms of amplitude), for which we are going to give explanatory bijections.

Theorem 3 (Corollary 4 [START_REF] Paul | On the number of walks in a triangular domain[END_REF]). Given any L ≥ 0, there are as many triangular paths in T L starting at O with p forward steps and q backward steps as bicolored Motzkin paths of length p + q with an amplitude less than or equal to L where p steps are colored in black and q are colored in white.

Setting p = n and q = 0, we obtain the following corollary about forward paths. Corollary 4. Given any L ≥ 0, there are as many forward paths in T L of length n starting at O as Motzkin paths of length n with an amplitude less than or equal to L.

An illustration of this corollary for n = 4 is shown by Figure 5.

Connections between Motzkin paths and tandem walks (the natural superset of forward paths) are not new. Regev [START_REF] Regev | Asymptotic values for degrees associated with strips of young diagrams[END_REF] was the first to notice via an algebraic method that standard Young tableaux with 3 rows or less and Motzkin paths are counted by the same numbers. Gouyou-Beauchamps [START_REF] Gouyou-Beauchamps | Standard young tableaux of height 4 and 5[END_REF] then found an explanation for this equinumeracy, thanks to the Robinson-Schensted correspondence. Since then, several authors [START_REF] Eu | Skew-standard tableaux with three rows[END_REF][START_REF] Eu | Standard young tableaux and colored motzkin paths[END_REF][START_REF] Chyzak | Bijections between Lukasiewicz walks and generalized tandem walks[END_REF][START_REF] Bousquet-Mélou | Plane bipolar orientations and quadrant walks[END_REF] have given new bijections between tandem walks and Motzkin paths, which each have their own ways to be generalized. It should be noted that none of these bijections restrict to a bijection between forward paths in T L and Motzkin paths with amplitude bounded by L.

By comparing Theorem 3 and its corollary, one can remark that there is a factor 2 n between forward paths in T L of length n and generic triangular paths in T L of length n. This fact was known before Mortimer and Prellberg's article for tandem walks and double-tandem walks (in other words, whenever L is infinite). Bousquet-Mélou and Mishna [START_REF] Bousquet | Walks with small steps in the quarter plane[END_REF] were the first to notice it and wondered whether there is a combinatorial explanation for this phenomenon. This was solved by Yeats via a convoluted bijection [START_REF] Yeats | A bijection between certain quarter plane walks and motzkin paths[END_REF]. This bijection was subsequently improved by Chyzak and Yeats [START_REF] Chyzak | Bijections between Lukasiewicz walks and generalized tandem walks[END_REF] by using the formalism of automata. Again, their bijection does not restrict to the triangular lattice T L .

Outline of the paper

This paper presents bijections that explain Theorem 3. More precisely, we demonstrate on one hand why the ratio between forward paths and generic paths of length n is 2 n , and on the other hand, we find several bijections for Corollary 4. Combining both results will give different combinatorial proofs of Theorem 3.

First, Section 2 concentrates around a symmetry property for the triangular paths: the number of paths starting from a point in T L with a fixed sequence of forward and backward steps does not depend on the sequence of forward and backward steps. This property, stated by Theorem 6, infers the above-mentioned 1-to-2 n function between forward paths and triangular paths of length n. The proof is based on a convergent rewriting system.

Section 3 provides a simple inductive proof of the equinumeracy between triangular paths in T L and Motzkin paths with amplitude bounded by L (Proposition 17). Furthermore, we manage to tweak this proof into a bijection which explains Corollary 4 (see Figure 12). However, this bijection is highly complex in the sense it is based on an inclusion-exclusion argument and can take an exponential time to be computed.

Almost independently from the previous sections, we describe in Section 4 a method to build numerous bijections between triangular paths and Motzkin paths of bounded amplitude. To do so, we relate the number of triangular paths starting at any z ∈ T L and the numbers of Motzkin meanders of amplitude bounded by L starting at height i (Theorem 24). This proves the existence of an object which we name scaffolding, which works in much the same way as a finite-state transducer. This enables us to find several parameterized bijections between forward paths and Motzkin paths (Algorithm 2), which can be extended into bijections between generic triangular paths and bicolored Motzkin paths (Subsection 4.3). In Subsection 4.4 we give an explicit scaffolding, with simple, albeit numerous transition rules, which has the additional property that it is independent of the size L.

Finally, in Section 5 we generalize our results to higher dimensions. The triangular lattice naturally extends to a simplicial lattice, in which the ratio property between forward paths and generic paths (Theorem 33) still holds. More surprisingly, we find a new bijection specifically in dimension 3. It matches walks using 4 steps confined within a pyramid with walks using the 4 cardinal steps returning to the x-axis confined in a domain which is the upper half of a square that have been rotated 45 • (Theorem 34). The second family of walks being easier to count than the first one, we find a formula for the generating function of the pyramidal walks, which was part of an open question from [START_REF] Paul | On the number of walks in a triangular domain[END_REF].

The bijections between forward paths and Motzkin paths have been implemented in python and are available at https://tinyurl.com/yajkqlyv.

From forward paths to generic triangular paths

This section describes a one-to-2 n function from the set of forward paths of length n in T L to the set of generic paths of length n in T L . This is a crucial step in finding a combinatorial proof of Theorem 3.

More precisely, we are going to describe a bijection between different sets of paths where in each set, all paths have the same sequence of forward and backward steps, which we call the direction vector. Definition 5. The direction vector of a generic path (ω 1 , . . . , ω n ) is the finite sequence (D 1 , . . . , D n ) where

D i = F if ω i is a forward step and D i = B if ω i is a backward step.
A forward path is then a generic path with direction vector (F, . . . , F ). Many examples of paths along with their direction vectors are shown in Figure 7. Theorem 6. Given z ∈ T L and two sequences W and W of {F, B} n , the set of triangular paths starting from z of direction vector W is in bijection with the set of triangular paths starting from z of direction vector W . This theorem will be proved in Section 2.2.

Forward and backward paths

This subsection shows by induction, without a bijection, a particular case of Theorem 6 between two direction vectors: W = (F, . . . , F ) and W = (B, . . . , B). This provides an elementary proof of a weaker result, which enables to understand why the more general theorem works. Definition 7. A backward (triangular) path is a triangular path of direction vector (B, B, . . . , B). In other words, a backward path starting at z ∈ T L is a sequence (σ 1 , . . . , σ n ) ∈ B n satisfying:

∀k ∈ {1, . . . , n}, z + k i=1 σ i ∈ T L .
Theorem 8. Let z be any point of T L and n ≥ 0. Inside T L , there are as many forward paths of length n starting from z as backward paths of length n starting from z.

The proof will use the following lemma, which concerns paths with one forward step and one backward step: Lemma 9. Given a starting point z and an ending point z , there are as many paths of length 2 from z to z made of a forward step then a backward step, as paths of length 2 from z to z made of a backward step then a forward step.

Proof. This lemma is obvious whenever the two steps can be permuted.

Let us first show that given a forward step σ and a backward step τ such that σ = -τ , the path (σ, τ ) stays in T L from z to z if and only if the path (τ , σ) stays in T L from z to z . For such steps σ and τ , there are two possibilities:

(1) σ is a step s i and τ is s i+1 . By cyclic permutation, we can assume that σ = s 1 = e 1 -e 3 and τ = s 2 = e 1 -e 2 . If z + σ ∈ T L and z + σ + τ ∈ T L , then z must have a positive e 2 -coordinate and a positive e 3 -coordinate. The same property holds if we replace the condition z + σ ∈ T L by z + τ ∈ T L . Therefore, we can permute the forward step and the backward step in that case. (2) τ is a step s i and σ is a step s i+1 . Again, we can assume that τ = s 1 = e 3 -e 1 and σ = s 2 = e 2 -e 1 . Under the assumption that z + σ + τ ∈ T L , we need z to have an e 1 -coordinate at least equal to 2. In this case, both paths (σ, τ ) and (τ , σ) are valid.

It remains to deal with paths satisfying σ = -τ . It is equivalent to treat the case z = z . It is then easy to check that for each possible position of z, there are as many paths of length 2 beginning with a forward step as paths of length 2 beginning with a backward step, as summarized by Figure 6.

Proof of Theorem 8. Let f n (z) be the number of forward paths of length n and starting at z ∈ T L , and b n (z) be the analogue for backward paths. We wish to prove that f n (z) = b n (z) for every z ∈ T L by strong induction on n ≥ 0.

For n = 0 and n = 1, the property is straightforward.

Let us assume that the assumption is true for some n ≥ 1 and n -1. For z ∈ T L we have: By the induction assumption,

f n+1 (z) = σ∈F z+σ∈T L f n (z + σ).
f n+1 (z) = σ∈F z+σ∈T L b n (z + σ) = path of length 2
from z to z made of a forward step then a backward step b n-1 (z ).

We use the induction assumption now for n -1, and Lemma 9:

f n+1 (z) = path of length 2
from z to z made of a backward step then a forward step

f n-1 (z ) = τ ∈B z+τ ∈T L f n (z + τ ). = τ ∈B z+τ ∈T L b n (z + τ ).
(by induction) = b n+1 (z), which concludes the induction, and hence the proof.

Bijection between sets of different direction vectors

In this subsection, we describe a bijection that proves Theorem 6.

(B, F, F ) (F, B, F ) (B, F, B) (B, B, B) (F, B, B) (B, B, F ) (F, F, B) (F, F, F ) Figure 7.
The bijections between all direction vectors (arranged as a Boolean lattice) applied to the forward path (s 1 , s 2 , s 1 ).

This bijection consists in combining the elementary operations below, in any possible order, until reaching a path with the desired direction sequences.

Definition 10 (Flips). We define here elementary reversible operations on a generic path (ω 1 , . . . , ω n ). A swap flip changes two consecutive steps ω i and ω i+1 with respect to the rules:

(s j , s k ) ←→ (s k , s j ) if j = k, (s k , s k ) ←→ (s k-1 , s k-1 ) otherwise.
(Recall that by convention, s 0 = s 3 .) This has the effect of doing a flip (F, B) ←→ (B, F ) in the direction vector.

A last-step flip changes the direction of the last step ω n thanks to the rule:

s i ←→ s i-1
For example, if we wish to bijectively transform the path (s 3 , s 3 , s 2 ) into a path of direction vector (F, B, B), we use the following flips (cf Figure 7):

(s 3 , s 3 , s 2 ) ←→ s 2 →s 3 (s 3 , s 3 , s 3 ) ←→ (s 3 ,s 3 )→(s 1 ,s 1 ) (s 3 , s 1 , s 1 ) ←→ s 1 →s 2 (s 3 , s 1 , s 2 ) ←→ (s 3 ,s 1 )→(s 1 ,s 3 )
(s 1 , s 3 , s 1 ).

Note that swap flips give a constructive proof to Lemma 9.

Proof of Theorem 6. We want to prove that successive flips induce a well-defined bijection between sets of triangular paths with different direction vectors. To do so, we have to establish the following points.

(1) The flips are well defined.

In other words, we want to show that a flip does not make a path of T L go outside T L .

For flips swapping steps s i and s j such that s i = -s j , we showed in the proof of Lemma 9 that a forward step and a backward step can commute under the condition that the two steps are not opposite.

The swap flip (s 1 , s 1 ) ←→ (s 3 , s 3 ) is also well-defined because s 1 and s 3 have both a negative e 3 -coordinate. Therefore, the position of the point just before the flip must have a positive e 3 -coordinate. One can safely apply s 1 or s 3 .

Similar arguments hold for the other swap flips, and for last-step flips. (2) Each flip is bijective.

This is clear from the definition of the flips. (3) Given two sequences W and W of {F, B} n , one can transform any path with direction vector W into a path of direction vector W by successive flips.

If W and W have the same number of B's, then we can use swap flips to transform a walk of direction vector W into one of direction vector W .

Otherwise, we can increment (resp. decrement) the number of B's of the direction vector by putting a forward step (resp. a backward step) at the end of the walk using successive swap flips, then changing the direction of this last step using a last-step flip. We rinse and repeat until obtaining the desired number of B's, then use swap flips as above. (4) If two different sequences of flips lead to triangular paths p and p that share a same direction vector, then p = p .

The proof of the last point is postponed until the next subsection (Proposition 14).

In particular, Theorem 6 gives a bijective proof of Theorem 8. If we wish to make it explicit, we can write an algorithm that chooses a specific sequence of flips that transforms an (F, . . . , F ) direction vector into a (B, . . . , B) vector.

Corollary 11. Given z ∈ T L and an integer n, Algorithm 1 forms a bijection between forward paths of length n starting at z and backward paths of length n starting at z. This bijection depends neither on the length L of the triangular lattice, nor on the position of the starting point z.

Algorithm 1: Bijection between forward paths and backward paths (for flips, see Definition 10). input : a f o r w a r d path p output : a backward path p n ← l e n g t h o f p ; for i from 1 to n do make a l a s t -s t e p f l i p on p [ i ] ;

for j decreasing from n-1 to i do make a swap f l i p between p [ j ] and p [ j + 1 ] ;

Remark 12. Algorithm 1 also transforms (in a bijective manner) a backward path into a forward path. Thus, if we apply twice Algorithm 1 to a forward path, we also obtain at the end a forward path. Therefore, assuming that the uniqueness claimed in Item (4) in the proof of Theorem 8 holds (and it does), the two forward paths must be the same: Algorithm 1 is in fact an involution.

Description of the bijection in terms of folded paths

This section presents the bijection of Theorem 6 in a more symmetric fashion. The last-step flip, which we defined in Definition 10, can be actually seen as a disguised swap flip, under the condition that the path is extended to what we call a folded path.

Definition 13 (Folded paths). Given a generic path ω = (ω 1 , . . . , ω n ) ∈ (F ∪ B) n , we define the folding of ω as the path -→ ←ω = (ω 1 , . . . , ω n , -ω n , . . . , -ω 1 ).

Such paths are said to be folded.

Let us denote by S n the tilted square lattice

S n = {(i, j) ∈ N × N : |i| + |j| ≤ n}.
We will geometrically represent folded paths of length 2n as labeled walks on S n starting at (-n, 0). To construct the walk on S n , we replace every forward step by a North-East step (+1, +1), and every backward step by a South-East step (+1, -1). Moreover, these North-East and South-East steps will carry labels, which are the steps of F ∪ B from which they originate. For example, the folding of the path (s 1 , s 3 , s 1 ) is represented on the left of Figure 8. Now, we are going to emulate the effect of swap flips (see Definition 10) on these walks. More precisely, we view S n as a square of size n × n which can be filled out with 1 × 1 square tiles of 9 types (see Figure 9). The four sides of the 9 allowed tiles are labeled with elements of F ∪ B such that the pairs formed by the two top labels and the two bottom labels correspond to a commutation rule described in Definition 10.

Figure 9. The 9 possible tiles

The tiling of S n proceeds as follows. We begin with the labels given by a folded path. Then, we place copies of the tiles of Figure 9 in such a way that the two top labels or the two bottom labels match (like a domino) with labels which were already in S n . Eventually, we obtain an alternative description of the bijection of Theorem 8, and thus the required uniqueness: Proposition 14. Let -→ ←ω be the folding of a triangular path ω of length n, which we embed in the tilted square lattice S n as described above.

There is a unique way to tile S n with the 9 tiles of Figure 9 while preserving the labels of -→ ←ω .

Furthermore, let us fix a sequence W = (W 1 , . . . , W n ) of {F, B} n . The path of direction vector W which corresponds to ω under the bijection of Theorem 6 is defined by the sequence of labels obtained by following the walk in S n whose k-th step is North-East if

W k = F or South-East if W k = B.
Example 15. Let us consider the path (s 1 , s 3 , s 1 ), represented in Figure 9 (left). The unique corresponding tiling is displayed on the right of the figure.

If we want the path of direction vector (B, F, F ) corresponding to (s 1 , s 3 , s 1 ), then we have to read labels from the walk going SE, NE, NE (in this order). We find (s 3 , s 1 , s 2 ).

Proof of Proposition 14. The existence and the uniqueness of the tiling are proved by induction. We just have to notice that every pair (σ, τ ) with σ ∈ F and τ ∈ B appears once among the top labels of the 9 tiles, and every pair (τ , σ) appears also once among the bottom labels. We have no choice in how to place new tiles: the tiling is automatic and unambiguous.

To connect the tiling with the bijection of Theorem 8, note that:

• A swap flip at positions k and k + 1 can be emulated by positioning a tile along the k-th and the (k + 1)-th step and by symmetrically placing a second tile along the (2n -k + 1)-th and the (2n -k)-th step. • A last-step flip can be emulated by positioning a tile on the vertical axis of S n .

One thus recovers what we described in previous subsection.

As a consequence, in view of the vertical symmetry of the tiling, one can describe the bijection of Theorem 8 uniquely in terms of swap flips -as claimed at the beginning of this subsection.

Corollary 16. The folded paths of direction vector (F, . . . , F, B, . . . , B) are in bijection with the folded paths of direction vector (B, . . . , B, F, . . . , F ) via successive uses of swap flips.

A first bijection between forward paths and Motzkin meanders

In this section, we provide two proofs of Corollary 4: the first one uses an induction and is elementary, the second one is based on a recursive bijection which is derived from the first proof.

Recursive proof of the equinumeracy

The following proposition links Motzkin meanders and forward paths starting from the border of T L . Proposition 17. For any n ≥ 0 and L > 0, let f n (z) be the number of forward paths in T L of length n starting at z, and m n ( ) the number of Motzkin meanders of length n starting at height and with an amplitude bounded by L (see Subsection 1.2 for the definitions).

Then, we have the formula

f n (O + s 1 ) = i=0 m n (i), for ∈ {0, . . . , L/2 }.
As a particular case = 0 of the result above, we recover the statement of Corollary 4.

Example 18. Figure 10 corroborates Proposition 17 with n = 3, L = 3, and = 1: numbers agree (8 on each side). Remark that if L is larger (L ≥ 4), the forward path s 1 s 1 s 1 will be added on the left, and the Motzkin meander , , on the right.

Proof of Proposition 17. Let us introduce the notation g n ( ) = f n (O + s 1 ), with the convention that g n ( ) = 0 for < 0. Let us also write ∆g n ( ) = g n ( ) -g n ( -1), and

H = L/2 .
Note that the numbers of Motzkin meanders m n ( ) satisfies the obvious recurrences

m n ( ) = m n-1 ( -1) + m n-1 ( ) + m n-1 ( + 1) for ∈ {1, . . . , H -1}, m n (0) = m n-1 (0) + m n-1 (1), m n-1 (H) = m n-1 (H -1) + m n (H) if L is odd m n-1 (H -1) if L is even , for n ≥ 1.
The proof is completed whenever we find the same recurrences for ∆g n (i).

The reader can refer to Figure 11 as a visual support for what follows.

n n-1 n-1 = + n n-1 n-1 = + Figure 11
. Explanation of Equations ( 1) and ( 2) in generic case. A dot with a subscript n represents the number of forward paths of length n starting from this point (which is, by Theorem 2, also the number of backward paths).

For any ∈ {1, . . . , H -1}, starting from O + s 2 , the only possible forward steps are s 1 and s 2 , so that

g n ( ) = f n-1 (O + s 1 + s 2 ) + f n-1 (O + s 1 + s 2 ) = g n-1 ( + 1) + f n-1 (O + s 1 + s 2 ). (1)
We now count backward paths starting from O + ( -1)s 1 . By Theorem 8, if b n (z) is the number of backward paths of length n starting at z, we have

f n (z) = b n (z) for every z ∈ T L . In particular, g n ( -1) = b n (O + ( -1)s 1 )
. Since only possible backward steps from O + ( -1)s 1 are s 1 and s 3 , we have for any ∈ {1, . . . , H -1},

g n ( -1) = b n-1 (O + ( -1)s 1 + s 1 ) + b n-1 (O + ( -1)s 1 + s 3 ) = f n-1 (O + ( -1)s 1 + s 1 ) + f n-1 (O + ( -1)s 1 + s 3 ) = g n-1 ( -2) + f n-1 (O + s 1 + (s 3 -s 1 )) = g n-1 ( -2) + f n-1 (O + s 1 + s 2 ). (2)
(Note that the case = 1 is correctly handled since by convention, g n-1 (-1) = 0.) Combining ( 1) and ( 2), we deduce that for ∈ {1, . . . , H -1},

g n ( ) -g n ( -1) = g n-1 ( + 1) -g n-1 ( -2),
and hence ∆g n ( ) = ∆g n-1 ( -1) + ∆g n-1 ( ) + ∆g n-1 ( + 1).

As for = 0, we straightforwardly have

∆g n (0) = g n (0) = g n-1 (1)
= ∆g n-1 (0) + ∆g n-1 (1).

(i) Let us first assume that L = 2H + 1 is odd. Then, using a symmetry through the plan of equation x 1 = x 3 (x 1 being the coordinate in e 1 and x 3 the one in e 3 ), we have f n-1 (O + Hs 1 ) = b n-1 (O + (H + 1)s 1 ). By Theorem 8, it translates g n-1 (H) = g n-1 (H + 1). Thus, ∆g n-1 (H + 1) = 0, and

∆g n (H) = ∆g n-1 (H -1) + ∆g n-1 (H).
It follows that (∆g n ( )) 0≤ ≤H satisfies the following recursion

          ∆g n (0) ∆g n (1) . . . . . . . . . ∆g n (H)           =            1 1 0 • • • • • • 0 1 1 1 . . . . . . 0 1 1 1 . . . . . . . . . . . . . . . . . . . . . 0 . . . . . . 1 1 1 0 • • • • • • 0 1 1                      ∆g n-1 (0) ∆g n-1 (1) . . . . . . . . . ∆g n-1 (H)          
which is the same recursion that we saw for (m n ( )) 0≤ ≤H . Since the base cases agree (∆g 0 ( ) = m 0 ( ) = 0 for > 1, and ∆g 0 (0) = m 0 (0) = 1), we have the equality m n ( ) = ∆g n ( ), and the result directly follows.

(ii) Let us now assume that L = 2H is even. Always thanks to the symmetry with respect the plane x 1 = x 3 , we have g n-1 (H -1) = g n-1 (H + 1), so that ∆g n-1 (H + 1) + ∆g n-1 (H) = 0, and ∆g n (H) = ∆g n-1 (H -1). It follows that (∆g n ( )) 0≤ ≤H satisfies the following recursion

          ∆g n (0) ∆g n (1) . . . . . . . . . ∆g n (H)           =            1 1 0 • • • • • • 0 1 1 1 . . . . . . 0 1 1 1 . . . . . . . . . . . . . . . . . . . . . 0 . . . . . . 1 1 1 0 • • • • • • 0 1 0                      ∆g n-1 (0) ∆g n-1 (1) . . . . . . . . . ∆g n-1 (H)          
.

We thus recover the recursion of (m n ( )) 0≤ ≤H , and we conclude like above.

Exponential bijection

We now convert the argument of Subsection 3.1 to a bijection, albeit one which is defined recursively and takes non-linear time to apply.

We fix in this section the length L of the triangular lattice T L , and H the semi-length:

H = L/2 .
Let G n (k) be the set of forward paths of length n starting at O + ks 1 and let M n (k) be the set of Motzkin meanders of length n starting at height k and having amplitude bounded by L.

It follows from Proposition 17 that |M

n (k)| = |G n (k)| -|G n (k -1)|.
To show this bijectively, we will recursively define a sequence of bijective functions

Ω n,k : G n (k) → M n (k)∪G n (k -1) for n ∈ N and k ∈ [0, H]
. This will use the bijection of Theorem 6 between triangular paths with different direction vectors. In particular, we will use this in the special cases sending paths with some direction vector W of length n

n = 0 n > 0 ω 1 = s 1 ω 1 = s 2 Return W n (s 3 ω ) Compare k with H In ω , replace
:= Ω n-1,k+1 (ω ) Compute [k] := Ω n-1,k ( [k+1]
)

Compute [k-1] := Ω n-1,k-1 ( [k]
)

Return [k+1] Return → [k] Return [k-1]
Return W n (s

1 [k-1]
)

Set [k+1] := ρ Set [k] := ρ k = 0 k > 0 k = H k < H [k+1]
is a forward path to paths with direction vector (F, . . . , F ). We denote this function by W n -this forms a bijection when the domain is restricted to those paths with some explicit direction vector.

[k+1] is a Motzkin meander [k] is a forward path [k] is a Motzkin meander L odd L even [k-1] is a forward path [k-1]
Theorem 19. Let k and n be two integers with k ≤ H. The function Ω n,k , defined by Figure 12, is a bijection from

G n (k) to M n (k) ∪ G n (k -1)
, where G n (k) is the set of forward paths of length n starting at O + ks 1 , and M n (k) is the set of Motzkin meanders of length n starting at height k and having amplitude bounded by L.

Proof. 1. Let us show that the map is well-defined, i.e. its image is included in

M n (k) ∪ G n (k -1).
It is quite straighforward, except maybe two points:

• Why is path ρ from block 15 of Figure 12 a valid triangular path of T L ? By replacing s 1 , s 2 , s 3 steps with s 1 , s 3 , s 2 , path ω undergoes a vertical reflection about the vertical midline of T L . Thus, ω is transformed into a backward path starting at

O + Hs 1 (if L is odd) or at O + (H -1)s 1 (if L is even). Applying W n-1 makes it a forward path, which is ρ, that belongs to G n-1 (H) (when L is odd) or G n-1 (H -1) (when L is even). • When k = H,
it is impossible to output a Motzkin meander starting at height H and beginning by a step. So the amplitude of every meander in the image is bounded by 2H +1. Moreover, when L is even and k = H, the returned meanders cannot begin by a horizontal step, which explains why they have amplitude bounded by L = 2H.

2. Let us show by induction on n that Ω n,k is a bijection for every k ≥ 0.

The case n = 0 is clear.

Let n be a positive integer. If the image is a Motzkin meander beginning by (resp. →, ), then the algorithm must end at block 8 (resp. 10, resp. 12). This covers all Motzkin paths of M n (k) (or M n (k)). Then we can bijectively recover the original path ω by following the arrows backwards up to block 1. In fact, all the arrows are reversible, notably because of the induction hypothesis. There is no ambiguity from blocks 9 and 12 (where there are a priori two possible ingoing arrows) because one can only go to block 7 and 9 if k < H. In the contrary case where k = H, one have to go to the right side of the diagram (blocks 17 and 18).

If the image is in G n (k -1), then the algorithms ends either to block 13 or to block 14. Since W n is a bijection from paths with direction vector (B, F, F, . . . , F ) to forward paths in G n (k -1), we can recover the preimage under W n . If this preimage begins by s 1 , then the algorithm actually ended at block 13; if it begins by s 3 , the algorithm ended at block 14. At this point, we can use the above reasoning to go backwards to the root of the decision tree and find ω. Thus, we prove that Ω n,k is a bijection.

When k = 0, Theorem 19 provides a bijection between forward paths and Motzkin paths of bounded amplitude. Go back to Figure 5 for examples: each forward path is put aside its image under Ω 3,0 . Thus, at this point, we have answered Mortimer and Prellberg's open question (Theorem 3). Indeed, starting from a bicolored Motzkin path m (let us say in black and white) of length n and of amplitude bounded by L, we can construct a direction vector W from it: write F for each black step; B for each white step. Then, we compute Ω n,0 (m), which is a forward path. Finally, we use the bijection from Theorem 6 to transform the forward path into a triangular path of direction vector W . ), we deduce that the complexity of Ω n,0 is bounded by an exponential in n. However, we do not know if this bound is tight. Experimentally, we have observed that the complexity of the algorithm has a large standard deviation when the input is randomly chosen: in most cases, the complexity is linear in n (in terms of running time and the number of recursive calls) but sometimes the complexity seems to be quadratic in n.

Many other bijections

In the previous section, we described a bijection between forward paths and Motzkin paths of bounded amplitude. However, the definition being recursive, the computation of an image takes a priori a long time, and its description lacks some clarity. This section proposes a new way to define bijections between forward paths and Motzkin paths. Such bijections will have a double advantage. First, they only require linear time to compute. Second, these bijections are parameterized: each one of them comes with a specific metadata (which we name scaffolding), making them all different.

Profile

We start to define a integer vector for each point of T L : Definition 20 (Profile). Let z = ie 1 + je 2 + ke 3 be any point of T L . The profile of z is the vector (p 0 (z), . . . , p H (z)) where H = L 2 and p 0 (z), . . . , p H (z) is the first half of the coefficients of the polynomial

(1 -x i+1 )(1 -x j+1 )(1 -x k+1 ) (1 -x) 2 = p 0 (z) + p 1 (z)x + • • • + p H (z)x H + • • • + p L+1 (z)x L+1 .
Example 21. Fix L = 5. The profile of any corner of T 5 (that is 5e 1 , 5e 2 or 5e 3 ) is (1, 0, 0) since the corresponding polynomial is (1 -x 6 ) (regardless of the corner). The profile of the point e 1 + e 2 + 3e 3 is (1, 2, 1), which can be found by expanding the polynomial

(1 -x 2 ) 2 (1 -x 4 )/(1 -x) 2 = 1 + 2x + x 2 -x 4 -2x 5 -x 6 .
Note that one can also extend the definition of profile for points ie 1 + je 2 + ke 3 where i = -1 or j = -1 or k = -1. Even if they are not in T L , we can see that the polynomial

(1-x i+1 )(1-x j+1 )(1-x k+1 ) (1-x) 2
is null for such points, so by convention, we can define the profile as the null vector (0, . . . , 0). It will be useful to deal with border cases. The profile of every point z is then illustrated by the cell representation C(z): for every (f, ) ∈ C(z), a square is placed at coordinates ( , f ). 2 For example, as shown by Figure 13, the cell representation of e 1 + e 2 + 3e 3 in T 5 (whose profile is (1, 2, 1), as mentioned above) can be represented as three rows of squares: the first (bottom) and the third (top) rows have 1 square each while the central row has 2 squares.

It is not obvious from Definition 20 that we always have p f (z) ≥ 0, and hence that a cell representation of T L exists for every L ∈ N. However a cell representation of T L will be explicitly given by Proposition 31, proving the non-negativity of the components of a profile.

The next lemma establishes some identities about the profile.

Lemma 23. Let z be in T L . Then for i ∈ {1, . . . , H -1}, the identities

p i (z + s 1 ) + p i (z + s 2 ) + p i (z + s 3 ) = p i-1 (z) + p i (z) + p i+1 (z), (3)
p 0 (z + s 1 ) + p 0 (z + s 2 ) + p 0 (z + s 3 ) = p 0 (z) + p 1 (z), (4)
p H (z + s 1 ) + p H (z + s 2 ) + p H (z + s 3 ) = p H (z) + p H-1 (z) if L is odd p H-1 (z) if L is even , (5) hold.
Proof. For z = ie 1 + je 2 + ke 3 ∈ T L , let P ol z (x) be the polynomial of Definition 20, that is

P ol z (x) = (1 -x i+1 )(1 -x j+1 )(1 -x k+1 ) (1 -x) 2 .
We also extend for any integer i the definition of p i (z) as the coefficient of x i in P ol z (x).

By an inelegant but simple expansion, one can check the identity

P ol z+s 1 (x) + P ol z+s 2 (x) + P ol z+s 3 (x) = x + 1 + 1 x P ol z (x) + x L+2 - 1 x .
Extracting the coefficient of x i in the above equality for i ∈ {0, . . . , H} straightforwardly gives

p i (z + s 1 ) + p i (z + s 2 ) + p i (z + s 3 ) = p i-1 (z) + p i (z) + p i+1 (z),
which proves (3). The equality (4) comes from the fact that p -1 (z) = 0.

Concerning i = H, we remark that

x L+1 P ol z (1/x) = -P ol z (x),
and hence p L+1-j (z) = -p j (z) for every integer j. In particular, if L = 2H + 1, then for j = H + 1, we have p H+1 (z) = -p H+1 (z) and so p H+1 (z) = 0. Equality ( 5) is then obtained by substituting i = H and p i+1 = 0 in (3). As for L = 2H even, set j = H, and get p H+1 (z) = -p H (z), which implies that only the term p H-1 (z) does not disappear in the right-hand side of the equality.

Thus, Proposition 17 is naturally extended to any point of T L (not only the ones on the border).

Theorem 24. Let z be any point of T L and (p 0 (z), . . . , p H (z)) be the profile of z. Let us denote f n (z) the number of forward paths in T L starting from z. We have

f n (z) = H i=0 p i (z)m n (i),
where m n (i) is the number of Motzkin meanders of length n starting at height i and having an amplitude bounded by L.

Proof. We only do the proof for the odd case, since the even case is very similar. We proceed to an induction on n.

For n = 0, we have p 0 (z) = 1 since it is the constant term in the polynomial

(1-x i+1 )(1-x j+1 )(1-x k+1 ) (1-x) 2
. Moreover, m 0 (i) is equal to 0 if i > 0, and m 0 (0) = 1. We consistently find f 0 (z) = 1.

Let us assume that the equality holds for a given n and for every z ∈ T L . We have

f n+1 (z) = f n (z + s 1 ) + f n (z + s 2 ) + f n (z + s 3 ) = H i=0 (p i (z + s 1 ) + p i (z + s 2 ) + p i (z + s 3 )) m n (i) by induction, = H-1 i=1 (p i-1 (z) + p i (z) + p i+1 (z)) m n (i) + (p 0 (z) + p 1 (z))m n (0) + (p H-1 (z) + p H (z))m n (H) by Lemma 23.
Collecting terms with respect to p i (z), we get

f n+1 (z) = p 0 (z) (m n (0) + m n (1)) + H-1 j=1 p j (z) (m n (j -1) + m n (j) + m n (j + 1)) + p H (z) (m n (H -1) + m n (H)) , which reads f n+1 (z) = H j=0 p j (H)m n+1 (j).
Let us explain why Proposition 17 is a special case of the previous theorem. Given a point of the border O + s 1 = s 1 e 1 + (L -)e 3 with ≤ H = L/2 , the associated polynomial is

(1 -x +1 )(1 -x L-+1 ) 1 -x = 1 + x + • • • + x (1 -x L-+1 ).
But since ≤ H, we have L -+ 1 > H. So the profile of O + s 1 follows the expansion of 1 + x + • • • + x . In other words,

p i (O + s 1 ) = 1 if i ≤ 0 otherwise .
We thus recover the formula f n (O + s 1 ) = i=0 m n (i).

Scaffoldings and new bijections

In order to illustrate the following definition, we begin this subsection by explaining the idea behind the bijection we are going to present next.

By Theorem 24, we know there should be a bijection between the set of triangular paths starting at z ∈ T L and the set of triplets (m, c) where m is a Motzkin meander of → Figure 14. A zoom on a scaffolding -more specifically it depicts the function s → δ e 1 +e 2 +3e 3 ((1, 2), s).

bounded amplitude and c is a cell in the cell representation of z such that h(c) is the starting height of m. For the sake of example, let us choose L = 5, z = e 1 + e 2 + 3e 3 , c = (f, ) = (1, 2). It corresponds to a specific cell of the profile of z, which is highlighted in Figure 14.

We now consider a Motzkin path m which we wish to transform into a triangular path starting at z, in a recursive manner. This transformation will depend on the cell we have chosen (here (1, 2)). At this point there are naturally three possibilities: m begins by , by →, or by . The idea is then to map these three possibilities to three other cells located in the profiles of the neighbors of z. The f -coordinates of these cells must be respectively 2, 1 and 0. We then use a recursion, which now depends on the new cell, to find the desired triangular path.

Of course there are several choices for these new cells. For example, if m begins by , we have 3 choices: there are 2 cells in the top floor of z + s 1 , 1 cell in the top floor of z + s 2 , and 0 cell in the top floor of z + s 3 . Following Figure 14, we choose the cell (2, 2) from the cell representation of z + s 1 . The triangular path we would like to output will begin by s 1 (because the chosen cell is in the profile of z + s 1 ), and the rest will be computed by recursion.

A scaffolding is precisely the data which dictates the choice of the new cells for the whole lattice. More precisely, it indicates in which cell we have to go when we consider a specific cell in some profile, and a particular step in { , →, }.

Definition 25 (Scaffolding). Let us fix L the size of the triangular lattice, and let H be L/2 . For a height f ∈ {0, . . . , H}, we say that a step s ∈ { , →, } is an allowed step from height f if it is a possible step from height f in a Motzkin meander. Precisely, the only restrictions are that (f, s) cannot be equal to (0, ) nor (H, ), and furthermore, if L is even, (f, s) cannot be equal to (H, →).

For z ∈ T L , we define the set

A(z) := {(c, s) ∈ C(z) × { , →, } : s is an allowed step from h(c)},
where C(z) is the cell representation of z (see Definition 22). For i ∈ {1, 2, 3}, we also introduce the notation

C i (z) := {(s i , c) : c ∈ C(z)}.
The set C i (z) is thus a subset of F × C(z), having same cardinality as C(z), since all the elements of C i (z) have the same first coordinate s i .

A scaffolding is a collection of functions (δ z ) z∈T L , such that for each z ∈ T L , the function

δ z : A(z) → C 1 (z + s 1 ) ∪ C 2 (z + s 2 ) ∪ C 3 (z + s 3 )
is a bijection. Furthermore, for every (c, s) ∈ A(z) with (σ, c ) = δ z (c, s), we have the restriction

h(c ) =    h(c) + 1 if s = h(c) if s =→ h(c) -1 if s = .
An entire scaffolding is shown by Figure 25.

Proposition 26. For any L ≥ 0, there exists a scaffolding.

Proof. Let us consider any point z of T L , and let f be an integer in {0, . . . , H}.

Consider the sets

U f (z) := {(c, ) ∈ A(z) : h(c) = f -1}, F f (z) := {(c, →) ∈ A(z) : h(c) = f }, D f (z) := {(c, ) ∈ A(z) : h(c) = f + 1}, C i,f (z) := {(s i , c ) ∈ C i (z) : h(c ) = f } for i ∈ {1, 2, 3}.
By Lemma 23, we have

U f (z) ∪ F f (z) ∪ D f (z) = C 1,f (z + s 1 ) ∪ C 2,f (z + s 2 ) ∪ C 3,f (z + s 3 ) .
We can then choose any bijection b f between these two sets and define δ z (c, s) for every (c, s)

∈ U f (z) ∪ F f (z) ∪ D f (z) as b f (c, s).
Doing so for every f ∈ {0, . . . , H} enables to cover every pair (c, s) ∈ A(z), and thus successfully define δ z on the set of such triplets.

The required bijectivity of δ z is straightforward (because b f is also bijective).

Once we fix a scaffolding for our triangular lattice, one can describe a bijection between triangular paths and Motzkin paths. The bijection is given by Algorithms 2 and 3. Algorithm 2: Bijection from Motzkin paths to triangular paths, given a scaffolding (δ z ) z∈T L (for scaffolding, see Definition 25). metadata : a s c a f f o l d i n g δ z input : a Motzkin path m output : a t r i a n g u l a r path p s t a r t i n g a t O n ← l e n g t h o f m; p ← empty path ; z ← O ; c ← unique c e l l o f h e i g h t 0 in t h e c e l l r e p r e s e n t a t i o n o f z ;

if s = if s =→ if s =
for i from 1 to n do ( σ , c ) ← δ z ( c , m[ i ] ) ;
add σ to t h e end o f p ; z ← z + σ ; return p ; input : a t r i a n g u l a r path p s t a r t i n g a t O output : a Motzkin path m n ← l e n g t h o f p ; m ← empty path ; z ← O + n i=1 p [ i ] ; c ← unique c e l l o f h e i g h t 0 in t h e c e l l r e p r e s e n t a t i o n o f z ;

for i decreasing from n to 1 do ( c , s ) ← δ -1 z ( p [ i ] , c ) ; add s to t h e b e g i n n i n g o f m; z ← z -p [ i ] ; return m;
Theorem 27. Let (δ z ) z∈T L be a scaffolding. Algorithms 2 and 3 give two inverse bijections between the set of Motzkin paths of length n with bounded amplitude L and the set of triangular paths of T L of length n starting at O. Proof. At the end of Algorithm 2, note that the height of the ending cell is 0, since variable f keeps track of the height of the input Motzkin path (because of the last restriction of Definition 25) and a Motzkin path always ends at height 0. Moreover, because the polynomial (1 2 always has a constant term equal to 1, by Definition 20, we have p 0 (z) = 1 for every z ∈ T L . But is always between 1 and p f (z), so at the end of Algorithm 2, must be 1.

-x i+1 )(1 -x j+1 )(1 -x k+1 )/(1 -x)
Thus, the values of z and c are the same at the end of Algorithm 2 and at the beginning of Algorithm 3. From this point, it is easy to see that the loop of Algorithm 3 reverses what the loop of Algorithm 2 did. Therefore the two algorithms are mutual inverse bijections.

Remark 28. If we omit the cost of a precalculation (which is the construction of a scaffolding which can be made in O(L 4 ) time), both algorithms have a linear-time complexity.

The scaffolding bijection of Subsection 4.4 does not require any precalculation (which can be costly if L is large) and it still has a linear-time complexity.

Remark 29. If two Motzkin paths m and m share a common prefix of length j, then the two corresponding triangular paths under Algorithm 2 will also share a common prefix of length j. The converse is not true. This property is not shared by the exponential bijection of Figure 12. This is why this bijection is not a particular case of the scaffolding bijections.

Remark 30. No scaffolding is necessary if we wish to sample a random forward path under the uniform distribution, given a uniform random Motzkin path of bounded amplitude.

Indeed, since any scaffolding is suitable to have a bijection, one can pick this scaffolding at random, on the fly. To do so, at each step of the loop in Algorithm 2, we choose δ z (c, m[i]) as one of the cells with height h belonging to C(z

+ s 1 ) ∪ C(z + s 2 ) ∪ C(z + s 3 ), where h = h(c) + 1 if m[i] = , h = h(c) if m[i] =→, or h = h(c) -1 if m[i] = .
This choice must be uniform among all cells of height h .

Two direct bijective proofs of Mortimer and Prellberg's theorem

We mention two ways to extend this to a bijection between bounded Motzkin paths with bicolored (black and white) edges and triangular paths (potentially including forward and backward steps), which provides a direct combinatorial interpretation of Theorem 3.

The first method is as mentioned at the end of Section 3: Starting with a bicolored Motzkin path, use the scaffolding bijection above to send the Motzkin path to a forward path, and map the colors to a direction vector based on the order in which they appear (black → F and white → B). Then, using the bijection of Theorem 6, send the forward path to a path with that direction vector. For the second method we start by defining a reverse scaffolding

f + = x 1 + x 2 f = = min{x 1 , x 2 } = 0 f = + x
δ z : A(z) → C 1 (z + s 1 ) ∪ C 2 (z + s 2 ) ∪ C 3 (z + s 3 ),
where each C i (z) is defined by

C i (z) := {(s i , c) : c ∈ C(z)}.
We define δ z symmetrically to δ z reflected about the midline of T L passing though O = x 3 e 3 . To be precise, if z = x 1 e 1 + x 2 e 2 + x 3 e 3 , let z = x 2 e 1 + x 1 e 2 + x 3 e 3 and δ z (a) = (s j , c). Then we define δ z (a) := (s 4-j , c). This is possible because the cell representation of z is necessarily the same as that of z. The bijection then runs as follows: starting with a bicolored Motzkin path, we apply the scaffolding δ z when there is a black step, and we apply the reverse scaffolding δ z when there is a white step. An advantage of that second version is that it takes linear time to apply.

A canonical scaffolding in terms of colored trapeziums

In this section we provide an explicit scaffolding which yields a bijection between bounded Motzkin paths and triangular paths which takes linear time to compute (it does not depend on L). First we define a new cell representation for T L .

Proposition 31. For every z ∈ T L , the set

C(z) := (f, ) ∈ Z 2 | max(0, f -x 3 ) ≤ ≤ min(f, x 1 , x 2 , x 1 + x 2 -f ) is a cell representation of z (see Definition 22).
C(z) C(z) C(z) C(z + s 3 ) C(z + s 2 ) C(z + s 1 )
Figure 19. A geometric depiction of the bijection δ z in the case x 1 = 8, x 2 = 13, L = 37. On the left, there are three copies of of C(z) while on the right we have C(s 1 + z), C(s 2 + z) or C(s 3 + z). Each case in Figure 18 is represented by a colored zone with labels matching the numbers shown in Figure 18. Cells for which the given step is not allowed are colored in red. The grey polygon on each of the cell representations is the outline of C(z) (equivalently, the pentagon delimited by the lines = 0, f = , = 8, f + = 21 and f = + 16).

Finally it remains to define a scaffolding where we recall that A(z) and C i (z) are defined by

δ z : A(z) → C 1 (z + s 1 ) ∪ C 2 (z + s 2 ) ∪ C 3 (z + s 3 ),
A(z) := {(c, s) ∈ C(z) × { , →, } : s is an allowed step from h(c)}. C i (z) := {(s i , c) : c ∈ C(z)}.
We define δ z by the procedure shown in Figure 18. Under this procedure there are 12 different cases, shown by the colored boxes labeled from 1 to 12.

In the following theorem we show that this is indeed a bijection. We give a geometric interpretation of this bijection in two specific cases in Figures 19 and20.

Theorem 32. For each z ∈ T L , the function δ z defined by the procedure in Figure 18 is a bijection from A(z) to C 1 (z + s 1 ) ∪ C 2 (z + s 2 ) ∪ C 3 (z + s 3 ).

Proof. To see that this is a bijection, is suffices to show that each element of C 1 (z + s 1 ) ∪ C 2 (z + s 2 ) ∪ C 3 (z + s 3 ) is covered exactly once by δ z .

First, we claim that C 1 (z + s 1 ) is covered by cases 2, 3, 8, 9 and 11. Note that

C(z +s 1 ) = {(f , ) ∈ Z 2 | max(0, f -x 3 + 1) ≤ ≤ min(f , 1 +x 1 , x 2 , 1 +x 1 +x 2 -f )}.
In particular, the pairs (f , ) ∈ C(z + s 1 ) covered by each of the five cases are those satisfying the following:

• Case 2: = 1 + x 1 + x 2 -f = 0. • Case 3: = 0 = 1 + x 1 + x 2 -f (this case only occurs if x 1 + x 2 ≤ x 3 i.e., 2(x 1 + x 2 ) ≤ L ). • Case 8: ≤ x 1 and < x 1 + x 2 -f . • Case 9: ≤ x 1 and = x 1 + x 2 -f . • Case 11: = x 1 + 1 ≤ x 1 + x 2 -f (this case only occurs for x 1 < x 2 ).
Next, we show that the set C 2 (z + s 2 ) is covered by cases 1, 4, 5, 7 and 10. We have

C(z + s 2 ) = {(f , ) ∈ Z 2 | max(0, f -x 3 ) ≤ ≤ min(f , x 1 -1, x 2 + 1, x 1 + x 2 -f )}.
In particular, the pairs ( , f ) ∈ C(z + s 2 ) covered by each of the five cases are those satisfying the following:

• Case 1: f = x 1 and = x 2 (this case only occurs if x 2 ≤ x 1 -1).

• Case 4: = x 1 + x 2 -f ≤ x 2 -1.
• Case 5: = x 2 + 1 (this case only occurs if

x 2 + 1 ≤ x 1 -1). • Case 7: = f ≤ x 2 -1. • Case 10: ≤ x 1 + x 2 -f -1, x 2 , f -1 or = f = x 2 (
the latter case only occurs for x 2 ≤ x 1 -1).

Finally, we show that the set C 3 (z + s 3 ) is covered by cases 6 and 12. Note that

C(z + s 3 ) = {(f , ) ∈ Z 2 | max(0, f -x 3 -1) ≤ ≤ min(f , x 1 , x 2 -1, x 1 + x 2 -1 -f ).
In particular, the pairs (f , ) ∈ C(z + s 3 ) covered by each of the five cases are those satisfying the following:

• Case 6: ≤ f -1.
• Case 12: = f . We thus have dealt with every element of C 1 (z + s 1 ) ∪ C 2 (z + s 2 ) ∪ C 3 (z + s 3 ).

Note that the rules in the definition of δ z only depend on x 1 , x 2 , f and , but not L. As a consequence, this bijection can be applied to any Motzkin path to yield a path in the 1/6-plane, and if L is the minimum sidelength of a triangle containing the resulting path then L is the amplitude of the Motzkin path.

Generalization to further dimension

This section explains to what extent the results of the previous sections can be generalized. In fact, there is a natural extension of triangular paths to higher dimension (already introduced by [START_REF] Paul | On the number of walks in a triangular domain[END_REF]) for which there still exists a bijective correspondence between forward and backward paths. More surprisingly, we can find in dimension 3 a new bijection between two families of lattice walks, which is an analogue of the bijection between triangular paths and Motzkin path of bounded amplitude.

What can be extended in any dimension

5.1.1. Definition. For dimension d, let (e 1 , e 2 , e 3 , . . . , e d+1 ) denote the standard basis of R d+1 . For some L ∈ N, we define the subset S d,L of N d+1 as the simplicial section of side length L of the integer lattice:

S d,L = {x 1 e 1 + • • • + x d+1 e d+1 : x 1 , . . . , x d+1 ∈ N, x 1 + • • • + x d+1 = L}.
We will consider walks in this simplex using forward steps s j = e j -e j-1 for 1 ≤ j ≤ d+1 (with the convention that s 0 = s d+1 ) and backward steps -s j . Paths of S d,L only using forward steps are again called forward paths. The origin of S d,L , denoted O, is defined as Le d+1 . The triangular lattice T L can be recovered by setting d = 2 -in other words

T L = S 2,L .
As in the triangle case, forward paths of S d,L starting from O form a subfamily of Standard Young Tableaux. Precisely, they are in bijection with standard Young tableaux with d rows or less with an extra restriction: for i > L, if there is a cell with label at position i in the top row of the Young tableau, then there is a cell at position i -L in the bottom row of the Young tableau with a label less than . The enumeration of standard Young tableaux with a bounded number of rows is the object of a very active research -see [START_REF] Mishna | On Standard Young Tableaux of Bounded Height[END_REF] for a survey. 5.1.2. Equinumeracy of forward and backward paths. Defining direction vector as in Definition 5, the equivalent of Theorem 6 still holds: Theorem 33. Given two sequences W and W of {F, B} n , the set of paths in S d,L of direction vector W are in bijection with the set of pyramid paths of direction vector W .

We can use the same proof almost verbatim. In fact, the bijection uses swap flips, defined exactly as in Definition 10:

(s j , s k ) ←→ (s k , s j ) if j = k, (s k , s k ) ←→ (s k-1 , s k-1 ) otherwise.
where, by convention, s 0 = s d+1 .

Dimension 3

It turns out that forward paths in dimension 3 are equinumerous with another family of paths, as in the two dimensional case. We will show this inductively, then give a bijection analogous to those in Section 4.

In dimension 3, the set By reducing the dimension of the recurrence using the bijection between forward and backward paths, we find a family of paths in bijection with pyramidal walks: Theorem 34. Define the waffle W L of size L by 21 (right) for a picture). For (i, j) ∈ W L , the number w n,i,j of square lattice walks in W L , starting at (i, j) and ending on the y-axis is given by w n,i,j = p n,i,j -p n,i-1,j-1 , where p n,i,j is the number of forward (or equally backward) pyramid paths of length n starting at the point (i -j)e 1 + je 2 + (L -i)e 4 .

W L = {(i, j) ∈ N : j ≤ i ≤ L -j} (see Figure
Proof. We prove this using an inductive approach. We define q n,i,j to be the number of such paths starting at the point (i -j)e 1 + je 2 + e 3 + (L -i -1)e 4 (this is 0 if the starting point is outside the region).

Considering the first step in a forwards path of length n + 1 starting at (i -j)e 1 + je 2 + (L -i)e 4 yields the following equation for n, i, j ≥ 0 satisfying i ≤ j ≤ L: p n+1,i,j = p n,i+1,j + p n,i,j+1 + q n,i-1,j-1 .

Using the same method for backward paths yields p n+1,i,j = p n,i-1,j + p n,i,j-1 + q n,i,j .

Canceling the q terms, we obtain the following equation as long as 1 ≤ j ≤ i ≤ L:

p n+1,i,j -p n+1,i-1,j-1 = p n,i+1,j + p n,i,j+1 -p n,i-2,j-1 -p n,i-1,j-2 .
Finally, writing w n,i,j := p n,i,j -p n,i-1,j-1 , we have the following recurrence for w: w n+1,i,j = w n,i+1,j + w n,i,j-1 + w n,i,j+1 + w n,i-1,j , which has only positive coefficients. By analysing this equation on the boundary, we deduce that it holds for 0 ≤ j ≤ i ≤ L + 1, if we define w n,i,j = 0 for i, j outside this region. Finally the initial condition for w 0,i,j follows from p 0,i,j = 1 for 0 ≤ j ≤ i ≤ L:

w 0,i,j = 0, for 1 ≤ j ≤ i ≤ L, w 0,i,0 = 1, for 0 ≤ i ≤ L, w 0,L+1,j = -1, for 1 ≤ j ≤ L + 1, w 0,L+1,0 = 0.
These initial conditions along with the recurrence uniquely define the terms w n,i,j . Now, by symmetry, w n,i,j = -w n,L+1-j,L+1-i , and in particular, w n,i,L+1-i = 0, so we only need to consider the region i + j ≤ L. Within this region, all terms are positive, so w n,i,j can be understood combinatorially. The combinatorial interpretation of the recurrence is precisely the statement of the theorem: w n,i,j is the number of square lattice walks starting at (i, j) and ending on the y-axis, which are confined to the region

W L = {(i, j) ∈ N : i ≤ j ≤ L -i}.
In particular, p n,0,0 = w n,0,0 .

Remark 35. If we apply the transformation (x, y) → (x -y, y) to waffle walks, we remark that pyramidal walks starting at O are in bijection with Gouyou-Beauchamps walks, i.e. walks with North-West, West, East, South-East steps, going from (0, 0) to a point on the x-axis and confined in the part of the positive quarter of plane below the line x + 2y = L. This is consistent with the fact that standard Young tableaux with 4 rows or less are in bijection with Gouyou-Beauchamps walks returning to the x-axis confined in the quarter of plane [START_REF] Gouyou-Beauchamps | Standard young tableaux of height 4 and 5[END_REF].

More generally, the following proposition relates the enumeration of pyramid walks starting at any point to waffle walks.

Proposition 36. The number p n (z) of length n pyramid walks starting at a point z = x 1 e 1 + x 2 e 2 + x 3 e 3 + x 4 e 4 is equal to the number of length n waffle walks starting at a point in the set W (z), defined by W (z) := {(x 1 + x 3 + p -q, p + q) : p, q ∈ N, p ≤ min(x 2 , x 4 ), q ≤ min(x 1 , x 3 )}.

C(z)

W (z)

m i n ( x 2 , x 4 ) + 1 m i n ( x 1 , x 3 ) + 1 min(x 2 , x 4 ) + 1 min(x 1 , x 3 ) + 1
Figure 22. The sets C(z) and W (z) for z = 4e 1 + e 2 + 3e 3 + 4e 4 . Now, we will give a bijective proof of this. The proof is via a scaffolding, analogous to Definition 25. Again, before we define scaffolding we define the profile of a point.

Definition 37 (Profile). For a point z = x 1 e 1 + x 2 e 2 + x 3 e 3 + x 4 e 4 , we define the profile C(z) of z by

C(z) := {(p, q) ∈ N 2 : p ≤ min(x 2 , x 4 ), q ≤ min(x 1 , x 3 )}.
We have a natural bijection h z : C(z) → W (z) defined by h z (p, q) := (x 1 +x 3 +p-q, p+q).

For z ∈ S 3,L , we define the set A(z) := {(c, s) ∈ C(z) × {↑, →, ↓, ←} : s is an allowed step from h z (c)}.

For i ∈ {1, 2, 3, 4}, we also introduce the notation

C i (z) := {(s i , c) : c ∈ C(z)}.
The set C i (z) is thus a subset of F × C(z), having same cardinality as C(z), since all the elements of C i (z) have the same first coordinate s i .

Definition 38 (Scaffolding). Let us fix the size L of the pyramid. A scaffolding is a collection of functions (δ z ) z∈S 3,L , such that for each z ∈ S 3,L , the function

δ z : A(z) → C 1 (z + s 1 ) ∪ C 2 (z + s 2 ) ∪ C 3 (z + s 3 ) ∪ C 4 (z + s 4 )
is a bijection and whenever δ z (c, s) = (s j , c j ), we have h z (c) + s = h z+s j (c j ). Figure 23 shows an example of the sets W (z) and C(z).

An explicit scaffolding δ z is given in Figure 23. The proof of the bijectivity of δ z is omitted (because of its tediousness -it is a case-by-case proof, similar to the one of Theorem 32), but some particular configuration is illustrated by Figure 24.

Given such a scaffolding, a bijection for each point z c ∈ S 3,L from the set of waffle walks starting at a point in the set W (z c ) to the set of pyramid walks starting at z c is given by Algorithm 4. Corollary 39. The generating function

P (t) = ∞ t=0
p n,0,0 t n for pyramid walks starting in a corner is given by

P (t) = 1 (L + 4) 2 L+4 1≤j<k≤L+3 2 j,k (α k + α -k -α j -α -j ) 2 (2 + α j + α -j )(2 + α -k + α k ) 1 -(α j + α -j + α k + α -k )t ,
where α = e iπ L+4 .

Proof. To prove this, we relate walks confined to the waffle to unconfined walks using the reflection principle [START_REF] Ira | Random walk in a weyl chamber[END_REF], which is possible because the waffle W L forms a Weyl chamber of some reflection group.

Let (x, y) be a point inside the waffle, let Ω be the set of unconstrained square lattice walks starting at (x, y) and let Ω be the set of walks in the waffle starting at (x, y). Let 1 , 2 and 3 be the lines just outside the boundary of W L , defined by y = -1, y -x = -1 and x + y = L + 1 respectively. We consider the involution f : Ω \ Ω → Ω \ Ω defined by reflecting the section of the walk after its first intersection with one of the lines 1 , Then the involution f sends walks in Ω \ Ω ending at a point in A L to walks ending at a point in B L and vice-versa. The only walks in Ω ending at a point in A L (or B L ) are those ending at (0, 0). Hence the number of waffle walks of a given length from (x, y) to (0, 0) is equal to the number of (uncontrained) walks of the same length from (x, y) to a point in A L minus the number of such walks from (x, y) to a point in B L . By shifting the starting point, this is the number of walks from a point in {(x, y), (x + 1, y + 3), (x + 4, y + 2), (x + 3, y -1)} to a point in T L minus the number of walks from a point in {(x + 1, y -1), (x, y + 2), (x + 3, y + 3), (x + 4, y)} to a point in T L . These numbers can easily be computed using the generating function for unconstrained walks, and doing so yields the formula in the statement of the theorem. As an example, we show how to compute the generating function for walks from (x, y) to a point in T L counted by length.

Let F (t, a, b) be the generating function for walks starting at (x, y) with walks of length n ending at (x 1 , y 1 ) contributing a x 1 b y 1 t n . We want to sum the coefficients where the powers x 1 and y 1 of a and b are both multiples of 2L + 8 or both L + 4 more than multiples of 2L + 8. For those where both x 1 and y 1 are multiples of 2L + 8, This is achieved by setting α = e iπ L+4 , and writing the sum 1 (2L + 8) 2 1≤j,k≤2L+7 F (t, α j , α k ), as the contribution to this sum from a monomial a x 1 b y 1 t n is

t n   1 2L + 8 1≤j≤2L+7 α x 1 j     1 2L + 8 1≤k≤2L+7 α y 1 k   ,
which is 0 unless x 1 and y 1 are both multiples of 2L + 8, in which case it is t n . Similarly, the generating function for the cases where x 1 -L -4 and y 1 -L -4 are multiples of 2L + 8 is 1 (2L + 8) 2 1≤j,k≤2L+7 (-1) j+k F (t, α j , α k ).

Similarly, one can write expressions for the generating function of walks from any given point to a point in T L . Adding and subtracting these as appropriate yields the desired result.

Conclusion

To sum up, we have found several bijections between forward triangular walks and Motzkin path with bounded amplitude, answering thus Mortimer and Prellberg's open question [START_REF] Paul | On the number of walks in a triangular domain[END_REF]. There were some interesting consequences from this discovery. First, by looking for a bijection, we discovered an unexpected symmetry property between forward and backward paths (Theorem 6). Second, we refined Mortimer and Prellberg's results by considering triangular walks starting not only at the origin, but at any point in the triangle (Theorem 24). Finally, by mimicking the proof of the first sections, we managed to extend some of our results to larger dimensions. In particular, we discovered a new bijective correspondence in dimension 3 (Theorem 34), enabling in the process to find an expression for the generating function of pyramid walks (Corollary 39), which was also an open question in Mortimer and Prellberg's paper. However, we still do not know if there exists a bijection between triangular walks in dimension d ≥ 4 and some class of walks in dimension d -1. It seems like our two-and three-dimensional argument (more precisely, the one in the proofs of Proposition 17 and Theorem 34) does not work anymore. We leave the question of Mortimer and Prellberg about the enumeration of triangular walks in higher dimension as an open question.

There is another conjecture from a different paper that may relate to this current work: the three authors of [START_REF] Bousquet-Mélou | Plane bipolar orientations and quadrant walks[END_REF] conjecture that there exists a length-preserving involution on double-tandem walks that exchanges x start -x min and y end -y min , while preserving y start -y min and x end -x min (point (x start , y start ) denotes the starting point, and x min and y min are respectively the minimal x-and y-coordinates during the walk). It may be interesting to see if techniques of Section 2 facilitate the discovery of this involution.

Finally, this paper shows two examples of bijections where there is a trade-off between domain and endpoint constraints:

• The one between triangular paths and Motzkin paths transform two-dimensional walks with no constraint on the endpoint into one-dimensional walks which must finish at the origin; • the one between pyramid paths and waffle walks transform three-dimensional walks with no constraint on the endpoint into two-dimensional walks which must end on one of the axis. This is somehow reminiscent of [START_REF] Sergi Elizalde | Bijections for pairs of non-crossing lattice paths and walks in the plane[END_REF][START_REF] Courtiel | Bijections for weyl chamber walks ending on an axis, using arc diagrams and schnyder woods[END_REF]. We wonder whether there are some other examples of this phenomenon, or even a generic framework for such bijections.

3 OFigure 1 .

 31 Figure 1. Left. The triangular lattice T 3 . Right. The planar representation of the same lattice, with F and B.

Figure 2 .

 2 Figure 2. All triangular paths of T 3 with length 2 starting at O.

Figure 3

 3 Figure 3. Equivalent definitions of the same object: forward paths of T 3 (left); tandem walks in the positive quarter of plane and below the antidiagonal x + y = 3 (middle); standard Young tableaux with three rows or less such that the label of the ith cell of the bottom row must be less than the label of (i + 3)th cell of the top row (right).

Figure 4 .

 4 Figure 4. Motzkin paths of length 4 sorted with respect to their amplitude (from 1 to 4)

Figure 5 .

 5 Figure 5. Equinumeracy between forward paths of T 3 with length 4 starting at O and Motzkin paths with amplitude bounded by 3.

Figure 6 .

 6 Figure 6. All paths of length 2 returning to their starting point.

Figure 10 .

 10 Figure 10. Left. 8 forward paths of length 3 starting from O + s 1 in T 3 . Right. 8 Motzkin meander of length 3 and amplitude bounded by L = 3: four of them begin at height 0, the remaining four begin at height 1.

1 orDecompose ω = ω 1 ω where ω 1

 11 Output Ω n,k (ω)A Motzkin meander of length n starting at height k A forward path of length n starting at O + (k -1)s is the first step

A forward path ω of length n starting at O + ks 1 1Figure 12 .

 112 Figure 12. Algorithm computing Ω n,k (ω) where ω is a path of length n starting at O + ks 1

Finally, let us

  discuss about the complexity of the algorithm. If c(n, k) denotes the worst-case complexity of Ω n,k , then we can derive from Figure 12 the (rough) upper bound c(n, k) ≤ c(n -1, k + 1) + c(n -1, k) + c(n -1, k -1) + n 2 . (The n 2 term reflects the complexity of the function W n-1 appearing in block 15.) Then, by a simple induction, one can see that c(n, k) ≤ m n (k) + O(n 3 ) where m n (k) is the number of Motzkin meanders of length n starting at height k and having amplitude bounded by L. Since m n (0) is O(3 n

Figure 13 .

 13 Figure 13. A cell representation of T 5 . The enlighten zone corresponds to point e 1 + e 2 + 3e 3 .

Figure 15 .

 15 Figure 15. A random scaffolding for T 3 .

Algorithm 3 :Figure 16 .

 316 Figure 16. The Motzkin paths and the triangular paths of length 3 in correspondence under Algorithms 2 and 3, given the scaffolding of Figure 15.

3 fFigure 17 .

 317 Figure 17. Left. The shape of the cell representation from Proposition 31 of a point x 1 e 1 + x 2 e 2 + x 3 e 3 . Right. The associated cell representation of T 5 .

Figure 20 .

 20 Figure20. The bijection δ z in the case x 1 = 13, x 2 = 7, L = 36. In comparaison with Figure19, this decomposition features the case where L is even, but most importantly, the case where x 1 > x 2 + 1.

Figure 21 .

 21 Figure 21. Left. The Pyramid S 3,3 . Right. The waffle W 12 .

S 3 ,

 3 L = {x 1 e 1 + x 2 e 2 + x 3 e 3 + x 4 e 4 : x 1 , x 2 , x 3 , x 4 ∈ N, x 1 + x 2 + x 3 + x 4 = L} is a pyramidal lattice, as shown by Figure 21 (left). We denote by F the set of forward steps, i.e., F = {e 1 -e 4 , e 2 -e 1 , e 3 -e 2 , e 4 -e 3 }, and we denote by B the set of backward steps, i.e., B = -F. A pyramidal walk is a walk in S 3,L using steps in F ∪ B.

Figure 24 .

 24 Figure 24. A geometric representation of δ z for x 1 = 8, x 2 = 4, x 3 = 6 and x 4 = 7. The numbers of the colored zones match with cases of the diagram of Figure 23.

2 and 3

 3 in that line. Now, defineT L := ((2L + 8)Z) × ((2L + 8)Z) ∪ (L + 4 + (2L + 8)Z) × (L + 4 + (2L + 8)Z) A L := T L ∪ ((-1, -3) + T L ) ∪ ((-4, -2) + T L ) ∪ ((-3, 1) + T L ) B L := ((-1, 1) + T L ) ∪ ((0, -2) + T L ) ∪ ((-3, -3) + T L ) ∪ ((-4, 0) + T L ) .

Usually a meander is defined as a prefix, but up to a vertical symmetry, it is equivalent.

We swap the two coordinates so that f (which stands for floor ) corresponds to the height of a cell, consistent with the fact that f represents the height in a Motzkin path.

Thanks JC was supported by the "CNRS projet JCJC " named ASTEC. AEP was supported by the European Research Council (ERC) in the European Union's Horizon 2020 research and innovation programme, under the Grant Agreement No. 759702. The authors 1 2

BIJECTIONS BETWEEN TRIANGULAR WALKS AND MOTZKIN PATHS

want also to thank the sponsors of the conference ALEA Young (ANR-MOST MetA-ConC, Normastic, Université de Caen Normandie) without which this collaboration would never have been born.

Input: a pair ((f, ), s) ∈ A(z).

Compare with

Return (s 1 , (f -1, ))

Compare with

Return (s 1 , (f + 1, + 1))

Return (s 1 , (f + 1, )) Proof. Set z = x 1 e 1 + x 2 e 2 + x 3 e 3 , so

can alternatively be written as

For x 3 < x 1 + x 2 , it suffices to remove from C(z) any points (f, ) for which (f, -x 3 -1) belongs to C(z), as this corresponds to multiplying the polynomial by (1 -y x 3 +1 ). This yields the above general formula for C(z).

Examples of the cell representation of Proposition 31 are shown in Figure 17.

Input: a pair ((p, q), s) ∈ A(z).

Return (s 4 , (p, q -1))

Return (s 4 , (p + 1, q -1))

Compare q with x 1 Return (s 3 , (p, q + 1))

Return (s 1 , (p, q + 1)) Algorithm 4: Bijection from waffle paths to pyramid paths, given a scaffolding (δ z ) z∈S 3,L (for scaffolding, see Definition 38). metadata : a s c a f f o l d i n g δ z input : A p o i n t (p c , q c ) ∈ C(z c ) , a w a f f l e path w s t a r t i n g a t h zc (p c , q c ) output : a pyramid path y s t a r t i n g a t z c . n ← l e n g t h o f w ; y ← empty path ; z ← z c ; p ← p c ; q ← q c ; for i from 1 to n do ( σ , p , q ) ← δ z ( f , q , w [ i ] ) ; add σ to t h e end o f y ; z ← z + σ ; return y ;

In the following corollary of Theorem 34, we enumerate pyramidal walks starting at O using the relation p n,0,0 = w n,0,0 , which relates their enumeration to that of waffle walks. This partially answers another open question of Mortimer and Prellberg [START_REF] Paul | On the number of walks in a triangular domain[END_REF]Section 4.1].