CS500 CS500 Satisfiability Sat and 3sat Consider a set of boolean variables x 1 , x 2 , . . . x n . Sat : Instance: A CNF formula φ . A literal is either a boolean variable x i or its negation ¬ x i . Question: Is there a truth assignment to the variables of φ such that φ evaluates to true? A clause is a disjunction of literals. For example, x 1 ∨ x 2 ∨ ¬ x 4 is a clause. 3sat : A formula in conjunctive normal form (CNF) is propositional Instance: A 3CNF formula φ . formula which is a conjunction of clauses: Question: Is there a truth assignment to the variables of φ such that φ evaluates to true? ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ) ∧ x 5 ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ) ∧ x 5 is satisfiable; take A CNF formula such that every clause has exactly 3 literals is a x 1 , x 2 , . . . x 5 to be all true 3CNF formula. ( x 1 ∨ ¬ x 2 ) ∧ ( ¬ x 1 ∨ x 2 ) ∧ ( ¬ x 1 ∨ ¬ x 2 ) ∧ ( x 1 ∨ x 2 ) is not ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ∨ x 1 ) satisfiable. CS500 CS500 Importance of Satisfiability Sat and 3sat • Sat and 3sat are basic constraint satisfaction problems. Clearly we have 3sat ≤ Sat • Many different problems can be reduced to SAT . But we also have Sat ≤ 3sat • Arise naturally in many applications involving hardware and software verification and correctness. Given ϕ a CNF formula we create a 3CNF formula ϕ ′ such that • As we will see, it is a fundamental problem in the theory of • ϕ is satisfiable iff ϕ ′ is satisfiable. NP-completeness. • ϕ ′ can be constructed from ϕ in time polynomial in | ϕ | . Idea: if a clause of ϕ is not of length 3 , replace it with several clauses of length exactly 3 .
CS500 CS500 One and two literals More than 3 literals Clause with 2 literals: Let c = ℓ 1 ∨ ℓ 2 . Let c = ℓ 1 ∨ · · · ∨ ℓ k . Let u be a new variable and let Let u 1 , . . . u k − 3 be new variables. Consider c ′ = ( ℓ 1 ∨ ℓ 2 ∨ u ) ∧ ( ℓ 1 ∨ ℓ 2 ∨ ¬ u ) . c ′ =( ℓ 1 ∨ ℓ 2 ∨ u 1 ) ∧ ( ℓ 3 ∨ ¬ u 1 ∨ u 2 ) ∧ Then c is satisfiable iff c ′ is satisfiable ( ℓ 4 ∨ ¬ u 2 ∨ u 3 ) ∧ Clause with 1 literal: Let c = ℓ 1 . · · · ∧ Let u and v be new variables and let ( ℓ k − 2 ∨ ¬ u k − 4 ∨ u k − 3 ) ∧ c ′ = ( ℓ 1 ∨ u ∨ v ) ∧ ( ℓ 1 ∨ u ∨ ¬ v ) ( ℓ k − 1 ∨ ℓ k ∨ ¬ u k − 3 ) . ∧ ( ℓ 1 ∨ ¬ u ∨ v ) ∧ ( ℓ 1 ∨ ¬ u ∨ ¬ v ) . c is satisfiable if and only if c ′ is satisfiable. Then c is satisfiable iff c ′ is satisfiable CS500 CS500 2sat 3Sat ≤ 3Coloring What about 2sat ? Reduction converts a formula φ in 3CNF into a graph G . It can be solved in polynomial time (even linear time). φ is satisfiable iff G can be colored with three colors. N Compare: truth gadget F T 2Coloring 3Coloring . . . ¬ x 1 ¬ x 2 ¬ x 3 ¬ x n 2Sat 3Sat x 1 x 2 x 3 x n We have one variable gadget for each variable. x i and ¬ x i must have different colors. Easy Hard All x i and ¬ x i vertices are connected to N, so they cannot be blue. So either x i is green (and ¬ x i red), or x i is red (and ¬ x i green).
CS500 CS500 Clause gadgets Clause gadgets For each clause c = ℓ 1 ∨ ℓ 2 ∨ ℓ 3 we build a gadget that can be For each clause c = ℓ 1 ∨ ℓ 2 ∨ ℓ 3 we build a gadget that can be colored iff at least one of the ℓ i nodes is green. colored iff at least one of the ℓ i nodes is green. ℓ 1 ℓ 1 T T ℓ 2 ℓ 2 ℓ 3 ℓ 3 CS500 CS500 Clause gadgets Complete construction For each clause c = ℓ 1 ∨ ℓ 2 ∨ ℓ 3 we build a gadget that can be We create a clause gadget for each clause. colored iff at least one of the ℓ i nodes is green. N F T ℓ 1 T . . . ℓ 2 ¬ x 1 ¬ x 2 ¬ x 3 ¬ x n x 1 x 2 x 3 x n ℓ 3 x 1 ∨ ¬ x 2 ∨ x n ¬ x 2 ∨ ¬ x 3 ∨ ¬ x n
CS500 Reduction Summary Planar3Coloring Sat 3Sat 3Coloring IndependentSet VertexCover Clique HamiltonianCycle SetCover SubsetSum HamiltonianPath Partition LongestPath So Sat ≤ X, for all these problems X.
Recommend
More recommend