CS Atlas GATE 2027
TOC course
0 / 91 complete

TOC/Phase 1 · Finite Automata

Lesson 1.2.2 · Item 21 of 91

ε-NFA and ε-closure

Read at your own pace. Try the questions before opening the answers.

On this page

Recall warm-up

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

    Read lesson 1.2.1

  2. 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 wk + 2
    contains w / ends with wk + 1
    |x| ≡ r mod nn
    |x| = k, |x| ≤ kk + 2
    |x| ≥ kk + 1
    #a mod m and/or #b mod nm·n (typical)
    binary value ≡ 0 mod k, k oddk
    binary ÷ 2ʲj + 1
    k-th symbol from start fixedk + 2

    Divisibility update: r ← (base·r + digit) mod k.

    Read lesson 1.1.3

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

    Read lesson 0.2.5

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.

p
start
ε
q
reached without reading
ECLOSE(p) = {p, q} before any input: since q accepts, ε is accepted.

ε-moves

ε-NFA: an NFA whose transition function also allows ε as a label: δ : Q × (Σ ∪ {ε}) → P(Q). An ε-move changes state without consuming input.
symbol move
p —a→ q consumes one a
ε-move
p —ε→ q consumes nothing
A free jump.

ε-closure

ECLOSE(q) = the set of states reachable from q using only ε-moves (including q itself, via zero moves). For a set S, ECLOSE(S) = ⋃ ECLOSE(q) over q ∈ S.

Compute it exactly like reachability in a graph (0.2.5), using only ε-edges: start with {q}, keep adding ε-successors until nothing new appears.

ε-closure is reachability using only ε-edges (1 →ε 2 →ε 3, 3 →a 4, 4 →ε 1).
ε-closure is reachability using only ε-edges (1 →ε 2 →ε 3, 3 →a 4, 4 →ε 1).

How an ε-NFA runs

  1. Start set = ECLOSE(q₀).
  2. On symbol a: move every active state on a (ignore ε here), take the union, then take ECLOSE of the result.
  3. Accept iff the final set contains an accepting state.

Formally δ̂(q, ε) = ECLOSE(q); δ̂(q, wa) = ECLOSE( ⋃_{p ∈ δ̂(q,w)} δ(p, a) ).

flowplay illustration
The ε-NFA loop: move, then close.

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.

ε-NFA
remove ε-moves
NFA
subset construction
DFA
Same language at every stage.

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

ε-NFA for a*b*

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
ε-NFA: (strings of a’s of even length) ∪ (strings of b’s of length divisible by 3)

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

Easy

ε-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).

Medium

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

GATE-level

ε-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

  1. MCQ

    ECLOSE(q) is:

    1. states reachable from q by any moves
    2. states reachable from q by ε-moves only, including q
    3. states reachable from q by exactly one ε-move
    4. the accepting states
  2. NAT

    ε-NFA: 1 ─ε→ 2, 2 ─ε→ 3, 3 ─ε→ 1, 3 ─a→ 4. |ECLOSE(2)| = ?

    Write your answer before opening the key.

  3. MSQ

    For the 0*1*0* ε-NFA in the GATE example, which strings are accepted?

    1. 000
    2. 101
    3. 1001
    4. 0110
  4. MCQ

    An ε-NFA accepts ε exactly when:

    1. q₀ ∈ F
    2. ECLOSE(q₀) ∩ F ≠ ∅
    3. F = ∅
    4. 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

  1. When every path dies or ends outside F.
  2. 4.
  3. All nodes with a path from it; grow the set until nothing new is added (BFS).

Self-test answers

  1. B — Zero or more ε-moves.
    • A: Symbol moves don’t count.
    • C: Zero or more, not exactly one.
    • D: Unrelated.
  2. 3 — {2, 3, 1}.
  3. 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.
  4. B — Free jumps from q₀ can reach F.
    • A: Sufficient but not necessary.
    • C: Then nothing is accepted.
    • D: Not enough by itself.

Flashcards

  1. ECLOSE(q) includes q?
    Reveal answerYes, always (zero ε-moves).
  2. How does an ε-NFA process a symbol?
    Reveal answerMove all active states on the symbol, union the results, then take the ε-closure.
  3. When does an ε-NFA accept ε?
    Reveal answerWhen ECLOSE(q₀) contains an accepting state.

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.