Chapter 15 P, NP, and Cook’s Theorem. 2 Computability Theory n Establishes whether decision problems are (only) theoretically decidable, i.e., decides.

Slides:



Advertisements
Similar presentations
Complexity Classes: P and NP
Advertisements

Time Complexity P vs NP.
CS 345: Chapter 9 Algorithmic Universality and Its Robustness
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Recap CS605: The Mathematics and Theory of Computer Science.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
Advanced Topics in Algorithms and Data Structures
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
P and NP Sipser (pages ). CS 311 Fall Polynomial time P = ∪ k TIME(n k ) … P = ∪ k TIME(n k ) … TIME(n 3 ) TIME(n 2 ) TIME(n)
Tractable and intractable problems for parallel computers
P, NP, PS, and NPS By Muhannad Harrim. Class P P is the complexity class containing decision problems which can be solved by a Deterministic Turing machine.
1 Polynomial Church-Turing thesis A decision problem can be solved in polynomial time by using a reasonable sequential model of computation if and only.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Read sections 7.1 – 7.3 of the book for next time.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
NP-Complete Problems Problems in Computer Science are classified into
1 Other Models of Computation. 2 Models of computation: Turing Machines Recursive Functions Post Systems Rewriting Systems.
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 9 Turing Machine (TMs).
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
Machines with Memory Chapter 3 (Part B). Turing Machines  Introduced by Alan Turing in 1936 in his famous paper “On Computable Numbers with an Application.
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
חישוביות וסיבוכיות Computability and Complexity Lecture 7 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AAAA.
Complexity theory and combinatorial optimization Class #2 – 17 th of March …. where we deal with decision problems, finite automata, Turing machines pink.
Review Byron Gao. Overview Theory of computation: central areas: Automata, Computability, Complexity Computability: Is the problem solvable? –solvable.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
CSC 413/513: Intro to Algorithms NP Completeness.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
Computability Chapter 5. Overview  Turing Machine (TM) considered to be the most general computational model that can be devised (Church-Turing thesis)
Lecture 12 P and NP Introduction to intractability Class P and NP Class NPC (NP-complete)
NP-completeness Class of hard problems. Jaruloj ChongstitvatanaNP-complete Problems2 Outline  Introduction  Problems and Languages Turing machines and.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 7 Time complexity Contents Measuring Complexity Big-O and small-o notation.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
LIMITATIONS OF ALGORITHM POWER
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 7 Time Complexity Some slides are in courtesy.
CS 3813: Introduction to Formal Languages and Automata Chapter 14 An Introduction to Computational Complexity These class notes are based on material from.
1 Chapter 10 Intractable Problems Switzerland Lion Monument in Lucerne.
Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language.
NP-Completeness  For convenience, the theory of NP - Completeness is designed for decision problems (i.e. whose solution is either yes or no).  Abstractly,
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation.
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Prof. Busch - LSU1 Time Complexity. Prof. Busch - LSU2 Consider a deterministic Turing Machine which decides a language.
Theory of Computational Complexity Yuji Ishikawa Avis lab. M1.
1 8.4 Extensions to the Basic TM Extended TM’s to be studied: Multitape Turing machine Nondeterministic Turing machine The above extensions make no increase.
Chapter 15 P, NP, and Cook’s Theorem. 2 Computability Theory n Establishes whether decision problems are (only) theoretically decidable, i.e., decides.
 2005 SDU Lecture14 Mapping Reducibility, Complexity.
Chapters 11 and 12 Decision Problems and Undecidability.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesTuring.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Intractable Problems Time-Bounded Turing Machines Classes P and NP
Analysis and design of algorithm
Intractable Problems Time-Bounded Turing Machines Classes P and NP
Intractable Problems Time-Bounded Turing Machines Classes P and NP
Intractable Problems Time-Bounded Turing Machines Classes P and NP
Chapter 14 Time Complexity.
CLASSES P AND NP.
Chapter 11 Limitations of Algorithm Power
Instructor: Aaron Roth
Presentation transcript:

Chapter 15 P, NP, and Cook’s Theorem

2 Computability Theory n Establishes whether decision problems are (only) theoretically decidable, i.e., decides whether each solvable problem has a practical solution that can be solved efficiently n A theoretically solvable problem may not have a practical solution, i.e., there is no efficient algorithm to solve the problem in polynomial time – an intractable problem  Solving intractable problems require extraordinary amount of time and memory.  Efficiently solvable problems are polynomial (P) problems.  Intractable problems are non-polynomial (NP) problems. n Can any problem that is solvable in polynomial time by a non-deterministic algorithm also be solved deterministically in polynomial time, i.e., P = NP ?

Time Complexity of NTMs n A deterministic TM searches for a solution to a problem by sequentially examining a number of possibilities, e.g., to determine a perfect square number. n A NTM employs a “guess-and-check” strategy on any one of the possibilities. n Defn The time complexity of a NTM M is the function tc M : N  N such that tc M (n) is the maximum number of transitions in any computation for an input of length n. n Time complexity measures the efficiency over all computations  the non-deterministic analysis must consider all possible computations for an input string.  the guess-and-check strategy is generally simpler than its deterministic counterparts.

4 n Example Consider the following two-tape NTM M that accepts the palindromes over {a, b}.  the time complexity of M is tc M (n) = n The strategy employed in the transformation of a NTM to an equivalent DTM (given in Section 8.7) does not preserve polynomial time solvability. n + 2 if n is odd n + 3 if n is even 15.1 Time Complexity of NTMs (odd) (even)

Time Complexity of NTMs n Theorem Let L be the language accepted by a one- tape NTM M with time complexity tc M (n) = f(n). Then L is accepted by a DTM M’ with time complexity tc M’ (n)  O(f(n)c f(n) ), where c is the maximum number of transitions for any pair of M.  Proof. Let M be a one-tape NTM that halts for all inputs, and let c be the maximum number of distinct transitions for any pair of M. A three-tape DTM M’ was described in Section 8.7 (pages ) whose computation with input w iteratively simulated all possible computations of M with input w. The transformation from non-determinism to determinism is obtained by associating a unique computation of M with a sequence (m 1, …, m n ), where 1  m i  c. The value m i indicates which of the c possible transitions of M should be executed on the i th step of the computation.

6 n Theorem (Continued)

Time Complexity of NTMs n Theorem (Cont.) Given a NTM M with tc M (n) = f(n), show a DTM M’ with time complexity tc M’ (n)  O(f(n)c f(n) ), where c = max. no. of transitions for any pair of M.  Proof. (Cont.) We analyze the number of transitions required by M’ to simulate all computations of M. For an input of length n, the max. no. of transitions in M is at most f(n). To simulate a single computation of M, M’ behaves as follows: 1) generates a sequence (m 1, …, m n ) of transitions, 1  m i  c 2) simulates the computation of M using (m 1, …, m n ), and 3) if the computation does not accept the input string, the computation of M’ continues with Step 1. In the worst case, c f(n) sequences are examined for each single computation of M. As the simulation of a computation of M can be performed using O(f(n)) transitions of M’, tc M’ (n)  O(f(n)c f(n) ) in simulating M by M’.

The Classes P and NP n Defn A language L is decidable in polynomial time if there is a standard TM M that accepts L with tc M  O(n r ). The family of languages decidable in polynomial time is denotes P. n Any problem that is polynomially solvable on a standard TM is in P, and the choice of DTM models (e.g., multi-tape, multi- track) for the analysis is invariant. n Defn A language L is accepted in nondeterministic polynomial time if there is a NTM M that accepts L with tc M  O(n r ). The family of languages accepted in non- deterministic polynomial time is denoted NP. n Since every DTM is a NTM, P  NP. n The family NP is a subset of the recursive languages, since the number of transitions ensure all computations terminates

Problem Representation and Complexity n Design a TM M to solve a decision problem R consists of 2 steps: 1. Represent the instances of R as strings 2. Construct M that analyzes the strings and solves R  which requires the discovery of an algorithm to solve R n The time complexity (tc) of a TM relates the length of the input to the number of transitions in the computations, and thus the selection of the representation have direct impacts on the computations. n Example. Given the following TMs M 1 (encodes n as 1 n+1 ) and M 2 (encodes n by the standard binary representation):  where M 1 and M 2 both solve the problem of deciding whether a natural number is even, with the inputs to M 1 using the unary representation and M 2 the binary representation.

Problem Representation and Complexity n Example. (Cont.)  The tc M 1 = tc M 2  O(n) and the difference in representation does not affect the complexity; however, the modification (shown below) has a significant impact on the complexity.  Consider TM M 3, which includes a TM T that transforms an input in binary to its unary in solving the same problem:  The complexity of the new solution, i.e., M 3, is analyzed in the following table, which shows the increase in string length caused by the conversion: M 3 : Binary representation  T  Unary representation  M 1  Yes  No i i1i i = = = i12i String Length Maximum Binary Number Decimal Value Unary Representation

Problem Representation and Complexity n Example. (Cont.)  tc M 3 is determined by the complexity of T and M 1.  For the input of length i, the string 1 i requires the maximum number of transitions of M 3, i.e., tc M 3 (n) = tc T (n) + tc M 1 (2 n ) = tc T (n) + 2 n + 1 which is exponential even without adding tc T. The increase in the complexity is caused by the increase in the length of the input string using the unary representation. (Binary) String Length Max. Binary No. Decimal Value Unary Representation = = = 1 8 i 1 i 2 i i

12 n Decision problems from P and NP 15.4 Decision Problems & Complexity Classes Acceptance of Palindromes Input: String u over alphabet  Output: yes – u is a palindrome no – otherwise Path Problem for Directed Graphs Input: Graph G = (N, A), v i, v j  N Output: yes – if  path(v i, v j ) in G no – otherwise Derivability in CNF Grammar Input: CNF grammar G, string w Output: yes – if S  w no – otherwise * Hamiltonian Circuit Problem Input: Directed graph G = (N, A) Output: yes – if  cycle with each vertex in G no – otherwise Subset Sum Problem Input: Set S, v: S  N, k Output: yes – if  S’ (  S) whose total value is k no – otherwise Each of the NP problems can be solved non- deterministically using a “guess-and-check” strategy Complexity – in P (O(n 2 ), p. 444) Complexity – in P (Dijkstra’s alg: O(n 2 )) Complexity – in P (CYK Alg: O(n 3 ), p. 124) Complexity – in P (unknown) – in NP (Yes)

13 n Reduction is a problem-solving technique employed to  avoid “reinventing the wheel” when encountering a new problem  transform the instances of the new problem into those of a problem that has been solved  establish the decidability and tractability of problems n Defn Let L be a language over alphabet  1 and Q be a language over  2. L is many-to-one reducible to Q if there exists a Turing computable function r :  1 *   2 * such that w  L if, and only if, r(w)  Q.  if a language L is reducible to a decidable language Q by a function r, then L is also decidable Polynomial-Time Reduction

14 n Example (p. 348). Let R be the TM that computes the reduction, i.e., input(L) to input(Q), and M the TM that accepts language Q. The sequential execution of R and M on strings from  1 * accepts language L (by accepting inputs to Q) is  R, the reduction TM, which does not determine membership in either L or Q, transforms strings from  1 * to  2 *.  Strings in Q are determined by M, and strings in L are by the combination of R and M Polynomial-Time Reduction

15 n A reduction of a language L to a language Q transforms the question of membership in L to that of membership in Q.  Let r be a reduction (function) of L to Q computed by a TM R. If Q is accepted by a TM M, then L is accepted by a TM that i) runs R on input string w   1 *, and ii) runs M on r(w). The string r(w) is accepted by M if, and only if, w  L  The time complexity includes i) time required to transform the instances of L, and ii) time required by the solution to Q. n Defn Let L and Q be languages over alphabets  1 and  2, respectively. L is reducible in polynomial time to Q if there is a polynomial-time computable function r :  1   2 such that w  L if, and only if, r(w)  Q Polynomial-Time Reduction

16 n Example (p. 349, 478) Reduces L = { x i y i z k | i  0, k  0 } to Q = {a i b i | i  0} by transforming w  {x, y, z} * to r(w)  {a, b}*.  If w  x * y * z *, replace each ‘x’ by ‘a’ and ‘y’ by ‘b’, and erase the z’s  otherwise, replace w by a single ‘a’ The following TM transforms multiple strings in L to the same string in Q (i.e., a many-to-one reduction): 15.6 Polynomial-Time Reduction Reduction Input Condition L w  {x, y, z}* w  L   r if and only if Q r(w)  {a, b}* r(w)  Q

17 n Theorem Let L be reducible to Q in polynomial time and let Q  P. Then L  P.  Proof. Let R denote the TM that computes the reduction of L to Q and M the TM that decides Q. L is accepted by a TM that sequentially run R and M. A computation of M processes at most tc M (k) transitions, where k is the length of its input string. The number of transitions of the composite TM (i.e., R and M) is bounded by the sum of the estimates of R and M Polynomial-Time Reduction The time complexities tc R and tc M combine to produce an upper bound on the no. of transitions of a computation of the composite TM. The computation of R with input string w generates the string r(w), which is the input to M. The function tc R can be used to establish a bound on the length of r(w). If the input string w to R has length n, then the length of r(w) cannot exceed the max(n, tc R (n)). tc R (n) + tc M (tc R (n))  O(n st ) If tc R  O(n s ) and tc M  O(n t ), then

18 n Example (Continued) Reduces L = { x i y i z k | i  0, k  0 } to Q = { a i b i | i  0 }:  For string n of length  0, tc R (0) =  The worst case occurs for the remainder of the strings when an ‘x’ or ‘y’ follows a ‘z’, i.e., when w is read in q 1, q 2, and q 3, and erased in q 4. The computation is completed by setting r(w) = a, and for n > 1, tc R (n) = 2n + 4.  Combining R and M  The combined TM accepts Q with tc M (n) = 2n 2 + 3n + 1.  Worst-case(tc M ): input a n/2 b n/2, if n is even, or a (n+1)/2 b (n-1)/2, if n is odd  Thus, tc R (n) + tc M (tc R (n)) = (2n + 4) + (2(2n+4) 2 + 3(2n + 4)+ 1)  O(n 2 ) Polynomial-Time Reduction The upper bound in Theorem , i.e., tc R (n) + tc M (tc R (n))  O(n st ). 2, tc R (1)= 4, tc R (2) = 8, etc.

19 n Example. A TM M that accepts Q = { a n b n | n  0 } and its tc: 15.6 Polynomial-Time Reduction q0q0 > B/B RB/B R qfqf a/a R, b/b R q1q1 a/B Ra/B R q2q2 B/B LB/B L q3q3 b/B Lb/B L q4q4 a/a L, b/b L B/B RB/B R B/B LB/B L tc M (n) = 2n 2 + 3n + 1  O(n 2 ) BB q 0 q 1 q f n = 0 BabB q 0 q 1 q 2 q 2 q 4 q 3 q f q 1 n = 1 BaabbB q 0 q 1 q 2 q 2 q 2 q 2 q 4 q 4 q 4 q 3 q 1 q 2 q 2 q 4 q 3 q f q 1 n = 2 B/B/ B/B/ B/B/ B/B/ B/B/ B/B/ n tc M (n)  Iteration Move Steps 1 R 2n+1 L 2n 2 R 2n-1 L 2n-2   

20 n A language accepted in polynomial time by DTM with multi- track or -tape is in P. n The process for constructing an equivalent DTM from a NTM does not preserve polynomial-time complexity. (See Theorem : tc M (n) = f(n)  tc M’ (n)  O(f(n)c f(n) ).) n Due to the additional time complexity of currently known non-deterministic solutions over deterministic solutions across a wide range of important problems, it is generally believe that P  NP. n The P = (  ) NP problem is a precisely formulated mathematical problem and will be resolved only when either (i) n Defn A language Q is called NP-hard if for every L  NP, L is reducible to Q in polynomial time P = NP ? the equality of the two classes, or (ii) P  NP is proved. An NP-hard language that is also in NP is called NP-complete.

21 n Some problems L are so hard that although we can prove they are NP-hard, we cannot prove they are NP-complete, i.e., L  NP. n P = NP, if there exists a polynomial-time TM, which accepts an NP-complete language, can be used to construct TMs to accept every language in NP in deterministic polynomial time. n Theorem If there is an NP-hard language that is also in P, then P = NP.  Proof. Assume that Q is an NP-hard language that is accepted in polynomial time by a DTM, i.e., Q  P P = NP ? Let L  NP. Since (by Defn ) Q is NP-hard, there is a polynomial time reduction of L to Q. By Theorem (which states that if L is reducible to Q in polynomial time and Q  P, then L  P), L  P.L  P.

22 n The class consisting of all NP-complete problems, which is non-empty, is denoted NPC.  If P  NP, then P and NPC are nonempty, disjoint subsets of NP, which is the scenario believed to be true by most mathematicians and computer scientists.  If P = NP, then the two sets collapse to a single class Complexity Class Relations P = NP NPC P P  NP