Lecture 18: More NP-Complete Problems

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

1. Introduction Recap

Essential facts about NP-completeness:

NP-Complete Reductions 2

More NP-Complete Problems

NP-Completeness. NP-Completeness 1

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

Theory of Computation Chapter 9

NP-Hardness reductions

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

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

NP-Complete Reductions 3

Polynomial-Time Reductions

Algorithm Design and Analysis

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

IE418 Integer Programming

4. How to prove a problem is NPC

NP and Computational Intractability

Chapter 34: NP-Completeness

Lecture 19: Finish NP-Completeness, conp and Friends

TRIPARTITE MATCHING, KNAPSACK, Pseudopolinomial Algorithms, Strong NP-completeness

P, NP, NP-Complete, and NPhard

8.5 Sequencing Problems

Polynomial-time reductions. We have seen several reductions:

CS154, Lecture 13: P vs NP

NP-Complete Problems. More reductions

NP-problems continued

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

NP-Complete Reductions 1

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

CS21 Decidability and Tractability

1.1 P, NP, and NP-complete

CS154, Lecture 13: P vs NP

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

Intro to Theory of Computation

Polynomial-time Reductions

CSC 373: Algorithm Design and Analysis Lecture 15

Design and Analysis of Algorithms

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

NP-Completeness. Sections 28.5, 28.6

NP and Computational Intractability

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

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

CS 583: Algorithms. NP Completeness Ch 34. Intractability

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

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Admin NP-COMPLETE PROBLEMS. Run-time analysis. Tractable vs. intractable problems 5/2/13. What is a tractable problem?

Part V. Intractable Problems

CSE 421 NP-Completeness

NP-Completeness. Subhash Suri. May 15, 2018

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

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

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

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

Correctness of Dijkstra s algorithm

NP-Completeness. Algorithmique Fall semester 2011/12

SAT, NP, NP-Completeness

CS154, Lecture 18: 1

NP-complete Problems

CS21 Decidability and Tractability

Chapter 8. NP and Computational Intractability

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

Approximation Preserving Reductions

Lecture 16: Time Complexity and P vs NP

NP Completeness and Approximation Algorithms

Hardness of Approximation

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

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

Chapter 3: Proving NP-completeness Results

CSI 4105 MIDTERM SOLUTION

ECS122A Handout on NP-Completeness March 12, 2018

NP-Complete Problems

Lecture 20: conp and Friends, Oracles in Complexity Theory

Lecture 13, Fall 04/05

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

NP-problems continued

PCPs and Inapproximability Gap-producing and Gap-Preserving Reductions. My T. Thai

Non-Deterministic Time

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

Supporting hyperplanes

Geometric Steiner Trees

NP and NP-Completeness

Formal definition of P

CS/COE

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

Algorithm Design and Analysis

NP Complete Problems. COMP 215 Lecture 20

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

There are two types of problems:

1 T 1 = where 1 is the all-ones vector. For the upper bound, let v 1 be the eigenvector corresponding. u:(u,v) E v 1(u)

INTRO TO COMPUTATIONAL COMPLEXITY

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

CSCI 1010 Models of Computa3on. Lecture 11 Proving Languages NP-Complete

CS Fall 2011 P and NP Carola Wenk

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

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

COMP 382. Unit 10: NP-Completeness

Data Structures and Algorithms (CSCI 340)

NP and NP-Completeness

Transcription:

6.045 Lecture 18: More NP-Complete Problems 1

The Clique Problem a d f c b e g Given a graph G and positive k, does G contain a complete subgraph on k nodes? CLIQUE = { (G,k) G is an undirected graph with a k-clique } 2

The Clique Problem Given a graph G and positive k, does G contain a complete subgraph on k nodes? CLIQUE = { (G,k) G is an undirected graph with a k-clique } Theorem (Karp): CLIQUE is NP-complete 3

Theorem: CLIQUE is NP-Complete P NP 3SAT CLIQUE 4

3SAT P CLIQUE Transform a 3-cnf formula into (G,k) such that 3SAT (G,k) CLIQUE Want transformation that can be done in time that is polynomial in the length of How can we encode a logic problem as a graph problem? 5

3SAT P CLIQUE We transform a 3-cnf formula into (G,k) such that 3SAT (G,k) CLIQUE Let C 1, C 2,, C m be clauses of. Assign k := m. Make a graph G with m groups of 3 nodes each. Group i corresponds to clause C i of Each node in group i is labeled with a literal of C i Put edges between all pairs of nodes in different groups, except pairs of nodes with labels x i and :x i Put no edges between nodes in the same group When done putting in all the edges, erase the labels 6

(x 1 x 1 x 2 ) ( x 1 x 2 x 2 ) ( x 1 x 2 x 2 ) x 1 x 2 x 2 x 1 x 1 x 1 x 2 x 2 x 2 V = 3(number of clauses) k = number of clauses 7

(x 1 x 1 x 1 ) ( x 1 x 1 x 2 ) (x 2 x 2 x 2 ) ( x 2 x 2 x 1 ) x 1 x 1 x 2 x 1 x 2 x 1 x 2 x 1 x 2 x 2 x 2 x 1 8

Claim: 3SAT (G,m) CLIQUE Claim: If 3SAT then (G,m) CLIQUE Proof: Let A be a SAT assignment of. For every clause C of, some literal in C is set true by A For every clause C, let v C be a vertex from group C of G, whose label is a literal that is set true by A Claim: S = {v C C 2 } is an m-clique in G. (note S =m) Proof: Let v C,v C be in S. If (v C,v C ) E Then v C and v C must label inconsistent literals, call them x and :x But assignment A cannot satisfy both x and :x Therefore (v C,v C ) 2 E, for all v C, v C 2S. Hence S is an m-clique, and (G,m) CLIQUE 9

Claim: 3SAT (G,m) CLIQUE Claim: If (G,m) CLIQUE then 3SAT Proof: Let S be an m-clique of G. We ll construct a satisfying assignment A of. Claim: S contains exactly one node from each group. For each variable x of, make variable assignment: A(x) := 1, if there is a vertex v ϵ S with label x A(x) := 0, otherwise For all i = 1,,m, one vertex from group i is in S. Therefore, for all i = 1,,m A satisfies at least one literal in the ith clause of Therefore A is a satisfying assignment to 10

Independent Set IS: Given a graph G = (V, E) and integer k, is there S µ V such that S k and no two vertices in S have an edge? CLIQUE: Given G = (V, E) and integer k, is there S µ V such that S k and every pair of vertices in S have an edge? CLIQUE P IS: Given G = (V, E), output G = (V, E ) where E = {(u,v) (u,v) E}. (G, k) 2 CLIQUE iff (G, k) 2 IS 11

The Vertex Cover Problem a d a d c c b e b e vertex cover = set of nodes C that cover all edges For all edges, at least one endpoint is in C 12

VERTEX-COVER = { (G,k) G is a graph with a vertex cover of size at most k} Theorem: VERTEX-COVER is NP-Complete (1) VERTEX-COVER NP (2) IS P VERTEX-COVER 13

IS P VERTEX-COVER Want to transform a graph G and integer k into G and k such that (G,k) IS (G,k ) VERTEX-COVER 14

IS P VERTEX-COVER Claim: For every graph G = (V,E), and subset S µ V, S is an independent set if and only if (V S) is a vertex cover Proof: S is an independent set (8 u, v 2 V)[ (u 2 S and v 2 S) ) (u,v) E ] (8 u, v 2 V)[ (u,v) 2 E ) (u S or v S) ] (V S) is a vertex cover Therefore (G,k) IS (G, V k) VERTEX-COVER Our polynomial time reduction: f(g,k) := (G, V k) 15

The Subset Sum Problem Given: Set S = {a 1,, a n } of positive integers and a positive integer t Is there an A µ {1,,n} such that t = i 2 A a i? SUBSET-SUM = {(S, t) 9 S µ S s.t. t = b 2 S b } A simple number-theoretic problem! Theorem: There is a O(n t) time algorithm for solving SUBSET-SUM. But t can be specified in (log t) bits this isn t an algorithm that runs in polytime in the input! 16

The Subset Sum Problem Given: Set S = {a 1,, a n } of positive integers and a positive integer t Is there an A µ {1,,n} such that t = i 2 A a i? SUBSET-SUM = {(S, t) 9 S µ S s.t. t = b 2 S b } A simple number-theoretic problem! Theorem: SUBSET-SUM is NP-complete 17

VC P SUBSET-SUM Want to reduce a graph to a set of numbers Given (G, k), let E = {e 0,,e m-1 } and V = {1,,n} Our subset sum instance (S, t) will have S = n+m Edge numbers : For every e j 2 E, put b j = 4 j in S Node numbers : For every i 2 V, put a i = 4 m + j : i 2 ej 4 j in S Set the target number: t = k 4 m + j=0 m-1 (2 4 j ) 18

For every e j 2 E, put b j = 4 j in S For every i 2 V, put a i = 4 m + j : i 2 ej 4 j in S Set t = k 4 m + j=0 m-1 (2 4 j ) Claim: If (G,k) VC then (S,t) SUBSET-SUM Suppose C µ V is a VC with k vertices. Let S = {a i : i 2 C} [ {b j : e j \ C = 1} S = (node numbers corresponding to nodes in C) plus (edge numbers corresponding to edges covered only once by C) Claim: The sum of all numbers in S equals t! Think of the numbers as being in base 4 as vectors with m+1 components 19

For every e j 2 E, put b j = 4 j in S For every i 2 V, put a i = 4 m + j : i 2 ej 4 j in S Set t = k 4 m + j=0 m-1 (2 4 j ) Claim: If (S,t) SUBSET-SUM then (G,k) VC Suppose C µ V and F µ E satisfy i 2 C a i + ej 2 F b j = t = k 4 m + j=0 m-1 (2 4 j ) Claim: C is a vertex cover of size k. Proof: Subtract out the b j numbers from the above sum. What remains is a sum of the form: i 2 C a i = k 4 m + j=0 m-1 (c j 4 j ) where each c j > 0. But c j = number of nodes in C covering e j This implies C is a vertex cover! 20

The Knapsack Problem Given: S = {(v 1,c 1 ), (v n,c n )} of pairs of positive integers a capacity budget C a value V Is there an S µ {1,,n} such that ( i 2 S v i ) V and ( i 2 S c i ) C? Define KNAPSACK = {(S, C, V) the answer is yes} A classic economics/logistics problem! Theorem: KNAPSACK is NP-complete 21

KNAPSACK is NP-complete KNAPSACK is in NP? Theorem: SUBSET-SUM P KNAPSACK Proof: Given an instance (S = {a 1,,a n }, t) of SUBSET-SUM, create a KNAPSACK instance: For all i, set (p i, c i ) := (a i, a i ) Define T = {(p 1, c 1 ),, (p n, c n )} Define C := P := t Then, (S,t) 2 SUBSET-SUM (T,C,P) 2 KNAPSACK Subset of S that sums to t = Solution to the Knapsack instance! 22

The Partition Problem Given: Set S = {a 1,, a n } of positive integers Is there an S µ S such that ( a_i 2 S a i ) = ( a_i 2 S-S a i )? (Formally, PARTITION is the set of all S such that the answer to this question is yes.) In other words, is there a way to partition S into two parts, with equal sum in both parts? A problem in fair division Theorem: PARTITION is NP-complete 23

PARTITION is NP-complete (1) PARTITION is in NP (2) SUBSET-SUM P PARTITION Given: Set S = {a 1,, a n } of positive integers positive integer t Output T := {a 1,, a n,2a-t,a+t}, where A := i a i Claim: (S,t) 2 SUBSET-SUM T 2 PARTITION 24

Given: Set S = {a 1,, a n } of positive integers positive integer t Output T := {a 1,, a n,2a-t,a+t}, where A := i a i Claim: (S,t) 2 SUBSET-SUM T 2 PARTITION What s the sum of all numbers in T? 4A Therefore: T 2 PARTITION There is a T µ T that sums to 2A. Proof of: (S,t) 2 SUBSET-SUM T 2 PARTITION: If (S,t) 2 SUBSET-SUM, let S µ S sum to t. Then S {2A-t} µ T sums to 2A, so T 2 PARTITION 25

Given: Set S = {a 1,, a n } of positive integers positive integer t Output T := {a 1,, a n,2a-t,a+t}, where A := i a i Claim: (S,t) 2 SUBSET-SUM T 2 PARTITION T 2 PARTITION There is a T µ T that sums to 2A. Proof of: T 2 PARTITION (S,t) 2 SUBSET-SUM If T 2 PARTITION, let T µ T be a subset that sums to 2A. Observation: Exactly one of {2A-t,A+t} is in T. If (2A-t) 2 T, then T {2A-t} sums to t. But T {2A-t} is a subset of S! So (S,t) 2 SUBSET-SUM If (A+t) 2 T, then (T T ) {2A-t} sums to (2A (2A-t)) = t Note that (T T ) {2A-t} is a subset of S. Therefore (S,t) 2 SUBSET-SUM 26

The Bin Packing Problem Given: Set S = {a 1,, a n } of positive integers, a bin capacity B, and a target integer K. Can we partition S into K subsets such that each subset sums to at most B? Is there a way to pack the items of S into K bins, with each bin having capacity B? Ubiquitous in shipping and optimization Theorem: BIN PACKING is NP-complete 27

BIN PACKING is NP-complete BIN PACKING is in NP? Theorem: PARTITION P BIN PACKING Proof: Given an instance S = {a 1,, a n } of PARTITION, create an instance of BIN PACKING with: S = {a 1,, a n } B = ( i a i )/2 k = 2 Then, S 2 PARTITION (S,B,k) 2 BIN PACKING: Partition of S into two equal sums = Solution to the Bin Packing instance! 28

Two Problems Let G denote a graph, and s and t denote nodes. SHORTEST PATH = {(G, s, t, k) G has a simple path of length < k from s to t } LONGEST PATH = {(G, s, t, k) G has a simple path of length > k from s to t } Are either of these in P? Are both of them? 29