Mapping Reductions

The goal of a reduction proof is to bootstrap what we already know, arguing that since XX is not decidable (or not semidecidable), YY can’t be decidable (or semidecidable) either. One particularly convenient form of reduction is mapping reduction (also known as many-one reduction).

We say that PmQP \leq_m Q if there is a computable function f:ΣΣf:\Sigma^* \to \Sigma^* such that

xPf(x)Qx\in P\quad\leftrightarrow\quad f(x)\in Q

for all xΣx\in \Sigma^*.

The intuition is this: we have a language PP and a string xx which may or may not be in PP.

Is x in P?

The trick is that instead of answering “is xx in PP?” directly, we can ask the question “is f(x)f(x) in QQ?” for some computable function ff chosen so that the answers to the two questions are the same.

A generic mapping reduction

As soon as we find a computable function ff with this property, we have a mapping reduction PmQP \leq_m Q; any question about membership in PP can be turned into a question about membership in QQ, and so determining membership in PP cannot be any harder than determining membership in QQ.

Theorem

Suppose PmQP \leq_m Q.

  1. If PP is not decidable, then QQ is not decidable.
  2. If PP is not semidecidable, then QQ is not semidecidable.

Proof:

  1. Suppose xPx\in P iff f(x)Qf(x)\in Q. If ff is a function that a TM can compute, then given any algorithm decide_Q, we can write a decider for PP that uses the following algorithm:

    def decide_P(x):
         return decide_Q(f(x))

    It follows that if QQ is decidable then so is PP.
    By the contrapositive, if PP is not decidable, then QQ is not decidable.

  2. Suppose xPx\in P iff f(x)Qf(x)\in Q. If ff is a function that a TM can compute, then given any algorithm semidecide_Q, we can write a semidecider for PP that uses the following algorithm:

    def semidecide_P(x):
         return semidecide_Q(f(x))

    It follows that if QQ is semidecidable then so is PP.
    By the contrapositive, if PP is not semidecidable, then QQ is not semidecidable.

We have already seen that

ATM={ M,w  wL(M) }A_\mathrm{TM} = \{\ \langle M, w\rangle\ |\ w\in L(M)\ \}

is not decidable, and that

¬ATM={ M,w  w∉L(M) }\lnot A_\mathrm{TM} = \{\ \langle M, w\rangle\ |\ w\not\in L(M)\ \}

is not semidecidable, which gives us:

Corollary

  1. If ATMmLA_\mathrm{TM} \leq_m L then LL is not decidable.
  2. If ¬ATMmL\lnot A_\mathrm{TM} \leq_m L then LL is not semidecidable.

Proving Mapping Reductions

What does a proof look like?

A typical mapping reduction proof that L1mL2L_1\leq_m L_2 goes as follows:

[Define a function ff mapping strings to strings.]
[If nonobvious, explain why ff is computable.]
[Show that if xL1x\in L_1 then f(x)L2f(x) \in L_2.]
[Show that if x∉L1x\not\in L_1 then f(x)∉L2f(x)\not\in L_2.]
Therefore xL1x\in L_1 iff f(x)L2f(x)\in L_2, so L1L_1 map-reduces to L2L_2.
QED.

Why is this useful?

A successful proof (exhibiting a function ff that maps strings in L1L_1 to strings in L2L_2 and maps strings not in L1L_1 to strings not in L2L_2) guarantees that L1L2L_1 \leq L_2 both in terms of decidability (if L1L_1 is not decidable then L2L_2 is not decidable) and in terms of semidecidability (if L1L_1 is not semidecidable then L2L_2 is not semidecidable).

This means that if we do a mapping-reduction proof where L1L_1 is a language like ATMA_\mathrm{TM} that we already know is not decidable, then just finding a suitable function ff guarantees that L2L_2 is not decidable.

And if we do a mapping-reduction proof where L1L_1 is a language like ¬ATM\lnot A_\mathrm{TM} that we already know is not semidecidable, then just finding a suitable function ff guarantees that L2L_2 is not semidecidable.

Examples

Example

We previously showed that the language

NETM={ M  L(M) }\mathit{NE}_\mathrm{TM} = \{\ \langle M\rangle\ |\ L(M) \not= \emptyset\ \}

of Turing Machines (programs) that accept at least one string is semidecidable.

Let ff be the function that takes M,w\langle M,w\rangle and returns (the code for) a Turing Machine MM' that ignores its input, and instead simulates MM running on the specific input ww.

Clearly ff is computable. (Given the code for MM and a specific string ww, we can produce a slightly longer piece of code that ignores its input and runs the code MM on the specific string ww.).

Note that ff does not run MM on ww! The input of ff is a piece of code and a string; the output is a slightly longer piece of code.

  • If M,wATM\langle M,w\rangle\in A_\mathrm{TM}, then L(M)=ΣL(M') = \Sigma^*, and so MNETMM' \in \mathit{NE}_\mathrm{TM}.

If MM accepts ww, a Turing Machine that ignores its input and runs MM on ww will accept not matter what input we provide.

  • If M,w∉ATM\langle M,w\rangle\not\in A_\mathrm{TM}, then L(M)=L(M') = \emptyset, and so M∉NETMM' \not\in \mathit{NE}_\mathrm{TM}.

    If MM does not accept ww, a Turing Machine that ignores its input and runs MM on ww will not accept any input we provide.

So M,wATM\langle M,w\rangle\in A_\mathrm{TM} if and only if f(M,w)=MNETMf(\langle M,w\rangle) = M'\in \mathit{NE}_\mathrm{TM} .

This proves ATMmNETMA_\mathrm{TM} \leq_m \mathit{NE}_\mathrm{TM} and so NETM\mathit{NE}_\mathrm{TM} is not decidable.


Intuitively, the above proof shows that NETM\mathit{NE}_\mathrm{TM} is not decidable because it is “harder than” the undecidable language ATMA_\mathrm{TM}, as shown by the following mapping reduction:

A_tm map-reduces to NEtm

which shows that if we had a decider for NETM\mathit{NE}_\mathrm{TM} (on the right) then we could combine it with this mapping function ff to build a decider for ATMA_\mathrm{TM} (on the left).

Example

There is no algorithm that can always tell us whether an arbitrary TM (code) accepts the string abba and nothing else. That is, the language

abbafanatics:={ M  L(M)={abba} }\mathtt{abba}{-}\mathit{fanatics}\quad:=\quad\{\ \langle M\rangle\ |\ L(M) = \{\mathtt{abba}\}\ \}

is not decidable.


To show: ATMmabbafanaticsA_\mathrm{TM} \leq_m \mathtt{abba}{-}\mathit{fanatics}

Let ff be the function that takes M,w\langle M,w\rangle and returns (the code for!) a Turing Machine MM' that accepts its input if the input is abba and MM accepts ww.

  • If M,wATM\langle M,w\rangle\in A_\mathrm{TM}, then L(M)={abba}L(M') = \{\mathtt{abba}\}.
  • If M,w∉ATM\langle M,w\rangle\not\in A_\mathrm{TM}, then L(M)={abba}L(M') = \emptyset \not= \{\mathtt{abba}\}.

So M,wATM\langle M,w\rangle\in A_\mathrm{TM} if and only if f(M,w)=Mabbafanaticsf(\langle M,w\rangle) = M'\in \mathtt{abba}{-}\mathit{fanatics} , as required.

A_tm map-reduces to abba-fanatics

Example

There is no algorithm that can always tell us whether an arbitrary TM (code) could be reimplemented as a DFA. That is, the language

DFAlike:={ M  L(M) is regular }\mathit{DFA{-}like}\quad:=\quad\{\ \langle M\rangle\ |\ L(M) \mathrm{~is~regular}\ \}

is not decidable.


To show: ATMmDFAlikeA_\mathrm{TM} \leq_m \mathit{DFA{-}like}

Let ff be the function that takes M,w\langle M,w\rangle and returns (the code for!) a Turing Machine MM' that accepts its input if the input has the form 0n1n\mathtt{0}^n\mathtt{1}^n for some n0n\geq 0 or if MM accepts ww.

  • If M,wATM\langle M,w\rangle\in A_\mathrm{TM}, then L(M)=ΣL(M') = \Sigma^{*} (which is regular).
  • If M,w∉ATM\langle M,w\rangle\not\in A_\mathrm{TM}, then L(M)={  0n1n  n0 }L(M') = \{\ \ 0^n1^n\ |\ n\geq 0\ \} (non-regular).

So M,wATM\langle M,w\rangle\in A_\mathrm{TM} if and only if f(M,w)=MDFAlikef(\langle M,w\rangle) = M'\in \mathit{DFA{-}like}, as required.

A_tm map-reduces to DFA-like

Example

In fact, the language

DFAlike:={ M  L(M) is regular }\mathit{DFA{-}like}\quad:=\quad\{\ \langle M\rangle\ |\ L(M) \mathrm{~is~regular}\ \}

of TMs equivalent to some DFA is not even semidecidable.


To show: ¬ATMmDFAlike\lnot A_\mathrm{TM} \leq_m \mathit{DFA{-}like}

Let ff be the function that takes M,w\langle M,w\rangle and returns (the code for!) a Turing Machine MM' that accepts its input if the input has the form 0n1n\mathtt{0}^n\mathtt{1}^n for some n0n\geq 0 and MM accepts ww.

  • If M,w¬ATM\langle M,w\rangle\in \lnot A_\mathrm{TM}, then L(M)=L(M') = \emptyset (which is regular).
  • If M,w∉¬ATM\langle M,w\rangle\not\in \lnot A_\mathrm{TM}, then L(M)={  0n1n  n0 }L(M') = \{\ \ 0^n1^n\ |\ n\geq 0\ \} (which is not regular).

So M,wATM\langle M,w\rangle\in A_\mathrm{TM} if and only if f(M,w)=MDFAlikef(\langle M,w\rangle) = M'\in \mathit{DFA{-}like}, as required.

Since DFAlike\mathit{DFA{-}like} is not semidecidable, it is also not decidable. Had we done this reduction first, we could have skipped the previous Example.

A_tm map-reduces to DFA-like

Example

The language

EQTM={ M1,M2  L(M1)=L(M2) }\mathit{EQ}_\mathrm{TM} = \{\ \langle M_1,M_2\rangle\ |\ L(M_1) =L(M_2)\ \}

is not even semidecidable.

Proof. We will prove that ETMEQTME_\mathrm{TM} \leq \mathit{EQ}_\mathrm{TM} .
Let ff be the function that turns the code M\langle M\rangle into the pair M,N\langle M,N\rangle where NN is a Turing Machine that rejects all strings.

(It’s not difficult to define a TM that rejects all strings; we just pick one and call it NN, and then define ff to be the function that returns its input MM paired with the fixed piece of code NN.)

  • If METM\langle M\rangle\in E_\mathrm{TM}, then L(M)==L(N)L(M) = \emptyset = L(N), so M,NEQTM\langle M,N\rangle\in\mathit{EQ}_\mathrm{TM}.
  • If M∉ETM\langle M\rangle\not\in E_\mathrm{TM}, then L(M)=L(N)L(M) \not= \emptyset = L(N), so M,N∉EQTM\langle M,N\rangle\not\in\mathit{EQ}_\mathrm{TM} .