Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3: Proving NP-completeness Results

Similar presentations


Presentation on theme: "Chapter 3: Proving NP-completeness Results"— Presentation transcript:

1 Chapter 3: Proving NP-completeness Results
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 Set and 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 Set and 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: You would think TSP is harder than HC, but it is not; both are NP-complete.

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.

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

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: Claim: 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 1 1

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

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 v0 v0 v2 1 1 v3 v2 v1 v1 1 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 3-Dimensional Matching
Theorem: 3DM is NP-complete. Proof: 3DM  NP 3-SAT  3DM A I = U,C 3-SAT instance I’ = W,X,Y,M 3DM instance

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): There is 1 of these blobs per variable. The size of the blobs are all the same, and depend on the # of clauses. Note that the superscripts appear incorrect, but are not.

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 exactly one triple from Cj if 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 Set and 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 Set and 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 Set and 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 Set and 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 v w x z u v w x z u v w x z

39 Vertex Cover, Independent Set and 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 v w x z u v w x z u v w x 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 Set and 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, Y and Z 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? 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,…,ak to 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)}} Call each an edge “cluster.”

51 Hamiltonian Circuit (HC)
3) For each vertex v  V, let the edges incident on v be: ev[1], ev[2],…,ev[deg(v)] Add the following edges: Ev’ = { {(v,ev[i],6),(v,ev[i+1],1)} : 1<=i<deg(v) } This creates a path in G’ that “touches” the cover-testing components corresponding to the edges adjacent to v in G. This path corresponds to the vertex v from G. start Call this a vertex “path.” end

52 Hamiltonian Circuit (HC)
4) Finally, add edges to G’ that connect the first (si) and last (ei) vertices from each of these paths to every one of the selector vertices: E’’ = { {ai,(v,ev[1],1)}, {ai,(v,ev[deg(v)],6)} : 1<=i<=K, v  V } s1 a1 e1 a2 s2 e2 : : aK s|V| e|V|

53 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5

54 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 a1 a2 a3

55 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 e1 a1 e2 a2 e3 e4 a3 e5

56 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 e1 a1 v e2 a2 e3 e4 a3 e5

57 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 e1 u a1 v e2 a2 e3 e4 a3 e5

58 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 e1 u a1 v e2 a2 e3 x e4 a3 e5

59 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 e1 u a1 v w e2 a2 e3 x e4 a3 e5

60 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 e1 u a1 v w e2 a2 e3 x e4 a3 e5 z

61 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 e1 u a1 v w e2 a2 e3 x e4 a3 e5 z

62 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 e1 u a1 v w e2 a2 e3 x e4 a3 e5 z

63 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 e1 u a1 v w e2 a2 e3 x e4 a3 e5 z

64 Hamiltonian Circuit (HC)
A complete example – consider the following instance of vertex cover: K = 3 u v w x z e1 e2 e3 e4 e5 e1 u a1 v w e2 a2 e3 x e4 a3 G as a vertex cover of size 3 If and only if G’ has a Hamiltonian circuit e5 z

65 Hamiltonian Circuit (HC)
(only if) K = 3 u v w x z e1 e2 e3 e4 e5 e1 u a1 v w e2 a2 e3 x e4 a3 e5 z

66 Hamiltonian Circuit (HC)
(if) K = 3 u v w x z e1 e2 e3 e4 e5 e1 u a1 v w e2 a2 e3 x e4 a3 e5 z

67 Hamiltonian Path (HP) HAMILTONIAN PATH (HP)
INSTANCE: A Graph G = (V, E), and vertices u,v ∊ V. QUESTION: Is there a Hamiltonian in G from vertex u to vertex v, that is an ordering < v1, v2,…,vn > of the vertices of G, where n = |V|, such that u = v1, v = vn, and {vi, vi+1}  E for all i, 1 ≤ i  n. FACT: HP is NP-complete (see page 60).

68 HW Problem Solution #1 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? Theorem: IS is NP-complete IS  NP 3DM  IS A I = M,W,X,Y 3DM instance G = (V, E), J IS instance

69 HW Problem Solution #1 Proof:
Let M be an instance of 3DM, and construct an instance of IS as follows. V = {vi | ti  M} E = {vi, vj | i  j and ti and tj agree on some coordinate} j = q Claims: The transformation can be performed in polynomial-time M contains a matching if and only if G=(V,E) contains an independent set of size j.

70 HW Problem Solution #1 (only if)
Let M’ = {t0, t1,…,tq-1} be a matching, where M’  M. It can be easily verified that V’ = {v0, v1,…,vq-1} is an independent set of size j. (if) Let V’ = {v0, v1,…,vq-1} is an independent set of size j for G. Then it can be easily verified that M’ = {t0, t1,…,tq-1} is a matching.

71 HW Problem Solution #2 I = M,W,X,Y I’ = M’,W’,X’,Y’,Z’ A 3DM instance
4-DIMENSIONAL MATCHING (4-DM) INSTANCE: A set M  W  X  Y  Z , where W, X, Y and Z 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? Theorem: 4DM is NP-complete 4DM  NP 3DM  4DM A I = M,W,X,Y 3DM instance I’ = M’,W’,X’,Y’,Z’ 4DM instance

72 HW Problem Solution #2 Proof:
Let M,W,X, and Y be an instance of 3DM, and construct an instance of 4DM as follows: W’ = W X’ = X Y’ = Y Z = {zi, where 0 ≤ i ≤ q-1, and q = |W|=|X|=|Y|} M’ = {(wi,xj,yk,zr) | (wi,xj,yk) ∊ M and zr ∊ Z} In other words, for each triple in M and value in Z, add a quadruple in M’. Claims: The transformation can be performed in polynomial-time M contains a matching if and only if M’ does.

73 HW Problem Solution #2 (only if)
Let M’’ = {t0, t1,…,tq-1} be a 3D matching, where M’’  M. Create a 4D matching M’’’ by adding zi to triple ti, for all i, where 0 ≤ i ≤ q-1. It can easily be verified that M’’’ is a 4D matching for I’. (if) Let M’’ = {t0, t1,…,tq-1} be a 4D matching, where M’’  M’. Create a 3D matching by letting M’’’ = {(wi,xj,yk) | (wi,xj,yk,zr) ∊ M”}. It can easily be verified that M’’’ is a 3D matching for I’.

74 Partition PARTITION INSTANCE: A finite set A and a “size” s(a)  Z+ for each a  A. QUESTION: Is there a subset A’  A such that: 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?

75 Partition Theorem: Partition is NP-complete Proof: 1) PARTITION  NP
2) 3DM  PARTITION Let W, X, and Y with |W| = |X| = |Y| = q, and M  W  X  Y be an instance of 3DM. Also let: W = {w1, w2,…, wq} X = {x1, x2,…, xq} Y = {y1, y2,…, yq} and: M = {m1, m2,…, mq} where q = |M|

76 Partition We will construct a set A, and a size s(a) ∊ Z+ for each a ∊ A, such that A contains a subset A’ satisfying: if and only if M contains a matching. First add k elements {ai :1≤i≤k}, where corresponds with triple mi M.

77 Techniques for Proving NP-Completeness
There are several “general” types of transformations: Restriction Local Replacement Component Design

78 Restriction Proving a problem   NP NP-complete by restriction consists of showing that  contains another known NP-complete problem ’ as a special case. What is a “special case” of a problem? Let I be all instances of a problem , and let I’ be all instances of a problem ’ If I’ ⊆ I and I’Y’ IFF I Y then ’ is said to be a special case of ’ Furthermore, if  and ’ are both in NP, and if ’ is NP-complete, then so is  The heart of a proof by restriction is the specification of restrictions to be placed on the instances of  so that the resulting problem will be identical to ’ Note that a proof by restriction is still a transformation, i.e., it is not a different kind of NP- completeness proof. In other words, every instance of the NP-complete problem must be an instance of the second problem, and this mapping must preserve “yes” and “no” instances.

79 Directed Hamiltonian Circuit (DHS)
DIRECTED HAMILTONIAN CIRCUIT (DHC) INSTANCE: A directed 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. HAMILTONIAN CIRCUIT (HC) INSTANCE: A Graph G = (V, E). Fact: HC is NP-complete.

80 Directed Hamiltonian Circuit (DHS)
Theorem: DHC is NP-complete Proof: DHC  NP HC  DHC, by restriction. Proof: Consider those instances of DHC where there is an edge from u to v if and only if there is an edge from v to u. Recall that technically a restriction is, in fact, a transformation. In what sense is the above proof a transformation?

81 Exact Cover by 3-Sets (X3C)
INSTANCE: A finite set X with |X| = 3q and a collection C of 3-element subsets of X. QUESTION: Does C contain an exact cover for X, that is, a sub-collection C’  C such that every element of X occurs in exactly one member of C’ ? How does this differ from 3DM? 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?

82 Exact Cover by 3-Sets (X3C)
Theorem: X3C is NP-complete Proof: X3C  NP 3DM  X3C Let M  W  Y  Z, where W, Y and Z are disjoint sets having the same number q of elements, be an instance of 3DM. Construct an instance of X3C as follows: Let X = W ∪ Y ∪ Z Let C = { {a,b,c} | (a,b,c) ∊ M} It can easily be verified that C contains an exact 3-cover for X IFF M contains a matching.

83 Exact Cover by 3-Sets (X3C)
Theorem: X3C is NP-complete Proof: X3C  NP 3DM  X3C Another way to view this is as a restriction from X3C to 3DM – consider those instances of X3C where X can be partitioned into 3 disjoint sets W, Y, and Z, and where each 3-element set C contains exactly one element from each of these sets.

84 MINIMUM COVER

85 Hitting Set HITTING SET
INSTANCE: A collection C of subsets of a set S, positive integer K. QUESTION: Does S contain a hitting set for C of size K or less, that is, a subset S’  S with |S’| ≤ K and such that S’ contains at least one element from each subset in C? Proof: Restrict to VC by considering those instances having |c| = 2 for all c ∊ C.

86 Subgraph Isomorphism SUBGRAPH ISOMORPHISM
INSTANCE: Two graphs G = (V1, E1) and H = (V2, E2). QUESTION: Does G contain a subgraph isomorphic to H, that is, a subset V  V1 and a subset E  E1 such that |V| = |V2|, |E| = |E2|, and there exists a one-to-one function f : V2 → V satisfying {u,v} ∊ E2 if and only if {f(u),f(v)} ∊ E. Proof: Restrict to CLIQUE by considering those instances where H is a complete graph, that is, E2 contains all possible edges joining two members of V2.

87 Bounded Degree Spanning Tree
Let G=(V,E) be a graph and let E’ ⊆ E. Then T=(V,E’) is said to be a spanning tree if T is connected and |E’| = |V|-1 (i.e., T contains no cycles). BOUNDED DEGREE SPANNING TREE INSTANCE: A graph G = (V, E) and a positive integer K≤ |V|-1. QUESTION: Is there a spanning tree for G in which no vertex has degree exceeding K, that is, a subset E’  E such that |E’| = |V|-1, the graph G’ = (V, E’) is connected , and no vertex in V is included in more than K edges from E’? Proof: Restrict to HAMILTONIAN PATH by considering only instances where K=2.

88 Minimum Equivalent Digraph
INSTANCE: A directed graph G = (V, A) and a positive integer K ≤ |A|. QUESTION: Is there a directed graph G’ = (V, A’) such that A  A’, |A’| ≤ K, and such that, for every pair of vertices u and v in V, G’ contains a directed path from u to v if and only if G contains a directed path from u to v. Proof: Restrict to DIRECTED HAMILTONIAN CIRCUIT by considering those instances where G is strongly connected, that is, contains a path from every vertex u to every vertex v, and K=|V|. Note that this is technically a restriction to DIRECTED HAMILTONIAN CIRCUIT FOR STRONGLY CONNECTED DIGRAPHS, but the NP-completeness of that problem follows immediately from the constructions given for HC and DIRECTED HC.

89 Knapsack KNAPSACK INSTANCE: A finite set U and a “size” s(u)  Z+ and a value s(v)  Z+ for each u  U, a size constraint B  Z+ , and a value goal K  Z+. QUESTION: Is there a subset U’  U such that: and Proof: Restrict to PARTITION by considering only those instances where s(u) = s(v) for all u ∊ U and:

90 Multiprocessor Scheduling
INSTANCE: A finite set A of “tasks,” a “length” l(a)  Z+ for each a  A, a number m  Z+ of “processors,“ and a “deadline” D  Z+. QUESTION: Is there a partition A = A1 ∪ A2 ∪ … ∪ Am of A into m disjoint sets such that: Proof: Restrict to PARTITION by considering only those instances where m=2 and:

91 Invalid Restriction Subset Sum
INSTANCE: Integers a1, a2,…,an and integer B. QUESTION: Is there a sequence of 0’s and 1’s, x1, x2,…,xn such that: Fact: Subset Sum is NP-complete Real Subset Sum QUESTION: Is there a sequence of real numbers x1, x2,…,xn such that:

92 Invalid Restriction, Cont.
Claim (from a Ph.D disseration): Subset Sum is just a special case of Real Subset Sum Therefore, Real Subset Sum is NP-complete The proof is in error since it restricts the question, and not the instances. In fact, the problem is actually trivially solvable in polynomial time simply taking x1 = B/a1 and xi = 0, for all i, where 2 ≤ i ≤ n. Also note that the “restriction” does not preserve yes and no instances (in fact, all are yes instances).

93 Other Invalid Restrictions
Some other invalid restrictions: 4-DM is NP-complete because it contains 3-DM as a special case. 4-SAT is NP-complete because it contains 3-SAT as a special case. In these cases, the instances of one aren’t even a subset of the other!

94 Homework #2 See page 75, the first group:
Longest Path Set Packing Partition into Hamiltonian Subgraphs Largest Common Subgraph Minimum Sum of Squares Give an NP-completeness proof for each of the above by restriction. Hand in any two.

95 Local Replacement Transformations are sufficiently non-trivial to warrant spelling out details, in contrast to restriction. An instance of a known NP-complete problem is broken up into some number of structurally similar “basic units” During the transformation, each “basic unit” is replaced by a different structure, which is part of the target problems instance. Each replacement constitutes only local modification.

96 Partition Partition into Triangles
INSTANCE: A Graph G = (V, E), with |X| = 3q. QUESTION: Is there a partition of V into q disjoint sets V1, V2,…,Vq of three vertices each such that, for each Vi = {vi[1], vi[2], vi[3] } the three edges {vi[1], vi[2]} , {vi[1], vi[3]} and {vi[2], vi[3]} all belong to E’? Theorem: Partition into Triangles is NP-complete Proof: Partition into Triangles  NP X3C  Partition into Triangles


Download ppt "Chapter 3: Proving NP-completeness Results"

Similar presentations


Ads by Google