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

Mahi 3B

The document discusses the equivalence of nondeterministic finite automata (NFAs) and deterministic finite automata (DFAs). It proves that NFAs and DFAs have equal computational power and accept the same regular languages. The proof works in two steps: 1) any DFA is trivially an NFA, so languages accepted by DFAs are accepted by NFAs. 2) any NFA can be converted to an equivalent DFA using a procedure that constructs the DFA states as sets of NFA states. This conversion preserves the accepted language, so languages accepted by NFAs are also accepted by DFAs. Therefore, the classes of languages accepted by NFAs and DFAs are equal and constitute the

Uploaded by

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

Mahi 3B

The document discusses the equivalence of nondeterministic finite automata (NFAs) and deterministic finite automata (DFAs). It proves that NFAs and DFAs have equal computational power and accept the same regular languages. The proof works in two steps: 1) any DFA is trivially an NFA, so languages accepted by DFAs are accepted by NFAs. 2) any NFA can be converted to an equivalent DFA using a procedure that constructs the DFA states as sets of NFA states. This conversion preserves the accepted language, so languages accepted by NFAs are also accepted by DFAs. Therefore, the classes of languages accepted by NFAs and DFAs are equal and constitute the

Uploaded by

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

Equivalence of NFAs and DFAs

Linz: 2.3 Equivalence of Deterministic and Nondeterministic Finite


Accepters, page 58

79
Equivalence of Machines

For DFAs or NFAs:

Machine M1 is equivalent to machine M2

if L M1   L M 2 

80
Example
NFA M1
LM1   {10} * 0
q0 q1 0, 1 q2
1

DFA M2 0,1
LM 2   {10} * 0
q0 q1 1 q2
1
0 81
Since LM1   LM 2   10*

machines M1 and M2 are equivalent

0
NFA M1 q0 q1 0, 1 q2
1

0,1
0
DFA M2 q0 q1 1 q2
1
0 82
Equivalence of NFAs and DFAs

Question: NFAs = DFAs ?

Same power?
Accept the same languages?

83
Equivalence of NFAs and DFAs

Question: NFAs = DFAs ? YES!

Same power?
Accept the same languages?

84
We will prove:


Languages Languages
accepted accepted
by NFAs by DFAs

NFAs and DFAs have the same


computation power

85
Step 1

Languages Languages
accepted  accepted
by NFAs by DFAs

Proof: Every DFA is trivially an NFA

A language accepted by a DFA


is also accepted by an NFA 86
Step 2

Languages Languages
accepted  accepted
by NFAs by DFAs

Proof: Any NFA can be converted to an


equivalent DFA

A language accepted by an NFA


is also accepted by a DFA 87
NFA to DFA
NFA M a
q0 a q1  q2
b

DFA M
q0 

88
NFA to DFA
NFA M a
q0 a q1  q2
b

DFA M
q0  a
q1, q2 

89
NFA to DFA
NFA M a
q0 a q1  q2
b

DFA M
q0  a
q1, q2 
b


90
NFA to DFA
NFA M a
q0 a q1  q2
b

a
DFA M
q0  a
q1, q2 
b


91
NFA to DFA
NFA M a
q0 a q1  q2
b

a
DFA M b

q0  a
q1, q2 
b


92
NFA to DFA
NFA M a
q0 a q1  q2
b

a
DFA M b

q0  a
q1, q2 
b

 a, b
93
NFA to DFA
NFA M a LM   L(M )
q0 a q1  q2
b
a
DFA M b

q0  a
q1, q2 
b

 a, b
94
NFA to DFA: Remarks

We are given an NFA M

We want to convert it
to an equivalent DFA M 

With LM   L(M )


95
If the NFA has states

q0 , q1, q2 ,...

the DFA has states in the powerset

, q0 , q1, q1, q2 , q3 , q4 , q7 ,....

96
Procedure NFA to DFA

1. Initial state of NFA: q0

Initial state of DFA: q0 

97
Example
NFA M a
q0 a q1  q2
b

DFA M
q0 

98
Procedure NFA to DFA
2. For every DFA’s state {qi , q j ,..., qm }

Compute in the NFA


 * qi , a ,
 * q j , a ,  {qi , qj ,..., qm
}
...
Add transition to DFA
 {qi , q j ,..., qm }, a   {qi , qj ,..., qm
}
99
Exampe
NFA M a
q0 a q1  q2
b
 * (q0 , a)  {q1, q2}
DFA M 

q0  a
q1, q2 

 q0 , a   q1, q2 
100
Procedure NFA to DFA

Repeat Step 2 for all letters in alphabet,


until
no more transitions can be added.

101
Example
NFA M a
q0 a q1  q2
b

a
DFA M b

q0  a
q1, q2 
b

 a, b
102
Procedure NFA to DFA
3. For any DFA state {qi , q j ,..., qm }

If some qj is a final state in the NFA

4. If the NFA
accepts the empty
Then, {qi , q j ,..., qm } string, then the
vertex {q0} is also
is a final state in the DFA made a final vertex.

Linz 6th, Theorem


2.2, page 62.
103
Example
NFA M a
q0 a q1  q2 q1  F
b
a
DFA M b

q0  a
q1, q2 
b q1, q2  F 
 a, b
104
Theorem
Take NFA M

Apply procedure to obtain DFA M

Then M and M are equivalent :

LM   LM 
105
Finally
We have proven


Languages Languages
accepted accepted
by NFAs by DFAs

106
We have proven


Languages Languages
accepted accepted
by NFAs by DFAs

Regular Languages

107
We have proven


Languages Languages
accepted accepted
by NFAs by DFAs

Regular Languages Regular Languages

108
We have proven


Languages Languages
accepted accepted
by NFAs by DFAs

Regular Languages Regular Languages

Thus, NFAs accept the regular languages

109

You might also like