Exercises — P vs NP — statement, why it matters
Two quick reminders we will lean on the whole way (each is earned — defined before use):
Level 1 — Recognition
Exercise 1.1
Classify each statement as True or False: (a) . (b) "NP" stands for "Non-Polynomial". (c) Every problem in has a poly-time verifier. (d) has been proven false.
Recall Solution 1.1
(a) True — a solver can ignore the certificate and just solve, so it doubles as a verifier. (b) False — NP = Nondeterministic Polynomial; it is about verifying, not slowness. (c) True — this is exactly (a) restated: . (d) False — it is open; experts believe but nobody has a proof. Score: 4 correct = full marks.
Exercise 1.2
Match each item to "certificate" or "verifier": (i) the filled-in Sudoku grid; (ii) the routine "check every row/column/box has 1–9 once"; (iii) a subset of numbers that sums to the target; (iv) the addition-and-compare step.
Recall Solution 1.2
- Certificate (the hint): (i) filled grid, (iii) the subset.
- Verifier (the poly-time checker): (ii) the validity scan, (iv) the addition-and-compare. Rule of thumb: a certificate is a thing handed to you; a verifier is an algorithm you run on it.
Level 2 — Application
Exercise 2.1
Show that CLIQUE is in . Problem: given a graph with vertices and an integer , is there a set of vertices all mutually connected (a "clique")?
Recall Solution 2.1
Follow the verifier recipe.
- Certificate: the list of vertices claimed to form the clique. Why: it is the natural "hint" a prover supplies. Each vertex is named by an ID, and there are vertices, so an ID costs about bits; the whole certificate has size — still polynomial in the input size.
- Verifier : (a) check has exactly distinct vertices; (b) check all pairs are edges of .
- Time: checking all pairs is at most — polynomial. ✔
- Correctness: if a -clique exists, the certificate listing it passes; if none exists, no set of vertices is fully connected, so nothing passes. Therefore CLIQUE . (Whether it's also in is unknown — but we will not use any hardness claim here; membership in NP is all this exercise asks for.)
Exercise 2.2
For , TSP brute force tries all tour orderings. Roughly how many is , and if a computer does orderings per second, roughly how many years?
Recall Solution 2.2
orderings. Time seconds. Convert: one year s, so The figure below drives the point home. Its amber curve is : read off the marked dot at , which sits near — the value we just computed. Compare it with the cyan curve (a stand-in for a "polynomial / P-world" cost) and the dashed white curve . Even on a logarithmic vertical axis (each gridline is ), the amber factorial climbs almost vertically while the cyan polynomial stays low and flat. That visual gap is the whole lesson: "finite" is not "polynomial" — factorial growth crushes any real machine long before the polynomial curve breaks a sweat.

Level 3 — Analysis
Exercise 3.1
Prove carefully that , and explain where "yes-instance vs no-instance" is used.
Recall Solution 3.1
Let , so there is a deterministic solver running in that outputs yes/no correctly. Construct a verifier — it throws the certificate away and just runs .
- Poly time: runs in the same as (ignoring costs nothing).
- Yes-instance: if is a yes, then , so every (in particular a short one) passes — "some passes" holds.
- No-instance: if is a no, then , so no passes — the verifier can't be fooled. Both verifier conditions hold, so . Since was arbitrary, . Where the case-split matters: NP's definition has two obligations (completeness for yes, soundness for no); we had to check both, and the "ignore " trick satisfies each.
Exercise 3.2
The Halting Problem is NP-hard but not in NP (in fact undecidable). Is it NP-complete? Explain using the exact definitions.
Recall Solution 3.2
First, the precise definitions (the reductions here are always polynomial-time many-one reductions: a poly-time map with " is yes for " " is yes for ", written ).
- is NP-hard if for every we have .
- is NP-complete if is NP-hard AND .
Is the Halting Problem NP-complete? No.
- NP-hard: ✔ (every NP problem reduces to it — an all-powerful undecidable oracle can settle any poly-time-mapped instance).
- In NP: ✘ — a problem in NP has a poly-time verifier, but the Halting Problem has no decider at all (see Halting Problem (undecidability)), let alone a poly-time verifier. Since one of the two conjuncts fails, it is not NP-complete. It sits outside NP while still being NP-hard.
Level 4 — Synthesis
Exercise 4.1
Suppose someone publishes a genuine algorithm for SAT. Prove that this forces . Which theorem do you invoke?
Recall Solution 4.1
Invoke the Cook–Levin Theorem: SAT is NP-complete, i.e. every reduces to SAT in poly time. Let be arbitrary. By NP-completeness there is a poly-time reduction turning any instance (size ) into a SAT formula of size for some polynomial , with " is yes" " is satisfiable." Chain the algorithms:
- Compute — poly time .
- Run the new SAT solver on — time , still polynomial (a polynomial of a polynomial is a polynomial).
- Output its answer. This solves in poly time, so . Since was any NP problem, . Combined with (Exercise 3.1) we get . Moral: one poly-time crack in a single NP-complete problem collapses the whole class — the "load-bearing pillar" idea from the parent note.
Exercise 4.2
Reductions have a direction. We know Subset-Sum is NP-complete. Which of these would prove a new problem is NP-hard? (a) reduce to Subset-Sum; (b) reduce Subset-Sum to . Justify.
Recall Solution 4.2
(b) — reduce the known-hard problem into . Read a poly-time reduction as " is no harder than ; is at least as hard as ." So:
- (b) Subset-Sum says is at least as hard as the NP-hard Subset-Sum ⇒ is NP-hard. ✔
- (a) Subset-Sum only says is no harder than something in NP ⇒ it shows (an upper bound), not hardness. ✘ Mnemonic: to prove hardness, map the monster onto your new problem, not the reverse.
Level 5 — Mastery
Exercise 5.1
A student argues: "Primality testing had only exponential algorithms for decades, therefore it must be NP-complete." Diagnose every flawed step. (Hint: AKS, 2002.)
Recall Solution 5.1
Two independent errors:
- "Slow known algorithm ⟹ not in P." The best algorithm, not the first one, decides membership in . In 2002 the AKS algorithm decided primality in polynomial time, so PRIMES . The old exponential methods said nothing about the true difficulty.
- "Hard-looking ⟹ NP-complete." Even if a problem were hard, "hard" is not the same as "NP-complete" — NP-complete needs a proof of NP-hardness (every NP problem reduces to it) and membership in NP. No such proof exists for PRIMES; in fact it's in P. Verdict: both the premise and the leap are wrong; PRIMES is a poly-time (hence NP, hence not NP-complete unless ) problem.
Exercise 5.2
If , does that break RSA? Explain the exact link, and state the honest caveat about why wouldn't instantly break every code in practice.
Recall Solution 5.2
Link: RSA's security assumes FACTORING is easy to check (multiply the factors back — ) but hard to find. FACTORING (as a decision problem, "does have a factor ?") is in NP: the certificate is a factor, the verifier is one division. If , then this NP problem is in , so factoring gets a poly-time algorithm ⇒ RSA keys can be broken efficiently. So yes, in principle RSA falls. Honest caveats (the mastery point):
- only guarantees some polynomial algorithm; the exponent/constant could be huge (e.g. ), so "poly" ≠ "instantly practical."
- The proof might be non-constructive — proving without exhibiting the actual algorithm.
- RSA is broken by factoring specifically; a proof breaks it if it yields (or implies) a usable factoring routine. So the correct statement is: would destroy the theoretical foundation of RSA-style security, with practical impact depending on the algorithm's real-world efficiency.
#recall
Which direction of reduction proves hardness of a new problem X
Is the Halting Problem NP-complete
Roughly how long is orderings at /sec
Why doesn't "exponential brute force" imply "not in P"
If SAT gets a poly-time algorithm, what follows
Connections
- P vs NP — statement, why it matters (index 4.6.24)
- NP-Completeness and Reductions
- Cook–Levin Theorem
- SAT and Boolean Satisfiability
- Big-O and Time Complexity
- Turing Machines (Deterministic vs Nondeterministic)
- Halting Problem (undecidability)
- Cryptography and RSA