Proofs: Subset construction
These are the human proofs of Subset construction, at full length.
The subset construction builds a complete DFA with the language of the NFA full
This proof shows: correctness, termination.
Let be the input, with . For , let be the set of states such that there is a path with , , and for . For and , let .
A run of on is a sequence of states joined by moves, which starts in , whose labels in order are with any number of labels between them, before them and after them. Let be the set of the last states of the runs on . By definition, if and only if .
Lemma 1 (CLOSE). CLOSE stops and returns .
Proof. A state enters at most once, and it is pushed on only when it enters , so line L13 runs at most times and the loop stops. We show two inclusions for the returned .
: at line L11, , because a path with is allowed. Line L14 adds only when for some . If by a path ending in , then that path followed by shows . So holds after each step.
: each state of is pushed once and popped once before the loop ends, and when is popped, line L14 adds each element of to . So the final contains and is closed under -moves: and give . By induction on , the last state of each path with lies in .
Lemma 2. , and for each and .
Proof. A run on is a path of -moves from , so . A run on has exactly one move labelled , the last move with a symbol label. Cut the run there. The part before the move is a run on , ending in a state . The move goes to a state , so . The part after the move is a path of -moves from , so the last state is in . Conversely, each with a run on , each and each path of -moves from join into a run on .
Lemma 3 (termination and completeness). The loop of line L3 stops. At the end, is defined for each and each , and .
Proof. A set enters only at line L2 or line L7, and only when it is not yet in , after which it is in . Sets are never removed from . So each set enters at most once, and since , the loop runs at most times. Each run of the loop removes one set, so the loop stops, and each set of is removed once. When is removed, lines L5 to L8 define for each , and line L7 puts the value into before line L8 uses it.
Theorem. The DFA returned at line L10 is complete, each of its states is reachable from , and .
Proof. Completeness is Lemma 3. Each set is put into at line L2, as , or at line L7 as of a set already in ; by induction on the order of insertion, each set of is reachable from .
We prove by induction on . For , $\delta'^*(S_0, \varepsilon) = S_0 = $ CLOSE by Lemma 1 and Lemma 2. For , let , which equals by the induction hypothesis. By line L6 and Lemma 1, , which is by Lemma 2. So .
By line L9, accepts if and only if , that is, , that is, .