CLIQUE ∈ NP: Given a graph G and a subset C of vertices, we can verify in polynomial time that C is a clique of size at least k by checking that |C| ≥ k and that every pair of vertices in C is connected by an edge.
3-SAT ≤p CLIQUE: Given a 3-CNF formula φ with m clauses, we construct a graph G:
- For each clause Cj and each literal li,j in Cj, create a vertex vi,j
- Connect two vertices vi,j and vi',j' by an edge if:
- j ≠ j' (they are from different clauses), and
- li,j and li',j' are not negations of each other
Set k = m, the number of clauses in φ.
Claim: φ is satisfiable if and only if G has a clique of size at least m.
(⇒) If φ is satisfiable, let α be a satisfying assignment. For each clause Cj, choose one literal li,j that is true under α. The corresponding vertices vi,j form a clique of size m because:
- We select exactly one vertex from each clause
- No two selected literals can be negations of each other (both can't be true under α)
(⇐) If G has a clique C of size m, it must include exactly one vertex from each clause (since vertices from the same clause are not connected). Set variables to make the corresponding literals true. This is consistent because no two literals in the clique are negations of each other. This assignment satisfies φ because at least one literal in each clause is true.
The reduction is polynomial-time, and since 3-SAT is NP-complete, CLIQUE is NP-complete.