0% found this document useful (0 votes)
48 views69 pages

1 - Module 1.2 - Equivalence of RE and FA

Automata Notes _ Ch. 1.2

Uploaded by

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

1 - Module 1.2 - Equivalence of RE and FA

Automata Notes _ Ch. 1.2

Uploaded by

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

VES INSTITUTE OF TECHNOLOGY

DEPARTMENT OF INFORMATION TECHNOLOGY

Automata Theory (ITC404)

BY
Mrs Charusheela Nehete
Assistant Professor,
IT Department ,
VESIT

1
Contents
● Regular Expressions
● Finite Automata
● Kleene’s Theorem
● RE to NFA - ε conversion
● NFA – ε to DFA Conversion
● NFA – ε to NFA without ε- moves Conversion
Introduction
● Regular expressions and finite automata have equivalent expressive power:
● For every regular expression R, there is a corresponding FA that accepts
the set of strings generated by R.
● For every FA A there is a corresponding regular expression that
generates the set of strings accepted by A.
Kleene’s Theorem
RE to DFA conversion
RE to FA conversion
● 3 steps

○ Construct NFA with epsilon transition

○ Convert it to NFA without epsilon transition

○ Construct equivalent DFA.


RE to NFA - ε moves
RE to NFA - ε moves

*
RE to NFA - ε moves
(a) NFA With Epsilon moves for (a+b)
(b) NFA With Epsilon moves for (a+b)*
(b) NFA With Epsilon moves for a.(a+b)*
Example 2

(a) Step 1 : a* (b) Step 2: b*


Example 2

(c) Step 3 : (a* + b *)


NFA - ε To DFA Conversion : Direct
Method I
Example 1: Design a FA accepting the language represented by RE : r=
0*1*2*
Design a FA accepting the language represented by RE : r= 0*1*2*
Equivalent DFA
Example 3: Construct DFA that accepts the language
represented by following RE
Final DFA
IMP Example 4 : Construct DFA that accepts the language represented by following RE R=(0+1)* (00+11)
NFA with ε to DFA: Direct Method II

• Step 1: We will take the ε-closure for the starting state of NFA as a starting state of
DFA.

• Step 2: Find the states for each input symbol that can be traversed from the present.
That means the union of transition value and their closures for each state of NFA
present in the current state of DFA.

• Step 3: If we found a new state, take it as current state and repeat step 2.

• Step 4: Repeat Step 2 and Step 3 until there is no new state present in the transition
table of DFA.

• Step 5: Mark the states of DFA as a final state which contains the final state of NFA.

30
Example 1
Convert the following NFA with ε into its equivalent DFA.

δE 0 1
ε
q0 Ø Ø {q1,q2}

q1 {q3} Ø Ø

q2 Ø {q3} Ø

q3 Ø {q4} Ø

*q4 Ø Ø Ø 31
Example 1

δE 0 1 ε ε-closure • Let us obtain ε-closure of


each state.
q0 Ø Ø {q1, {q0, q1, q2
} • ε-closure {q0} = {q0, q1, q2}
q2}

q1 {q3 Ø Ø {q1}
• ε-closure {q1} = {q1}
}
• ε-closure {q2} = {q2}
q2 Ø {q3} Ø {q2}
• ε-closure {q3} = {q3}
q3 Ø {q4} Ø {q3}
• ε-closure {q4} = {q4}
*q4 Ø Ø Ø {q4}
32
Example 2
Steps for converting NFA with ε to DFA:
Partial DFA will look
like this:

Now, let ε-closure {q0} = {q0, q1, q2} be state A.


δE 0 1 ε ε-closure

q0 Ø Ø {q1, {q0, q1, q2


}
q2}

q1 {q3 Ø Ø {q1}
}
q2 Ø {q3} Ø {q2}

q3 Ø {q4} Ø {q3}

*q4 Ø Ø Ø {q4}
33
Final DFA

δE 0 1 ε ε-closure

q0 Ø Ø {q1,q2} {q0, q1, q2}

q1 {q3} Ø Ø {q1}

q2 Ø {q3} Ø {q2}

q3 Ø {q4} Ø {q3}

*q4 Ø Ø Ø {q4}

34
EXAMPLE 2

35
Example 3
Convert the given NFA - ε into its equivalent DFA.

δE 0 1 2 ε ε-closure

q0 {q0} Ø Ø {q1,q2} {q0, q1, q2}

q1 Ø {q1} Ø {q2} {q1,q2}

*q2 Ø Ø {q2} Ø {q2}

36
Example 3
Convert the given NFA - ε into its equivalent DFA
• Now we will obtain δ' transition.
Let ε-closure(q0) = {q0, q1, q2}
call it as state A.

δE 0 1 2 ε ε-closure

q0 {q0} Ø Ø {q1,q2} {q0, q1, q2}

q1 Ø {q1} Ø {q2} {q1,q2}

*q2 Ø Ø {q2} Ø {q2}

37
Example 3
Convert the given NFA - ε into its equivalent DFA
• Now we will obtain δ' transition.
Let ε-closure(q0) = {q0, q1, q2}
call it as state A.

δE 0 1 2 ε ε-closure

q0 {q0} Ø Ø {q1,q2} {q0, q1, q2}

q1 Ø {q1} Ø {q2} {q1,q2}

*q2 Ø Ø {q2} Ø {q2}

38
The Partial DFA will be

39
Example 3
Convert the given NFA - ε into its equivalent DFA

• State B = {q1,q2}
δE 0 1 2 ε ε-closure

q0 {q0} Ø Ø {q1,q2} {q0, q1, q2}

q1 Ø {q1} Ø {q2} {q1,q2}

*q2 Ø Ø {q2} Ø {q2}

40
Example 3
Convert the given NFA - ε into its equivalent DFA

δE 0 1 2 ε ε-closure

• State C = {q2}
q0 {q0} Ø Ø {q1,q2} {q0, q1, q2}

q1 Ø {q1} Ø {q2} {q1,q2}

*q2 Ø Ø {q2} Ø {q2}

41
Final DFA will be as follows:

42
Exercises

Convert NFA with ε


transition to
equivalent DFA
δE a b ε ε-closure

1 {3} Ø {2} {1,2}

*2 1 Ø Ø {2}

3 2 {2,3} Ø {3}

43
Convert NFA with ε transition to equivalent DFA
Exercises
δE a b ε ε-closure
Let us obtain ε-closure of each
state.
ε-closure {1} = {1,2} call this as
1 {3} Ø {2} {1,2} state A
ε-closure {2} = {2}
*2 {1} Ø Ø {2} ε-closure {3} = {3}

3 {2} {2,3} Ø {3}

δ'(A, a) = ε-closure {δ(( 1, 2), a) } δ'(B, a) = ε-closure {δ(( 1, 2,3), a) }


= ε-closure { δ(1, a) ∪ δ(2, a) } = ε-closure { δ(1, a) ∪ δ(2, a) ) ∪ δ(3, a) }
= ε-closure {3,1} = ε-closure {3,1,2}
= {1,2,3} call it as state B. = {1,2,3}
δ'(A, b) = ε-closure {δ(( 1, 2), b) } δ'(B, b) = ε-closure {δ(( 1, 2,3), b) }
= ε-closure { δ(1, b) ∪ δ(2, b) } = ε-closure { δ(1, b) ∪ δ(2, b) ∪ δ(3, b) }
= ε-closure {Ø} = ε-closure {2,3}
=Ø = {2,3} call it as state C

44
Convert NFA with ε transition to equivalent DFA
Exercises
δE a b ε ε-closure
Let us obtain ε-closure of each
state.
ε-closure {1} = {1,2} call this
1 {3} Ø {2} {1,2} as state A
ε-closure {2} = {2}
*2 {1} Ø Ø {2} ε-closure {3} = {3}

3 {2} {2,3} Ø {3}

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


= ε-closure { δ(2, a) ∪ δ(3, a) }
= ε-closure {3,1} δ' a b
= {1,2} i.e A
δ'(C, b) = ε-closure {δ(( 2, 3), b) }
= ε-closure { δ(2, b) ∪ δ(3, b) } *A Ø
= ε-closure {2,3} B
= {2,3} ie.C
*B B C

*C A C

45
Final DFA

δ' a b
a

*A Ø
B

*B B C
A B
*C A C

b
a

46
Exercises
Convert NFA with ε
transition to
equivalent DFA

47
Exercise

• Convert NFA with ε transition to equivalent DFA

48
DFA TO RE
(Writing a RE for the given DFA)
1. Obtain the RE that denotes the language accepted by
following FA?

r = (a + b) (a + b) *
2. Obtain the RE that denotes the language accepted by
following FA?

r = (a + b) *
3. Obtain the RE that denotes the language accepted by
following FA?

r = a.(a + b) *
4. Obtain the RE that denotes the language accepted by following FA?
4. Obtain the RE that denotes the
language accepted by following FA?
5. Obtain the RE that denotes the language accepted by
following FA?
6. Obtain the RE that denotes the language accepted by
following FA?

r=
Exercises
1. L := {w ∈ {a, b}∗ | |w| divisible by 3}
((a + b) · (a + b) · (a + b))∗

2. L := {w ∈ {a, b}∗ | starts and ends with same character}


a (a+b)*a + b(a+b)*)

3. L := {w ∈ {0, 1}∗ | no of 0 divisible by 3}


1* + (1* 0 1* 0 1*01)*

4. L := {w ∈ {0, 1}∗ | starts with 0 and has odd length, or starts with 1 and
has even length }
0((0+1) (0+1))* + 1(0+1)((0+1)(0+1))*

5. All strings which do not contain the substring ba.


a ∗b ∗
NFA – ε to NFA without ε- moves
conversion
1)Design a FA that accepts the language over ∑ = {0,1} containing strings
with at least 2 zeroes

2) Design a FA that accepts the language over ∑ = {0,1} containing


strings with at the most 2 zeroes

3) Design a FA that accepts the language over ∑ = {0,1} containing


strings With exactly two zeroes

4) Design a FA that accepts the language over ∑ = {0,1} containing


strings At least 2 consecutive zeroes.
1)Design a FA that accepts the language over ∑ = {0,1} containing strings
with at least 2 zeroes

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