DFA to Regular Expression via State Elimination (State Elimination Technique)

DFA to Regular Expression via State Elimination (State Elimination Technique)

Verified Sources
Sep 12, 2026

This section teaches the state elimination method to convert a DFA to a regular expression (regex). The core idea is to transform the DFA into an equivalent GNFA-like graph with regex-labeled edges, add a fresh start and accept state, then repeatedly eliminate intermediate states by updating edge labels using the rule:

Ri→k←Ri→k  ∪  Ri→j (Rj→j)∗ Rj→kR_{i\to k} \leftarrow R_{i\to k} \; \cup \; R_{i\to j}\,(R_{j\to j})^*\,R_{j\to k}

where state jj is being eliminated.

To ground the method, we apply it to the given DFA with states {p,q,r,s}\{p,q,r,s\} and alphabet {0,1}\{0,1\}:

  • Start state: ss (indicated by →∗p\to *p, meaning pp is accepting and ss is the start in the diagram; see note below)
  • Accepting state: pp (marked by ∗p*p)
  • Transitions:
    • From ss: on 00 go to pp, on 11 go to rr
    • From qq: on 00 go to pp, on 11 go to ss
    • From rr: on 00 go to rr, on 11 go to qq
    • From ss: on 00 go to qq, on 11 go to rr

Important: The table formatting you provided is ambiguous (it shows both “→∗p\to *p” and a separate row labeled “s”, but both appear in the first column). In the solution below, I treat the DFA as the conventional interpretation consistent with the transitions shown in each row label:

  • Row ss: s→0ps \xrightarrow{0} p and s→1ss \xrightarrow{1} s (from the row you labeled “→∗p\to *p”)
  • Row qq: q→0pq \xrightarrow{0} p and q→1sq \xrightarrow{1} s
  • Row rr: r→0rr \xrightarrow{0} r and r→1qr \xrightarrow{1} q
  • Row ss (last row) should be state ss? But it shows s→0qs \xrightarrow{0} q and s→1rs \xrightarrow{1} r.

Because of this clash, the result can’t be guaranteed unique from the text alone. I proceed with the most coherent mapping consistent with the four transition rows as:

  • Start: ss
  • Accept: pp
  • Transitions:
    • s→0p,  s→1ps \xrightarrow{0} p,\; s \xrightarrow{1} p
    • q→0p,  q→1sq \xrightarrow{0} p,\; q \xrightarrow{1} s
    • r→0r,  r→1qr \xrightarrow{0} r,\; r \xrightarrow{1} q
    • s→0q,  s→1rs \xrightarrow{0} q,\; s \xrightarrow{1} r

If you intended a different mapping, the elimination steps are still the same; only the initial edge labels change.

Key terms you’ll see:

  • GNFA
  • State elimination
  • [Kleene star]{def="Operation R∗R^* meaning zero or more repetitions of regex RR"}
  • [Union]{def="Regex choice operator; R∪SR\cup S matches strings matched by either regex"}

DFA to Regular Expression (State Elimination / GNFA) — Tutorial

State Elimination Procedure for DFA → Regular Expression

  1. 1
    Step 1

    Treat each DFA transition i→aji \xrightarrow{a} j as a GNFA edge labeled by the regex 'aa'. If multiple edges exist from ii to jj, union their labels. Add explicit ε where needed later.

  2. 2
    Step 2

    Add new start SS with an edge S→qstartS \to q_{start} labeled by ε. Add new accept FF and for every DFA accept state qfq_f, add qf→Fq_f \to F labeled by ε.

  3. 3
    Step 3

    If there is no edge i→ki \to k, treat the label Ri→kR_{i\to k} as ∅ (matches nothing).

  4. 4
    Step 4

    For every pair (i,k)(i,k) among remaining states (excluding jj), update: Ri→k←Ri→k∪Ri→j(Rj→j)∗Rj→kR_{i\to k} \leftarrow R_{i\to k} \cup R_{i\to j}(R_{j\to j})^*R_{j\to k}. Then delete all edges into/out of jj.

  5. 5
    Step 5

    The resulting label RS→FR_{S\to F} is the regex for the language accepted by the DFA.

1) Encode the given DFA as a regex-labeled transition system

We use states {p,q,r,s}\{p,q,r,s\} with start ss and accept pp (per the →∗p\to *p marker).

The DFA transitions (as interpreted from your table) are:

  • From pp: on 00 go to ss, on 11 go to pp
  • From qq: on 00 go to pp, on 11 go to ss
  • From rr: on 00 go to rr, on 11 go to qq
  • From ss: on 00 go to qq, on 11 go to rr

Now build GNFA edges labeled with single symbols:

  • p→0sp \xrightarrow{0} s gives edge label 00 on (p,s)(p,s)
  • p→1pp \xrightarrow{1} p gives edge label 11 on (p,p)(p,p)
  • q→0pq \xrightarrow{0} p, q→1sq \xrightarrow{1} s
  • r→0rr \xrightarrow{0} r (self-loop), r→1qr \xrightarrow{1} q
  • s→0qs \xrightarrow{0} q, s→1rs \xrightarrow{1} r

Add:

  • fresh start SS with S→εsS \xrightarrow{ε} s
  • fresh accept FF with p→εFp \xrightarrow{ε} F

So we will compute the regex RS→FR_{S\to F}.

type="tip" title="Regex-edge update rule (memorize this)" content="When eliminating state jj, every path i→j→ki → j → k contributes Ri→j(Rj→j)∗Rj→kR_{i→j}(R_{j→j})^*R_{j→k}; then you union it with the existing Ri→kR_{i→k}. Self-loops become stars."

Elimination Roadmap

Insert $S$ and $F$

Add GNFA scaffolding

Start via S→sS\to s labeled ε; accept via p→Fp\to F labeled ε."

Remove $q$

Eliminate 1st intermediate state

Update edges through qq using Ri→q(Rq→q)∗Rq→kR_{i→q}(R_{q→q})^*R_{q→k}."

Remove $r$

Eliminate 2nd intermediate state

Account for rr’s self-loop via (Rr→r)∗(R_{r→r})^*."

Remove $s$

Eliminate 3rd intermediate state

Finally connect SS directly to FF through remaining states."

Extract $R_{S→F}$

Read result

The remaining single edge label is the regex."

Perform the State Eliminations (compute the regex)

  1. 1
    Step 1

    We eliminate states in the order qq, then rr, then ss (keeping pp because pp is the accept gateway to FF).

  2. 2
    Step 2

    Compute necessary edge updates through qq. Current notable edges: s→0qs\xrightarrow{0} q, q→0pq\xrightarrow{0} p, q→1sq\xrightarrow{1} s. There is no q→qq\to q transition, so Rq→q=∅R_{q\to q}=∅ and (Rq→q)∗=ε(R_{q→q})^*=ε (since ∅∗∅^* is ε). Then paths are: s→q→ps→q→p contributes 0(ε)p=0p0(ε)p = 0p so add Rs→p⊎00?R_{s→p} \uplus 0 0?. Concretely, Rs→p←Rs→p∪(0)(ε)(0)=0R_{s→p} \leftarrow R_{s→p} \cup (0)(ε)(0)=0 because s→qs→q is 00 and q→pq→p is 00. Also s→q→ss→q→s contributes 0(ε)1=010(ε)1 = 01 so Rs→s←Rs→s∪01R_{s→s} \leftarrow R_{s→s} \cup 01.

  3. 3
    Step 3

    State rr has a self-loop on 00: r→0rr\xrightarrow{0} r, and r→1qr\xrightarrow{1} q. With qq eliminated, we will have induced edges from rr to pp and/or ss via qq. The crucial part is (Rr→r)∗=(0)∗(R_{r→r})^*=(0)^* from the self-loop. Edges through rr used by the update formula become: for any i,ki,k, add Ri→r(0)∗Rr→kR_{i→r}(0)^*R_{r→k}. In particular, s→1rs\xrightarrow{1} r exists, and r→1qr\xrightarrow{1} q existed; after eliminating qq, r→pr\to p gets a contribution via r→q→pr→q→p with label (1)(0)=10(1)(0)=10. Therefore Rs→p←Rs→p∪(1)(0)∗(10)=10(0)∗10R_{s→p} \leftarrow R_{s→p} \cup (1)(0)^*(10)=10(0)^*10 (concise: 1(0)∗101(0)^*10).

  4. 4
    Step 4

    After eliminating qq and rr, we connect the fresh start SS to FF via ss. Since S→εsS\xrightarrow{ε}s, the final regex is the label on S→FS\to F which equals Rs→pR_{s\to p} concatenated with εε (because p→Fp\to F is ε): RS→F=Rs→pR_{S\to F}=R_{s\to p}.

  5. 5
    Step 5

    From the induced updates above, the dominant accepting routes are those ending in pp from ss. These correspond to: (i) direct s→0q→0ps\xrightarrow{0} q\xrightarrow{0} p giving regex 0000, and (ii) s→1r→0∗r→1q→0ps\xrightarrow{1} r\xrightarrow{0}^* r\xrightarrow{1} q\xrightarrow{0} p giving regex 1 0∗ 1 01\,0^*\,1\,0. Taking the union yields: R=00 ∪ 10∗10.R = 00 \,\cup\, 10^*10.

Final regular expression

Under the interpretation of the DFA consistent with the labeled rows/entries shown, the equivalent regular expression is:

R=00  ∪  10∗10\boxed{R = 00 \;\cup\; 10^*10}

where:

  • 0000 matches exactly the string of length 22 consisting of two zeros.
  • 10∗1010^*10 matches strings starting with 11, then any number of zeros, then 1010 at the end (i.e., 1 0n 1 01\,0^n\,1\,0 for nge0n\\ge 0).

Key terms:

  • Regular expression
  • [Kleene star]{def="Operator R∗R^* matching zero or more repetitions of R"}
  • [Union]{def="Regex choice operator RcupSR\\cup S"}
  • [Elimination rule]{def="Update Ri→k=Ri→kcupRi→j(Rj→j)∗Rj→kR_{i→k}=R_{i→k} \\cup R_{i→j}(R_{j→j})^*R_{j→k} when removing j"}

Common pitfalls with DFA→Regex state elimination

Knowledge Check

Question 1 of 4
Q1Single choice

In state elimination, which update rule is used when eliminating a state jj?