comp-330 theory of computation - mcgill...
TRANSCRIPT
![Page 1: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/1.jpg)
COMP-330 Theory of Computation
Fall 2017 -- Prof. Claude Crépeau Lec. 4 : NFAs + Kleene’s
theorem
![Page 2: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/2.jpg)
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
![Page 3: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/3.jpg)
Regular Operations
![Page 4: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/4.jpg)
Regular Operations
![Page 5: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/5.jpg)
Regular Operations
![Page 6: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/6.jpg)
Regular Operations : Kleene’s theorem
Stephen Kleene
![Page 7: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/7.jpg)
Regular Operations : Kleene’s theorem
![Page 8: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/8.jpg)
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.
![Page 9: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/9.jpg)
M1
q1q0
0 10
1
M2,2Example
![Page 10: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/10.jpg)
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
![Page 11: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/11.jpg)
Regular Operations : Kleene’s theorem
(NFA)
(DFA)
![Page 12: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/12.jpg)
Regular Operations : Kleene’s theorem (NFA)
![Page 13: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/13.jpg)
Non-Deterministic Finite Automata
![Page 14: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/14.jpg)
Non-Deterministic Finite Automata
N1
![Page 15: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/15.jpg)
Non-Deterministic Finite Automata
![Page 16: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/16.jpg)
Non-Deterministic Finite Automata
010110
q1
N1
![Page 17: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/17.jpg)
Non-Deterministic Finite Automata
010110
0
q1
N1
![Page 18: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/18.jpg)
Non-Deterministic Finite Automata
010110
1
q11 q2 q3ℰ
N1
![Page 19: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/19.jpg)
Non-Deterministic Finite Automata
010110
0
q1 q30
N1
![Page 20: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/20.jpg)
Non-Deterministic Finite Automata
010110
1
q11 q2 ℰ q3
1 q4
N1
![Page 21: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/21.jpg)
Non-Deterministic Finite Automata
010110
1
q11 q2 ℰ q3
1
1
q4
N1
![Page 22: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/22.jpg)
Non-Deterministic Finite Automata
010110
0
q10 q3
0
q4
N1
![Page 23: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/23.jpg)
Nondeterministic Finite Automata
010110
q1 q3 q4
010110 ∈ LN₁ ⇔
{q1,q3,q4} ∩ F = {q4} ≠ ∅
N1
![Page 24: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/24.jpg)
Definition of NFA
∑ℰ = ∑∪{ℰ} 𝓟(Q) = { S : S⊆Q }
![Page 25: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/25.jpg)
![Page 26: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/26.jpg)
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
![Page 27: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/27.jpg)
NFA-DFA equivalence
![Page 28: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/28.jpg)
Regular Languages
![Page 29: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/29.jpg)
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}
![Page 30: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/30.jpg)
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≠∅ }
![Page 31: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/31.jpg)
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)
![Page 32: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/32.jpg)
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}
![Page 33: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/33.jpg)
NFAN2
DFA
![Page 34: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/34.jpg)
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≠∅ }
![Page 35: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/35.jpg)
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
![Page 36: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/36.jpg)
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
![Page 37: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/37.jpg)
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
![Page 38: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/38.jpg)
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
![Page 39: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/39.jpg)
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
![Page 40: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/40.jpg)
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
![Page 41: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/41.jpg)
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
![Page 42: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/42.jpg)
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
![Page 43: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/43.jpg)
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
![Page 44: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/44.jpg)
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
![Page 45: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/45.jpg)
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
![Page 46: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/46.jpg)
Regular Operations : Kleene’s theorem (NFA)
![Page 47: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/47.jpg)
Regular Operations : Kleene’s theorem
![Page 48: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/48.jpg)
![Page 49: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/49.jpg)
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
![Page 50: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/50.jpg)
Example
q0
N2
N1
ℰ
ℰ
NU
A A A A
B B B B
![Page 51: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/51.jpg)
Regular Operations : Kleene’s theorem
![Page 52: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/52.jpg)
![Page 53: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/53.jpg)
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
![Page 54: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/54.jpg)
Example
N2
N1
ℰ
NC
A A A
B B B B
A
![Page 55: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/55.jpg)
Regular Operations : Kleene’s theorem
![Page 56: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/56.jpg)
![Page 57: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/57.jpg)
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)*.
![Page 58: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/58.jpg)
Example
N1
ℰ
NS
ℰq0
![Page 59: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-4.pdf · 2017. 9. 14. · COMP 330 Fall 2017: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022071115/5feffb5efda7034eee022238/html5/thumbnails/59.jpg)
COMP-330 Theory of Computation
Fall 2017 -- Prof. Claude Crépeau Lec. 4 : NFAs + Kleene’s
theorem