P and NP (Millenium problem)

Similar documents
Introduction to Algorithms

NP-Completeness. Algorithms

NP-Complete Reductions 2

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

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

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

NP-complete Reductions

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

Computability Theory

8 NP-complete problem Hard problems: demo

8.1 Polynomial-Time Reductions

Complexity Classes and Polynomial-time Reductions

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

Chapter 10 Part 1: Reduction

8.1 Polynomial-Time Reductions

P = NP; P NP. Intuition of the reduction idea:

CSCE750 Analysis of Algorithms Fall 2017 NP-Complete Problems

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

6.006 Introduction to Algorithms. Lecture 25: Complexity Prof. Erik Demaine

W4231: Analysis of Algorithms

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

1 Definition of Reduction

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

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

Where Can We Draw The Line?

Steven Skiena. skiena

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

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

Introduction to Algorithms. Lecture 24. Prof. Patrick Jaillet

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

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

Solutions for the Exam 6 January 2014

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

Some Hardness Proofs

NP-Complete Problems

Chapter 8. NP-complete problems

PCP and Hardness of Approximation

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

9.1 Cook-Levin Theorem

CMPSCI611: The SUBSET-SUM Problem Lecture 18

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

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

4.1 Review - the DPLL procedure

Partha Sarathi Mandal

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

Recitation 4: Elimination algorithm, reconstituted graph, triangulation

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

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

Reductions and Satisfiability

NP and computational intractability. Kleinberg and Tardos, chapter 8

Module 6 NP-Complete Problems and Heuristics

Chapter 9 Graph Algorithms

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

Chapter 9 Graph Algorithms

Lecture 7: Counting classes

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Algorithms For Inference Fall 2014

Chapter 9 Graph Algorithms

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

Approximation Algorithms

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

The k-center problem Approximation Algorithms 2009 Petros Potikas

Module 6 NP-Complete Problems and Heuristics

Ch9: Exact Inference: Variable Elimination. Shimi Salant, Barak Sternberg

W[1]-hardness. Dániel Marx. Recent Advances in Parameterized Complexity Tel Aviv, Israel, December 3, 2017

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

Nondeterministic Polynomial Time

The complement of PATH is in NL

CS 125 Section #10 Midterm 2 Review 11/5/14

Introduction to Algorithms

Questions? You are given the complete graph of Facebook. What questions would you ask? (What questions could we hope to answer?)

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

Theorem 2.9: nearest addition algorithm

Approximation slides 1. An optimal polynomial algorithm for the Vertex Cover and matching in Bipartite graphs

Exercises Computational Complexity

Boolean Functions (Formulas) and Propositional Logic

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

Greedy algorithms Or Do the right thing

Copyright 2000, Kevin Wayne 1

Fixed Parameter Algorithms

COMP260 Spring 2014 Notes: February 4th

W[1]-hardness. Dániel Marx 1. Hungarian Academy of Sciences (MTA SZTAKI) Budapest, Hungary

Fixed-Parameter Algorithm for 2-CNF Deletion Problem

Sorting. CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk

Module 6 NP-Complete Problems and Heuristics

Examples of P vs NP: More Problems

Lecture 21: Other Reductions Steven Skiena

SAT-CNF Is N P-complete

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

P vs. NP. Simpsons: Treehouse of Horror VI

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

Vertex Cover Approximations

arxiv: v2 [cs.cc] 29 Mar 2010

Parameterized Reductions

Reductions. designing algorithms establishing lower bounds establishing intractability classifying problems. Bird s-eye view

6,8:15. MA/CSSE 473 Day 37. Student Questions. Kruskal data structures. Disjoint Set ADT. Complexity intro

APPROXIMATION ALGORITHMS FOR GEOMETRIC PROBLEMS

Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost

CS521 \ Notes for the Final Exam

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

Transcription:

CMPS 2200 Fall 2017 P and NP (Millenium problem) Carola Wenk Slides courtesy of Piotr Indyk with additions by Carola Wenk CMPS 2200 Introduction to Algorithms 1

We have seen so far Algorithms for various problems Running times O(nm 2 ),O(n 2 ),O(n log n), O(n), etc. I.e., polynomial in the input size Can we solve all (or most of) interesting problems in polynomial time? Not really CMPS 2200 Introduction to Algorithms 2

Example difficult problem Traveling Salesperson Problem (TSP; optimization variant) Input: Undirected graph with weights on edges Output: Shortest tour that visits each vertex exactly once Best known algorithm: O(n 2 n ) time. 5 10 8 9 6 4 2 9 11 5 7 3 CMPS 2200 Introduction to Algorithms 3

Another difficult problem Clique (optimization variant): Input: Undirected graph G=(V,E) Output: Largest subset C of V such that every pair of vertices in C has an edge between them (C is called a clique) Best known algorithm: O(n 2 n ) time CMPS 2200 Introduction to Algorithms 4

What can we do? Spend more time designing algorithms for those problems People tried for a few decades, no luck Prove there is no polynomial time algorithm for those problems Would be great Seems really difficult Best lower bounds for natural problems: (n 2 ) for restricted computational models 4.5n for unrestricted computational models CMPS 2200 Introduction to Algorithms 5

What else can we do? Show that those hard problems are essentially equivalent. I.e., if we can solve one of them in polynomial time, then all others can be solved in polynomial time as well. Works for at least 10 000 hard problems CMPS 2200 Introduction to Algorithms 6

The benefits of equivalence Combines research efforts If one problem has a polynomial time solution, then all of them do More realistically: Once an exponential lower bound is shown for one problem, it holds for all of them P1 P3 P2 CMPS 2200 Introduction to Algorithms 7

Summing up If we show that a problem is equivalent to ten thousand other well studied problems without efficient algorithms, then we get a very strong evidence that is hard. We need to: 1. Identify the class of problems of interest Decision problems, NP 2. Define the notion of equivalence Polynomial-time reductions 3. Prove the equivalence(s) CMPS 2200 Introduction to Algorithms 8

Decision Problem Decision problems: answer YES or NO. Example: Search Problem Search Given an unsorted set S of n numbers and a number key, is key contained in S? Input is x=(s,key) Possible algorithms that solve Search (x) : A 1 (x): Linear search algorithm. O(n) time A 2 (x): Sort the array and then perform binary search. O(n log n) time A 3 (x): Compute all possible subsets of S (2 n many) and check each subset if it contains key. O(n2 n ) time. CMPS 2200 Introduction to Algorithms 9

Decision problem vs. optimization problem 3 variants of Clique: 1. Input: Undirected graph G=(V,E), and an integer k 0. Output: Does G contain a clique C such that C k? 2. Input: Undirected graph G=(V,E) Output: Largest integer k such that G contains a clique C with C =k. 3. Input: Undirected graph G=(V,E) Output: Largest clique C of V. 3. is harder than 2. is harder than 1. So, if we reason about the decision problem (1.), and can show that it is hard, then the others are hard as well. Also, every algorithm for 3. can solve 2. and 1. as well. CMPS 2200 Introduction to Algorithms 10

Decision problem vs. optimization problem (cont.) Theorem: a) If 1. can be solved in polynomial time, then 2. can be solved in polynomial time. b) If 2. can be solved in polynomial time, then 3. can be solved in polynomial time. Proof: a) Run 1. for values k = 1... n. Instead of linear search one could also do binary search. b) Run 2. to find the size k opt of a largest clique in G. Now check one edge after the other. Remove one edge from G, compute the new size of the largest clique in this new graph. If it is still k opt then this edge is not necessary for a clique. If it is less than k opt then it is part of the clique. CMPS 2200 Introduction to Algorithms 11

Class of problems: NP Decision problems: answer YES or NO. E.g., is there a tour of length K? Solvable in non-deterministic polynomial time: Intuitively: the solution can be verified in polynomial time E.g., if someone gives us a tour T, we can verify in polynomial time if T is a tour of length K. Therefore, the decision variant of TSP is in NP. CMPS 2200 Introduction to Algorithms 12

Formal definitions of P and NP A decision problem is solvable in polynomial time (or P), if there is a polynomial time algorithm A(.) such that for any input x: (x)=yes iff A(x)=YES A decision problem is solvable in nondeterministic polynomial time (or NP), if there is a polynomial time algorithm A(.,.) such that for any input x: (x)=yes iff there exists a certificate y of size poly( x ) such that A(x,y)=YES CMPS 2200 Introduction to Algorithms 13

Examples of problems in NP Is Does there exist a clique in G of size K in NP? Yes: A(x,y) interprets x as (G,K), y as a set C, and checks if all vertices in C are adjacent and if C K Is Sorting in NP? No, not a decision problem. Is Sortedness in NP? Yes: ignore y, and check if the input x is sorted. CMPS 2200 Introduction to Algorithms 14

Summing up If we show that a problem is equivalent to ten thousand other well studied problems without efficient algorithms, then we get a very strong evidence that is hard. We need to: 1. Identify the class of problems of interest Decision problems, NP 2. Define the notion of equivalence Polynomial-time reductions 3. Prove the equivalence(s) CMPS 2200 Introduction to Algorithms 15

: Reduce to x A for YES NO x A for YES NO CMPS 2200 Introduction to Algorithms 16

: Reduce to f f(x )= x A for YES NO x A for YES NO CMPS 2200 Introduction to Algorithms 17

Reductions is polynomial time reducible to ( ) iff 1. there is a polynomial time function f that maps inputs x for into inputs x for, 2. such that for any x : (x )= (f(x )) (or in other words (x )=YES iff (f(x )=YES) CMPS 2200 Introduction to Algorithms 18

Clique again Clique (decision variant): Input: Undirected graph G=(V,E), and an integer K 0 Output: Is there a clique C, i.e., a subset C of V such that every pair of vertices in C has an edge between them, such that C K? CMPS 2200 Introduction to Algorithms 19

Independent Set (IS) Independent Set (decision variant): Input: Undirected graph G=(V,E), and an integer K 0 Output: Is there a subset S of V, S K such that no pair of vertices in S has an edge between them? (S is called an independent set) CMPS 2200 Introduction to Algorithms 20

Clique IS =IS =clique x Given an input G=(V,E), K to Clique, need to construct an input G =(V,E ), K to IS, f(x )=x such that G has clique of size K iff G has IS of size K. Construction: K =K,V =V,E =E Reason: C is a clique in G iff it is an IS in G s complement. CMPS 2200 Introduction to Algorithms 21

Clique IS =IS =clique x Given an input G=(V,E), K to Clique, need to construct an input G =(V,E ), K to IS, f(x )=x such that G has clique of size K iff G has IS of size K. Construction: K =K,V =V,E =E Reason: C is a clique in G iff it is an IS in G s complement. clique IS CMPS 2200 Introduction to Algorithms 22

Reductions is polynomial time reducible to ( ) iff 1. there is a polynomial time function f that maps inputs x for into inputs x for, 2. such that for any x : (x )= (f(x )) (or in other words (x )=YES iff (f(x )=YES) Fact 1: if P and then P Fact 2: if NP and then NP Fact 3 (transitivity): if and then CMPS 2200 Introduction to Algorithms 23

Recap We defined a large class of interesting problems, namely NP We have a way of saying that one problem is not harder than another ( ) Our goal: show equivalence between hard problems CMPS 2200 Introduction to Algorithms 24

Showing equivalence between difficult problems Options: Show reductions between all pairs of problems Reduce the number of reductions using transitivity of TSP P3 Clique P4 P5 CMPS 2200 Introduction to Algorithms 25

Showing equivalence between difficult problems Options: Show reductions between all pairs of problems Reduce the number of reductions using transitivity of Show that all problems in NP are reducible to a fixed. To show that some problem NP is equivalent to all difficult problems, we only show. TSP P3 Clique P4 P5 CMPS 2200 Introduction to Algorithms 26

The first problem Satisfiability problem (SAT): Given: a formula φ with m clauses over n variables, e.g., x 1 v x 2 v x 5, x 3 v x 5 Check if there exists TRUE/FALSE assignments to the variables that makes the formula satisfiable CMPS 2200 Introduction to Algorithms 27

SAT is NP-complete Fact: SAT NP Theorem [Cook 71]: For any NP, we have SAT. Definition: A problem such that for any NP we have, is called NP-hard Definition: An NP-hard problem that belongs to NP is called NP-complete Corollary: SAT is NP-complete. CMPS 2200 Introduction to Algorithms 28

Plan of attack: Show that the problems below are in NP, and show a sequence of reductions: SAT Clique Independent set Vertex cover (thanks, Steve ) Follow from Cook s Theorem Conclusion: all of the above problems are NP-complete CMPS 2200 Introduction to Algorithms 29

Clique again Clique (decision variant): Input: Undirected graph G=(V,E), and an integer K 0 Output: Is there a clique C, i.e., a subset C of V such that every pair of vertices in C has an edge between them, such that C K? CMPS 2200 Introduction to Algorithms 30

SAT Clique Given a SAT formula φ=c 1,,C m over x 1,,x n, we need to produce G=(V,E) and K, f(x )=x such that φ satisfiable iff G has a clique of size K. Notation: a literal is either x i or x i x CMPS 2200 Introduction to Algorithms 31

SAT Clique reduction For each literal t occurring in φ, create a vertex v t Create an edge v t v t iff: t and t are not in the same clause, and t is not the negation of t CMPS 2200 Introduction to Algorithms 32

SAT Clique example Edge v t v t t and t are not in the same clause, and t is not the negation of t Formula: x 1 v x 2 v x 3, x 2 v x 3, x 1 v x 2 Graph: x 2 x 1 x 3 x 2 x 3 x 1 x 2 Claim: φ satisfiable iff G has a clique of size m CMPS 2200 Introduction to Algorithms 33

Proof Edge v t v t part of Claim: t and t are not in the same clause, and t is not the negation of t Take any assignment that satisfies φ. E.g., x 1 =F, x 2 =T, x 3 =F Let the set C contain one satisfied literal per clause C is a clique x 3 x 2 x 1 x 2 x 3 x 1 x 2 CMPS 2200 Introduction to Algorithms 34

Proof Edge v t v t t and t are not in the same clause, and t is not the negation of t part of Claim: Take any clique C of size m (i.e., = m) Create a set of equations that satisfies selected literals. E.g., x 3 =T, x 2 =F, x 1 =F The set of equations is consistent and the solution satisfies φ x 3 x 2 x 1 x 2 x 3 x 1 x 2 CMPS 2200 Introduction to Algorithms 35

Altogether We constructed a reduction that maps: YES inputs to SAT to YES inputs to Clique NO inputs to SAT to NO inputs to Clique The reduction works in polynomial time Therefore, SAT Clique Clique NP-hard Clique is in NP Clique is NP-complete CMPS 2200 Introduction to Algorithms 36

Vertex cover (VC) Input: undirected graph G=(V,E), and K 0 Output: is there a subset C of V, C K, such that each edge in E is incident to at least one vertex in C. CMPS 2200 Introduction to Algorithms 37

IS VC x Given an input G=(V,E), K to IS, need to construct an input G =(V,E ), K to VC, such that f(x )=x G has an IS of size K iff G has VC of size K. Construction: V =V, E =E, K = V -K Reason: S is an IS in G iff V-S is a VC in G. CMPS 2200 Introduction to Algorithms 38