Lecture 16: Time Complexity and P vs NP

Similar documents
Finish K-Complexity, Start Time Complexity

CS154, Lecture 13: P vs NP

CS154, Lecture 13: P vs NP

TIME COMPLEXITY AND POLYNOMIAL TIME; NON DETERMINISTIC TURING MACHINES AND NP. THURSDAY Mar 20

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) Spring l. Blum TIME COMPLEXITY AND POLYNOMIAL TIME;

Chapter 7: Time Complexity

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

Theory of Computation Time Complexity

Time Complexity. CS60001: Foundations of Computing Science

COMPLEXITY THEORY. PSPACE = SPACE(n k ) k N. NPSPACE = NSPACE(n k ) 10/30/2012. Space Complexity: Savitch's Theorem and PSPACE- Completeness

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 Theory of Computation

Lecture 17: Cook-Levin Theorem, NP-Complete Problems

CISC 4090 Theory of Computation

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved!

CSE 135: Introduction to Theory of Computation NP-completeness

BBM402-Lecture 11: The Class NP

Time Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)

CS154, Lecture 17: conp, Oracles again, Space Complexity

Computability Theory

Lecture 21: Space Complexity (The Final Exam Frontier?)

Complexity (Pre Lecture)

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine.

Harvard CS 121 and CSCI E-121 Lecture 20: Polynomial Time

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete)

CSE 105 THEORY OF COMPUTATION

Advanced Topics in Theoretical Computer Science

Time-Space Tradeoffs for SAT

Computational complexity

Complexity Theory Part II

Lecture 19: Finish NP-Completeness, conp and Friends

Lecture 20: conp and Friends, Oracles in Complexity Theory

Could we potentially place A in a smaller complexity class if we consider other computational models?

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

satisfiability (sat) Satisfiability unsatisfiability (unsat or sat complement) and validity Any Expression φ Can Be Converted into CNFs and DNFs

CS151 Complexity Theory. Lecture 1 April 3, 2017

Intro to Theory of Computation

CS Lecture 28 P, NP, and NP-Completeness. Fall 2008

Theory of Computation

The Polynomial Hierarchy

Computability and Complexity

Applied Computer Science II Chapter 7: Time Complexity. Prof. Dr. Luc De Raedt. Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

Notes for Lecture Notes 2

Computational Models Lecture 11, Spring 2009

Theory of Computation CS3102 Spring 2015 A tale of computers, math, problem solving, life, love and tragic death

Friday Four Square! Today at 4:15PM, Outside Gates

q FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) Spring L. Blum. REVIEW for Midterm 2 TURING MACHINE

Complexity: moving from qualitative to quantitative considerations

1 Computational Problems

1 Non-deterministic Turing Machine

Welcome to... Problem Analysis and Complexity Theory , 3 VU

22c:135 Theory of Computation. Analyzing an Algorithm. Simplifying Conventions. Example computation. How much time does M1 take to decide A?

Lecture 2 (Notes) 1. The book Computational Complexity: A Modern Approach by Sanjeev Arora and Boaz Barak;

Lecture 6: Oracle TMs, Diagonalization Limits, Space Complexity

Review of Basic Computational Complexity

NP-Completeness and Boolean Satisfiability

Computability Theory. CS215, Lecture 6,

Lecture 3: Nondeterminism, NP, and NP-completeness

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

De Morgan s a Laws. De Morgan s laws say that. (φ 1 φ 2 ) = φ 1 φ 2, (φ 1 φ 2 ) = φ 1 φ 2.

Computational Complexity

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

Definition: conp = { L L NP } What does a conp computation look like?

Polynomial time reduction and NP-completeness. Exploring some time complexity limits of polynomial time algorithmic solutions

Decidability and Undecidability

CMPT 710/407 - Complexity Theory Lecture 4: Complexity Classes, Completeness, Linear Speedup, and Hierarchy Theorems

SOLUTION: SOLUTION: SOLUTION:

NP, polynomial-time mapping reductions, and NP-completeness

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan August 30, Notes for Lecture 1

Exam Computability and Complexity

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

conp, Oracles, Space Complexity

NP-Completeness. A language B is NP-complete iff B NP. This property means B is NP hard

MTAT Complexity Theory October 20th-21st, Lecture 7

Time Complexity. Definition. Let t : n n be a function. NTIME(t(n)) = {L L is a language decidable by a O(t(n)) deterministic TM}

Complexity. Complexity Theory Lecture 3. Decidability and Complexity. Complexity Classes

The Complexity of Optimization Problems

Lecture 2: Tape reduction and Time Hierarchy

TURING MAHINES

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

CSCE 551 Final Exam, Spring 2004 Answer Key

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Lecture 3: Reductions and Completeness

Computability and Complexity CISC462, Fall 2018, Space complexity 1

NP-Complete Problems. More reductions

Computational Intractability 2010/4/15. Lecture 2

DRAFT. Diagonalization. Chapter 4

Chapter 1 - Time and Space Complexity. deterministic and non-deterministic Turing machine time and space complexity classes P, NP, PSPACE, NPSPACE

1 Showing Recognizability

ECE 695 Numerical Simulations Lecture 2: Computability and NPhardness. Prof. Peter Bermel January 11, 2017

: Computational Complexity Lecture 3 ITCS, Tsinghua Univesity, Fall October 2007

Intro to Theory of Computation

P and NP. Or, how to make $1,000,000.

On the Computational Hardness of Graph Coloring

Transcription:

6.045 Lecture 16: Time Complexity and P vs NP 1

Time-Bounded Complexity Classes Definition: TIME(t(n)) = { L there is a Turing machine M with time complexity O(t(n)) so that L = L(M) } = { L L is a language decided by a Turing machine with c t(n) + c running time } We showed: A = { 0 k 1 k k 0 } TIME(n log n) Puzzle: Show A TIME( (n log n)/loglog n) 2

An Efficient Universal TM Theorem: There is a (one-tape) Turing machine U which takes as input: - the code of an arbitrary TM M - an input string w - and a string of t 1s, t > w such that U(M, w, 1 t ) halts in O( M 2 t 2 ) steps and U accepts (M, w, 1 t ) M accepts w in t steps The Universal TM with a Clock Idea: Make a multi-tape TM U that does the above, and runs in O( M t) steps. Convert to one-tape TM. 3

The Time Hierarchy Theorem Intuition: If you get more time to compute, then you can solve strictly more problems. Theorem: For all reasonable f, g : N! N where for all n, g(n) > n 2 f(n) 2, TIME(f(n)) TIME(g(n)) Proof Idea: Diagonalization with a clock Make a TM N that on input M, simulates the TM M on input M for f( M ) steps, then flips the answer. We will show L(N) cannot have time complexity f(n) 4

The Time Hierarchy Theorem Theorem: For reasonable f, g where g(n) > n 2 f(n) 2, TIME(f(n)) TIME(g(n)) Proof Sketch: Define a TM N as follows: N(M) = Compute t = f( M ) Run U(M, M, 1 t ) and output the opposite answer. Claim: L(N) does not have time complexity f(n). Proof: Assume N runs in f(n) time, and L(N ) = L(N). By assumption, N (N ) runs in f( N ) time and outputs the opposite answer of U(N, N, 1 f( N ) ) So N (N ) accepts U(N, N, 1 f( N ) ) rejects N (N ) rejects in f( N ) steps [U is universal] This is a contradiction! 5

The Time Hierarchy Theorem Theorem: For reasonable f, g where g(n) > n 2 f(n) 2, TIME(f(n)) TIME(g(n)) Proof Sketch: Define a TM N as follows: N(M) = Compute t = f( M ) Run U(M, M, 1 t ) and output the opposite answer. So, L(N) does not have time complexity f(n). For what functions g(n) will N run in O(g(n)) time? 1. Compute t = f( M ) in O(g( M )) time [ reasonable ] 2. Run U(M, M, 1 t ) in O(g( M )) time Recall: U(M, w, 1 t ) halts in O( M 2 t 2 ) steps So set g(n) so that g( M ) > M 2 f( M ) 2 for all n. QED Remark: Time hierarchy also holds for multitape TMs! 6

The Time Hierarchy Theorem Theorem: For reasonable f, g where g(n) > n 2 f(n) 2, TIME(f(n)) TIME(g(n)) Proof Sketch: Define a TM N with Σ = 0, 1 as follows: N(0 c 1M) = Compute t = c f( 0 c 1M ) + c Run U(M, 0 c 1M, 1 t ) and output opposite answer. Claim: L(N) does not have time complexity O(f(n)). Proof: Assume N runs in c f(n) + c time, and L(N ) = L(N). Therefore N (0 c 1N ) runs in c f( 0 c 1N ) + c time and outputs the opposite of U(N, 0 c 1N, 1 c f( 0 c1n )+c ) So N (0 c 1N ) accepts U(N, 0 c 1N, 1 c f( 0 c1n )+c ) rejects N (0 c 1N ) rejects in c f( N ) + c time This is a contradiction! 7

The Time Hierarchy Theorem Theorem: For reasonable f, g where g(n) > n 2 f(n) 2, TIME(f(n)) TIME(g(n)) Proof Sketch: Define a TM N with Σ = 0, 1 as follows: N(0 c 1M) = Compute t = c f( 0 c 1M ) + c Run U(M, 0 c 1M, 1 t ) and output opposite answer. So, L(N) does not have time complexity f(n). For what functions g(n) will N run in O(g(n)) time? 1. Compute t = c f( 0 c 1M ) + c in O(g( 0 c 1M )) time 2. Simulate U(M, 0 c 1M, 1 t ) in O(g( 0 c 1M )) time Recall: U(M, w, 1 t ) halts in O( M 2 t 2 ) steps Set g(n) s.t. g( 0 c 1M ) > M 2 (c f( 0 c 1M ) + c) 2 for all n. Remark: Time hierarchy also holds for multitape TMs! 8

A Better Time Hierarchy Theorem Theorem: For reasonable f, g where g(n) > f(n) log 2 f(n), TIME(f(n)) TIME(g(n)) Corollary: TIME(n) TIME(n 2 ) TIME(n 3 ) There is an infinite hierarchy of increasingly more time-consuming problems Question: Are there important everyday problems that are high up in this time hierarchy? A natural problem that needs exactly n 10 time? THIS IS AN OPEN QUESTION! 9

k N P = TIME(n k ) Polynomial Time The analogue of decidability in the world of complexity theory 10

The EXTENDED Church-Turing Thesis Everyone s Intuitive Notion of Efficient Algorithms = Polynomial-Time Turing Machines A controversial (dead?) thesis! Counterexamples include n 100 time algorithms, randomized algorithms, quantum algorithms, 11

Nondeterminism and NP 12

Nondeterministic Turing Machines are just like standard TMs, except: 1. The machine may proceed according to several possible transitions (like an NFA) 2. The machine accepts an input string if there exists an accepting computation history for the machine on the string 13

read write move 0 0, R 0 0, R, R q accept, R 0 0, R q reject 14

Definition: A nondeterministic TM is a 7-tuple T = (Q, Σ, Γ,, q 0, q accept, q reject ), where: Q is a finite set of states Σ is the input alphabet, where Σ Γ is the tape alphabet, where Γ and Σ Γ : Q Γ 2 (Q Γ {L,R}) q 0 Q is the start state q accept Q is the accept state q reject Q is the reject state, and q reject q accept 15

Defining Acceptance for NTMs Let N be a nondeterministic Turing machine An accepting computation history for N on w is a sequence of configurations C 0,C 1,,C t where 1. C 0 is the start configuration q 0 w, 2. C t is an accepting configuration, 3. Each configuration C i yields C i+1 Def. N(w) accepts in t time Such a history exists N has time complexity T(n) if for all n, for all inputs of length n and for all histories, N halts in T(n) time 16

Definition: NTIME(t(n)) = { L L is decided by a O(t(n)) time nondeterministic Turing machine } Note: TIME(t(n)) NTIME(t(n)) Is TIME(t(n)) = NTIME(t(n)) for all t(n)? THIS IS AN OPEN QUESTION! What can be done in short NTIME that cannot be done in short TIME? 17

Boolean Formulas logical parentheses operations A satisfying assignment is a setting of the variables that makes the formula true = ( x y) z x = 1, y = 1, z = 1 is a satisfying assignment for Boolean variables (0 or 1) (x y) (z x) 0 0 1 0 18

A Boolean formula is satisfiable if there exists a true/false setting to the variables that makes the formula true YES NO a b c d (x y) x SAT = { is a satisfiable Boolean formula } (How are we encoding formulas? In a reasonable way!) Encoding: takes formula φ of n symbols, and outputs O(n c ) bits Decoding: takes O(n c ) bits and i, and outputs i-th symbol of φ 19

A 3cnf-formula has the form: (x 1 x 2 x 3 ) (x 4 x 2 x 5 ) (x 3 x 2 x 1 ) literals clauses Ex: (x 1 x 2 x 1 ) (x 3 x 1 ) (x 3 x 2 x 1 ) (x 1 x 2 x 3 ) ( x 4 x 2 x 1 ) (x 3 x 1 x 1 ) (x 1 x 2 x 3 ) (x 3 x 2 x 1 ) 3SAT = { is a satisfiable 3cnf-formula } 20

3SAT = { is a satisfiable 3cnf-formula } Theorem: 3SAT NTIME(n c ) for some constant c > 1 Proof Idea: On input : 1. Check if the formula is in 3cnf 2. For each variable v in, nondeterministically substitute either 0 or 1 in place of v ( x y x ) ( 0 y 0 ) ( 1 y 1 ) ( 0 0 0 ) ( 0 1 0 ) 3. Evaluate the formula and accept iff is true 21

NP = NTIME(n k ) k N Nondeterministic Polynomial Time The analogue of recognizability 22

Theorem: L NP There is a constant k and polynomial-time TM V such that L = { x y ϵ Σ* [ y x k and V(x,y) accepts ] } Proof: (1) If L = { x y y x k and V(x,y) accepts } then L NP Given the poly-time TM V, our NP machine for L is: N(x): Nondeterministically guess y. Run V(x,y) (2) If L NP then L = { x y y x k and V(x,y) accepts } Let N be a nondet. poly-time TM that decides L. Define a TM V(x,y) which accepts y encodes an accepting computation history of N on x 23

Moral: A language L is in NP if and only if there are polynomial-length proofs for membership in L 3SAT = { y such that is in 3cnf and y is a satisfying assignment to } SAT = { y such that is a Boolean formula and y is a satisfying assignment to } 24

NP = Problems with the property that, once you have the answer, it is easy to verify the answer SAT is in NP because a satisfying assignment is a polynomial-length proof that a formula is satisfiable When ϵ SAT, I can prove that fact to you with a short proof you can quickly verify 25

The Hamiltonian Path Problem b f e g a d i c h A Hamiltonian path traverses through each node exactly once 26

Assume a reasonable encoding of graphs (example: the adjacency matrix is reasonable) HAMPATH = { (G,s,t) G is a directed graph with a Hamiltonian path from s to t } Theorem: HAMPATH NP A Hamiltonian path P in G from s to t is a proof that (G,s,t) is in HAMPATH Given P (as a permutation on the nodes) can easily check that it is a path through all nodes exactly once 27

The k-clique Problem a d f c b e g k-clique = complete subgraph on k nodes 28

CLIQUE = { (G,k) G is an undirected graph with a k-clique } Theorem: CLIQUE NP A k-clique in G is a proof that (G, k) is in CLIQUE Given a subset S of k nodes from G, we can efficiently check that all possible edges are present between the nodes in S 29

A language is in NP if and only if there are polynomial-length proofs for membership in the language P = the problems that can be efficiently solved NP = the problems where proposed solutions can be efficiently verified Is P = NP? can problem solving be automated? 30

$$$ P = NP? $$$ 31

If P = NP Mathematicians/creators may be out of a job Cryptography as we know it may be impossible no one-way functions! In principle, every aspect of daily life could be efficiently and globally optimized life as we know it would be different Conjecture: P NP 32

Next Episode: NP-Complete Problems 33