Professional Documents
Culture Documents
a
X Y
a a,b
Example
Construct DFA for a*bc
b c
X Y Z
a,b
c a,b,c
T
Example
Construct DFA for a+bc
a b c
W X Y Z
a,b
b,c c a,b,c
T
Example
Construct DFA for (ab)*b
b
A B
a b b
C D
a
Example
1) Construct DFA for Even number of a’s, when Σ ={a,b}.
RE ➔ ( b + ab*ab* ) *
DFA➔ a
A a
B
b b
Exercise
2) Construct DFA for string with “ab” as substring , when
Σ ={a,b}.
(a+b)* ab (a+b)*
RE ➔
b a a, b
DFA ➔
a b
X Y Z
Procedure: State Elimination(Reduction) Method
Note: If more than one Final state exists, then they can
be merged by considering all the paths without
changing the language
16-05-2022 10
Generalized Transition Graph:
It is the transition graph which allows regular expression
as the label on the directed edges.
Note: DFA allows only input symbol on the edge
NFA allows both input symbol and λ or ϵ on the edge
Case 1: Single state with final state
r RE = r*
Case 3: Initial state and one final state (with back edge)
r1 r2 r3 RE = r1* r2 ( r3 + r4 r1* r2) *
X Y
r4 11
FA to RE
State elimination method –
Remove all intermediate states
Remove all the trap states and thus solve
a b RE = ab
X Y Z
a
RE = a+b
X Y
b
b
a b*a RE = b*a
X Y X Y
Example-1
a a a,b
b b
1 2 3
a a+b
b a*b
1 2 3
a a+b
ba*b
1 3
c d
1 2
a*b
d
1 a*b 2
ca*b
RE = a*b(d + ca*b)*
Example-3 0
0
A B
1 A B
0 1 Removing trap state
0 1 0
0 1
C 1 D
C 1 D
0
A B A 01 A 01 A 01 + 10
1
0 1 0 1
10
C C
RE = (01+10)*
Example-4
0 1 0,1
1 0
q0 q1 q2
0 1 0,1
1 0
q0 q1 q2
0 1 0*1*
1
q0 q1 q0
0
1 0,1 1 0,1
1*0
1*1 01*1
q0 q1 q2 q0 q2
0
0+1 01*0
1+01*0
01*1
q0 q2 RE= (1+01*0)*01*1(0+1)*
Example-6 a λ
a,b a b bb
1 2 3 4
a
a λ a ab
a+b ab bb (a+b)ab bb
1 2 4 1 4
a a
1 a*(a+b)ab 4 ab+bb
1 a*(a+b)ab 4 ab+bb
aa*(a+b)ab
a
aa a(bb)*a
ab(bb)*ba
00
b+a(bb)*ba
ab(bb)*a+b
01
RE = (aa+ab(bb)*ba)* (ab(bb)*a+b)
( a(bb)*a +
a(bb)*a (b+a(bb)*ba) (aa+ab(bb)*ba)* (ab(bb)*a+b) )*
Example-8
a a+b a+b*
a a+b
0 1 2
a*b+c
a a+b* a a+b*
a (a+b)*(a+b) a(a+b)*(a+b)
0 1 2 0 2
a*b+c a*b+c
a a+b*
(a*b+c)+(a(a+b)+ ) a*(a*b+c)+(a(a+b)+ )(a+b*)*
0 2 0 2
RE = a*(a*b+c)+(a(a+b)+ )(a+b*)*
Exercise
3) Construct DFA for the string with regular expression
(111 + 11111)*
Strings accepted are 3 (111), 5 (11111),6 (111 twice), 8 (111 once and 11111 once),
9 (111 trice),10 (11111 twice), Count of 1 afterwards
1 1 1 1 1 1 1
1
1
OR
Exercise
4) Construct DFA for the strings of 0’s and 1’s without
any consecutive ones
(10+0)* (1+ λ)
0,1
3 OR
0 0
1
1 0
0 1 2
1
Assignment
RE to DFA:
1) String with a divisible by 3, when Σ ={a,b}.
2) Odd number of a’s, when Σ ={a,b}.
3) Construct DFA for :
1) (a+b)ba
2) (a+b)*ba
3) (a*b*)*
FA to RE: a e b
1. 0 1 2
d c