0% found this document useful (0 votes)
22 views

Toc Module l5

The document discusses epsilon-nondeterministic finite automata (ε-NFA) and converting them to deterministic finite automata (DFA). It provides examples of calculating the epsilon-closure of states in an ε-NFA and using those closures to define the states and transitions of an equivalent DFA. Specifically, it shows taking the ε-closure of each state, treating those closures as the DFA states, and determining the transitions between those states based on the transitions out of and epsilon paths between the original ε-NFA states.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Toc Module l5

The document discusses epsilon-nondeterministic finite automata (ε-NFA) and converting them to deterministic finite automata (DFA). It provides examples of calculating the epsilon-closure of states in an ε-NFA and using those closures to define the states and transitions of an equivalent DFA. Specifically, it shows taking the ε-closure of each state, treating those closures as the DFA states, and determining the transitions between those states based on the transitions out of and epsilon paths between the original ε-NFA states.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Finite automata with and without epsilon transitions

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
1
Finite automata with and without epsilon transitions

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
2
Finite automata with and without epsilon transitions

Problems

1. Construct є-NFA for accepting the keywords either web or ebay


2. Construct є-NFA for accepting the keywords either if or for

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
3
Finite automata with and without epsilon transitions

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
4
Finite automata with and without epsilon transitions

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
5
Finite automata with and without epsilon transitions

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
6
Epsilon-Closure (є-closure)

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
7
Epsilon-Closure (є-closure)

Є-closure(1)={1,2,3,4,6}
Є-closure(2)=?
Є-closure (3)=?
Є-closure (4)=?
Є-closure (5)=?

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
8
Epsilon-Closure (є-closure)

1. ε-closure(q0) = {q0}
2. ε-closure(q1) = {q1, q2}
3. ε-closure(q2) = {q2}

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
9
Eliminating є moves in NFA (convert є-NFA to DFA)

Convert the ε -NFA into its equivalent DFA.

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
10
Epsilon-Closure (є-closure)

Solution:
Let us obtain ε-closure of each state.
1. ε-closure {q0} = {q0, q1, q2}
2. ε-closure {q1} = {q1}
3. ε-closure {q2} = {q2}
4. ε-closure {q3} = {q3}
5. ε-closure {q4} = {q4}
Now, let ε-closure {q0} = {q0, q1, q2} be state A.
Hence

δ'(A, 0) = ε-closure {δ((q0, q1, q2), 0) }


= ε-closure {δ(q0, 0) ∪ δ(q1, 0) ∪ δ(q2, 0) }
= ε-closure {q3}
= {q3} call it as state B.
Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
11
Epsilon-Closure (є-closure)

δ'(A, 1) = ε-closure {δ((q0, q1, q2), 1) }


= ε-closure {δ((q0, 1) ∪ δ(q1, 1) ∪ δ(q2, 1) }
= ε-closure {q3}
= {q3} = B.
The partial DFA will be

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
12
Epsilon-Closure (є-closure)
Now,
δ'(B, 0) = ε-closure {δ(q3, 0) }

δ'(B, 1) = ε-closure {δ(q3, 1) }
= ε-closure {q4}
= {q4} i.e. state C
For state C:
1. δ'(C, 0) = ε-closure {δ(q4, 0) }

2. δ'(C, 1) = ε-closure {δ(q4, 1) }

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
13
Epsilon-Closure (є-closure)

The DFA will be,

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
14
Epsilon-Closure (є-closure)

The DFA will be,

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
15
Epsilon-Closure (є-closure)

Example 2: Convert the given NFA into its equivalent DFA.

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
16
Epsilon-Closure (є-closure)
Solution: Let us obtain the ε-closure of each state.
1. ε-closure(q0) = {q0, q1, q2}
2. ε-closure(q1) = {q1, q2}
3. ε-closure(q2) = {q2}
Now we will obtain δ' transition. Let ε-closure(q0) = {q0, q1, q2}
call it as state A.
δ'(A, 0) = ε-closure{δ((q0, q1, q2), 0)}
= ε-closure{δ(q0, 0) ∪ δ(q1, 0) ∪ δ(q2, 0)}
= ε-closure{q0}
= {q0, q1, q2}

δ'(A, 1) = ε-closure{δ((q0, q1, q2), 1)}


= ε-closure{δ(q0, 1) ∪ δ(q1, 1) ∪ δ(q2, 1)}
= ε-closure{q1}
= {q1, q2} call it as state B
Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
17
Epsilon-Closure (є-closure)
δ'(A, 2) = ε-closure{δ((q0, q1, q2), 2)}
= ε-closure{δ(q0, 2) ∪ δ(q1, 2) ∪ δ(q2, 2)}
= ε-closure{q2}
= {q2} call it state C
Thus we have obtained
1. δ'(A, 0) = A
2. δ'(A, 1) = B
3. δ'(A, 2) = C
The partial DFA will be:

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
18
Epsilon-Closure (є-closure)

Now we will find the transitions on states B and C for each input.
Hence
δ'(B, 0) = ε-closure{δ((q1, q2), 0)}
= ε-closure{δ(q1, 0) ∪ δ(q2, 0)}
= ε-closure{ϕ}

δ'(B, 1) = ε-closure{δ((q1, q2), 1)}
= ε-closure{δ(q1, 1) ∪ δ(q2, 1)}
= ε-closure{q1}
= {q1, q2} i.e. state B itself
δ'(B, 2) = ε-closure{δ((q1, q2), 2)}
= ε-closure{δ(q1, 2) ∪ δ(q2, 2)}
= ε-closure{q2}
= {q2} i.e. state C itself
Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
19
Epsilon-Closure (є-closure)

Thus we have obtained


1. δ'(B, 0) = ϕ
2. δ'(B, 1) = B
3. δ'(B, 2) = C
The partial transition diagram will be

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
20
Epsilon-Closure (є-closure)

Now we will obtain transitions for C:


δ'(C, 0) = ε-closure{δ(q2, 0)}
= ε-closure{ϕ}

δ'(C, 1) = ε-closure{δ(q2, 1)}


= ε-closure{ϕ}

δ'(C, 2) = ε-closure{δ(q2, 2)}


= {q2}
Hence the DFA is

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
21
Epsilon-Closure (є-closure)

As A = {q0, q1, q2} in which final state q2 lies hence A is final state.
B = {q1, q2} in which the state q2 lies hence B is also final state. C
= {q2}, the state q2 lies hence C is also a final state.

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
22
Epsilon-Closure (є-closure)

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
23
Epsilon-Closure (є-closure)

Prepared By : Dr K RAJENDRA PRASAD, PROFESSOR, DEPT. OF CSE (CS), IARE (Autonomous), NANDYAL
24

You might also like