Deterministic Finite Automaton — Definition, Formula & Example
A deterministic finite automaton (DFA) is an abstract machine that reads a string one symbol at a time, moving between a fixed, finite set of states. At the end, it either accepts or rejects the string. From any state, each input symbol sends the machine to exactly one next state, so the same string always follows the same path.
A DFA is a 5-tuple . Here is a finite set of states, is a finite input alphabet, is a total transition function, is the start state, and is the set of accepting states. accepts a string if there is a sequence of states with , for , and . The set of all strings accepts is its language .
Key Formula
Where:
- = Finite set of states
- = Finite input alphabet, such as
- = Transition function: gives exactly one next state for each (state, symbol) pair
- = Start state, where every computation begins
- = Set of accepting (final) states
Worked Example
Problem: A DFA over has states , start state , and accepting set . It reads a binary number left to right. State means the bits read so far have remainder when divided by 3, so the transition rule is . Does the DFA accept the string 1101?
Step 1: Start in and apply the transition rule to each bit in order. Reading a bit doubles the old value and adds the bit, so the remainder updates as mod 3.
Step 2: Continue with the last two bits, 0 and then 1.
Step 3: The input is used up and the machine stops in . Since , the string is rejected. Check: 1101 in binary is 13, and 13 leaves remainder 1 when divided by 3, which matches the final state.
Answer: The DFA ends in , a non-accepting state, so it rejects 1101. This is correct, because 13 is not divisible by 3. The machine never stores the whole number. Its current state records only the remainder so far.
Why It Matters
DFAs are a core topic in a college Theory of Computation course. Kleene's theorem shows that they recognize exactly the regular languages, the same languages that regular expressions describe. Compilers use DFAs in their lexical analyzers to split source code into tokens. Text-search tools and network protocol checkers also use DFA-based pattern matching.
Common Mistakes
Mistake: Drawing a DFA where some state has no arrow for a symbol, or has two arrows labeled with the same symbol.
Correction: In a DFA, is a total function. Every state needs exactly one outgoing transition for each symbol in . If a symbol should lead to failure, send it to a non-accepting trap state that loops to itself. A diagram with missing or duplicate arrows describes a nondeterministic automaton (NFA) instead.
