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:

RikRik    Rij(Rjj)RjkR_{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: s0ps \xrightarrow{0} p and s1ss \xrightarrow{1} s (from the row you labeled “p\to *p”)
  • Row qq: q0pq \xrightarrow{0} p and q1sq \xrightarrow{1} s
  • Row rr: r0rr \xrightarrow{0} r and r1qr \xrightarrow{1} q
  • Row ss (last row) should be state ss? But it shows s0qs \xrightarrow{0} q and s1rs \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:
    • s0p,  s1ps \xrightarrow{0} p,\; s \xrightarrow{1} p
    • q0p,  q1sq \xrightarrow{0} p,\; q \xrightarrow{1} s
    • r0r,  r1qr \xrightarrow{0} r,\; r \xrightarrow{1} q
    • s0q,  s1rs \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 RR^* meaning zero or more repetitions of regex RR"}
  • [Union]{def="Regex choice operator; RSR\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 iaji \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 SqstartS \to q_{start} labeled by ε. Add new accept FF and for every DFA accept state qfq_f, add qfFq_f \to F labeled by ε.

  3. 3
    Step 3

    If there is no edge iki \to k, treat the label RikR_{i\to k} as ∅ (matches nothing).

  4. 4
    Step 4

    For every pair (i,k)(i,k) among remaining states (excluding jj), update: RikRikRij(Rjj)RjkR_{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 RSFR_{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:

  • p0sp \xrightarrow{0} s gives edge label 00 on (p,s)(p,s)
  • p1pp \xrightarrow{1} p gives edge label 11 on (p,p)(p,p)
  • q0pq \xrightarrow{0} p, q1sq \xrightarrow{1} s
  • r0rr \xrightarrow{0} r (self-loop), r1qr \xrightarrow{1} q
  • s0qs \xrightarrow{0} q, s1rs \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 RSFR_{S\to F}.

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

Elimination Roadmap

Insert $S$ and $F$

Add GNFA scaffolding

Start via SsS\to s labeled ε; accept via pFp\to F labeled ε."

Remove $q$

Eliminate 1st intermediate state

Update edges through qq using Riq(Rqq)RqkR_{i→q}(R_{q→q})^*R_{q→k}."

Remove $r$

Eliminate 2nd intermediate state

Account for rr’s self-loop via (Rrr)(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: s0qs\xrightarrow{0} q, q0pq\xrightarrow{0} p, q1sq\xrightarrow{1} s. There is no qqq\to q transition, so Rqq=R_{q\to q}=∅ and (Rqq)=ε(R_{q→q})^*=ε (since ∅^* is ε). Then paths are: sqps→q→p contributes 0(ε)p=0p0(ε)p = 0p so add Rsp00?R_{s→p} \uplus 0 0?. Concretely, RspRsp(0)(ε)(0)=0R_{s→p} \leftarrow R_{s→p} \cup (0)(ε)(0)=0 because sqs→q is 00 and qpq→p is 00. Also sqss→q→s contributes 0(ε)1=010(ε)1 = 01 so RssRss01R_{s→s} \leftarrow R_{s→s} \cup 01.

  3. 3
    Step 3

    State rr has a self-loop on 00: r0rr\xrightarrow{0} r, and r1qr\xrightarrow{1} q. With qq eliminated, we will have induced edges from rr to pp and/or ss via qq. The crucial part is (Rrr)=(0)(R_{r→r})^*=(0)^* from the self-loop. Edges through rr used by the update formula become: for any i,ki,k, add Rir(0)RrkR_{i→r}(0)^*R_{r→k}. In particular, s1rs\xrightarrow{1} r exists, and r1qr\xrightarrow{1} q existed; after eliminating qq, rpr\to p gets a contribution via rqpr→q→p with label (1)(0)=10(1)(0)=10. Therefore RspRsp(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 SFS\to F which equals RspR_{s\to p} concatenated with εε (because pFp\to F is ε): RSF=RspR_{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 s0q0ps\xrightarrow{0} q\xrightarrow{0} p giving regex 0000, and (ii) s1r0r1q0ps\xrightarrow{1} r\xrightarrow{0}^* r\xrightarrow{1} q\xrightarrow{0} p giving regex 10101\,0^*\,1\,0. Taking the union yields: R=001010.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    1010\boxed{R = 00 \;\cup\; 10^*10}

where:

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

Key terms:

  • Regular expression
  • [Kleene star]{def="Operator RR^* matching zero or more repetitions of R"}
  • [Union]{def="Regex choice operator RcupSR\\cup S"}
  • [Elimination rule]{def="Update Rik=RikcupRij(Rjj)RjkR_{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?