Finite automata (DFA / NFA)
Parent: regular-languages
A machine with a finite set of states and nothing else — read the input left to right, changing state; accept if you end in an accepting state.
DFAA deterministic finite automaton is
(Q, Σ, δ, q₀, F): statesQ, alphabetΣ, transitionδ : Q × Σ → Q, startq₀, acceptingF ⊆ Q. On inputw, followδsymbol by symbol fromq₀; accept iff the final state is inF.
NFAA nondeterministic finite automaton lets
δreturn a set of next states (δ : Q × Σ →a subset ofQ) and allowsε-moves (change state reading nothing). It acceptswiff some run ends inF.
Key facts
- NFA = DFA. The subset (powerset) construction turns an NFA into a DFA whose states are sets of NFA states — same language, but up to
2ⁿstates (the blow-up is real). - Minimal DFA is unique. Merging indistinguishable states (Hopcroft's algorithm) yields a canonical minimum-state DFA; its state count equals the number of Myhill–Nerode classes.
- No memory. The only "state" is one of finitely many
Q— so a finite automaton can't count unbounded quantities (hence notaⁿbⁿ, regular-languages).
Finite automata are the machine face of the regular class; the expression face is regular-expressions and the grammar face is regular-grammar, all tied together by regular-equivalences.