4.6.27 · D4Theory of Computation

Exercises — NP-hard — harder than NP, may not be in NP

2,773 words13 min readBack to topic

Before we start, fix the vocabulary in one picture. The figure below draws NP as the blue oval (problems with a short certificate), NP-hard as the pink dashed region stretching off to the right and upward (the floor of difficulty — reduction arrows point into it), and their overlap as NP-complete (yellow). Notice SAT sits in the yellow overlap, while HALT and optimization-TSP are drawn as dots outside the blue oval but still inside the pink region — that is the entire point of this page: NP-hard reaches beyond NP.

Figure — NP-hard — harder than NP, may not be in NP
Recall The three words you must never confuse
  • In NP = a yes/no problem with a short certificate you can check fast (the blue oval).
  • NP-hard = everything in NP reduces into you (the pink floor); reduction arrows point toward you.
  • NP-complete = both at once (the yellow overlap). Reduction direction ::: To prove hard you show known-hard (arrow into ), never known-hard.

Level 1 — Recognition

Recall Solution L1.1

a) TRUE. NP-complete NP-hard in NP, so the NP-hard part is included by definition. b) FALSE. NP-hardness is only a lower bound; it never forces membership. (Halting Problem is the counterexample.) c) TRUE. The why: you take a known NP-hard problem (3-SAT) and build, in poly time, a machine that halts iff is satisfiable — giving . Because 3-SAT is NP-hard, transitivity makes HALT NP-hard too. (The full construction of that machine is exercise L4.1; here we only assert it exists.) d) TRUE. This is literally the definition of NP-complete.

Recall Solution L1.2

(i) Eligible — yes/no answer, certificate = the cycle. (ii) Ineligible — it outputs a number, not a yes/no. (Optimization; can still be NP-hard.) (iii) Eligible — yes/no, certificate = the assignment. (iv) Ineligible — it outputs a count, not a yes/no. (Counting problem, class #P.)

Rule of thumb: if the answer is a bit (yes/no), it can live in NP; if the answer is a number, it cannot — see Decision vs Optimization problems.


Level 2 — Application

Recall Solution L2.1

A reduction means: a fast solver for 3-SAT gives a fast solver for . That shows is no harder than 3-SAT — informally it hints might be in NP, the opposite of hardness. To prove is NP-hard you need the arrow the other way: i.e. a fast solver for gives a fast solver for 3-SAT. Then, since 3-SAT is NP-hard, transitivity gives for every NP, so is NP-hard.

Recall Solution L2.2

Take any NP. Because 3-SAT is NP-hard, . Chain the reductions: Transitivity of (proved in the parent) collapses this chain to . Since was arbitrary in NP, every NP problem reduces to VERTEX-COVER, so VERTEX-COVER is NP-hard.

Note we only ever built one new reduction (); the rest is bookkeeping.

Recall Solution L2.3

Step 1 — run : time , and output size (can't write more symbols than time steps). Step 2 — run on that output of size : time . Total: — a polynomial. So is a valid poly-time reduction. This is why "polynomial composed with polynomial is polynomial" matters.


Level 3 — Analysis

Recall Solution L3.1

(a) NP-hard. Decision-TSP ("is there a tour of length ?") is NP-complete, hence NP-hard. Suppose you had a fast solver for optimization-TSP that returns the minimum tour length . Then to answer decision-TSP with bound : run , and answer yes iff . That is a poly-time reduction . Since decision-TSP is NP-hard, so is optimization-TSP. (b) Not in NP. NP is a class of decision (yes/no) languages. Optimization-TSP outputs a number, so it is not even the right type of object — there is no single bit answer to certify. Hence it cannot be in NP regardless of how easy or hard it is. (See Decision vs Optimization problems.)

Recall Solution L3.2

(a) SAT becomes solvable in polynomial time. SAT is NP-complete, so it is in NP; if then everything in NP (including SAT) is in P. See P vs NP. (b) HALT is unaffected — it stays undecidable. only says "the NP class equals the P class." HALT is NP-hard but not in NP (it isn't even decidable), so collapsing NP onto P touches nothing about HALT. No amount of -vs- news gives you an algorithm that doesn't exist. Moral: helps exactly the NP-hard problems that are also in NP (the NP-complete ones).

Recall Solution L3.3

is NP-complete, so it is in NP; being in NP and NP-hard gives . Symmetrically NP and NP-hard give . So both directions hold — all NP-complete problems are inter-reducible. But is not symmetric in general. Example: any reduces to 3-SAT (, trivially by solving during the reduction), yet would put an NP-hard problem inside P, unknown/false unless . The mutual reducibility above is a special feature of NP-completeness, not of .


Level 4 — Synthesis

Recall Solution L4.1

Construction. Given a 3-CNF formula with variables, output the description of a machine that ignores its input and does:

  1. Enumerate all truth assignments in order.
  2. For each, evaluate (poly time per assignment).
  3. If some satisfies : halt. If it exhausts all assignments: enter an infinite loop (while true: skip).

The figure below traces this: the blue box is the input , the yellow arrow is the poly-time build step, and the pink box is the machine whose behaviour splits into "halt" or "loop forever." Read the equivalence line under it.

Figure — NP-hard — harder than NP, may not be in NP

Equivalence. If is satisfiable, step 3 finds a satisfying and halts → HALT. If is unsatisfiable, no assignment triggers the halt, so loops forever → HALT. Thus HALT. Poly-time. We are only writing down the code of (embedding 's clauses as constants). The description length is linear in ; we never run . So the reduction is poly-time — even though itself may run forever.

Key subtlety we exploited: the reduction converts "does a witness exist?" into "does this searcher ever stop?" — turning search into halting.

Recall Solution L4.2

Problem: = "given a CNF formula , output the maximum number of clauses simultaneously satisfiable."

  • NP-hard: From its answer you can decide "can all clauses be satisfied?" (i.e. SAT) by checking if the output equals . That is a poly-time reduction , and SAT is NP-hard.
  • Not in NP: It outputs a number, not yes/no, so it is not a decision language — ineligible for NP, just like optimization-TSP.

(Another valid answer: the counting problem = "how many satisfying assignments?" — NP-hard, not a decision problem, hence not in NP.)


Level 5 — Mastery

Recall Solution L5.1

Step (1) is correct (that reduction is exactly L4.1). Step (2) is wrong, and here is precisely why:

  • The trace of a halting computation can be exponentially (or unboundedly) long — there is no polynomial bound on the number of steps before halts. A certificate for NP must have length polynomial in the input size; a trace violates that.
  • Even worse, for a non-halting input there is no finite trace at all to reason about, and no bound tells the verifier when to give up. This is exactly why HALT is undecidable — Turing's diagonal argument shows no algorithm (hence no poly-time verifier) decides it. Correct conclusion: HALT is NP-hard but not in NP, therefore not NP-complete. It is the canonical "harder than NP, not in NP" example. See Halting Problem — undecidability.
Recall Solution L5.2

Problem: = "is this fully-quantified Boolean formula true?" (Quantified SAT / TQBF).

  • Decidable: finitely many variables → brute force over all assignments decides it. So unlike HALT, it has an algorithm.
  • NP-hard: 3-SAT is the special case where all quantifiers are (). That is an immediate reduction , so TRUE-QBF is NP-hard.
  • Believed not in NP: TQBF is PSPACE-complete. If it were in NP, then every problem in PSPACE would also be in NP: any PSPACE problem satisfies (TQBF is PSPACE-hard), and composing that reduction with TQBF's assumed NP-membership would put in NP too — forcing . Since is widely conjectured false (it would collapse the polynomial hierarchy), TQBF is believed not to be in NP. So under standard assumptions TRUE-QBF is NP-hard, decidable, yet outside NP.

This fills the last cell of the map: NP-hard problems can be (i) in NP [NP-complete], (ii) decidable but likely above NP [TQBF], or (iii) undecidable [HALT].

Figure — NP-hard — harder than NP, may not be in NP

Recall One-line map of everything above

NP-hard = floor of difficulty. On that floor you find: NP-complete (in NP, e.g. SAT), decidable-but-above-NP (e.g. TQBF, PSPACE-complete), and undecidable (e.g. HALT). Membership in NP is a separate question decided by "is there a short, poly-checkable certificate?"