+ All Categories
Home > Documents > NFA TO DFA

NFA TO DFA

Date post: 04-Feb-2016
Category:
Upload: zeal
View: 108 times
Download: 5 times
Share this document with a friend
Description:
NFA TO DFA. Non Deterministic Features of NFA. There are three main cases of non- determinism in NFAs: Transition to a state without consuming any input. Multiple transitions on the same input symbol. No transition on an input symbol. - PowerPoint PPT Presentation
Popular Tags:
23
NFA TO DFA NFA TO DFA
Transcript
Page 1: NFA TO DFA

NFA TO DFANFA TO DFA

Page 2: NFA TO DFA

Non Deterministic Features of NFANon Deterministic Features of NFA

There are three main cases of non- determinism in NFAs:There are three main cases of non- determinism in NFAs:

1.1. Transition to a state without Transition to a state without consuming any input.consuming any input.

2.2. Multiple transitions on the same input Multiple transitions on the same input symbol.symbol.

3.3. No transition on an input symbol.No transition on an input symbol.

To convert NFAs to DFAs we need to get rid of non-To convert NFAs to DFAs we need to get rid of non-determinism from NFAs.determinism from NFAs.

Page 3: NFA TO DFA

Subset Construction MethodSubset Construction Method

Using Subset construction method to convert NFA to Using Subset construction method to convert NFA to DFA involves the following steps:DFA involves the following steps:

For every state in the NFA, determine all For every state in the NFA, determine all reachable statesreachable states for for every input symbol.every input symbol.

The set of reachable states constitute a The set of reachable states constitute a single statesingle state in the in the converted DFA (Each state in the DFA corresponds to a converted DFA (Each state in the DFA corresponds to a subset of states in the NFA).subset of states in the NFA).

Find Find reachable statesreachable states for each for each new DFAnew DFA state, until no more state, until no more new states can be found.new states can be found.

Page 4: NFA TO DFA

Subset Construction MethodSubset Construction Method

Fig1. NFA without λ-transitionsFig1. NFA without λ-transitions

Page 5: NFA TO DFA

Subset Construction MethodSubset Construction Method

Fig1. NFA without λ-transitionsFig1. NFA without λ-transitions

1

3

2

4

5

aaa

aa

aa

aa

b

b

b

a,b

a,b

Page 6: NFA TO DFA

Subset Construction MethodSubset Construction Method

Fig1. NFA without λ-transitionsFig1. NFA without λ-transitions

Step1Step1

1

3

2

4

5

aaa

aa

aa

aa

b

b

b

a,b

a,b

Construct a transition table showing all reachable states for every state for every input signal.

Page 7: NFA TO DFA

Subset Construction MethodSubset Construction Method

Fig1. NFA without λ-transitionsFig1. NFA without λ-transitions Fig2. Transition tableFig2. Transition table

1

3

2

4

5

aaa

aa

aa

aa

b

b

b

a,b

a,b

Page 8: NFA TO DFA

Subset Construction MethodSubset Construction Method

Fig1. NFA without λ-transitionsFig1. NFA without λ-transitions Fig2. Transition tableFig2. Transition table

1

3

2

4

5

aaa

aa

aa

aa

b

b

b

a,b

a,b

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

Page 9: NFA TO DFA

Subset Construction MethodSubset Construction Method

Fig1. NFA without λ-transitionsFig1. NFA without λ-transitions Fig2. Transition tableFig2. Transition table

1

3

2

4

5

aaa

aa

aa

aa

b

b

b

a,b

a,b

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

Transition from state q with input a

Transition from state q with input b

Starts here

Page 10: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

Subset Construction MethodSubset Construction Method

Step2Step2

The set of states resulting from every transition function constitutes a new state. Calculate all reachable states for every such state for every input signal.

Page 11: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

Starts withInitial state

Fig3. Subset Construction tableFig3. Subset Construction table

Page 12: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5}

Starts withInitial state

Fig3. Subset Construction tableFig3. Subset Construction table

Page 13: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5}

Starts withInitial state

Fig3. Subset Construction tableFig3. Subset Construction table

Step3Step3

Repeat this process(step2) until no more new states are reachable.

Page 14: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5}

{2,4,5}{2,4,5}

Fig3. Subset Construction tableFig3. Subset Construction table

Page 15: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5} 55 44

{2,4,5}{2,4,5}

55

44

Fig3. Subset Construction tableFig3. Subset Construction table

Page 16: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5} 55 44

{2,4,5}{2,4,5} {3,5}{3,5} 44

55

44

{3,5}{3,5}

Fig3. Subset Construction tableFig3. Subset Construction table

Page 17: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5} 55 44

{2,4,5}{2,4,5} {3,5}{3,5} 44

55 ∅ ∅44

{3,5}{3,5}

Fig3. Subset Construction tableFig3. Subset Construction table

Page 18: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5} 55 44

{2,4,5}{2,4,5} {3,5}{3,5} 44

55 ∅ ∅44 55 44

{3,5}{3,5}

We already got 4 and 5.So we don’t add them again.

Fig3. Subset Construction tableFig3. Subset Construction table

Page 19: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5} 55 44

{2,4,5}{2,4,5} {3,5}{3,5} 44

55 ∅ ∅44 55 44

{3,5}{3,5} ∅ 22

∅22

Fig3. Subset Construction tableFig3. Subset Construction table

Page 20: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5} 55 44

{2,4,5}{2,4,5} {3,5}{3,5} 44

55 ∅ ∅44 55 44

{3,5}{3,5} ∅ 22

∅ ∅ ∅22

Fig3. Subset Construction tableFig3. Subset Construction table

Page 21: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5} 55 44

{2,4,5}{2,4,5} {3,5}{3,5} 44

55 ∅ ∅44 55 44

{3,5}{3,5} ∅ 22

∅ ∅ ∅22 33 5533

Fig3. Subset Construction tableFig3. Subset Construction table

Page 22: NFA TO DFA

Fig2. Transition tableFig2. Transition table

q δ(q,a) δ(q,b)

11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

22 {3}{3} {5}{5}

33 ∅ {2}{2}

44 {5}{5} {4}{4}

55 ∅ ∅

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5} 55 44

{2,4,5}{2,4,5} {3,5}{3,5} 44

55 ∅ ∅44 55 44

{3,5}{3,5} ∅ 22

∅ ∅ ∅22 33 5533 ∅ 22

Fig3. Subset Construction tableFig3. Subset Construction table

Stops here as there are no more reachable states

Page 23: NFA TO DFA

q δ(q,a) δ(q,b)11 {1,2,3,4,5}{1,2,3,4,5} {4,5}{4,5}

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

{4,5}{4,5} 55 44

{2,4,5}{2,4,5} {3,5}{3,5} 44

55 ∅ ∅44 55 44

{3,5}{3,5} ∅ 22

∅ ∅ ∅22 33 55

33 ∅ 22

1

45

12345 245

35

5

4

∅3

2

a

a

a

a

a

a

a

a

b

b

b

b

b

b

b

b

a,b

a,b

Fig3. Subset Construction tableFig3. Subset Construction tableFig4. Resulting FA after applying Fig4. Resulting FA after applying Subset Construction to fig1Subset Construction to fig1


Recommended