Professional Documents
Culture Documents
Lect 7
Lect 7
DFA
• For every string x, there is a unique path
from initial state and associated with x.
• [ε] = {s}
• Suppose [x] is known. How to get [xa] for
a in Σ?
From [x] to [xa]
a
• [xa] = { p | there exists a path q path
p for
some q in [x] }
= { p | there exists q in [x],
a
q edgep }
= U δ(q,a)
q in [x]
Construction of M’
• F’ = {[x] | x in L(M)}
= {[x] | [x] ∩ F ≠ Ǿ }
Example 1
• Construct DFA to accept 00(0+1)*
0
0, 1
0 0 0
q s p 0
s p q
1
1
1 Ǿ
0,1
Example 2
• Design DFA to accept (0+1)*11
0
0 1
0 1 s 1 1
1 s q
s p s p
p q
0
1
Example 3
• Design DFA to accept 00(0+1)*11
0
0 0 1 1
s p q r t
Ǿ 0,1 1
1 1 0 1
1 q 1 q
s 0 0 r
p q
r t
0
0
Example 4
• Construct DFA M for L(M)=ε.
s Is this a DFA?
0,1
0
s Ǿ
1
Example 5
• Construct DFA M for L(M)=Ǿ.
s Is it a DFA?
0
s Ǿ 0,1
0,1
1
Construction of M’
• For q in Q, define
ε
ε-closure(q) = {p | there exists a path q pathp}
• [ε] = {q | there is a path s ε q}
path
= ε-closure(s)
• Suppose [x] is known. How to get [xa] for
a in Σ?
From [x] to [xa]
a
• [xa] = { p | there exists a path q path p for
some q in [x] }
= { p | there exists q in [x],
a ε
q edger pathp }
= { p | for some q in [x] and r in δ(q,a),
p in ε-closure(r) }
= Uq in [x]U r in δ(q,a) ε-closure(r)
Construction of M’
• F’ = {[x] | x in L(M)}
= {[x] | [x] ∩ F ≠ Ǿ }
Example 6
• Construct DFA M for L(M)=(0+1)*.
0,1
ε ε
s p q
0,1
0,1
s 0 p
p
q q
1
Example 7
• Convert the following NFA to DFA.
q 0
0 0
s
0 ε ε 1 s 0 q
r r s
ε p p
p r
1
1 1
0 0
q, r, p
1
0,1 0 0 0 0
0 1 1 1 1
s a b c d e
0 0
s s,a s,a,b 0 s,a,b,c 0 s,a,b,c,d 0 s,a,b,c,d,e
1
s,b 5
1 How many states? 2 =32
s,c
4
1 How many final states? 2 = 16
s,d
1
s,e Can we simplify it? No, it is minimum!