Class 5 NFA
Class 5 NFA
DFA vs NFA
In a DFA
1) Each symbol causes a move (even though the state of the
machine remains unchanged after the move)
2) The next state is completely determined by the current state
and current symbol.
In a NFA
3) The machine can move without consuming any symbols and
some times there is no possible moves and sometimes there are
more than one possible moves.
4) The state is only partially determined by the current state and
input symbol.
Formal Definition of NFA
A NFA is formerly defined as a 5 tuple (Q , Σ , δ ,
q0 ,F)
Where Q – Finite set of states which is non-empty
Σ - Finite set of Input symbol
q0 - Initial State belongs to Q
F - Set of final states and F ⊆ Q
δ - Transition function or mapping
function Q x Σ 2Q
δ ( q0, 010) = δ (δ(q0,01), 0)
= δ ({q0,q1},0)
= δ (q0,0) υ δ (q1,0)
= {q0,q3} υ Ф
= {q0,q3}
δ (q0,0100) = δ (δ (q0,010),0)
= δ ({q0,q3},0)
= δ (q0,0) υ δ (q3,0)
= {q0,q3} υ {q4}
= {q0,q3,q4}
δ( q0,0) = {q0,q3}
δ (q0,01001) = δ (δ (q0,0100), 1)
δ( q0,01) = δ (δ(q0,0),1)
= δ ({q0,q3,q4},1)
= δ ({q0,q3}, 1)
= δ (q0,1) υ δ(q3,1) υ δ(q4,1)
= δ (q0,1) υ δ (q3,1)
= {q0,q1} υ {Ф} υ { q4}
= {q0,q1} υ Ф
= {q0,q1,q4}
= {q0,q1}
δ (q0,01001) Ƞ F = {q0,q1,q4} Ƞ {q2,q4}
= {q4} = Final state
Hence the given string is accepted
Input String = 0100
δ(q0,0) = {q0,q1} δ(q0,0100) = δ(δ(q0,010),0)
δ(q0,01) = δ(δ(q0,0),1) = δ( {q0,q2},0)
= δ( {q0,q1},1) = δ(q0,0)υ δ (q2,0)
= δ(q0,1) υ δ (q1,1) = {q0,q1} υ {q0,q2}
= {q2} υ {q1,q2} = {q0,q1,q2}
= {q1,q2}
Since it contains q0 which is a final
state, hence the string is accepted
δ(q0,010) = δ(δ(q0,01),1)
= δ( {q1,q2},0)
= δ(q1,0) υ δ(q2,0)
= Ф υ{q0,q2}
= {q0,q2}
Construct a NFA over alphabet Σ ={a,b} that accepts string with substring ab.
Construct a NFA over alphabet Σ ={a,b} that accepts string which has 3rd symbol ‘b’ from
right.
The NFA with states {1,2,3,4,5} and input alphabet Σ = {a,b} has the
following transition table.
I) Calculate δ(1,ab)
II) Calculate δ(1,abab)
I ) δ(1,a) = {1,2}
δ(1,ab) = δ({1,2},b)
= δ(1,b) υ δ(2,b)
= {1} υ {3}
= {1,3}
Therefore δ(1,ab) = {1,3}
2) δ(1,aba) = δ({1,3},a)
= δ(1,a) υ δ(3,a)
= {1,2} υ { 4}
= {1,2,4}
(1,abab) = δ({1,2,4},b)
= δ(1,b) υ δ(2,b) υ δ(4,b)
= {1} υ {3} υ { Ф } = {1,3}
Design of NFA
https://www.youtube.com/watch?v=mc9E3WwDPCY
https://www.youtube.com/watch?v=p34O-VvUdRc