HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Why is NP-hard not necessarily NP?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
necessarilywhynothard

Problem

A problem X is NP-hard if every problem in NP can be reduced to X. But every problem in NP has a polynomial time verification algorithm, so then does that not mean that I can also verify X in polynomial time because every NP problem is reducible to X? Can someone please explain or give an example.

Solution

Here is an abstract definition of the concepts NP-hard and NP-complete. If $A,B$ are two decision problems, say that $A \leq B$ if there is a polytime reduction from $A$ to $B$, that is, if there exists a polytime function $f$ such that $x \in A$ iff $f(x) \in B$. Then:
$$
\begin{align*}
&\mathsf{NP\text{-}hard} = \{ B : A \leq B \text{ for all } A \in \mathsf{NP} \}, \\
&\mathsf{NP\text{-}complete} = \mathsf{NP\text{-}hard} \cap \mathsf{NP}.
\end{align*}
$$

Here is a different example. Consider the universe of all subsets of $\mathbb{N}$, ordered under $A \leq B$ if $A \subseteq B$. Let $\mathsf{X}$ consist of all subsets of some fixed set $X$. Define $\mathsf{X\text{-}hard}$ and $\mathsf{X\text{-}complete}$ just as above. You can check that
$$
\begin{align*}
&\mathsf{X\text{-}hard} = \{ S : S \supseteq X \}, \\
&\mathsf{X\text{-}complete} = \{ X \}.
\end{align*}
$$
In a similar way, NP-hardness is a lower bound on the difficulty, whereas NP-completeness is both a lower bound and an upper bound. In contrast to the second example above, there are many NP-complete problems, all of them having the same level of difficulty (two problems $A,B$ have the same level of difficulty if $A \leq B \leq A$).

Finally, here is a concrete problem which is NP-hard but not NP-complete: the halting problem.

The halting problem is NP-hard. Let $A$ be any computable decision problem, say computed by a Turing machine $M$ which always halts. Let $M'$ be the Turing machine which simulates $M$, halts if $M$ accepts, and runs into an infinite loop if $M$ rejects. Define a polytime function $f$ by $f(x) = (\langle M' \rangle,x)$. Then $x \in A$ iff $M$ accepts $x$ iff $M'$ halts on $x$ iff $f(x) \in \mathsf{HALT}$.

The halting problem is not in NP. The halting problem is not computable, and in particular not in NP.

Context

StackExchange Computer Science Q#75722, answer score: 7

Revisions (0)

No revisions yet.