Sub topic 9
Why Some Languages Have No Machine: Counting and Diagonalization
Assume you know finite and countably infinite sets, how Turing machines are encoded as strings, and proof by contradiction. This chapter explains why some languages cannot be recognized by any Turing machine.
Counting machines and languages
A Turing machine has a finite description. Its states, tape symbols, and transition rules can all be written as a finite string over a finite alphabet. Therefore, all Turing machines can be listed:
\[ M1, M2, M_3, \ldots \]
The set of all possible input strings, \(\Sigma^*\), can also be listed:
\[ w1, w2, w_3, \ldots \]
Thus, the set of Turing machines is countable. There are only countably many machine descriptions.
A language over \(\Sigma\) is any subset of \(\Sigma^\). Since \(\Sigma^\) is countable, a language can be represented by an infinite row of yes-or-no answers. Each position says whether one string belongs to the language.
However, the set of all subsets of a countably infinite set is uncountable. This is a result called Cantor's theorem. Consequently, there are uncountably many languages but only countably many Turing machines.
| Object | Number of objects |
|---|---|
| Turing machines | Countably infinite |
| Input strings | Countably infinite |
| Languages over the input alphabet | Uncountably infinite |
Since each machine can recognize at most one language, some languages cannot be recognized by any Turing machine. Counting proves that such languages exist, but it does not identify one directly.
The diagonal argument
Diagonalization constructs a language that differs from every machine on at least one input. Imagine a table whose rows are machines and whose columns are input strings. Put a 1 in cell \((i,j)\) if \(Mi\) accepts \(wj\). Put a 0 if it does not accept \(w_j\). A 0 includes both rejection and looping.
Define the diagonal language:
\[ D=\{wi \mid Mi \text{ does not accept } w_i\}. \]
For every machine \(Mi\), the language \(D\) disagrees with \(Mi\) on \(wi\). If \(Mi\) accepts \(wi\), then \(wi\notin D\). If \(Mi\) does not accept \(wi\), then \(w_i\in D\).
Therefore, no machine in the list recognizes \(D\). The list already contains every Turing machine, so no Turing machine recognizes \(D\).
Why this matters
Diagonalization shows a limit on computation. The result does not say that a particular program is difficult to write. It says that no program can recognize this language at all. Later undecidability proofs use the same strategy indirectly through reductions and the halting problem.
Exercise
Why does reversing the diagonal entry defeat machine Mi?
Show answer
The language D gives the opposite answer to whether Mi accepts wi. Thus Mi must be wrong on wi, so Mi cannot recognize D.