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

Similar documents
Theory of Computer Science

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)

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. 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. E2.1 P and NP. E2.2 Polynomial Reductions. E2.3 NP-Hardness and NP-Completeness. E2.

Theory of Computer Science

NP Complete Problems. COMP 215 Lecture 20

Chapter 34: NP-Completeness

Foundations of Artificial Intelligence

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

Theory of Computer Science

1.1 P, NP, and NP-complete

Theory of Computer Science

Show that the following problems are NP-complete

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

NP-Completeness. NP-Completeness 1

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

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Principles of Knowledge Representation and Reasoning

1. Introduction Recap

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

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

Part 1: Propositional Logic

Lecture 9: The Splitting Method for SAT

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

NP-Complete Reductions 2

NP-Completeness Part II

NP-Complete Reductions 1

Lecture 13, Fall 04/05

SAT, NP, NP-Completeness

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

SAT, Coloring, Hamiltonian Cycle, TSP

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

Comp487/587 - Boolean Formulas

CS21 Decidability and Tractability

Essential facts about NP-completeness:

Lecture 5: Efficient PAC Learning. 1 Consistent Learning: a Bound on Sample Complexity

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.

Non-Deterministic Time

Correctness of Dijkstra s algorithm

NP and NP-Completeness

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

NP and Computational Intractability

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

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

CSCI 1590 Intro to Computational Complexity

CSE 105 THEORY OF COMPUTATION

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

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

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

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

Introduction to Complexity Theory

A Collection of Problems in Propositional Logic

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

Spring Lecture 21 NP-Complete Problems

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

NP-Completeness Part II

NP-problems continued

Discrete Optimization 2010 Lecture 10 P, N P, and N PCompleteness

Theory of Computation Chapter 9

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

CSCI3390-Lecture 16: NP-completeness

NP-Complete Problems. More reductions

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

CSL 356: Analysis and Design of Algorithms. Ragesh Jaiswal CSE, IIT Delhi

NP Completeness. Richard Karp, 1972.

Polynomial-time Reductions

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

NP-Completeness. Subhash Suri. May 15, 2018

Propositional and Predicate Logic - II

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

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

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

Design and Analysis of Algorithms

Introduction to Solving Combinatorial Problems with SAT

Lecture 18: More NP-Complete Problems

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

Polynomial-time reductions. We have seen several reductions:

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

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

CSC 373: Algorithm Design and Analysis Lecture 15

Theory of Computation Time Complexity

ENEE 459E/CMSC 498R In-class exercise February 10, 2015

IE418 Integer Programming

NP and Computational Intractability

More NP-Complete Problems

NP-complete Problems

Advanced Topics in Theoretical Computer Science

Computational complexity theory

Conjunctive Normal Form and SAT

NP-Completeness. Sections 28.5, 28.6

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, Notes 22 for CS 170

NP Completeness and Approximation Algorithms

CS154, Lecture 13: P vs NP

Introduction to Computational Complexity

CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal?

Transcription:

Theory of Computer Science May 30, 2016 E4. Some NP-Complete Problems, Part I Theory of Computer Science E4. Some NP-Complete Problems, Part I Malte Helmert University of Basel May 30, 2016 E4.1 Overview E4.2 3SAT E4.3 Graph Problems E4.4 Summary M. Helmert (Univ. Basel) Theorie May 30, 2016 1 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 2 / 38 Overview: Course Overview: Complexity Theory contents of this course: logic How can knowledge be represented? How can reasoning be automated? automata theory and formal languages What is a computation? computability theory What can be computed at all? complexity theory What can be computed efficiently? Complexity Theory E1. Motivation and Introduction E2. P, NP and Polynomial Reductions E3. Cook-Levin Theorem E4. Some NP-Complete Problems, Part I E5. Some NP-Complete Problems, Part II M. Helmert (Univ. Basel) Theorie May 30, 2016 3 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 4 / 38

Further Reading (German) Further Reading (English) Literature for this Chapter (German) Theoretische Informatik kurz gefasst by Uwe Schöning (5th edition) Chapter 3.3 Literature for this Chapter (English) Introduction to the Theory of Computation by Michael Sipser (3rd edition) Chapter 7.4 and 7.5 Note: Sipser does not cover all problems that we do. M. Helmert (Univ. Basel) Theorie May 30, 2016 5 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 6 / 38 E4. Some NP-Complete Problems, Part I Overview E4. Some NP-Complete Problems, Part I Overview Further NP-Complete Problems The proof of NP-completeness for SAT was complicated. But with its help, we can now prove much more easily that further problems are NP-complete. E4.1 Overview 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 shown in the exercises. Second part follows directly by definition of NP-completeness. M. Helmert (Univ. Basel) Theorie May 30, 2016 7 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 8 / 38

E4. Some NP-Complete Problems, Part I Overview NP-Complete Problems E4. Some NP-Complete Problems, Part I Overview 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. DirHamiltonCycle SubsetSum In the remaining two chapters, we get to know some of these problems. HamiltonCycle Partition TSP BinPacking M. Helmert (Univ. Basel) Theorie May 30, 2016 9 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 10 / 38 E4. Some NP-Complete Problems, Part I Overview What Do We Have to Do? E4. Some NP-Complete Problems, Part I Overview SAT p 3SAT SAT We want to show the NP-completeness of these 11 problems. We already know that SAT is NP-complete. Hence it is sufficient to show 3SAT 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. DirHamiltonCycle SubsetSum (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.) HamiltonCycle Partition TSP BinPacking M. Helmert (Univ. Basel) Theorie May 30, 2016 11 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 12 / 38

E4. Some NP-Complete Problems, Part I 3SAT E4. Some NP-Complete Problems, Part I 3SAT SAT and 3SAT E4.2 3SAT Definition (Reminder: SAT) The problem SAT (satisfiability) is defined as follows: Given: a propositional logic formula ϕ Question: Is ϕ satisfiable? Definition (3SAT) The problem 3SAT is defined as follows: Given: a propositional logic formula ϕ in conjunctive normal form with at most three literals per clause Question: Is ϕ satisfiable? M. Helmert (Univ. Basel) Theorie May 30, 2016 13 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 14 / 38 E4. Some NP-Complete Problems, Part I 3SAT 3SAT is NP-Complete (1) E4. Some NP-Complete Problems, Part I 3SAT 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 ψ ))... M. Helmert (Univ. Basel) Theorie May 30, 2016 15 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 16 / 38

E4. Some NP-Complete Problems, Part I 3SAT 3SAT is NP-Complete (3) E4. Some NP-Complete Problems, Part I 3SAT 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 I = ψ. It follows that ϕ is satisfiable (χ 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 M. Helmert (Univ. Basel) Theorie May 30, 2016 17 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 18 / 38 3SAT p SAT E4.3 Graph Problems 3SAT DirHamiltonCycle SubsetSum HamiltonCycle Partition TSP BinPacking M. Helmert (Univ. Basel) Theorie May 30, 2016 19 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 20 / 38

is NP-Complete (1) Definition () The problem is defined as follows: Given: undirected graph G = V, E, number K N 0 Question: Does G have a clique of size at least K, i. e., a set of vertices C V with C K and {u, v} E for all u, v C with u v? Theorem ( is NP-Complete) is NP-complete. German: M. Helmert (Univ. Basel) Theorie May 30, 2016 21 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 22 / 38 is NP-Complete (2) is NP-Complete (3) Proof. NP: guess and check. is NP-hard: We show 3SAT p. We are given a 3-CNF formula ϕ, and we may assume that each clause has exactly three literals. In polynomial time, we must construct a graph G = V, E and a number K such that: G has a clique of size at least K ϕ is satisfiable. construction of V, E, K on the following slides.... Let m be the number of clauses in ϕ. Let l ij the j-th literal in clause i. Define V, E, K as follows: V = { i, j 1 i m, 1 j 3} a vertex for every literal of every clause E contains edge between i, j and i, j if and only if i i belong to derent clauses, and lij and l i j are not complementary literals K = m obviously polynomially computable to show: reduction property... M. Helmert (Univ. Basel) Theorie May 30, 2016 23 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 24 / 38

is NP-Complete (4) is NP-Complete (5) ( ): If ϕ is satisfiable, then V, E has clique of size at least K: Given a satisfying variable assignment choose a vertex corresponding to a satisfied literal in each clause. The chosen K vertices are all connected with each other and hence form a clique of size K.... ( ): If V, E has a clique of size at least K, then ϕ is satisfiable: Consider a given clique C of size at least K. The vertices in C must all correspond to derent clauses (vertices in the same clause are not connected by edges). exactly one vertex per clause is included in C Two vertices in C never correspond to complementary literals X and X (due to the way we defined the edges). If a vertex corresp. to X was chosen, map X to 1 (true). If a vertex corresp. to X was chosen, map X to 0 (false). If neither was chosen, arbitrarily map X to 0 or 1. satisfying assignment M. Helmert (Univ. Basel) Theorie May 30, 2016 25 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 26 / 38 p SAT 3SAT Definition () The problem is defined as follows: DirHamiltonCycle SubsetSum Given: undirected graph G = V, E, number K N 0 Question: Does G have an independent set of size at least K, i. e., a set of vertices I V with I K and {u, v} / E for all u, v I with u v? HamiltonCycle Partition German: unabhängige Menge TSP BinPacking M. Helmert (Univ. Basel) Theorie May 30, 2016 27 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 28 / 38

is NP-Complete (1) is NP-Complete (2) Proof. NP: guess and check. Theorem ( is NP-Complete) is NP-complete. is NP-hard: We show p. We describe a polynomial reduction f. Let G, K with G = V, E be the given input for. Then f ( G, K ) is the instance G, K, where G := V, E and E := {{u, v} V u v, {u, v} / E}. (This graph G is called the complement graph of G.) Clearly f can be computed in polynomial time.... M. Helmert (Univ. Basel) Theorie May 30, 2016 29 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 30 / 38 is NP-Complete (3) p We have: SAT V, E, K 3SAT there exists a set V V with V K and {u, v} E for all u, v V with u v there exists a set V V with V K DirHamiltonCycle SubsetSum and {u, v} / E for all u, v V with u v V, E, K HamiltonCycle Partition f ( V, E, K ) and hence f is a reduction. TSP BinPacking M. Helmert (Univ. Basel) Theorie May 30, 2016 31 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 32 / 38

is NP-Complete (1) Definition () The problem is defined as follows: Given: undirected graph G = V, E, number K N 0 Question: Does G have a vertex cover of size at most K, i. e., a set of vertices C V with C K and {u, v} C for all {u, v} E? Theorem ( is NP-Complete) is NP-complete. German: Knotenüberdeckung M. Helmert (Univ. Basel) Theorie May 30, 2016 33 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 34 / 38 is NP-Complete (2) is NP-Complete (3) Proof. NP: guess and check. is NP-hard: We show p. We describe a polynomial reduction f. Let G, K with G = V, E be the given input for. Then f ( G, K ) := G, V K. This can clearly be computed in polynomial time.... For vertex set V V, we write V for its complement V \ V. Observation: a set of vertices is a vertex cover its complement is an independent set. We thus have: V, E, K V, E has an independent set I with I K V, E has a vertex cover C with C K V, E has a vertex cover C with C V K V, E, V K f ( V, E, K ) and hence f is a reduction. M. Helmert (Univ. Basel) Theorie May 30, 2016 35 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 36 / 38

E4. Some NP-Complete Problems, Part I Summary E4. Some NP-Complete Problems, Part I Summary Summary E4.4 Summary Thousands of important problems are NP-complete. Usually, the easiest way to show that a 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. In this chapter we showed NP-completeness of: 3SAT, a restricted version of SAT three classical graph problems:,, M. Helmert (Univ. Basel) Theorie May 30, 2016 37 / 38 M. Helmert (Univ. Basel) Theorie May 30, 2016 38 / 38