23
Converting an NFA into an FSA Proving LNFA is a subset of LFSA.

Converting an NFA into an FSA Proving LNFA is a subset of LFSA

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Converting an NFA into an FSA

Proving LNFA is a subset of LFSA.

Page 2: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Purpose

• This presentation presents an example execution of the algorithm which takes as input an NFA (without -transitions) and produces as output an equivalent FSA

• Algorithm Specification

– Input: NFA M1 (without -transitions)

– Output: FSA M2 such that L(M2) = L(M1)

Page 3: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Input NFA M1

a

b

a,b

b b

a a

1

2

3

4

5

6

Page 4: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Initialization

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1}

Initial State of FSA M2: {1}

Page 5: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Expand State {1}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}

Page 6: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Add States {2} and {3}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2}{3}

Page 7: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Expand State {2}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3}

Page 8: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Add State {}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3}{}

Page 9: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Expand State {3}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{}

Page 10: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Add States {3,4} and {3,5}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{}

{3,4}{3,5}

Page 11: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Expand State {}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4}{3,5}

Page 12: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

No New States Added

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4}{3,5}

Page 13: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Expand State {3,4}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4} {3,4,6} {3,5}{3,5}

Page 14: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Add State {3,4,6}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4} {3,4,6} {3,5}{3,5}

{3,4,6}

Page 15: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Expand State {3,5}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4} {3,4,6} {3,5}{3,5} {3,4} {3,5,6}

{3,4,6}

Page 16: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Add State {3,5,6}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4} {3,4,6} {3,5}{3,5} {3,4} {3,5,6}

{3,4,6}{3,5,6}

Page 17: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Expand State {3,4,6}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4} {3,4,6} {3,5}{3,5} {3,4} {3,5,6}

{3,4,6} {3,4,6} {3,5}{3,5,6}

Page 18: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

No New States Added

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4} {3,4,6} {3,5}{3,5} {3,4} {3,5,6}

{3,4,6} {3,4,6} {3,5}{3,5,6}

Page 19: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Expand State {3,5,6}

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4} {3,4,6} {3,5}{3,5} {3,4} {3,5,6}

{3,4,6} {3,4,6} {3,5}{3,5,6} {3,4} {3,5,6}

Page 20: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

No New States Added

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4} {3,4,6} {3,5}{3,5} {3,4} {3,5,6}

{3,4,6} {3,4,6} {3,5}{3,5,6} {3,4} {3,5,6}

Page 21: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Identify Accepting States

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4} {3,4,6} {3,5}{3,5} {3,4} {3,5,6}

{3,4,6} {3,4,6} {3,5}{3,5,6} {3,4} {3,5,6}

Accepting states of FSA M2: {3,4,6} and {3,5,6}

Page 22: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Transition Diagram

a

b

a,b

b b

a a

1

2

3

4

5

6

a b{1} {2} {3}{2} {} {}{3} {3,4} {3,5}{} {} {}

{3,4} {3,4,6} {3,5}{3,5} {3,4} {3,5,6}

{3,4,6} {3,4,6} {3,5}{3,5,6} {3,4} {3,5,6}

Accepting states of FSA M2: {3,4,6} and {3,5,6}

{1} {2} {}

{3}

{3,4}

{3,4,6} {3,5,6}

{3,5}

a

b

a,b

a

a

a

a

ab

b

b

b

b

a,b

FSA M2

Page 23: Converting an NFA into an FSA Proving LNFA is a subset of LFSA

Summary

a

b

a,b

b b

a a

1

2

3

4

5

6

{1} {2} {}

{3}

{3,4}

{3,4,6} {3,5,6}

{3,5}

a

b

a,b

a

a

a

a

ab

b

b

b

b

a,b

Original NFA M1 Equivalent FSA M2