Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
COMP-330 Theory of Computation
Fall 2017 -- Prof. Claude Crépeau Lec. 8 : Pumping Lemma & NON-Reg. Languages
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
DFA → GNFA → Reg. Exp.
N+2N N+1
. . .
DFA → GNFA → Reg. Exp.
Two examples
DFA → GNFA → Reg. Exp.
DFA → GNFA → Reg. Exp.
DFA → GNFA → Reg. Exp.
DFA → GNFA → Reg. Exp.
DFA → GNFA → Reg. Exp.
DFA → GNFA → Reg. Exp.
DFA → GNFA → Reg. Exp.
q0
𝟘
𝟙
𝟚
𝟘
𝟙
𝟚 q1
q2
𝟙 𝟚
𝟘𝟘=0U3U6U9, 𝟙=1U4U7, 𝟚=2U5U8
Multiples of 3 (base 10)
q0𝟘𝟙
𝟚
𝟘
𝟙
𝟚q1
q2
𝟙 𝟚
𝟘
qS
qA
𝟙
𝟛𝟚
𝟘
𝞮∅
∅
𝟘=0U𝟛, 𝟛=3U6U9, 𝟙=1U4U7, 𝟚=2U5U8
Multiples of 3 (base 10)
𝟘U𝟚𝟘*𝟙
q1
q2
𝟙U𝟚𝟘*𝟚 𝟚U𝟙𝟘*𝟙
𝟘U𝟙𝟘*𝟚
qS
qA
𝟙U𝟛𝟘*𝟙
𝟚U𝟛𝟘*𝟚
𝟘U𝟛𝟘*
𝟚𝟘*
𝟙𝟘*
𝟘=0U𝟛, 𝟛=3U6U9, 𝟙=1U4U7, 𝟚=2U5U8
Multiples of 3 (base 10)
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)
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)
𝟛 = 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)
Regular and non-Regular Languages
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:
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-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
Computability TheoryAll languages
languageswe can describe
RegularLanguages
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.
All languages
Computability Theory
RegularLanguages
NON-Regular Languagesvia Pumping Lemma
NON-RegularLanguages
via Reductions
languageswe can describe
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 }
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.
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.
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.
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.
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...
Pumping Lemma
Yehoshua Bar-Hillel Eli ShamirMicha A. Perles
Pumping Lemma
1 1 1 1
1 1 1 1
q1
q10q2 q9
q13q6q5
q15
xyz = 101101110
Pumping Lemma
1 1 1 1
1 1 1 1
1
xyz = 101101110
q1
q10q2 q9
q13q6q5
q15
Pumping Lemma
1 1 1 1
1 1 1 1
0
xyz = 101101110
q1
q10q2 q9
q13q6q5
q15
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1
q1
q10q2 q9
q13q6q5
q15
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1
q1
q10q2 q9
q13q6q5
q15
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
0
q1
q10q2 q9
q13q6q5
q15
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1q1
q10q2 q9
q13q6q5
q15
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1
q1
q10q2 q9
q13q6q5
q15
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1
q1
q10q2 q9
q13q6q5
q15
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
0
q1
q10q2 q9
q13q6q5
q15
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
q1
q10q2 q9
q13q6q5
q15
Pumping Lemma
1 1 1 1
1 1 1 1
xyz = 101101110
1
0
1
q1
q10q2 q9
q13q6q5
q15
101 0
11
Pumping Lemma
1 1 1 1
1 1 1 1
xz = 101110
q1
q10q2 q9
q13q6q5
q15
101 0
11
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
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
Pumping LemmaIf |xyz|>number-of-states then q9 exists...
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.
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.).
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
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.
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.
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.
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.
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...
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.
All languages
Computability Theory
Decidable Languages
Context-freeLanguages
RegularLanguages
Languages we can describe
NON-Regular Languagesvia Pumping Lemma
NON-RegularLanguages
via Reductions
COMP-330 Theory of Computation
Fall 2017 -- Prof. Claude Crépeau Lec. 8 : Pumping Lemma & NON-Reg. Languages