Computational complexity

Similar documents
Chapter 7: Time Complexity

CSCI3390-Lecture 14: The class NP

Time Complexity. CS60001: Foundations of Computing Science

CSE 105 THEORY OF COMPUTATION

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

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

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

CISC 4090 Theory of Computation

Lecture 16: Time Complexity and P vs NP

Finish K-Complexity, Start Time Complexity

CSE 105 THEORY OF COMPUTATION

Theory of Computation

Advanced topic: Space complexity

Complexity (Pre Lecture)

Lecture 3: Nondeterminism, NP, and NP-completeness

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

Theory of Computation Time Complexity

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

Complexity: moving from qualitative to quantitative considerations

Computability Theory

CSE200: Computability and complexity Space Complexity

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}

Computational Models Lecture 11, Spring 2009

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

Turing machines COMS Ashley Montanaro 21 March Department of Computer Science, University of Bristol Bristol, UK

CS154, Lecture 13: P vs NP

CSE 105 THEORY OF COMPUTATION

Complexity Theory Part I

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

Turing Machines and Time Complexity

CS151 Complexity Theory. Lecture 1 April 3, 2017

CS154, Lecture 13: P vs NP

Computer Sciences Department

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

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

CSE 105 Theory of Computation

1 Computational Problems

Computability and Complexity

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

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

Notes for Lecture Notes 2

Computational Complexity

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

Algorithms and Theory of Computation. Lecture 19: Class P and NP, Reduction

Theory of Computation

COMPUTATIONAL COMPLEXITY

In complexity theory, algorithms and problems are classified by the growth order of computation time as a function of instance size.

Notes on Complexity Theory Last updated: December, Lecture 2

NP-Completeness. Until now we have been designing algorithms for specific problems

Complexity Theory Part II

Lecture 19: Finish NP-Completeness, conp and Friends

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

P, NP, NP-Complete, and NPhard

Theory of Computation

Lecture 20: conp and Friends, Oracles in Complexity Theory

conp, Oracles, Space Complexity

Lecture 18: P & NP. Revised, May 1, CLRS, pp

CSCE 551 Final Exam, Spring 2004 Answer Key

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

Lecture 6: Oracle TMs, Diagonalization Limits, Space Complexity

UNIT-VIII COMPUTABILITY THEORY

Introduction to Complexity Theory

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?

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Lecture 3: Reductions and Completeness

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP)

The purpose here is to classify computational problems according to their complexity. For that purpose we need first to agree on a computational

Umans Complexity Theory Lectures

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

Intro to Theory of Computation

Advanced Topics in Theoretical Computer Science

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

6-1 Computational Complexity

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

INTRODUCTION TO THE THEORY OF NP-COMPLETENESS

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

Week 2: Defining Computation

NP-Completeness. Algorithmique Fall semester 2011/12

Computability and Complexity Theory: An Introduction

The Polynomial Hierarchy

Time to learn about NP-completeness!

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

Complexity Theory Part I

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

NP Complete Problems. COMP 215 Lecture 20

Chapter 2: The Basics. slides 2017, David Doty ECS 220: Theory of Computation based on The Nature of Computation by Moore and Mertens

Non-Deterministic Time

1. Introduction Recap

NP and NP Completeness

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

Lecture 18: PCP Theorem and Hardness of Approximation I

1 Non-deterministic Turing Machine

15.1 Proof of the Cook-Levin Theorem: SAT is NP-complete

Time-bounded computations

SAT, NP, NP-Completeness

CP405 Theory of Computation

Quantum Computing Lecture 8. Quantum Automata and Complexity

1 Computational problems

Transcription:

COMS11700 Computational complexity Department of Computer Science, University of Bristol Bristol, UK 2 May 2014 COMS11700: Computational complexity Slide 1/23

Introduction If we can prove that a language is decidable, that does not mean we can solve the corresponding decision problem in practice. Computational complexity theory studies the question of which problems we can solve given restricted resources: in particular, restricted time or space. We are generally interested in how the resources we need to solve a family of problems grow with problem size. This allows us to compare the complexity of different problems and formalise the intuitive notion that some problems are harder than others. COMS11700: Computational complexity Slide 2/23

Time complexity Time complexity Let M be a deterministic Turing machine that halts on all inputs. The running time or time complexity of M is the function f : N N where f (n) is the maximum number of steps that M uses on any input of length n. COMS11700: Computational complexity Slide 3/23

Time complexity Time complexity Let M be a deterministic Turing machine that halts on all inputs. The running time or time complexity of M is the function f : N N where f (n) is the maximum number of steps that M uses on any input of length n. Some notes on this definition: A step is a transition, which includes reading a symbol, changing state and writing a new symbol to the tape. This is a worst-case notion of complexity, i.e. we define the running time of M on inputs of a certain length to be the number of steps that M takes on the worst possible input of that length. We usually use n to represent the length of the input. COMS11700: Computational complexity Slide 3/23

When comparing running times we often only care about the scaling behaviour with the input size n. COMS11700: Computational complexity Slide 4/23

When comparing running times we often only care about the scaling behaviour with the input size n. For example, given two Turing machines M 1 and M 2 with running times 3n 2 + 2n and 137n + 276 respectively, for large n the 3n 2 term in the running time of the first machine will dominate. 1.2 104 1 3n 2 + 2n 0.8 137n + 276 f (n) 0.6 0.4 0.2 0 0 20 40 60 80 n COMS11700: Computational complexity Slide 4/23

Big-O notation Big-O notation allows us to simplify expressions for running times etc. while still retaining the important features. Definition Let f, g : N R + be functions. We write f (n) = O(g(n)) if there exist positive integers c and n 0 such that, for all integers n n 0, f (n) c g(n). COMS11700: Computational complexity Slide 5/23

Big-O notation Big-O notation allows us to simplify expressions for running times etc. while still retaining the important features. Definition Let f, g : N R + be functions. We write f (n) = O(g(n)) if there exist positive integers c and n 0 such that, for all integers n n 0, f (n) c g(n). For example: f (n) = 3n 2 + n: f (n) = O(n 2 ) f (n) = 0.01n 2 + 0.001n 3 : f (n) = O(n 3 ), but f (n) is not O(n 2 ). COMS11700: Computational complexity Slide 5/23

Time complexity classes Definition Let t : N R + be a function. Then TIME(t(n)) is the set of all languages which are decidable by a Turing machine running in time O(t(n)). COMS11700: Computational complexity Slide 6/23

Time complexity classes Definition Let t : N R + be a function. Then TIME(t(n)) is the set of all languages which are decidable by a Turing machine running in time O(t(n)). For example, recall the language L EQ = {w#w w {0, 1} } of two equal bit-strings, separated by a # symbol. Claim: L EQ TIME(n 2 ). COMS11700: Computational complexity Slide 6/23

Time complexity classes Recall the following algorithm for deciding this language: Algorithm for deciding L EQ (sketch) 1. Scan forwards and backwards, testing each corresponding pair of bits either side of the # for equality in turn. 2. Overwrite each bit with an x symbol after checking it so we don t check the same bits twice. 3. Accept if all pairs of bits match each other; otherwise reject. COMS11700: Computational complexity Slide 7/23

Time complexity classes Recall the following algorithm for deciding this language: Algorithm for deciding L EQ (sketch) 1. Scan forwards and backwards, testing each corresponding pair of bits either side of the # for equality in turn. 2. Overwrite each bit with an x symbol after checking it so we don t check the same bits twice. 3. Accept if all pairs of bits match each other; otherwise reject. Bounding the time complexity (sketch): In the worst case, the input string is of the form w#w for some string w {0, 1} m. COMS11700: Computational complexity Slide 7/23

Time complexity classes Recall the following algorithm for deciding this language: Algorithm for deciding L EQ (sketch) 1. Scan forwards and backwards, testing each corresponding pair of bits either side of the # for equality in turn. 2. Overwrite each bit with an x symbol after checking it so we don t check the same bits twice. 3. Accept if all pairs of bits match each other; otherwise reject. Bounding the time complexity (sketch): In the worst case, the input string is of the form w#w for some string w {0, 1} m. For each symbol in the part of the string to the left of #, m + 1 moves to the right are made, the corresponding symbol to the right of # is checked and m + 1 moves to the left are made. COMS11700: Computational complexity Slide 7/23

Time complexity classes Recall the following algorithm for deciding this language: Algorithm for deciding L EQ (sketch) 1. Scan forwards and backwards, testing each corresponding pair of bits either side of the # for equality in turn. 2. Overwrite each bit with an x symbol after checking it so we don t check the same bits twice. 3. Accept if all pairs of bits match each other; otherwise reject. Bounding the time complexity (sketch): In the worst case, the input string is of the form w#w for some string w {0, 1} m. For each symbol in the part of the string to the left of #, m + 1 moves to the right are made, the corresponding symbol to the right of # is checked and m + 1 moves to the left are made. So the algorithm runs in time O(m 2 ), which is also O(n 2 ). COMS11700: Computational complexity Slide 7/23

Polynomial and exponential time We would like to distinguish between algorithms which are efficient (run in a reasonable length of time) and algorithms which are inefficient. One way to do this is via the concepts of polynomial-time and exponential-time algorithms. COMS11700: Computational complexity Slide 8/23

Polynomial and exponential time We would like to distinguish between algorithms which are efficient (run in a reasonable length of time) and algorithms which are inefficient. One way to do this is via the concepts of polynomial-time and exponential-time algorithms. Definitions P = k 0 TIME(n k ) EXP = k 0 TIME(2 nk ) So P is the class of languages that are decided by Turing machines with runtime polynomial in the input size. EXP is the class of languages decided by Turing machines with runtime exponential in the input size. COMS11700: Computational complexity Slide 8/23

Polynomial and exponential time 1.2 104 1 2 n 0.8 f (n) 0.6 0.4 0.2 0 n 2 0 10 20 30 40 50 n COMS11700: Computational complexity Slide 9/23

Some examples of languages in P Consider the language PATH defined by PATH = { G, s, t G is a directed graph that has a path from s to t} B E A D G C F COMS11700: Computational complexity Slide 10/23

Some examples of languages in P Consider the language PATH defined by PATH = { G, s, t G is a directed graph that has a path from s to t} B E A D G C F PATH is a formalisation of the problem of determining whether there is a path between two specified points in a directed graph. COMS11700: Computational complexity Slide 10/23

Some examples of languages in P Consider the language PATH defined by PATH = { G, s, t G is a directed graph that has a path from s to t} B E A D G C F PATH is a formalisation of the problem of determining whether there is a path between two specified points in a directed graph. A naïve algorithm would be to try every possible path (sequence of vertices) from s to t in turn to see if that path exists. But if G has m vertices, in the worst case this could involve checking m m paths... COMS11700: Computational complexity Slide 10/23

Some examples of languages in P A polynomial-time algorithm deciding PATH On input G, s, t : 1. Place a mark on vertex s. 2. Repeat until no further vertices are found: Check all the edges in G. If an edge is found from a marked vertex to an unmarked vertex, mark the target of the edge. 3. If t is marked, accept; otherwise reject. COMS11700: Computational complexity Slide 11/23

Some examples of languages in P A polynomial-time algorithm deciding PATH On input G, s, t : 1. Place a mark on vertex s. 2. Repeat until no further vertices are found: Check all the edges in G. If an edge is found from a marked vertex to an unmarked vertex, mark the target of the edge. 3. If t is marked, accept; otherwise reject. A rough upper bound on the running time of this algorithm: Assume the input graph G is on m vertices and is provided as an adjacency matrix, so the input size n = O(m 2 ). COMS11700: Computational complexity Slide 11/23

Some examples of languages in P A polynomial-time algorithm deciding PATH On input G, s, t : 1. Place a mark on vertex s. 2. Repeat until no further vertices are found: Check all the edges in G. If an edge is found from a marked vertex to an unmarked vertex, mark the target of the edge. 3. If t is marked, accept; otherwise reject. A rough upper bound on the running time of this algorithm: Assume the input graph G is on m vertices and is provided as an adjacency matrix, so the input size n = O(m 2 ). Step 2 is repeated at most m times and checks at most m 2 edges. COMS11700: Computational complexity Slide 11/23

Some examples of languages in P A polynomial-time algorithm deciding PATH On input G, s, t : 1. Place a mark on vertex s. 2. Repeat until no further vertices are found: Check all the edges in G. If an edge is found from a marked vertex to an unmarked vertex, mark the target of the edge. 3. If t is marked, accept; otherwise reject. A rough upper bound on the running time of this algorithm: Assume the input graph G is on m vertices and is provided as an adjacency matrix, so the input size n = O(m 2 ). Step 2 is repeated at most m times and checks at most m 2 edges. Checking each edge in step 2 can be done in time O(m k ) for some fixed k (depending on the computational model). COMS11700: Computational complexity Slide 11/23

Some examples of languages in P A polynomial-time algorithm deciding PATH On input G, s, t : 1. Place a mark on vertex s. 2. Repeat until no further vertices are found: Check all the edges in G. If an edge is found from a marked vertex to an unmarked vertex, mark the target of the edge. 3. If t is marked, accept; otherwise reject. A rough upper bound on the running time of this algorithm: Assume the input graph G is on m vertices and is provided as an adjacency matrix, so the input size n = O(m 2 ). Step 2 is repeated at most m times and checks at most m 2 edges. Checking each edge in step 2 can be done in time O(m k ) for some fixed k (depending on the computational model). So the running time of the algorithm is O(m k+3 ), which is poly(n). COMS11700: Computational complexity Slide 11/23

Some examples of languages in P Many other important problems are known to be in P. For example: The language PRIMES = {x {0, 1} x is a prime number written in binary} is in P but this was only proven in 2002 (by two undergraduate students and a professor). COMS11700: Computational complexity Slide 12/23

Some examples of languages in P Many other important problems are known to be in P. For example: The language PRIMES = {x {0, 1} x is a prime number written in binary} is in P but this was only proven in 2002 (by two undergraduate students and a professor). Every context-free language is in P. The algorithm we presented showing decidability of CFLs does not imply this (why not?), but the CYK Algorithm you saw in Algorithms and Programming does. COMS11700: Computational complexity Slide 12/23

Some examples of languages in P Many other important problems are known to be in P. For example: The language PRIMES = {x {0, 1} x is a prime number written in binary} is in P but this was only proven in 2002 (by two undergraduate students and a professor). Every context-free language is in P. The algorithm we presented showing decidability of CFLs does not imply this (why not?), but the CYK Algorithm you saw in Algorithms and Programming does. Other examples include evaluation of circuits, finding shortest paths, pattern matching, linear programming,... COMS11700: Computational complexity Slide 12/23

Problems whose solutions are easy to check There are problems which may not be easy to solve, but for which it is easy to check a claimed solution. Pics: Wikipedia/Sudoku COMS11700: Computational complexity Slide 13/23

Problems whose solutions are easy to check There are problems which may not be easy to solve, but for which it is easy to check a claimed solution. Pics: Wikipedia/Sudoku COMS11700: Computational complexity Slide 13/23

Problems whose solutions are easy to check We can formalise this using the notion of a verifier. Definition A verifier for a language L is a Turing machine V such that L = {x there exists a string c such that V accepts x, c }. We think of c as a proof or witness that x L, which V can check. COMS11700: Computational complexity Slide 14/23

Problems whose solutions are easy to check We can formalise this using the notion of a verifier. Definition A verifier for a language L is a Turing machine V such that L = {x there exists a string c such that V accepts x, c }. We think of c as a proof or witness that x L, which V can check. V should accept a correct proof, but not be fooled by any claimed incorrect proof. COMS11700: Computational complexity Slide 14/23

Problems whose solutions are easy to check We can formalise this using the notion of a verifier. Definition A verifier for a language L is a Turing machine V such that L = {x there exists a string c such that V accepts x, c }. We think of c as a proof or witness that x L, which V can check. V should accept a correct proof, but not be fooled by any claimed incorrect proof. A polynomial-time verifier is a verifier which runs in time polynomial in the length of the input x, i.e. O( x k ) for some fixed k. Definition NP is the class of languages which have a polynomial-time verifier. COMS11700: Computational complexity Slide 14/23

Problems whose solutions are easy to check An example of a language in NP: FACTORING = { x, y x is an integer with a prime factor lower than y}. For example, 15, 4 is in the language, but 15, 2 is not. COMS11700: Computational complexity Slide 15/23

Problems whose solutions are easy to check An example of a language in NP: FACTORING = { x, y x is an integer with a prime factor lower than y}. For example, 15, 4 is in the language, but 15, 2 is not. For any x, the list of prime factors of x can be used as a proof to determine whether x, y is in the language. Given some claimed prime factors of x, we can multiply them together to determine whether we get x. If so, we check whether the smallest of them is lower than y. COMS11700: Computational complexity Slide 15/23

Problems whose solutions are easy to check Another example is graph colouring problems. We say a graph can be properly k-coloured if each vertex can be assigned one of k colours, such that all pairs of adjacent vertices have different colours. COMS11700: Computational complexity Slide 16/23

Problems whose solutions are easy to check Another example is graph colouring problems. We say a graph can be properly k-coloured if each vertex can be assigned one of k colours, such that all pairs of adjacent vertices have different colours. COMS11700: Computational complexity Slide 16/23

Problems whose solutions are easy to check Another example is graph colouring problems. We say a graph can be properly k-coloured if each vertex can be assigned one of k colours, such that all pairs of adjacent vertices have different colours. COMS11700: Computational complexity Slide 16/23

Problems whose solutions are easy to check Another example is graph colouring problems. We say a graph can be properly k-coloured if each vertex can be assigned one of k colours, such that all pairs of adjacent vertices have different colours. We can formalise this decision problem as the language 3-COLOURING = { G G is a graph which can be properly 3-coloured}. Given a graph, we can be convinced that it can be properly 3-coloured by being given a 3-colouring and checking that it is proper; so 3-COLOURING is in NP. COMS11700: Computational complexity Slide 16/23

P vs. NP Every language in P is also in NP. For any language in P, the verifier can ignore any claimed proof and just decide the language directly. COMS11700: Computational complexity Slide 17/23

P vs. NP Every language in P is also in NP. For any language in P, the verifier can ignore any claimed proof and just decide the language directly. Also, every language in NP is also in EXP. If there exists an m-bit witness that the input is in a language, by looping over all possible witnesses a Turing machine can find that witness in time O(2 m ). COMS11700: Computational complexity Slide 17/23

P vs. NP Every language in P is also in NP. For any language in P, the verifier can ignore any claimed proof and just decide the language directly. Also, every language in NP is also in EXP. If there exists an m-bit witness that the input is in a language, by looping over all possible witnesses a Turing machine can find that witness in time O(2 m ). So P NP EXP. COMS11700: Computational complexity Slide 17/23

P vs. NP Every language in P is also in NP. For any language in P, the verifier can ignore any claimed proof and just decide the language directly. Also, every language in NP is also in EXP. If there exists an m-bit witness that the input is in a language, by looping over all possible witnesses a Turing machine can find that witness in time O(2 m ). So P NP EXP. It is not known whether P = NP and this question is considered the most important open problem in computer science! Resolving it would win you everlasting fame (as well as $1M). COMS11700: Computational complexity Slide 17/23

Nondeterministic polynomial-time Recall that a nondeterministic Turing machine (NDTM) can explore multiple computational paths simultaneously. It accepts if and only if at least one of the computational paths accepts. q 3 0 1 0 1 0... q 3 q 4 0 1 1 1 0... 0 1 0 1 0... q 1 0 1 1 1 0... COMS11700: Computational complexity Slide 18/23

Nondeterministic polynomial-time Definitions Let t : N R + be a function. Then NTIME(t(n)) is the set of all languages which are decidable by a nondeterministic Turing machine running in time O(t(n)). We say that an NDTM runs in time O(t(n)) if all of its computational paths halt in time O(t(n)). COMS11700: Computational complexity Slide 19/23

Nondeterministic polynomial-time Definitions Let t : N R + be a function. Then NTIME(t(n)) is the set of all languages which are decidable by a nondeterministic Turing machine running in time O(t(n)). We say that an NDTM runs in time O(t(n)) if all of its computational paths halt in time O(t(n)). We will now see that there is a close connection between nondeterministic Turing machines and verification of proofs. This will explain the name NP, which stands for Nondeterministic Polynomial-time (and not non-polynomial time ). COMS11700: Computational complexity Slide 19/23

Nondeterministic polynomial-time Theorem NP = k 0 NTIME(n k ). COMS11700: Computational complexity Slide 20/23

Nondeterministic polynomial-time Theorem NP = k 0 NTIME(n k ). Proof (sketch) We first show that L NP implies that L is decided by an NDTM running in polynomial time (i.e. NP k 0 NTIME(nk )). COMS11700: Computational complexity Slide 20/23

Nondeterministic polynomial-time Theorem NP = k 0 NTIME(n k ). Proof (sketch) We first show that L NP implies that L is decided by an NDTM running in polynomial time (i.e. NP k 0 NTIME(nk )). From the definition of NP, there exists a verifier V for L running in time O(n k ) for some fixed k. COMS11700: Computational complexity Slide 20/23

Nondeterministic polynomial-time Theorem NP = k 0 NTIME(n k ). Proof (sketch) We first show that L NP implies that L is decided by an NDTM running in polynomial time (i.e. NP k 0 NTIME(nk )). From the definition of NP, there exists a verifier V for L running in time O(n k ) for some fixed k. We define an NDTM N which behaves as follows: 1. Nondeterministically guess a string c of length at most O(n k ). 2. Run V on input x, c. If V accepts, accept; otherwise, reject. COMS11700: Computational complexity Slide 20/23

Theorem NP = k 0 NTIME(n k ). Proof (sketch) For the other direction, we show that if L is decided by an NDTM running in polynomial time, L NP (i.e. k 0 NTIME(nk ) NP). COMS11700: Computational complexity Slide 21/23

Theorem NP = k 0 NTIME(n k ). Proof (sketch) For the other direction, we show that if L is decided by an NDTM running in polynomial time, L NP (i.e. k 0 NTIME(nk ) NP). From the definition of NTIME, there exists an NDTM N which decides L and runs in time O(n k ) for some fixed k. COMS11700: Computational complexity Slide 21/23

Theorem NP = k 0 NTIME(n k ). Proof (sketch) For the other direction, we show that if L is decided by an NDTM running in polynomial time, L NP (i.e. k 0 NTIME(nk ) NP). From the definition of NTIME, there exists an NDTM N which decides L and runs in time O(n k ) for some fixed k. We define a verifier V which takes as input a string x and a witness c. c is the description of a sequence of computational path choices made by N. COMS11700: Computational complexity Slide 21/23

Theorem NP = k 0 NTIME(n k ). Proof (sketch) For the other direction, we show that if L is decided by an NDTM running in polynomial time, L NP (i.e. k 0 NTIME(nk ) NP). From the definition of NTIME, there exists an NDTM N which decides L and runs in time O(n k ) for some fixed k. We define a verifier V which takes as input a string x and a witness c. c is the description of a sequence of computational path choices made by N. V simulates the computation of N on input x according to c, checking whether each transition made is valid. COMS11700: Computational complexity Slide 21/23

Theorem NP = k 0 NTIME(n k ). Proof (sketch) For the other direction, we show that if L is decided by an NDTM running in polynomial time, L NP (i.e. k 0 NTIME(nk ) NP). From the definition of NTIME, there exists an NDTM N which decides L and runs in time O(n k ) for some fixed k. We define a verifier V which takes as input a string x and a witness c. c is the description of a sequence of computational path choices made by N. V simulates the computation of N on input x according to c, checking whether each transition made is valid. If N accepts in the end, V accepts; otherwise, V rejects. COMS11700: Computational complexity Slide 21/23

NP-completeness Some languages in the class NP are known to actually be NP-complete. A language L is said to be NP-complete if: L NP; Every language L NP reduces to L in polynomial time. So NP-complete problems are the hardest problems in NP: if we can solve them efficiently, we can solve every other problem in NP efficiently. COMS11700: Computational complexity Slide 22/23

NP-completeness Some languages in the class NP are known to actually be NP-complete. A language L is said to be NP-complete if: L NP; Every language L NP reduces to L in polynomial time. So NP-complete problems are the hardest problems in NP: if we can solve them efficiently, we can solve every other problem in NP efficiently. Examples of NP-complete problems include 3-colouring, clique finding in graphs, optimal packing problems... in fact, many of the most practically important problems in computer science. COMS11700: Computational complexity Slide 22/23

Summary and further reading Computational complexity theory allows us to study the resources required to solve problems. Problems can be classified according to the time required to solve them in the deterministic Turing machine model. P is the class of problems which can be solved in time polynomial in the input size, while NP is the class of problems whose solutions can be verified in time polynomial in the input size. NP has an alternative definition in terms of nondeterministic Turing machines. Further reading: Sipser 7.1 7.3. COMS11700: Computational complexity Slide 23/23