STEP-BY-STEP LESSON · §12.2
Finite-State Automata
Trace a string through a deterministic finite automaton.
Before you begin
Words, alphabet and empty word
An alphabet is a finite set of allowed symbols. A word is a finite sequence of them; order and repetitions matter. ε is the empty word, with length 0. The language {ε} contains one word, whereas ∅ contains none.
Function, domain and codomain
A function assigns exactly one permitted output to every input in its domain. Its codomain is the declared output set; some members of that set may never be reached. The same formula on another domain or codomain can have different properties. f(x) names the output at x; it is not multiplication.
Symbols
- δ(q,a)
- next state after symbol a in state q
Definitions and notation for this topic
DFA transition and acceptance
δ:Q×Σ→Q; δ(q,a); q₀; F⊆Q
A deterministic finite automaton has a finite state set Q, alphabet Σ, one initial state q₀, accepting states F⊆Q, and a transition δ(q,a) for each state-symbol pair. The transition gives the next state.
A word is accepted if and only if the state after its entire input lies in F. ε is accepted exactly when q₀∈F. An accepting state is not necessarily a halt state.
Separate glossary example
To accept binary words with an even number of 1s, use states E,O, start E, accept E. Reading 1 toggles E↔O; reading 0 leaves the state unchanged.
Step by step
Step 1 / 6
Specify the machine
Specify states, an alphabet, a start state, accepting states, and a transition for every symbol from every state.
A complete DFA determines each next step uniquely.
Worked example
A DFA tracks parity of the number of 1s: E starts and accepts; O rejects. A 1 toggles E↔O; a 0 leaves the state unchanged. Trace 101.
- Start in E before reading any symbol; the input symbols in order are 1,0,1.
- From E, a 1 moves to O. A 0 leaves us in O.
- The last 1 returns to E; the string is accepted because it contains two 1s.
Optional self-check
A DFA starts in rejecting S. Any 1 sends either state to accepting T; any 0 sends either state to S. Does input 10 accept?
Show answer
No. The run is S→T→S, and the final state rejects. Visiting T after a prefix does not settle acceptance.