Skip to content

Decidability

5.1 Decidable Languages

Theorem 5.1. The following languages are decidable:

  • A_{\mathrm{DFA} = \{\langle B, w \rangle : B \mathrm{ is a DFA that accepts w\}.
  • E_{\mathrm{DFA} = \{\langle B \rangle : B \mathrm{ is a DFA with L(B) = \emptyset\}.
  • \mathrm{EQ_{\mathrm{DFA} = \{\langle A, B \rangle : A, B \mathrm{ are DFAs with L(A) = L(B)\}.
  • A_{\mathrm{CFG} = \{\langle G, w \rangle : G \mathrm{ is a CFG that generates w\}.

Proof (for A_{\mathrm{DFA}). Simulate BB on input ww. This takes O(w)O(|w|) steps and always halts.

Proof (for E_{\mathrm{DFA}). Mark the start state. Repeatedly mark states reachable by Transitions from already-marked states. After no more states can be marked, check if any accept state Is marked. If not, L(B)=L(B) = \emptyset.

Proof (for \mathrm{EQ_{\mathrm{DFA}). Use the product construction to build a DFA for L(A)L(B)=(L(A)L(B))(L(A)L(B))L(A) \triangle L(B) = (L(A) \cap \overline{L(B)}) \cup (\overline{L(A)} \cap L(B)). Test if this DFA accepts any string (using the algorithm for E_{\mathrm{DFA}). \blacksquare

Additional decidable problems:

  • A_{\mathrm{REX} = \{\langle R, w \rangle : R \mathrm{ is a regex and w \in L(R)\} — convert RR to a DFA, then decide A_{\mathrm{DFA}.
  • E_{\mathrm{CFG} = \{\langle G \rangle : L(G) = \emptyset\} — test all derivations up to length 2V2^{|V|}.
  • \mathrm{INF_{\mathrm{CFL} = \{\langle G \rangle : L(G) \mathrm{ is infinite\} — check if any variable has a self-embedding derivation.

5.2 The Halting Problem

Theorem 5.2. A_{\mathrm{TM} = \{\langle M, w \rangle : M \mathrm{ is a TM and M \mathrm{ accepts w\} Is Turing-recognisable but undecidable.

Proof of recognisability. Simulate MM on ww. If MM accepts, accept. If MM rejects, reject. This recognises A_{\mathrm{TM}. \blacksquare

Proof of undecidability (by contradiction). Assume a decider HH for A_{\mathrm{TM} exists. Construct a TM DD that on input M\langle M \rangle:

  1. Run HH on M,M\langle M, \langle M \rangle \rangle.
  2. If HH accepts, reject.
  3. If HH rejects, accept.

Consider DD on input D\langle D \rangle:

  • If DD accepts D\langle D \rangleThen by construction DD rejects D\langle D \rangle. Contradiction.
  • If DD rejects D\langle D \rangleThen by construction DD accepts D\langle D \rangle. Contradiction.

Therefore HH cannot exist. \blacksquare

Theorem 5.2a. \overline{A_{\mathrm{TM}} is not Turing-recognisable.

Proof. If \overline{A_{\mathrm{TM}} were Turing-recognisable, then since A_{\mathrm{TM} is Also Turing-recognisable, A_{\mathrm{TM} would be decidable (run both recognisers in parallel; one Must accept). But A_{\mathrm{TM} is undecidable. Contradiction. \blacksquare

5.3 Reductions and Undecidability

A reduction from language AA to language BB is a computable function ff that maps instances of AA to instances of BB such that wA    f(w)Bw \in A \iff f(w) \in B.

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

Proof. To decide AA on input ww: compute f(w)f(w)Then decide BB on f(w)f(w). Since both steps are Computable, AA is decidable. \blacksquare

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

Applications. Using reductions from A_{\mathrm{TM}We can prove many problems undecidable:

LanguageDescriptionReduction from
\mathrm{HALT_{\mathrm{TM}\{M, w : M \mathrm{ halts on w\}A_{\mathrm{TM}
E_{\mathrm{TM}{M:L(M)=}\{M : L(M) = \emptyset\}A_{\mathrm{TM}
\mathrm{REGULAR_{\mathrm{TM}\{M : L(M) \mathrm{ is regular\}A_{\mathrm{TM}
\mathrm{EQ_{\mathrm{TM}{M1,M2:L(M1)=L(M2)}\{M_1, M_2 : L(M_1) = L(M_2)\}E_{\mathrm{TM}

Example reduction. A_{\mathrm{TM} \leq_m \mathrm{HALT_{\mathrm{TM}.

Proof. Given M,w\langle M, w \rangleConstruct a TM M"M" that on input xx: simulates MM on ww. If MM accepts, accept. If MM rejects, loop. Then \langle M, w \rangle \in A_{\mathrm{TM} iff MM' halts on some input (any input), iff \langle M' \rangle \in \mathrm{HALT_{\mathrm{TM}. \blacksquare

Worked Example: $A_{\mathrm{TM} \leq_m E_{\mathrm{TM}$

Proof. Given M,w\langle M, w \rangleConstruct a TM MwM_w that on input xx:

  1. Simulate MM on ww.
  2. If MM accepts wwAccept xx.
  3. If MM rejects wwReject xx.

Then L(Mw)=ΣL(M_w) = \Sigma^* if MM accepts wwAnd L(Mw)=L(M_w) = \emptyset if MM does not accept ww.

Therefore: \langle M, w \rangle \in A_{\mathrm{TM} iff L(Mw)L(M_w) \neq \emptyset Iff \langle M_w \rangle \notin E_{\mathrm{TM}.

The reduction f(M,w)=Mwf(\langle M, w \rangle) = \langle M_w \rangle is computable. So if E_{\mathrm{TM} Were decidable, \overline{E_{\mathrm{TM}} would be decidable, and hence A_{\mathrm{TM} Would be decidable — contradiction. \blacksquare

Worked Example: $E_{\mathrm{TM} \leq_m \mathrm{EQ_{\mathrm{TM}$

Proof. Given M\langle M \rangleConstruct two TMs:

  • M1M_1: on any input, immediately rejects. So L(M1)=L(M_1) = \emptyset.
  • M2M_2: on any input, simulates MM and accepts iff MM accepts. So L(M2)=L(M)L(M_2) = L(M).

Then L(M)=L(M) = \emptyset iff L(M1)=L(M2)L(M_1) = L(M_2).

Therefore \langle M \rangle \in E_{\mathrm{TM} iff \langle M_1, M_2 \rangle \in \mathrm{EQ_{\mathrm{TM}. If \mathrm{EQ_{\mathrm{TM} were decidable, E_{\mathrm{TM} would be decidable — contradiction. \blacksquare

5.4 Rice’s Theorem

Theorem 5.5 (Rice’s Theorem). Every non-trivial property of the language recognised by a Turing Machine is undecidable.

A property PP is a set of Turing-recognisable languages. It is non-trivial if PP is neither Empty nor the set of all Turing-recognisable languages.

Proof (sketch). Let PP be a non-trivial property. Since PP is non-trivial, there exists a TM M0M_0 with L(M0)PL(M_0) \in P and a TM M1M_1 with L(M1)PL(M_1) \notin P. Given an arbitrary TM MM and input wwConstruct MwM_w that on input xx: first simulates MM on wwThen simulates M0M_0 on xx. If MM accepts wwThen L(Mw)=L(M0)PL(M_w) = L(M_0) \in P; if MM does not accept ww, L(Mw)=L(M_w) = \emptyset. If P\emptyset \notin PThen MwPM_w \in P iff MM accepts wwSo deciding PP would decide ATMA_{\mathrm{TM}}. The case P\emptyset \in P is similar. \blacksquare

Corollary. The following are undecidable: “Does MM accept at least one string?”, “Is L(M)L(M) Finite?”, “Is L(M)L(M) regular?”, “Is L(M)L(M) context-free?”

:::caution Common Pitfall Rice’s theorem applies only to properties of the language L(M)L(M)Not properties of the machine MM itself. For example, “Does MM halt within 100 steps on input ww?” is a property Of MM‘s behaviour, not of L(M)L(M)And is in fact decidable (just simulate for 100 steps).

5.5 Post Correspondence Problem

Definition. An instance of the Post Correspondence Problem (PCP) consists of two lists of Strings α=(α1,,αk)\alpha = (\alpha_1, \ldots, \alpha_k) and β=(β1,,βk)\beta = (\beta_1, \ldots, \beta_k) over some Alphabet Σ\Sigma. A solution is a non-empty sequence of indices i1,i2,,imi_1, i_2, \ldots, i_m such That:

αi1αi2αim=βi1βi2βim\alpha_{i_1} \alpha_{i_2} \cdots \alpha_{i_m} = \beta_{i_1} \beta_{i_2} \cdots \beta_{i_m}

The PCP language is PCP={α,β:α,βhaveasolution}\mathrm{PCP} = \{\langle \alpha, \beta \rangle : \alpha, \beta \mathrm{ have} a solution\}.

Example. α=(a,ab,bba)\alpha = (a, ab, bba), β=(ba,aa,bb)\beta = (ba, aa, bb). The sequence (2,1,1,3)(2, 1, 1, 3) gives abaabba=abaabbaab \cdot a \cdot a \cdot bba = abaabba and aabababb=aabababbaa \cdot ba \cdot ba \cdot bb = aabababb — not equal. The sequence (1,3,1)(1, 3, 1) gives abbaa=abbaaa \cdot bba \cdot a = abbaa and babbba=babbaba \cdot bb \cdot ba = babba — not equal. This instance may or may not have a solution; determining this is undecidable .

Worked Example: A solvable PCP instance

α=(b,ba,aab)\alpha = (b, ba, aab), β=(bb,aa,ba)\beta = (bb, aa, ba).

Try the sequence (2,3,1)(2, 3, 1):

  • Top: α2α3α1=baaabb=baaabb\alpha_2 \alpha_3 \alpha_1 = ba \cdot aab \cdot b = baaab b
  • Bottom: β2β3β1=aababb=aababb\beta_2 \beta_3 \beta_1 = aa \cdot ba \cdot bb = aababb

Not equal.

Try (3,2,1,3,2,1)(3, 2, 1, 3, 2, 1):

  • Top: aabbabaabbab=aabbaabaabbaab \cdot ba \cdot b \cdot aab \cdot ba \cdot b = aabbaabaabb
  • Bottom: baaabbbaaabb=baabbbbaabbba \cdot aa \cdot bb \cdot ba \cdot aa \cdot bb = baabbbbaabb

Not equal. Finding solutions to PCP instances can be very difficult — there is no general algorithm.

Theorem 5.6. PCP is undecidable.

Proof (sketch). Reduce from ATMA_{\mathrm{TM}}. Given TM MM and input wwConstruct a PCP instance Whose tiles encode the computation history of MM on ww. The tiles are designed so that a matching Sequence corresponds to a valid accepting computation: the first tile starts the computation, middle Tiles enforce that each configuration follows from the previous by a valid transition, and the last Tile allows termination only if an accept state is reached. Thus the PCP instance has a solution iff MM accepts ww. The construction is computable, so if PCP were decidable, ATMA_{\mathrm{TM}} would Be decidable — contradiction. \blacksquare

Modified PCP (MPCP). In the modified version, the first tile used must be tile 1. MPCP is also Undecidable, and the reduction from PCP to MPCP adds a “prefix” tile that forces tile 1 to be used First.

5.6 Oracle Machines and the Arithmetical Hierarchy

An oracle machine MOM^O is a Turing machine with access to an oracle OO for a language OΣO \subseteq \Sigma^*. In addition to its ordinary transitions, MOM^O may enter a special “query state,” write a string qq on a query tape, and enter an “answer state” where the tape Contains 1 if qOq \in O and 0 if qOq \notin O. The oracle answers in one step.

Definition. AO={w:MOacceptsw}A^O = \{w : M^O \mathrm{ accepts} w\} for a fixed oracle TM MM and oracle OO.

Theorem 5.7. There exists an oracle AA such that PANPAP^A \neq NP^AAnd an oracle BB such That PB=NPBP^B = NP^B.

This result (Baker—Gill—Solovay, 1975) shows that resolving P=?NPP \stackrel{?}{=} NP will require Non-relativising techniques — …/1-number-and-algebra/3_proof-and-logic methods that do not carry over in the presence of oracles.

The Turing jump. Given a language AADefine the halting problem relative to AA:

A' = \{\langle M^A, w \rangle : M^A \mathrm{ accepts w\}

Theorem 5.8. A̸TAA' \not\leq_T A (i.e., AA' is strictly more difficult than AA under Turing Reductions).

The arithmetical hierarchy is defined by iterating the jump: (0)=\emptyset^{(0)} = \emptyset (n+1)=((n))\emptyset^{(n+1)} = (\emptyset^{(n)})'. Each jump produces a strictly more difficult problem, Yielding an infinite hierarchy of undecidability.

::: :::caution Common Pitfall A common mistake when using reductions is confusing the direction. To prove BB is undecidable Using a reduction from a known undecidable problem AAYou need AmBA \leq_m BNot BmAB \leq_m A. Remember: if AmBA \leq_m B and AA is undecidable, then BB is undecidable (contrapositive of “if BB is decidable then AA is decidable”). Reversing the direction gives a valid implication (“if BmAB \leq_m A and AA is undecidable, then…”) that tells us nothing about BB.

:::