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

Similar documents
8.5 Sequencing Problems

Polynomial-Time Reductions

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

NP and Computational Intractability

Chapter 8. NP and Computational Intractability

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

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

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

Computational Intractability 2010/4/15. Lecture 2

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

4/12/2011. Chapter 8. NP and Computational Intractability. Directed Hamiltonian Cycle. Traveling Salesman Problem. Directed Hamiltonian Cycle

CS 583: Algorithms. NP Completeness Ch 34. Intractability

NP and Computational Intractability

COP 4531 Complexity & Analysis of Data Structures & Algorithms

CS 580: Algorithm Design and Analysis

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

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

SAT, Coloring, Hamiltonian Cycle, TSP

Polynomial-time Reductions

4/30/14. Chapter Sequencing Problems. NP and Computational Intractability. Hamiltonian Cycle

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

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

Algorithm Design and Analysis

Lecture 4: NP and computational intractability

Algorithm Design and Analysis

Algorithm Design and Analysis

NP Complete Problems. COMP 215 Lecture 20

NP-Complete Problems. More reductions

NP-Complete problems

More NP-Complete Problems

NP completeness and computational tractability Part II

Lecture 24 : Even more reductions

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

VIII. NP-completeness

Intro to Theory of Computation

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

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

CS 580: Algorithm Design and Analysis

Limitations of Algorithm Power

NP-Complete Reductions 2

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Theory of Computation Chapter 9

CS/COE

Algorithms and Complexity Theory. Chapter 8: Introduction to Complexity. Computer Science - Durban - September 2005

CSCI3390-Lecture 17: A sampler of NP-complete problems

CSC 373: Algorithm Design and Analysis Lecture 15

NP-Complete Problems

Chapter 34: NP-Completeness

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

Polynomial-time reductions. We have seen several reductions:

Correctness of Dijkstra s algorithm

More on NP and Reductions

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

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

NP-complete Problems

Lecture 18: More NP-Complete Problems

NP-Completeness. Until now we have been designing algorithms for specific problems

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

NP-Complete Reductions 1

Design and Analysis of Algorithms

NP-Completeness. Subhash Suri. May 15, 2018

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

SAT, NP, NP-Completeness

P and NP. Warm Up: Super Hard Problems. Overview. Problem Classification. Tools for classifying problems according to relative hardness.

Automata Theory CS Complexity Theory I: Polynomial Time

NP and NP-Completeness

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

The P versus NP Problem. Ker-I Ko. Stony Brook, New York

Chapter 3: Proving NP-completeness Results

P and NP. Inge Li Gørtz. Thank you to Kevin Wayne, Philip Bille and Paul Fischer for inspiration to slides

Data Structures and Algorithms (CSCI 340)

NP-completeness. Chapter 34. Sergey Bereg

Hamiltonian Cycle. Hamiltonian Cycle

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

Algorithms Design & Analysis. Approximation Algorithm

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

Graph Theory and Optimization Computational Complexity (in brief)

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

COMP 382. Unit 10: NP-Completeness

1. Introduction Recap

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

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

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

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

Approximation Preserving Reductions

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. NP-Completeness 1

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

A difficult problem. ! Given: A set of N cities and $M for gas. Problem: Does a traveling salesperson have enough $ for gas to visit all the cities?

Intractability. A difficult problem. Exponential Growth. A Reasonable Question about Algorithms !!!!!!!!!! Traveling salesperson problem (TSP)

BBM402-Lecture 11: The Class NP

NP Completeness and Approximation Algorithms

Topics in Complexity Theory

7.8 Intractability. Overview. Properties of Algorithms. Exponential Growth. Q. What is an algorithm? A. Definition formalized using Turing machines.

CS21 Decidability and Tractability

Comparison of several polynomial and exponential time complexity functions. Size n

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

Graduate Algorithms CS F-21 NP & Approximation Algorithms

Travelling Salesman Problem

Transcription:

Algorithms and Theory of Computation Lecture 22: NP-Completeness (2) Xiaohui Bei MAS 714 November 8, 2018 Nanyang Technological University MAS 714 November 8, 2018 1 / 20

Set Cover Set Cover Input: a set U of elements, a collection S 1, S 2,..., S m of subsets of U, and an integer k Question: does there exist a collection of no more than k of these sets whose union is equal to U? Sample applications: m available pieces of software Set U of n capabilities that we would like our system to have The ith piece of software provides the set S i U of capabilities Goal: achieve all n capabilities using fewest pieces of software Nanyang Technological University MAS 714 November 8, 2018 2 / 20

Reducing Vertex Cover to Set Cover Theorem Set Cover is NP-complete. Part 1: Set Cover NP: guess the collection Part 2: reduction from Vertex Cover Let G = (V, E) and k be an instance of Vertex Cover. Create an instance of Set Cover U = E Create S u for each u V, where S u contains the edges adjacent to u. Proposition U can be covered by k sets iff G has a vertex cover of size k. = : If k sets S u1,..., S uk cover U then every edge is adjacent to at least one of the vertices u 1,... u k, yielding a vertex cover of size k. =: If u 1,..., u k is a vertex cover, then sets S u1,..., S uk cover U. Nanyang Technological University MAS 714 November 8, 2018 3 / 20

Hamiltonian Cycle A Hamiltonian cycle in a directed graph G is a cycle that visits every vertex in G exactly once. Hamiltonian Cycle Input: a directed graph G = (V, E) Question: does G have a Hamiltonian cycle? Nanyang Technological University MAS 714 November 8, 2018 4 / 20

Reducing 3SAT to Hamiltonian Cycle Theorem Hamiltonian Cycle is NP-complete Part 1: Hamiltonian Cycle NP: exercise Part 2: we will show 3SAT P Hamiltonian Cycle Given 3SAT formula ϕ, we want to create a graph G ϕ, such that G ϕ has a Hamiltonian cycle if and only if ϕ is satisfiable G ϕ should be constructible from ϕ by a polynomial time algorithm A Notation: ϕ has n variables x 1, x 2,..., x n and m clauses C 1, C 2,..., C m. Nanyang Technological University MAS 714 November 8, 2018 5 / 20

Reduction: First Ideas Viewing SAT: Assign values to n variables, and each clauses has 3 ways in which it can be satisfied. Construct graph with 2 n Hamiltonian cycles, where each cycle corresponds to some boolean assignment. Then add more graph structure to encode constraints on assignments imposed by the clauses. Nanyang Technological University MAS 714 November 8, 2018 6 / 20

The Reduction: Phase 1 3-satisfiability reduces to directed hamilton cycle Traverse path i from left to right iff x i is set to true Construction. Given 3-SAT instance Φ with n variables x i and k clauses. Construct G to have 2 n Hamilton cycles. Each path has 3(m + 1) vertices where m is number of clauses; vertice Intuition: numbered traverse from path left i from to left right to right (1 to 3m set + variable 3) x i = true. s x1 x2 x3 t 3k + 3 33 Nanyang Technological University MAS 714 November 8, 2018 7 / 20

The Reduction: Phase 2 Add3-satisfiability vertex c j for reduces clause to directed C j. c j has hamilton edgecycle from vertex 3j and to vertex 3j + 1 on path i if x i appears in clause C j, and has edge from vertex 3j + Construction. 1 and to vertex Given 3-SAT 3j if instance x i appears Φ with n invariables C x j i and k clauses. For each clause, add a node and 6 edges. C 1 = x 1 x 2 x 3 clause node 1 clause node 2 C 2 = x 1 x 2 x 3 s x1 x2 x3 t 3k + 3 34 Nanyang Technological University MAS 714 November 8, 2018 8 / 20

Correctness Lemma ϕ is satisfiable iff G has a Hamiltonian cycle. Proof. = : Suppose ϕ has a satisfying assignment x. Then, define Hamiltonian cycle in G as follows: if x i = true, traverse row i from left to right if x i = false, traverse row i from right to left for each clause C j, there will be at least one row i in which we are going in correct direction to splice clause vertex C j into cycle (and we splice in C j exactly once) Nanyang Technological University MAS 714 November 8, 2018 9 / 20

Correctness Lemma ϕ is satisfiable iff G has a Hamiltonian cycle. Proof. =: Suppose G has a Hamiltonian cycle Γ. If Γ enters clause vertex C j, it must depart on mate edge vertice immediately before and after C j are connected by an edge removing C j from cycle, and replacing it with that edge yields Hamiltonian cycle on G {C j } Continuing in this way, we are left with a Hamiltonian cycle Γ in G {C 1, C 2,..., C m }. Set x i to true iff Γ traverses row i left to right. Since Γ visits each clause node C j, at least one of the paths is traversed in correct direction, and each clause is satisfied. Nanyang Technological University MAS 714 November 8, 2018 10 / 20

TSP Traveling Salesman Problem Traveling salesperson problem Given a set of n cities and a pairwise distance function d(u, v), is there a TSP. Given a set of n cities and a pairwise distance function d(u, v), tour of length D? is there a tour of length D? 13,509 cities in the United States http://www.tsp.gatech.edu Figure: 13,509 cities in the United States http://www.tsp.gatech.edu 38 Nanyang Technological University MAS 714 November 8, 2018 11 / 20

TSP Traveling Salesman Problem Traveling salesperson problem Given a set of n cities and a pairwise distance function d(u, v), is there a TSP. Given a set of n cities and a pairwise distance function d(u, v), tour of length D? is there a tour of length D? optimal TSP tour http://www.tsp.gatech.edu Figure: optimal TSP tour http://www.tsp.gatech.edu 39 Nanyang Technological University MAS 714 November 8, 2018 12 / 20

Reducing Hamiltonian Cycle to TSP Theorem Hamiltonian Cycle P TSP Proof. Given a Hamiltonian Cycle instance G = (V, E), create n cities with distance function { 1 if (u, v) E d(u, v) = 2 if (u, v) / E TSP instance has tour of length n iff G has a Hamiltonian cycle. Nanyang Technological University MAS 714 November 8, 2018 13 / 20

Subset Sum Subset Sum Given natural numbers w 1,..., w n and an integer W, is there a subset that adds up to exactly W? Example Input: {1, 4, 16, 64, 256, 1040, 1041, 1093, 1284, 1344}, W = 3754 Answer: Yes. 1 + 16 + 64 + 256 + 1040 + 1093 + 1284 = 3754 Remark. With arithmetic problems, input integers are encoded in binary. Poly-time reduction must be polynomial in binary encoding. Theorem 3SAT P Subset Sum Nanyang Technological University MAS 714 November 8, 2018 14 / 20

Reducing 3SAT to Subset Sum Construction. Given a 3SAT formula ϕ with n variables and m clauses, form 2n + 2m decimal integers, each of n + m digits: include one digit for each variable x i and for each clause C j two numbers for each variable x i two numbers for each clause C j sum of each x i digit is 1; sum of each C j digit is 4. C 1 = x 1 x 2 x 3 C 2 = x 1 x 2 x 3 C 3 = x 1 x 2 x 3 x 1 x 2 x 3 C 1 C 2 C 3 x 1 1 0 0 0 1 0 x 1 1 0 0 1 0 0 x 2 0 1 0 1 0 0 x 2 0 1 0 0 1 1 x 3 0 0 1 1 1 0 x 3 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 0 1 0 0 0 0 0 2 W 1 1 1 4 4 4 Nanyang Technological University MAS 714 November 8, 2018 15 / 20

Reducing 3SAT to Subset Sum Lemma ϕ is satisfiable iff there exists a subset that sums to W. Proof. = : Suppose ϕ is satisfiable Choose integers corresponding to each true literal. Since ϕ is satisfiable, each C j digit sums to at least 1 from x i rows. Choose dummy integers to make clause digits sum to 4. C 1 = x 1 x 2 x 3 C 2 = x 1 x 2 x 3 C 3 = x 1 x 2 x 3 x 1 x 2 x 3 C 1 C 2 C 3 x 1 1 0 0 0 1 0 x 1 1 0 0 1 0 1 x 2 0 1 0 1 0 0 x 2 0 1 0 0 1 1 x 3 0 0 1 1 1 0 x 3 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 0 1 0 0 0 0 0 2 W 1 1 1 4 4 4 Nanyang Technological University MAS 714 November 8, 2018 16 / 20

Reducing 3SAT to Subset Sum Lemma ϕ is satisfiable iff there exists a subset that sums to W. Proof. =: Suppose there is a subset that sums to W Digit x i forces subset to select either row x i or x i (but not both). Digit C j forces subset to select at least one literal in clause. Assign x i = true iff row x i selected. C 1 = x 1 x 2 x 3 C 2 = x 1 x 2 x 3 C 3 = x 1 x 2 x 3 x 1 x 2 x 3 C 1 C 2 C 3 x 1 1 0 0 0 1 0 x 1 1 0 0 1 0 1 x 2 0 1 0 1 0 0 x 2 0 1 0 0 1 1 x 3 0 0 1 1 1 0 x 3 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 0 1 0 0 0 0 0 2 W 1 1 1 4 4 4 Nanyang Technological University MAS 714 November 8, 2018 17 / 20

More NP-Complete Problems Basic genres of NP-complete problems and paradigmatic examples Packing/covering problems: Set Cover, Vertex Cover, Independent Set Constraint satisfaction problems: SAT, 3SAT Sequencing problems: Hamiltonian Cycle, TSP Partitioning problems: 3D-Matching, 3-Color Numerical problems: Subset Sum, Partition Most NP problems are known to be either in P or NP-complete Notable exceptions: Factoring, Graph Isomorphism, Nash Equilibrium Theorem(Ladner 1975) Unless P = NP, there exist problems in NP that are neither in P nor NP-complete. Nanyang Technological University MAS 714 November 8, 2018 18 / 20

Karp s Karp's 21 21 NP-complete problems problems Dick Karp (1972) 1985 Turing Award Nanyang Technological University MAS 714 November 8, 2018 19 / 20 76

Small Difference? Big Difference P shortest path min cut 2-satisfiability planar 4-colorability bipartite vertex cover matching linear programming NP-complete longest path max cut 3-satisfiability planar 3-colorability vertex cover 3d-matching integer linear programming Nanyang Technological University MAS 714 November 8, 2018 20 / 20