cs 301
play

CS 301 Lecture 25 NP -complete Stephen Checkoway April 29, 2018 1 - PowerPoint PPT Presentation

CS 301 Lecture 25 NP -complete Stephen Checkoway April 29, 2018 1 / 30 Polynomial-time reducibility A function f is a polynomial-time computable function if some poly-time TM M exists that halts with just f ( w ) on its


  1. CS 301 Lecture 25 – NP -complete Stephen Checkoway April 29, 2018 1 / 30

  2. Polynomial-time reducibility A function f ∶ Σ ∗ → Σ ∗ is a polynomial-time computable function if some poly-time TM M exists that halts with just f ( w ) on its tape when run on w I.e., f is a computable function as defined before and its TM runs in time poly (∣ w ∣) 2 / 30

  3. Polynomial-time reducibility A function f ∶ Σ ∗ → Σ ∗ is a polynomial-time computable function if some poly-time TM M exists that halts with just f ( w ) on its tape when run on w I.e., f is a computable function as defined before and its TM runs in time poly (∣ w ∣) A is polynomial-time reducible to B (written A ≤ p B ) if a polynomial-time computable function f exists such that w ∈ A ⟺ f ( w ) ∈ B I.e., A ≤ m B and the computable mapping is polynomial time 2 / 30

  4. Another “good-news” reduction theorem Theorem If A ≤ p B and B ∈ P , then A ∈ P Similar proof to all of the others 3 / 30

  5. Another “good-news” reduction theorem Theorem If A ≤ p B and B ∈ P , then A ∈ P Similar proof to all of the others Proof. Let f be the poly-time reduction and let M decide B in poly time M ′ = “On input w , 1 Compute f ( w ) 2 Run M on f ( w ) ; if M accepts, then accept ; otherwise reject ” 3 / 30

  6. Another “good-news” reduction theorem Theorem If A ≤ p B and B ∈ P , then A ∈ P Similar proof to all of the others Proof. Let f be the poly-time reduction and let M decide B in poly time M ′ = “On input w , 1 Compute f ( w ) 2 Run M on f ( w ) ; if M accepts, then accept ; otherwise reject ” Computing f ( w ) takes time poly (∣ w ∣) and ∣ f ( w )∣ = poly (∣ w ∣) Running M on f ( w ) takes time poly (∣ f ( w )∣) = poly ( poly (∣ w ∣)) = poly (∣ w ∣) Thus, M ′ decides A in polynomial time so A ∈ P 3 / 30

  7. Another “good-news” reduction theorem Theorem If A ≤ p B and B ∈ P , then A ∈ P Similar proof to all of the others Proof. Let f be the poly-time reduction and let M decide B in poly time M ′ = “On input w , 1 Compute f ( w ) 2 Run M on f ( w ) ; if M accepts, then accept ; otherwise reject ” Computing f ( w ) takes time poly (∣ w ∣) and ∣ f ( w )∣ = poly (∣ w ∣) Running M on f ( w ) takes time poly (∣ f ( w )∣) = poly ( poly (∣ w ∣)) = poly (∣ w ∣) Thus, M ′ decides A in polynomial time so A ∈ P Replacing P with NP in the proof and using NTMs rather than TMs shows that A ≤ p B and B ∈ NP , then A ∈ NP 3 / 30

  8. CNF-SAT ≤ p 3-SAT CNF-SAT = {⟨ φ ⟩ ∣ φ is in CNF } 3-SAT = {⟨ φ ⟩ ∣ φ is in 3-CNF } Show that CNF-SAT ≤ p 3-SAT To do this, we need to give a poly-time algorithm that converts φ in CNF to φ ′ in CNF where each clause has exactly 3 literals φ = C 1 ∧ C 2 ∧ ⋯ ∧ C n where each C i is a disjunction (OR) of literals We just need a procedure to convert a clause C = ( u 1 ∨ u 2 ∨ ⋯ ∨ u k ) to 3-CNF 4 / 30

  9. Converting a clause to 3-CNF Four cases 1 C = u : Output u 1 ∨ u 1 ∨ u 1 5 / 30

  10. Converting a clause to 3-CNF Four cases 1 C = u : Output u 1 ∨ u 1 ∨ u 1 2 C = u 1 ∨ u 2 : Output u 1 ∨ u 2 ∨ u 2 5 / 30

  11. Converting a clause to 3-CNF Four cases 1 C = u : Output u 1 ∨ u 1 ∨ u 1 2 C = u 1 ∨ u 2 : Output u 1 ∨ u 2 ∨ u 2 3 C = u 1 ∨ u 2 ∨ u 3 : Output C 5 / 30

  12. Converting a clause to 3-CNF Four cases 1 C = u : Output u 1 ∨ u 1 ∨ u 1 2 C = u 1 ∨ u 2 : Output u 1 ∨ u 2 ∨ u 2 3 C = u 1 ∨ u 2 ∨ u 3 : Output C 4 C = u 1 ∨ u 2 ∨ ⋯ ∨ u k : Introduce k − 3 new variables z 2 , z 3 , ⋯ z k − 2 and output ( u 1 ∨ u 2 ∨ z 2 ) ∧ ( k − 2 ( z i − 1 ∨ u i ∨ z i )) ∧ ( z k − 2 ∨ u k − 1 ∨ u k ) ⋀ i = 3 For example, ( a ∨ b ∨ c ∨ d ∨ e ) ↦ ( a ∨ b ∨ z 2 ) ∧ ( z 2 ∨ c ∨ z 3 ) ∧ ( z 3 ∨ d ∨ e ) 5 / 30

  13. Converting a clause to 3-CNF Four cases 1 C = u : Output u 1 ∨ u 1 ∨ u 1 2 C = u 1 ∨ u 2 : Output u 1 ∨ u 2 ∨ u 2 3 C = u 1 ∨ u 2 ∨ u 3 : Output C 4 C = u 1 ∨ u 2 ∨ ⋯ ∨ u k : Introduce k − 3 new variables z 2 , z 3 , ⋯ z k − 2 and output ( u 1 ∨ u 2 ∨ z 2 ) ∧ ( k − 2 ( z i − 1 ∨ u i ∨ z i )) ∧ ( z k − 2 ∨ u k − 1 ∨ u k ) ⋀ i = 3 For example, ( a ∨ b ∨ c ∨ d ∨ e ) ↦ ( a ∨ b ∨ z 2 ) ∧ ( z 2 ∨ c ∨ z 3 ) ∧ ( z 3 ∨ d ∨ e ) Cases 1–3 clearly preserve the property that any assignment that makes C true makes the output true and vice versa 5 / 30

  14. Correctness of case 4 4 C = u 1 ∨ u 2 ∨ ⋯ ∨ u k : Introduce k − 3 new variables z 2 , z 3 , ⋯ z k − 2 and output φ ′ = ( u 1 ∨ u 2 ∨ z 2 ) ∧ ( k − 2 ( z i − 1 ∨ u i ∨ z i )) ∧ ( z k − 2 ∨ u k − 1 ∨ u k ) ⋀ i = 3 If C = T , then there is some true literal, say u i = T , then φ ′ = T by setting z j = { T for j < i F for j ≥ i Even if all of the other literals are false, setting z j this way satisfies each clause in φ ′ 6 / 30

  15. Correctness of case 4 4 C = u 1 ∨ u 2 ∨ ⋯ ∨ u k : Introduce k − 3 new variables z 2 , z 3 , ⋯ z k − 2 and output φ ′ = ( u 1 ∨ u 2 ∨ z 2 ) ∧ ( k − 2 ( z i − 1 ∨ u i ∨ z i )) ∧ ( z k − 2 ∨ u k − 1 ∨ u k ) ⋀ i = 3 If C = T , then there is some true literal, say u i = T , then φ ′ = T by setting z j = { T for j < i F for j ≥ i Even if all of the other literals are false, setting z j this way satisfies each clause in φ ′ If u 1 = u 2 = ⋯ = u k = F , then no matter how we set the z j , at least one of the clauses in φ ′ is false: • For ( u 1 ∨ u 2 ∨ z 2 ) = T , we’d need z 2 = T 6 / 30

  16. Correctness of case 4 4 C = u 1 ∨ u 2 ∨ ⋯ ∨ u k : Introduce k − 3 new variables z 2 , z 3 , ⋯ z k − 2 and output φ ′ = ( u 1 ∨ u 2 ∨ z 2 ) ∧ ( k − 2 ( z i − 1 ∨ u i ∨ z i )) ∧ ( z k − 2 ∨ u k − 1 ∨ u k ) ⋀ i = 3 If C = T , then there is some true literal, say u i = T , then φ ′ = T by setting z j = { T for j < i F for j ≥ i Even if all of the other literals are false, setting z j this way satisfies each clause in φ ′ If u 1 = u 2 = ⋯ = u k = F , then no matter how we set the z j , at least one of the clauses in φ ′ is false: • For ( u 1 ∨ u 2 ∨ z 2 ) = T , we’d need z 2 = T • For ( z 2 ∨ u 3 ∨ z 3 ) = T , we’d need z 3 = T and so on; thus z j = T for all 2 ≤ j ≤ k − 2 6 / 30

  17. Correctness of case 4 4 C = u 1 ∨ u 2 ∨ ⋯ ∨ u k : Introduce k − 3 new variables z 2 , z 3 , ⋯ z k − 2 and output φ ′ = ( u 1 ∨ u 2 ∨ z 2 ) ∧ ( k − 2 ( z i − 1 ∨ u i ∨ z i )) ∧ ( z k − 2 ∨ u k − 1 ∨ u k ) ⋀ i = 3 If C = T , then there is some true literal, say u i = T , then φ ′ = T by setting z j = { T for j < i F for j ≥ i Even if all of the other literals are false, setting z j this way satisfies each clause in φ ′ If u 1 = u 2 = ⋯ = u k = F , then no matter how we set the z j , at least one of the clauses in φ ′ is false: • For ( u 1 ∨ u 2 ∨ z 2 ) = T , we’d need z 2 = T • For ( z 2 ∨ u 3 ∨ z 3 ) = T , we’d need z 3 = T and so on; thus z j = T for all 2 ≤ j ≤ k − 2 • But then ( z k − 2 ∨ u k − 1 ∨ u k ) = F 6 / 30

  18. Proof that CNF-SAT ≤ p 3-SAT Proof. Define TM T = “On input ⟨ φ ⟩ , 1 For each clause C in φ , Convert C to 3-CNF using the given algorithm 2 3 Output the conjunction (AND) of the result for each clause” 7 / 30

  19. Proof that CNF-SAT ≤ p 3-SAT Proof. Define TM T = “On input ⟨ φ ⟩ , 1 For each clause C in φ , Convert C to 3-CNF using the given algorithm 2 3 Output the conjunction (AND) of the result for each clause” If ⟨ φ ⟩ ∈ CNF-SAT , then there is some assignment of truth values to variables that makes φ = T . By setting the extra variables from the algorithm appropriately, the output is satisfiable so f (⟨ φ ⟩) ∈ 3-SAT 7 / 30

  20. Proof that CNF-SAT ≤ p 3-SAT Proof. Define TM T = “On input ⟨ φ ⟩ , 1 For each clause C in φ , Convert C to 3-CNF using the given algorithm 2 3 Output the conjunction (AND) of the result for each clause” If ⟨ φ ⟩ ∈ CNF-SAT , then there is some assignment of truth values to variables that makes φ = T . By setting the extra variables from the algorithm appropriately, the output is satisfiable so f (⟨ φ ⟩) ∈ 3-SAT If ⟨ φ ⟩ ∉ CNF-SAT , then for any assignment, some clause in φ is false and by construction, no matter how the extra variables are set for the corresponding output clauses, one of them is false so f (⟨ φ ⟩) ∉ 3-SAT 7 / 30

  21. Proof that CNF-SAT ≤ p 3-SAT Proof. Define TM T = “On input ⟨ φ ⟩ , 1 For each clause C in φ , Convert C to 3-CNF using the given algorithm 2 3 Output the conjunction (AND) of the result for each clause” If ⟨ φ ⟩ ∈ CNF-SAT , then there is some assignment of truth values to variables that makes φ = T . By setting the extra variables from the algorithm appropriately, the output is satisfiable so f (⟨ φ ⟩) ∈ 3-SAT If ⟨ φ ⟩ ∉ CNF-SAT , then for any assignment, some clause in φ is false and by construction, no matter how the extra variables are set for the corresponding output clauses, one of them is false so f (⟨ φ ⟩) ∉ 3-SAT If φ has n total literals, then the output of T has less than 3 n clauses each of which has 3 literals so ∣ f (⟨ φ ⟩)∣ = poly (∣⟨ φ ⟩∣) thus T takes polynomial time 7 / 30

  22. NP -hard and NP -complete Language B is NP -hard if every language A ∈ NP is poly-time reducible to B ( ∀ A ∈ NP . A ≤ p B ) 8 / 30

Recommend


More recommend