Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

CS411-2015F-05 Deterministic Finite Automata vs.

Non-Deterministic Finite Automata 1

05-0: YANFAE1

• All strings over {a,b} that begin or end with aa

1 Yet Another NFA Example 05-1: YANFAE1

• All strings over {a,b} that begin or end with aa

a,b
a a
0 1 2

a,b

a a
3 4 5

a,b

1 Yet Another NFA Example 05-2: NFA → DFA

• Can we create a DFA for the same langauge?


• All strings over {a,b} that begin or end with aa

05-3: NFA → DFA

• Can we create a DFA for the same langauge?


• All strings over {a,b} that begin or end with aa
CS411-2015F-05 Deterministic Finite Automata vs. Non-Deterministic Finite Automata 2

a,b

0 a 1 a 2

b b a
b
a a
3 4 5
b
b
05-4: LN F A vs LDF A

• What is the relationship between LN F A and LDF A ?


• LDF A ⊆ LN F A
• Why?

05-5: LN F A vs LDF A

• What is the relationship between LN F A and LDF A ?


• LDF A ⊆ LN F A
• Every DFA is also an NFA

05-6: LN F A vs LDF A

• What is the relationship between LN F A and LDF A ?


• LDF A ⊂ LN F A ?
• LDF A ⊆ LN F A ∧ LN F A ⊆ LN F A (LN F A = LDF A )?
• Given any NFA M , can we create a DFA M ′ such that L[M ] = L[M ′ ]?

05-7: LN F A vs LDF A

• What is the relationship between LN F A and LDF A ?


• LDF A ⊆ LN F A ∧ LN F A ⊆ LN F A (LN F A = LDF A )
• Given any NFA M , we can create a DFA M ′ such that L[M ] = L[M ′ ]

05-8: NFA → DFA

• NFA for all strings over {a,b} containing aba

a b a
0 1 2 3

a,b a,b

• Trace abab
CS411-2015F-05 Deterministic Finite Automata vs. Non-Deterministic Finite Automata 3

05-9: NFA → DFA

• NFA for all strings over {a,b} containing aba


a b a
0 1 2 3

a,b a,b

• Trace abab
q0, abab q0, bab q0, ab q0, b q0, ε Reject

q1, bab q2, ab q1, b q2, ε Reject

q3, b q3, ε Accept


05-10: NFA → DFA

• NFA for all strings over {a,b} containing aba


a b a
0 1 2 3

a,b a,b

• Trace abab
a b a b
q0 q0 q0 q0 q0 Reject
a a
b b
q1 q2 q1 q2 Reject
a
b
q3 q3 Accept
05-11: NFA → DFA

• NFA for all strings over {a,b} containing aba


a b a
0 1 2 3

a,b a,b

• Trace abab
a b a b
q0 q0 q0 q0 q0 Reject
a a
b b
q1 q2 q1 q2 Reject
a
b
q3 q3 Accept

05-12: NFA → DFA


CS411-2015F-05 Deterministic Finite Automata vs. Non-Deterministic Finite Automata 4

• NFA for all strings over {a,b} containing aba

a b a
0 1 2 3

a,b a,b

• Trace abab

q0 q0
q0 q0
a b a b
q0 q1 q2
q1 q2
q3 q3

05-13: NFA → DFA

• NFA for all strings over {a,b} containing aba

a b a
0 1 2 3

a,b a,b

• Build Equivalent DFA

05-14: NFA → DFA

• NFA for all strings over {a,b} containing aba

a b a
0 1 2 3

a,b a,b

• Build Equivalent DFA

b a

b b
a b a
0 0,1 0,2 0,1,3 0,2,3 0,3
a

b a
a b

05-15: NFA → DFA

• What about ǫ-transitions?


CS411-2015F-05 Deterministic Finite Automata vs. Non-Deterministic Finite Automata 5

a b
0 1 2
ε

a a b
3 4 5 6

ε
05-16: NFA → DFA

• What about ǫ-transitions?


ε

0 a 1 b 2

3 a 4 a 5 b 6

a {0,2,3}
b
b
a b
{0,3} {1,4} {} a,b
a
a b

{5} b {0,6,3}
a

05-17: NFA → DFA

• Example 6= Proof!
• Need to show, given any NFA M , we can create a DFA M ′ such that L[M ] = L[M ′ ]
• Constructive Proof

05-18: Proof: LN F A ⊆ LDF A

• Given NFA M = (K, Σ, ∆, s, F )


• Create DFA M ′ = (K ′ , Σ′ , δ ′ , s′ , F ′ )
• Such that L[M ′ ] = L[M ]

05-19: Proof: LN F A ⊆ LDF A

• NFA M = (K, Σ, ∆, s, F )
• DFA M ′ = (K ′ , Σ′ , δ ′ , s′ , F ′ )
CS411-2015F-05 Deterministic Finite Automata vs. Non-Deterministic Finite Automata 6

• K′ =
• Σ′ =
• δ′ =
• s′ =
• F′ =

05-20: Proof: LN F A ⊆ LDF A


• NFA M = (K, Σ, ∆, s, F )
• DFA M ′ = (K ′ , Σ′ , δ ′ , s′ , F ′ )
• K ′ = 2K
• Σ′ = Σ
• δ ′ = {((q1 , a), q2 ) : q1 ∈ K ′ , a ∈ Σ,
q2 = ǫ-closure ({q : (q3 ∈ q1 ) ∧ ((q3 , a), q) ∈ ∆})
• s′ = ǫ-closure(s)
• F ′ = {Q : Q ∈ 2K ∧ Q ∩ F 6= ∅}
05-21: Example: LN F A ⊆ LDF A
a a
0 1 2

a,b
• K = {q0 , q1 , q2 }
• Σ = {a, b}
• ∆ = ((q0 , a), q0 ), ((q0 , a), q1 ), ((q0 , b), q0 ), ((q1 , a), q2 )}
• s = q0
• F = {q2 }
05-22: Example: LN F A ⊆ LDF A

• K ′ = {{}, {q0 }, {q1 }, {q2 }, {q0 , q1 }, {q0 , q2 }, {q1 , q2 }, {q0 , q1 , q2 }}


• Σ′ = {a, b}
• δ ′ = {(({}, a), {}), (({}, b), {}), (({q0 }, a), {q0 , q1 }),
(({q0 }, b), {q0 }), (({q1 }, a), {q2 }), (({q1 }, b), {}),
(({q2 }, a), {}), (({q2 }, b), {}),
(({q0 , q1 }, a), {q0 , q1 , q2 }), (({q0 , q1 }, b), {q0 }),
(({q0 , q2 }, a), {q0 , q1 }), (({q0 , q2 }, b), {q0 }),
(({q1 , q2 }, a), {q2 }), (({q1 , q2 }, b), {}),
(({q0 , q1 , q2 }, a), {q0 , q1 , q2 }), (({q0 , q1 , q2 }, b), {q0 })
• s′ = {q0 }
• F ′ = {{q2 }, {q0 , q2 }, {q1 , q2 }, {q0 , q1 , q2 }}

05-23: Example: LN F A ⊆ LDF A


CS411-2015F-05 Deterministic Finite Automata vs. Non-Deterministic Finite Automata 7

a,b

{}

b b a,b

{0} {1} a {2}

b a a b
b
b
{0,1} a {0,2} {1,2}
a

{0,1,2}

You might also like