Notes for Lecture Notes 2

Similar documents
1 Computational Problems

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

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

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

Notes for Lecture 3... x 4

Advanced topic: Space complexity

Notes for Lecture 3... x 4

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

34.1 Polynomial time. Abstract problems

CS154, Lecture 13: P vs NP

Time-bounded computations

Lecture 6: Oracle TMs, Diagonalization Limits, Space Complexity

CS6901: review of Theory of Computation and Algorithms

CSCI3390-Lecture 6: An Undecidable Problem

CS154, Lecture 13: P vs NP

CS3719 Theory of Computation and Algorithms

Lecture 16: Time Complexity and P vs NP

Time Complexity. CS60001: Foundations of Computing Science

Turing Machine Recap

MTAT Complexity Theory October 13th-14th, Lecture 6

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

CS294: Pseudorandomness and Combinatorial Constructions September 13, Notes for Lecture 5

Finish K-Complexity, Start Time Complexity

CSCE 551 Final Exam, April 28, 2016 Answer Key

CSCE 551 Final Exam, Spring 2004 Answer Key

Polynomial Time Computation. Topics in Logic and Complexity Handout 2. Nondeterministic Polynomial Time. Succinct Certificates.

BBM402-Lecture 11: The Class NP

CSCI3390-Lecture 14: The class NP

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

Lecture Notes: The Halting Problem; Reductions

Decidability: Church-Turing Thesis

Computability Theory

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

CMSC 441: Algorithms. NP Completeness

Complexity Theory Part II

COL 352 Introduction to Automata and Theory of Computation Major Exam, Sem II , Max 80, Time 2 hr. Name Entry No. Group

Lecture 3: Reductions and Completeness

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan 9/6/2004. Notes for Lecture 3

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

: On the P vs. BPP problem. 30/12/2016 Lecture 12

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

CSE 105 THEORY OF COMPUTATION

conp, Oracles, Space Complexity

Notes on Space-Bounded Complexity

DRAFT. Diagonalization. Chapter 4

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

1 Showing Recognizability

CSE 105 Theory of Computation

Computability and Complexity

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

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

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

Undecidability. Andreas Klappenecker. [based on slides by Prof. Welch]

4.2 The Halting Problem

CPSC 421: Tutorial #1

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

SOLUTION: SOLUTION: SOLUTION:

CS151 Complexity Theory. Lecture 1 April 3, 2017

Further discussion of Turing machines

2 P vs. NP and Diagonalization

ECS 120 Lesson 18 Decidable Problems, the Halting Problem

Automata Theory CS S-FR2 Final Review

Design and Analysis of Algorithms

Computer Sciences Department

Notes on Space-Bounded Complexity

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

1 Reals are Uncountable

Turing Machines Part III

Computational Models Lecture 8 1

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

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

A non-turing-recognizable language

Randomized Complexity Classes; RP

1 From previous lectures

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

Lecture 4 : Quest for Structure in Counting Problems

On the Computational Hardness of Graph Coloring

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

1 Computational problems

NP-Completeness and Boolean Satisfiability

Section 14.1 Computability then else

CS154, Lecture 10: Rice s Theorem, Oracle Machines

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.

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

Theory of Computation

Intractable Problems [HMU06,Chp.10a]

CSE 105 THEORY OF COMPUTATION

Computational Models Lecture 8 1

Computational complexity

Limits of Feasibility. Example. Complexity Relationships among Models. 1. Complexity Relationships among Models

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

Lecture 20: conp and Friends, Oracles in Complexity Theory

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Boolean circuits. Lecture Definitions

Complexity (Pre Lecture)

Computational Complexity: A Modern Approach. Draft of a book: Dated January 2007 Comments welcome!

Complexity Theory Part I

Computational Complexity

Transcription:

Stanford University CS254: Computational Complexity Notes 2 Luca Trevisan January 11, 2012 Notes for Lecture Notes 2 In this lecture we define NP, we state the P versus NP problem, we prove that its formulation for search problems is equivalent to its formulation for decision problems, and we prove the time hierarchy theorem, which remains essentially the only known theorem which allows to show that certain problems are not in P. 1 Computational Problems In a computational problem, we are given an input that, without loss of generality, we assume to be encoded over the alphabet {0, 1}, and we want to return as output a solution satisfying some property: a computational problem is then described by the property that the output has to satisfy given the input. In this course we will deal with four types of computational problems: decision problems, search problems, optimization problems, and counting problems. 1 For the moment, we will discuss decision and search problem. In a decision problem, given an input x {0, 1}, we are required to give a YES/NO answer. That is, in a decision problem we are only asked to verify whether the input satisfies a certain property. An example of decision problem is the 3-coloring problem: given an undirected graph, determine whether there is a way to assign a color chosen from {1, 2, 3} to each vertex in such a way that no two adjacent vertices have the same color. A convenient way to specify a decision problem is to give the set L {0, 1} of inputs for which the answer is YES. A subset of {0, 1} is also called a language, so, with the previous convention, every decision problem can be specified using a language (and every language specifies a decision problem). For example, if we call 3COL the subset of {0, 1} containing (descriptions of) 3-colorable graphs, then 3COL is the language that specifies the 3-coloring problem. From now on, we will talk about decision problems and languages interchangeably. In a search problem, given an input x {0, 1} we want to compute some answer y {0, 1} that is in some relation to x, if such a y exists. Thus, a search problem is specified by a relation R {0, 1} {0, 1}, where (x, y) R if and only if y is an admissible answer given x. Consider for example the search version of the 3-coloring problem: here given an undirected graph G = (V, E) we want to find, if it exists, a coloring c : V {1, 2, 3} of the vertices, such that for every (u, v) V we have c(u) c(v). This is different (and more demanding) than the decision version, because beyond being asked to determine whether such a c exists, we are also asked to construct it, if it exists. Formally, the 3-coloring problem is specified by the relation R 3COL that contains all the pairs (G, c) where G is a 3-colorable graph and c is a valid 3-coloring of G. 1 This distinction is useful and natural, but it is also arbitrary: in fact every problem can be seen as a search problem 1

2 P and NP In most of this course, we will study the asymptotic complexity of problems. Instead of considering, say, the time required to solve 3-coloring on graphs with 10, 000 nodes on some particular model of computation, we will ask what is the best asymptotic running time of an algorithm that solves 3-coloring on all instances. In fact, we will be much less ambitious, and we will just ask whether there is a feasible asymptotic algorithm for 3-coloring. Here feasible refers more to the rate of growth than to the running time of specific instances of reasonable size. A standard convention is to call an algorithm feasible if it runs in polynomial time, i.e. if there is some polynomial p such that the algorithm runs in time at most p(n) on inputs of length n. We denote by P the class of decision problems that are solvable in polynomial time. We say that a search problem defined by a relation R is a NP search problem if the relation is efficiently computable and such that solutions, if they exist, are short. Formally, R is an NP search problem if there is a polynomial time algorithm that, given x and y, decides whether (x, y) R, and if there is a polynomial p such that if (x, y) R then y p( x ). We say that a decision problem L is an NP decision problem if there is some NP relation R such that x L if and only if there is a y such that (x, y) R. Equivalently, a decision problem L is an NP decision problem if there is a polynomial time algorithm V (, ) and a polynomial p such that x L if and only if there is a y, y p( x ) such that V (x, y) accepts. We denote by NP the class of NP decision problems. The class NP has the following alternative characterization, from which it takes its name. (NP stands for Nondeterministic Polynomial time.) Theorem 1 NP is the set of decision problems that are solvable in polynomial time by a non-deterministic Turing machine. Proof: Suppose that L is solvable in polynomial time by a non-deterministic Turing machine M: then we can define the relation R such that (x, t) R if and only if t is a transcript of an accepting computation of M on input x (that is, the sequence of configurations of an accepting branch of M on input x) and it s easy to prove that R is an NP relation and that L is in NP according to our first definition. Suppose that L is in NP according to our first definition and that R is the corresponding NP relation. Then, on input x, a nondeterministic Turing machine can guess a string y of length less than p( x ) and then accept if and only if (x, y) R. Such a machine can be implemented to run in non-deterministic polynomial time and it decides L. The reason why NP, as a complexity class, is defined as a class of decision problems rather than search problems is that one can develop a cleaner theory for decision problems (the definition of reduction, for example, is simpler), and the complexity of decision problems in NP completely characterizes the complexity of search problems. Theorem 2 For every NP search problem there is an NP decision problem such that if the decision problem is solvable in time t(n) then the search problem is solvable in time 2

O(n O(1) t(n O(1) )). In particular, P = NP if and only if every NP search problem is solvable in polynomial time. Proof: Let R be an NP relation defining an NP search problem. following decision problem: Then consider the Input: a pair of strings x, w Goal: determine if there is a string z such that (x, w z) R, where denotes string concatenation. Suppose the above decision problem is solvable in time t(n) by an algorithm A. Then consider the following algorithm for the search problem (ɛ denotes the empty string): Input x if A(x, ɛ) == F ALSE, then return no solution w := ɛ while (x, w) R if A(x, w 0) == T RUE then w := w 0 else w := w 1 return w If there is no solution for x, then the algorithm discovers that at the beginning. Otherwise, every iteration of the while loop increases the length of w while maintaining the invariant that w is a prefix of a valid solution to x. Since R is an NP relation, such a solution must be of length polynomial in the length of x, and so the loop terminates after a polynomial number of iterations, with a valid solution. For a function t : N N, we define by DTIME(t(n)) the set of decision problems that are solvable by a deterministic Turing machine within time t(n) on inputs of length n, and by NTIME(t(n)) the set of decision problems that are solvable by a non-deterministic Turing machine within time t(n) on inputs of length n. Hence, P = k DTIME(O(nk )) and NP = k NTIME(O(nk )). 3 Diagonalization Diagonalization is essentially the only way we know of proving separations between complexity classes. The basic principle is the same as in Cantor s proof that the set of real numbers is not countable. First note that if the set of real numbers r in the range [0, 1) is countable then the set of infinite binary sequences is countable: we can identify a real number r in [0, 1) with its binary expansion r = j=1 2 j r[j]. If we had an enumeration of real numbers, then we would also have an enumeration of infinite binary string. (The only 3

thing to watch for is that some real numbers may have two possible binary representations, like 0.01000 and 0.001111.) So, suppose towards a contradiction that the set of infinite binary sequences were countable, and let B i [j] be the j-th bit of the i-th infinite binary sequence. Then define the sequence B whose j-th bits is 1 B j [j]. This is a well-defined sequence but there can be no i such that B = B i, because B differs from B i in the i-th bit. Similarly, we can prove that the Halting problem is undecidable by considering the following decision problem D: on input M, the description of a Turing machine, answer NO if M( M ) halts and accepts and YES otherwise. The above problem is decidable if the Halting problem is decidable. However, suppose D where decidable and let T be a Turing machine that solves D, then T ( T ) halts and accepts if and only if T ( T ) does not halt and accept, which is a contradiction. It is easy to do something similar with time-bounded computations. Definition 3 (Time constructible functions) A function f : N N is time constructible if there is an algorithm that, on input n, computes the value t(n) in time O(t(n)) All polynomials p(n) are time constructible, as well as all combinations of exponential, polynomial, and root functions such as 2 n, 2 n, 2 2n3 1, and so on. Indeed, one needs to work quite hard to come with an example of a function that is not time constructible. One example of a function that is not time constructible is the following: define t(n) to equal n 2 if the number n written in binary encodes a turing machine that halts on all inputs, and define t(n) to equal n 2 + 1 otherwise. Theorem 4 (Time hierarchy theorem simplified version) For every time-constructible function t( ), there is a language L such that every algorithm that decides L must run in time > t(n) on infinitely many inputs, but L DTIME(t O(1) (n)). Proof: The theorem holds for any model of computation which is simulable within the model. For concreteness, we give the proof for the case of Turing machine. We define the language L := {(M, x) : M((M, x)) halts and rejects in t( (M, x) ) steps } That is, an input to the problem is a pair (M, x), where M is a Turing machine and x is a possible input for x, and the goal of the problem is to determine whether M, on input x, halts and rejects in at most t(n) steps, where n is the length of (M, x). First, we note that L is decidable in time polynomial in t(n) on inputs of length n. Given an input (M, x), we compute t(n), where n is the length of (M, x) in time O(t(n)) (here we are using the time-constructibility of t( )) and then we run a simulation of the computation of M on input x. If the simulation halts and reject within t(n) steps, then we accept. If the simulation accepts within t(n) steps, or is still running after t(n) + 1 steps, then we reject. It remains to argue that every machine that decides L must run in time > t(n) for infinitely many inputs. 4

Let M be a machine that decides L and let x be any string. Suppose that M, on input (M, x), halts after t( (M, x) ) steps. Then if M, on input (M, x), rejects, then (M, x) L, by definition of L, and so M is incorrectly deciding L on input (M, x). If M, on input (M, x) accepts, then (M, x) L, and so M is again incorrect. In either case we reach a contradiction to the assumption that M decides L. It follows that M halts after > t( M, x ) steps on all the inputs of the form (M, x), of which there are infinitely many. We define two more complexity classes in order to derive certain simple consequences of the time hierarchy theorem. E := DTIME(2 O(n) ) EXP := k DTIME(2 O(nk) ) Corollary 5 P E and E EXP Proof: Apply the time hierarchy theorem to t(n) = 2 n, and let L be the resulting language. Then L is decidable in time 2 O(n), and so it is in E. Suppose that L P, and so that there is a machine that decides L in time at most p(n) on inputs of length n, where p( ) is a polynomial. Since p(n) 2 n for all but finitely many values of n, contradicting the property of L guaranteed by the time hierarchy theorem. Apply the time hierarchy theorem to t(n) = 2 n2, and let L be the resulting language. Then L is decidable in time 2 O(n2), and so L EXP, but we cannot have L E or else the machine deciding L in time 2 O(n) would run in time 2 n2 for all but a finite number of inputs. Besides separating complexity classes, we can also use the hierarchy theorem to prove lower bounds for specific problems. Consider the time-bounded acceptance problem BA defined as BA := {(M, x, t) : M accepts x within t time steps} Then we see that BA is solvable in time 2 O(n) given an input of length n. (The simulation can be performed in time polynomial in the length of M, in the length of x, and in the value of t. If n is the overall input length, then the length of M and x are at most n, and the value of t is at most 2 n.) Now, suppose that there was an algorithm for BA running in time 2 o(n) : we show that this implies that every problem in E can also be solved in 2 o(n time. Indeed, let L be a problem in E, and let M be a machine that solves L in time 2 cn for a constant c on inputs of length n. Then, given an input x for L of length n, we can prepare the input (M, x, 2 cn ) for BA, and we see that x L if and only if (M, x, 2 cn ) BA. Since (M, x, 2 cn ) is an input of BA length n = O(1) + n + cn, it can be decided in time 2 o(n ), which is 2 o(n). Now, deciding all problems in E in time 2 o(n) is a violation of the time hierarchy theorem, and so the assumption that there is a 2 o(n) -time algorithm for BA must be false. 5