2.4 E-Nfa To Nfa Conversion
2.4 E-Nfa To Nfa Conversion
CS-202
Finite Automata
Finite Automata
4
Examples (Cont..)
1. Design an ε NFA for the language
L={0n1m, n,m≥0}
ε NFA
5
Examples (Cont..)
2. Design an ε NFA over ∑ ={a,b,c}for the
language
L={ambncp, m,n,p≥0}
ε NFA
6
Examples (Cont..)
3. Design an ε NFA for the language
L={0m1n, m+n=odd}
Occurrence of 0’s and 1’s
0 1 sum
Even even even
Even odd odd
Odd even odd
Odd odd even
7
3. Design an ε NFA for the language
L={0m1n, m+n=odd}
0 0 1 1 Rejected
Input Strings
0 0 1 1 1 Accepted
f
Conversion from ε-NFA to NFA
• In NFA, when a specific input is given to the current state, the machine
goes to multiple states. It can have zero, one or more than one move on a
given input symbol.
9
ε-closure:
It is a set of all the states which can be obtained from a state,
only by seeing ε-moves.
10
Steps for converting ε-NFA to NFA:
• Step-1: Consider the vertices having the epsilon move. For each
state (or vertex) find epsilon closure.
• Step-2: Now obtain δ' transition function of NFA for the states of
ε-NFA over each input symbol ‘x’ (say).
δ'(qi, x) = ε-closure[δ(ε-closure(qi), x)]
x is an input alphabet
• Step-3: In NFA, the final state will be all the states whose
closure contain F(final states of ε-NFA).
11
Example
Convert the given ε NFA to NFA
Solution: For the given transition diagram we will first obtain the ε-closure of
each state.
12
Example (Cont..)
Solution:
Now we will obtain δ' transition. Let ε-closure(q0) = {q0, q1, q2}
δ'(q0, a) = ε-closure{δ((q0, q1, q2), a)} = ε-closure{δ(q0, a) ∪ δ(q1, a) ∪ δ(q2, a)}
= ε-closure{q0} = {q0, q1, q2}
Solution:
• Now we will find the transitions on states q1 and q2 for each input.
Hence
δ'(q1, a) = ε-closure{δ((q1, q2), a)} = ε-closure{δ(q1, a) ∪ δ(q2, a)}
= ε-closure{ϕ} =ϕ
14
Example (Cont..)
Solution:
15
Example (Cont..)
Solution:
As ε-closure{ q0}= {q0, q1, q2} in which final state q2 lies hence q0 is final
state.
ε-closure{ q1} = {q1, q2} in which the state q2 lies hence q1 is also final state.
ε-closure{ q2} = {q2}, the state q2 lies hence q2 is also a final state.
16
The Transition table for NFA will be:
States a b c
* q0 {q0, q1, q2} {q1, q2} { q2}
*q1 ϕ {q1, q2} { q2}
*q2 ϕ ϕ { q2}
17
The Transition diagram for NFA will be:
States a b c
* q0 {q0, q1, q2} {q1, q2} { q2}
*q1 ϕ {q1, q2} { q2}
*q2 ϕ ϕ { q2}
18
Suggested readings