---
title: Finite Automata Extraction Methods
url: https://www.emergentmind.com/topics/finite-automata-extraction-fae
type: topic
---

# Finite Automata Extraction Methods

Searching arXiv for recent and foundational papers on finite automata extraction.
Finite Automata Extraction (FAE) is the task of constructing an explicit finite-state surrogate for an opaque language recognizer, sequence model, program semantics, heap-shape analyzer, or world model. Across the literature, the extracted object may be a deterministic finite automaton (DFA), residual symbolic finite automaton (RSFA), weighted finite automaton (WFA), probabilistic deterministic finite automaton (PDFA), deterministic register automaton (DRA), Mealy machine, or forest automaton, depending on the input domain and the target behavior being modeled. In the black-box setting, FAE typically proceeds either by querying the target system, by clustering or merging observed internal states, or by synthesizing symbolic transition rules from traces. The common objective is to replace an implicit computational process with a finite, inspectable transition system that preserves the relevant acceptance, prediction, or transition behavior sufficiently well for analysis, explanation, verification, or control [1711.09576] [1902.07417] [2201.12451] [2406.05564] [2206.14621] [2508.11836] [2511.19100].

## 1. Scope and formal objects

FAE is not tied to a single automaton class. In formal-language settings, the target is often a DFA learned from a binary acceptor, with a standard tuple $\mathcal{A} = (Q, \Sigma, \delta, q_0, F)$ and acceptance defined by whether the state reached after consuming a word lies in $F$ [2201.12451] [2406.05564]. Query-based symbolic learning generalizes this to symbolic finite automata over an effective Boolean algebra $(D, \mathcal{B}, \llbracket\cdot\rrbracket)$, where transitions are labeled by predicates rather than individual symbols, and to residual symbolic finite automata, in which every state recognizes a residual language [1902.07417].

For quantitative sequence models, especially recurrent neural networks used in natural language processing, the extracted model is often a WFA
$$
A = (\Sigma, Q, \alpha, \{A_\sigma\}_{\sigma \in \Sigma}, \beta),
$$
or a PDFA when outgoing transition weights form a probability distribution [2206.14621] [2306.14040] [1910.13895]. In these settings, FAE does not merely reproduce binary acceptance; it attempts to approximate stepwise output distributions, conditional next-token probabilities, or label distributions induced by the source model.

When the alphabet is not finite, finite automata are insufficient. For numeric or continuous data sequences, DRAs extend finite-state control with registers storing values and guards comparing the current input with register contents and constants; this permits patterns depending on order or equality over $\mathbb{Q}$ that ordinary DFAs cannot express [2511.19100]. In world-model learning from gameplay video, the extracted automata are per-sprite Mealy machines
$$
M_s = (S_s, \Sigma, \delta_s, \lambda_s, s_0),
$$
whose transitions encode sprite-type changes and whose outputs encode actions in a domain-specific language [2508.11836]. In heap analysis, forest automata represent sets of tree decompositions of heap graphs, and the extraction problem becomes automatic discovery of reusable sub-automata, called boxes, for repetitive graph patterns [1304.5806].

This variety suggests that FAE is best understood as a family of finite-state distillation procedures rather than as a single algorithm. A plausible implication is that the decisive modeling choice is the structure one wishes to preserve: Boolean acceptance, symbolic predicates, weighted predictions, numeric comparisons, graph decomposition, or executable transition logic.

## 2. Query-based learning and exact-learning lineages

A central FAE paradigm is active learning by membership and equivalence queries. In the classical RNN setting, Angluin’s $\mathrm{L}^*$ algorithm is used as the learner, while the trained recurrent network acts as an oracle through its acceptance function [1711.09576]. Membership queries evaluate whether a word is accepted. Equivalence queries are handled by abstraction and counterexample-guided refinement over the RNN hidden-state space: the method builds a finite abstraction of the continuous state space, compares it with the current DFA hypothesis, and either returns a true counterexample or refines the partition if the conflict is attributable to abstraction imprecision [1711.09576]. The method guarantees that every returned counterexample is true and that every refinement is justified, while the learner always proposes a minimal DFA hypothesis [1711.09576].

The same active-learning architecture has been extended to weighted and probabilistic models. For real-valued RNN scorers, WFA extraction uses a weighted extension of $\mathrm{L}^*$ grounded in Hankel-style observation tables, while equivalence queries are guided by regression from RNN hidden states to WFA configurations [1904.02931]. The regression model prioritizes counterexample candidates by hidden-state geometry, which is used to focus search on poorly aligned regions of the learned abstraction [1904.02931]. For language models, a probabilistic variant learns PDFAs from conditional next-token distributions, replacing Boolean row equality with a local tolerance over probability vectors and using observation tables populated by conditional probabilities rather than raw word probabilities [1910.13895]. The resulting automata are deterministic and stochastic by construction, in contrast to spectrally extracted WFAs, which need not be stochastic [1910.13895].

A further development replaces deterministic symbolic automata with RSFAs [1902.07417]. In this setting, the minimally adequate teacher provides membership queries $\mathrm{MQ}(w)$ and equivalence queries $\mathrm{EQ}(H)$, and the learner maintains an observation table $T=(U,V,T)$ together with a collection of predicate learners over the underlying Boolean algebra [1902.07417]. Counterexamples trigger either state refinement, by enlarging the prefix and suffix sets used to approximate residuals, or predicate refinement, by passing violating letters to per-transition predicate learners [1902.07417]. Structural conditions specific to residual nondeterminism are enforced before posing equivalence queries, including monotone successor, residual-cover, and row-language consistency conditions [1902.07417].

These methods share a common architecture: a finite hypothesis is proposed, challenged against the target through some form of equivalence test, and revised using counterexamples. What differs is the observation domain—Boolean acceptance, real-valued scores, symbolic predicates, or probabilistic continuations—and the complexity of the abstraction mediating equivalence.

## 3. State abstraction, clustering, and state merging

A second major lineage extracts automata from observed internal states rather than from formal equivalence queries. In recurrent networks, one influential approach builds a prefix-tree acceptor from labeled prefixes and then merges compatible states according to both acceptance consistency and hidden-state similarity [2201.12451]. Each prefix $x_{:t}$ induces a PTA node $q(x_{:t})$, a hidden-state feature vector $\phi(q(x_{:t})) = h_t(x)$, and a binary accepting label obtained by thresholding the RNN’s per-prefix acceptance probability at $\tau = 0.5$ [2201.12451]. Two states may be merged when they have matching acceptance labels and sufficiently high cosine similarity, with tolerance controlled by $\kappa$ [2201.12451]. Because merging can temporarily introduce nondeterminism, determinization and minimization are applied afterward, yielding a smallest DFA for the merged automaton’s language [2201.12451].

On the Tomita languages, this state-merging procedure achieved $100.0\%$ fidelity for languages 1–6 and $99.62\% \pm 0.55$ for language 7 when $\kappa = 0.01$ and the PTA size was $m = 300$ [2201.12451]. The extracted minimal DFA sizes matched the ground truth for languages 1–6, while language 7 exhibited higher variance [2201.12451]. The paper also reports that continued training after the network had already reached approximately $100\%$ development accuracy improved extraction, because the RNN’s internal state space became more compressed and more amenable to cosine-based merging [2201.12451]. This suggests that FAE can reveal not only what a model computes, but also how its internal geometry changes during optimization.

Transformer extraction cannot rely on an explicit recurrent transition function, so the state-abstraction problem is reformulated. Encoder-only Transformers are treated as black-box acceptors, while a continuous-state surrogate automaton, the DCSA, is trained so that its prefix-wise state evolution aligns with the Transformer’s final \([CLS]\) representations [2406.05564]. Representation alignment combines a label-consistency loss with an $L_1$ discrepancy term between Transformer representations and DCSA states [2406.05564]. A partition of the DCSA state space then induces a DFA abstraction, and $\mathrm{L}^*$ is used pedagogically with approximate equivalence queries derived from sampling and comparison with the DCSA-induced abstraction [2406.05564]. Reported fidelities include $C(T,A)=1.000$ on several regular languages and near-perfect agreement even on cases where the Transformer itself did not learn the ground-truth language well, such as parity, where $C(L,T)\approx 0.5013$ but $C(T,A)=0.9963$ [2406.05564].

Across these approaches, the extracted automaton is shaped by the geometry of learned representations. A plausible implication is that the quality of a finite-state surrogate depends not only on the target function being regular or approximately regular, but also on whether the hidden-state manifold organizes itself into stable, mergeable equivalence classes.

## 4. Large alphabets, symbolic predicates, and residual nondeterminism

When the alphabet is very large or infinite, explicit symbol-by-symbol transition learning becomes impractical. Symbolic automata address this by labeling transitions with predicates over a Boolean algebra, so that one transition can denote a large character class [1902.07417]. In the RSFA framework, the alphabet is a domain $D$ and transitions are enabled by $a \in \llbracket \varphi \rrbracket$ for predicates $\varphi \in \mathcal{B}$ [1902.07417]. The target denotation for a transition from $q$ to $q'$ is
$$
D_{q \to q'} = \{ a \in D \mid \mathrm{row}(q') \subseteq \{ v \in V \mid \mathrm{MQ}(qav) = + \} \},
$$
and this set is learned by a predicate learner delegated to the underlying Boolean algebra [1902.07417].

Residuality is essential here. In reduced RFAs and RSFAs, states correspond to prime residuals, yielding automata that can be exponentially smaller than minimal DFAs [1902.07417]. The RSFA learner exploits two forms of succinctness simultaneously: fewer states than deterministic symbolic automata, and predicate-labeled transitions that compress many symbol-specific edges into single symbolic edges [1902.07417]. The paper gives worst-case bounds of at most $O(n^4 \mathcal{E})$ equivalence queries and $O(n^6(\mathcal{E}+\mathcal{M}) + n^5 \mathcal{E}\log m)$ membership queries, where $n = |\mathrm{Res}(L_*)|$, $m$ is the maximum counterexample length, and $\mathcal{E}, \mathcal{M}$ bound the underlying predicate learner’s costs [1902.07417].

Empirically, the RSFA learner and the deterministic symbolic learner of Argyros–D’Antoni were both implemented on top of the open-source `symbolicautomata` library, and tested on $50{,}000$ random nondeterministic SFAs over the full 32-bit integer alphabet [1902.07417]. The reported result is that the RSFA learner consistently asked far fewer equivalence and membership queries than the deterministic learner, even though the RSFA worst-case bounds are higher [1902.07417]. The paper attributes this partly to the smaller number of states and partly to the fact that RSFA transitions admit a range of acceptable predicates between simplified and saturated semantics, allowing predicate learners to converge with fewer splits [1902.07417].

This symbolic-residual viewpoint clarifies a recurrent theme in FAE: nondeterminism is not merely a representational convenience. In some settings it directly reduces learning cost by enlarging the space of transition predicates compatible with the target language.

## 5. Weighted, probabilistic, and natural-language extraction

Natural-language tasks impose two difficulties absent from regular-language benchmarks: large vocabularies and context-sensitive outputs. In response, several works extract WFA-like models from RNNs by clustering output traces into a finite state set and learning per-token transition matrices [2206.14621] [2306.14040]. The extracted WFA propagates a state distribution
$$
d(w) = \alpha^\top A_{\sigma_1}\cdots A_{\sigma_n},
$$
and maps it to a label distribution through a matrix of state centers [2206.14621] [2306.14040].

A recurring problem is transition sparsity: many state-token pairs are never observed because vocabulary items follow a Zipfian distribution [2206.14621] [2306.14040]. Both papers address this by complementing missing rows using a distance-weighted mixture over observed rows from semantically similar abstract states, combined with a self-transition component controlled by a parameter $\beta$ [2206.14621] [2306.14040]. They further introduce a context-aware adjustment
$$
A'_\sigma = \alpha I + (1-\alpha)A_\sigma,
$$
which injects a simple memory of previous state distributions through self-loop bias [2206.14621] [2306.14040]. Two data-augmentation tactics—synonym replacement and replacement by $\langle\mathrm{unk}\rangle$—expand the observed dynamics of rare words [2206.14621] [2306.14040].

On the QC and Toxic datasets, these changes improved Consistency Rate with the RNN from $60\%$ to $84\%$ and from $86\%$ to $94\%$, respectively, relative to a common uniform-fill baseline without context or augmentation [2206.14621]. The companion work additionally proposes Transition Matrix Embeddings, which vectorize per-token transition matrices into task-oriented word representations suitable for explanation, pretraining, and adversarial example generation [2306.14040]. Reported improvements include CR from approximately $0.60/0.86$ to approximately $0.84/0.94$ and Jensen–Shannon divergence from approximately $0.21/0.06$ to approximately $0.12/0.02$ on QC and Toxic, respectively, for the full empirical-filling, context-aware, augmented pipeline [2306.14040].

Probabilistic language-model extraction takes a more query-theoretic route. The PDFA learner of [1910.13895] observes conditional probabilities $P^l(w\sigma)$ and compares observation-table rows up to a tolerance $t$ under an $\ell_\infty$ metric [1910.13895]. Hypothesis construction requires clustering rows into cliques satisfying both pairwise $t$-equality and determinism constraints [1910.13895]. The extracted automaton is stochastic and deterministic by construction, and on unbounded-history benchmark languages the method reconstructs the exact PDFA structure where $n$-gram models fail [1910.13895].

Taken together, these results show that FAE for natural language is less about exact recovery of a minimal recognizer and more about preserving predictive structure under data sparsity, large alphabets, and context dependence. This suggests a shift from exact-language identification toward faithful, analyzable surrogates of learned sequential decision boundaries.

## 6. Infinite domains, programs, heaps, and world models

Several works extend FAE far beyond standard language recognition. For numeric data sequences, DRAs provide a finite-state model with registers and guards over $(\mathbb{Q};<,=)$ [2511.19100]. A $k$-register automaton maintains finitely many stored values and accepts based on deterministic transitions whose guards compare the current input with registers and constants [2511.19100]. The paper combines passive SMT-based synthesis, local-search synthesis, and active learning with RALib, and then composes the extracted DRA with register automata with accumulators that compute distances such as Hamming, Manhattan, edit, DTW, and last-letter distances [2511.19100]. For fixed $k$, local robustness checking is polynomial-time, via reductions from bounded projected coverability to shortest path in a weighted graph [2511.19100]. The framework yields PAC-style agreement guarantees and either certifies local robustness or returns a concrete counterexample sequence [2511.19100].

In imperative semantics, FAE appears as abstraction from small-step operational semantics to a finite automaton [1409.7841]. A zipper-based semantics preserves execution context explicitly as a pair of a focused statement and a context path, avoiding the loss of control-flow information that would occur if identical subterms were collapsed naively [1409.7841]. The resulting automaton has finite node set because the syntax tree is finite, while silent administrative steps are represented by `NoAct` transitions and later eliminated by $\tau$-closure [1409.7841]. The paper proves a simulation from the operational semantics to the generated automaton and a further simulation from the original automaton to its $\tau$-closed form [1409.7841].

Heap-shape analysis uses forest automata, where the extraction problem is automatic discovery of boxes—finite automata encoding repetitive graph motifs such as list segments or skip-list levels [1304.5806]. The method identifies optimal knots, splits automata around their entry points, constructs boxes from the extracted subgraphs, and folds them back into higher-level forest automata [1304.5806]. This fully automated analysis handles structures as complex as skip lists and avoids manual provision of box abstractions [1304.5806].

A distinct direction is neuro-symbolic world modeling from gameplay video [2508.11836]. Here, perception first maps frames to symbolic sprite grids using a MarioNette-derived VAE with background subtraction and a reconstruction weight $\gamma = 10$ [2508.11836]. Program synthesis then performs greedy local search over if-then clauses in the Retro Coder DSL, minimizing a batch-wise predictive absolute error
$$
D(i;b)=\sum_{x=i}^{i+b}\mathrm{AE}(G_{x+1}, \hat G_{x+1}),
$$
with $b=3$ [2508.11836]. The result is one Mealy-machine-like program per sprite type [2508.11836]. On Pac-Man and River Raid under low data, FAE achieved very low FID and used far fewer conditions than the symbolic baseline GEL, for example $1.75 \pm 0.83$ conditions versus $73 \pm 22.55$ on Pac-Man and $2.00 \pm 1.87$ versus $125.42 \pm 19.58$ on River Raid [2508.11836].

These examples show that FAE is increasingly used wherever a sequential or stateful process can be approximated by finite control enriched with the right symbolic interfaces: registers for numbers, boxes for graph motifs, or DSL actions for world dynamics.

## 7. Evaluation criteria, advantages, and limitations

FAE methods are evaluated by markedly different criteria depending on the target. Query-learning work emphasizes exactness, number of membership and equivalence queries, and compactness of the extracted automaton [1711.09576] [1902.07417] [1910.13895]. State-merging and representation-alignment work emphasizes fidelity to the source model, recovery of minimal automata where applicable, and sensitivity to hyperparameters such as merge tolerance $\kappa$ or clustering resolution [2201.12451] [2406.05564]. Natural-language WFA extraction uses Consistency Rate and distributional discrepancies such as Jensen–Shannon divergence [2206.14621] [2306.14040]. World-model extraction evaluates predictive image quality and next-frame error through FID and absolute-error-derived prediction metrics [2508.11836].

A shared advantage is inspectability. Extracted automata expose states, transitions, guards, predicates, or clauses that can be analyzed formally or edited directly [1711.09576] [1902.07417] [2201.12451] [2406.05564] [2511.19100] [2508.11836]. Another is computational leverage: WFAs and PDFAs offer efficient inference relative to the source RNN, and symbolic automata allow reasoning about huge alphabets without explicit enumeration [1904.02931] [1910.13895] [1902.07417]. Several papers also use FAE diagnostically, for example to reveal that Transformers learn complex non-minimal surrogates for periodic languages, or that RNNs trained beyond convergence compress hidden-state geometry in ways favorable to extraction [2406.05564] [2201.12451].

The limitations are equally consistent. Exact equivalence queries are rarely available in practical black-box settings, so many systems substitute sampling, conformance testing, or approximate teachers [2406.05564] [1902.07417] [2511.19100]. Extraction quality can depend strongly on clustering choices, tolerance parameters, or the hidden-state geometry induced by training [2201.12451] [2206.14621] [2306.14040]. Natural-language models create transition sparsity and context-loss problems [2206.14621] [2306.14040]. Symbolic methods require an effective Boolean algebra and a strong predicate learner [1902.07417]. DRA robustness checking is polynomial only for a fixed number of registers [2511.19100]. Gameplay-world extraction depends on perception quality and is limited by the expressiveness of the DSL, which currently lacks explicit time constructs, stochasticity, off-screen spawning, and robust handling of large multi-cell sprites [2508.11836].

The broader picture is that FAE has moved from a narrow problem of recovering DFAs from RNN acceptors to a general methodology for synthesizing finite-state surrogates across symbolic, statistical, and neuro-symbolic systems. This suggests that future progress will depend less on a single canonical automaton model than on better matches between task structure and extracted state formalism: symbolic predicates for huge alphabets, weighted transitions for probabilistic outputs, registers for numeric memory, and executable rule languages for interactive environments.

Source: https://www.emergentmind.com/topics/finite-automata-extraction-fae