Deterministic finite automaton
ID: deterministic-finite-automaton
A deterministic finite automaton has exactly one automaton transition for every automaton state and input symbol. Formally, a DFA is a tuple : is a nonempty finite set of automaton states, a finite alphabet, a function, the initial automaton state, and the accepting automaton states. Its unique path on a word accepts if it ends in after consuming the entire input. Visiting earlier does not suffice.
For a concrete binary divisibility automaton, recognize the words whose values in the binary numeral system are divisible by three. Choose , , , and . Each automaton state names the congruence class of the integer read so far. Appending a binary digit changes its value to , so the automaton transition isThe modular arithmetic therefore needs only three automaton states, whatever the input length. The full function is , , , , , and .
A three-state DFA for binary digits representing integers divisible by three, with accepted and rejected traces
. Details. For , the successive automaton states are , so the word is accepted. For , they are , so it is rejected. Leading zeros are allowed: they leave the initial automaton state unchanged. We explicitly assign value zero to the empty word, which is accepted because the initial automaton state is accepting. This is a convention for a formal language, rather than a claim that ordinary written numerals include a blank numeral.
The generator checks every word of up to eight binary digits, comparing the final automaton state with the integer value modulo three. Each length includes all words, preserving leading zeros as distinct inputs:
All 511 checks agree. They are useful for catching a reversed arrow or mistaken label, but the reason the DFA works at every length is its invariant: after reading any word of value , its automaton state is . The update preserves that statement by mathematical induction. Through the extended transition function of a deterministic finite automaton, this becomes .
New to topics? Read the docs here!
