COMP-330 Theory of Computation - McGill...
Transcript of COMP-330 Theory of Computation - McGill...
![Page 1: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/1.jpg)
COMP-330 Theory of Computation
Fall 2017 -- Prof. Claude Crépeau Lec. 8 : Pumping Lemma & NON-Reg. Languages
![Page 2: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/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 6. Determinization+Kleene’s theorem7. Regular Expressions+GNFA8. The pumping lemma9-10. Regular Expressions and Languages
+ Myhill-Nerode theorem,11. Duality12. Labelled transition systems13. MIDTERM
![Page 3: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/3.jpg)
DFA → GNFA → Reg. Exp.
N+2N N+1
. . .
![Page 4: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/4.jpg)
DFA → GNFA → Reg. Exp.
Two examples
![Page 5: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/5.jpg)
DFA → GNFA → Reg. Exp.
![Page 6: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/6.jpg)
DFA → GNFA → Reg. Exp.
![Page 7: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/7.jpg)
DFA → GNFA → Reg. Exp.
![Page 8: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/8.jpg)
DFA → GNFA → Reg. Exp.
![Page 9: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/9.jpg)
DFA → GNFA → Reg. Exp.
![Page 10: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/10.jpg)
DFA → GNFA → Reg. Exp.
![Page 11: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/11.jpg)
DFA → GNFA → Reg. Exp.
![Page 12: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/12.jpg)
q0
𝟘
𝟙
𝟚
𝟘
𝟙
𝟚 q1
q2
𝟙 𝟚
𝟘𝟘=0U3U6U9, 𝟙=1U4U7, 𝟚=2U5U8
Multiples of 3 (base 10)
![Page 13: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/13.jpg)
q0𝟘𝟙
𝟚
𝟘
𝟙
𝟚q1
q2
𝟙 𝟚
𝟘
qS
qA
𝟙
𝟛𝟚
𝟘
𝞮∅
∅
𝟘=0U𝟛, 𝟛=3U6U9, 𝟙=1U4U7, 𝟚=2U5U8
Multiples of 3 (base 10)
![Page 14: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/14.jpg)
𝟘U𝟚𝟘*𝟙
q1
q2
𝟙U𝟚𝟘*𝟚 𝟚U𝟙𝟘*𝟙
𝟘U𝟙𝟘*𝟚
qS
qA
𝟙U𝟛𝟘*𝟙
𝟚U𝟛𝟘*𝟚
𝟘U𝟛𝟘*
𝟚𝟘*
𝟙𝟘*
𝟘=0U𝟛, 𝟛=3U6U9, 𝟙=1U4U7, 𝟚=2U5U8
Multiples of 3 (base 10)
![Page 15: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/15.jpg)
q2
𝟘U𝟙𝟘*𝟚U(𝟚U𝟙𝟘*𝟙)(𝟘U𝟚𝟘*𝟙)*(𝟙U𝟚𝟘*𝟚)
qS
qA
𝟚U𝟛𝟘*𝟚U(𝟙U𝟛𝟘*𝟙)(𝟘U𝟚𝟘*𝟙)*(𝟙U𝟚𝟘*𝟚)
𝟘U𝟛𝟘*U(𝟙U𝟛𝟘*𝟙)(𝟘U𝟚𝟘*𝟙)*𝟚𝟘*
𝟙𝟘*U(𝟚U𝟙𝟘*𝟙)(𝟘U𝟚𝟘*𝟙)*𝟚𝟘*
𝟘=0U𝟛, 𝟛=3U6U9, 𝟙=1U4U7, 𝟚=2U5U8
Multiples of 3 (base 10)
![Page 16: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/16.jpg)
qS
qA
𝟘=0U𝟛, 𝟛=3U6U9, 𝟙=1U4U7, 𝟚=2U5U8
𝟘U𝟛𝟘*U(𝟙U𝟛𝟘*𝟙)(𝟘U𝟚𝟘*𝟙)*𝟚𝟘* U[𝟚U𝟛𝟘*𝟚 U (𝟙U𝟛𝟘*𝟙)(𝟘U𝟚𝟘*𝟙)*(𝟙U𝟚𝟘*𝟚)][𝟘U𝟙𝟘*𝟚 U (𝟚U𝟙𝟘*𝟙)(𝟘U𝟚𝟘*𝟙)*(𝟙U𝟚𝟘*𝟚)]*[𝟙𝟘* U (𝟚U𝟙𝟘*𝟙)(𝟘U𝟚𝟘*𝟙)*𝟚𝟘*]
Multiples of 3 (base 10)
![Page 17: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/17.jpg)
𝟛 = 3U6U9,𝟘 = 0U𝟛, 𝟙 = 1U4U7,𝟚 = 2U5U8
𝟘 U 𝟛𝟘* U(𝟙U𝟛𝟘*𝟙) (𝟘U𝟚𝟘*𝟙)* 𝟚𝟘* U[𝟚 U 𝟛𝟘*𝟚 U (𝟙U𝟛𝟘*𝟙) (𝟘U𝟚𝟘*𝟙)* (𝟙U𝟚𝟘*𝟚)] [𝟘 U 𝟙𝟘*𝟚 U (𝟚U𝟙𝟘*𝟙) (𝟘U𝟚𝟘*𝟙)* (𝟙U𝟚𝟘*𝟚)]* [𝟙𝟘* U (𝟚U𝟙𝟘*𝟙) (𝟘U𝟚𝟘*𝟙)* 𝟚𝟘*]
Multiples of 3 (base 10)
![Page 18: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/18.jpg)
Regular and non-Regular Languages
![Page 19: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/19.jpg)
footnote 3 page 46:
Let MA=(QA,∑,δA,q0A,FA) be a DFA accepting LAand 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
andFU = { (q,q’) | q∈FA or q’∈FB }.
LU = LA∪LB.
We can also write FU = (FA × QB) ∪ (QA × FB).(Not the same as FA × FB.)
FA × FB would yield the intersection (and notthe union) of LA and LB. This proves that theclass of regular languages is also closedunder intersection.
footnote 3 page 46:
![Page 20: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/20.jpg)
NON-Regular Languages
B = { 0n1n | n≥0 }
C = { w | w contains an equal number of 0’s and 1’s }
D = { w | w contains an equal number of occurrences of 01 and 10 as sub-strings }
![Page 21: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/21.jpg)
NON-Regular Languages
B = { 0n1n | n≥0 }
C = { w | w contains an equal number of 0’s and 1’s }
D = { w | w contains an equal number of occurrences of 01 and 10 as sub-strings }
NON-Reg
ular
NON-Reg
ular
Regular
![Page 22: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/22.jpg)
Computability TheoryAll languages
languageswe can describe
RegularLanguages
![Page 23: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/23.jpg)
NON-Regular Languages
Theorem: Some languages are not regular.Proof idea: all regular languages have certain properties. Some languages provably do not have one of these properties.
![Page 24: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/24.jpg)
All languages
Computability Theory
RegularLanguages
NON-Regular Languagesvia Pumping Lemma
NON-RegularLanguages
via Reductions
languageswe can describe
![Page 25: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/25.jpg)
ReductionsIf C is regular then so is B.
Proof: Regular laguages are closed under intersection (see footnote 3 page 46). Define A = L(0*1*). Obviously A is regular. If C was regular then so would C∩A = B. QED
If B is NON-regular then so is C.
B = { 0n1n | n≥0 }
C = { w | w contains an equal number of 0’s and 1’s }
![Page 26: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/26.jpg)
Reductions
If A is regular then so is A’.
Regular laguages are closed under complement (see ex. 1.14), intersection, union, concatenation and star. If there exists R, a regular language, such that either AC=A’, A*=A’, A∩R=A’, A∪R=A’, A∘R=A’ or any combinations of these operations then A’ is regular as long as A is.
If A’ is NON-regular then so is A.
![Page 27: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/27.jpg)
Simple Reductions
If A* is NON-regular then so is A.
If A is NON-regular then so is AC.
If A is NON-regular then so is AR.
![Page 28: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/28.jpg)
Complex Reductions
Let A’= (A∪R)∩(AC∪R’) (R,R’ regular)
Let A’= ((AC∩R)∪(A*∩R’))∘R’’ (R,R’,R’’ regular)
Let A’= (A∘R)∩(AC∘R’) (R,R’ regular)
If A’ is NON-regular then so is A.
![Page 29: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/29.jpg)
NON-Regular Languages
Theorem: Some languages are not regular.Proof idea: all regular languages have certain properties. Some languages provably do not have one of these properties.
Example: A property of all regular languages= the Pumping Lemma.
![Page 30: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/30.jpg)
NON-Regular Languages
Application: any language that does not satisfy the pumping lemma is non-regular.
Note however that some non-regular languages DO satisfy the Pumping Lemma...
![Page 31: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/31.jpg)
Pumping Lemma
Yehoshua Bar-Hillel Eli ShamirMicha A. Perles
![Page 32: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/32.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
q1
q10q2 q9
q13q6q5
q15
xyz = 101101110
![Page 33: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/33.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
1
xyz = 101101110
q1
q10q2 q9
q13q6q5
q15
![Page 34: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/34.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
0
xyz = 101101110
q1
q10q2 q9
q13q6q5
q15
![Page 35: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/35.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1
q1
q10q2 q9
q13q6q5
q15
![Page 36: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/36.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1
q1
q10q2 q9
q13q6q5
q15
![Page 37: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/37.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
0
q1
q10q2 q9
q13q6q5
q15
![Page 38: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/38.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1q1
q10q2 q9
q13q6q5
q15
![Page 39: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/39.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1
q1
q10q2 q9
q13q6q5
q15
![Page 40: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/40.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1
q1
q10q2 q9
q13q6q5
q15
![Page 41: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/41.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
0
q1
q10q2 q9
q13q6q5
q15
![Page 42: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/42.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
q1
q10q2 q9
q13q6q5
q15
![Page 43: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/43.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1
0
1
q1
q10q2 q9
q13q6q5
q15
101 0
11
![Page 44: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/44.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xz = 101110
q1
q10q2 q9
q13q6q5
q15
101 0
11
![Page 45: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/45.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyyz = 101101101110
q1
q10q2 q9
q13q6q5
q15
101 0
1
1
0
1
1
0
1 1
![Page 46: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/46.jpg)
Pumping Lemma
1 1 1 1
1 1 1 1
xyyyz = 101101101101110
1
0
1
q1
q10q2 q9
q13q6q5
q15
101 0
11
1
0
1
1
0
1
![Page 47: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/47.jpg)
Pumping LemmaIf |xyz|>number-of-states then q9 exists...
![Page 48: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/48.jpg)
Pumping Lemma
Proof: Let M be an automaton accepting A. Let n be the number of states of M. Consider setting p=n+1 as the pumping length. By the fact that p>n, any sequence of states s0...sm accepting a string w of length m≥p must contain two identical states si=sj with j>i. Let j be the least index so that sj=si for some i<j as above.
![Page 49: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/49.jpg)
Pumping Lemma
Define x to be the string digested by M from s0 to si, y be the string digested by M from si to sj and z be the string digested by M from sj to sm.
Since j>i we have |y|>0 (2.).
Because our choice of y produces a closed loop it is clear that zero, one, or many repetitions of y will make no difference to being a member of A or not (1.).
![Page 50: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/50.jpg)
Pumping Lemma
Define x to be the string digested by M from s0 to si, y be the string digested by M from si to sj and z be the string digested by M from sj to sm.
We obtain:s0 x1 s1 x2 s2...si-1 xi si y1 si+1 y2 si+2...sj-1 yj-i sj z1... where all states upto sj-1 are disctinct by the assumptions above. Thus |xy| = i+j-i = j ≤ p (3.). QED
![Page 51: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/51.jpg)
Application of the Pumping Lemma
B = { 0n1n | n≥0 } is NON-Regular.
Assume B is regular. Then by the pumping Lemma there exists a pumping length p with properties 1., 2. and 3. satisfied. Take n=p and set w = 0p1p∈B. Then by 3. xy contains only zeros. Therefore if we pump even once to obtain w’ = xyyz = 0q1p it will contain more zeros than ones (q>p) : a string w’ not in B. Thus B is non-regular.
![Page 52: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/52.jpg)
Application of the Pumping Lemma
F = { ww | w∈∑* } is NON-Regular.
Assume F is regular. Then by the pumping Lemma there exists a pumping length p with properties 1., 2. and 3. satisfied. Take w=0p10p1∈F. Then by 3. xy contains only zeros. Therefore if we pump even once to obtain w’=xyyz it will contain more zeros than ones : a string w’ not in F. Thus F is non-regular.
![Page 53: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/53.jpg)
Application of the Pumping Lemma
E = { 0i1j | i>j≥0 } is NON-Regular.
Assume E is regular. Then by the pumping Lemma there exists a pumping length p with properties 1., 2. and 3. satisfied. Take i=p+1, j=p and obtain w=0p+11p∈E. Then by 3. xy contains only zeros.
![Page 54: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/54.jpg)
Application of the Pumping Lemma
E = { 0i1j | i>j≥0 } is NON-Regular.
Therefore if we pump up to obtain w’=xyyz=0k1j , k>i it will contain even more zeros than ones, which is still a string w’ in E. If we pump down however w’’=xz, the number of zeros will become smaller or equal to the number of ones: a w’’ not in E. Thus E is non-regular.
![Page 55: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/55.jpg)
Application (?) of the Pumping Lemma
c. The Pumping Lemma says: if A is regular then 1.,2. and 3. are satisfied. It does not say: if A is not regular then 1., 2. or 3. is not satisfied... We can only conclude the opposite: if 1., 2. or 3. is not satisfied then A is not regular...
![Page 56: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/56.jpg)
Application of the Pumping Lemma
D = { 1n² | n≥0 } is NON-Regular.
Assume D is regular. Then by the pumping Lemma there exists a pumping length p with properties 1., 2. and 3. satisfied. Take n=p and obtain w=1p². Let i=|y|≤p. If we pump up we get w’’=xyyz=1p²+i. Is it possible that both p² and p²+i be perfect squares ? No! The next square after p is (p+1)² = p²+2p+1 > p²+p+1 > p²+i proving that w’’ is not in D. So D is non-regular.
![Page 57: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/57.jpg)
All languages
Computability Theory
Decidable Languages
Context-freeLanguages
RegularLanguages
Languages we can describe
NON-Regular Languagesvia Pumping Lemma
NON-RegularLanguages
via Reductions
![Page 58: COMP-330 Theory of Computation - McGill Universitycrypto.cs.mcgill.ca/~crepeau/COMP330/LECTURE-8.pdfCOMP 330 Fall 2017: Lectures Schedule 14. Context-free languages 15. Pushdown automata](https://reader035.fdocuments.us/reader035/viewer/2022081407/60504e8e9cf2da78d43e0d56/html5/thumbnails/58.jpg)
COMP-330 Theory of Computation
Fall 2017 -- Prof. Claude Crépeau Lec. 8 : Pumping Lemma & NON-Reg. Languages