Exercises — NP-completeness — Cook's theorem (SAT is NP-complete), reduction
Level 1 — Recognition
L1.1
State, in one sentence each, what it means for a problem to be (a) in NP, (b) NP-hard, (c) NP-complete.
Recall Solution
(a) In NP: a "yes" instance has a certificate (a guessed solution) that can be checked by a deterministic machine in polynomial time. See Verifier definition of NP. (b) NP-hard: every problem NP reduces to by a polynomial-time reduction ( for all such ). "At least as hard as everything in NP." (c) NP-complete: is in NP and is NP-hard. The hardest problems that still live inside NP.
L1.2
The reduction is defined by a poly-time function with . Which of , is "at least as hard"?
Recall Solution
is at least as hard as . Reason: if you had a fast solver for , you could solve any instance of by computing (cheap) and asking your -solver. So 's power ≥ 's power. See Polynomial-time reduction.
L1.3
Cook's theorem shows SAT is NP-complete. Which two statements together make up that claim?
Recall Solution
(1) SAT NP — given a truth assignment, plug in and evaluate in poly time. (2) SAT is NP-hard — every NP reduces to SAT (the tableau construction). Both together = NP-complete.
Level 2 — Application
L2.1
Given the 3-SAT formula , is satisfiable? Give one satisfying assignment.
Recall Solution
Try . Then appears (positively) in both clauses, so both are satisfied regardless of . One satisfying assignment: . Check: clause 1 ; clause 2 . So . Satisfiable. ✔
L2.2
Split the long clause into equivalent 3-literal clauses using one fresh variable . Then prove the equivalence in both directions.
Recall Solution
The split is Here is a brand-new variable, not appearing anywhere else. We claim: there is a way to assign that makes both new clauses true if and only if at least one of is true (which is exactly what the original clause demands).
Direction 1 — original true split satisfiable. Suppose some is true. There are two cases:
- If or is true, set . Then clause 1 is true (via or ), and clause 2 is true because . ✔
- If instead or is true, set . Then clause 1 is true because , and clause 2 is true (via or ). ✔ Either way we found a value of making both clauses true.
Direction 2 — split satisfiable original true. Suppose both new clauses are true for some choice of . Look at the value of :
- If , then clause 2 has , so it is true only if or is true.
- If , then clause 1 has , so it is true only if or is true. In either case at least one original literal is true, so the original clause is true. ✔
Both directions give the iff. In particular, if all four are false: clause 1 forces , clause 2 forces — a contradiction, so the split is unsatisfiable, matching the original. This is the 3-SAT clause-splitting reduction.
L2.3
For the 3-SAT Independent Set reduction, how many vertices and what target size does the formula produce? Explain why an independent set of size corresponds to a satisfying assignment.
Recall Solution
First recall the two ingredients (built here so you need nothing external). An independent set is a collection of graph vertices with no edge between any two of them. The construction turns each clause into a triangle (3 mutually-connected vertices, one per literal) and joins two vertices by a conflict edge whenever they are complementary literals ( with ). See Independent Set.
Counts for this formula:
- Vertices: one per literal-occurrence literals clauses .
- Target: number of clauses .
The figure below shows the exact graph. Read it top-to-bottom: the two blue triangles are the two clauses; the two red dashed lines are the conflicts – and –. Notice the third literal of each clause is , appearing on both sides with no conflict edge between them, because and are the same literal, not complementary.

Why an independent set of size forces exactly one true literal per clause:
- Each triangle has 3 vertices, all mutually adjacent. An independent set may contain at most one vertex from any triangle (two vertices of a triangle are always joined). So across triangles you can pick at most vertices total. To reach the target , you must pick exactly one vertex from every triangle — no clause is skipped.
- The chosen vertex in a triangle names one literal of that clause; declare that literal TRUE. Because we picked one per triangle, every clause gets a true literal, so the formula is satisfied.
- The conflict edges stop this assignment from being contradictory: since and are joined, an independent set can never contain both, so we never simultaneously declare true and true. The assignment is consistent.
Conversely, a satisfying assignment picks, in each clause, one literal it made true, and those chosen vertices form an independent set of size (same-triangle pairs excluded by the triangle, complementary pairs excluded by consistency). This is the two-way correspondence that makes the reduction correct.
Level 3 — Analysis
L3.1
In Cook's tableau, why do we only need to check local windows to guarantee the whole run is a legal Turing-machine computation? Give a rough count showing the number of window-clauses is .
Recall Solution
A Turing machine changes only the cell under the head and, via head movement, its immediate neighbour in a single step. So legality of "row leads to row " is a property of small horizontal neighbourhoods. If every window of 2 rows × 3 columns is consistent with the transition rules, then, cell by cell, each row correctly follows from the one above — hence the entire tableau is a legal run.
The count. The tableau has time-rows and tape-columns. A window is fixed by choosing its top-left corner: any of the first rows (so the window's second row still exists) and any of the first columns (so all three columns exist). That is at most windows. For each window we AND in a bounded set of clauses — one forbidding each illegal content-pattern of that window — and the number of possible patterns is a constant (it depends only on the fixed alphabet and state set of , not on ). So total window-clauses . Polynomial. ✔
L3.2
The number of Boolean variables in Cook's construction is up to a constant factor. Where does the square come from, and where does the constant come from?
Recall Solution
The tableau is — one dimension for time steps, one for tape cells. That product gives the grid positions (the square). For each position we have one variable per possible content : each tape symbol, plus each (state, "head here") pairing. The alphabet and state set are fixed for the machine , independent of input length — that fixed count is the constant. Total: .
L3.3
Prove that is transitive: if and , then . Why is transitivity essential for the whole theory?
Recall Solution
Let reduce to and reduce to , both poly-time. Define . (Recall is the length of the string , and "poly-time" means the step-count is at most multiplied by itself a fixed number of times.)
- Correctness: , i.e. . ✔
- Poly-time: say runs in at most steps for some fixed whole number (input length raised to the power ). Since cannot write more symbols than steps it takes, its output length satisfies . Now runs in at most steps for some fixed , and — the input length raised to the fixed power . That is still a fixed power of , so is poly-time. ✔
Why essential: Cook gives "everything in NP SAT." To crown a new problem NP-complete we only show SAT (or another known NP-complete ) . Transitivity then chains "everything " with "" to yield "everything " — without transitivity, one reduction wouldn't inherit the hardness of all of NP. See Karp's 21 NP-complete problems.
Level 4 — Synthesis
L4.1
Design a reduction showing Vertex Cover is NP-hard using Independent Set (assume IS is already NP-complete). State and prove the iff. (This exercise asks only for NP-hardness.)
Recall Solution
First, definitions built here. A vertex cover of a graph is a set of vertices such that every edge has at least one endpoint in — the vertices "cover" all edges. Recall an independent set is a set with no edge inside it. See Vertex Cover.
Key fact: is an independent set iff its complement is a vertex cover. Reason: no edge lies inside every edge has at least one endpoint outside , i.e. in .
Reduction : given an IS-instance (does have an independent set of size ?), output the Vertex-Cover instance — same graph, complementary target. This is clearly polynomial-time: we copy the graph and compute one subtraction.
The iff: has an independent set of size has a vertex cover of size .
- () An independent set with gives cover of size .
- () A vertex cover with gives independent set of size .
The figure makes the complement concrete: on a small graph, the green vertices form an independent set and the leftover orange vertices form a vertex cover.

Read the figure: the green pair has no edge between them (independent, size ); the orange pair is exactly the leftover, and you can check every drawn edge touches an orange vertex (cover, size ). This visual is the "complement" fact.
Since IS Vertex Cover and IS is NP-complete, Vertex Cover is NP-hard. (The exercise stops here — we were only asked for NP-hardness, not the extra membership-in-NP argument.)
L4.2
Show Clique is NP-hard by reducing from Independent Set. Give and the iff.
Recall Solution
Definition built here: a clique is a set of vertices with an edge between every pair (a fully-connected group). The complement graph has the same vertices as but swaps edges and non-edges: two vertices are adjacent in iff they were non-adjacent in . See Clique.
Key fact: a set is an independent set in (no edges inside ) iff is a clique in (all pairs inside are edges of ). This is immediate: "no edge in among " becomes "every non-edge, i.e. every -edge, present among ."
Reduction : given IS-instance , output Clique-instance . Building examines each of the at most vertex pairs once, so is polynomial-time.
The iff: has an independent set of size has a clique of size (same vertex set works, same ).
Therefore IS Clique, and since IS is NP-complete, Clique is NP-hard.
Level 5 — Mastery
L5.1
A student claims: "I built a poly-time reduction that maps every SAT instance to a graph, so SAT Independent Set — but my map sometimes outputs a graph whose vertex count is ." Is this a valid reduction? Explain precisely what breaks.
Recall Solution
Not valid. A reduction must be computable in polynomial time. Writing down a graph with vertices requires at least steps just to output it — that is exponential, not polynomial. So the map fails the poly-time requirement, and the chain of hardness is broken (see the parent note's last mistake callout). A correct SAT/3-SAT IS reduction produces vertices, which is polynomial in the input size.
L5.2
Consider the empty formula (no clauses) and the formula with an empty clause . What does SAT answer for each, and why must a correct reduction respect these degenerate cases?
Recall Solution
- Empty formula (a conjunction of zero clauses): vacuously TRUE, so satisfiable — the empty AND is TRUE by convention.
- Empty clause (a disjunction of zero literals): FALSE, so any formula containing it is unsatisfiable — the empty OR is FALSE. Why it matters: a reduction must satisfy for every instance, including these edge cases. In the 3-SAT IS reduction, the empty formula maps to a graph with triangles and target ; an independent set of size trivially exists — consistent with "satisfiable." If your construction crashed or gave the wrong answer on zero clauses, the iff fails and the reduction is wrong.
L5.3
Cook's construction runs in polynomial time yet SAT is (believed) hard. A student concludes "P = NP because we found a poly-time procedure." Pinpoint the confusion.
Recall Solution
Two different tasks are being conflated:
- Constructing the formula from is poly-time. That is what Cook's reduction does.
- Solving SAT — deciding whether is satisfiable — is the (believed) hard part. No known poly-time algorithm does this.
Building a hard question quickly is not the same as answering it quickly. The reduction moves the difficulty into SAT; it does not dissolve it. Whether SAT (and hence all of NP) can be solved in poly time is precisely the open P vs NP problem. So the conclusion is unwarranted.
Recall One-line self-check
Direction of a hardness reduction ::: reduce FROM a known NP-complete problem INTO your new problem ( makes hard). SAT satisfiability of the empty formula ::: TRUE (vacuous conjunction), so satisfiable. SAT satisfiability of a formula containing the empty clause ::: FALSE (vacuous disjunction), unsatisfiable.