90 likes | 252 Views
Finite Automaton: Example 1. 0 0 1 0 1 1. accepted. Finite Automaton: Example 2. 0 0 1 0 1 0. not accepted. Reducing REs to NFAs. ab. a. b. b. ε. ✓. NFA for (ab|ba)*. ( ab|ba )*. ✓. a. b. b. a. a( ab|ba )*. b( ab|ba )*. NFA for (ab|aba)*. ( ab|aba )*. ✓. a. a. b.
E N D
Finite Automaton: Example 1 0 0 1 0 1 1 accepted CMSC 330 - Spring 2011
Finite Automaton: Example 2 0 0 1 0 1 0 not accepted CMSC 330 - Spring 2011
Reducing REs to NFAs ab a b b ε ✓ CMSC 330 - Spring 2011
NFA for (ab|ba)* (ab|ba)* ✓ a b b a a(ab|ba)* b(ab|ba)* CMSC 330 - Spring 2011
NFA for (ab|aba)* (ab|aba)* ✓ a a b ba(ab|aba)* b(ab|aba)* a b a(ab|aba)* CMSC 330 - Spring 2011
NFA DFA Example 1 • r0 = {S1} • R = {r0} = { {S1} } • r R = {S1} • move({S1}, a} = {S2,S3} • R = R ∪ {{S2,S3}} = { {S1}, {S2,S3} } • = ∪ {<{S1}, a, {S2,S3}>} • move({S1},b} = Ø • R = R ∪ {Ø} = { Ø, {S1}, {S2,S3} } • = ∪ {<{S1}, b, Ø>} NFA a b S1 S2 S3 a DFA a {S1} {S2,S3} b ∅ CMSC 330 - Spring 2011
NFA DFA Example 1 (cont.) • R = { {S1}, {S2,S3}, Ø } • r R = {S2,S3} • move({S2,S3},a} = Ø • move({S2,S3},b} = {S3} • R = R ∪ {{S3} = { {S1}, {S2,S3} }, Ø, {S3} } • = ∪ {<{S2,S3},a, Ø >, <{S2,S3}, b, {S3}>} NFA a b S1 S2 S3 a DFA a b {S1} {S3} {S2,S3} b a ∅ CMSC 330 - Spring 2011
NFA DFA Example 1 (cont.) • R = { {S1}, {S2,S3}, Ø, {S3} } • r R = Ø • move(Ø,a} = Ø • move(Ø,b} = Ø • R = { {S1}, {S2,S3} }, Ø, {S3} } • = ∪ {<Ø,a,Ø>, <Ø,b, Ø>} NFA a b S1 S2 S3 a DFA a b {S1} {S3} {S2,S3} b a ∅ a b CMSC 330 - Spring 2011
NFA DFA Example 1 (cont.) • R = { {S1}, {S2,S3}, Ø, {S3} } • r R = {S3} • move({S3},a} = Ø • move({S3},b} = Ø • R = { {S1}, {S2,S3} }, Ø, {S3} } • = ∪ {<{S3},a, Ø >, <{S3}, b, Ø>} • Fd = {{S2,S3}, {S3}} • Since S3 Fn • Done! NFA a b S1 S2 S3 a DFA a b {S1} {S3} {S2,S3} b a a,b ∅ a b CMSC 330 - Spring 2011