NFA To Minimized DFA
NFA To Minimized DFA
NFA To Minimized DFA
RE to DFA
• To convert RE to NFA use – Thompson’s algorithm
• To convert NFA to DFA use – Subset Construction algorithm
• To minimize the obtained DFA use – Tabulation method (also called
Mark/Reduce procedure)
Subset construction algorithm
Step 1: Find the λ-closure of all the states
Step 2: Let the λ-closure of the initial state be named as A
Step 3: Now find the transitions of each input symbol on this state A.
Then, find the λ-closure of the above set and name it as A if it appears
to be same otherwise give a new name as B.
Step 4: Repeat Step 3 for each of the new states added until there are
no new states in the queue.
Step 5: Convert the above representation to a DFA. The initial state of
the DFA will be A. Mark the final states of DFA.
λ-closure
• Lambda Closure, λ(S), for a set of states S is defined as:
• Every element of S in an element of λ(S)
• For any q λ(S), every element of (q, λ) is in λ(S)
• No other element of Q are in λ(S)
Example 1
• Convert the RE (a+b)*abb to a minimized DFA
b
DFA Minimization - Tabulation method
• Are All states reachable from initial state?
• Yes – include that state for next step
• No – remove that state
Eg-1: Eg-2:
Pair – (AC) A B C D
Minimized DFA
States a b States a b
-> A B C -> A B A
B B D B B D
a
C B C D B E
D B E *E B A b b
a B D
*E B C
a
A b
a
b E
Example 2
• Find the minimal DFA for abb(a+b)*
Example 2
Pairs F
{{DE}{DF}}
{EF} => {DEF} A B C D E
Example 2 – Minimized DFA
States a b
-> A B φ
a, b
B φ C
C φ D T
*D D D a, b
b a
a
a b b
A B C D
Example 3
• Convert to minimized DFA
1
0
0, 1 0, 1
q0 q1 q2
• λ-closure(q0) = {q0}
• λ-closure(q1) = {q1}
• λ-closure(q2) = {q2}
Example 3
• λ-closure(q0) = {q0} – A
• λ-closure(ẟ(A, 0)) = λ-closure(q0,q1} = {q0,q1} – B
• λ-closure(ẟ(A, 1)) = λ-closure(q1} = {q1} – C
• λ-closure(ẟ(B, 0)) = λ-closure(q0,q1,q2} = {q0,q1,q2} – D
• λ-closure(ẟ(B, 1)) = λ-closure(q1,q2} = {q1,q2} – E
• λ-closure(ẟ(C, 0)) = λ-closure(q2} = {q2} – F
• λ-closure(ẟ(C, 1)) = λ-closure(q2} = {q2} – F
• λ-closure(ẟ(D, 0)) = λ-closure(q0,q1,q2} = {q0,q1,q2} – D
• λ-closure(ẟ(D, 1)) = λ-closure(q1,q2} = {q1,q2} - E
Example 3
• λ-closure(ẟ(E, 0)) = λ-closure(q2} = {q2} – F
• λ-closure(ẟ(E, 1)) = λ-closure(q2} = {q2} – F States 0 1
• λ-closure(ẟ(F, 0)) = φ -> A B C
E
States 0 1
-> A B C F
*B D E
*C F F
A B C D E
*D D E Pairs:
*E F F
F φ F
(BD), (CE)
Example 3 – Minimized DFA
States 0 1 States 0 1
-> A B C -> A X Y
*B D E *X X Y
*C F F *Y F F
*D D E F φ F
0 0, 1
*E F F
F φ F X
0
F
• Let (BD) be X A 1
0, 1
• Let (CE) be Y 1 Y
Example 4
• Find the minimized DFA for the given NFA
0 1 1
q0 q1
q1 q2
0, λ 0, 1
->* A B C
C All pairs are
indistinguishable
*B B C So, {ABC} is a single
state
A B
*C B C
0, 1
X
Example 5 - Minimize the given DFA
States 0 1 States 0 1
q1
-> q0 q1 q3 -> q0 X X
q1 q2 q4 X X q4
q2 q1 q4 *q4 q4 q4 q2
q3 q2 q4
*q4 q4 q4 q3
A B X
C
λ λ
1
0
2.
A B C
0,1 0,1
Exercises – NFA to Minimized DFA
3. a
b a, b
A B X
C
a, λ b, λ
b, λ
4. RE ab*a(a+b)
5. RE (0+1)+(0+1)*
6. 𝐿 = 𝑎𝑛 𝑏 𝑚 ∶ n ≥ 1, m ≥ 2
7. 𝐿 = 𝑎𝑛 b: n ≥ 1} ⋃ {𝑏 𝑛 a ∶ n ≥ 1
Exercises – Minimize the DFA
8. States 0 1 9.
-> A B F
B G C
*C A C
D C G
E H F
F C G
G G E
H G C
Exercises
10.