Undecidability
Not all problems can be solved by algorithms. Some are undecidable — no Turing machine exists that always halts and correctly answers the question.
Diagonalization
Cantor's diagonalization showed: The set of all languages over
Countability of TMs
Every TM can be encoded as a finite binary string
Conclusion: There exist languages that are not RE (most languages, in fact).
is Undecidable
Theorem:
Proof by diagonalization: Suppose there is a decider
Construct the "diagonal" TM
D(<M>):
Run H(<M, <M>>)
If H accepts, reject
If H rejects, acceptNow, what does
- If
accepts , then accepts, meaning rejects — contradiction - If
rejects , then rejects, meaning accepts — contradiction
Therefore,
The Halting Problem
Theorem:
Proof by reduction from
S(<M, w>):
Run R(<M, w>)
If R rejects, reject (M doesn't halt, so can't accept)
If R accepts, simulate M on w until it halts
If M accepts, accept
If M rejects, rejectProving Undecidability by Reduction
To prove problem
A mapping reduction from
Notable Undecidable Problems
: Emptiness of TM Language
Undecidable (not even RE). Reduction from
: Equivalence of TMs
Undecidable (not RE). Reduction from
: Is Regular?
Undecidable (not RE). Rice's Theorem applies.
: Is Context-Free?
Similarly undecidable.
Rice's Theorem
Any nontrivial property of the RE languages is undecidable.
A property
- There exists a TM
such that - There exists a TM
such that
Formal Statement
Let
is undecidable.
Consequences
Almost every semantic question about programs is undecidable:
- Does the program halt on all inputs?
- Does the program compute
? - Is the program's output always positive?
- Are two programs equivalent?
- Does the program contain a virus?
Rice's Theorem says: you cannot algorithmically determine any nontrivial behavioral property of programs by inspecting their code.
Post's Correspondence Problem (PCP)
Given two lists of strings
Theorem: PCP is undecidable.
PCP is a powerful tool for proving undecidability — many problems (ambiguity of CFGs, emptiness of intersection of CFLs, etc.) reduce to PCP.
The Recursion Theorem
For any computable function
In other words: TMs can obtain and use their own description.
Consequences:
- There exists a TM that prints its own description (a "quine")
- Used to prove Rice's Theorem elegantly
- Underpins self-referential constructions in computability theory
Hierarchy of Undecidability
- RE (
): Semi-decidable — TM halts and accepts on YES instances - co-RE (
): Complement is RE — TM halts and accepts on NO instances = Recursive = RE co-RE - Higher levels correspond to problems with alternating quantifiers