NP and NP-Completeness

Similar documents
Computational Intractability 2010/4/15. Lecture 2

NP and Computational Intractability

NP and Computational Intractability

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

Polynomial-Time Reductions

Algorithm Design and Analysis

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

Algorithms Design & Analysis. Approximation Algorithm

COMP 382. Unit 10: NP-Completeness

COP 4531 Complexity & Analysis of Data Structures & Algorithms

More NP-Complete Problems

8.5 Sequencing Problems

NP-Complete problems

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

NP-completeness. Chapter 34. Sergey Bereg

Algorithm Design and Analysis

Essential facts about NP-completeness:

CS21 Decidability and Tractability

1. Introduction Recap

CS 583: Algorithms. NP Completeness Ch 34. Intractability

NP-Complete Problems. More reductions

4/19/11. NP and NP completeness. Decision Problems. Definition of P. Certifiers and Certificates: COMPOSITES

CS 580: Algorithm Design and Analysis

3/22/2018. CS 580: Algorithm Design and Analysis. Circuit Satisfiability. Recap. The "First" NP-Complete Problem. Example.

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

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

4/20/11. NP-complete problems. A variety of NP-complete problems. Hamiltonian Cycle. Hamiltonian Cycle. Directed Hamiltonian Cycle

NP-Complete Reductions 1

Lecture 4: NP and computational intractability

4/22/12. NP and NP completeness. Efficient Certification. Decision Problems. Definition of P

Geometric Steiner Trees

SAT, Coloring, Hamiltonian Cycle, TSP

Computability and Complexity Theory: An Introduction

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

Introduction. Pvs.NPExample

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam

NP-Completeness. Subhash Suri. May 15, 2018

Design and Analysis of Algorithms

CS21 Decidability and Tractability

NP-Completeness Review

Polynomial-time Reductions

NP-complete Problems

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

8.5 Sequencing Problems. Chapter 8. NP and Computational Intractability. Hamiltonian Cycle. Hamiltonian Cycle

Complexity, P and NP

8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability. Classify Problems

Chapter 8. NP and Computational Intractability

1.1 P, NP, and NP-complete

NP-Complete Reductions 3

Lecture 15 - NP Completeness 1

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

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

CS154, Lecture 13: P vs NP

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

3/22/2018. CS 580: Algorithm Design and Analysis. 8.3 Definition of NP. Chapter 8. NP and Computational Intractability. Decision Problems.

SAT, NP, NP-Completeness

Chapter 34: NP-Completeness

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

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

Announcements. Analysis of Algorithms

Algorithm Design and Analysis

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

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

NP-Complete Reductions 2

CS154, Lecture 13: P vs NP

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

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

Correctness of Dijkstra s algorithm

CS 151 Complexity Theory Spring Solution Set 5

More on NP and Reductions

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

Intro to Theory of Computation

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Lecture 18: More NP-Complete Problems

NP and NP Completeness

Intro to Theory of Computation

Limitations of Algorithm Power

Automata Theory CS Complexity Theory I: Polynomial Time

A.Antonopoulos 18/1/2010

NP-Completeness. ch34 Hewett. Problem. Tractable Intractable Non-computable computationally infeasible super poly-time alg. sol. E.g.

Theory of Computation Chapter 9

CSCI 1590 Intro to Computational Complexity

Lecture 7: Polynomial time hierarchy

NP completeness and computational tractability Part II

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.

The Cook-Levin Theorem

Classes of Problems. CS 461, Lecture 23. NP-Hard. Today s Outline. We can characterize many problems into three classes:

Chapter 8. NP and Computational Intractability. CS 350 Winter 2018

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

NP-problems continued

CSI 4105 MIDTERM SOLUTION

BBM402-Lecture 11: The Class NP

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

Automata Theory CS S-18 Complexity Theory II: Class NP

Formal definition of P

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

Part V. Intractable Problems

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

Transcription:

0/2/206 Algorithms NP-Completeness 7- Algorithms NP-Completeness 7-2 Efficient Certification NP and NP-Completeness By a solution of a decision problem X we understand a certificate witnessing that an instance is a yes -instance We say that an algorithm B is an efficient certifier for a problem X if - B is a polynomial time algorithm that takes two input arguments: instance s and a certificate t - there is polynomial p such that for eery string s, we hae s X if and only if there exists a string t such that t p( s ) and B(s,t) = yes The class of problems haing an efficient certifier is denoted by NP Design and Analysis of Algorithms Andrei Bulato Certifying s. Soling Certifying and brute force Algorithms NP-Completeness 7-3 Algorithms NP-Completeness 7-4 Efficient Certification: Composite COMPOSITES. Gien an integer s, is s composite Certificate. A nontriial factor t of s. Note that such a certificate exists iff s is composite. Moreoer t s. Certifier. Check if t > and t < s If yes, check if t is a diisor of s Instance. s = 437,669. Certificate. t = 54 or 809. Conclusion. COMPOSITES is in NP. 437,669 = 54 809 Efficient Certification: 3-SAT SAT. Gien a CNF formula Φ, is there a satisfying assignment Certificate. An assignment of truth alues to the n boolean ariables. Certifier. Check that each clause in Φ has at least one true literal. Example ( x x x ) ( x x x ) ( x x x ) ( x x ) 2 3 2 3 2 4 3 x4 Conclusion. SAT is in NP. instance s x =, x2=, x3= 0, x4= certificate t Algorithms NP-Completeness 7-5 Algorithms NP-Completeness 7-6 Efficient Certification: Hamilton Cycle HAM-CYCLE. Gien an undirected graph G = (V, E), does there exist a simple cycle C that isits eery node Certificate. A permutation of the n nodes. Certifier. Check that the permutation contains each node in V exactly once, and that there is an edge between each pair of adjacent nodes in the permutation. Conclusion. HAM-CYCLE is in NP. NP P is the class of problems for which there is a polynomial time algorithm NP is the class of problems for which there is an efficient certifier 3-SAT, Independent Set, Vertex Coer, problems about feasible circulations are in NP P NP instance s certificate t Certifier is a solution algorithm that runs with empty certificate.

0/2/206 Algorithms NP-Completeness 7-7 Algorithms NP-Completeness 7-8 NP-Completeness What are the most difficult problems in NP A problem X is said to be NP-complete if (i) X NP (ii) for any Y NP, we hae Y X If an NP-complete problem solable in polynomial time then P = NP. Circuit Satisfiability A circuit consists of: inputs wires logic gates: (AND), (OR), (NOT) output Output 0 Inputs Algorithms NP-Completeness 7-9 Algorithms NP-Completeness 7-0 Circuit Satisfiability (cntd) The output computed by a circuit is defined in the natural way A circuit is said to be satisfiable if there are alues of the inputs such that the output is The Circuit Satisfiability Problem Instance: A circuit C Objectie: Is C satisfiable Circuit Satisfiability: NP-Completeness Theorem (Cook, Lein) Circuit Satisfiability is NP-complete (Idea) We hae to reduce eery problem X NP to Circuit Satisfiability Use the fact that X has an efficient certifier B(, ) The main idea is that the work of any algorithm on inputs of fixed length can be simulated by a circuit Simulation is in the sense that there is a circuit that outputs if and only if the algorithm outputs yes Moreoer, the number of gates (size) of the circuit is O(running time of the algorithm) Algorithms NP-Completeness 7- Algorithms NP-Completeness 7-2 Circuit Satisfiability: NP-Completeness (cntd) In order to decide if s X, we hae to check if there is a string t of length p( s ) such that B(s,t) outputs yes We use Circuit Satisfiability as a black box as follows: Consider B(, ) as an algorithm on n + p(n) bits Transform B(s, ) into a circuit C(s) with s `hardwired, and p( s ) inputs for possible t Ask if C(s) is satisfiable. If yes, there is a required t, and therefore s X If not, there is no t such that B(s,t) = yes, hence s X Example Construction below creates a circuit C whose inputs can be set so that C outputs iff graph G has an independent set of size 2. independent set both endpoints of some edge hae been chosen u w independent set of size 2 set of size 2 G = (V, E), n = 3 u- u-w -w u w 0 n hard-coded inputs (graph description) n inputs (nodes in independent set) 2 2

0/2/206 Algorithms NP-Completeness 7-3 Algorithms NP-Completeness 7-4 Proing NP-Completeness Remark. Once we establish first "natural" NP-complete problem, others are much easier Recipe to establish NP-completeness of problem Y. Step. Show that Y is in NP. Step 2. Choose an NP-complete problem X. Step 3. Proe that X Y. Proing NP-Completeness If X is an NP-complete problem, and Y is a problem in NP with the property that X Y then Y is NP-complete. Let W be any problem in NP. Then W X Y. By transitiity, W Y. Hence Y is NP-complete. Algorithms NP-Completeness 7-5 Algorithms NP-Completeness 7-6 3-SAT: NP-Completeness Theorem 3-SAT is NP-complete Suffices to show that CIRCUIT-SAT 3-SAT since 3-SAT is in NP. Let C be any circuit. Create a 3-SAT ariable x i for each circuit element i. x output 0 x x 4 0 3-SAT: NP-Completeness Make circuit compute correct alues at each node: = x = x4 x5 x0 = x x2 add 2 clauses: add 3 clauses: add 3 clauses: Hard-coded input alues and output alue. = 0 add clause: x 0 = add clause: x0 Final step: turn clauses of length < 3 into clauses of length exactly 3. x2 x3, x2x3 x x4, x x5, x x4x5 x0 x, x0x2, x0x x2 output x x 0 x 4 0 Algorithms NP-Completeness 7-7 Algorithms NP-Completeness 7-8 Hamiltonian Cycle Hamiltonian Cycle The Hamiltonian Cycle Problem Instance: An undirected graph G = (V, E) Objectie: Does there exist a simple cycle Γ that contains eery node in V. 2 3 ' 2' 3' 4 4' 5 NO: bipartite graph with odd number of nodes. YES: ertices and faces of a dodecahedron. 3

0/2/206 Algorithms NP-Completeness 7-9 Algorithms NP-Completeness 7-20 The Problem Instance: A directed graph G = (V, E) Objectie: Does there exist a simple directed cycle Γ that contains eery node in V. Hamiltonian Cycle. Gien a directed graph G = (V, E) with n nodes, construct an undirected graph G' with 3n nodes. a b c G d e We show that G has a Hamiltonian cycle iff G' does. Suppose G has a directed Hamiltonian cycle Γ. Then G' has an undirected Hamiltonian cycle (same order). a out b out c out in G' out d in e in Algorithms NP-Completeness 7-2 Algorithms NP-Completeness 7-22 Suppose G' has an undirected Hamiltonian cycle Γ'. Γ' must isit nodes in G' using one of following two orders:, B, G, R, B, G, R, B, G, R, B,, B, R, G, B, R, G, B, R, G, B, Blue nodes in Γ make up directed Hamiltonian cycle Γ in G, or reerse of one. Theorem 3-SAT Gien an instance Φ of 3-SAT, we construct an instance of Directed Hamiltonian Cycle that has a Hamiltonian cycle iff Φ is satisfiable. Construction. n First, create graph that has 2 Hamiltonian cycles which correspond n in a natural way to 2 possible truth assignments. Gien 3-SAT instance Φ with n ariables x i and k clauses. Construct G to hae 2n Hamiltonian cycles. Intuition: traerse path i from left to right set ariable x i = Algorithms NP-Completeness 7-23 Algorithms NP-Completeness 7-24 Gien 3-SAT instance Φ with n ariables For each clause: add a node and 6 edges. x i and k clauses. s C = x V x2 V x3 clause node clause node C 2 = x V x2 V x3 x s x t 3k + 3 t 4

0/2/206 Algorithms NP-Completeness 7-25 Algorithms NP-Completeness 7-26 Claim. Φ is satisfiable iff G has a Hamiltonian cycle. Suppose 3-SAT instance has satisfying assignment x*. Then, define Hamiltonian cycle in G as follows: if x * i =, traerse row i from left to right if x * i = 0, traerse row i from right to left for each clause C i, there will be at least one row i in which we are going in "correct" direction to splice node C i into tour Proing NP-Completeness Suppose G has a Hamiltonian cycle Γ. If Γ enters clause node C i, it must depart on mate edge. Thus, nodes immediately before and after C i are connected by an edge e in G remoing C i from cycle, and replacing it with edge e yields Hamiltonian cycle on G { C i } Continuing in this way, we are left with Hamiltonian cycle Γ' in G { C, C2, K, C k }. Set x * i = iff Γ' traerses row i left to right. Since Γ isits each clause node C i, at least one of the paths is traersed in "correct" direction, and each clause is satisfied. 5