reductions and np
play

Reductions and NP Part I Lecture 2 August 29, 2013 Reductions - PowerPoint PPT Presentation

CS 573: Algorithms, Fall 2013 Reductions and NP Part I Lecture 2 August 29, 2013 Reductions Continued Sariel (UIUC) CS573 1 Fall 2013 1 / 66 Sariel (UIUC) CS573 2 Fall 2013 2 / 66 Propositional Formulas Satisfiability Definition


  1. CS 573: Algorithms, Fall 2013 Reductions and NP Part I Lecture 2 August 29, 2013 Reductions Continued Sariel (UIUC) CS573 1 Fall 2013 1 / 66 Sariel (UIUC) CS573 2 Fall 2013 2 / 66 Propositional Formulas Satisfiability Definition SAT Consider a set of boolean variables x 1 , x 2 , . . . x n . Instance : A CNF formula ϕ . A literal is either a boolean variable x i or its negation ¬ x i . 1 Question: Is there a truth assignment to the variable of ϕ such A clause is a disjunction of literals. that ϕ evaluates to true? 2 For example, x 1 ∨ x 2 ∨ ¬ x 4 is a clause. A formula in conjunctive normal form ( CNF ) is 3 propositional formula which is a conjunction of clauses 3SAT ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ) ∧ x 5 is a CNF formula. 1 Instance : A 3CNF formula ϕ . A formula ϕ is a 3CNF : 4 Question: Is there a truth assignment to the variable of ϕ such A CNF formula such that every clause has exactly 3 literals. that ϕ evaluates to true? ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ∨ x 1 ) is a 3CNF formula, but 1 ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ) ∧ x 5 is not. Sariel (UIUC) CS573 3 Fall 2013 3 / 66 Sariel (UIUC) CS573 4 Fall 2013 4 / 66

  2. Satisfiability Importance of SAT and 3SAT SAT SAT and 3SAT are basic constraint satisfaction problems. 1 Given a CNF formula ϕ , is there a truth assignment to variables Many different problems can reduced to them because of the 2 such that ϕ evaluates to true? simple yet powerful expressively of logical constraints. Arise naturally in many applications involving hardware and Example 3 software verification and correctness. ( x 1 ∨ x 2 ∨ ¬ x 4 ) ∧ ( x 2 ∨ ¬ x 3 ) ∧ x 5 is satisfiable; take 1 As we will see, it is a fundamental problem in theory of 4 x 1 , x 2 , . . . x 5 to be all true NP-Complete ness. ( x 1 ∨ ¬ x 2 ) ∧ ( ¬ x 1 ∨ x 2 ) ∧ ( ¬ x 1 ∨ ¬ x 2 ) ∧ ( x 1 ∨ x 2 ) is not 2 satisfiable. 3SAT Given a 3CNF formula ϕ , is there a truth assignment to variables such that ϕ evaluates to true? (More on 2SAT in a bit...) Sariel (UIUC) CS573 5 Fall 2013 5 / 66 Sariel (UIUC) CS573 6 Fall 2013 6 / 66 SAT ≤ P 3SAT 3SAT ≤ P SAT 3SAT ≤ P SAT . 1 How SAT is different from 3SAT ? Because... 2 In SAT clauses might have arbitrary length: 1 , 2 , 3 , . . . variables: A 3SAT instance is also an instance of SAT . � � � � � � x ∨ y ∨ z ∨ w ∨ u ∧ ¬ x ∨ ¬ y ∨ ¬ z ∨ w ∨ u ∧ ¬ x In 3SAT every clause must have exactly 3 different literals. To reduce from an instance of SAT to an instance of 3SAT , we must make all clauses to have exactly 3 variables... Basic idea Pad short clauses so they have 3 literals. 1 Break long clauses into shorter clauses. 2 Repeat the above till we have a 3CNF . 3 Sariel (UIUC) CS573 7 Fall 2013 7 / 66 Sariel (UIUC) CS573 8 Fall 2013 8 / 66

  3. SAT ≤ P 3SAT SAT ≤ P 3SAT A clause with a single literal Claim SAT ≤ P 3SAT . Reduction Ideas Given ϕ a SAT formula we create a 3SAT formula ϕ ′ such that Challenge: Some of the clauses in ϕ may have less or more than 3 literals. For each clause with < 3 or > 3 literals, we will construct a ϕ is satisfiable iff ϕ ′ is satisfiable. 1 set of logically equivalent clauses. ϕ ′ can be constructed from ϕ in time polynomial in | ϕ | . 2 Case clause with one literal: Let c be a clause with a single 1 literal (i.e., c = ℓ ). Let u , v be new variables. Consider Idea: if a clause of ϕ is not of length 3 , replace it with several clauses of length exactly 3 . c ′ = � � � � ℓ ∨ u ∨ v ∧ ℓ ∨ u ∨ ¬ v � � � � ∧ ℓ ∨ ¬ u ∨ v ∧ ℓ ∨ ¬ u ∨ ¬ v . Observe that c ′ is satisfiable iff c is satisfiable Sariel (UIUC) CS573 9 Fall 2013 9 / 66 Sariel (UIUC) CS573 10 Fall 2013 10 / 66 SAT ≤ P 3SAT Breaking a clause A clause with two literals Lemma For any boolean formulas X and Y and z a new boolean variable. Then X ∨ Y is satisfiable Reduction Ideas: 2 and more literals Case clause with 2 literals: Let c = ℓ 1 ∨ ℓ 2 . Let u be a new if and only if, z can be assigned a value such that 1 variable. Consider � � � � X ∨ z ∧ Y ∨ ¬ z is satisfiable c ′ = � � � � ℓ 1 ∨ ℓ 2 ∨ u ∧ ℓ 1 ∨ ℓ 2 ∨ ¬ u . (with the same assignment to the variables appearing in X and Y ). Again c is satisfiable iff c ′ is satisfiable Sariel (UIUC) CS573 11 Fall 2013 11 / 66 Sariel (UIUC) CS573 12 Fall 2013 12 / 66

  4. SAT ≤ P 3SAT (contd) An Example Clauses with more than 3 literals Example Let c = ℓ 1 ∨ · · · ∨ ℓ k . Let u 1 , . . . u k − 3 be new variables. Consider � � � � c ′ = ϕ = ¬ x 1 ∨ ¬ x 4 ∧ x 1 ∨ ¬ x 2 ∨ ¬ x 3 � � � � ℓ 1 ∨ ℓ 2 ∨ u 1 ∧ ℓ 3 ∨ ¬ u 1 ∨ u 2 � � � � ∧ ¬ x 2 ∨ ¬ x 3 ∨ x 4 ∨ x 1 ∧ x 1 . � � ∧ ℓ 4 ∨ ¬ u 2 ∨ u 3 ∧ Equivalent form: � � � � · · · ∧ ℓ k − 2 ∨ ¬ u k − 4 ∨ u k − 3 ∧ ℓ k − 1 ∨ ℓ k ∨ ¬ u k − 3 . ψ = ( ¬ x 1 ∨ ¬ x 4 ∨ z ) ∧ ( ¬ x 1 ∨ ¬ x 4 ∨ ¬ z ) Claim ∧ ( x 1 ∨ ¬ x 2 ∨ ¬ x 3 ) c is satisfiable if and only if c ′ is satisfiable. ∧ ( ¬ x 2 ∨ ¬ x 3 ∨ y 1 ) ∧ ( x 4 ∨ x 1 ∨ ¬ y 1 ) ∧ ( x 1 ∨ u ∨ v ) ∧ ( x 1 ∨ u ∨ ¬ v ) Another way to see it — reduce size of clause by one: ∧ ( x 1 ∨ ¬ u ∨ v ) ∧ ( x 1 ∨ ¬ u ∨ ¬ v ) . c ′ = � � � � ℓ 1 ∨ ℓ 2 . . . ∨ ℓ k − 2 ∨ u k − 3 ∧ ℓ k − 1 ∨ ℓ k ∨ ¬ u k − 3 . Sariel (UIUC) CS573 13 Fall 2013 13 / 66 Sariel (UIUC) CS573 14 Fall 2013 14 / 66 Overall Reduction Algorithm What about 2SAT ? Reduction from SAT to 3SAT 2SAT can be solved in polynomial time! (specifically, linear time!) ReduceSATTo3SAT ( ϕ ): // ϕ : CNF formula. No known polynomial time reduction from SAT (or 3SAT ) to for each clause c of ϕ do 2SAT . If there was, then SAT and 3SAT would be solvable in if c does not have exactly 3 literals then construct c ′ as before polynomial time. else c ′ = c Why the reduction from 3SAT to 2SAT fails? ψ is conjunction of all c ′ constructed in loop Consider a clause ( x ∨ y ∨ z ) . We need to reduce it to a collection return Solver3SAT ( ψ ) of 2 CNF clauses. Introduce a fake variable α , and rewrite this as Correctness (informal) ( x ∨ y ∨ α ) ∧ ( ¬ α ∨ z ) (bad! clause with 3 vars) ϕ is satisfiable iff ψ is satisfiable because for each clause c , the new or ( x ∨ α ) ∧ ( ¬ α ∨ y ∨ z ) (bad! clause with 3 vars) . 3CNF formula c ′ is logically equivalent to c . (In animal farm language: 2SAT good, 3SAT bad.) Sariel (UIUC) CS573 15 Fall 2013 15 / 66 Sariel (UIUC) CS573 16 Fall 2013 16 / 66

  5. What about 2SAT ? Independent Set A challenging exercise: Given a 2SAT formula show to compute its Independent Set satisfying assignment... (Hint: Create a graph with two vertices for each variable (for a Instance : A graph G , integer k . variable x there would be two vertices with labels x = 0 and x = 1 ). Question: Is there an independent set in G of size k ? For ever 2 CNF clause add two directed edges in the graph. The edges are implication edges: They state that if you decide to assign a certain value to a variable, then you must assign a certain value to some other variable. Now compute the strong connected components in this graph, and continue from there...) Sariel (UIUC) CS573 17 Fall 2013 17 / 66 Sariel (UIUC) CS573 18 Fall 2013 18 / 66 3SAT ≤ P Independent Set Interpreting 3SAT There are two ways to think about 3SAT The reduction 3SAT ≤ P Independent Set Find a way to assign 0/1 (false/true) to the variables such that 1 Input: Given a 3CNF formula ϕ the formula evaluates to true, that is each clause evaluates to Goal: Construct a graph G ϕ and number k such that G ϕ has an true. independent set of size k if and only if ϕ is satisfiable. Pick a literal from each clause and find a truth assignment to 2 G ϕ should be constructable in time polynomial in size of ϕ make all of them true. You will fail if two of the literals you pick Importance of reduction: Although 3SAT is much more expressive, it are in conflict, i.e., you pick x i and ¬ x i can be reduced to a seemingly specialized Independent Set problem. We will take the second view of 3SAT to construct the reduction. Notice: We handle only 3CNF formulas – reduction would not work for other kinds of boolean formulas. Sariel (UIUC) CS573 19 Fall 2013 19 / 66 Sariel (UIUC) CS573 20 Fall 2013 20 / 66

Recommend


More recommend