Algorithm Design and Analysis

Similar documents
Intro to Theory of Computation

Polynomial-Time Reductions

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

COP 4531 Complexity & Analysis of Data Structures & Algorithms

NP and Computational Intractability

8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability. Classify Problems

Chapter 8. NP and Computational Intractability. CS 350 Winter 2018

Algorithms Design & Analysis. Approximation Algorithm

NP and Computational Intractability

P and NP. Inge Li Gørtz. Thank you to Kevin Wayne, Philip Bille and Paul Fischer for inspiration to slides

CS 583: Algorithms. NP Completeness Ch 34. Intractability

SAT, Coloring, Hamiltonian Cycle, TSP

Algorithm Design and Analysis

P and NP. Warm Up: Super Hard Problems. Overview. Problem Classification. Tools for classifying problems according to relative hardness.

Computational Intractability 2010/4/15. Lecture 2

Lecture 4: NP and computational intractability

NP Complete Problems. COMP 215 Lecture 20

SAT, NP, NP-Completeness

Algorithm Design and Analysis

NP Completeness and Approximation Algorithms

Essential facts about NP-completeness:

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

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

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

CSC 373: Algorithm Design and Analysis Lecture 15

7.8 Intractability. Overview. Properties of Algorithms. Exponential Growth. Q. What is an algorithm? A. Definition formalized using Turing machines.

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

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

1. Introduction Recap

Algorithms 6.5 REDUCTIONS. designing algorithms establishing lower bounds classifying problems intractability

Design and Analysis of Algorithms

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

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

CSE 421 NP-Completeness

NP-Complete problems

NP completeness and computational tractability Part II

COMP Analysis of Algorithms & Data Structures

Lecture 18: More NP-Complete Problems

COMP 382. Unit 10: NP-Completeness

Computability and Complexity Theory: An Introduction

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Computability and Complexity

Complexity, P and NP

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

CS21 Decidability and Tractability

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

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

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

More NP-Complete Problems

Show that the following problems are NP-complete

9. PSPACE 9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

NP-Complete Problems. More reductions

9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

P, NP, NP-Complete, and NPhard

8.5 Sequencing Problems

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

Chapter 8. NP and Computational Intractability

Reductions. Reduction. Linear Time Reduction: Examples. Linear Time Reductions

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?

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Chapter 9. PSPACE: A Class of Problems Beyond NP. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

NP and NP Completeness

Polynomial-time Reductions

A An Overview of Complexity Theory for the Algorithm Designer

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

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

NP-Completeness. Subhash Suri. May 15, 2018

Intro to Theory of Computation

Lecture 13, Fall 04/05

The Complexity of Optimization Problems

Theory of Computation Chapter 9

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

Geometric Steiner Trees

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

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

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

CS/COE

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

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

3/22/2018. CS 580: Algorithm Design and Analysis. 8.3 Definition of NP. Chapter 8. NP and Computational Intractability. Decision Problems.

A difficult problem. ! Given: A set of N cities and $M for gas. Problem: Does a traveling salesperson have enough $ for gas to visit all the cities?

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

Intractability. A difficult problem. Exponential Growth. A Reasonable Question about Algorithms !!!!!!!!!! Traveling salesperson problem (TSP)

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

Computational Complexity

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

Automata Theory CS Complexity Theory I: Polynomial Time

NP-Complete Reductions 1

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

Correctness of Dijkstra s algorithm

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

Week 3: Reductions and Completeness

More on NP and Reductions

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

Limitations of Algorithm Power

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

} } } Lecture 23: Computational Complexity. Lecture Overview. Definitions: EXP R. uncomputable/ undecidable P C EXP C R = = Examples

4/30/14. Chapter Sequencing Problems. NP and Computational Intractability. Hamiltonian Cycle

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

Transcription:

Algorithm Design and Analysis LECTURE 26 Computational Intractability Polynomial Time Reductions Sofya Raskhodnikova S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.1

What algorithms are (im)possible? Algorithm design patterns. Examples. Greedy. O(n log n) interval scheduling. Divide-and-conquer. O(n log n) sorting. Dynamic programming. O(n 2 ) edit distance. Augmenting paths. Max flow. Simplex method Linear programming Reductions. Maximum matcing (lots more out there) New goal: understand what is hard to compute. NP-completeness. O(n k ) algorithm unlikely. PSPACE-completeness. O(n k ) certification algorithm unlikely. Undecidability. No algorithm possible. 2

Intractability: Central ideas we ll cover Poly-time as feasible most natural problems either are easy (say n 3 ) or have no known poly-time algorithms P = problems that are easy to answer e.g. minimum cut NP = {problems whose answers are easy to verify given hint} e.g. graph 3-coloring Reductions: X is no harder than Y NP-completeness many natural problems are easy if and only if P=NP 3

Polynomial-Time Reductions S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.4

Classify Problems According to Computational Requirements Q. Which problems will we be able to solve in practice? A working definition. [Cobham 1964, Edmonds 1965, Rabin 1966] Those with polynomial-time algorithms. Yes Shortest path Matching Min cut 2-SAT Planar 4-color Bipartite vertex cover Probably no Longest path 3D-matching Max cut 3-SAT Planar 3-color Vertex cover Primality testing Factoring 5

Classify Problems Desiderata. Classify problems according to those that can be solved in polynomial-time and those that cannot. Provably requires exponential-time. Given a Turing machine, does it halt in at most k steps? Given a board position in an n-by-n generalization of chess, can black guarantee a win? Frustrating news. Huge number of fundamental problems have defied classification for decades. This lecture. Show that these fundamental problems are "computationally equivalent" and appear to be different manifestations of one really hard problem. 6

Polynomial-Time Reduction Desiderata'. Suppose we could solve X in polynomial-time. What else could we solve in polynomial time? don't confuse with reduces from Reduction. Problem X poly-time reduces to problem Y if arbitrary instances of problem X can be solved using: Polynomial number of standard computational steps, plus Polynomial number of calls to oracle that solves problem Y. computational model supplemented by special piece of hardware that solves instances of Y in a single step Notation. X p,cook Y (or X P Y). Later in the lecture. X p,karp Y. Remarks. We pay for time to write down instances sent to black box instances of Y must be of polynomial size. 7

Polynomial-Time Reduction Purpose. Classify problems according to relative difficulty. Design algorithms. If X P Y and Y can be solved in polynomial-time, then X can also be solved in polynomial time. Establish intractability. If X P Y and X cannot be solved in polynomial-time, then Y cannot be solved in polynomial time. Establish equivalence. If X P Y and Y P X, we use notation X P Y. up to cost of reduction 8

Simplifying Assumption: Decision Problems Search problem. Find some structure. Example. Find a minimum cut. Decision problem. X is a set of strings. Instance: string s. If x X, x is a YES instance; if x X is a NO instance. Algorithm A solves problem X: A(s) = yes iff s X. Example. Does there exist a cut of size k? Self-reducibility. Search problem P, Cook decision version. Applies to all (NP-complete) problems in Chapter 8 of KT. Justifies our focus on decision problems. 9

Polynomial Transformation Def. Problem X poly-time reduces (Cook) to problem Y if arbitrary instances of problem X can be solved using: Polynomial number of standard computational steps, plus Polynomial number of calls to oracle that solves problem Y. Def. Problem X poly-time transforms (Karp) to problem Y if given any input x to X, we can construct an input y such that x is a yes instance of X iff y is a yes instance of Y. we require y to be of size polynomial in x Note. Poly-time transformation is poly-time reduction with just one call to oracle for Y, exactly at the end of the algorithm for X. Open question. Are these two concepts the same? Caution: KT abuses notation p and blurs distinction 10

Basic reduction strategies Basic reduction strategies Reduction by simple equivalence. Reduction from special case to general case. Reduction by encoding with gadgets. S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.11

Independent Set Given an undirected graph G, an independent set in G is a set of nodes, which includes at most one endpoint of every edge. INDEPENDENT SET = { G, k G is an undirected graph which has an independent set with k nodes} Is there an independent set of size 6? Yes. Is there an independent set of size 7? No. independent set S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.12

Vertex Cover Given an undirected graph G, a vertex cover in G is a set of nodes, which includes at least one endpoint of every edge. VERTEX COVER= { G, k G is an undirected graph which has a vertex cover with k nodes} Is there vertex cover of size 4? Yes. Is there a vertex cover of size 3? No. vertex cover S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.13

Independent Set and Vertex Cover Claim. S is an independent set iff V S is a vertex cover. Let S be any independent set. Consider an arbitrary edge (u, v). S is independent u S or v S u V S or v V S. Thus, V S covers (u, v). Let V S be any vertex cover. Consider two nodes u S and v S. Then (u, v) E since V S is a vertex cover. Thus, no two nodes in S are joined by an edge S independent set. S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.14

INDEPENDENT SET reduces to VERTEX COVER Theorem. INDEPENDENT-SET p VERTEX-COVER. Proof. On input G, k, where G is an undirected graph and k is an integer, 1. Output G, n k, where n is the number of nodes in G. Correctness: G has an independent set of size k iff it has a vertex cover of size n k. Reduction runs in linear time. S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.15

Reduction: special case to general case Basic reduction strategies Reduction by simple equivalence. Reduction from special case to general case. Reduction by encoding with gadgets. S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.16

Set Cover Given a set U, called a universe, and a collection of its subsets S 1, S 2,, S m, a set cover of U is a subcollection of subsets whose union is U. SET COVER={ U, S 1, S 2,, S m ; k U has a set cover of size k} Sample application. m available pieces of software. U = { 1, 2, 3, 4, 5, 6, 7 } k = 2 S 1 = {3, 7} S 4 = {2, 4} S 2 = {3, 4, 5, 6} S 5 = {5} S 3 = {1} S 6 = {1, 2, 6, 7} Set U of n capabilities that we would like our system to have. The ith piece of software provides the set S i U of capabilities. Goal: achieve all n capabilities using fewest pieces of software. S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.17

VERTEX COVER reduces to SET COVER Theorem. VERTEX-COVER P SET-COVER. Proof. On input G, k, where G = (V, E) is an undirected graph and k is an integer, 1. Output U, S 1, S 2,, S m ; k, where U=E and S v = {e E : e incident to v } Correctness: G has a vertex cover of size k iff U has a set cover of size k. Reduction runs in linear time. VERTEX COVER a b SET COVER k = 2 f e 7 e 1 e 2 e 3 e 6 e d e 4 e 5 c U = { 1, 2, 3, 4, 5, 6, 7 } k = 2 S a = {3, 7} S b = {2, 4} S c = {3, 4, 5, 6} S d = {5} S e = {1} S f = {1, 2, 6, 7} S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.18

Reduction by encoding with gadgets Basic reduction strategies Reduction by simple equivalence. Reduction from special case to general case. Reduction by encoding with gadgets. S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.19

Satisfiability Boolean variables: variables that can take on values T/F (or 1/0) Boolean operations:,, and Boolean formula: expression with Boolean variables and ops SAT = { Φ Φ is a satisfiable Boolean formula} Literal: A Boolean variable or its negation. Clause: OR of literals. x i or x i C j x 1 x 2 x 3 Conjunctive normal form (CNF): AND of clauses. 3SAT = { Φ Φ is a satisfiable Boolean CNF formula, where each clause contains exactly 3 literals} each corresponds to a different variable C 1 C 2 C 3 C 4 Ex: x 1 x 2 x 3 x 1 x 2 x 3 x 2 x 3 x 1 x 2 x 3 Yes: x 1 = true, x 2 = true x 3 = false. S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.20

3SAT reduces to INDEPENDENT SET Theorem. 3-SAT P INDEPENDENT-SET. Proof. On input Φ, where Φ is a 3CNF formula, 1. Construct graph G from Φ G contains 3 vertices for each clause, one for each literal. Connect 3 literals in a clause in a triangle. Connect literal to each of its negations. 2. Output G, k, where k is the number of clauses in Φ. x 1 x 2 x 1 G k = 3 x 2 x 3 x 1 x 2 x 3 x 1 x 2 x 3 x 1 x 2 x 4 x 1 x 3 S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.21 x 2 x 4

3SAT reduces to INDEPENDENT SET Correctness. Let k = # of clauses and l= # of literals in. is satisfiable iff G contains an independent set of size k. Given satisfying assignment, select one true literal from each triangle. This is an independent set of size k. Let S be an independent set of size k. S must contain exactly one vertex in each triangle. Set these literals to true, and other literals in a consistent way. Truth assignment is consistent and all clauses are satisfied. Run time. O(k + l 2 ), i.e. polynomial in the input size. S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.22

Summary Basic reduction strategies. Simple equivalence: INDEPENDENT-SET P VERTEX-COVER. Special case to general case: VERTEX-COVER P SET-COVER. Encoding with gadgets: 3-SAT P INDEPENDENT-SET. Transitivity.If X P Y and Y P Z, then X P Z. Proof idea. Compose the two algorithms. Ex: 3-SAT P INDEPENDENT-SET P VERTEX-COVER P SET-COVER. S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.23