# Combinatorics of nondeterministic walks of the Dyck and Motzkin type

This paper introduces nondeterministic walks, a new variant of one-dimensional discrete walks. At each step, a nondeterministic walk draws a random set of steps from a predefined set of sets and explores all possible extensions in parallel. We introduce our new model on Dyck steps with the nondeterministic step set --1, 1, --1, 1 and Motzkin steps with the nondeterministic step set --1, 0, 1, --1, 0, --1, 1, 0, 1, --1, 0, 1. For general lists of step sets and a given length, we express the generating function of nondeterministic walks where at least one of the walks explored in parallel is a bridge (ends at the origin). In the particular cases of Dyck and Motzkin steps, we also compute the asymptotic probability that at least one of those parallel walks is a meander (stays nonnegative) or an excursion (stays nonnegative and ends at the origin). This research is motivated by the study of networks involving encapsulations and decapsulations of protocols. Our results are obtained using generating functions and analytic combinatorics.

## Authors

• 6 publications
• 3 publications
• 7 publications
06/09/2016

### Hypergeometric Expressions for Generating Functions of Walks with Small Steps in the Quarter Plane

We study nearest-neighbors walks on the two-dimensional square lattice, ...
01/24/2020

### Arcsine laws for random walks generated from random permutations with applications to genomics

A classical result for the simple symmetric random walk with 2n steps is...
12/01/2021

### Efficient and Local Parallel Random Walks

Random walks are a fundamental primitive used in many machine learning a...
04/03/2020

### On the Search Efficiency of Parallel Lévy Walks on Z^2

Lévy walk is a popular movement model where an agent repeatedly samples ...
09/15/2017

### Analytic Combinatorics in Several Variables: Effective Asymptotics and Lattice Path Enumeration

The field of analytic combinatorics, which studies the asymptotic behavi...
12/12/2020

### On partially homogeneous nearest-neighbour random walks in the quarter plane and their application in the analysis of two-dimensional queues with limited state-dependency

This work deals with the stationary analysis of two-dimensional partiall...
03/29/2020

### The Search Efficiency of Intermittent Lévy walks Optimally Scales with Target Size

We address the general question of what is the best strategy to employ w...
##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

In recent years lattice paths have received a lot of attention in different fields, such as probability theory, computer science, biology, chemistry, physics, and much more

[11, 9, 5]. One reason for that is their versatility as models like e.g., the up-to-date model of certain polymers in chemistry [16]. In this paper we introduce yet another application: the encapsulation of protocols over networks. To achieve this goal we generalize the class of lattice paths to so called nondeterministic lattice paths.

### 1.1 Definitions

#### Classical walks.

We mostly follow terminology from [2]. Given a set of integers, called the steps, a walk is a sequence of steps . In this paper we will always assume that our walks start at the origin. Its length is the number of its steps, and its endpoint is equal to the sum of the steps . As illustrated in Figure (a)a, a walk can be visualized by its geometric realization. Starting from the origin, the steps are added one by one to the previous endpoints. This gives a sequence of ordinates at discrete time steps, such that and A bridge is a walk with endpoint . A meander is a walk where all points have nonnegative ordinate, i.e., for all . An excursion is a meander with endpoint .

#### Nondeterministic walks.

This paper investigates a new variant of walks, called nondeterministic walks, or N-walks. In our context, this word does not mean “random

”. Instead it is understood in the same sense as for automata and Turing machines. A process is nondeterministic if several branches are explored in parallel, and the process is said to end in an accepting state if one of those branches ends in an accepting state. Let us now give a precise definition of these walks.

[Nondeterministic walks] An N-step is a nonempty set of integers. Given an N-step set , an N-walk is a sequence of N-steps. Its length is equal to the number of its N-steps.

As for classical walks we always assume that they start at the origin and we distinguish different types.

[Types of N-walks] An N-walk and a classical walk are compatible if they have the same length , the same starting point, and for each , the step is included in the N-step, i.e., . An N-bridge (resp. N-meander, resp. N-excursion) is an N-walk compatible with at least one bridge (resp. meander, resp. excursion). Thus, N-excursions are particular cases of N-meanders.

The endpoints of classical walks are central to the analysis. We define their nondeterministic analogues.

[Reachable points] The reachable points of a general N-walk are the endpoints of all walks compatible with it. For N-meanders, the reachable points are defined as the set of endpoints of compatible meanders. In particular, all reachable endpoints of an N-meander are nonnegative. The minimum (resp. maximum) reachable point of an N-walk is denoted by (resp. ). The minimum (resp. maximum) reachable point of an N-meander is denoted by (resp. ). The geometric realization of an N-walk is the sequence, for from to , of its reachable points after steps. Figure 1 illustrates the geometric realization of a walk in ((a)a), of an N-walk in ((b)b), and of the classical meanders compatible with in ((c)c). Note that the walk (highlighted in red) is compatible with the N-walk .

#### Probabilities.

Any set of weights, and in particular any probability distribution on the set of steps or N-steps induces a probability distribution on walks or N-walks. The probability associated to the walk or N-walk

is then the product of the probabilities of its steps or N-steps.

### 1.2 Main results

Our main results are the analysis of the asymptotic number of nondeterministic walks of the Dyck and Motzkin type with step sets and , respectively. The results for the unweighted case where all weights are set equal to one are summarized in Table 1. These results are derived using generating functions and singularity analysis. The reappearing phenomenon is the one of a simple dominating polar singularity arising from the large redundancy in the steps. The type of N-walk only influences the constant or the proportion among all N-walks. The lower order terms are exponentially smaller and of the square root type. These are much more influenced by the types. From a combinatorial point of view, we see a quite different behavior compared with classical paths. In particular, the limit probabilities for a Dyck N-walk of even length to be an N-bridge, an N-meander, or an N-excursion, are , , or , and for Motzkin N-walks , , or .

We also explore general N-steps and prove that the generating function of N-bridges is always algebraic. N-excursions with general N-steps will be investigated in a longer version of this article.

### 1.3 Motivation and related work

Let us start with a vivid motivation of the model using Russian dolls. Suppose we have a set of people arranged in a line. There are three kinds of people. A person of the first kind is only able to put a received doll in a bigger one. A person of the second kind is only able to extract a smaller doll (if any) from a bigger one. If she receives the smallest doll, then she throws it away. Finally, a person of the third kind can either put a doll in a bigger one or extract a smaller doll if any. We want to know if it is possible for the last person to receive the smallest doll after it has been given to the first person and then, consecutively, handed from person to person while performing their respective operations. This is equivalent to asking if a given N-walk with each N-step is an N-excursion, i.e., if the N-walk is compatible with at least one excursion. The probabilistic version of this question is: what is the probability that the last person can receive the smallest doll according to some distribution on the set of people over the three kinds?

#### Networks and encapsulations.

The original motivation of this work comes from networking. In a network, some nodes are able to encapsulate protocols (put a packet of a protocol inside a packet of another one), decapsulate protocols (extract a nested packet from another one), or perform any of these two operations (albeit most nodes are only able to transmit packets as they receive them). Typically, a tunnel is a subpath starting with an encapsulation and ending with the corresponding decapsulation. Tunnels are very useful for achieving several goals in networking (e.g., interoperability: connecting IPv6 networks across IPv4 ones [19]; security and privacy: securing IP connections [18], establishing Virtual Private Networks [17], etc.). Moreover, tunnels can be nested to achieve several goals. Replacing the Russian dolls by packets, it is easy to see that an encapsulation can be modeled by a step and a decapsulation by a , while a passive transmission of a packet is modeled by a step.

Given a network with some nodes that are able to encapsulate or decapsulate protocols, a path from a sender to a receiver is feasible if it allows the latter to retrieve a packet exactly as dispatched by the sender. Computing the shortest feasible path between two nodes is polynomial [12] if cycles are allowed without restriction. In contrast, the problem is -hard if cycles are forbidden or arbitrarily limited. In [12], the algorithms are compared through worst-case complexity analysis and simulation. The simulation methodology for a fixed network topology is to make encapsulation (resp. decapsulation) capabilities available with some probability and observe the processing time of the different algorithms. It would be interesting, for simulation purposes, to generate random networks with a given probability of existence of a feasible path between two nodes. This work is the first step towards achieving this goal, since our results give the probability that any path is feasible (i.e., is a N-excursion) according to a probability distribution of encapsulation and decapsulation capabilities over the nodes.

#### Lattice paths.

Nondeterministic walks naturally connect between lattice paths and branching processes. This is underlined by our usage of many well-established analytic and algebraic tools previously used to study lattice paths. In particular, those are the robustness of D-finite functions with respect to the Hadamard product, and the kernel method [7, 4, 2].

The N-walks are nondeterministic one-dimensional discrete walks. We will see that their generating functions require three variables: one marking the lowest point that can be reached by the N-walk , another one marking the highest point , and the last one marking its length . Hence, they are also closely related to two-dimensional lattice paths, if we interpret as coordinates in the plane.

## 2 Dyck N-walks

The step set of classical Dyck paths is . The N-step set of all nonempty subsets is

 S={{−1},{1},{−1,1}},

and we call the corresponding N-walks Dyck N-walks. To every step we associate a weight or probability , and , respectively.

###### Example 2.1 (Dyck N-walks)

Let us consider the Dyck N-walk The sequence of its reachable points is . There are classical walks compatible with it:

Classical walk Geometric realization
(sequence of steps) (ordinates)

There are two bridges, which happen to be excursions. Thus, is an N-bridge and an N-excursion.

The set of reachable points of a Dyck N-walk or N-meander has the following particular structure.

The reachable points of a Dyck N-walk are where , , and the length of have the same parity. The same result holds for Dyck N-meanders, with and replaced by and (see Definition 1.1).

We define the generating functions , , of Dyck N-walks and Dyck N-meanders as

 ∑Dyck N-walk w (∏s∈wps)xmin(w)ymax(w)t|w|, ∑Dyck N-meander w (∏s∈wps)xmin+(w)ymax+(w)t|w|.

Note that by construction these are power series in with Laurent polynomials in and , as each of the finitely many N-walks of length has a finite minimum and maximum reachable point.

One difference to classical lattice paths is the choice of the catalytic variables and . Here, they encode the minimum and the maximum reachable points, while in classical problems one chooses to keep track of the coordinates of the endpoint, (see [2], for example).

### 2.1 Dyck N-meanders and N-excursions

As a direct corollary of Lemma 2.1, all N-bridges and N-excursions have even length. The total number of Dyck N-bridges and Dyck N-excursions are then, respectively, given by

 [x≤0y≥0t2n]D(x,y;t)andD+(0,1;t),

where the coefficient extraction operator is defined as and the nonpositive part extraction operator is defined as (and analogously for ).

The generating function of Dyck N-meanders is characterized by the relation

 D+(x,y;t)=1 +t(p−1x−1y−1+p1xy+p−1,1x−1y) ×(D+(x,y;t)−D+(0,y;t)) +t(p−1xy−1+(p1+p−1,1)xy) ×(D+(0,y;t)−D+(0,0;t)) +t(p1+p−1,1)xyD+(0,0;t).

Applying the symbolic method (see [7]), we translate the following combinatorial characterization of N-meanders into the claimed equation. An N-meander is either of length , or it can be uniquely decomposed into an N-meander followed by an N-step. If is nonzero, then any N-step can be applied. The generating function of N-meanders with positive minimum reachable point is . If vanishes, but is nonzero (those N-meanders have generating function ), then an additional N-step increases (the path ending at  disappears, and the one ending at  becomes the minimum) and decreases , while an additional N-step or increases both and . Finally, if and vanish, which corresponds to the generating function , then the N-step is forbidden, and the two other available N-steps both increase and .

Let us introduce the min-max-change polynomial and the kernel as

 S(x,y) :=p−1xy+p1xy+p−1,1yx, K(x,y) :=xy(1−tS(x,y)).

The generating function of Dyck N-walks has now the compact form . A key role in the following result on the closed form of Dyck N-meanders is played by and , the unique power series solutions satisfying , and which are given by

 Y(t) =1−√1−4p−1(p1+p−1,1)t22(p1+p−1,1)t, X(y,t) =1−√1−4p1(p−1+p−1,1y2)t22p1yt.

The generating function of Dyck -meanders is algebraic of degree , and equal to

 x−X(y,t)1−X(y,t)2y−xY(t)−X(y,t)Y(t)+xyX(y,t)xy(1−tS(x,y)).

The generating function of Dyck N-excursions is symmetric in and , and equal to

 D+(0,1;t) =X(1,t)1−X(1,t)21−X(1,t)Y(t)(p−1+p−1,1)t.

Starting from the result of Proposition 2.1 one first substitutes and finds a closed-form expression for using the kernel method. After substituting this expression back into the initial equation one applies the kernel method again with respect to and finds a closed-form solution for . Combining these results one proves the claim. Finally, using a computer algebra system a short computation using the closed form of Dyck N-excursions shows the symmetry in and .

It would be desirable to find a combinatorial interpretation of the surprising symmetry in and of Dyck N-excursions (which is clear for Dyck N-bridges).

With this result, we can easily answer the counting problem in which all weights are set equal to one. Thereby we also solve a conjecture in the OEIS111The on-line encyclopedia of integer sequences: http://oeis.org/A151281. on the asymptotic growth.

For the generating function of unweighted Dyck N-meanders is

 D+(1,1,t) =−1−4t−√1−8t24t(1−3t) =1+2t+6t2+16t3+48t4+….

The number of unweighted Dyck N-meanders is asymptotically equal to

 [tn]D+(1,1,t)=3n2+ (3√2(1+(−1)n)+4(1−(−1)n)) ×8n/2√πn3+O(8n/2n5/2).

These N-walks are in bijection with walks in the first quadrant starting at and consisting of steps . The counting sequence is given by OEIS A151281.

For the complete generating function of unweighted Dyck N-excursions is

 D+(0,1,t) =1−8t2−(1−12t2)√1−8t28t2(1−9t2) =1+4t2+28t4+2246+18888+….

The number of unweighted Dyck N-excursions is asymptotically equal to

 (1+(−1)n)(3n8+√88n/2√πn3+O(8n/2n5/2)).

Finally, we come back to one of the starting questions from the networking motivation.

The probability for a random Dyck N-walk of length to be an N-excursion has for the following asymptotic form where the roles of and are interchangeable:

• if ,

• if and ,

• if ,

• if and

Starting from the results of Theorem 2.1 we perform a singularity analysis [7]. Thereby different regimes need to be considered, leading to the different cases in the result. In the last case the condition guarantees that is closer to than .

Note that the (huge) formula for the constant in the last case can be made explicit in terms of and . However, it is of different shape for , and . In Figure 2 we compare the theoretical results with simulations for three different probability distributions. These nicely exemplify three of the four possible regimes of convergence.

### 2.2 Dyck N-bridges

We now turn our attention to Dyck N-bridges. Their generating function is defined as

 B(x,y,t)=∑n,k,ℓ≥0b2n,k,ℓx−kyℓt2n.

Recall the following relation with all N-walks (note that bridges have to be of even length): In the following theorem we will reveal a great contrast to classical walks: nearly all N-walks are N-bridges.

The generating function of Dyck N-bridges is algebraic of degree . For the generating function of unweighted Dyck N-bridges is algebraic of degree :

 B(1,1,t) =1−6t2√1−8t2(1−9t2) =1+7t2+63t4+583t6+5407t8+….

The number of unweighted Dyck N-bridges is asymptotically equal to

 1+(−1)n2(3n−2√2√π8n/2√n+O(8n/2n3/2)).

In order to improve readability we drop the parity condition on and define

 B2(x,y,t):=[x≤0y≥0]D(x,y;t),

such that

 (1) B2(x,y,t)=D(x,y;t)−[x>0]D(x,y,t)−[y<0]D(x,y,t).

It is then simple to recover from . In words, an N-bridge is an N-walk of even length whose minimum is not strictly positive, nor is its maximum strictly negative222We thank Mireille Bousquet-Mélou for suggesting us this approach..

The change in the - (minimal reachable point) and -coordinate (maximal reachable point) can be conveniently encoded in the min-max-change polynomial

 S(x,y)=p−1xy+p1xy+p−1,1yx.

Then, the construction can be interpreted as the one of two-dimensional walks of length , starting at , with the step set , and ending in the fourth quadrant . A lot is known about these walks, see e.g., [4]. By (1) it suffices to find the generating functions and for -walks ending with a positive abscissa (resp. negative ordinate). The theory of formal Laurent series with positive coefficients tells us automatically that they are algebraic, which implies that the generating function of bridges is algebraic, see e.g., [8, Section 6] which also gives further historical references.

Due to the symmetry of the step set we have after additionally interchanging the role of and . In order to end the proof it remains to compute the roots of the denominator of and perform a partial fraction decomposition.

After this detailed discussion of nondeterministic walks derived from Dyck paths, we turn to the probably next most classical lattice paths: Motzkin paths.

## 3 Motzkin N-walks

The step set of classical Motzkin paths is . The N-step set of all nonempty subsets is

 S={{−1},{0},{1},{−1,0},{−1,1},{0,1},{−1,0,1}},

and we call the corresponding N-walks Motzkin N-walks. A Motzkin N-walk is said to be

• of type if is equal to ,

• of type if is equal to and .

The following proposition explains how these two types are sufficient to characterize the structure of Motzkin N-walks.

A Motzkin N-walk is of type if and only if it is constructed only from the N-steps , , , and . Otherwise, it is of type .

The proof is based on a recurrence and a case-by-case analysis on the number and type of N-steps.

The set of Motzkin N-walks of type (resp. ) is denoted by (resp. ), and their generating functions are defined as

 M1(x,y;t) =∑w∈M1xmin(w)ymax(w)t|w|, M2(x,y;t) =∑w∈M2xmin(w)ymax(w)−1t|w|.

The generating functions of Motzkin N-walks of type and are rational. The generating function of Motzkin N-bridges is algebraic.

The first statement is a direct corollary of the previous proposition due to a simple sequence construction. An N-bridge of type is an N-walk that satisfies , , and is even. Note that in this case this property is not equivalent to an even number of steps. An N-bridge of type is an N-walk that satisfies and . Thus, the generating function of Motzkin N-bridges is equal to

 [x≤0y≥0](M1(x,y;t)+M1(−x,y;t)2+M2(x,y;t)).

Since the generating functions of and are rational, according to [4, Proposition 1] (see also [13]), the generating function of N-bridges is D-finite. Yet the generating function is even algebraic, which can be proved similarly as done the proof of Theorem 2.2.

Using a computer algebra system it is easy to get closed-form solutions and asymptotics for specific values of the weights. We do not give these closed forms, as they are quite large and do not shed new light on the problem. It is however interesting to compute the asymptotic proportion of N-bridges among all N-walks. For example, when all weights are set to , it is equal to

 1−√3π(6/7)n√n+O((6/7)nn3/2).

Hence, nearly all N-walks are N-bridges.

We now turn to the analysis of Motzkin N-meanders and N-excursions.

The generating functions of Motzkin N-meanders and N-excursions are algebraic.

Without loss of generality we perform all computations here with all weights . Let and denote the Motzkin N-meanders of type and . Their generating functions are

 M+1(x,y;t) =∑w∈M+1xmin+(w)ymax+(w)t|w|, M+2(x,y;t) =∑w∈M+2xmin+(w)ymax+(w)−1t|w|.

Let also

denote the column vector

. An N-meander is either empty – in which case, it is of type – or it is an N-meander followed by an N-step . The type of depends on the type of , the N-step , as well as on the case if or if . Specifically,

• when has type , then has type if , otherwise it has type ,

• when has type and then has type for any ,

• when has type and (i.e. the reachable points are ) then has type if , and type otherwise.

Applying the Symbolic Method [7] and the same reasoning as in the proof of Proposition 2.1, we obtain the following system of equations characterizing the generating functions from the vector

 M+(x,y;t) =e1+t(A(x,y)(M+(x,y;t)−M+(0,y;t)) +B(x,y)(M+(0,y;t)−M+(0,0;t)) +C(x,y)M+(0,0;t)),

where is the column vector , and , , are two-by-two matrices with Laurent polynomials in and given in Figure 3. Observe that the first two matrices are upper-triangular.

This equation is rearranged into

 (Id−tA(x,y))M+(x,y;t)= (2) e1−t(A(x,y)−B(x,y))M+(0,y;t) −t(B(x,y)−C(x,y))M+(0,0;t).

Next, we apply the kernel method (see e.g., [2] and [1]) successively on and in a two phases to compute the generating function of Motzkin N-meanders. The small roots in the variable of the equations

 1−tA0,0(x,y) =0, 1−tA1,1(x,y) =0,

are denoted by and , and are equal to

 1−t−√1−4t2y2−3t2−2t2ty, 1−t(y+1)−√1−7t2y2−2t2y−3t2−2ty−2t2ty.

We then define the row vectors

 u1 =(1,0), u2(y,t) =(tA1,0(X2(y,t),y),1−tA0,0(X2(y,t),y)),

so that the left-hand side of Equation (2) vanishes both when evaluated at and left-multiplied by , and also when evaluated at and left-multiplied by . Combining the corresponding two right-hand sides, we obtain a new two-by-two system of linear equations

 (3) tD(y,t)M+(0,y;t)=f(y,t)−E(y,t)M+(0,0;t),

where the vector of size has its first element equal to , and its second element equal to

 (ty+t−√−7t2y2−3t2−2(t2+t)y−2t+1+1)t1−ty−t−√−7t2y2−3t2−2(t2+t)y−2t+1,

and the two-by-two matrices and are two large to be shown here. Again, the matrix is upper-triangular. We now define

 Y1(t) =t−1+√−7t2−2t+14t, Y2(t) =1−2t−√−12t2−4t+18t,

and the row vectors

 v1 =(1,0), v2(t) =(−D1,0(Y2(t),t),D0,0(Y2(t),t)),

to ensure that and have series expansions at the origin, and that the left-hand side of Equation (3) vanishes both when evaluated at and left-multiplied by , and also when evaluated at and left-multiplied by . The corresponding two right-hand side are combined to form a new two-by-two system of equations

 h(t)=tF(t)M+(0,0;t),

where the column vector and the matrix are too large to be shown here. The matrix is invertible, so the generating function of Motzkin N-meanders with maximum reachable point is equal to

 M+(0,0;t)=1tF(t)−1h(t).

This expression is injected in Equation (3) to express the generating function of Motzkin N-meanders with minimum reachable point

 M+(0,y;t)=1tD(y,t)−1(f(y,t)−E(y,t)M+(0,0;t)).

Finally, this expression is injected in Equation (2) to express the generating function of Motzkin N-meanders

 M+(x,y;t)= (Id−tA(x,y))−1 ×(e1−t(A(x,y)−B(x,y))M+(0,y;t) −t(B(x,y)−C(x,y))M+(0,0;t)).

The generating function of N-meanders and N-excursions are then, respectively, and .

As before we can use a computer algebra system to get numeric results. After tedious computations one gets that for all ’s equal to the generating function of N-meanders is algebraic of degree and given by

 10t−1+√(1+2t)(1−6t)8t(1−7t).

The total number of N-meanders is asymptotically equal to

 347n+3√32√π6n√n3+O(6nn5/2).

The generating function of N-excursions is algebraic of degree . Their asymptotic number is

 9167n−γ6n√πn3+O(6