Title

ECS 120 Theory of Computation
NP Hardness, NP Completeness, and Reductions, Pt 3
Julian Panetta
University of California, Davis

Recall: definition of Polynomial-Time Reducibility

Let \(A, B \subseteq \binary^*\) be decision problems. We say \(A\) is polynomial-time reducible to \(B\)
if there is a polynomial-time computable function \(f\) such that for all \(x \in \binary^*\):

\[ x \in A \iff f(x) \in B \]

We denote this by \(A \le^P B\).

\(A \le^P B\) means: “B is at least as hard as A” (to within a polynomial-time factor).

  • If \(A \le^P B\) and \(B \in \P\) then \(A \in \P\).
  • If \(A \le^P B\) and \(A \notin \P\) then \(B \notin \P\).

Recall: Reductions Between Problems of Different Types

Theorem: \(\probThreeSAT \le^P \probIndSet\).

Proof:

  • Given a 3-CNF formula \(\phi\): \[ \phi = (a_1 \lor b_1 \lor c_1) \land (a_2 \lor b_2 \lor c_2) \land \ldots \land (a_k \lor b_k \lor c_k) \] we produce a pair \((G, k)\) such that: \[ \encoding{\phi} \in \probThreeSAT \; \iff \; \encoding{G, k} \in \probIndSet \]

  • Set \(k\) equal to the number of clauses in \(\phi\).

  • Create one node in \(G\) for each literal in \(\phi\).

  • Create edge {u, v} in \(G\) if and only if:

    • \(u\) and \(v\) correspond to literals in the same clause (triple), or
    • \(u\) is labeled \(x\) and \(v\) is labeled \(\overline{x}\) for some variable \(x\) (or vice versa).
data/images/complexity/3sat_to_indset.png

Reductions Don’t Themselves Solve Problems!

data/images/complexity/reduction_schematic.png

  • A reduction \(f\) is just a (polynomial-time) algorithm
  • It enables solving problem \(A\) in terms of an algorithm for problem \(B\).
  • However, \(f\) does not itself solve either problem!
    • It transforms an instance of problem \(A\) (e.g., a formula for \(\probThreeSAT\))
      into an instance of problem \(B\) (e.g., a graph for \(\probIndSet\)).
    • It preserves the “yes” or “no” answer to the original problem
      (but does not provide the answer itself).

NP-Hardness and NP-Completeness

A language \(B\) is called NP-hard if for every language \(A \in \NP\), \(A \le^P B\).

A language \(B\) is called NP-complete if:

  1. \(B \in \NP\); and
  2. \(B\) is NP-hard.

Theorem: If \(B\) is NP-complete and if \(B \in \P\) then \(\P = \NP\).

Proof:

  • Assume that \(B\) is NP-complete and \(B \in \P\).
  • We know \(\P \subseteq \NP\) and just need to show \(\NP \subseteq \P\).
  • We do this by showing that for any \(A \in \NP\), we have \(A \in \P\).
    • Since \(B\) is NP-hard, we have \(A \le^P B\).
    • Then according to this theorem, \(A \in \P\).

NP-Hardness and NP-Completeness

A language \(B\) is called NP-hard if for every language \(A \in \NP\), \(A \le^P B\).

A language \(B\) is called NP-complete if:

  1. \(B \in \NP\); and
  2. \(B\) is NP-hard.

Theorem: If \(B\) is NP-complete and if \(B \in \P\) then \(\P = \NP\).

Corollary: If \(\P \ne \NP\) then no NP-complete problem is in \(\P\).

This is the significance of NP-completeness:
if you show your problem is NP-hard, then there is (probably) no efficient algorithm for it.

Transitive Property of Polynomial-Time Reducibility

We can chain reductions together!

Observation: \(\le^P\) is transitive
(if \(A \le^P B\) and \(B \le^P C\), then \(A \le^P C\))

def reduce_A_to_B(x):
  """
  reduction from NP prob
  A to NP-hard prob B
  """
  raise NotImplementedError()
def reduce_B_to_C(x):
  """
  reduction from B
  to NP-hard prob C
  """
  raise NotImplementedError()
def C_decider(x):
  """
  hypothetical polynomial-time
  decider
  """
  raise NotImplementedError()
def A_decider(x):
  """
  polynomial time
  """
  y = reduce_A_to_B(x)
  z = reduce_B_to_C(y)
  return C_decider(z)

\(A\) will be a stand-in for any problem in \(\NP\).

Transitive Property of Polynomial-Time Reducibility

Theorem: If \(B\) is \(\NP\)-hard and \(B \le^P C\) for some language \(C\),
then \(C\) is also \(\NP\)-hard.

Proof:

  • Let \(A \in \NP\).
  • Since \(B\) is \(\NP\)-hard, \(A \le^P B\).
  • Since \(\le^P\) is transitive, \(A \le^P C\).
  • Therefore \(C\) is \(\NP\)-hard.

Corollary: If \(B\) is \(\NP\)-complete, \(B \le^P C\),
and \(C \in \NP\), then \(C\) is \(\NP\)-complete.

NP P NP Complete

Finding a reduction from any known-NP-hard problem \(B\) to \(C\) proves that all problems in \(\NP\) are reducible to \(C\)! (\(C\) is NP-hard too.)

Restatement of the Cook-Levin Theorem

Cook-Levin Theorem: \(\probSAT\) and \(\probThreeSAT\) are NP-complete.

  • Proof: Optional Section 10.10 (and ECS 220)
  • This is proved “directly” by exhibiting a reduction from a generic problem \(A \in \NP.\)
  • Once we have these “base” NP-complete problems, we can build up a library of
    NP-complete problems by finding reductions from other problems.

Theorem: \(\probIndSet\) and \(\probClique\) are NP-complete.

Proof:

  • \(\probThreeSAT \le^P \probIndSet\) as proved earlier, so \(\probIndSet\) is NP-hard.
  • \(\probIndSet \le^P \probClique\) as proved earlier, so \(\probClique\) is NP-hard.
  • \(\probClique, \probIndSet \in \NP\) due to polynomial-time verifiers (shown for \(\probClique\) here).
  • Thus, both \(\probIndSet\) and \(\probClique\) are NP-complete.