Proofs: L* algorithm
These are the human proofs of L* algorithm, at full length.
L* learns the minimal DFA with at most n equivalence queries full
This proof shows: correctness, termination, complexity.
Let be the target, and let be the number of states of its minimal complete DFA, which is also the number of classes of the Myhill-Nerode relation ( when for all ). DFAs are complete and have no -moves. For a DFA with transition function we use . A DFA agrees with the table if for all and , accepts if and only if . The target's minimal DFA agrees with every table that L* builds, since holds true membership answers.
Throughout, is prefix-closed and is suffix-closed, and , . This holds after line L1, and lines L4, L6 and L10 keep it: line L4 adds with , whose proper suffixes are suffixes of and so in ; line L6 adds with ; line L10 adds all prefixes of . Let be the number of distinct rows with .
Part 1: the hypothesis agrees with the table
Let the table be closed and consistent, and let with transition function , start and accepting set . As noted on the page, and are well defined.
Lemma 1. For every , .
Proof. By induction on . For it is the definition of . Let with . If , then since is prefix-closed. If , then is the element of that was extended. In both cases , so by the induction hypothesis by the definition of .
Lemma 2. For every and , if and only if .
Proof. By induction on . If : by Lemma 1, . By closedness (or trivially if ) there is with , so if and only if , and because the two rows agree on the column .
If with : then since is suffix-closed. Pick with . Then
using Lemma 1 for and for . By the induction hypothesis for and , this state is in if and only if . Finally , because and .
So agrees with the table.
Part 2: uniqueness of the hypothesis
Lemma 3. Let the table be closed and consistent, let , and let be a DFA that agrees with the table and has at most states. Then is isomorphic to .
Proof. For let map to 1 if and only if . Because agrees with the table, for all . The strings of have distinct rows, so the states with have at least distinct images under , and so are at least distinct states. As , these are all the states of , , and maps bijectively onto the set of rows of . Hence a state of is determined by its value.
Define for . It is well defined: if , the two states have the same value and so are equal. It is a bijection from the states of onto by the previous paragraph. It maps start to start, since . It preserves transitions: for and , closedness gives with , and the states and have the same value , so they are equal. It preserves acceptance: if and only if (agreement with ), if and only if .
Part 3: the number of rows
Lemma 4. at all times, and never decreases.
Proof. If , some has , so . So the access strings with distinct rows lie in distinct classes of , of which there are . Adding a string to adds a row and changes no other row. Adding a column to extends every row by one entry, so rows that differed still differ. Hence never decreases.
Lemma 5. Each execution of line L4 or line L6 increases by at least one.
Proof. Line L4 adds where and ; after the addition the rows of and differ in the new column, and by Lemma 4 no other pair of distinct rows merges, so grows. Line L6 adds , whose row differs from every row of ; the new column set is the same, so grows by one.
Part 4: counterexamples and termination
Lemma 6. Let be a hypothesis with states that receives the counterexample , and let be the next hypothesis. Then has more than states.
Proof. Let be the table that gave and the table that gives . Then , , and extends . agrees with by Part 1, and so it also agrees with , whose strings are among those of the new table. The number of states of is by Lemma 4. Suppose that it is exactly . Then agrees with and has at most states, so it is isomorphic to by Lemma 3, and . But after line L10 and , so accepts if and only if , that is, if and only if ; and accepts if and only if . This contradicts .
Theorem. L* stops after at most equivalence queries and at most executions of lines L4 and L6 in all, and returns the minimal DFA of .
Proof. By Lemmas 4 and 5, starts at 1 and is at most , and each execution of L4 or L6 increases it, so there are at most such executions in the whole run. Between two consecutive equivalence queries, the loop therefore makes finitely many passes, each of which either adds a column, adds a row, or reaches line L7 with a closed and consistent table. The hypotheses have states by Lemma 4, and by Lemma 6 their sizes strictly increase. Since the first has at least one state, there are at most hypotheses, so at most equivalence queries, and the last one is answered "yes" (the loop cannot run forever without asking another one, by the bound on L4 and L6). The returned satisfies and has at most states, so it has exactly states and, by the uniqueness of the minimal DFA up to isomorphism, it is the minimal DFA.
Part 5: cost
Let be the length of the longest counterexample. By Lemma 4 and Lemma 5, . gains at most strings at line L6 and at most new strings at each of at most executions of line L10 (the prefix is already present), so . The table has entries, and each membership query fills one new entry, so this bounds the number of membership queries.
The loop runs at most times. In each pass, the consistency check, the closedness check, the construction of the hypothesis and the filling of new entries read each entry of the table a constant number of times, which is entries, and each read hashes a string of length at most . So a pass takes time, and the whole run time besides the teacher's work. The table stores strings of length , which is space.