Discrete MathematicsLanguages, Automata and Computability3 of 6
Languages, Automata and Computability · 3

Nondeterminism and Kleene's Theorem

Building a DFA requires wiring a backup arrow for every input that breaks a pattern, even when the pattern itself is just a few characters long.

1

Nondeterministic Finite Automata and Clones

A Nondeterministic Finite Automaton (NFA) removes those backup arrows by allowing a state to have multiple arrows for the same input, or no arrow for an input at all.

Nondeterministic Finite Automata and Clones
ends in 101\text{ends in }101
DFA\htmlClass{lc-mute}{\text{DFA}}
AA
11
BB
00
CC
11
DD
AA
BB
CC
DD
0, 10,\,1
11
00
11
ε\varepsilon

An ε\varepsilon-arrow is a transition a token crosses for free: the instant a token lands on a state with an outgoing ε\varepsilon-arrow, it immediately spawns a clone across that arrow before the next character is read, while the original token stays put.

To see whether the ends-in-101101 NFA accepts 11011101, we track the set of states holding surviving clones after each character.

Text solution
Split on the first 11Starting from a single token on AA, the first 11 follows both the loop on AA and the arrow to BB.
{A}→1{A,B}\displaystyle \{A\} \walk{\xrightarrow{1}} \{A, B\}
Advance and vanish on 1010On the second 11, the token on AA splits into AA and BB while the old token on BB has no 11-arrow and vanishes; on 00, AA stays on AA and BB moves to CC.
{A,B}→1{A,B}→0{A,C}\displaystyle \{A, B\} \walk{\xrightarrow{1}} \{A, B\} \walk{\xrightarrow{0}} \{A, C\}
Check the final group on the last 11The final 11 splits AA into AA and BB and moves CC into DD, so a surviving token stands on the finish state and the machine accepts 11011101.
{A,C}→1{A,B,D⏟finish}\displaystyle \{A, C\} \walk{\xrightarrow{1}} \{A, B, \underbrace{\finish{D}}_{\finish{\text{finish}}}\}

In the ends-in-101101 NFA below, the token looping on AA acts as a permanent safety net that tests every 11 as a possible start of the final 101101, while failed attempts disappear on their own without backward backup arrows.

The token looping on A sends out a fresh clone on every 1 while failed clones vanish, catching a final 101 without any backward arrows.
2

Subset Construction: Converting an NFA to a DFA

Even with parallel clones and free ε\varepsilon-arrows, an NFA can only hold tokens on a subset of its states at any moment. Subset Construction converts an NFA into an equivalent DFA by making each state in the DFA represent the exact subset of NFA states currently holding tokens.

Subset Construction: Converting an NFA to a DFA
NFA\htmlClass{lc-mute}{\text{NFA}}
11
22
33
bb
ε\varepsilon
aa
a, ba,\,b
aa
DFA\htmlClass{lc-mute}{\text{DFA}}
??
NFA\htmlClass{lc-mute}{\text{NFA}}
11
22
33
bb
ε\varepsilon
aa
a, ba,\,b
aa
DFA\htmlClass{lc-mute}{\text{DFA}}
{1,3}\{1,\htmlClass{lc-green}{3}\}
{2}\{2\}
{3}\{\htmlClass{lc-green}{3}\}
{2,3}\{2,\htmlClass{lc-green}{3}\}
Empty\text{Empty}
{1,2,3}\{1,2,\htmlClass{lc-green}{3}\}
aa
bb
aa
bb
aa
bb
aa
bb
bb
aa
a, ba,\,b
Text solution
Follow ε\varepsilon-arrows for the starting subsetPlacing a token on state 11 immediately spawns a clone across 1→ε31 \walk{\xrightarrow{\varepsilon}} 3 before any character is read, forming the DFA's start state.
Start\displaystyle \text{Start} ={1,3}\displaystyle = \{1, \finish{3}\}
Pool the surviving tokens on aa and bbFrom each subset, combine the destinations of all its tokens on aa and on bb (along with any ε\varepsilon-arrows they trigger), drawing a new DFA state whenever a new subset appears.
{1,3}→a{1,3},{1,3}→b{2}{2}→a{2,3},{2}→b{3}{2,3}→a{1,2,3},{2,3}→b{3}{1,2,3}→a{1,2,3},{1,2,3}→b{2,3}\displaystyle \begin{aligned} \{1, \finish{3}\} &\xrightarrow{a} \{1, \finish{3}\}, \\ \{1, \finish{3}\} &\xrightarrow{b} \{2\} \\[6pt] \{2\} &\xrightarrow{a} \{2, \finish{3}\}, \\ \{2\} &\xrightarrow{b} \{\finish{3}\} \\[6pt] \{2, \finish{3}\} &\xrightarrow{a} \{1, 2, \finish{3}\}, \\ \{2, \finish{3}\} &\xrightarrow{b} \{\finish{3}\} \\[6pt] \{1, 2, \finish{3}\} &\xrightarrow{a} \{1, 2, \finish{3}\}, \\ \{1, 2, \finish{3}\} &\xrightarrow{b} \{2, \finish{3}\} \end{aligned}
Send dead ends to Empty\text{Empty}From {3}\{\finish{3}\}, reading aa goes to 11 and crosses the ε\varepsilon-arrow to {1,3}\{1, \finish{3}\}, whereas reading bb makes the last token vanish and goes to Empty\text{Empty}, which loops on a,ba, b forever.
{3}→a{1,3},{3}→bEmpty→a,bEmpty\displaystyle \{\finish{3}\} \xrightarrow{a} \{1, \finish{3}\}, \qquad \{\finish{3}\} \xrightarrow{b} \text{Empty} \xrightarrow{a, b} \text{Empty}
Mark every subset containing 3\finish{3} as a finish stateBecause the NFA accepts whenever at least one clone stands on 3\finish{3}, every DFA state that includes 3\finish{3} becomes a double circle.
Finish states\displaystyle \text{Finish states} ={1,3}, {2,3}, {3}, {1,2,3}\displaystyle = \{1, \finish{3}\},\ \{2, \finish{3}\},\ \{\finish{3}\},\ \{1, 2, \finish{3}\}

Stepping through the 3-state NFA alongside its subset DFA shows that every group of tokens on the NFA is a single state in the DFA, landing on a double circle right when at least one NFA token sits on state 3\finish{3}.

At every step, one pointer on the DFA tracks the whole group of tokens on the NFA, and both machines accept at the same time.
3

Power-Set Blowup and the Complement Trap

Because an nn-state NFA has 2n\howmany{2^n} possible subsets of states, converting a small NFA into a DFA can cause an exponential blowup in the number of states. Tracking subsets of clones also shows why flipping finish states directly on an NFA fails to give the complement language.

Power-Set Blowup and the Complement Trap
{1,3}\{1,\htmlClass{lc-green}{3}\}
{2}\{2\}
{2,3}\{2,\htmlClass{lc-green}{3}\}
Empty\text{Empty}
{3}\{\htmlClass{lc-green}{3}\}
{1,2,3}\{1,2,\htmlClass{lc-green}{3}\}
Empty=∅\text{Empty} = \emptyset

For the language of binary strings whose kk-th character from the end is 11, an NFA only needs a safety-net start state plus a kk-state chain, while a DFA never knows when the string will end and must remember all 2k\howmany{2^k} possible kk-bit endings:

NFA: k+1 states⟶Smallest DFA: 2k states\displaystyle \begin{aligned} & \text{NFA: } && \howmany{k + 1} \text{ states} \\ \convert{\longrightarrow} \quad & \text{Smallest DFA: } && \howmany{2^k} \text{ states} \end{aligned}

When you want the complement of an NFA's language (accepting every string the NFA rejects, and rejecting every string it accepts), swapping single and double circles directly on the NFA can fail, because a surviving clone on a state the swap turned into a finish state, like the safety-net clone on AA, still triggers acceptance. You must convert the NFA to a DFA first so that each state represents the entire group of clones at once:

NFA→Subset ConstructionDFA→swap single anddouble circlesComplement DFA\displaystyle \begin{aligned} \text{NFA} &\convert{\xrightarrow{\text{Subset Construction}}} \text{DFA} \\ &\convert{\xrightarrow{\begin{gathered}\scriptstyle\text{swap single and} \\ \scriptstyle\text{double circles}\end{gathered}}} \text{Complement DFA} \end{aligned}
4

Kleene's Theorem and Regular Expressions to NFAs

Kleene's Theorem states that DFAs, NFAs, and Regular Expressions all recognize the exact same class of languages: every regular expression can be wired into a machine, and every machine can be turned into a regular expression.

Kleene's Theorem and Regular Expressions to NFAs
NFA↔DFA\text{NFA} \leftrightarrow \text{DFA}
Regex\text{Regex}
Choice\text{Choice}
0+10 + 1
Followed by\text{Followed by}
101101
Star\text{Star}
(0+1)∗(0 + 1)^*
Followed byAB\text{Followed by}\quad \htmlClass{lc-blue}{A}\htmlClass{lc-violet}{B}
A\htmlClass{lc-blue}{A}
B\htmlClass{lc-violet}{B}
ε\varepsilon
ChoiceA+B\text{Choice}\quad \htmlClass{lc-blue}{A} + \htmlClass{lc-violet}{B}
A\htmlClass{lc-blue}{A}
B\htmlClass{lc-violet}{B}
ε\varepsilon
ε\varepsilon
ε\varepsilon
ε\varepsilon
StarA∗\text{Star}\quad \htmlClass{lc-blue}{A}^*
A\htmlClass{lc-blue}{A}
ε\varepsilon
ε\varepsilon
ε\varepsilon
ε\varepsilon

Using one-entrance, one-exit boxes connected by ε\varepsilon-arrows, we can assemble an NFA for (ab+a)∗(ab + a)^* directly from its pieces.

Text solution
Chain aa followed by bbBuild 2-state boxes for aa and bb, and connect the exit of aa to the entrance of bb with an ε\varepsilon-arrow.
[ ◯→a◯ ]→ε[ ◯→b◯ ]\displaystyle [\,\bigcirc \xrightarrow{a} \bigcirc\,] \xrightarrow{\varepsilon} [\,\bigcirc \xrightarrow{b} \bigcirc\,]
Split and merge for the choice ab+aab + aAdd a new start state with ε\varepsilon-arrows into both the abab box and a separate aa box, and run ε\varepsilon-arrows from their exits into one new finish state.
◯→ε[ ab ]→ε→ε[  a  ]→ε◯\displaystyle \bigcirc \begin{array}{c} \xrightarrow{\varepsilon} [\,ab\,] \xrightarrow{\varepsilon} \\ \xrightarrow{\varepsilon} [\;a\;] \xrightarrow{\varepsilon} \end{array} \bigcirc
Wrap with a backward loop and bypass for (ab+a)∗(ab + a)^*Add an outer start and finish state connected by ε\varepsilon-arrows, a backward ε\varepsilon-arrow from the inner exit to the inner entrance to repeat the pattern, and a bypass ε\varepsilon-arrow from outer start to outer finish for zero repetitions.
◯→ε[ ab+a ]⏟←repeatε→ε⊚(plus outer start→bypassεouter finish)\displaystyle \begin{gathered} \bigcirc \xrightarrow{\varepsilon} \underbrace{[\,ab + a\,]}_{\xleftarrow[\text{repeat}]{\varepsilon}} \xrightarrow{\varepsilon} \circledcirc \\ (\text{plus outer start} \\ \xrightarrow[\text{bypass}]{\varepsilon} \text{outer finish}) \end{gathered}

Because every box has one entrance and one exit wired solely by free ε\varepsilon-arrows, the three box patterns below assemble complex regular expressions out of smaller machines without changing any arrows inside the boxes.

Each regular expression operation connects smaller machines from the outside with epsilon-arrows, without changing a single state or arrow inside the boxes.
5

State Elimination: Machines to Regular Expressions

To turn a finite automaton back into a regular expression, State Elimination removes states one by one, replacing every incoming-loop-outgoing path through the removed state with a single regular-expression arrow.

State Elimination: Machines to Regular Expressions
In\text{In}
a\htmlClass{lc-blue}{a}
Middle\text{Middle}
c\htmlClass{lc-violet}{c}
b\htmlClass{lc-pink}{b}
Out\text{Out}

Whenever removing a state Middle\text{Middle} (with self-loop c\looppart{c}) replaces the path In→aMiddle→bOut\text{In} \xrightarrow{\inpart{a}} \text{Middle} \xrightarrow{\outpart{b}} \text{Out} alongside an existing direct arrow In→dOut\text{In} \xrightarrow{d} \text{Out}, the two parallel routes merge with a ++ sign:

In→d+ac∗bOut\displaystyle \text{In} \xrightarrow{d + \inpart{a}\looppart{c^*}\outpart{b}} \text{Out}

We can apply this rule to reduce a 2-state machine, where start state 11 has loop aa and arrow 1→b21 \xrightarrow{b} 2, and finish state 22 has loop bb and arrow 2→a12 \xrightarrow{a} 1, into a single regular expression.

Text solution
Add isolated start and finish states SS and FFBecause state 11 has an incoming arrow and state 22 has outgoing arrows, connect a new start S→ε1S \xrightarrow{\varepsilon} 1 and a new finish 2→εF2 \xrightarrow{\varepsilon} F.
S→ε1,2→εF\displaystyle S \xrightarrow{\varepsilon} 1, \qquad 2 \xrightarrow{\varepsilon} F
Eliminate state 11 and record the round trip from 22State 11 is entered from SS on ε\inpart{\varepsilon} and from 22 on a\inpart{a}, loops with a∗\looppart{a^*}, and leaves to 22 on b\outpart{b}, producing a forward arrow from SS to 22 and a round-trip loop aa∗b\inpart{a}\looppart{a^*}\outpart{b} on 22 that merges with 22's existing bb loop.
S→a∗b2,loop on 2: b+aa∗b\displaystyle S \xrightarrow{\looppart{a^*}\outpart{b}} 2, \qquad \text{loop on } 2:\ b + \inpart{a}\looppart{a^*}\outpart{b}
Eliminate state 22 to connect SS directly to FFChaining the incoming arrow a∗b\inpart{a^*b}, the merged self-loop (b+aa∗b)∗\looppart{(b + aa^*b)^*}, and the outgoing ε\outpart{\varepsilon}-arrow leaves a single regular expression from SS to FF.
S→a∗b(b+aa∗b)∗F\displaystyle S \xrightarrow{\inpart{a^*b}\looppart{(b + aa^*b)^*}} F

As you remove each state between SS and FF below, every path through it becomes a direct regular-expression arrow, including round trips that leave a neighbor and come right back as a new loop.

Removing a state turns every path through it, including round trips back to a neighbor, into a direct regular-expression arrow until only one arrow from start to finish remains.

Key concepts

DFAs, NFAs, and Regular Expressions all define the exact same class of languages, and you can move between them depending on what a problem asks for:

Tracing or converting an NFA to a DFA (Subset Construction)

Track the subset of states holding tokens at the same time. Whenever a token starts on or moves to a state with an ε\varepsilon-arrow like 1→ε31 \xrightarrow{\varepsilon} 3, include state 33 in that subset immediately. If all tokens vanish on an input, send that transition to an Empty\text{Empty} state that loops on every letter, and mark any subset containing an old finish state as a finish state.

Finding the complement of a machine

If the machine is already a DFA, simply swap single and double circles; do not run Subset Construction on a machine that is already deterministic. If the machine is an NFA (such as AA looping on 0,10, 1 with A→1BA \xrightarrow{1} B), never flip its states directly; convert the NFA to a DFA first, and then swap single and double circles.

Regular Expression to NFA (ε\varepsilon-box wiring)

Build 2-state boxes for single letters and wire them with ε\varepsilon-arrows: chain A→εB\boxA{A} \xrightarrow{\varepsilon} \boxB{B} for concatenation AB\boxA{A}\boxB{B}, split and merge with four ε\varepsilon-arrows for choice A+B\boxA{A} + \boxB{B}, and use four ε\varepsilon-arrows (entry, exit, backward repeat, and outer bypass) for A∗\boxA{A}^*.

Machine to Regular Expression (State Elimination)

First add S→εstartS \xrightarrow{\varepsilon} \text{start} and finish→εF\text{finish} \xrightarrow{\varepsilon} F so no arrows enter SS or leave FF. When erasing a state with loop c\looppart{c}, replace every pair of incoming arrow a\inpart{a} and outgoing arrow b\outpart{b} (including round trips from a neighbor back to itself) with ac∗b\inpart{a}\looppart{c^*}\outpart{b}, and merge parallel arrows between the same two states using d+ac∗bd + \inpart{a}\looppart{c^*}\outpart{b}.

6

Practice

1

Consider the NFA with states {1,2,3}\{1, 2, 3\}, start state 11, finish state 33, and transitions 1→b21 \xrightarrow{b} 2, 1→ε31 \xrightarrow{\varepsilon} 3, 2→a22 \xrightarrow{a} 2, 2→a,b32 \xrightarrow{a,b} 3, and 3→a13 \xrightarrow{a} 1. Trace the set of states holding tokens before any input is read and after each character of the string babababa. Does the NFA accept babababa?

Before reading the first bb, check whether the starting token on 11 can cross any arrow for free.

Start (before reading any input)A token starts on 11 and immediately spawns a clone across 1→ε31 \walk{\xrightarrow{\varepsilon}} 3, giving {1,3}\{1, \finish{3}\}. (Watch out: forgetting the initial ε\varepsilon-arrow starts the trace at {1}\wrong{\{1\}}, and forgetting it again on the final step leaves {1}\wrong{\{1\}} instead of {1,3}\{1, \finish{3}\}, which falsely rejects the string.)
After each character of babababa
{1,3}→b{2}→a{2,3}→b{3}→a{1,3}\displaystyle \begin{aligned} \{1, \finish{3}\} &\walk{\xrightarrow{b}} \{2\} \walk{\xrightarrow{a}} \{2, \finish{3}\} \\ &\walk{\xrightarrow{b}} \{\finish{3}\} \walk{\xrightarrow{a}} \{1, \finish{3}\} \end{aligned}
DecisionBecause the final subset {1,3}\{1, \finish{3}\} contains the finish state 3\finish{3}, the NFA accepts babababa.
2

An NFA over {0,1}\{0, 1\} has states {A,B,C}\{A, B, C\}, start state AA, finish state CC, and transitions A→0AA \xrightarrow{0} A, A→0,1BA \xrightarrow{0, 1} B, B→1CB \xrightarrow{1} C, and no outgoing arrows from CC. Convert this NFA into a DFA using Subset Construction: give the start state, the transitions on 00 and 11 for every reachable subset state, the finish states, and list which subsets of {A,B,C}\{A, B, C\} are unreachable.

Start from {A}\{A\} and pool where the tokens go on 00 and on 11; what DFA state do you draw when every token in a subset vanishes?

Start state{A}\{A\}.
Transitions for the 6\howmany{6} reachable states
{A}→0{A,B},{A}→1{B}{A,B}→0{A,B},{A,B}→1{B,C}{B}→0Empty,{B}→1{C}{B,C}→0Empty,{B,C}→1{C}{C}→0Empty,{C}→1EmptyEmpty→0Empty,Empty→1Empty\displaystyle \begin{aligned} \{A\} &\xrightarrow{0} \{A, B\}, \\ \{A\} &\xrightarrow{1} \{B\} \\[6pt] \{A, B\} &\xrightarrow{0} \{A, B\}, \\ \{A, B\} &\xrightarrow{1} \{B, \finish{C}\} \\[6pt] \{B\} &\xrightarrow{0} \text{Empty}, \\ \{B\} &\xrightarrow{1} \{\finish{C}\} \\[6pt] \{B, \finish{C}\} &\xrightarrow{0} \text{Empty}, \\ \{B, \finish{C}\} &\xrightarrow{1} \{\finish{C}\} \\[6pt] \{\finish{C}\} &\xrightarrow{0} \text{Empty}, \\ \{\finish{C}\} &\xrightarrow{1} \text{Empty} \\[6pt] \text{Empty} &\xrightarrow{0} \text{Empty}, \\ \text{Empty} &\xrightarrow{1} \text{Empty} \end{aligned}
(Watch out: if you drop dead-end transitions instead of sending {B}\{B\}, {B,C}\{B, \finish{C}\}, and {C}\{\finish{C}\} on 00 to Empty\text{Empty}, the resulting machine is missing arrows and is not a valid DFA.)
Finish states{B,C}\{B, \finish{C}\} and {C}\{\finish{C}\} (every reachable subset containing CC; do not mark only {C}\{\finish{C}\} and forget {B,C}\{B, \finish{C}\}).
Unreachable subsetsOut of the 23=82^3 = 8 subsets, the 2\unreached{2} unreachable subsets are {A,C}\unreached{\{A, C\}} and {A,B,C}\unreached{\{A, B, C\}} (being in AA after a step requires the last bit read to be 00, whereas being in CC requires the last bit read to be 11).
3

Consider the language of all binary strings over {0,1}\{0, 1\} whose 4th character from the end is 11. Describe how to construct an NFA for this language, give its number of states, and find how many states the smallest DFA for this language requires.

Once a clone leaves the start state on a 11, how many more characters must it step through to verify that this 11 was the 4th character from the end?

NFA constructionBuild a start state AA that loops on 0,10, 1 and has a 11-arrow to the first state of a 4-state chain, where each of the 3 steps along the chain moves forward on 0,10, 1 and the 4th state in the chain is the sole finish state (with no outgoing arrows).
Number of NFA states5\howmany{5} states (11 start state plus the 44 states in the chain). (Watch out: counting only the 44 states in the chain and forgetting the initial safety-net state AA gives the wrong answer 4\wrong{4}.)
Smallest DFA state countBecause a DFA must remember the exact last 44 bits at every step, the smallest DFA requires 24=162^4 = \howmany{16} states (not 25=322^5 = \wrong{32}, which comes from plugging in the NFA's 5\howmany{5} states instead of the 44 remembered bits).
4

Consider the 2-state NFA over {0,1}\{0, 1\} for strings ending in 11: start state AA has a loop on 0,10, 1 and a 11-arrow to finish state BB, and BB has no outgoing arrows. (a) If you swap the finish and non-finish states directly on this NFA (making AA the finish state and BB non-finish), what happens on the input string 11? (b) Construct a valid DFA for the complement language (strings that do not end in 11).

In part (a), track all clones produced when reading 11 from AA, not just the one that moves to BB.

(a)On input 11, the token on AA splits onto both AA and BB, ending on {A,B}\{A, B\}. Because a surviving clone sits on the new finish state AA, the flipped NFA accepts 11 even though the original NFA also accepts 11 (in fact, because a clone stays on AA forever, the flipped NFA accepts every binary string). (Watch out: looking only at the clone that reaches BB leads to the wrong conclusion that the flipped NFA rejects 11.)
(b)Convert the NFA to a DFA first, which gives two states: start state {A}\{A\} (where 0→{A}0 \to \{A\} and 1→{A,B}1 \to \{A, \finish{B}\}) and finish state {A,B}\{A, \finish{B}\} (where 0→{A}0 \to \{A\} and 1→{A,B}1 \to \{A, \finish{B}\}). Swapping finish and non-finish states on this DFA makes {A}\{A\} the sole finish state and {A,B}\{A, \turnedoff{B}\} non-finish.
5

Using the entrance-and-exit box method with ε\varepsilon-arrows, describe how to build an NFA for the regular expression a(a+b)∗a(a + b)^*. How many ε\varepsilon-arrows does this construction use, and what does each one do?

Count the ε\varepsilon-arrows inside the choice box a+ba + b, then the star wrapper around (a+b)∗(a + b)^*, and finally the link from the leading aa.

Box construction and ε\varepsilon-arrow breakdownBuild three basic 2-state boxes (one for the leading aa, and one each for the inner aa and bb):
Choice a+ba + b (44 ε\varepsilon-arrows)Add a choice-start state with 22 ε\varepsilon-arrows splitting into the inner aa and bb boxes, and 22 ε\varepsilon-arrows merging their exits into a choice-finish state.
Star (a+b)∗(a + b)^* (44 ε\varepsilon-arrows)Add a star-start state with 11 ε\varepsilon-arrow into the choice-start, 11 ε\varepsilon-arrow from the choice-finish into a star-finish state, 11 backward ε\varepsilon-arrow from the choice-finish to the choice-start for repetition, and 11 bypass ε\varepsilon-arrow from the star-start to the star-finish for zero repetitions. (Watch out: leaving out the bypass ε\varepsilon-arrow gives 8\wrong{8} instead of 9\howmany{9} and forces at least one repetition of a+ba + b.)
Concatenation a(a+b)∗a(a + b)^* (11 ε\varepsilon-arrow)Run 11 ε\varepsilon-arrow from the exit of the leading aa box into the star-start state.
Total9\howmany{9} ε\varepsilon-arrows.
6

Convert the following 3-state machine into a regular expression using State Elimination: state 11 is the start state with loop 1→a11 \xrightarrow{a} 1, arrow 1→b21 \xrightarrow{b} 2, and arrow 1→c31 \xrightarrow{c} 3; state 22 has loop 2→b22 \xrightarrow{b} 2 and arrow 2→a32 \xrightarrow{a} 3; state 33 is the sole finish state with arrow 3→a13 \xrightarrow{a} 1. Eliminate the states in the order 22, then 11, then 33.

When you eliminate state 11, check both states that have arrows entering 11: SS and 33.

Add SS and FFAdd new start state SS with S→ε1S \xrightarrow{\varepsilon} 1 and new finish state FF with 3→εF3 \xrightarrow{\varepsilon} F.
Eliminate state 22The path 1→b21 \xrightarrow{\inpart{b}} 2 (with loop b∗\looppart{b^*}) →a3\xrightarrow{\outpart{a}} 3 becomes 1→bb∗a31 \xrightarrow{\inpart{b}\looppart{b^*}\outpart{a}} 3, which merges with 1→c31 \xrightarrow{c} 3 into:
1→c+bb∗a3\displaystyle 1 \xrightarrow{c + \inpart{b}\looppart{b^*}\outpart{a}} 3
Eliminate state 11State 11 is entered from SS on ε\inpart{\varepsilon} and from 33 on a\inpart{a}, loops with a∗\looppart{a^*}, and leaves to 33 on c+bb∗a\outpart{c + bb^*a}. This creates the forward arrow from SS to 33 and a round-trip self-loop on 33:
S→a∗(c+bb∗a)3,loop on 3: aa∗(c+bb∗a)\displaystyle \begin{gathered} S \xrightarrow{\looppart{a^*}\outpart{(c + bb^*a)}} 3, \\ \text{loop on } 3:\ \inpart{a}\looppart{a^*}\outpart{(c + bb^*a)} \end{gathered}
(Watch out: forgetting the round-trip path 3→a1→c+bb∗a33 \xrightarrow{\inpart{a}} 1 \xrightarrow{\outpart{c + bb^*a}} 3 drops the self-loop on 33 and produces the wrong answer a∗(c+bb∗a)\wrong{a^*(c + bb^*a)}.)
Eliminate state 33Connecting SS through 33's loop into FF gives the final regular expression:
a∗(c+bb∗a)(aa∗(c+bb∗a))∗\displaystyle \inpart{a^*(c + bb^*a)}\looppart{(aa^*(c + bb^*a))^*}