NP-Completeness Yin Tat Lee

Slides:



Advertisements
Similar presentations
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
Advertisements

The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 22 Instructor: Paul Beame.
Clique Cover Cook’s Theorem 3SAT and Independent Set
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Lecture 22 More NPC problems
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
1 Computational Complexity Classify problems according to the amount of computational resources used by the best algorithms that solve them Recall: worst-case.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 29.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
28.
CSE 6311 – Spring 2009 ADVANCED COMPUTATIONAL MODELS AND ALGORITHMS Lecture Notes – Feb. 3, 2009 Instructor: Dr. Gautam Das notes by Walter Wilson.
NPC.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
Given this 3-SAT problem: (x1 or x2 or x3) AND (¬x1 or ¬x2 or ¬x2) AND (¬x3 or ¬x1 or x2) 1. Draw the graph that you would use if you want to solve this.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Theory of NP-Completeness
The NP class. NP-completeness
P & NP.
Chapter 10 NP-Complete Problems.
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Polynomial-Time Reduction
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
Richard Anderson Lecture 26 NP-Completeness
NP-Completeness (36.4-5) P: yes and no in pt NP: yes in pt NPH  NPC
CS21 Decidability and Tractability
Intro to Theory of Computation
Intro to Theory of Computation
CS154, Lecture 16: More NP-Complete Problems; PCPs
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
Chapter 34: NP-Completeness
Chapter 8 NP and Computational Intractability
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
CS 3343: Analysis of Algorithms
NP-Completeness Yin Tat Lee
CSE 6408 Advanced Algorithms.
P, NP and NP-Complete Problems
NP-Completeness Yin Tat Lee
The Theory of NP-Completeness
CS154, Lecture 16: More NP-Complete Problems; PCPs
CSE 589 Applied Algorithms Spring 1999
P, NP and NP-Complete Problems
Richard Anderson Lecture 25 NP Completeness
Instructor: Aaron Roth
Our old list of problems
RAIK 283 Data Structures & Algorithms
CHAPTER 7 Time complexity
Lecture 23 NP-Hard Problems
Presentation transcript:

NP-Completeness Yin Tat Lee CSE 421 NP-Completeness Yin Tat Lee

Computational Complexity Goal: Classify problems according to the amount of computational resources used by the best algorithms that solve them Here we focus on time complexity Recall: worst-case running time of an algorithm max # steps algorithm takes on any input of size n

Relative Complexity of Problems Want a notion that allows us to compare the complexity of problems Want to be able to make statements of the form “If we could solve problem B in polynomial time then we can solve problem A in polynomial time” “Problem B is at least as hard as problem A”

Polynomial Time Reduction Def A P B: if there is an algorithm for problem A using a ‘black box’ (subroutine) that solve problem B s.t., Algorithm uses only a polynomial number of steps Makes only a polynomial number of calls to a subroutine for B So, Conversely, In words, B is as hard as A (it can be even harder) B is Polynomial time solvable A is Polynomial No efficient Algorithm for A Algorithm for B

≤ 𝑝 1 Reductions Here, we often use a restricted form of polynomial-time reduction often called Karp reduction. 𝐴 ≤ 𝑝 1 𝐵: if and only if there is an algorithm for A given a black box solving B that on input x Runs for polynomial time computing an input f(x) of B Makes one call to the black box for B for input f(x) Returns the answer that the black box gave We say that the function f(.) is the reduction

Example 1: Indep Set ≤ 𝑝 Clique Indep Set: Given G=(V,E) and an integer k, is there 𝑆⊆𝑉 s.t. 𝑆 ≥𝑘 and no two vertices in S are joined by an edge? Clique: Given a graph G=(V,E) and an integer k, is there 𝑆⊆𝑉, |U|  k s.t., every pair of vertices in S is joined by an edge? Claim: Indep Set ≤ 𝑝 Clique Pf: Given 𝐺=(𝑉,𝐸) and instance of indep Set. Construct a new graph 𝐺 ′ =(𝑉, 𝐸 ′ ) where 𝑢,𝑣 ∈𝐸′ if and only if 𝑢,𝑣 ∉𝐸. 1 2 3 4 5 1 2 3 4 5 S is an indep set in G S is an Clique in G’

Example 2: Vertex Cover ≤ 𝑝 Indep Set Vertex Cover: Given a graph G=(V,E) and an integer k, is there a vertex cover of size at most k? Claim: For any graph 𝐺= 𝑉,𝐸 , S is an independent set iff 𝑉−𝑆 is a vertex cover Pf: => Let S be a independent set of G Then, 𝑆 has at most one endpoint of every edge of G So, 𝑉−𝑆 has at least one endpoint of every edge of G So, 𝑉−𝑆 is a vertex cover. <= Suppose 𝑉−𝑆 is a vertex cover Then, there is no edge between vertices of S (otherwise, 𝑉−𝑆 is not a vertex cover) So, 𝑆 is an independent set.

Example 3: Vertex Cover ≤ 𝑝 Set Cover Set Cover: Given a set U, collection of subsets 𝑆 1 ,…, 𝑆 𝑚 of U and an integer k, is there a collection of k sets that contain all elements of U? Claim: Vertex Cover ≤ 𝑝 Set Cover Pf: Given (𝐺= 𝑉,𝐸 ,𝑘) of vertex cover we construct a set cover input 𝑓(𝐺,𝑘) 𝑈=𝐸 For each 𝑣∈𝑉 we create a set 𝑆 𝑣 of all edges connected to 𝑣 This clearly is a polynomial-time reduction So, we need to prove it gives the right answer

Example 3: Vertex Cover ≤ 𝑝 Set Cover Claim: Vertex Cover ≤ 𝑝 Set Cover Pf: Given (𝐺= 𝑉,𝐸 ,𝑘) of vertex cover we construct a set cover input 𝑓(𝐺,𝑘) 𝑈=𝐸 For each 𝑣∈𝑉 we create a set 𝑆 𝑣 of all edges connected to 𝑣 Vertex-Cover (G,k) is yes => Set-Cover f(G,k) is yes If a set 𝑊⊆𝑉 covers all edges,, just choose 𝑆 𝑣 for all 𝑣∈𝑊, it covers all 𝑈. Set-Cover f(G,k) is yes => Vertex-Cover (G,k) is yes If ( 𝑆 𝑣 1 ,…, 𝑆 𝑣 𝑘 ) covers all 𝑈, the set { 𝑣 1 ,…, 𝑣 𝑘 } covers all edges of G.

Decision Problems A decision problem is a computational problem where the answer is just yes/no Here, we study computational complexity of decision Problems. Why? Simpler to deal with Decision version is not harder than Search version, so it gives a lower bound for Decision version usually, you can use decider multiple times to find an answer.

Polynomial Time Define P (polynomial-time) to be the set of all decision problems solvable by algorithms whose worst-case running time is bounded by some polynomial in the input size. Do we well understand P? We can prove that a problem is in P by exhibiting a polynomial time algorithm It is in most cases very hard to prove a problem is not in P.

Beyond P? We have seen many problems that seem hard Independent Set 3-coloring Vertex Cover 3-SAT Given a 3-CNF 𝑥 1 ∨ 𝑥 2 ∨ 𝑥 9 ∧ 𝑥 2 ∨ 𝑥 3 ∨ 𝑥 7 ∧… is there a satisfying assignment? Common Property: If the answer is yes, there is a “short” proof (a.k.a., certificate), that allows you to verify (in polynomial-time) that the answer is yes. The proof may be hard to find The independent set S The 3-coloring The vertex cover S The T/F assignment conjunctive normal form (CNF)

NP Certifier: Algorithm C(x, t) is a certifier for problem A if for every string x, the answer is “yes” iff there exists a string t such that C(x, t) = yes. Intuition: Certifier doesn't determine whether answer is “yes” on its own; rather, it checks a proposed proof t that answer is “yes”. NP: Set of all decision problems for which there exists a poly-time certifier. Remark. NP stands for nondeterministic polynomial-time.

Example: 3SAT is in NP Given a 3-CNF formula, is there a satisfying assignment? Certificate: An assignment of truth values to the n boolean variables. Verifier: Check that each clause has at least one true literal. Ex: 𝑥 1 ∨ 𝑥 3 ∨ 𝑥 4 ∧ 𝑥 2 ∨ 𝑥 4 ∨ 𝑥 3 ∧( 𝑥 2 ∨ 𝑥 1 ∨ 𝑥 3 ) Certificate: 𝑥 1 =𝑇, 𝑥 2 =𝐹, 𝑥 3 =𝑇, 𝑥 4 =𝐹 Conclusion: 3-SAT is in NP Conclusion. 3SAT is in NP.

What do we know about NP? Nobody knows if all problems in NP can be done in polynomial time, i.e. does P=NP? one of the most important open questions in all of science. Huge practical implications specially if answer is yes Every problem in P is in NP one doesn’t even need a certificate for problems in P so just ignore any hint you are given Every problem in NP is in exponential time Some problems in NP seem really hard nobody knows how to prove that they are really hard to solve, i.e. 𝑃≠𝑁𝑃

NP Completeness Complexity Theorists Approach: We don’t know how to prove any problem in NP is hard. So, let’s find hardest problems in NP. NP-hard: A problem B is NP-hard iff for any problem 𝐴∈𝑁𝑃, we have 𝐴 ≤ 𝑝 𝐵 NP-Completeness: A problem B is NP-complete iff B is NP-hard and 𝐵∈𝑁𝑃. Motivations: If 𝑃≠𝑁𝑃, then every NP-Complete problems is not in P. So, we shouldn’t try to design Polytime algorithms To show 𝑃=𝑁𝑃, it is enough to design a polynomial time algorithm for just one NP-complete problem.

3-SAT ≤ 𝑝 Independent Set ≤ 𝑝 Vertex Cover ≤ 𝑝 Set Cover Cook-Levin Theorem Theorem (Cook 71, Levin 73): 3-SAT is NP-complete, i.e., for all problems 𝐴∈𝑁𝑃, 𝐴 ≤ 𝑝 3-SAT. (See CSE 431 for the proof) So, 3-SAT is the hardest problem in NP. What does this say about other problems of interest? Like Independent set, Vertex Cover, … Fact: If 𝐴 ≤ 𝑝 𝐵 and 𝐵 ≤ 𝑝 𝐶 then, 𝐴 ≤ 𝑝 𝐶 Pf idea: Just compose the reductions from A to B and B to C So, if we prove 3-SAT ≤ 𝑝 Independent set, then Independent Set, Clique, Vertex cover, Set cover are all NP-complete 3-SAT ≤ 𝑝 Independent Set ≤ 𝑝 Vertex Cover ≤ 𝑝 Set Cover

3-SAT ≤ 𝑝 Independent Set Map a 3-CNF to (G,k). Say m is number of clauses Create a vertex for each literal Joint two literals if They belong to the same clause (blue edges) The literals are negations, e.g., 𝑥 𝑖 , 𝑥 𝑖 (red edges) Set k be the # of clauses. 𝑥 1 ∨ 𝑥 3 ∨𝑥4 ∧ 𝑥 2 ∨ 𝑥 4 ∨𝑥3 ∧ 𝑥 2 ∨ 𝑥 1 ∨𝑥3 𝑥 1 𝑥 2 𝑥 2 Polynomial-Time Reduction 𝑥 3 𝑥 4 𝑥 1 𝑥 4 𝑥 3 𝑥 3

Correctness of 3-SAT ≤ 𝑝 Indep Set F satisfiable => An independent of size k Given a satisfying assignment, Choose one node from each clause where the literal is satisfied 𝑥 1 ∨ 𝑥 3 ∨ 𝑥 4 ∧ 𝑥 2 ∨ 𝑥 4 ∨ 𝑥 3 ∧ 𝑥 2 ∨ 𝑥 1 ∨ 𝑥 3 Satisfying assignment: 𝑥 1 =𝑇, 𝑥 2 =𝐹, 𝑥 3 =𝑇, 𝑥 4 =𝐹 S has exactly one node per clause => No blue edges between S S follows a truth-assignment => No red edges between S S has one node per clause => |S|=k 𝑥 1 𝑥 2 𝑥 2 𝑥 3 𝑥 4 𝑥 1 𝑥 4 𝑥 3 𝑥 3

Correctness of 3-SAT ≤ 𝑝 Indep Set An independent set of size k => A satisfying assignment Given an independent set S of size k. S has exactly one vertex per clause (because of blue edges) S does not have 𝑥 𝑖 , 𝑥 𝑖 (because of red edges) So, S gives a satisfying assignment Satisfying assignment: 𝑥 1 =𝐹, 𝑥 2 =?, 𝑥 3 =𝑇, 𝑥 4 =𝑇 𝑥 1 ∨ 𝑥 3 ∨ 𝑥 4 ∧ 𝑥 2 ∨ 𝑥 4 ∨ 𝑥 3 ∧ 𝑥 2 ∨ 𝑥 1 ∨ 𝑥 3 𝑥 1 𝑥 3 𝑥 4 𝑥 2

Summary If a problem is NP-hard it does not mean that all instances are hared, e.g., Vertex-cover has a polynomial-time algorithm in trees We learned the crucial idea of polynomial-time reduction. This can be even used in algorithm design, e.g., we know how to solve max-flow so we reduce image segmentation to max-flow NP-Complete problems are the hardest problem in NP NP-hard problems may not necessarily belong to NP. Polynomial-time reductions are transitive relations