MODULE 8:   P vs NP
Polynomial-Time Reductions

In a previous chapter, we have studied reductions and saw how they can be used to both expand the landscape of decidable languages and expand the landscape of undecidable languages. As such, the concept of a reduction is a very powerful tool.

In the context of computational complexity, reductions once again play a very important role. In particular, by tweaking our definition of a reduction a bit so that it is required to be efficiently computable, we can use reductions to expand the landscape of tractable (i.e. efficiently decidable) languages and to expand the landscape of intractable languages. Another cool feature of reductions is that it allows us to show that many seemingly unrelated problems are essentially the same problem in disguise, and this allows us to have a deeper understanding of the mysterious and fascinating world of computational complexity.

Our goal in this chapter is to introduce you to the concept of polynomial-time (efficient) reductions, and give you a few examples to make the concept more concrete and illustrate their power.

In some sense, this chapter marks the introduction to our discussion on the P\mathsf{P} vs NP\mathsf{NP} problem, even though the definition of NP\mathsf{NP} will only be introduced in the next chapter, and the connection will be made more precise then.

1 Problems of Interest

In this section, we present the definitions of some of the decision problems that will be part of our discussion in this module.

Definition (kk-Coloring problem)

In the kk-coloring problem, the input is an undirected graph G=(V,E)G=(V,E), and the output is True if and only if the graph is kk-colorable (see Definition (kk-colorable graphs)). We denote this problem by kCOLk\text{COL}. The corresponding language is {G:G is a k-colorable graph}.\{\langle G \rangle: \text{$G$ is a $k$-colorable graph}\}.

Definition (Clique problem)

Let G=(V,E)G = (V,E) be an undirected graph. A subset SS of the vertices is called a clique if for all u,vSu, v \in S with uvu \neq v, {u,v}E\{u,v\} \in E. We say that GG contains a kk-clique if there is a subset of the vertices of size kk that forms a clique.

In the clique problem, the input is an undirected graph G=(V,E)G=(V,E) and a number kN+k \in \mathbb N^+, and the output is True if and only if the graph contains a kk-clique. We denote this problem by CLIQUE\text{CLIQUE}. The corresponding language is {G,k:G is a graph, kN+G contains a k-clique}.\{\langle G, k \rangle: \text{$G$ is a graph, $k \in \mathbb N^+$, $G$ contains a $k$-clique}\}.

Definition (Independent set problem)

Let G=(V,E)G = (V,E) be an undirected graph. A subset of the vertices is called an independent set if there is no edge between any two vertices in the subset. We say that GG contains an independent set of size kk if there is a subset of the vertices of size kk that forms an independent set.

In the independent set problem, the input is an undirected graph G=(V,E)G=(V,E) and a number kN+k \in \mathbb N^+, and the output is True if and only if the graph contains an independent set of size kk. We denote this problem by IS\text{IS}. The corresponding language is {G,k:G is a graph, kN+G contains an independent set of size k}.\{\langle G, k \rangle: \text{$G$ is a graph, $k \in \mathbb N^+$, $G$ contains an independent set of size $k$}\}.

Note (Unary NOT, binary AND, binary OR)

We denote by ¬\neg the unary NOT operation, by \wedge the binary AND operation, and by \vee the binary OR operation. In particular, we can write the truth tables of these operations as follows:

image

Definition (Boolean satisfiability problem)

Let x1,,xnx_1,\ldots,x_n be Boolean variables, i.e., variables that can be assigned True or False. A literal refers to a Boolean variable or its negation. A clause is an “OR” of literals. For example, x1¬x3x4x_1 \vee \neg x_3 \vee x_4 is a clause. A Boolean formula in conjunctive normal form (CNF) is an “AND” of clauses. For example, (x1¬x3)(x2x2x4)(x1¬x1¬x5)x4(x_1 \vee \neg x_3) \wedge (x_2 \vee x_2 \vee x_4) \wedge (x_1 \vee \neg x_1 \vee \neg x_5) \wedge x_4 is a CNF formula. We say that a Boolean formula is a satisfiable formula if there is a truth assignment (which can also be viewed as a 0/10/1 assignment) to the Boolean variables that makes the formula evaluate to true (or 11).

In the CNF satisfiability problem, the input is a CNF formula, and the output is True if and only if the formula is satisfiable. We denote this problem by SAT\text{SAT}. The corresponding language is {φ:φ is a satisfiable CNF formula}.\{\langle \varphi \rangle: \text{$\varphi$ is a satisfiable CNF formula}\}. In a variation of SAT\text{SAT}, we restrict the input formula such that every clause has exactly 3 literals (we call such a formula a 3CNF formula). For instance, the following is a 3CNF formula: For example, (x1¬x3x4)(x2x2x4)(x1¬x1¬x5)(¬x2¬x3¬x3)(x_1 \vee \neg x_3 \vee x_4) \wedge (x_2 \vee x_2 \vee x_4) \wedge (x_1 \vee \neg x_1 \vee \neg x_5) \wedge (\neg x_2 \vee \neg x_3 \vee \neg x_3) This variation of the problem is denoted by 3SAT\text{3SAT}.

Definition (Boolean circuit)

A Boolean circuit with nn-input variables (n0n \geq 0) is a directed acyclic graph with the following properties. Each node of the graph is called a gate and each directed edge is called a wire. There are 55 types of gates that we can choose to include in our circuit: AND gates, OR gates, NOT gates, input gates, and constant gates. There are 2 constant gates, one labeled 00 and one labeled 11. These gates have in-degree/fan-in 00. There are nn input gates, one corresponding to each input variable. These gates also have in-degree/fan-in 00. An AND gate corresponds to the binary AND operation \wedge and an OR gate corresponds to the binary OR operation \vee. These gates have in-degree/fan-in 22. A NOT gate corresponds to the unary NOT operation ¬\neg, and has in-degree/fan-in 11. One of the gates in the circuit is labeled as the output gate. Gates can have out-degree more than 11, except for the output gate, which has out-degree 00.

For each 0/1 assignment to the input variables, the Boolean circuit produces a one-bit output. The output of the circuit is the output of the gate that is labeled as the output gate. The output is calculated naturally using the truth tables of the operations corresponding to the gates. The input-output behavior of the circuit defines a function f:{0,1}n{0,1}f:\{0,1\}^n \to \{0,1\} and in this case, we say that ff is computed by the circuit.

Example

Below is an example of how we draw a circuit. In this example, n=4n = 4.

image

The output gate is the gate at the very top with an arrow that links to nothing. The circuit outputs 1 if and only if x1x2x_1 \neq x_2 and x3x4x_3 \neq x_4.

Definition (Circuit satisfiability problem)

A satisfiable circuit is such that there is 0/1 assignment to the input gates that makes the circuit output 1. In the circuit satisfiability problem, the input is a Boolean circuit, and the output is True if and only if the circuit is satisfiable. We denote this problem by CIRCUIT-SAT\text{CIRCUIT-SAT}. The corresponding language is {C:C is a Boolean circuit that is satisfiable}.\{\langle C \rangle: \text{$C$ is a Boolean circuit that is satisfiable}\}.

Note (Names of decision problems and languages)

The name of a decision problem above refers both to the decision problem and the corresponding language.

Note (Inputs of decision problems)

Recall that in all the decision problems above, the input is an arbitrary word in Σ\Sigma^*. If the input does not correspond to a valid encoding of an object expected as input (e.g. a graph in the case of kkCOL), then those inputs are rejected (i.e., they are not in the corresponding language).

Note (Exponential-time algorithms for the decision problems above)

All the problems defined above are decidable and have exponential-time algorithms solving them.

2 Cook and Karp Reductions
Note (Cook reduction: Polynomial-time (Turing) reduction)

Fix some alphabet Σ\Sigma. Let AA and BB be two languages. We say that AA polynomial-time reduces to BB, written APBA \leq^PB, if there is a polynomial-time decider for AA that uses a decider for BB as a black-box subroutine. Polynomial-time reductions are also known as Cook reductions, named after Stephen Cook.

Note (Polynomial-time reductions and P\mathsf{P})

Suppose APBA \leq^PB. Observe that if BPB \in \mathsf{P}, then APA \in \mathsf{P}. Equivalently, taking the contrapositive, if A∉PA \not \in \mathsf{P}, then B∉PB \not \in \mathsf{P}. So when APBA \leq^PB, we think of BB as being at least as hard as AA with respect to polynomial-time decidability.

Note (Transitivity of Cook reductions)

Note that if APBA \leq^PB and BPCB \leq^PC, then APCA \leq^PC.

Recall that in a previous chapter, we introduced the concept of a mapping reduction (see Note (Mapping reductions)) as a special kind of a regular (Turing) reduction. We observed that to specify a mapping reduction from LL to KK, one simply needs to define an algorithm computing a function f:ΣΣf: \Sigma^* \to \Sigma^* such that xLx \in L if and only if f(x)Kf(x) \in K. Below we define the notion of a polynomial-time mapping reduction.

Definition (Karp reduction: Polynomial-time mapping reduction)

Let AA and BB be two languages. Suppose that there is a polynomial-time computable function (also called a polynomial-time transformation) f:ΣΣf: \Sigma^* \to \Sigma^* such that xAx \in A if and only if f(x)Bf(x) \in B. Then we say that there is a polynomial-time mapping reduction (or a Karp reduction, named after Richard Karp) from AA to BB, and denote it by AmPBA \leq_m^PB.

Important Note (Steps to establish a Karp reduction)

To show that there is a Karp reduction from AA to BB, you need to do the following things.

  1. Present a computable function f:ΣΣf: \Sigma^* \to \Sigma^*.

  2. Show that xA    f(x)Bx \in A \implies f(x) \in B.

  3. Show that x∉A    f(x)∉Bx \not \in A \implies f(x) \not \in B (it is usually easier to argue the contrapositive).

  4. Show that ff can be computed in polynomial time.

In picture, the transformation ff looks as follows.

image

Note that ff need not be injective and it need not be surjective.

Important Note (Mapping reductions vs Turing reductions)

Recall that a mapping reduction is really a special kind of a Turing reduction. In particular, if there is a mapping reduction from language AA to language BB, then one can construct a regular (Turing) reduction from AA to BB. We explain this below as a reminder.

To establish a Turing reduction from AA to BB, we need to show how we can come up with a decider MAM_A for AA given that we have a decider MBM_B for BB. Now suppose we have a mapping reduction from AA to BB. This means we have a computable function ff as in the definition of a mapping reduction. This ff then allows us to build MAM_A as follows. Given any input xx, first feed xx into ff, and then feed the output y=f(x)y = f(x) into MBM_B. The output of MAM_A is the output of MBM_B. We illustrate this construction with the following picture.

image

Take a moment to verify that this reduction from AA to BB is indeed correct given the definition of ff.

Even though a mapping reduction can be viewed as a regular (Turing) reduction, not all reductions are mapping reductions.

Theorem (CLIQUE reduces to IS)

CLIQUEmPIS\text{CLIQUE} \leq_m^P\text{IS}.

Proof

Following the previous important note, we start by presenting a computable function f:ΣΣf: \Sigma^* \to \Sigma^*.

def    f(graph G=(V,E),  positive natural k):1.    E={{u,v}:{u,v}∉E}.2.    Return G=(V,E),k.\begin{aligned} \hline\hline\\[-12pt] &\textbf{def}\;\; f(\langle \text{graph } G = (V,E), \; \text{positive natural } k\rangle):\\ &{\scriptstyle 1.}~~~~\texttt{$E' = \{\{u,v\} : \{u,v\} \not\in E\}$.}\\ &{\scriptstyle 2.}~~~~\texttt{Return $\langle G' = (V,E'), k \rangle$.}\\ \hline\hline\end{aligned}

(In a Karp reduction from AA to BB, when we define f:ΣΣf: \Sigma^* \to \Sigma^*, it is standard to define it so that invalid instances of AA are mapped to invalid instances of BB. We omit saying this explicitly when presenting the reduction, but you should be aware that this is implicitly there in the definition of ff. In the above definition of ff, for example, any string xx that does not correspond to a valid instance of CLIQUE (i.e., not a valid encoding of a graph GG together with a positive integer kk) is mapped to an invalid instance of IS (e.g. they can be mapped to ϵ\epsilon, which we can assume to not be a valid instance of IS.))

To show that ff works as desired, we first make a definition. Given a graph G=(V,E)G=(V,E), the complement of GG is the graph G=(V,E)G' = (V,E') where E={{u,v}:{u,v}∉E}E' = \{\{u,v\} : \{u,v\} \not \in E\}. In other words, we construct GG' by removing all the edges of GG and adding all the edges that were not present in GG.

We now argue that xCLIQUEx \in \text{CLIQUE} if and only if f(x)ISf(x) \in \text{IS}. First, assume xCLIQUEx \in \text{CLIQUE}. Then xx corresponds to a valid encoding G=(V,E),k\langle G=(V,E), k \rangle of a graph and an integer. Furthermore, GG contains a clique SVS \subseteq V of size kk. In the complement graph, this SS is an independent set ({u,v}E\{u,v\} \in E for all distinct u,vSu,v \in S implies {u,v}∉E\{u,v\} \not \in E' for all distinct u,vSu,v \in S). Therefore G=(V,E),kIS\langle G'=(V,E'), k \rangle \in \text{IS}. Conversely, if G=(V,E),kIS\langle G'=(V,E'), k \rangle \in \text{IS}, then GG' contains an independent set SVS \subseteq V of size kk. This set SS is a clique in the complement of GG', which is GG. So the pre-image of G=(V,E),k\langle G'=(V,E'), k \rangle under ff, which is G=(V,E),k\langle G=(V,E), k \rangle, is in CLIQUE.

Finally, we argue that the function ff can be computed in polynomial time. This is easy to see since the construction of EE' (and therefore GG') can be done in polynomial time as there are polynomially many possible edges.

Exercise (IS reduces to CLIQUE)

How can you modify the above reduction to show that ISmPCLIQUE\text{IS} \leq_m^P\text{CLIQUE}?

Solution

We can use exactly the same reduction as the one in the reduction from CLIQUE to IS:

def    f(graph G=(V,E),  positive natural k):1.    E={{u,v}:{u,v}∉E}.2.    Return G=(V,E),k.\begin{aligned} \hline\hline\\[-12pt] &\textbf{def}\;\; f(\langle \text{graph } G = (V,E), \; \text{positive natural } k\rangle):\\ &{\scriptstyle 1.}~~~~\texttt{$E' = \{\{u,v\} : \{u,v\} \not\in E\}$.}\\ &{\scriptstyle 2.}~~~~\texttt{Return $\langle G' = (V,E'), k \rangle$.}\\ \hline\hline\end{aligned}

This reduction establishes ISmPCLIQUE\text{IS} \leq_m^P\text{CLIQUE}. The proof of correctness is the same as in the proof of Theorem (CLIQUE reduces to IS); just interchange the words “clique” and “independent set” in the proof.

Exercise (Hamiltonian path reductions)

Let G=(V,E)G=(V,E) be a graph. A Hamiltonian path in GG is a path that visits every vertex of the graph exactly once. The HAMPATH problem is the following: given a graph G=(V,E)G=(V,E), output True if it contains a Hamiltonian path, and output False otherwise.

  1. Let L={G,k:G is a graph, kNG has a path of length k}L = \{\langle G, k \rangle : \text{$G$ is a graph, $k \in \mathbb N$, $G$ has a path of length $k$}\}. Show that HAMPATHmPL\text{HAMPATH}\leq_m^PL.

  2. Let K={G,k:G is a graph, kNG has a spanning tree with k leaves}K = \{\langle G, k \rangle : \text{$G$ is a graph, $k \in \mathbb N$, $G$ has a spanning tree with $\leq k$ leaves}\}. Show that HAMPATHmPK\text{HAMPATH}\leq_m^PK.

Solution

Part (1): We need to show that there is a poly-time computable function f:ΣΣf : \Sigma^* \to \Sigma^* such that xx \in HAMPATH if and only if f(x)Lf(x) \in L. Below we present ff.

def    f(graph G=(V,E)):1.    Return G,V1.\begin{aligned} \hline\hline\\[-12pt] &\textbf{def}\;\; f(\langle \text{graph } G = (V,E)\rangle):\\ &{\scriptstyle 1.}~~~~\texttt{Return $\langle G, |V|-1 \rangle$.}\\ \hline\hline\end{aligned}

We first prove the correctness of the reduction. If xHAMPATHx \in \text{HAMPATH}, then xx corresponds to an encoding of a graph GG that contains a Hamiltonian path. Let nn be the number of vertices in the graph. A Hamiltonian path visits every vertex of the graph exactly once, so has length n1n-1 (the length of a path is the number of edges along the path). Therefore, by the definition of LL, we must have f(x)=G,n1Lf(x) = \langle G, n-1 \rangle \in L. For the converse, suppose f(x)Lf(x) \in L. Then it must be the case that f(x)=G,n1f(x) = \langle G, n-1 \rangle, where x=Gx = \langle G \rangle, GG is some graph, and nn is the number of vertices in that graph. Furthermore, by the definition of LL, it must be the case that GG contains a path of length n1n-1. A path cannot repeat any vertices, so this path must be a path visiting every vertex in the graph, that is, it must be a Hamiltonian path. So xHAMPATHx \in \text{HAMPATH}.

To see that the reduction is polynomial time, note that the number of vertices in the given graph can computed in polynomial time. So the function ff can be computed in polynomial time.

Part (2): We need to show that there is a poly-time computable function f:ΣΣf : \Sigma^* \to \Sigma^* such that xx \in HAMPATH if and only if f(x)Kf(x) \in K. Below we present ff.

def    f(graph G=(V,E)):1.    Return G,2.\begin{aligned} \hline\hline\\[-12pt] &\textbf{def}\;\; f(\langle \text{graph } G = (V,E)\rangle):\\ &{\scriptstyle 1.}~~~~\texttt{Return $\langle G, 2 \rangle$.}\\ \hline\hline\end{aligned}

A note: For the correctness proof below, we are going to ignore the edge case where the graph has 1 vertex. By convention, we don’t allow graphs with 0 vertices.

We now prove the correctness of the reduction. If xHAMPATHx \in \text{HAMPATH}, then xx corresponds to an encoding of a graph GG that contains a Hamiltonian path. A Hamiltonian path visits every vertex of the graph, so it forms a spanning tree with 2 leaves. Therefore, by the definition of KK, we must have f(x)=G,2Kf(x) = \langle G, 2 \rangle \in K. For the converse, suppose f(x)Kf(x) \in K. Then it must be the case that f(x)=G,2f(x) = \langle G, 2 \rangle, where x=Gx = \langle G \rangle and GG is some graph. Furthermore, by the definition of KK, GG must contain a spanning tree with 2 leaves (recall that every tree with at least 2 vertices must contain at least 2 leaves). A tree with exactly 2 leaves must be a path (prove this as an exercise). Since this path is a spanning tree, it must contain all the vertices. Therefore this path is a Hamiltonian path in GG. So xHAMPATHx \in \text{HAMPATH}.

It is clear that the function ff can be computed in polynomial time. This completes the proof.

The theorem below illustrates how reductions can establish an intimate relationship between seemingly unrelated problems.

Theorem (CIRCUIT-SAT reduces to 3COL)

CIRCUIT-SATmP3COL\text{CIRCUIT-SAT}\leq_m^P3\text{COL}.

Remark

It is completely normal (and expected) if the proof below seems magical and if you get the feeling that you could not come up with this reduction yourself. You do not have to worry about any of the details of the proof (it is completely optional). The point of this example is to illustrate to you that reductions can be complicated and unintuitive at first. It is meant to highlight that seemingly unrelated problems can be intimately connected via very interesting transformations.

Proof

To prove the theorem, we will present a Karp reduction from CIRCUIT-SAT\text{CIRCUIT-SAT} to 3COL\text{3COL}. In particular, given a valid CIRCUIT-SAT\text{CIRCUIT-SAT} instance CC, we will construct a 3COL\text{3COL} instance GG such that CC is a satisfiable Boolean circuit if and only if GG is 33-colorable. Furthermore, the construction will be done in polynomial time.

First, it is generally well-known that any Boolean circuit with AND, OR, and NOT gates can be converted into an equivalent circuit that only has NAND gates (in addition to the input gates and constant gates). A NAND gate computes the NOT of AND. The transformation can easily be done in polynomial time: for each AND, OR and NOT gate, you just create a little circuit with NAND gates that mimics the behavior of AND, OR and NOT. So without loss of generality, we assume that our circuit CC is a circuit with NAND gates, input gates and constant gates. We construct GG by converting each NAND gate into the following graph.

image

The vertices labeled with xx and yy correspond to the inputs of the NAND gate. The vertex labeled with ¬(xy)\neg(x\wedge y) corresponds to the output of the gate. We construct such a graph for each NAND gate of the circuit, however, we make sure that if, say, gate g1g_1 is an input to gate g2g_2, then the vertex corresponding to the output of g1g_1 coincides with (is the same as) the vertex corresponding to one of the inputs of g2g_2. Furthermore, the vertices labeled with 00, 11 and nn are the same for each gate. In other words, in the whole graph, there is only one vertex labeled with 00, one vertex labeled with 11, and one vertex labeled with nn. Lastly, we put an edge between the vertex corresponding to the output vertex of the output gate and the vertex labeled with 00. This completes the construction of the graph GG. Before we prove that the reduction is correct, we make some preliminary observations.

Let’s call the 33 colors we use to color the graph 00, 11 and nn (we think of nn as “none”). Any valid coloring of GG must assign different colors to 33 vertices that form a triangle (e.g. vertices labeled with 00, 11 and nn). If GG is 33-colorable, we can assume without loss generality that the vertex labeled 00 is colored with the color 00, the vertex labeled 11 is colored with color 11, and the vertex labeled nn is colored with the color nn. This is without loss of generality because if there is a valid coloring of GG, any permutation of the colors corresponds to a valid coloring as well. Therefore, we can permute the colors so that the labels of those vertices coincide with the colors they are colored with.

Notice that since the vertices corresponding to the inputs of a gate (i.e. the xx and yy vertices) are connected to vertex nn, they will be assigned the colors 00 or 11. Let’s consider two cases:

  • If xx and yy are assigned the same color (i.e. either they are both 00 or they are both 11), the vertex labeled with xyx \wedge y will have to be colored with that same color. That is, the vertex labeled with xyx \wedge y must get the color corresponding to the evaluation of xyx \wedge y. To see this, just notice that the vertices labeled s1s_1 and s2s_2 must be colored with the two colors that xx and yy are not colored with. This forces the vertex xyx \wedge y to be colored with the same color as xx and yy.

  • If xx and yy are assigned different colors (i.e. one is colored with 00 and the other with 11), the vertex labeled with xyx \wedge y will have to be colored with 00. That is, as in the first case, the vertex labeled with xyx \wedge y must get the color corresponding to the evaluation of xyx \wedge y. To see this, just notice that one of the vertices labeled d1d_1 or d2d_2 must be colored with 11. This forces the vertex xyx \wedge y to be colored with 00 since it is already connected to vertex nn.

In either case, the color of the vertex xyx \wedge y must correspond to the evaluation of xyx \wedge y. It is then easy to see that the color of the vertex ¬(xy)\neg (x \wedge y) must correspond to the evaluation of ¬(xy)\neg (x \wedge y).

We are now ready to argue that circuit CC is satisfiable if and only if GG is 33-colorable. Let’s first assume that the circuit we have is satisfiable. We want to show that the graph GG we constructed is 33-colorable. Since the circuit is satisfiable, there is a 0/1 assignment to the input variables that makes the circuit evaluate to 11. We claim that we can use this 0/1 assignment to validly color the vertices of GG. We start by coloring each vertex that corresponds to an input variable: In the satisfying truth assignment, if an input variable is set to 00, we color the corresponding vertex with the color 00, and if an input variable is set to 11, we color the corresponding vertex with the color 11. As we have argued earlier, a vertex that corresponds to the output of a gate (the vertex at the very bottom of the picture above) is forced to be colored with the color that corresponds to the value that the gate outputs. It is easy to see that the other vertices, i.e., the ones labeled s1,s2,d1,d2s_1,s_2,d_1,d_2 and the unlabeled vertices can be assigned valid colors. Once we color the vertices in this manner, the vertices corresponding to the inputs and output of a gate will be consistently colored with the values that it takes as input and the value it outputs. Recall that in the construction of GG, we connected the output vertex of the output gate with the vertex labeled with 00, which forces it to be assigned the color 11. We know this will indeed happen since the 0/1 assignment we started with makes the circuit output 11. This shows that we can obtain a valid 33-coloring of the graph GG.

The other direction is very similar. Assume that the constructed graph GG has a valid 33-coloring. As we have argued before, we can assume without loss of generality that the vertices labeled 00, 11, and nn are assigned the colors 00, 11, and nn respectively. We know that the vertices corresponding to the inputs of a gate must be assigned the colors 00 or 11 (since they are connected to the vertex labeled nn). Again, as argued before, given the colors of the input vertices of a gate, the output vertex of the gate is forced to be colored with the value that the gate would output in the circuit. The fact that we can 33-color the graph means that the output vertex of the output gate is colored with 11 (since it is connected to vertex 00 and vertex nn by construction). This implies that the colors of the vertices corresponding to the input variables form a 0/1 assignment that makes the circuit output a 11, i.e. the circuit is satisfiable.

To finish the proof, we must argue that the construction of graph GG, given circuit CC, can be done in polynomial time. This is easy to see since for each gate of the circuit, we create at most a constant number of vertices and a constant number of edges. So if the circuit has ss gates, the construction can be done in O(s)O(s) steps.

Exercise (Transitivity of Karp reductions)

Show that if AmPBA \leq_m^PB and BmPCB \leq_m^PC, then AmPCA \leq_m^PC.

Solution

Suppose AmPBA \leq_m^PB and BmPCB \leq_m^PC. Let f:ΣΣf : \Sigma^* \to \Sigma^* be the map that establishes AmPBA \leq_m^PB and let g:ΣΣg: \Sigma^* \to \Sigma^* be the map that establishes BmPCB \leq_m^PC. So xAx \in A if and only if f(x)Bf(x) \in B. And xBx \in B if and only if g(x)Cg(x) \in C. Both ff and gg are computable in polynomial time.

To show AmPCA \leq_m^PC, we define h:ΣΣh:\Sigma^* \to \Sigma^* such that h=gfh = g \circ f. That is, for all xΣx \in \Sigma^*, h(x)=g(f(x))h(x) = g(f(x)). We need to show that

  • xAx \in A if and only if h(x)Ch(x) \in C;

  • hh is computable in polynomial time.

For the first part, note that by the properties of ff and gg, xAx \in A if and only if f(x)Bf(x) \in B if and only if g(f(x))Cg(f(x)) \in C (i.e., h(x)Ch(x) \in C).
(If you are having trouble following this, you can break this part up into two parts:
(i) xA    h(x)Cx\in A \implies h(x) \in C, (ii) x∉A    h(x)∉Cx \not \in A \implies h(x) \not \in C.)
For the second part, if ff is computable in time O(nk)O(n^k), k1k \geq 1, and gg is computable in time O(nt)O(n^t), t1t \geq 1, then hh can be computed in time O(nkt)O(n^{kt}). (Why?)

3 Hardness and Completeness
Definition (C\mathcal{C}-hard, C\mathcal{C}-complete)

Let C\mathcal{C} be a set of languages containing P\mathsf{P}.

  • We say that LL is C\mathcal{C}-hard (with respect to Cook reductions) if for all languages KCK \in \mathcal{C}, KPLK \leq^PL.
    (With respect to polynomial time decidability, a C\mathcal{C}-hard language is at least as “hard” as any language in C\mathcal{C}.)

  • We say that LL is C\mathcal{C}-complete if LL is C\mathcal{C}-hard and LCL \in \mathcal{C}.
    (A C\mathcal{C}-complete language represents the “hardest” language in C\mathcal{C} with respect to polynomial time decidability.)

Note (C\mathcal{C}-completeness and P\mathsf{P})

Suppose LL is C\mathcal{C}-complete. Then observe that LPC=PL \in \mathsf{P}\Longleftrightarrow \mathcal{C}= \mathsf{P}.

Note (C\mathcal{C}-hardness with respect to Cook and Karp reductions)

Above we have defined C\mathcal{C}-hardness using Cook reductions. In literature, however, they are often defined using Karp reductions, which actually leads to a different notion of C\mathcal{C}-hardness. There are good reasons to use this restricted form of reductions. More advanced courses may explore some of these reasons.

4 Check Your Understanding
Problem
  1. What is a Cook reduction? What is a Karp reduction? What is the difference between the two?

  2. Explain why every Karp reduction can be viewed as a Cook reduction.

  3. Explain why every Cook reduction cannot be viewed as a Karp reduction.

  4. True or false: ΣmP\Sigma^* \leq_m^P\varnothing.

  5. True or false: For languages AA and BB, AmPBA \leq_m^PB if and only if BmPAB \leq_m^PA.

  6. Define the complexity class P\mathsf{P}.

  7. True or false: The language 251CLIQUE={G: G is a graph containing a clique of size 251}\text{251CLIQUE} = \{\langle G \rangle : \text{ $G$ is a graph containing a clique of size 251}\} is in P\mathsf{P}.

  8. True or false: Let L,KΣL, K \subseteq \Sigma^* be two languages. Suppose there is a polynomial-time computable function f:ΣΣf : \Sigma^*\to\Sigma^* such that xLx\in L iff f(x)Kf(x)\notin K. Then LL Cook-reduces to KK.

  9. True or false: There is a Cook reduction from 3SAT to HALTS.

  10. For a complexity class C\mathcal{C} containing P\mathsf{P}, define what it means to be C\mathcal{C}-hard.

  11. For a complexity class C\mathcal{C} containing P\mathsf{P}, define what it means to be C\mathcal{C}-complete.

  12. Suppose LL is C\mathcal{C}-complete. Then argue why LPC=PL \in \mathsf{P}\Longleftrightarrow \mathcal{C}= \mathsf{P}.

5 High-Order Bits
Important Note
  1. There are two very important notions of reductions introduced in this chapter: Cook reductions and Karp reductions. Make sure you understand the similarities and differences between them. And make sure you are comfortable presenting and proving the correctness of reductions. This is the main goal of the chapter.

  2. The chapter concludes with a couple of important definitions: C\mathcal{C}-hardness, C\mathcal{C}-completeness. We present these definitions in this chapter as they are closely related to reductions. However, we will make use of these definitions in the next chapter after we introduce the complexity class NP\mathsf{NP}. For now, make sure you understand the definitions and also Note (C\mathcal{C}-completeness and P\mathsf{P}).

The in-degree of a gate is also known as the fan-in of the gate.
Technically, the black-box decider for \(B\) is called an oracle, and every call to the oracle is assumed to take 1 step. In these notes, we omit the formal definition of these reductions that require introducing oracle Turing machines. This semi-informal treatment is sufficient for our purposes.
Definition (\(k\)-colorable graphs)

Let \(G = (V,E)\) be a graph. Let \(k \in \mathbb{N}^+\). A \(k\)-coloring of \(V\) is just a map \(\chi : V \to C\) where \(C\) is a set of cardinality \(k\). (Usually the elements of \(C\) are called colors. If \(k = 3\) then \(C = \{\text{red},\text{green},\text{blue}\}\) is a popular choice. If \(k\) is large, we often just call the “colors” \(1,2, \dots, k\).) A \(k\)-coloring is said to be legal for \(G\) if every edge in \(E\) is bichromatic, meaning that its two endpoints have different colors. (I.e., for all \(\{u,v\} \in E\) it is required that \(\chi(u)\neq\chi(v)\).) Finally, we say that \(G\) is \(k\)-colorable if it has a legal \(k\)-coloring.

See in chapter
Note (Mapping reductions)

Many reductions \(L \leq K\) have the following very special structure. The TM \(M_L\) is such that on input \(x\), it first transforms \(x\) into a new string \(y = f(x)\) by applying some computable transformation \(f\). Then \(f(x)\) is fed into \(M_K\). The output of \(M_L\) is the same as the output of \(M_K\). In other words \(M_L(x) = M_K(f(x))\).

image

These special kinds of reductions are called mapping reductions (or many-one reductions), with the corresponding notation \(L \leq_m K\). Note that the reduction we have seen from \(\text{SA}_{\text{TM}}\) to \(\text{ACCEPTS}_{\text{TM}}\) is a mapping reduction, as well as the reduction from \(\text{ACCEPTS}_{\text{TM}}\) to \(\text{HALTS}_{\text{TM}}\). However, the reduction from \(\overline{\text{SA}_{\text{TM}}}\) to \(\text{SA}_{\text{TM}}\) is not a mapping reduction because the output of \(M_K\) is flipped, or in other words, we have \(M_L(x) = \textbf{not } M_K(f(x))\).

Almost all the reductions in this section will be mapping reductions.

Note that to specify a mapping reduction from \(L\) to \(K\), all one needs to do is specify a TM \(M_f\) that computes \(f : \Sigma^* \to \Sigma^*\) with the property that for any \(x \in \Sigma^*\), \(x \in L\) if and only if \(f(x) \in K\).

image

See in chapter
Theorem (CLIQUE reduces to IS)

\(\text{CLIQUE} \leq_m^P\text{IS}\).

See in chapter
Note (\(\mathcal{C}\)-completeness and \(\mathsf{P}\))

Suppose \(L\) is \(\mathcal{C}\)-complete. Then observe that \(L \in \mathsf{P}\Longleftrightarrow \mathcal{C}= \mathsf{P}\).

See in chapter