SlideShare a Scribd company logo
Non Deterministic Finite Automata
To
Deterministic Finite Automata Construction
1
Course Name: Compiler Design
Course Code: CSE331
Level:3, Term:3
Department of Computer Science and Engineering
Daffodil International University
There are three main cases of non- determinism in NFAs:
1. Transition to a state without consuming any input.
2. Multiple transitions on the same input symbol.
3. No transition on an input symbol.
To convert NFAs to DFAs we need to get rid of non-
determinism from NFAs.
Non Deterministic Features of NFA
Using Subset construction method to convert NFA to DFA
involves the following steps:
• For every state in the NFA, determine all reachable states for
every input symbol.
• The set of reachable states constitute a single state in the
converted DFA (Each state in the DFA corresponds to a subset of
states in the NFA).
• Find reachable states for each new DFA state, until no more new
states can be found.
Subset Construction Method
Fig1. NFA without λ-transitions
1
3
2
4
5
a
a
a
b
a
b
b
a
a,b
a,b
Subset Construction Method
Fig1. NFA without λ-transitions
Step1
1
3
2
4
5
a
a
a
b
a
b
b
a
a,b
a,b
Construct a transition table showing
all reachable states for every state
for every input signal.
Subset Construction Method
Fig1. NFA without λ-transitions
Fig2. Transition table
1
3
2
4
5
a
a
a
b
a
b
b
a
a,b
a,b
Subset Construction Method
Fig1. NFA without λ-transitions
Fig2. Transition table
1
3
2
4
5
a
a
a
b
a
b
b
a
a,b
a,b
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
Subset Construction Method
Fig1. NFA without λ-transitions
Fig2. Transition table
1
3
2
4
5
a
a
a
a
a
b
b
b
a,b
a,b
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
Transition from state q with
input a
Transition from state q
with input b
Starts here
Subset Construction Method
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
Step2
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.
Subset Construction Method
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
Starts with
Initial state
Fig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5}
{4,5}
Starts with
Initial state
Fig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5}
{4,5}
Starts with
Initial state
Fig3. Subset Construction table
Step3
Repeat this process(step2) until no
more new states are reachable.
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5} {1,2,3,4,5} {2,4,5}
{4,5}
{2,4,5}
Fig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5} {1,2,3,4,5} {2,4,5}
{4,5} 5 4
{2,4,5}
5
4
Fig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5} {1,2,3,4,5} {2,4,5}
{4,5} 5 4
{2,4,5} {3,5} {4,5}
5
4
{3,5}
Fig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5} {1,2,3,4,5} {2,4,5}
{4,5} 5 4
{2,4,5} {3,5} {4,5}
5 ∅ ∅
4
{3,5}
∅
Fig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5} {1,2,3,4,5} {2,4,5}
{4,5} 5 4
{2,4,5} {3,5} {4,5}
5 ∅ ∅
4 5 4
{3,5}
We already got 4 and 5.
So we don’t add them again.
Fig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5} {1,2,3,4,5} {2,4,5}
{4,5} 5 4
{2,4,5} {3,5} {4,5}
5 ∅ ∅
4 5 4
{3,5} ∅ 2
∅
2
Fig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5} {1,2,3,4,5} {2,4,5}
{4,5} 5 4
{2,4,5} {3,5} {4,5}
5 ∅ ∅
4 5 4
{3,5} ∅ 2
∅ ∅ ∅
2
Fig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5} {1,2,3,4,5} {2,4,5}
{4,5} 5 4
{2,4,5} {3,5} {4,5}
5 ∅ ∅
4 5 4
{3,5} ∅ 2
∅ ∅ ∅
2 3 5
3
Fig3. Subset Construction table
Fig2. Transition table
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
2 {3} {5}
3 ∅ {2}
4 {5} {4}
5 ∅ ∅
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5} {1,2,3,4,5} {2,4,5}
{4,5} 5 4
{2,4,5} {3,5} {4,5}
5 ∅ ∅
4 5 4
{3,5} ∅ 2
∅ ∅ ∅
2 3 5
3 ∅ 2
Fig3. Subset Construction table
Stops here as there are
no more reachable states
q δ(q,a) δ(q,b)
1 {1,2,3,4,5} {4,5}
{1,2,3,4,5} {1,2,3,4,5} {2,4,5}
{4,5} 5 4
{2,4,5} {3,5} {4,5}
5 ∅ ∅
4 5 4
{3,5} ∅ 2
∅ ∅ ∅
2 3 5
3 ∅ 2
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 table
Fig4. Resulting FA after applying
Subset Construction to fig1
NFA to DFA Conversion
Let X = (Qx, ∑, δx, q0, Fx) be an NFA which accepts the language L(X). We have to
design an equivalent DFA Y = (Qy, ∑, δy, q0, Fy) such that L(Y) = L(X).
The following procedure converts the NFA to its equivalent DFA −
Algorithm:
Input − An NFA
Output − An equivalent DFA
Step 1 − Create state table from the given NFA.
Step 2 − Create a blank state table under possible input alphabets for the
equivalent DFA.
Step 3 − Mark the start state of the DFA by q0 (Same as the NFA).
Step 4 − Find out the combination of States {Q0, Q1,... , Qn} for each possible input
alphabet.
Step 5 − Each time we generate a new DFA state under the input alphabet
columns, we have to apply step 4 again, otherwise go to step 6.
Step 6 − The states which contain any of the final states of the NFA are the final
states of the equivalent DFA.
23
Example
Let us consider the NFA
shown in the figure:
q δ(q,0) δ(q,1)
a {a,b,c,d,e} {d,e}
b {c} {e}
c ∅ {b}
d {e} ∅
e ∅ ∅
The state transition table of
the NFA is:
24
q δ(q,0) δ(q,1)
a {a,b,c,d,e} {d,e}
b {c} {e}
c ∅ {b}
d {e} ∅
e ∅ ∅
Using the algorithm, we find its
equivalent DFA.
The state transition table of the
DFA is:
q δ(q,0) δ(q,1)
[a] [a,b,c,d,e] [d,e]
[a,b,c,d,e] [a,b,c,d,e] [b,d,e]
[d,e] [e] ∅
[b,d,e] [c,e] [e]
[e] ∅ ∅
[c, e] ∅ [b]
[b] [c] [e]
[c] ∅ [b]
Example…
The state transition table
of the NFA is:
25
Example…
The state transition table of
the DFA is:
q δ(q,0) δ(q,1)
[a] [a,b,c,d,e] [d,e]
[a,b,c,d,e] [a,b,c,d,e] [b,d,e]
[d,e] [e] ∅
[b,d,e] [c,e] [e]
[e] ∅ ∅
[c, e] ∅ [b]
[b] [c] [e]
[c] ∅ [b]
The state diagram of the DFA is as follows:
26
THANK YOU
27

More Related Content

PPTX
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
PDF
Formal Languages and Automata Theory Unit 1
PPT
Hima1
PDF
Nondeterministic Finite Automata AFN.pdf
PPTX
Theory of Automata and formal languages unit 1
PDF
NFA DFA Equivalence theorem
PPTX
NFA Converted to DFA , Minimization of DFA , Transition Diagram
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
Formal Languages and Automata Theory Unit 1
Hima1
Nondeterministic Finite Automata AFN.pdf
Theory of Automata and formal languages unit 1
NFA DFA Equivalence theorem
NFA Converted to DFA , Minimization of DFA , Transition Diagram

Similar to Lecture 6.1 - NFA to DFA toc and compiler design (20)

PPT
Automata theory 4-finite-automata.ppt for computer science student
PDF
Lecture4 lexical analysis2
DOCX
Deterministic finite automata
PDF
Lecture 17- F19.pdf
PPT
Finite automata examples
PPT
Finite automata examples
PDF
Automata theory
PDF
Teori automata lengkap
PDF
TOC 4 | Non-deterministic Finite Automata
PDF
Theory of Computation FSM Conversions and Problems
PDF
Finite automata
PPT
Nfa vs dfa
PPT
Finite automata
PPTX
Minimization of DFA.pptx
PDF
Theory of computation and automata
PDF
Theory of computation and automata
PPT
Dfa h11
PDF
IRJET- Partition Method for DFA Minimization
PPTX
NFA to DFA Conversion Using Subset Construction Method
Automata theory 4-finite-automata.ppt for computer science student
Lecture4 lexical analysis2
Deterministic finite automata
Lecture 17- F19.pdf
Finite automata examples
Finite automata examples
Automata theory
Teori automata lengkap
TOC 4 | Non-deterministic Finite Automata
Theory of Computation FSM Conversions and Problems
Finite automata
Nfa vs dfa
Finite automata
Minimization of DFA.pptx
Theory of computation and automata
Theory of computation and automata
Dfa h11
IRJET- Partition Method for DFA Minimization
NFA to DFA Conversion Using Subset Construction Method
Ad

Recently uploaded (20)

PPTX
Institutional Correction lecture only . . .
PDF
Insiders guide to clinical Medicine.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Computing-Curriculum for Schools in Ghana
PPTX
master seminar digital applications in india
PPTX
Cell Types and Its function , kingdom of life
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Pharma ospi slides which help in ospi learning
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
Institutional Correction lecture only . . .
Insiders guide to clinical Medicine.pdf
Supply Chain Operations Speaking Notes -ICLT Program
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
O7-L3 Supply Chain Operations - ICLT Program
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Computing-Curriculum for Schools in Ghana
master seminar digital applications in india
Cell Types and Its function , kingdom of life
O5-L3 Freight Transport Ops (International) V1.pdf
TR - Agricultural Crops Production NC III.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPH.pptx obstetrics and gynecology in nursing
Sports Quiz easy sports quiz sports quiz
human mycosis Human fungal infections are called human mycosis..pptx
Microbial disease of the cardiovascular and lymphatic systems
Pharma ospi slides which help in ospi learning
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial diseases, their pathogenesis and prophylaxis
Ad

Lecture 6.1 - NFA to DFA toc and compiler design

  • 1. Non Deterministic Finite Automata To Deterministic Finite Automata Construction 1 Course Name: Compiler Design Course Code: CSE331 Level:3, Term:3 Department of Computer Science and Engineering Daffodil International University
  • 2. There are three main cases of non- determinism in NFAs: 1. Transition to a state without consuming any input. 2. Multiple transitions on the same input symbol. 3. No transition on an input symbol. To convert NFAs to DFAs we need to get rid of non- determinism from NFAs. Non Deterministic Features of NFA
  • 3. Using Subset construction method to convert NFA to DFA involves the following steps: • For every state in the NFA, determine all reachable states for every input symbol. • The set of reachable states constitute a single state in the converted DFA (Each state in the DFA corresponds to a subset of states in the NFA). • Find reachable states for each new DFA state, until no more new states can be found. Subset Construction Method
  • 4. Fig1. NFA without λ-transitions 1 3 2 4 5 a a a b a b b a a,b a,b Subset Construction Method
  • 5. Fig1. NFA without λ-transitions Step1 1 3 2 4 5 a a a b a b b a a,b a,b Construct a transition table showing all reachable states for every state for every input signal. Subset Construction Method
  • 6. Fig1. NFA without λ-transitions Fig2. Transition table 1 3 2 4 5 a a a b a b b a a,b a,b Subset Construction Method
  • 7. Fig1. NFA without λ-transitions Fig2. Transition table 1 3 2 4 5 a a a b a b b a a,b a,b q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ Subset Construction Method
  • 8. Fig1. NFA without λ-transitions Fig2. Transition table 1 3 2 4 5 a a a a a b b b a,b a,b q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ Transition from state q with input a Transition from state q with input b Starts here Subset Construction Method
  • 9. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ Step2 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. Subset Construction Method
  • 10. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} Starts with Initial state Fig3. Subset Construction table
  • 11. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {4,5} Starts with Initial state Fig3. Subset Construction table
  • 12. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {4,5} Starts with Initial state Fig3. Subset Construction table Step3 Repeat this process(step2) until no more new states are reachable.
  • 13. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {1,2,3,4,5} {2,4,5} {4,5} {2,4,5} Fig3. Subset Construction table
  • 14. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {1,2,3,4,5} {2,4,5} {4,5} 5 4 {2,4,5} 5 4 Fig3. Subset Construction table
  • 15. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {1,2,3,4,5} {2,4,5} {4,5} 5 4 {2,4,5} {3,5} {4,5} 5 4 {3,5} Fig3. Subset Construction table
  • 16. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {1,2,3,4,5} {2,4,5} {4,5} 5 4 {2,4,5} {3,5} {4,5} 5 ∅ ∅ 4 {3,5} ∅ Fig3. Subset Construction table
  • 17. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {1,2,3,4,5} {2,4,5} {4,5} 5 4 {2,4,5} {3,5} {4,5} 5 ∅ ∅ 4 5 4 {3,5} We already got 4 and 5. So we don’t add them again. Fig3. Subset Construction table
  • 18. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {1,2,3,4,5} {2,4,5} {4,5} 5 4 {2,4,5} {3,5} {4,5} 5 ∅ ∅ 4 5 4 {3,5} ∅ 2 ∅ 2 Fig3. Subset Construction table
  • 19. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {1,2,3,4,5} {2,4,5} {4,5} 5 4 {2,4,5} {3,5} {4,5} 5 ∅ ∅ 4 5 4 {3,5} ∅ 2 ∅ ∅ ∅ 2 Fig3. Subset Construction table
  • 20. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {1,2,3,4,5} {2,4,5} {4,5} 5 4 {2,4,5} {3,5} {4,5} 5 ∅ ∅ 4 5 4 {3,5} ∅ 2 ∅ ∅ ∅ 2 3 5 3 Fig3. Subset Construction table
  • 21. Fig2. Transition table q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} 2 {3} {5} 3 ∅ {2} 4 {5} {4} 5 ∅ ∅ q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {1,2,3,4,5} {2,4,5} {4,5} 5 4 {2,4,5} {3,5} {4,5} 5 ∅ ∅ 4 5 4 {3,5} ∅ 2 ∅ ∅ ∅ 2 3 5 3 ∅ 2 Fig3. Subset Construction table Stops here as there are no more reachable states
  • 22. q δ(q,a) δ(q,b) 1 {1,2,3,4,5} {4,5} {1,2,3,4,5} {1,2,3,4,5} {2,4,5} {4,5} 5 4 {2,4,5} {3,5} {4,5} 5 ∅ ∅ 4 5 4 {3,5} ∅ 2 ∅ ∅ ∅ 2 3 5 3 ∅ 2 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 table Fig4. Resulting FA after applying Subset Construction to fig1
  • 23. NFA to DFA Conversion Let X = (Qx, ∑, δx, q0, Fx) be an NFA which accepts the language L(X). We have to design an equivalent DFA Y = (Qy, ∑, δy, q0, Fy) such that L(Y) = L(X). The following procedure converts the NFA to its equivalent DFA − Algorithm: Input − An NFA Output − An equivalent DFA Step 1 − Create state table from the given NFA. Step 2 − Create a blank state table under possible input alphabets for the equivalent DFA. Step 3 − Mark the start state of the DFA by q0 (Same as the NFA). Step 4 − Find out the combination of States {Q0, Q1,... , Qn} for each possible input alphabet. Step 5 − Each time we generate a new DFA state under the input alphabet columns, we have to apply step 4 again, otherwise go to step 6. Step 6 − The states which contain any of the final states of the NFA are the final states of the equivalent DFA. 23
  • 24. Example Let us consider the NFA shown in the figure: q δ(q,0) δ(q,1) a {a,b,c,d,e} {d,e} b {c} {e} c ∅ {b} d {e} ∅ e ∅ ∅ The state transition table of the NFA is: 24
  • 25. q δ(q,0) δ(q,1) a {a,b,c,d,e} {d,e} b {c} {e} c ∅ {b} d {e} ∅ e ∅ ∅ Using the algorithm, we find its equivalent DFA. The state transition table of the DFA is: q δ(q,0) δ(q,1) [a] [a,b,c,d,e] [d,e] [a,b,c,d,e] [a,b,c,d,e] [b,d,e] [d,e] [e] ∅ [b,d,e] [c,e] [e] [e] ∅ ∅ [c, e] ∅ [b] [b] [c] [e] [c] ∅ [b] Example… The state transition table of the NFA is: 25
  • 26. Example… The state transition table of the DFA is: q δ(q,0) δ(q,1) [a] [a,b,c,d,e] [d,e] [a,b,c,d,e] [a,b,c,d,e] [b,d,e] [d,e] [e] ∅ [b,d,e] [c,e] [e] [e] ∅ ∅ [c, e] ∅ [b] [b] [c] [e] [c] ∅ [b] The state diagram of the DFA is as follows: 26