Theory of Computation: Lecture 5
Encoded decision problems, decidability of DFA emptiness and equivalence, diagonalization, HALT and ATM, and the boundary between decidable, recognizable, and unrecognizable languages.
Encoded Decision Problems
Turing machines can decide languages beyond finite memory, and Hilbert's tenth problem shows that some problems have no decider at all. To map that boundary systematically, turn the machines into data and ask decision questions about automata and Turing machines themselves. A Turing machine receives ordinary strings as input, but these questions are about structured objects: automata, graphs, pairs of machines, or a machine together with its input. To ask them with a Turing machine, the objects must first be written as strings.
Encoding. A finite representation of an object as a string. The notation means "the encoding of object ". For pairs, means one string encoding both objects with enough delimiters to decode them.
Anything finite and discrete can be encoded as a binary string: states, transition tables, graph edges, formulas, and even Turing machines themselves.
Invalid encodings are harmless in decidability proofs. A decider may first check whether the input is a valid encoding and reject if it is not.
Decision problem. A yes/no problem viewed as a language of encodings. The language contains exactly the encodings of instances whose answer is yes.
| Problem | Language form |
|---|---|
| Does DFA accept no strings? | |
| Do DFAs and accept the same language? | |
| Does TM halt on input ? |
High-level TM description. A finite algorithmic description that can be implemented by a Turing machine. By the Church-Turing thesis, it is enough to describe ordinary effective procedures such as parsing an encoding, simulating an automaton, or running a graph search.
The machine model is low-level; decidability proofs are usually written at the algorithm level.
Deciding DFA Properties
The first useful decision problems ask whether an encoded DFA has a property. These are easier than they may look because a DFA is a finite graph.
DFA emptiness problem.
A tempting algorithm enumerates all strings and simulates on each one. If accepts some string, the algorithm rejects. But if , no accepting string is ever found, so the algorithm runs forever. It is not a decider for .
The right algorithm does not search through infinitely many strings. It searches through finitely many states.
Reachability set. For a DFA , the set of states reachable from by following zero or more transitions.
Emptiness criterion. A DFA has nonempty language if and only if some accepting state is reachable from .
If is reachable, the path labels form a string accepted by . Conversely, if accepts some string, the run on that string ends in a reachable accepting state.
Emptiness is a graph question: ignore the infinite set of possible strings and ask whether an accepting vertex is reachable.
Recipe: deciding .
- Parse the input as with .
- Initialize .
- While there exist , , and with , add to .
- When no new state can be added, accept iff .
The loop halts because is finite and each successful iteration adds a new state.
DFA equivalence problem.
Two DFAs differ exactly on the strings in the symmetric difference of their languages.
Symmetric difference. For languages and over the same alphabet,
It contains exactly the strings that belong to one language but not the other. Therefore:
Regular languages are closed under complement, union, and intersection, so is regular. More concretely, for and the product construction from Lecture 1 builds a DFA with states , start state , and transition . Only the accepting set is new, the disagreement pairs where exactly one side accepts:
If accepts the strings ending in 0 and accepts the even-length strings, then 0 lies in their symmetric difference, so a disagreement pair is reachable and the two DFAs are not equivalent.
Recipe: deciding .
- Parse the input as .
- Build the product DFA for .
- Run the decider for on .
- Accept iff .
A decider may call another decider as a subroutine. The only obligation is that every subroutine call halts.
Diagonalization
Decidable languages are not all languages. The reason is already visible at the level of size: there are only countably many machines but uncountably many languages.
Bijection. A function that is both injective and surjective. It pairs the elements of two sets with no duplicates and no omissions.
Countable set. A set that is finite or can be listed as . Equivalently, it has a bijection with .
The even numbers are countable by . The positive rationals are countable by listing them in a grid and skipping duplicates.
Diagonalization. A proof method that assumes a complete list and constructs an object that differs from the -th listed object at position . The constructed object cannot appear anywhere in the list.
Cantor's diagonal argument shows that the real numbers are uncountable: given a supposed list of decimal expansions, choose a new number whose -th digit differs from the -th digit of the -th listed real.
The same idea applies to languages. Fix an order
Every language has a characteristic sequence , where the -th bit is iff . The same diagonal argument makes these sequences uncountable: given any list of them, flip the -th bit of the -th sequence to get one that is missing. So the set of all languages is uncountable.
Turing machines are countable because every machine has a finite encoding, and all finite strings can be listed by length. Since each TM recognizes at most one language, some languages are not Turing-recognizable.
There are more yes/no string problems than there are programs.
Diagonal language. List by length and read each string as a Turing machine, treating any string that is not a valid encoding as a fixed machine that rejects everything. This enumerates all Turing machines as , and every machine appears as some .
Tabulate how each machine behaves on each encoding: write A when it accepts, R when it rejects, and when it loops forever. Row records and column uses the input , so the entry in row , column is the outcome of running on .
| Machine on input | |||||
|---|---|---|---|---|---|
| A | R | A | |||
| R | A | A | |||
| R | R | ||||
| A | R | A | |||
Only the diagonal matters, the bold entries where runs on its own encoding . Define
where "does not accept" covers both rejecting and looping. So collects exactly the encodings whose diagonal entry is not A, the R and cases. Reading the diagonal above:
- accepts (A), so .
- loops on (), so .
- rejects (R), so .
- accepts (A), so .
Equivalently, is the complement of the diagonal: for every it is built to disagree with at the single input , turning accept into non-membership and reject-or-loop into membership.
Theorem: is undecidable.
1. Assumption. Suppose some TM decides .
2. Self-reference. Since the list contains every TM, for some . Because decides , .
3. Diagonal question. Ask whether .
If , then , so by definition does not accept , contradiction.
If , then does not accept , so , contradiction.
4. Conclusion. No decider for exists.
The impossible machine would have to answer the opposite of its own answer on its own encoding.
The Halting and Acceptance Problems
The diagonal language is artificial, but it is useful because it can be used to prove natural machine-input problems undecidable.
Recipe: proving a language undecidable.
- Assume a decider. Suppose a TM decides the target language .
- Reduce from a known case. Use it as a subroutine to build a decider for a language already known to be undecidable, such as .
- Derive the contradiction. That language has no decider, so the assumed decider for cannot exist.
Halting problem.
Universal simulation. A TM can simulate another encoded TM step by step on an encoded input. Thus is recognizable:
- On input , simulate on .
- If the simulation ever reaches or , accept.
If loops on , this recognizer also loops. That is why it recognizes but does not decide it.
Theorem: is undecidable.
Assume, for contradiction, that decides . Build a decider for :
- On input , run on .
- If rejects, then loops on , so does not accept ; accept.
- If accepts, simulate on until it halts. If accepts, reject; if rejects, accept.
halts on every input because halts, and in the third case has certified that the simulation of will halt. Moreover, accepts exactly the machines that do not accept their own encoding. Therefore decides , contradiction.
The hard part is not noticing when a machine halts. It is proving in finite time that it never will.
Acceptance problem.
Theorem: is undecidable.
Assume, for contradiction, that decides . Build a decider for : on input , run on and output the opposite answer. Then always halts because does, and accepts exactly when does not accept , which is exactly . So decides , contradiction.
Unlike the halting reduction, this one needs no re-simulation: reports acceptance directly, so only flips its answer.
The difference between and is the event being tested:
| Language | Yes when | No when |
|---|---|---|
| accepts or rejects | loops on | |
| accepts | rejects or loops on |
Recognizable and Unrecognizable Languages
The halting problem separates recognizability from decidability: is recognizable but undecidable. To find a language that is not even recognizable, use complements.
Complement recognizability theorem. A language is decidable if and only if both and are recognizable.
1. Decidable to recognizable. If is decidable, its decider recognizes . Swapping accept and reject gives a decider, hence a recognizer, for .
2. Recognizable complements to decidable. Suppose recognizes and recognizes . Construct a machine :
- On input , run and on in dovetailing fashion: one step of , then one step of , and repeat.
- If accepts, accept.
- If accepts, reject.
For every , either or . Therefore one of the two recognizers eventually accepts, so halts on every input and decides .
Running recognizers "in parallel" means alternating finite pieces of their computations so neither one can starve the other.
Corollary. is not recognizable.
is recognizable but undecidable. If were recognizable too, the complement recognizability theorem would imply that is decidable, contradiction.
The strict containments now known are, writing for the set of all languages:
Regular languages are decidable because a TM can simulate a DFA and halt. The containment is strict because languages such as equal numbers of 0s and 1s are decidable but not regular. Decidable languages are recognizable by definition, and the containment is strict because is recognizable but undecidable. Finally, is a concrete language outside the recognizable languages.