#  2004 SDU Lecture17-P,NP, NPC.  2004 SDU 2 1.Decision problem and language decision problem decision problem and language 2.P and NP Definitions of.

## Presentation on theme: " 2004 SDU Lecture17-P,NP, NPC.  2004 SDU 2 1.Decision problem and language decision problem decision problem and language 2.P and NP Definitions of."— Presentation transcript:

 2004 SDU Lecture17-P,NP, NPC

 2004 SDU 2 1.Decision problem and language decision problem decision problem and language 2.P and NP Definitions of P and NP 3.Polynomial reduction and NP-complete Definition of polynomial reduction Definition of NP-complete 4.Cook’s theorem The first NP-complete problem Concepts concerning NP- completeness

 2004 SDU 3 Why decision problem? 1.Easy to give uniform definition, and thus convenient to study 2.Many optimization problems can be converted to decision problems. E.g., TSP. Optimization version: Given n cities and the distances between them. Find the shortest tour that visits each city exactly once. Decision version: Given n cities and the distance between them, and an integer K. Does there exist a tour that visits each city exactly once and with cost less than K? 3. The proof of the first NPC problem use the uniform descriptions of problems in NP. Formal description of a decision problem: Describe the parameters of instances and the yes-no problem. Input: Given two graphs G1=(V1,E1) and G2=(V2,E2) Question: Does G1 contain a sub-graph that is isomorphic to G2? Decision problem

 2004 SDU 4 TSP:  = {c,[,],/,0,1,2,3,4,5,6,7,8,9,#} c[1]c[2]c[3]c[4]//10/5/9//6/9//3#25 Language: Let  be a finite set of characters,  * be the set of all the finite strings over . Then any subset of  * is called a language on . Decision problem лdescribed as language: Under a coding system, each instance is coded as a string I. All the instances form the language D л. The “yes” instances form the language Y л. Then for each I  Dл, is I  Yл? Language and decision problem

 2004 SDU 5 Solve decision problem  by algorithms  Decide language D  by a Turing machine. For a decision problem , there may be many coding systems. U. w. l. g., we mean a reasonable coding system: No redundant characters Numbers are coded in binary (What happens if in unary?) Decodable Under different reasonable coding systems, the lengths of instances: D  Z + are polynomial related, i.e., suppose e, e’ be two reasonable coding systems, the lengths of instance I under e and e’ are L[I] and L’[I], respectively, then there are polynomials P and P’ such that L’[I]  P(L[I]), L[I]  P’(L’[I]) Language and decision problem

 2004 SDU 6 Class P: The set of decision problems that can be solved in polynomial time. Class NP: The set of decision problems that can be verified in polynomial time (also called solved non-deterministically). An algorithm A verifies a decision problem  : For an instance I  D , A first guesses a witness y, and then on input, it produces an answer. And I  Y   there exists a witness y ， such that A answers “yes” on input. Polynomial verifier A: There exists polynomial P, such that on each input, A halts in P(length[I]) time. P and NP -- Informal definitions

 2004 SDU 7 1. The length of guess “y” is no more than P(length[I]) 2. For an “yes” instance I  Y  ， there exists at least one such witness y ， such that on input, A answers “yes”. 3. Such a verifier could be viewed as an infinite parallel machine that on an instance I, guesses all the witnesses and if on one witness, one process answers “yes”, then the whole machine halts and answers “yes”. The shortest time for answering “yes” can be the running time on this instance. Notes on NP!

 2004 SDU 8 A decision problem  and its complement  c.  : given an instance I ， ask if X holds?  c : given an instance I ， ask if X does not hold? i.e., D  =D  c, Y  =D  c － Y  c, Y  c =D  － Y .  P   c  P  NP   c  NP? Not necessarily. e.g., Hamilton cycle problem and its complement. Non-symmetric of NP

 2004 SDU 9 P={L: there exists polynomial Turing Machine M such that L=L M } NP={L: there exists polynomial non-deterministic Turing Machine such that L=L M } P and NP—formal definitions

 2004 SDU 10 P  NP P = NP ? P and NP—relationships

 2004 SDU 11 Theorem: If L  NP, then there exists polynomial P such that L can be solved by a DTM in O(2 P(n) ) time. proof. L  NP, then there exists NDTM M, and polynomial q, such that on each x  L,|x|=n, there exists a witness y, |y|  q(n), such that M answers “yes” on in q(n) time. Note that the number of witnesses shorter than q(n) is at most K q(n), K=|  |. Construct DTM M’ as follows: On instance I, write all the witnesses y shorter than q(n) one by one, and on, simulate the verifying process of M. If on one such y, M answers “yes” within q(n) steps, then M’ answers “Yes” and halt; if on all such y’s, M answers “no”, then M’ answers “no”. Obviously L M’ = L M. Time(M’)= O(K q(n) q(n)) = O(2 P(n) ) How hard is problem in NP?

 2004 SDU 12 Polynomial reduction: Let  1,  2 be two decision problems. If there exists a function f: D  1  D  2, such that I. f can be computed in polynomial time II.  I  D  1, I  Y  1  f(I)  Y  2 then we say that f is a polynomial reduction from  1 o  2, and that  1 is polynomial reduced to  2, denoted as  1   2. Steps to construct reduction ： 1.Construct function f: D  1  D  2, that is, for each instance I in D  1, construct an instance f(I) of D  2 2.Prove that I  Y  1  f(I)  Y  2 3.Prove f(I) can be constructed in polynomial time. Polynomial Reduction

 2004 SDU 13 HC  TSP HC : Given a graph G=(V,E), does there exist a tour that visits each vertex exactly once? TSP ： Given cities C={c1,c2,…,cm}, and integers d(ci,cj) ， 1  i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4035316/slides/slide_13.jpg", "name": " 2004 SDU 13 HC  TSP HC : Given a graph G=(V,E), does there exist a tour that visits each vertex exactly once.", "description": "TSP ： Given cities C={c1,c2,…,cm}, and integers d(ci,cj) ， 1  i

 2004 SDU 14 Conclusion: f is a polynomial reduction from HC to TSP. Proof. 1. If G has a HC, then is also a tour in f(G). Obviously each edge on this tour has length 1, hence, the total length of this tour is m. Hence, f(G) is also a “yes” instance of TSP. The opposite. Suppose is a tour of f(G) no more than B. Then since each edge has length either 1 or 2, and since there are B edges on the tour, each edge on the tour must have length 1. Thus proves that this tour is also a HC of G. 2. Concerning polynomial. We have to construct m(m-1)/2 d(vi, vj), i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4035316/slides/slide_14.jpg", "name": " 2004 SDU 14 Conclusion: f is a polynomial reduction from HC to TSP.", "description": "Proof. 1. If G has a HC, then is also a tour in f(G). Obviously each edge on this tour has length 1, hence, the total length of this tour is m. Hence, f(G) is also a yes instance of TSP. The opposite. Suppose is a tour of f(G) no more than B. Then since each edge has length either 1 or 2, and since there are B edges on the tour, each edge on the tour must have length 1. Thus proves that this tour is also a HC of G. 2. Concerning polynomial. We have to construct m(m-1)/2 d(vi, vj), i

 2004 SDU 15 1 ） If L1  L2, then L2  P  L1  P. 2 ） If L1  L2, L2  L3, then L1  L3. Proof ? Polynomial Reduction--properties

 2004 SDU 16 NP-complete: If L  NP, and for each L’  NP, L’  L, then we call L NP-complete. Denote L  NPC. Properties of NP-completeness （ 1 ） If L1,L2  NP, L1  NPC, and L1  L2, then L2  NPC. （ 2 ） If L  NPC, then L  P  P = NP. （ 3 ） If P  NP, then NPC  P= . Proofs? NP-complete

 2004 SDU 17 A boolean formula (in conjunctive normal form)is a conjunction of clauses: A finite set of boolean variables: U={u 1,u 2,...,u m } Literals: u and  u Clause: disjunction of finite literals Truth assignment for a boolean formula: A set of values for the variables. Satisfying assignment: A truth assignment that causes a formula to evaluate to 1. SAT problem: Given a boolean formula, does there exist a satisfying assignment? Cook’s theorem—the first NPC problem

 2004 SDU 18 Cook’s Theorem: SAT is in NPC. 1. SAT  NP. A verifier is as follows: Guesses a truth assignment for an input instance, and then tests whether this is a satisfying assignment. This can be finished within polynomial time. 2.For each L  NP, L  SAT. The proof is left to the interested people. Cook’s theorem—the first NPC problem There are many other NPC problems, you may find one…

Download ppt " 2004 SDU Lecture17-P,NP, NPC.  2004 SDU 2 1.Decision problem and language decision problem decision problem and language 2.P and NP Definitions of."

Similar presentations