NP-Completeness: Proofs
Total Page:16
File Type:pdf, Size:1020Kb
NP-Completeness : Proofs ••• Proof Methods A method to show a decision problem ΠΠΠ NP-complete is as follows. (1) Show ΠΠΠ ∈∈∈ NP. (2) Choose an NP-complete problem ΠΠΠ’. (3) Show ΠΠΠ’ ∝∝∝ ΠΠΠ. A method to show an optimization problem ΨΨΨ NP-hard is as follows. (1) Choose an NP-hard problem ΨΨΨ’ (ΨΨΨ’ may be NP-complete). (2) Show ΨΨΨ’ ∝∝∝ ΨΨΨ. An alternative method to show ΨΨΨ NP-hard is to show the decision version of ΨΨΨ NP-complete. 1 ••• Two Simple Examples Ex. Sum of Subsets Instance : A finite set A of positive integers and a positive integer c. Question : Is there a subset A’ of A whose elements sum to c ? For example, if A = {7, 5, 19, 1, 12, 8, 14} and c = 21, then the answer is yes (A’ = {7, 14}). NP-completeness of Sum of Subsets is shown below. ♣ Sum of Subsets ∈∈∈ NP. ♣ A chosen NP-complete problem : Exact Cover. 2 Exact Cover Instance : A finite set S and k subsets S1, S2, …, Sk of S. Question : Is there a subset of {S1, S2, …, Sk} that forms a partition of S ? For example, if S = {7, 5, 19, 1, 12, 8, 14}, k = 4, S1 = {7, 19, 12, 14}, S2 = {7, 5, 8}, S3 = {5, 1, 8}, and S4 = {19, 1, 8, 14}, then the answer is yes ({S1, S3} forms a partition of S). 3 ♣ Exact Cover ∝∝∝ Sum of Subsets. Let S = {u1, u2, …, um} and S1, S2, …, Sk be an arbitrary instance of Exact Cover. An instance of Sum of Subsets can be obtained in polynomial time as follows. − m 1 i A = {a1, a2, …, ak} and c = ∑ (k + 1) , i=0 where for 1 ≤≤≤ j ≤≤≤ k, m a = e( k + 1)i−1 , j ∑ j, i i=1 with ej,i = 1 if ui ∈∈∈ Sj and ej,i = 0 if ui ∉∉∉ Sj. ⇒ Sum of Subsets has the answer yes if and only if Exact Cover has the answer yes . 4 For example, given the following instance of Exact Cover : S = {7, 5, 19, 1, 12, 8, 14}, k = 4, S1 = {7, 19, 12, 14}, S2 = {7, 5, 8}, S3 = {5, 1, 8}, and S4 = {19, 1, 8, 4}, a matrix e is defined as follows. 7 5 19 1 12 8 14 S 1 1010101 S 1100010 2 S 3 0101010 S 4 0011011 An instance of Sum of Subsets is constructed as follows. 5 0 1 2 6 A = {a1, a2, a3, a4} and c = 5 + 5 + 5 + … + 5 , where 0 2 4 6 st a1 = 5 + 5 + 5 + 5 (1 row of e); 0 1 5 nd a2 = 5 + 5 + 5 (2 row of e); 1 3 5 rd a3 = 5 + 5 + 5 (3 row of e); 2 3 5 6 th a4 = 5 + 5 + 5 + 5 (4 row of e). The construction relates ai with Si and c with S. It is not difficult to see a1 + a3 = c ⇔ S1 ∪∪∪ S3 = S and S1 ∩∩∩ S3 = ∅∅∅. 6 Ex. Partition Instance : A multiset B = {b1, b2, …, bn} of positive integers. Question : Is there a subset B’ ⊆⊆⊆ B such that ∑ bi = ∑ b j ? bi∈∈∈ B' bj∈∈∈ B− B' For example, when B = {17, 53, 9, 35, 41, 32, 35}, then the answer is yes (B’ = {17, 53, 41}). NP-completeness of Partition is shown below. ♣ Partition ∈∈∈ NP. ♣ A chosen NP-complete problem : Sum of Subsets. 7 ♣ Sum of Subsets ∝∝∝ Partition Let A = {a1, a2, …, am} and c be an arbitrary instance of Sum of Subsets. An instance of Partition can be obtained in polynomial time as follows: B = A ∪∪∪ { am+1 , am+2 }, where am+1 = c + 1 and am+2 = 1 −−− c + ∑ ai . ai∈∈∈ A Since am+1 + am+2 = ∑ ai + 2, we have ai∈∈∈ A {am+1 , am+2 } ⊄⊄⊄ B’ and {am+1 , am+2 } ⊄⊄⊄ B −−− B’ . We show below that ∑ ai = c if and only if ai∈∈∈Α' am+2 + ∑ ai = am+1 + ∑ ai ai∈∈∈Α' ai∈∈∈ΑΑ− ' (i.e., B’ = A’ + {am+2 }). 8 ⇒⇒⇒ ( ) Suppose ∑ ai = c. ai∈∈∈Α' am+2 + ∑ ai = (1 −−− c + ∑ ai ) + ∑ ai ai∈∈∈Α' ai∈∈∈ A ai∈∈∈Α' = 1 + ∑ ai . ai∈∈∈Α am+1 + ∑ ai = (c + 1) + ∑ ai ai∈∈∈ΑΑ− ' ai∈∈∈ΑΑ− ' = 1 + ∑ ai . ai∈∈∈Α (⇐⇐⇐) Suppose am+2 + ∑ ai = am+1 + ∑ ai , ai∈∈∈Α' ai∈∈∈ΑΑ− ' i.e., B’ = A’ + {am+2 }. Then, (1 −−− c + ∑ ai ) + ∑ ai = (c + 1) + ai∈∈∈ A ai∈∈∈Α' ∑ ai , ai∈∈∈ΑΑ− ' from which ∑ ai = c can be derived. ai∈∈∈Α' 9 Exercise 5. Read Example 8-14 on page 367 of the textbook. (1) Give a reduction from Partition to the bin packing problem. (2) Illustrate the reduction by an example. (3) Verify the reduction. Exercise 6. Read Theorem 11.2 on page 518 of Ref. (2). (1) Give a reduction from Satisfiability to Clique. (2) Illustrate the reduction by an example. (3) Verify the reduction. 10 ••• Three Proof Techniques Restriction Local Replacement Component Design 11 ••• Restriction If a problem ΠΠΠ contains an NP-hard problem ΠΠΠ’ as a special case (i.e., ΠΠΠ’ is a restricted subproblem of ΠΠΠ), then ΠΠΠ is NP-hard. Ex. Exact Cover Instance : A finite set S and k subsets S1, S2, …, Sk of S. Question : Is there a subset of {S1, S2, …, Sk} that forms a partition of S ? Exact Cover by 3-Sets Instance : A finite set S with |S| = 3p and k 3- element subsets S1, S2, …, Sk of S. Question : Is there a subset of {S1, S2, …, Sk} that forms a partition of S ? 12 Exact Cover by 3-Sets is a special case of Exact Cover. 3-Dimensional Matching Instance : A set M ⊆⊆⊆ W ××× X ××× Y, where W, X and Y are three disjoint q-element subsets. Question : Does M contain a matching , i.e., a subset M’ ⊆⊆⊆ M such that |M’ | = q and no two elements of M’ agree in any coordinate ? For example, if W = {0, 1}, X = {a, b}, Y = {+++, −−−}, and M = {(0, a, +++), (1, b, +++), (1, b, −−−)}, then the answer is yes (M’ = {(0, a, +++), (1, b, −−−)}). 3-Dimensional Matching is a special case of Exact Cover by 3-Sets. 13 For example, the following instance of 3-Dimensional Matching : W = {0, 1}, X = {a, b}, Y = {+++, −−−}, and M = {(0, a, +++), (1, b, +++), (1, b, −−−)} can be transformed into an instance of Exact Cover by 3-Sets as follows : S1 = {0 W, aX, +++Y}, S2 = {1 W, bX, +++Y}, S3 = {1 W, bX, −−−Y}, and S = W ∪∪∪ X ∪∪∪ Y = {0W, 1W, aX, bX, +++Y, −−−Y}. Therefore, 3-Dimensional Matching is NP-complete. ⇒⇒⇒ Exact Cover by 3-Sets is NP-complete. ⇒⇒⇒ Exact Cover is NP-complete. 14 Ex. Hamiltonian Cycle Instance : An undirected graph G = (V, E). Question : Does G contain a Hamiltonian Cycle , i.e., an ordering (v1, v2, …, v|V|) of the vertices of G such that ( v1, v|V|) ∈∈∈ E and ( vi, vi+1 ) ∈∈∈ E for all 1 ≤≤≤ i < |V| ? Directed Hamiltonian Cycle Instance : A directed graph G = (V, A), where A is a set of arcs (i.e., ordered pairs of vertices). Question : Does G contain a directed Hamiltonian cycle , i.e., an ordering (v1, v2, …, v|V|) of the vertices of G such that ( v1, v|V|) ∈∈∈ A and ( vi, vi+1 ) ∈∈∈ A for all 1 ≤≤≤ i < |V| ? 15 Hamiltonian Cycle is a special case of Directed Hamiltonian Cycle (or Hamiltonian Cycle ∝∝∝ Directed Hamiltonian Cycle, where each ( u, v) ∈∈∈ E corresponds to two arcs (u, v), ( v, u) ∈∈∈ A). Therefore, Hamiltonian Cycle is NP-complete. ⇒⇒⇒ Directed Hamiltonian Cycle is NP-complete. 16 Hamiltonian Path between Two Vertices Instance : An undirected graph G = (V, E) and two distinct vertices u, v ∈∈∈ V. Question : Does G contain a Hamiltonian path starting at u and ending at v, i.e., an ordering (v1, v2, …, v|V|) of the vertices of G such that u = v1, v = v|V|, and (vi, vi+1 ) ∈∈∈ E for all 1 ≤≤≤ i < |V| ? Hamiltonian Cycle ∝∝∝ Hamiltonian Path between Two Vertices : if the latter is polynomial time solvable, then the former is also polynomial time solvable (considering all edges (u, v) ∈∈∈ V for the latter). ⇒⇒⇒ Hamiltonian Path between Two Vertices is NP-complete. 17 Hamiltonian Path Instance : An undirected graph G = (V, E). Question : Does G contain a Hamiltonian path ? Hamiltonian Cycle ∝∝∝ Hamiltonian Path : For each (u, v) ∈∈∈ E, construct an instance of Hamiltonian Path by adding x, y to V and (x, u), ( y, v) to E (thus G’ is induced). x y u v u v G G’ G has a Hamiltonian cycle if and only if G’ has a Hamiltonian x-y path. ⇒⇒⇒ If Hamiltonian Path is polynomial time solvable, then Hamiltonian Cycle is also polynomial time solvable. ⇒ Hamiltonian Path is NP-complete. 18 Exercise 7. Show the following two problems NP- complete by restriction to Hamiltonian Path and Partition, respectively. Bounded Degree Spanning Tree Instance : An undirected graph G = (V, E) and a positive integer k ≤≤≤ |V| −−− 1. Question : Does G contains a spanning tree in which each node has degree at most k ? 0/1 Knapsack + Instance : A finite set U, a “size” s(u) ∈∈∈ Z and + a “value” v(u) ∈∈∈ 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 ∑ s( u ) ≤≤≤ b and ∑ v( u ) ≥≥≥ k ? u∈∈∈ U' u∈∈∈ U' 19 ••• Local Replacement In order to show ΠΠΠ’ ∝∝∝ ΠΠΠ, local replacement specifies the “basic units” for ΠΠΠ’ and replaces them with others, while constructing a corresponding instance of ΠΠΠ. Usually, local replacement has one kind of basic units that each are replaced with the same structure.