NP-Complete Reductions 2

Similar documents
Computability Theory

NP-complete Reductions

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

Where Can We Draw The Line?

NP-Completeness. Algorithms

P and NP (Millenium problem)

Example of a Demonstration that a Problem is NP-Complete by reduction from CNF-SAT

8 NP-complete problem Hard problems: demo

CMPSCI611: The SUBSET-SUM Problem Lecture 18

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

CS 4407 Algorithms. Lecture 8: Circumventing Intractability, using Approximation and other Techniques

1. Suppose you are given a magic black box that somehow answers the following decision problem in polynomial time:

Some Hardness Proofs

Complexity Classes and Polynomial-time Reductions

W4231: Analysis of Algorithms

PCP and Hardness of Approximation

Computational problems. Lecture 2: Combinatorial search and optimisation problems. Computational problems. Examples. Example

More NP-complete Problems. CS255 Chris Pollett May 3, 2006.

NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

Chapter 10 Part 1: Reduction

9.1 Cook-Levin Theorem

2SAT Andreas Klappenecker

P and NP CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang

1 Definition of Reduction

P and NP CISC5835, Algorithms for Big Data CIS, Fordham Univ. Instructor: X. Zhang

Lecture 20: Satisfiability Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

Introduction to Algorithms. Lecture 24. Prof. Patrick Jaillet

(p 300) Theorem 7.27 SAT is in P iff P=NP

NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT

8.1 Polynomial-Time Reductions

Chapter 8. NP-complete problems

NP and computational intractability. Kleinberg and Tardos, chapter 8

CS154, Lecture 18: PCPs, Hardness of Approximation, Approximation-Preserving Reductions, Interactive Proofs, Zero-Knowledge, Cold Fusion, Peace in

In this lecture we discuss the complexity of approximation problems, and show how to prove they are NP-hard.

8.1 Polynomial-Time Reductions

Introduction to Algorithms

1 Introduction. 1. Prove the problem lies in the class NP. 2. Find an NP-complete problem that reduces to it.

Reductions. Linear Time Reductions. Desiderata. Reduction. Desiderata. Classify problems according to their computational requirements.

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

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

Reductions and Satisfiability

CS 580: Algorithm Design and Analysis

3/7/2018. CS 580: Algorithm Design and Analysis. 8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

Lecture 21: Other Reductions Steven Skiena

Steven Skiena. skiena

Decision Problems. Observation: Many polynomial algorithms. Questions: Can we solve all problems in polynomial time? Answer: No, absolutely not.

Module 6 NP-Complete Problems and Heuristics

Homework 4 Solutions

Partha Sarathi Mandal

Decision Procedures. An Algorithmic Point of View. Decision Procedures for Propositional Logic. D. Kroening O. Strichman.

Chapter 9 Graph Algorithms

Solutions for the Exam 6 January 2014

Vertex Cover Approximations

CSCE750 Analysis of Algorithms Fall 2017 NP-Complete Problems

More NP-Complete Problems [HMU06,Chp.10b] Node Cover Independent Set Knapsack Real Games

Chapter 9 Graph Algorithms

HW1. Due: September 13, 2018

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Module 6 NP-Complete Problems and Heuristics

Lecture 21: Other Reductions Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

Chapter 9 Graph Algorithms

CSC 505, Fall 2000: Week 12

Introduction to Parameterized Complexity

P -vs- NP. NP Problems. P = polynomial time. NP = non-deterministic polynomial time

COMP 355 Advanced Algorithms Approximation Algorithms: VC and TSP Chapter 11 (KT) Section (CLRS)

PROPOSITIONAL LOGIC (2)

Greedy algorithms Or Do the right thing

Lecture 24: More Reductions (1997) Steven Skiena. skiena

The Resolution Algorithm

Approximation Algorithms

arxiv: v2 [cs.cc] 29 Mar 2010

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14

CSE 417 Branch & Bound (pt 4) Branch & Bound

ALGORITHMS EXAMINATION Department of Computer Science New York University December 17, 2007

NP-Complete Problems

Boolean Functions (Formulas) and Propositional Logic

Prove, where is known to be NP-complete. The following problems are NP-Complete:

The Satisfiability Problem [HMU06,Chp.10b] Satisfiability (SAT) Problem Cook s Theorem: An NP-Complete Problem Restricted SAT: CSAT, k-sat, 3SAT

Module 6 NP-Complete Problems and Heuristics

CS521 \ Notes for the Final Exam

1 The Traveling Salesperson Problem (TSP)

Reference Sheet for CO142.2 Discrete Mathematics II

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Module 6 P, NP, NP-Complete Problems and Approximation Algorithms

Lecture 2: NP-Completeness

CMSC 451: Lecture 22 Approximation Algorithms: Vertex Cover and TSP Tuesday, Dec 5, 2017

Math 776 Graph Theory Lecture Note 1 Basic concepts

NP-Hard (A) (B) (C) (D) 3 n 2 n TSP-Min any Instance V, E Question: Hamiltonian Cycle TSP V, n 22 n E u, v V H

Binary Decision Diagrams

SAT-CNF Is N P-complete

Lecture 14: Lower Bounds for Tree Resolution

CS 151 Complexity Theory Spring Final Solutions. L i NL i NC 2i P.

CPSC 536N: Randomized Algorithms Term 2. Lecture 10

Exercises Computational Complexity

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem

Hardness of Approximation for the TSP. Michael Lampis LAMSADE Université Paris Dauphine

Implementation of a Sudoku Solver Using Reduction to SAT

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 CS 447, Algorithms

CS 447, Algorithms 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

CS 447, Algorithms 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

CS 447, Algorithms 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. CS 447, Algorithms

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. CS 447, Algorithms

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 CS 447, Algorithms

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) CS 447, Algorithms

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 CS 447, Algorithms

CS 447, Algorithms 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. CS 447, Algorithms

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. CS 447, Algorithms

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 ) CS 447, Algorithms

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

CS 447, Algorithms 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

CS 447, Algorithms The Reduction for any clause ( ) V = formula s length K= no. of clauses connected iff

CS 447, Algorithms 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.

CS 447, Algorithms 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

CS 447, Algorithms 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).

CS 447, Algorithms 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.

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

CS 447, Algorithms 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. CS 447, Algorithms

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 ) CS 447, Algorithms

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 CS 447, Algorithms there s an IS of size k in its complement

CS 447, Algorithms Formal Proof: Example Vertex Cover is NP-Complete

CS 447, Algorithms 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.

CS 447, Algorithms 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

CS 447, Algorithms 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.

CS 447, Algorithms 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. CS 447, Algorithms

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) CS 447, Algorithms

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

CS 447, Algorithms 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

Slack variables variables 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 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 CS 447, Algorithms t = 1 1 1 3 3 3 3

CS 447, Algorithms Achieving Target digit per clause c 1 c 2 c k <d<4 target:

CS 447, Algorithms Achieving Target digit per clause c 1 c 2 c k 1 1 target: 3

CS 447, Algorithms 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

CS 447, Algorithms 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

CS 447, Algorithms 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. 1 in the leftmost l digits satisfiability 3 in the rightmost k digits CS 447, Algorithms

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. CS 447, Algorithms

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

CS 447, Algorithms 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 1 1 1 1 1 y 1 z 1 y l z l 1 1 1 1 1 1 3 3 3

CS 447, Algorithms 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 1 1 1 1 1 1 y 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 CS 447, Algorithms

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

Appendix 52

CS 447, Algorithms 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) 3CNF: a CNF formula with three literals in each clause. Example: (x y z) (x y z) negation: not ( ) conjunction: and ( ) disjunction: or ( )

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 CS 447, Algorithms

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. CS 447, Algorithms