Extensions of partial cyclic orders, Euler numbers and multidimensional boustrophedons

We enumerate total cyclic orders on $\left\{1,\ldots,n\right\}$ where we prescribe the relative cyclic order of consecutive triples $(i,{i+1},{i+2})$, these integers being taken modulo $n$. In some cases, the problem reduces to the enumeration of descent classes of permutations, which is done via the boustrophedon construction. In other cases, we solve the question by introducing multidimensional versions of the boustrophedon. In particular we find new interpretations for the Euler up/down numbers and the Entringer numbers.


Introduction
In this paper we enumerate some extensions of partial cyclic orders to total cyclic orders. In certain cases, this question is related to that of linear extensions of some posets.
A (linear) order on a set X is a reflexive, antisymmetric and transitive binary relation on this set. When the set X possesses a partial order, a classical problem is the search for (and the enumeration of) linear extensions, i.e. total orders on X that are compatible with this partial order. Szpilrajn [11] proved that such a linear extension always exists using the axiom of choice. It is possible to find a linear extension of a given finite poset in linear time (cf [4] section 22.4). Brightwell and Winkler [2] proved that counting the number of linear extensions of a poset was #P -complete.
Another type of order one can put on a set X is a cyclic order, which is a ternary relation Z ⊂ X 3 satisfying the following conditions: by Megiddo [9]. Galil and Megiddo [7] proved that the problem of determining whether a given partial cyclic order admits an extension is NP-complete.
For any n ≥ 1, denote by X n the set {x 1 , . . . , x n }. In this paper, we solve the question of the enumeration of total cyclic orders on X n which extend a partial cyclic order prescribing the relative order of any triple (x i , x i+1 , x i+2 ). This is the cyclic counterpart of the classical linear extension problem considered in Subsection 2.1, where the relative order of every pair (x i , x i+1 ) is prescribed. We enumerate three types of total cyclic orders. For any n ≥ 1, let W n be the set of words of length n with letters in {+, −}. Definition 1.1. Fix n ≥ 3, w = ε 1 · · · ε n−2 ∈ W n−2 and η ∈ {+, −}.
• The set P w is the set of all total cyclic orders Z on X n such that for any 1 ≤ i ≤ n − 2 verifying ε i = + (resp. for any 1 ≤ i ≤ n − 2 verifying • The set Q + w (resp. Q − w ) is the set of all total cyclic orders Z ∈ P w such that (x n−1 , x n , x 1 ) ∈ Z (resp. (x 1 , x n , x n−1 ) ∈ Z).
See Figure 1 for an example.
x 1 x 3 x 4 x 2 Figure 1: A cyclic order Z on X n may be represented pictorially by placing all the x i 's on a circle, in such a way that (x i , x j , x k ) ∈ Z if and only if starting at x i and turning in the positive direction, one sees x j before x k . Here n = 4 and Z is the set formed by the union of the four triples (x 1 , x 3 , x 4 ), (x 3 , x 4 , x 2 ), (x 4 , x 2 , x 1 ) and (x 2 , x 1 , x 4 ) with the eight possible cyclic permutations of these four triples. The arrow indicates the positive direction of rotation. The cyclic order Z belongs to the following sets : Our main results concern the enumeration of total cyclic orders of each of the three above types. It is not hard to see that each such enumeration question is equivalent to the enumeration of total cyclic orders extending some given partial cyclic order on X n . We show that these enumeration questions can always be solved by using linear recurrences which extend the classical boustrophedon construction used to compute the Entringer numbers. As a consequence, this provides an algorithm for computing the cardinalities of the sets P w , Q η w and R η1,η2 w which runs in polynomial time in the length of w, instead of the naive super-exponential algorithm which would consist in testing every total cyclic order to check if it belongs to one of these sets.

Outline of the paper
In Section 2, we state that the enumeration of each P w is equivalent to the enumeration of some descent class of permutations. As a consequence, we obtain new interpretations for the Euler and Entringer numbers in terms of cyclic orders. We prove these statements in Section 4 by producing a specific bijection between total cyclic orders on X n+1 and permutations in S n . In Section 3, we briefly recall the classical boustrophedon construction and we explain how to extend it to higher dimensions to enumerate the classes Q η w and R η1,η2 w . The proof of these linear recurrence relations can be found in Section 5. We finish in Section 6 by formulating a conjecture regarding the asymptotic densities of the classes Q η w and R η1,η2 w inside the class P w , when all the letters of w are +, in the limit when the length of w goes to infinity.

Enumeration of P w and relation with the Euler and Entringer numbers
The enumeration of the total cyclic orders in P w will be shown to be equivalent to the enumeration of descent classes of permutations, which we now introduce.

Descent classes of permutations
For any n ≥ 1, denote by I n the set {1, . . . , n} and by S n the set of permutations of I n .
Definition 2.1. For any n ≥ 2, the descent pattern of a permutation σ ∈ S n is the word w = ε 1 . . . ε n−1 ∈ W n−1 such that for all 1 ≤ i ≤ n − 1 The descent class S w is defined to be the set of all permutations with descent pattern w.
For example, the descent pattern of the permutation σ whose one-line nota- To any word w = ε 1 . . . ε n−1 ∈ W n−1 , we associate the partial order ≺ w on X n generated by the following relations : for any Then the number of linear extensions of ≺ w is #S w , hence the enumeration of descent classes is also a problem of enumeration of linear extensions of a poset.
The first formula for #S w was obtained by MacMahon [8]. For further formulas for #S w , see [12] and the references therein.
A special descent class is the class of up/down permutations, this is the case when the letters of w in odd (resp. even) positions are all + (resp. −). André [1] showed that if we write F (x) = sec x + tan x, then the number of up/down permutations in S n is the n-th Euler number E n := F (n) (0). One way to compute the Euler numbers is via the Entringer numbers e n,i , which count the number of up/down permutations σ ∈ S n such that σ(n) = i. These Entringer numbers satisfy linear recurrence relations corresponding to the boustrophedon construction [5] (see Subsection 3.1 for more details).

Connection with the enumeration of total cyclic orders
For any n ≥ 1 and w ∈ W n , one can express the number of total cyclic orders in P w in terms of cardinalities of descent classes of permutations. Define the involution i on W := n≥1 W n which flips all the signs at even locations : For any permutation σ ∈ S i(w) , the word w is sometimes called the alternating descent pattern of σ, see for example [3]. Remark 2.3. We prove Theorem 2.2 by constructing a somewhat natural bijection between each P w and S i(w) . It would have been easier to just show that the numbers #P w verify the same linear recurrence relations as the ones verified by the numbers #S i(w) (cf Subsection 3.1), but exhibiting a bijection between these sets provides a stronger connection between the classes P w and descent classes of permutations.
As a corollary, taking w to be a word with all the letters that are +, we deduce a new interpretation for the Euler numbers : Corollary 2.4. For any n ≥ 1, the Euler number E n is the number of total cyclic orders Z on X n+1 which verify (x i , x i+1 , x i+2 ) ∈ Z for any 1 ≤ i ≤ n − 1.
As a corollary of the proof of Theorem 2.2, we also obtain a new interpretation of the Entringer numbers in terms of cyclic orders. Given a total order Z on X n , we define for any pair of distinct elements (x i , x j ) ∈ X n the content of the arc from x i to x j to be For example, c Z (x 3 , x 4 ) = 0 for the total cyclic order Z depicted in Figure 1.
Then we have the following result : For any 1 ≤ i ≤ n, the Entringer number e n,i is the number of total cyclic orders Z on X n+1 verifying the following two conditions : 2. the parameter i satisfies 3 Enumeration of Q η w and R η 1 ,η 2 w and higher-dimensional boustrophedons 3

.1 Boustrophedons
The classical way to compute the Euler and Entringer numbers is to set up a triangular array of numbers, called either the boustrophedon or the Seidel-Entringer-Arnold triangle. Each line of the array is obtained by a linear transformation of the previous line, and the answer is read on the bottom line (see Figure 2). Here each entry of a line of even (resp. odd) index is obtained by taking the sum of the entries of the previous line that lie to its left (resp. right).
Viennot [12] extended this construction to obtain the cardinality of any descent class S w . Thus, by Theorem 2.2, one can compute the cardinality of P w by means of a linear inductive process.
Unlike the case of P w , it seems that we cannot reduce the question of enumerating Q η w and R η1,η2 w to the enumeration of some nice or known class of permutations. For example, while (#P + n ) n≥1 (where + n denotes the word of length n with all letters equal to +) is the sequence of Euler numbers by Corollary 2.4, the sequences (#Q + + n ) n≥1 and (#R +,+ + n ) n≥1 are currently absent from the Online Encyclopedia of Integer Sequences [10] (see Table 1 for the first few values).  Table 1: The first ten values of the cardinalities of the sets P + n , Q + + n and R +,+ + n . The first sequence corresponds to the Euler up/down numbers. We formulate in Section 6 a conjecture regarding the asymptotic ratio of the terms of these sequences.
However, we solve these enumeration questions by introducing linear recurrences that are higher-dimensional versions of the boustrophedon. The bous-trophedon can be seen as the time-evolution of a sequence of numbers, where at time t the sequence has length t and the sequence at time t + 1 is obtained from the sequence at time t by a linear transformation.
The enumeration of Q η w (resp. R η1,η2 w ) is done via the time-evolution of triangles of numbers (resp. tetrahedra of numbers), where at time t the triangles (resp. tetrahedra) have side-length t and the triangles (resp. tetrahedra) at time t + 1 are obtained from the triangles (resp. tetrahedra) at time t by a linear transformation. We will introduce a family of operators Φ a,b,c and show that the recursions for P w , Q η w and R η1,η2 w can all be expressed simply using these operators.
Foata and Han [6] also studied the evolution of triangular arrays of numbers in order to enumerate Bi-Entringer numbers, which count up/down permutations σ ∈ S n with prescribed values of σ(1) and σ(n). Our Φ operators can also be used to describe their recurrence formulas.

Enumeration of Q η w
In order to enumerate Q η w or R η1,η2 w , we need to refine these classes by fixing finitely many reference points and introducing a parameter to specify the content of each arc between two consecutive reference points. Given a total order Z on a set X and (y 1 , . . . , y p ) a p-tuple of distinct elements in X, we define the multi-content c Z (y 1 , . . . , y p ) to be the p-tuple For any n ≥ 3, w ∈ W n−2 and nonnegative integers i, j, k such that i+j +k = n − 3, set If w ∈ W n , we denote by w+ (resp. w−) the word on n + 1 letters obtained by adding the letter + (resp −) at the end of the word w. We also denote by |w| the length of w. We then have the following recurrence relations : For a fixed w ∈ W and η ∈ {+, −}, the collection forms a triangular array of numbers, and Theorem 3.1 gives a recursive way to compute the cardinality of any Q η w : compute the evolution of the pair of triangular arrays (T + w , T − w ), for w a prefix of w of increasing length, until one gets to T η w , then take the sum of all the entries of T η w (see Figure 3). The recurrences are initialized as follows :  Table 1.
The linear recursions can be rewritten in a more compact way, using a single type of operators. Fix m ≥ 2 and 1 ≤ a, b, c ≤ m to be three integers such that b = c (a may be equal to b or c). We define the linear endomorphism Φ a,b,c of Z[X 1 , . . . , X m ] by its action on monomials : for any i 1 , . . . , i m ≥ 0, Note that Φ a,b,c maps any homogeneous polynomial of degree d to a homogeneous polynomial of degree d + 1.
For any w ∈ W and η ∈ {+, −}, we form the generating function (3.10) Then Theorem 3.1 can be rewritten as follows.

Theorem 3.2.
For any w ∈ W, we have Remark 3.3. The Φ operators can be used to enumerate P w , which by Theorem 2.2 corresponds to the classical boustrophedon and its extension by Viennot in [12]. For any n ≥ 3, w ∈ W n−2 and nonnegative integers i, j such that i + j = n − 2, set and define the generating function Then we have Remark 3.4. Foata and Han [6] introduced and studied Seidel triangle sequences, which are sequences (A n ) n≥1 of triangular arrays of numbers of growing size satisfying some linear recursion relations. One may reformulate their definition using the Φ operators as follows. Fix H to be an arbitrary infinite triangular array of numbers (the n-th line of H contains n numbers). For any n ≥ 1, denote by T n (H) the triangular array of numbers of side-length n defined as 3 .
follows : the entries of T n (H) are constant along rows of constant j-coordinate and the last line of T n (H) is equal to the n-th line of H (see Figure 4 for an example). Then the Seidel triangle sequence built from H is defined to be the sequence of triangular arrays (A n ) n≥1 such that A 1 = T 1 (H) and for any n ≥ 2, A n = Φ 1,1,3 (A n−1 ) + T n (H). Note that here we slightly abused the notation by applying Φ 1,1,3 to a triangular array of numbers instead of its generating function.

Enumeration of
In order to obtain linear recurrence relations to compute the cardinality of R η1,η2 w , we need to define six types of subsets, distinguished according to the cyclic order of the four elements 1, 2, n − 1 and n. If Z is a total order on a finite set X and y 1 , . . . , y p are p distinct elements of X (with p ≥ 3), we say that (y 1 , . . . , y p ) forms a Z-chain if for any 3 ≤ i ≤ p, (y 1 , y i−1 , y i ) ∈ Z. We denote by C Z the set of Z-chains. Using this notation, we define for any n ≥ 4 and w ∈ W n−2 the following : Note that for any w ∈ W with |w| ≥ 2, As in the previous case, we enumerate each class by refining according to the multi-content associated with the four reference points x 1 , x 2 , x n−1 and x n . For any n ≥ 4 and nonnegative integers i, j, k, such that i + j + k + = n − 4, set : For any 1 ≤ α ≤ 6 and w ∈ W with |w| ≥ 2, the collection w,i,j,k, |i + j + k + = |w| − 2 forms a tetrahedral array of numbers. We provide linear recurrence formulas for these arrays directly in the language of generating functions (we skip the less compact formulation in terms of sequences indexed by i, j, k, ). For any 1 ≤ α ≤ 6 and w ∈ W with |w| ≥ 2, we set Then we can express the recurrence relations among the R (α) w 's by using the operators Φ a,b,c defined above : Theorem 3.5. For any w ∈ W with |w| ≥ 2, we have The recurrences are initialized as follows :

Proof of Theorem 2.2
To prove Theorem 2.2, we first establish in Subsection 4.1 a one-to-one correspondence between P w and a certain class of cyclic permutations on I n , which we call the cyclic descent class C w . Then in Subsection 4.2, we define a map F between C := n≥2 C n and S := n≥1 S n , where C n denotes the set of cyclic permutations on I n . We show in Subsection 4.3 that F is a bijection from each C n+1 to S n for any n ≥ 1 and in Subsection 4.4 that F maps C w to S i(w) for any w ∈ W.

Cyclic descent classes
There is a one-to-one correspondence between permutations σ ∈ S n and total orders < σ on X n , by setting x i < σ x j if and only if σ(i) < σ(j). As observed in Subsection 2.1, this reduces the problem of enumerating certain linear extensions of posets on X n to enumerating descent class of permutations in S n . By analogy with the linear setting, we define a one-to-one correspondence between cyclic permutations π ∈ C n and total cyclic orders Z on X n . For any n ≥ 3, let Z n denote the set of all total cyclic orders on X n . Define the map ζ : where for any π ∈ C n , ζ(π) is defined as follows : (x i1 , x i2 , x i3 ) ∈ ζ(π) if and only if i 2 = π k (i 1 ) and i 3 = π (i 1 ) for some 1 ≤ k < ≤ n − 1. In words, for the total cyclic order ζ(π), x π(i) is the next element after x i when turning in the positive direction. For example, if n = 4 and π = [1, 3, 4, 2], then ζ(π) is the total cyclic order depicted in Figure 1. The map ζ is clearly a bijection from C n to Z n for any n ≥ 3.
Continuing the analogy with the linear setting, we define cyclic descent classes. Definition 4.1. Fix n ≥ 3. The cyclic descent pattern of a cyclic permutation π ∈ C n is the word w = ε 1 . . . ε n−2 ∈ W n−2 such that for all 1 ≤ i ≤ n − 2 The cyclic descent class C w is defined to be the set of all cyclic permutations with cyclic descent pattern w.
Clearly ζ maps C w to P w . Thus, to prove Theorem 2.2, it suffices to show that for any word w ∈ W, #C w = #S i(w) .

Construction of a bijection
Before describing the construction of F , we need some preliminary remarks about notations for permutations. For any n ≥ 3, we define the map ∂ : C n → C n−1 as follows : for any π ∈ C n , ∂(π) is the cyclic permutation such that for any 1 ≤ i ≤ n − 1, For example, ∂([1, 5, 3, 4, 2]) = [1,3,4,2]. For any n ≥ 2, we define the map d : S n → S n−1 as follows : for any σ ∈ S n , d(σ) is the permutation such that for any 1 ≤ i ≤ n − 1, For example, using the one-line notation for permutations, we have d((14253)) = (1324). Note that D : is a bijection. We will define the bijection F by induction on the size of the cyclic permutation π. There is a unique cyclic permutation π 0 ∈ C 2 . We set F (π 0 ) to be the unique permutation in S 1 . Fix n ≥ 2. Assume we have defined how F acts on cyclic permutations in C n . Fix now π ∈ C n+1 and write σ = F (∂(π)). Set and write Then we set F (π) = D −1 ( σ, α).  Corollary 2.5 about Entringer numbers follows from formula (4.2) defining α.

Proof of Lemma 4.2.
The sets C n+1 and S n both have cardinality n!. We will show by induction on n ≥ 1 that F : C n+1 → S n is surjective. It is clear for n = 1.
Pick σ ∈ S n with n ≥ 2. By induction hypothesis, we can find π ∈ C n such that F ( π) = d(σ). We set β to be n − σ(n) (resp. σ(n) − 1) if n is even (resp. odd). For any 1 ≤ i ≤ n + 1, define It is not hard to check that π ∈ C n+1 . In words, π is obtained from π by adding the element n + 1 to the cycle in such a way that c ζ(π) (x n , x n+1 ) = β. Thus by construction of F we have F (π) = σ, which concludes the proof of Lemma 4.2.

Proof of the recursion formulas for Q η w and R (α)
w We first show how to derive linear recursion relations for the triangles and tetrahedra of numbers, then how to translate them to the language of generating functions.

Recursion relations for triangles and tetrahedra of numbers
The proof of the linear recursion formulas for Q η w (resp. for R (α) w ) goes along the following lines : take a total cyclic order Z on X n+1 where the elements x n , x n+1 and x 1 (resp. x n , x n+1 , x 1 and x 2 ) form a prescribed chain in Z, obtain a total cyclic order Z on X n by deleting the element x n+1 and look at the possible chains formed in Z by x n−1 , x n and x 1 (resp. x n−1 , x n , x 1 and x 2 ).
Define the map ∂ : .
In words, for any n ≥ 3 and Z ∈ Z n+1 , ∂(Z) is the total order on X n obtained by deleting from Z all the triples involving x n+1 . For any n ≥ 3, w ∈ W n and i, j, k ≥ 0 with i + j + k = n − 3, set Lemma 5.1. For any w ∈ W and i, j, k ≥ 0 such that i + j + k = |w|, the restriction of the map ∂ to Q + w+,i,j,k is a bijection from Q + w+,i,j,k to the set Proof. Fix n ≥ 3 and Z ∈ Q + w+,i,j,k with |w| = n − 2. We first show that ∂Z lies in Q w,i,j,k . Since ∂Z lies in Z n and the relative order of any triple x i , x i+1 , x i+2 with 1 ≤ i ≤ n − 2 is prescribed by the word w, ∂Z must lie either in some Q − w,i ,j ,k or in some Q + w,i ,j ,k . Assume first that ∂Z lies in some Q − w,i ,j ,k (see Figure 5).
Then (x n−1 , x n , x n+1 ) ∈ Z and (x n−1 , x 1 , x n ) ∈ ∂Z ⊂ Z thus by transitivity, (x n−1 , x 1 , x n , x n+1 ) forms a chain in Z. From this we deduce the following : Similarly, in the case when ∂Z lies in some Q + w,i ,j ,k , we obtain that x n−1 x 1 x n x 2 j k i j k i Figure 5: A cyclic order Z in some Q + w+,i,j,k with |w| = n − 2 and such that ∂Z ∈ Q − w,i ,j ,k . The small dashed circle indicates that x n+1 is not counted by i .
For any Z ∈ Q w,i,j,k , let ι( Z) be the total order on X n+1 obtained from Z by adding x n+1 on the circle in such a way that More precisely, writing π = ζ −1 ( Z), set ι( Z) := ζ(π), where π is defined by It is not hard to see that ι is a left-and right-inverse to the restriction of the map ∂ to Q + w+,i,j,k , which is thus a bijection. The recurrence relation (3.4) from Theorem 3.1 immediately follows from Lemma 5.1. The other statements of this Theorem are proved using statements analogous to Lemma 5.1. For the recurrence relation (3.5), one should observe that the image under ∂ of Q − w+,i,j,k must lie in some Q + w,i ,j ,k , using transitivity : if Z ∈ Q − w+,i,j,k , then (x n , x 1 , x n+1 ) ∈ Z and (x n , x n+1 , x n−1 ) ∈ Z thus (x n , x 1 , x n−1 ) ∈ Z and (x n , x 1 , x n−1 ) ∈ ∂Z. Finally, one obtains similarly linear recursion formulas for the g (α) w,i,j,k, .

Recursion relations for generating functions
Before we translate the recursion relations for triangles and tetrahedra of numbers into recursion relations for generating functions, we need to introduce some notation for certain subsets of indices. Fix m ≥ 2 and 1 ≤ a, b, c ≤ m such that b = c. For any i = (i 1 , . . . , i m ) an m-tuple of nonnegative integers, we define the set I a,b,c (i) as follows.
1. If a = b, then I a,a,c (i) is the set of all m-tuples of nonnegative integers i = (i 1 , . . . , i m ) verifying the following conditions : • 0 ≤ i a ≤ i a − 1 ; • i c = i c + i a − 1 − i a ; • i = i if / ∈ {a, c}.
2. If a = b, then I a,b,c (i) is the set of all m-tuples of nonnegative integers i = (i 1 , . . . , i m ) verifying the following conditions : • 0 ≤ i a ≤ i a − 1 ; For any n ≥ 0, denote by J n the set of all m-tuples of nonnegative integers i = (i 1 , . . . , i m ) such that i 1 + · · · + i m = n.
In order to translate the recursion formulas for triangular or tetrahedral arrays of numbers into recursion formulas for generating functions, we apply for the following lemma : The proof of Lemma 5.2 is a straightforward computation.

A conjecture on asymptotic densities
Observe that for any word w ∈ W, we have One may investigate the density of each R (α) w inside P w . In particular, in the case when w = + n (in which case #P w is an Euler number), denote by p (α) n := #R (α) + n #P + n the density of each R (α) + n inside P + n for any 1 ≤ α ≤ 6. We conjecture the following regarding the asymptotics of p (α) n :