On this page
A finite automaton is one of the simplest models of a computer: fixed, finite memory, one left-to-right pass over the input, and a yes or no answer. Michael Rabin and Dana Scott, in their 1959 paper Finite Automata and Their Decision Problems, define one as a finite set of internal states, a table of moves, an initial state and a set of designated final states.
What is a deterministic finite automaton?
A DFA has a finite set of states, an input alphabet, a transition function giving exactly one next state for each state and symbol, a start state, and a set of accepting states (Rabin and Scott, Definition 1). It accepts a string if, after reading it, it ends in an accepting state. A language is regular if some DFA accepts it.
How do you build a DFA for binary numbers divisible by 3?
You need only the remainder when divided by 3, not the whole number. Reading one more bit b after a number n gives 2n + b, so the remainder r becomes (2r + b) mod 3.
So use three states, q0, q1 and q2, one per remainder; start and accept in q0:
q0: on 0 go to q0, on 1 go to q1
q1: on 0 go to q2, on 1 go to q0
q2: on 0 go to q1, on 1 go to q2
Trace three inputs:
110 (six): q0, q1, q0, q0. Accepted.
1001 (nine): q0, q1, q2, q1, q0. Accepted.
1011 (eleven): q0, q1, q2, q2, q2. Rejected; 11 leaves remainder 2.
How are regular expressions and DFAs equivalent?
A regular expression builds a language from symbols with union (written |), concatenation and star (repeat zero or more times). Stephen Kleene introduced these "regular events" in Representation of Events in Nerve Nets and Finite Automata (1956). Kleene's theorem says a language is accepted by a finite automaton exactly when a regular expression describes it.
See one direction on our DFA by deleting states and relabelling the paths through them:
Remove q2. The trip q1 to q2 and back reads 0, any number of 1s, then 0: q1 gets a self-loop 01*0.
Remove q1. The trip q0 to q1 and back reads 1(01*0)*1: q0 gets a second self-loop.
q0 loops on 0 or that pattern, any number of times.
The result is (0|1(01*0)*1)*. Check 1001: a 1, then 00, then a 1.
How does the subset construction turn an NFA into a DFA?
A nondeterministic automaton (NFA) may have several moves for a state and symbol, or none, and accepts if at least one sequence of choices ends in a final state. Rabin and Scott introduced these machines and proved they accept nothing a DFA cannot: their Definition 11 builds a DFA whose states are sets of NFA states, and Theorem 11 shows it accepts the same strings.
Take strings whose second-to-last symbol is 1. The NFA has state A (loops on 0 and 1, and on a 1 may also guess and move to B), state B (either symbol goes to C) and accepting state C. Track the set of states the NFA could be in:
{A}: on 0 to {A}, on 1 to {A,B}
{A,B}: on 0 to {A,C}, on 1 to {A,B,C}
{A,C}: on 0 to {A}, on 1 to {A,B}
{A,B,C}: on 0 to {A,C}, on 1 to {A,B,C}
The sets containing C are accepting. Only 4 of the 2^3 = 8 possible subsets are reachable; in general an n-state NFA can need up to 2^n, which is why NFAs are often far smaller to write.
How do you minimise the states of a DFA?
Suppose you tracked the remainder mod 6 instead, accepting 0 and 3. It works but is wasteful. Partition refinement, the idea behind Moore's and Hopcroft's algorithms, shrinks it:
Split accepting from rejecting: {0,3} and {1,2,4,5}.
On input 1, states 1 and 4 go to 3 (accepting) while 2 and 5 go to 5 (rejecting). Split into {1,4} and {2,5}.
Check again. Every state in each block now moves to the same block on both inputs, so stop.
The blocks {0,3}, {1,4} and {2,5} are the remainders mod 3: the minimised machine is our 3-state DFA. By the Myhill-Nerode theorem the minimal DFA is unique apart from state names (DFA minimisation).
A finite automaton cannot count without limit: Rabin and Scott show no finite automaton accepts exactly the strings 0^n 1 0^n. For machines with unbounded memory, see why the halting problem is undecidable; the same states-and-moves thinking solves river crossing puzzles with a state graph and drives elementary cellular automata.
If a definition still feels shaky, the Fermi Concept Library has a lesson for every concept in computing and mathematics. To practise, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer.



