7. In general, how do we convert a regular expression to an NFA?
Regular expressions
A regular expression over Σ is an expression formed by the following
rules
• The symbols ∅ and ε are regular expressions
• Every symbol in Σ is a regular expression
• If Σ = {0,1}, then 0 and 1 are both regular expressions
• If R asd S are regular expressions, so are R + S, RS and R∗
6/23
11. Simplify the NFA
First we simplify the NFA so that
• It has exactly one accepting state
• No arrows come into the start state
• No arrows go out of the accepting state
q5
10/23
q3
q1
q4
12. q3
ε
q0
ε
q1 q5
ε
q4
Simplify the NFA
First we simplify the NFA so that
• It has exactly one accepting state
• No arrows come into the start state
• No arrows go out of the accepting state
11/23
14. Simplify the NFA
0 1
• It has exactly one accepting state ✓
• No arrows come into the start state ✓
• No arrows go out of the accepting state ✓
13/23
q0
ε q1
1
0
q2
ε q3
15. Generalized NFAs
A generalized NFA is an NFA whose transitions are labeled by regular
expressions, like
0∗1
01
14/23
q0
ε + 10∗
q1
0∗11 q2
18. State elimination: general method
To eliminate state q, for every pair of states (u, v) such that u → q → v
Replace
R4
by
Remember to do this even when u = v
17/23
u
R1
R2
q
R3
v
u
R1R∗
2R3 + R4
q v
24. Check your answer!
0 1
All strings ending in 1
(0 + 1)∗1
0∗1(00∗1 + 1)∗ Always ends in 1
Does every string ending in 1
= 0∗1(0∗1)∗
have this form?
Yes
23/23
q1
1
0
q2