{S1} NFA DFA ∅ b

Finite Automaton: Example 1
001011
accepted
CMSC 330 - Spring 2011
1
Finite Automaton: Example 2
001010
not accepted
CMSC 330 - Spring 2011
2
Reducing REs to NFAs
ab
a
b
b
ε
CMSC 330 - Spring 2011
✓
3
NFA for (ab|ba)*
(ab|ba)*✓
a
b
b
b(ab|ba)*
CMSC 330 - Spring 2011
a
a(ab|ba)*
4
NFA for (ab|aba)*
(ab|aba)*
✓
a
a
b
ba(ab|aba)*
b(ab|aba)*
a
b
a(ab|aba)*
CMSC 330 - Spring 2011
5
NFA  DFA Example 1
•
•
•
•
r0 = {S1}
R = {r0} = { {S1} }
r  R = {S1}
move({S1}, a} = {S2,S3}



a
R = R ∪ {Ø}
= { Ø, {S1}, {S2,S3} }
 =  ∪ {<{S1}, b, Ø>}
b
S1
S2
{S1}
S3
a
R = R ∪ {{S2,S3}} = { {S1}, {S2,S3} }
 =  ∪ {<{S1}, a, {S2,S3}>}
• move({S1},b} = Ø

NFA
DFA
a
{S2,S3}
b
∅
6
NFA  DFA Example 1 (cont.)
•
•
•
•
R = { {S1}, {S2,S3}, Ø }
r  R = {S2,S3}
move({S2,S3},a} = Ø
move({S2,S3},b} = {S3}


NFA
a
b
S1
S2
R = R ∪ {{S3} = { {S1}, {S2,S3} }, Ø, {S3} }
 =  ∪ {<{S2,S3},a, Ø >, <{S2,S3}, b, {S3}>} DFA
{S1}
S3
a
a
b
{S2,S3}
b
{S3}
a
∅
7
NFA  DFA Example 1 (cont.)
•
•
•
•
R = { {S1}, {S2,S3}, Ø, {S3} }
rR=Ø
move(Ø,a} = Ø
move(Ø,b} = Ø


NFA
a
b
S1
S2
S3
a
R = { {S1}, {S2,S3} }, Ø, {S3} }
 =  ∪ {< Ø,a,Ø >, <Ø,b, Ø>}
DFA
{S1}
a
b
b
a
{S3}
{S2,S3}
a
∅
b
8
NFA  DFA Example 1 (cont.)
•
•
•
•
R = { {S1}, {S2,S3}, Ø, {S3} }
r  R = {S3}
move({S3},a} = Ø
move({S3},b} = Ø


a
Since S3  Fn
b
S1
S2
S3
a
R = { {S1}, {S2,S3} }, Ø, {S3} }
 =  ∪ {<{S3},a, Ø >, <{S3}, b, Ø>}
• Fd = {{S2,S3}, {S3}}

NFA
DFA
{S1}
a
b
{S2,S3}
b
• Done!
a
a
∅
{S3}
a,b
b
9