Constraint Satisfaction Complexity and Logic Phokion G. Kolaitis IBM Almaden Research Center & UC Santa Cruz
Total Page:16
File Type:pdf, Size:1020Kb
Constraint Satisfaction Complexity and Logic Phokion G. Kolaitis IBM Almaden Research Center & UC Santa Cruz 1 Goals Goals: ² Show that Constraint Satisfaction Problems (CSP) form a broad class of algorithmic problems that arise naturally in several di®erent areas. ² Present an overview of CSP with emphasis on the computational complexity aspects of CSP and on the connections with database theory, univeral algebra, and logic 2 Course Outline Constraint Satisfaction Problems (CSP) ² De¯nition & Examples of CSP ² CSP & the Homomorphism Problem ² CSP & Database Theory ² Computational Complexity of CSP { Uniform & Non-Uniform CSP { Schaefer's Dichotomy Theorem for Boolean CSP { The Feder-Vardi Dichotomy Conjecture for general CSP 3 Course Outline ² The Pursuit of Tractable Cases of CSP { Universal Algebra and Closure Properties of Constraints { Datalog, Finite-variable Logics, and Pebble Games { Bounded Treewidth and Finite-variable Log- ics 4 Algorithmic Problems ² k-SAT:(k ¸ 2 is ¯xed) Given a k-CNF formula, is it satis¯able? ² k-Colorability:(k ¸ 2 is ¯xed) Given a graph H = (V; E), is it k-colorable? ² Clique: Given a graph H = (V; E) and a positive inte- ger k, does H contain a k-clique? ² Hamiltonian Cycle: Given a graph H = (V; E), does it contain a Hamiltonian cycle? 5 Algorithmic Problems Latin Squares: L. Euler { 1783 A Latin square of order n is an n £ n matrix of n symbols such that each symbol occurs exactly once in each row and each column of the matrix. A Latin Square of Order 4 2 3 1 4 3 4 2 1 4 1 3 2 1 2 4 3 Latin Square Completion: given a n £ n grid and a partial assignment of n symbols, can this partial assignment be completed to a Latin square of order n? 6 Latin Square Completion ² There is a completion to a Latin square 2 4 4 1 4 3 1 ² There is no completion to a Latin square 3 4 1 2 2 7 Latin Square Completion Is there a completion to a Latin square? 3 4 6 5 1 3 2 5 7 3 7 2 4 3 2 5 3 8 Algorithmic Problems Problems: ² k-SAT (k ¸ 2) ² k-Colorability (k ¸ 2) ² Clique ² Hamiltonian Cycle ² Latin Square Completion Question: What do these have in common? 9 Constraint Satisfaction Problems Problems: ² k-SAT (k ¸ 2) ² k-Colorability (k ¸ 2) ² Clique ² Hamiltonian Cycle ² Latin Square Completion Question: What do these have in common? Answer: Each of them is a Constraint Satisfaction Problem. 10 Constraint Satisfaction Problem U. Montanari { 1974 CSP { Informal De¯nition Input: A set V of variables, a domain D of values for the variables, and a set C of constraints. Question: Is there an assignment of values to variables such that all constraints in C are satis- ¯ed? Example: k-SAT as a CSP k-CNF ': variables x1; : : : ; xn; clauses c1; : : : ; cm ² Variables: x1; : : : ; xn ² Values: 0; 1 ² Constraints: Given by the clauses of '. 11 Constraint Satisfaction Problem Input: (V; D; C) ² A ¯nite set V of variables ² A ¯nite domain D of values for the variables ² A set C of constraints (t; R) restricting the values that tuples of variables can take. { t: a tuple t = (x1; : : : ; xm) of variables { R: a relation on D of arity jtj = m Question: Does (V; D; C) have a solution? Solution: A mapping h : V ! D such that h(t) = (h(x1); : : : ; h(xm)) 2 R; for every constraint (t; R) 2 C. An assignment of values to the variables such that all constraints are satis¯ed. 12 Example ² 3-Sat: Given a 3CNF-formula ' with variables x1; : : : ; xn and clauses c1; : : : ; cm, is ' satis¯able? ² 3-Sat as a CSP: { Variables x1; : : : ; xn { Domain D = f0; 1g { Constraints ((x; y; z);Ri), i = 0; 1; 2; 3 Clause Relation 3 (x _ y _ z) R0 = f0; 1g ¡ f(0; 0; 0)g 3 (:x _ y _ z) R1 = f0; 1g ¡ f(1; 0; 0)g 3 (:x _:y _ z) R2 = f0; 1g ¡ f(1; 1; 0)g 3 (:x _:y _:z) R3 = f0; 1g ¡ f(1; 1; 1)g 13 Example ² 3-Colorability: Given a graph H = (V; E), is it 3-colorable? ² 3-Colorability as a CSP: { The variables are the nodes in V { The domain is the set D = fR; G; Bg of three colors. { The constraints are the pairs ((u; v);Q), where (u; v) 2 E and Q is the relation f(R; G); (G; R); (R; B); (B; R); (B; G); (G; B)g: 14 More Examples Homework Assignment #1: Express the following problems as CSPs: ² 4-Colorability ² Clique ² Hamiltonian Cycle ² Latin Square Completion 15 Constraint Satisfaction Problems Fundamental & ubiquitous problems in AI and CS: ² Boolean Satis¯ability, Graph Colorability, ... ² Database Query Processing ² Planning and Scheduling ² Belief Maintenance ² Machine Vision ² ¢ ¢ ¢ ² Linguistics 16 Homomorphisms De¯nition: Consider two relational structures A A B B A = (A; R1 ;:::;Rm) and B = (B; R1 ;:::;Rm). h : A ! B is a homomorphism if for every i · m n and every tuple (a1; : : : ; an) 2 A , A B Ri (a1; : : : ; an) =) Ri (h(a1); : : : ; h(an)): Example: Clique K4 vs. Clique K5 v ¯LQ´ Q ´ Q v v ´ ¯ L Q @ ¡ ´ ¯ L Q v´´ Qv @ ¡ b ¯ L " @ ¡ B b " £ b ¯ L " £ @¡ B b¯ "L £ B b " ¡ @ ¯ "b L £ ¡ @ B " b ¯ " b L £ ¡¡ @@vv BBv"¯ bL v£ ² There is a homomorphism from K4 to K5; ² There is no homomorphism from K5 to K4. 17 The Homomorphism Problem De¯nition: The Homomorphism Problem Given two relational structures A and B, is there a homomorphism h : A ! B? Fact: Feder & Vardi { 1993 CSP can be identi¯ed with the Homomorphism Problem. 18 Example 3-Sat as a Homomorphism Problem: Given 3-CNF formula ' with variables x1; : : : ; xn: ' ' ' ' ' ² A = (fx1; : : : ; xng;R0 ;R1 ;R2 ;R3 ), where ' R0 = f(x; y; z):(x _ y _ z) is a clause of 'g ' R1 = f(x; y; z):(:x _ y _ z) is a clause of 'g ' R2 = f(x; y; z):(:x _:y _ z) is a clause of 'g ' R3 = f(x; y; z):(:x _:y _:z) is a clause of 'g ² B = (f0; 1g;R0;R1;R2;R3), where 3 R0 = f0; 1g ¡ f(0; 0; 0)g 3 R1 = f0; 1g ¡ f(1; 0; 0)g 3 R2 = f0; 1g ¡ f(1; 1; 0)g 3 R3 = f0; 1g ¡ f(1; 1; 1)g Fact: ' is satis¯able i® there is hom. h : A' ! B. 19 Examples 3-Colorability as a Homomorphism Problem: Fact: A graph H = (V; E) is 3-colorable () there is a homomorphism h : H ! K3, where K3 is the 3-clique, i.e., K3 = (fR; G; Bg;E3), where E3 = f(R; G); (G; R); (R; B); (B; R); (B; G); (G; B)g: k-Colorability as a Homomorphism Problem: Fact: A graph H = (V; E) is k-colorable () there is a homomorphism h : H ! Kk, where Kk is the k-clique. 20 More Examples Homework Assignment #2: Express the following problems as Homomorphism Problems: ² 2-Sat ² Hamiltonian Cycle ² Latin Square Completion 21 Cliques and Homomorphisms De¯nition: The Clique Problem: Given a graph H = (V; E) and a positive integer k, does H contain a k-clique? Fact: The following are equivalent for a graph H and a positive integer k: ² H contains a k-clique. ² There is a homomorphism from Kk to H. Thus, the Clique Problem can be viewed as a Homomorphism Problem. 22 Homomorphisms and Cliques De¯nition: Given two graphs G = (V; E) and H = (V 0;E0) the homomorphism product G ± H is the graph with ² V £ V 0 as nodes; ² ((s; t); (s0; t0)) is an edge of G ± H if s 6= s0 and whenever (s; s0) 2 E, then (t; t0) 2 E0. Proposition: (Ba·c¶³kand Mahajan) The following are equivalent for two graphs G and H: ² There is a homomorphism from G to H. ² G ± H contains a clique of size jV j. ² The clique number of G ± H is jV j. Thus, the Homomorphism Problem has a direct reduction to the Clique Problem. 23 From CSP to the Homomorphism Problem Given a CSP-instance (V; D; C), let R1;:::;Rm be the distinct relations on D occurring in C. De¯ne the instance (A; B) of the Homomorphism Problem, where A = (V; ft :(t; R1) 2 Cg;:::; ft :(t; Rm) 2 Cg) and B = (D; R1;:::;Rm): Fact: The CSP instance (V; D; C) has a solution () there is a homomorphism from A to B. 24 From the Homomorphism Problem to CSP A A Given an instance A = (A; R1 ;:::;Rm) and B = B B (B; R1 ;:::;Rm) of the Homomorphism Prob- lem, de¯ne the instance (V; D; C) of CSP, where ² V = A (i.e., the elements of A are variables); ² D = B (i.e., the elements of B are values); B A ² C = f(t; Ri ): t 2 Ri ; 1 · i · mg: Fact: There is a homomorphism from A to B () the CSP-instance (V; D; C) has a solution. 25 CSP vs. the Homomorphism Problem Conclusion: Feder & Vardi { 1993 CSP = Homomorphism Problem Some Advantages: ² Clean, algebraic formulation of CSP. ² Makes it possible to apply methods from universal algebra and logics to the study of CSP. ² Makes the connections between CSP and database theory transparent. 26 CSP vs. the Homomorphism Problem ² CSP = Homomorphism Problem ² \A constraint network consists of a ¯nite set of variables, each associated with a set of discrete values, and a set of constraints. Each of the constraints is expressed as a relation, de¯ned on some subset of variables, whose tuples are all the simultaneous value assignments to the members of this variable subset that, as far as this constraint is concerned, are legala." Encyclopedia of Arti¯cial Intelligence { 1992 aThis does not mean that the actual representation of any constraint is necessarily in the form of its de¯ning re- lation, but that the relation can, in principle, be generated using the constraints' speci¯cation without the need to con- sult other constraints in the network.