Skip to content

A PRACTICAL GUIDE TO AUTOMATA · 12 NOVEMBER 2026

A finite-state machine remembers one thing: where it is.

A finite-state machine, or FSM, describes behaviour as a fixed set of states and rules for moving between them. In a deterministic FSM, each state and event pair has one next state.

01

THE FIVE PARTS

The formal definition, in plain language

Textbooks write a deterministic finite automaton as a five-part tuple. The notation is compact; the ingredients are ordinary.

M = (Q, Σ, δ, q₀, F)

Q

the finite set of states

Σ

the events or input alphabet

δ

the transition function

q₀

the initial state

F

the accepting states, when acceptance matters

02

RUN THE EXAMPLE

A turnstile needs two states

The gate is either locked or unlocked. A coin and a push are the only events. Press the buttons below and watch the active state move through the graph.

LIVE MACHINE · TURNSTILE

Current state: locked

COINPUSHLockedPUSH → LOCKEDUnlockedCOIN → UNLOCKED

The gate starts locked.

03

TRANSITION FUNCTION

The graph and the table say the same thing

Every row answers one question: given this state and this event, which state comes next? A deterministic machine has exactly one answer for each pair.

CURRENT STATEEVENTNEXT STATE
LockedCOINUnlocked
LockedPUSHLocked
UnlockedCOINUnlocked
UnlockedPUSHLocked

04

WHERE THE MODEL FITS

Use an FSM when the named states explain the behaviour

Good fits

• checkout and approval flows

• UI modes such as idle, loading, ready and failed

• protocol and device controllers

• parsers, validators and simple game logic

Warning signs

• the state is mostly an unbounded number or document

• independent regions produce a large cross-product

• the hard part is continuous time rather than discrete events

• names for the states add less clarity than direct rules

05

BEYOND THE BASIC FSM

Statecharts keep larger machines readable

Real applications often need nested states, several active regions, guarded transitions and data carried beside the state. Statecharts add those tools while preserving the same event-driven model.

ViaState stores the result as an XState-compatible definition. The canvas shows the structure, and the simulator exposes the active states and context after each event.