automata/lab
RUNS IN YOUR BROWSERSource ↗

FINITE MACHINES. INFINITE POSSIBILITIES.

A regex, under the hood.

Build it. Reduce it. Follow every transition.

THOMPSON → SUBSET → MINIMAL
AN INTERACTIVE COMPILER EXPLORER

The smallest equivalent machine.

States with identical future behavior become one.

5 STATES
Finite automatonStates and transitions. Use the state selector and transition table for the same information in text.
activeacceptingε = no input consumed
NFA STATES—
DFA STATES—
MINIMAL STATES—
COMPILER WORK—

Inspect a state

Outgoing transitions for the selected state
ON INPUTGO TOCHARACTERS
Compiling…
01 / THOMPSON CONSTRUCTION

Compose little machines.

Each syntax node becomes a fragment. Epsilon transitions connect them into a nondeterministic automaton.

02 / SUBSET CONSTRUCTION

Make every move certain.

Each DFA state represents a set of NFA states. Every character has exactly one destination, including a dead state when needed.

03 / PARTITION REFINEMENT

Keep only real distinctions.

Repeatedly split states with different futures. Equivalent states merge without changing the language the machine accepts.