Formal Language Theory
Finite
State
Machines
An interactive toolkit for building, visualising, and converting automata — step by step, state by state.
NFA DFA ε-closure Subset Construction Transition Tables
Theory
🧠
Automata Theory
Understand what finite automata are, how they differ, and the maths behind them.
Animated
String Acceptor
Enter a DFA and a test string — watch each symbol consumed step by step with live state animation.
Step-by-step
NFA → DFA
Run subset construction and watch each DFA state materialise from NFA state-sets — animated, narrated, pauseable.
← Back to Home
Automata Theory
A finite automaton is a mathematical model of computation — a machine that reads an input string symbol by symbol and decides, at the end, whether to accept or reject it. Despite their simplicity, finite automata underpin lexers, regex engines, network protocols, and hardware controllers.

What is a Finite Automaton?

Formally, an automaton is a 5-tuple (Q, Σ, δ, q₀, F) where Q is a finite set of states, Σ is the input alphabet, δ is the transition function, q₀ ∈ Q is the start state, and F ⊆ Q is the set of accept states.

The machine starts in q₀, reads each character, follows the transition for that character, and accepts if it ends in a state in F.

Accept condition: A string w is accepted if, after reading all of w starting from q₀, the machine is in some state q ∈ F. The set of all accepted strings is called the language of the automaton, written L(M).

DFA vs NFA — Key Differences

The two main flavours of finite automaton differ in how their transition function is defined.

DFA — Deterministic

From every state, on every symbol, there is exactly one next state. δ: Q × Σ → Q. Simple to simulate; one active state at a time.

NFA — Non-deterministic

From a state, a symbol may lead to zero, one, or many next states. δ: Q × Σ → 2^Q. Easier to design; harder to execute directly.

PropertyDFANFA
Transitions per symbolExactly 10, 1 or many
ε-transitions allowedNoYes (ε-NFA)
Simulation costO(n) per symbolO(n·|Q|) per symbol
Expressive powerIdentical — both recognise exactly the regular languages

Epsilon (ε) Transitions

An ε-NFA allows the machine to change state without consuming any input. These free moves make NFAs far more convenient to construct — for example, when combining two automata for union or concatenation.

ε-closure(S): The set of all states reachable from any state in S by following zero or more ε-transitions. When simulating an ε-NFA we always take the ε-closure after every step.

In this tool you can write eps or ε in the alphabet and transitions fields to add epsilon moves.

Subset Construction (Powerset Algorithm)

Every NFA can be converted to an equivalent DFA. The idea is elegant: each DFA state represents a set of NFA states the machine could currently be in.

Algorithm sketch:

1. Start DFA state = ε-closure({q₀})
2. For each unprocessed DFA state S and each symbol a ∈ Σ, compute move(S, a) then take its ε-closure — that is the next DFA state.
3. A DFA state is accepting if any NFA state in its set is accepting.
4. Repeat until no new states appear.

Worst case: An NFA with n states can produce up to 2ⁿ DFA states. In practice most states are unreachable and the blowup is rarely observed.

Ready to see it live?
Build an NFA and watch subset construction run state by state — each DFA state annotated with the NFA subset it represents.

↩ Back to Home

Define Your NFA

Pick a preset or fill in the fields, then hit Build to see the conversion live.
Quick Presets
Comma-separated
Use ε or 'eps' for epsilon
Comma-separated
One per line: from, symbol, to  ·  Use 'eps' for ε transitions
Use ← → arrow keys or Space to step through the conversion
NFA original
NFA Transition Table · highlighted = active states at this step
DFA being built
DFA Transition Table · rows appear as states are discovered · highlighted cell = current computation
💡
WAITING
Run the construction to begin.
0/0
↩ Edit NFA
← Home
String Acceptor · define a DFA, enter a string, watch it run
0/0
Trace Log
DFA Graph active state pulses
⬡  Enter a string and press Run
DFA (before minimization)
Distinguishability Table (Table-Filling) · ✗ = distinguishable · ≡ = equivalent
Minimized DFA
Equivalence Classes
🔬
WAITING
Step through the table-filling algorithm.
0/0
↩ Back to DFA