An important problem in enumerative combinatorics is the study of lattice walks in restricted lattices. Many efforts have been deployed in recent years for classifying them, see e.g. the surveys and  and the references therein. The generating functions of lattice walks are not only intriguing for combinatorial reasons, but also from the perspective of computer algebra. For combinatorial reasons they are interesting because, depending on the choice of admissible steps, the generating functions may have quite different algebraic and analytic properties. For computational reasons they are interesting because their descriptions (whether by a polynomial or by a linear differential equation, as we will see below) are sometimes so large in size that it becomes difficult to handle them with a reasonable efficiency.
In the present article, we consider small step walks restricted to the quarter plane, defined as follows. Let be a fixed subset of , which will contain all steps allowed in the walks. An -walk of length starts at the origin and consists of consecutive steps, where a step from a point to a point is admitted if , and both and belong to the quarter plane . These walks are called restricted to the quarter plane because they are not allowed to step out of it, and with small steps because a single step changes the position by no more than in each coordinate. As an example, for (Kreweras walks), a possible walk of length six is
A brute-force enumeration with rejection shows that, altogether, there are 125 different walks of length six for this particular step set. In the general case of an arbitrary step set , with denoting the number of different -walks of length , we are interested in the generating function .
The generating function corresponding to the example step set above is algebraic [31, 22, 10], i.e., it satisfies a polynomial equation for some . But this is not the case for all other step sets. Still, among those step sets that induce a transcendental (i.e., non-algebraic) generating function , some have a that is D-finite, i.e., that satisfies a linear differential equation with polynomial coefficients. The step set is an example for this case [9, 12]. Finally, there are also step sets whose corresponding generating function is not even D-finite; Mishna and Rechnitzer  proved that this is the case for example when .
More generally, for a fixed step set , one is interested in the study of the trivariate power series
where denotes the number of -walks of length starting at and ending at . The power series is called the complete generating function for -walks. Note that the counting series introduced before is nothing but the specialization of at . Other combinatorially meaningful specializations are , the generating function of -walks returning to the origin (also called excursions), , the generating function of -walks ending on the horizontal axis, and , the generating function of -walks ending on the vertical axis.
Bousquet-Mélou and Mishna  have undertaken a systematic classification of the 256 step sets , from the viewpoint of structural properties of the generating function . Again, the concerned properties are algebraicity and D-finiteness, yet applied to a multivariate setting111A trivariate power series is algebraic if it is the root of a nonzero polynomial . It is called D-finite if the set of all partial derivatives of spans a finite-dimensional vector space over . . They found out that there are 79 inherently different and nontrivial models to consider, of which they recognized 22 models for which is D-finite; a 23rd model, of the so-called Gessel walks, was proved to be D-finite (and even algebraic) by Bostan and Kauers . These 23 models share the feature that a certain group associated to is finite. In the remaining 56 cases, it has been proved that the groups are infinite , and that the complete generating functions are not D-finite [38, 32, 8, 36].
Of the 23 D-finite generating functions, 4 were recognized to be algebraic [11, 7]: one corresponds to the Kreweras model , one to its reverse , one to , and one to Gessel’s. All the other 19 generating functions were proved to be transcendental , although some of their specializations are algebraic, e.g., for . These 19 models form the main object of this article; they are depicted in the third column of Table 1.
The proofs of D-finiteness given by Bousquet-Mélou and Mishna are implicit (i.e., qualitative): the existence of differential equations satisfied by the generating functions was shown without obtaining the differential equations explicitly. On the other hand, Bostan and Kauers [6, 5] provided explicit differential equations for (specializations of) the 23 D-finite generating functions, but these equations were determined only experimentally and, in most of the transcendental cases, they still lack formal proofs (in the 4 algebraic cases, differential equations are easily proved, starting from algebraic equations). Therefore, the following problems were left unsolved by Bousquet-Mélou and Mishna:
The original goal of the present paper was to answer question (i). In this regard, we rigorously prove the differential equations for and guessed by Bostan and Kauers [6, 5] for the 19 models with D-finite transcendental complete generating function. We actually do more, that is we also find and prove differential equations for and for , that specialize to equations for and .
By solving these differential equations, we answer (ii) in the following sense: for all the 19 models mentioned above we uniformly find closed form expressions for in terms of Gauss’ hypergeometric series with parameters , with , defined by
where denotes the Pochhammer symbol for .
More precisely, we obtain the following structure result, that has been conjectured in [6, §3.2]. Note that a similar expression also appears in a related combinatorial context  for rook paths on a three-dimensional chessboard.
Let be one of the 19 models of small step walks in the quarter plane (see Table 1). The complete generating function is expressible as a finite sum of iterated integrals of products of algebraic functions in and of expressions of the form , where and .
The parameters of the occurring ’s as well as the rational functions are explicitly given in Table 2. The full expressions of the generating functions , , , , , and are too large to be displayed in this paper, and are available on-line at http://specfun.inria.fr/chyzak/ssw/closed_forms.html. It turns out by inspection that the involved hypergeometric functions have a very particular form: they are intimately related to elliptic integrals, namely to the complete elliptic integrals of first and second kinds,
For instance, for the step set of the so-called king walks (case 4 in Table 1), we prove that
See Section 2 for a detailed presentation of this example. Alternatively, an expression of in terms of elliptic integrals is
The relationship to elliptic integrals appears to hold true in a far more general setting. Indeed, taking Theorem 1 as starting point, one of us (van Hoeij) has checked that for many (more than 100) integer sequences in the OEIS whose generating function is both D-finite and convergent in a small neighborhood of , all second-order irreducible factors of the minimal-order linear differential operator annihilating are solvable either in terms of algebraic functions, or in terms of complete elliptic integrals. This surprisingly general feature, reminiscent of Dwork’s conjecture mentioned in [6, §3.2], begs for a combinatorial explanation. See also [48, Section 8] for a similar discussion.
In Theorem 1 and in representations of generating functions like (2), all “functions” bear a combinatorial meaning: they have to be understood as denoting formal series at 0, potentially with a (finite) polar part. Correspondingly, integration has to be viewed as a linear operator from the set of formal Laurent series without term in to the whole field of formal Laurent series. By the natural growth of the number of walks counted by length, all series considered can also be viewed as analytic series that converge at least on an annulus around 0. This alternative interpretation will be used in Section 4.3 only, for asymptotic considerations.
Finally, concerning question (iii), we start from the explicit differential equations and we exhaustively classify the algebraic cases among all the specializations of the generating function at points . As a corollary, we reprove the transcendence of . More precisely, we prove:
Let be one of the 19 models of small step walks in the quarter plane (see Table 1), with complete generating function . For any , the power series is transcendental, except in the following four cases:
Case 18 at and at ,
Cases 17 and 18 at .
As a consequence, the power series , , and are transcendental for all the 19 models. Additionally, the generating functions of the four algebraic cases are equal to:
in case 17,
in case 18,
in case 18.
As an aside, starting from the explicit expressions in terms of hypergeometric functions, we use singularity analysis and transfer theorems that are classical in Analytic Combinatorics to get some asymptotic formulas for the th coefficient of , , and .
Our proofs of Theorems 1 and 2 are computer-driven and crucially rely on the use of several modern computer algebra algorithms. The starting point is a result by Bousquet-Mélou and Mishna , stating that for the 19 models in Table 1 the complete generating function can be expressed as the positive part of a certain rational function in three variables. The notion of positive part is one of the key mathematical ingredients in what follows. In one variable, extraction of the positive part is an operator, denoted , which acts on formal Laurent series by cutting away all the terms with zero or negative exponents, leaving a formal power series with no constant term as a result. For example,
Note that interpreting the rational function as a formal Laurent series in instead of would lead to a different extraction map. Indeed, for this other definition of positive-part extraction, we would have
Things get more complicated in the multivariate setting. Using the kernel method, Bousquet-Mélou and Mishna showed in [11, Prop. 8] that the generating function , can be written in the form
where and are certain (structured) Laurent polynomials in with coefficients that are rational functions in . These quantities depend on and are listed in Table 1. Since there is no unique natural way of mapping rational functions in several variables to multivariate formal Laurent series, it is a priori not clear how the positive-part extraction is defined in this context. Here is the intended reading of (3): first interpret as an element of , owing to particular properties of and (see Lemma 9 below); let act term by term, obtaining a series in that can be shown to actually belong to for all cases in Table 1; then let act term by term, finally obtaining an element of . In this reading, the composition of positive-part operators is only applied to Laurent polynomials, for which it is certainly well-defined, in a unique way.
As pointed out by Bousquet-Mélou and Mishna, Equation (3) already implies the D-finiteness of , since positive parts can be encoded as diagonals, and diagonals of D-finite power series are again D-finite . This argument also implies an algorithm for computing linear differential equations satisfied by , since the D-finiteness proof in  is effective and basically amounts to linear algebra. Therefore, from (3) one could, in principle, determine differential equations for . To be more specific, the positive part of a formal power series can be encoded as
where the Hadamard product denoted is the term-wise product of two series, while the diagonal operator selects those terms with equal exponents of and . However, the direct use of (4
) in our context leads to infeasible computations; worse, the intermediate algebraic objects involved in the calculations would probably have too large sizes to be merely written and stored. This is really unfortunate, since our need is mere evaluations of the diagonals in (4) at specific values for and .
To bypass this computational obstacle, we use two ingredients.
The first one is our main theoretical innovation: we reformulate the generating function in terms of formal residues. This idea is classical (and in fact already used in Lipshitz’ proof ): we encode diagonals as residues, with the added advantage that early specialization of the variables and/or becomes possible. Additionally, our derivation bases on a positive-part extraction that differs from Bousquet-Mélou and Mishna’s iterated operator : we use a theory  of series with exponents that may be arbitrarily large in negative directions, but are restricted to fixed cones, together with a different, direct positive-part operator, , to be defined in Section 3. The outcome of this reformulation is the ability to compute linear differential equations with polynomial coefficients for the specializations and .
To perform these computations, we use a second ingredient, creative telescoping, an efficient algorithmic technique for the symbolic integration of multivariate functions. Indeed, a direct application of Lipshitz’ linear-algebra algorithm (even with specialized variables) still leads to too large systems, while creative telescoping succeeds in our cases of application; see [4, §2.3] for a related discussion. By specialization and recombination, the equations thus obtained give rise to rigorously proved differential equations for , , and , thus answering question (i). The analysis of these differential equations combined with Kovacic’s algorithm  allows to answer question (iii) and to prove Theorem 2. Moreover, these differential equations are solved in explicit terms using symbolic algorithms for ODE factorization and ODE solving, leading to the proof of Theorem 1 and to the answer of question (ii).
The remarkable property that the differential equations in the cases could all be solved in terms of hypergeometric functions relies on the fact that these operators share a very peculiar factorization pattern: they factor into factors that all have order 1 with the exception of the left-most one that can have order 1 or 2. The origin of this common mathematical feature deserves to be better understood.
We conclude this introduction by mentioning previous contributions on the main topics of the article: D-finiteness, transcendence and explicit expressions for and its specializations.
D-finiteness. For the simplest models, the square walk (case 1) and the diagonal walk (case 2), D-finiteness is classical (e.g., ). Some more involved models have been considered sporadically: for case 19, Gouyou-Beauchamps  proved bijectively that is D-finite; for cases 5 and 15 Mishna [39, §2.4.1, §2.4.2] showed that is D-finite using the kernel method; and for case 17 she proved [39, §2.3.3] that is D-finite by using a bijection with Young tableaux of height at most 3.
Several methods have been proposed to capture D-finiteness in a uniform way. For models with a vertical symmetry (cases 1–16), Bousquet-Mélou and Petkovšek [12, §2] proved that is D-finite by a combinatorial argument, and Bousquet-Mélou [9, §3] proved D-finiteness of by an algebraic argument (a variation of the kernel method). For cases 17–19, Gessel and Zeilberger  proved D-finiteness of by using an algebraic version of the reflection principle; their argument works more generally when the step set is left invariant by a Weyl group and the walks are confined to a corresponding Weyl chamber. Bousquet-Mélou and Mishna  reproved D-finiteness of in all 19 cases by using the kernel equation and the group of the walk borrowed from ; their method generalizes the previous ones from  and . Raschel  uses boundary value problems to get integral representations for that imply its D-finiteness in all 19 cases. By using methods from the book , Fayolle and Raschel reproved in [17, Theorem 1.1] that is D-finite for each and in all 19 cases.
Transcendence. Algebraicity/transcendence proofs were first considered in some isolated cases: in case 15, was proved transcendental by Mishna [39, Th. 2.5]; in case 17, Mishna [39, §2.3.3], then Bousquet-Mélou and Mishna [11, §5.2], showed that and are transcendental and that is algebraic; in case 18, was proved algebraic by Bousquet-Mélou and Mishna [11, §5.2]; in case 19, Bousquet-Mélou and Mishna [11, §5.3] showed that , , and are transcendental. The first unified transcendence proof for applying to all 19 cases is by Fayolle and Raschel [17, Theorem 1.1], although they attribute that result to Bousquet-Mélou and Mishna . They actually proved more, namely that is transcendental for each , using the approach in [18, Chap. 4]. However, this result does not provide any transcendence information about specializations at .
Explicit equations and formulas. For the simplest models (cases 1–2), simple formulas exist, see e.g. ; some of them admit bijective proofs, see e.g. . For models 5 and 15, Mishna [39, Th. 2.5 and 2.6] gives explicit expressions of in terms of some auxiliary series. For model 17, basing on earlier work by Regev  and using a bijection with Young tableaux of height at most 3, Mishna [39, §2.3.3] shows that has a nice hypergeometric expression and that is the (algebraic) generating function of Motzkin numbers. In cases 17–18, Bousquet-Mélou and Mishna [11, §5.2] gave explicit expressions for (and more generally for ). For model 19, it was proved by Gouyou-Beauchamps  that the number of -step walks ending on the -axis is a product of Catalan numbers; hypergeometric expressions for the total number of walks are derived in [11, §5.3], and for those ending at an arbitrary point . Bostan and Kauers [6, 5] empirically determined differential equations for and for all 19 models. For the “highly symmetric” models (cases 1–4), Melczer and Mishna  proved differential equations for conjectured by Bostan and Kauers . Raschel  provides explicit integral representations of the complete generating function using a uniform analytic approach.
Before we enter into the details, Section 2 goes through the whole process on one concrete example. From now on, we more simply write and , respectively, for and .
2. A Worked Example: King Walks in the Quarter Plane
We illustrate our approach on an example. We choose the so-called king walks in the quarter plane (case 4 in Table 1), with step set . The first terms of the generating function of king walks with prescribed length and arbitrary endpoint read (see http://oeis.org/A151331)
and the methods of the present article allow to obtain the above-mentioned closed formula (2) for it.
Here are the main steps of our approach. First, the classical kernel equation [11, Lemma 4] relates to , , and :
where is the generating polynomial of the step set:
A simple but important observation is that the kernel remains unchanged under the change of variables , and . (Other step sets could require different changes of variables to provide the same property.)
Applying these rational transformations to the kernel equation (5) yields the four relations:
Upon adding up these equations, all terms in the right-hand side involving disappear, resulting in