Skip to content

Nondeterministic Finite Automaton

A finite-state string recognizer with set-valued transitions that accepts when at least one complete run reaches an accepting state.

Version
v1 · 2026-10-03 · History
Domain-specific #
13470
Domain group
Applied Sciences & Engineering
Origin domain
Computer Science & Software Engineering
Subdomains
Automata Theory, Formal Language Theory → Computer Science & Software Engineering
Aliases
NFA, Nondeterministic finite-state automaton, Nondeterministic finite state machine

Core Idea

A nondeterministic finite automaton (NFA) recognizes strings using finitely many states. From a state and input symbol it may have no successor, one successor, or several. It accepts a word if some complete run consumes every symbol and finishes in an accepting state, even if all other runs fail. Nondeterminism here is existential choice, not randomness or necessarily a physical machine executing paths in parallel.[1]

In the conventional single-start model, its transition is \(\delta:Q\times\Sigma\to\mathcal P(Q)\). An ε-NFA additionally permits transitions that consume no symbol; ε-moves are useful for regular-expression construction but not required for the NFA identity.[2] Rabin and Scott proved that tracking reachable subsets of \(Q\) gives an equivalent DFA. Thus NFAs and DFAs recognize exactly the regular languages, although their representations and execution costs can differ.[1]

How would you explain it like I'm…

The Any-Path-Wins Maze

Imagine a maze where at some spots you could go several ways, or there's no way forward at all. You read a word one letter at a time, and each letter tells you which paths you may take. If even one path uses up the whole word and ends at the treasure, the word wins.

Machines With Many Paths

A finite automaton is a simple machine with a few states that reads a word letter by letter and decides whether to accept it. In a nondeterministic finite automaton (NFA), a state and a letter can lead to several next states, one, or none. The word is accepted if at least one possible path reads the whole word and ends in an 'accepting' state, even if other paths get stuck or end in the wrong place. It's not about luck or guessing; it just asks whether a good path exists. Any NFA can be turned into a regular (deterministic) machine that accepts the exact same words.

Existential-Acceptance Automata

A nondeterministic finite automaton (NFA) is a finite-state machine for recognizing strings. Unlike a deterministic finite automaton (DFA), where each state and input symbol determine exactly one next state, an NFA may allow zero, one or several next states. A string is accepted if at least one complete run starts at a start state, reads the entire string, and ends in an accepting state; other runs may fail or end elsewhere. This is an 'exists a path' rule, not a probability and not a machine that magically guesses right. Some NFAs also allow ε-moves, transitions that read no symbol, which are convenient but can be removed without changing the language. Every NFA can be converted into an equivalent DFA by the subset construction, so NFAs recognize exactly the regular languages, though the DFA may need many more states.

 

An NFA is a finite-state recognizer whose transition relation allows, for each state and input symbol, zero, one or several successor states. In the common single-start, no-ε convention it is a tuple N = (Q, Σ, δ, q0, F), with Q finite, Σ a finite alphabet, q0 ∈ Q, F ⊆ Q, and δ: Q × Σ → P(Q). A word a1…am is accepted if there is a sequence of states q0, q1, …, qm with each qi ∈ δ(q(i−1), ai) and qm ∈ F; acceptance is existential over complete runs, so other runs may halt early or end in non-accepting states. Rabin and Scott's original formulation allowed a set of initial states, and the single-start version is an equivalent normalization. ε-NFAs add transitions that consume no input; they are handy when composing regular-expression fragments but can be eliminated without changing the language. The subset construction treats each set of currently reachable NFA states as a single DFA state, proving that NFAs recognize exactly the regular languages. That equivalence concerns expressive power only; the DFA can need far more states and the two need not have equal execution costs.

Scope of Application

NFAs are used to specify regular-language recognizers and to construct recognizers compositionally from classical regular expressions. A pattern alternation can split into two branches, and an implementation can advance the set of states reachable after each input character rather than sample one path. Cox's original engine exposition demonstrates both construction and state-set simulation.[2]

Lexical analysis uses adjacent regular-language machinery, but the NFA is not an entire lexer: the original Lex report describes a deterministic generated recognizer plus longest-match and action policies. Likewise, regex extensions such as backreferences are not covered by the classical NFA equivalence theorem merely because they are called “regular expressions.”[3]

Clarity

Specify finite states, alphabet, start state or states, accepting set, and set-valued transitions. For a word, follow only transitions matching successive symbols; after consuming the whole word, ask whether any reachable state is accepting. A dead branch does not reject the word if another branch survives. With ε-links, take ε-closure without consuming input.[1][2]

The recognized language is the set of accepted words, not the NFA itself. A DFA is the singleton-successor specialization; an unambiguous finite automaton may branch but limits each word to at most one accepting run. A probabilistic automaton instead assigns weights or chances. These distinctions concern machine structure or acceptance semantics, not just names.

Manages Complexity

Branching can make a pattern description or proof construction compact, but “NFA is smaller” is not a universal statement. Determinization collects all possible NFA states after a prefix into one DFA state; as many as \(2^{|Q|}\) subsets are possible, though many may be unreachable. Direct NFA simulation can compute the currently reachable set on demand without materializing the whole DFA.[1][2]

The distinction between specification size and recognition work is essential. A backtracking interpreter may revisit paths; a reachable-set simulator merges their equivalent current-state information. Both can implement the same existential recognition rule but have different costs.[2]

Abstract Reasoning

To prove an NFA correct, show that every accepted word has a valid complete witness run and every intended word has at least one. For example, to recognize binary strings whose nth symbol from the end is \(1\), loop in the start state and branch on a \(1\) into a chain that demands exactly \(n-1\) further symbols. Only a correctly timed guess can reach the final state exactly at input end. In a regex for abab|abbb, the abab path fails on abbb, but the abbb path accepts; failed alternatives do not negate that one witness.[1][2]

Knowledge Transfer

The model shows how existential path semantics can be simulated by maintaining the set of still-possible states. That method transfers to related finite-state algorithms, but the exact subset bound and regular-language theorem depend on finite control and whole-word acceptance. The proposed DAG parent is the live Automaton identity; DFA and unambiguous finite automaton are related specializations, not strict parents of this general branching recognizer.

Relationships to Other Abstractions

Local relationship map for Nondeterministic Finite AutomatonParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.NondeterministicFinite AutomatonDOMAINDomain-specific abstraction: Automaton — is a kind ofAutomatonDOMAIN

Current abstraction Nondeterministic Finite Automaton Domain-specific

Parents (1) — outgoing typed relations

  • Nondeterministic Finite Automaton is a kind of Automaton Domain-specific

    A nondeterministic finite automaton is an automaton specialized to finite-word, finite-state existential recognition.

Hierarchy paths (2) — routes to 2 parentless roots

Neighborhood in Abstraction Space

Nondeterministic Finite Automaton sits in a crowded region of the domain-specific corpus (35th percentile for distinctiveness): several abstractions share nearly its structure, so a description that fits it tends to fit its neighbors too.

Family — Formal Sequences & Language Structure (19 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14

References

[1] Michael O. Rabin and Dana Scott, “Finite Automata and Their Decision Problems,” IBM Journal of Research and Development 3, no. 2 (1959): 114–125, especially Definitions 9–11 and Theorem 11, pp. 120–121. Original paper PDF. registry ↩a ↩b ↩c ↩d ↩e

[2] Russ Cox, “Regular Expression Matching Can Be Simple And Fast,” sections on NFA construction, simulation, and DFA caching. Author's original article and code. registry ↩a ↩b ↩c ↩d ↩e ↩f

[3] M. E. Lesk and E. Schmidt, “Lex—A Lexical Analyzer Generator” (1975), Abstract and Introduction. Original report mirror. registry ↩