NPCompleteness Chuck Cusack Based on M Sipser Introduction
NP-Completeness Chuck Cusack Based on – M. Sipser, “Introduction to the Theory of Computation, ” Second Edition, Thomson/Course Technology, 2006, Chapter 7. 3 -7. 5.
Verifiers and Certificates • Definition: A verifier for a language A is an algorithm V, where A = { w | V accepts w, c for some string c} • c is called a certificate since it provides “proof” that the string w is in the language A. • Put more simply, a verifier is an algorithm that takes as input: – w, the string we want to prove is in the language A – c, the certificate that (supposedly) provides enough information to verify that w is indeed in the language A. • If V is a verifier, then for every string w in the language A, there has to exist some certificate c so that V accepts w, c. • An important but subtle point: The verifier does not have to use the certificate.
Example: CLIQUE • Let G be an undirected graph. • A k-clique in a graph is a subgraph of G which has k vertices all of which are connected. (That is, Kk is a subgraph of G) • Problem: CLIQUE = { G, k | G is an undirected graph with a k-clique} • How can we determine whether or not a graph has a k-clique? • This may not be clear right now, so we aren’t sure how to decide this problem (at least in polynomial time). • What piece of information can help us determine that G does indeed have a k-clique? • It is easy to see that if you give me a list of k vertices in G, I can very quickly verify that G has a k-clique.
Example: VERTEX-COVER • A vertex cover in an undirected graph G is a subset of the vertices such that every edge is adjacent to one of those vertices. • Problem: VERTEX-COVER = { G, k | G is an undirected graph that has a k-node vertex cover} • How can we determine whether or not a graph has a vertex cover with k nodes? • This may not be clear right now, so we aren’t sure how to decide this problem (at least in polynomial time). • What piece of information can help us determine that G does indeed have a vertex cover with k nodes? • If you give me a list of k vertices in G, I can very quickly verify that every edge is adjacent to one of those.
Background: Graph Pebbling • Given a graph, each vertex has 0 or more pebbles • If a vertex contains two or more pebbles, one pebble can be moved to any adjacent vertex, but another pebble is lost in the process. • A configuration of pebbles is solvable if it is possible to reach every vertex with a sequence of pebbling moves
Example: PEBBLING-NUMBER • Given a graph, what is the smallest number of pebbles needed to guarantee that no matter how they are placed it is solvable? • Problem: PEBBLING-NUMBER = { G, k | G is an undirected graph such that every configuration of k pebbles is solvable and some configuration with k-1 pebbles is unsolvable} • How can we determine whether or not the pebbling number of a graph is k? • This may not be clear right now, so we aren’t sure how to decide this problem (at least in polynomial time). • What piece of information can help us determine that the pebbling number of G does is k? • Unlike the previous examples, this is unclear, so we don’t know how to verify this problem.
Polynomial Time Verifiers and NP • Definition: A verifier is a polynomial time verifier if it runs in polynomial time in the length of w. • Definition: A language is a polynomially verifiable if it has a polynomial time verifier. • Definition: NP is the class of languages that have polynomial time verifiers • Theorem: A language is in NP iff it is decided by some polynomial time nondeterministic Turing machine. • Thus, NP stands for Nondeterministic Polynomial • NP does not stand for Non-Polynomial! • We will see why this is important shortly.
Problems in NP • Which of the following problems are in NP? Justify. – – – – – CLIQUE VERTEX-COVER HAMPATH RELPRIME COMPOSITES SAT and 3 SAT SUBSET-SUM PEBBLING-NUMBER In P • All but the last one are in NP • Recall: A language is in P iff it is decided by some polynomial time single-tape deterministic Turing machine. • Which of these problems are in P? • So are the others not in P?
P and NP • NP: – A language is NP iff it is decided by some polynomial time nondeterministic Turing machine. – Thus, NP is the set of languages which can be verified quickly. • P: – A language is in P iff it is decided by some polynomial time deterministic Turing machine. – Thus, P is the set of languages which can be decided quickly • What does this say about the relationship between P and NP? • P is a subset of NP: • Question: Is P=NP? P NP or P=NP
Is P = NP? • According to many, this question is the most important open question in theoretical computer science. • Why is this so important? • Is there a way to prove that P=NP? • Theorem 7. 27: SAT P iff P = NP. • In other words, if we can find a polynomial time algorithm to decide SAT, then we can find a polynomial time algorithm to decide every problem in NP! • In fact, there are hundreds (thousands? ) of problems for which the same thing has been shown, including CLIQUE, SUBSET-SUM, VERTEX-COVER, etc. • These problems are those in the class NP-Complete, which we will define shortly.
Polynomial Time Reducible • Definition: A function f: ∑*→ ∑* is a polynomial time computable function if some polynomial time TM M exists that halts with just f(w) on its tape for every input w. • Definition: A language A is polynomial time mapping reducible to language B if there is a polynomial time computable function f: ∑*→ ∑*, where for every string w, w A f(w) B • If A is polynomial time mapping reducible to B, we write A ≤p B. • The function f is called the polynomial-time reduction of A to B. • These are the same definitions you saw earlier with the added stipulation that they are polynomial time.
Reductions in Pictures All Strings A B
Reductions and P Thm 7. 31: If A ≤p B and B P, then A P. Proof: • You tell me.
NP-Complete—The most important slide • Definition: A language B is said to be NP-hard if for every A NP, A ≤p B. • So, to prove a problem B is NP-hard, you only have to show that every possible language in NP can be polynomial time reduced to B. • That seems impossible. Nonetheless, we continue: • Definition: A language B is said to be NP-complete if B NP and B NP-hard. • The big deal with NP-completeness? • Theorem 7. 35: If B is NP-complete and B P, then P = NP. • Thus a polynomial time algorithm to solve any problem in NP-complete leads to a polynomial time algorithm to solve every problem in NP!
Anything in NP-Complete? • Is it even possible to show any problems are in NPcomplete? • Recall, we have to show that every possible language in NP can be polynomial time reduced to B. • We don’t even know every possible language in NP, so how can we even begin to prove this? • Nonetheless, it can be done: • Theorem 7. 37: SAT is NP-complete. Proof ideas: (Very oversimplified) 1. Build a Boolean circuit that decides the language. That is, the circuit is satisfiable iff the input is in the language. 2. Given the NTM that decides the language, construct a Boolean formula based on the tape configurations, etc…
Being NP-complete • A student asked: – What does it mean for an NP problem’s “individual complexity” to “be related to that of the entire class”? (pg. 271) Does it mean all other problems in NP can be no more complex than that certain problem? • In this context, the author is talking about SAT being NP-Complete. • The answer is yes. • In general, a problem is X-Complete if it is in the set X and is (one of) the hardest problems in X.
Proving NP-Completeness • With lots of effort and some cleverness, one problem was shown to be in NP-Complete. • So, do we have to go to that much work every time? • Lucky for us, the answer here is “no”. • Theorem 7. 36: If C NP and there is some B NP-complete such that B ≤p C, then C is NP-complete. • Proof: Can you prove this? • Thus, to prove that C is NP-complete, you just need to find a polynomial time reduction from any problem in NP-complete. • We demonstrate with a diagram…
A Reduction Diagram NP-Problem 1 NP-Problem 2 NP-Problem 3 … SAT 3 SAT VERTEX-COVER HAMPATH UHAMPATH CLIQUE SUBSET-SUM
Important Note about Proving NP-Completeness • To prove that C is NP-Complete, you need to find an NPComplete problem B and map from B to C, not the other way around! • That is, map from the known problem to your problem. • You have to prove that your mapping is – A reduction (What does that mean again? ) – Can be done in polynomial time (Why does this matter? ) • How do you prove a mapping is a reduction? – Show that if a B, then f(a) C; and – Show one of the following: • • If a B, then f(a) C; OR If f(a) C, then a B. (Notice that this is not showing that if y C then f-1(y) B)
- Slides: 19