12.5.2 Polynomial Reductions

Much of the knowledge we would like to have about the inherent complexity of important problems is currently beyond our reach. However, mathematicians and computer scientists have made good progress in establishing information about the relative complexity of many important problems.

One important way to relate the complexity of problem A to problem B is to show that problem A can be done efficiently if an algorithm that solves B can be used as a sub- algorithm.

DEFINITION: Problem A is polynomially Turing reducible to problem B ([A] <=PT [B]) if there exists an algorithm for solving A in a time that *would* be polynomial if we could solve instances of problem B at unit cost.

(This assumes that the solution to problem B will be called O(p(N)) times and that the maximum size instance of problem B solved will be O(t(N)), where p and t are polynomials and N is the size of the instance of problem A to be solved. For example, it's "not fair" to call an O(N) subroutine 2^N times, or to give an instance of size 2^N to an O(N) subroutine.)

It's easy to show that <=PT is reflexive and transitive.

EXAMPLE:

THEOREM: HAM and HAMD are polynomially Turing reducible to one another.

(HAM is the problem of *finding* a Hamiltonian cycle in an undirected graph, if one exists. HAMD is the problem of deciding whether or not an undirected graph contains a Hamiltonian cycle.)

PROOF:

Suppose that HAM(G) is a function that is guaranteed to return a Hamiltonian cycle of the graph G if one exists. If no Hamiltonian cycle exists in G, it just returns something -- anything.

The following function demonstrates that [HAMD] <=PT [HAM]:

function HamD(G : graph)
  s <-- Ham(G) ;
  IF   s defines a Hamiltonian 
       cycle in G
  THEN return true
  ELSE return false
Note that the algorithm gives the correct result, and that it is simple to make it run in polynomial time if Ham is assumed to be of unit cost. Part of what makes this feasible is that it is easy to check "s" in linear time to see if it is a Hamiltonian path.

This function demonstrates that [HAM] <=PT [HAMD]:

function Ham(G=(N,A): graph)
    /* N is the node set, and A is the edge set. */
  IF   HamD(G)=false
  THEN return "there is no solution"
  FOR each edge e in the edge set A of G
  DO  IF    HamD(N,A-{e})
      THEN  A <-- A-{e}
  s <-- sequence of nodes obtained by following
           the unique cycle remaining in G.


Note that an edge is removed only if the resulting graph will still be Hamiltonian. It follows that the edges that remain comprise a single Hamiltonian cycle. The number of edges that will be examined will be O(N^2), so HamD will be called only O(N^2) times. Each instance of the problem called will be of size no larger than the size of G. QED

The example above illustrates that a decision problem can be equivalent to a problem that is not a decision problem. This is quite common. It shows that information we gain about P and NP can shed light on many other problems besides decision problems.

THEOREM: If X is polynomially Turing reducible to Y, and if Y can be solved in polynomial time, then X can be solved in polynomial time.

PROOF: By the definition of polynomially Turing reducible, if X is polynomially Turing reducible to Y, then there is an algorithm Al(X) and three polynomials p, q, and r with the following properties:
  1. Al(X) solves arbitrary problems of type X by, in part, calling a hypothetical algorithm Al(Y) as a subroutine.
  2. To solve a problem of type X and size N, Al(X) calls Al(Y) no more than p(N) times.
  3. When Al(X) solves a problem of size N, the problems of type Y that it passes to Al(Y) are of size no greater than q(N).
  4. Outside of the calls to Al(Y), the other work done by Al(X) is bounded by r(N).
Suppose that t(M) is an eventually non-decreasing work function for Al(Y). Typically, t(M) represents a bound on how much work is done by Al(Y) on a problem of size M (or smaller) in the worst case.

Because of the facts listed above, each time Al(X) calls Al(Y) while working on a problem of size N, Al(Y) does work at most t(q(N)). Also Al(X) calls Al(Y) at most p(N) times. Therefore the total amount of work done in the calls to Al(Y) is at most p(N)*t(q(N)).

If Y can be solved in polynomial time, then we may assume that t(M) is a polynomial in M. It is not hard to show that therefore p(N)*t(q(N))+r(N) is a polynomial in N. This latter function is a bound on the total amount of work done by Al(X) on a problem of size N. Therefore X can be done in polynomial time if Y can. QED.

DEFINITION: A Decision problem X defined on instance set I is polynomially many-one reducible to problem Y defined on instance set J ([X] <=MP [Y]) if there exists a function f:I-->J computable in polynomial time such that x is in X if and only if y=f(x) is in Y for any instance x in I of problem X.

THEOREM: If X and Y are decision problems such that [X] <=MP [Y], then also [X] <=TP [Y].

PROOF: Suppose that [X] <=MP [Y].

Let I, J, and f be as in the definition of <=MP.

Suppose that DecideY is an algorithm for solving Y. Consider:

Function DecideX(x)
  y <-- f(x);
  IF   DecideY(f(x))
  THEN return true
  ELSE return false


Clearly DecideX would be a polynomial time algorithm if the call to DecideY could be executed at unit cost.

Because f is computable in polynomial time, we know that the size of the storage taken up by y is bounded by some polynomial in the size of x. Thus the argument to the call to DecideY is not "too large".

We can conclude then that [X] <=TP [Y]. QED

THEOREM: [HAMD] <=MP [TSPD] and [HAMD] <=TP [TSPD]

(Here TSPD is the "travelling salesperson problem decision" -- the problem of determining if a given undirected graph has a Hamiltonian cycle of total cost no greater than some limit L.)

PROOF: Let G=<N,A> be a graph with N nodes. Define f(G) to be the instance of TSPD consisting of <H,c,L> where: H is the complete graph <N,NXN>; The cost function c is defined by c(u,v)=1 if {u,v} is an edge of G, and c(u,v)=2 otherwise; and The cost limit L is equal to N.

Any Hamiltonian cycle in G translates into a tour in H that has cost exactly N. If there is no Hamiltonian cycle in G, then H will have no Hamiltonian of cost less than N+1. Therefore G is a yes- instance of HAMD if and only if f(G) is a yes-instance of TSPD. Function f is easy to compute in polynomial time. Basically the work involved is just to create an NXN cost matrix. This proves that [HAMD] <=MP [TSPD], and [HAMD] <=TP [TSPD] follows immediately from the theorem.