knowledge

Theory of Computation: Lecture 9

NP-completeness reduction chains for CLIQUE, VERTEX COVER, SET COVER, and SUBSET-SUM, with graph complements and pseudo-polynomial subset-sum.

Reduction Chains

A known NP-complete language becomes a source for later hardness proofs. If CC is NP-complete, CPLC\le_P L, and LNPL\in NP, then LL is NP-complete: every language in NPNP reduces to CC, and CC reduces to LL.

Reduction chain. A directed collection of polynomial-time reductions, where an arrow ABA\to B means APBA\le_P B.

Follow arrows from a known hard problem to the new problem. The arrow direction is the reduction direction.

SATINDSET3SATVERTEX COVERCLIQUESET COVERSUBSET-SUMknown complete sources feed later complete targets by transitivity
SATINDSETCLIQUEVERTEX COVERSET COVERSUBSET-SUM3SATarrows transfer NP-hardnesswhen the target is in NP
Each arrow means a polynomial-time reduction from the source problem to the target problem.

Recipe: extending an NP-completeness chain.

  1. Show LNPL\in NP by giving a polynomial-time verifier.
  2. Choose a known NP-complete language CC.
  3. Construct a polynomial-time map ff from instances of CC to instances of LL.
  4. Prove exact preservation:
xCf(x)L.x\in C \quad\Longleftrightarrow\quad f(x)\in L.

The direction is essential. To prove LL hard, reduce a known hard problem to LL, not LL to the known problem.

CLIQUE and Graph Complements

Clique. A kk-clique in a graph GG is a subset of kk vertices such that every pair of distinct vertices in the subset is connected by an edge.

CLIQUE. The language

CLIQUE={G,kG has a clique of size k}.\mathrm{CLIQUE} = \{\langle G,k\rangle\mid G\text{ has a clique of size }k\}.

The language is in NPNP: a certificate is a set SS of kk vertices, and the verifier checks that every pair in SS is adjacent.

Graph complement. For a graph G=(V,E)G=(V,E), the complement graph G=(V,E)\overline G=(V,\overline E) has the same vertices and exactly the missing edges:

{u,v}E{u,v}E.\{u,v\}\in\overline E \quad\Longleftrightarrow\quad \{u,v\}\notin E.

Thus non-adjacency in GG becomes adjacency in G\overline G.

Theorem. CLIQUE\mathrm{CLIQUE} is NP-complete.

Membership in NPNP was shown above. For hardness, reduce INDSET\mathrm{INDSET} to CLIQUE\mathrm{CLIQUE}. Given G,k\langle G,k\rangle, output

f(G,k)=G,k.f(\langle G,k\rangle)=\langle \overline G,k\rangle.

The complement graph is computable in polynomial time by checking each pair of vertices. Correctness follows from the definition of complement:

S is an independent set of size k in GS is a clique of size k in G.S\text{ is an independent set of size }k\text{ in }G \quad\Longleftrightarrow\quad S\text{ is a clique of size }k\text{ in }\overline G.

Therefore INDSETPCLIQUE\mathrm{INDSET}\le_P\mathrm{CLIQUE}, and CLIQUE\mathrm{CLIQUE} is NP-complete. The same complement idea also gives CLIQUEPINDSET\mathrm{CLIQUE}\le_P\mathrm{INDSET}.

VERTEX COVER

Vertex cover. A vertex cover of a graph G=(V,E)G=(V,E) is a subset SVS\subseteq V such that every edge of GG has at least one endpoint in SS.

A vertex cover touches every edge.

VERTEX COVER. The language

VERTEX COVER={G,kG has a vertex cover of size k}.\mathrm{VERTEX\ COVER} = \{\langle G,k\rangle\mid G\text{ has a vertex cover of size }k\}.

The language is in NPNP: a certificate is a set CC of vertices. The verifier checks that C=k|C|=k and rejects if it finds an edge {u,v}\{u,v\} with both uCu\notin C and vCv\notin C.

Vertex-cover duality. For every graph G=(V,E)G=(V,E) and every subset SVS\subseteq V,

S is a vertex coverVS is an independent set.S\text{ is a vertex cover} \quad\Longleftrightarrow\quad V\setminus S\text{ is an independent set}.

If SS covers every edge, then no edge can have both endpoints outside SS, so VSV\setminus S is independent. Conversely, if VSV\setminus S is independent, then every edge has at least one endpoint in SS, so SS is a vertex cover.

Theorem. VERTEX COVER\mathrm{VERTEX\ COVER} is NP-complete.

Reduce INDSET\mathrm{INDSET} to VERTEX COVER\mathrm{VERTEX\ COVER}. Given G,k\langle G,k\rangle, let n=V(G)n=|V(G)| and output

f(G,k)=G,nk.f(\langle G,k\rangle)=\langle G,n-k\rangle.

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 kG has a vertex cover of size nk.G\text{ has an independent set of size }k \quad\Longleftrightarrow\quad G\text{ has a vertex cover of size }n-k.

Thus INDSETPVERTEX COVER\mathrm{INDSET}\le_P\mathrm{VERTEX\ COVER}, and since VERTEX COVERNP\mathrm{VERTEX\ COVER}\in NP, the language is NP-complete.

SET COVER

Set cover. Let UU be a finite universe and let F={T1,,Tm}\mathcal F=\{T_1,\ldots,T_m\} be a family of subsets of UU. A set cover of size kk is a subfamily {Ti1,,Tik}F\{T_{i_1},\ldots,T_{i_k}\}\subseteq\mathcal F whose union is all of UU:

j=1kTij=U.\bigcup_{j=1}^k T_{i_j}=U.

SET COVER. The language

SET COVER={U,F,kF contains a set cover of size k}.\mathrm{SET\ COVER} = \{\langle U,\mathcal F,k\rangle\mid \mathcal F\text{ contains a set cover of size }k\}.

The language is in NPNP: a certificate is kk chosen sets from F\mathcal F, and the verifier checks that their union equals UU.

Example 1. Covering a universe.

For U={1,,9}U=\{1,\ldots,9\}, the three sets {1,2,4}\{1,2,4\}, {3,5,6}\{3,5,6\}, and {4,7,8,9}\{4,7,8,9\} cover UU. No two of these three sets cover all elements.

Theorem. SET COVER\mathrm{SET\ COVER} is NP-complete.

Reduce VERTEX COVER\mathrm{VERTEX\ COVER} to SET COVER\mathrm{SET\ COVER}. Given an instance G=(V,E),k\langle G=(V,E),k\rangle, build a set-cover instance as follows:

  1. Let the universe be the edge set: U=EU=E.
  2. For every vertex vVv\in V, create a set
Sv={eEe is incident to v}.S_v=\{e\in E\mid e\text{ is incident to }v\}.
  1. Let F={SvvV}\mathcal F=\{S_v\mid v\in V\} and keep the same parameter kk.

The construction is polynomial time because it creates one set per vertex and one universe element per edge.

If CVC\subseteq V is a vertex cover of size kk, then every edge is incident to some vertex in CC. Therefore the sets {SvvC}\{S_v\mid v\in C\} cover U=EU=E.

Conversely, if Sv1,,SvkS_{v_1},\ldots,S_{v_k} cover U=EU=E, then every edge belongs to at least one of those sets. Hence every edge is incident to one of v1,,vkv_1,\ldots,v_k, so {v1,,vk}\{v_1,\ldots,v_k\} is a vertex cover.

Thus

G,kVERTEX COVERE,{SvvV},kSET COVER.\langle G,k\rangle\in\mathrm{VERTEX\ COVER} \quad\Longleftrightarrow\quad \langle E,\{S_v\mid v\in V\},k\rangle\in\mathrm{SET\ COVER}.

So VERTEX COVERPSET COVER\mathrm{VERTEX\ COVER}\le_P\mathrm{SET\ COVER}, and SET COVER\mathrm{SET\ COVER} is NP-complete.

SUBSET-SUM and Encoding

SUBSET-SUM. Let XX be a multiset of positive integers. The language

SUBSET-SUM={X,sX contains a sub-multiset whose elements sum to s}.\mathrm{SUBSET\text{-}SUM} = \{\langle X,s\rangle\mid X\text{ contains a sub-multiset whose elements sum to }s\}.

The language is in NPNP: a certificate is the chosen sub-multiset, or equivalently a bit vector selecting which entries of XX to use. The verifier sums the selected numbers and compares the result with ss.

Example 2. Subset sums.

For X={1,3,4,6,13,13}X=\{1,3,4,6,13,13\}, X,8SUBSET-SUM\langle X,8\rangle\in\mathrm{SUBSET\text{-}SUM} because 1+3+4=81+3+4=8. But X,12SUBSET-SUM\langle X,12\rangle\notin\mathrm{SUBSET\text{-}SUM}.

Dynamic-programming table for SUBSET-SUM. Let X={x1,,xm}X=\{x_1,\ldots,x_m\} and let

T=i=1mxi.T=\sum_{i=1}^m x_i.

Define A[i,j]A[i,j] to be true iff some subset of {x1,,xi}\{x_1,\ldots,x_i\} sums to jj, for 0im0\le i\le m and 0jT0\le j\le T.

  1. Set A[0,0]=trueA[0,0]=\mathrm{true}.
  2. Set A[0,j]=falseA[0,j]=\mathrm{false} for j>0j>0.
  3. For i=1,,mi=1,\ldots,m and j=0,,Tj=0,\ldots,T, use
A[i,j]=A[i1,j](jxi and A[i1,jxi]).A[i,j] = A[i-1,j] \vee \bigl(j\ge x_i\text{ and }A[i-1,j-x_i]\bigr).
  1. Accept iff A[m,s]=trueA[m,s]=\mathrm{true}.

The table has (m+1)(T+1)(m+1)(T+1) entries, so the running time is O(mT)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:

EncodingInput lengthEffect on the O(mT)O(mT) algorithm
UnaryΘ(x1++xm+s)\Theta(x_1+\cdots+x_m+s)Polynomial in the input length
BinaryΘ(logx1++logxm+logs)\Theta(\lceil\log x_1\rceil+\cdots+\lceil\log x_m\rceil+\lceil\log s\rceil)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-SUMP\mathrm{SUBSET\text{-}SUM}\in P.

Theorem. SET COVERPSUBSET-SUM\mathrm{SET\ COVER}\le_P\mathrm{SUBSET\text{-}SUM}.

Combined with SET COVER\mathrm{SET\ COVER} being NP-complete and SUBSET-SUMNP\mathrm{SUBSET\text{-}SUM}\in NP, this implies that SUBSET-SUM\mathrm{SUBSET\text{-}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.