NFA to DFA Conversion Rabin and Scott (1959) Prasad L12NFA2DFA

Download Report

Transcript NFA to DFA Conversion Rabin and Scott (1959) Prasad L12NFA2DFA

NFA to DFA Conversion
Rabin and Scott (1959)
Prasad
L12NFA2DFA
1
Removing Nondeterminism
• By simulating all moves of an NFA-λ in
parallel using a DFA.
• λ-closure of a state is the set of states
reachable using only the λ-transitions.
Prasad
L12NFA2DFA
2
NFA-λ
p2
λ
a
p1
λ
q1
p3
λ
λ
q2
p5
a
p4
t ( q1, a )  { p1, p 2, p3, p 4, p5}
Prasad
L12NFA2DFA
3
q1   - closure ( q1)
q2   - closure ( q1)
p3   - closure ( p1)
 - closure (U{qi })

i
U - closure (q )
i
i
Prasad
L12NFA2DFA
4
Transition Function
t : Q    Powerset (Q )
t ( qi , a ) 
q j  -closure( qi )
t ( q1 , a ) 
Prasad
 - closure ( ( q
U

U - closure ( (q
q j { q1 , q 2 }
L12NFA2DFA
j
j
, a ))
, a ))
5
t ( q1 , a )   - closure ( ( q1 , a ))
  - closure ( ( q2 , a ))
t (q1, a)   - closure ( p1 )   - closure ( p4 )
t ( q1 , a )  { p1 , p2 , p3}  { p4 , p5}
Prasad
L12NFA2DFA
6
Equivalence Construction
• Given NFA-λ M, construct a DFA DM such
that L(M) = L(DM).
• Observe that
– A node of the DFA = Set of nodes of NFA-λ
– Transition of the DFA = Transition among set of
nodes of NFA- λ
Prasad
L12NFA2DFA
7
a
{q1,…,qn}
{p1,…,pm}
For every pi, there exists qj such that

 (q j ,  * a*)  pi
Prasad
L12NFA2DFA
8
Start state of DFA =
 - closure ({q0})
Final/Accepting state of DFA =
All subsets of states of NFA-λ
that contain an accepting state
of the NFA-λ
Dead state of DFA =
Prasad

L12NFA2DFA
9
Example
a
b
q1
a
q0
a+c*b*
λ
a
q2
c
Prasad
L12NFA2DFA
10
{q0}
a
{q0}
b
c
Prasad
{q0,q1,q2}

L12NFA2DFA
11
a
a
{q0}
{q0,q1,q2}
{q1}
c
b
c
b

{q1,q2}
a,b,c
Prasad
L12NFA2DFA
12
b
{q1}
a,c

c
b
{q1,q2}
Prasad
a
L12NFA2DFA
{q1}

13
Equivalent DFA
a
a
{q0}
{q0,q1,q2}
b
b,c

a,c
b
{q1}
c
c
{q1,q2}
b
a
a,b,c
Prasad
L12NFA2DFA
14