Recall warm-up
- When does an NFA reject a string?
Stuck? Peek at 1.2.1 Nondeterminism and the NFA
- NFA: δ : Q × Σ → P(Q); moves may be 0, 1, many.
- Accept iff some path ends in F ⇔ δ̂(q₀, w) ∩ F ≠ ∅. Track the set of active states.
- DFA ⊆ NFA; NFAs accept exactly the regular languages.
- No dead state needed. Swapping F does NOT complement an NFA.
- Minimal DFA states for “starts with ab” over {a,b}?
Stuck? Peek at 1.1.3 DFA design patterns
Language (|w| = k pattern) Minimal states starts with w k + 2 contains w / ends with w k + 1 |x| ≡ r mod n n |x| = k, |x| ≤ k k + 2 |x| ≥ k k + 1 #a mod m and/or #b mod n m·n (typical) binary value ≡ 0 mod k, k odd k binary ÷ 2ʲ j + 1 k-th symbol from start fixed k + 2 Divisibility update: r ← (base·r + digit) mod k.
- What is the reachable set from a node in a graph and how is it computed?
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.
The Hook
You have one machine for “even number of a’s” and another for “b’s in multiples of three”. You want a machine for “either”. With an NFA you could carefully merge the start states. Easier: add a new start state with two free jumps — one into each machine — that read nothing. Free jumps are called ε-moves, and they turn machine-building into Lego.
Predict First
In the ε-NFA for a*b* below, before reading anything, which states can the machine already be in?
Core Concept
Prediction check
Answer: {p, q}. It starts in p and can take the free ε-jump to q without reading. That set is the ε-closure of p. Because q is accepting, ε is accepted.
ε-moves
ε-closure
Compute it exactly like reachability in a graph (0.2.5), using only ε-edges: start with {q}, keep adding ε-successors until nothing new appears.
How an ε-NFA runs
- Start set = ECLOSE(q₀).
- On symbol a: move every active state on a (ignore ε here), take the union, then take ECLOSE of the result.
- Accept iff the final set contains an accepting state.
Formally δ̂(q, ε) = ECLOSE(q); δ̂(q, wa) = ECLOSE( ⋃_{p ∈ δ̂(q,w)} δ(p, a) ).
Same power again
Every ε-NFA can be converted to an NFA without ε-moves (and then to a DFA). ε-NFAs still accept exactly the regular languages. Their value is in construction: union, concatenation and repetition of machines become one-line ε-wirings — the basis of converting regular expressions to automata in Phase 2.
Putting it together
- ε-moves change state without reading input.
- ECLOSE(q) = ε-reachable states including q; take it at the start and after every symbol.
- ε-NFAs accept exactly the regular languages.
Visual
States: p, q
Transitions: p>p: a; p>q: ε; q>q: b
a*b*: p (a-loop) ──ε──► q (b-loop, accepting)
ECLOSE(p) = {p, q} ECLOSE(q) = {q}
trace "aab": {p,q} ─a→ ECLOSE({p}) = {p,q} ─a→ {p,q} ─b→ ECLOSE({q}) = {q} q ∈ F ACCEPT
trace "ba" : {p,q} ─b→ {q} ─a→ ∅ REJECT
States: s, e0, e1, b0, b1, b2
Transitions: s>e0: ε; s>b0: ε; e0>e1: a; e1>e0: a; b0>b1: b; b1>b2: b; b2>b0: b
Worked Examples
ε-NFA: 1 ─ε→ 2, 2 ─ε→ 3, 3 ─a→ 4, 4 ─ε→ 1. Find ECLOSE(1), ECLOSE(4).
Show the full solution
ECLOSE(1) = {1, 2, 3}. ECLOSE(4) = {4, 1, 2, 3} (4 ─ε→ 1 then onward).
In the union machine above, trace “aa” and “bb”.
Show the full solution
Start ECLOSE(s) = {s, e0, b0}. “aa”: a → {e1} → a → {e0} ∈ F ⇒ accept. “bb”: b → {b1} → b → {b2} ⇒ reject (needs 3, 6, … b’s).
ε-NFA over {0,1}: A (start) ─0→ A, A ─ε→ B, B ─1→ B, B ─ε→ C, C ─0→ C, C accepting. Which of 0101, 0010, 110, ε are accepted?
Show the full solution
The structure is 0*1*0*. ε: ECLOSE(A) = {A,B,C} includes C ⇒ accept. 0010: 0* (00), 1* (1), 0* (0) ⇒ accept. 110: ⇒ accept. 0101: after 0,1,0 we are only in C; next 1 has no move from C ⇒ reject. Accepted: ε, 0010, 110.
GATE Traps
- ECLOSE(q) always includes q itself.
- Take the closure at the start AND after every symbol.
- ε-moves are not symbols of the input; |w| does not count them.
- An ε-NFA accepts ε iff ECLOSE(q₀) contains an accepting state — not only if q₀ ∈ F.
Memory Hook
ε-moves are free teleporters: stepping onto the pad costs no input, and you always check where every pad can take you before and after each step.
Connect the Dots
We have three machine types — DFA, NFA, ε-NFA. Next lesson proves they are equally powerful by converting each into a DFA, and shows the price: the DFA can need up to 2ⁿ states.
Self-Test
- MCQ
ECLOSE(q) is:
- states reachable from q by any moves
- states reachable from q by ε-moves only, including q
- states reachable from q by exactly one ε-move
- the accepting states
- NAT
ε-NFA: 1 ─ε→ 2, 2 ─ε→ 3, 3 ─ε→ 1, 3 ─a→ 4. |ECLOSE(2)| = ?
Write your answer before opening the key.
- MSQ
For the 0*1*0* ε-NFA in the GATE example, which strings are accepted?
- 000
- 101
- 1001
- 0110
- MCQ
An ε-NFA accepts ε exactly when:
- q₀ ∈ F
- ECLOSE(q₀) ∩ F ≠ ∅
- F = ∅
- it has an ε-move
Rule Card
- ε-NFA: δ : Q × (Σ ∪ {ε}) → P(Q).
- ECLOSE(q) = ε-reachable states incl. q (graph reachability on ε-edges).
- Run: start ECLOSE(q₀); each symbol: move, then ECLOSE. Accept iff final set ∩ F ≠ ∅.
- Same power as DFA/NFA; great for wiring machines together.
Concept Ledger
- ε-move
- ε-NFA
- ε-closure ECLOSE(q)
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- When every path dies or ends outside F.
- 4.
- All nodes with a path from it; grow the set until nothing new is added (BFS).
Self-test answers
- B — Zero or more ε-moves.
- A: Symbol moves don’t count.
- C: Zero or more, not exactly one.
- D: Unrelated.
- 3 — {2, 3, 1}.
- AD — The machine accepts exactly 0*1*0*: some 0s, then some 1s, then some 0s. 000 = 000·ε·ε and 0110 = 0·11·0 fit.
- B: 101: after 1 then 0 the machine is only in C, and C has no move on 1.
- C: 1001: same problem — a 1 cannot follow the final block of 0s.
- B — Free jumps from q₀ can reach F.
- A: Sufficient but not necessary.
- C: Then nothing is accepted.
- D: Not enough by itself.
Flashcards
- ECLOSE(q) includes q?
Reveal answer
Yes, always (zero ε-moves). - How does an ε-NFA process a symbol?
Reveal answer
Move all active states on the symbol, union the results, then take the ε-closure. - When does an ε-NFA accept ε?
Reveal answer
When ECLOSE(q₀) contains an accepting state.