Countability and Cantor Diagonalisation
Context: FIT2014_MOC · how big are infinite sets? · the argument that there are more languages than descriptions — the seed of undecidability later in the unit
Quick Revision
- 🎯 Objective: a set is countable if it is finite or in bijection with ➔ are countable, but the set of all languages is uncountable.
- ⚡ Key Constraint: the consequence — since descriptions (programs, regexes, grammars) form a countable set but languages are uncountable, most languages have no finite description at all.
📝 Countability
- Definition ➔ a set is countable if either it is finite, or it can be put in one-to-one correspondence (bijection) with .
- is countable ➔ trivially, by the identity correspondence
- is countable ➔ interleave the signs: — every integer is reached.
- is countable ➔ list words in length order, alphabetically within each length: — every finite word appears at a finite position.
- Key idea ➔ “countable” means listable: you can enumerate the elements so that every element eventually appears.
🧮 Formal Proof Blueprint — the set of all languages is uncountable
Theorem (Cantor). The set of all languages (over a fixed ) is uncountable.
Strategy. Proof by contradiction + diagonalisation: assume a listing exists, then construct a language that cannot be anywhere on it.
Derivation.
Therefore the set of all languages is uncountable.
- Why “diagonal” ➔ picture rows against columns with a tick when ; is built by walking the main diagonal and inverting every entry, guaranteeing a mismatch with row at column .
💥 Why this matters
- Descriptions are countable ➔ regular expressions, grammars and programs are finite strings over a finite alphabet, so they form a countable set.
- Languages are uncountable ➔ therefore no description system can capture every language — there are strictly more languages than finite descriptions.
- Foreshadowing ➔ this counting gap is the reason unsolvable problems exist at all; it returns as undecidability and the halting problem later in the unit.
⚠️ Common Mistakes
- 💡 Countable ≠ finite ➔ countable includes countably infinite ( are all infinite yet countable). The contrast is countable vs uncountable.
- 💡 is countable but languages is not ➔ the words are listable; the sets of words are not. A language is a subset of , and the powerset jumps in size.
- 💡 The diagonal language must be genuinely new ➔ the force of the argument is that is a perfectly legitimate language yet provably absent from the list; if you only showed it differed from some , there’d be no contradiction.
🧠 Active Recall
is countable. Why doesn't that make the set of all languages countable too?
Answer
- Short answer: a language is a subset of , so the set of all languages is the powerset of . Cantor’s diagonal argument shows this powerset cannot be listed — given any listing , the language defined by differs from every .
- Why: Listing words ≠ listing sets of words ➔ enumerating elements is strictly easier than enumerating subsets; the diagonal construction always escapes any proposed enumeration of the subsets.
What does uncountability of languages imply about regular expressions and programs?
Answer
- Short answer: every regex/grammar/program is a finite string, so descriptions are countable; languages are uncountable; hence almost all languages have no finite description — no regex, no grammar, no program decides them.
- Why: Cardinality mismatch ➔ a countable set cannot surject onto an uncountable one, so any description formalism necessarily misses (uncountably) many languages — the counting foundation of later undecidability results.