1 / 19

CSCI 3130: Formal languages and automata theory

Fall 2011. The Chinese University of Hong Kong. CSCI 3130: Formal languages and automata theory. More on NP-completeness. Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130. NP problems. 1. 1. 1. 2. 2. 2. 3. 3. 3. 4. 4. 4. clique. independent set. vertex cover.

dart
Download Presentation

CSCI 3130: Formal languages and automata theory

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fall 2011 The Chinese University of Hong Kong CSCI 3130: Formal languages and automata theory More on NP-completeness Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130

  2. NP problems 1 1 1 2 2 2 3 3 3 4 4 4 clique independent set vertex cover CLIQUE = {〈G, k〉: G is a graph with a clique of k vertices} IS = {〈G, k〉: G is a graph with an independent set of k vertices} VC = {〈G, k〉: G is a graph with a vertex cover of k vertices}

  3. SAT and 3SAT SAT = {〈f〉: fis a satisfiable Boolean formula} ((x1∨x2 ) ∧ (x1∨x2)) ∨ ((x1∨(x2 ∧ x3)) ∧x3) 3SAT = {〈f〉: fis a satisfiable 3CNF formula} (x1∨x2∨x2 ) ∧ (x2∨x3∨x4) ∧ (x2∨x3∨x5) ∧ (x1∨x5∨x5)

  4. P, NP, and reductions reduction from CLIQUE to IS IS reduces to VC CLIQUE 3SAT SAT (G, k) (G’, k’) G has a k-clique G’ has a k’-ind set P NP (easy to solve) (easy to verify solution)

  5. The plan for today Why? IS reduces to VC CLIQUE Because everything in NP reduces to SAT 3SAT SAT NP-complete (the Cook-Levin theorem) … so all these are NP-complete P NP (easy to solve) (easy to verify solution)

  6. Reducing IS to VC • Proof: We describe a reduction from IS to VC • Example 2 1 R (G, k) (G’, k’) 4 3 G has an IS of size k G’ has a VC of size k’ vertex covers independent sets {2, 4}, {3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 3, 4} ∅, {1}, {2}, {3}, {4}, {1, 2}, {1, 3}

  7. Reducing IS to VC • Claim • Proof 2 1 S is an independent set of G if and only if S is a vertex cover of G 4 3 VC IS ∅ {1} {2} {3} {4} {1, 2} {1, 3} {2, 4} {3, 4} {1, 2, 3} {1, 2, 4} {1, 3, 4} {2, 3, 4} {1, 2, 3, 4} S is an independent set of G no edge has both endpoints in S every edge has an endpoint in S S is a vertex cover of G

  8. Reducing IS to VC VC R (G, k) (G’, k’) ✓ IS ✓ CLIQUE R: On input (G, k), Output (G, n – k). 3SAT SAT G has an IS of size k G has a VC of size n – k

  9. Reducing 3SAT to CLIQUE • Proof: We give a reduction from 3SAT to CLIQUE 3SAT = {f: f is a satisfiable Boolean formula in 3CNF} CLIQUE = {(G, k): G is a graph with a clique of k vertices} R 3CNF formula f (G, k) G has a cliqueof size k f is satisfiable

  10. Reducing 3SAT to CLIQUE • Example: f = (x1∨x1∨x2 ) ∧ (x1∨x2∨x2) ∧ (x1∨x2∨x3) x1 x1 x1 x1 x2 x2 x2 x2 x3 Put a vertex for every literal Put an edge for every consistent pair

  11. Reducing 3SAT to CLIQUE R 3CNF formula f (G, k) R: On input f, where f is a 3CNF formula with m clauses Construct the following graph G: G has 3m vertices, divided into m groups, one for each literal in f If a and b are in different groups and a ≠ b, put an edge (a, b) Output(G, m)

  12. Reducing 3SAT to CLIQUE R 3CNF formula f (G, m) G has a cliqueof size m f is satisfiable x1 x1 x1 x1 x2 x2 x2 x2 x3 f =(x1∨x1∨x2 ) ∧ (x1∨x2∨x2) ∧ (x1∨x2∨x3) T T F F F T F F T

  13. Reducing 3SAT to CLIQUE R 3CNF formula f (G, m) G has a cliqueof size m f is satisfiable x1 x1 x1 x1 x2 x2 x2 x2 x3 f =(x1∨x1∨x2 ) ∧ (x1∨x2∨x2) ∧ (x1∨x2∨x3) F F T T F F T T T

  14. Reducing 3SAT to CLIQUE • Every satisfying assignment of f gives a clique of size m in G • Conversely, every clique of size m in Ggives a consistent satisfying assignment of f. R 3CNF formula f (G, m) f is satisfiable G has a clique of size m VC ✓ IS ✓ CLIQUE ✓ 3SAT SAT

  15. SAT and 3SAT SAT = {〈f〉: fis a satisfiable Boolean formula} ((x1∨x2 ) ∧ (x1∨x2)) ∨ ((x1∨(x2 ∧ x3)) ∧x3) 3SAT = {〈f〉: fis a satisfiable 3CNF formula} (x1∨x2∨x2 ) ∧ (x2∨x3∨x4) ∧ (x2∨x3∨x5) ∧ (x1∨x5∨x5)

  16. Reducing SAT to 3SAT • Example: f = (x2∨(x1∧x2 ))∧(x1∧(x1∨x2 )) x4x5 x7 x7 = x4 ∧ x5 x10 T T T TT T F FT F T FT F F TF T T FF T F TF F T FF F F T AND (x4∨x5∨x7) x8 x9 (x4∨x5∨x7) OR NOT x6 x7 (x4∨x5∨x7) AND AND (x4∨x5∨x7) x4 x5 x3 NOT NOT OR (x4∨x5∨x7) ∧(x4∨x5∨x7) x2 x1 x2 x1 x1 x2 ∧(x4∨x5∨x7) ∧(x4∨x5∨x7) We add extra variables for every “wire”

  17. Turning gates into 3CNFs z z z Gj: AND OR NOT x y x y x x y z = y ∧ x x y z = y ∨ x x z = x z z z T T T TT T F FT F T FT F F TF T T FF T F TF F T FF F F T T T T TT T F FT F T TT F F FF T T TF T F FF F T FF F F T T T FT F T F T TF F F (x∨z)∧(x∨z) (x∨y∨z)∧(x∨y∨z) ∧(x∨y∨z)∧(x∨y∨z) (x∨y∨z)∧(x∨y∨z) ∧(x∨y∨z)∧(x∨y∨z) fj: (x∨x∨z)∧(x∨x∨z)

  18. Reducing SAT to 3SAT R Boolean formula f 3CNF formula f’ R:= On input f, where f is a boolean formula Construct and output the following 3CNF formula f’: f’ has extra variables xn+1, ..., xn+t one for each gate Gj in f For each gate Gj, construct the formulafj Output f’ = fn+1 ∧ fn+2 ∧ ... ∧ ft ∧ (xn+t ∨xn+t ∨xn+t ) requires thatoutput of f is true

  19. Reducing SAT to 3SAT • Every satisfying assignment of fextends uniquely to a satisfying assignment of f’ • In the other direction, in every satisfying assignment of f’ the part x1, ..., xnis satisfies f R Boolean formula f 3CNF formula f’ ✔ f’ is satisfiable f is satisfiable

More Related