Sub topic 8
What It Means to Be NP-Hard
This chapter assumes you already know what the class NP is and what a polynomial-time many-one reduction is. It also assumes that, when we write A ≤p B, you read it as "A reduces to B in polynomial time."
The Definition
A problem H is NP-hard if every problem in NP reduces to H in polynomial time. In symbols: for every L in NP, L ≤p H.
The definition says nothing about whether H belongs to NP. It only says that H is at least as hard as everything in NP. A polynomial-time algorithm for H would give you one for every NP problem. To solve any L in NP, first map its instance to an instance of H, then run H's algorithm on the result.
Proving Hardness in Practice
Nobody proves NP-hardness by building a separate reduction from every NP problem. Reductions compose: if A ≤p B and B ≤p C, then A ≤p C. The reason is that running one polynomial-time map after another still takes polynomial time. So the usual recipe has two steps:
- Pick a problem K that is already known to be NP-hard.
- Build a polynomial-time reduction K ≤p H.
Every NP problem reduces to K, and K reduces to H, so every NP problem reduces to H. The process needs a first NP-hard problem to start from, and a later chapter covers where that first problem comes from.
NP-Hard Problems Outside NP
Some NP-hard problems are not in NP at all. Here are two common kinds:
| Problem | Why it is NP-hard | Why it is not in NP (or not known to be) |
|---|---|---|
| Halting problem | Any NP problem can be mapped to a program that halts exactly when a certificate exists | It is undecidable, so it is in no time-bounded class |
| TSP optimization ("output the shortest tour") | Solving it answers the TSP decision question | It is not a yes/no question, so NP membership does not apply |
The halting problem is NP-hard but cannot be solved at all. So "NP-hard" sets a lower bound on difficulty and no upper bound.
Common Errors
- Reversing the direction. To show H is hard, you reduce a known hard problem to H. Reducing H to a known hard problem only shows that H is no harder than that problem.
- Treating "NP" as "not polynomial." NP stands for nondeterministic polynomial time. P is a subset of NP. NP-hard does not mean "proven to need exponential time." No such lower bound is known for any NP-hard problem in NP.
- Assuming NP-hard means in NP. Membership in NP is a separate claim that needs its own proof, usually a polynomial-time verifier.
- Using a slow reduction. If the mapping takes exponential time, hardness does not carry over, because the composed algorithm is no longer polynomial.
Exercise
You show that your problem X can be solved by converting its instances to 3-SAT in polynomial time and calling a 3-SAT solver. Does this prove X is NP-hard?
Show answer
No. The argument shows X ≤p 3-SAT, which means X is no harder than 3-SAT. It places X in NP if the conversion is polynomial, but it says nothing about a lower bound. To prove X is NP-hard you need the reverse: a polynomial-time reduction from 3-SAT, or another known NP-hard problem, to X.
Exercise
Problem H is NP-hard, and someone finds an O(n^5) algorithm for H. What follows?
Show answer
Every problem in NP can then be solved in polynomial time: reduce it to H, then run the O(n^5) algorithm. So P = NP.