Chapter 2 : Time complexity

Similar documents
Theory of Computation Time Complexity

Intro to Theory of Computation

BBM402-Lecture 11: The Class NP

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

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

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

Chapter 7: Time Complexity

CSE 105 THEORY OF COMPUTATION

Computational Models Lecture 11, Spring 2009

CS154, Lecture 13: P vs NP

NP Complete Problems. COMP 215 Lecture 20

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

CISC 4090 Theory of Computation

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

CSE 135: Introduction to Theory of Computation NP-completeness

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.

Time Complexity. CS60001: Foundations of Computing Science

CS154, Lecture 13: P vs NP

NP-completeness. Chapter 34. Sergey Bereg

NP-Complete Problems. More reductions

CSE 105 THEORY OF COMPUTATION

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

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

Computability Theory

Complexity (Pre Lecture)

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

Lecture 19: Finish NP-Completeness, conp and Friends

CSE 105 Theory of Computation

ECS 120 Lesson 24 The Class N P, N P-complete Problems

1. Introduction Recap

CS 3719 (Theory of Computation and Algorithms) Lectures 23-32

Essential facts about NP-completeness:

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

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

Intro to Theory of Computation

1 Non-deterministic Turing Machine

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

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

CSE 105 THEORY OF COMPUTATION

More Completeness, conp, FNP,etc. CS254 Chris Pollett Oct 30, 2006.

Lecture 3: Nondeterminism, NP, and NP-completeness

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

NP-Complete Reductions 1

NP-Complete Reductions 2

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

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

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

NP and Computational Intractability

CMPT307: Complexity Classes: P and N P Week 13-1

13.1 Nondeterministic Polynomial Time

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

Polynomial-time reductions. We have seen several reductions:

Chapter 34: NP-Completeness

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

Lecture 4: NP and computational intractability

More NP-Complete Problems

CS311 Computational Structures. NP-completeness. Lecture 18. Andrew P. Black Andrew Tolmach. Thursday, 2 December 2010

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

Show that the following problems are NP-complete

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

Lecture 16: Time Complexity and P vs NP

Polynomial-time Reductions

Lecture 20: conp and Friends, Oracles in Complexity Theory

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

SAT, Coloring, Hamiltonian Cycle, TSP

Lecture 13, Fall 04/05

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

Spring Lecture 21 NP-Complete Problems

Computational Intractability 2010/4/15. Lecture 2

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

Artificial Intelligence. 3 Problem Complexity. Prof. Dr. Jana Koehler Fall 2016 HSLU - JK

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

CS 6505, Complexity and Algorithms Week 7: NP Completeness

Time and space classes

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

CS151 Complexity Theory. Lecture 1 April 3, 2017

CS21 Decidability and Tractability

COP 4531 Complexity & Analysis of Data Structures & Algorithms

NP and NP-Completeness

Correctness of Dijkstra s algorithm

CS 583: Algorithms. NP Completeness Ch 34. Intractability

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

Quiz 3. Please write your name in the upper corner of each page. Problem Points Grade. Total 100 Q3-1

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

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

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

1 Computational Problems

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

Space Complexity. The space complexity of a program is how much memory it uses.

6.840 Language Membership

conp, Oracles, Space Complexity

Notes for Lecture Notes 2

Topics in Complexity Theory

Final exam study sheet for CS3719 Turing machines and decidability.

NP Completeness and Approximation Algorithms

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

Transcription:

Dr. Abhijit Das, Chapter 2 : Time complexity In this chapter we study some basic results on the time complexities of computational problems. concentrate our attention mostly on polynomial time complexities, deterministic and nondeterministic. We 2.1 The complexity classes P and NP P is the class of languages accepted by poly-time DTMs, whereas NP is the class of languages accepted by poly-time NTMs. More specifically for input size n we define: P := TIME(n k ), and NP := NTIME(n k ). These classes are invariant for all computational models that are polynomially equivalent to the single-tape single-head TM (deterministic for P, nondeterministic for NP). We use e n c o d i n g s... of (a finite number of) objects into a string. We assume only reasonable encodings. Examples of reasonable encodings include the binary (or decimal or hexadecimal) encoding of positive integers, adjacency matrix representation of a graph and so on. The unary encoding of positive integers is not reasonable, since it demands unreasonable (exponential) amount of space compared to reasonable encodings (like binary). 2.1 Example (1) The language PATH := { G, s, t There is a path from vertex s to vertex t in a directed graph G} is in P. The proof is based on search algorithms (like BFS or DFS) in the graph. (2) The language RELPRIME := { x, y The positive integers x and y are relatively prime} is also in P. The proof is based on the Euclidean division and gcd algorithms. (3) Every context-free language is in P. For the proof one may use a dynamic programming algorithm for context-free grammars in Chomsky-normal form. NP comprises precisely the languages that are verifiable in poly-time, i.e., that have succinct certificates. 2.2 Definition A v e r i f i e r for a language L Σ is defined to be a DTM V, such that L = {α α, β L(V ) for some β Σ }. The string β is a c e r t i f i c a t e for the membership of α in L. V is called a p o l y - t i m e v e r i f i e r, if V runs in poly-time in the size of α. For a poly-time verifier a certificate β for α must be of polynomial length in α. Such certificates are called s u c c i n c t c e r t i f i c a t e s. 2.3 Theorem A NP if and only if A has a poly-time verifier.

Page 2 of 6 17642 Computational Complexity 2.4 Example The following languages are in NP: HAMPATH := { G, s, t There is a Hamiltonian path from vertex s to vertex t in the directed graph G} UHAMPATH := { G, s, t There is a Hamiltonian path from vertex s to vertex t in the undirected graph G} CLIQUE := { G, k The undirected graph G has a k-clique} INDEP-SET := { G, k The undirected graph G has an independent set of size k} VERTEX-COVER := { G, k The undirected graph G has a vertex cover of size k} COMPOSITE := { x The positive integer x is composite} { SUBSET-SUM := S, t There is a subset T of the set S with t = } x x T Exercises for Section 2.1 1. Prove that the following languages are in P: SAT := { φ φ is a satisfiable Boolean formula} 3SAT := { φ φ is a satisfiable Boolean formula in 3-cnf} CONNECTED := { G G is a connected undirected graph} BIPARTITE := { G G is an undirected bipartite graph} TRIANGLE-FREE := { G G is a triangle-free undirected graph} 2. Show that the language GRAPHISO := { G 1, G 2 The undirected graphs G 1 and G 2 are isomorphic} is in NP. ** 3. Show that the language PRIME := { x x is a prime positive integer} is in NP. (Remark: Of course, we now know that PRIME P and so in NP as well. An independent proof that PRIME NP is not as easy as proving COMPOSITE NP. You may use the fact that p N is prime if and only if Z p is cyclic and of order p 1. You may require the prime factorization of p 1 as part of a certificate for primality of p.) * 4. (a) Demonstrate that the class P is closed under union, intersection, complement, concatenation and Kleene star. (b) Prove that the class NP is closed under union, intersection, concatenation and Kleene star. (Remark: It is widely believed that NP is not closed under complement.) 2.2 NP-complete problems Complete problems in a complexity class constitute the set of most difficult problems in the class. The definition of completeness in a particular class depends on suitable reduction algorithms between problems. 2.5 Definition A p o l y - t i m e c o m p u t a b l e f u n c t i o n f : Σ Σ is a function for which a poly-time DTM M exists with the property that M, on input α, halts with f(α) (and nothing else) on its tape. A language A is p o l y - t i m e r e d u c i b l e to a language B, if there exists a poly-time computable function f such that for every α we have α A if and only if f(α) B. In this case we write A P B. 2.6 Definition A language L is called N P - c o m p l e t e, if: (1) L NP and (2) A P L for every A NP. 2.7 Theorem If A P B and B P, then A P.

Chapter 2: Time complexity Page 3 of 6 2.8 Theorem If A is NP-complete and A P, then P = NP. 2.9 Theorem If A is NP-complete and A P B, then B is NP-complete too. The last theorem suggests that once we have proved certain problems to be NP-complete, we can reduce these problems to other problems in NP to prove the NP-completeness of these new problems. That makes the class of NP-complete problems bigger and allows more possibilities for reductions to newer problems. However, the challenge is to prove from the scratch a first NP-complete problem to be so. This is done by the following pioneering work. 2.10 Theorem [ C o o k - L e v i n ] SAT is NP-complete. A simple continuation of the proof of Cook-Levin s theorem implies: 2.11 Theorem 3SAT is NP-complete. 2.12 Example All the problems introduced in Example 2.4 (except COMPOSITE) can be proved to be NP-complete. One may use the following reductions: 3SAT P CLIQUE, CLIQUE P INDEP-SET, INDEP-SET P VERTEX-COVER, 3SAT P HAMPATH, HAMPATH P UHAMPATH and 3SAT P SUBSET-SUM. Exercises for Section 2.2 1. Show that if P = NP and L P \ {, Σ }, then L is NP-complete. 2. Show that 2 2 windows are not sufficient in the proof of the Cook-Levin theorem. ** 3. Let 2SAT := { φ φ is a satisfiable Boolean formula in 2-cnf}. Show that 2SAT P. 4. Prove that the following problems are NP-complete. HAMCYCLE := { G There is a Hamiltonian cycle in the directed graph G} UHAMCYCLE := { G There is a Hamiltonian cycle in the undirected graph G} 5. [ T h e t r a v e l i n g s a l e s p e r s o n p r o b l e m ] Assume that a salesperson wishes to visit m cities with each city visited exactly once. Associated with each pair of cities a (positive) cost representing the overhead for inter-city travel (assumed symmetric with respect to the two cities). The objective of the salesperson is to reduce the total cost for the travel. Consider an undirected (complete) graph on m vertices with each vertex representing a city and with each edge labeled by the cost of the corresponding inter-city travel. The traveling salesperson problem can be reformulated as finding an (undirected) Hamiltonian cycle in the graph with the minimum sum of labels on the edges of the cycle. The following is the decision version of this problem: TSP := { G, k G has a Hamiltonian cycle of (total) cost k}. Show that TSP is NP-complete. 6. Let DOUBLE-SAT := { φ φ has 2 satisfying assignments}. Show that DOUBLE-SAT is NP-complete. 7. For a fixed k define kcolor := { G The undirected graph G is k-colorable}. Prove that: * (a) 2COLOR P. ** (b) 3COLOR is NP-complete.

Page 4 of 6 17642 Computational Complexity 2.3 The class conp The complements of languages in NP constitute the class conp: conp := {L L NP}. Thus conp consists of languages that have p o l y - t i m e d i s q u a l i f i e r s. It is not known if NP = conp. The popular belief is that these two classes are different. One can define complete problems for the class conp using poly-time reductions as in Definition 2.6. It turns out that: 2.13 Theorem L is NP-complete if and only if L is conp-complete. 2.14 Theorem If P = NP, then NP = conp. However, one may have NP = conp, even when P NP. We also have the following result: 2.15 Theorem If a conp-complete problem is in NP, then NP = conp. 2.16 Theorem P NP conp. It is widely believed that P NP conp. The conjectured relationships among the complexity classes introduced so far are described in Figure 2.1. Here all containments are conjectured to be proper. We can only prove P EXP, where EXP is the deterministic exponential-time class defined for input size n as: EXP := TIME(2 nk ). The exponential-time simulation of an NTM by a DTM implies: 2.17 Theorem NP EXP. Figure 2.1: Conjectured relationships among the time complexity classes EXP NP conp NP complete P conp complete Exercises for Section 2.3 1. (a) Prove that the class EXP is closed under union, intersection, complement, concatenation and Kleene star. (b) Deduce that conp EXP.

Chapter 2: Time complexity Page 5 of 6 2. A s t r o n g n o n d e t e r m i n i s t i c T u r i n g m a c h i n e has three possible outcomes: accept, reject and notsure, and decides a language L as follows: If α L, all branches of computation on input α end up in outcomes accept or notsure, with at least one branch providing an accept answer. On the other hand, if α / L, all possible branches of computation on α end up in reject or notsure, with at least one reject answer. Deduce that L is decided by a poly-time strong NTM if and only if L NP conp. * 3. Define the decision version of the integer factoring problem as: FACTORING := { n, k n N has a factor d with 1 < d < k}. Show that FACTORING NP conp. (Hint: For the proof of FACTORING conp you may assume that PRIME NP.) ** 4. The nondeterministic exponential-time class NEXP is defined as: NEXP := NTIME(2 nk ), where n is the input size. Clearly, EXP NEXP. It is not known if (but popularly believed that) this containment is proper. Prove that if P = NP, then EXP = NEXP. (Hint: Let L NEXP and N an NTM that decides L in time 2 nk for some k N. Define the language L := {α 2 α k α α L}, where is a quasiblank symbol. First show that L NP. By hypothesis, there is a DTM M that decides L in poly-time. Convert M to an exponential-time DTM M to accept L.) 2.4 Function problems So far we have considered only decision problems, i.e., problems that have yes/no answers. In practice, however, we deal with problems that compute some quantities from the input string. For example, SAT talks about the satisfiability of a Boolean function. We now frame the problem: if φ is satisfiable, compute a satisfying assignment for φ. We call this new problem FSAT. It may turn out that these compute something problems are more difficult than the corresponding decision versions. However, we have strong results that justify concentrating on studies of decision problems only. 2.18 Theorem FSAT can be solved in (deterministic) poly-time if and only if SAT P. We now formally introduce function problems. 2.19 Definition Let ρ Σ Σ be a relation (on Σ ). ρ is said to be p o l y n o m i a l l y d e c i d a b l e, if { α, β (α, β) ρ} is in P. ρ is said to be p o l y n o m i a l l y b a l a n c e d, if whenever (α, β) ρ, we have β α k for some constant k N (depending on L but independent of α or β). 2.20 Theorem Let L Σ. Then L NP if and only if there exists a polynomially decidable and polynomially balanced relation ρ L Σ Σ with L = {α (α, β) ρ L for some β}. 2.21 Definition Let L NP and ρ L be as in Theorem 2.20. The f u n c t i o n p r o b l e m associated with L is the following: If α L, compute some β with (α, β) ρ L ; if α / L, return no. (Of course, such a problem does not compute a function in the mathematical sense, since there may be several β for a given α.) Let us denote by FL the function problem associated with L NP. We can now define the class: FNP := {FL L NP}. FP is the subclass of FNP consisting of function problems that can be solved in deterministic poly-time.

Page 6 of 6 17642 Computational Complexity It is not known (but believed) that FP FNP. The problem FSAT of Theorem 2.18 is in FNP, but unlikely to be in FP. One can define reduction between problems in FNP and also complete problems for the class FNP. It can be shown that FSAT is FNP-complete. This implies that: 2.22 Theorem FP = FNP if and only if P = NP. Some function problems have language Σ and are not interesting in terms of their decidability. Such problems are typically meant for computing some quantity and this computation makes sense for every possible input. In this case, the relation ρ L is important (and not the trivial language L). 2.23 Definition A problem ρ L in FNP is called total, if for every α Σ there exists β with (α, β) ρ L. TFNP is the subclass of FNP consisting of total function problems. 2.24 Example (1) The total version TFACTORING of the integer factoring problem deals with the computation of the prime factorization of the positive integer represented by the input α. Note that every positive integer has a (unique) prime factorization. Thus the problem of deciding if a factorization exists is not important; what is important is to compute it. (2) The HAPPYNET problem on an undirected graph G = (V, E) is defined as follows. The vertices of G are thought of as human beings and each edge (u, v) E is labeled by an integer (positive or negative) weight w(u, v) indicating the extent to which the vertices u and v like (or dislike) one another. A state is a map σ : V {1, 1}. A vertex u V is said to be happy in a state σ, if σ(u) (u,v) E w(u, v)σ(v) 0. For any undirected graph G there exists a state in which every vertex is happy. The HAPPYNET problem computes one such state given the graph G. Problems in TFNP are believed to be easier than FNP-complete. The conjectured relationships among the function problems are depicted in Figure 2.2, where all containments are believed to be proper. Figure 2.2: Conjectured relationships among the complexity classes for function problems FNP complete FNP FP TFNP Exercises for Section 2.4 ** 1. Consider the total version TTSP of TSP (Exercise 2.2.5), in which an optimal tour of the salesperson is to be computed. Demonstrate that if TSP P, then TTSP has a poly-time algorithm. * 2. Consider the total version TFACTORING of the integer factoring problem (Exercise 2.3.3), in which the prime factorization of the input is to be computed. Deduce that if FACTORING P, then TFACTORING has a polytime algorithm. 3. Let a 1,..., a n be n positive integers with n i=1 a i < 2 n 1. Show that there exist disjoint nonempty subsets S and T of {a 1,..., a n } with x S x = y T y. The problem of computing such subsets S and T is thus in TFNP. This problem has no known poly-time algorithm.