The Timpson Lyceum · Computation Theory
Lecture 15 (Computation Theory) Decidable and Undecidable Languages
Decidable and Undecidable Languages – Lecture 15
Overview
This lecture surveys which language-recognition problems can be solved by an algorithm and which cannot. Building on the Church–Turing thesis (an algorithm is exactly what a Turing machine can do) and the existence of a universal Turing machine, we prove that a whole family of natural questions about DFAs, NFAs, regular expressions, and context-free grammars are decidable. We then cross into undecidability: the acceptance problem for Turing machines, , is recognizable but not decidable. To set up that impossibility proof we develop Cantor's theory of set size — bijections, countable sets, and the diagonalization argument showing the real numbers are uncountable. The thread tying it together is the difference between being able to confirm "yes" answers and being able to settle every answer, yes or no.
Key Concepts
The language hierarchy. Every regular language is context-free, every context-free language is decidable, and every decidable language is Turing-recognizable. Each containment is strict.
Decidable vs. recognizable.
- A language is decidable if some Turing machine halts on every input and answers correctly: it accepts every string in the language and rejects every string not in it (it can confirm both "yes" and "no").
- A language is (Turing-)recognizable if some Turing machine accepts exactly the strings in the language, but may loop forever on strings not in it (it can confirm "yes," but not necessarily "no").
Encodings. Angle brackets denote an encoding of an object as a string, e.g. is the DFA and string packaged as a single input. Languages are sets of strings, so any machine, grammar, or pair must first be encoded.
Decidable problems about regular languages. Each of these languages is decidable:
- Acceptance for DFAs: . Decided by simulating on ; a DFA always halts after reading the finite input, so we accept iff it ends in an accept state.
- Acceptance for NFAs: . Decided by first converting the NFA to an equivalent DFA, then calling the decider as a subroutine.
- Acceptance for regular expressions: . Same idea — convert the regular expression to an equivalent DFA, then reuse the decider.
- Emptiness for DFAs: . Decided by a marking (reachability) procedure: mark the start state, repeatedly mark any state reachable from a marked state until nothing new is marked, then accept iff no accept state was marked.
- Equality for DFAs: . Decided using the symmetric difference . Because regular languages are closed under union, intersection, and complement, this is regular; build a DFA for it and run the decider. The two languages are equal iff their symmetric difference is empty.
Decidable problems about context-free languages.
- Chomsky normal form (CNF): every rule has the form (two variables) or (one terminal). Every CFG can be converted to CNF. Key fact: a derivation of a string of length in CNF takes exactly steps ( to build the variables, to convert them to terminals).
- Acceptance for CFGs: . Decided by converting to CNF and exhaustively listing all derivations of length (where ); accept iff appears. Only finitely many such derivations exist, so the search always terminates.
- Emptiness for CFGs: . Decided by a marking procedure that works backwards from the terminals: mark all terminals, then mark any variable all of whose right-hand-side symbols (for some rule) are marked, repeat until stable, and reject (non-empty) iff the start variable gets marked.
- Every context-free language is decidable: given a CFL , there is a CFG generating it; the decider for hard-codes and runs the decider on .
Acceptance for Turing machines is undecidable. is recognizable — the universal TM simulates on and accepts if accepts. But we cannot make it a decider: if loops, the simulation never returns, and unlike DFAs/CFGs there is no finite bound on the number of steps after which a TM must halt. turns out to be recognizable but undecidable, and its complement is not even recognizable.
Cardinality and bijections. Two sets have the same cardinality, , iff there is a bijection — a map that is onto (every element of is hit, so is not larger than ) and one-to-one (distinct inputs give distinct outputs, so is not larger than ).
Countable vs. uncountable. A set is countable if it is finite or has the same cardinality as . Examples of countably infinite sets: the even naturals, the integers , and (via dovetailing through the grid of fractions) the rationals . A set that is neither finite nor the size of is uncountable.
Diagonalization — the reals are uncountable. Assume a bijection exists. Build a real whose -th decimal digit differs from the -th digit of (e.g. use if that digit is , otherwise add ). Then for every , so is missed — is not onto, contradicting that it was a bijection. No such bijection exists, so (and hence ) is uncountable. This counting machinery is the engine behind proving undecidable.
Worked Example
Claim: the even natural numbers have the same cardinality as .
To show we exhibit a bijection and verify it is onto and one-to-one.
Every even natural is the image of some natural (onto), and equal outputs force equal inputs (one-to-one), so is a bijection and — halving an infinite set leaves its cardinality unchanged.
Summary
- Decidable means a TM halts and answers correctly on every input (settles yes and no); recognizable means it accepts the yes-instances but may loop on the no-instances.
- All of , , , , , , are decidable, and every context-free language is decidable — proofs reuse earlier deciders as subroutines and rely on finite halting bounds (DFAs halt after reading input; CNF derivations of have exactly steps).
- is decided via the symmetric difference: iff , which works because regular languages are closed under union, intersection, and complement.
- is recognizable (just simulate via the universal TM) but undecidable, because a TM has no finite halting bound and may loop forever.
- Cantor's framework defines equal size via a bijection; , , and are all countable, but diagonalization shows is uncountable — the key tool for the undecidability results to come.