Regulr Lnguge Nonregulr Lnguges The Pumping Lemm Models of Comput=on Chpter 10 Recll, tht ny lnguge tht cn e descried y regulr expression is clled regulr lnguge In this lecture we will prove tht not ll lnguges re regulr. Tht is, there re lnguges for which no regulr expression will suffice to descrie the lnguge. Regulr Lnguge Sying tht there is no RE to descrie lnguge is different thn sying I don t know how to write the RE for this lnguge. The RE for nonregulr lnguge Does. Not. Exist. The pumping lemm Imgine n infinite regulr lnguge tht is descried y some FA with six sttes. For exmple: () * The pumping lemm For exmple: () * From finite mchine:,,,, 1
Words with more le\ers thn mchine hs sttes Only possile ecuse of loops,,,, The generliz=on An FA for n infinite lnguge lwys hs words tht re lrger thn the numer of (finite) sttes the mchine hs The generliz=on So, for words in the lnguge tht re lrger thn the numer of sttes in the mchine, every word cn e descried s fctors: So, there will lwys e these loops.,, x is wht is efore the loop y is the loop; not Λ z is wht follows the loop,, The pumping lemm Aritrrily long words re generted y pumping extr =mes through the loop. The generliz=on,, Importnt point: The generliz=on Every infinite regulr lnguge cn e pumped; otherwise, it would require n FA with infinite sttes, which is not possile. So, n infinite lnguge tht cn not e pumped must not e regulr. 2
w = Exmple Exmple w = x = y = z = n = 1,, x = y = z = n = 8,, Necessry vs. sufficient condi=ons If A implies B Then not- B implies not- A But B does not necessrily imply A We sy tht A is sufficient ut not necessry to imply B. Necessry vs. sufficient condi=ons If lnguge is regulr then it is pumple Therefore, if lnguge is not pumple then it is not regulr But if it is pumple then it my or my not e regulr. Regulrity is sufficient ut not necessry for pumpility. There re exmples of pumple nonregulr lnguges (e.g. ww R v; see ref. h\p://www.rdford.edu/~nokie/clsses/420/chp1-4- NonregulrLngs.html) So, no=cing tht lnguge is pumple mens nothing. But finding tht lnguge is not pumple mens tht the lnguge is nonregulr. Exmple L = { n n ; n = 0 1 2 } { Λ } Drw the FA. Before eginning, you might wnt to know tht it s regulr. Since it s infinite, tht mens it cn e pumped if it is regulr. Exmple If this is prt of regulr lnguge, then it must e pumple. So how would we divide it up? If y is ll s or ll s then, when pumped they re no longer equl. If there re oth s nd s in y, then n could pper jer which is not correct for this lnguge. 3
Exmple So, there is no wy to divide the words in this lnguge to conform to: Therefore the lnguge is nonregulr. So don t other trying to drw the FA. You cn t. No one cn. Becuse it s not regulr lnguge. Exmple So we hve just used the pumping lemm to prove tht L = { n n ; n = 0 1 2 } is nonregulr. New prolem. Lnguge Equl All words with sme numer of s s s. Equl For exmple { Λ } Importnt oserv=on: { n n ; n = 0 1 2 } Equl In fct, we cn sy more thn tht: Equl { n n ; n = 0 1 2 } = * * Equl 1. n n is nonregulr; previous pumping lemm exmple 2. Since it s n RE, then * * is regulr 3. the intersec=on of two regulr lnguges is regulr; proof in lst chpter 4. Therefore, Equl most not e regulr. { n n ; n = 0 1 2 } = * * Equl Equl is nonregulr { n n ; n = 0 1 2 } = * * Equl 1. n n i nonregulr; previous pumping lemm exmple 2. Since it s n RE, then * * is regulr 3. the intersec=on of two regulr lnguges is regulr; proof in lst chpter 4. Therefore, Equl most not e regulr. Cool, huh? Pumping lemm; version 2 Let L e n infinite lnguge ccepted y n FA with n sttes. Then for ll words w in L tht hve more thn n le\ers, there re strings x, y, nd z, where y is not null nd len(x)+len(y) n such tht xyz nd xy m z (for m = 1 2 3 ) re in L. Exmple: PAL PAL = the set of ll plindromes for nd { Λ } 4
Proof tht PAL is nonregulr Proof y contrdic=on. Assume tht PAL is regulr. Then there is n FA to define the lnguge. Suppose one such FA hs 123 sttes. It will generte ll memers of PAL including: 150 150 Proof tht PAL is nonregulr Becuse 150 150 hs more le\ers thn the mchine hs sttes, then it cn e fctored in xy m z. Since len(x)+len(y) 123 (in this cse), then the non- null y prt must contin ll s. But tht mens we ll pump more s into the front ut not into the ck; so it will no longer e in PAL. Proof tht PAL is nonregulr So, the ini=l ssump=on PAL is regulr needs must e incorrect. PAL is nonregulr. 5