1 / 113

Chapter 3: Proving NP-completeness Results

Chapter 3: Proving NP-completeness Results. Six Basic NP-Complete Problems Some Techniques for Proving NP-Completeness Some Suggested Exercises. Six Basic NP-Complete Problems. 3-SATISFIABILITY (3SAT) 3-DIMENSIONAL MATCHING (3DM) VERTEX COVER (VC) CLIQUE HAMILTONIAN CIRCUIT (HC)

paulhart
Download Presentation

Chapter 3: Proving NP-completeness Results

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. Chapter 3: Proving NP-completenessResults • Six Basic NP-Complete Problems • Some Techniques for Proving NP-Completeness • Some Suggested Exercises

  2. Six Basic NP-Complete Problems • 3-SATISFIABILITY (3SAT) • 3-DIMENSIONAL MATCHING (3DM) • VERTEX COVER (VC) • CLIQUE • HAMILTONIAN CIRCUIT (HC) • PARTITION First, a tour…

  3. 3-Satisfiability 3-SATISFIABILITY (3-SAT) INSTANCE: Collection C = {c1, c2,…,cm} of clauses on a finite set U of variables such that {cj} = 3, for 1 ≤ j ≤ m. QUESTION: Is there a truth assignment for U that satisfies all the clauses in C?

  4. 3-Dimensional Matching 3-DIMENSIONAL MATCHING (3-DM) INSTANCE: A set M  W  X  Y, where W, X and Y are disjoint sets having the same number q of elements. QUESTION: Does M contain a matching, that is, a subset M’  M such at |M’| = q and no two elements of M’ agree in any coordinate? Example #1: q = 3 (not part of input technically) W = {a1, a2, a3} X = {b1, b2, b3} Y = {c1, c2, c3} M = { (a1, b2, c1), (a2, b1, c3), (a3, b3, c2), (a1, b1, c3), (a2, b2, c1) } Yes! The first 3 form a matching. Note that every element in each set will appear in exactly one triple in M’.

  5. 3-Dimensional Matching Example #2: q = 3 (not part of input technically) W = {a1, a2, a3} X = {b1, b2, b3} Y = {c1, c2, c3} M = { (a1, b1, c1), (a1, b1, c2), (a2, b1, c3), (a3, b1, c1) } No! In fact b2 and b3 do not appear in any triple.

  6. Vertex Cover, Independent Setand Clique VERTEX COVER (VC) INSTANCE: A Graph G = (V, E) and a positive integer K <= |V|. QUESTION: Is there a vertex cover of size K or less for G, that is, a subset V’  V such that |V’| <= K and, for each edge {u,v}  E, at least one of u and v belongs to V’? K = 3 u v w x z

  7. Vertex Cover, Independent Setand Clique CLIQUE INSTANCE: A Graph G = (V, E) and a positive integer J <= |V|. QUESTION: Does G contain a clique of size J or more? J = 3 u v w x z

  8. Hamiltonian Circuit (HS) HAMILTONIAN CIRCUIT (HC) INSTANCE: A Graph G = (V, E). QUESTION: Does G have a Hamiltonian circuit, that is an ordering < v1, v2,…,vn > of the vertices of G, where n = |V|, such that {vn, v1}  E and {vi, vi+1}  E for all i, 1 ≤ i  n. How is a Hamiltonian circuit different from a tour, as in TSP? TRAVELING SALESMAN INSTANCE: Set C of m cities, distance d(ci, cj)  Z+ for each pair of cities ci, cj C positive integer B. QUESTION: Is there a tour of C having length B or less, I.e., a permutation <c(1) , c(2),…, c(m)> of C such that:

  9. 3-Satisfiability • A restricted version of satisfiability in which all instances have exactly 3 literals per clause. 3-SATISFIABILITY (3-SAT) INSTANCE: Collection C = {c1, c2,…,cm} of clauses on a finite set U of variables such that {cj} = 3, for 1 ≤ j ≤ m. QUESTION: Is there a truth assignment for U that satisfies all the clauses in C? • Contrasted with the more general SAT: SATISFIABILITY (SAT) INSTANCE: Collection C of clauses on a finite set U of variables. QUESTION: Is there a truth assignment for U that satisfies all the clauses in C?

  10. A I’ = U’,C’ 3-SAT instance I = U,C SAT instance 3-Satisfiability Theorem 3.1: 3-SAT is NP-Complete. • 3-SAT  NP • SAT  3-SAT I is satisfiable iff I’ is

  11. 3-Satisfiability • Each clause cj in I => a set Cj’ of clauses with new variables Uj’ • Let cj = {z1, z2,…,zk} where zi’s are literals derived from variables in U • Case 1) k=1 cj = {z1} Uj’ = {yj1, yj2} Cj’ = { {z1, yj1, yj2}, {z1, yj1, yj2}, {z1, yj1, yj2}, {z1, yj1, yj2} } • Case 2) k=2 cj = {z1, z2} Uj’ = {yj1} Cj’ = { {z1, z2, yj1}, {z1, z2, yj1} }

  12. 3-Satisfiability • Case 3) k=3 cj = {z1, z2, z3} Uj’ = {} Cj’ = { {z1, z2, z3} } • Case 4) k>=4 cj = {z1, z2,…,zk} Uj’ = {yji | 1 ≤ i ≤ k-3} Cj’ = { {z1, z2, yj1} } U {yji, zi+2, yji+1 } | 1 ≤ i ≤ k-4} U {yjk-3, zk-1, zk } } Example: cj = {z1, z2, z3, z4, z5, z6} Uj’ = { {z1, z2, a}, {a, z3, b}, {b, z4, c}, {c, z5, z6} }

  13. 3-Satisfiability • Finally, let: U’ = U  { Uj’ | 1 ≤ j ≤ m } C’ = { Cj’ | 1 ≤ j ≤ m } • Claim: 1) I = U,C is satisfiable iff I’ = U’,C’ is satisfiable. 2) I’ can be computed in polynomial time.

  14. Six Basic NP-Complete Problems • A review of basic logic…and language… A if and only if B • Equates to: A if B The “if” part A only if B The “only if” part • Similarly: A if B ≈ B only if A ≈ B => A A only if B ≈ B if A ≈ A => B

  15. Six Basic NP-Complete Problems • Lastly, to prove: X => Y • We frequently show: ~Y => ~X

  16. 3-Satisfiability • So lets go back to the basic claim: 1) I = U,C is satisfiable iff I’ = U’,C’ is satisfiable. a) (if) I = U,C is satisfiable if I’ = U’,C’ is… b) (only if) I = U,C is satisfiable only if I’ = U’,C’ is…

  17. 3-Satisfiability 2) I’ can be computed in polynomial time: Let m = |C|, n = |U| case 1) creates 4 clauses case 2) creates 2 clauses case 3) creates 1 clause case 4) creates k-1 clauses, where k is the number of literals in the clause This gives a total of at most k-1 new clauses in I’ for each clause in I Therefore, there is a total of m*(k-1) clauses in I’ Since k<=2n, it follows that there are at most 2nm clauses in I’, which is O(mn)

  18. 3-Satisfiability • 3-SAT is an example of what is called a “special case” of SAT. • Some special cases, like 3-SAT, are NP-complete • Others are solvable in polynomial time (chapter 4) • How about 4-SAT? • 5-SAT? • N-SAT, for any fixed N>=3? • 1-SAT? • 2-SAT?

  19. Some More New Problems Not All Equal (NAE) 3-SAT INSTANCE: Collection C = {c1, c2,…,cm} of clauses on a finite set U of variables such that {cj} = 3, for 1 ≤ j ≤ m. QUESTION: Is there a truth assignment for U such that each clause in C has at least one true literal and at least one false literal? Fact: NAE 3-SAT is NP-complete

  20. Some More New Problems • Examples: { (a, b, c), (a, b, c), (a, b, c) } a = T, b = T, c = F { (a, b, c), (a, b, c), (a, b, c), Not even satistfiable (a, b, c), (a, b, c), (a, b, c) (a, b, c), (a, b, c) } { (a, b, c), (a, b, c), (a, b, c), Satistfiable, but not with (a, b, c), (a, b, c), (a, b, c) at least one literal true and false (a, b, c) } per clause

  21. More Problems, cont. Hypergraph 2-Colorability (H2C) INSTANCE: Hypergraph H = (V, E), where 2 ≤ |ei| ≤ 3, for all ei E. QUESTION: Is H 2-colorable? In other words, is there a function f : V  {0, 1} such that for all ei E there exist vertices u,v  ei such that f(u)  f(v)? Examples: No Yes No 0 1 1 0 0 0

  22. A I = U,C NAE3SAT instance H = (V, E) H2C instance H2C is NP-Complete Theorem: H2C is NP-complete H2C  NP Not All Equal 3-SAT  H2C

  23. H2C is NP-Complete, cont. • Suppose I = U,C where U = {u0, u1,…,un-1} and C = {c0, c1,…,cm-1} • Construct H = (V, E) where: V = { vi1 | ui U}  {vi2 | ui U} vi1 corresponds to ui vi2 corresponds to the complement of ui E = E1 E2 where E1 = { (v1, v2, v3) | ci C, ci = (z1, z2, z3) and v1, v2, v3 are the vertices corresponding to the literals z1, z2 and z3, respectively} E2 = { (vi1, vi2) | 0 ≤i≤ n-1}

  24. H2C is NP-Complete, cont. • Example: U = {u0, u1, u2, u3} C = { (u0, u1, u2), (u0,u2, u3), (u1, u2,u3) } • The resulting hyper-graph is 2-colorable IFF there is a NAE satisfying truth assignment for the Boolean expression. • (if) Suppose there is a NAE assignment, then there is a 2-coloring. • (only if) Suppose there is a 2-coloring, then there is a NAE satisfying assignment. 1 0 v0 1 1 0 v0 v2 v1 v3 1 v2 0 0 v1 v3

  25. 3-Dimensional Matching 3-DIMENSIONAL MATCHING (3-DM) INSTANCE: A set M  W  X  Y, where W, X and Y are disjoint sets having the same number q of elements. QUESTION: Does M contain a matching, that is, a subset M’  M such at |M’| = q and no two elements of M’ agree in any coordinate? Example #1: q = 3 (not part of input technically) W = {a1, a2, a3} X = {b1, b2, b3} Y = {c1, c2, c3} M = { (a1, b2, c1), (a2, b1, c3), (a3, b3, c2), (a1, b1, c3), (a2, b2, c1) } Yes! The first 3 form a matching. Note that every element in each set will appear in exactly one triple in M’.

  26. 3-Dimensional Matching Example #2: q = 3 (not part of input technically) W = {a1, a2, a3} X = {b1, b2, b3} Y = {c1, c2, c3} M = { (a1, b1, c1), (a1, b1, c2), (a2, b1, c3), (a3, b1, c1) } No! In fact b2 and b3 do not appear in any triple.

  27. A I’ = W,X,Y,M 3DM instance I = U,C 3-SAT instance 3-Dimensional Matching Theorem: 3DM is NP-complete. Proof: • 3DM  NP • 3-SAT  3DM

  28. 3-Dimensional Matching • Suppose I = U,C where: U = {u1, u2,…,un} C = {c1, c2,…,cm} • Construct M as follows. • M will consists of three types of “components:” • Truth Setting and fan-out • Satisfaction testing • Garbage collection

  29. 3-Dimensional Matching • Suppose I = U,C where: U = {u1, u2,…,un} C = {c1, c2,…,cm} • Construct M as follows. • M will consists of three types of “components:” • Truth Setting and fan-out • Satisfaction testing • Garbage collection

  30. Truth Setting and Fan Out Components • For each variable ui U, create the following (TS&FO) elements: Tit = { (ui[j], ai[j], bi[j]) | 1 ≤ j ≤ m } U Tif = { (ui[j], ai[j+1], bi[j]) | 1 ≤ j ≤ m-1 } U { (ui[m], ai[1], bi[m]) } a big “blob” for each Boolean variable (suppose m=4):

  31. Truth Setting and Fan Out Components • Observation #1: Creates 2mn elements in W, mn in X and mn in Y. • ui[j] represents the fact that variable ui could occur in clause cj. • Similarly for ui[j] • Observation #2: ai[j] and bi[j] both occur in exactly two triples and nowhere else. • Observation #3: This tells us that in any matching M’  M we must have all white or all shaded triples, in other words, all triples from Tit or all triples from Tif • This corresponds to setting the variable false or true, respectively.

  32. Satisfaction Testing Components • For each clause cj C, create (ST) triples: Cj = { (ui[j], s1[j], s2[j]) | ui cj} U { (ui[j], s1[j], s2[j]) | ui cj } • Observation #4: This adds m elements to X, and m elements to Y. • Observation #5: For each j, 1 ≤ j ≤ m, s1[j] and s2[j] both appear in exactly three triples and nowhere else. • Observation #6: Any matching must choose exactly one triple from Cj • This corresponds to making that literal true, thereby satisfying the clause. • This gives a total of m triples selected from the ST triples. • Observation #7: Any matching will contain exactlyone triple from Cjif and only if there is a satisfying truth assignment for the 3-SAT instance.

  33. Garbage Collection Components • For each clause cj C, create 2mn(n-1) (GC) triples: G = { (ui[j], g1[k], g2[k]), (ui[j], g1[k], g2[k]) | 1 ≤ k ≤ m(n-1), 1 ≤ i ≤ n, 1 ≤ j ≤ m} • Observation #8: This adds m(n-1) elements to X, and to Y. • Observation #9: For each k, 1 ≤ k ≤ m(n-1), g1[k] and g2[k] both appear in exactly 2mn triples and nowhere else. • Observation #10: Consequently, exactly m(n-1) triples from G must occur in any matching for M. • Observation #11: |W| = |X| = |Y| = 2mn = q.

  34. Garbage Collection Components • The resulting instance I’ of 3DM has a matching IFF the 3-SAT instance I is satisfiable. • (if) Suppose you have a satisfying truth assignment for I. How do you construct the matching? • (only if) Suppose you have a matching. What is the satisfying truth assignment?

  35. Vertex Cover, Independent Setand Clique VERTEX COVER (VC) INSTANCE: A Graph G = (V, E) and a positive integer K <= |V|. QUESTION: Is there a vertex cover of size K or less for G, that is, a subset V’  V such that |V’| <= K and, for each edge {u,v}  E, at least one of u and v belongs to V’? K = 3 u v w x z

  36. Vertex Cover, Independent Setand Clique INDEPENDENT SET (IS) INSTANCE: Graph G = (V, E) and positive integer J <= |V|. QUESTION: Does G contain an independent set of size J or more? J = 2 u v w x z

  37. Vertex Cover, Independent Setand Clique CLIQUE INSTANCE: A Graph G = (V, E) and a positive integer J <= |V|. QUESTION: Does G contain a clique of size J or more? J = 3 u v w x z

  38. Vertex Cover, Independent Setand Clique Lemma 3.1: For any graph G=(V,E) and subset V’  V, the following statements are equivalent: (a) V’ is a vertex cover for G (b) V-V’ is an independent set for G (c) V-V’ is a clique in the complement Gc of G, where Gc=(V,Ec) with Ec={{u,v} | u,v  V and {u,v}  E} u u u v v v w w w x x x z z z

  39. Vertex Cover, Independent Setand Clique Lemma 3.1: For any graph G=(V,E) and subset V’  V, the following statements are equivalent: (a) V’ is a vertex cover for G (b) V-V’ is an independent set for G (c) V-V’ is a clique in the complement Gc of G, where Gc=(V,Ec) with Ec={{u,v} | u,v  V and {u,v}  E} u u u v v v w w w x x x z z z

  40. Vertex Cover Theorem: VERTEX COVER is NP-complete Proof: • VC  NP • 3SAT  VC Suppose I = U,C is an instance of 3SAT where: U = {u1, u2,…,un} C = {c1, c2,…,cm} We will construct a graph G=(V,E) and a positive integer K<=|V| such that G has a vertex cover of size K or less if and only if C is satistfiable.

  41. Vertex Cover For each variable ui U, there is a “truth-setting component” Ti=(Vi,Ei) where: Vi = {ui, ui} and Ei = {{ui,ui}} *Note that any vertex cover will have to contain at least one of ui and its complement. For each clause cj C, create a “satisfaction testing component” Sj = (Vj’, Ej’): Vj’= { a1[j], a2[j], a3[j] } Ej’ = { {a1[j], a2[j]}, {a1[j], a3[j]}, {a2[j], a3[j]} } *Note that any vertex cover will have to contain at least two vertices from Vj’ in order to cover the edges in Ej’.

  42. Vertex Cover For each clause cj C, let the three literals in cj be xj, yj, zj. Then add “communication edges:” Ej’’ = { {a1[j], xj}, {a2[j], yj}, {a3[j], zj} } Finally, let K = n + 2m.

  43. Vertex Cover Example: U = {u1, u2,u3, u4} C = { (u1, u3, u4), (u1, u2, u4) } K = n + 2m = 8

  44. Vertex Cover Observations: • The transformation can be performed in polynomial-time. • G = (V, E) will have a vertex cover of size K or less IFF I = U,C is satisfiable. (if) Suppose I = U,C is satisfiable… (only if) Suppose G = (V, E) has a vertex cover of size K or less…

  45. Vertex Cover, Independent Setand Clique • Recall Lemma 3.1: Lemma 3.1: For any graph G=(V,E) and subset V’  V, the following statements are equivalent: (a) V’ is a vertex cover for G (b) V-V’ is an independent set for G (c) V-V’ is a clique in the complement Gc of G, where Gc=(V,Ec) with Ec={{u,v} | u,v V and {u,v}  E} • What does the previous result say about the independent set and clique problems?

  46. Homework Problems INDEPENDENT SET (IS) INSTANCE: Graph G = (V, E) and positive integer J <= |V|. QUESTION: Does G contain an independent set of size J or more? Prove IS NP-complete by giving a transformation from 3DM. 4-DIMENSIONAL MATCHING (4-DM) INSTANCE: A set M  W  X Y Z , where W, X, Yand Zare disjoint sets having the same number q of elements. QUESTION: Does M contain a matching, that is, a subset M’  M such at |M’| = q and no two elements of M’ agree in any coordinate? Prove 4-DM NP-complete by giving a transformation from 3DM.

  47. Hamiltonian Circuit (HS) HAMILTONIAN CIRCUIT (HC) INSTANCE: A Graph G = (V, E). QUESTION: Does G have a Hamiltonian circuit, that is an ordering < v1, v2,…,vn > of the vertices of G, where n = |V|, such that {vn, v1}  E and {vi, vi+1}  E for all i, 1 ≤ i  n. How is a Hamiltonian circuit different from a tour, as in TSP?

  48. Hamiltonian Circuit (HS) HAMILTONIAN CIRCUIT (HC) INSTANCE: A Graph G = (V, E). QUESTION: Does G have a Hamiltonian circuit, that is an ordering < v1, v2,…,vn > of the vertices of G, where n = |V|, such that {vn, v1}  E and {vi, vi+1}  E for all i, 1 ≤ i  n. VERTEX COVER (VC) INSTANCE: A Graph G = (V, E) and a positive integer K <= |V|. QUESTION: Is there a vertex cover of size K or less for G, that is, a subset V’  V such that |V’| <= K and, for each edge {u,v}  E, at least one of u and v belongs to V’?

  49. Hamiltonian Circuit (HC) Theorem: HC is NP-complete Proof: • HC  NP • VC  HC Let G = (V,E) and K <= |V| be an instance of VC. We will construct a graph G’ = (V’,E’) such that G has a vertex cover of size K or less if and only if G’ has a Hamiltonian circuit.

  50. Hamiltonian Circuit (HC) 1) Add “selector” vertices a1, a2,…,akto V’ 2) For each edge e = {u,v} in E, construct the following “cover testing” component: this side this side corresponds to u corresponds to v More specifically, add the following 12 vertices: Ve’ = {(u,e,i), (v,e,i) : 1<=i<=6}} And 14 edges: Ee’ = {{(u,e,i), (u,e,i+1)}, {(v,e,i), (v,e,i+1)} : 1<=i<=5 } ∪ {{(u,e,3), (v,e,1)}, {(v,e,3), (u,e,1)}} ∪ {{(u,e,6), (v,e,4)}, {(v,e,6), (u,e,4)}}

More Related