The Timpson Lyceum seal

The Timpson Lyceum · Computation Theory

Lecture 16 (Computation Theory) Decidability and Undecidability

Decidability and Undecidability – Lecture 16

Overview

This lecture establishes the boundary between what computers can and cannot do. It opens by recapping the many languages already shown decidable (the acceptance and emptiness problems for DFAs, NFAs, regular expressions, and context-free grammars), then pivots to a fundamentally different kind of argument: proving that some problems are undecidable or even unrecognizable. The central tools are cardinality and diagonalization — the idea that two sets have the same size exactly when a bijection exists between them. Using these, we show the real numbers are uncountable, that there are uncountably many languages but only countably many Turing machines, and finally that the acceptance problem for Turing machines (ATMA_{TM}) is undecidable. The punchline: there exist well-defined problems for which no algorithm can ever exist.

Key Concepts

Decidable vs. recognizable.

Languages already known decidable (proved by constructing a deciding machine):

Same cardinality via bijection.

Countable vs. uncountable.

Cantor diagonalization. To show (0,1)(0,1) is uncountable, assume a bijection f:N→(0,1)f : \mathbb{N} \to (0,1) exists and build a number x=0.d1d2d3…x = 0.d_1 d_2 d_3 \ldots that differs from f(n)f(n) in the nn-th decimal place (e.g. add 1 to that digit, mapping 9 to 8). Then x≠f(n)x \neq f(n) for every nn, so ff is not onto — a contradiction. The same argument shows β\beta, the set of all infinite binary strings, is uncountable.

Counting Turing machines. Every Turing machine M=(Q,Σ,Γ,δ,q0,qaccept,qreject)M = (Q, \Sigma, \Gamma, \delta, q_0, q_{accept}, q_{reject}) is built from finite sets, so each has a finite encoding ⟨M⟩\langle M \rangle as a string. Listing all finite binary strings in order eventually lists every machine, so the set of Turing machines is countable.

An unrecognizable language must exist. Let LL be the set of all binary languages — equivalently the power set of Σ∗\Sigma^*. One can biject LL with β\beta (map each language to its characteristic sequence: the ii-th bit is 1 iff the ii-th string of Σ∗\Sigma^* is in the language). Since β\beta is uncountable, so is LL. There are only countably many Turing machines, each recognizing exactly one language, so some languages are recognized by no machine at all.

ATMA_{TM} is undecidable. ATM={ ⟨M,w⟩∣M is a TM that accepts w }A_{TM} = \{\,\langle M, w\rangle \mid M \text{ is a TM that accepts } w\,\}. It is recognizable (simulate MM on ww and accept if MM does) but not decidable.

Problems = languages. A language is a computation theorist's encoding of a problem; "no Turing machine recognizes LL" means "no algorithm solves that problem." Practical consequences: no compiler/IDE can decide in general whether an arbitrary program crashes (the halting problem), and there is no general algorithm to decide whether an arbitrary Diophantine equation has an integer solution (recognizable but not decidable). The halting problem is the usual alternative starting point; its proof mirrors the one below.

Worked Example

Proving ATMA_{TM} is undecidable (diagonalization). Assume, for contradiction, that ATMA_{TM} is decidable, so some TM HH decides it:

H(⟨M,w⟩)=accept  ⟺  M accepts wH(⟨M,w⟩)=reject  ⟺  M does not accept w\begin{aligned} H(\langle M, w\rangle) &= \texttt{accept} \iff M \text{ accepts } w \\ H(\langle M, w\rangle) &= \texttt{reject} \iff M \text{ does not accept } w \end{aligned}

Build a new machine DD that, on input ⟨M⟩\langle M\rangle, runs HH on MM paired with its own encoding and then flips the answer:

D(⟨M⟩)=accept  ⟺  H(⟨M,⟨M⟩⟩)=reject=accept  ⟺  M does not accept ⟨M⟩\begin{aligned} D(\langle M\rangle) &= \texttt{accept} \iff H(\langle M, \langle M\rangle\rangle) = \texttt{reject} \\ &= \texttt{accept} \iff M \text{ does not accept } \langle M\rangle \end{aligned}

Now feed DD its own encoding ⟨D⟩\langle D\rangle:

D accepts ⟨D⟩  ⟺  D does not accept ⟨D⟩\begin{aligned} D \text{ accepts } \langle D\rangle &\iff D \text{ does not accept } \langle D\rangle \end{aligned}

This is a contradiction — DD both accepts and does not accept itself. Therefore DD cannot exist; but DD is easily built from HH, so HH cannot exist either. Hence no machine decides ATMA_{TM}, and ATMA_{TM} is undecidable. (Diagonally: list machines M1,M2,…M_1, M_2, \ldots down the rows and their encodings across the columns, filling each cell with HH's verdict; DD is forced to be the opposite of the diagonal entry, so when the diagonal reaches DD's own row it must differ from itself.)

Summary