Counting linear extensions of restricted posets

The classical 1991 result by Brightwell and Winkler states that the number of linear extensions of a poset is #P-complete. We extend this result to posets with certain restrictions. First, we prove that the number of linear extension for posets of height two is #P-complete. Furthermore, we prove that this holds for incidence posets of graphs. Finally, we prove that the number of linear extensions for posets of dimension two is #P-complete.


Introduction
Counting linear extensions (#LE) of a finite poset is a fundamental problem in both Combinatorics and Computer Science. In 1991, Brightwell and Winkler showed that #LE is #P-complete [BW91]. They conjectured that the following problem is #P-complete: Here height two means that P has two levels, i.e. no chains of length 3. This problem has been open for 27 years, most recently reiterated in [Hub14,LS17]. Its solution is the first result in this paper.
Our second result is an extension of Theorem 1. It was proposed recently by Lee and Skipper in [LS17], motivated by the optimization of nonlinear functions over the much-studied correlation polytope (see e.g. [DL97,LSS18]).
Theorem 2 implies Theorem 1, of course. Formally, the proofs of both results are independent, but use the same technical ideas of using number theory to to obtain targeted reductions modulo primes. Since the proof Theorem 1 is both technically and conceptually simpler, we chose to include both proofs.
Remark 3. The height-2 posets is an important and well studied class of posets. Brightwell and Winkler write: "We strongly suspect that Linear Extension Count for posets of height 2 is still #P-complete, but it seems that an entirely different construction is required to prove this" [BW91]. Incidence posets have also been studied quite intensely. We refer to recent papers [LS17,TW14] for an overview of the area and further references.

Notation
We assume the reader is familiar with basic definitions on posets, see e.g. [Tro95] and [Sta97,Ch. 3]. We describe a linear extension of a poset P = (X, ≺) on a set X with n elements informally as an assignment of the values {1, 2, . . . , n} to X, or formally as a function η : X → {1, 2, . . . , n}, s.t. η(x) < η(y) for all x ≺ y, x, y ∈ X. Finally, we refer to [MM11,Pap94] for notation, basic definitions and results in computational complexity.

Height two posets
Let P = (X, <) be a poset on a set X of n elements {x 1 , . . . , x n }. Denote by Γ = (X, E) its comparability graph, with oriented edges ( Denote by X a identical copy of X with elements {x 1 , . . . , x n }. Define the poset Q = (X ∪ X , ≺) on 2n elements, by having x i ≺ x i for all x i ∈ X, and x i ≺ x j for all x i < x j , with x i , x j ∈ X. In particular, the Hasse diagram of Q consists of n + |E| edges. Note that Q is a poset of height 2, see Figure 2.
x 4 x 2 x 3 x 1 Figure 1: The Hasse diagram of a poset P.
x 1 x 2 x 3 x 4 x 1 x 2 x 3 x 4 For every prime p between n and n 2 , we construct the modified poset Q p by adding, for all i and j satisfying 1 i n and 1 j p−2, the element x ij and the relation x ij ≺ x i . Note that Q p is still of height 2 and has pn elements (see Figure 3).
Consider η ∈ e {2,4,6,...,2n} (Q). We will show that η[ We have just proved this statement holds for the case m = n − 1. We proceed by induction on n − m. There exist x j ∈ X and x k ∈ X with η[x j ] = 2m and η[x k ] = 2m − 1. Note that we cannot have η[x k ] > 2m, since then we would have η[ Applying this result, we have so that Φ(Ψ(η)) = η, as desired.
Finally, for every pair , and Ψ(η) is a linear extension of P. We conclude that Φ and Ψ are inverse maps, which completes the proof.
The above lemma should be compared with the following result: Proof. Throughout the proof of this lemma, we will consider colorings of a set of integers. A coloring of a set is a function from that set to some list of acceptable colors.
Let A ∈ [2n] n , and write A = {a 1 , . . . , a n }, with a 1 < a 2 < · · · < a n . A coloring of the set [pn] = {1, 2, . . . , pn} is called A-compatible if the following conditions are satisfied: 1. there is a sequence of 2n integers b 1 < · · · < b 2n colored black, 2. there are another n colors C 1 , . . . , C n , and p − 2 integers are colored with each of these colors, 3. all of the elements colored with C k lie before b a k .
Let f p (A) be the number of A-compatible colorings of [pn]. Given a linear extension η ∈ e(Q), we write e η (Q p ) for the number of linear extensions of Q p which preserve the ordering on X ∪ X given by η. When η ∈ e A (Q), we claim that Given a linear extension η ∈ e A (Q) and a coloring in f p (A), we can construct (p − 2)! n linear extensions ρ ∈ e η (Q p ) as follows. Let the electronic journal of combinatorics 27(4) (2020), #P4.48 for all x i ∈ X, and similarly let ] some permutation of the integers with color C k . This gives (p − 2)! choices for each k, so the total number of linear extensions ρ preserving the ordering η for a fixed coloring is (p − 2)! n , as desired. Reversing this procedure gives a linear extension for every choice of a linear extension η ∈ e A (Q) and an A-compatible coloring. We then have, by Wilson's theorem: In an A-compatible coloring of {1, 2, . . . , pn}, there are a k − 1 + k(p − 2) terms to the left of b a k colored either black or one of the colors C 1 , . . . , C k . Among these terms, we can choose the position of the elements colored C k arbitrarily. This gives For A = {2, 4, 6, . . . , 2n}, we have a k = 2k, so this becomes by Lucas's theorem. For every other A with e A (Q) = 0, we have f p (A) ≡ 0 mod p. Indeed, suppose e A (Q) = 0 and consider some η ∈ e A (Q). Then η[x i ] = 2n for some i, since η[x i ] = 2n contradicts x i ≺ x i . Thus a n = 2n. We proceed by induction on n − k.
We need the following number theory result: Proposition 6 (see e.g. [BW91,p. 4]). For k 4, the product of primes between k and k 2 is at least 2 k k!.
Proof of Theorem 1. We make an argument based on the Chinese Remainder Theorem similar to that in [BW91]. Since e(P) n!, the proposition above together with the Chinese Remainder Theorem shows that computing the residue of e(P) mod p for the primes p with n p n 2 is sufficient to determine e(P). The lemmas above show that we can compute the residue of e(P) mod p by computing e(Q p ). Since #LE is #P-complete, so is #H2LE.

Counting incidence posets
Given a graph G = (V, E), we construct its incidence poset I G , with elements corresponding to vertices and edges of G, with x < y in P if and only if x ∈ E, y ∈ V and y is an endpoint of x. We write e(G) for the number of linear extensions of I G .
Our approach here is similar to our approach in Section 2. We produce, given a poset P and a prime p > |P|, a graph G p (P) with: e (G p (P)) ≡ (−1) |P| · 8 e(P) mod p.
Informally, to compute e σ (G) we visit the vertices of G in the order dictated by σ, accounting for the new edges we meet at each step. Formally, given a permutation σ ∈ S n , we produce the sequence {t 1 , . . . , t n }, where t i is the number of edges in E with x σ −1 (i) as an endpoint, and no endpoint x σ −1 (j) for j < i. Let {u 1 , . . . , u n } be the sequence of partial sums of the t i 's, so that Note that u k is the total number of edges incident to the set of vertices x σ −1 (1) , . . . , x σ −1 (k) .
Let |E| = m. Then we call a coloring of the set {1, 2, . . . , m + n} (G, σ)-compatible if the following conditions are satisfied: 1. there is a sequence of n integers b 1 < · · · < b n colored black, 2. there are another n colors C 1 , . . . , C n , and t k integers are colored with the color C k , 3. all of the elements colored with C k lie before b k .
Let f (G, σ) be the number of (G, σ)-compatible colorings. In such a coloring, there are u k + k − 1 numbers to the left of b k colored either black or one of the colors C 1 , . . . , C k . Among these terms, we can choose the position of the elements colored C k arbitrarily. This gives: A (G, σ)-compatible coloring corresponds to a collection of linear extensions of I G counted by e σ (G). The values assigned to the t k new edges at x σ −1 (k) are given by the numbers colored with C k , and these values can be assigned in (t k )! ways, so that we have: (1) In particular, when we are counting modulo p we can restrict our attention to permutations σ, which have corresponding sequences {t 1 , . . . , t n } with t i < p for all i. Informally, we want to visit each vertex of G in the order given by σ, deleting the edges incident to each vertex after we visit it, and ensure that no vertex has at least p edges by the time we visit it. Now we give the actual construction of G p (P). The first step is to construct a gadget J p , which is a graph defined as follows. Start with the complete bipartite graph K p−1,p−1 on 2p − 2 vertices. Call these vertices y 1 , . . . , y p−1 and z 1 , . . . , z p−1 and add an additional p − 2 edges from z p−1 to z i for 1 i < p − 1. Note that each of the y i 's has degree p − 1 and the z i 's have degree p (see Figure 4). We need the following: Lemma 7. e(J p ) ≡ −8 mod p.
We defer the proof of this lemma to the end of this section. To construct G p (P), add below J p the Hasse diagram of P (treated as an undirected graph). For each element x ∈ P, let v x be the number of elements in P that cover x. Add p − 1 − v x edges from x to the degree p − 1 vertices y i of J p in an arbitrarily way (see Figure 5).
Theorem 2 follows immediately from the following: Lemma 8. e(G p (P)) ≡ (−1) |P|+1 · 8 e(P) mod p Proof. Every maximal element of P has v x = 0, and so is connected to each of the y i 's in J p . Since P has at least one maximal element, every element of J p has degree p. Thus every σ which visits a vertex in J p before visiting every maximal element of P has x 4 x 2 x 3 x 1 Figure 5: G p (P) for P as in Figure 1 and p = 3.
a term t i p, so that e σ (G p (P)) ≡ 0 mod p. Likewise, of these permutations, every permutation σ that visits an element of P before visiting all of its immediate predecessors has e σ (G p (P)) ≡ 0 mod p.
Thus we can restrict our count of e(G p (P)) modulo p to permutations that have as their first n terms a linear extension of P. For these permutations, we have t 1 = t 2 = . . . = t n = p − 1, so that (t k )! ≡ −1 mod p by Wilson's theorem, and Furthermore, for every k > n, we have t 1 + . . . + t k = np − n + (t n+1 + · · · + t k ) + k − 1, so that Now comparing the expressions for e(G p (P)) and e(J p ) given by (1), we have e (G p (P)) ≡ (−1) |P| e(P)e(J p ) mod p, and Lemma 7 completes the proof.
Proof of Theorem 2. Using the same Chinese Remainder Theorem argument we used in Section 2, the two lemmas above show that computing e(G p (P )) for the primes between |P| and |P| 2 is sufficient to determine e(P). Since #LE is #P-Complete, so is #IPLE.

Proof of Lemma 7
Note that the values t k and u k + k − 1 in (1) are both independent of the order in which the previous k − 1 vertices are visited. They can be computed solely by identifying the vertex x σ −1 (k) and the collection of vertices {x σ −1 (i) } i<k . This motivates the following (4, 3, 1) (1, 0, 1) construction. Recall that the induced subgraphs of a graph G are those formed by deleting some vertices together with all incident edges. Take a directed graph G whose vertices are the induced subgraphs of J p and whose edges point from each subgraph to those obtained from it by deleting a single vertex. Attach to each edge the weight Then e(J p ) is equal to the sum of all weighted paths in G from J p to the empty subgraph. Let J p (a, b, c) be an induced subgraph of J p with a of the y i 's, b of the z i 's, for 1 i < p − 1, and c = 1 if z p−1 ∈ J p (a, b, c), c = 0 otherwise, for 0 a p − 1 and 0 b p − 2. Since the y i 's, and the z i 's, except for z p−1 , are indistinguishable, these subgraphs J p (a, b, c) are all of the induced subgraphs of J p , up to isomorphism.
We can thus reduce our graph of subgraphs G to the graph G containing only these 2p 2 − 2p vertices. We re-weight the edges from J p (a, b, c) where a, b or c is reduced by one, by multiplying by a, b or c, respectively. This accounts for the a, b or c choices of vertex to remove. Write (a, b, c) for the value of u k−1 + k − 1 upon reaching J p (a, b, c), that is, (a, b, c) is the number of vertices and edges that must be deleted from J p (p − 1, p − 2, 1) to give J p (a, b, c). Then (2) gives the weight of the edge from J p (a, b, c) to J p (a − 1, b, c) in terms of a, b, c and : The equations for the edges from J p (a, b, c) to J p (a, b−1, c) and J p (a, b, c−1) are the same up to a cyclic permutation of (a, b, c). The total number of edges in J p is (p−1) 2 +(p−2) = p 2 − p − 1. The number of edges in J p (a, b, c) is ab + ac + bc, and we reach J p (a, b, c) by deleting (p − 1 − a) + (p − 2 − b) + (1 − c) vertices. We then calculate: Lemma 9. When c = 1, (a + 2)(p − b − 2) > p and (p − a − 2)(b + 2) > p, every path in G that visits J p (a, b, c) has weight zero modulo p.
Proof. We argue by induction on (2p − 3) − (a + b), that is, on the distance in G from J p (p − 1, p − 2, 1) to J p (a, b, c). When a = p − 1, b = p − 2, c = 1, the conditions of the lemma are not met, and the statement is true vacuously. Now suppose that a, b, c satisfy the conditions in this lemma. Then a path that visits J p (a, b, c) must come from either J p (a + 1, b, c) or J p (a, b + 1, c). If the values a + 1, b, c satisfy the conditions in this lemma, we can then apply the induction hypothesis to show that every path through J p (a + 1, b, c) has weight 0 modulo p. In particular, a path that includes the edge from J p (a + 1, b, c) to J p (a, b, c) has weight 0 modulo p.
On the other hand, suppose that a + 1, b, c do not satisfy the conditions in this lemma.
. Thus, (a+1, b, c) > p (a, b, c), and so by (3), the edge from J p (a+1, b, c) to J p (a, b, c) has weight 0 modulo p. The argument for the edge from J p (a, b + 1, c) to J p (a, b, c) is the same by symmetry.
Lemma 10. Given a, b with (b + 2)(p − a − 2) p the edge from J p (a, b, 1) to J p (a, b, 0) has weight 0 unless a = p − 3 and b = 0, a = p − 2 and b = 0 or 1, or a = p − 1 with b arbitrary. Similarly, given a, b with (a + 2)(p − b − 2) p, the edge from J p (a, b, 1) to J p (a, b, 0) has weight 0 unless b = p − 3 and a = 0, or b = p − 2 and a = 0 or 1.
Proof. We give the proof of the first statement, since the proof of the second is essentially identical. Permuting (a, b, c) in (3) to find the weight of the edge from J p (a, b, 1) to J p (a, b, 0), we note that we must have a + b < p and a + b < p a + b + (a, b, 1). Since (a, b, 1) ≡ (b + 2)(p − a − 2) mod p, this gives: This implies that p < a + 1 + 3 b+1 a + 4.
We conclude that a > p − 4, and the rest of the lemma follows by elementary case analysis.
Proof of Lemma 7. Note that the edges from J p (p − 1, p − 2, 1) to J p (p − 1, p − 3, 1) and J p (p − 1, p − 2, 0) have weight 0 modulo p. Combining this with the previous two lemmas, we conclude that every path in G has weight 0 modulo p unless it visits either J p (p−2, 1, 1) or J p (1, p − 2, 1). We now complete the desired calculation, through repeated applications of (3), symmetry, and Wilson's theorem: (p − 2, 1, 1)) + e J p (p − 2, 0, 1) ≡ 2 e J p (p − 2, 1, 1) This completes the proof. where n = |V |, vol(∆ n ) = √ n/(n − 1)!, and P G,X is a poset constructed from G and X [MR16, Prop. 3] (see also [Sta97] for a strongly related order polytope). The poset P G,X is formed by taking the elements of V together with the relation x < y for every pair (x, y) with x ∈ X and (x, y) ∈ E. This poset has height 2, with vertices in X on one level and V X on the other. The authors then discuss the problem of computing e P G,X .

Polytope of modes
The following result follows easily from our Theorem 2. Curiously, we learned about this problem after the paper had been written.
Proposition 11. For every incidence poset I G of a simple graph G = (V, E), there exists some graph H and some independent set X ⊆ H with P H,X = I G .
Proof. The desired graph H is the medial graph defined as a graph on the set of vertices V ∪ E. The edges of this graph are pairs (v, e) where v is incident to e in G. This graph is bipartite, so V is an independent set, and we take X = V . Now we note that the poset P H,X consists of the set V ∪ E together with the relation v < e whenever v is incident to e, so that P H,X = I G , as desired.
Corollary 12. The problem of computing e P G,X is #P-complete.
Proof. By the proposition, computing e P H,X allows us to compute e(I G ) for any graph G. Applying Theorem 2 completes the proof.