Professional Documents
Culture Documents
ATFL Lecture 5
ATFL Lecture 5
Languages
A. Senthil - Professor/CSE 1
Equivalence of Machines
if L( M1 ) = L( M 2 )
A. Senthil - Professor/CSE 2
Example of equivalent machines
NFA M1
L(M1 ) = {10} * 0
q0 q1
1
DFA M2 0,1
L(M 2 ) = {10} * 0
q0 q1 1 q2
1
0
A. Senthil - Professor/CSE 3
We will prove:
=
Languages
Regular
accepted
Languages
by NFAs
Languages
accepted
by DFAs
NFAs and DFAs have the
same computation power
A. Senthil - Professor/CSE 4
Step 1
Languages
accepted Ê Regular
Languages
by NFAs
Languages
accepted Í Regular
Languages
by NFAs
DFA M¢
{q0 }
A. Senthil - Professor/CSE 7
Convert NFA to DFA
NFA M
a
q0 a q1 l q2
b
DFA M¢
{q0 } a
{q1, q2 }
A. Senthil - Professor/CSE 8
Convert NFA to DFA
NFA M
a
q0 a q1 l q2
b
DFA M¢
{q0 } a
{q1, q2 }
b
Æ
A. Senthil - Professor/CSE 9
Convert NFA to DFA
NFA M
a
q0 a q1 l q2
b
a
DFA M¢
{q0 } a
{q1, q2 }
b
Æ
A. Senthil - Professor/CSE 10
Convert NFA to DFA
NFA M
a
q0 a q1 l q2
b
b a
DFA M¢
{q0 } a
{q1, q2 }
b
Æ
A. Senthil - Professor/CSE 11
Convert NFA to DFA
NFA M
a
q0 a q1 l q2
b
b a
DFA M¢
{q0 } a
{q1, q2 }
b
Æ a, b
A. Senthil - Professor/CSE 12
Convert NFA to DFA
NFA M
a
q0 a q1 l q2
b
L(M ) = L(M ¢)
a
DFA M¢ b
{q0 } a
{q1, q2 }
b
Æ a, b
A. Senthil - Professor/CSE 13
NFA to DFA: Remarks
We want to convert it
M ¢ = (QD , S, d D ,{q0 }, FD )
to an equivalent DFA
With
L(M ) = L(M ¢)
A. Senthil - Professor/CSE 14
If the NFA has n states
QN = {q0 , q1 , q2 ,..., qn }
A. Senthil - Professor/CSE 15
Procedure NFA to DFA
A. Senthil - Professor/CSE 16
Example
NFA M a
q0 a q1 l q2
b
DFA M¢
{q0 }
A. Senthil - Professor/CSE 17
Procedure NFA to DFA
2. For every DFA’s state {qi , q j ,..., qm }
{q0 } a
{q1, q2 }
d ({q0 }, a ) = {q1, q2 }
A. Senthil - Professor/CSE 19
Procedure NFA to DFA
A. Senthil - Professor/CSE 20
Example
NFA M a
q0 a q1 l q2
b
b a
DFA M¢
{q0 } a
{q1, q2 }
b
Æ a, b
A. Senthil - Professor/CSE 21
Procedure NFA to DFA
3. For any DFA state {qi , q j ,..., qm }
A. Senthil - Professor/CSE 22
Example
NFA M a
q0 a q1 l q2 q1 Î F
b
a
DFA M¢ b
{q0 } a
{q1, q2 }
b {q1, q2 }Î F ¢
Æ a, b
A. Senthil - Professor/CSE 23
Theorem
Take NFA M
L( M ) = L( M ¢)
A. Senthil - Professor/CSE 24
Proof
L( M ) = L( M ¢)
L( M ) Í L( M ¢) AND L( M ) Ê L( M ¢)
A. Senthil - Professor/CSE 25
First we show: L( M ) Í L( M ¢)
A. Senthil - Professor/CSE 26
wÎ L(M )
M: q0 w qf
w = s 1s 2 !s k
s1 s2 sk
M: q0 qf
A. Senthil - Professor/CSE 27
We will show that if wÎ L(M )
w = s 1s 2 !s k
s1 s2 sk
M: q0 qf
s1 s2 sk
M¢:
{q0 } {q f ,!}
w Î L(M ¢)
A. Senthil - Professor/CSE 28
More generally, we will show that if in M:
(arbitrary string) v = a1a2 ! an
a1 a2 an
M: q0 qi qj ql qm
a1 a2 an
M¢:
{q0 } {qi ,!} {q j ,!} {ql ,!} {qm ,!}
A. Senthil - Professor/CSE 29
Proof by induction on |v|
Induction Basis: v = a1
a1
M: q0 qi
a1
M¢:
{q0 } {qi ,!}
A. Senthil - Professor/CSE 30
Induction hypothesis: 1 £| v |£ k
v = a1a2 ! ak
a1 a2 ak
M: q0 qi qj qc qd
a1 a2 ak
M¢:
{q0 } {qi ,!} {q j ,!} {qc ,!} {qd ,!}
A. Senthil - Professor/CSE 31
Induction Step: | v |= k + 1
v = a1a2 % ak ak +1 = v¢ak +1
$!#! "
v¢
a1 a2 ak
M: q0 qi qj qc qd
v¢
a1 a2 ak
M¢:
{q0 } {qi ,!} {q j ,!} {qc ,!} {qd ,!}
v¢
A. Senthil - Professor/CSE 32
Induction Step: | v |= k + 1
v = a1a2 % ak ak +1 = v¢ak +1
$!#! "
v¢
a1 a2 ak ak +1
M: q0 qi qj qc qd qe
v¢
a1 a2 ak ak +1
M¢:
{q0 } {qi ,!} {q j ,!} {qc ,!} {qd ,!} {qe ,!}
v¢
A. Senthil - Professor/CSE 33
Therefore if wÎ L(M )
w = s 1s 2 !s k
s1 s2 sk
M: q0 qf
s1 s2 sk
M¢:
{q0 } {q f ,!}
w Î L(M ¢)
A. Senthil - Professor/CSE 34
We have shown: L( M ) Í L( M ¢)
(proof is similar)
A. Senthil - Professor/CSE 35