Skip to main content
Springer logoLink to Springer
. 2018 Sep 4;81(4):1657–1683. doi: 10.1007/s00453-018-0496-4

Counting Linear Extensions: Parameterizations by Treewidth

E Eiben 1,, R Ganian 2, K Kangas 3, S Ordyniak 4
PMCID: PMC6449496  PMID: 31007326

Abstract

We consider the #P-complete problem of counting the number of linear extensions of a poset (#LE); a fundamental problem in order theory with applications in a variety of distinct areas. In particular, we study the complexity of #LE parameterized by the well-known decompositional parameter treewidth for two natural graphical representations of the input poset, i.e., the cover and the incomparability graph. Our main result shows that #LE is fixed-parameter intractable parameterized by the treewidth of the cover graph. This resolves an open problem recently posed in the Dagstuhl seminar on Exact Algorithms. On the positive side we show that #LE becomes fixed-parameter tractable parameterized by the treewidth of the incomparability graph.

Keywords: Partially ordered sets, Linear extensions, Parameterized complexity, Structural parameters, Treewidth

Introduction

Counting the number of linear extensions of a poset is a fundamental problem of order theory that has applications in a variety of distinct areas such as sorting [30], sequence analysis [25], convex rank tests [27], sampling schemes of Bayesian networks [28], and preference reasoning [24]. Determining the exact number of linear extensions of a given poset is known to be #P-complete [6] already for posets of height at least 3. Informally, #P-complete problems are as hard as counting the number of accepting paths of any nondeterministic Turing machine, implying that such problems are not tractable unless P = NP. The currently fastest known method for counting linear extensions of a general n-element poset is by dynamic programming over the lattice of downsets and runs in time O(2n·n) [10]. Polynomial time algorithms have been found for various special cases such as series-parallel posets [26] and posets whose cover graph is a (poly)tree [2]. Fully polynomial time randomized approximation schemes are known for estimating the number of linear extensions [7, 13].

Due to the inherent difficulty of the problem, it is natural to study whether it can be solved efficiently by exploiting the structure of the input poset. In this respect, the parameterized complexity framework [9, 12] allows a refined view of the interactions between various forms of structure in the input and the running time of algorithms. The idea of the framework is to measure the complexity of problems not only in terms of input sizes, but also with respect to an additional numerical parameter. The goal is then to develop so-called fpt algorithms, which are algorithms that run in time f(k)nO(1) where n is the input size and f is a computable function depending only on the parameter k. A less favorable outcome is a so-called XP algorithm, which runs in time nf(k); the existence of such algorithms then gives rise to the respective complexity classes FPT (fixed-parameter tractable) and XP.

The first steps in this general direction have been taken, e.g., in [19], using the decomposition diameter as a parameter, in [15] using a parameter called activity for N-free posets, and very recently in [22], where the treewidth of the so-called cover graph was considered as a parameter. Also the exact dynamic programming algorithm [10] can be shown to run in time O(nw·w) for a poset with n elements and width w (the size of the largest anti-chain). Interestingly, none of these efforts has so far led to an fpt algorithm.

We believe that this uncertainty about the exact complexity status of counting linear extensions with respect to these various parameterizations is at least partly due to the fact that we deal with a counting problem whose decision version is trivial, i.e., every poset has at least one linear extension. This fact makes it considerably harder to show that the problem is fixed-parameter intractable; in particular, the usual approach based on parsimonious reductions fails. On the other hand, the same predicament makes studying the complexity of counting linear extensions significantly more interesting, as noted also by Flum and Grohe [16]:

The theory gets interesting with those counting problems that are harder than their corresponding decision versions.

Results

In this paper we study the complexity of counting linear extensions when the parameter is the treewidth—a fundamental graph parameter which has already found a plethora applications in many areas of computer science [17, 18, 29]. In particular, we settle the fixed-parameter (in)tractability of the problem when parameterizing by the treewidth of two of the most prominent graphical representations of posets, the cover graph (also called the Hasse diagram) and the incomparability graph.

Our main result then provides the first evidence that the problem does not allow for an fpt algorithm parameterized by the treewidth of the cover graph unless FPT=W[1]. We remark that this complements the XP algorithm of [22] and resolves an open problem recently posed in the Dagstuhl seminar on Exact Algorithms [21]. The result is based on a so-called fpt turing reduction from Equitable Coloring parameterized by treewidth [14], and combines a counting argument with a fine-tuned construction to link the number of linear extensions with the existence of an equitable coloring. To the best of our knowledge, this is the first time this technique has been used to show fixed-parameter intractability of a counting problem.

We complement this negative result by obtaining an fpt algorithm for the problem when the parameter is the treewidth of the incomparability graph of the poset. To this end, we use the so-called combined graph (also called the cover-incomparability graph [5]) of the poset, which is obtained from the cover graph by adding the edges of the incomparability graph. We employ a special normalization procedure on a decomposition of the incomparability graph to show that the treewidth of the combined graph must be bounded by the treewidth of the incomparability graph. Once this is established, the result follows by giving a formulation of the problem in Monadic Second Order Logic and applying an extension of Courcelle’s Theorem for counting.

Organization of the Paper

The paper is organized as follows. Section 2 introduces the required preliminaries and notation. Section 3 is then dedicated to proving the fixed-parameter intractability of the problem when parameterized by the treewidth of the cover graph, and the subsequent Sect. 4 presents our positive results for the problem. Concluding notes are then provided in Sect. 5.

Preliminaries

For standard terminology in graph theory, such as the notions of a graph, digraph, path, etc. we refer readers to [11]. Given a graph G, we let V(G) denote its vertex set and E(G) its edge set. The (open) neighborhood of a vertex xV(G) is the set {yV(G):{x,y}E(G)} and is denoted by N(x). The closed neighborhood N[v] of v is defined as N(v){v}. A path between two disjoint vertex sets A,BV(G) is a path with one endpoint in A, one endpoint in B, and all internal vertices disjoint from AB. A set XV(G) is a separator in G if G-X contains at least two connected components.

We use [i] to denote the set {0,1,,i}. The following fact about prime numbers will also be useful later.

Fact 1

([6]) For any n4, the product of primes strictly between n and n2 is at least n!2n.

Treewidth

A tree-decomposition of a graph G is a pair (T,X={Xt}tV(T)), where T is a rooted tree whose every vertex t is assigned a vertex subset XtV(G), called a bag, such that the following properties hold:

  1. tV(T)Xt=V(G),

  2. for every uV(G), the set Tu={tV(T):uXt} induces a connected subtree of T (monotonicity), and

  3. for each uvE(G) there exists tV(T) such that u,vXt.

To distinguish between the vertices of the tree T and the vertices of the graph G, we will refer to the vertices of T as nodes; for brevity, we will also interchange T and V(T) when the context is clear. The width of the tree-decomposition T is maxtT|Xt|-1. The treewidth of G, tw(G), is the minimum width over all tree-decompositions of G.

In some cases, we will make use of a well-established canonical form of tree-decompositions. A tree-decomposition T=(T,X) is nice if T contains a root r (introducing natural ancestor-descendant relations in T) and the following conditions are satisfied:

  • Xr= and X= for every leaf of T. In other words, all the leaves as well as the root contain empty bags.

  • Every non-leaf node of T is of one of the following three types:
    • Introduce node A note t with exactly one child t such that Xt=Xt{v} for some vertex vXt; we say that v is introduced at t. If uXt and uv is an edge in G, then we also say that uv is introduced at t.
    • Forget node A note t with exactly one child t such that Xt=Xt\{w} for some vertex wXt; we say that w is forgotten at t.
    • Join node A node t with two children t1, t2 such that Xt=Xt1=Xt2.

We note that there exists a polynomial-time algorithm that converts an arbitrary tree-decomposition into a nice tree-decomposition of the same width [23]. A path-decomposition is a tree-decomposition where each node of T has degree at most 2, and nice path-decompositions are nice tree-decompositions which do not contain join nodes. Nice path-decompositions can also be computed from standard path-decompositions in polynomial time while preserving width [23]. Observe that any path-decomposition can be fully characterized by the order of appearance of its bags along T, and hence we will consider succinct representations of path-decompositions in the form Q=(Q1,,Qd), where Qi is the i-th bag in Q. The pathwidth of G, pw(G), is the minimum width of a path-decomposition of G.

We list some useful facts about treewidth and pathwidth.

Fact 2

[3, 4] There exists an algorithm which, given a graph G and an integer k, runs in time O(kO(k3)n) and either outputs a tree-decomposition of G of width at most k or correctly identifies that tw(G)>k. Furthermore, there exists an algorithm which, given a graph G and an integer k, runs in time O(kO(k3)n) and either outputs a path-decomposition of G of width at most k or correctly identifies that pw(G)>k.

Fact 3

(Folklore) Let T be a tree-decomposition of G and tT. Then each connected component of G-Xt lies in a single subtree of T-t. In particular, for each connected component C of G-Xt there exists a subtree T of T-t such that for each vertex aC there exists taT such that aXta.

We note that if G is a directed graph, then tw(G) and a tree-decomposition of G refer to the treewidth and a tree-decomposition of the underlying undirected graph of G, i.e., the undirected graph obtained by replacing each directed edge with an edge (and removing duplicate edges).

Monadic Second Order Logic

We consider Monadic Second Order (MSO) logic on (edge-)labeled directed graphs in terms of their incidence structure whose universe contains vertices and edges; the incidence between vertices and edges is represented by a binary relation. We assume an infinite supply of individual variablesx,x1,x2, and of set variablesX,X1,X2, The atomic formulas are Vx (“x is a vertex”), Ey (“y is an edge”), Ixy (“vertex x is incident with edge y”), Hxy (“vertex x is the head of the edge y”), Txy (“vertex x is the tail of the edge y”), x=y (equality), xy (inequality), Pax (“vertex or edge x has label a”), and Xx (“vertex or edge x is an element of set X”). MSO formulas are built up from atomic formulas using the usual Boolean connectives (¬,,,,), quantification over individual variables (x, x), and quantification over set variables (X, X).

Let Φ(X) be an MSO formula with a free set variable X. For a labeled graph G=(V,E) and a set SE we write GΦ(S) if the formula Φ holds true on G whenever X is instantiated with S.

The following result (an extension of the well-known Courcelle’s Theorem [8]) shows that if G has bounded treewidth then we can count the number of sets S with GΦ(S).

Fact 4

[1] Let Φ(X) be an MSO formula with a free set variable X and w a constant. Then there is a linear-time algorithm that, given a labeled directed graph G=(V,E) of treewidth at most w, outputs the number of sets SE such that GΦ(S).

We note that the above result requires a tree-decomposition of width at most w to be provided with the input. However, as seen in Fact 2, for a graph of treewidth at most w such a tree decomposition can be found in linear time, hence we can drop this requirement from the statement of the theorem.

Posets

A partially ordered set (poset) P is a pair (P,P) where P is a set and P is a reflexive, antisymmetric, and transitive binary relation over P. The size of a poset P=(P,P) is |P|:=|P|. We say that pcoversp for p,pP, denoted by pPp, if pPp, pp, and for every p with pPpPp it holds that p{p,p}. We say that p and p are incomparable (in P), denoted pPp, if neither pPp nor pPp.

A chainC of P is a subset of P such that xPy or yPx for every x,yC. An antichainA of P is a subset of P such that for all x,yA it is true that xPy. A family C1,,C of pairwise disjoint subsets of P forms a total order if for each i,j[] and each aCi, bCj, it holds that ab iff i<j. Furthermore, for each i[-1] we say that Ci and Ci+1 are consecutive. We call a poset P such that every two elements of P are comparable a linear order. A linear extension of a poset P=(P,P) is a reflexive, antisymmetric, and transitive binary relation over P such that xy whenever xPy and the poset P=(P,) is a linear order.

We denote the number of linear extensions of P by e(P). For completeness, we provide a formal definition of the problem of counting the number of linear extensions below. graphic file with name 453_2018_496_Figa_HTML.jpg

We consider the following graph representations of a poset P=(P,P). The cover graph of P, denoted C(P), is the undirected graph with vertex set P and edge set {{a,b}|ab}. The incomparability graph of P, denoted I(P), is the undirected graph with vertex set P and edge set {{a,b}|ab}. The combined graph of P, denoted IC(P), is the directed graph with vertex set P and edge set {(a,b)|(ab)(ab)}. Finally, the poset graph of P, denoted PG(P), is the directed graph with vertex set P and edge set {(a,b)|ab}. We will use the following known fact about tree-decompositions and path-decompositions of incomparability graphs.

Fact 5

[20, Theorem 2.1] Let P be a poset. Then tw(I(P))=pw(I(P)).

Corollary 1

(of Facts 2 and 5) Let P be a poset and k=tw(I(P)). Then it is possible to compute a nice path-decomposition Q of I(P) of width at most k in time O(kO(k3)n).

Parameterized Complexity

We refer the reader to [9, 12, 16] for an in-depth introduction to parameterized complexity; here we only briefly summarize the most important notions required by our results.

A parameterized counting problemA is a function Σ×NN for some finite alphabet Σ. We call a parameterized counting problem Afixed-parameter tractable (FPT) if A can be computed in time f(k)·|x|O(1) where f is an arbitrary computable function and (xk) is the instance. The complexity class W[1] can be seen an the analog of NP for parameterized decision problems. To prove that a parameterized problem A is W[1]-hard, one can give an fpt turing reduction from a known W[1]-hard problem B to A; such an fpt turing reduction is a deterministic algorithm solving A with an oracle to B with the following properties: (a) the algorithm is FPT, and (b) the parameter for B in each oracle query is bounded by a function of the parameter for A. To avoid confusion, we remark that there also exists the complexity class #W[1] which is an analog of #P for parameterized counting problems.

Our main negative result is based on an fpt turing reduction from the following fairly well-known W[1]-hard decision problem [14]. graphic file with name 453_2018_496_Figb_HTML.jpg

We denote by #EC(G,r) the number of equitable colorings of graph G with r colors. We remark that the problem remains W[1]-hard even if we restrict to the instances, where |V(G)| is divisible by r. This can be seen, for example, by padding of the instance by a single isolated clique.

Fixed-Parameter Intractability of Counting Linear Extensions

The goal of this section is to prove Theorem 1, stated below.

Theorem 1

#LE parameterized by the treewidth of the cover graph of the input poset does not admit an fpt algorithm unless W[1]=FPT.

We begin by giving a brief overview of the proof, whose general outline follows the #P-hardness proof of the problem [6]. However, since our parameter is treewidth, we needed to reduce from a problem that is not fixed-parameter tractable parameterized by treewidth. Consequently, instead of reducing from SAT, we will use Equitable Coloring. This made the reduction considerably more complicated and required the introduction of novel gadgets, which allow us to encode the problem without increasing the treewidth too much.

The proof is based on solving an instance (Gr) of Equitable Coloring[tw] in FPT time using an oracle that solves #LE in FPT time parameterized by the treewidth of the cover graph (i.e., an fpt turing reduction). The first step is the construction of an auxiliary poset P(G,r) of size 2(r-1)|V(G)|+(r2-1)|E(G)|. Then, for a given sufficiently large (polynomially larger than |V(G)|) prime number p, we show how to construct a poset P(G,r,p) such that e(P(G,r,p))e(P(G,r))·#EC(G,r)·Apmodp, where Ap is a constant that depends on p and is not divisible by p. Therefore, if we choose a prime p that does not divide e(P(G,r))·#EC(G,r), then e(P(G,r,p)) will not be divisible by p. Using Fact 1 we show that if #EC(G,r)0, then there always exists a prime p within a specified polynomial range of |V| such that p does not divide e(P(G,r))·#EC(G,r).

From the above, it follows that there exists an equitable coloring of G with r colors if and only if, for at least one prime p within a specified (polynomial) number range, the number of linear extensions of P(G,r,p) is not divisible by p. Moreover, we show that all inputs for the oracle will have size polynomial in the size of G and treewidth bounded by a polynomial in tw(G)+r. Before proceeding to a formal proof of Theorem 1, we state two auxiliary lemmas which will be useful for counting linear extensions later in the proof.

Lemma 1

If a poset P is a disjoint union of posets P1,,Pk for some positive integer k, then

e(P)=i=1k|Pi|!i=1k|Pi|!i=1ke(Pi).

Proof

We use induction on k, and observe that the lemma trivially holds for k=1. Let Q denote the disjoint union of posets P1,,Pk-1. For each combination of linear extension of Q and of Pk there are |Q|+|Pk||Pk| linear extensions of P. Hence,

e(P)=e(Q)e(Pk)|Q|+|Pk||Pk|=(i=1k-1|Pi|)!i=1k-1|Pi|!(i=1k-1e(Pi))·e(Pk)·i=1k|Pi||Pk|=(i=1k-1|Pi|)!i=1k-1|Pi|!(i=1k|Pi|)!(i=1k-1|Pi|)!|Pk|!i=1ke(Pi)=(i=1k|Pi|)!i=1k|Pi|!i=1ke(Pi).

In the following we say that a set C of elements of a poset P is a connected component of P if C is a connected component of C(P).

Lemma 2

Let p be a prime number and Q be a connected component of a poset P such that |Q|=p-1. If the number of linear extensions of P is not divisible by p, then the number of elements in each connected component of P other than Q is divisible by p.

Proof

Let P1 be a connected component of P different than Q. First note that from Lemma 1, it is clear that e(P) will be divisible by the number of linear extensions of the poset P formed as a disjoint union of Q and P1. Now, by Lemma 1 it holds that

e(P)=(p-1+|P1|)!(p-1)!|P1|!e(P1)e(Q).

Since e(P) is not divisible by p, it must follow that e(P) is also not divisible by p. Note that (p-1+|P1|)!(p-1)!|P1|!=p-1+|P1|p-1 is a natural number and a divisor of e(P). Furthermore, (p-1)! cannot be divisible by p since p is prime. Hence it follows that (p-1+|P1|)!|P1|!=p-1+|P1|p-1·(p-1)! cannot be divisible by p. Suppose that |P1|=ap+b for some non-negative integers a and b such that b<p; then we obtain that the expression (p-1+ap+b)!(ap+b)! is not divisible by p. But

(p-1+ap+b)!(ap+b)!=i=1p-1ap+b+i,

which is clearly divisible by (a+1)p whenever b1. Therefore b=0 and hence |P1| is divisible by p, which concludes the proof of the lemma.

We now proceed to the proof of our main theorem.

Proof

(of Theorem 1) The proof is structured as follows. We begin by giving the construction of P(G,r) and P(G,r,p), after which we establish the desired properties of P(G,r,p) and P(G,r), and summarize in the conclusion.

Construction ofP(G,r)and the main gadget Let (Gr) be an instance of Equitable Coloring[tw] such that |V(G)| is divisible by r (if this is not the case, then this can be enforced by padding the instance with isolated vertices, see also [14]). We begin by constructing the poset P(G,r), which will play an important role later on. For every vertex v of V(G) we create 2(r-1) elements denoted vi,j, where 1ir-1 and j{0,1}, such that the only dependencies in the poset between these elements are vi,1vi,0 for all vV(G), for all i{1,,r-1}. For every edge e=uvE(G) we create r2-1 pairwise-incomparable elements ei,j, such that (i,j)({0,,r-1}2\{(0,0)}). The dependencies of ei,j are: if i>0 then ui,0ei,j, and if j>0 then vj,0ei,j (see also Fig. 1).

Fig. 1.

Fig. 1

The cover graph for an edge e=uv of G in P(G,3)

Construction ofP(G,r,p) Let us now fix a prime number p such that p does not divide e(P(G,r)) and p>2r|V(G)|+r2|E(G)|. The main gadget in our reduction is a so-called (ab)-flower, which consists of an antichain of a vertices (called the petals) covering a chain of p-b elements (called the stalk); an illustration is provided in Fig. 2. Due to Lemma 2, (ab)-flowers will later allow us to force a choice of exactly b vertices out of a.

Fig. 2.

Fig. 2

An (ab)-flower

Let G be a graph, r be an integer and p be a prime number as above. Recall that |V(G)| is divisible by r and let s=|V(G)|r (note that this implies that each color in an equitable coloring of G must occur precisely s times in G). We proceed with a description of the poset P(G,r,p). The poset P(G,r,p) is split into r+3levelsL1,,Lr+3 by linearly ordered elements a0a1ar+2ar+3, called the anchors. Each of these levels, besides Lr+3, will consist of some flowers and a chain of p-1 elements which we call a stick; each of these flowers and the stick will always be pairwise incomparable. The anchors a0 and ar+3 are the unique minimum and maximum elements, respectively. The stick and all the stalks of flowers in level Li will always lie between two consecutive elements ai-1 and ai, and the petals of these flowers will be incomparable with ai as well as some anchors above that (as defined later). Observe that while the relative position of any stalk and any anchor is fixed in every linear extension, petals can be placed above ai.

We say that a flower (or its stalk, petals, or elements) is associated with the level in which it is constructed, i.e., with the level Li such that ai-1cai for stalk elements c and ai-1d and dai for petals d. We denote the set of all petals associated with level Li as Ai (see Fig. 3). For the construction, it will be useful to keep in mind the following intended goal: whenever an (ab)-flower is placed in level i, it will force the selection of precisely b petals (from its total of a petals), where selected elements remain on level i (i.e., between ai-1 and ai) in the linear extension and unselected elements are moved to level r+2 (i.e., between ar+2 and ar+3) in the linear extension. We will later show that the total number of linear extensions which violate this goal must be divisible by p, and hence such extensions can all be disregarded modulo p.

Fig. 3.

Fig. 3

Each level consists of a chain of length p-1 and a few flowers. The set of petals associated with level Li is denoted by Ai

The first r levels are so-called color class levels, each representing one color class. We use these levels to make sure that every color class contains exactly s vertices. Aside from the stick, each such level contains a single (|V(G)|, s)-flower. Recall that the stalk and the stick on level 1ir both lie between anchors ai-1 and ai, and that the stalk and the flower are incomparable. We associate each petal of the flower at level Li with a unique vertex vV(G) and denote the petal vi. Each petal vi will be incomparable with all anchors above ai-1 up to ar+3, i.e., viaj for ijr+2 and viar+3. Intuitively, the flower in each color class level will later force a choice of s vertices to be assigned the given color.

Level Lr+1 is called the vertex level and consists of one stick and |V(G)|-many (r, 1)-flowers; the purpose of this level is to ensure that every vertex is assigned exactly one color. Each flower is associated with one vertex vV(G) and we denote the petals of the flower associated with vertex v as vi for 1ir. We set vivi for all vV(G) and 1ir.

Level Lr+2 is called the edge level, and its purpose is to ensure that the endpoints of every edge have a different color. It consists of a stick and |E(G)|-many (r2,1)-flowers. Each flower is associated with one edge e=uvV(G) and we denote the petals of the flower associated with e as ei,j for 1ir and 1jr. Moreover, for edge e=uv we set uiei,j, vjei,j, and we set ar+2ei,j whenever i=j. Observe that this forces any petal ei,i to lie between ar+2 and ar+3 in every linear extension (i.e., prevents ei,i from being “selected”).

Level Lr+3 is called the trash level. It does not contain any new elements in the poset, but it plays an important role in the reduction: we will later show that any petals which are interpreted as “not selected” must be located between ar+2 and ar+3 in any linear extension that is not automatically “canceled out” due to counting modulo p.

A high-level overview of the whole constructed poset P(G,r,p) is presented in Fig. 4.

Fig. 4.

Fig. 4

The cover graph of P(G,r,p). The edge e is the edge in G between vertices u and v

Establishing the desired properties ofP(G,r,p)andP(G,r) We begin by formalizing the notion of selection. Let a configuration be a partition ϕ of petals of all flowers into r+3 sets L1ϕ,,Lr+3ϕ. Let Φ denote a set of all configurations. We say that a linear extension of P(G,r,p)respects the configuration ϕ if L1ϕa1L2ϕa2ar+2Lr+3ϕ and we denote the set of all linear extensions of P(G,r,p) that respects ϕ by Lϕ. We say that a configuration ϕ is consistent if Lϕ is non-empty; this merely means that L1ϕa1L2ϕa2ar+2Lr+3ϕ does not violate any inequalities in P(G,r,p). Observe that if ϕ is consistent, then Lϕ is exactly the set of linear extension of the partial order Pϕ(G,r,p), where Pϕ(G,r,p) is obtained by enriching P(G,r,p) with the relations L1ϕa1L2ϕa2ar+2Lr+3ϕ and performing transitive closure (in other words, Pϕ(G,r,p) is obtained by enforcing ϕ onto P(G,r,p)).

Since every linear extension of P(G,r,p) respects exactly one configuration, it is easy to see that e(P(G,r,p))=ϕΦ|Lϕ|=ϕΦe(Pϕ(G,r,p)). Intuitively, a configuration ϕcontributes to the above sum modulo p if e(Pϕ(G,r,p)) is not divisible by p. We shall prove that the only configurations which contribute to this sum modulo p are those where from every (ab)-flower there are exactly b petals in the same level as the stalk, and the remaining a-b petals are in the trash. Furthermore, in each configuration ϕ which contributes to the above sum modulo p, the petals in Lr+1ϕ represent a proper equitable coloring of G with r colors, and each such configuration is respected by the same number of linear extensions.

Let us first remark that for any configuration ϕ, the anchors a0,a1,,ar+3 are comparable to all elements of Pϕ(G,r,p). Now, let PLiϕ be the poset induced by all elements ePϕ(G,r,p) such that ai-1eai and eai-1, eai. It is readily seen that e(Pϕ(G,r,p))=i=1r+3e(PLiϕ). We proceed by stating a series of claims about our construction.

Claim 1

For each i{1,,r}, it holds that either e(PLiϕ)0modp, or e(PLiϕ)=s!2p-1p and Liϕ contains exactly s petals of Ai and no other petals.

Proof

(of the Claim) Assume that e(PLiϕ)0modp and recall that level Li contains a stick, which is a chain of p-1 elements that is incomparable with all elements of PLiϕ in every configuration ϕ. By Lemma 2 this implies that every connected component of PLiϕ distinct from the stick has size divisible by p. Clearly, Liϕ contains only those stalks that are associated with the level Li, and it contains all such stalks. It is readily seen from the construction that any petal in j<iAj would necessarily form a component of size one in PLiϕ. Hence, PLiϕ contains only elements associated with level Li, namely elements of the stick and elements of a (|V(G)|, s)-flower. Moreover, by Lemma 2 and the fact that |V(G)|+p-s<2p, each such flower has exactly p elements in level PLiϕ. Since the p-s elements of the stalk must be in PLiϕ, the poset PLiϕ contains exactly s elements of Ai. Clearly, the number of linear extensions of the petals of the (|V(G)|, s)-flower in PLiϕ is s! and hence by Lemma 1e(PLiϕ)=s!2p-1p, which concludes the proof.

Claim 2

Either e(PLr+1ϕ)0modp, or e(PLr+1ϕ)=(|V(G)|p+p-1)!(p-1)!(p!)|V(G)| and Lr+1ϕ contains exactly |V(G)| elements of Ar+1, specifically one petal for each (r, 1)-flower on level Lr+1.

Proof

(of the Claim) Assume e(PLr+1ϕ)0modp, and let us first examine elements that are not associated with level Lr+1. Clearly, no element associated with level Lr+2 can appear in PLr+1ϕ and the only elements associated with any level i<r+1 that can end up in PLr+1ϕ are petals. Each of these elements is smaller than exactly one petal at level Lr+1 and incomparable to all other elements associated with this level. It is easy to see that largest possible size of a connected component of PLr+1ϕ is p-1+2r<2p. By Lemma 2, every connected component in PLr+1ϕ (except for the stick) will have size p, and therefore PLr+1ϕ will contain exactly one element for every set of petals associated with Lr+1 and no other elements. Hence, PLr+1ϕ consists of |V(G)| chains of length p and one chain of length p-1. Then e(PLr+1ϕ)=(|V(G)|p+p-1)!(p-1)!(p!)|V(G)| follows from Lemma 1.

Claim 3

Either e(PLr+2ϕ)0modp, or e(PLr+2ϕ)=(|E(G)|p+p-1)!(p-1)!(p!)|E(G)| and Lr+2ϕ contains exactly |E(G)| elements of Ar+2, specifically one petal for each (r2,1)-flower on level Lr+2.

Proof

(of the Claim) The idea of the proof is similar to the proof of the previous claim, with one additional obstacle: that several flowers can be connected with petals from lower levels into one connected component on level Lr+2 through the petals of flowers on level Lr+1. So, assume e(PLr+2ϕ) contains a connected component C which contains at least a single stalk. If C contains precisely the single stalk, then by Lemma 2 we have e(PLr+2ϕ)0modp. Otherwise, for each stalk in C, there must be at least one petal in the same flower (otherwise the stalk cannot be connected to the rest of C); in other words, the intersection of each flower and C contains at least p vertices. Let a denote the number of flowers which intersect C, b2 denote |Ar+2C|, b1 denote |Ar+1C| and b0 denote i=1r|ArC|. Then it follows that |C|=p·a+(b2-a)+b1+b0p·a+r2|E|+r|V|+r|V|, and recall that r2|E|+r|V|+r|V|<p. Furthermore, if b1>0 (and at least one petal from Ar+1 is required unless C contains only a single flower), we have a·p<|C|<(a+1)·p. Hence any such C cannot have size divisible by p and by Lemma 2 we have e(PLr+2ϕ)0modp. Otherwise, if no two flowers are connected through a petal of a flower associated with level Lr+1, then every connected component of PLr+2ϕ of size p must consist of a stalk and exactly one petal and the claim follows analogously as the proof of Claim 2.

Claim 4

If ϕ is a consistent configuration and for all i{1,,r+2} it holds that e(PLiϕ)0modp, then 1) the petals in Lr+1ϕ encode a proper equitable coloring of V(G) where vertex v receives color i iff the petal vi lies in Liϕ, and 2)PLr+3ϕ is isomorphic with P(G,r).

Proof

(of the Claim) From Claims 12 and 3 together with the assumption that e(PLiϕ)0modp, it follows that each of the levels L1ϕ,,Lrϕ contains exactly s petals associated with the corresponding level, level Lr+1ϕ contains exactly one petal for each vertex of G and level Lr+2ϕ contains exactly one petal for each edge of G.

For the first part of this claim, we observe that each pair of petals in L1ϕ,,Lrϕ are associated with distinct vertices of G. If this were not the case, then since |V(G)|=rs there would exist a vertex v such that no element of L1ϕ,,Lrϕ is associated with v. But due to the construction at level r+1 there exists some i{1,,r} such that viLr+1ϕ. Then, since vivi and vi can only occur either in level Liϕ or Lr+3ϕ (the latter of which lies above vi in the linear extension due to the configuration ϕ), this would lead to a contradiction. In particular, we conclude that there is a matching between the petals in level r+1 (encoding the color for each vertex) and the union of petals in levels 1,2,r (encoding the vertices assigned to each color class), and by Claim 1 it follows that there are exactly s petals in Lr+1 associated with each color class.

We now argue that the coloring is proper. Observe that by the same argument as above, if an edge e=uv satisfies ei,jLr+2ϕ, then uiLr+1ϕ and vjLr+1ϕ. From the construction of P(G,r,p) it follows that if i=j, then ei,jLr+2. Combining these two facts we get that the coloring encoded in Lr+1ϕ is indeed proper.

Now let us take a look at level Lr+3ϕ. To prove the claim, we will construct an isomorphism f from elements of PLr+3ϕ to elements of P(G,r). For every vertex vV(G), precisely one element viLr+1ϕ and precisely one of the first r levels contains an element associated with v; to be precise, viLiϕ and vjLr+3ϕ and hence also vjLr+3ϕ for all ji. We set f(vj)=vj,0 and f(vj)=vj,1, whenever ji and j<r. For the last remaining elements, we set f(vr)=vi,0 and f(vr)=vi,1. Next, for every edge e=uv there is exactly one ea,bLr+2ϕ. Moreover, if ea,bLr+2ϕ then uaLr+1ϕ and vbLr+1ϕ, and all other petals for this edge e are in Lr+3ϕ. Let gi(r)=i, gi(i)=0, and gi(k)=k otherwise. Then we set f(ei,j)=ega(i),gb(j). Observe that, since ea,b does not lie in Lr+3ϕ, no edge is mapped to the non-existent element e0,0 in P(G,r). It is straightforward to verify that f is really bijective mapping between elements of PLr+3ϕ and P(G,r). Moreover, f(u)f(v) in P(G,r) if and only if uv in PLr+3ϕ. Therefore, PLr+3ϕ is isomorphic with P(G,r) and the claim holds.

Claim 5

e(P(G,r,p))0modp if and only if e(P(G,r))·#EC(G,r)0modp.

Proof

(of the Claim) From previous claims and in particular Claim 4, we already know that e(Pϕ(G,r,p))0modp only if ϕ corresponds to an equitable coloring of G with r colors. Moreover, we know that e(Pϕ(G,r,p))=i=1r+3e(PLiϕ) and if e(Pϕ(G,r,p))0modp, then

i=1r+3e(PLiϕ)=s!2p-1pr(|V(G)|p+p-1)!(p-1)!(p!)|V(G)|(|E(G)|p+p-1)!(p-1)!(p!)|E(G)|e(P(G,r)).

Since p>|V(G)|+|E(G)|, (|V(G)|p+p-1)! is divisible by p|V(G)|, but not by p|V(G)|+1 and (|E(G)|p+p-1)! is divisible by p|E(G)|, but not by p|E(G)|+1. Therefore, it is readily seen that

s!2p-1pr(|V(G)|p+p-1)!(p-1)!(p!)|V(G)|(|E(G)|p+p-1)!(p-1)!(p!)|E(G)|

is not divisible by p. We will denote this latter expression as cp; note that cp corresponds to the constant Ap introduced at the beginning of this section. Hence, it is easy to see that if #EC(G,r) denotes the actual number of equitable coloring of G with r colors, then

e(P(G,r,p))cpe(P(G,r))#EC(G,r)modp.

Since cp is not divisible by p, it is clear that e(P(G,r,p))0modp if and only if e(P(G,r))·#EC(G,r)0modp, and the claim holds.

Claim 6

If #EC(G,r)0, then there is a prime number p greater than 2r|V(G)|+r2|E(G)| and smaller than (2r|V(G)|+r2|E(G)|)2 such that p does not divide e(P(G,r))·#EC(G,r).

Proof

(of the Claim) Let us first upperbound e(P(G,r))#EC(G,r). Clearly, P(G,r) contains m=2(r-1)|V(G)|+(r2-1)|E(G)| elements, hence e(P(G,r))m!. It can easily be verified that the number of possibilities of dividing |V(G)|=rs vertices into r color classes with exactly s colors each is (rs)!(s!)r. By Fact 1, the product of all primes between 2r|V(G)|+r2|E(G)| and (2r|V(G)|+r2|E(G)|)2 is at least (2r|V(G)|+r2|E(G)|)!22r|V(G)|+r2|E(G)|. However, 2(r-1)|V(G)|+(r2-1)|E(G)|+|V(G)|2r|V(G)|+r2|E(G)| and hence e(P(G,r))#EC(G,r)(2(r-1)|V(G)|+(r2-1)|E(G)|)!+|V(G)|!(s!)r is clearly less than the product of all primes between 2r|V(G)|+r2|E(G)| and (2r|V(G)|+r2|E(G)|)2. Note that if a natural number N is divisible by set of primes p1,,p then N is divisible by the product of these primes and in particular N is bigger than the product of these primes. Therefore, e(P(G,r))#EC(G,r) cannot be divisible by all primes between 2r|V(G)|+r2|E(G)| and (2r|V(G)|+r2|E(G)|)2, from which the claim follows.

Claim 7

tw(C(P(G,r,p)))r·(tw(G)+3)+6.

Proof

(of the Claim) To distinguish vertices of G and C(P(G,r,p)) in this proof, we will refer to the vertices of C(P(G,r,p)) as elements. So, let T=(T,{Xt}tV(T)) be a nice tree-decomposition of G of width tw(G). Using T, we show how to construct a tree-decomposition T=(T,{Xt}tV(T)) of C(P(G,r,p)) with treewidth at most r·(tw(G)+3)+6. The construction can be summarized as follows:

  1. All bags of T will contain the anchors a0,,ar+3 as well as the top-most element of each stalk of the (|V(G)|, s)-flowers in the first r levels; let δ denote this set of 2r+4 elements.

  2. For every bag tT, the tree-decomposition T will contain a node t such that if vXt then {v1,,vr}Xt.

  3. Afterwards, every introduce node tT that introduces a vertex v will be replaced by a long path Pt which gradually introduces and subsequently forgets all remaining elements associated with the flower of v at level r+1 (i.e., the stalk) as well as every petal from the first r levels associated with v .

  4. For each edge e, we pick an introduce node tT which contains both endpoint of e and extend the path Pt by a new segment which introduces and subsequently forgets all elements associated with the flower of e at level r+2.

  5. The root node is replaced by a path that takes care of all elements which are not associated with any vertex or edge in G.

Let us now take a closer look what happens in T when tT is an introduce node. Let vV(G) be the vertex introduced at t. Since Xt contains elements a0,,ar+2,v1,,vr, and the maximum element of each stalk of the (|V(G)|, s)-flower in the first r levels, it is easily seen that every petal from the first r levels associated with v as well as the stalk of the flower associated with v in level Lr+1 each forms a separate connected component of C(P(G,r,p))\Xt. Moreover, for an edge e=uv such that Xt contains both endpoints of e, we have that Xt also contains elements u1,,ur and one can see that also the flower associated with e at level Lr+2 is a connected component of C(P(G,r,p))\Xt. It is readily seen that the singleton, chain, and flower all have pathwidth 1 and hence there is a nice path-decomposition (B1,,Bt) with B1=Bt= of the graph containing every petal element from first r levels associated with v, the stalk of the flower associated with v in level Lr+1, and the flower associated with e in level Lr+2 for every edge e introduced at t. We then replace Xt by a path (Y1,,Yt) such that Yi=BiXt and for each i{1,,t-1} the node with bag Yi+1 is the parent of the node with the bag Yi.

It is easy to see now, that when we are forgetting vertex v in node t in T, we can forget elements v1,,vr in T, because we already introduced all its adjacent edges in C(P(G,r,p)) either in the path corresponding to the node of T introducing v or the one introducing a neighbor of v.

Finally, when we get to the root node of T, we have already forgotten all elements associated with any specific vertex or edge of G. Therefore, the only elements besides δ which need to be included in T are the remaining elements in the stalks in the first r levels and the sticks in every level. However, it is easy to see that at this point they all form separate chains in C(P(G,r,p))\δ. Hence there once again exists a path-decomposition of width at most |δ|+2 which gradually introduces and subsequently forgets all of these elements.

One can readily see that the properties (T1), (T2), and (T3) are satisfied and we are only left with computing the width of T. By construction, every join and forget node in T will become a node in T whose bag has size at most r·|Xt|+2r+4. On the other hand, every introduce node in T will become a path in T, and the largest bag on this path has size at most r·|Xt|+2r+6, from which the claim follows.

Concluding the proof Let us summarize the fpt turing reduction used to prove Theorem 1. Given an instance (Gr) of Equitable Coloring[tw], we loop over all primes p such that 2r|V(G)|+r2|E(G)|<p<(2r|V(G)|+r2|E(G)|)2, and for each such prime we construct the poset P(G,r,p); from Claim 6 it follows that if #EC(G,r)0, then at least one such prime will not divide e(P(G,r))·#EC(G,r), and by Claim 7 the cover graph of each of the constructed posets P(Grp) has bounded treewidth. For each such poset P(G,r,p), we compute e(P(G,r,p)) by the black-box procedure provided as part of the reduction. If for any prime p we get e(P(G,r,p))0modp, then we conclude that (Gr) is a yes-instance, and otherwise we reject (Gr), and this is correct by Claim 5.

Fixed-Parameter Tractability of Counting Linear Extensions

This section is dedicated to proving our algorithmic result, stated below.

Theorem 2

#LE is fixed-parameter tractable parameterized by the treewidth of the incomparability graph of the input poset.

The proof of Theorem 2 is divided into two steps. First, we apply a transformation process to a path-decomposition Q of small width (the existence of which is guaranteed by Corollary 1) of I(P) which results in a tree-decomposition T of I(P) satisfying certain special properties. The properties of T are then used to prove that IC(P) has treewidth bounded by the treewidth of I(P). In the second step, we construct an MSO formulation which enumerates all the linear extensions of P using IC(P), and apply Fact 4.

The Treewidth of Combined Graphs

We begin by arguing a useful property of separators in incomparability graphs.

Lemma 3

Let SV(I(P)). Then for each pair of distinct connected components C1,C2 in I(P)-S, it holds that for any a1,b1C1 and any a2,b2C2 we have a1a2 iff b1b2. Namely, the poset contains a total order of all connected components in I(P)-S.

Proof

We begin by proving the following claim.

Claim 8

Let a, b, c be three distinct elements of P such that ab and both pairs a, c and b, c are comparable. Then ac iff bc.

Proof

(of the Claim) Suppose that, w.l.o.g., ac and cb. Then by the transitivity of , we get ab which contradicts our assumption that ab.

Now to prove Lemma 3, assume for a contradiction that, w.l.o.g., there exist a1,b1C1 and a2,b2C2 such that a1b1 and b2a2. Let Q1 be an a1-a2 path in I[C1]. By Claim 8, a1b1 implies that every element q on Q1 satisfies qb1, and in particular a2b1. Next, let Q2 be a b1-b2 path in I[C2]. Then Claim 8 also implies that each element q on Q2 satisfies a2q. Since b2 lies on Q2, this would imply that a2b2, a contradiction.

To proceed further, we will need some additional notation. Let T=(T,X) be a rooted tree-decomposition and tT. We denote by L(t) the set of all vertices which occur in the “branch” of T-t containing the root r; formally, L(t)={vXt\Xt|t lies in the same connected component as rinT-t}. We then set R(t)=V(G)\(L(t)Xt). We also let Ttr denote the connected component of T-t which contains the root r.

Next, recall that each connected component of the graph obtained after deleting Xt must lie in a subtree of T-t (Fact 3). Let Υt be the set of connected components of (I(P)\Xt)R(t). Recall that because of Lemma 3, the components of Υt are totally ordered by P. We say that two components B1, B2Υt are consecutive if there is no element vV(I(P))\(XtB1B2) that is in between elements in these components; formally, for every v it holds that either vb for all bB1B2, or vb for all bB1B2.

A block of a bag Xt is a maximum set of consecutive connected components in (I(P)-Xt)R(t); note that each block has a natural total ordering among the contained components, given by Lemma 3. We say that a node tT has z blocks if there exist z distinct blocks of Xt. Blocks will play an important role in the tree-decomposition we wish to obtain from our initial path-decomposition of I(P). The following lemma captures the operation we will use to alter our path-decomposition.

Lemma 4

Let T=(T,X) be a rooted tree-decomposition of a graph G and let tT be such that there are z blocks of Xt. Then there is a tree-decomposition T(T,X) satisfying:

  1. The width of T is at most the width of T.

  2. The tree T contains Ttr as a subtree which is separated from the rest of T by t.

  3. The degree of t in T is z+1.

  4. There exists a bijection α between the z blocks of Xt and the z trees in T-t other than Ttr such that for each block B of Xt, we have sα(B)Xs\Xt=B.

  5. For each tN[t]\Ttr, we have Xt=Xt.

Proof

It will be useful to observe that T-Ttr is a subtree of T and in particular it is connected. Consider the following construction of T. First, we copy all nodes of Ttr{t} (along with their bags) into T, thus ensuring that Property 2 holds. Second, for each block B of Xt we make a copy TB of the tree T-Ttr, and connect the node tB corresponding to t in T\Ttr by an edge to the node t in T. Moreover, for each node sT\Ttr we set XsB=Xs(BXt). It is easy to verify that all of the required properties are now satisfied, and it remains to show that T is indeed a tree-decomposition.

We argue that T satisfies all three properties of tree-decompositions. Property (T1) follows directly from fact that T was tree decomposition, and hence every vertex that does not occur in a bag in Ttr must occur in some bag Xs for some node sT\Ttr; then this vertex either also occurs in Xt or occurs in some block B and hence in XsB. Property (T2) is also straightforward, since each vertex either does not occur in any block or in exactly one block, and in both cases monotonicity follows from the monotonicity of T and the construction. For the final Property (T3), we recall that there are no edges between the blocks of Xt; in particular every edge e=ab in I(P)[XtR(t)] is either contained in Xt, goes between a vertex of Xt and a vertex of some block B, or is contained in some block B. In all three cases, it holds that if a,bXs for some sT\Ttr, then eXsB for some block B. Therefore, T is a tree-decomposition and the proof is complete.

We proceed by showing how Lemma 4 is applied to transform a given path-decomposition.

Lemma 5

Let Q be a nice path-decomposition of I(P). Then there is a rooted tree-decomposition T=(T,X) of I(P) with the following properties. T is rooted at a leaf r and Xr=, the width of T is at most the width of Q, and for any node tT with z>1 blocks:

  1. The degree of t in T is z+1.

  2. There exists a bijection α between the z blocks of Xt and the z trees in T-t other than Ttr such that for each block B of Xt, we have sα(B)Xs\Xt=B.

  3. For tN(t)Ttr there exists a vertex v such that Xt=Xt\{v}, and furthermore t has degree at most 2 and 1 block.

  4. For each pair of neighbors t,tT, it holds that |Xt\Xt|+|Xt\Xt|1.

Proof

Let us order the vertices of I(P) in the order in which they were introduced in Q. We set the first leaf of Q to be the root r, and observe that Xr= since Q is nice. We then process the vertices of I(P) in their order of introduction; when processing each such vertex v, we apply Lemma 4 to the unique node t of the current tree-decomposition which is closest to r and contains v; with a slight abuse of terminology, we say that t is the node where v is introduced. We show that the following invariants hold after (and before) each step of this procedure:

  1. For each pair of neighbors t,tT, it holds that |Xt\Xt|+|Xt\Xt|1.

  2. For each vertex u that was already processed, the introduce node of u satisfies the conditions of the lemma.

  3. Any node t of degree greater than 2 is an introduce node of an already processed vertex.

Clearly, all invariant conditions hold for Q rooted at r (the first invariant condition follows by the fact that Q is nice, and the remaining two are satisfied trivially). Similarly, all invariant conditions hold after applying Lemma 4 on the first introduce node t in Q. Indeed, note that since Xr=, we can assume w.l.o.g. that t is a child of r and Xt={v} for some vertex v. Then the first and third invariant condition is immediately seen to hold; as for invariant condition 2, if t has more than 1 block then applying Lemma 4 ensures that t satisfies Conditions 1, 2, and 4, while Condition 3 holds since t=r.

For the induction step, suppose that the conditions hold in a tree-decomposition T obtained by inductively applying Lemma 4 as above, and the first unprocessed vertex is v. Let t be the unique node where v is introduced, and let T be the tree-decomposition we obtained by applying Lemma 4 on T and t.

It is easy to verify that T then satisfies the desired Conditions 1, 2, and 4 at the node t by Lemma 4. As for Condition 3, since t is the introduce node of v and the first invariant condition holds in T, it is clear that for tN(t)Ttr it is the case that Xt=Xt\{v}. Moreover, t cannot be an introduce node, since then t would have to introduce an already processed vertex, which would imply that Xt=Xt due to our application of Lemma 4 on introduce nodes. So, let us consider the node s on the unique t-r path that is the closest introduce node to t, and let s be the neighbor of s on the s-t path. Since no vertex was introduced on the s-t path, it follows that R(s)=R(t). Since s only has 1 block by the construction, it must be the case that t also only has one block, and so Condition 3 also holds.

We proceed by arguing that the invariant conditions remain satisfied by T. Since Q was nice and T satisfied the first invariant condition, it is readily seen that the first invariant condition holds for all pairs of neighbors in Ttr as well as for t with all of its neighbors. If sB and sB are neighbors in a tree α(B) of T-t, then by the construction in Lemma 4 there exists a pair of neighbors s,sT\Ttr such that XsB=Xs(BXt) and XsB=Xs(BXt). But then |XsB\XsB|+|XsB\XsB|=|(Xs(BXt))\(Xs(BXt))|+|(Xs(BXt))\(Xs(BXt))||Xs\Xs|+|Xs\Xs|1 and the first invariant condition follows. As for the second invariant condition, notice that from the construction it follows that all the vertices that precede v in the order of introduction in Q must have been introduced in some node of Ttr, and the application of Lemma 4 does not alter such introduce nodes for previously processed vertices. Finally, by the induction hypothesis all nodes of T\Ttr have degree at most 2, therefore from the construction in Lemma 4 it is clear that all nodes in T\(Ttr{t}) also have degree 2. Since all introduce nodes of unprocessed vertices lie in T\(Ttr{t}), we conclude that the third invariant condition also holds in T.

Now, let us consider the tree-decomposition T obtained after processing all vertices of I(P) according to the procedure described above. T satisfies Condition 4 due to the first invariant of our procedure, and for all other conditions it suffices to consider nodes with more than 1 block. In particular, it suffices to verify that all such nodes satisfy the conditions of Lemma 4 and additionally also condition 3 of this Lemma. So, suppose for a contradiction that there exists a node t which does not meet these conditions, but all nodes on the unique t-r path do. Then there are two possibilities to consider for the unique neighbor t of t on the t-r path. If t were to have more than 1 block, then by our assumptions t would have to satisfy the conditions of Lemma 4, contradicting the fact that t has more than 1 block. On the other hand, if t were to have only a single block, then by construction t must be an introduce node of some vertex v and by our invariants and the construction it follows that t in fact must satisfy all the required conditions. In particular we conclude that all nodes t satisfy Conditions 1-4 and the lemma follows.

We call a tree-decomposition rooted at a leaf with Xr= which satisfies the properties of Lemma 5 a blocked tree-decomposition. The next ingredient we will need for proving that IC(P) has small treewidth is the notion of cover-guards.

Let T=(T,X) be a tree-decomposition of I(P) rooted at r and let tr. Then the cover-guard of t, denoted At, is the set of vertices in L(t) which are incident to a cover edge whose other endpoint lies in R(t); formally, At={vL(t)|uR(t):{uv}E(C(P). For a vertex vI(P), we let Av={tT|vAt} and Xv={tT|vXt}.

Our next aim is to add all the cover-guards into each bag. Below, we show that this does not increase the size of bags too much.

Lemma 6

Let T=(T,X) be a blocked tree-decomposition of I(P) of width k. Then for each tT it holds that |At|2k+2.

Proof

First, observe that if a node tT has 0 blocks, then R(t)=At=. So, consider a node t which has exactly 1 block consisting of connected components (D1,,Dj) in (I(P)-Xt)R(t).

Claim 9

|At|2k+2.

Proof

(of the Claim) Assume for a contradiction that |At|>2k+2. By Lemma 3 we have that (D1,,Dj) are consecutive connected components in a total order of connected components in I(P)-Xt. Hence any edge in C(P)-Xt between R(t) and L(t) must necessarily have one endpoint in D1Dj. Furthermore, an element in At cannot be adjacent to both D1 and Dj in C(P)-Xt due to transitivity and acyclicity. So, we may partition At into At1={vAt|uD1:vPu} and At2={vAt|uDj:uPv}.

By Lemma 3, it also follows that At1 and At2 must each lie in separate connected components of I(P)-Xt, say C1 and C2 respectively. Furthermore, each element in At1 is maximal in C1 and each element in At2 is minimal in C2. In particular, each of At1, At2 forms a clique in I(P). But by our assumption on the size of At, at least one of At2 and At1 must have size greater than k+1, which implies that I(P) contains a clique of size at least k+2. It is well-known that each clique must be completely contained in at least one bag of a tree-decomposition, and so we arrive at a contradiction with tw(I(P))k. Hence we conclude that |At|2k+2 and the claim holds.

Finally, consider a node t which has at least 2 blocks. By Property 3 of Lemma 5, it holds that t has a neighbor t in Ttr such that Xt=Xt\{v} and t has 1 block. By Claim 9 we know that At2k+2. Since L(t)=L(t) and R(t)R(t), it follows that AtAt, and in particular |At||At|. We have now proved the desired bound for all nodes in T, and so the lemma holds.

The following lemma allows us to argue that adding cover-guards into each bag still results in a tree-decomposition; it is worth noting that the assumption that the decomposition is blocked is essential for the lemma to hold.

Lemma 7

Let T=(T,X) be a blocked tree-decomposition of I(P) rooted at r and let vI(P). Then T[AvXv] is a tree.

Proof

Since T is a tree-decomposition, we have that T[Xv] must be a tree. Consider a connected component A of T[Av] and its unique A-Xv path Q, with endpoints xXv and aA. Since r is located at a leaf of T it must hold that rQ. We consider two cases: either r lies in the same connected component as Xv in T-Q, or it lies in a different connected component.

In the former case, it follows that each internal vertex q of Q satisfies R(a)R(q) and vL(q). But then by the definition of Av and the fact that aAv, this would imply qAv, contradicting our construction of Q. Hence if r lies in the same connected component as Xv in T-Q, then A is adjacent to Xv.

In the latter case, there must exist a node qQ of degree at least 3 such that each of A, Xv and r occur in different components of T-q. By the definition of Av, there exists a vertex uR(a) such that vPu or uPv. Since u,vR(q) due to the location of the root and there is a cover edge between them, it follows that either uv occur in the same connected component of Xq or in two consecutive ones, but in either case uv must lie in the same block of q, say block B. But since u,vXq, this contradicts Property 2 in Lemma 5; indeed, each tree in T-q contains at most one of vu in its bags, and hence there exists no tree T in T-q satisfying tTXt\Xq=B. Hence r cannot occur in a different connected component than Xv in T-Q.

We conclude that Q contains no internal vertices. In particular, every connected component of T[Av] is adjacent to Xv.

With Lemmas 6 and 7, we have the tools necessary for arguing that there exists a tree-decomposition of the combined graph of small width.

Lemma 8

Let T=(T,X) be a blocked tree-decomposition of I(P) such that tw(T)k. Then there exists a tree-decomposition T of IC(P) of width at most 3k+2.

Proof

Consider the tree-decomposition T=(T,X) where X={Xt|tT} is defined as follows. For each tT such that its unique neighbor s in Ttr satisfies |Xt\Xs|=1, we set Xt=XtAs; it will be useful to observe that AsAt. For all other nodes tT, we then set Xt=XtAt. We call nodes of the first type non-standard and nodes of the second type standard.

First, we note that the size of each bag in T is at most 3k+2, since every node tT satisfies |At|2k+2 by Lemma 6. Furthermore, T satisfies condition (T1) because T was a tree-decomposition of I(P). T also satisfies condition (T2); indeed, for each vP it holds that Xv restricted to standard nodes is a connected tree by Lemma 7, and by construction every non-standard node t such that vXt\Xt is adjacent to a standard node containing v. So, it only remains to argue condition (T3).

Obviously, condition (T3) holds for any edge of I(P). So, consider two elements uv of P such that uPv or vPu. If there exists a node tT such that u,vXt, then u,vXt and the condition also holds for this edge in IC(P). So, assume that Xv and Xu are disjoint and let Q be the unique Xv-Xu path in T. By Property 4, the Xv-Xu path Q in T must contain at least one internal node.

Consider the case where one of these subtrees, say w.l.o.g. Xv, lies in the connected component Ttr of T-Q. Then for each internal node qQ, it holds that vL(q) and uR(q), which in turn implies that vAq. Let qu be the endpoint of Q in Xu and let q0 be the neighbor of qu in Q. By Property 4 we have Xqu\Xq0={u}, which implies that qu is a non-standard node and in particular Aq0Xqu. Since q0 is an internal node of Q, it follows that vXqu which means that condition (T3) also holds for any edge uv in this case.

Finally, consider the case where there exists a node qQ of degree at least 3 such that each of Xu, Xv and r occur in different components of T-q. Then we reach a contradiction similarly as in the proof of Lemma 7. In particular, since u,vR(q) due to the location of the root and there is a cover edge between them, it follows that either uv occur in the same connected component of Xq or in two consecutive ones, but in either case uv must lie in the same block of q, say block B. But since u,vXq, this contradicts Property 2 in Lemma 5; indeed, each tree in T-q contains at most one of vu in its bags, and hence there exists no tree T in T-q satisfying tTXt\Xq=B. Hence this case in fact violates our assumptions and cannot occur.

Summarizing the above arguments, we conclude that each bag in T has size at most 3k+2 and that T satisfies all of the conditions of a tree-decomposition.

Corollary 2

Let P be a poset such that tw(I(P))k. Then tw(IC(P))3k+2.

Proof

By Corollary 1 we know that there exists a nice path-decomposition of I(P) of width at most k. By Lemma 5, it follows that there exists a blocked tree-decomposition of I(P) of width at most k. The corollary then follows by Lemma 8.

MSO Formulation

In this subsection, we use Fact 4 to prove the following result, which forms the second ingredient required for our proof of Theorem 2.

Lemma 9

#LE is fixed-parameter tractable parameterized by the treewidth of the combined graph of the input poset.

Proof

Let P:=(P,P) be a poset. Let G be an (edge-)labeled directed graph obtained from IC(P) by directing every bidirectional edge of IC(P), i.e., every edge of I(P), in an arbitrary way and labeling it with the label .

For a set of edges EE(G) with label , let G[E] be the graph obtained from G after reversing every edge in E. Moreover, for a linear extension of P let EG() be the set of edges (uv) of G such that vu. Note that because every linear extension of P has to respect the direction of the edges in G given by C, it holds that every edge in EG() has label .

Claim 10

EG() defines a bijection between the set of linear extensions of P and the set of subsets E of edges of G with label such that G[E] is acyclic.

Proof

(of the Claim) Let be a linear extension of P. Then, as observed above, EG() is a set of edges of G with label . Moreover, because G[EG()] is a subgraph of PG() and PG() is acyclic so is G[EG()]. Hence, EG() is a function from the set of linear extensions of P to the set of subsets E of edges of G with label such that G[E] is acyclic. Towards showing that EG() is injective, assume for a contradiction that this is not the case, i.e., there are two distinct linear extensions 1 and 2 of P such that EG(1)=EG(2) and let u and v be two elements of P ordered differently by 1 and 2. Then {u,v}I(P) and hence either (u,v)G or (v,u)G the label of (uv) or (vu) respectively is . W.l.o.g. assume that (u,v)G with label . But then, because 1 and 2 differ on u and v, either (u,v)EG(1) but not (u,v)EG(2) or (u,v)EG(2) but not (u,v)EG(1). In both cases we get a contradiction to our assumption that EG(1)=EG(2).

It remains to show that EG() is surjective. To see this let E be a subsets of the edges of G with label such that G[E] is acyclic. Because G[E] is acyclic it has a topological ordering, say , of its vertices. Because G[E] contains C(P) as a subgraph and any topological ordering of C(P) is a linear extension of P, we obtain that is a linear extension and also E=EG().

It follows from the above that instead of counting the number of linear extensions of P directly, we can count the number of subsets E of the edges of G with label such that G[E] is acyclic. We will show next that there is an MSO formula Φ(X), whose length is independent of G and can hence be considered constant, such that GΦ(X) if and only if X is a subset of the edges of G with label such that G[E] is acyclic. Because of Fact 4, this implies that #LE is fixed-parameter tractable when parameterized by tw(G) and hence also when parameterized by tw(IC(P)), concluding the proof of the lemma.

Informally, Φ(X) will check that X is a set of edges of G with label and there is no non-empty set of edges C of G[X] that forms a cycle. For the definition of Φ(X) we will need the following auxiliary formulas.

  • The formula edgesin(X):=xXxPx, which holds if and only if X is a set of edges of G with label .

  • The formula edgesne(C):=cCc(cCcEc), which holds if and only if C is a non-empty set of edges of G.

  • The formula cyclic(C,X):=vVvdegree(C,X,v), which holds if and only if the set C of edges of G[X] is a disjoint union of directed cycles. Note that this implies that either C is empty or C contains at least one (directed) cycle.

  • The formula degree(C,X,v):=degree0(C,X,v)degree2(C,X,v), which holds if and only if either no edge in C is incident to v or there are exactly two edges in C that are incident to v such that one of them corresponds to an edge in G[X] with tail v and the other corresponds to an edge in G[X] with head v.

  • The formula degree0(C,X,v):=¬cCcIvc, which holds if and only if no edge in C is incident to v.

  • The formula
    degree2(C,X,v):=cicoCciCcoin(X,ci,v)out(X,co,v)c(Cc¬c=ci¬c=co)¬(HvcTvc)
    which holds if and only if there are exactly two edges in C that are incident to v such that one of them corresponds to an edge in G[E] with tail v and the other corresponds to an edge in G[E] with head v.
  • The formula
    in(X,c,v):=(¬PcHvc)(Pc¬XcHvc)(PcXcTvc)
    which holds if and only if v is the head of the edge of G[X] represented by c.
  • The formula
    out(X,c,v):=(¬PcTvc)(Pc¬XcTvc)(PcXcHvc)
    which holds if and only if v is the tail of the edge of G[X] represented by c.

Then Φ(X) is the formula:

Φ(X):=edgesin(X)¬Cedgesne(C)cyclic(C,X)

Which concludes the proof.

For completeness, we conclude the section by stating the proof of Theorem 2.

Proof

(of Theorem 2) Let P be the input poset and let k=tw(I(P)). Then tw(IC(P))3k+2 by Corollary 2, and the theorem follows by Lemma 9.

Conclusions and Future Work

We have given the first parameterized intractability result for counting linear extensions. We hope that the employed techniques will inspire similar results and expand our knowledge about the parameterized complexity of counting problems. In particular, even for #LE there remain many open questions concerning other very natural parameterizations such as the width of the poset (which is, in fact, upper-bounded by the treewidth of the incomparability graph) or the treewidth of the poset graph. Moreover, our intractability result for the treewidth of the cover graph poses the question whether there are stronger parameterizations under which #LE becomes tractable, e.g., the treewidth of the comparability graph (i.e., the undirected graph underlying the poset graph), the treedepth or even vertex cover number of the comparability or cover graph, as well as combinations of these parameters with parameters such as the width, the dimension, or the height of the poset. These numerous examples illustrate that the parameterized complexity of #LE is still largely unexplored. As a side note it would also be interesting to establish whether our hardness result for #LE can be sharpened to #W[1]-hardness and to obtain matching membership results.

Acknowledgements

Open access funding provided by Austrian Science Fund (FWF). Eduard Eiben was supported by Pareto-Optimal Parameterized Algorithms (ERC Starting Grant 715744) and by the Austrian Science Fund (FWF, projects P26696 and W1255-N23). Robert Ganian is also affiliated with FI MU, Brno, Czech Republic.

Footnotes

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

References

  • 1.Arnborg S, Lagergren J, Seese D. Easy problems for tree-decomposable graphs. J. Algorithms. 1991;12(2):308–340. doi: 10.1016/0196-6774(91)90006-K. [DOI] [Google Scholar]
  • 2.Atkinson MD. On computing the number of linear extensions of a tree. Order. 1990;7(1):23–25. doi: 10.1007/BF00383170. [DOI] [Google Scholar]
  • 3.Bodlaender HL. A linear-time algorithm for finding tree-decompositions of small treewidth. SIAM J. Comput. 1996;25(6):1305–1317. doi: 10.1137/S0097539793251219. [DOI] [Google Scholar]
  • 4.Bodlaender HL, Kloks T. Efficient and constructive algorithms for the pathwidth and treewidth of graphs. J. Algorithms. 1996;21(2):358–402. doi: 10.1006/jagm.1996.0049. [DOI] [Google Scholar]
  • 5.Bresar B, Changat M, Klavzar S, Kovse M, Mathews J, Mathews A. Cover-incomparability graphs of posets. Order. 2008;25(4):335–347. doi: 10.1007/s11083-008-9097-1. [DOI] [Google Scholar]
  • 6.Brightwell, G., Winkler, P.: Counting linear extensions is #P-complete. In: Proceedings of the 3rd Annual ACM Symposium on Theory of Computing, STOC’91, pp. 175–181 (1991)
  • 7.Bubley R, Dyer M. Faster random generation of linear extensions. Discrete Math. 1999;201(1–3):81–88. doi: 10.1016/S0012-365X(98)00333-1. [DOI] [Google Scholar]
  • 8.Courcelle B. The monadic second-order logic of graphs. i. Recognizable sets of finite graphs. Inf. Comput. 1990;85(1):12–75. doi: 10.1016/0890-5401(90)90043-H. [DOI] [Google Scholar]
  • 9.Cygan M, Fomin FV, Kowalik L, Lokshtanov D, Marx D, Pilipczuk M, Pilipczuk M, Saurabh S. Parameterized Algorithms. Berlin: Springer; 2015. [Google Scholar]
  • 10.De Loof K, De Meyer H, De Baets B. Exploiting the lattice of ideals representation of a poset. Fundam. Inf. 2006;71(2,3):309–321. [Google Scholar]
  • 11.Diestel R. Graph Theory. 4. Berlin: Springer; 2012. [Google Scholar]
  • 12.Downey RG, Fellows MR. Fundamentals of Parameterized Complexity. Berlin: Springer; 2013. [Google Scholar]
  • 13.Dyer M, Frieze A, Kannan R. A random polynomial-time algorithm for approximating the volume of convex bodies. J. ACM. 1991;38(1):1–17. doi: 10.1145/102782.102783. [DOI] [Google Scholar]
  • 14.Fellows MR, Fomin FV, Lokshtanov D, Rosamond FA, Saurabh S, Szeider S, Thomassen C. On the complexity of some colorful problems parameterized by treewidth. Inf. Comput. 2011;209(2):143–153. doi: 10.1016/j.ic.2010.11.026. [DOI] [Google Scholar]
  • 15.Felsner S, Manneville T. Linear extensions of N-free orders. Order. 2014;32(2):147–155. doi: 10.1007/s11083-014-9321-0. [DOI] [Google Scholar]
  • 16.Flum J, Grohe M. The parameterized complexity of counting problems. SIAM J. Comput. 2004;33(4):892–922. doi: 10.1137/S0097539703427203. [DOI] [Google Scholar]
  • 17.Gottlob G, Pichler R, Wei F. Bounded treewidth as a key to tractability of knowledge representation and reasoning. Artif. Intell. 2010;174(1):105–132. doi: 10.1016/j.artint.2009.10.003. [DOI] [Google Scholar]
  • 18.Grohe M. The complexity of homomorphism and constraint satisfaction problems seen from the other side. J. ACM. 2007;54(1):1:1–1:24. doi: 10.1145/1206035.1206036. [DOI] [Google Scholar]
  • 19.Habib M, Möhring RH. On some complexity properties of N-free posets and posets with bounded decomposition diameter. Discrete Math. 1987;63(2):157–182. doi: 10.1016/0012-365X(87)90006-9. [DOI] [Google Scholar]
  • 20.Habib M, Möhring RH. Treewidth of cocomparability graphs and a new order-theoretic parameter. Order. 1994;11(1):47–60. doi: 10.1007/BF01462229. [DOI] [Google Scholar]
  • 21.Husfeldt T, Paturi R, Sorkin GB, Williams R. Exponential algorithms: algorithms and complexity beyond polynomial time (Dagstuhl Seminar 13331) Dagstuhl Rep. 2013;3(8):40–72. [Google Scholar]
  • 22.Kangas, J.-K., Hankala, T., Niinimäki, T.M., Koivisto, M.: Counting linear extensions of sparse posets. In: Proceedings of the 25th International Joint Conference on Artificial Intelligence, IJCAI 2016, New York City, July 9–15, 2016 (2016) (to appear)
  • 23.Kloks T. Treewidth, Computations and Approximations. Berlin: Springer; 1994. [Google Scholar]
  • 24.Lukasiewicz T, Martinez MV, Simari GI. Probabilistic preference logic networks. In: Schaub T, Friedrich G, O’Sullivan B, editors. ECAI 2014—21st European Conference on Artificial Intelligence, Aug 18–22, 2014, Prague, Czech Republic—Including Prestigious Applications of Intelligent Systems (PAIS 2014), Amsterdam: IOS Press; 2014. pp. 561–566. [Google Scholar]
  • 25.Mannila, H., Meek, C.: Global partial orders from sequential data. In: Proceedings of the 6th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD’00, pp. 161–168, New York (2000). ACM
  • 26.Möhring Rolf H. Computationally tractable classes of ordered sets. In: Rival I, editor. Algorithms and Order. Dordrecht: Springer; 1989. pp. 105–193. [Google Scholar]
  • 27.Morton J, Pachter L, Shiu A, Sturmfels B, Wienand O. Convex rank tests and semigraphoids. SIAM J. Discrete Math. 2009;23(3):1117–1134. doi: 10.1137/080715822. [DOI] [Google Scholar]
  • 28.Niinimäki, T.M., Koivisto, M.: Annealed importance sampling for structure learning in Bayesian networks. In: IJCAI. IJCAI/AAAI (2013)
  • 29.Paulusma D, Slivovsky F, Szeider S. Model counting for CNF formulas of bounded modular treewidth. Algorithmica. 2016;76(1):168–194. doi: 10.1007/s00453-015-0030-x. [DOI] [Google Scholar]
  • 30.Peczarski M. New results in minimum-comparison sorting. Algorithmica. 2004;40(2):133–145. doi: 10.1007/s00453-004-1100-7. [DOI] [Google Scholar]

Articles from Algorithmica are provided here courtesy of Springer

RESOURCES