knowledge

Theory of Computation: Lecture 6

Computable functions, mapping reductions, reduction-based undecidability proofs, ATM reductions to HALT and REG_TM, and unrecognizability via EQ_TM.

From Hard Problems to Reductions

Concrete undecidable and unrecognizable languages, such as ATMA_{\mathrm{TM}} and ATM\overline{A_{\mathrm{TM}}}, become tools once they can be transformed into other problems. Reductions turn one hard example into a method: to prove that a new problem is hard, show that a known hard problem can be translated into it.

Reduction. A transformation from instances of one decision problem to instances of another decision problem that preserves yes/no answers.

A reduction says: if I had a solver for the target problem, I could solve the source problem by translating the input first.

The direction matters. If AA reduces to BB, then BB is at least as hard as AA:

  • if BB is decidable, then AA is decidable;
  • if AA is undecidable, then BB is undecidable.

Example 1. DFA nonemptiness as reachability.

Let

NEDFA={DD is a DFA and L(D)}.NE_{\mathrm{DFA}}=\{\langle D\rangle\mid D\text{ is a DFA and }L(D)\ne\varnothing\}.

Let

Lpath={G,v,wG is a directed graph and there is a path from v to w}.L_{\mathrm{path}}=\{\langle G,v,w\rangle\mid G\text{ is a directed graph and there is a path from }v\text{ to }w\}.

Given a DFA D=(Q,Σ,δ,q0,F)D=(Q,\Sigma,\delta,q_0,F), build a directed graph from its transition graph, ignore transition labels, add a fresh target vertex tt, and add an edge qtq\to t from every accepting state qFq\in F. Then:

L(D)there is a path from q0 to t.L(D)\ne\varnothing \quad\Longleftrightarrow\quad \text{there is a path from }q_0\text{ to }t.
DFA Dq0q1qf011accepting state reachablefGraph instanceq0q1qftpath from q0 to t<D> maps to <G,q0,t>; transition labels are dropped
DFA Dq0q1qf011accepting state reachablefGraph instanceq0q1qftpath from q0 to t<D> maps to <G,q0,t>labels are dropped
DFA nonemptiness becomes reachability: an accepting state is reachable iff the target is reachable.

The transformation does not decide whether DD is nonempty. It only builds the graph instance. The path solver, if available, answers the translated question.

Mapping Reductions

To use reductions inside Turing-machine proofs, the transformation itself must be algorithmic.

Computable function. A total function f:ΣΣf:\Sigma^*\to\Sigma^* is computable if some Turing machine halts on every input ww with exactly f(w)f(w) on its tape.

Totality is essential: the reduction must always finish producing the translated instance, even when the instance it produces contains a machine that may later loop.

Mapping reduction. A language AA is mapping reducible to a language BB, written AmBA\le_m B, if there is a computable function f:ΣΣf:\Sigma^*\to\Sigma^* such that for every string ww,

wAf(w)B.w\in A \quad\Longleftrightarrow\quad f(w)\in B.
  • Computability. The function ff can be produced by a decider-like TM that halts on every input.
  • Correctness. Membership is preserved exactly, both for yes-instances and for no-instances.

The function need not be surjective. Some instances of BB may never appear as f(w)f(w).

decider for Awff(w)MBcomputabletotaldecider for Bcorrectness condition: w in A iff f(w) in B
decider for Awff(w)MBcomputabletotaldecider for Bcorrectness:w in A iff f(w) in B
If a decider for B exists, compose it with the reduction to decide A.

Theorem. If AmBA\le_m B and BB is decidable, then AA is decidable.

Proof. Let MBM_B decide BB, and let ff be a mapping reduction from AA to BB. Construct a TM NN:

  1. On input ww, compute f(w)f(w).
  2. Run MBM_B on input f(w)f(w).
  3. Output whatever MBM_B outputs.

NN halts because ff is computable and MBM_B is a decider. Also,

N accepts wMB accepts f(w)f(w)BwA.N\text{ accepts }w \quad\Longleftrightarrow\quad M_B\text{ accepts }f(w) \quad\Longleftrightarrow\quad f(w)\in B \quad\Longleftrightarrow\quad w\in A.

So NN decides AA.

Corollary. If AmBA\le_m B and AA is undecidable, then BB is undecidable.

Otherwise, a decider for BB would give a decider for AA, contradicting the known undecidability of AA.

Recipe: proving undecidability by mapping reduction.

  1. Choose a known undecidable language AA.
  2. For an arbitrary input ww of AA, construct an instance f(w)f(w) of the target language BB.
  3. Prove that ff is computable. Usually this means showing that a TM can write down the code of the new machine without running it.
  4. Prove the two cases: wAf(w)Bw\in A\Rightarrow f(w)\in B and wAf(w)Bw\notin A\Rightarrow f(w)\notin B.
  5. Conclude that BB is undecidable.

The reduction must translate instances, not solve the source problem while translating.

Undecidability Examples

The halting problem can be reproved cleanly as a mapping-reduction result. Use the notation

HALTTM={M,wM is a TM and M halts on w},\mathrm{HALT}_{\mathrm{TM}}= \{\langle M,w\rangle\mid M\text{ is a TM and }M\text{ halts on }w\},

the same language previously denoted HALT\mathrm{HALT}.

Theorem. ATMmHALTTMA_{\mathrm{TM}}\le_m\mathrm{HALT}_{\mathrm{TM}}. Therefore HALTTM\mathrm{HALT}_{\mathrm{TM}} is undecidable.

Given x=M,wx=\langle M,w\rangle, define

f(x)=M,w,f(x)=\langle M',w\rangle,

where MM' is the following machine:

  1. On input yy, run MM on ww.
  2. If MM accepts ww, accept yy.
  3. If MM rejects ww, loop forever.

The function ff is computable because it only writes the code of MM' with MM and ww embedded inside it. It does not run MM'.

If M,wATM\langle M,w\rangle\in A_{\mathrm{TM}}, then MM accepts ww, so MM' accepts every input, in particular ww. Thus M,wHALTTM\langle M',w\rangle\in\mathrm{HALT}_{\mathrm{TM}}.

If M,wATM\langle M,w\rangle\notin A_{\mathrm{TM}}, then MM either rejects or loops on ww. In either case MM' does not halt on any input: it loops explicitly after rejection, or it waits forever for MM to halt. Thus M,wHALTTM\langle M',w\rangle\notin\mathrm{HALT}_{\mathrm{TM}}.

So ff is a mapping reduction from ATMA_{\mathrm{TM}} to HALTTM\mathrm{HALT}_{\mathrm{TM}}. Since ATMA_{\mathrm{TM}} is undecidable, HALTTM\mathrm{HALT}_{\mathrm{TM}} is undecidable.

Regularity of TM languages.

REGTM={NN is a TM and L(N) is regular}.REG_{\mathrm{TM}}= \{\langle N\rangle\mid N\text{ is a TM and }L(N)\text{ is regular}\}.

Unlike EDFAE_{\mathrm{DFA}} or EQDFAEQ_{\mathrm{DFA}}, this problem asks a property of a Turing machine's language. The machine itself is finite, but the language it accepts may be non-regular, undecidable, or only recognizable.

Theorem. REGTMREG_{\mathrm{TM}} is undecidable.

Reduce from ATMA_{\mathrm{TM}}. Let

B={0n1nn0},B=\{0^n1^n\mid n\ge 0\},

which is non-regular. Given x=M,wx=\langle M,w\rangle, output f(x)=Mf(x)=\langle M'\rangle, where MM' is:

  1. On input yy, if yBy\in B, accept.
  2. Otherwise, run MM on ww.
  3. Accept yy iff MM accepts ww.
<M,w>f<M'>RREGM' on input yy in B?acceptrun M on wacceptno acceptyesnoacceptsotherwiseif M accepts w: L(M') = Sigma*otherwise: L(M') = B = {0n1n | n >= 0}
<M,w>f<M'>RREGM' on input yy in B?acceptrun M on wno acceptacceptyesnootherwiseacceptsif M accepts w: L(M') = Sigma*otherwise:L(M') = B = {0n1n | n >= 0}
The reduction builds M' so its language is either all strings or the known non-regular language B.

The test yBy\in B is decidable by a Turing machine: check that the input has the form 010^*1^* and that the two block lengths match.

If M,wATM\langle M,w\rangle\in A_{\mathrm{TM}}, then MM accepts ww. Every yBy\in B is accepted by step 1, and every yBy\notin B is accepted by step 3. Hence

L(M)={0,1},L(M')=\{0,1\}^*,

which is regular.

If M,wATM\langle M,w\rangle\notin A_{\mathrm{TM}}, then MM does not accept ww. The only strings accepted by MM' are the strings caught by step 1, so

L(M)=B,L(M')=B,

which is non-regular.

Thus

M,wATMMREGTM.\langle M,w\rangle\in A_{\mathrm{TM}} \quad\Longleftrightarrow\quad \langle M'\rangle\in REG_{\mathrm{TM}}.

So ATMmREGTMA_{\mathrm{TM}}\le_m REG_{\mathrm{TM}}, and REGTMREG_{\mathrm{TM}} is undecidable.

Recognizability and Equality of TM Languages

The same pipeline works for recognizers, but the conclusion is weaker because recognizers may loop on no-instances.

recognizer for Awff(w)RBcomputabletotalrecognizer for Bcorrectness condition: w in A iff f(w) in B
recognizer for Awff(w)RBcomputabletotalrecognizer for Bcorrectness:w in A iff f(w) in B
If a recognizer for B exists, compose it with the reduction to recognize A.

Theorem. If AmBA\le_m B and BB is recognizable, then AA is recognizable.

Let RBR_B recognize BB, and let ff reduce AA to BB. On input ww, compute f(w)f(w) and run RBR_B on f(w)f(w). The resulting machine accepts exactly when

wAf(w)BRB accepts f(w).w\in A \quad\Longleftrightarrow\quad f(w)\in B \quad\Longleftrightarrow\quad R_B\text{ accepts }f(w).

If wAw\notin A, then f(w)Bf(w)\notin B, so RBR_B may reject or loop. That is allowed for recognizers.

Corollary. If AmBA\le_m B and AA is unrecognizable, then BB is unrecognizable.

TM language equivalence.

EQTM={M1,M2M1,M2 are TMs and L(M1)=L(M2)}.EQ_{\mathrm{TM}}= \{\langle M_1,M_2\rangle\mid M_1,M_2\text{ are TMs and }L(M_1)=L(M_2)\}.

For DFAs, equivalence was decidable by product construction and reachability. For Turing machines, equality of recognized languages is not even recognizable.

Theorem. EQTMEQ_{\mathrm{TM}} is unrecognizable.

Use the known unrecognizable language ATM\overline{A_{\mathrm{TM}}}. Given x=M,wx=\langle M,w\rangle, construct

f(x)=M1,M2f(x)=\langle M_1,M_2\rangle

where:

Machine M1M_1. On input yy, run MM on ww. If MM accepts ww, accept yy. If MM rejects ww, loop forever.

Machine M2M_2. On input yy, reject.

If M,wATM\langle M,w\rangle\in\overline{A_{\mathrm{TM}}}, then MM does not accept ww. The machine M1M_1 accepts no string, and M2M_2 also accepts no string. Hence

L(M1)==L(M2),L(M_1)=\varnothing=L(M_2),

so M1,M2EQTM\langle M_1,M_2\rangle\in EQ_{\mathrm{TM}}.

If M,wATM\langle M,w\rangle\notin\overline{A_{\mathrm{TM}}}, then MM accepts ww. The machine M1M_1 accepts every input, while M2M_2 accepts none:

L(M1)=ΣandL(M2)=.L(M_1)=\Sigma^* \quad\text{and}\quad L(M_2)=\varnothing.

So M1,M2EQTM\langle M_1,M_2\rangle\notin EQ_{\mathrm{TM}}.

Therefore

ATMmEQTM.\overline{A_{\mathrm{TM}}}\le_m EQ_{\mathrm{TM}}.

Since ATM\overline{A_{\mathrm{TM}}} is unrecognizable, EQTMEQ_{\mathrm{TM}} is unrecognizable. In particular, it is undecidable.