NP-Complete Reductions 1

Similar documents
NP-Complete Reductions 2

NP-Completeness. NP-Completeness 1

Essential facts about NP-completeness:

CS21 Decidability and Tractability

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

NP Complete Problems. COMP 215 Lecture 20

Lecture 4: NP and computational intractability

NP-Complete Problems. More reductions

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

1. Introduction Recap

Chapter 34: NP-Completeness

Correctness of Dijkstra s algorithm

NP-completeness. Chapter 34. Sergey Bereg

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

NP-Complete Reductions 3

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

CS21 Decidability and Tractability

Design and Analysis of Algorithms

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

NP-Complete problems

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

CS Fall 2011 P and NP Carola Wenk

DESIGN AND ANALYSIS OF ALGORITHMS. Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

NP Completeness and Approximation Algorithms

SAT, Coloring, Hamiltonian Cycle, TSP

1.1 P, NP, and NP-complete

Polynomial-time reductions. We have seen several reductions:

More NP-Complete Problems

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

NP-Completeness. Subhash Suri. May 15, 2018

Introduction to Complexity Theory

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

Complexity, P and NP

SAT, NP, NP-Completeness

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

NP and Computational Intractability

There are two types of problems:

Intro to Theory of Computation

Polynomial-time Reductions

NP-Completeness. NP-Completeness 1

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

Limitations of Algorithm Power

CSC 373: Algorithm Design and Analysis Lecture 15

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

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?

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

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

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

CSE 105 THEORY OF COMPUTATION

Polynomial time reduction and NP-completeness. Exploring some time complexity limits of polynomial time algorithmic solutions

NP and NP Completeness

CS 583: Algorithms. NP Completeness Ch 34. Intractability

CS154, Lecture 13: P vs NP

CSE 135: Introduction to Theory of Computation NP-completeness

Computational Intractability 2010/4/15. Lecture 2

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

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.

Polynomial-Time Reductions

NP and Computational Intractability

Theory of Computation Chapter 9

No Harder Than. We want these transformations to effectively be a problem-hardness version of #, which we will call No Harder Than.

CSL 356: Analysis and Design of Algorithms. Ragesh Jaiswal CSE, IIT Delhi

Lecture 3: Nondeterminism, NP, and NP-completeness

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

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

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

Introduction to Computational Complexity

Introduction. Pvs.NPExample

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

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

Notes for Lecture 21

Non-Deterministic Time

ECE 695 Numerical Simulations Lecture 2: Computability and NPhardness. Prof. Peter Bermel January 11, 2017

Algorithms Design & Analysis. Approximation Algorithm

15-451/651: Design & Analysis of Algorithms October 31, 2013 Lecture #20 last changed: October 31, 2013

NP Completeness. Richard Karp, 1972.

Lecture 18: More NP-Complete Problems

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

NP-problems continued

The Cook-Levin Theorem

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

CS154, Lecture 13: P vs NP

Formal definition of P

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

1 Primals and Duals: Zero Sum Games

Algorithm Design and Analysis

Algorithm Design and Analysis

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

NP-Completeness. Sections 28.5, 28.6

NP Completeness and Approximation Algorithms

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

Lecture 19: Finish NP-Completeness, conp and Friends

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

Lecture 13, Fall 04/05

NP-Hardness reductions

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

Transcription:

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

Lecture Outline x x x 2 x 2 x 3 x 3 x 4 x 4 2 22 32 NP-Complete Reductions Notion of reduction Circuit Satisfiability: the first NP-complete problem Reduction process Sample reductions Circuit-SAT 2SAT Vertex Vertex Cover SAT Cover Clique 3 2 23 3 33

Today s Learning Objectives Definitions NP is the set of all problems (languages) that can be accepted non-deterministically (using choose operations) in polynomial time. verified in polynomial-time given a certificate y. Reduction techniques Local replacement Component design Some NP-complete problem reductions Problem reduction SAT (and CNF-SAT and 3SAT) Vertex Cover Clique Hamiltonian Cycle

Some Thoughts about P and NP NP-complete problems live here NP P Belief: P is a proper subset of NP. CIRCUIT-SAT Implication: the NP-complete problems are the hardest in NP. Why: Because if we could solve an NP-complete problem in polynomial time, we could solve every problem in NP in polynomial time. That is, if an NP-complete problem is solvable in polynomial time, then P=NP. Since so many people have attempted without success to find polynomialtime solutions to NP-complete problems, showing your problem is NPcomplete is equivalent to showing that a lot of smart people have worked on your problem and found no polynomial-time algorithm.

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: 0 0 0 Output: 0 0

Transitivity of Reducibility If A B and B C, then A C. An input x for A can be converted to x for B, such that x is in A if and only if x is in B. Likewise, for B to C. Convert x into x for C such that x is in B iff x is in C. Hence, if x is in A, x is in B, and x is in C. Likewise, if x is in C, x is in B, and x is in A. Thus, A C, since polynomials are closed under composition. Types of reductions: 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.

History Cook proved the first problem to be NP- Complete (970) Satisfiability Karp (972) then showed a number of decision problems were also NP-Complete Since then, hundreds of problems have been shown to be NP-complete

Satisfiability Literal: A variable or a negated variable. E.g. x, y Clause: Literals connected with E.g. (x y z) A Boolean formula is in conjunctive normal form, or a CNF-formula, if it consists of clauses connected by E.g. (x,y,z,w) (x y z w) (x y z w) A CNF-formula is a 3-CNF-fomula if each clause of has 3 literals. E.g. (x,y,z,w) (x y z) (x y w) CNF-SAT { : is a satisfiable CNF-formula} 3-SAT { : is a satisfiable 3-CNF-formula}

The Cook-Levin Theorem Theorem (Cook 970, Levin 972) SAT is NP- Complete. Further, CNF-SAT is also NP-Complete. Corollary 3-SAT is NP-Complete. Proof of Corollary (next lecture)

Cook-Levin Theorem SAT is NP-complete. We already showed it is in NP. To prove it is NP-hard, we have to show that every language in NP can be reduced to it. Let M be in NP, and let x be an input for M. Let y be a certificate that allows us to verify membership in M in polynomial time, p(n), by some algorithm D. Let S be a circuit of size at most O(p(n) 2 ) that simulates a computer (details omitted ) NP M poly-time CIRCUIT-SAT

A First NP-Complete Problem A Boolean circuit is a circuit of AND, OR, and NOT gates; the CIRCUIT-SAT problem is to determine if there is an assignment of 0 s and s to a circuit s inputs so that the circuit outputs. Inputs: Logic Gates: NOT 0 0 0 Output: OR 0 0 AND

CIRCUIT-SAT is in NP Non-deterministically choose a set of inputs and the outcome of every gate, then test each gate s I/O. Inputs: Logic Gates: NOT 0 0 0 Output: OR 0 0 AND

CIRCUIT-SAT is NP-Complete Lemma 34.5. The circuit-satisfiability problem belongs to the class NP. Lemma 34.6. The circuit-satisfiability problem is NP-hard. Proof. L P CIRCUIT _ SAT L NP. Theorem 34.7. NP-Complete. The circuit-satisfiability problem is

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

SAT A Boolean formula is a formula where the variables and operations are Boolean (0/): (a+b+ d+e)( a+ c)( b+c+d+e)(a+ c+ e) OR: +, AND: (times), NOT: SAT: Given a Boolean formula S, is S satisfiable, that is, can we assign 0 s and s to the variables so that S is ( true )? Easy to see that CNF-SAT is in NP: Non-deterministically choose an assignment of 0 s and s to the variables and then evaluate each clause. If they are all ( true ), then the formula is satisfiable.

SAT is NP-complete Reduce CIRCUIT-SAT to SAT. Inputs: Given a Boolean circuit, make a variable for every input and gate. Create a sub-formula for each gate, characterizing its effect. Form the formula as the output variable AND-ed with all these sub-formulas: Example: m((a+b) e)(c f)(d g)(e h)(ef i) a b c d e f g j h i k n Output: m The formula is satisfiable if and only if the Boolean circuit is satisfiable.

Vertex Cover A vertex cover of graph G=(V,E) is a subset W of V, such that, for every edge (a,b) in E, a is in W or b is in W. VERTEX-COVER: Given an graph G and an integer K, is does G have a vertex cover of size at most K? VERTEX-COVER is in NP: Non-deterministically choose a subset W of size K and check that every edge is covered by W.

Vertex-Cover is NP-complete Reduce 3SAT to VERTEX-COVER. Let S be a Boolean formula in CNF with each clause having 3 literals. For each variable x, create a node for x and x, and connect these two: x x For each clause (a+b+c), create a triangle and connect these three nodes. a c b

Vertex-Cover is NP-complete Completing the construction Connect each literal in a clause triangle to its copy in a variable pair. E.g., a clause ( x+y+z) x x y y z z Let n=# of variables Let m=# of clauses Set K=n+2m a c b

Vertex-Cover is NP-complete Example: (a+b+c)( a+b+ c)( b+ c+ d) Graph has vertex cover of size K=4+6=0 iff formula is satisfiable. a a b b c c d d 2 22 32 3 2 23 3 33

Clique A clique of a graph G=(V,E) is a subgraph C that is fullyconnected (every pair in C has an edge). CLIQUE: Given a graph G and an integer K, is there a clique in G of size at least K? This graph has a clique of size 5 CLIQUE is in NP: non-deterministically choose a subset C of size K and check that every pair in C has an edge in G.

CLIQUE is NP-Complete Reduction from VERTEX-COVER. A graph G has a vertex cover of size K if and only if it s complement has a clique of size n-k. G G

Lecture Summary NP-Completeness proof steps for problem Q Q is in NP Some NP-complete problem reduces to Q in polynomial time Study of Reduction techniques Local replacement Component design Some NP-complete problem reductions Circuit-SAT SAT 3SAT Vertex Cover

Some Other 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

Some Other NP-Complete Problems 0/ 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 Saleperson 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.