CS 154. Time Complexity: P and NP. Complexity Theory. Measuring Time Complexity. A = { 0 k 1 k k 0 } TIME(n log n) Time-Bounded Complexity Classes

Similar documents
CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

Theoretical Computer Science (Bridging Course) Complexity

Diagonalization. Ahto Buldas. Lecture 3 of Complexity Theory October 8, Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach.

Notes on Complexity Theory Last updated: August, Lecture 1

Theory of Computation Chapter 2: Turing Machines

Lecture 2: Universality

3515ICT Theory of Computation Turing Machines

The Classes P and NP

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

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

Turing Machines: An Introduction

OHJ-2306 Introduction to Theoretical Computer Science, Fall

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

The Halting Problem is Undecidable

Quantum and Non-deterministic computers facing NP-completeness

NP-Completeness and Cook s Theorem

Introduction to NP-Completeness Written and copyright c by Jie Wang 1

Algebraic Computation Models. Algebraic Computation Models

Lecture 7: NP-Complete Problems

Computability Theory

Lecture 1: Oracle Turing Machines

Introduction to Logic in Computer Science: Autumn 2006

CS 3719 (Theory of Computation and Algorithms) Lecture 4

24 Uses of Turing Machines

Introduction to Algorithms. Part 3: P, NP Hard Problems

Computational Models Lecture 8, Spring 2009

SIMS 255 Foundations of Software Design. Complexity and NP-completeness

Notes on Complexity Theory Last updated: August, Lecture 1

Complexity Classes. Chapter 27 of the forthcoming CRC Handbook on Algorithms and Theory of Computation. Eric Allender 1. Rutgers University

Universality in the theory of algorithms and computer science

Complexity Classes P and NP

Tutorial 8. NP-Complete Problems

CAs and Turing Machines. The Basis for Universal Computation

NP-complete? NP-hard? Some Foundations of Complexity. Prof. Sven Hartmann Clausthal University of Technology Department of Informatics

1 Definition of a Turing machine

Turing Machines, Part I

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München

6.080/6.089 GITCS Feb 12, Lecture 3

Complexity Classes. Eric Allender Rutgers University. Michael C. Loui University of Illinois at Urbana-Champaign

Chapter. NP-Completeness. Contents

Turing Machines and Understanding Computational Complexity

Automata and Computability. Solutions to Exercises

Lecture summary for Theory of Computation

A Working Knowledge of Computational Complexity for an Optimizer

MATHEMATICS: CONCEPTS, AND FOUNDATIONS Vol. III - Logic and Computer Science - Phokion G. Kolaitis

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Notes on NP Completeness

Properties of Stabilizing Computations

Computational complexity theory

(67902) Topics in Theory and Complexity Nov 2, Lecture 7

P versus NP, and More

THE SEARCH FOR NATURAL DEFINABILITY IN THE TURING DEGREES

Generalized CHR machines

Nondeterministic polynomial time factoring in the tile assembly model

On the Relationship between Classes P and NP

Simulation-Based Security with Inexhaustible Interactive Turing Machines

CSC 373: Algorithm Design and Analysis Lecture 16

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Chapter 7 Uncomputability

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Regular Expressions and Automata using Haskell

Two-dimensional Languages

Fixed-Point Logics and Computation

Reminder: Complexity (1) Parallel Complexity Theory. Reminder: Complexity (2) Complexity-new

Reminder: Complexity (1) Parallel Complexity Theory. Reminder: Complexity (2) Complexity-new GAP (2) Graph Accessibility Problem (GAP) (1)

The P versus NP Solution

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Outline Introduction Circuits PRGs Uniform Derandomization Refs. Derandomization. A Basic Introduction. Antonis Antonopoulos.

Chapter 1. NP Completeness I Introduction. By Sariel Har-Peled, December 30, Version: 1.05

SOLVING NARROW-INTERVAL LINEAR EQUATION SYSTEMS IS NP-HARD PATRICK THOR KAHL. Department of Computer Science

How To Compare A Markov Algorithm To A Turing Machine

Proof Systems that Take Advice

A logical approach to dynamic role-based access control

Finite Automata. Reading: Chapter 2

Secrecy for Bounded Security Protocols With Freshness Check is NEXPTIME-complete

Introduction to computer science

Lecture 2: Complexity Theory Review and Interactive Proofs

Guessing Game: NP-Complete?

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, School of Informatics University of Edinburgh als@inf.ed.ac.

2.1 Complexity Classes

Quantum Computability and Complexity and the Limits of Quantum Computation

On the Unique Games Conjecture

Introduction to Automata Theory. Reading: Chapter 1

Revisiting a Limit on Efficient Quantum Computation

Introduction to Turing Machines

Hypercomputation: computing more than the Turing machine

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

The Parameterized Complexity of Short Computation and Factorization

CS 301 Course Information

6.852: Distributed Algorithms Fall, Class 2

T Reactive Systems: Introduction and Finite State Automata

! X is a set of strings. ! Instance: string s. ! Algorithm A solves problem X: A(s) = yes iff s! X.

Quantum Monte Carlo and the negative sign problem

898 BOOK REVIEWS MICHAEL P. DRAZIN. irrespective of the statements in The New York Times, November 7, 1979, p. 1.

Transcription:

CS 154 Time Complexity: P and NP Complexity Theory Study of what can and can t be computed with limited resources on computation, such as time, space, and so on We ll start with: Time complexity Measuring Time Complexity We measure time complexity by counting the elementary steps required for a machine to halt Consider the language A = { 0 k 1 k k 0 } On input of length n: 1. Scan across the tape and reject if the ~n string is not of the form 0 i 1 j ~n 2 ~n 2. Repeat the following if both 0s and 1s remain on the tape: Scan across the tape, crossing off a single 0 and a single 1 3. If 0s remain after all 1s have been crossed off, or vice-versa, reject. Otherwise accept. Let M be a TM that halts on all inputs. Definition: The running time or time complexity of M is the function f : N N such that f(n) = maximum number of steps taken by M over any input of length n. 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 O(t(n)) running time } We showed: A = { 0 k 1 k k 0 } TIME(n 2 ) A = { 0 k 1 k k 0 } TIME(n log n) M(w) := If w is not of the form 0*1*, reject. Repeat until all bits of w are crossed out: If the parity of 0 s parity of 1 s, reject. Cross out every other 0. Cross out every other 1. Otherwise, accept. 00000000000001111111111111 x0x0x0x0x0x0xx1x1x1x1x1x1x xxx0xxx0xxx0xxxx1xxx1xxx1x xxxxxxx0xxxxxxxxxxxx1xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx 1

Theorem: A = { 0 k 1 k k 0 } can be decided in O(n) time with a two-tape TM. Proof Idea: Scan all 0s, copy them to the second tape. Scan all 1s. For each 1 scanned, cross off a 0 from the second tape. Different models of computation can yield different running times for the same language! Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine Theorem: Let t(n) be a function such that t(n) n. Then every t(n) time multi-tape TM has an equivalent O(t(n) 2 ) single tape TM Our simulation of multitape TMs achieved this! T(n) time FINITE STATE CONTROL 1 0 0 T(n) 2 time FINITE STATE CONTROL... 1 0 0 # # # Time Hierarchy Theorem Intuition: If you get more time to work, then you can solve strictly more problems Theorem: For reasonable f, g : N N where f(n) = O(g(n) 1/3 ), TIME(f(n)) TIME(g(n)) Proof Idea: Diagonalization! Make a TM N that does the opposite of all g(n) 1/3 time machines on at least one input, and runs in O(g(n)) time So L(N) is in TIME(g(n)) but not in TIME(f(n)) Time Hierarchy Theorem Theorem: For reasonable f, g where f(n) = O(g(n) 1/3 ) TIME(f(n)) TIME(g(n)) Proof Sketch: Define a machine N as follows. N(w) = If w is not equal to M10 i for some M, i, reject Simulate M on w for f( w ) steps (This simulation itself uses f( w ) 2 time) If M tries to take more time, reject Accept if and only if M has rejected Eventually, w is large enough that f( w ) < g( w ) Simulation can be carried out using multitape sim. Need to compute f( w ) using only O(g( w )) time 2

Time Hierarchy Theorem Theorem: For reasonable f, g where f(n) = O(g(n) 1/3 ) TIME(f(n)) TIME(g(n)) Corollary: TIME(n) TIME(n 2 ) TIME(n 4 ) There is an infinite hierarchy of increasingly more time-consuming problems P = TIME(n k ) k N Question: Are there important everyday problems that are high up in the hierarchy? A natural problem that needs exactly n 10 time? THIS IS AN OPEN QUESTION! The EXTENDED Church-Turing Thesis Everyone s Intuitive Notion = Polynomial-Time of Efficient Turing Machines Algorithms Nondeterminism and NP Much more controversial. Potential counterexamples include n 100 time algorithms, Quantum & Randomized algorithms Nondeterministic Turing Machines read write move 0 0, R are just like standard TMs, except: 0 0, R, R q accept 1. The machine may proceed according to several possibilities, R q reject 0 0, R 2. The machine accepts a string if there exists a path from start configuration to an accepting configuration 3

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 Deterministic Computation accept or reject Nondeterministic Computation accept reject 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 N(w) accepts in t time iff such a history exists. Accepting computation histories for N on w do not have to be unique! Definition: NTIME(t(n)) = { L L is decided by a O(t(n)) time nondeterministic Turing machine } TIME(t(n)) NTIME(t(n)) Is this a proper containment for all t(n)? THIS IS AN OPEN QUESTION! A Boolean formula is satisfiable if there exists a satisfying assignment for it A 3cnf-formula has the form: (x 1 x 2 x 3 ) (x 4 x 2 x 5 ) (x 3 x 2 x 1 ) YES NO a b c d (x y) x SAT = { φ φ is a satisfiable Boolean formula } literals clauses (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 } 4

3SAT = { φ φ is a satisfiable 3cnf-formula } Theorem: 3SAT NTIME(n 2 ) On input φ: 1. Check if the formula is in 3cnf 2. For each variable, nondeterministically substitute it with 0 or 1 ( x y x ) NP = NTIME(n k ) k N ( 0 y 0 ) ( 1 y 1 ) ( 0 0 0 ) ( 0 1 0 ) 3. Test if the assignment satisfies φ Theorem: L NP there is a poly-time Turing machine V and k such that we can define L as: 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 Nondeterministically guess y and then run V(x,y) (2) If L NP then L = { x y y x k and V(x,y) accepts } 3SAT = { φ y such that y is a satisfying assignment to φ and φ is in 3cnf } SAT = { φ y such that y is a satisfying assignment to φ } Let N be a nondeterministic poly-time TM that decides L. Define V(x,y) to accept iff y is an accepting computation history of N on x The Hamiltonian Path Problem A language is in NP if and only if there are polynomial-length proofs for membership to the language b a e d f g SAT is in NP because a satisfying assignment is a polynomial-length proof that a formula is satisfiable i A Hamiltonian path traverses through each node exactly once c h 5

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 Next Episode: NP-Complete Problems The Hamiltonian path is a proof that (G,s,t) is a member of HAMPATH 6