Computational Complexity Theory Lecture 2: Reductions, NP-completeness, Cook-Levin theorem Indian Institute of Science.

Slides:



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

Complexity Classes: P and NP
 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.
The class NP Section 7.3 Giorgi Japaridze Theory of Computability.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
Complexity class NP Is the class of languages that can be verified by a polynomial-time algorithm. L = { x in {0,1}* | there exists a certificate y with.
The Theory of NP-Completeness
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Complexity 12-1 Complexity Andrei Bulatov Non-Deterministic Space.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
1 L is in NP means: There is a language L’ in P and a polynomial p so that L 1 · L 2 means: For some polynomial time computable map r : 8 x: x 2 L 1 iff.
Computability and Complexity 14-1 Computability and Complexity Andrei Bulatov Cook’s Theorem.
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
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 )
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Read sections 7.1 – 7.3 of the book for next time.
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.
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
Submitted by : Estrella Eisenberg Yair Kaufman Ohad Lipsky Riva Gonen Shalom.
Analysis of Algorithms CS 477/677
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
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.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Definition: Let M be a deterministic Turing Machine that halts on all inputs. Space Complexity of M is the function f:N  N, where f(n) is the maximum.
1 L is in NP means: There is a language L’ in P and a polynomial p so that L 1 ≤ L 2 means: For some polynomial time computable map r : x: x L 1 iff r(x)
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.
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.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
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.
Theory of Computing Lecture 17 MAS 714 Hartmut Klauck.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
CSCI 2670 Introduction to Theory of Computing December 1, 2004.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 P P := the class of decision problems (languages) decided by a Turing machine so that for some polynomial p and all x, the machine terminates after at.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1. 2 Lecture outline Basic definitions: Basic definitions: P, NP complexity classes P, NP complexity classes the notion of a certificate. the notion of.
NP-completeness Section 7.4 Giorgi Japaridze Theory of Computability.
NP-completeness Class of hard problems. Jaruloj ChongstitvatanaNP-complete Problems2 Outline  Introduction  Problems and Languages Turing machines and.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
Fall 2013 CMU CS Computational Complexity Lecture 2 Diagonalization, 9/12/2013.
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.
Theory of Computational Complexity Yuji Ishikawa Avis lab. M1.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
1 SAT SAT: Given a Boolean function in CNF representation, is there a way to assign truth values to the variables so that the function evaluates to true?
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
NP-Completeness A problem is NP-complete if: It is in NP
Computational Complexity Theory
L is in NP means: There is a language L’ in P and a polynomial p so that L1 ≤ L2 means: For some polynomial time computable map r :  x: x  L1 iff.
Computational Complexity Theory
CS154, Lecture 13: P vs NP.
Recall last lecture and Nondeterministic TMs
CS21 Decidability and Tractability
Umans Complexity Theory Lectures
Our First NP-Complete Problem
Instructor: Aaron Roth
Instructor: Aaron Roth
Theory of Computability
Intro to Theory of Computation
Presentation transcript:

Computational Complexity Theory Lecture 2: Reductions, NP-completeness, Cook-Levin theorem Indian Institute of Science

Recap: Class P and FP A language L ⊆ {0,1}* is in P if  There’s a (deterministic) poly-time TM M such that  for every x ∈ {0,1}*, x ∈ L iff M(x) = 1

Recap: Class P and FP A language L ⊆ {0,1}* is in P if  There’s a (deterministic) poly-time TM M such that  for every x ∈ {0,1}*, x ∈ L iff M(x) = 1 A function f: {0,1}* {0,1}* is in FP if  There’s a (deterministic) poly-time TM M such that  for every x ∈ {0,1}*, M(x) = f(x)

Recap: Class P and FP A language L ⊆ {0,1}* is in P if  There’s a (deterministic) poly-time TM M such that  for every x ∈ {0,1}*, x ∈ L iff M(x) = 1 A function f: {0,1}* {0,1}* is in FP if  There’s a (deterministic) poly-time TM M such that  for every x ∈ {0,1}*, M(x) = f(x) Obviously, |f(x)| ≤ |x| c for some constant c

Recap: Class P and FP A language L ⊆ {0,1}* is in P if  There’s a (deterministic) poly-time TM M such that  for every x ∈ {0,1}*, x ∈ L iff M(x) = 1 A function f: {0,1}* {0,1}* is in FP if  There’s a (deterministic) poly-time TM M such that  for every x ∈ {0,1}*, M(x) = f(x) We say f is poly-time computable

Recap: Class NP A language L ⊆ {0,1}* is in NP if  There’s a poly-time verifier M such that  x ∈ L iff there’s a poly-size certificate u s.t M(x,u) = 1

Recap: Class NP A language L ⊆ {0,1}* is in NP if  There’s a poly-time verifier M such that  x ∈ L iff there’s a poly-size certificate u s.t M(x,u) = 1  Note that verifier cannot be fooled.

Recap: Class NP A language L ⊆ {0,1}* is in NP if  There’s a poly-time verifier M such that  x ∈ L iff there’s a poly-size certificate u s.t M(x,u) = 1  Note that verifier cannot be fooled. Linear Programming (search version): Given m constraints of the form a 1 x 1 + … + a n x n ≤ b where a i ’s are rationals, check if there exists an assignment of rational numbers to the x i ’s that satisfy all constraints.

Recap: Class NP A language L ⊆ {0,1}* is in NP if  There’s a poly-time verifier M such that  x ∈ L iff there’s a poly-size certificate u s.t M(x,u) = 1  Note that verifier cannot be fooled. Assignment problem: Prove that Linear Programming is in NP.

Nondeterministic Turing Machines A nondeterministic Turing machine is like a deterministic Turing machines but with two transition functions. It is formally defined by a tuple ( Γ, Q, δ 0, δ 1 ).

Nondeterministic Turing Machines A nondeterministic Turing machine is like a deterministic Turing machines but with two transition functions. It is formally defined by a tuple ( Γ, Q, δ 0, δ 1 ). It has a special state q accept in addition to q start and q halt.

Nondeterministic Turing Machines A nondeterministic Turing machine is like a deterministic Turing machines but with two transition functions. It is formally defined by a tuple ( Γ, Q, δ 0, δ 1 ). It has a special state q accept in addition to q start and q halt. At every step of computation, the machine applies one of two functions δ 0 and δ 1 arbitrarily.

Nondeterministic Turing Machines A nondeterministic Turing machine is like a deterministic Turing machines but with two transition functions. It is formally defined by a tuple ( Γ, Q, δ 0, δ 1 ). It has a special state q accept in addition to q start and q halt. At every step of computation, the machine applies one of two functions δ 0 and δ 1 arbitrarily. this is different from randomly

Nondeterministic Turing Machines A nondeterministic Turing machine is like a deterministic Turing machines but with two transition functions. It is formally defined by a tuple ( Γ, Q, δ 0, δ 1 ). It has a special state q accept in addition to q start and q halt. At every step of computation, the machine applies one of two functions δ 0 and δ 1 arbitrarily. also called nondeterministically

Nondeterministic Turing Machines A nondeterministic Turing machine is like a deterministic Turing machines but with two transition functions. It is formally defined by a tuple ( Γ, Q, δ 0, δ 1 ). It has a special state q accept in addition to q start and q halt. At every step of computation, the machine applies one of two functions δ 0 and δ 1 arbitrarily. Unlike DTMs, NTMs are not intended to be physically realizable (because of the arbitrary nature of application of the transition functions).

Nondeterministic Turing Machines Definition. An NTM M accepts a string x ∈ {0,1}* iff on input x there exists a sequence of applications of the transition functions δ 0 and δ 1 (beginning from the start configuration) that makes M reach q accept.

Nondeterministic Turing Machines Definition. An NTM M accepts a string x ∈ {0,1}* iff on input x there exists a sequence of applications of the transition functions δ 0 and δ 1 (beginning from the start configuration) that makes M reach q accept. Defintion. An NTM M decides a language L ⊆ {0,1}* if  M accepts x x ∈ L  On every sequence of applications of the transition functions on input x, M either reaches q accept or q halt.

Nondeterministic Turing Machines Definition. An NTM M accepts a string x ∈ {0,1}* iff on input x there exists a sequence of applications of the transition functions δ 0 and δ 1 (beginning from the start configuration) that makes M reach q accept. Defintion. An NTM M decides a language L ⊆ {0,1}* if  M accepts x x ∈ L  On every sequence of applications of the transition functions on input x, M either reaches q accept or q halt. remember in this course we’ll always be dealing with TMs that halt on every input.

Nondeterministic Turing Machines Definition. An NTM M accepts a string x ∈ {0,1}* iff on input x there exists a sequence of applications of the transition functions δ 0 and δ 1 (beginning from the start configuration) that makes M reach q accept. Defintion. An NTM M decides L in T(|x|) time if  M accepts x x ∈ L  On every sequence of applications of the transition functions on input x, M either reaches q accept or q halt within T(|x|) steps of computation.

Class NTIME Definition. A language L is in NTIME(T(n)) if there’s an NTM M that decides L in c. T(n) time on inputs of length n, where c is a constant.

Alternate characterization of NP Definition. A language L is in NTIME(T(n)) if there’s an NTM M that decides L in c. T(n) time on inputs of length n, where c is a constant. Theorem. NP = ∪ NTIME (n c ). c > 0

Alternate characterization of NP Definition. A language L is in NTIME(T(n)) if there’s an NTM M that decides L in c. T(n) time on inputs of length n, where c is a constant. Theorem. NP = ∪ NTIME (n c ). Proof sketch: Let L be a language in NP. Then, there’s a poly-time verifier M s.t, x ∈ L ∃ u ∈ {0,1} p(|x|) s.t. M(x, u) = 1 c > 0

Alternate characterization of NP Definition. A language L is in NTIME(T(n)) if there’s an NTM M that decides L in c. T(n) time on inputs of length n, where c is a constant. Theorem. NP = ∪ NTIME (n c ). Proof sketch: Let L be a language in NP. Then, there’s a poly-time verifier M s.t, x ∈ L ∃ u ∈ {0,1} p(|x|) s.t. M(x, u) = 1 Think of an NTM M’ that on input x, at first guesses a u ∈ {0,1} p(|x|) by applying δ 0 and δ 1 nondeterministically c > 0

Alternate characterization of NP Definition. A language L is in NTIME(T(n)) if there’s an NTM M that decides L in c. T(n) time on inputs of length n, where c is a constant. Theorem. NP = ∪ NTIME (n c ). Proof sketch: Let L be a language in NP. Then, there’s a poly-time verifier M s.t, x ∈ L ∃ u ∈ {0,1} p(|x|) s.t. M(x, u) = 1 …. and then simulates M on (x, u) to verify M(x,u) = 1. c > 0

Alternate characterization of NP Definition. A language L is in NTIME(T(n)) if there’s an NTM M that decides L in c. T(n) time on inputs of length n, where c is a constant. Theorem. NP = ∪ NTIME (n c ). Proof sketch: Let L be in NTIME (n c ). Then, there’s an NTM M’ that decides L in p(n) = O(n c ) time. (|x| = n) c > 0

Alternate characterization of NP Definition. A language L is in NTIME(T(n)) if there’s an NTM M that decides L in c. T(n) time on inputs of length n, where c is a constant. Theorem. NP = ∪ NTIME (n c ). Proof sketch: Let L be in NTIME (n c ). Then, there’s an NTM M’ that decides L in p(n) = O(n c ) time. (|x| = n) Think of a verifier M that takes x and u ∈ {0,1} p(n) as input, c > 0

Alternate characterization of NP Definition. A language L is in NTIME(T(n)) if there’s an NTM M that decides L in c. T(n) time on inputs of length n, where c is a constant. Theorem. NP = ∪ NTIME (n c ). Proof sketch: Let L be in NTIME (n c ). Then, there’s an NTM M’ that decides L in p(n) = O(n c ) time. (|x| = n) Think of a verifier M that takes x and u ∈ {0,1} p(n) as input, and simulates M’ on x with u as the sequence of choices for applying δ 0 and δ 1. c > 0

Alternate characterization of NP Definition. A language L is in NTIME(T(n)) if there’s an NTM M that decides L in c. T(n) time on inputs of length n, where c is a constant. Theorem. NP = ∪ NTIME (n c ). Proof sketch: (home work) Fill in the details… c > 0

Polynomial time reduction Definition. We say a language L 1 ⊆ {0,1}* is polynomial time (Karp) reducible to a language L 2 ⊆ {0,1}* if there’s a polynomial time computable function f s.t. x ∈ L 1 f(x) ∈ L 2

Polynomial time reduction Definition. We say a language L 1 ⊆ {0,1}* is polynomial time (Karp) reducible to a language L 2 ⊆ {0,1}* if there’s a polynomial time computable function f s.t. x ∈ L 1 f(x) ∈ L 2 L1L1 L1L1 L2L2 L2L2 f(L 1 )

Polynomial time reduction Definition. We say a language L 1 ⊆ {0,1}* is polynomial time (Karp) reducible to a language L 2 ⊆ {0,1}* if there’s a polynomial time computable function f s.t. x ∈ L 1 f(x) ∈ L 2 L1L1 L1L1 L2L2 L2L2 f(L 1 )

Polynomial time reduction Definition. We say a language L 1 ⊆ {0,1}* is polynomial time (Karp) reducible to a language L 2 ⊆ {0,1}* if there’s a polynomial time computable function f s.t. x ∈ L 1 f(x) ∈ L 2 L1L1 L1L1 L2L2 L2L2 f(L 1 )

Polynomial time reduction Definition. We say a language L 1 ⊆ {0,1}* is polynomial time (Karp) reducible to a language L 2 ⊆ {0,1}* if there’s a polynomial time computable function f s.t. x ∈ L 1 f(x) ∈ L 2 Notation. L 1 ≤ p L 2

Polynomial time reduction Definition. We say a language L 1 ⊆ {0,1}* is polynomial time (Karp) reducible to a language L 2 ⊆ {0,1}* if there’s a polynomial time computable function f s.t. x ∈ L 1 f(x) ∈ L 2 Notation. L 1 ≤ p L 2 Theorem. (Transitivity) If L 1 ≤ p L 2 and L 2 ≤ p L 3 then L 1 ≤ p L 3.

Polynomial time reduction Definition. We say a language L 1 ⊆ {0,1}* is polynomial time (Karp) reducible to a language L 2 ⊆ {0,1}* if there’s a polynomial time computable function f s.t. x ∈ L 1 f(x) ∈ L 2 Notation. L 1 ≤ p L 2 Theorem. (Transitivity) If L 1 ≤ p L 2 and L 2 ≤ p L 3 then L 1 ≤ p L 3. Proof: Excercise

NP-completeness Definition. A language L’ is NP-hard if for every L in NP, L ≤ p L’.

NP-completeness Definition. A language L’ is NP-hard if for every L in NP, L ≤ p L’. Further, L’ is NP-complete if L’ is in NP and is NP-hard.

NP-completeness Theorem. If L’ is NP-hard and L’ is in P then P = NP.

NP-completeness Definition. A language L’ is NP-hard if for every L in NP, L ≤ p L’. Further, L’ is NP-complete if L’ is in NP and is NP-hard. Theorem. If L’ is NP-hard and L’ is in P then P = NP. If L’ is NP-complete then L’ in P if and only if P = NP.

NP-completeness Definition. A language L’ is NP-hard if for every L in NP, L ≤ p L’. Further, L’ is NP-complete if L’ is in NP and is NP-hard. Theorem. If L’ is NP-hard and L’ is in P then P = NP. If L’ is NP-complete then L’ in P if and only if P = NP. Proof. Home work

NP-completeness Definition. A language L’ is NP-hard if for every L in NP, L ≤ p L’. Further, L’ is NP-complete if L’ is in NP and is NP-hard. Theorem. If L’ is NP-hard and L’ is in P then P = NP. If L’ is NP-complete then L’ in P if and only if P = NP. P NPC NP Hardest problems inside NP in the sense that if one NPC problem is in P then all problems in NP is in P.

NP-completeness Definition. A language L’ is NP-hard if for every L in NP, L ≤ p L’. Further, L’ is NP-complete if L’ is in NP and is NP-hard. Theorem. If L’ is NP-hard and L’ is in P then P = NP. If L’ is NP-complete then L’ in P if and only if P = NP. Exercise. Let L 1 ⊆ {0,1}* be any language and L 2 be a language in NP. If L 1 ≤ p L 2 then L 1 is also in NP.

A few words on reductions As to how we define a reduction from one language to the other (or one function to the other) is usually guided by a question on whether two complexity classes are different or identical.

A few words on reductions As to how we define a reduction from one language to the other (or one function to the other) is usually guided by a question on whether two complexity classes are different or identical. For polynomial time reductions, the question is whether P equals NP.

A few words on reductions As to how we define a reduction from one language to the other (or one function to the other) is usually guided by a question on whether two complexity classes are different or identical. For polynomial time reductions, the question is whether P equals NP. Reductions help us define complete problems (the ‘hardest’ problems in a class) which in turn help us compare the complexity classes under consideration.

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps }

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete.

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. Clearly L’ is in NP. Think of a verifier M that on input ( α, x, 1 m, 1 t ) and u,

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. Clearly L’ is in NP. Think of a verifier M that on input ( α, x, 1 m, 1 t ) and u,  checks if u has length m,

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. Clearly L’ is in NP. Think of a verifier M that on input ( α, x, 1 m, 1 t ) and u,  checks if u has length m,  simulates M α on (x, u) for t steps,

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. Clearly L’ is in NP. Think of a verifier M that on input ( α, x, 1 m, 1 t ) and u,  checks if u has length m,  simulates M α on (x, u) for t steps,  and accepts iff M α accepts.

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. L’ is in NP-hard.

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. L’ is in NP-hard. Let L be a language in NP. Then L has a verifier M α s.t.

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. L’ is in NP-hard. Let L be a language in NP. Then L has a verifier M α s.t.  string representation of M α is α,

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. L’ is in NP-hard. Let L be a language in NP. Then L has a verifier M α s.t.  string representation of M α is α,  x ∈ L ∃ u ∈ {0,1} p(|x|) s.t. M(x, u) = 1

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. L’ is in NP-hard. Let L be a language in NP. Then L has a verifier M α s.t.  string representation of M α is α,  x ∈ L ∃ u ∈ {0,1} p(|x|) s.t. M(x, u) = 1  Running time of M α is poly(|x,u|) = q(|x|), say.

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. L’ is in NP-hard. Let L be a language in NP. Now think of the following map. x ( α, x, 1 p(|x|), 1 q(|x|) ) f

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Proof. L’ is in NP-hard. Let L be a language in NP. Now think of the following map. x ∈ L iff f(x) ∈ L’

NP-complete problem: First example Let L’ = { ( α, x, 1 m, 1 t ) : there exists a u ∈ {0,1} m s.t. M α accepts (x, u) in t steps } Observation. L’ is NP-complete. Exercise. To see the importance of 1 m and 1 t in the definition of the language L’, try to drop any of them and prove that L’ is NP-complete.

A natural NP-complete problem The language L’ involves Turing machine in its definition. Next, we’ll see an example of an NP-complete problem that is arguably more natural.

A natural NP-complete problem The language L’ involves Turing machine in its definition. Next, we’ll see an example of an NP-complete problem that is arguably more natural. Definition. A boolean formula on variables x 1, …, x n consists of AND, OR and NOT operations. e.g. ϕ = (x 1 ∨ x 2 ) ∧ (x 3 ∨ ¬x 2 )

A natural NP-complete problem The language L’ involves Turing machine in its definition. Next, we’ll see an example of an NP-complete problem that is arguably more natural. Definition. A boolean formula on variables x 1, …, x n consists of AND, OR and NOT operations. e.g. ϕ = (x 1 ∨ x 2 ) ∧ (x 3 ∨ ¬x 2 ) Definition. A boolean formula ϕ is satisfiable if there’s a {0,1}-assignment to its variables that makes ϕ evaluate to 1.

A natural NP-complete problem Definition. A boolean formula is in Conjunctive Normal Form (CNF) if it is an AND of OR of literals. e.g. ϕ = (x 1 ∨ x 2 ) ∧ (x 3 ∨ ¬x 2 )

A natural NP-complete problem Definition. A boolean formula is in Conjunctive Normal Form (CNF) if it is an AND of OR of literals. e.g. ϕ = (x 1 ∨ x 2 ) ∧ (x 3 ∨ ¬x 2 ) clauses

A natural NP-complete problem Definition. A boolean formula is in Conjunctive Normal Form (CNF) if it is an AND of OR of literals. e.g. ϕ = (x 1 ∨ x 2 ) ∧ (x 3 ∨ ¬x 2 ) literals

A natural NP-complete problem Definition. A boolean formula is in Conjunctive Normal Form (CNF) if it is an AND of OR of literals. e.g. ϕ = (x 1 ∨ x 2 ) ∧ (x 3 ∨ ¬x 2 ) Definition. Let SAT be the language consisting of all satisfiable CNF formulae.

A natural NP-complete problem Definition. A boolean formula is in Conjunctive Normal Form (CNF) if it is an AND of OR of literals. e.g. ϕ = (x 1 ∨ x 2 ) ∧ (x 3 ∨ ¬x 2 ) Definition. Let SAT be the language consisting of all satisfiable CNF formulae. Theorem. (Cook-Levin) SAT is NP-complete.

A natural NP-complete problem Definition. A boolean formula is in Conjunctive Normal Form (CNF) if it is an AND of OR of literals. e.g. ϕ = (x 1 ∨ x 2 ) ∧ (x 3 ∨ ¬x 2 ) Definition. Let SAT be the language consisting of all satisfiable CNF formulae. Theorem. (Cook-Levin) SAT is NP-complete. Easy to see that SAT is in NP. Need to show that SAT is NP-hard.

Cook-Levin theorem: Proof Main idea: Computation is local;

Cook-Levin theorem: Proof Main idea: Computation is local; i.e. every step of computation looks at and changes only constantly many bits;

Cook-Levin theorem: Proof Main idea: Computation is local; i.e. every step of computation looks at and changes only constantly many bits; and hence this step can be implemented by a small CNF formula.

Cook-Levin theorem: Proof Main idea: Computation is local; i.e. every step of computation looks at and changes only constantly many bits; and hence this step can be implemented by a small CNF formula. Let L ∈ NP. We intend to come up with a polynomial time computable function f: x ϕ x s.t.,  x ∈ L ϕ x ∈ SAT

Cook-Levin theorem: Proof Main idea: Computation is local; i.e. every step of computation looks at and changes only constantly many bits; and hence this step can be implemented by a small CNF formula. Let L ∈ NP. We intend to come up with a polynomial time computable function f: x ϕ x s.t.,  x ∈ L ϕ x ∈ SAT  Note: | ϕ x | := number of ∨ or ∧ symbols in ϕ x ≤ |x| c

Cook-Levin theorem: Proof Language L has a poly-time verifier M such that x ∈ L ∃ u ∈ {0,1} p(|x|) s.t. M(x, u) = 1

Cook-Levin theorem: Proof Language L has a poly-time verifier M such that x ∈ L ∃ u ∈ {0,1} p(|x|) s.t. M(x, u) = 1 Idea: Capture the computation of M(x,..) by a CNF ϕ x such that ∃ u ∈ {0,1} p(|x|) s.t. M(x, u) = 1 ϕ x is satisfiable

Cook-Levin theorem: Proof Language L has a poly-time verifier M such that x ∈ L ∃ u ∈ {0,1} p(|x|) s.t. M(x, u) = 1 Idea: Capture the computation of M(x,..) by a CNF ϕ x such that ∃ u ∈ {0,1} p(|x|) s.t. M(x, u) = 1 ϕ x is satisfiable For any fixed x, M(x,..) is a deterministic TM that takes u as input and runs in time polynomial in |u|.

Cook-Levin theorem: Proof Theorem. Let N be a deterministic TM that runs in time T(n) on inputs of length n, and outputs 0 or 1. Then,

Cook-Levin theorem: Proof Theorem. Let N be a deterministic TM that runs in time T(n) on inputs of length n, and outputs 0 or 1. Then, 1.There’s a CNF ϕ of size poly(T(n)) such that ϕ (u, “additional variables”) is satisfiable if and only if N(u) =1, for every input u of size n.

Cook-Levin theorem: Proof Theorem. Let N be a deterministic TM that runs in time T(n) on inputs of length n, and outputs 0 or 1. Then, 1.There’s a CNF ϕ of size poly(T(n)) such that ϕ (u, “additional variables”) is satisfiable if and only if N(u) =1, for every input u of size n. 2. ϕ is computable in time poly(T(n)).

Cook-Levin theorem: Proof Theorem. Let N be a deterministic TM that runs in time T(n) on inputs of length n, and outputs 0 or 1. Then, 1.There’s a CNF ϕ of size poly(T(n)) such that ϕ (u, “additional variables”) is satisfiable if and only if N(u) =1, for every input u of size n. 2. ϕ is computable in time poly(T(n)). Cook-Levin theorem follows from above.

Cook-Levin theorem: Proof Assume (w.l.o.g) that N has a single tape and it writes its output on the first cell at the end of computation.

Cook-Levin theorem: Proof Assume (w.l.o.g) that N has a single tape and it writes its output on the first cell at the end of computation. A step of computation of N consists of  Changing the content of the current cell  Changing state  Changing head position

Cook-Levin theorem: Proof Assume (w.l.o.g) that N has a single tape and it writes its output on the first cell at the end of computation. A step of computation of N consists of  Changing the content of the current cell  Changing state  Changing head position Think of a ‘compound’ tape in which every cell stores the current state and a head indicator in addition to its bit content.

Cook-Levin theorem: Proof …. A compund tape a cell

Cook-Levin theorem: Proof …. A compund tape a cell h bQ

Cook-Levin theorem: Proof …. A compund tape a cell h bQ h = 1 if head points to this cell = 0 otherwise

Cook-Levin theorem: Proof …. A compund tape a cell h bQ 0/1 bit content of this cell

Cook-Levin theorem: Proof …. A compund tape a cell h bQ Current state when h = 1; otherwise we don’t care

Cook-Levin theorem: Proof …. A compund tape a cell Computation of N can be completely described by a sequence of T(n) compound tapes, the i-th of which captures a `snapshot’ of N’s computation at the i-th step.

Cook-Levin theorem: Proof …. A compund tape a cellq start u first input bit

Cook-Levin theorem: Proof …. A compund tape a cellq start u …. q start u 1 0 2

Cook-Levin theorem: Proof …. A compund tape a cellq start u …. q start u …. T(n) q accept o/p

Cook-Levin theorem: Proof …. A compund tape a cellq start u …. q start u …. T(n) q accept o/p T(n) cells

Cook-Levin theorem: Proof …. cell j q i,j b i,j h i,j i …. h i,j = 1 iff head points to cell j at i-th step b i,j = bit content of cell j at i-th step

Cook-Levin theorem: Proof …. cell j q i,j b i,j h i,j i …. h i,j = 1 iff head points to cell j at i-th step b i,j = bit content of cell j at i-th step q i,j = a sequence of log |Q| bits which contains the current state info if h i,j = 1; otherwise don’t care

Cook-Levin theorem: Proof …. cell j q i,j b i,j h i,j i …. Think of h i,j, b i,j and the bits of q i,j as formal boolean variables.

Cook-Levin theorem: Proof …. cell j q i,j b i,j h i,j i …. Locality of computation: The variables h i,j, b i,j and q i,j depends only on the variables  h i-1,j-1, b i-1,j-1, q i-1,j-1,  h i-1,j, b i-1,j, q i-1,j, and  h i-1,j+1, b i-1,j+1, q i-1,j+1 …. cell j q i-1,j b i-1,j h i-1,j i-1 …. q i-1,j-1 b i-1,j-1 h i-1,j-1 q i-1,j+1 b i-1,j+1 h i-1,j+1 cell j-1cell j+1

Cook-Levin theorem: Proof Hence, b ij = B ij ( h i-1,j-1, b i-1,j-1, q i-1,j-1, h i-1,j, b i-1,j, q i-1,j, h i-1,j+1, b i-1,j+1, q i-1,j+1 ) = a fixed function of the arguments depending only on N’s transition function δ.

Cook-Levin theorem: Proof Hence, b ij = B ij ( h i-1,j-1, b i-1,j-1, q i-1,j-1, h i-1,j, b i-1,j, q i-1,j, h i-1,j+1, b i-1,j+1, q i-1,j+1 ) = a fixed function of the arguments depending only on N’s transition function δ. The above equality can be captured by a constant size CNF Ψ ij. Also, Ψ ij is easily computable from δ.

Cook-Levin theorem: Proof Similarly, h ij = H ij ( h i-1,j-1, b i-1,j-1, q i-1,j-1, h i-1,j, b i-1,j, q i-1,j, h i-1,j+1, b i-1,j+1, q i-1,j+1 ) = a fixed function of the arguments depending only on N’s transition function δ. The above equality can be captured by a constant size CNF Φ ij. Also, Φ ij is easily computable from δ.

Cook-Levin theorem: Proof Similarly, q ijk = C ijk ( h i-1,j-1, b i-1,j-1, q i-1,j-1, h i-1,j, b i-1,j, q i-1,j, h i-1,j+1, b i-1,j+1, q i-1,j+1 ) = a fixed function of the arguments depending only on N’s transition function δ. The above equality can be captured by a constant size CNF θ ijk. Also, θ ijk is easily computable from δ.

Cook-Levin theorem: Proof Similarly, q ijk = C ijk ( h i-1,j-1, b i-1,j-1, q i-1,j-1, h i-1,j, b i-1,j, q i-1,j, h i-1,j+1, b i-1,j+1, q i-1,j+1 ) = a fixed function of the arguments depending only on N’s transition function δ. The above equality can be captured by a constant size CNF θ ijk. Also, θ ijk is easily computable from δ. k-th bit of q ij where 1 ≤ k ≤ log |Q|

Cook-Levin theorem: Proof Observe that a computation of N is valid if and only if Ψ ij, Φ ij and θ ijk are satisfied for all i, j and k.

Cook-Levin theorem: Proof Observe that a computation of N is valid if and only if Ψ ij, Φ ij and θ ijk are satisfied for all i, j and k.  i ∈ [1, T(n)],  j ∈ [1, T(n)], and  k ∈ [1, log |Q|]

Cook-Levin theorem: Proof Observe that a computation of N is valid if and only if Ψ ij, Φ ij and θ ijk are satisfied for all i, j and k. Let λ be the conjunction of Ψ ij, Φ ij and θ ijk for all i, j and k. Size of λ is O(T(n) 2 ).

Cook-Levin theorem: Proof Observe that a computation of N is valid if and only if Ψ ij, Φ ij and θ ijk are satisfied for all i, j and k. Let λ be the conjunction of Ψ ij, Φ ij and θ ijk for all i, j and k. Size of λ is O(T(n) 2 ). N accepts u if and only if the computation is valid (i.e. λ is satisfied), and N outputs 1 (i.e. b T(n),1 = 1)

Cook-Levin theorem: Proof Observe that a computation of N is valid if and only if Ψ ij, Φ ij and θ ijk are satisfied for all i, j and k. Let λ be the conjunction of Ψ ij, Φ ij and θ ijk for all i, j and k. Size of λ is O(T(n) 2 ). N accepts u if and only if the computation is valid (i.e. λ is satisfied), and N outputs 1 (i.e. b T(n),1 = 1). Define ϕ = λ ∧ (b T(n),1 = 1)

Cook-Levin theorem: Proof Observe that a computation of N is valid if and only if Ψ ij, Φ ij and θ ijk are satisfied for all i, j and k. Let λ be the conjunction of Ψ ij, Φ ij and θ ijk for all i, j and k. Size of λ is O(T(n) 2 ). N accepts u if and only if the computation is valid (i.e. λ is satisfied), and N outputs 1 (i.e. b T(n),1 = 1). Define ϕ = λ ∧ (b T(n),1 = 1) Convert to CNF

Cook-Levin theorem: Proof ϕ is a CNF of size O(T(n) 2 ) and is also computable from N in O(T(n) 2 ) time.

Cook-Levin theorem: Proof ϕ is a CNF of size O(T(n) 2 ) and is also computable from N in O(T(n) 2 ) time. ϕ is a function of u (the input) and some “additional variables” (the b ij, h ij and q ijk variables).

Cook-Levin theorem: Proof ϕ is a CNF of size O(T(n) 2 ) and is also computable from N in O(T(n) 2 ) time. ϕ is a function of u (the input) and some “additional variables” (the b ij, h ij and q ijk variables). ϕ (u, “additional variables”) is satisfiable if and only if N(u) =1.

Cook-Levin theorem: Proof ϕ is a CNF of size O(T(n) 2 ) and is also computable from N in O(T(n) 2 ) time. ϕ is a function of u (the input) and some “additional variables” (the b ij, h ij and q ijk variables). ϕ (u, “additional variables”) is satisfiable if and only if N(u) =1. Q.E.D

Cook-Levin theorem: Comments With some more effort, size ϕ can be brought down to O(T(n). log T(n)).

Cook-Levin theorem: Comments With some more effort, size ϕ can be brought down to O(T(n). log T(n)). The reduction from N, u to ϕ (u, …) is not just a poly- time reduction, it is actually a log-space reduction (we’ll define this later).

Cook-Levin theorem: Comments With some more effort, size ϕ can be brought down to O(T(n). log T(n)). The reduction from N, u to ϕ (u, …) is not just a poly- time reduction, it is actually a log-space reduction (we’ll define this later). Observe that once u is fixed the values of the “additional variables” are also determined

Cook-Levin theorem: Comments With some more effort, size ϕ can be brought down to O(T(n). log T(n)). The reduction from N, u to ϕ (u, …) is not just a poly- time reduction, it is actually a log-space reduction (we’ll define this later). Observe that once u is fixed the values of the “additional variables” are also determined (in polynomial time).

Cook-Levin theorem: Comments With some more effort, size ϕ can be brought down to O(T(n). log T(n)). The reduction from N, u to ϕ (u, …) is not just a poly- time reduction, it is actually a log-space reduction (we’ll define this later). Each clause of ϕ has only constantly many literals.