Polynomial-Time Reductions Contents
Total Page:16
File Type:pdf, Size:1020Kb
Contents Polynomial-Time Reductions Contents. ■ Polynomial-time reductions. ■ Reduction from special case to general case. – COMPOSITE reduces to FACTOR – VERTEX-COVER reduces to SET-COVER ■ Reduction by simple equivalence. – PRIMALITY reduces to COMPOSITE, and vice versa – VERTEX COVER reduces to CLIQUE, and vice versa ■ Reduction from general case to special case. – SAT reduces to 3-SAT – 3-COLOR reduces to PLANAR-3-COLOR ■ Reduction by encoding with gadgets. – 3-CNF-SAT reduces to CLIQUE – 3-CNF-SAT reduces to HAM-CYCLE – 3-CNF-SAT reduces to 3-COLOR Princeton University • COS 423 • Theory of Algorithms • Spring 2001 • Kevin Wayne 2 Polynomial-Time Reduction Polynomial-Time Reduction Intuitively, problem X reduces to problem Y if: Purpose. Classify problems according to relative difficulty. ■ Any instance of X can be "rephrased" as an instance of Y. ≤ Design algorithms. If X P Y and Y can be solved in polynomial-time, Formally, problem X polynomial reduces to problem Y if arbitrary then X can be solved in polynomial time. instances of problem X can be solved using: ≤ ■ Polynomial number of standard computational steps, plus Establish intractability. If X P Y and X cannot be solved in polynomial-time, then X cannot be solved in polynomial time. ■ Polynomial number of calls to oracle that solves problem Y. – computational model supplemented by special piece of ≤ ≤ ≡ hardware that solves instances of Y in a single step Anti-symmetry. If X P Y and Y P X, we use notation X P Y. ≤ ≤ ≤ Remarks. Transitivity. If X P Y and Y P Z, then X P Z. ■ ■ We pay for time to write down instances sent to black box ⇒ Proof idea: compose the two algorithms. instances of Y are of polynomial size. ■ Given an oracle for Z, can solve instance of X: ■ Note: Cook-Turing reducibility (not Karp or many-to-one). – run the algorithm for X using a oracle for Y T ■ ≤ ≤ – each time oracle for Y is called, simulate it in a polynomial Notation: X P Y (or more precisely X P Y ). number of steps by using algorithm for Y, plus oracle calls to Z 3 4 Polynomial-Time Reduction Compositeness and Primality Basic strategies. COMPOSITE: Given the decimal representation of an integer x, does x ■ Reduction by simple equivalence. have a nontrivial factor? ■ Reduction from special case to general case. PRIME: Given the decimal representation of an integer x, is x prime? ■ Reduction from general case to special case. ■ ≡ Reduction by encoding with gadgets. Claim. COMPOSITE P PRIME. ≤ ■ COMPOSITE P PRIME. ≤ ■ PRIME P COMPOSITE. COMPOSITE (x) PRIME (x) IF (PRIME(x) = TRUE) IF (COMPOSITE(x) = TRUE) RETURN FALSE RETURN FALSE ELSE ELSE RETURN TRUE RETURN TRUE 5 6 Vertex Cover Vertex Cover VERTEX COVER: Given an undirected graph G = (V, E) and an integer VERTEX COVER: Given an undirected graph G = (V, E) and an integer k, is there a subset of vertices S ⊆ V such that |S| ≤ k, and if (v, w) ∈ E k, is there a subset of vertices S ⊆ V such that |S| ≤ k, and if (v, w) ∈ E then either v ∈ S, w ∈ S or both. then either v ∈ S, w ∈ S or both. Ex. Ex. ■ Is there a vertex cover of size 4? 1 6 ■ Is there a vertex cover of size 4? 1 6 YES. 2 7 YES. 2 7 ■ Is there a vertex cover of size 3? 3 8 3 8 NO. 4 9 4 9 5 10 5 10 7 8 Clique Vertex Cover and Clique ≡ CLIQUE: Given N people and their pairwise relationships. Is there a Claim. VERTEX COVER P CLIQUE. group of S people such that every pair in the group knows each other. ■ Given an undirected graph G = (V, E), its complement is G' = (V, E'), where E' = { (v, w) : (v, w) ∉ E}. Ex. ■ G has a clique of size k if and only if G' has a vertex cover of size ■ People: a, b, c, d, e, . , k. |V| - k. ■ Friendships: (a, e), (a, f), (a, g), . ., (h, k). ■ Clique size: S = 4. a b c k d d u v u v YES Instance j e z w z w i f y x y x h g G G' Friendship Graph Clique = {u, v, x, y} Vertex cover = {w, z} 9 10 Vertex Cover and Clique Vertex Cover and Clique ≡ ≡ Claim. VERTEX COVER P CLIQUE. Claim. VERTEX COVER P CLIQUE. ■ Given an undirected graph G = (V, E), its complement is G' = (V, E'), ■ Given an undirected graph G = (V, E), its complement is G' = (V, E'), where E' = { (v, w) : (v, w) ∉ E}. where E' = { (v, w) : (v, w) ∉ E}. ■ G has a clique of size k if and only if G' has a vertex cover of size ■ G has a clique of size k if and only if G' has a vertex cover of size |V| - k. |V| - k. Proof. ⇒ u v Proof. ⇐ u v ■ Suppose G has a clique S with |S| = k. ■ Suppose G' has a cover S' with |S'| = |V| - k. z w z w ■ Consider S' = V –S. ■ Consider S = V –S'. y x ■ |S'| = |V| - k. ■ Clearly |S| = k. y x ■ To show S' is a cover, consider any ■ To show S is a clique, consider some edge (v, w) ∈ E'. edge (v, w) ∈ E'. – then (v, w) ∉ E u v – if (v, w) ∈ E', then either v ∈ S', w ∈ S', or both u v – at least one of v or w is not in S – by contrapositive, if v ∉ S' and w ∉ S', z w (since S forms a clique) then (v, w) ∈ E z w – at least one of v or w is in S' – thus S is a clique in G y x y x – hence (v, w) is covered by S' 11 12 Polynomial-Time Reduction Compositeness Reduces to Factoring Basic strategies. COMPOSITE: Given an integer x, does x have a nontrivial factor? ■ Reduction by simple equivalence. FACTOR: Given two integers x and y, does x have a nontrivial factor ■ Reduction from special case to general case. less than y? ■ Reduction from general case to special case. ≤ ■ Reduction by encoding with gadgets. Claim. COMPOSITE P FACTOR. Proof. Given an oracle for FACTOR, we solve COMPOSITE. ■ Is 350 composite? ■ Does 350 have a nontrivial factor less than 350? COMPOSITE (x) IF (FACTOR(x, x) = TRUE) RETURN TRUE ELSE RETURN FALSE 13 14 Primality Testing and Factoring Set Cover We established: SET COVER: Given a set U of elements, a collection S1, S2, . , Sm of ≤ ≤ ■ PRIME P COMPOSITE P FACTOR. subsets of U, and an integer k, does there exist a collection of at most k of these sets whose union is equal of U? Natural question: ≤ Sample application. ■ Does FACTOR P PRIME ? ■ n available pieces of software. ■ Consensus opinion = NO. ■ Set U of n capabilities that we would like our system to have. ⊆ State-of-the-art. ■ The ith piece of software provides the set Si U of capabilities. ■ ■ PRIME in randomized P and conjectured to be in P. Goal: achieve all n capabilities using small number of pieces of software. ■ FACTOR not believed to be in P. Ex. U = {1, 2, 3, . , 12}, k = 3. RSA cryptosystem. ■ S = {1, 2, 3, 4, 5, 6} S = {5, 6, 8, 9} ■ Based on dichotomy between two problems. 1 2 ■ S = {1, 4, 7, 10} S = {2, 5, 7, 8, 11} ■ To use, must generate large primes efficiently. 3 4 ■ S5 = {3, 6, 9, 12} S6 = {10, 11} ■ Can break with efficient factoring algorithm. YES: S3, S4, S5. 15 16 Vertex Cover Reduces to Set Cover Vertex Cover Reduces to Set Cover SET COVER: Given a set U of elements, a collection S1, S2, . , Sn' of SET COVER: Given a set U of elements, a collection S1, S2, . , Sn' of subsets of U, and an integer k, does there exist a collection of at most subsets of U, and an integer k, does there exist a collection of at most k of these sets whose union is equal to U? k of these sets whose union is equal to U? VERTEX COVER: Given an undirected graph G = (V, E) and an integer VERTEX COVER: Given an undirected graph G = (V, E) and an integer k, is there a subset of vertices S ⊆ V such that |S| ≤ k, and if (v, w) ∈ E k, is there a subset of vertices S ⊆ V such that |S| ≤ k, and if (v, w) ∈ E then either v ∈ S, w ∈ S or both. then either v ∈ S, w ∈ S or both. ≤ ≤ Claim. VERTEX-COVER P SET-COVER. Claim. VERTEX-COVER P SET-COVER. Proof. Given black box that solves instances of SET-COVER. Proof. Given black box that solves instances of SET-COVER. ■ Let G = (V, E), k be an instance of VERTEX-COVER. U = {1, 2, 3, 4, 5, 6, 7} ■ Create SET-COVER instance: G = (V, E) a b k = 2 ∈ k = 2 S = {3, 7} S = {2, 4} – k = k, U = E, Sv = {e E : e incident to v } e7 e e a b e2 3 4 Sc = {3, 4, 5, 6} Sd = {5} ■ Set-cover of size at most k if and only if vertex cover of size at f e6 c Se = {1} Sf= {1, 2, 6, 7} most k. e e Vertex Cover 1 5 e d Set Cover 17 18 Polynomial-Time Reduction Factoring and Finding Factors Basic strategies. FACTOR: Given two integers x and y, does x have a nontrivial factor ■ Reduction by simple equivalence. less than y? ■ Reduction from special case to general case. FACTORIZE: Given an integer x, find its prime factorization.