1 / 23

NP-completeness

Giorgi Japaridze Theory of Computability. NP-completeness. Section 7.4. 7.4.a. Giorgi Japaridze Theory of Computability. Importance. NP-complete problems form a certain important subclass of NP . The phenomenon of NP-completeness was discovered in the early 1970s

mizell
Télécharger la présentation

NP-completeness

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Giorgi Japaridze Theory of Computability NP-completeness Section 7.4

  2. 7.4.a Giorgi JaparidzeTheory of Computability Importance • NP-complete problems form a certain important subclass of NP. The • phenomenon of NP-completeness was discovered in the early 1970s • by Stephen Cook and Leonid Levin. • If a polynomial time algorithm exists for any of the NP-complete • problems, all problems in NP would be polynomial time solvable. • To prove that P=NP, it would be sufficient to take any particular • NP-complete problem A and show that AP. • To prove that P≠NP, it would be sufficient to take any particular • NP-complete problem A and show that AP. • On the practical side, finding that a given problem A is NP-complete • may prevent wasting time looking for a (probably nonexistent, or • unlikely-to-be-found even if exists) polynomial time algorithm for A.

  3. 7.4.b Giorgi JaparidzeTheory of Computability Boolean formulas Boolean variablesx,y,… take one of the two values 0 (false) or 1 (true). Boolean operations:  (NOT),  (AND),  (OR). We write A for A. Boolean formulas are constructed from variables and operations in the standard way. Once a truth assignment for variables is given, the value of a compound formula is calculated as follows: 0 = 1 0  0 = 0 0  0 = 0 1 = 0 0  1 = 0 0  1 = 1 1  0 = 0 1  0 = 1 1  1 = 1 1  1 = 1 (1  (0  1))  (0  1) If x=0 and y=1, what is the value of the following formula? (y  (x  y))  (x  y) (1  (1  0))  (0  0) (1  1 )  0 1  0 1

  4. 7.4.c Giorgi JaparidzeTheory of Computability The SAT problem We say that a Boolean formula is satisfiable iff there is an assignment of 0s and 1s to its variables that makes the formula evaluate to 1. Are the following formulas satisfiable? x(xy) x(xy) SAT = {<> |  is a satisfiable Boolean formula} SAT  P? SAT  NP? Theorem 7.27 (Cook-Levin theorem) SATP iff P=NP.

  5. 7.4.d Giorgi JaparidzeTheory of Computability Definition 7.28 A polynomial time computable function is a function computed by some polynomial time TMO. Polynomial time reducibility Definition 7.29 Let A and B be be languages over an alphabet . We say that A is polynomial time mapping reducible, or simply polynomial time reducible, to B, written APB, if a polynomial time computable function f: * *exists s.t. for every string w*, wA iff f(w)B. Such a function f is called a polynomial time reduction of A to B. Theorem 7.31 If APB and BP, then AP. Proof. Assume M is a polynomial time decider for B, and f is a polynomial time reduction from A to B. The following is a polynomial time algorithm deciding A: N = “On input w: 1. Compute f(w). 2. Run M on input f(w) and do (accept or reject) whatever M does.”

  6. 7.4.e Giorgi JaparidzeTheory of Computability • A literal is a Boolean variable x or a negated Boolean variable x. • A clause is several literals connected with s, as in (x  y  z  t). • A Boolean formula is in conjunctive normal form, called a • cnf-formula, if it comprises several clauses connected with s, as in • (x  y  z  t)  (x  z)  (x  y t) • A cnf-formula is a 3cnf-formula if all the clauses have 3 literals, as in • (x  y  z)  (x  z  t)  (x  y  t) (z  y  t) • 3SAT = {<> |  is a satisfiable 3cnf-formula} The 3SAT problem 3SAT  P? 3SAT  NP?

  7. 7.4.f Giorgi JaparidzeTheory of Computability Reducing 3SAT to CLIQUE (a) Theorem 7.323SAT is polynomial time reducible to CLIQUE. Proof. Let  be a 3cnf-formula with k clauses such as  = (a1 b1 c1)  (a2 b2 c2)  …  (ak bk ck) Our reduction f is going to generate the string <G,k>, where G is an undirected graph defined as follows. The nodes of G are organized into k groups of three nodes each called the triples, t1,…,tk. Each triple corresponds to one of the clauses in , and each node in a triple corresponds to a literal in the associated clause. Label each node of G with its corresponding literal in . The edges of G connect all but two types of pairs of nodes: (1) no edge is present between two nodes in the same triple, and (2) No edge is present between nodes with contradictory labels, as in x and x.

  8. 7.4.g Giorgi JaparidzeTheory of Computability = (x  x z) (x z z)(x z z) For instance, if  is as above, thenGwould be Reducing 3SAT to CLIQUE (b) x z z x x x z z z Obviously transforming into G takes polynomial time. Next we argue that (slide 7.4.h) if 3SAT, then <G,k>CLIQUE, and that (slide 7.4.i) if <G,k>CLIQUE, then3SAT. So, we indeed have a polynomial time reduction.

  9. 7.4.h Giorgi JaparidzeTheory of Computability Reducing 3SAT to CLIQUE (c) x z z x x x z z z = (x  x z) (x z z)(x z z) Suppose has a satisfying assignment. Then at least one literal should be true in each clause. Select one such literal in each clause, and select the corresponding nodes in the graph. Those nodes form a k-clique! Because there are k such nodes, and each pair is connected by an edge because they are in different triples and non-contradictory.

  10. 7.4.i Giorgi JaparidzeTheory of Computability Reducing 3SAT to CLIQUE (d) x z z x x x z x = z = 0 1 z z = (x  x z) (x z z)(x z z) Now suppose G has a k-clique. Each of its nodes should be in different triples as there are no edges within triples. So, each triple has exactly one node of the clique. Select the corresponding literals in , and select an assignment that makes each such literal true. This is possible (why?). Then the same assignment makes true.

  11. 7.4.j Giorgi JaparidzeTheory of Computability Definition of NP-completeness Definition 7.34 A language B is NP-complete if it satisfies two conditions: 1. B is in NP, and 2. every language in NP is polynomial time reducible to B. Theorem 7.35 If a language B is NP-complete and BP, then P=NP. Proof. Immediately from the above clause 2 and Theorem 7.31. Theorem 7.36 If CNP,B is NP-complete and BPC, then C is NP-complete. Proof. We already know that CNP, so we only need to show that APC for every ANP. Consider any ANP. We must have APB, because B is NP-complete. Let f be a polynomial time reduction from A to B. Next, we know that BPC, so let g be a polynomial time reduction from B to C. Let now h be the composition of f and g, that is, h(w) = g(f(w)). It is easy to see that h is a polynomial time reduction from A to C. So, indeed A PC.

  12. 7.4.k Giorgi JaparidzeTheory of Computability The Cook-Levin theorem: Getting started Theorem 7.37 SAT is NP-complete. (The above is just a rephrasing of Theorem 7.27) Proof. That SATNP is obvious (why?). So we only need to show that every language A from NP is polynomial time reducible to SAT. Pick an arbitrary ANP, and N be NTM deciding A. We assume that the running time of N is nk (to be more accurate, nk-3). We are going to show how to turn a string w into a Boolean formula  that “simulates” N on input w in the sense that  is satisfiable iff N accepts w.

  13. 7.4.l Giorgi JaparidzeTheory of Computability A tableau for N on w is an nknk table whose rows are the configurations of a(ny) computation branch of N on input w=w1…wn. The 1st and last columns contain #s. The Cook-Levin theorem: Tableaus - - … - … # q0 w1 w2 wn # 1st (start) configuration # # 2nd configuration # # 3rd configuration nk window # # nkth configuration nk We say that a tableau is accepting if any of its rows is an accepting configuration. Every accepting tableau for N on w corresponds to an accepting computation branch of N on input w. Thus the problem of determining whether N accepts w is equivalent to determining whether there is an accepting tableau for N on w.

  14. 7.4.m Giorgi JaparidzeTheory of Computability The Cook-Levin theorem:  … - - … - # q0 w1 w2 w3 wn # … - - … - # w1 q7 w2 w3 wn # … - - … - # q5 w1 $ w3 wn # We denote by C the set Q{#}, where Q is the set of states of N and  is the tape alphabet. C is thus the set of all possible contents of the cells of the tableau. The cell in row i and column j is called cell[i,j]. For each such cell and each sC, we create a Boolean variable xi,j,s. Its meaning is going to be “cell[i,j] contains symbol s”. Our formula is going to be built from those variables, and we have  = cell  start  move  accept cellasserts that each cell contains exactly one symbol startasserts that the first row is the start configuration on input w moveasserts that rows are related to each other in accordance with the transition function acceptasserts that one of the cells contains the accept state thus asserts that the tableau is for an accepting computation branch, i.e. that wA.

  15. 7.4.n Giorgi JaparidzeTheory of Computability ( xi,j,s) sC (  (xi,j,s xi,j,t))  [ (xi,j,s )  (  (xi,j,s xi,j,t) )] s,tC s≠t 1i,jnk sC s,tC s≠t cell asserts that each cell contains exactly one symbol The Cook-Levin theorem: cell xi,j,s “cell[i,j] contains symbol s” = “cell[i,j] contains at least one symbol” = (xi,j,s xi,j,t) “cell[i,j] does not contain both s and t” = “cell[i,j] contains at most one symbol” = “each cell “cell[i,j] contains exactly one symbol” cell

  16. 7.4.o Giorgi JaparidzeTheory of Computability x1,1,#  x1,2,q0  x1,3,w1  x1,4,w2  …  x1,n+2,wn  x1,n+3,-  … x1,nk-1,-  x1,nk,# The Cook-Levin theorem: start start asserts that the first row is the start configuration on input w - - … - … # q0 w1 w2 wn # 1st (start) configuration x1,1,# “cell[1,1] contains #” = “cell[1,2] contains q0” = x1,2,q0 … start =

  17. 7.4.p Giorgi JaparidzeTheory of Computability xi,j,qaccept 1i,jnk The Cook-Levin theorem: accept accept asserts that one of the cells contains the accept state xi,j,qaccept “cell[i,j] contains qaccept” = accept =

  18. 7.4.q Giorgi JaparidzeTheory of Computability The Cook-Levin theorem: Windows 1 2 3 … j … 1 2 3 . . . the (i,j) window i a1 a2 a3 a4 a5 a6 . . . We say that (the content of) a window is legal if it(s content) could appear in some (legal) tableau for N.

  19. 7.4.r Giorgi JaparidzeTheory of Computability a b a a # b a a a b q1 q1 b b q1 b q1 a b b a a a b b b q1 a c # a a q2 a q1 q2 a b a a b b a b a a q2 b q2 a b q2 c a The Cook-Levin theorem: Examples of legal and illegal windows Where  is the transition function of N, assume we have (q1,a) = {(q1,b,R)} and (q1,b) = {(q2,c,L),(q2,a,R)}. Are the following windows legal or illegal?

  20. 7.4.s Giorgi JaparidzeTheory of Computability x b q1 y ? b ? Claim 7.41 If the top row of the tableau is the start configuration and every window in the tableau is legal, then each row in the tableau is a configuration that legally follows the preceding one. The Cook-Levin theorem: Claim about windows Proof. Consider any two adjacent rows (configurations). In the upper configuration, every cell that isn’t adjacent to a state symbol and doesn’t contain the boundary symbol #, is the center top cell in a window whose top row contains no states. Therefore that symbol, in a legal window, must appear unchanged in the center bottom of the window. Hence it appears (as it should) in the same position in the bottom configuration. The window containing the state symbol in the center top cell guarantees that the corresponding three positions are updated consistently with the transition function. Therefore, if the upper configuration is a legal configuration, so is the lower configuration, and the lower one follows the upper one according to N’s rules.

  21. 7.4.t Giorgi JaparidzeTheory of Computability Let us say that a 6-tuple (a1,a2,a3,a4,a5,a6) of symbols from C is legal ifthe window on the right is legal. Notice that the number of legal 6-tuples is fixed and it does not depend on w. BTW, at most how many legal 6-tuples could exist? a1 a2 a3 a4 a5 a6  (xi,j-1,a1  xi+1,j+1,a6 ) xi,j,a2  xi,j+1,a3  xi+1,j-1,a4  xi+1,j,a5  (a1,…,a6) is legal  (the (i,j) window is legal) 1 i nk-1 2 j nk-1 The Cook-Levin theorem: move moveasserts that rows are related to each other in accordance with the transition function |C|6 “the content of cell[i,j] is (a1,…,a6)” “the (i,j) window is legal” move =

  22. 7.4.u Giorgi JaparidzeTheory of Computability Our reduction does nothing but builds , so its time complexity is asymptotically the same as the size of . We want to see this size is polynomial in n. For this, in turn, it would be sufficient to verify the polynomiality (in n) of the four conjuncts of . The Cook-Levin theorem: The complexity of the reduction What is the size of start? What is the size of accept? What is the size of cell? What is the size of move? The complexity of our reduction is thus O(n2k), i.e. polynomial.

  23. 7.4.v Giorgi JaparidzeTheory of Computability The NP-completeness of 3SAT Corollary 7.423SAT is NP-complete. Proof. From logic, a polynomial-time-computable function f: {<> |  is a(ny) Boolean formula}  {<> |  is a 3cnf-formula} is known such that, for any Boolean formula , we have  is satisfiable iff f() is satisfiable. Thus, f is a polynomial time reduction from SAT to 3SAT. Hence, in view of the already known NP-completeness of SAT together with Theorem 7.36, we find that 3SAT is NP-complete. The book gives a slightly different and full proof of this result.

More Related