0% found this document useful (0 votes)
55 views9 pages

BCS313 L6 Epsilon in NFAs

Uploaded by

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

BCS313 L6 Epsilon in NFAs

Uploaded by

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

EPSILON (ε) IN NFAs

In the context of NFAs, ε marks state transitions that do not consume input. These
transitions thus express the non-determinism of the automaton. It's the empty string,
so a string of length zero.

When discussing the acceptance of ε, the symbol marks the empty string (this is
equivalent to the condition that an accepting state is reachable by a sequence of ε-
transitions from the start state). to avoid confusion, some authors use a different
symbol for the empty string (often λ).

What is an epsilon closure

The ε closure(P) is a set of states which are reachable from state P on ε-transitions.

The epsilon closure is as mentioned below −

 ε-closure (P) = P, where P ∈ Q


 If there exists ε-closure (P) = {q} and 𝛿 (q, ε) =r then, ε-closure (P) = {q, r}

Example

Find ε-closure for the following Non-deterministic finite automata (NFA) with
epsilon.

Solution

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

self state+ ε-reachable states.

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

q1 is self-state and q2 is a state obtained from q1 with epsilon input.

ε-closure (q2)= {q2}


Lets us consider an example to understand more clear about epsilon closure −

Problem − find the number of epsilon closure in the below diagram?

Solution −

The epsilon closure set of f2 consist of the elements − {f2, f3}. Therefore, the count
of the element in the closure set is 2.

Eliminating ε Transitions

NFA with ε can be converted to NFA without ε, and this NFA without ε can be
converted to DFA. To do this, we will use a method, which can remove all the ε
transition from given NFA. The method will be:

1. Find out all the ε transitions from each state from Q. That will be called as ε-
closure{q1} where qi ∈ Q.
2. Then δ' transitions can be obtained. The δ' transitions mean a ε-closure on δ
moves.
3. Repeat Step-2 for each input symbol and each state of given NFA.
4. Using the resultant states, the transition table for equivalent NFA without ε
can be built.

Example:

Convert the following NFA with ε to NFA without ε.


Solutions: We will first obtain ε-closures of q0, q1 and q2 as follows:

. ε-closure(q0) = {q0}
. ε-closure(q1) = {q1, q2}
. ε-closure(q2) = {q2}
Now the δ' transition on each input symbol is obtained as:

. δ'(q0, a) = ε-closure(δ(δ^(q0, ε),a))


. = ε-closure(δ(ε-closure(q0),a))
. = ε-closure(δ(q0, a))
. = ε-closure(q1)
. = {q1, q2}
.
. δ'(q0, b) = ε-closure(δ(δ^(q0, ε),b))
. = ε-closure(δ(ε-closure(q0),b))
. = ε-closure(δ(q0, b))
. =Ф
Now the δ' transition on q1 is obtained as:

. δ'(q1, a) = ε-closure(δ(δ^(q1, ε),a))


. = ε-closure(δ(ε-closure(q1),a))
. = ε-closure(δ(q1, q2), a)
. = ε-closure(δ(q1, a) ∪ δ(q2, a))
. = ε-closure(Ф ∪ Ф)
. =Ф
.
. δ'(q1, b) = ε-closure(δ(δ^(q1, ε),b))
. = ε-closure(δ(ε-closure(q1),b))
. = ε-closure(δ(q1, q2), b)
. = ε-closure(δ(q1, b) ∪ δ(q2, b))
. = ε-closure(Ф ∪ q2)
. = {q2}
The δ' transition on q2 is obtained as:

. δ'(q2, a) = ε-closure(δ(δ^(q2, ε),a))


. = ε-closure(δ(ε-closure(q2),a))
. = ε-closure(δ(q2, a))
. = ε-closure(Ф)
. =Ф
.
. δ'(q2, b) = ε-closure(δ(δ^(q2, ε),b))
. = ε-closure(δ(ε-closure(q2),b))
. = ε-closure(δ(q2, b))
. = ε-closure(q2)
. = {q2}
Now we will summarize all the computed δ' transitions:

. δ'(q0, a) = {q0, q1}


. δ'(q0, b) = Ф
. δ'(q1, a) = Ф
. δ'(q1, b) = {q2}
. δ'(q2, a) = Ф
. δ'(q2, b) = {q2}
The transition table can be:

States a b
→q0 {q1, q2} Ф
*q1 Ф {q2}
*q2 Ф {q2}
State q1 and q2 become the final state as ε-closure of q1 and q2 contain the final
state q2. The NFA can be shown by the following transition diagram:

Conversion from NFA to DFA

In this section, we will discuss the method of converting NFA to its equivalent DFA.
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.
On the other hand, in DFA, when a specific input is given to the current state, the
machine goes to only one state. DFA has only one move on a given input symbol.

Let, M = (Q, ∑, δ, q0, F) is an NFA which accepts the language L(M). There should
be equivalent DFA denoted by M' = (Q', ∑', q0', δ', F') such that L(M) = L(M').

Steps for converting NFA to DFA:


Step 1: Initially Q' = ϕ

Step 2: Add q0 of NFA to Q'. Then find the transitions from this start state.

Step 3: In Q', find the possible set of states for each input symbol. If this set of states
is not in Q', then add it to Q'.

Step 4: In DFA, the final state will be all the states which contain F(final states of
NFA)

Example 1:

Convert the given NFA to DFA.

Solution: For the given transition diagram we will first construct the transition table.

State 0 1
→q0 q0 q1
q1 {q1, q2} q1
*q2 q2 {q1, q2}
Now we will obtain δ' transition for state q0.

. δ'([q0], 0) = [q0]
. δ'([q0], 1) = [q1]
The δ' transition for state q1 is obtained as:

. δ'([q1], 0) = [q1, q2] (new state generated)


. δ'([q1], 1) = [q1]
The δ' transition for state q2 is obtained as:

. δ'([q2], 0) = [q2]
. δ'([q2], 1) = [q1, q2]
Now we will obtain δ' transition on [q1, q2].

. δ'([q1, q2], 0) = δ(q1, 0) ∪ δ(q2, 0)


. = {q1, q2} ∪ {q2}
. = [q1, q2]
. δ'([q1, q2], 1) = δ(q1, 1) ∪ δ(q2, 1)
. = {q1} ∪ {q1, q2}
. = {q1, q2}
. = [q1, q2]
The state [q1, q2] is the final state as well because it contains a final state q2. The
transition table for the constructed DFA will be:

State 0 1
→[q0] [q0] [q1]
[q1] [q1, q2] [q1]
*[q2] [q2] [q1, q2]
*[q1, q2] [q1, q2] [q1, q2]
The Transition diagram will be:

The state q2 can be eliminated because q2 is an unreachable state.

Example 2:

Convert the given NFA to DFA.


Solution: For the given transition diagram we will first construct the transition table.

State 0 1
→q0 {q0, q1} {q1}
*q1 ϕ {q0, q1}
Now we will obtain δ' transition for state q0.

. δ'([q0], 0) = {q0, q1}


. = [q0, q1] (new state generated)
. δ'([q0], 1) = {q1} = [q1]
The δ' transition for state q1 is obtained as:

. δ'([q1], 0) = ϕ
. δ'([q1], 1) = [q0, q1]
Now we will obtain δ' transition on [q0, q1].

. δ'([q0, q1], 0) = δ(q0, 0) ∪ δ(q1, 0)


. = {q0, q1} ∪ ϕ
. = {q0, q1}
. = [q0, q1]
Similarly,

. δ'([q0, q1], 1) = δ(q0, 1) ∪ δ(q1, 1)


. = {q1} ∪ {q0, q1}
. = {q0, q1}
. = [q0, q1]
As in the given NFA, q1 is a final state, then in DFA wherever, q1 exists that state
becomes a final state. Hence in the DFA, final states are [q1] and [q0, q1]. Therefore
set of final states F = {[q1], [q0, q1]}.

The transition table for the constructed DFA will be:

State 0 1
→[q0] [q0, q1] [q1]
*[q1] ϕ [q0, q1]
*[q0, q1] [q0, q1] [q0, q1]
The Transition diagram will be:

Even we can change the name of the states of DFA.

Suppose

. A = [q0]
. B = [q1]
. C = [q0, q1]
With these new names the DFA will be as follows:
Questions
1. Differentiate between epsilon and epsilon clossures
2. Define epsilon and show how it can be eliminated from an NFA
3. State the steps of converting from an NFA to DFA and use one example to
demonstrate the conversion

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy