Acyclic orders, partition schemes and CSPs: Uniﬁed hardness proofs and improved algorithms

Many computational problems arising in, for instance, artiﬁcial intelligence can be realized as inﬁnite-domain constraint satisfaction problems (CSPs) based on partition schemes : a set of pairwise disjoint binary relations (containing the equality relation) whose union spans the underlying domain and which is closed under converse. We ﬁrst consider partition schemes that contain an acyclic order and where the constraint language contains all unions of the basic relations; such CSPs are frequently occurring in e.g. temporal and spatial reasoning. We identify properties of such orders which, when combined, are suﬃcient to establish NP-hardness of the CSP and strong lower bounds under the exponential-time hypothesis, even for degree-bounded problems. This result explains, in a uniform way, many existing hardness results from the literature, and shows that it is impossible to obtain subexponential time algorithms unless the exponential-time hypothesis fails. However, some of these problems (including several important temporal problems), despite likely not being solvable in subexponential time, admit non-trivial improved exponential-time algorithm, and we present a novel improved algorithm for RCC-8 and related formalisms. © 2021 The Authors. Published by Elsevier B.V. This is an open access article under the CC BY license (http://creativecommons.org/licenses/by/4.0/).


Introduction
In this article we study the complexity of infinite-domain constraint satisfaction problems over partition schemes.In this framework one can formulate many naturally occurring reasoning problems in artificial intelligence such as Allen's interval algebra and the region connection calculus.We identify shared properties among these problems, based on the existence of acyclic orders, and use these properties to provide a general NP-hardness result and prove strong lower bounds under the exponential-time hypothesis.Importantly, to the best of our knowledge, this is the first lower bound under the exponentialtime hypothesis for problems of this form.Motivated by these lower bounds we also turn to the problem of constructing improved algorithms for CSPs over partition schemes, with a particular focus on the region connection calculus.

Background
The constraint satisfaction problem over a constraint language (CSP( )) is the decision problem of verifying whether a set of constraints based on the relations in admits a satisfying assignment.For finite domains the complexity of ✩ Parts of this article appeared in the proceedings of the 43rd International Symposium on Mathematical Foundations of Computer Science (MFCS-2018).
CSP( ) is well understood due to the recent dichotomy theorem separating tractable from NP-complete problems [9,42], but for infinite domains the situation differs markedly.This class of problems includes both undecidable problems and NP-intermediate problems, and it is therefore common to impose additional assumptions on the allowed constraints.The predominant method has been to fix a constraint language , usually satisfying certain model-theoretic properties, and analyse the complexity of CSPs over first-order reducts of .Traditionally, this has also been the case for CSPs arising from artificial intelligence, e.g.temporal and spatial reasoning problems, albeit usually with weaker closure conditions.Motivated by problems of this form, we study the complexity of infinite-domain CSPs over partition schemes.A partition scheme [29] is a set of pairwise disjoint binary relations B over a domain D such that R∈B R = D 2 , the equality relation is a member of B, and the converse of R is in B for every R ∈ B. Due to their capability of modelling many different kinds of qualitative reasoning problems, partition schemes are the de facto standard for CSPs in the artificial intelligence community [13].Given a partition scheme, the predominant way of forming new relations is to allow unions of the relations in B, and we let B ∨= denote this set.Equivalently, each relation in B ∨= can be defined as a disjunction of the form B 1 (x, y) ∨ B 2 (x, y) ∨ • • • ∨ B k (x, y) for some {B 1 , . . . ,B k } ⊆ B, and the set B ∨= thus contains all relations definable in this way.
Famous AI examples of formalisms based on partition schemes include Allen's interval algebra, the region connection calculus (RCC-8), and the rectangle algebra.For more examples, see e.g. the survey by Dylla et al. [14].CSP(B ∨= ) problems have been proven to be NP-hard for many choices of B. The proofs have utilised various reductions from various problems, but there has not been a clear explanation why the majority of them are NP-hard.Thus, does there exist one reduction applicable to every partition scheme?Or does one need separate proofs for (e.g.) RCC-8 and Allen's interval algebra, and then perform an exhaustive case analysis on all possible set of base relations B?
Thus, while quite a bit is known about specific partition schemes, it is safe to say that we lack a more general understanding of why these problems are NP-hard.When turning to questions of more fine-grained complexity the situation is even more dire.For example, can CSPs over partition schemes be solved roughly as fast as Boolean satisfiability problems, i.e., in O (2 n ) time?Or at least as fast as a finite-domain CSP, i.e., O (c n ) for some c ≥ 1? Classifying partition schemes according to this highly "fine-grained" level of complexity is a very hard open problem which we should not hope to immediately resolve, and as a first sanity check it is common to first rule out the existence of subexponential algorithms, i.e., algorithms with a running time of 2 o (n) .Naturally, this cannot be done unconditionally, and a popular assumption in this context is the exponential-time hypothesis (ETH) which states that the 3-SAT problem cannot be solved in subexponential time.Despite the fact that CSPs over partition schemes are among the most frequently studied CSPs in artificial intelligence, it is fair to say that such ETH-based lower bounds have largely been neglected by both the artificial intelligence community and the CSP community, and to the best of our knowledge there are no concrete lower bounds under the ETH for these problems.There are a few reasons for this.First, significant efforts have been made to solve hard reasoning problems with efficient heuristics [35], which are typically difficult to analyse rigorously even if they work well for certain real-world instances.Second, existing lower bounds are typically based on size-preserving reductions from SAT-like problems where one needs the ability to express disjunctive clauses, which is difficult to express with partition schemes.To the best of our knowledge, the only concrete lower bounds for a CSP over a partition scheme is the bound by Jonsson and Lagerkvist [25] which relates the complexity of Allen's interval algebra to the complexity of the Chromatic Number problem (but not under the more common assumption ETH).

Our results
Our first step (in Section 3) is to note that the majority of practically relevant partition schemes contain acyclic orders satisfying certain properties, which we in this article refer to as unbounded total orders, in-forks, out-forks, and no-forks.For brevity, we typically refer to these conditions as C 1 , C 2 , C 3 and C 4 .We provide several examples from the literature of partition schemes containing acyclic orders of this form, e.g., Allen's interval algebra, the unit interval algebra, and RCC-8.While there is no general recipe for proving that a partition scheme contains an acyclic order of the above form, all the examples that we have tried show that it in practice is rather straightforward.
In Section 4 we turn to the problem of proving lower bounds for CSPs over partition schemes containing an acyclic order satisfying C 1 -C 4 .Through a sophisticated reduction we prove that no problem of this form can be solved in subexponential time (under the ETH), even in the structurally restricted case where a variable may occur in at most 3 constraints.The case when a variable may occur in at most 2 constraints is handled in Section 4.3 where we establish that all CSPs of this form are tractable if the template in question is ω-categorical.
In particular, our results imply that CSPs over partition schemes containing acyclic orders of this form are NP-hard.Hence, we succeed both in finding a uniform hardness proof, and with proving lower bounds under the ETH.Importantly, our lower bounds are the first ETH-based lower bounds for CSPs of this form.It might also be interesting to observe that we do not need any strong model-theoretic properties, e.g.ω-categoricity, which is otherwise common for infinite-domain CSPs.The reduction establishing NP-hardness is also interesting to compare to the procedure by Renz and Li [36] which takes a partition scheme as input and tries to prove NP-hardness.One important distinction is that our result provides a concrete source of NP-hardness while the algorithm in Renz and Li gives no such insight.Moreover, this procedure is not complete, and is due to computational constraints not applicable to e.g. the rectangle algebra, while it is a straightforward task to prove that this algebra falls within the scope of our result.Hence, our study offers a more theoretical explanation of why so many naturally occurring CSPs over partition schemes are computationally hard.
One way of interpreting these results is that CSP(B ∨= ), when B is a partition scheme containing an acyclic order satisfying the aforementioned properties, is far from being polynomial-time solvable: there is a constant c > 1 such that the problem cannot be solved in O (c n ) time.An immediate consequence of lower bounds of this form is that we can immediately rule out certain kinds of algorithms for CSP(B ∨= ), e.g.algorithms based on graph-decomposition and k-consistency, which typically run in subexponential or polynomial time.It is of course tempting to strengthen our lower bound even further since the current best known algorithm for CSP(B ∨= ) for an arbitrary partition scheme B runs in 2 O (n 2 ) time, if CSP(B) is polynomial-time solvable [25,39].Improvements to 2 O (n log n) are possible for certain temporal CSPs and for Allen's interval algebra [25], so there is reason for being optimistic.We attack this question in Section 5 where we begin by presenting an 2 O (n) time algorithm for the degree-bounded case, and then present a novel 2 O (n log n) time algorithm for RCC-8.This is the first example of a non-trivial spatial partition scheme whose CSP can be solved in 2 o(n 2 ) time.Classifying partition schemes admitting improved algorithms of this form is an interesting open question, which we discuss in greater detail in Section 6, among other unresolved questions.

Preliminaries
In this section we introduce the necessary prerequisites concerning constraint satisfaction problem and partition schemes.We begin by defining the CSP problem when it is parameterized by a set of relations.Definition 1.Let be a set of finitary relations over some set D of values.The constraint satisfaction problem over (CSP( )) is defined as follows: The set is called a constraint language, and the function f is sometimes called a satisfying assignment, or a solution.Importantly, the domain D is allowed to be infinite, and CSPs over constraint languages over infinite domains are typically called infinite-domain CSPs, to contrast them with finite-domain CSPs.Given an instance I of CSP( ) we write ||I|| for the number of bits required to represent I .We will occasionally encounter bounded-degree CSP instances.Let (V , C ) denote an instance of CSP( ).If a variable x occurs in B (distinct) constraints in C , then we say that the degree of x is B. We let CSP( )-B denote the CSP( ) problem where each variable in the input is restricted to have degree at most B. Note that if (V , C ) is a CSP( )-B instance, then |C| ≤ B • |V |, implying that the number of constraints is linearly bounded with respect to the number of variables.
We are now ready to introduce partition schemes [29].Let B = {B 1 , . . ., B m } be a constraint language consisting of binary relations over a domain D. We say that B is jointly exhaustive if B = D 2 and that B is pairwise disjoint if B i ∩ B j = ∅ whenever i = j.We say that B is a partition scheme if (1) B is jointly exhaustive and pairwise disjoint, (2)  are typical objects that are studied in the artificial intelligence literature.For example, it has been common to use a relation algebra A as a starting point and then define a network satisfaction problem over A, which in our notation is nothing else than the CSP over a set of binary relations.Note that if CSP(B) is polynomial-time solvable, then CSP(B ∨= ) is a member of NP. [2] is a well-known formalism for temporal reasoning where one considers relations between intervals of the form I = [I − , I + ], where I − , I + ∈ R is the start and end point, respectively.In Allen's algebra one can for instance describe that one interval begins before another interval, and one express such relations in terms of a partition scheme consisting of 13 basic relations (see Table 1), and then form more complicated relations by taking the union of the basic relations.If we let A denote the set of 13 basic relations in Allen's algebra, then CSP(A ∨= ) is an alternative formulation of the network consistency problem over Allen's algebra.Note that CSP(A ∨= ) is an infinite-domain CSP since the underlying domain of real intervals is intrinsically infinite.

Example 1. Allen's interval algebra
An extension of the interval algebra is the so-called rectangle algebra [19,32].Here, one considers relations between rectangles in the plane by extending the basic relations in the interval algebra to the projections of a rectangle onto the xand y-axis, respectively.In other words, given r, s ∈ A and two rectangles represented by the intervals I x , I y , J x , J y we may define the relation r ⊕ s in the rectangle algebra holding if I x (r) J x and I y (s) J y .
Example 2. RCC-8 [34] is a formalism for qualitative spatial reasoning where the basic objects (referred to as regions) are non-empty regular closed subsets of a topological space.The regions do not have to be internally connected, that is, they

Table 1
The thirteen basic relations in Allen's interval algebra.The endpoint relations I − < I + and J − < J + that are valid for all relations have been omitted.

Basic relation Example Endpoints
x precedes y p xxx x meets y m xxxx x finishes y f xxx x equals y may consist of different disconnected pieces.RCC-8 contains eight basic relations: EQ (equal), PO (partial overlap), DC (disconnected), EC (externally connected), NTPP (non-tangential proper part), its converse NTPP −1 , TPP (tangential proper part) and its converse TPP −1 .See Fig. 1 for examples.RCC-5 is a variant of RCC-8 where one is not able to distinguish regions from their topological closure, i.e. the distinction between boundary points and interior points is ignored.Thus, the disconnectedness relations DC and EC are replaced by DR = DC ∪ EC, the tangential and non-tangential proper part relations TPP and NTPP are replaced by PP = TPP ∪ NTPP, and PP −1 is defined analogously.
Last, we define two satisfiability problems useful in the context of lower bounds, which we will return to in Section 4.1.
If V is a set of variables and f a function from V to {0, 1}, then we define the function For k ≥ 1 we define the k-satisfiability (k-SAT) problem as follows.
Instance: A set of variables V and a set clauses of the form ( 1 ∨ . . .∨ k ), where i = ¬x or i = x for some x ∈ V .Question: Does there exist a function f : The variant of k-SAT where we in addition require that the function f does not assign the same value to each literal in any clause is known as the not-all-equal-k-satisfiability problem (NAE-k-SAT).NAE-3-SAT remains NP-hard even if it is restricted to clauses containing only positive literals, and we invite the reader to verify that this restricted problem can be formulated as a Boolean CSP over the template N = {0, 1} 3 \ {(0, 0, 0), (1, 1, 1)}.

Acyclic orders
CSPs based on partition schemes are often used for qualitative reasoning.We acknowledge that it is not obvious how to define "qualitative reasoning" rigorously, but the concept seems to have an informal meaning that is generally accepted.Renz and Nebel [39, p. 161] write Qualitative reasoning is an approach for dealing with commonsense knowledge without using numerical computation.Instead, one tries to represent knowledge using a limited vocabulary such as qualitative relationships between entities or qualitative categories of numerical values, ... Abstraction is the defining feature of qualitative reasoning: qualitative reasoning is about disregarding unnecessary and uninteresting details.With this in mind, it is clear that an important kind of qualitative relationships between objects are "part-of" relations.One may argue that such relations are orders that satisfy certain additional properties.A typical example of such a relation is the NTPP relation in RCC-8-this can be viewed as an archetypical example of a "part-of" relation.Inspired by this, we present (in Section 3.1) a collection of four properties that capture some common aspects of "part-of" relations.Many other relations (that are not necessarily "part-of" relations) satisfy these properties, too: one example is the precedes relation p in Allen's algebra.In fact, relations of this kind appear very frequently in CSPs for qualitative reasoning and we present a number of examples in Section 3.2.Naturally, while our conditions on acyclic orders are sufficient to establish hardness, there exists CSPs over other types of partition schemes which are of independent interest.For example, if we leave the realm of qualitative reasoning, then the graph interval sandwich problem [17] can be phrased as a CSP over the two relations p ∪ p −1 and R∈A\{p,p −1 } R, neither of which is acyclic.Another relevant example is the partition scheme {eq D , neq D } over a countably infinite D. While the tractable problem CSP({eq D , neq D }) might not be terribly interesting, the optimisation variant of this problem where one is interested in maximising the number of satisfied constraints, MAX-CSP({eq D , neq D }), can be viewed as an alternative formulation of correlation clustering [5].

Conditions on acyclic orders
Let ≺ ⊆ D 2 denote a binary relation and let denote its converse ≺ .We say that ≺ is an acyclic order if there does not exist any finite subset {d 1 , . . ., It is easy to verify that strict partial orders are acyclic orders but that there exist acyclic orders that are not strict partial orders.We say that ≺ is a strict total order if ≺ is a strict partial order and it is a connex relation, i.e. for arbitrary distinct d, d ∈ D, either d ≺ d or d ≺ d holds.We will now define additional properties of acyclic orders particularly relevant in the context of CSP(B ∨= ).Here, we invite the reader to view the relation which holds between two elements if they are not comparable with respect to ≺, although all that is needed is that satisfies the following properties.
Definition 2. Let ≺ ⊆ D 2 be an acyclic order and ⊆ D 2 a relation.We define the following properties.
C 1 . (unbounded total orders) for every k ∈ N, there exists a subset L ⊆ D such that |L| ≥ k and ≺ is a strict total order on L, Relations satisfying these properties are abundant in the artificial intelligence literature, but they have to the best of our knowledge not been explicitly formalized before.The conditions in-fork and out-fork are illustrated in Fig. 2. Given a relation R it is typically easy to check if it is an acyclic order that contains an infinite total order, but checking C 2 -C 4 may need additional work.
Many partition schemes contain strict partial orders, and these are slightly easier to work with than acyclic relations, since it is always possible to define the relation in a canonical way.Given an order ≺ ⊆ D 2 , we let denote its incomparability relation D 2 \ {≺, , eq D }.If B is a partition scheme and B ∨= contains an order ≺, then is included in B ∨= , too.
We obtain the following characterization.

Examples
Consider Allen's algebra and the relation p, i.e. the relation stating that one interval appears strictly before another interval.In this case, can be chosen to be the relation that holds if and only if two distinct intervals have at least one point in common.The relation p is clearly acyclic (in fact, it is a strict partial order) and it contains many infinite strict total orders such as (or is preceded by I 2 ) cannot share a point with both I 1 and I 3 .We continue with a more complex example that is based on acyclic orders instead of strict partial orders.The Unit Interval Algebra (UIA) is Allen's interval algebra restricted to intervals of length one.The UIA has important applications in, for instance, bioinformatics [33].Consider the overlaps relation o.This relation is irreflexive but it is not transitive in general: the unit intervals [0, 1], [0.9, 1.9], and [1.8, 2.8] are examples of this.Hence, it is not a partial order.We show that o is an acyclic order that satisfies C 1 -C 4 .The fact that o is an acyclic order is easy to verify.Choose the relation ≺ to equal o and let hold if and only if two intervals do not have a common point, i.e., = (p, p −1 ).C 1 .We claim that the order (L, o) where L = {[x, x + 1] | 0 < x < 1 and x ∈ Q} is an infinite strict total order-this implies property C 1 .Irreflexivity is obvious so we continue with the connexity property.We see that if  holds between two regions if and only if neither region included in the other.For each k ≥ 1 it is then clear that there exists a set of k regions where ≺ induces a strict total order, e.g., k disks c 1 , c 2 , . . ., c k where How to choose suitable disks for verifying in-fork and out-fork is illustrated in Fig. 4. For the no-fork property, simply observe that any region containing (or is contained by)

Lower bounds for CSP(B ∨= )
We will now study the computational complexity of CSP(B ∨= ) when B ∨= contains an acyclic order ≺ and a relation that satisfy C 1 -C 4 .To avoid lengthy formulations of this kind we introduce the following set of templates.Definition 4. We let H be the set of partition schemes B such that (1) CSP(B) is solvable in polynomial time, and (2) B contains an acyclic order ≺ and a relation that satisfy Note that it is sufficient that the partition scheme contains a single acyclic order with these properties: the relations are not relevant as long as CSP(B) is tractable.Examples where the connection between acyclic orders and the complexity of the resulting CSPs is quite pronounced can be found in, for instance, Grigni et al. [18], Renz and Nebel [37], Moratz et al. [31], and Krokhin et al. [27].Thus, is CSP(B ∨= ) always NP-hard when B ∈ H, or can there exist tractable cases?If CSP(B ∨= ) is indeed NP-hard, how fast can it be solved?Might there exist some particularly "easy" partition scheme B where CSP(B ∨= ) is solvable in O (c n ) for a very small constant c? Or even in O (c n ) time for every constant c > 1, i.e., in subexponential time1 ?Naturally, we cannot hope to unconditionally prove that a CSP(B ∨= ) problem is not subexponential, and it is instead common to prove lower bounds subjected to the assumption that a specific problem is not solvable in subexponential time.For this purpose the 3-SAT problem, i.e., satisfiability of clauses of length at most 3, has turned out to be a very useful starting point.Definition 5.The conjecture that 3-SAT is not solvable in subexponential time is known as the exponential-time hypothesis (ETH) [23].
The general idea behind a non-subexponentiality lower bound subjected to the ETH is then similar to a typical NPhardness proof: one needs to provide a suitable reduction from 3-SAT to the problem in question.The complicating factor, of course, is that one needs reductions preserving subexponential complexity, which can sometimes be much more difficult to construct than ordinary polynomial-time many-one reductions.More information about the ETH and its consequences can be found in the survey by Lokshtanov et al. [30].
Example 3. Consider the classical gadget reduction from 4-SAT to 3-SAT which replaces a clause of the form ( , where y is a fresh variable.If one is not careful then one might be led to believe that this reduction preserves subexponential complexity since we for each clause in the original instance only introduces one fresh variable.But what if the instance contains a superlinear amount of clauses with respect to the number of variables, e.g., a quadratic number?Assuming that 3-SAT is solvable in O (c n ) time for some c > 0, where n is the number of variables, this reduction would then only say that 4-SAT is solvable in O (c n 2 ) time, and in particular would not imply that 4-SAT is subexponential if 3-SAT is subexponential.However, it is known that the degree-bounded k-SAT problem (for some fixed B > 0) is solvable in subexponential time if and only if k-SAT is solvable in subexponential time, using the powerful idea of sparsification [23].If one then reduces from a degree-bounded problem the total number of clauses is linear with respect to the number of variables, meaning that the above reduction preserves subexponential complexity.Impagliazzo et al. [23] introduce a more general theory of reductions preserving subexponential complexity but for our purposes, it is sufficient with polynomial-time many-one reductions which given an instance with n variables produce an instance with O (n) variables.

ETH-based lower bounds and NP-hardness
Arbitrarily choose B in H.We have two challenges to overcome: first, is it possible to find a uniform reduction applicable to every CSP(B ∨= ) problem; second, can such a reduction, if it even exists, be used to obtain lower bounds under the ETH?
We will reach an affirmative answer to both of these questions in this section, and will see that it is possible to obtain lower bounds even for degree-bounded CSP(B ∨= )-B problems, indeed, even for the severely restricted problem CSP(B ∨= )-3 where a variable may occur in at most 3 constraints.However, before we turn to the details we consider an example which shows a large difference between CSP(B ∨= ) problems and related CSPs, and highlight the involved difficulty.
Example 4. For a partition scheme B over the domain D, let B ∨k be the set of all relations definable by disjunctions of length at most k, where each atom is a constraint over B. It is easy to see that B ∨= ⊆ B ∨k for some k, but that the converse is not necessarily true.In fact, B ∨k is in general much more expressive than B ∨= in the context of CSPs.To see this, consider the following reduction from 3-SAT to CSP(B ∨3 ).We only sketch the details since they are not important for the subsequent results.
1. Assume that the domain D contains at least two elements.
2. Since B is a partition scheme it always contains the equality relation eq D and the inequality relation neq D over D. 3. Introduce two fresh variables x f and x t and constrain them as neq D (x f , x t ). 4. For each 3-clause, e.g., ( In other words this reduction is a standard gadget reduction from 3-SAT to CSP(B ∨3 ) which replaces each 3-clause by the corresponding disjunction over B.Moreover, since it only introduces 2 fresh variables in total, it immediately follows that CSP(B ∨3 ) cannot be solved in subexponential time without violating the ETH (recall Example 3).Note that we do not even require any additional assumptions on B: it is sufficient that it is a partition scheme.
For CSP(B ∨= ) the situation is much more difficult since it (in general) is not possible to represent disjunctions of the required form.We will soon see that while it is possible to obtain a suitable reduction to CSP(B ∨= ) when B ∈ H, it is significantly more complicated than the reduction in Example 4. Before we proceed with the actual reduction we define a useful gadget.Lemma 6. Assume that B ∈ H. Then there exists an instance of CSP(B ∨= ) with variables {a, b, c, x 1 , x 2 } which satisfies the following properties: We demonstrate that G satisfies G 1 -G 4 .Properties G 1 and G 2 follow immediately from in-fork and out-fork.To prove G 3 and G 4 , we need to show that whenever a, b, c is totally ordered in a way different from a ≺ b ≺ c or c ≺ b ≺ a, then the gadget is not satisfied.Assume for instance that b ≺ a ≺ c.Then, {b ≺ a, a ≺ c, x 2 (≺, )a, x 2 b, x 2 c} must be satisfiable and this violates property C 4 .The remaining three cases can be ruled out analogously.We conclude that G has the properties Informally, the gadget G(a, b, c, x 1 , x 2 ) constrains b to be between a and c.Equipped with this lemma, we are now ready to prove a weaker version of the main result of the article.Lemma 7. Let B ∈ H. Then CSP(B ∨= ) is NP-hard and it is not solvable in subexponential time, unless the ETH is false.

CSP({N}) to CSP(B ∨= ).
Arbitrarily choose an instance (A, T ) of CSP({N}) and construct an instance I = f ((A, T )) of CSP(B ∨= ) as follows: F 1 : add the variable M to I , F 2 : for each a ∈ A, add a variable a and the constraint a(≺, )M to I , F 3 : for each triple N(a, b, c) ∈ T , introduce five variables z, x 1 , x 2 , x 3 , x 4 and add a(≺, )b, a(≺, )c, b(≺, )c, G(a, M, z, x 1 , x 2 ), and G(b, z, c, x 3 , x 4 ) to I , where G is the gadget from Lemma 6.
Clearly, the reduction above can be carried out in polynomial time.We proceed with the correctness proof.
First, assume that s is a solution to I .For each a ∈ A, either s(a) ≺ s(M) or s(a) s(M).We define a solution s : A → {0, 1} such that s (a) = 0 if and only if s(a) ≺ M. We continue by proving that s satisfies each N(a, b, c) ∈ T .Assume to the contrary that s (a) = s (b) = s (c) = 0, i.e. s(a), s(b), s(c) ≺ s(M).We analyse the gadgets G(a, M, z, x 1 , x 2 ), G(b, z, r, x 3 , x 4 ) and the four orderings that they allow.

s(a) ≺ s(M) ≺ s(z) and s(b) s(z) s(r)
. We see that s(M) ≺ s(z) ≺ s(b) so s (b) = 1 and this is not possible.

s(a) s(M) s(z) and s(b) s(z) s(r). This is not possible since we know that s(a) ≺ s(M).
The case when s (a) = s (b) = s (c) = 1 can be ruled out similarly.We conclude that at least one variable is assigned 0, at least one variable is assigned 1, and the constraint N(a, b, c) is satisfied.
For the other direction, assume that there exists a solution s : A → {0, 1} to (A, T ).We show how to construct a solution to the instance I .Let A 0 ⊆ A be the variables that are assigned 0 by s and let A 1 ⊆ A that are assigned 1.Let (L, ≺) denote a strict total order in (D, ≺) that contains 2| A| + 2 elements The function s satisfies all constraints introduced in step F 2 .We continue by the constraints introduced in step F 3 .Consider an arbitrary constraint N(a, b, c) ∈ T and the corresponding constraints in I : we have introduced five fresh variables z, x 1 , x 2 , x 3 , x 4 and the constraints: (1) a(≺, )b, (2) a(≺, )c, (3) b(≺, )c, (4) G(a, M, z, x 1 , x 2 ), and (5) G(b, z, c, x 3 , x 4 ).The constraints (1) − (3) are clearly satisfied by s.We will now show how to choose s(z) in order to satisfy constraints (3) and (4).Have in mind that, for instance in constraint (4), it is sufficient to choose s(z) such that s(a) ≺ s(M) ≺ s(z) or s(a) s(M) s(z); suitable values always exist for x 1 and x 2 due to G 1 and G 2 .
Let e + be the e-element in (L, ≺) that is the immediate larger neighbour to the element f (M) and define e − analogously.Given two distinct a, b ∈ A, let e ab be an arbitrary e-element in (L, ≺) that lies between s(a) and s(b).The following table summarises how s(z) should be chosen.
We conclude that the function s can be extended to a solution to I .
We need the last stepping stone to prove the stronger version of the lemma above (recall that CSP(B ∨= )-3 is the degreebounded problem where a variable may occur in at most 3 constraints).
Lemma 8. Let B be a partition scheme and assume (V , C ) is an instance of CSP(B ∨= ).If |C| ≤ c|V | for some constant c, then (V , C ) can be reduced to an instance of CSP(B ∨= )-3 with at most 2c|V | variables in polynomial time.
Proof.First, recall that eq D ∈ B since B is a partition scheme.Then pick a variable x ∈ V occurring in constraints c 1 , . . ., c k for k > 3. Introduce k fresh variables x 1 , . . ., x k together with the constraints x 1 (eq D )x 2 , x 2 (eq D )x 3 , . . ., replace each occurrence of x in c i by the corresponding variable x i .Clearly, the degree of each x i variable is at most 3, and the equality constraints enforce that x 1 , . . ., x k are always assigned the same value in any satisfying assignment.Moreover, each constraint contains two variables, so the total number of variables introduced by this reduction is bounded from above by 2|C | ≤ 2c|V |.
With this lemma at hand, we are now ready to prove the main result by carefully analysing the reduction in Lemma 7.
Theorem 9. Let B ∈ H. Then CSP(B ∨= )-3 is NP-hard and it is not solvable in subexponential time, unless the ETH is false.
Take an arbitrary instance (A, T ) of CSP({N})-B with |A| = n (note that |T | ≤ Bn) and apply the reduction f from Lemma 7 to obtain an instance (V , Naturally, Theorem 9 also implies that CSP(B ∨= )-3 (and, hence, CSP(B ∨= )) is NP-complete.For strict partial orders we may combine Theorem 9 with the observation in Theorem 3 to obtain the following corollary.
Corollary 10.Let B be a partition scheme with domain D such that B ∨= contains a strict partial order ≺.Assume ≺ together with the incomparability relation satisfy C 1 -C 3 .Then CSP(B ∨= )-3 is NP-hard and not solvable in subexponential time, unless the ETH is false.
In summary, we may rule out subexponential time algorithms for CSP(B ∨= )-3 for partition schemes B ∈ H.However, the best general algorithm for CSP(B ∨= ) [25,39].Hence, there is a large discrepancy between the upper and lower bound for this problem, suggesting that (at least) one of these bounds can be strengthened.We return to this question in Section 5.

Consequences
The properties in Definition 2 are sufficient for establishing NP-hardness of CSP(B ∨= ), and it is thus natural to ask to which extent they are also necessary.Although a complete answer seems difficult to obtain, we may at least observe that if ≺ ∈ B is an acyclic order such that every strict total order in it contains at most k elements and there is at least one strict total order with three or more elements, then CSP(B ∨= ) is NP-hard, regardless of whether ≺ has properties C 2 -C 4 or not.This can be seen via a polynomial-time reduction from k-Colourability (i.e. the problem CSP({R k }) where R k = {(x, y) ∈ {1, . . ., k} 2 | x = y}) to CSP(B ∨= ).Let (V , E) be an arbitrary undirected graph.Introduce variables c 1 , . . ., c k for each colour, and constrain them as c 1 (≺)c 2 (≺) . . .(≺)c k .For each vertex v ∈ V , introduce a variable w and the constraints w(≺, , eq D )c i , 1 ≤ i ≤ k.Recall that , eq D ∈ B since B is a partition scheme so the relation (≺, , eq D ) is a member of B ∨= .Note that these constraints imply that w equals exactly one colour variable in any satisfying assignment.Finally, introduce the constraint w(≺, )w for each edge (v, v ) in E. It is easy to verify that the resulting CSP(B ∨= ) instance has a solution if and only if (V , E) is k-colourable.It is also easy to verify that the reduction can be computed in polynomial time since k is a constant that only depends on the choice of B. Since k-Colourability is NP-hard whenever k ≥ 3, NP-hardness of CSP(B ∨= ) follows.
Similarly, it is natural to ask what happens if ≺ is an acyclic order that contains infinite strict total orders but does not have in-and/or out-forks.We have seen that this sometimes leads to tractability, as in the case of e.g. the point algebra and the branching time algebra, but this is not always the case.For a simple counterexample, let D = {(0, i), (1, i), (2, i) | i ∈ N} and define ≺ ⊆ D 2 such that (a, b) ≺ (c, d) if and only if a = c and b < d.It is easy to verify that ≺ is an acyclic order (in fact, it is a strict partial order), it contains infinite strict partial orders (such as (0, 0) ≺ (0, 1) ≺ (0, 2) ≺ . . .), and that it does not have in-or out-forks.Let B = {≺, , , eq D } where = D 2 \ {≺, , eq D }, and observe that B is a partition scheme.We show that CSP(B ∨= ) is an NP-hard problem via a polynomial-time reduction from 3-Colourability.Let (V , E) be an arbitrary undirected graph.For each vertex v ∈ V , introduce a variable w, and for each edge (w, w ) ∈ E, introduce the constraint w w .Note that ((a, b), (c, d)) ∈ if and only if a = c and that a and c are restricted to the three-element set {0, 1, 2}.Given this, it is easy to verify that the resulting CSP(B ∨= ) instance has a solution if and only if (V , E) is 3-colourable.

A tractable subclass of degree-bounded problems
Given that CSP(B ∨= )-3 is NP-hard whenever B ∈ H, it is interesting to see whether the degree bound can be further lowered with retained NP-hardness or not.We will not be able to answer this question in its full generality but for ω-categorical partition schemes B, CSP(B ∨= )-2 is, to the contrary, always solvable in polynomial time.We begin by recapitulating the concept of ω-categoricity and its connections to qualitative CSPs.A first-order theory is a set of first-order sentences and the first-order theory of a constraint language is the set of first-order sentences that are logically entailed by .We say that a satisfiable first-order theory T is ω-categorical if all countable models of are isomorphic, and a constraint language is ω-categorical if its first-order theory is ω-categorical.It is known that a large number of qualitative CSPs can be captured via ω-categorical constraint languages: well-known examples include Allen's algebra [21] and RCC-8 [8].Many more examples can be found in Section 1 of Bodirsky & Jonsson [7].
The basic idea behind our tractability result is to study the tree-width of CSP(B ∨= )-2 instances and exploit a result by Bodirsky & Dalmau [6].A tree-decomposition of a graph G = (V , E) is a pair D = (T , f ), where T is a rooted tree with vertex set T and f : T → 2 V is a function such that the following properties hold: t∈T f (t) = V , (T 2 ) for every u ∈ V , the set {t ∈ T | u ∈ f (t)} induces a connected subtree of T , and (T 3 ) for each edge (u, v) ∈ E, there exists a t ∈ T such that {u, v} ⊆ f (t).
The width of the tree-decomposition D is max t∈T | f (t)| − 1, and the treewidth of G is the minimum width over all tree-decompositions of G.
We will consider the treewidth of Gaifman graphs.The Gaifman graph (or the primal graph) of a CSP instance (V , C ) is the graph on vertex set V where two distinct vertices v i and v j are adjacent if and only if v i and v j simultaneously appear in the scope of some constraint in C .The following result is a direct consequence of Corollary 1 in Bodirsky & Dalmau [6].
Proposition 11.Let be a finite ω-categorical constraint language.Then CSP( ) restricted to instances whose Gaifman graphs have tree-width bounded by some constant is solvable in polynomial time.
Proof.If B is ω-categorical, then B ∨= is ω-categorical, too, since this property is preserved under first-order definitions [22,Theorem 7.3.8].Let (V , C ) be an arbitrary instance of CSP(B ∨= )-2.Since the relations in B ∨= are binary, it is easy to see that the Gaifman graph of (V , C ) is the disjoint union of simple paths and cycles.It is well-known (and not difficult to verify) that such a graph has tree-width at most 2. The result follows from Proposition 11 since B ∨= is a finite set of relations.

Faster exponential-time algorithms for CSP(B ∨= )
We have established that CSP(B ∨= ) for B ∈ H is unlikely to be solvable in subexponential time, so we focus our efforts on constructing faster exponential-time algorithms.Algorithm 1 (that we present below) is an abstract description of the "classical" backtracking algorithm for solving CSPs over partition schemes.It is not so difficult to see that this algorithm solves CSP(B ∨= ) in 2 O (n 2 ) time (cf.Jonsson & Lagerkvist [25] or Renz & Nebel [38]), and we will soon see that this algorithm applied to the degree-bounded problem runs in 2 O (n) time.The algorithm is well-known but we give a detailed account of it since it makes the presentation of the degree-bounded case much simpler.We note that the general upper bound can be improved for several specific partition schemes, for instance: • the CSP over Allen's interval algebra admits a 2 O (n log n) time algorithm [25], and • the CSP over Allen's interval algebra restricted to intervals of unit length admits a 2 O (n log log n) time algorithm [11].
Importantly, as we will prove in this section, the CSP problem over RCC-8 also admits a 2 O (n log n) time algorithm.This immediately implies, for instance, that the CSPs for RCC-5 and the partial-order time algebra can be solved within this time bound, too [3].

The branching algorithm
When presenting the branching algorithm we for simplicity assume that the constraint language B is a partition scheme where CSP(B) is solvable in polynomial time.One can show that an instance I = (V , C ) of CSP(B ∨= ) is satisfiable by providing a certificate defined as a satisfiable instance I = (V , C ) of CSP(B) obtained by removing all but one relation from each constraint in C .Note that I is satisfiable if and only if it has a certificate: a satisfying assignment to I satisfies I , and vice versa.
Observe that constraints of the restricted instance I π do not contain relations from N 1 ∪ • • • ∪ N 6 .Thus, I π is in H 8 and we can solve it in polynomial time.By definition, the algorithm is sound, i.e. if it returns yes, then I is satisfiable.To prove completeness, assume that I = (V , C ) is a certificate to I .Define two relations according to C : an equivalence relation and an acyclic order 2) respects (1), so it induces an acyclic ordering on the equivalent classes.Arbitrarily extend it to a linear order and index equivalence classes V 1 , . . ., V r accordingly.Define π : V → {1, . . ., r} as π (v) = i if and only if v ∈ V i for all v ∈ V .Since the algorithm enumerates ordered partitions, at some point it considers I π and returns yes.
To determine the time complexity, we observe that there are at most n n ordered partitions of an n-element set.Generating all unordered partitions of a set takes O (1) amortized time per partition [41] and generating all permutations takes O (1) time per permutation [40].Checking a restricted instance takes polynomial time.Thus, the running time of the algorithm is bounded by This algorithm may be interesting to compare with the algorithm for RCC-8 suggested by Renz and Nebel [38].Their approach is based on Algorithm 1 but SolveBaseCase is applied to instances of maximal tractable subclasses instead of instances of CSP(R).The algorithm presented in Theorem 16 also utilises a maximal tractable subclass but the underlying search strategy is very different.Renz and Nebel's algorithm improves the branching factor when compared to Algorithm 1 and the effect is clearly noticeable in their experimental evaluation.However, the algorithm by Renz and Nebel uses heuristics and it is thus difficult to calculate its running time and compare it to the concrete upper bound obtained in Theorem 16.

Discussion
Our main focus has been to study the complexity of CSPs over partition schemes B, with a particular emphasis on CSP(B ∨= ) when B contains an acyclic order.We identified the four properties C 1 , C 2 , C 3 , C 4 and provided several real-world examples of acyclic orders satisfying these properties.More importantly, we proved that these properties are sufficient for establishing both NP-hardness and lower bounds under the ETH, even for the degree-bounded problems.At this stage it is worth to yet again point out that none of our results require model-theoretic assumptions such as ω-categoricity.
One important consequence of lower bound results is that they can be used to rule out certain types of algorithms.First of all, k-consistency algorithms are not applicable since they run in polynomial time for arbitrary fixed k.The powerful generalisation of k-consistency, the Datalog framework [6,16], is not applicable either since every Datalog program runs in polynomial time, too.Another example is provided by graph-decomposition algorithms for CSPs (for instance, algorithms that exploit treewidth).Such algorithms have been highly influential in the CSP context [1,4,12], but they typically result in polynomial-time or subexponential algorithms and are therefore unlikely to be usable for CSP(B ∨= ) problems.
Naturally, there are types of exponential-time algorithms that are not ruled out by our lower bounds, and one of the main open questions of our article is whether it is possible to classify the CSP(B ∨= ) problems solvable faster than 2 O (n 2 ) -similarly to how we were able to obtain an improved algorithm for RCC-8.Could it be the case that all problems of this form are solvable in 2 O (n log n) time, or even in single-exponential time?A uniform upper bound of this form would be a major improvement but would not contradict any of our lower bounds.Jonsson and Lagerkvist [25] have presented general results for obtaining algorithms based on enumeration of domain values, which are sometimes much faster than branching algorithms.For example, Allen's interval algebra is solvable in 2 O (n 2 ) time with the branching algorithm in Section 5, but the enumeration-based algorithm in Jonsson and Lagerkvist [25] runs in 2 O (n log n) time.The range of applicability for enumeration-based algorithms is unfortunately not well understood, and more work is needed to clarify whether it generalises to broader classes of partition schemes.
Another viable approach is to use methods that have been successful in solving finite-domain CSPs.Einarson [15] demonstrates how the finite-domain version of the PPSZ algorithm [20] can be applied to infinite-domain CSPs.His results are inconclusive: the algorithm is faster than previously known algorithms for certain problems but it is, for instance, not competetive for Allen's interval algebra CSP(A ∨= ).Similarly, there exist several general results on the kernelizability of finite domain CSPs [10,24,28], i.e., algorithms for reducing the number of constraints.Could some of these approaches be generalised to infinite-domain CSPs?If yes, then we might be able to obtain improved algorithm simply by combining a kernelization procedure with the branching algorithm presented in Section 5.
These examples also suggest that it may be worthwhile to strengthen the subexponential lower bound for CSP(B ∨= ) even further-if possible.One possible way of doing this is to exploit the strong exponential-time hypothesis, i.e. the conjecture that SAT is not solvable in O * (c n ) time for any c < 2. The challenge here is that the SETH intrinsically requires reductions where one can "simulate" clauses of arbitrary high arity with a very small overhead-this seems difficult for CSP(B ∨= ) which only allows binary relations.Another possibility is to use bounds based on the Chromatic Number problem: Jonsson and Lagerkvist [25,Th. 21] have related the time complexity of Allen's interval algebra with the time complexity of the Chromatic Number problem and obtained concrete lower bounds of the form O * (c n ) for a constant c > 1 depending on the complexity of Chromatic Number.Thus, we ask the following: should stronger lower bounds for CSP(B ∨= ) be pursued in the setting of CNF-SAT and the SETH, or are problems of this kind fundamentally closer to e.g.colouring problems?

Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Fig. 1 .
Fig. 1.Illustration of the basic relations of RCC-8 with two-dimensional disks.
and a ≺ c, then there exists d 1 ∈ D such that d 1 a, d 1 b, and d 1 (≺, )c, C 3 . (out-fork) if a, b, c ∈ D and a ≺ b ≺ c, and a ≺ c, then there exists d 2 ∈ D such that d 2 (≺, )a, d 2 b, and d 2 c, and C 4 . (no-fork) if a, b, c ∈ D and a ≺ b ≺ c, and a ≺ c, then there does not exist any d 3 ∈ D such that d 3 a, d 3 (≺, )b, and d 3 c.

Theorem 3 . 2 Fig. 3 .
Fig. 3.The choice of d 1 and d 2 in the unit interval example.Proof.Assume to the contrary that there exist a, b, c, d 3 ∈ D such that d 3 a, d 3 (≺, )b, and d 3 c.The relation ≺ is a strict partial order so it is transitive.If d 3 ≺ b, then d 3 ≺ c.But then d 3 c cannot hold since the relations ≺ and are

3 .
The transitivity of p implies that I 1 (p)I 3 , too.For in-fork, we choose I 4 = [I − 1 , I + 2 ] so that I 4 I 1 , I 4 I 2 , and I 4 ≺ I 3 .For out-fork, one may choose I 5 = [I − 2 , I + 3 ].Concerning the no-fork property, simply note that an interval I 6 which precedes I 2

C 4 .
Pick three unit intervals a, b, c = [a − , a + ], [b − , b + ], [c − , c + ] in D such that a(o)b(o)c and a(o)c.Assume to the contrary that there is a d 3 ∈ D such that d 3 a, d 3 (≺, )b, and d 3 c.If d 3 (p)a, then d 3 cannot satisfy d 3 (≺, )b so d 3 (p −1 )a.Similarly d 3 (p)c.This contradicts the fact that a ≺ c.Let us consider another example where the domain contains the closed disks in R 2 , the relation ≺ is the strict subset relation, and where

Fig. 4 .
Fig. 4. The dashed circles show possible choices of disks for in-fork (left) and out-fork (right).

d 2 also contains d 1 (
or is contained by d 3 ).This example can easily be adapted to relations such as PP in RCC-5, NTPP in RCC-8, and the relation d ⊕ d in the rectangle algebra.The examples presented above are just a small selection of partition schemes that satisfy properties C 1 -C 4 and many additional examples can be found, for instance, in the survey by Dylla et al.[14].Last, let us remark that there are examples of strict partial orders that do not have in-and/or out-forks.Well-known examples are the less-than relation < in the (1dimensional) point algebra and in the branching time algebra.Interestingly, CSP(B ∨= ) is polynomial-time solvable in these two cases and we will come back to this observation at the end of Section 4.1.
since we introduce a constraint a(≺, )M for each a ∈ A and five constraints for each N(a, b, c) ∈ T .The term 1 + 5B is constant.Hence, combining f with the reduction from Lemma 7 yields an instance of CSP(B ∨= )-3 with O (n) variables in polynomial time.
and (3) for every B i ∈ B, the converse relation B i (i.e.B i = {(y, x) | (x, y) ∈ B i }) is in B. We define B ∨= to be the set of all unions of relations from B. Note that each such relation is still binary, i.e., of arity 2. Equivalently, each relation in B ∨= can be viewed as a disjunctionB 1 (x, y) ∨ B 2 (x, y) ∨ • • • ∨ B k (x, y) for some {B 1 , . .., B k } ⊆ B.We sometimes abuse notation and write (B 1 , . . ., B k ) to denote the relation B 1 ∪ • • • ∪ B k .The set B ∨= and the problem CSP( ) where ⊆ B ∨= Acyclic orders are irreflexive (i.e. they do not contain any element d such that d ≺ d) by definition.We say that ≺ is a strict partial order if it is irreflexive and for arbitrary d, d , d ∈ D: d ≺ d and d ≺ d imply d ≺ d (transitivity).Note that these two properties also ensure that ≺ is antisymmetric, i.e. if d ≺ d , then d ≺ d does not hold.