Theory of Computer Science. Theory of Computer Science. E3.1 Overview. E3.2 Cook-Levin Theorem E3.3 3SAT. E3.4 Summary. Further Reading (German)

Similar documents
Theory of Computer Science

Theory of Computer Science. Theory of Computer Science. E4.1 Overview E4.2 3SAT. E4.3 Graph Problems. E4.4 Summary.

Theory of Computer Science. Theory of Computer Science. E2.1 P and NP. E2.2 Polynomial Reductions. E2.3 NP-Hardness and NP-Completeness. E2.

Theory of Computer Science

Theory of Computer Science. Theory of Computer Science. E5.1 Routing Problems. E5.2 Packing Problems. E5.3 Conclusion.

Theory of Computer Science. Theory of Computer Science. E2.1 P and NP. E2.2 Polynomial Reductions. E2.3 NP-Hardness and NP-Completeness. E2.

Theory of Computer Science

Theory of Computer Science. Theory of Computer Science. E1.1 Motivation. E1.2 How to Measure Runtime? E1.3 Decision Problems. E1.

Theory of Computer Science

Theory of Computer Science. Theory of Computer Science. D7.1 Introduction. D7.2 Turing Machines as Words. D7.3 Special Halting Problem

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

CSCI3390-Lecture 16: NP-completeness

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

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

Foundations of Artificial Intelligence

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

Introduction to Complexity Theory

Theory of Computer Science

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

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.

CSE 555 HW 5 SAMPLE SOLUTION. Question 1.

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?

Applied Computer Science II Chapter 7: Time Complexity. Prof. Dr. Luc De Raedt. Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

2 COLORING. Given G, nd the minimum number of colors to color G. Given graph G and positive integer k, is X(G) k?

Theory of Computer Science. Theory of Computer Science. D8.1 Other Halting Problem Variants. D8.2 Rice s Theorem

Lecture 13, Fall 04/05

Complexity Theory. Knowledge Representation and Reasoning. November 2, 2005

The Cook-Levin Theorem

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

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

NP-Complete Reductions 1

CS154, Lecture 13: P vs NP

Planning and Optimization

Principles of Knowledge Representation and Reasoning

NP-Completeness Part II

Harvard CS 121 and CSCI E-121 Lecture 22: The P vs. NP Question and NP-completeness

NP Completeness. Richard Karp, 1972.

Comp487/587 - Boolean Formulas

NP Complete Problems. COMP 215 Lecture 20

Chapter 7: Time Complexity

NP-Completeness and Boolean Satisfiability

CSE 105 THEORY OF COMPUTATION

Theory of Computation Time Complexity

Lecture 9: The Splitting Method for SAT

NP and NP-Completeness

Lecture 25: Cook s Theorem (1997) Steven Skiena. skiena

Lecture 16: Time Complexity and P vs NP

Keywords. Approximation Complexity Theory: historical remarks. What s PCP?

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

SAT, Coloring, Hamiltonian Cycle, TSP

B6.1 (Bounded-Cost) Plan Existence

NP and Computational Intractability

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

1. Introduction Recap

Part 1: Propositional Logic

Theory of Computer Science. D5.1 Introduction. Theory of Computer Science. D5.2 Primitive Recursion vs. LOOP. D5.3 µ-recursion vs.

CS 6505, Complexity and Algorithms Week 7: NP Completeness

On the Computational Hardness of Graph Coloring

Lecture 7: Polynomial time hierarchy

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

Computability Theory

Non-Deterministic Time

Complexity (Pre Lecture)

A Probabilistic Algorithm for -SAT Based on Limited Local Search and Restart

1.1 P, NP, and NP-complete

Turing Machines and Time Complexity

CS154, Lecture 13: P vs NP

Show that the following problems are NP-complete

Chapter 34: NP-Completeness

NP-Completeness Part II

Finish K-Complexity, Start Time Complexity

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

Lecture 20: conp and Friends, Oracles in Complexity Theory

NP-Completeness. Dr. B. S. Panda Professor, Department of Mathematics IIT Delhi, Hauz Khas, ND-16

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

NP-completeness was introduced by Stephen Cook in 1971 in a foundational paper.

Essential facts about NP-completeness:

Intro to Theory of Computation

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

A Lower Bound for Boolean Satisfiability on Turing Machines

CS Lecture 28 P, NP, and NP-Completeness. Fall 2008

Polynomial-time reductions. We have seen several reductions:

NP-Completeness. Sections 28.5, 28.6

About the relationship between formal logic and complexity classes

NP-Completeness. NP-Completeness 1

Lecture Notes 4. Issued 8 March 2018

Time to learn about NP-completeness!

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

Week 3: Reductions and Completeness

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Theory of Computer Science

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

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

Spring Lecture 21 NP-Complete Problems

Advanced Topics in Theoretical Computer Science

COMP 382. Unit 10: NP-Completeness

Conjunctive Normal Form and SAT

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

Transcription:

Theory of Computer Science May 16, 2018 E3. Proving NP-Completeness Theory of Computer Science E3. Proving NP-Completeness Gabriele Röger University of Basel May 16, 2018 E3.1 Overview E3.2 Cook-Levin Theorem E3.3 3SAT E3.4 Summary Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 1 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 2 / 36 Course Overview Further Reading (German) Background Logic Nondeterminism Literature for this Chapter (German) Theory Automata Theory Computability Complexity P, NP Polynomial Reductions Cook-Levin Theorem Theoretische Informatik kurz gefasst by Uwe Schöning (5th edition) Chapter 3.2 and 3.3 NP-complete Problems Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 3 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 4 / 36

Further Reading (English) Literature for this Chapter (English) Introduction to the Theory of Computation by Michael Sipser (3rd edition) Chapter 7.4 E3.1 Overview Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 5 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 6 / 36 Proving NP-Completeness by Reduction Proving NP-Completeness by Reduction: Proof Suppose we know one NP-complete problem (we will use satisfiability of propositional logic formulas). With its help, we can then prove quite easily that further problems are NP-complete. Theorem (Proving NP-Completeness by Reduction) Let A and B be problems such that: A is NP-hard, and A p B. Then B is also NP-hard. If furthermore B NP, then B is NP-complete. Proof. First part: We must show X p B for all X NP. From X p A (because A is NP-hard) and A p B (by prerequisite), this follows due to the transitivity of p. Second part: follows directly by definition of NP-completeness. Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 7 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 8 / 36

NP-Complete Problems Overview of the Reductions There are thousands of known NP-complete problems. An extensive catalog of NP-complete problems from many areas of computer science is contained in: SAT 3SAT Michael R. Garey and David S. Johnson: Computers and Intractability A Guide to the Theory of NP-Completeness W. H. Freeman, 1979. Clique DirHamiltonCycle SubsetSum In the remaining chapters, we get to know some of these problems. IndSet HamiltonCycle Partition VertexCover TSP BinPacking Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 9 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 10 / 36 What Do We Have to Do? We want to show the NP-completeness of these 11 problems. We first show that SAT is NP-complete. Then it is sufficient to show that polynomial reductions exist for all edges in the figure (and thus all problems are NP-hard) and that the problems are all in NP. (It would be sufficient to show membership in NP only for the leaves in the figure. But membership is so easy to show that this would not save any work.) E3.2 Cook-Levin Theorem Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 11 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 12 / 36

Course Overview SAT is NP-complete Background Definition (SAT) The problem SAT (satisfiability) is defined as follows: Theory Logic Automata Theory Nondeterminism P, NP Given: a propositional logic formula ϕ Question: Is ϕ satisfiable? Computability Complexity Polynomial Reductions Cook-Levin Theorem NP-complete Problems Theorem (Cook, 1971; Levin, 1973) SAT is NP-complete. Proof. SAT NP: guess and check. SAT is NP-hard: somewhat more complicated (to be continued) Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 13 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 14 / 36 NP-hardness of SAT (1) NP-hardness of SAT (2) We must show: A p SAT for all A NP. Let A be an arbitrary problem in NP. We have to find a polynomial reduction of A to SAT, i. e., a function f computable in polynomial time such that for every input word w over the alphabet of A: w A iff f (w) is a satisfiable propositional formula. Because A NP, there is an NTM M and a polynomial p such that M accepts the problem A in time p. Idea: construct a formula that encodes the possible configurations which M can reach in time p( w ) on input w and that is satisfiable if and only if an end configuration can be reached in this time. Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 15 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 16 / 36

NP-hardness of SAT (3) NP-hardness of SAT (4) Let M = Q, Σ, Γ, δ, q 0,, E be an NTM for A, and let p be a polynomial bounding the computation time of M. Without loss of generality, p(n) n for all n. Let w = w 1 w n Σ be the input for M. We number the tape positions with integers (positive and negative) such that the TM head initially is on position 1. Observation: within p(n) computation steps the TM head can only reach positions in the set Pos = { p(n) + 1, p(n) + 2,, 1, 0, 1,, p(n) + 1}. Instead of infinitely many tape positions, we now only need to consider these (polynomially many!) positions. We can encode configurations of M by specifying: what the current state of M is on which position in Pos the TM head is located which symbols from Γ the tape contains at positions Pos can be encoded by propositional variables To encode a full computation (rather than just one configuration), we need copies of these variables for each computation step. We only need to consider the computation steps Steps = {0, 1,, p(n)} because M should accept within p(n) steps. Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 17 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 18 / 36 NP-hardness of SAT (5) Use the following propositional variables in formula f (w): state t,q (t Steps, q Q) encodes the state of the NTM in the t-th configuration head t,i (t Steps, i Pos) encodes the head position in the t-th configuration tape t,i,a (t Steps, i Pos, a Γ) encodes the tape content in the t-th configuration Construct f (w) such that every satisfying interpretation describes a sequence of TM configurations that begins with the start configuration, reaches an accepting configuration and follows the TM rules in δ Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 19 / 36 NP-hardness of SAT (6) Auxiliary formula: ( ) oneof X := x Auxiliary notation: x X x X y X \{x} (x y) The symbol stands for an arbitrary unsatisfiable formula (e.g., (A A), where A is an arbitrary proposition). Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 20 / 36

NP-hardness of SAT (7) NP-hardness of SAT (8) 1. describe the configurations of the TM: Valid := ( oneof {state t,q q Q} t Steps oneof {head t,i i Pos} ) oneof {tape t,i,a a Γ} i Pos 2. begin in the start configuration Init := state 0,q0 head 0,1 n tape 0,i,wi i=1 i Pos\{1,...,n} tape 0,i, Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 21 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 22 / 36 NP-hardness of SAT (9) NP-hardness of SAT (10) 3. reach an accepting configuration Accept := state t,qe t Steps q e E 4. follow the rules in δ: Trans := t Steps q e E state t,qe Rule t,r R δ where Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 23 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 24 / 36

NP-hardness of SAT (11) 4. follow the rules in δ (continued): Rule t, q,a, q,a,d := state t,q state t+1,q ( ) headt,i tape t,i,a head t+1,i+d tape t+1,i,a i Pos i Pos a Γ ( headt,i tape t,i,a tape t+1,i,a ) For D, interpret L 1, N 0, R +1. special case: tape and head variables with a tape index i + D outside of Pos are replaced by ; likewise all variables with a time index outside of Steps. Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 25 / 36 NP-hardness of SAT (12) Putting the pieces together: Set f (w) := Valid Init Accept Trans. f (w) can be constructed in time polynomial in w. w A iff M accepts w in p( w ) steps w A iff f (w) is satisfiable w A iff f (w) SAT A p SAT Since A NP was arbitrary, this is true for every A NP. Hence SAT is NP-hard and thus also NP-complete. Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 26 / 36 Course Overview Background E3.3 3SAT Theory Logic Automata Theory Nondeterminism P, NP Computability Polynomial Reductions Complexity Cook-Levin Theorem NP-complete Problems Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 27 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 28 / 36

SAT p 3SAT SAT and 3SAT SAT 3SAT Definition (Reminder: SAT) The problem SAT (satisfiability) is defined as follows: Given: a propositional logic formula ϕ Question: Is ϕ satisfiable? Clique DirHamiltonCycle SubsetSum Definition (3SAT) The problem 3SAT is defined as follows: IndSet HamiltonCycle Partition Given: a propositional logic formula ϕ in conjunctive normal form with at most three literals per clause Question: Is ϕ satisfiable? VertexCover TSP BinPacking Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 29 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 30 / 36 3SAT is NP-Complete (1) 3SAT is NP-Complete (2) Proof. 3SAT NP: guess and check. 3SAT is NP-hard: We show SAT p 3SAT. Theorem (3SAT is NP-Complete) 3SAT is NP-complete. Let ϕ be the given input for SAT. Let Sub(ϕ) denote the set of subformulas of ϕ, including ϕ itself. For all ψ Sub(ϕ), we introduce a new proposition X ψ. For each new proposition X ψ, define the following auxiliary formula χ ψ : If ψ = A for an atom A: χψ = (X ψ A) If ψ = ψ : χ ψ = (X ψ X ψ ) If ψ = (ψ ψ ): χ ψ = (X ψ (X ψ X ψ )) If ψ = (ψ ψ ): χ ψ = (X ψ (X ψ X ψ )) Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 31 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 32 / 36

3SAT is NP-Complete (3) Restricted 3SAT Consider the conjunction of all these auxiliary formulas, χ all := ψ Sub(ϕ) χ ψ. Every interpretation I of the original variables can be extended to a model I of χ all in exactly one way: for each ψ Sub(ϕ), set I (X ψ ) = 1 iff I = ψ. It follows that ϕ is satisfiable iff (χ all X ϕ ) is satisfiable. This formula can be computed in linear time. It can also be converted to 3-CNF in linear time because it is the conjunction of constant-size parts involving at most three variables each. (Each part can be converted to 3-CNF independently.) Hence, this describes a polynomial-time reduction. Note: 3SAT remains NP-complete if we also require that every clause contains exactly three literals and a clause may not contain the same literal twice Idea: remove duplicated literals from each clause. add new variables: X, Y, Z add new clauses: (X Y Z), (X Y Z), (X Y Z), ( X Y Z), (X Y Z), ( X Y Z), ( X Y Z) satisfied if and only if X, Y, Z are all true fill up clauses with fewer than three literals with X and if necessary additionally with Y Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 33 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 34 / 36 E3. Proving NP-Completeness Summary E3. Proving NP-Completeness Summary Summary E3.4 Summary Thousands of important problems are NP-complete. The satisfiability problem of propositional logic (SAT) is NP-complete. Proof idea for NP-hardness: Every problem in NP can be solved by an NTM in polynomial time p( w ) for input w. Given a word w, construct a propositional logic formula ϕ that encodes the computation steps of the NTM on input w. Construct ϕ so that it is satisfiable if and only if there is an accepting computation of length p( w ). Usually (as seen for 3SAT), the easiest way to show that another problem is NP-complete is to show that it is in NP with a guess-and-check algorithm, and polynomially reduce a known NP-complete to it. Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 35 / 36 Gabriele Röger (University of Basel) Theory of Computer Science May 16, 2018 36 / 36