4.6.3 · D4Theory of Computation

Exercises — NFA — formal definition, epsilon transitions

2,260 words10 min readBack to topic

We use one small example NFA repeatedly. Meet it once, on paper, so no symbol is a surprise later.

Figure — NFA — formal definition, epsilon transitions

Level 1 — Recognition

Recall Solution

True. In an NFA outputs a set of states (). The empty set is a perfectly legal set — it just means "this branch dies here." Other branches may still reach . Contrast with a DFA, where a missing edge really is a modelling gap.

Recall Solution
  • : start at (include it — zero ε-moves allowed). One ε-arrow . From there are no ε-arrows. So .
  • : start at , no outgoing ε-arrows. So .
Recall Solution

Two differences from a DFA's :

  1. Output is a set () → allows many/zero targets.
  2. Domain includes → allows free moves.

Level 2 — Application

Recall Solution
  • Base: . Why? Before reading anything, ε-arrows already carry us to for free.
  • Read 1 from set :
    • union , then (ε-arrow from re-adds ).
  • accept ✅ (1 ends in 1).
Recall Solution
  • Base: .
  • Read 1: union → ECLOSE .
  • Read 0 from :
    • (that guess dies — a 0 can't be preceded straight into )
    • union , ECLOSE .
  • reject ✅ (10 ends in 0).
Recall Solution

, start , .

  • ,
  • ,
  • ,

Why nondeterminism helps: at on a we guess "this a starts the ab" (go to ) while also keeping the "not yet" branch alive at . If a b follows, the guess pays off () and loops forever, so acceptance sticks. The DFA would need explicit bookkeeping of each partial match — the NFA gets it for free.


Level 3 — Analysis

Recall Solution

Reachability of : The only way into is . The only way into is the ε-arrow from . And is reachable after reading any prefix (it loops on 0 and 1). So the accepting path is: sit in through the whole prefix, ε-slide to , read a final 1.

() If accepts , that path required a last consumed symbol equal to 1 (the step). Hence ends in 1.

() If ends in 1: read staying in (loops absorb everything), ε-slide to , read the final 1. Accept.

Empty string : . Intersect with : empty ⇒ reject. Correct — the empty string does not "end in 1."

Recall Solution

ECLOSE(): follow ε-chain . So . Why chain fully? "zero or more" ε-moves means we follow the arrows transitively until nothing new appears.

  • : , contains accept.
  • : from read a: only fires; union ; ECLOSE ; contains accept. This machine accepts .
Recall Solution

Number of subsets of a 3-element set : namely . Why it matters: the subset construction makes each DFA state one subset of NFA states (the set the NFA "is in"). Hence a -state NFA yields a DFA with at most states — that power-set blow-up is the price of removing nondeterminism, and it links directly to Regular Languages being closed under this conversion.


Level 4 — Synthesis

Recall Solution

Reuse the union pattern from the parent note. , start , .

  • (split into both branches for free)
  • ,
  • ,

Trace 11:

  • Base: .
  • Read 1: , , ; union ; ECLOSE .
  • Read 1: . Contains accept ✅.

Trace 01:

  • Base: .
  • Read 0: only ; set .
  • Read 1: ; set . Empty ⇒ reject ✅ (mixed string).

Why ε makes this clean: the single free split at is the union construction — a hallmark of Closure Properties of Regular Languages. Compare with the Regular Expressions 0*|1*: the | mirrors the ε-branch.

Recall Solution

Guess the 1: , start , .

  • , (guess: this 1 is 3rd-from-end)
  • ,
  • ,
  • : no outgoing edges (must be the end).

Trace 100:

  • Base: (no ε-arrows here, ECLOSE is trivial).
  • Read 1: (kept the "not yet" branch and the guess).
  • Read 0: , ; union .
  • Read 0: , ; union .
  • accept ✅ (in 100, third-from-end is the 1).

Level 5 — Mastery

Recall Solution

Effect of the new arrow : is accepting, is not, and was already reachable on every prefix. The new arrow only adds (and via its ε-arrow ) to any set already containing . It never removes states, and it never adds to a set that lacked it.

  • So a string previously accepted (reached a set containing ) still reaches a set containing (nothing is deleted) ⇒ still accepted.
  • A string previously rejected reached a set without ; the new arrow fires only from , so it cannot manufacture a where none existed ⇒ still rejected. Conclusion: is unchanged — still "ends in 1." Silent arrows only matter when they open a new route into .
Recall Solution

Bound: at most DFA states (one per subset of ). Tight in the worst case; often far fewer after removing unreachable subsets. Why is a legit DFA state: when all NFA branches die on some symbol, the "current set" becomes . In the DFA this is a non-accepting dead state that loops to itself on every symbol (since of the empty set is empty). It is the DFA's honest bookkeeping of "no NFA branch survives." This ties to DFA — formal definition, where every transition must be total — the state supplies the missing edges.

Recall Solution

Concept: Intersection of two regular languages is regular — a Closure Properties of Regular Languages result, realised by the product construction (run both machines' state-sets in parallel, accept when both accept). You would take (ends in 1) and a 2-state parity NFA (even length), form the product, and mark states final only where both components are final. Verify on 01:

  • Base: .
  • Read 0: , ; union ; ECLOSE .
  • Read 1: , ; union ; ECLOSE .
  • Contains accept ✅. (01 ends in 1; its length is even, so it would also survive the intersection.)

Recap

Recall One-line reminders (hide answers)
  • Output type of NFA ? ::: — a set of states.
  • When accept? ::: .
  • Meaning of ? ::: that branch dies, not an error.
  • DFA states from an -state NFA (worst case)? ::: .
  • How to get intersection of two regular languages? ::: product construction (AND of both machines).