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 () is undecidable. The punchline: there exist well-defined problems for which no algorithm can ever exist.
Key Concepts
Decidable vs. recognizable.
- A language is decidable if some Turing machine halts on every input and correctly answers yes for strings in the language and no for strings not in it.
- A language is (Turing-)recognizable if some Turing machine answers yes for every string in the language, but may loop forever (never halt) on strings not in it.
- Every decidable language is recognizable; the converse fails.
Languages already known decidable (proved by constructing a deciding machine):
- , , — acceptance problems for DFAs, NFAs, and regular expressions.
- (emptiness) and (equivalence of two DFAs).
- (a grammar generates a string) and (emptiness); in fact every context-free language is decidable.
Same cardinality via bijection.
- if and only if there exists a bijection .
- A bijection is one-to-one (injective: equal outputs force equal inputs) and onto (surjective: every element of is hit).
- You need not count two sets to compare them — pairing their elements off suffices (e.g. left hands and right hands in a room).
Countable vs. uncountable.
- A set is countable if its cardinality is (finite, or in bijection with ).
- , , and are all countable — even though each appears "bigger" than the last.
- (and even just the open interval ) is uncountable: no bijection from exists.
Cantor diagonalization. To show is uncountable, assume a bijection exists and build a number that differs from in the -th decimal place (e.g. add 1 to that digit, mapping 9 to 8). Then for every , so is not onto — a contradiction. The same argument shows , the set of all infinite binary strings, is uncountable.
Counting Turing machines. Every Turing machine is built from finite sets, so each has a finite encoding 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 be the set of all binary languages — equivalently the power set of . One can biject with (map each language to its characteristic sequence: the -th bit is 1 iff the -th string of is in the language). Since is uncountable, so is . There are only countably many Turing machines, each recognizing exactly one language, so some languages are recognized by no machine at all.
is undecidable. . It is recognizable (simulate on and accept if does) but not decidable.
Problems = languages. A language is a computation theorist's encoding of a problem; "no Turing machine recognizes " 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 is undecidable (diagonalization). Assume, for contradiction, that is decidable, so some TM decides it:
Build a new machine that, on input , runs on paired with its own encoding and then flips the answer:
Now feed its own encoding :
This is a contradiction — both accepts and does not accept itself. Therefore cannot exist; but is easily built from , so cannot exist either. Hence no machine decides , and is undecidable. (Diagonally: list machines down the rows and their encodings across the columns, filling each cell with 's verdict; is forced to be the opposite of the diagonal entry, so when the diagonal reaches 's own row it must differ from itself.)
Summary
- Decidable means a TM halts and decides yes/no on every input; recognizable means it accepts every yes-instance but may loop on no-instances. Decidable recognizable.
- Two sets have equal cardinality exactly when a bijection (one-to-one and onto) connects them; this lets us compare infinite sets without counting.
- are countable; , the interval , and the set of infinite binary strings are uncountable, proved by diagonalization.
- Turing machines are countable (finite encodings), but the set of all languages is uncountable (it bijects with ), so unrecognizable languages must exist.
- The acceptance problem is recognizable but undecidable, proved by a self-referential machine that contradicts itself on its own encoding.
- Languages model problems, so undecidability means there are genuinely unsolvable problems — e.g. detecting in general whether a program halts/crashes, or whether a Diophantine equation has a solution.