Recap: P and NP"
Recap: P and NP"
•! Input: A graph G = (V, E)" •! Input: A graph G = (V, E) and an integer k > 0"
•! Question: Does G have a Hamiltonian path?" •! Q: Does G have a vertex cover of size # k?"
•! Definition: A Hamiltonian path of G is a path •! Definition: A vertex cover of G is a subset of V
that covers all vertices of G." that covers (i.e., “touches”) every edge in E."
•! To turn this into a language, define " •! To turn this into a language, define "
HAMPATH = {$G%: G is a graph" VC = {$G, k%: G is a graph that"
that has a Hamiltonian path}." has a vertex cover of size # k}.
Proof that HAMPATH # NP" Proof that VC # NP"
•! “On input $G%, where G = (V, E) is a graph:"
•! “On input $G, k%, where G = (V, E)… :"
1.! Let n = |V|."
1.! Guess a subset C = {v1, v2, …, vk} of V."
2.! Guess a permutation v1, v2, …, vn of V."
2.! For each edge {u,v} # E:"
3.! For i = 1 to (n-1):"
3.1. If u & C and v & C, then REJECT."
3.1. If {vi, vi+1} & E, then REJECT."
3.! ACCEPT.”"
4.! ACCEPT.”"
•! We’ve now seen several problems that are in NP Our P-time reductions will be mapping reductions!
but don’t seem to be in P: " Reduction A ! B will look like"
HAMPATH, VC, SAT, SUBSET-SUM" "“On input x:"
•! We shall see: if we could somehow solve one of " - Perform some computation to produce y = f(x)"
these problems in P-time, we could solve all of " - Output y”"
them in P-time."
•! How? Via P-time reductions." Essential property of f: "x # A ) f(x) # B"
–! i.e., reductions that run in polynomial time." The computation (i.e., f) “maps” A to B"
NP-completeness" What it means to be NP-complete"
•! A language L is said to be NP-complete if " •! Suppose we’ve proven (somehow) that a
1.! L # NP" language L is NP-complete."
2.! Every language in NP can be P-time reduced to L." •! This suggests that L can’t be decided in P-time."
–! Because, if L could be decided thus, then so could
•! In other words, the power to solve L gives us every problem in NP…"
the power to solve everything in NP!" –! …such as these one thousand problems that
–! Here “solve” means “solve in polynomial time.”" generations of brilliant computer scientists have been
unable to solve…"
•! In still other words, if L # P then P = NP." •! Suggests, but does not prove."