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.

Time 25–35 minBook Ch. 0 and §1.1Exam win Identify a DFA’s language from its arrows
The win

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.

Start q₀. On 0 every state goes to q₀. On 1, q₀ goes to q₁, q₁ to q₂, and q₂ stays. Only q₂ accepts.
Reading 0 resets the trailing count of 1s, and the accepting loop keeps track of runs of at least two.
StateMeaning after the input read so farNext on 0Next on 1
q₀No trailing 1s, including before any inputq₀q₁
q₁Exactly one trailing 1q₀q₂
q₂At least two trailing 1sq₀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.

The highlighted symbol is next to read. The state displayed is the state after the symbols already read.
The mistake everyone makes

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.”

Start and accepting state E. O rejects. Each state loops on 0 and moves to the other state on 1.
A 1 changes the state and a 0 preserves it, so E means an even 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

6Check yourself

7Cheat card

Reading deterministic finite automata
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.
Ask your teacher for another worked example or for feedback on your own trace.