COMP-330 Theory of Computation
Fall 2017 -- Prof. Claude Crépeau Lec. 4 : NFAs + Kleene’s
theorem
COMP 330 Fall 2017: Lectures Schedule
14. Context-free languages15. Pushdown automata16. Parsing17. The pumping lemma for CFLs18. Introduction to computability19. Models of computation Basic computability theory20. Reducibility, undecidability and Rice’s theorem21. Undecidable problems about CFGs22. Post Correspondence Problem23. Validity of FOL is RE / Gödel’s and Tarski’s thms24. Universality / The recursion theorem 25. Degrees of undecidability26. Introduction to complexity
1-2. Introduction 1.5. Some basic mathematics2-3. Deterministic finite automata +Closure properties,4. Nondeterministic finite automata5. Minimization+ Myhill-Nerode theorem 6. Determinization+Kleene’s theorem7. Regular Expressions+GNFA8. Regular Expressions and Languages9-10. The pumping lemma11. Duality12. Labelled transition systems13. MIDTERM
Regular Operations
Regular Operations
Regular Operations
Regular Operations : Kleene’s theorem
Stephen Kleene
Regular Operations : Kleene’s theorem
Regular Operations : Kleene’s theorem
Let MA=(QA,∑,δA,q0A,FA) be a DFA accepting LA and MB=(QB,∑,δB,q0B,FB) be a DFA accepting LB.
Consider MU=(QAxQB,∑,δU,(q0A,q0B),FU) where δU((q,q’),s) = ( δA(q,s), δB(q’,s) ) for all q,q’,s and FU = { (q,q’) | q∈FA or q’∈FB }.
LU = LA∪LB.
M1
q1q0
0 10
1
M2,2Example
q01
1
q02 q03
q11 q12 q13
0
011
1
10
MU
L(MU) = L(M1) ∪ L(M2,2)
M1 q
1q
0
01
01
M2,2 1
0
00
Regular Operations : Kleene’s theorem
(NFA)
(DFA)
Regular Operations : Kleene’s theorem (NFA)
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
N1
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
010110
q1
N1
Non-Deterministic Finite Automata
010110
0
q1
N1
Non-Deterministic Finite Automata
010110
1
q11 q2 q3ℰ
N1
Non-Deterministic Finite Automata
010110
0
q1 q30
N1
Non-Deterministic Finite Automata
010110
1
q11 q2 ℰ q3
1 q4
N1
Non-Deterministic Finite Automata
010110
1
q11 q2 ℰ q3
1
1
q4
N1
Non-Deterministic Finite Automata
010110
0
q10 q3
0
q4
N1
Nondeterministic Finite Automata
010110
q1 q3 q4
010110 ∈ LN₁ ⇔
{q1,q3,q4} ∩ F = {q4} ≠ ∅
N1
Definition of NFA
∑ℰ = ∑∪{ℰ} 𝓟(Q) = { S : S⊆Q }
Definition of NFA
Let N = (Q,∑,δ,q0,F) be a nondet. finite state automaton and let w=w1w2...wn (n≥0) be a string where each symbol wi∈∑.
N accepts w if ∃ m≥n, ∃ s0,s1,...,sm and ∃ y1y2...ym = w, with each yi ∈ ∑ℰ s.t. 1. s0 = q0 2. si+1 ∈ δ(si,yi+1) for i = 0 ... m-1, and 3. sm ∈ F
NFA-DFA equivalence
Regular Languages
1 1 1 1
1 1 1 1
NFAN2
DFAq{1}
q{1,2,3}q{1,2} q{1,2,4}
q{1,3,4}q{1,3}q{1,4}
q{1,2,3,4}
NFA-DFA equivalence
(without empty transitions)
Let N = (Q,∑,δ,q0,F) be an NFA (without empty transitions) accepting language A. We show a DFA M = (Q’,∑,δ’,q’0,F’) accepting A.
Q’ = 𝓟(Q) = { R | R⊆Q }
δ’(R,a) = { q ∈ Q | ∃r ∈ R, q ∈ δ(r,a) }
q’0 = {q0}
F’ = { R∈Q’ | R∩F≠∅ }
N2
q0001=q{1} q0111=q{1,2,3} q0110=q{2,3}q0000=q∅
q0011=q{1,2} q0010=q{2} q1011=q{1,2,4} q1010=q{2,4}
q0100=q{3} q1100=q{3,4}
q1001=q{1,4} q1000=q{4} q1110=q{2,3,4} q1111=q{1,2,3,4}
q1101=q{1,3,4}q0101=q{1,3}
qw₄w₃w₂w₁=qR : (wi=1 ⟺ i∈R)
1 1 1 1
1 1 1 1
NFAN2
DFAq{1}
q{1,2,3}q{1,2} q{1,2,4}
q{1,3,4}q{1,3}q{1,4}
q{1,2,3,4}
NFAN2
DFA
NFA-DFA equivalence (with empty transitions)
Let N = (Q,∑,δ,q0,F) be an NFA accepting language A. We construct a DFA M = (Q’,∑,δ’,q’0,F’) accepting A as well.
Q’ = 𝓟(Q) = { R | R⊆Q }
δ’(R,a) = { q ∈ Q | ∃r ∈ R, q ∈ E(δ(r,a)) }, ∀ a≠ℰ
q’0 = E(q0)
F’ = { R∈Q’ | R∩F≠∅ }
q{1} q{1,2,3} q{2,3}q∅
q{1,2} q{2} q{1,2,4} q{2,4}
q{3} q{3,4}
q{1,4} q{4} q{2,3,4} q{1,2,3,4}
q{1,3,4}q{1,3}
N1
0
1
1
q{1} q{1,2,3} q{2,3}q∅
q{1,2} q{2} q{1,2,4} q{2,4}
q{3} q{3,4}
q{1,4} q{4} q{2,3,4} q{1,2,3,4}
1
0
1
1q{1,3,4}
00 1
0
0q{1,3}
N1
0
1
1
q{1} q{1,2,3}
q{1,4} q{1,2,3,4}
1
0
1
1q{1,3,4}
00 1
0
0q{1,3}
N1
0
1
1
q{1} q{1,2,3} q{1,4}
q{1,2,3,4}
0
11
q{1,3,4}
0
0
00
q{1,3}1
1
N1
0
1
1
q{1} q{1,2,3} q{1,4}
q{1,2,3,4}
0
11
q{1,3,4}
0
0
00
q{1,3}1
1
010110
q1
N1
0
1
1
q{1} q{1,2,3} q{1,4}
q{1,2,3,4}
0
11
q{1,3,4}
0
0
00
q{1,3}1
1
010110
0
q1
N1
0
1
1
q{1} q{1,2,3} q{1,4}
q{1,2,3,4}
0
11
q{1,3,4}
0
0
00
q{1,3}1
1
010110
1
q11 q2 q3ℰ
N1
0
1
1
q{1} q{1,2,3} q{1,4}
q{1,2,3,4}
0
11
q{1,3,4}
0
0
00
q{1,3}1
1
010110
0
q1 q30
N1
0
1
1
q{1} q{1,2,3} q{1,4}
q{1,2,3,4}
0
11
q{1,3,4}
0
0
00
q{1,3}1
1
010110
1
q11 q2 ℰ q3
1
1
q4
N1
0
1
1
q{1} q{1,2,3} q{1,4}
q{1,2,3,4}
0
11
q{1,3,4}
0
0
00
q{1,3}1
1
010110
1
q11 q2 ℰ q3
1
1
q4
N1
0
1
1
q{1} q{1,2,3} q{1,4}
q{1,2,3,4}
0
11
q{1,3,4}
0
0
00
q{1,3}1
1
010110
0
q10 q3
0
q4
N1
Regular Operations : Kleene’s theorem (NFA)
Regular Operations : Kleene’s theorem
Let NA=(QA,∑,δA,q0A,FA) be a NFA accepting LA and NB=(QB,∑,δB,q0B,FB) be a NFA accepting LB (QA∩QB=∅).
Consider NU=( {q0}∪QA∪QB ,∑,δU,q0,FU) where
δU(q0,ℰ) = {q0A,q0B}, δU(q0,a) = ∅ for all a≠ℰ,
δU(q,a) = δX(q,a) for all q∈QX, X∈{A,B}, and all a, FU = FA∪FB.
LU = LA ∪ LB.
Kleene’s theorem
Example
q0
N2
N1
ℰ
ℰ
NU
A A A A
B B B B
Regular Operations : Kleene’s theorem
Let NA=(QA,∑,δA,q0A,FA) be a NFA accepting LA and NB=(QB,∑,δB,q0B,FB) be a NFA accepting LB (QA∩QB=∅).
Consider NC=( QA∪QB ,∑,δC,q0A,FB) where δC(q,a) = δB(q,a) for all q∈QB, all a, δC(q,a) = δA(q,a) for all q∈QA, all a≠ℰ, δC(q,ℰ) = δA(q,ℰ) for all q∈QA\FA, δC(q,ℰ) = δA(q,ℰ)∪{q0B} for all q∈FA.
LC = LA∘LB.
Kleene’s theorem
Example
N2
N1
ℰ
NC
A A A
B B B B
A
Regular Operations : Kleene’s theorem
Kleene’s theorem
Let NA=(QA,∑,δA,q0A,FA) be a NFA accepting LA.
Consider NS=( QA∪{q0} ,∑,δS,q0,FA∪{q0}) where δS(q0,ℰ) = q0A, and δS(q0,a) = ∅ for all a≠ℰ, δS(q,a) = δA(q,a) for all q∈QA\FA, all a, δs(q,ℰ) = δA(q,ℰ)∪{q0A} for all q∈FA, δs(q,a) = δA(q,a) for all q∈FA, all a≠ℰ.
LS = (LA)*.
Example
N1
ℰ
NS
ℰq0
COMP-330 Theory of Computation
Fall 2017 -- Prof. Claude Crépeau Lec. 4 : NFAs + Kleene’s
theorem