Invariants of the learning loop
The learner repeatedly moves through the following stages:
obtain required MQ values -> closedness -> right consistency -> build a hypothesis DFA -> equivalence query -> monoid consistency or terminationEvery refinement adds information to , or . The target language never changes, so membership answers already stored for complete words remain valid throughout the run.
Closedness discovers representatives
The observation structure is closed when every boundary word is represented by some with the same full row:
If no such exists, describes a newly observed class and is added to . The learner handles one new representative at a time and then restarts the refinement loop.
Closedness is both an algorithmic condition and a construction rule. It ensures that every one-letter transition from a represented class has a represented target.
Right consistency preserves future behavior
Suppose two representatives have the same suffix row:
Right consistency requires their one-letter extensions to remain suffix-equivalent:
If this fails, some satisfies
The learner adds to . This exposes the hidden distinction and refines the right-language approximation.
The implementation intentionally performs this test with suffix rows, not with the complete rows. This retains the classical L-star meaning of right consistency while the additional left structure is handled separately.
Building the hypothesis DFA
After closedness and right consistency hold, each distinct full row becomes a hypothesis state. For reproducibility, the implementation chooses the shortest stable-sorted element of as the representative of each row.
The semantic mapping from hypothesis states to these words is stored as state_to_rep. It is not a cache: it is needed to interpret a hypothesis run and to locate a useful suffix inside a counterexample.
Processing an equivalence counterexample
If the teacher returns , then the hypothesis and the target disagree on . The main implementation uses a Rivest-Schapire-style breakpoint search.
It follows the hypothesis trajectory, compares the teacher’s answers at selected boundaries and uses binary search to locate an adjacent pair where the expected behavior changes. The resulting distinguishing suffix is added to .
This needs membership queries for a counterexample of length , excluding answers already present in the global query cache. A simpler expand mode that inserts many prefixes and suffixes is retained for debugging, but the principal experiments use the breakpoint strategy.
Why a successful EQ is not the end
An EQ proves that the hypothesis accepts the correct language:
It does not by itself prove that the current row quotient is already the syntactic monoid. The same regular language can be accepted by automata whose internal algebraic structures are not the minimal two-sided quotient.
For a boundary word , let be its current representative:
The Monoid Consistency Check tests whether known left multiplication preserves this merge. For and , it compares
Equivalently, it checks the finite condition
If a mismatch is found, the left context is added to . The previously merged boundary and representative then become distinguishable in their full rows.
This check is finite and targeted. It does not enumerate every possible context in and should not be described as comparing infinite rows. It verifies only the representative-boundary pairs and the currently known contexts.
Complete pseudocode
I := {epsilon}P := {epsilon}S := {epsilon}
repeat: if some t in I.Sigma has no equal full row in I: add t to I continue
if some suffix-equivalent i,j fail right consistency on a: add a.s to S for a distinguishing suffix s continue
H := build_hypothesis(I, P, S) counterexample := EQ(H)
if counterexample exists: refine S with its breakpoint suffix continue
if a representative-boundary pair fails monoid consistency: add the distinguishing representative to P continue
return HThe implementation supports a second policy that modifies the closedness step: every new member of is immediately promoted into . That policy can omit the final Monoid Consistency Check and is studied in the engineering and experimental articles.