0% found this document useful (0 votes)
134 views19 pages

2.4 E-Nfa To Nfa Conversion

Uploaded by

yadavankit222136
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views19 pages

2.4 E-Nfa To Nfa Conversion

Uploaded by

yadavankit222136
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Theory of Computation

CS-202
Finite Automata
Finite Automata

- Epsilon Non Deterministic Finite Accepters


-Conversion from ε –NFA to NFA
ε –NFA or Epsilon NFA
ε –NFA or Epsilon NFA
It is an extended version of NFA, which makes the designing of NFA much
easier.

An ε –NFA is defined using the quintuple


M=(Q, Σ, q0, 𝛿, F)

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.

• Epsilon NFA is the NFA which contains epsilon move(s)/Null move(s). To


remove the epsilon move/Null move from epsilon-NFA we can convert it
into NFA.

9
ε-closure:
It is a set of all the states which can be obtained from a state,
only by seeing ε-moves.

Now the transition function for NFA is defined as:


δ'(qi, x) = ε-closure[δ(ε-closure(qi), x) ]
x is an input alphabet

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.

ε-closure(q0) = {q0, q1, q2}


ε-closure(q1) = {q1, q2}
ε-closure(q2) = {q2}

12
Example (Cont..)

δ'(qi, x) = ε-closure[δ(ε-closure(qi), x)]

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}

δ'(q0, b) = ε-closure{δ((q0, q1, q2), b)} = ε-closure{δ(q0, b) ∪ δ(q1, b) ∪ δ(q2, b)}


= ε-closure{q1} = {q1, q2}

δ'(q0, c) = ε-closure{δ((q0, q1, q2), c)} = ε-closure{δ(q0, c) ∪ δ(q1, c) ∪ δ(q2, c)}


= ε-closure{q2} = {q2}
13
Example (Cont..)

Solution:

Thus we have obtained


δ'(q0, a) = {q0, q1, q2}
δ'(q0, b) = { q1, q2} δ'(qi, x) = ε-closure[δ(ε-closure(qi), x)]
δ'(q0, c) = { q2}

• 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:

δ'(qi, x) = ε-closure[δ(ε-closure(qi), x)]

δ'(q1, b) = ε-closure{δ((q1, q2), b)} = ε-closure{δ(q1, b) ∪ δ(q2, b)}


= ε-closure{q1} = {q1, q2}

δ'(q1, c) = ε-closure{δ((q1, q2), c)} = ε-closure{δ(q1, c) ∪ δ(q2, c)}


= ε-closure{q2} = {q2}
Thus we have obtained
δ'(q1, a) = ϕ
δ'(q1, b) = {q1, q2}
δ'(q1, c) = {q2}

15
Example (Cont..)
Solution:

δ'(qi, x) = ε-closure[δ(ε-closure(qi), x)]


• Now we will obtain transitions for q2:
δ'(q2, a) = ε-closure{δ(q2, a)} = ε-closure{ϕ} =ϕ
δ'(q2, b) = ε-closure{δ(q2, b)} = ε-closure{ϕ} =ϕ
δ'(q2, c) = ε-closure{δ(q2, c)} = {q2}

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

1. An introduction to FORMAL LANGUAGES and


AUTOMATA by PETER LINZ.
2. Introduction to Automata Theory, Languages, And
Computation by JOHN E. HOPCROFT, RAJEEV
MOTWANI, JEFFREY D. ULLMAN
3. Theory of computer science: automata, languages and
computation by K.L.P MISHRA

You might also like