NP-completeness Section 7.4 Giorgi Japaridze Theory of Computability.

Slides:



Advertisements
Similar presentations
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Advertisements

Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
The class NP Section 7.3 Giorgi Japaridze Theory of Computability.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
NL equals coNL Section 8.6 Giorgi Japaridze Theory of Computability.
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
Complexity 11-1 Complexity Andrei Bulatov Space Complexity.
Computability and Complexity 14-1 Computability and Complexity Andrei Bulatov Cook’s Theorem.
NP-completeness Sipser 7.4 (pages 271 – 283). CS 311 Mount Holyoke College 2 The classes P and NP NP = ∪ k NTIME(n k ) P = ∪ k TIME(n k )
NP-completeness Sipser 7.4 (pages 271 – 283). CS 311 Fall The classes P and NP NP = ∪ k NTIME(n k ) P = ∪ k TIME(n k )
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
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-Completeness CS 51 Summer 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AA A A AAA.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
NP-Complete Problems Problems in Computer Science are classified into
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
Time Complexity.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
Clique Cover Cook’s Theorem 3SAT and Independent Set
February 20, 2015CS21 Lecture 191 CS21 Decidability and Tractability Lecture 19 February 20, 2015.
1 The Cook-Levin Theorem Zeph Grunschlag. 2 Announcements Last HW due Thursday Please give feedback about course at oracle.seas.columbia.edu/wces oracle.seas.columbia.edu/wces.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
PSPACE-Completeness Section 8.3 Giorgi Japaridze Theory of Computability.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
Lecture 22 More NPC problems
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
Computational Complexity Theory Lecture 2: Reductions, NP-completeness, Cook-Levin theorem Indian Institute of Science.
Theory of Computing Lecture 17 MAS 714 Hartmut Klauck.
NP Complexity By Mussie Araya. What is NP Complexity? Formal Definition: NP is the set of decision problems solvable in polynomial time by a non- deterministic.
MCS 312: NP Completeness and Approximation algorthms Instructor Neelima Gupta
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA.
Complexity 25-1 Complexity Andrei Bulatov Counting Problems.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSC401 – Analysis of Algorithms Chapter 13 NP-Completeness Objectives: Introduce the definitions of P and NP problems Introduce the definitions of NP-hard.
Additional NP-complete problems
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
NP-Algorithms Tractable vs Intractable Some problems are intractable: as they grow large, we are unable to solve them in reasonable time.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong The Cook-Levin.
NP-completeness Class of hard problems. Jaruloj ChongstitvatanaNP-complete Problems2 Outline  Introduction  Problems and Languages Turing machines and.
CS 461 – Nov. 30 Section 7.5 How to show a problem is NP-complete –Show it’s in NP. –Show that it corresponds to another problem already known to be NP-complete.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
CSC 413/513: Intro to Algorithms
NP-complete Languages
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong NP-complete.
Complexity ©D.Moshkovitz 1 Our First NP-Complete Problem The Cook-Levin theorem A B C.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
1 Design and Analysis of Algorithms Yoram Moses Lecture 13 June 17, 2010
 2005 SDU Lecture15 P,NP,NP-complete.  2005 SDU 2 The PATH problem PATH = { | G is a directed graph that has a directed path from s to t} s t
P & NP.
NP-complete problems The Chinese University of Hong Kong Fall 2008
Intro to Theory of Computation
Intro to Theory of Computation
Theory of Computability
Theory of Computability
Additional NP-complete problems
CSC 4170 Theory of Computation The class NP Section 7.3.
CS154, Lecture 13: P vs NP.
Our First NP-Complete Problem
Instructor: Aaron Roth
Instructor: Aaron Roth
Lecture 23 NP-Hard Problems
Presentation transcript:

NP-completeness Section 7.4 Giorgi Japaridze Theory of Computability

Importance 7.4.a Giorgi Japaridze Theory of Computability 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.

Boolean formulas 7.4.b Giorgi Japaridze Theory of Computability Boolean variables x,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 If x=0 and y=1, what is the value of the following formula? ( y  (x  y) )  (x  y) ( 1  (0  1) )  (0  1) ( 1  (1  0) )  (0  0) (1  1 )  0 1  0 1

The SAT problem 7.4.c Giorgi Japaridze Theory of Computability 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?

Polynomial time reducibility 7.4.d Giorgi Japaridze Theory of Computability Definition 7.28 A polynomial time computable function is a function computed by some polynomial time TMO. 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  P B, 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  P B 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.”

The 3SAT problem 7.4.e Giorgi Japaridze Theory 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} 3SAT  P? 3SAT  NP?

Reducing 3SAT to CLIQUE (a) 7.4.f Giorgi Japaridze Theory of Computability Theorem SAT is polynomial time reducible to CLIQUE. Proof. Let  be a 3cnf-formula with k clauses such as  = (a 1  b 1  c 1 )  (a 2  b 2  c 2 )  …  (a k  b k  c k ) Our reduction f is going to generate the string, 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, t 1,…,t k. 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.

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

Reducing 3SAT to CLIQUE (c) 7.4.h Giorgi Japaridze Theory of Computability x z z zzx z x x  = (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.

Reducing 3SAT to CLIQUE (d) 7.4.i Giorgi Japaridze Theory of Computability x z z zzx z x x  = (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. x = z = 0101

Definition of NP-completeness 7.4.j Giorgi Japaridze Theory of Computability 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 Theorem 7.36 If C  NP, B is NP-complete and B  P C, then C is NP-complete. Proof. We already know that C  NP, so we only need to show that A  P C for every A  NP. Consider any A  NP. We must have A  P B, because B is NP-complete. Let f be a polynomial time reduction from A to B. Next, we know that B  P C, 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  P C.

Cook-Levin theorem: Getting started 7.4.k Giorgi Japaridze Theory of Computability Theorem 7.37 (Cook-Levin Theorem) SAT is NP-complete. 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 n k (to be more accurate, n k -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.

Cook-Levin theorem: Tableaus 7.4.l Giorgi Japaridze Theory of Computability A tableau for N on w is an n k  n k table whose rows are the configurations of a(ny) computation branch of N on input w=w 1 …w n. The 1 st and last columns contain #s. 1 st (start) configuration # # # # # # # # q0q0 w1w1 w2w2 … wnwn - - … 2 nd configuration n k th configuration window nknk nknk 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. 3 rd configuration -

Cook-Levin theorem:  7.4.m Giorgi Japaridze Theory of Computability # # # # # # q0q0 w1w1 w2w2 … wnwn - - …- wnwn wnwn … … … … - - q7q7 w2w2 w1w1 w1w1 $q5q5 w3w3 w3w3 w3w3 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 x i,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  cell asserts that each cell contains exactly one symbol  start asserts that the first row is the start configuration on input w  move asserts that rows are related to each other in accordance with the transition function  accept asserts 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.

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

Cook-Levin theorem:  start 7.4.o Giorgi Japaridze Theory of Computability  start asserts that the first row is the start configuration on input w “cell[1,1] contains #” = x 1,1,# 1 st (start) configuration ##q0q0 w1w1 w2w2 … wnwn - - …- “cell[1,2] contains q 0 ” =x 1,2,q 0 …  start = x 1,1,#  x 1,2,q 0  x 1,3,w 1  x 1,4,w 2  …  x 1,n+2,w n  x 1,n+3, -  … x 1,n k -1, -  x 1,n k,#

Cook-Levin theorem:  accept 7.4.p Giorgi Japaridze Theory of Computability  accept asserts that one of the cells contains the accept state “cell[i,j] contains q accept ” = x i,j,q accept  accept =  x i,j,q accept 1  i,j  n k

Cook-Levin theorem: Windows 7.4.q Giorgi Japaridze Theory of Computability … j … the (i,j) window i... a1a1 a2a2 a3a3 a4a4 a5a5 a6a6... We say that (the content of) a window is legal if it(s content) could appear in some (legal) tableau for N.

Cook-Levin theorem: Examples of legal and illegal windows 7.4.r Giorgi Japaridze Theory of Computability Where  is the transition function of N, assume we have  (q 1,a) = {(q 1,b,R)} and  (q 1,b) = {(q 2,c,L),(q 2,a,R)}. Are the following windows legal or illegal? q1q1 q2q2 ab ac q1q1 a ab aq2q2 a a aq1q1 ab b # #a ba b a aa bq2q2 b c bb bb b a aa aa q1q1 q1q1 ab aa q1q1 q2q2 bb bq2q2

Cook-Levin theorem: Claim about windows 7.4.s Giorgi Japaridze Theory of Computability 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. 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. b ? xy b? 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. q 1

Cook-Levin theorem:  move 7.4.t Giorgi Japaridze Theory of Computability  move asserts that rows are related to each other in accordance with the transition function Let us say that a 6-tuple (a 1,a 2,a 3,a 4,a 5,a 6 ) of symbols from C is legal if the 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? a2a2 a1a1 a3a3 a4a4 a5a5 a6a6 |C| 6 “the content of cell[i,j] is (a 1,…,a 6 )” ( x i,j-1,a 1  x i,j,a 2  x i,j+1,a 3  x i+1,j-1,a 4  x i+1,j,a 5  x i+1,j+1,a 6 ) “the (i,j) window is legal”  (a 1,…,a 6 ) is legal  move =  1  i  n k -1 2  j  n k -1 (the (i,j) window is legal)

Cook-Levin theorem: The complexity of the reduction 7.4.u Giorgi Japaridze Theory 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 . 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(n 2k ), i.e. polynomial.

Cook-Levin theorem: Wrapping it up 7.4.v Giorgi Japaridze Theory of Computability It remains to understand why our reduction is indeed a reduction, i.e., why it is the case that w  A iff  is satisfiable. (  ) Assume w  A. Then N accepts w, i.e. there is an accepting computation branch of N on input w. Construct a tableau that describes such a branch. Then declare each variable x i,j,s to be true iff, in that tableau, cell[i,j] contains symbol s. Obviously this truth assignment satisfies . (  ) Assume  is satisfiable, i.e. there is an assignment that makes  true. Fix it. Construct a tableau by putting symbol s in cell[i,j] iff x i,j,s is true (the truth of  cell guarantees that such a construction is possible and unique). Obviously such a tableau describes a certain accepting computation branch of N on input w. Thus, N accepts w, meaning that w  A.

The NP-completeness of 3SAT 7.4.w Giorgi Japaridze Theory of Computability Corollary SAT 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.