Recall warm-up
- State the Myhill–Nerode theorem in one line.
Stuck? Peek at 1.3.3 Myhill–Nerode theorem
- x ≡_L y ⇔ ∀z: xz ∈ L ⇔ yz ∈ L. Right-invariant equivalence.
- L regular ⇔ finite index; index = #states of minimal DFA (incl. dead class).
- Infinitely many pairwise distinguishable strings ⇒ not regular. aⁿbⁿ: strings aⁱ separated by bⁱ.
- Minimal DFA states for “2nd symbol from the end is 1”?
Stuck? Peek at 1.2.3 Subset construction and the 2ⁿ blow-up
- Subset construction: start {q₀} (or ECLOSE(q₀)); δ(S,a) = ⋃ δ(q,a) (then ECLOSE); accept iff S ∩ F ≠ ∅; ∅ = dead state.
- ≤ 2ⁿ states; count only reachable sets.
- ε-removal: δ'(q,a) = ECLOSE(δ(ECLOSE(q), a)); F' = {q : ECLOSE(q) ∩ F ≠ ∅}.
- k-th from end is 1: NFA k+1, DFA 2ᵏ. k-th from start: DFA k+2.
- DFA ≡ NFA ≡ ε-NFA in power.
- How many states does a product of 3- and 4-state DFAs have at most?
Stuck? Peek at 1.1.4 Product construction and complement
- Product: states Q₁×Q₂, δ((p,q),a) = (δ₁(p,a), δ₂(q,a)), start (s₁,s₂).
- ∩: F₁×F₂. ∪: F₁×Q₂ ∪ Q₁×F₂. −: F₁×(Q₂−F₂). ≤ |Q₁|·|Q₂| states.
- Complement: complete the DFA (add dead state), swap F ↔ Q−F; same state count.
- Regular languages closed under ∪, ∩, −, complement.
The Hook
A traffic-light controller doesn’t answer yes or no — it outputs a colour at every moment. A serial adder outputs one bit for every pair of input bits. These are finite-state machines that translate an input string into an output string. GATE gives this topic low weight, but the two output conventions are easy marks.
Predict First
A machine prints one output symbol every time it is in a state (including the start state). For an input of length 5, how long is the output?
Core Concept
Prediction check
Answer: 6. It visits 6 states (start + one after each symbol) — the same “moments” count as the pigeonhole lesson (0.2.4). That is a Moore machine.
| moment | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| input read | — | 1 | 0 | 1 |
| state | r0 | r1 | r2 | r2 |
| output | 0 | 1 | 2 | 2 |
Moore machine
Mealy machine
Neither machine has accepting states; they compute outputs, not yes/no.
| step | state | reads | output | next |
|---|---|---|---|---|
| 1 | A | 0 | 0 | A |
| 2 | A | 1 | 0 | B |
| 3 | B | 1 | 1 | B |
| 4 | B | 1 | 1 | B |
Equivalence and conversion
A Moore and a Mealy machine are considered equivalent if their outputs agree after ignoring the Moore machine’s initial output λ(q₀).
- Moore → Mealy: same states; λ'(q, a) = λ(δ(q, a)) (output the label of the state you enter). States: same number.
- Mealy → Moore: split each state q into copies (q, o) for each output o of transitions entering q. At most |Q| · |Δ| states (plus possibly one extra copy for the start state).
Typical machines
- Residue mod 3 of a binary number (Moore): states r0, r1, r2 output 0, 1, 2.
- 1’s complement (Mealy): one state, output 1 on input 0 and 0 on input 1.
- Detect “11” (Mealy): output 1 on a transition that completes 11.
Putting it together
- Moore: output per state, n + 1 symbols. Mealy: output per transition, n symbols.
- Moore → Mealy keeps the states; Mealy → Moore may need |Q|·|Δ|.
- Neither has accepting states — they translate rather than decide.
Visual
Moore: residue mod 3 (state/output) input 101 (=5):
0 1 r0/0 ─1→ r1/1 ─0→ r2/2 ─1→ r2/2
→ r0/0 r0 r1 output 0 1 2 2 (length 3+1 = 4)
r1/1 r2 r0 last output 2 = 5 mod 3 ✓
r2/2 r1 r2
Mealy: output 1 when the last two inputs are 11
state on 0 on 1 input 0111:
A A / 0 B / 0 A ─0/0→ A ─1/0→ B ─1/1→ B ─1/1→ B
B A / 0 B / 1 output 0 0 1 1 (length 4)Worked Examples
A Moore machine reads 10 symbols. How many output symbols does it produce? A Mealy machine?
Show the full solution
Moore: 11. Mealy: 10.
Convert the residue-mod-3 Moore machine to Mealy.
Show the full solution
λ'(q,a) = output of δ(q,a). r0: 0 → r0/0, 1 → r1/1. r1: 0 → r2/2, 1 → r0/0. r2: 0 → r1/1, 1 → r2/2. Still 3 states. On 101: outputs 1, 2, 2 — the Moore output minus its initial 0 ✓.
A Mealy machine has 4 states and output alphabet {0,1}. What is the maximum number of states of an equivalent Moore machine produced by the standard conversion?
Show the full solution
Each state splits by incoming output: at most 4 × 2 = 8 (the start state may need one extra copy if it has no incoming transition with a suitable output; the usual exam answer is |Q|·|Δ| = 8).
GATE Traps
- Moore output length n + 1 (includes the start state’s output); Mealy n.
- Neither machine accepts or rejects — no F.
- Moore → Mealy keeps the state count; Mealy → Moore can multiply it by |Δ|.
Memory Hook
MOore = Output On states (n+1). MEaly = output on the Edges (n).
Connect the Dots
Phase 1 complete. Finite automata in every flavour: DFA, NFA, ε-NFA, minimal DFA, and output machines. Phase 2 gives regular languages a second face: algebraic formulas called regular expressions — the thing behind search patterns in every editor.
Self-Test
- NAT
A Moore machine processes an input of length 12. Output length?
Write your answer before opening the key.
- MCQ
In a Mealy machine the output function is:
- λ : Q → Δ
- λ : Q × Σ → Δ
- λ : Σ → Δ
- λ : Δ → Q
- MSQ
Which are true?
- Moore → Mealy needs no extra states
- Mealy and Moore machines have accepting states
- Mealy → Moore may need up to |Q|·|Δ| states
- A Moore machine’s output depends only on the current state
- NAT
Using the residue-mod-3 Moore machine, what is the last output symbol for input 1101?
Write your answer before opening the key.
Rule Card
- Moore: λ : Q → Δ; output length n+1. Mealy: λ : Q × Σ → Δ; output length n.
- Moore → Mealy: same states, λ'(q,a) = λ(δ(q,a)). Mealy → Moore: ≤ |Q|·|Δ| states.
- No accepting states; equivalence ignores Moore’s first output.
Concept Ledger
- transducer (output machine)
- output alphabet Δ
- Moore machine (output on states)
- Mealy machine (output on transitions)
- Moore ↔ Mealy conversion
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- L is regular iff ≡_L has finite index; index = minimal DFA states.
- 4.
- 12.
Self-test answers
- 13 — n + 1.
- B — Output on transitions.
- A: That is Moore.
- C: Ignores state.
- D: Backwards.
- ACD — Standard conversions.
- B: They are transducers, without F.
- 1 — 1101 = 13; 13 mod 3 = 1.
Flashcards
- Moore vs Mealy output length for input length n?
Reveal answer
Moore n + 1; Mealy n. - Max Moore states when converting a Mealy machine?
Reveal answer
|Q| · |Δ| (standard answer). - Moore output function type?
Reveal answer
λ : Q → Δ