Sie sind auf Seite 1von 15

1

Formal Methods in Computer Science


CS1502
Equivalence of NFAs and DFAs
Patchrawat Uthaisombut
University of Pittsburgh
2
Goals
Equivalence of NFAs and DFAs
Closure properties of regular languages.
General idea of closure property
Closure of regular languages under regular
operations.
3

c
and P(Q)

c
= { c }
If = {a, b}
Then
c
= { a, b, c }

P(Q) = power set of Q
If Q = {A,B,C}
Then P(Q) = { {}, {A}, {B}, {C}, {A,B}, {A,C},
{B,C}, {A,B,C} }
Note, if Q has n members, then P(Q) has 2^n
members.
4
Definition of DFA
A (Deterministic) Finite Automaton
(FA, DFA) is a 5-tuple (Q,,o,q
0
,F) where
Q is a finite set of states
is a finite alphabet
o:QQ is the transition function
q
0
eQ is the start state
F_Q is the set of accept states
5
Definition of NFA
A Nondeterministic Finite Automaton
(NFA) is a 5-tuple (Q,,o,q
0
,F) where
Q is a finite set of states
is a finite alphabet
o:Q
c
P(Q) is the transition function
q
0
eQ is the start state
F_Q is the set of accept states
6
q1
q2 q3
1
0
0,1 c
q4 q5
c
M = (Q,,o,q
1
,F) where
Q = {q1,q2,q3,q4,q5}
= { 0, 1 }
o is given as the table
q1 is the start state
F={ q3, q5 }.

0 1 c
q
1
{ } { } {q
2
,q
4
}
q
2
{ } {q
3
} { }
q
3
{q
3
} {q
3
} { }
q
4
{q
5
} { } { }
q
5
{ } { } { }
o:Q
c
P(Q)
7
p
p q r
0
p r
1
p q r
0
p q
r
0
p q r
0,1
0 1, c
0100
8
DFAs vs. NFAs
Are DFAs more powerful than NFAs?
Is there a language L that is recognized by
some DFA but is not recognized by any NFA?
No. DFAs are special cases of NFAs.

Are NFAs more powerful than DFAs?
Unclear.
We will show that they are not.
9
p
p q r
0
p r
1
p q r
0
p q
r
0
p q r
0,1
0 1, c
0100
10
E(R)
E(R) = { q | q can be reached from R by traveling
along zero or more c transitions}




E( {q1} ) = ?
{ q1, q2, q3, q4 }
E( {q2, q4} ) = ?
{ q2, q3, q4 }
q1
q2 q3
c
0
1 c
q4 q5
c
11
Equivalence of NFAs and DFAs
Let N=(Q,E,o,q
0
,F) be an NFA
Construct a DFA M=(Q,E,o, q
0
,F) as follows
1. Q = P(Q)
2. for ReQ and aeE,
let o(R,a) = { q e Q | q e E(o(r,a)) for some r e R }.
3. q
0
= E( {q
0
} )
4. F = { ReQ | R contains an accept state of N }

We claim that L(M) = L(N).
12
Implications
Are NFAs more powerful than DFAs?
Is there a language L that is recognized by
some NFA but is not recognized by any
DFA?

We can use NFAs to study the question
If A and B are regular, is A . B regular?
13
Union: revisit
If A and B are regular, is A B regular?
Yes. We proved that by simulating 2
machines in parallel.
A new proof
Make use of the equivalence of DFAs and
NFAs.

14
Closure property
A set X and an operation y.
X is said to be closed under y if when we apply
operation y to any member of X, the result is still a
member of X.
Examples
The set of integers is closed under addition
The set of integers is not closed under division
The set of regular languages is closed under union.
Take any union of two regular languages and the result is still a
regular language.
15
Closure under regular operations
The class of regular languages is closed under
union.

The class of regular languages is closed under
concatenation.

The class of regular languages is closed under
star.

Proofs

Das könnte Ihnen auch gefallen