Theory of Computer Science May 22, 2017 — E2
Total Page:16
File Type:pdf, Size:1020Kb
Theory of Computer Science May 22, 2017 | E2. P, NP and Polynomial Reductions Theory of Computer Science E2.1 P and NP E2. P, NP and Polynomial Reductions E2.2 Polynomial Reductions Malte Helmert University of Basel E2.3 NP-Hardness and NP-Completeness May 22, 2017 E2.4 Summary Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 1 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 2 / 30 Overview: Course Overview: Complexity Theory contents of this course: logic I X Complexity Theory . How can knowledge be represented? . How can reasoning be automated? E1. Motivation and Introduction E2. P, NP and Polynomial Reductions I automata theory and formal languages X . What is a computation? E3. Cook-Levin Theorem I computability theory X E4. Some NP-Complete Problems, Part I . What can be computed at all? E5. Some NP-Complete Problems, Part II I complexity theory . What can be computed efficiently? Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 3 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 4 / 30 Further Reading (German) Further Reading (English) Literature for this Chapter (German) Literature for this Chapter (English) Theoretische Informatik { kurz gefasst Introduction to the Theory of Computation by Uwe Sch¨oning(5th edition) by Michael Sipser (3rd edition) I Chapters 3.1 and 3.2 I Chapter 7.1{7.4 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 5 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 6 / 30 E2. P, NP and Polynomial Reductions P and NP E2. P, NP and Polynomial Reductions P and NP Accepting a Word in Time n Definition (Accepting a Word in Time n) Let M be a DTM or NTM with input alphabet Σ, ∗ E2.1 P and NP w 2 Σ a word and n 2 N0. M accepts w in time n if there is a sequence of configurations c0;:::; ck with k ≤ n, where: I c0 is the start configuration for w, I c0 ` c1 ` · · · ` ck , and I ck is an end configuration. German: M akzeptiert w in Zeit n Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 7 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 8 / 30 E2. P, NP and Polynomial Reductions P and NP E2. P, NP and Polynomial Reductions P and NP Accepting a Language in Time f P and NP Definition (Accepting a Language in Time f ) Let M be a DTM or NTM with input alphabet Σ, Definition (P and NP) ∗ L ⊆ Σ a language and f : N0 ! N0 a function. P is the set of all languages L for which a DTM M M accepts L in time f if: and a polynomial p exist such that M accepts L in time p. 1 for all words w 2 L: M accepts w in time f (jwj) NP is the set of all languages L for which an NTM M and a polynomial p exist such that M accepts L in time p. 2 for all words w 2= L: M does not accept w German: M akzeptiert L in Zeit f Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 9 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 10 / 30 E2. P, NP and Polynomial Reductions P and NP E2. P, NP and Polynomial Reductions P and NP P and NP: Remarks Example: DirHamiltonCycle 2 NP Example (DirHamiltonCycle 2 NP) I Sets of languages like P and NP that are defined in terms of computation time of TMs The nondeterministic algorithm of Chapter E1 solves the problem (or other computation models) are called complexity classes. and can be implemented on an NTM in polynomial time. I We know that P ⊆ NP. (Why?) I Is DirHamiltonCycle 2 P also true? Whether the converse is also true is an open question: I The answer is unknown. this is the famous P-NP problem. I I So far, only exponential deterministic algorithms German: Komplexit¨atsklassen, P-NP-Problem for the problem are known. Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 11 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 12 / 30 German: E2. P, NP and Polynomial Reductions P and NP E2. P, NP and Polynomial Reductions Polynomial Reductions Simulation of NTMs with DTMs I Unlike DTMs, NTMs are not a realistic computation model: they cannot be directly implemented on computers. I But NTMs can be simulated by systematically trying all computation paths, e. g., with a breadth-first search. E2.2 Polynomial Reductions More specifically: I Let M be an NTM that accepts language L in time f , where f (n) ≥ n for all n 2 N0. 0 0 I Then we can specify a DTM M that accepts L in time f , where f 0(n) = 2O(f (n)). I without proof (cf. Sipser, Theorem 7.11) Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 13 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 14 / 30 E2. P, NP and Polynomial Reductions Polynomial Reductions E2. P, NP and Polynomial Reductions Polynomial Reductions Polynomial Reductions: Idea Polynomial Reductions I Reductions are a common and powerful concept in computer Definition (Polynomial Reduction) science. We know them from Part D. Let A ⊆ Σ∗ and B ⊆ Γ∗ be decision problems. I The basic idea is that we solve a new problem by reducing it We say that A can be polynomially reduced to B, ∗ ∗ to a known problem. written A ≤p B, if there is a function f :Σ ! Γ such that: I In complexity theory we want to use reductions I f can be computed in polynomial time by a DTM that allow us to prove statements of the following kind: I i. e., there is a polynomial p and a DTM M such that M computes f (w) in at most p(jwj) steps given input w 2 Σ∗ Problem A can be solved efficiently if problem B can be solved efficiently. I f reduces A to B ∗ I i. e., for all w 2 Σ : w 2 A iff f (w) 2 B I For this, we need a reduction from A to B f is called a polynomial reduction from A to B that can be computed efficiently itself (otherwise it would be useless for efficiently solving A). German: A polynomiell auf B reduzierbar, polynomielle Reduktion von A auf B Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 15 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 16 / 30 E2. P, NP and Polynomial Reductions Polynomial Reductions E2. P, NP and Polynomial Reductions Polynomial Reductions Polynomial Reductions: Remarks Polynomial Reductions: Example (1) I Polynomial reductions are also called Karp reductions (after Richard Karp, who wrote a famous paper Definition (HamiltonCycle) describing many such reductions in 1972). HamiltonCycle is the following decision problem: I In practice, of course we do not have to specify a DTM for f : I Given: undirected graph G = hV ; Ei it just has to be clear that f can be computed I Question: Does G contain a Hamilton cycle? in polynomial time by a deterministic algorithm. Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 17 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 18 / 30 E2. P, NP and Polynomial Reductions Polynomial Reductions E2. P, NP and Polynomial Reductions Polynomial Reductions Polynomial Reductions: Example (2) Polynomial Reductions: Example (3) Definition (TSP) TSP (traveling salesperson problem) is the following decision problem: Theorem (HamiltonCycle ≤p TSP) HamiltonCycle ≤ TSP. I Given: finite set S 6= ; of cities, symmetric cost function p cost : S × S ! N0, cost bound K 2 N0 Proof. I Question: Is there a tour with total cost at most K, i. e., blackboard a permutation hs1;:::; sni of the cities with Pn−1 i=1 cost(si ; si+1) + cost(sn; s1) ≤ K? German: Problem der/des Handlungsreisenden Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 19 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 20 / 30 E2. P, NP and Polynomial Reductions Polynomial Reductions E2. P, NP and Polynomial Reductions Polynomial Reductions Properties of Polynomial Reductions (1) Properties of Polynomial Reductions (2) Proof. Theorem (Properties of Polynomial Reductions) for 1.: Let A, B and C decision problems. We must show that there is a DTM accepting A 1 If A ≤p B and B 2 P, then A 2 P. in polynomial time. 2 If A ≤p B and B 2 NP, then A 2 NP. We know: 3 If A ≤p B and A 2= P, then B 2= P. I There is a DTM MB that accepts B in time p, 4 If A ≤p B and A 2= NP, then B 2= NP. where p is a polynomial. 5 If A ≤p B and B ≤p C, then A ≤p C. I There is a DTM Mf that computes a reduction from A to B in time q, where q is a polynomial. ... Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 21 / 30 Malte Helmert (University of Basel) Theory of Computer Science May 22, 2017 22 / 30 E2. P, NP and Polynomial Reductions Polynomial Reductions E2. P, NP and Polynomial Reductions Polynomial Reductions Properties of Polynomial Reductions (3) Properties of Polynomial Reductions (4) Proof (continued).