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



Similar documents
NP-Completeness and Cook s Theorem

Introduction to Logic in Computer Science: Autumn 2006

Lecture 7: NP-Complete Problems

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

The Online Freeze-tag Problem

OHJ-2306 Introduction to Theoretical Computer Science, Fall

The Classes P and NP

Point Location. Preprocess a planar, polygonal subdivision for point location queries. p = (18, 11)

Notes on Complexity Theory Last updated: August, Lecture 1

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

Theoretical Computer Science (Bridging Course) Complexity

Notes on Complexity Theory Last updated: August, Lecture 1

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

Chapter. NP-Completeness. Contents

CSC 373: Algorithm Design and Analysis Lecture 16

As we have seen, there is a close connection between Legendre symbols of the form

Complexity Classes P and NP

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

P versus NP, and More

6.042/18.062J Mathematics for Computer Science December 12, 2006 Tom Leighton and Ronitt Rubinfeld. Random Walks

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

On the Relationship between Classes P and NP

A Working Knowledge of Computational Complexity for an Optimizer

An important observation in supply chain management, known as the bullwhip effect,

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

Lecture 2: Universality

SOME PROPERTIES OF EXTENSIONS OF SMALL DEGREE OVER Q. 1. Quadratic Extensions

Notes on NP Completeness

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

Theory of Computation Chapter 2: Turing Machines

ENFORCING SAFETY PROPERTIES IN WEB APPLICATIONS USING PETRI NETS

Computability Theory

Generating models of a matched formula with a polynomial delay

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

Complex Conjugation and Polynomial Factorization

Lecture summary for Theory of Computation

A Modified Measure of Covert Network Performance

The Halting Problem is Undecidable

1 Gambler s Ruin Problem

9.2 Summation Notation

Turing Machines: An Introduction

Software Model Checking: Theory and Practice

Lectures on the Dirichlet Class Number Formula for Imaginary Quadratic Fields. Tom Weston

Introduction to computer science

Exponential time algorithms for graph coloring

Solving NP-complete problems in the tile assembly model

FACTORING BIVARIATE SPARSE (LACUNARY) POLYNOMIALS

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

Computing the Most Probable String with a Probabilistic Finite State Machine

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

1 Definition of a Turing machine

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

Tutorial 8. NP-Complete Problems

Chapter 7 Uncomputability

PRIME NUMBERS AND THE RIEMANN HYPOTHESIS

CHAPTER 7 GENERAL PROOF SYSTEMS

Quantum and Non-deterministic computers facing NP-completeness

Computational Finance The Martingale Measure and Pricing of Derivatives

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

Lecture 1: Oracle Turing Machines

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

Assignment 9; Due Friday, March 17

Mathematics Course 111: Algebra I Part IV: Vector Spaces

3515ICT Theory of Computation Turing Machines

C-Bus Voltage Calculation

2.1 Complexity Classes

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

The P versus NP Solution

Regular Languages and Finite Automata

The Parameterized Complexity of Short Computation and Factorization

(LMCS, p. 317) V.1. First Order Logic. This is the most powerful, most expressive logic that we will examine.

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

TRANSCENDENTAL NUMBERS

Universality in the theory of algorithms and computer science

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

United Arab Emirates University College of Sciences Department of Mathematical Sciences HOMEWORK 1 SOLUTION. Section 10.1 Vectors in the Plane

Computational complexity theory

Factoring & Primality

Notes on Determinant

Service Network Design with Asset Management: Formulations and Comparative Analyzes

P NP for the Reals with various Analytic Functions

COMMUTATIVITY DEGREES OF WREATH PRODUCTS OF FINITE ABELIAN GROUPS

Sudoku as a SAT Problem

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

Number Theory Naoki Sato

Offline 1-Minesweeper is NP-complete

POISSON PROCESSES. Chapter Introduction Arrival processes

A Note on Integer Factorization Using Lattices

NP-completeness and the real world. NP completeness. NP-completeness and the real world (2) NP-completeness and the real world

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

How To Solve An Npa-Complete Problems With Quantum Computing And Chaotic Dynamics

Fixed-Point Logics and Computation

Discuss the size of the instance for the minimum spanning tree problem.

Introduction to Automata Theory. Reading: Chapter 1

Transcription:

91.502 Foundations of Comuter Science 1 Introduction to Written and coyright c by Jie Wang 1 We use time-bounded (deterministic and nondeterministic) Turing machines to study comutational comlexity of decision roblems. In this model, a Turing machine has two different halting states, called the acceting state and the rejecting state, resectively. We say that a Turing machine M is bounded by time T if for any inut x, M on x always halts in T ( x ) moves (stes). If M is deterministic and M on inut x halts at the acceting state, then we say that x is acceted by M. If M is nondeterministic and there exists at least one comutation ath of M on inut x that halts on the acceting state, then we say that x is acceted by M. We are articularly interested in olynomial-time bounds for the following reasons. Let 1. All roblems in ractice that are solvable efficiently can be solved by deterministic Turing machines in olynomial time. 2. Polynomials are closed under addition, multilication, and comosition. P = {D D is solvable by a DTM in olynomial time} NP = {D D is solvable by an NTM in olynomial time}. Problems in P are considered tractable. Clearly, P is included in NP. Many comutational roblems, while being in NP, are not known to be in P. It is the central oen roblem in comuter science whether all roblems in NP are tractable; namely, whether P = NP. While there is no known mathematical roof in either direction at this oint, it is commonly believed that P NP. We use the notion of NP -comleteness to measure the hardest roblems in NP. (Remark: N P -comleteness is a worst-case measure.) First, we define the notion of olynomial-time reductions. Definition 1 Let A and B be two decision roblems. If there is a olynomial-time comutable reduction f such that A m B via f, namely, x : x A iff f(x) B, written as A m B, then we say that A is olynomial-time reducible to B. The following roosition is straightforward (its roof is left to the reader). Proosition 2 1. Polynomial-time reductions are closed for P. Namely, if A m B and B P, then A P. 1 Written in Sring 2003. First udate in Fall 2003. Second udate in Fall 2006.

91.502 Foundations of Comuter Science 2 2. Polynomial-time reductions are transitive. Namely, if A m B and B m C, then A m C. Proosition 2(1) indicates that, in the context of olynomial-time solvability, if A m B, then A is not harder than B. So the hardest roblem in NP is one that can be reduced to from any roblem in NP. We call such a roblem an NP -comlete roblem. Definition 3 A roblem D is NP -comlete if (1) D NP and (2) A NP : A m D. Thousands of roblems have been shown NP -comlete. In the resent note we will look at four classic N P -comlete roblems; they are bounded halting (BH), bounded tiling (BT), Boolean satisfiability (SAT), and 3-Satisfiability (3SAT). 1 Bounded Halting Recall that the halting roblem defined below is Turing-accetable but not decidable. H = { M, x M is a TM and M on x halts}. We can further show that every r.e. language is reducible to H. Let A be an r.e. set. Then there is a TM M A such that M A accets A. Construct a reduction f by f(x) = M A, x. Clearly, f is a recursive function. We have x : x A iff M A halts on x iff f(x) H. This result indicates that H is comlete for all r.e. sets; in other words, H is the hardest roblem in r.e. sets. Bounded Halting Problem (BH) Instance. A (nondeterministic) Turing machine M, a binary string x, and a unitary notion 0 n reresenting ositive integer n. Question. Does M accet x in n stes? For convenience we use BH to denote the ositive instances of Bounded Halting; namely, Theorem 4 BH is NP-comlete. BH = { M, x, 0 n M accets x in n stes}. Proof. It is straightforward to show that BH NP, for M, x, 0 n = Θ( M + x + n) (the detailed roof is left to the reader). We will now olynomially reduce every roblem in NP to BH. Let A NP. Then there exists a nondeterministic TM M A such that M A accets A in time, where is a fixed olynomial. Construct a reduction f by f(x) = M A, x, 0 ( x ).

91.502 Foundations of Comuter Science 3 Then x : x A iff M A accets x in ( x ) time iff M A, x, 0 ( x ) BH iff f(x) BH. Since M A is a fixed TM and is a olynomial, roducing M A, x, 0 ( x ) from x can be carried out in time olynomial of x. Hence, f is olynomial-time comutable. Thus, A m BH. This comletes the roof. 2 Bounded Tiling A tile is a square with a symbol on each side. We assume that titles may not be rotated or turned over, and that there is an unlimited suly of each tile. By tiling of an n n square it means to select and arrange n 2 tiles to cover the square so that the symbols on the common sides of adjacent tiles are the same. The size of a tile is the length of the binary reresentation of the four symbols at each edge in a fixed order. Bounded Tiling Problem (BT) Instance. A finite set of tiles T, a unitary notation 0 n reresenting ositive integer n, and a sequence S = s 1 s 2... s k (k n) of tiles that match each other, i.e. the symbol on the right side of s i is the same as that on the left side of s i+1. (The size of the instance is n lus the summation of the sizes of all tiles in T lus the summation of the sizes of all members in S.) Question. Can S be extended to tile an n n square using tiles from T? Denote by BT the ositive instances of bounded tiling, namely, BT = { T, S, 0 n S can be extended to tile an n n square using tiles from T }. Theorem 5 Bounded tiling is NP-comlete. Proof. That BT N P is straightforward (the reader can easily fill in the details). We will now olynomially reduce every roblem in NP to BT. Let A NP. Then there is a (nondeterministic) Turing machine M A = (Q, Σ, δ, q 0, {h a, h r }) that accets A in olynomial time. Without loss of generality, we assume that Σ = {0, 1, B}, and all comutation aths of M A on inut x have length strictly less than ( x ), where is a fixed olynomial. Here Q is the finite set of states of M A, δ the transition function, q 0 the initial state, h a the acceting state, h r the rejecting state, and B the blank symbol. We construct the following set T (M A ) of legal tiles: for α {0, 1, B} : α α

91.502 Foundations of Comuter Science 4 for α, β, γ {0, 1, B}, q Q {h a, h r }, Q, δ(q, α) = (, β, R): β (,γ) (q,α) γ for α, β, γ {0, 1, B}, q Q {h a, h r }, Q, δ(q, α) = (, β, L): β (,γ) (q,α) γ for α {0, 1, B}: (h a,α) (h a,α) and for α {0, 1, B}: (q 0,α) α The desired reduction is defined by f(x) = T (M A ), S, 0 ( x ), where if x is written as x 1 x 2... x k for x i {0, 1}, S is the following sequence of tiles with ( x ) k blanks: (q 0,x 1 ) x k B B From the construction, it is easy to see that f is olynomial-time comutable. If S extends to a set of legal tiles which tile a ( x ) ( x ) square, then S will have to occuy the bottom row of the square. In this case, the symbols at the to of the bottom row reresents the initial configuration of M A on inut x. Likewise, the symbols at the to of the ith row from the bottom will reresent the configuration of a osition reachable by M A within i stes. Since M A will reach the acceting or rejecting state in less than ( x ) stes, and the tiling can only dulicate the acceting state, S can extend to a tiling only if M A accets x. Similarly, if M A accets x, then S can be extended to a tiling of a ( x ) ( x ) square. This comletes the roof. 3 Boolean Satisfiability We consider Boolean formulas in conjunctive normal form. Namely, each formula F of n variables is given as a set of clauses {C 1, C 2,..., C m }, where each C i is a set of literals {l i,1,..., l i,ji }. A literal is a variable or negation of a variable. Then F = m ji i=1 k=1 l i,j k, where denotes conjunction, and denotes disjunction.

91.502 Foundations of Comuter Science 5 Boolean Satisfiability Problem (SAT) Instance. A boolean formula ψ in conjunctive normal form. Question. Is ψ satisfiable? For convenience, denote by SAT the ositive instances of Boolean satisfiability roblem; namely, SAT = {ψ ψ is satisfiable}. Theorem 6 (Cook s Theorem) SAT is NP-comlete. Proof. We will olynomially reduce bounded tiling to SAT. Then by Proosition 2(2), we know that every roblem in NP is olynomially reducible to SAT. Let T, S, 0 n be an instance of bounded tiling. Label the different tiles occurred in S as t 1,..., t l, and the tiles in T but not in S as t l+1,..., t T. Let H T denote the set of tile airs [t i, t j ] such that t i can be laced horizontally left to t j, and V T the set of tile airs [t i, t j ] such that t i can be laced vertically below t j. Create N = n 2 T variables v i,j,k, where 1 i, j n, and 1 k T. We will later want v i,j,k to be 1 if the (i, j)th cell of the square is covered by the kth tile. We construct a formula ψ = ψ 1 ψ 2 ψ 3 as follows. 1. Let S = s 1 s m. Assume that s j = t kj for j = 1,..., m, where k j {1,..., l}. Let m ψ 1 = v 1,j,kj. (1) j=1 Then ψ 1 = 1 if and only if the jth cell in the bottom row is covered by t kj for 1 j m. 2. For all k, k with [t k, t k ] H T, where 1 k, k T, let ψ 2,1 = n 1 i=1 j=1 For all k, k with [t k, t k ] V T, where 1 k, k T, let ψ 2,2 = n 1 i=1 j=1 [t k,t k ] H T ( v i,j,k + v i,j+1,k ). (2) [t k,t k ] V T ( v i,j,k + v i+1,j,k ). (3) Let ψ 2 = ψ 2,1 ψ 2,2. Then ψ 2 = 1 if and only if the adjacency conditions of tiling are satisfied.

91.502 Foundations of Comuter Science 6 3. Finally, let ψ 3 = ψ 3,1 ψ 3,2, where and ψ 3,2 = ψ 3,1 = i=1 j=1 T i=1 j=1 k=1 v i,j,k (4) k k ( v i,j,k + v i,j,k ) (5) Then ψ 3,1 = 1 if and only if each cell is covered by at least one tile, and ψ 3,2 = 1 if and only if each cell is covered by at most one tile. Thus, ψ 3 = 1 if and only if each cell is covered by exactly one tile. We note that ψ = Θ(n 2 T 2 ). Let f( T, S, 0 n ) = ψ, then it is easy to see that f is olynomial-time comutable. If T, S, 0 n is a ositive instance of bounded tiling, then for all i and j with 1 i n and 1 j n, there must be a 1 k T such that the square at location (i, j) is tiled by t k. Set v i,j,k = 1. We conclude that every clause in (4) and (5) is satisfied. Clearly, every unit clause in (1) is satisfied. Now for each air (k, k ) with (t k, t k ) H T, and for all (i, j) with 1 i, j n, at least one of v i,j,k and v i,j,k has not been set to 1. Set that variable to 0. Thus, every clause in (2) is satisfied. Similarly, every clause in (3) is also satisfied. Conversely, we can show that if ψ is satisfiable then T, S, 0 n is a ositive instance of bounded tiling. This comletes the roof. 4 3-Satisfiability We consider CNF Boolean formula F of n variables {C 1, C 2,..., C m } in which each clause consists of exactly three literals. We call such a formula a 3CNF formula. 3-Satisfiability Problem (3SAT) Instance. A 3CNF formula ψ. Question. Is ψ satisfiable? Denote by 3SAT the ositive instances of 3-Satisfiability roblem; namely, Theorem 7 3SAT is NP-comlete. 3SAT = {ψ ψ is a 3CNF and is satisfiable}.

91.502 Foundations of Comuter Science 7 Proof. It suffices to reduce a CNF formula to a 3CNF formula. Let F be a CNF formula. We introduce three new variables y 1, y 2, y 3 and seven new clauses: {y 1, y 2, y 3 }, {y 1, y 2, y 3 }, {y 1, y 2, y 3 }, { y 1, y 2, y 3 }, {y 1, y 2, y 3 }, { y 1, y 2, y 3 }, { y 1, y 2, y 3 }. Namely, these seven new clauses are all ossible 3-literal (nontrivial) clauses over variables y 1, y 2, y 3 excet { y 1, y 2, y 3 }. It is easy to see that the only truth-value assignment to satisfy all these seven clauses is y 1 = y 2 = y 3 = 1. Let C be a clause of F. Then C = {z 1, z 2,..., z k } for some k 1, where z i is a literal. We will relace C by 3-clause(s) as follows. Case 1: k = 1. Relace C by {z 1, y 1, y 2 }. Case 2: k = 2. Relace C by {z 1, z 2, y 1 }. Case 3: k = 3. Do nothing. Case 4: k = 4. Introduce one new variable u 1 = y C, and relace C by the following 3-clauses: {z 1, z 2, u 1 }, {z 3, z 4, u 1 }, { z 3, u 1, y 1 }, { z 4, u 1, y 1 }. Note that the last three 3-clauses imly that z 3 + z 4 is equivalent to u 1, and so z 1 + z 2 + u 1 is equivalent to z 1 + z 2 + z 3 + z 4. Case 5: k > 4. Inductively aly Case 4 until only clauses of 3 literals left. For examle, when k = 5, first relace C with the following clauses: {z 1, z 2, z 3, u 1 }, {z 4, z 5, u 1 }, { z 4, u 1, y 1 }, { z 5, u 1, y 1 }. Then the last three clauses of three literals imly that z 4 + z 5 is equivalent to u 1. Thus, z 1 + z 2 + z 3 + z 4 + z 5 is equivalent to z 1 + z 2 + z 3 + u 1. Now relace the first clause of four literals {z 1, z 2, z 3, u 1 } by the following 3-clauses, where u 2 is a new variable: {z 1, z 2, u 2 }, {z 3, u 1, u 2 }, { z 3, u 2, y 1 }, { u 1, u 2, y 1 }. As shown before that the last three clauses imly that u 2 is equivalent to z 3 + u 1, and so z 1 + z 2 + z 3 + u 1 is equivalent to z 1 + z 2 + u 2. Let G be the roduct of all new clauses. It is straightforward to see that F is satisfiable if and only if G is satisfiable, and the above transformation from C to a set of 3-clauses can be carried out in time olynomial in k. Thus, SAT m 3SAT. This comletes the roof.