Tractable Set Constraints
aa r X i v : . [ c s . A I] J u l Tractable Set Constraints
Manuel Bodirsky ˚ ´Ecole Polytechnique, LIX(UMR 7161 du CNRS),91128 Palaiseau, FranceMartin HilsInstitut de Math´ematiques de Jussieu(UMR 7586 du CNRS),Universit´e Paris Diderot Paris 7, UFR de Math´ematiques,75205 Paris Cedex 13, FranceOctober 25, 2018 Abstract
Many fundamental problems in artificial intelligence, knowledge representation, and ver-ification involve reasoning about sets and relations between sets and can be modeled as setconstraint satisfaction problems (set CSPs) . Such problems are frequently intractable, butthere are several important set CSPs that are known to be polynomial-time tractable. Weintroduce a large class of set CSPs that can be solved in quadratic time. Our class, which wecall EI , contains all previously known tractable set CSPs, but also some new ones that areof crucial importance for example in description logics. The class of EI set constraints hasan elegant universal-algebraic characterization, which we use to show that every set constraintlanguage that properly contains all EI set constraints already has a finite sublanguage with anNP-hard constraint satisfaction problem. An extended abstract of the content of this article appeared in the proceedings of IJCAI’11 [BHK11].
Constraint satisfaction problems are computational problems where, informally, the input consistsof a finite set of variables and a finite set of constraints imposed on those variables; the task isto decide whether there is an assignment of values to the variables such that all the constraintsare simultaneously satisfied.
Set constraint satisfaction problems are special constraint satisfactionproblems where the values are sets, and the constraints might, for instance, force that one set y includes another set x , or that one set x is disjoint to another set y . The constraints might also ˚ Manuel Bodirsky has received funding from the ERC under the European Community’s Seventh FrameworkProgramme (FP7/2007-2013 Grant Agreement no. 257039).
1e ternary, such as the constraint that the intersection of two sets x and y is contained in z , insymbols p x X y q Ď z .To systematically study the computational complexity of constraint satisfaction problems, ithas turned out to be a fruitful approach to consider constraint satisfaction problems CSP p Γ q wherethe set of allowed constraints is formed from a fixed set Γ of relations R Ď D k over a commondomain D . This way of parametrizing the constraint satisfaction problem by a constraint language Γ has led to many strong algorithmic results [BD06, IMM `
10, BK09a, BK07, BK09b], and to manypowerful hardness conditions for large classes of constraint satisfaction problems [Sch78, BKJ05,Bul03, Bul06, BK09b].A set constraint language
Γ is a set of relations R Ď p P p N qq k where the common domain D “ P p N q is the set of all subsets of the natural numbers; moreover, we require that each relation R can be defined by a Boolean combination of equations over the signature [ , \ , c , , and , whichare function symbols for intersection, union, complementation, the empty and full set, respectively.Details of the formal definition and many examples of set constraint languages can be found inSection 3. The choice of N is just for notational convenience; as we will see, we could have selectedany infinite set for our purposes. In the following, a set constraint satisfaction problem (set CSP) is a problem of the form CSP p Γ q for a set constraint language Γ. It has been shown by Marriottand Odersky [MO96] that all set CSPs are contained in NP; they also showed that the largest setconstraint language, which consists of all relations that can be defined as described above, has anNP-hard set CSP.Drakengren and Jonsson [DJ98] initiated the search for set CSPs that can be solved in polynomialtime. They showed that CSP ptĎ , || , ‰uq can be solved in polynomial time, where • x Ď y holds iff x is a subset of or equal to y ; • x || y holds iff x and y are disjoint sets; and • x ‰ y holds iff x and y are distinct sets.They also showed that CSP p Γ q can be solved in polynomial time if all relations in Γ can be definedby formulas of the form x ‰ y _ ¨ ¨ ¨ _ x k ‰ y k _ x Ď y or of the form x ‰ y _ ¨ ¨ ¨ _ x k ‰ y k _ x || y where x , . . . , x k , y , . . . , y k are not necessarily distinct variables. We will call the set of all relationsthat can be defined in this way Drakengren and Jonsson’s set constraint language . It is easy to seethat the algorithm they present runs in time quadratic in the size of the input.On the other hand, Drakengren and Jonsson [DJ98] show that if Γ contains the relations definedby formulas of the form x ‰ y _ ¨ ¨ ¨ _ x k ‰ y k _ u || v _ ¨ ¨ ¨ _ u k || v k the problem CSP p Γ q is NP-hard. Contributions and Outline.
We present a significant extension of Drakengren and Jonsson’sset constraint language (Section 3) whose CSP can still be solved in quadratic time in the inputsize (Section 6); we call this set constraint language EI . Unlike Drakengren and Jonsson’s set2onstraint language, our language also contains the ternary relation defined by p x X y q Ď z , which isa relation that is of particular interest in description logics – we will discuss this below. Moreover,we show that any further extension of EI contains a finite sublanguage with an NP-hard set CSP(Section 7), using concepts from model theory and universal algebra. In this sense, we present a maximal tractable class of set constraint satisfaction problems.Our algorithm is based on the concept of independence in constraint languages which wasdiscovered several times independently in the 90’s [Kou01, JB98, MO96] – see also [BJR02, CJJK00];however, we apply this concept twice in a novel, nested way, which leads to a two level resolutionprocedure that can be implemented to run in quadratic time. The technique we use to prove thecorrectness of the algorithm is also an important contribution of our paper, and we believe that asimilar approach can be applied in many other contexts; our technique is inspired by the alreadymentioned connection to universal algebra. Application Areas and Related Literature
Set Constraints for Programming Languages.
Set constraints find applications in programanalysis; here, a set constraint is of the form X Ď Y , where X and Y are set expressions. Examplesof set expressions are (denoting the empty set), set-valued variables, and union and intersectionof sets, but also expressions of the form f p Z , Z q where f is a function symbol and Z , Z are againset expressions. Unfortunately, the worst-case complexity of most of the reasoning tasks consideredin this setting is very high, often EXPTIME-hard; see [Aik94] for a survey. More recently, ithas been shown that the quantifier-free combination of set constraints (without function symbols)and cardinality constraints (quantifier-free Pressburger arithmetic) has a satisfiability problem inNP [KR07]. This logic (called QFBAPA) is interesting for program verification [KNR06]. Tractable Description Logics.
Description logics are a family of knowledge representationformalisms that can be used to formalize and reason with concept definitions. The computationalcomplexity of most of the computational tasks that have been studied for the various formalismsis usually quite high. However, in the last years a series of description logics (for example EL , EL `` , Horn- F L , and various extensions and fragments [KM02, Baa03, BBL05, KRH06]) hasbeen discovered where crucial tasks such as e.g. entailment, concept satisfiability and knowledgebase satisfiability can be decided in polynomial time.Two of the basic assertions that can be made in EL `` and Horn- F L are C || C ( there is no C that is also C ) and C X C Ď C ( every C that is C is also C ), for concept names C , C , C .These are EI set constraints, and the latter has not been treated in the framework of Drakengrenand Jonsson. None of the description logics with a tractable knowledge base satisfiability problemcontains all EI set constraints. Spatial Reasoning.
Several spatial reasoning formalisms (like RCC-5 and RCC-8) are closelyrelated to set constraint satisfaction problems. These formalisms allow to reason about relationsbetween regions ; in the fundamental formalism RCC-5 (see e.g. [JD97]), one can think of a region asa non-empty set, and possible (binary) relationships are containment, disjointness, equality, overlap,and disjunctive combinations thereof. Thus, the exclusion of the empty set is the most prominentdifference between the set constraint languages studied by Drakengren and Jonsson in [DJ98] (whichare contained in the class of set constraint languages considered here), and RCC-5 and its fragments.3
Constraint Satisfaction Problems
To use existing terminology in logic and model theory, it will be convenient to formalize constraintlanguages as (relational) structures (see e.g. [Hod93]). A structure
Γ is a tuple p D ; f Γ1 , f Γ2 , . . . , R Γ1 , R Γ2 , . . . q where D is a set (the domain of Γ), each f Γ i is a function from D k i Ñ D (where k i is called the arity of f Γ i ), and each R Γ i is a relation over D , i.e., a subset of D l i (where l i is called the arity of R Γ i ). For each function f Γ i we assume that there is a function symbol which we denote by f i , andfor each relation R Γ i we have a relation symbol which we denote by R i . Constant symbols will betreated as 0-ary function symbols. The set τ of all relation and function symbols for some structureΓ is called the signature of Γ, and we also say that Γ is a τ -structure . If the signature of Γ onlycontains relation symbols and no function symbols, we also say that Γ is a relational structure . Inthe context of constraint satisfaction, relational structures Γ are also called constraint languages ,and a constraint language Γ is called a sublanguage (or reduct ) of a constraint language Γ if therelations in Γ are a subset of the relations in Γ (and Γ is called an expansion of Γ ).Let Γ be a relational structure with domain D and a finite signature τ . The constraint sat-isfaction problem for Γ is the following computational problem, also denoted by CSP p Γ q : given afinite set of variables V and a conjunction Φ of atomic formulas of the form R p x , . . . , x k q , where x , . . . , x k P V and R P τ , does there exists an assignment s : V Ñ D such that for every constraint R p x , . . . , x k q in the input we have that p s p x q , . . . , s p x k qq P R Γ ?The mapping s is also called a solution to the instance Φ of CSP p Γ q , and the conjuncts of Φ arecalled constraints . Note that we only introduce constraint satisfaction problems CSP p Γ q for finiteconstraint languages , i.e., relational structures Γ with a finite relational signature. In this section, we give formal definitions of set constraint languages. Let S be the structure withdomain P p N q , the set of all subsets of natural numbers, and with signature t[ , \ , c, , u , where • [ is a binary function symbol that denotes intersection, i.e., [ S “ X ; • \ is a binary function symbol for union, i.e., \ S “ Y ; • c is a unary function symbol for complementation, i.e., c S is the function that maps S Ď N to N z S ; • and are constants (treated as 0-ary function symbols) denoting the empty set H and thefull set N , respectively.Sometimes, we simply write [ for the function [ S and \ for the function \ S , i.e., we do notdistinguish between a function symbol and the respective function. We use the symbols [ , \ andnot the symbols X , Y to prevent confusion with meta-mathematical usages of X and Y in the text.A set constraint language is a relational structure with a set of relations with a quantifier-freefirst-order definition in S . We always allow equality in first-order formulas, and the equality symbol “ is always interpreted to be the true equality relation on the domain of the structure. Example 1.
The ternary relation p x, y, z q P P p N q | x [ y Ď z ( has the quantifier-free first-orderdefinition z [ p x [ y q “ x [ y over S . heorem 2 (Follows from Proposition 5.8 in [MO96]) . Let Γ be a set constraint language with afinite signature. Then CSP p Γ q is in NP. It is well-known that the structure p P p N q ; \ , [ , c, , q is a Boolean algebra, with • playing the role of false, and playing the role of true; • c playing the role of ; • [ and \ playing the role of ^ and _ , respectively.To not confuse logical connectives with the connectives of Boolean algebras, we always use thesymbols [ , \ , and c instead of the usual function symbols ^ , _ , and in Boolean algebras. Tofacilitate the notation, we also write ¯ x instead of c p x q , and x ‰ y instead of p x “ y q .We assume that all terms t over the functional signature t[ , \ , c, , u are written in (inner)conjunctive normal form (CNF) , i.e., as t “ Ű ni “ Ů n i j “ l ij where l ij is either of the form ¯ x or of theform x for a variable x (every term over t[ , \ , c, , u can be re-written into an equivalent term ofthis form, using the usual laws of Boolean algebras [Boo47]). We allow the special case n “ t becomes ), and the special case n i “ Ů n i j “ l ij becomes ). We referto c i : “ t l ij | ď j ď n i u as an (inner) clause of t , and to l ij as an (inner) literal of c i . We saythat a set of inner clauses is satisfiable if there exists an assignment from V Ñ P p N q such that forall inner clauses, the union of the evaluation of all literals equals N (this is the case if and only ifthe formula t “ has a satisfying assignment).We assume that all quantifier-free first-order formulas φ over the signature t[ , \ , c, , u arewritten in (outer) conjunctive normal form (CNF) , i.e., as φ “ Ź mi “ Ž m i j “ L ij where L ij is eitherof the form t “ (a positive (outer) literal ) or of the form t ‰ (a negative (outer) literal ). Again,it is well-known and easy to see that we can for every quantifier-free formula find a formula in thisform which is equivalent to it in every Boolean algebra. We refer to C i : “ t L ij | ď j ď m i u asan (outer) clause of φ , and to L ij as an (outer) literal of C i . Whenever convenient, we identify φ with its set of clauses. E I Set Constraints
To define EI set constraints, we need to introduce a series of important functions defined on theset of subsets of natural numbers. Definition 3.
Let • i : p P p N qq Ñ P p N q be the function that maps p S , S q to the set t x | x P S u Y t x ` | x P S u ; • F be the function that maps S Ď N to the set of finite non-empty subsets of S ; • G : N Ñ F p N q be a bijection between N and the set of finite non-empty subsets of N (sinceboth sets are countable, such a bijection exists); • e : P p N q Ñ P p N q be defined by e p S q “ t G ´ p T q | T P F p S qu ;5 ei be the function defined by ei p x, y q ÞÑ e p i p x, y qq . Definition 4.
Let f : p P p N qq k Ñ P p N q be a function, and R Ď P p N q l be a relation. Thenwe say that f preserves R if the following holds: for all a , . . . , a k P p P p N qq l we have that p f p a , . . . , a k q , . . . , f p a l , . . . , a kl qq P R if a i P R for all i ď k . If f does not preserve R , we alsosay that f violates R . We say that f strongly preserves R if for all a , . . . , a k P p P p N qq l we havethat p f p a , . . . , a k q , . . . , f p a l , . . . , a kl qq P R if and only if a i P R for all i ď k . If φ is a first-orderformula that defines a relation R over S , and f preserves (strongly preserves) R , then we also saythat f preserves (strongly preserves) φ . Finally, if g : p P p N qq l Ñ P p N q is a function, we say that f preserves (strongly preserves) g if it preserves (strongly preserves) the graph of g , i.e., the relation p x , . . . , x l , g p x , . . . , x l qq | x , . . . , x l Ď N ( .Note that if an injective function f preserves a function g , then it must also strongly preserve g . Definition 5.
The set of all relations with a quantifier-free first-order definition over S that arepreserved by the operation ei is denoted by EI . Remark.
We will see later (Proposition 35 and Proposition 36) that the class EI is independentfrom the precise choice of the operations e and i .Proposition 12 shows that EI has a large subclass, called Horn-Horn, which has an intuitivesyntactic description. In Section 5 we also present many examples of relations that are from EI and of relations that are not from EI . Before, we will establish some properties of the functions i and e . Fact 6.
The mapping i is an isomorphism between S and S .Proof. The mapping i can be inverted by the mapping that sends S Ď N to ` t x | x P S u , t x | x ` P S u ˘ . It is straightforward to verify that i strongly preserves , , c , \ , [ .We write x Ď y as an abbreviation for x [ y “ x . Proposition 7.
The function e has the following properties. • e is injective, • e strongly preserves , , and [ , and • for x, y, z P P p N q such that x \ y “ z , not x Ď y , and not y Ď x , we have that e p x q\ e p y q Ř e p z q .Proof. We verify the properties one by one. Since G is bijective, e p x q “ e p y q if and only if x and y have the same finite subsets. This is the case if and only if x “ y , and hence e is injective. Thus,to prove that e strongly preserves , , and [ , it suffices to check that e preserves , , and [ .Since G is bijective, we have that G p N q equals the set of all finite subsets of N , and hence e p N q “ N , which shows that e preserves . We also compute e pHq “ G ´ p F pHqq “ G ´ pHq “ H .Next, we verify that for all x, y P P p N q we have e p x q [ e p y q “ e p x [ y q . Let a P N be arbitrary.We have a P e p x q [ e p y q if and only if G p a q P F p x q X F p y q . By definition of F and since G p a q isa finite subset of N , this is the case if and only if G p a q P F p x [ y q . This is the case if and only if a P e p x [ y q , which concludes the proof that e preserves [ .6e verify that if x \ y “ z , not x Ď y , and not y Ď x , then e p x q \ e p y q Ř e p z q . Firstobserve that for all u, v Ď N with u Ď v we have e p u q Ď e p v q since e preserves [ . This impliesthat e p x q \ e p y q Ď e p z q . Since x Ę y and y Ę x , there are a, b such that a P x , a R y , b P y , b R x . Then we have that t a, b u P F p z q , but t a, b u R F p x q Y F p y q . Hence, G ´ pt a, b uq P e p z q , but G ´ pt a, b uq R e p x q \ e p y q . This shows that e p z q ‰ e p x q \ e p y q .Note that in particular e preserves Ă , Ď , and || . Moreover, e p c p x qq Ď c p e p x qq : this follows frompreservation of || , since x || c p x q , and therefore e p x q|| e p c p x qq , which is equivalent to the inclusionabove. Both e and i strongly preserve [ , , and , and therefore also ei strongly preserves [ , ,and . A large and important subclass of E I set constraints is the class of Horn-Horn set constraints. Definition 8.
A quantifier-free first-order formula is called
Horn-Horn if1. every outer clause is outer Horn , i.e., contains at most one positive outer literal, and2. every inner clause of positive outer literals is inner Horn , i.e., contains at most one positiveinner literal.A relation R Ď P p N q k is called • outer Horn if it can be defined over S by a conjunction of outer Horn clauses; • inner Horn if it can be defined over S by a formula of the form p c [ ¨ ¨ ¨ [ c k q “ whereeach c i is inner Horn; • Horn-Horn if it can be defined by a Horn-Horn formula over S .The following is a direct consequence of the fact that isomorphisms between Γ k and Γ preserveHorn formulas over Γ; since the simple proof is instructive for what follows, we give it here for thespecial case that is relevant here. Fact 9.
Outer Horn relations are preserved by i .Proof. Let φ be a conjunction of outer Horn clauses with variables V . Let t t “ , t ‰ , . . . , t k ‰ u be an outer clause of φ . Let u, v : V Ñ P p N q be two assignments that satisfy this clause. Let w : V Ñ P p N q be given by x ÞÑ i p u p x q , v p x qq . Suppose that w satisfies t j “ for all 1 ď j ď k .Since i is injective we must have that t j “ for both u and v for 1 ď j ď k , and thereforeneither assignment satisfies the negative literals. Hence, u and v must satisfy t “ . Since i isan isomorphism between S and S , it preserves in particular t “ , and hence w also satisfies t “ . Proposition 10.
Inner Horn relations are strongly preserved by e .Proof. Observe that x \p Ů j y j q “ is equivalent to x [p Ű j y j q “ Ű j y j , which is strongly preservedby e since e strongly preserves [ . This clearly implies the statement.7ote that Fact 9 and Proposition 10 imply that ei strongly preserves inner Horn relations. Welater also need the following. Lemma 11.
Let x , . . . , x k , y , . . . , y l Ď N , where k ě . Then the following are equivalent.1. e p x q \ ¨ ¨ ¨ \ e p x k q \ e p y q \ ¨ ¨ ¨ \ e p y l q “ .2. there exists an i ď k such that x i \ p Ů j y j q “ .3. there exists an i ď k such that e p x i q \ p Ů j e p y j qq “ .For k “ , we have that Ů j y j ď l “ if and only if Ů j ď l e p y j q “ .Proof. For the implication from p q to p q , suppose that there is for every i ď k an a i P N suchthat a i R X i : “ x i \ p Ů j y j q . Let c be G ´ ` t a , a , . . . , a k u ˘ . Then for each i ď k , we have that c R e p x i q \ Ů j ď l e p y j q . To see this, first observe that a i P Ű j ď l y j [ x i . Therefore, t a , . . . , a k u P Ű j ď l F p y j q [ F p x i q for all i ď k . We conclude that c R e p x q \ ¨ ¨ ¨ \ e p x k q \ e p y q \ ¨ ¨ ¨ \ e p y l q .The implication p q ñ p q follows directly from Proposition 10. The implication p q ñ p q istrivial. The second statement is a direct consequence of Proposition 10. Proposition 12.
Every Horn-Horn relation is preserved by e and i ; in particular, it is from E I .Proof. Suppose that R has a Horn-Horn definition φ over S with variables V . Since R is inparticular outer Horn, it is preserved by i by Fact 9.Now we verify that R is preserved by e . Let u : V Ñ P p N q be an assignment that satisfies φ . That is, u satisfies at least one literal in each outer clause of φ . It suffices to show that theassignment v : V Ñ P p N q defined by x ÞÑ e p u p x qq satisfies the same outer literal. Suppose first thatthe outer literal is positive; because φ is Horn-Horn, it is of the form x \ y \ ¨ ¨ ¨ \ y l “ or of theform y \ ¨ ¨ ¨ \ y l “ , which is preserved by e by Lemma 11.Now, suppose that the outer literal is negative, that is, of the form x \¨ ¨ ¨\ x k \ y \¨ ¨ ¨\ y l ‰ for some k ě
0. We will treat the case k ě
1, the other case being similar. Suppose for contradictionthat v p x q \ ¨ ¨ ¨ \ v p x k q \ v p y q \ ¨ ¨ ¨ \ v p y l q “ . By Lemma 11, there exists an i ď k such that u p x i q\p Ů j u p y j qq “ . But then we have in particular that u p x q\¨ ¨ ¨\ u p x k q\ u p y q\¨ ¨ ¨\ u p y l q “ , in contradiction to the assumption that u satisfies φ . Examples.
1. The disjointness relation || is Horn-Horn: it has the definition ¯ x \ ¯ y “ .2. The inequality relation ‰ is inner Horn: it has the definition p y \ ¯ x q [ p x \ ¯ y q ‰ .3. Using the previous example, the relation tp x, y, u, v q | x ‰ y _ u “ v u can easily be seen to beHorn-Horn.4. The ternary relation tp x, y, z q | x X y Ď z u , which we have encountered above, has the Horn-Horn definition ¯ x \ ¯ y \ z “ .5. Examples of relations that are clearly not Horn-Horn: tp x, y q | x \ y “ u is violated by e ,and tp x, y, z q | p x “ y q _ p y “ z qu is violated by i .8. The formula p x [ y ‰ x q^ p x [ y ‰ y q^ p v “ _ u “ _ x \ y ‰ q is clearly not Horn-Horn. However, the relation defined by the formula is from EI : if p x , y , u , u q und p x , y , u , v q are from that relation, then neither i p x , x q Ď i p y , y q nor i p y , y q Ď i p x , x q . By Proposition 7, p ei p x , x q , ei p y , y q , ei p u , u q , ei p v , v qq satisfiesthe formula.There is no equivalent Horn-Horn formula, since the formula is not preserved by i .7. The formula pp x \ y ‰ q _ p u \ v “ qq ^ p ¯ x \ y ‰ q ^ p x \ ¯ y ‰ q is not Horn-Horn.However, it is preserved by e and by i : the reason is that one of its clauses has the negativeliteral x \ y ‰ , and the conjuncts t ¯ x \ y ‰ u and t x \ ¯ y ‰ u . Therefore, for every tuple t P R the tuple e p t q satisfies x \ y ‰ and is in R as well. By Fact 9, R is preserved by i .In this case, the authors suspect that there is no equivalent Horn-Horn formula. More gen-erally, it is an open problem whether there exist formulas that are preserved by e and i , butthat are not equivalent to a Horn-Horn formula. Proposition 13.
Drakengren and Jonsson’s set constraint language only contains Horn-Horn re-lations.Proof.
For inclusion x Ď y , disjointness || , and inequality ‰ this has been discussed in the examples.Horn-Horn is preserved under adding additional outer disequality literals to the outer clauses, soall relations considered in Drakengren and Jonsson’s language are Horn-Horn.We prepare now some results that can be viewed as a partial converse of Proposition 12. Definition 14.
A quantifier-free first-order formula φ (in the syntactic form described at the endof Section 3) is called reduced if if every formula obtained from φ by removing an outer literal isnot equivalent to φ over S . Lemma 15.
Every quantifier-free formula is over S equivalent to a reduced formula.Proof. It is clear that every quantifier-free formula can be written as a formula φ in CNF and inthe form as we have discussed it after Theorem 2. We now remove successively outer literals aslong as this results in an equivalent formula.We first prove the converse of Fact 9. Proposition 16.
Let φ be a reduced formula that is preserved by i . Then each outer clause of φ isHorn.Proof. Let V be the set of variables of φ . Assume for contradiction that φ contains an outer clausewith two positive literals, t “ and t “ . If we remove the literal t “ from its clause C , theresulting formula is inequivalent to φ , and hence there is an assignment s : V Ñ P p N q that satisfiesnone of the literals of C except for t “ . Similarly, there is an assignment s : V Ñ P p N q thatsatisfies none of the literals of C except for t “ . By injectivity of i , and since i strongly preserves9 , [ , \ , and , the assignment s : V Ñ P p N q defined by x ÞÑ i p s p x q , s p x qq does not satisfy thetwo literals t “ and t “ . Since i strongly preserves c , \ , [ , none of the other literals in C issatisfied by those mappings as well, in contradiction to the assumption that φ is preserved by i . Definition 17.
Let V be a set of variables, and s : V Ñ P p N q be a mapping. Then a function from V Ñ P p N q of the form x ÞÑ e p s p x qq is called a core assignment . Lemma 18.
For every quantifier-free formula φ there exists a formula ψ such that all inner clausesare inner Horn, and such that φ and ψ have the same satisfying core assignments. If φ is preservedby ei , then the set of all satisfying core assignments of ψ is closed under ei .Proof. Suppose that φ has an outer clause C with a positive outer literal t “ such that t containsan inner clause c : “ x \ ¨ ¨ ¨ \ x k \ y \ ¨ ¨ ¨ \ y l that is not Horn, i.e., k ě
2. Then we replace theouter literal t “ in φ by k literals t “ , . . . , t k “ where t i is obtained from t by replacing c by x i \ y \ ¨ ¨ ¨ \ y l .We claim that the resulting formula φ has the same set of satisfying core assignments. Observethat x i \ y \ ¨ ¨ ¨ \ y l Ď c , and hence t i “ implies t “ . An arbitrary satisfying assignment of φ satisfies either one of the positive outer literals t i “ , in which case that observation shows that italso satisfies φ , or it satisfies one of the other outer literals of C , in which case it also satisfies thisliteral in φ . Hence, φ implies φ . Conversely, let s be a satisfying core assignment of φ . If s satisfiesa literal from C other than t “ , then it also satisfies this literal in φ , and s satisfies φ . Otherwise, s must satisfy t “ , and hence s p x q \ ¨ ¨ ¨ \ s p x k q \ s p y q \ ¨ ¨ ¨ \ s p y l q “ . Since s is a coreassignment, Lemma 11 implies that there exists an i ď k such that s p x i q \ s p y q \ ¨ ¨ ¨ \ s p y l q “ .So s satisfies φ .Suppose that φ has an outer clause C with a negative outer literal t ‰ such that t contains aninner clause c : “ x \ ¨ ¨ ¨\ x k \ y \ ¨ ¨ ¨ \ y l that is not Horn, i.e., k ě
2. Then we replace the clause C in φ by k clauses C , . . . , C k where C k is obtained from C by replacing c with x i \ y \ ¨ ¨ ¨ \ y l .We claim that the resulting formula φ has the same set of satisfying core assignments. Observethat x \ ¨ ¨ ¨ \ x k \ y \ ¨ ¨ ¨ \ y l ‰ implies that x i \ y \ ¨ ¨ ¨ \ y l ‰ , for every i ď k . Theobservation shows that an arbitrary assignment of φ is also an assignment of φ . Conversely, let s be a satisfying core assignment of φ . If s satisfies one of the other literals of C other than t ‰ ,then s satisfies φ . Otherwise, s must satisfy x i \ y \ ¨ ¨ ¨ \ y l ‰ for all i ď k , and by Lemma 11we have that s also satisfies x \ ¨ ¨ ¨ \ x k \ y \ ¨ ¨ ¨ \ y l ‰ .We perform these replacements until we obtain a formula φ where all inner clauses are Horn;this formula satisfies the requirements of the first statement of the lemma.To prove the second statement, let u, v : V Ñ P p N q be two satisfying core assignments of φ .Since φ and φ have the same satisfying core assignments, u and v also satisfy φ . Then the mapping w : V Ñ P p N q given by x ÞÑ ei p u p x q , v p x qq is a core assignment, and because ei preserves φ , themapping w satisfies φ . Since φ and φ have the same core assignments, w is also a satisfyingassignment of φ , which proves the statement. Definition 19.
A quantifier-free first-order formula φ (in the syntactic form described at the endof Section 3) is called strongly reduced if every formula obtained from φ by removing an outer literaldoes not have the same set of satisfying core assignments over S . Proposition 20.
Let φ be a strongly reduced formula all of whose inner clauses are Horn. If theset of satisfying core assignments of φ is closed under ei , then φ is Horn-Horn. roof. Let V be the set of variables of φ . It suffices to show that all clauses of φ are outer Horn.Assume for contradiction that φ contains an outer clause with two positive literals, t “ and t “ . If we remove the literal t “ from its clause C , the resulting formula has strictly lesssatisfying core assignments; this shows the existence of a core assignment s : V Ñ P p N q thatsatisfies none of the literals of C except for t “ . Similarly, there exists a core assignment s : V Ñ P p N q that satisfies none of the literals of C except for t “ . By assumption, theinner clauses of t and t are Horn. We claim that the assignment s : V Ñ P p N q defined by x ÞÑ ei p s p x q , s p x qq does not satisfy the clause C . Since ei strongly preserves inner Horn clauses,we have that s does not satisfy t “ _ t “ . For the same reasons s does not satisfy anyother literals in C ; this contradicts the assumption that the satisfying core assignments for φ arepreserved by ei . Proposition 21.
Let Γ be a finite set constraint language from E I . Then CSP p Γ q can be reducedin linear time to the problem to find a satisfying assignment for a given set of Horn-Horn clauses.Proof. Let Φ be an instance of CSP p Γ q , and let V be the set of variables that appear in Φ. For eachconstraint R p x , . . . , x k q from Φ, let φ R be the definition of R over S . By Lemma 18, there existsa formula ψ R that has the same satisfying core assignments as φ R and where all inner clauses areHorn; moreover, since φ R is preserved by ei , the lemma asserts that the set of all satisfying coreassignments of ψ R is preserved by ei . We can assume without loss of generality that ψ R is stronglyreduced; this can be seen similarly to Lemma 15. By Proposition 20, the formula ψ R is Horn-Horn.Let Ψ be the set of all Horn-Horn clauses of formulas ψ R p x , . . . , x k q obtained from constraints R p x , . . . , x k q in Φ in the described manner. We claim that Φ is a satisfiable instance of CSP p Γ q if and only if Ψ is satisfiable. This follows from the fact that for each constraint R p x , . . . , x k q in Φ, the formulas φ R and ψ R have the same satisfying core assignments, and that both φ R and ψ R are preserved by ei (for ψ R this follows from Proposition 12), so in particular by the function x ÞÑ ei p x, x q .Note that in Proposition 21 we reduce satisfiability for E I to satisfiability for a proper subclass ofHorn-Horn set constraints: while for general Horn-Horn set constraints we allow that inner clausesof negative outer literals are not Horn, the reduction only produces Horn-Horn clauses where all inner clauses are Horn. We present an algorithm that takes as input a set Φ of Horn-Horn clauses and decides satisfiabilityof Φ over S “ p P p N q ; \ , [ , c, , q in time quadratic to the length of the input. By Proposition 21,this section will therefore conclude the proof that CSP p Γ q is tractable when all relations in Γ arefrom E I .We first discuss an important sub-routine of our algorithm, which we call the inner resolu-tion algorithm . As in the case of Boolean positive unit resolution [DG84] one can implement theprocedure Inner-Res such that it runs in linear time in the input size. Lemma 22.
Let Φ be a finite set of inner Horn clauses. Then the following are equivalent.1. Ű Φ “ is satisfiable over S .2. Inner-Res p Φ q from Figure 1 accepts. nner-Res(Φ)// Input: A finite set Φ of inner Horn clauses// Accepts iff Ű Φ “ is satisfiableDuring the entire algorithm:if Φ contains an empty clause, then reject.Repeat := trueWhile Repeat = true doRepeat := falseIf Φ contains a positive unit clause t x u thenRepeat := trueRemove all clauses where the literal x occurs.Remove the literal x from all clauses.End ifLoopAccept Figure 1: Inner Resolution Algorithm. Ű Φ “ has a solution whose image is contained in tH , N u .Proof. It is obvious that Ű Φ “ is unsatisfiable when Inner-Res p Φ q rejects; in fact, for all innerclauses c derived by Inner-Res from Φ, the formula c “ is logically implied by Ű Φ “ . Conversely,if the algorithm accepts then we can set all eliminated variables to N and all remaining variablesto H , which satisfies all clauses: in the removed clauses the positive literal is satisfied, and in theremaining clauses we have at least one negative literal at the final stage of the algorithm, and allclauses with negative literals at the final stage of the algorithm are satisfied.The proof of the previous lemma shows that Ű Φ “ is satisfiable over S if and only if Ű Φ “ is satisfiable over the two-element Boolean algebra. As we will see in the following, this holds moregenerally (and not only for inner Horn clauses). The following should be well-known, and can beshown with the same proof as given in [Kop89] for the weaker Proposition 2.19 there. We repeatthe proof here for the convenience of the reader (for definitions of the notions appearing in theproof, however, we refer to [Kop89]). Fact 23.
Let t , t be terms over t[ , \ , c, , u . Then the following are equivalent:1. t “ ^ t ‰ is satisfiable over the two-element Boolean algebra;2. t “ ^ t ‰ is satisfiable over all Boolean algebras;3. t “ ^ t ‰ is satisfiable in a Boolean algebra.Proof. Obviously, 1 implies 2, and 2 implies 3. For 3 implies 1, assume that t “ ^ t ‰ has asatisfying assignment in some Boolean algebra C . Let c be the element denoted by t in C underthis assignment. It is well-known that every element a ‰ of a Boolean algebra is contained in anultrafilter (see e.g. Corollary 2.17 in [Kop89]). So let U be an ultrafilter of C that contains c , andlet f : C Ñ t , u be the characteristic function of U . Then f is a homomorphism from C to thetwo-element Boolean algebra that maps c to ; thus t “ ^ t ‰ is satisfiable over t , u .12he same statement for t “ instead of t “ ^ t ‰ is Proposition 2.19. in [Kop89].Fact 23 has the following consequence that is crucial for the way how we use the inner resolutionprocedure in our algorithm. Lemma 24.
Let Ψ be a finite set of inner Horn clauses. Then Inner-Res p Ψ Yt x , . . . , x k , y , . . . , y l uq rejects if and only if Ű Ψ “ implies that x \ ¨ ¨ ¨ \ x k \ y \ ¨ ¨ ¨ \ y l “ over S .Proof. Ű Ψ “ implies that x \ ¨ ¨ ¨ \ x k \ y \ ¨ ¨ ¨ \ y l “ if and only if Ű Ψ “ ^ x \¨ ¨ ¨ \ x k \ y \ ¨ ¨ ¨ \ y l ‰ is unsatisfiable over S . By Fact 23, this is the case if and only if Ű Ψ “ ^ x \ ¨ ¨ ¨ \ x k \ y \ ¨ ¨ ¨ \ y l ‰ is unsatisfiable over the 2-element Boolean algebra,which is the case if and only if Ű Ψ “ ^ x \ ¨ ¨ ¨ \ x k \ y \ ¨ ¨ ¨ \ y l “ is unsatisfiable overthe two-element Boolean algebra. As we have seen in Lemma 22, this is turn holds if and only ifInner-Res p Ψ Yt x , . . . , x k , y , . . . , y l uq rejects. Outer-Res(Φ)// Input: A finite set Φ of Horn-Horn clauses// Accepts iff Φ is satisfiable over p P p N q ; [ , \ , c, , q During the entire algorithm:if Φ contains an empty clause, then reject.Repeat := trueWhile Repeat = true doRepeat := falseLet Ψ be the set of all inner Horn clauses of terms t from positive unit clauses t t “ u in Φ.If Inner-Res rejects Ψ, then reject.For each negative literal t ‰ in clauses from ΦFor each inner clause D “ t x , . . . , x k , y , . . . , y l u of t Call Inner-Res onΨ
Y t x “ , . . . , x k “ , y “ , . . . , y l “ u If Inner-Res rejects then remove clause D from t End forIf all clauses in t have been removed, thenRemove outer literal t ‰ from its clauseRepeat := trueEnd forLoopAccept Figure 2: Outer Resolution Algorithm.
Theorem 25.
The algorithm ‘Outer-Res’ in Figure 2 decides satisfiability for sets of Horn-Hornclauses in quadratic time.Proof.
We first argue that if the algorithm rejects Φ, then Φ has indeed no solution. First note thatduring the whole argument, the set of clauses Φ has the same satisfying tuples (i.e. the correspondingformulas are equivalent): Observe that only negative literals get removed from clauses, and that anegative literal t ‰ only gets removed from a clause when Inner-Res rejects Ψ Y t x “ , . . . , x k “ , y “ , . . . , y l “ u for each inner clause t x , . . . , x k , y , . . . , y l u of t . By Lemma 24, if Inner-Resrejects Ψ Yt x “ , . . . , x k “ , y “ , . . . , y l “ u then Ψ implies that x \¨ ¨ ¨\ x k \ y \¨ ¨ ¨\ y l “ .Hence, the positive unit clauses imply that t “ and therefore the literal t ‰ can be removedfrom the clause without changing the set of satisfying tuples. Now the algorithm rejects if eitherInner-Res rejects Ψ or if it derives the empty clause. In both cases it is clear that Φ is not satisfiable.Thus, it suffices to construct a solution when the algorithm accepts. Let Ψ be the set of all innerclauses of terms from positive unit clauses at the final stage, when the algorithm accepts. For eachremaining negative outer literal t t ‰ u and each remaining inner clause D “ t x , . . . , x k , y , . . . , y l u of t there exists an assignment α D from V Ñ P p N q that satisfies Ψ Yt x \¨ ¨ ¨\ x k \ y \¨ ¨ ¨\ y l ‰ u :otherwise, by Lemma 24, the inner resolution algorithm would have rejected Ψ Y t x “ , . . . , x k “ , y “ , . . . , y l “ u , and would have removed the inner clause D from t . Let D , . . . , D s be anenumeration of all remaining inner clauses D that appear in all remaining negative outer literals.Write i s for the s -ary operation defined by p x , . . . , x s q ÞÑ i p x , i p x , . . . , i p x s ´ , x s q ¨ ¨ ¨ qq (where i is as in Fact 6). We claim that s : V Ñ P p N q given by x ÞÑ i s p α D p x q , . . . , α D s p x qq satisfies all clauses in Φ. Let C be a clause from Φ. By assumption, at the final stage of thealgorithm, the clause C is still non-empty. Also note that since all formulas in the input were Horn-Horn, they contain at most one positive literal. This holds in particular for C , and we thereforeonly have to distinguish the following cases: • At the final state of the algorithm, C still contains a negative literal t ‰ . Since t ‰ has not been removed, there must be a remaining inner clause D “ t x , . . . , x k , y , . . . , y l u of t . Observe that s p x q \ ¨ ¨ ¨ \ s p x k q \ s p y q \ ¨ ¨ ¨ \ s p y l q “ if and only if α D j p x q \ ¨ ¨ ¨ \ α D j p x k q \ α D j p y q \ ¨ ¨ ¨ \ α D j p y l q “ for all 1 ď j ď s . Hence, and since α D p x q \ ¨ ¨ ¨ \ α D p x k q \ α D p y q \ ¨ ¨ ¨ \ α D p y l q ‰ , s satisfies t ‰ . This shows that s satisfies C . • All negative literals have been removed from C during the algorithm. The positive literal t “ of C is such that the inner clauses of t are Horn. They will be part of Ψ, andtherefore t “ is satisfied by s . Indeed, by assumption the assignments α D j satisfy Ψ, andΨ is preserved by i .We conclude that s is a solution to Φ. The inner resolution algorithm has a linear time complexity;the outer resolution algorithm performs at most a linear number of calls to the inner resolutionalgorithm, and it is straightforward to implement all necessary data structures for outer resolutionto obtain a running time that is quadratic in the input size.Combining Proposition 21 with Theorem 25, we obtain the following. Theorem 26.
Let Γ be a finite set constraint language from E I . Then CSP p Γ q can be solved inquadratic time. In this section we show that the class E I is a maximal tractable set constraint language. Morespecifically, let Γ be a set constraint language that strictly contains all E I relations. We then14how that Γ contains a finite set of relations Γ such that already the problem CSP p Γ q is NP-hard(Theorem 40).In our proof we use the so-called universal-algebraic approach to the complexity of constraint sat-isfaction problems, which requires that we re-formulate set CSPs as constraint satisfaction problemsfor ω -categorical structures. For a more detailed introduction to the universal-algebraic approach for ω -categorical structures, see [Bod12]. A structure Γ with a countable domain is called ω -categorical if all countable structures that satisfy the same first-order sentences as Γ are isomorphic to Γ (seee.g. [Hod93]). By the theorem of Ryll-Nardzewski, and for countable signatures, this is equivalentto requiring that every relation that is preserved by the automorphisms of Γ is first-order definablein Γ (see e.g. [Hod93]). The set of all automorphisms of Γ is denoted by Aut p Γ q .It is well-known that all countable atomless Boolean algebras are isomorphic (Corollary 5.16in [Kop89]; also see Example 4 on page 100 in [Hod93]); let A denote such a countable atomlessBoolean algebra. Let A denote the domain of A . Again, we use [ and \ to denote join and meetin A , respectively. Since the axioms of Boolean algebras and the property of not having atomscan all be written as first-order sentences, it follows that A is ω -categorical. A structure B has quantifier elimination if every first-order formula is over B equivalent to a quantifier-free formula.It is well-known that A has quantifier elimination (see Exercise 17 on Page 391 in [Hod93]). Wewill also make use of the following. Theorem 27 (Corollary 5.7 in [MO96]) . A quantifier-free formula is satisfiable in some infiniteBoolean algebra if and only if it is satisfiable in all infinite Boolean algebras.
A fundamental concept in the complexity theory of constraint satisfaction problems is the notionof primitive positive definitions . A first-order formula is called primitive positive (pp) if it is of theform D x , . . . , x n p ψ ^ ¨ ¨ ¨ ^ ψ m q where for each i ď m the formula ψ i is of the form R p y , . . . , y l q or of the form y “ y , andwhere R is a relation symbol and y , y , . . . , y l are either free variables or from t x , . . . , x n u . Wesay that a k -ary relation R Ď D k is primitive positive definable (pp definable) over a τ -structure Γwith domain D iff there exists a primitive positive formula φ p x , . . . , x k q with the k free variables x , . . . , x k such that a tuple p b , . . . , b k q is in R if and only if φ p b , . . . , b k q is true in Γ. Example.
The relation tp x, y q P P p N q | x Ă y u is pp definable in p P p N q ; S, ‰q where S “tp x, y, z q | x [ y Ď z u . The pp definition is S p x, x, y q ^ x ‰ y (the definition is even quantifier-free). Example.
The relation tp x , x , x , y q P P p N q | x [ x [ x Ď y u is pp definable in p P p N q ; S q where S “ tp x, y, z q | x [ y Ď z u . The pp definition is D u p S p x , x , u q ^ S p u, x , y qq .When every relation of a structure Γ is preserved by an operation f , then f is called a polymor-phism of Γ. Note that polymorphisms of Γ also preserve all relations that have a pp definition in Γ.The following has been shown for finite domain constraint satisfaction in [BKJ05]; the easy proofalso works for infinite domain constraint satisfaction. Lemma 28.
Let R be a relation with a primitive positive definition in a structure Γ . Then CSP p Γ q and the CSP for the expansion of Γ by the relation R are polynomial-time equivalent. An isomorphism of a structure Γ with itself is called an automorphism of Γ. An atom in a Boolean algebra is an element x ‰ such that for all y with x X y “ y and x ‰ y we have y “ .If a Boolean algebra does not contains atoms, it is called atomless . ω -categorical templates(when this is possible). Theorem 29 (from [BN06]) . Let Γ be an ω -categorical structure. Then R is primitive positivedefinable in Γ if and only if R is preserved by all polymorphisms of Γ . The previous and the next result together can be used to translate questions about primitivepositive definability into purely operational questions. Let D be a set, let O p n q be D n Ñ D , andlet O be Ť n “ O p n q the set of operations on D of finite arity. An operation π P O p n q is called a projection if for some fixed i P t , . . . , n u and for all n -tuples p x , . . . , x n q P D n we have the identity π p x , . . . , x n q “ x i . The composition of a k -ary operation f and k operations g , . . . , g k of arity n is the n -ary operation defined by p f p g , . . . , g k qqp x , . . . , x n q“ f ` g p x , . . . , x n q , . . . , g k p x , . . . , x n q ˘ . Definition 30.
We say that F Ď O locally generates f : D n Ñ D if for every finite subset A of D n there is an operation g : D n Ñ D that can be obtained from the operations in F and projectionmaps by composition such that f p a q “ g p a q for all a P A . Theorem 31 (see [Sze86]) . Let F Ď O be a set of operations with domain D . Then an operation f : D k Ñ D preserves all finitary relations that are preserved by all operations in F if and only if F locally generates f . In the following, we always consider sets of operations F that contain Aut p A q , and thereforemake the following convention. For F Ď O , we say that F generates f P O if F Y Aut p A q locallygenerates f . We now define analogs of the operations e and i , defined on A instead of P p N q . Proposition 32.
There is an isomorphism ˜ i between A and A .Proof. It is straightforward to verify that A is again a countable atomless Boolean algebra.Motivated by the properties of e described in Lemma 11, we make the following definition. Definition 33.
Let B and B be two arbitrary Boolean algebras with domains B and B , respec-tively, and let g : B Ñ B be a function that strongly preserves [ , , and . We say that g forgetsunions if for all k ě l ě
0, and x , . . . , x k , y , . . . , y l P B we have e p x q \ ¨ ¨ ¨ \ e p x k q \ e p y q \ ¨ ¨ ¨ \ e p y l q “ if and only if there exists an i ď k such that x i \ y \ ¨ ¨ ¨ \ y l “ . Proposition 34.
There exists an injection ˜ e : A Ñ A that strongly preserves [ , , and in A ,and that forgets unions.Proof. The construction of ˜ e is by a standard application of K¨onig’s tree lemma for ω -categoricalstructures (see e.g. [Bod12]); it suffices to show that there is an injection f from every finite inducedsubstructure B of A to A such that f strongly preserves [ , , and , and forgets unions.So let B be such a finite substructure of A , and let B be the domain of B . Let C “p P p B q ; [ , \ , c, , q be the Boolean algebra of the subsets of B . We claim that g : B Ñ P p B q given by g p q “ and g p x q “ t z | z ‰ ^ z Ď B x u for x ‰ preserves and : this is by definition; • preserves [ : for x, y P B (including the case that x “ or y “ ) we have g p x q [ C g p y q “ t z | z ‰ ^ z Ď B x ^ z Ď B y u“ z | z ‰ ^ z Ď B p x [ B y q ( “ g p x [ B y q ; • is injective: if x, y P B such that g p x q “ g p y q , then x Ď B y and y Ď B x , and hence x “ y ; • strongly preserves [ : this follows from the previous two items; • forgets unions: This can be shown analogously to the proof of Lemma 11.Clearly, there is an embedding h from C into A . Then f : “ h p g q is a homomorphism from B to A that forgets unions. Proposition 35.
Let φ be a quantifier-free first-order formula over the signature t[ , \ , c, , u .Then e preserves φ over S if and only if ˜ e preserves φ over A . Moreover, every operation from A Ñ A that strongly preserves [ , , and and forgets unions generates ˜ e , and is generated by ˜ e .Proof. Let ¯ a be a tuple of elements from A . Clearly, there exists a tuple ¯ b of elements from P p N q such that ¯ a and ¯ b satisfy the same set ψ of quantifier-free first-order formulas; this follows from thefact that every finite Boolean algebra is the Boolean algebra of subsets of a finite set. Now observethat whether or not the tuple e p ¯ b q satisfies a quantifier-free first-order formula φ only depends on ψ , by Lemma 11. Since ˜ e strongly preserves [ , , and , and forgets unions, the same is true forthe quantifier-free first-order formulas that hold on ˜ e p ¯ a q . Hence, ˜ e preserves φ over A if and only if e preserves φ over S .To prove the second part of the statement, we use Theorem 31. Suppose that ¯ c and ¯ d are tuplesof elements from A that satisfy the same quantifier-free first-order formulas. By the equivalentcharacterization of ω -categoricity mentioned above, and the fact that A has quantifier-elimination,there exists an automorphism α of A that maps ¯ c to ¯ d . By the above observations and Theorem 31,this implies that all operations that strongly preserve [ , , and , and forget unions generate eachother.Let r ei be the operation p x, y q ÞÑ ˜ e p ˜ i p x, y qq . The following can be shown similarly to Proposi-tion 35. Proposition 36.
Let φ be a quantifier-free first-order formula over the signature t[ , \ , c, , u .Then ei preserves φ over S if and only if r ei preserves φ over A . Moreover, every binary operation g that strongly preserves [ , , and , and forgets unions generates r ei , and is generated by r ei . We now give the central argument for the maximal tractability of E I , stated in universal-algebraic language. We say that an operation from A k Ñ A depends on the argument i P t , . . . , k u if there is no p k ´ q -ary operation f such that for all x , . . . , x k P A f p x , . . . , x k q “ f p x , . . . , x i ´ , x i ´ , x i ` , . . . , x k q . We can equivalently characterize k -ary operations that depend on the i -th argument by requiringthat there are x , . . . , x k P A and x i P A such that f p x , . . . , x k q ‰ f p x , . . . , x i ´ , x i , x i ` , . . . , x k q . heorem 37. Let f be an operation generated by t r ei u . Then either t f u generates r ei , or f isgenerated by t ˜ e u .Proof. To show the statement of the theorem, let f be a k -ary operation generated by t r ei u . For thesake of notation, let x , . . . , x l be the arguments on which f depends, for l ď k . Let f : A l Ñ A bethe operation given by f p x , . . . , x l q “ f p x , . . . , x l , . . . , x l q . Clearly, f must be injective (since itis generated from an injective operation and depends on all arguments). Since f is generated by r ei it preserves [ , , , and since f is injective, it also strongly preserves those functions.Consider first the case that l “
1, i.e., f is unary. If for all finite subsets of A , the operation f equals an automorphism of A , then f is generated by Aut p A q and there is nothing to show. So as-sume otherwise; that is, assume that there is a finite set S Ď A such that there is no a P Aut p A q with f p x q “ a p x q for all x P S . We claim that f forgets unions. To see this, let u , . . . , u m , v , . . . , v n be from A such that f p u q \ ¨ ¨ ¨ \ f p u m q \ f p v q \ ¨ ¨ ¨ \ f p v n q “ . Since f is generated by t ˜ ei u , there is a term composed from automorphisms of A and r ei such that f p x q “ T p x q for all x P S Y t u , . . . , u m , v , . . . , v n u . By the choice of S , this term cannot be composed of automor-phisms alone, and hence there must be a P Aut p A q and operational terms T , T composed fromautomorphisms of A and r ei such that f p x q “ a p r ei p T p x q , T p x qqq for all x P S . As r ei forgets unions,there exists an i ď k such that T p u i q \ T p v q \ ¨ ¨ ¨ \ T l p v n q “ . Since T strongly preserves [ weconclude that there exists an i such that u i \ v \ ¨ ¨ ¨ \ v n “ (see the proof of Proposition 10),which is what we wanted to show. By Proposition 35 it follows that f is generated by ˜ e . But then f is generated by ˜ e as well.Next, consider the case that l ą
1. Let g be the binary operation defined by g p x, y q “ f p x, y, . . . , y q ; since f is injective, the operation g will also be injective, and in particular de-pends on both arguments, and strongly preserves , , and [ . We claim that g forgets unions.Let u “ p u , u q , . . . , u m “ p u m , u m q , v “ p v , v q , . . . , v n “ p v n , v n q be from A such that g p u q \ ¨ ¨ ¨ \ g p u m q \ g p v q \ ¨ ¨ ¨ \ g p v n q “ . Since g is generated by r ei and cannot be generated bythe automorphisms of A alone, there is a term of the form T p x, y q “ a p r ei p T p x, y q , T p x, y qqq where • a P Aut p A q , • T and T are operational terms composed from automorphisms of A and r ei , • g p x, y q “ T p x, y q for all p x, y q P t u , . . . , u m , v , . . . , v n u .Since r ei forgets unions, there exists an i ď k such that T p u i q \ T p v q \ ¨ ¨ ¨ \ T p v n q “ and T p u i q \ T p v q \ ¨ ¨ ¨ \ T p v n q “ . Suppose first that T depends on both arguments. Then T defines an injective operation and strongly preserves [ . It follows that u i \ v \ ¨ ¨ ¨ \ v n “ in A since these equations are inner Horn. We can argue similarly if T depends on both arguments,and in those cases we have established that g forgets unions. Suppose now that each of T and T does not depend on both arguments. Consider first the case that T only depends on thefirst argument. Then the function x ÞÑ T p x, x q is injective and strongly preserves [ , and from T p u i q \ T p v q \ ¨ ¨ ¨ \ T p v n q “ we derive as above that u i \ v \ ¨ ¨ ¨ \ v n “ holds in A .In this case, T must depend on the second argument, since T depends on both arguments. Wetherefore also have that u i \ v \ ¨ ¨ ¨ \ v n “ holds in A . The situation that T only depends onthe second argument and T only depends on the first argument is analogous. So g forgets unions.By Proposition 36, g generates r ei . Consequently, also f generates r ei .18 efinition 38. Let
U, I Ď A be the following relations U : “tp x, y, z q | p x \ y “ z qu I : “tp x, y, z q | p x [ y “ z qu Note that both U and I are preserved by ˜ i . The following demonstrates that when Γ has thepolymorphism ˜ i , this does not suffice for tractability of CSP p Γ q . Proposition 39.
Let Γ be the structure with domain A and three relations U , I , and ‰ . Then CSP p Γ q is NP-hard.Proof. The proof is by reduction from 3SAT. We compute from a given 3SAT instance Φ withvariable set V an instance Ψ of CSP p Γ q (in polynomial time) as follows. There are distinguishedvariables t and f in Ψ. For each variable x of Φ there are two variables x t and x f in Ψ. For aclause C : “ t l , l , l u of Φ (with literals l i either of the form x or of the form x ) we create afresh variable u C , and add the constraints U p v , v , u C q and U p u C , v , t q where v i : “ x f if l i “ x ,and v i : “ x t if l i “ x . Moreover, we add for each variable x P V the constraints U p x t , x f , t q and I p x t , x f , f q . Finally, add the constraint t ‰ f and I p t, f, f q .It is clear that if Φ has the satisfying assignment α : V Ñ t , u then the following assignment β satisfies all constraints in Ψ. Choose S f Ĺ S t arbitrarily. Then β maps t to S t and f to S f , itmaps x t P V to S t if α p x q “ S f otherwise, it maps x f P V to S f if α p x q “ S t otherwise, and for every clause C “ t l , l , l u of Φ it maps u C to S t if α p l q “ α p l q “
1, andto S f otherwise.Conversely, suppose that β maps the variables of Ψ to the elements of Γ satisfying all constraintsof Ψ. Let B be the finite Boolean algebra that is generated by β p V q in Γ. Since β p f q Ĺ β p t q , wehave that β p t q is non-empty. Select an arbitrary atom a of B that is contained in β p t q . Then weset α p x q for x P V to 1 if a Ď β p x t q and to 0 otherwise. In this way all clauses t l , l , l u of Φ aresatisfied. To see this, assume for simplicity of presentation that l “ x is negative and l “ y and l “ z are positive; the general case is analogous. Since we have the constraints U p x f , y t , u C q and U p u C , z t , t q , and since a is an atom of B , one of β p x f q , β p y t q , β p z t q must contain a . If a is in β p y t q or β p z t q then α p y q or α p z q is set to 1. If a is in β p x f q , then the clause I p x t , x f , f q forces that a isnot in β p x t q , and hence α p x q is set to 0. Thus, α sets at least one of x, y, z to 1, and the clause C is satisfied. Theorem 40.
Let Γ be a set constraint language. Suppose that Γ contains all relations from E I ,and also contains a relation that is not from E I . Then there is a finite sublanguage Γ of Γ suchthat CSP p Γ q is NP-hard.Proof. When R , R , . . . are the relations of Γ, let φ , φ , . . . be quantifier-free first-order formulasthat define R Γ1 , R Γ2 , . . . over S “ p P p N q ; \ , [ , c, , q . Let R A , R A , . . . be the relations defined by φ , φ , . . . over A , and let ∆ be the relational structure with domain A and exactly those relations.By Proposition 36, ∆ contains a relation that is not preserved by r ei , and contains all relations thatare preserved by r ei . Consider the set F of all polymorphisms of ∆.The set F does not contain r ei , since this would contradict by Theorem 31 the fact that ∆ containsa relation that is not preserved by r ei . Since F is locally closed, it follows from Theorem 37 thatall operations f P F are generated by ˜ e . But then the relation tp x, y, z q | x “ y ‰ z _ x ‰ y “ z u is preserved by all operations in F , and hence pp definable in Γ by Theorem 29. This relationhas an NP-complete CSP [BK08]. Let ∆ be the reduct of ∆ that contains exactly the relations19hat appear in those pp definitions. Clearly, there are finitely many such relations; we denote thecorresponding relation symbols by τ Ă τ . By Lemma 28, CSP p ∆ q is NP-hard.This establishes also the hardness of CSP p Γ q : let Γ be the τ -reduct of Γ. We claim thatCSP p Γ q and CSP p ∆ q are the same computational problem. We have to show that a conjunctionof atomic τ -formulas Φ is satisfiable in Γ if and only if it is true in ∆ . Replacing each atomic τ -formula in Φ by its quantifier-free first-order definition, this follows from Theorem 27. We have introduced the powerful set constraint language of E I set constraints, which in particularcontains all Horn-Horn set constraints and all previously studied tractable set constraint languages.Constraint satisfaction problems over E I can be solved in polynomial – even quadratic – time. Ourtractability result is complemented by a complexity result which shows that tractability of E I setconstraints is best-possible within a large class of set constraint languages.It is not hard to see from the properties we prove for E I set constraints that there is an algorithmto test whether a given finite set constraint language (where relations in the language are given byquantifier-free formulas over the signature t\ , [ , c , , u ) is contained in E I . This means that theso-called meta-problem for E I set constraints can be decided effectively.We would also like to remark that one can analogously obtain tractability for the class ofconstraints where the inner clauses of the positive outer literals are dual Horn (i.e., have at mostone negative literal). Acknowledgements
We want to thank Fran¸cois Bossi`ere who pointed out mistakes in the con-ference version of the paper.
References [Aik94] Alexander Aiken. Set constraints: Results, applications, and future directions. In
PPCP ,pages 326–335, 1994.[Baa03] Franz Baader. Least common subsumers and most specific concepts in a descriptionlogic with existential restrictions and terminological cycles. In
IJCAI , pages 319–324,2003.[BBL05] Franz Baader, Sebastian Brandt, and Carsten Lutz. Pushing the EL envelope. In
IJCAI ,pages 364–369, 2005.[BD06] Andrei A. Bulatov and V´ıctor Dalmau. A simple algorithm for Mal’tsev constraints.
SIAM Journal on Computing , 36(1):16–27, 2006.[BHK11] Manuel Bodirsky, Martin Hils, and Alex Krimkevitch. Tractable set constraints. In
Proceedings of IJCAI , pages 510–515, 2011.[BJR02] M. Broxvall, P. Jonsson, and J. Renz. Disjunctions, independence, refinements.
ArtificialIntelligence , 140(1/2):153–173, 2002.20BK07] Manuel Bodirsky and Martin Kutz. Determining the consistency of partial tree descrip-tions.
Artificial Intelligence , 171:185–196, 2007.[BK08] Manuel Bodirsky and Jan K´ara. The complexity of equality constraint languages.
The-ory of Computing Systems , 3(2):136–158, 2008. A conference version appeared in theproceedings of CSR’06.[BK09a] Libor Barto and Marcin Kozik. Constraint satisfaction problems of bounded width. In
Proceedings of FOCS , pages 595–603, 2009.[BK09b] Manuel Bodirsky and Jan K´ara. The complexity of temporal constraint satisfactionproblems.
Journal of the ACM , 57(2):41 pp, 2009. An extended abstract appeared inthe proceedings of STOC’08.[BKJ05] Andrei A. Bulatov, Andrei A. Krokhin, and Peter G. Jeavons. Classifying the complexityof constraints using finite algebras.
SIAM Journal on Computing , 34:720–742, 2005.[BN06] Manuel Bodirsky and Jaroslav Neˇsetˇril. Constraint satisfaction with countable homo-geneous templates.
Journal of Logic and Computation , 16(3):359–373, 2006.[Bod12] Manuel Bodirsky. Complexity classification in infinite-domain constraint satisfaction.Memoire d’habilitation `a diriger des recherches, Universit´e Diderot – Paris 7. Availableat arXiv:1201.0856, 2012.[Boo47] G. Boole.
An Investigation of the Laws of Thought . Walton, London, 1847. Reprintedby Philisophical Library, New York, 1954.[Bul03] Andrei A. Bulatov. Tractable conservative constraint satisfaction problems. In
Proceed-ings of LICS’03 , pages 321–330, Ottawa, Canada, 2003.[Bul06] Andrei A. Bulatov. A dichotomy theorem for constraint satisfaction problems on a3-element set.
Journal of the ACM , 53(1):66–120, 2006.[CJJK00] David Cohen, Peter Jeavons, Peter Jonsson, and Manolis Koubarakis. Building tractabledisjunctive constraints.
Journal of the ACM , 47(5):826–853, 2000.[DG84] William F. Dowling and Jean H. Gallier. Linear-time algorithms for testing the satisfia-bility of propositional horn formulae.
The Journal of Logic Programming , 1(3):267–284,1984.[DJ98] Thomas Drakengren and Peter Jonsson. Reasoning about set constraints applied totractable inference in intuitionistic logic.
Journal of Logic and Computation , 8(6):855–875, 1998.[Hod93] Wilfrid Hodges.
Model theory . Cambridge University Press, 1993.[IMM `
10] Pawel M. Idziak, Petar Markovic, Ralph McKenzie, Matthew Valeriote, and RossWillard. Tractability and learnability arising from algebras with few subpowers.
SIAMJournal on Computing , 39(7):3023–3037, 2010.[JB98] Peter Jonsson and Christer B¨ackstr¨om. A unifying approach to temporal constraintreasoning.
Artificial Intelligence , 102(1):143–155, 1998.21JD97] Peter Jonsson and Thomas Drakengren. A complete classification of tractability inRCC-5.
Journal of Artificial Intelligence Research , 6:211–221, 1997.[KM02] Ralf K¨usters and Ralf Molitor. Approximating most specific concepts in descriptionlogics with existential restrictions.
AI Commun. , 15(1):47–59, 2002.[KNR06] Viktor Kuncak, Huu Hai Nguyen, and Martin C. Rinard. Deciding boolean algebra withpresburger arithmetic.
J. Autom. Reasoning , 36(3):213–239, 2006.[Kop89] S. Koppelberg. Projective boolean algebras. In
Handbook of Boolean Algebras , volume 3,pages 741–773. North Holland, Amsterdam-New York-Oxford- Tokyo, 1989.[Kou01] M. Koubarakis. Tractable disjunctions of linear constraints: Basic results and applica-tions to temporal reasoning.
Theoretical Computer Science , 266:311–339, 2001.[KR07] Viktor Kuncak and Martin C. Rinard. Towards efficient satisfiability checking forboolean algebra with presburger arithmetic. In
CADE , pages 215–230, 2007.[KRH06] Markus Kr¨otzsch, Sebastian Rudolph, and Pascal Hitzler. On the complexity of Horndescription logics. In
OWLED , 2006.[MO96] Kim Marriott and Martin Odersky. Negative Boolean constraints.
Theoretical ComputerScience , 160(1&2):365–380, 1996.[Sch78] Thomas J. Schaefer. The complexity of satisfiability problems. In
Proceedings of STOC ,pages 216–226, 1978.[Sze86] ´Agnes Szendrei.