CISC 462 — Lecture 8

Reducibility

We'll be looking at some examples of undecidable languages. To show that these languages are undecidable, we will be using an idea that is fairly central to theoretical computer science: reducibility. The idea behind reducibility is similar to some that you've already encountered in computer science by now. Essentially, it's the idea that you can be clever about using a solution to some other problem you've already solved. For instance, it is fairly labourious to show that a problem is undecidable by setting up a diagonalization argument every time. Instead, we want to be able to make use of results that we've already proved, which in this case would involve reducing a problem to some other problem that we know is already undecidable.

Informally, a reduction is a way of converting one problem into another problem in such a way that a solution to the second problem can be used to solve the first problem.

To start, we'll consider a problem that you've already seen: the halting problem. The halting problem is defined $$ HALT_{TM} = \{ \langle M,w \rangle \mid \text{$M$ is a TM and $M$ halts on input $w$} \}.$$

Theorem. $HALT_{TM}$ is undecidable.

Proof. Assume that there exists a Turing machine $H$ that decides $HALT_{TM}$. Then we can construct the following Turing machine to decide $A_{TM}$:

  1. On input $\langle M,w \rangle$, where $M$ is a TM and $w$ is a string, run TM $H$ on input $\langle M,w \rangle$.
  2. If $H$ rejects, reject.
  3. If $H$ accepts, simulate $M$ on $w$ until it halts.
  4. If $M$ accepts, then accept; if $M$ rejects, then reject.

So if $H$ decides $HALT_{TM}$, then we can decide $A_{TM}$ with the preceding TM. However, we know that $A_{TM}$ is undecidable, so this is a contradiction and $HALT_{TM}$ must be undecidable. $$\tag*{$\Box$}$$

Now, we can go and ask the same questions of TMs as we've been asking about DFAs and CFGs. As you'd probably expect, they are all undecidable. Let's consider the following language $$ E_{TM} = \{ \langle M \rangle \mid \text{$M$ is a TM and $L(M) = \emptyset$} \}. $$

Theorem. $E_{TM}$ is undecidable.

Proof. First, we construct a machine $M_w$ that operates in the following way:

  1. On input $x$, if $x \neq w$, reject.
  2. If $x = w$, run $M$ on input $w$ and accept if $M$ accepts.

The machine $M_w$ rejects every word that is not $w$. Then the only word that can be accepted is $w$. If $M_w$ doesn't accept $w$, then $L(M_w) = \emptyset$. Thus, $M_w$ recognizes the empty language if and only if it doesn't accept $w$.

Now, we assume that there exists a TM $R$ that decides $E_{TM}$ and construct a TM $S$ that decides $A_{TM}$ as follows:

  1. On input $\langle M,w \rangle$, where $M$ is an encoding of a TM and $w$ is an input string, construct $M_w$ as described.
  2. Run $R$ on $\langle M_w \rangle$
  3. If $R$ accepts, reject; if $R$ rejects, accept.

Thus, if $R$ decides $E_{TM}$, then $S$ decides $A_{TM}$. However, we know that $A_{TM}$ is undecidable, so $R$ cannot exist and $E_{TM}$ is undecidable. $$\tag*{$\Box$}$$

Here's another kind of question we can ask of Turing machines, since they are so powerful. We can ask whether or not the language of a TM can be recognized by a less powerful model of computation, like a DFA. Such a language is defined $$ REG_{TM} = \{ \langle M \rangle \mid \text{$M$ is a TM and $L(M)$ is a regular language} \}. $$ Or as it turns out, we can't ask that question because it is undecidable.

Theorem. $REG_{TM}$ is undecidable.

Proof. Let $R$ be a TM that decides $REG_{TM}$. Construct a TM $S$ that does the following:

  1. On input $\langle M,w \rangle$, where $M$ is a TM and $w$ is a string, construct the TM $M'$:
    1. On input $x$, if $x$ has the form $0^n 1^n$, accept.
    2. If $x$ doesn't have this form, run $M$ on $w$ and accept if $M$ accepts $w$.
  2. Run $R$ on $\langle M' \rangle$.
  3. If $R$ accepts, accept; if $R$ rejects, reject.

How does this work? The TM $M'$ accepts all strings in $\{0^n 1^n \mid n \geq 0\}$, which we know is context-free. If $M$ doesn't accept $w$, then $L(M') = \{0^n 1^n \mid n \geq 0\}$. If $M$ accepts $w$, then $M'$ also accepts every other string and in this case $L(M') = \Sigma^*$, which is regular. In this way, if there's a way to figure out whether $M'$ recognizes a regular language, then we can come up with a way to decide $A_{TM}$. $$\tag*{$\Box$}$$

Finally, let's consider the problem of equality between two TMs, specified as $$ EQ_{TM} = \{ \langle M_1, M_2 \rangle \mid \text{$M_1,M_2$ are TMs and $L(M_1) = L(M_2)$} \}. $$

Theorem. $EQ_{TM}$ is undecidable.

Proof. This time, we reduce from $E_{TM}$. Suppose we have a TM $R$ that decides $EQ_{TM}$. Then we can construct the following TM to decide $E_{TM}$.

  1. On input $\langle M \rangle$, where $M$ is a TM, run $R$ on $\langle M, N \rangle$, where $N$ is a TM that rejects all inputs.
  2. If $R$ accepts, accept; if $R$ rejects, reject.

Here, $N$ rejects all input so $L(N) = \emptyset$. If we test whether $M$ and $N$ accept the same language, then we're basically testing whether $L(M) = \emptyset$ and now we have a way to decide $E_{TM}$. $$\tag*{$\Box$}$$