Recall warm-up
- What does “deterministic” mean for δ?
Stuck? Peek at 1.1.1 States and the DFA
- DFA = (Q, Σ, δ, q₀, F), δ : Q × Σ → Q total. One step per symbol; always halts.
- Accept iff the last state ∈ F. ε accepted ⇔ q₀ ∈ F.
- Dead state: non-accepting, all self-loops. GATE counts it in minimal-DFA questions.
- Exactly one string of length k: k + 2 states. #DFAs (n states, m symbols, fixed start) = nⁿᵐ · 2ⁿ.
- When are there infinitely many paths from u to v in a graph?
Stuck? Peek at 0.2.5 Directed graphs
- Directed graph (V, E ⊆ V×V); self-loop; in/out-degree; labelled edges spell words along paths.
- Path length = #edges. Cycle = path returning to start. Self-loop = cycle of length 1.
- Reachable set: grow from u until nothing new (BFS). Shortest path in n-node graph ≤ n−1 edges.
- Infinitely many u→v paths ⇔ some cycle lies on a u→v route.
- What is Σ⁰?
Stuck? Peek at 0.3.2 Σᵏ, Σ*, Σ⁺ and languages
- |Σᵏ| = |Σ|ᵏ; Σ⁰ = {ε}; Σ* = ⋃ Σᵏ (k ≥ 0); Σ⁺ = Σ* − {ε}.
- #strings of length ≤ n over k symbols = (kⁿ⁺¹ − 1)/(k − 1); binary: 2ⁿ⁺¹ − 1.
- Language = any subset of Σ*. ∅ (no strings) ≠ {ε} (one string). Exactly r of one symbol in length n (binary): C(n, r).
- Shortlex order lists every string at a finite position.
The Hook
δ tells you one step. But you never ask a DFA about one symbol — you hand it a whole string, like a file to scan. We need a single function that answers “starting here, after reading this whole string, where am I?”, and then a precise name for the set of strings a DFA accepts. That name — regular language — is the first of the great language families in this subject.
Predict First
For the “ends with 01” DFA below, without tracing step by step: what state will it be in after reading 110101? (Hint: what does each state “mean”?)
Core Concept
Prediction check
Answer: q2. Each state has a meaning: q0 = “last symbol was 1 and not part of …01, or nothing read”, q1 = “last symbol was 0”, q2 = “last two symbols were 01”. 110101 ends in 01, so it is in q2. Thinking in meanings instead of tracing is the fastest way to work with DFAs.
The extended transition function δ̂
δ̂(q, ε) = q (reading nothing leaves you where you are)
δ̂(q, wa) = δ(δ̂(q, w), a) (read w, then one more symbol a)
δ̂(q, w) is simply “the state reached from q by following the path that spells w”. A key property: δ̂(q, xy) = δ̂(δ̂(q, x), y).
Acceptance and the language of a DFA
L(M) = { w ∈ Σ* | δ̂(q₀, w) ∈ F } — the language of M.
“M accepts the language L” means L(M) = L exactly (Lesson 0.3.4: yes on all of L, no on everything else).
Regular languages
This is the definition used throughout. Every finite language is regular (build a branching DFA with one path per string). The even-a’s language, “ends with 01”, “divisible by 3” are regular. Whether something like {aⁿbⁿ} is regular is a real question — answered in Phase 2.
Proving a DFA correct: the invariant method
Give each state a meaning (an invariant), then prove by induction on |w| that δ̂(q₀, w) = q exactly when w has q’s meaning. Base: ε lands in q₀ and has q₀’s meaning. Step: one more symbol moves to the state whose meaning now holds. Finally check that F is exactly the states whose meanings mean “in L”.
Reading a DFA’s language from its graph
- L(M) = ∅ iff no accepting state is reachable from q₀.
- L(M) = Σ* iff every state reachable from q₀ is accepting.
- L(M) is infinite iff some cycle lies on a path from q₀ to an accepting state (Lesson 0.2.5).
- Strings of length n accepted: count paths of length n from q₀ into F (a small table, row by row).
Putting it together
- δ̂(q, ε) = q and δ̂(q, wa) = δ(δ̂(q, w), a): the walk for a whole string.
- L(M) = { w : δ̂(q₀, w) ∈ F }; a language is regular iff some DFA accepts it.
- Emptiness, everything, infiniteness and counting are graph questions about the diagram.
Visual
States: q0, q1, q2
Transitions: q0>q0: 1; q0>q1: 0; q1>q1: 0; q1>q2: 1; q2>q0: 1; q2>q1: 0
δ̂ unrolled on w = 1101 (ends-with-01 DFA)
δ̂(q0, ε) = q0
δ̂(q0, 1) = δ(q0,1) = q0
δ̂(q0, 11) = δ(q0,1) = q0
δ̂(q0, 110) = δ(q0,0) = q1
δ̂(q0, 1101) = δ(q1,1) = q2 ∈ F → ACCEPT
rejected: w = 011 → q0 ─0→ q1 ─1→ q2 ─1→ q0 ∉ F → REJECT
state meanings (invariants)
q0 : w = ε, or w ends in 1 but not in 01 (i.e. ends in 11)
q1 : w ends in 0
q2 : w ends in 01 F = {q2}Worked Examples
Using the even-a’s DFA (1.1.1), compute δ̂(E, abab).
Show the full solution
E ─a→ O ─b→ O ─a→ E ─b→ E. δ̂(E, abab) = E, accepted (2 a’s).
How many strings of length 3 over {0,1} does the ends-with-01 DFA accept?
Show the full solution
Length 3 ending in 01: first symbol free → 2 strings (001, 101). Or count paths with a table: after 0 symbols {q0:1}; after 1: {q0:1, q1:1}; after 2: q0 gets from q0 on 1 (1) and q2 on 1 (0) → 1; q1 gets from all states on 0 → 2; q2 gets from q1 on 1 → 1; after 3: q2 = (#q1 after 2) = 2. Answer 2.
A DFA over {a,b} has states {p, q, r}, start p, F = {r}. δ(p,a)=q, δ(p,b)=p, δ(q,a)=r, δ(q,b)=p, δ(r,a)=r, δ(r,b)=r. Describe L(M) and decide whether it is finite.
Show the full solution
p = “no progress”, q = “just read a (after a non-a or start)”, r = “seen aa” (then stay forever). L(M) = strings containing aa as a substring. r has self-loops and is reachable ⇒ a cycle lies on a path into F ⇒ infinite. Check: aab → p→q→r→r accept; aba → p→q→p→q reject ✓.
GATE Traps
- δ̂(q, ε) = q — reading ε does not move the machine.
- L(M) is the set of all accepted strings, not “the strings in the examples”.
- “Regular” is a property of a language, not of a single string or of a particular machine.
- Every finite language is regular — including ∅ and {ε}.
Memory Hook
δ is one footstep; δ̂ is the whole walk. Regular = “some DFA can take this walk for every string and end on the right squares.”
Connect the Dots
We can now say precisely what a DFA accepts. Next: a toolbox of design patterns — starts-with, ends-with, contains, counting mod n, divisibility — that covers most GATE DFA questions, with formulas for the number of states.
Self-Test
- MCQ
δ̂(q, ε) equals:
- q₀
- q
- the dead state
- undefined
- MSQ
Which are regular languages over {a,b}?
- ∅
- {ε}
- {a, ab, abb}
- Σ*
- NAT
The contains-aa DFA from the GATE example: how many strings of length 3 does it accept?
Write your answer before opening the key.
- MCQ
L(M) is infinite iff:
- M has a cycle
- M has a self-loop
- a cycle lies on some path from q₀ to an accepting state
- M has more than one accepting state
- MCQ
For any DFA, δ̂(q, xy) equals:
- δ̂(q, x) · δ̂(q, y)
- δ̂(δ̂(q, x), y)
- δ̂(δ̂(q, y), x)
- δ(q, xy)
Rule Card
- δ̂(q, ε) = q; δ̂(q, wa) = δ(δ̂(q, w), a); δ̂(q, xy) = δ̂(δ̂(q, x), y).
- L(M) = { w : δ̂(q₀, w) ∈ F }. Regular ⇔ accepted by some DFA. All finite languages are regular.
- From the graph: empty ⇔ no reachable final; Σ* ⇔ all reachable states final; infinite ⇔ cycle on a path start→final.
- Prove correctness with state meanings + induction on |w|.
Concept Ledger
- extended transition function δ̂
- M accepts w
- language of a DFA L(M)
- regular language
- state invariant (meaning of a state)
- counting accepted strings by paths
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- Exactly one next state for every (state, symbol).
- When a cycle lies on a route from u to v.
- {ε}.
Self-test answers
- B — Base case of the definition.
- A: Only if q = q₀.
- C: Reading nothing doesn’t trap you.
- D: It is defined.
- ABCD — All finite languages are regular, and Σ* is accepted by a 1-state DFA.
- 3 — aaa, aab, baa.
- C — Only cycles you can use on the way to accepting matter.
- A: A cycle in a dead state doesn’t help (dead state has self-loops but L may be finite).
- B: Same issue.
- D: Irrelevant.
- B — Read x first, then continue with y.
- A: States are not multiplied.
- C: Wrong order.
- D: δ takes one symbol.
Flashcards
- Definition of δ̂?
Reveal answer
δ̂(q, ε) = q; δ̂(q, wa) = δ(δ̂(q, w), a). - Definition of a regular language?
Reveal answer
A language accepted by some DFA. - Is every finite language regular?
Reveal answer
Yes. - When is L(M) infinite (graph view)?
Reveal answer
When some cycle lies on a path from q₀ to an accepting state.