Home

statemachines

A state machine, sometimes written as statemachine, is a computational model used to design computer programs and sequential logic. It consists of a finite set of states, a finite set of inputs (events), a transition function that determines how states change in response to inputs, and optional actions associated with transitions or states. The machine starts in a designated initial state and produces behavior by moving between states as events occur.

There are several variants. Deterministic finite automata (DFA) have exactly one transition for each input in

A common representation is a state diagram, where nodes denote states and directed edges denote transitions

State machines are widely used in software engineering and embedded systems to model control flow, user interfaces,

State machines have roots in automata theory developed in the 20th century and were popularized by Harel's

every
state,
while
non-deterministic
automata
(NFA)
may
have
multiple
possible
transitions.
For
output
behavior,
Moore
machines
emit
outputs
according
to
the
current
state,
while
Mealy
machines
emit
outputs
based
on
the
state
and
input.
Hierarchical
and
concurrent
variants,
such
as
statecharts,
extend
the
basic
model
with
nesting
and
parallel
regions.
labeled
with
event
names,
guard
conditions,
and
actions.
Transitions
can
include
entry
and
exit
actions
for
states,
and
some
models
distinguish
between
internal
transitions.
In
formal
terms,
a
DFA
or
Mealy/Moore
machine
is
described
by
its
state
set,
input
alphabet,
transition
function,
and
output
function.
protocol
handlers,
parsers,
and
game
logic.
They
support
modular
design,
easier
testing,
and
formal
reasoning
about
properties
such
as
deadlock
freedom
and
reachability.
They
can
be
implemented
as
code,
tables,
or
generated
from
model
tools.
Statecharts
and
later
by
UML
state
machine
diagrams.
They
remain
a
foundational
tool
for
modeling
predictable,
event-driven
behavior
across
engineering
disciplines.