finite automaton: example 1

9
CMSC 330 - Spring 2011 1 Finite Automaton: Example 1 0 0 1 0 1 1 accepted

Upload: dea

Post on 07-Jan-2016

53 views

Category:

Documents


0 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Finite Automaton: Example 1

CMSC 330 - Spring 2011 1

Finite Automaton: Example 1

0 0 1 0 1 1accepted

Page 2: Finite Automaton: Example 1

CMSC 330 - Spring 2011 2

Finite Automaton: Example 2

0 0 1 0 1 0not accepted

Page 3: Finite Automaton: Example 1

Reducing REs to NFAs

CMSC 330 - Spring 2011 3

ab

b

ε

a

b

Page 4: Finite Automaton: Example 1

NFA for (ab|ba)*

CMSC 330 - Spring 2011 4

(ab|ba)*

b(ab|ba)* a(ab|ba)*

a b

b a

Page 5: Finite Automaton: Example 1

NFA for (ab|aba)*

CMSC 330 - Spring 2011 5

(ab|aba)*

b(ab|aba)* ba(ab|aba)*

a a

b

a

a(ab|aba)*

b

Page 6: Finite Automaton: Example 1

6

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, Ø>}

bS1 S2 S3

a

a

a{S2,S3}{S1}

NFA

DFA

b

Page 7: Finite Automaton: Example 1

7

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}>}

bS1 S2 S3

a

a

a b{S3}{S1}

NFA

DFA

b{S2,S3}

a

Page 8: Finite Automaton: Example 1

8

NFA DFA Example 1 (cont.)

• R = { {S1}, {S2,S3}, Ø, {S3} }

• r R = Ø

• move(Ø,a} = Ø

• move(Ø,b} = Ø R = { {S1}, {S2,S3} }, Ø, {S3} } = ∪ {< Ø,a,Ø >, <Ø,b, Ø>}

bS1 S2 S3

a

a

a b{S1}

NFA

DFA

b{S2,S3}

a

a b

{S3}

Page 9: Finite Automaton: Example 1

9

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!

bS1 S2 S3

a

a

NFA

DFA

a b{S1}

b{S2,S3}

a

a b

{S3}

a,b