140 likes | 304 Views
Proofs of Non-Regularity. Reading: Section 4.3. Are all languages Regular?. No! (L = a n b n : n > 0) How do you prove a language is regular? How do you prove a language is not regular? If a language is finite, is it regular?. The Pigeonhole Principle. “Common Sense” Math Principle.
E N D
Proofs of Non-Regularity Reading: Section 4.3
Are all languages Regular? • No! (L = anbn : n > 0) • How do you prove a language is regular? • How do you prove a language is not regular? • If a language is finite, is it regular?
The Pigeonhole Principle • “Common Sense” Math Principle. • If there are n pigeons put in m holes, and n > m, there must be a hole with more than one pigeon in it.
The Pumping Lemma - Intuition • If L is infinite regular language, it must have a DFA. So it is represented by a finite number of states. • Consider a very long string in L, one that is longer than the number of states in the DFA. • Then we must land in the same state more than once while processing the string. • Then, taking out a piece, or putting in another cycle, results in more strings in the language. • L is infinite, its DFA is finite, so there is a cycle in the DFA. The cycle can happen any number of times.
Pumping Lemma • Let L be an infinite reg. lang. • Then, there exists some integer m so that any w in L where |w| >= m can be written as: w = xyz, such that the following hold: • |xy| <= m • |y| > 0 • w’ = xyiz is in L for all i > 0.
Pumping Lemma Picture Y X Z For any w > m in the language, its path MUST look like this!
Proof of the Pumping Lemma • Let L be regular, and its dfa have states qo,q1,…,qn. • Choose w in L such that |w| > n (m is n+1) • The path in the dfa on w is qo,qi,qj,…,qf. • At least one of these states must be repeated (pigeonhole) before the nth state • So the path is q0,qi,qj,…,qr,…,qr,…,qf • So, there must be strings so that • x = the string on q0,qi,qj,…,qr • y = the string on qr,…,qr • z = the string on qr,…,qf • So |xy| <= m, and |y| >0. • The cycle can happen any number of times and must still end in qf.
Using the pumping lemma to prove a language is NOT regular • Assume L is regular, so it satisfies the p.l. • Suppose that someone else picks a number m. • Choose a string w so that |w| >= m. • The opponent picks a decomposition xyz, subject to |xy| <= m, and |y| >0 • Find any i >= 0 such that xyiz is not in L. • Then the language must not have been regular.
Examples: L = {anbn : n >= 0} • Opponent picks m, I pick w = m a’s followed by m b’s. • Opponent picks decomposition, but |xy| <= m, so anything they choose is x = all a’s and y = all a’s. • For any i > 1, new string xyiz has too many a’s and is not in L. • So L is not regular.
Example: na(w) < nb(w) • Opponent chooses m • We choose w = ambm+1 • Opponent chooses xyz, but |xy| <= m, so both must consist of all a’s. (y = ak,k <=m) • Choose i = 2. Then w’ = xm-ky2kbm+1 w’ = am+kbm+1 w’ is not in L, so L is not regular.
L = (ab)nak : n > k, k>=0 • Opponent chooses m, we choose w = (ab)mam-1 • Opponent chooses decomposition xyz, but x and y must be part of the ab part. • If they chose y ends in a, then choose i = 0. • If they chose y = b, then choose i = 0. • If they chose y = (ab)k, then choose i = 0.
L = anbkcn+k: n >= 0, k >= 0 • Apply homomorphism : h(a) = a h(b) = a h(c) = c Then h(L) = akck, k >= 0, which we know is not regular. So L couldn’t have been regular.
What’s wrong with it?Example: L = wwR • Opponent picks any m. • We pick string w = a2m • Opponent picks decomposition xyz, and y is all a’s. • Then w’ is missing a’s in front and is therefore not in L.
Examples: • L = wwR • L = ancbn :n > 0 • L = anbn+scs :n,s > 0