All Tools

Finite State Machine Builder

Build finite automata visually. Add states and transitions, then test input strings with animated step-by-step processing. Works for both DFA and NFA machines.

Add states and transitions to build your machine

Build Machine

Test Input

Machine Properties

NFAIncomplete0 states0 transitions

Reference Guide

Finite Automata

A finite automaton is a mathematical model of computation with a finite number of states. It reads an input string one symbol at a time, transitioning between states according to a set of rules.

Formally, a finite automaton is a 5-tuple:

M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F)

where Q is the set of states, Σ\Sigma is the input alphabet, δ\delta is the transition function, q0q_0 is the start state, and F is the set of accept states.

DFA vs NFA

A DFA (Deterministic Finite Automaton) has exactly one transition per state per symbol. For every state and every input symbol, the next state is uniquely determined.

An NFA (Nondeterministic Finite Automaton) allows multiple transitions for the same symbol from a single state. It accepts if any possible path leads to an accept state.

Both DFA and NFA recognize exactly the same class of languages, the regular languages. Every NFA can be converted to an equivalent DFA (though the DFA may have exponentially more states).

Transition Functions

The transition function defines how the machine moves between states. For a DFA it maps a state and input symbol to exactly one next state:

δ:Q×ΣQ\delta : Q \times \Sigma \to Q

For an NFA, the transition function maps to a set of possible next states:

δ:Q×ΣP(Q)\delta : Q \times \Sigma \to \mathcal{P}(Q)

A transition is written as δ(q0,a)=q1\delta(q_0, a) = q_1, meaning "from state q0q_0, on input aa, go to state q1q_1".

Regular Languages

A language is regular if some finite automaton recognizes it. Regular languages are closed under union, intersection, complement, concatenation, and Kleene star.

Examples of regular languages include "binary strings divisible by 3", "strings ending in ab", and "strings with an even number of 0s". All of these can be expressed as regular expressions and recognized by finite automata.

Not all languages are regular. For instance, the language of balanced parentheses requires a pushdown automaton (stack), making it context-free but not regular.