comp-330 theory of computation - mcgill...
TRANSCRIPT
![Page 1: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/1.jpg)
COMP-330 Theory of Computation
Fall 2017 -- Prof. Claude Crépeau Lec. 7 : Regular
Expressions & GNFA
![Page 2: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/2.jpg)
COMP 330 Fall 2012: 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 6. Determinization+Kleene’s theorem7. Regular Expressions+GNFA8. Regular Expressions and Languages
+ Myhill-Nerode theorem,9-10. The pumping lemma11. Duality12. Labelled transition systems13. MIDTERM
![Page 3: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/3.jpg)
Regular Expressions
![Page 4: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/4.jpg)
Regular Expressions
![Page 5: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/5.jpg)
1*(01+)*
![Page 6: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/6.jpg)
Regular Expressions vs Regular Languages
![Page 7: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/7.jpg)
Regular Expressions vs Regular Languages
![Page 8: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/8.jpg)
Regular Expressions vs Regular Languages
![Page 9: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/9.jpg)
Let RA generating LA.
If RA is a symbol “a” then use .If RA is “𝞮” then use .If RA is “∅” then use .If RA is R1 ∪ R2 then use Thm 1.45 and recursively use N1 and N2 s.t. L(N1) = L(R1) and L(N2) = L(R2).If RA is R1 ∘ R2 then use Thm 1.47 and recursively use N1 and N2 s.t. L(N1) = L(R1) and L(N2) = L(R2).If RA is R* then use Thm 1.49 and recursively use N s.t. L(N)=L(R).
Regular Expressions generate Reg. Languages
a
![Page 10: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/10.jpg)
Reg. Expression → NFA
Two examples
(ab∪a)*
(a∪b)*aba
![Page 11: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/11.jpg)
![Page 12: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/12.jpg)
![Page 13: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/13.jpg)
Automata recognize Regular Expressions
![Page 14: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/14.jpg)
Generalized NFA
![Page 15: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/15.jpg)
Example of GNFA
q1
q2
![Page 16: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/16.jpg)
Generalized NFA
![Page 17: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/17.jpg)
Generalized NFA
![Page 18: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/18.jpg)
Definition of GNFA
1. Q={qstart,q1,q2,qaccept}
2.∑={a,b}
3.δ is given as
4.qstart is the start state
5.qaccept is the (unique) accept state
q1
q2
δ q1 q2 qaccept
qstart ab* ∅ b
q1 aa a* ab∪ba
q2 (aa)* ab b*
![Page 19: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/19.jpg)
Let G = (Q,∑,δ,qstart,qaccept) be a generalized nondeterministic finite state automaton and let w=w1w2...wn (n≥0) be a string where each sub-string wi∈∑*.
G accepts w if ∃ s0,s1,...,sn s.t. 1. s0 = qstart 2. wi ∈ L( δ(si-1,si) ) for i = 1 ... n, and 3. sn = qaccept
Definition of GNFA
![Page 20: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/20.jpg)
Example of GNFA
q1
q2
abbbaaaababaaba
qstart
![Page 21: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/21.jpg)
Example of GNFA
q1
q2
abbbaaaababaaba ab*
![Page 22: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/22.jpg)
Example of GNFA
q1
q2
abbbaaaababaaba
a*
![Page 23: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/23.jpg)
Example of GNFA
q1
q2
abbbaaaababaaba
ab
![Page 24: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/24.jpg)
Example of GNFA
q1
q2
abbbaaaababaaba
ab
![Page 25: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/25.jpg)
Example of GNFA
q1
q2
abbbaaaababaaba
(aa)*
![Page 26: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/26.jpg)
Example of GNFA
q1
q2
abbbaaaababaaba
ab∪ba
qaccept
![Page 27: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/27.jpg)
DFA → GNFA → Reg. Exp.
![Page 28: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/28.jpg)
Example NFA→GNFA
N1
![Page 29: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/29.jpg)
Example NFA→GNFA
N1qstart
![Page 30: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/30.jpg)
Example NFA→GNFA
N1𝞮qstart
![Page 31: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/31.jpg)
Example NFA→GNFA
N1𝞮qstart
![Page 32: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/32.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
![Page 33: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/33.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
![Page 34: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/34.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
![Page 35: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/35.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
0∪1
![Page 36: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/36.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
∅
0∪1
![Page 37: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/37.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
0∪1
![Page 38: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/38.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
∅
0∪1
![Page 39: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/39.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
0∪1
![Page 40: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/40.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
0∪1
∅
![Page 41: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/41.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
0∪1
![Page 42: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/42.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
∅
0∪1
![Page 43: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/43.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
0∪1
![Page 44: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/44.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
0∪1
∅
![Page 45: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/45.jpg)
Example NFA→GNFA
N1𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
0∪1
![Page 46: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/46.jpg)
Example NFA→GNFA
N1
G1
𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
0∪1
![Page 47: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/47.jpg)
Example NFA→GNFA
N1
G1
𝞮qstart
𝞮
qacc
0∪1
0∪𝞮
∅
∅ ∅
0∪1
∅
∅
![Page 48: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/48.jpg)
DFA → GNFA → Reg. Exp.
![Page 49: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/49.jpg)
Ripping a state
![Page 50: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/50.jpg)
GNFA→ Reg. Exp.
![Page 51: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/51.jpg)
Ripping of a GNFA
q1
q2
Ripping q1
![Page 52: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/52.jpg)
Ripping of a GNFA
q2
Ripping q1
R4
R1 R2
R3
![Page 53: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/53.jpg)
Ripping of a GNFA
q2
Ripping q1
∅∪ab*(aa)*a*
![Page 54: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/54.jpg)
Ripping of a GNFA
q2
Ripping q1
∅∪ab*(aa)*a*
R4
R1 R2
R3
![Page 55: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/55.jpg)
Ripping of a GNFA
q2
Ripping q1
∅∪ab*(aa)*a*
b∪ab*(aa)*(ab∪ba)
![Page 56: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/56.jpg)
Ripping of a GNFA
q2
Ripping q1
∅∪ab*(aa)*a*
b∪ab*(aa)*(ab∪ba)
R4
R1
R2
R3
![Page 57: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/57.jpg)
Ripping of a GNFA
q2
Ripping q1
∅∪ab*(aa)*a*
b∪ab*(aa)*(ab∪ba)
ab∪(aa)*(aa)*a*
![Page 58: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/58.jpg)
Ripping of a GNFA
q2
Ripping q1
∅∪ab*(aa)*a*
b∪ab*(aa)*(ab∪ba)
ab∪(aa)*(aa)*a*R4
R2
R3
R1
![Page 59: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/59.jpg)
Ripping of a GNFA
q2
∅∪ab*(aa)*a*
b∪ab*(aa)*(ab∪ba)
ab∪(aa)*(aa)*a*b*∪(aa)*(aa)*(ab∪ba)
![Page 60: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/60.jpg)
Ripping of a GNFA
q2
∅∪ab*(aa)*a*
b∪ab*(aa)*(ab∪ba)
ab∪(aa)*(aa)*a*b*∪(aa)*(aa)*(ab∪ba)
![Page 61: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/61.jpg)
Ripping of a GNFA
q2
∅∪ab*(aa)*a*
b∪ab*(aa)*(ab∪ba)
Ripping q2ab∪(aa)*(aa)*a*b*∪(aa)*(aa)*(ab∪ba)
![Page 62: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/62.jpg)
Ripping of a GNFA
q2
∅∪ab*(aa)*a*
b∪ab*(aa)*(ab∪ba)
Ripping q2ab∪(aa)*(aa)*a*b*∪(aa)*(aa)*(ab∪ba)
R4
R1
R2
R3
![Page 63: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/63.jpg)
Ripping of a GNFA
q2(b∪ab*(aa)*(ab∪ba))
∪(∅∪ab*(aa)*a*)
(ab∪(aa)*(aa)*a*)*(b*∪(aa)*(aa)*(ab∪ba))
![Page 64: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/64.jpg)
GNFA → Reg. Expression
“equivalent” means L( CONVERT(G) ) = L(G)
![Page 65: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/65.jpg)
GNFA → Reg. Expression
Induction basis
Let G be a GNFA with exactly k=2 states. Because of the special form of our GNFA, the two states are the start and accept states. The regular expression on the transition from qstart to qaccept generates the language accepted by this GNFA.
![Page 66: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/66.jpg)
Induction step
Let G be a GNFA with exactly k>2 states. We assume for induction hypothesis that all GNFA G’ of k-1 states accept the laguage defined by the regular expression obtained via CONVERT, i.e. L(G’)=L(CONVERT(G’)).
Since k>2 then there exists at least one state qrip which is neither qstart nor qaccept.
GNFA → Reg. Exp.
![Page 67: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/67.jpg)
Induction step
Let G’ be, as in CONVERT, the GNFA obtained after ripping qrip from G.
Let w be a string accepted by G, w∈L(G). C o n s i d e r a n a c c e pt i n g s e q u e n c e qstart,q1,q2,...,qaccept for string w.
GNFA → Reg. Exp.
![Page 68: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/68.jpg)
If qrip is not a state of the sequence, then the very same exact sequence will accept w in G’ because its transitions R4 contain all those R4 in G (except for qrip) in a union with new possibilities related to ripping qrip.
GNFA → Reg. Exp.
![Page 69: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/69.jpg)
If qrip is a state of the sequence, then the same sequence (but with all qrip removed) will accept w in G’. That’s because any three elements in a row qi,qrip,qj (qi≠qrip≠qj) in G’s accepting sequence, will be processed identically through states qi,qj in G’. Remember that the transitions for qi,qj in G’ contain all those R1(R2)*R3 from G involving qrip in a union with older possibilities (R4). (we can deal with qi,qrip,...,qrip,qj similarly.)
GNFA → Reg. Exp.
![Page 70: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/70.jpg)
This proved “if w∈L(G) then w∈L(G’)”. We should also prove “if w∈L(G’) then w∈L(G)”.
Let w be a string accepted by G’, i.e. w∈L(G’). Consider an accepting sequence qstart,q1,q2,...,qaccept for string w. Consider any two consecutive states qi,qi+1. The same portion of w is processed in G in either part of the union, R1(R2)*R3 or R4, along the transition between qi and qi+1.
GNFA → Reg. Exp.
![Page 71: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/71.jpg)
If the portion of w is generated by R4 in G’ then it is also generated by R4 in G. If the portion of w is generated by R1(R2)*R3 in G’ then there exists an m such that it is generated by R1(R2)mR3 and it is also generated in G by R1, going through qrip m times via R2 and finally R3. Thus qi,qi+1 is replaced by qi,qrip,...,qrip,qi+1.
We conclude that if w∈L(G’) then w∈L(G).
GNFA → Reg. Exp.
![Page 72: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/72.jpg)
GNFA → Reg. Exp.
Combining both statements we get L(G’)=L(G).
By induction hypothesis L(G’)=L(CONVERT(G’)) becau se G’ conta ins k-1 state s. By construction, CONVERT(G)=CONVERT(G’). Therefore L(CONVERT(G))=L(CONVERT(G’))=L(G’)=L(G). QED
![Page 73: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-7.pdf · 2017-10-03 · COMP 330 Fall 2012: Lectures Schedule 14. Context-free languages](https://reader035.vdocument.in/reader035/viewer/2022062402/5e7a117a59b79e587f32b26b/html5/thumbnails/73.jpg)
COMP-330 Theory of Computation
Fall 2017 -- Prof. Claude Crépeau Lec. 7 : Regular
Expressions & GNFA