then the left side is clearly an y sequence of 0 s and 1
play

Then the left side is clearly \an y sequence of 0's and - PDF document

Extended RE's UNIX pioneered the use of additional op erators and notation for RE's: E ? = 0 or 1 o ccurrences of E = + E . + = 1 or more o ccurrences of = . E E E E Char acter


  1. Extended RE's UNIX pioneered the use of additional op erators and notation for RE's: � E ? = 0 or 1 o ccurrences of E = � + E . + � = 1 or more o ccurrences of = . E E E E � � � Char acter classes [ a z GX ] = the union of all (ASCI I) c haracters from a to z , plus the c haracters G and X , for example. Algebraic La ws for RE's If t w o expressions E and F ha v e no v ariables, then = means that L ( E ) = L ( F ) (not that and E F E are iden tical expressions). F + � Example: 1 = 11 � . If and are RE's with v ariables, then = E F E ( E is ) means that whatev er F e quivalent to F languages w e substitute for the v ariables (pro vided w e substitute the same language ev erywhere the same v ariable app ears), the resulting expressions denote the same language. � Example: + = . R RR � With t w o notable exceptions, w e can think of ; union (+) as if it w ere addition with in place of the iden tit y 0, and concatenation, with � in place of the iden tit y 1, as m ultiplication. � + and concatenation are b oth asso ciativ e. � + is comm utativ e. � La ws of the iden tities hold for b oth. � ; is the annihilator for concatenation. � The exceptions: 1. Concatenation is comm utativ e: ab 6 = not ba . 2. + is idemp otent : E + E = E for an y expression E . Chec king a La w Supp ose w e are told that the la w ( R + ) = S � ( R ) holds for RE's. Ho w w ould w e c hec k that � S � � this claim is true? � Think of R and S as if they w ere single sym b ols, rather than placeholders for languages, i.e., = f 0 g and = f 1 g . R S ✦ Then the left side is clearly \an y sequence of 0's and 1's. 1

  2. ✦ The righ t side also denotes an y string of 0's and 1's, since 0 and 1 are eac h in L ( 0 � 1 � ). � That test is (i.e., if the test fails, ne c essary then the la w do es not hold. ✦ W e ha v e particular languages that serv e as a coun terexample. � But is it (if the test succeeds, the su�cient la w holds)? Pro of of Su�ciency The b o ok has a fairly simple argumen t for wh y , when the \concretized" expressions denote the same language, then the languages w e get b y substituting an y languages for the v ariables are also the same. � But if y ou think that's ob vious, the b o ok also has an example of \RE's with in tersection" where the same statemen t is false. � Also | is it clear that w e can tell whether t w o RE's without v ariables denote the same language? ✦ Algorithm to do so will b e co v ered. Closure Prop erties � Not ev ery language is a regular language. � Ho w ev er, there are some rules that sa y \if these languages are regular, so is this one deriv ed from them. � There is also a p o w erful tec hnique | the pumping lemma | that helps us pro v e a language to b e regular. not � Key to ol: Since w e kno w RE's, DF A's, NF A's, � -NF A's all de�ne exactly the regular languages, w e can use whic hev er represen tation suits us when pro ving something ab out a regular language. Pumping Lemma If L is a regular language, then there exists a constan t n suc h that ev ery string w in L , of length or more, can w e written as = , where: n w xy z 1. 0 j y j . < j xy j � 2. n . 2

  3. i 3. F or all � 0, is also in L . i w y z ✦ i 0 Note = rep eated times; = � . y y i y � The alternating quan ti�ers in the logical statemen t of the PL mak es it v ery complex: ( 8 L )( 9 n )( 8 w )( 9 x; y ; z )( 8 i ). Pro of of Pumping Lemma � Since w e claim is regular, there m ust b e a L DF A suc h that = L ( A ). A L � Let ha v e states; c ho ose this for the A n n pumping lemma. � Let b e a string of length � in L , sa y = w n w � � � , where � n . a a a m 1 2 m � Let b e the state is in after reading the q A i �rst sym b ols of . i w ✦ = start state, = ( q ), = q q � ; a q 0 1 0 1 2 ^ ( q ), etc. � ; a a 0 1 2 � Since there are only di�eren t states, t w o of n m ust b e the same; sa y = , q ; q ; : : : ; q q q 0 1 n i j where 0 � � n . i < j � Let = � � � ; = � � � ; = x a a y a a z 1 i i +1 j � � � . a a j +1 m � Then b y rep eating the lo op from to with q q i i lab el � � � zero times once, or more, w e a a i +1 j i can sho w that is accepted b y A . xy z PL Use W e use the PL to sho w a language is L not regular. � Start b y assuming L is regular. � Then there m ust b e some that serv es as the n PL constan t. ✦ W e ma y no kno w what is, but w e can n w ork the rest of the \game" with n as a parameter. � W e c ho ose some w that is kno wn to b e in L . ✦ T ypically , w dep ends on n . � Applying the PL, w e kno w can b e brok en w in to xy z , satisfying the PL prop erties. ✦ Again, w e ma y not kno w ho w to break w , so w e use x; y ; z as parameters. � W e deriv e a con tradiction b y pic king i (whic h migh t dep end on n , x , y , and/or z ) suc h that i xy z is not in L . 3

  4. Example Consider the set of strings of 0's whose length is a p erfect square; formally = f 0 i j is a square g . L i � W e claim L is not regular. � Supp ose is regular. Then there is a constan t L satisfying the PL conditions. n 2 � n Consider w = 0 , whic h is surely in L . � Then = , where j xy j � and 6 = � . w xy z n y � By PL, is in L . But the length of xy y z xy y z is greater than 2 and no greater than 2 + n . n n 2 � Ho w ev er, the next p erfect square after n is 2 2 ( n + 1) = n + 2 n + 1. � Th us, is not of square length and is not xy y z in L . � Since w e ha v e deriv ed a con tradiction, the only unpro v ed assumption | that L is regular | m ust b e at fault, and w e ha v e a \pro of b y con tradiction" that L is not regular. Closure Prop erties Certain op erations on regular languages are guaran teed to pro duce regular languages. � Example: the union of regular languages is regular; start with RE's, and apply + to get an RE for the union. Substitu ti on � T ak e a regular language L o v er some alphab et �. � F or eac h in �, let b e a regular language. a L a � Let s b e the substitution de�ned b y s ( a ) = L a for eac h a . ✦ Extend to strings b y s ( a � � � ) = s a a n 1 2 s ( a ) s ( a ) � � � s ( a ); i.e., concatenate the 1 2 n languages L L � � � L . a a a 1 2 n ✦ Extend to languages b y s ( M ) = [ s w in M s ( w ). � Then s ( L ) is regular. Pro of That Substitu ti on of Regular Languages In to a Regular Language is Regular � Let R b e a regular expression for language L . 4

  5. � Let b e a regular expression for language R a s ( a ) = L , for all sym b ols a in �. a � Construct a RE E for s ( L ) b y starting with R and replacing eac h sym b ol a b y the RE L . a � Pro of that L ( E ) = s ( L ) is an induction on the heigh t of (the expression tree for) RE R . : is a single sym b ol, a . Then = , Basis R E R a = f a g , and s ( L ) = s ( f a g ) = L ( R ). L a � Cases where R is � or ; easy . Induction : There are three cases, dep ending on whether R = R + R , R = R R , or R = R � . 1 2 1 2 1 W e'll do only R = R R . 1 2 � = , where = L ( R ) and = L L L L L 1 2 1 1 2 L ( R ). 2 � Let E b e R , with eac h a replaced b y R , 1 1 a and E similarly . 2 � By the IH, L ( E ) = s ( L ) and L ( E ) = s ( L ). 1 1 2 2 � Th us, L ( E ) = s ( L ) s ( L ) = s ( L ). 1 2 Application s of the Substitu ti on Theorem � If L and L are regular, so is L L . 1 2 1 2 ✦ Let s ( a ) = L and s ( b ) = L . Substitute 1 2 in to the regular language f ab g . � So is [ . L L 1 2 ✦ Substitute in to f a; b g . � Ditto L � . 1 ✦ Substitute in to L ( a � ). � Closure under = substitution homomorphism of one string for eac h sym b ol. ✦ Sp ecial case of a substitution. Example: Homomorphism Let = L ( 0 ), and let b e a homomorphism L � 1 � h de�ned b y h (0) = and h (1) = � . aa � � � Then h ( L ) = aa ) = all strings of an ev en L � n um b er of a 's. Closure Under In v erse Homomorphism � � 1 f w j L g . h ( L ) = h ( w ) is in 5

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend