NP-Complete Reductions 3

Similar documents
NP-Complete Reductions 2

NP-Complete Reductions 1

NP-Complete Problems. More reductions

CS21 Decidability and Tractability

1. Introduction Recap

Lecture 18: More NP-Complete Problems

CS154, Lecture 13: P vs NP

1 Non-deterministic Turing Machine

CS21 Decidability and Tractability

CS154, Lecture 13: P vs NP

Computational Intractability 2010/4/15. Lecture 2

Theory of Computation Chapter 9

8.5 Sequencing Problems

NP-Hardness reductions

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

BBM402-Lecture 11: The Class NP

Lecture 19: Finish NP-Completeness, conp and Friends

NP and Computational Intractability

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

NP and NP-Completeness

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

More NP-Complete Problems

CS 583: Algorithms. NP Completeness Ch 34. Intractability

Topics in Complexity Theory

Polynomial-time reductions. We have seen several reductions:

NP-Complete problems

Intro to Theory of Computation

NP and Computational Intractability

CSE 421 NP-Completeness

Theory of Computation Time Complexity

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

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

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Chapter 8. NP and Computational Intractability

Time Complexity. CS60001: Foundations of Computing Science

Applied Computer Science II Chapter 7: Time Complexity. Prof. Dr. Luc De Raedt. Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

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

Design and Analysis of Algorithms

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

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine.

CSI 4105 MIDTERM SOLUTION

Quiz 3. Please write your name in the upper corner of each page. Problem Points Grade. Total 100 Q3-1

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

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

Computability Theory

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

Approximation Algorithms

Essential facts about NP-completeness:

Lecture 16: Time Complexity and P vs NP

Lecture 13, Fall 04/05

Algorithms Design & Analysis. Approximation Algorithm

COMP 382. Unit 10: NP-Completeness

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

NP-problems continued

Today: NP-Completeness (con t.)

Algorithm Design and Analysis

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

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

Introduction. Pvs.NPExample

NP-Completeness Part II

Polynomial-Time Reductions

Chapter 7: Time Complexity

Complexity, P and NP

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

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München

CS 5114: Theory of Algorithms. Tractable Problems. Tractable Problems (cont) Decision Problems. Clifford A. Shaffer. Spring 2014

NP-Completeness Part II

Chapter 3: Proving NP-completeness Results

CSCI 1590 Intro to Computational Complexity

NP-Completeness. NP-Completeness 1

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

Lecture 4: NP and computational intractability

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

Lecture 10: Lovász Local Lemma. Lovász Local Lemma

Algorithm Design and Analysis

Topics in Complexity

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

NP Complete Problems. COMP 215 Lecture 20

Polynomial-time Reductions

NP-Completeness. Subhash Suri. May 15, 2018

Limitations of Algorithm Power

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

ECS122A Handout on NP-Completeness March 12, 2018

NP Completeness and Approximation Algorithms

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

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

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

CISC 4090 Theory of Computation

CSE 135: Introduction to Theory of Computation NP-completeness

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?

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

Intro to Theory of Computation

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

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP)

SAT, NP, NP-Completeness

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

Chapter 2 : Time complexity

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

Transcription:

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

HARDEST PROBLEMS IN NP Definition: Theorem: A language B is NP-complete if: 1. B NP 2. Every A is NP-complete A in is poly-time and A P reducible B to B (i.e. B is NP-hard) If B is NP-Complete and P NP, then There is no fast algorithm for B.

REDUCTION STRATEGIES A reduction by restriction shows that the source problem is a special case of the target problem. For example, 3SAT P CNF-SAT because every satisfiable 3CNF is also a satisfiable CNF. Example. Prove 3SAT P 4SAT by restriction. A 3CNF can be converted to an equivalent 4CNF by repeating one literal in each clause.

COLORING COLOR = { G,k G is k-colorable } a d a d c b e b c 3COLOR = { G G is 3-colorable} Prove that 3COLOR P COLOR

HAMILTONIAN PATHS b f e g a d i c h HAMPATH = { G,s,t G has a hamiltonian path from s to t }

HAM PATH BETWEEN 2 VERTICES (H2V) INSTANCE: Graph G(V,E), vertices u,v V QUESTION: Does G contain a HAMILTON PATH from u to v? Prove that H2V is NP-complete

HAM-PATH P H2V Proof: H2V is NP-complete Restrict HAM-PATH such that the beginning node is u and the end node is v HAM-PATH is a special case of H2V

LONGEST PATH INSTANCE: Graph G(V,E), positive integer k V QUESTION: Does G contain a simple path with k or more edges.

LONGEST-PATH is NP-Complete Perform reduction from H2V Assume for LONGEST-PATH we have the case where k= V LONGEST-PATH is a special case of H2V where the path is Hamiltonian

VERTEX COVER a d a d c c b e b e VERTEX-COVER = { G,k G has a vertex cover of size at most k }

INDEPENDENT SET a d a d c c b e b e INDSET = { G,k G has an independent set of size at least k } Prove that VERTEX-COVER P INDSET.

SUBSET SUM SUBSET-SUM = { y 1,, y n,t S {1,,n}. Σ j2s y j =t } Which of the following are in SUBSET-SUM? YES 1,3,5,7, 10 NO 19,11,27,4, 13 YES 19,11,27,4, 61

KNAPSACK = { (w 1,v 1 ),(w n,v n ),W, V S {1 n} so that Σ i S w i W and Σ i S v i V} 15 lbs $500 ½ lb $15 3 lbs $2000 50 1lb, $20

Theorem. SUBSET-SUM P KNAPSACK Proof. A subset sum instance is a knapsack where the weights are equal to the values: Let ƒ(y 1,,y n,t) = (y 1,y 1 ) (y n,y n ),t,t. Then S. Σ i S y i = t iff S. Σ i S y i t and Σ i S y i t, so y 1 y n,t SUBSET-SUM iff ƒ(y 1 y n,t) KNAPSACK

SET-COVER = { S 1,,S n,k i,s i U and i[1 k] so that S i[1] S i[2] S i[k] = U } Which of the following are in SET-COVER? YES NO YES {1}, {1,2}, {2}, {3}, 2 {1,4}, {1,2}, {1,3}, {4}, 2 {1}, {2}, {1,2}, 2 Theorem. VERTEX-COVER P SET-COVER Proof. A vertex cover instance is just a set cover instance where every node is a set of edges.

REDUCTION STRATEGIES A reduction from A to B by local replacement shows how to translate between units of A and units of B. Example. vertex cover units are vertices and edges; set cover units are elements and sets. Example. CIRCUIT-SAT units are gates, CNFSAT units are clauses, 3SAT units are 3-literal clauses.

GRADUATION A transcript is a set of course numbers a student has taken A major consists of: Pairs: exactly one of which must be taken Lists: at least one course of which must be taken GRADUATION = { T,M a subset of T satisfies M} For example: T = {1901A, 1902B, 1902A, 2011, 4041A, 4061, 4211} M = [1901A,1901B], [1902A,1902B] (4011,4041A,4041B), (4211,4707), (4061)

GRADUATION 2 NP: The subset is a proof that (T,M) 2 GRADUATION. 3SAT P GRADUATION: T = {101, 102, 201, 202, 301, 302} (x 1 x 2 x 3 ) ( x 1 x 2 x 2 ) ( x 2 x 3 x 1 ) M = [101, 102], [201, 202], [301, 302] (101,201,302), (101,201,201), (101,202,301)

GRADUATION 2 NP: The subset is a proof that (T,M) 2 GRADUATION. 3SAT P GRADUATION: Let = C 1 C 2 C m have variables x 1 x k For each x i : add classes i01 and i02 to T. add pair (i01,i02) to M. For each C j, we add a triple to M: if x i is a literal in C j, the triple includes i01. if x i is a literal in C j, the triple include i02.

UHAMPATH No HAM PATH Undirected HAM PATH A B A B C D C D E F E F UHAMPATH = { G,s,t G is an undirected graph with a Hamiltonian path from s to t}

HAMPATH P UHAMPATH A B A in A mid Aout C D E F

HAMPATH P UHAMPATH A B C D E F

HAMPATH P UHAMPATH f(g,s,t) = (G,s,t ) where: For each node u G: add nodes u in, u out, u mid to G. add edges {u in,u mid } and {u mid,u out } to G For each edge (u,v) G, add {u out,v in } to G s = s in, t = t out. If (G,s,t) HAMPATH, then (G,s,t ) UHAMPATH: (s,u,v,..,t)! (s in,s mid,s out,u in,u mid,u out,v in,v mid,v out, t out )

HAMPATH P UHAMPATH If (G,s,t ) 2 UHAMPATH, then (G,s,t)2 HAMPATH: Let (s in =v 1,v 2,,v 3n =t out ) be the undirected path. Claim: for all i 0, there exists u G so that: v 3i+1 =u in, v 3i+2 =u mid, v 3i+3 =u out. i=0: If v 2 s mid, then no v i =s mid. So v 2 =s mid, v 3 =s out Induction: if v 3i = u out, then v 3i+1 =u in, so v 3i+2 =u mid. The directed Hamiltonian path is (u 1, u 2,, u n )

3SAT P SUBSET-SUM We transform a 3-cnf formula into (y 1 y n, t): 3SAT (y 1 y n,t) SUBSET-SUM The transformation can be done in time polynomial in the length of

Each variable and each clause result in two y i s. Each y i will have a digit for each clause and variable. (x 1 x 2 x 2 ) ( x 1 x 2 x 2 ) (x 1 x 2 x 2 ) x 1 x 2 C 3 C 2 C 1 x 2 x 1 C 3 C 2 C 1 y 1 1 1 0 1 y 2 1 0 1 0 y 3 1 0 1 1 1 y 4 1 0 1 0 0 y 5 1 0 0 y 6 1 0 0 y 7 1 0 y 8 1 0 y 9 1 y 10 1 t 1 1 3 3 3

3SAT P SUBSET-SUM Let = C 1 Æ C 2 Æ C m have k variables x 1 x k. We output y 1 y 2k + 2m, each a k+m-digit number. for each 1 j k: for each 1 i m: the i th digit of y 2j-1 is 1 if x j 2 C i, else 0 the i th digit of y 2j is 1 if :x j 2 C i, else 0. digit j+m of y 2j, y 2j-1 is 1. For each 1 j m: y 2k+2j = y 2k+2j-1 = 10 j-1 Output t = 11..1133..3