Conversion of an NFA to a DFA using Subset Construction Algorithm

24
Conversion of an NFA to a DFA using Subset Construction Algorithm

description

Conversion of an NFA to a DFA using Subset Construction Algorithm. Algorithm of Subset construction`. Operations on NFA States. Example:. By using subset construction algorithm convert the following NFA N for ( alb ) * abb to DFA. Example: To apply subset construction . - PowerPoint PPT Presentation

Transcript of Conversion of an NFA to a DFA using Subset Construction Algorithm

Page 1: Conversion of an NFA to a  DFA using Subset Construction Algorithm

Conversion of an NFA to a DFAusing

Subset Construction Algorithm

Page 2: Conversion of an NFA to a  DFA using Subset Construction Algorithm

Algorithm of Subset construction`

Page 3: Conversion of an NFA to a  DFA using Subset Construction Algorithm

Operations on NFA States

Page 4: Conversion of an NFA to a  DFA using Subset Construction Algorithm

By using subset construction algorithm convert the following NFA N for (alb) * abb to DFA

Example:

Page 5: Conversion of an NFA to a  DFA using Subset Construction Algorithm

we need to remove :1. ε – transition• That require to construct ε – closure (s)

2. A multiple transition on input symbol from some state s in T:Mov(T,a)

Example: To apply subset construction

Page 6: Conversion of an NFA to a  DFA using Subset Construction Algorithm

{0 , 1, 2, 4, 7} {0= }{1, 2, 4} {1= }{2} {2= }{1, 2, 3, 4, 6, 7} {3= }{4} {4= }{1, 2, 4, 5, 6, 7} {5= }{1, 2, 4, 6, 7} {6= }{7} {7= }{8} {8= }{9} {9= }{10} {10= }

Example: First step: construct ε – closure (s)

Page 7: Conversion of an NFA to a  DFA using Subset Construction Algorithm

The start state A of the equivalent DFA is ε – closure (0)

The ε – closure (0) = {0, 1, 2, 4, 7}

Then the starting state A = {0, 1, 2, 4, 7}

Example: Second step: Looking for the start state for the DFA

{0, 1, 2, 4, 7}A

a

b

Page 8: Conversion of an NFA to a  DFA using Subset Construction Algorithm

• First determine the input alphabet

here input alphapet = {a,b}• Second compute:

1. Dtran[A,a] = ε -closure(move(A,a))2. Dtran[A,b] = ε -closure(move(A,b))

Example: Third step: Compute U = ε -closure(move(T,a)

Remember:

A = {0, 1, 2, 4, 7}

Page 9: Conversion of an NFA to a  DFA using Subset Construction Algorithm

1. Dtran[A,a] = ε -closure(move(A,a))• Among the state 0, 1, 2, 4, 7, only 2 and 7 have transitions on a to 3 and 8,

respectively.

Thus move(A,a) = {3, 8}Also, ε- closure ({3,8} = {1, 2, 3, 4, 6, 7, 8}

So we conclude:Dtran[A,a] = ε -closure(move(A,a)) = ε- closure ({3,8} = {1, 2, 3, 4, 6, 7, 8}

Let us call this set B so:Dtran[A,a] = B

{1 ,2 ,3 ,4 ,6 ,7 ,8 }B

aA

Page 10: Conversion of an NFA to a  DFA using Subset Construction Algorithm

2. Dtran[A,b] = ε -closure(move(A,b))Among the states in A, only 4 has a transition on b, and it goes to 5Thus: Dtran[A,b] = ε -closure(move(A,b)) = ε- closure ({5} = {1, 2, 4, 5, 6, 7 }

Let us call this set C so:Dtran[A,b] = C

{1 ,2 ,4 ,5 ,6 ,7 } C

bA

Page 11: Conversion of an NFA to a  DFA using Subset Construction Algorithm

• Third compute:3. Dtran[B,a] = ε -closure(move(B,a))4. Dtran[B,b] = ε -closure(move(B,b))

Page 12: Conversion of an NFA to a  DFA using Subset Construction Algorithm

3. Dtran[B,a] = ε -closure(move(B,a))Among the states in B, only 2, 7 has a transition on a, and it goes to {3, 8} respectivelyThus: Dtran[B,a] = ε -closure(move(B,a)) = ε- closure ({3,8} = {1, 2, 3, 4, 6, 7, 8 }

Dtran[B,a] = B

{1 ,2 ,3 ,4 ,6 ,7 ,8 } B

aA

a

Page 13: Conversion of an NFA to a  DFA using Subset Construction Algorithm

4. Dtran[B,b] = ε -closure(move(B,b))Among the states in B, only 4, 8 has a transition on b, and it goes to {5, 9} respectivelyThus: Dtran[B,b] = ε -closure(move(B,b)) = ε- closure ({5,9} = {1, 2, 4, 5, 6, 7,9}

Dtran[B,b] = D

{1 ,2 ,4 ,5 ,6 ,7,9}B

aA

a

bBD

Page 14: Conversion of an NFA to a  DFA using Subset Construction Algorithm

• Fourth compute:5. Dtran[C,a] = ε -closure(move(C,a))6. Dtran[C,b] = ε -closure(move(C,b))

Page 15: Conversion of an NFA to a  DFA using Subset Construction Algorithm

5. Dtran[C,a] = ε -closure(move(C,a))Among the states in C, only 2, 7 has a transition on a, and it goes to {3, 8} respectivelyThus: Dtran[C,a] = ε -closure(move(C,a)) = ε- closure ({3,8} = {1, 2, 3, 4, 6, 7, 8 }

Dtran[C,a] = B

{1 ,2 ,4 ,5 ,6 ,7 } C

A Bab

Page 16: Conversion of an NFA to a  DFA using Subset Construction Algorithm

6. Dtran[C,b] = ε -closure(move(C,b))Among the states in C, only 4 has a transition on b, and it goes to {5} respectivelyThus:

Dtran[C,b] = ε -closure(move(C,b)) = ε- closure ({5} = {1, 2, 4, 5, 6, 7}

Dtran[C,b] = C

{1 ,2 ,4 ,5 ,6 ,7}bAC

b

Page 17: Conversion of an NFA to a  DFA using Subset Construction Algorithm

• Fifth compute:7. Dtran[D,a] = ε -closure(move(D,a))8. Dtran[D,b] = ε -closure(move(D,b))

Page 18: Conversion of an NFA to a  DFA using Subset Construction Algorithm

7. Dtran[D,a] = ε -closure(move(D,a))Among the states in D, only 2, 7 has a transition on a, and it goes to {3, 8} respectivelyThus: Dtran[D,a] = ε -closure(move(D,a)) = ε- closure ({3,8} = {1, 2, 3, 4, 6, 7, 8 }

Dtran[D,a] = B

{1 ,2 ,4 ,5 ,6 ,7,9}

DB b

a

Page 19: Conversion of an NFA to a  DFA using Subset Construction Algorithm

8. Dtran[D,b] = ε -closure(move(D,b))Among the states in D, only 4 and 9 has a transition on b, and it goes to {5, 10} respectivelyThus:Dtran[D,b] = ε -closure(move(D,b)) = ε- closure ({5,10} = {1,2, 4, 5, 6, 7, 10}

Dtran[D,b] = E

{1 ,2 ,4 ,5,6 ,7 ,10}

bBb

{1 ,2 ,4 ,5 ,6 ,7 ,9}Da E

Page 20: Conversion of an NFA to a  DFA using Subset Construction Algorithm

• Finally compute:9. Dtran[E,a] = ε -closure(move(E,a))

10. Dtran[E,b] = ε -closure(move(E,b))

Page 21: Conversion of an NFA to a  DFA using Subset Construction Algorithm

9. Dtran[E,a] = ε -closure(move(E,a))Among the states in E, only 2, 7 has a transition on a, and it goes to {3, 8} respectivelyThus: Dtran[E,a] = ε -closure(move(E,a)) = ε- closure ({3,8} = {1, 2, 3, 4, 6, 7, 8 }

Dtran[E,a] = B

{1 ,2 ,4 ,5 ,6 ,7,9}

ED b Ba

Page 22: Conversion of an NFA to a  DFA using Subset Construction Algorithm

10. Dtran[E,b] = ε -closure(move(E,b))Among the states in E, only 4 has a transition on b, and it goes to {5} respectivelyThus:Dtran[E,b] = ε -closure(move(E,b)) = ε- closure ({5} = {1,2, 4, 5, 6, 7}

Dtran[E,b] = C

{1 ,2 ,4 ,5,6 ,7 ,10}

bDE

b C

Page 23: Conversion of an NFA to a  DFA using Subset Construction Algorithm

Transition table Dtran for DFA D

Page 24: Conversion of an NFA to a  DFA using Subset Construction Algorithm

Result of applying the subset Construction NFA for (alb) * abb