Constraint Satisfaction and Semilinear Expansions of Addition over the Rationals and the Reals

Constraint Satisfaction and Semilinear Expansions of Addition over the Rationals and the Reals

Abstract

A semilinear relation is a finite union of finite intersections of open and closed half-spaces over, for instance, the reals, the rationals, or the integers. Semilinear relations have been studied in connection with algebraic geometry, automata theory, and spatiotemporal reasoning. We consider semilinear relations over the rationals and the reals. Under this assumption, the computational complexity of the constraint satisfaction problem (CSP) is known for all finite sets containing , , and . These problems correspond to expansions of the linear programming feasibility problem. We generalise this result and fully determine the complexity for all finite sets of semilinear relations containing . This is accomplished in part by introducing an algorithm, based on computing affine hulls, which solves a new class of semilinear CSPs in polynomial time. We further analyse the complexity of linear optimisation over the solution set and the existence of integer solutions.

Keywords. Constraint satisfaction problems, Semilinear sets, Algorithms, Computational complexity

The first author was partially supported by the Swedish Research Council (VR) under grant 621-2012-3239.

peter.jonsson@liu.se

thapper@u-pem.fr

1Introduction

We work over a ground set (or domain) , which will either be the rationals, , or the reals, . We say that a relation is semilinear if it can be represented as a finite union of finite intersections of open and closed half-spaces in . Alternatively, is semilinear if it is first-order definable in where [12]. Semilinear relations appear in many different contexts within mathematics and computer science: they are, for instance, frequently encountered in algebraic geometry, automata theory, spatiotemporal reasoning, and computer algebra. Semilinear relations have also attained a fair amount of attention in connection with constraint satisfaction problems (CSPs). In a CSP, we are given a set of variables, a (finite or infinite) domain of values, and a finite set of constraints. The question is whether or not we can assign values to the variables so that all constraints are satisfied. From a complexity theoretical viewpoint, solving general constraint satisfaction problems is obviously a hard problem. Various ways of refining the problem can be adopted to allow a more meaningful analysis. A common refinement is that of introducing a constraint language; a finite set of allowed relations. One then considers the problem CSP in which all constraint in the input must be members of . This parameterisation of constraint satisfaction problems has proved to be very fruitful for CSPs over both finite and infinite domains. Since is finite, the computational complexity of such a problem does not depend on the actual representation of the constraints.

The complexity of finite-domain CSPs has been studied for a long time and a powerful algebraic toolkit has gradually formed [7]. Much of this work has been devoted to the Feder-Vardi conjecture [10] which posits that every finite-domain CSP is either polynomial-time solvable or NP-complete. Infinite-domain CSPs, on the other hand, constitute a much more diverse set of problems. In fact, every computational problem is polynomial-time equivalent to an infinite-domain CSP [1]. Obtaining a full understanding of their computational complexity is thus out of the question, and some further restriction is necessary. In this article, this restriction will be to study semilinear relations and constraint languages.

A relation is said to be essentially convex if for all there are only finitely many points on the line segment between and that are not in . A constraint language is said to be essentially convex if every relation in is essentially convex. The main motivation for this study is the following result:

One may suspect that there are semilinear constraint languages such that CSP but is not essentially convex. This is indeed true and we identify two such cases. In the first case, we consider relations with large “cavities”. It is not surprising that the algorithm for essentially convex relations (and the ideas behind it) cannot be applied in the presence of such highly non-convex relations. Thus, we introduce a new algorithm which solves CSPs of this type in polynomial time. It is based on computing affine hulls and the idea of improving an easily representable upper bound on the solution space by looking at one constraint at a time; a form of “local consistency” method. In the second case, we consider relations that are not necessarily essentially convex, but look essentially convex when viewed form the origin. That is, any points and that witnesses a not essentially convex relation lie on a line that passes outside of the origin. We show that we can remove all such holes from to find an equivalent constraint language that is essentially convex, and thereby solve the problem in polynomial time.

Combining these algorithmic results with matching NP-hardness results and the fact that CSP is always in NP for a semilinear constraint language (cf. Theorem 5.2 in Bodirsky et al. [2]) yields a dichotomy:

Our result immediately generalises the first part of Theorem ?. It also generalises another result by Bodirsky et al. [3] concerning expansions of with relations that are first-order definable in . One may note that this class of relations is a severely restricted subset of the semilinear relations since it admits quantifier elimination over the structure , where denotes the binary addition function. This follows from the more general fact that the first-order theory of torsion-free divisible abelian groups admits quantifier elimination (see e.g. Theorem 3.1.9 in [18]). One may thus alternatively view relations that are first-order definable in as finite unions of sets defined by homogeneous linear systems of equations.

We continue by generalising the second part of Theorem ?, too: if is semilinear and contains , then the problem of optimising a linear polynomial over the solution set of CSP is polynomial-time solvable if and only CSP is polynomial-time solvable (and NP-hard otherwise). We also study the problem of finding integer solutions to CSP for certain semilinear constraint languages . Here, we obtain some partial results but a full classification remains elusive. Our results shed some light on the scalability property introduced by Jonsson and Lööw [16].

This article has the following structure. We begin by formally defining constraint satisfaction problems and semilinear relations together with some terminology and minor results in Section 2. The algorithms and tractability results that are presented in Section 3 while the hardness results can be found in Section 4. By combining the results from Section 3 and Section 4, we prove Theorem ? in Section 5. We partially generalise Theorem ? to optimisation problems in Section 6, and we study the problem of finding integer solutions in Section 7. Finally, we discuss some obstacles to further generalisations in Section 8. This article is a revised and extended version of a conference paper [17].

2Preliminaries

2.1Constraint satisfaction problems

Let be a finite set of finitary relations over some domain (which will usually be infinite). We refer to as a constraint language. In order to avoid some uninteresting trivial cases, we will assume that all constraint languages are non-empty and contain non-empty relations only.

A first-order formula is called primitive positive if it is of the form , where each is an atomic formula, i.e., either or with the relation symbol for a -ary relation from . We call such a formula a pp-formula. Note that all variables do not have to be existentially quantified; if they are, then we say that the formula is a sentence. Given a pp-formula , we let denote the set of variables appearing in . The atomic formulas in a pp-formula are also called the constraints of .

The constraint satisfaction problem for a constraint language (CSP for short) is the following decision problem:

The exact representation of the relations in is unessential since we exclusively study finite constraint languages.

A relation is pp-definable from if there exists a quantifier-free pp-formula over such that

The set of all relations that are pp-definable over is denoted by . The following easy but important result explains the role of primitive positive definability for studying the computational complexity of CSPs. We will use it extensively in the sequel without making explicit references.

Let and be two constraint languages such that and are relations of the same arity. Given an instance of CSP, let denote the instance where each occurrence of a relation is replaced by . We say that CSP is equivalent to CSP if is true in if and only if is true in . It is clear that if CSP and CSP are equivalent CSPs, then they have the same complexity (up to a trivial linear-time transformation).

2.2Semilinear relations

The domain, , of every relation in this article will be the set of rationals, , or the set of reals, . In all cases, the set of coefficients, , will be the set of rationals, but in order to avoid confusion, we will still make this explicit in our notation. We define the following sets of relations.

  • denotes the set of linear equalities over with coefficients in .

  • denotes the set of (strict and non-strict) linear inequalities over with coefficients in .

Sets defined by finite conjunctions of inequalities from are called linear sets. The set of semilinear sets, , is defined to be the set of finite unions of linear sets. We will refer to and as semilinear relations over and , respectively. One should be aware of the representation of objects in and compared to . In and , we view the equalities and inequalities as syntactic objects which we can use for building logical formulas. Now, recall the definition of a linear set: it is defined by a conjunction of inequalities. However, a linear set is not a logical formula, it is a subset of . The same thing holds for semilinear sets: they are defined by unions of linear sets and should thus not be viewed as logical formulas. This distinction has certain advantages when it comes to terminology and notation but it also emphasise a difference in the way we view and use these objects. The objects in and are often used in a logical context (such as pp-definitions) while the semilinear relations are typically used in a geometric context.

Given a relation of arity , let and . We demonstrate that CSP and CSP are equivalent as constraint satisfaction problems whenever . Thus, we will exclusively concentrate on relations from in the sequel. Let and let be an instance of CSP. Construct an instance of CSP by replacing each occurrence of in by . If has a solution, then has a solution since for each . If has a solution, then it has a rational solution by Lemma 3.7 in Bodirsky et al. [2] so has a solution, too.

The following lemma is a direct consequence of our definitions: this particular property is often referred to as -minimality in the literature [14].

The set of semilinear relations can also be defined as those relations that are first-order definable in [12]. In particular, is closed under pp-definitions. Consequently, Lemma ? is applicable to all relations discussed in this article.

It follows that and . One may also note that every homogeneous linear equation (with coefficients from ) is pp-definable in .

2.3Unary semilinear relations

For a rational , and a unary relation , let . When ‚ we will also write for .

Given a relation and two distinct points , we define

The relation is a parameterisation of the intersection between the relation and a line through the points and . Note that is a member of so, by Lemma ?, is a member of , too.

A -ary relation is bounded if there exists an such that . A unary relation is unbounded in one direction if is not bounded, but there exists an such that one of the following holds: ; or . A unary relation is called a bnu (for bounded, non-constant, and unary) if it is bounded and contains more than one point.

(1) By Lemma ?, there exists an such that either

  1. and ; or

  2. and .

Assume that ( ?) holds. (The remaining case follows by considering .) By choosing a rational , it is not hard to see that the relation

is bounded and contains an interval. The result then follows from Lemma ?.

(2) Assume that ( ?) holds and let be a negative element. (The remaining case follows by considering .) Then,

is bounded and contains the element . The result again follows from Lemma ?.

For a unary semilinear relation , and a rational , let denote the set of unary semilinear relations such that and for all , there exists a with .

Let and . By Lemma ?, there exist elements with and . The relation is pp-definable in and satisfies: , , and .

Let . The proof then follows using a similar construction as in the proof of Lemma ?.

2.4Essential convexity

Let be a -ary relation over . The relation is convex if for all , contains all points on the line segment between and . We say that is essentially convex if for all there are only finitely many points on the line segment between and that are not in .

We say that excludes an interval if there are and real numbers such that whenever . Note that we can assume that are rational numbers, since we can choose any two distinct rational numbers between and instead of and .

If is not essentially convex, and if and are such that there are infinitely many points on the line segment between and that are not in , then we say that and witness that is not essentially convex. Due to Lemma ?, we conclude that a semilinear relation is essentially convex if and only if it does not exclude an interval. We say that a constraint language is essentially convex if all its relations are essentially convex.

3Tractability

In this section, we present our two main sources of tractability. Section 3.1 contains a new algorithm for semilinear constraint languages containing and such that does not contain a bnu. In Section 3.2, we extend the applicability of Theorem ? from essentially convex semilinear constraint languages to a certain class of semilinear CSPs that are not essentially convex.

3.1Affine consistency

Instead of computing the exact solution set to a CSP instance, our approach will be to reduce an upper bound on this set as far as possible. In particular, we will maintain a representation of an affine subspace that is guaranteed to contain the solution set, and repeatedly intersect this subspace with every constraint in order to attempt to reduce it further. This can be seen as a form of local consistency. If we manage to reduce the upper bound to an empty set, then we are certain that the instance is unsatisfiable. We will show that under certain conditions, the converse holds; if the upper bound is non-empty, then there are necessarily solutions. To formalise this idea, we will need some definitions.

For a subset , let denote the affine hull of in :

An affine subspace is a subset for which . The points are said to be affinely independent if with implies . The dimension, , of a set is defined to be one less than the maximum number of affinely independent points in .

We define a notion of consistency for sets of semilinear constraints which we call affine consistency. Let be a finite set of variables and let . A set of constraints with is affinely consistent with respect to a non-empty affine subspace if for all , where .

Algorithm ? establishes affine consistency for a set of constraints and answers “yes” if the resulting affine subspace is non-empty and “no” otherwise. In the rest of this section, we show that this algorithm correctly solves CSP when is a semilinear constraint language such that does not contain a bnu. Furthermore, we show that the algorithm can be implemented to run in polynomial time when applied to constraint languages of this kind.

We begin by proving a technical lemma which is the basis for these results.

The proof is by induction on the dimension . For , both and consist of a single point . Clearly, for some and for some . Now assume that and that the lemma holds for all , with and . Let be affinely independent points in and let be affinely independent points in . For , consider the lines through and , and the lines through and . Let () be a hyperplane in through the origin that is not parallel to any of the lines or . Then, intersects each of the lines. Let and let .

Express the line as , for some . Let . Since contains and , it follows that is not a constant and hence unbounded. By Lemma ?(1), is unbounded in both directions. By Lemma ?, , for some positive constant . An analogous argument shows that that , for some positive constant . Let be a positive constant such that and let . This ensures that for any , intersects the lines in affinely independent points, and intersects the lines in affinely independent points.

Let , , , and . We now have with , for every . By induction on and , it follows that for some and . This holds for all , hence there exist distinct with and . Since , , and , it follows that strictly contains , so we have , and . Therefore we have the equality . The lemma follows.

For a semilinear relation , we let denote the representation size of , i.e., the number of bits needed to describe the arities and coefficients of each inequality in some fixed definition of .

Let be the representation of as the union of linear sets . By Lemma ?, there exists an such that and since for all , the algorithm will find such an on line 1 by simply comparing the dimensions of these sets. If , then the algorithm returns , signalling that the affine hull is empty.

Otherwise, the affine hull of a non-empty polyhedron can always be obtained as a subset of its defining inequalities (cf. Schrijver [20]). Here, some of the inequalities may be strict, but it is not hard to see that removing them does not change the affine hull. If is an inequality that cannot be removed without increasing the dimension of the affine hull, then it is clear that still cannot be removed after the loop. Hence, after the loop, no inequality in can be removed without increasing the dimension of the affine hull. It follows that itself defines an affine subspace, , and .

Using the ellipsoid method, we can determine the dimension of the affine hull of a polyhedron defined by a system of linear inequalities in time polynomial in the representation size of the inequalities [20]. To handle strict inequalities on line 1, we can perturb these by a small amount, while keeping the representation sizes polynomial, to obtain a system of non-strict inequalities with the same affine hull. The algorithm does at most affine hull calculations. The total time is thus polynomial in . Finally, the set is a subset of , so .

Assume that each relation is given as , where is a linear set for each . First, we show that the algorithm terminates with equal to the affine hull of the solution space of the constraints.

Assume that the input consists of the constraints over variables , . Let denote the solution space of the instance. It is clear that is contained in throughout the execution of the algorithm. Therefore, so it suffices to show that . We will show that for all . When the algorithm terminates, we have for every . In particular, the claim holds for . Now assume that the claim holds for . Then, and satisfy the requirements of Lemma ? with . Therefore, we can use this lemma to conclude that .

Finally, we show that the algorithm can be implemented to run in polynomial time. The call to Algorithm ? in the inner loop is carried out at most times, where . The size of is at most , so the size of never exceeds , where is a relation with maximal representation size. Therefore, each call to Algorithm ? takes polynomial time and consequently, the entire algorithm runs in polynomial time.

3.2Essential convexity

We will now identify another family of polynomial-time solvable semilinear CSPs. This time, we base our result on essentially convex semilinear constraint languages (Theorem ?). We extend this result to the situation where we are only guaranteed that all unary relations that are pp-definable in the language are essentially convex. The idea is that even if we do not have the constant relation to help us identify excluded intervals, we are still able to see excluded full-dimensional holes. We follow up this by showing that we can remove certain lower-dimensional holes and thus recover an equivalent essentially convex constraint language. We remind the reader that the dimension of a set is defined with respect to its affine hull, as in Section 3.1.

For , we let denote the euclidean norm of , and the euclidean distance between and .

Let denote the convex hull of and let denote its dimension. The set is semilinear (see, for instance, Stengle et al. [21]). Let be a formula for and let be a formula for on quantifier-free DNF over . It remains to show that for each , the dimension of the convex set defined by is smaller than . To prove this, we show that for every point in , and every , there exists a point in such that . Since every -dimensional convex set contains a small -dimensional open ball around every point in its interior, it follows from this that none of the sets can be -dimensional.

An illustration of the entities involved in the induction step.
An illustration of the entities involved in the induction step.

Carathéodory’s theorem (cf. Schrijver [20]) states that for every , we can find affinely independent points, , such that lies in . By induction over , we show that for every point , and every , there is a point such that . For , this statement follows trivially as each was chosen from . Now assume that and that the statement holds for all . By the induction hypothesis, the statement holds for the set . Every can be written as for some and . Let be a point in that is at distance at most from and let . Then,

Let be a small constant to be fixed later. By Lemma ?, there exists a unary relation . Consider the following relation:

Since , we also have . By assumption, does not exclude an interval, so there exists a such that and . Then, by the definition of , there exists a and a point such that:

where is a constant for a fixed , and the first inequality follows from the triangle inequality. The claim now follows for the point by taking since .

If is essentially convex, then there is nothing to prove. Assume therefore that is not essentially convex. By Lemma ?, each can be defined by a formula , where , , …, are conjunction over , and , …, define sets whose affine hulls are of dimensions strictly lower than that of the set defined by . Assume additionally that the formulas are numbered so that the affine hulls of the sets defined by do not contain and that the affine hulls of the sets defined by do contain . Define by

where defines the affine hull of the set defined by . Then, the constraint language is essentially convex since witnesses of an excluded interval only occur inside an affine subspace not containing ; otherwise we could use such a witness to pp-define a unary relation excluding an interval.

Let be an arbitrary instance of CSP over the variables and assume where is quantifier-free. Construct an instance of CSP by replacing each occurrence of a relation in by . Clearly, if is satisfiable, then so is . Conversely, let be a solution to and assume that is not satisfiable. Let be the line in through and and let be the unary relation . All tuples in correspond to solutions of that are not solutions to .

Fix a constraint in and consider the points in that satisfy this constraint but not . These are the points on for which satisfies . For each , satisfies at most one point on since otherwise the affine hull of the relation defined by would contain . Hence, each constraint in can account for at most a finite number of points in , so is finite.

Assume first that . Then, is not essentially convex which contradicts the assumption that every unary relation in is essentially convex. Assume instead that , where the single point in corresponds to the solution . Recall that is not essentially convex. Let be a -ary relation that is not essentially convex and let witness this. The relation since . Then, is unary and not essentially convex which leads to a contradiction. It follows that if is satisfiable, then so is .

4NP-hardness

We now derive a unified condition for all hard CSPs classified in this article. It is based on a polynomial-time reduction from the NP-hard problem Not-All-Equal 3SAT [19], i.e. the problem CSP where . The proof is divided into three different lemmas. First, we present a reduction from Not-All-Equal 3SAT to a simple semilinear CSP. We then show that having a bnu that is bounded away from allows us to pp-define unary relations that are, in a certain sense, close to being either the relation or . In the final step, we combine these two results and show that having a bnu that excludes an interval and that is bounded away from is a sufficient condition for CSP() to be NP-hard.

The proof is by a polynomial time reduction from CSP. Let denote an arbitrary instance of CSP. Construct an instance of CSP as follows. Impose the constraint on each variable. For each constraint in , introduce the constraints and , where is a fresh variable.

Assume that has a solution. Consider a constraint in . If two of the variables are assigned the value , then the equation is satisfied by choosing . If two of the variables are assigned the value , then the equation is satisfied by choosing . Hence, is satisfiable.

Assume that has a solution . Then, has a solution defined by if and if . Assume to the contrary that for some variables with a constraint . Consider the equation in . By the assumption on , we have , and hence . But this is a contradiction as the constraint is also in . We can similarly rule out the case . This proves that is a solution to .

If , then the result follows from Lemma ?. Otherwise, by Lemma ?, there exists a constant such that the set is non-empty and contains points that are either all positive or all negative. Similarly, there exists a constant such that is non-empty and contains points that are either all positive or all negative. Let and . Assume that both sets contain positive points only or that both sets contain negative points only. Then, the result follows using Lemma ? with the relation (or if the points of are negative). The case when the one set contains positive points and the other contains negative points is handled similarly using the relation .

We show that contains a unary relation . The result then follows from Lemma ?. If already contains such a relation, then we are done. Otherwise, by Lemma ?, contains a unary relation , for every . Since excludes an interval, there are points and such that whenever . Furthermore, and can be chosen so that , and by scaling , we may assume that . Let . Note that , for some . Similarly, possibly by first scaling , let be distinct points with and let .

Now, define the following unary relations:

The relations and are roughly translations of and , where the constant relation has been approximated by the relation . Since , we have . Hence, if is chosen small enough, then the relation will satisfy the conditions of Lemma ?. This finishes the proof.

5Semilinear expansions of

In this section, we prove our main result: Theorem ?. We divide the proof into two parts. Consider the following two properties:

  • There is a unary relation in that contains a positive point and satisfies for some .

  • There is a unary relation in that contains a positive point and satisfies for some .

In the first part of the proof (Section Section 5.1), we consider constraint languages that simultaneously satisfy the properties (P) and (P). In the second part (Section Section 5.2), we consider constraint languages that violates at least one of them. In both parts, we give a detailed description of the boundary between easy and hard problems. By combining Theorem ? and Theorem ?, we establish Theorem ?.

In addition to the two algorithmic results in Section 3.1, there is also a trivial source of tractability. A relation is -valid if it contains the tuple and a constraint language is -valid if every relation in it is -valid. Every instance of a CSP over a -valid constraint language admits the solution that assigns to every variable.

When we consider constraint languages that are not -valid, the following lemma shows that there is always a pp-definable unary relation that is not -valid.

By assumption, contains some -ary relation that is not -valid, and by our definition of a constraint language, is non-empty. Let be a tuple that contains the largest possible number of zeroes. Assume for simplicity that the first entries of equals . Consider the following unary relation in .

The relation is non-empty and not -valid.

5.1The case (P) and (P)

The following theorem covers the case when the constraint language satisfies both of the properties (P) and (P). As a corollary, we obtain a complete classification for semilinear constraint languages containing . The latter result is interesting in itself and it will also be used in Section 5.2 and Section 6.

Let be the set of all bounded, non-empty unary relations in such that for some . Assume that is not -valid. First, we show that is non-empty. By Lemma ?, contains a non-empty unary relation that is not -valid. Scale this relation so that it contains and call the resulting relation . Let be a unary relation witnessing (P) and let be a unary relation witnessing (P). Scale and so that some positive point from each coincides with 1 and let . If does not contain a negative point, then . Otherwise, contains a negative point . It follows that . Hence, the set is non-empty.

Assume that does not contain a bnu. Then, neither does and hence contains only constants. It follows by Theorem ? that establishing affine consistency solves CSP().

Otherwise, contains a bnu. If all unary relations of are essentially convex, then by Lemma ? and Theorem ?, CSP is equivalent to CSP for an essentially convex constraint language . Tractability follows from Theorem ?.

Finally, if contains a bnu and contains a unary relation that excludes an interval, then NP-hardness follows from Lemma ?.

If does not contain a bnu, then tractability follows from Theorem ?. If all relations in are essentially convex, then tractability follows from Theorem ?.

Otherwise, contains a bnu, and since , also contains a unary relation that is not essentially convex. Since is not -valid, NP-hardness then follows from Theorem ?.

5.2The case P or P

Let be a constraint language such that either (P) or (P) is violated. In this section, we show that can be replaced by an equivalent constraint language of a restricted type. Let denote the set of relations that are are finite unions of homogeneous linear sets. We will call such relations homogeneous semilinear relations. We remind the reader that we can always pp-define the relations and in : and . Hence, we can freely use the constant 0 and negation in forthcoming pp-definitions.

From now on, let , , and . For a relation , define to be the cone over . For a constraint language , let . Note that, for , we have , and since , we also have .

For an assignment and a rational , let denote the assignment .

Assume that does not satisfy (P). The proof for the case when does not satisfy (P) follows similarly.

Let be a relation in and let be a quantifier-free DNF formula for , where each formula is conjunction of strict and non-strict inequalities. Remove every disjunct that contains a non-homogeneous inequality which is not satisfied by the -tuple. Let be the relation defined by the resulting formula . Since does not satisfy (P), it follows that for every point in , there is a point in that lies on the open line segment between and . Therefore, . Next, for each , let be the relation defined by . Remove every non-homogeneous inequality from , let be the resulting formula and let be the relation defined by . Clearly, . Let be a point in with and . Since every non-homogeneous inequality in is satisfied by the -tuple, it follows that they are satisfied by every point in a small ball centred at . Let be a point in on the line segment between and and note that every homogeneous inequality in satisfies and therefore also . It follows that is in so and are in , which shows that . Let