FA to Regular Expression (GNFA State Elimination)

Context: FIT2014_MOC Β· legs 3–4 of the Kleene’s Theorem cycle β€” the return journey from machine to expression Β· Assignment 1 hand skill Problem it solves: given an FA/NFA, produce a regular expression describing exactly the language it recognises.

Quick Revision

  • 🎯 Trigger: an automaton to convert into a regex βž” turn it into a standard GNFA, then rip out one state at a time until a single edge remains.
  • ⚑ Key Constraint: the elimination formula must be applied to every ordered pair before the state is deleted β€” missing a pair loses strings.

πŸ“ GNFA β€” the bridging model

  • Definition βž” a Generalised NFA is an NFA whose transitions may be labelled by regular expressions, not just single letters.
  • Acceptance βž” is accepted if it splits as along a Start-to-Final sequence of transitions labelled with each matching .
  • Standard GNFA βž” one Final state, distinct from the Start state; the Start state has no incoming transitions; the Final state has no outgoing transitions.
    • (Sipser additionally demands an arc between every pair of states, using where no transition should occur β€” β€œspecial form”. Not needed for this algorithm, but it simplifies proofs.)

βš™οΈ Step 1 β€” FA standard GNFA

  1. Single Final state with incoming arcs only βž” if necessary add a new Final state and -transitions from each old Final state to it; the old ones stop being Final.
  2. Single Start state with outgoing arcs only βž” if necessary add a new Start state with an -transition to the old Start state; the old one stops being Start.
  • Letters are already regexes βž” every existing edge label is a valid one-letter regular expression, so nothing else changes.
  • Language preserved βž” the resulting GNFA accepts exactly the original language.

βš™οΈ Step 2 β€” GNFA regular expression (state elimination)

Repeat until only the Start state, the Final state and one transition remain; that transition’s label is the answer.

Notation for the state being removed:

SymbolMeaning
the state being eliminated (neither Start nor Final)
any non-Final state (a predecessor)
any non-Start state (a successor)
label on
label on (self-loop)
label on
existing label on

The replacement rule β€” the new label on is

stateDiagram-v2
    direction LR
    qin --> q: R_in
    q --> q: R_loop
    q --> qout: R_out
    qin --> qout: R_direct
  • Reading the formula βž” either go straight from to (), or detour via : enter with , loop there any number of times (, possibly zero), then leave with .
  • Do it for all pairs βž” apply the rule for every and every , then delete . The result is an equivalent GNFA with one fewer state.

πŸ“Š Worked elimination (4-state example)

Eliminating state 2 from a GNFA on states (Start), , , (Final):

Pair rewrittenNew label

Then eliminating state 3 leaves the single Start-to-Final label:

  • Shape of the answer βž” each elimination round wraps the previous labels in one more layer, which is why these expressions grow quickly and rarely look β€œsimplified”.

✍️ Practice

⚠️ Common Mistakes

  • πŸ’‘ Eliminate every pair before deleting βž” the rule runs over all combinations, including (creating or extending a self-loop). Deleting early silently drops paths.
  • πŸ’‘ Never eliminate the Start or Final state βž” they are the endpoints; only intermediate states get ripped out.
  • πŸ’‘ covers zero loops βž” the star already includes β€œpass straight through ”, so don’t add a separate case for it.
  • πŸ’‘ No direct edge means , not βž” contributes nothing to the union; using would wrongly accept skipping the segment entirely.
  • πŸ’‘ Expect ugly output βž” the expression is correct even if far from minimal; simplifying is a separate (optional) step.

🧠 Active Recall