🖨️ Printing Instructions: Press Ctrl/Cmd + P and select "Save as PDF".
2
Learning Goals
- Review the recipe for proving NP-Completeness.
- Walk through the 3-SAT → Clique reduction in detail.
- Learn how Independent Set ↔ Vertex Cover relate via a simple complement.
- Know that Subset Sum and 3-Coloring are also NP-Complete (via reductions from 3-SAT).
- Practice identifying whether problems are NP-Complete.
3
Quick Recap from Last Time
4
NP-Completeness: The Definition
- A problem $X$ is NP-Complete if:
- 1. $X \in NP$ (YES answers have a short certificate that can be verified in polynomial time).
- 2. $X$ is NP-Hard: for every problem $Y \in NP$, $Y \le_p X$.
- In practice, for step 2 we pick one known NPC problem and reduce it to $X$.
- Why is one reduction enough? Because NPC problems are all connected by reductions — if any one of them reduces to $X$, they all do (by transitivity).
5
The Two-Step Recipe (Review)
- To prove a new problem $C$ is NP-Complete:
- Step 1 (Show $C \in NP$): State the certificate and explain how to verify it in polynomial time.
- Step 2 (Show $C$ is NP-Hard): Reduce a known NPC problem $B$ to $C$.
- (a) Describe a polynomial-time transformation: instance of $B$ → instance of $C$.
- (b) Prove the if-and-only-if: $B$-instance is YES $\iff$ $C$-instance is YES.
- Today we will see this recipe in action for several important reductions.
6
Reduction: 3-SAT → Clique (Detailed Walkthrough)
7
Recall: 3-SAT and Clique
- 3-SAT: Given a CNF formula with $m$ clauses, each with exactly 3 literals, is there a satisfying assignment?
- Clique: Given a graph $G$ and integer $k$, does $G$ contain a complete subgraph on $k$ vertices?
- Goal: Transform any 3-SAT formula into a graph so that the formula is satisfiable if and only if the graph has a clique of a certain size.
8
The Construction
- Given a 3-SAT formula with $m$ clauses $C_1, C_2, \ldots, C_m$:
- Vertices: For each clause $C_j$, create 3 vertices — one for each literal in the clause. Total: $3m$ vertices.
- Example: Clause $C_1 = (x_1 \lor \neg x_2 \lor x_3)$ creates three vertices labeled $x_1^{(1)}, \neg x_2^{(1)}, x_3^{(1)}$.
- Edges: Connect vertex $u$ to vertex $v$ if and only if:
- (1) $u$ and $v$ come from different clauses, AND
- (2) $u$ and $v$ are not contradictory (meaning $u \neq \neg v$).
- Set $k = m$ (the number of clauses).
9
Why It Works: A Small Example
- Formula: $(x_1 \lor \neg x_2 \lor x_3) \land (\neg x_1 \lor x_2 \lor x_3)$. So $m = 2$, $k = 2$.
- Clause 1 vertices: $x_1^{(1)}, \neg x_2^{(1)}, x_3^{(1)}$.
- Clause 2 vertices: $\neg x_1^{(2)}, x_2^{(2)}, x_3^{(2)}$.
- Edges connect across clauses, except contradictions: no edge between $x_1^{(1)}$ and $\neg x_1^{(2)}$, and no edge between $\neg x_2^{(1)}$ and $x_2^{(2)}$.
- For example, $x_3^{(1)}$ connects to all three of $\neg x_1^{(2)}, x_2^{(2)}, x_3^{(2)}$ (no contradictions).
- Satisfying assignment $x_1 = T, x_2 = T, x_3 = T$: pick $x_1^{(1)}$ and $x_2^{(2)}$ — these are from different clauses, both true, and not contradictory → clique of size 2. ✓
10
Correctness Proof (Both Directions)
- Forward (Satisfiable → Clique): If the formula is satisfiable, pick one TRUE literal from each clause. This gives $m$ vertices. They are pairwise connected because: (1) they come from different clauses, (2) they are all simultaneously true, so no two can be contradictory.
- Backward (Clique → Satisfiable): A clique of size $m$ must contain exactly one vertex from each clause (since no two vertices in the same clause are connected). The literals labeling these vertices are pairwise non-contradictory, so we can set them all to TRUE consistently. Each clause has a TRUE literal, so the formula is satisfied.
- Running time: Building the graph takes $O(m^2)$ time — polynomial. ✓
11
Independent Set and Vertex Cover
12
Clique → Independent Set
- Independent Set: Does graph $G$ have a set of $k$ vertices with no edges between them?
- Key idea: Build the complement graph $\bar{G}$ (same vertices, but an edge exists in $\bar{G}$ iff it does NOT exist in $G$).
- Claim: $G$ has a clique of size $k$ $\iff$ $\bar{G}$ has an independent set of size $k$.
- Why: A set of vertices that are ALL connected in $G$ are NONE connected in $\bar{G}$, and vice versa.
- Building $\bar{G}$ takes $O(|V|^2)$ time — polynomial. ✓
- Since Clique is NPC and Independent Set is in NP (certificate = the $k$ vertices), Independent Set is NPC.
13
Independent Set → Vertex Cover
- Vertex Cover: Does graph $G$ have a set of $\le k$ vertices that touches every edge?
- Key observation: $S$ is an independent set $\iff$ $V \setminus S$ is a vertex cover.
- Why: If no edge has both endpoints in $S$ (independent set), then every edge must have at least one endpoint in $V \setminus S$ (vertex cover).
- Reduction: $G$ has an independent set of size $k$ $\iff$ $G$ has a vertex cover of size $|V| - k$.
- No need to modify the graph at all — just change the parameter!
- Since Independent Set is NPC and Vertex Cover is in NP, Vertex Cover is NPC.
14
The Triangle of Equivalences
- These three problems are tightly related:
- Clique on $G$ ↔ Independent Set on $\bar{G}$ (complement the graph).
- Independent Set on $G$ ↔ Vertex Cover on $G$ (complement the vertex set).
- If you can solve any one of them in polynomial time, you can solve all three in polynomial time.
- All three are NP-Complete.
15
Other Important NPC Results (Without Proof Details)
16
3-SAT → Subset Sum (Result Only)
- Subset Sum: Given a set of positive integers and a target $T$, is there a subset that sums to exactly $T$?
- Result: Subset Sum is NP-Complete, proven by reduction from 3-SAT.
- High-level idea: The reduction encodes variables and clauses as digit positions in carefully constructed numbers. Choosing which numbers to include in the subset corresponds to choosing TRUE/FALSE for each variable.
- Why it's tricky: 3-SAT is about logic (TRUE/FALSE), while Subset Sum is about numbers — the reduction cleverly bridges this gap.
- The details are intricate, but the key takeaway is: Subset Sum is NPC, so there is no known polynomial-time algorithm for it.
17
3-SAT → 3-Coloring (Result Only)
- 3-Coloring: Can we assign one of 3 colors to each vertex of a graph so that no two adjacent vertices share the same color?
- Result: 3-Coloring is NP-Complete, proven by reduction from 3-SAT.
- High-level idea: The reduction builds a graph with special "gadgets" — small subgraphs that force variables to act like TRUE/FALSE and force clauses to be satisfied.
- • Variable gadgets ensure each variable is assigned exactly one of two colors (representing TRUE or FALSE).
- • Clause gadgets ensure that at least one literal in each clause is TRUE — otherwise the gadget cannot be 3-colored.
- The key takeaway: 3-Coloring is NPC, even though 2-Coloring (bipartiteness) is in P!
18
The Reduction Chain (Updated)
19
How Today's Reductions Fit In
- SAT (Cook-Levin: NPC from scratch)
- └→ 3-SAT
- ├→ Clique → Independent Set → Vertex Cover
- ├→ 3-Coloring (stated without proof details)
- ├→ Subset Sum → Knapsack (stated without proof details)
- └→ Hamiltonian Cycle → TSP
- Today we covered the reductions marked in bold.
- Each arrow $A \to B$ means $A \le_p B$ (we reduced $A$ to $B$ to prove $B$ is NPC).
21
Problem 1: Euler Tour vs. Hamiltonian Cycle
- Euler Tour: Does the graph have a cycle that uses every edge exactly once?
- Hamiltonian Cycle: Does the graph have a cycle that visits every vertex exactly once?
- These sound similar but have very different complexity:
- Euler Tour is in P — solvable in linear time. (A connected graph has an Euler tour iff every vertex has even degree.)
- Hamiltonian Cycle is NP-Complete.
- This is a great example of how small changes in problem definition can lead to huge changes in complexity.
22
Problem 2: Is Finding a Bigger Clique Harder?
- Question: We proved Clique (does $G$ have a clique of size $k$?) is NPC. What if we change $k$ to a fixed constant, say $k = 3$?
- Answer: Finding a clique of size 3 (a triangle) is in P — just check all triples of vertices in $O(|V|^3)$ time.
- The problem is NP-Complete only when $k$ is part of the input and can grow with the graph size.
- Lesson: Whether a parameter is fixed or part of the input can change the complexity entirely.
23
Problem 3: Identifying the Reduction Direction
- Scenario: You want to prove that a new problem $X$ is NP-Complete. You already know Clique is NPC.
- Which reduction do you need?
- (A) Reduce $X$ to Clique
- (B) Reduce Clique to $X$
- Answer: (B) Reduce Clique to $X$.
- Why: You need to show $X$ is at least as hard as Clique. If you can transform any Clique instance into an $X$ instance, then solving $X$ would let you solve Clique — so $X$ must be at least as hard.
- Reducing $X$ to Clique would only show Clique is at least as hard as $X$ — that's the wrong direction!
25
Mistakes to Avoid in Reductions
- Forgetting the if-and-only-if: A reduction must work in BOTH directions. Showing "satisfiable → clique" is only half the proof; you also need "clique → satisfiable."
- Wrong direction of reduction: To prove problem $X$ is NPC, reduce FROM a known NPC problem TO $X$, not the other way around.
- Forgetting Step 1: Always show the problem is in NP before doing the reduction. State the certificate and verifier explicitly.
- Confusing complement graph with complement set: Clique ↔ Independent Set uses the complement graph $\bar{G}$. Independent Set ↔ Vertex Cover uses the complement vertex set $V \setminus S$ on the same graph.
27
Key Takeaways
- 3-SAT → Clique: Create one vertex per literal per clause, connect non-contradictory literals across clauses, set $k =$ number of clauses.
- Clique ↔ Independent Set ↔ Vertex Cover: These three problems reduce to each other via graph complement and set complement. All three are NPC.
- Subset Sum and 3-Coloring are also NPC (via reductions from 3-SAT). The reductions are more complex but the results are important to know.
- Reduction direction matters: To prove $X$ is NPC, reduce a known NPC problem to $X$.
- Always remember the recipe: (1) Show the problem is in NP, (2) Reduce a known NPC problem to it, proving both directions of correctness.
28
Supplementary Resources