NP-Complete Reductions 2

Similar documents
NP-Complete Reductions 1

NP-Complete Problems. More reductions

NP-Complete Reductions 3

Essential facts about NP-completeness:

CS21 Decidability and Tractability

NP Complete Problems. COMP 215 Lecture 20

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

1. Introduction Recap

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

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

CS 583: Algorithms. NP Completeness Ch 34. Intractability

Lecture 18: More NP-Complete Problems

Lecture 4: NP and computational intractability

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

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

NP Completeness and Approximation Algorithms

Design and Analysis of Algorithms

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

NP-Hardness reductions

CS21 Decidability and Tractability

NP-completeness. Chapter 34. Sergey Bereg

NP and Computational Intractability

Correctness of Dijkstra s algorithm

NP-Complete problems

Introduction. Pvs.NPExample

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

CS Fall 2011 P and NP Carola Wenk

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

Chapter 34: NP-Completeness

CS 6505, Complexity and Algorithms Week 7: NP Completeness

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete)

Show that the following problems are NP-complete

Computational Intractability 2010/4/15. Lecture 2

More NP-Complete Problems

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

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.

BBM402-Lecture 11: The Class NP

SAT, Coloring, Hamiltonian Cycle, TSP

Today: NP-Completeness (con t.)

Theory of Computation Chapter 9

NP-Completeness Part II

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

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

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

NP-Completeness Part II

Polynomial-time Reductions

Polynomial-time reductions. We have seen several reductions:

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

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

Complexity, P and NP

COP 4531 Complexity & Analysis of Data Structures & Algorithms

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

CS154, Lecture 13: P vs NP

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

VIII. NP-completeness

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

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

1.1 P, NP, and NP-complete

Polynomial-Time Reductions

Spring Lecture 21 NP-Complete Problems

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

CS154, Lecture 13: P vs NP

Automata Theory CS Complexity Theory I: Polynomial Time

Chapter 7: Time Complexity

Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel

Lecture 24 : Even more reductions

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

Graduate Algorithms CS F-21 NP & Approximation Algorithms

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

8.5 Sequencing Problems

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

Topics in Complexity Theory

Intro to Theory of Computation

NP and Computational Intractability

Instructor N.Sadagopan Scribe: P.Renjith. Lecture- Complexity Class- P and NP

CSE 3500 Algorithms and Complexity Fall 2016 Lecture 25: November 29, 2016

Lecture 13, Fall 04/05

More Completeness, conp, FNP,etc. CS254 Chris Pollett Oct 30, 2006.

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

ECS122A Handout on NP-Completeness March 12, 2018

Chapter 3: Proving NP-completeness Results

Limitations of Algorithm Power

NP-problems continued

Lecture 18: PCP Theorem and Hardness of Approximation I

NP Completeness. Richard Karp, 1972.

NP-Completeness. Subhash Suri. May 15, 2018

SAT, NP, NP-Completeness

A brief introduction to Logic. (slides from

Chapter 2 : Time complexity

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?

NP and NP-Completeness

CSI 4105 MIDTERM SOLUTION

NP-complete Problems

Lecture 12 Scribe Notes

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

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

P, NP, NP-Complete, and NPhard

Transcription:

x 1 x 1 x 2 x 2 x 3 x 3 x 4 x 4 12 22 32 CS 447 11 13 21 23 31 33 Algorithms NP-Complete Reductions 2 Prof. Gregory Provan Department of Computer Science University College Cork 1

Lecture Outline NP-Complete Reductions 2 Objectives: To introduce more NP-Complete problems. Overview: 3SAT CLIQUE & INDEPENDENT-SET SUBSET-SUM x 1 x 1 x 2 x 2 x 3 x 3 x 4 x 4 12 22 32 11 13 21 23 31 33

Today s Learning Objectives Review of Reduction techniques Local replacement Component design Additional examples of NP-complete problem reductions 3SAT Clique Independent Set Subset-Sum

Problem Reduction A language M is polynomial-time reducible to a language L if an instance x for M can be transformed in polynomial time to an instance x for L such that x is in M if and only if x is in L. Denote this by M L. A problem (language) L is NP-hard if every problem in NP is polynomial-time reducible to L. A problem (language) is NP-complete if it is in NP and it is NPhard. CIRCUIT-SAT is NP-complete: CIRCUIT-SAT is in NP For every M in NP, M CIRCUIT-SAT. Inputs: 1 1 1 1 1 Output: 1 1 1

Reducibility Chart CIRCUIT-SAT SAT 3CNF-SAT Clique HAM-CYCLE VERTEX COVER TSP SUBSET-SUM

Method How to show a problem is in NPC? First show it s in NP Then show it is NP-hard by reducing some NP- Hard problem to it.

Reducibility Techniques Local replacement: Show A B by dividing an input to A into components and show how each component can be converted to a component for B. Component design: Show A B by building special components for an input of B that enforce properties needed for A, such as choice or evaluate.

New Base Problems Start by introducing a useful variants of SAT 3SAT We ll use it as our base problem Perform reductions to additional problems

3SAT Instance: a 3CNF formula Problem: To decide if the formula is satisfiable. A satisfiable 3CNF formula (x y z) (x y z) An unsatisfiable 3CNF formula (x x x) ( x x x)

3SAT is NP-Complete 3SAT is a special case of SAT, and is therefore clearly in NP. In order to show it s also NP-Complete, reduce SAT s formula so it produces a 3CNF formula. Ensure Polynomial-time reduction

3SAT is NP-Complete 3SAT is a special case of SAT, and is therefore clearly in NP. In order to show it s also NP-Complete, we ll alter the proof of SAT s NP-Completeness so it produces 3CNF formulas. Polynomial-time reduction

Revisiting SAT s NP-Completeness Proof Given a TM and an input we ve produced a conjunction of: φ cell = x i,j,s k 1 i,j n s C s t C (x i,j,s x i,j, t ) φ start = x1,1,# x1,2,q x1,3,w... x1,n 2,_... x k 1 + 1,n 1,_ x 1,n k,# φ accept = ( ) + + φ = x... x move i 1,j,a i 1,j 1,a 1 i,j n legal a,...,a k 1 6 1 6 1 i,j n k x i,j,q accept

Transforming the Formula into a CNF Formula All the sub-formulas, but φ move, form a CNF formula. Using the distributive law we can transform φ move into a conjunction of clauses. The formula stays succinct (check!).

CNF 3CNF (x y) (x 1 x 2... x t )... clauses with 1 or 2 literals clauses with more than 3 literals replication split (x y x) (x 1 x 2 c 11 ) ( c 11 x 3 c 12 )... ( c 1t-3 x t-1 x t )

3SAT is NP-Complete Since we ve shown a reduction from SAT (any NP problem) to 3SAT, and 3SAT is in NP, 3SAT is NP-Complete.

CLIQUE Instance: A graph G=(V,E) and a threshold k. Problem: To decide if there is a set of nodes C={v 1,...,v k } V, s.t for any u,v C: (u,v) E.

CLIQUE is in NP On input G=(V,E),k: Guess C={v 1,...,v k } V For any u,v C: verify (u,v) E Reject if one of the tests fail, accept otherwise. The length of the certificate: O(n) (n= V ) Time complexity: O(n 2 )

CLIQUE is NP-Complete Proof: We ll show 3SAT p CLIQUE. (......)... (......) p

CLIQUE is NP-Complete Already showed that CLIQUE NP. Will show that 3-SAT P CLIQUE, i.e. a poly-time reduction f that takes as input a 3-CNF-formula φ outputs G,k = f( φ ) s.t. φ is satisfiable iff G has a k- clique

The Reduction for any clause (α β γ) V = formula s length α β γ K= no. of clauses connected iff α δ δ

Poly-time Reduction from 3-SAT to CLIQUE Input: A 3-CNF-formula φ. Let k = # of clauses in φ. Output: G,k, where G is constructed as follows: Nodes in G divided into k triples: Each triple corresponds to a clause in φ. φ Each node in a triple corresponds to a literal in the corresponding clause. Edges in G connect all but two types of nodes: No edge between any two nodes (literals) in the same triple (clause) No edge between any two nodes (literals) with contradictory labels, i.e. one labeled with x and the other labeled x for some x.

Poly-time Reduction from 3-SAT to CLIQUE Example: φ = (x y z) ( x y z) ( x y z) x y z x y x y z z

Poly-time Reduction from 3-SAT to CLIQUE Claim φ satisfiable G has a k-clique φ satisfiable an assignment s.t. each of the k clauses of φ has at least 1 satisfied literal Take 1 satisfied literal from each clause. Then by construction of G, the corresponding k nodes in G form a k- clique in G: No two of the k literals can be contradictory, as all the k literals are satisfied. Each of the k literals (nodes) comes from a distinct clause (triple).

Poly-time Reduction from 3-SAT to CLIQUE Claim G has a k-clique φ satisfiable Suppose G has a k-clique C Then by construction of G, Each of the k nodes (literal) of C comes from a distinct triple (clause) No two of the k nodes can be contradictory Hence we can satisfy all the k corresponding literals, thus all the k clauses, and thus φ.

Another View: Proof of Correctness 1 NOT connected!... a clique of size k must contain one node from every layer. k

Correctness given a k-clique, assign x TRUE or FALSE according to whether x or x is in the clique; this satisfies the formula (......)... (......). given a satisfying assignment, a set comprising of one satisfied literal of each clause forms a k-clique.

INDEPENDENT-SET Instance: A graph G=(V,E) and a goal k. Problem: To decide if there is a set of nodes I={v 1,...,v k } V, s.t for any u,v I: (u,v) E.

INDEPENDENT-SET NP On input G=(V,E),k: Guess I={v 1,...,v k } V For any u,v C: verify (u,v) E Reject if one of the tests fail, accept otherwise. The length of the certificate: O(n) (n= V ) Time complexity: O(n 2 )

INDEPENDENT-SET is NPC Proof: By the previous claim and a trivial reduction from CLIQUE. there s a clique of size k in a graph there s an IS of size k in its complement

Formal Proof: Example Vertex Cover is NP-Complete

Vertex Cover Def A vertex cover of a graph G = (V, E) is a subset V V s.t. if (u,v) E, then either u V or v V. Optimization Problem: Find a minimum vertex cover of a graph G. Decision Problem: Does a graph G have a vertex cover of size k? VERTEX-COVER = { G,k : G has a vertex cover of size k} Clearly, VERTEX-COVER NP A VC of size k is a proof that G has a VC of size k.

VERTEX-COVER is NP-Complete Define the complement of G = (V, E) as G c = (V, E c ), where E c = {(u,v): u V, v V, (u,v) E} Thus (u,v) E c iff (u,v) E G G c

VERTEX-COVER is NP-Complete Poly-time Reduction from CLIQUE to VERTEX-COVER: G, k G c, n k, where n = V Claim G, k CLIQUE iff G c, n k VERTEX-COVER. That is, G has a clique of size k iff G c has a vertex cover of size n k. Proof: Suffices to show that C is a clique in G iff V C is a vertex cover in G c.

VERTEX-COVER is NP-Complete Claim 1 C is a clique in G V C is a vertex cover in G c. Let C be a clique in G. Suppose an edge (u,v) E c not covered by V C. Then both u,v C, and (u,v) E. But C is a clique, so (u,v) E, contradiction. Claim 2 V C is a vertex cover in G c C is a clique in G. Suppose V C is a vertex cover in G c. Then (u,v) E c, either u C or v C. Thus u,v C, (u,v) E c, so (u,v) E.

SUBSET-SUM Instance: A multi-set of numbers denoted S and a target number t. Problem: To decide if there exists a subset Y S, s.t Σ y Y y=t.

On input S,t: Guess Y S SUBSET-SUM is in NP Accept iff Σ y Y y=t. The length of the certificate: O(n) (n= S ) Time complexity: O(n)

SUBSET-SUM is NP-Complete Proof: We ll show 3SAT p SUBSET-SUM. (......)... (......) p

Satisfying Clauses digit per clause c 1 c 2 c k number per variable x i assigned true: y i number per variable x i assigned false: z i 1 if x i is in c j 1 if x i is in c j otherwise otherwise

F = (x 1 x2 x3) ( x1 x2 x3) ( x1 x2 x3) (x1 x2 x3) x1 = x 1 x2 x3 C1 C2 C3 C4 x2 = x3 = 1 variables Slack variables v 1 = 1 1 1 v 1 = 1 1 1 v 2 = 1 1 v 2 = 1 1 1 1 v 3 = 1 1 1 v 3 = 1 1 1 s 1 = 1 s 1 = 1 s 2 = 1 s 2 = 1 s 3 = 1 s 3 = 1 s 4 = 1 s 4 = 1 t = 1 1 1 3 3 3 3

Achieving Target digit per clause c 1 c 2 c k <d<4 target:

Achieving Target digit per clause c 1 c 2 c k 1 1 target: 3

Achieving Target Alas, a subset may contain both y i and z i y 1 z 1 y l z l c 1 c 2 c k 1... 1 1 1 1 1... 1 3 3 3

Imposing Assignment Consistency y 1 z 1 y l z l 1 1 1 c 1 c 2 c k 1 1... 1 1 1 1 1 1 1... 1 1 3 3 3

Succinctness l k 2l 2k

Completeness If there is a satisfying assignment, a subset hitting the target is as follows: If the i-th variable is assigned TRUE, take y i, else take z i. Add as many auxiliary numbers as needed. satisfiability 3 in the rightmost k digits 1 in the leftmost l digits

Soundness If there is a subset that sums up to the target, construct an assignment as follows: If y i is in the subset, assign TRUE to the i-th variable. If z i is in the subset, assign FALSE to the i-th variable.

Observation: No Carry All digits are either or 1. Each column contains at most five 1 s. c 1 c 2 c k 1 y 1 Hence, a carry into the 1 1 1 next column never 1 occurs. 1 1 1 1 1 1 z 1 y l z l 1 1 1 1 1 3 3 3

Consistency Thus, to get 1 in the leftmost l digits, our subset necessarily contains either y i or z i (Not both!). 1 1 1 1 c 1 c 2 c k 1 y 1 1 1 1 1 1 z 1 y l z l 1 1 1 1 1 1 3 3 3

Satisfiablity In each column, at most 2 can come from the auxiliary numbers, so all clauses are satisfied. 1 1 1 1 c 1 c 2 c k 1 y 1 1 1 1 1 1 1 z 1 y l z l 1 1 1 1 1 3 3 3

Summing Up 1. SUBSET-SUM is in NP 2. 3SAT p SUBSET-SUM 3. Thus SUBSET-SUM is NP-Complete

Summary In this lecture we ve added many new problems to our NPC bank. Interestingly, NPC contains over 1 different problems!

Appendix 52

Dictionary literal: (negated or not) Boolean variable Examples: x, x clause: several literals connected with Example: (x y z) CNF (Conjunctive Normal Form): several clauses connected with Example: (x y) (x y z) negation: not ( ) conjunction: and ( ) disjunction: or ( ) 3CNF: a CNF formula with three literals in each clause. Example: (x y z) (x y z)

Catalogue of NP-Complete Problems SET-COVER: Given a collection of m sets, are there K of these sets whose union is the same as the whole collection of m sets? NP-complete by reduction from VERTEX-COVER SUBSET-SUM: Given a set of integers and a distinguished integer K, is there a subset of the integers that sums to K? NP-complete by reduction from VERTEX-COVER

Catalogue of NP-Complete Problems /1 Knapsack: Given a collection of items with weights and benefits, is there a subset of weight at most W and benefit at least K? NP-complete by reduction from SUBSET-SUM Hamiltonian-Cycle: Given an graph G, is there a cycle in G that visits each vertex exactly once? NP-complete by reduction from VERTEX-COVER Traveling Salesperson Tour: Given a complete weighted graph G, is there a cycle that visits each vertex and has total cost at most K? NP-complete by reduction from Hamiltonian-Cycle.