np completeness
play

NP-completeness CSCI 3130 Formal Languages and Automata Theory Siu - PowerPoint PPT Presentation

NP-completeness CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Fall 2018 Chinese University of Hong Kong 1/30 Polynomial-time reductions What we say Independent-Set is at least as hard as Clique What does that mean? We


  1. NP-completeness CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Fall 2018 Chinese University of Hong Kong 1/30

  2. Polynomial-time reductions What we say “Independent-Set is at least as hard as Clique” What does that mean? We mean If Clique cannot be decided by a polynomial-time Turing machine, then neither does Independent-Set If Independent-Set can be decided by a polynomial-time Turing machine, then so does Clique Similar to the reductions we saw in the past 4-5 lectures, but with the additional restriction of polynomial-time 2/30

  3. Polynomial-time reductions Theorem If Independent-Set has a polynomial-time Turing machine, so does Clique 3/30 Clique = {� G , k � | G is a graph having a clique of k vertices } Independent-Set = {� G , k � | G is a graph having an independent set of k vertices }

  4. Polynomial-time reductions If Independent-Set has a polynomial-time Turing machine, so does Clique Proof Suppose Independent-Set is decided by a poly-time TM A We want to build a TM S that uses A to solve Clique R A accept if G has a clique of size k reject otherwise S 4/30 � G ′ , k ′ � � G , k �

  5. Reducing Clique to Independent-Set fmip all edges clique of size k Graph G 4 3 2 1 We look for a polynomial-time Turing machine R that turns the 5/30 4 3 2 1 into “Does G have a clique of size k ?” question “Does G ′ have an independent set (IS) of size k ′ ?” �− → Graph G ′ k = k ′ ← → IS of size k ′

  6. Reducing Clique to Independent-Set R • If G does not have a clique of size k • If G has a clique of size k Cliques in G 6/30 of G On input � G , k � Construct G ′ by fmipping all edges � G , k � � G ′ , k ′ � Set k ′ = k Output � G ′ , k ′ � ← → Independent sets in G ′ then G ′ has an independent set of size k then G ′ does not have an independent set of size k

  7. Reduction recap We showed that If Independent-Set is decidable by a polynomial-time Turing machine, so is Clique Clique Clique into ones of Independent-Set 7/30 by converting any Turing machine for Independent-Set into one for To do this, we came up with a reduction that transforms instances of

  8. Polynomial-time reductions IS G has a clique of size k R L 8/30 there exists a polynomial-time Turing machine R that takes an Clique Language L polynomial-time reduces to L ′ if instance x of L into an instance y of L ′ such that x ∈ L if and only if y ∈ L ′ L ′ x = � G , k � y = � G ′ , k ′ � x ∈ L y ∈ L ′ G ′ has an IS of size k

  9. The meaning of reductions Therefore R poly-time x accept reject y TM accepts 9/30 L reduces to L ′ means L is no harder than L ′ If we can solve L ′ , then we can also solve L If L polynomial-time reduces to L ′ and L ′ ∈ P, then L ∈ P TM for L ′ y ∈ L ′ x ∈ L

  10. Direction of reduction Pay attention to the direction of reduction “A is no harder than B” and “B is no harder than A” have completely different meanings For example, IS and Clique reduce to each other 10/30 It is possible that L reduces to L ′ and L ′ reduces to L That means L and L ′ are as hard as each other

  11. Boolean formula satisfjability A boolean formula is an expression made up of variables, ANDs, ORs, and negations, like Task: Assign TRUE/FALSE values to variables so that the formula e.g. Given a formula, decide whether such an assignment exist 11/30 ϕ = ( x 1 ∨ x 2 ) ∧ ( x 2 ∨ x 3 ∨ x 4 ) ∧ ( x 1 ) evaluates to true x 1 = F x 2 = F x 3 = T x 4 = T

  12. 3SAT AND of ORs of literals clause literal 3CNF: CNF with 3 literals per clause (repetitions allowed) Conjuctive Normal Form (CNF): literal: 12/30 SAT = {� ϕ � | ϕ is a satisfjable Boolean formula } 3SAT = {� ϕ � | ϕ is a satisfjable Boolean formula conjunctive normal form with 3 literals per clause } x i or x i ( x 1 ∨ x 2 ∨ x 2 ) ∧ ( x 2 ∨ x 3 ∨ x 4 ) ���� � �� �

  13. 3SAT is in NP FTTF evaluating the formula substitute possible assignments For n variables, there are 2 n TTTT TFTT FTTT TTTF TFTF FFTT FFTF FTFF Finding a solution: Try all possible assignments TTFT FFFF 13/30 TFFF TTFF FFFT FTFT TFFT ϕ = ( x 1 ∨ x 2 ) ∧ ( x 2 ∨ x 3 ∨ x 4 ) ∧ ( x 1 ) Verifying a solution: x 1 = F x 2 = F x 3 = T x 4 = T ϕ = ( F ∨ T ) ∧ ( F ∨ F ∨ T ) ∧ ( T ) can be done in linear time Takes exponential time

  14. Cook–Levin theorem must be the “hardest problem” NP in NP P But SAT itself is in NP, so SAT Every problem in NP is no harder than SAT 14/30 Every L ∈ NP polynomial-time reduces to SAT SAT = {� ϕ � | ϕ is a satisfjable Boolean formula } e.g. ϕ = ( x 1 ∨ x 2 ) ∧ ( x 2 ∨ x 3 ∨ x 4 ) ∧ ( x 1 ) • • SAT • • If SAT ∈ P, then P = NP • •

  15. NP-completeness A language L is NP-hard if: For every N in NP, N polynomial-time reduces to L A language L is NP-complete if L is in NP and L is NP-hard Cook–Levin theorem SAT is NP-complete P NP 15/30 • • L • • • •

  16. Our (conjectured) picture of NP NP-complete P NP In practice, most NP problems are either in P (easy) or NP-complete (probably hard) 16/30 • SAT • IS • Clique • • PATH • L 01 • A → B : A polynomial-time reduces to B

  17. Interpretation of Cook–Levin theorem Optimistic: If we manage to solve SAT, then we can also solve Clique and many other Pessimistic: algorithm for SAT 17/30 Since we believe P � = NP, it is unlikely that we will ever have a fast

  18. Ubiquity of NP-complete problems We saw a few examples of NP-complete problems, but there are many more Surprisingly, most computational problems are either in P or NP-complete By now thousands of problems have been identifjed as NP-complete 18/30

  19. Reducing IS to VC Independent sets: vertex covers: 4 3 2 1 R 19/30 Example G has an IS of size k � G , k � � G ′ , k ′ � ← → G ′ has a VC of size k ′ ∅ , { 1 } , { 2 } , { 3 } , { 4 } , { 2 , 4 } , { 3 , 4 } , { 1 , 2 } , { 1 , 3 } { 1 , 2 , 3 } , { 1 , 2 , 4 } , { 1 , 3 , 4 } , { 2 , 3 , 4 } , { 1 , 2 , 3 , 4 }

  20. Reducing IS to VC Proof: VC Claim S is a vertex cover no edge has both endpoints in S S is an independent set IS 4 1 3 S is an independent set if and 20/30 2 only if S is a vertex cover ∅ { 1 , 2 , 3 , 4 } { 1 } { 2 , 3 , 4 } � { 2 } { 1 , 3 , 4 } { 3 } { 1 , 2 , 4 } � { 4 } { 1 , 2 , 3 } every edge has an endpoint in S { 1 , 2 } { 3 , 4 } � { 1 , 3 } { 2 , 4 }

  21. Reducing IS to VC G has an IS of size k Overall sequence of reductions: R 21/30 � G , k � � G ′ , k ′ � R : On input � G , k � Output � G , n − k � ← → G has a VC of size n − k ✓ ✓ SAT → 3SAT → Clique → IS → VC

  22. Reducing 3SAT to Clique R G has a clique of size k 22/30 3SAT = { ϕ | ϕ is a satisfjable Boolean formula in 3CNF } Clique = {� G , k � | G is a graph having a clique of k vertices } � G , k � 3CNF formula ϕ ← → ϕ is satisfjable

  23. Reducing 3SAT to Clique Example: x 1 x 1 x 2 x 1 x 2 x 2 x 1 x 2 x 3 One vertex for each literal occurrence One edge for each consistent pair (non-opposite literals) 23/30 ϕ = ( x 1 ∨ x 1 ∨ x 2 ) ∧ ( x 1 ∨ x 2 ∨ x 2 ) ∧ ( x 1 ∨ x 2 ∨ x 3 )

  24. Reducing 3SAT to Clique R Construct the following graph G : G has 3 m vertices, divided into m groups If vertices u and v are in different groups and consistent 24/30 � G , k � 3CNF formula ϕ R : On input ϕ , where ϕ is a 3CNF formula with m clauses One for each literal occurrence in ϕ Add an edge ( u , v ) Output � G , m �

  25. Reducing 3SAT to Clique x 2 T x 3 x 2 R x 2 x 2 x 1 x 1 x 1 x 1 25/30 G has a clique of size m � G , k � 3CNF formula ϕ ← → ϕ is satisfjable T ∨ x 1 T ∨ x 2 F ) ∧ ( x 1 F ∨ x 2 T ∨ x 2 T ) ∧ ( x 1 F ∨ x 2 F ∨ x 3 ϕ = ( x 1 )

  26. Reducing 3SAT to Clique: Summary R Conversely, every clique of size m in G gives a satisfying assignment Overall sequence of reductions: 26/30 � G , k � 3CNF formula ϕ Every satisfying assignment of ϕ gives a clique of size m in G of ϕ ✓ ✓ ✓ SAT → 3SAT → Clique → IS → VC

  27. SAT and 3SAT 27/30 SAT = { ϕ | ϕ is a satisfjable Boolean formula } e.g. (( x 1 ∨ x 2 ) ∧ ( x 1 ∨ x 2 )) ∨ (( x 1 ∨ ( x 2 ∧ x 3 )) ∧ x 3 ) 3SAT = { ϕ ′ | ϕ ′ is a satisfjable 3CNF formula in 3CNF } e.g. ( x 1 ∨ x 2 ∨ x 2 ) ∧ ( x 2 ∨ x 3 ∨ x 4 ) ∧ ( x 2 ∨ x 3 ∨ x 5 )

  28. Reducing SAT to 3SAT F F F T T T F F T F T F T F F T F T T F F T F T F F T F T x 5 Clauses added: x 4 x 5 x 7 x 4 x 5 x 7 x 4 x 5 x 7 x 4 x 5 x 7 T T T x 4 Example: x 4 AND OR AND NOT x 2 x 3 x 6 x 8 NOT AND NOT x 1 OR x 7 x 5 x 7 x 9 x 1 x 2 x 10 each wire in the tree Add clauses to for each gate x 4 x 5 x 7 28/30 ϕ = ( x 2 ∨ ( x 1 ∧ x 2 )) ∧ ( x 1 ∧ ( x 1 ∨ x 2 )) x 1 x 2 Tree representation of ϕ Add extra variable to ϕ ′ for

  29. Reducing SAT to 3SAT T F F each wire in the tree x 4 x 5 x 7 T T T T T T F F T F T F T x 10 F T T F F T F T F F T F F F F T Clauses added: Example: 28/30 x 2 NOT AND OR AND NOT x 2 x 3 x 6 x 8 NOT AND x 1 x 4 OR x 5 x 7 x 9 x 1 ϕ = ( x 2 ∨ ( x 1 ∧ x 2 )) ∧ ( x 1 ∧ ( x 1 ∨ x 2 )) Add clauses to ϕ ′ for each gate x 7 = x 4 ∧ x 5 x 1 x 2 Tree representation of ϕ Add extra variable to ϕ ′ for ( x 4 ∨ x 5 ∨ x 7 ) ∧ ( x 4 ∨ x 5 ∨ x 7 ) ( x 4 ∨ x 5 ∨ x 7 ) ∧ ( x 4 ∨ x 5 ∨ x 7 )

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend