Deterministic Finite Automata: States, Transitions, and Accepted Languages
Anchor (Master): Sipser 2013 Introduction to the Theory of Computation 3e (Cengage) §1.1-1.2; Hopcroft, Motwani & Ullman 2006 Introduction to Automata Theory, Languages, and Computation 3e (Pearson) §2.1-2.4 (DFA, NFA, product construction, closure properties, minimisation via Myhill-Nerode)
Intuition Beginner
Imagine a turnstile at a subway station. It has two positions: locked and unlocked. You push a coin in, and it unlocks. You walk through, and it locks again. No matter how many times you push a coin without walking through, the turnstile stays unlocked. It has no memory beyond its current position.
A deterministic finite automaton (DFA) is exactly this kind of device. It is a machine with a fixed collection of positions called states. At every moment it is in exactly one state. It reads an input string one symbol at a time, and each symbol causes a single, predetermined move to a new state. There is no choice, no randomness, and no memory of the past beyond which state you happen to be in right now.
After reading the entire input, the DFA either accepts or rejects the string. Acceptance depends only on whether the final state belongs to a designated set of accept states. The language of the DFA is the collection of all strings it accepts.
The remarkable fact about DFAs is that, despite their extreme simplicity, they capture a large and useful class of languages called the regular languages. Every language you can describe with a regular expression, every language you can search for with a text editor's find command, every pattern that does not require counting or nesting — all of these are the languages of some DFA.
Visual Beginner
A DFA drawn as a directed graph. Each state is a circle. Arrows between states are labelled with input symbols. The start state has an incoming arrow from nowhere. Accept states have double circles.
0 1 0 1
→ [q0] ──→ [q1] ──→ [q2] ──→ [q0]
│ ↑ │
└── 1 ─────────────┘ (self-loop omitted for clarity)This DFA accepts strings over {0, 1} that end in "01". State q0 is the start. After reading a 0, move to q1 (the "maybe we just saw a 0" state). After reading a 1 from q1, move to q2 (accept). From q2, reading a 0 restarts the cycle at q1.
| Input string | State sequence | Accepted? |
|---|---|---|
| 01 | q0 → q1 → q2 | Yes |
| 001 | q0 → q1 → q1 → q2 | Yes |
| 010 | q0 → q1 → q2 → q1 | No |
| 1101 | q0 → q0 → q0 → q1 → q2 | Yes |
| 10 | q0 → q0 → q1 | No |
The pattern: only strings whose last two symbols are 0 then 1 land in the double-circled accept state q2.
Worked example Beginner
We build a DFA for the language of all strings over the alphabet {0, 1} that end in "01". Call the states , , .
State meanings. State means "I have not just read a 0 that could start the suffix 01." State means "I just read a 0, so the next symbol could complete 01." State means "I just completed 01."
Transitions. From , reading a 0 moves to (a potential start of the suffix). Reading a 1 stays in (a 1 cannot start 01).
From , reading a 1 completes the suffix, so move to (accept). Reading a 0 stays in (we just saw a 0, which could still be the start of a new suffix).
From , reading a 0 moves to (the new 0 could start another suffix). Reading a 1 moves to (a 1 after a completed 01 resets us — we have not just seen a 0).
Accept states. Only . The start state is .
Trace the string "1101". Start at . Read 1: stay . Read 1: stay . Read 0: go to . Read 1: go to . Accept. The string ends in 01, so the DFA correctly accepts it.
Trace the string "10". Start at . Read 1: stay . Read 0: go to . End in , which is not an accept state. Reject. The string does not end in 01, so the DFA correctly rejects it.
Check your understanding Beginner
Formal definition Intermediate+
Definition (DFA). A deterministic finite automaton is a 5-tuple where:
- is a finite set of states,
- is a finite input alphabet,
- is the transition function,
- is the start state (also called the initial state),
- is the set of accept states (also called final states).
The transition function is total: for every state and every symbol , the value is a unique state in . This totality and uniqueness are what make the automaton deterministic.
Definition (extended transition function). The function extends from single symbols to entire strings by recursion:
where is the empty string, , and .
Definition (accepted language). The DFA accepts a string if . The language recognised (or accepted) by is
A language is regular if there exists a DFA with . The class of regular languages over is denoted .
Definition (product construction). Given two DFAs and over the same alphabet, the product DFA is
where and is chosen according to the desired operation:
- For intersection: .
- For union: .
- For complement of : flip accept and non-accept states, .
Counterexamples to common slips
"A DFA with more states accepts more strings." The number of states constrains memory, not the size of the language. A single-state DFA with an accept state and self-loops on all symbols accepts , an infinite language, while a 100-state DFA can accept the empty language.
"The transition function can be undefined on some inputs." By definition is a total function from to . If you want some transitions to be "missing," you are thinking of a nondeterministic automaton (see
47.01.02)."Accepting a string means the DFA prints yes." Acceptance is defined by the final state being in . There is no output beyond the classification into accept or reject.
Key theorem with proof Intermediate+
Theorem (closure under Boolean operations). The class of regular languages is closed under union, intersection, and complement. That is, if and are regular, then so are , , and .
Proof (complement). Let recognise . Define . For any string :
since the transition function is unchanged. The string is accepted by iff , which holds iff . So .
Proof (intersection via product). Let recognise and recognise . Construct with . By induction on :
The base case is immediate. The inductive step: .
Therefore iff and , i.e. .
Bridge. The product construction is the foundational reason regular languages form a Boolean algebra: any two regular languages can be combined by intersection, union, or complement without leaving the class. This builds toward the Myhill-Nerode theorem in 47.01.04, where the product construction reappears as the canonical way to compute the minimal DFA, and it appears again in 47.01.02 where the subset construction converts an NFA into a DFA by taking the power set of the NFA's states — a generalised product. The central insight is that DFAs compose: running two machines in parallel is itself a machine, and this is exactly what makes the regular languages algebraically well-behaved.
Exercises Intermediate+
Lean formalization Intermediate+
Mathlib has a DFA structure in Computability.DFA with fields δ, evalFrom, and accepts, but it does not provide the product construction for intersection or union as a named construction, nor the proof that the product DFA accepts the intersection of the two component languages. The Myhill-Nerode theorem and the minimisation algorithm are also absent. A Codex.Automata.DFA.Product module defining DFA.product and proving DFA.accepts (M₁.prod M₂) = DFA.accepts M₁ ∩ DFA.accepts M₂ would be the load-bearing first step; this unit ships without it.
Advanced results Master
The product construction gives regular languages the structure of a Boolean algebra. Three further results sharpen our understanding of what DFAs can and cannot do.
Theorem 1 (Myhill-Nerode). Let . Define the equivalence relation on by iff , . Then is regular iff has finitely many equivalence classes. Moreover, the number of classes equals the number of states in the minimal DFA for [Hopcroft, Motwani & Ullman §2.4].
The proof constructs the minimal DFA directly: each state corresponds to an equivalence class, and the transition function sends the class of under symbol to the class of . This DFA is unique up to isomorphism, and any other DFA for can be collapsed onto it by merging states that are -equivalent. The Myhill-Nerode theorem is the structural reason why some languages need many states and others need few.
Theorem 2 (closure under reversal). If is regular, then (where is written backwards) is also regular.
The proof uses an NFA construction: reverse all arrows, swap the start state with the accept states, and convert back to a DFA via the subset construction of 47.01.02. The resulting DFA may have exponentially more states, but it is still finite.
Theorem 3 (closure under homomorphism and inverse homomorphism). Let be a homomorphism (a function satisfying ). If is regular, then is regular. If is regular, then need not be regular, but is regular when is a letter homomorphism (each symbol maps to a single symbol or the empty string).
The inverse homomorphism closure is proved by feeding each symbol into the DFA for by running the DFA on from the current state. The extended transition function handles multi-symbol images naturally. This result is fundamental in the theory of regular substitutions and is used in the proof of the pumping lemma 47.01.04.
Synthesis. The DFA model is the foundational reason the regular languages are algebraically well-behaved: the product construction gives Boolean closure, the Myhill-Nerode theorem gives a canonical minimal representative for each regular language, and homomorphism closure connects regularity over one alphabet to regularity over another. The central insight is that finiteness of the state set constrains memory but not expressiveness within the regular class, and putting these together with the subset construction of 47.01.02 and Kleene's theorem of 47.01.03 yields the equivalence of three characterisations of regularity: DFAs, NFAs, and regular expressions. This equivalence is the structural backbone of formal language theory, and it appears again in the Chomsky hierarchy where each level (regular, context-free, context-sensitive, recursively enumerable) is defined by the type of automaton that recognises it.
Full proof set Master
Proposition 1 (closure under complement). If is regular, then is regular.
Proof. Let recognise . Define . Since the transition function is unchanged, for all . Then iff iff iff . So .
Proposition 2 (product construction correctness for intersection). Let and be DFAs over . Then when .
Proof. Let where . Claim: for all ,
By induction on . Base: , both sides equal . Step: . By induction, . Then:
Therefore iff iff and iff .
Proposition 3 (Myhill-Nerode theorem, forward direction). If is regular, then has finitely many equivalence classes.
Proof. Let recognise . Define by . If then for all , , so , i.e., . The function partitions into at most classes, so has at most equivalence classes.
Connections Master
50.03.01— Big-O and complexity analysis provide the framework for analysing the time and space efficiency of DFA simulation, where processing a string of length takes time and space (the current state).37.01.01— Probability spaces and distributions underpin the theory of probabilistic automata, a generalisation of DFAs where transitions are stochastic and acceptance is defined by a threshold on the probability of reaching an accept state.47.01.02— NFAs generalise DFAs by allowing multiple transitions per state-symbol pair; the subset construction converts any NFA to a DFA, proving both models recognise exactly the regular languages.47.01.03— Regular expressions provide an algebraic description of the same class of languages; Kleene's theorem proves the equivalence of DFA-recognisable and regex-describable languages.47.01.04— The pumping lemma for regular languages proves that certain languages are not regular by exploiting the finiteness of the DFA state set, formalising the pigeonhole argument that a DFA with states reading a string of length must revisit a state.
Historical & philosophical context Master
The concept of finite automata emerged from the study of nerve nets by Warren McCulloch and Walter Pitts in 1943, who modelled neurons as threshold logic devices. Stephen Kleene formalised their behaviour in 1956 with the representation theorem for regular events, proving that the languages recognised by these finite-state devices are exactly those described by regular expressions [Sipser §1.1].
Michael Rabin and Dana Scott's 1959 paper "Finite Automata and Their Decision Problems" introduced the formal DFA model as a 5-tuple, proved closure under Boolean operations via the product construction, and established the equivalence between deterministic and nondeterministic finite automata. This work earned them the Turing Award in 1976. The product construction itself is a natural instance of the Cartesian product of monoid actions: the state sets of two DFAs carry actions of the free monoid , and the product DFA carries the diagonal action.
Anil Nerode (1958) and John Myhill (1957) independently proved the theorem that now bears their names, characterising regularity by the finiteness of a right-invariant equivalence relation. The Myhill-Nerode theorem provides a canonical minimal DFA for each regular language and is the theoretical basis for DFA minimisation algorithms used in compiler design and pattern matching.
Bibliography Master
@book{sipser2013,
author = {Sipser, Michael},
title = {Introduction to the Theory of Computation},
edition = {3rd},
publisher = {Cengage Learning},
year = {2013},
}
@book{hopcroft2006,
author = {Hopcroft, John E. and Motwani, Rajeev and Ullman, Jeffrey D.},
title = {Introduction to Automata Theory, Languages, and Computation},
edition = {3rd},
publisher = {Pearson},
year = {2006},
}
@article{rabin1959finite,
author = {Rabin, Michael O. and Scott, Dana},
title = {Finite Automata and Their Decision Problems},
journal = {IBM Journal of Research and Development},
volume = {3},
number = {2},
pages = {114--125},
year = {1959},
}
@article{nerode1958linear,
author = {Nerode, Anil},
title = {Linear Automaton Transformations},
journal = {Proceedings of the American Mathematical Society},
volume = {9},
number = {4},
pages = {541--544},
year = {1958},
}
@article{kleene1956representation,
author = {Kleene, Stephen C.},
title = {Representation of Events in Nerve Nets and Finite Automata},
journal = {Automata Studies},
pages = {3--41},
year = {1956},
publisher = {Princeton University Press},
}