Enumerating All Solutions for Constraint Satisfaction Problems Henning Schnoor Ilka Schnoor Institut f¨ ur Theoretische Informatik Leibniz Universit¨ at Hannover Aachen, 24.2.2007 Enumerating All Solutions for Constraint Satisfaction Problems 1
Constraint Satisfaction Problems Introduction Algorithms Classification Outlook Generalization of many well-known problems ◮ 3SAT ◮ Horn-SAT ◮ Graph colorability ◮ . . . all kinds of combinatorial problems Enumerating All Solutions for Constraint Satisfaction Problems 2
Satisfiability Problems Introduction Algorithms Classification Outlook A few satisfiability problems ◮ General SAT-problem: NP-complete. ◮ Restriction to 3SAT: NP-complete. ( x 1 ∨ x 2 ∨ x 3 ) ∧ ( x 2 ∨ x 4 ∨ x 5 ) ◮ Restriction to 2SAT: complete for NL . ( x 1 ∨ x 2 ) ∧ ( x 2 ∨ x 1 ) ◮ Restriction to Horn-formulas: complete for P. (( x 1 ∧ x 2 ∧ x 3 ) → x 4 ) ∧ (( x 2 ∧ x 3 ¸ ∧ x 5 ) → x 1 ) Enumerating All Solutions for Constraint Satisfaction Problems 3
Constraint Satisfaction Problems: Definitions Introduction Algorithms Classification Outlook ◮ constraint language Γ: set of relations over domain D ◮ Γ 3SAT := { ( x ∨ y ∨ z ) , ( x ∨ y ∨ z ) , ( x ∨ y ∨ z ) , ( x ∨ y ∨ z ) } ◮ Γ-formula: R 1 ( x 1 , . . . , x k ) ∧ · · · ∧ R n ( y 1 , . . . , y l ) for R i ∈ Γ Enumerating All Solutions for Constraint Satisfaction Problems 4
Constraint Satisfaction Problems: Definitions Introduction Algorithms Classification Outlook ◮ constraint language Γ: set of relations over domain D ◮ Γ 3SAT := { ( x ∨ y ∨ z ) , ( x ∨ y ∨ z ) , ( x ∨ y ∨ z ) , ( x ∨ y ∨ z ) } ◮ Γ-formula: R 1 ( x 1 , . . . , x k ) ∧ · · · ∧ R n ( y 1 , . . . , y l ) for R i ∈ Γ ◮ solution: assignment I to the variables with ( I ( x 1 ) , . . . , I ( x k )) ∈ R 1 , . . . , ( I ( y 1 ) , . . . , I ( y l )) ∈ R n ◮ constraint satisfaction problem CSP (Γ) : Does a given Γ-formula have a solution? Enumerating All Solutions for Constraint Satisfaction Problems 4
Constraint Satisfaction Problems: Example Introduction Algorithms Classification Outlook Example: CSP can express colorability ◮ D := { 0 , 1 , 2 } , R := { ( x , y ) | x , y ∈ D , x � = y } . Enumerating All Solutions for Constraint Satisfaction Problems 5
Constraint Satisfaction Problems: Example Introduction Algorithms Classification Outlook Example: CSP can express colorability ◮ D := { 0 , 1 , 2 } , R := { ( x , y ) | x , y ∈ D , x � = y } . ◮ G a graph with edges ( u 1 , v 1 ) , . . . , ( u n , v n ) ◮ Define ϕ := R ( u 1 , v 1 ) ∧ · · · ∧ R ( u n , v n ) . Enumerating All Solutions for Constraint Satisfaction Problems 5
Constraint Satisfaction Problems: Example Introduction Algorithms Classification Outlook Example: CSP can express colorability ◮ D := { 0 , 1 , 2 } , R := { ( x , y ) | x , y ∈ D , x � = y } . ◮ G a graph with edges ( u 1 , v 1 ) , . . . , ( u n , v n ) ◮ Define ϕ := R ( u 1 , v 1 ) ∧ · · · ∧ R ( u n , v n ) . ◮ ϕ is satisfiable if and only if G is 3-colorable. Corollary In general, CSP (Γ) is NP -complete. Enumerating All Solutions for Constraint Satisfaction Problems 5
Complexity Results for CSP Introduction Algorithms Classification Outlook ◮ Complexity classifications for 2- and 3-element domains Schaefer 1978, Bulatov 2003 ◮ CSP (Γ) is either in P , or NP -complete for all known cases We are interested in the complexity of enumerating all solutions for a given constraint formula. Enumerating All Solutions for Constraint Satisfaction Problems 6
Research Goal Introduction Algorithms Classification Outlook Question For Γ , decide if efficient enumeration for Γ-formulas is possible. Enumerating All Solutions for Constraint Satisfaction Problems 7
Efficient Enumeration Introduction Algorithms Classification Outlook Efficient enumeration algorithm On input ϕ, print all solutions of ϕ such that ◮ Time between two solutions is bounded by a polynomial ◮ Each solution I | = ϕ is printed exactly once Enumerating All Solutions for Constraint Satisfaction Problems 8
A Simple Algorithm Introduction Algorithms Classification Outlook An algorithm for the Boolean case ◮ Let ϕ be a formula with variables x 1 , . . . , x n . Enumerating All Solutions for Constraint Satisfaction Problems 9
A Simple Algorithm Introduction Algorithms Classification Outlook An algorithm for the Boolean case ◮ Let ϕ be a formula with variables x 1 , . . . , x n . ◮ If ϕ ∧ x 1 ∈ SAT: enumerate all solutions of ϕ ∧ x 1 ◮ If ϕ ∧ x 1 ∈ SAT: enumerate all solutions of ϕ ∧ x 1 Enumerating All Solutions for Constraint Satisfaction Problems 9
A Simple Algorithm Introduction Algorithms Classification Outlook An algorithm for the Boolean case ◮ Let ϕ be a formula with variables x 1 , . . . , x n . ◮ If ϕ ∧ x 1 ∈ SAT: enumerate all solutions of ϕ ∧ x 1 ◮ If ϕ ∧ x 1 ∈ SAT: enumerate all solutions of ϕ ∧ x 1 Theorem (Creignou, H´ ebrard, 1997) ◮ In the Boolean case, there is no other algorithm. Enumerating All Solutions for Constraint Satisfaction Problems 9
A Simple Algorithm Introduction Algorithms Classification Outlook ◮ Algorithm needs decision for“Γ-formulas with literals.” ◮ Works if CSP for Γ plus ( x = 0) and ( x = 1) is tractable. � �� � � �� � x x Enumerating All Solutions for Constraint Satisfaction Problems 10
A Simple Algorithm Introduction Algorithms Classification Outlook ◮ Algorithm needs decision for“Γ-formulas with literals.” ◮ Works if CSP for Γ plus ( x = 0) and ( x = 1) is tractable. � �� � � �� � x x ◮ Generalization to non-Boolean case: ◮ Γ + is Γ plus clauses ( x = α ) for α ∈ D . ◮ Γ + is“Γ with literals.” Enumerating All Solutions for Constraint Satisfaction Problems 10
A Simple Algorithm Introduction Algorithms Classification Outlook ◮ Algorithm needs decision for“Γ-formulas with literals.” ◮ Works if CSP for Γ plus ( x = 0) and ( x = 1) is tractable. � �� � � �� � x x ◮ Generalization to non-Boolean case: ◮ Γ + is Γ plus clauses ( x = α ) for α ∈ D . ◮ Γ + is“Γ with literals.” CSP (Γ + ) is SAT for formulas ϕ ∧ ( x 1 = 4) ∧ ( x 2 = 1) . . . Satisfiability problem with literals. Enumerating All Solutions for Constraint Satisfaction Problems 10
Non-Boolean Generalization Introduction Algorithms Classification Outlook Theorem (Cohen, 2004) If CSP (Γ + ) ∈ P , then Γ has an efficient enumeration algorithm. Proof Generalization of previous algorithm. Enumerating All Solutions for Constraint Satisfaction Problems 11
Non-Boolean Generalization Introduction Algorithms Classification Outlook Theorem (Cohen, 2004) If CSP (Γ + ) ∈ P , then Γ has an efficient enumeration algorithm. Proof Generalization of previous algorithm. Converse? ◮ For the Boolean case, the converse holds as well. Creignou, H´ ebrard, 1997 ◮ What about arbitrary domains? Enumerating All Solutions for Constraint Satisfaction Problems 11
Lexicographic Orderings Introduction Algorithms Classification Outlook ◮ A weaker version of the converse does hold. Theorem Equivalent: 1. CSP (Γ + ) ∈ P . 2. Solutions for Γ -formuls can be enumerated in lexicographical ordering, with different order for each variable. ◮ For x 1 , we demand 0 < 2 < 4 < . . . ◮ For x 2 , we demand 4 < 3 < 1 < . . . Enumerating All Solutions for Constraint Satisfaction Problems 12
Summery Introduction Algorithms Classification Outlook Proposition ◮ If CSP (Γ + ) ∈ P , there is an efficient enumeration algorithm. ◮ If CSP (Γ) / ∈ P , there is no efficient enumeration algorithm. Enumerating All Solutions for Constraint Satisfaction Problems 13
Summery Introduction Algorithms Classification Outlook Proposition ◮ If CSP (Γ + ) ∈ P , there is an efficient enumeration algorithm. ◮ If CSP (Γ) / ∈ P , there is no efficient enumeration algorithm. We are interested in the remaining cases: CSP (Γ) ∈ P , and CSP (Γ + ) / ∈ P . ◮ In this case, we can add some , but not all literals to Γ and remain tractable. Enumerating All Solutions for Constraint Satisfaction Problems 13
Typical Enumeration Strategy Introduction Algorithms Classification Outlook Situation ◮ D = { 0 , 1 , 2 } ◮ CSP for Γ plus ( x = 0) , ( x = 1) tractable, ◮ CSP for Γ plus ( x = 0) , ( x = 1) , ( x = 2) not tractable. Enumerating All Solutions for Constraint Satisfaction Problems 14
Typical Enumeration Strategy Introduction Algorithms Classification Outlook Situation ◮ D = { 0 , 1 , 2 } ◮ CSP for Γ plus ( x = 0) , ( x = 1) tractable, ◮ CSP for Γ plus ( x = 0) , ( x = 1) , ( x = 2) not tractable. ◮ For every solution, exchanging 2 with a 1 again gives solution. ◮ If I = (2 , 1 , 1 , 0 , 0 , 1 , 2 , 1) is solution, so is I ′ = (1 , 1 , 1 , 0 , 0 , 1 , 1 , 1) . This is a typical situation. Enumerating All Solutions for Constraint Satisfaction Problems 14
Approach Introduction Algorithms Classification Outlook ◮ CSP for Γ plus“literal clauses”( x = 0) and ( x = 1) is tractable Enumerating All Solutions for Constraint Satisfaction Problems 15
Recommend
More recommend