03 TOC
03 TOC
Σ={a,b}
• Every string contains a substring “abb”
• Every string does not contains a substring “ab”
• Every string where every “a” is followed by 3 “b’s”
• String does not contain 3 consecutive “a’s”
Finite automata
y
∗ 𝑞1 𝑞1 𝑞2
𝑞1 𝑞2
∗ 𝑞2 𝑞2 𝑞1
y
𝛿 = { q1, 𝑥 , q1 ,
q1, 𝑦 , q2 , q2, 𝑥 , q2 , q2, 𝑦 , q1 }
• Let Σ = {0, 1}. Give DFAs for {}, {ε}, Σ*, and Σ+.
4
Nondeterministic Finite State Automata (NFA)
• An NFA is a five-tuple:
M = (Q, Σ, δ, q0, F)
0 1 0/1
Q = {q0, q1, q2}
0 1
Σ = {0, 1} q0 q1 q2
Start state is q0
F = {q2}
δ: 0 1
q0
{q0, q1} {}
q1 {} {q1, q2}
{q2} {q2}
q2
6
• Example #2: pair of 0’s or pair of 1’s as substring
0/1 0/1
Q = {q0, q1, q2 , q3 , q4}
Σ = {0, 1} 0 0
q0 q3 q4
Start state is q0
F = {q2, q4} 1 0/1
1
δ: 0 1 q1 q2
q0 {q0, q3} {q0, q1}
q1 {} {q2}
{q2} {q2}
q2
{q4} {}
q3
{q4} {q4}
q4
7
• Design the min DFA and Min NFA for the Language L={ε}, Σ = {a, b}
a,b
𝑞1
a,b 𝑞2
𝑞1
• Design the min DFA and Min NFA for the Language L=(𝑎 + 𝑏)+ , Σ = {a, b}
a,b
a,b 𝑞2
𝑞1
a,b 𝑞2 a,b
𝑞1 𝑞1 𝑞2
Points to remember
• For every regular set, there is infinite no of DFAs
• For every regular set, there is infinite no of NFAs
• For every regular set, only one min DFA (unique)
• For every regular language, min DFA and min NFA need not be equal.
• For every regular language, there exist 1 or more min NFAs.
• How many paths are there for “bbb”
b
b
b 𝑞2
𝑞1
•2
•3
•4
•5
• What is the min NFA and min DFA for the below language
Min DFA Min NFA
1. L= 𝑎𝑎(𝑎 + 𝑏)∗ 4 3
2. L= (𝑎 + 𝑏)∗ 𝑎 2 2
3. L= (𝑎 + 𝑏)∗ a (𝑎 + 𝑏)∗ 2 2
a,b a,b
a a a a
𝑞1 𝑞2 𝑞3 𝑞1 𝑞2 𝑞3
b b
𝑞4
a,b
L= (𝑎 + 𝑏)∗ 𝑎
b a
a
𝒒𝟏 𝒒𝟐
b a,b
a
𝒒𝟏 𝒒𝟐
Construct the min NFA and min DFA, Σ = {a, b}
• L= (𝑎 + 𝑏)∗ 𝑎𝑎𝑎(𝑎 + 𝑏)∗ ,
• L= 𝑎𝑏 ∗
• L=(𝑎𝑏)∗
• L=𝑎∗ 𝑏 ∗
• L={w|w ϵ {𝑎, 𝑏}∗ , 𝑤 } is divisible by 3} , No. of states in min DFA is ______.
• L={w|w ϵ {𝑎, 𝑏}∗ , 𝑤 } is even} , No. of states in min DFA is ______.
Difference between DFA and NDFA/NFA
DFA NDFA/NFA
Dead Configuration is not allowed Dead Configuration is allowed
Multiple choices are not available corresponding to an Multiple choices are available corresponding to an
input input
ε move is not allowed Ε move is allowed
Digital computer are deterministic Non deterministic feature is not associated with
computers
Designing and understanding is difficult Designing and understanding is easier
Number of states are more or equal to NFA Number of states are lesser or equal to DFA
Only one min DFA (unique) There exist 1 or more min NFAs
NFA to DFA conversion
Example 1 NFA to DFA Conversion
NFA DFA
0,1
1 0,1
𝑞1 𝑞3 𝑞4
IF n is the number of states in NFA then maximum 2𝑛 states are possible for the converted DFA
ε-NFA (Epsilon NFA)
• Epsilon NFA (ε-NFA) is similar to the NFA but with a little difference
in that it has an epsilon (ε) transition that NFA doesn’t have.
• A Transition that does not consume any input symbol is called an
ε-transitions.
• Due to ε-transitions, the first string of language may be empty.
Formal Definition of Epsilon-NFA
0 1 0 0 0 1 0 0
0
0
𝑞2 𝑞3 𝑞2 𝑞3
0
1
𝑞0 𝑞1 𝑞5 𝑞6
0 1 0 0
0
0
𝑞2 𝑞3
Limitations of Finite State Automata (FSA)
• Limited Memory
• Strings without comparison
• Linear Power
Application of FSA