Theory of Computation · Week 1 · Lesson 0001 of 7
Reading deterministic finite automata
A state records the part of the input history that affects the decision.
Trace a string one symbol at a time and explain what each state remembers.
1Symbols, strings and languages
An alphabet is a finite, nonempty set of symbols. The binary alphabet is Σ = {0, 1}. It specifies the symbols an input may use.
A string is a finite sequence of symbols from an alphabet. Its length, written |w| for a string w, counts its symbols. The empty string ε is the unique string of length zero. In “|0110| = 4,” the bars count the symbols in the sequence.
Σk is the set of strings of length exactly k. Σ* is the set of all finite strings over Σ, including ε. Σ+ consists of the strings of positive length. For example, 01 belongs to Σ2, Σ+, and Σ* when Σ is binary.
A language over Σ is a set of strings drawn from Σ*. This lets us express a rule as the set of inputs that satisfy it. “The language of binary strings of length two is {00, 01, 10, 11}.” The empty language ∅ contains zero strings. The language {ε} contains one string.
Sipser, Introduction to the Theory of Computation, Ch. 0 and §1.1.
2The state diagram
A state is one of the machine’s possible positions. A transition gives the next state when the machine reads a symbol. A deterministic finite automaton (DFA) has finitely many states and exactly one next state for each state and input symbol. This makes a run unique for every input.
The formal description is (Q, Σ, δ, q₀, F). Q contains the states, Σ is the alphabet, δ maps a state and symbol to one next state, q₀ ∈ Q is the start state, and F ⊆ Q is the set of accepting states. The unlabeled incoming arrow marks the start. A double circle marks acceptance. A loop returns to its own state.
| State | Meaning after the input read so far | Next on 0 | Next on 1 |
|---|---|---|---|
| q₀ | No trailing 1s, including before any input | q₀ | q₁ |
| q₁ | Exactly one trailing 1 | q₀ | q₂ |
| q₂ | At least two trailing 1s | q₀ | q₂ |
A suffix is a string at the end of a string. These state meanings give a decision for every possible suffix. “The DFA accepts precisely the strings with suffix 11.”
3Tracing a run
A run is the sequence of states visited while the machine reads a string. Start at q₀, follow one arrow per symbol from left to right, and accept if the final state belongs to F. A machine recognizes L when its set of accepted strings equals L. A language is regular if some DFA recognizes it.
Reaching an accepting state before the input ends does not decide the result. Finish the input and inspect the final state.
For a different input, 0110, the first 0 leaves the machine at q₀. The next 1 moves it to q₁. The second 1 moves it to q₂. The last 0 returns it to q₀, so it rejects. The string contains 11 but has suffix 10.
On ε, the machine reads no symbols and stays at q₀. Since q₀ is a single circle here, the machine rejects ε.
4Reading a parity machine
Parity is whether a count is even or odd. To remember parity, two states suffice, even when the count can grow arbitrarily. “Reading a 1 switches the parity of the number of 1s.”
For 1010, the states are E → O → O → E → E, so the string is accepted. For 100, the states are E → O → O → O, so the string is rejected. The start state E accepts ε because zero is even.
5Recap
- Each complete DFA gives one run per string.
- The final state decides whether the string belongs to the recognized language.
- A state meaning that survives each transition explains the behavior on strings of any length.
6Check yourself
7Cheat card
- DFA
- Exactly one next state per current state and symbol.
- Acceptance
- Start at q₀. Read every symbol. Accept exactly when the final state is in F.
- Language
- L(M) is the set of all strings the machine M accepts.
- Memory hook
- The start arrow sets your position. The final circle settles the decision.