A known NP-complete language becomes a source for later hardness proofs. If C is NP-complete, C≤PL, and L∈NP, then L is NP-complete: every language in NP reduces to C, and C reduces to L.
Reduction chain. A directed collection of polynomial-time reductions, where an arrow A→B means A≤PB.
Follow arrows from a known hard problem to the new problem. The arrow direction is the reduction direction.
Each arrow means a polynomial-time reduction from the source problem to the target problem.
Recipe: extending an NP-completeness chain.
Show L∈NP by giving a polynomial-time verifier.
Choose a known NP-complete language C.
Construct a polynomial-time map f from instances of C to instances of L.
Prove exact preservation:
x∈C⟺f(x)∈L.
The direction is essential. To prove L hard, reduce a known hard problem toL, not L to the known problem.
Vertex cover. A vertex cover of a graph G=(V,E) is a subset S⊆V such that every edge of G has at least one endpoint in S.
A vertex cover touches every edge.
VERTEX COVER. The language
VERTEXCOVER={⟨G,k⟩∣G has a vertex cover of size k}.
The language is in NP: a certificate is a set C of vertices. The verifier checks that ∣C∣=k and rejects if it finds an edge {u,v} with both u∈/C and v∈/C.
Vertex-cover duality. For every graph G=(V,E) and every subset S⊆V,
S is a vertex cover⟺V∖S is an independent set.
If S covers every edge, then no edge can have both endpoints outside S, so V∖S is independent. Conversely, if V∖S is independent, then every edge has at least one endpoint in S, so S is a vertex cover.
Theorem.VERTEXCOVER is NP-complete.
Reduce INDSET to VERTEXCOVER. Given ⟨G,k⟩, let n=∣V(G)∣ and output
f(⟨G,k⟩)=⟨G,n−k⟩.
The map is polynomial time because it only counts vertices and changes the integer parameter. By vertex-cover duality,
G has an independent set of size k⟺G has a vertex cover of size n−k.
Thus INDSET≤PVERTEXCOVER, and since VERTEXCOVER∈NP, the language is NP-complete.
Set cover. Let U be a finite universe and let F={T1,…,Tm} be a family of subsets of U. A set cover of size k is a subfamily {Ti1,…,Tik}⊆F whose union is all of U:
j=1⋃kTij=U.
SET COVER. The language
SETCOVER={⟨U,F,k⟩∣F contains a set cover of size k}.
The language is in NP: a certificate is k chosen sets from F, and the verifier checks that their union equals U.
Example 1. Covering a universe.
For U={1,…,9}, the three sets {1,2,4}, {3,5,6}, and {4,7,8,9} cover U. No two of these three sets cover all elements.
Theorem.SETCOVER is NP-complete.
Reduce VERTEXCOVER to SETCOVER. Given an instance ⟨G=(V,E),k⟩, build a set-cover instance as follows:
Let the universe be the edge set: U=E.
For every vertex v∈V, create a set
Sv={e∈E∣e is incident to v}.
Let F={Sv∣v∈V} and keep the same parameter k.
The construction is polynomial time because it creates one set per vertex and one universe element per edge.
If C⊆V is a vertex cover of size k, then every edge is incident to some vertex in C. Therefore the sets {Sv∣v∈C} cover U=E.
Conversely, if Sv1,…,Svk cover U=E, then every edge belongs to at least one of those sets. Hence every edge is incident to one of v1,…,vk, so {v1,…,vk} is a vertex cover.
Thus
⟨G,k⟩∈VERTEXCOVER⟺⟨E,{Sv∣v∈V},k⟩∈SETCOVER.
So VERTEXCOVER≤PSETCOVER, and SETCOVER is NP-complete.
SUBSET-SUM. Let X be a multiset of positive integers. The language
SUBSET-SUM={⟨X,s⟩∣X contains a sub-multiset whose elements sum to s}.
The language is in NP: a certificate is the chosen sub-multiset, or equivalently a bit vector selecting which entries of X to use. The verifier sums the selected numbers and compares the result with s.
Example 2. Subset sums.
For X={1,3,4,6,13,13}, ⟨X,8⟩∈SUBSET-SUM because 1+3+4=8. But ⟨X,12⟩∈/SUBSET-SUM.
Dynamic-programming table for SUBSET-SUM. Let X={x1,…,xm} and let
T=i=1∑mxi.
Define A[i,j] to be true iff some subset of {x1,…,xi} sums to j, for 0≤i≤m and 0≤j≤T.
Set A[0,0]=true.
Set A[0,j]=false for j>0.
For i=1,…,m and j=0,…,T, use
A[i,j]=A[i−1,j]∨(j≥xi and A[i−1,j−xi]).
Accept iff A[m,s]=true.
The table has (m+1)(T+1) entries, so the running time is O(mT).
Pseudo-polynomial time. An algorithm is pseudo-polynomial if its running time is polynomial in the numeric values of the input, but not necessarily polynomial in the number of bits needed to encode those values.
For SUBSET-SUM, the distinction is decisive:
Encoding
Input length
Effect on the O(mT) algorithm
Unary
Θ(x1+⋯+xm+s)
Polynomial in the input length
Binary
Θ(⌈logx1⌉+⋯+⌈logxm⌉+⌈logs⌉)
May be exponential in the input length
SUBSET-SUM uses binary encoding in the NP-completeness statement. Therefore the dynamic program does not prove SUBSET-SUM∈P.
Theorem.SETCOVER≤PSUBSET-SUM.
Combined with SETCOVER being NP-complete and SUBSET-SUM∈NP, this implies that SUBSET-SUM is NP-complete. The hardness result is compatible with the dynamic program because pseudo-polynomial time is weaker than polynomial time under binary encoding.