C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c, c, c, c, c, c, c, c (d) c, c, c, c (e ) c, c, c, c
C K Ngpl Forml Lnguges nd utomt Theory ol. () 11*2 () 0+1 (c) ()* (d) ** (e ) (+)* (f) (+)* (g) (+)*c(+)* (h) ()*+()* (i) (+)*(+)* (j) 0(0+1)*11 (k) 0(10)*1+0(10)*+1(01)*0+1(01)* (l) (00+01+10+11)*(0+1) (m) (00+01+10+11)* ol. (),, c () C d D c (c)
C K Ngpl Forml Lnguges nd utomt Theory k k D c d, e d,e F Cution: O ne my construct the F s shown elow. uch n utomton will ccept ll the vlid strings in the lnguge ut it will lso ccept some strings tht re not vlid in the lnguge. For exmple, repetition of k re llowed only fter repetitions of or c re over. Once k is reched repetitions of or c re not llowed. ut this utomton llows repetitions of, c nd k in ny order which is not llowed. Hence, the ove finite utomton. k d, e D c (d) c c F ol. Let L e regulr lnguge with its corresponding finite utomton hving m numer of sttes. Let w=0 k 1 k e the string in the lnguge L such tht w =2k > m. To use pumping lemm tke w = xyz w ith xy m nd y 0.
C K Ngpl Forml Lnguges nd utomt Theory Now, the next step is to prove tht the string xy i z does not elong to L for ll i 0. Let us tke three possile cses. Cse I: y hs only 0s. Let y=0 t for some t > 0. Now, xz=0 k-t 1 k. ince t > 0 therefore k-t < k nd the string xz does not elong to L. ince t i=0, w=xyz=xz does not elong to L, hence L is not regulr. Cse II: y hs only 1s. Proof is similr to cse I. Cse III : Let y contin oth 0 nd 1. Let y=0 p 1 s. Now x=0 k-p nd z=1 k-s. t i=4, xy 4 z= 0 k-p 0 p 1 s 0 p 1 s 0 p 1 s 0 p 1 s 1 k-s. This string does not elong to L. Hence L is not regulr. ol. () elongs to R 1 ut not to R 2. elongs to R 1 ut not to R 2. ϵ elongs to R1 ut not to R2. () elongs to R 2 ut not to R 1. elongs to R 2 ut not to R 1. (c) elongs to othr 1 nd R 2. elongs to othr1 nd R2. (d) elongs to neither R 1 nor R 2. elongs to neither R 1 nor R 2.
C K Ngpl Forml Lnguges nd utomt Theory ol. () 1 1 1 0 D 0 0 E () 0, 1 0 1 0 (c) 1 1 0 0 0 0 C D F 1 (d) 0 0, 1 0 1 F 1 0 1 1
C K Ngpl Forml Lnguges nd utomt Theory ol. Q1={,, } Q2={P, Q, R} Q1 X Q2= { (, P), (, Q), (, R), (, P), (, Q), (, R), (F, P), (F, Q), (F, R)} Trnsition Tle Current tte Input ymol {, P } {, P} {, Q} {,Q} {,P} {, R} {, R} {, R} {,R} {, P } {, P} {F, Q} {,Q} {,P} {F, R} {, R} {, R} {F,R} {F, P } {, P} {, Q} {F,Q} {,P} {, R} {F, R} {, R} {,R} fter removing the sttes tht re not generted tht is {, Q} nd {F, P}. Current tte Input ymol {, P } {, P} {, Q} {, P } {, P} {F, Q} {,Q} {,P} {, R}
C K Ngpl Forml Lnguges nd utomt Theory {F,Q} {,P} {, R} {, R} {, R} {,R} {, R} {, R} {F,R} {F, R} {, R} {,R} utomt for the lnguge L1 U L2. Current tte Input ymol {, P } {, P} {, Q} {, P } {, P} {F, Q} {,Q} {,P} {, R} *{F,Q} {,P} {, R} *{, R} {, R} {,R} *{, R} {, R} {F,R} *{F, R} {, R} {,R} utomt for the lnguge L1 L2 Current tte Input ymol {, P } {, P} {, Q} {, P } {, P} {F, Q} {,Q} {,P} {, R} {F,Q} {,P} {, R} {, R} {, R} {,R} {, R} {, R} {F,R} *{F, R} {, R} {,R}
C K Ngpl Forml Lnguges nd utomt Theory utomt for the lnguge L1 - L2 Current tte Input ymol {, P } {, P} {, Q} {, P } {, P} {F, Q} {,Q} {,P} {, R} *{F,Q} {,P} {, R} {, R} {, R} {,R} {, R} {, R} {F,R} {F, R} {, R} {,R} utomt for the lnguge L2 L1 Current tte Input ymol {, P } {, P} {, Q} {, P } {, P} {F, Q} {,Q} {,P} {, R} {F,Q} {,P} {, R} *{, R} {, R} {,R} *{, R} {, R} {F,R} {F, R} {, R} {,R} ol. ()
C K Ngpl Forml Lnguges nd utomt Theory = ϵ + 1= ϵ1* = 1* F=0 =0+ 1+ F1 =1*0 + 1+01=1*0+(1+01)=1*0(1+01)* F=0= 1*0(1+01)*0 Required regulr expression: 1*0(1+01)*0 () = ϵ =0+ 1+ 0 F=1+F0=1(0*)*=10* =0 +F1= 0+10*1=0(10*1)* =0+1+0= ϵ0+ 1+ 0(10*1)*0=0+1+ 0(10*1)*0= 0+ (1+ 0(10*1)*0) =0(1+ 0(10*1)*0)* = 0(10*1)*= 0(1+ 0(10*1)*0)*0(10*1)* F=10*=0(1+ 0(10*1)*0)*0(10*1)*10* Required regulr expression: 0(1+ 0(10*1)*0)*0(10*1)*10* + 0(1+ 0(10*1)*0)*0(10*1)* ol. = ϵ == ϵ= F= += ϵ+=+ = +(+)+F=+(+)+F=+F+(+)=+(+)+(+) =++(++)=(+)(++)* F=+(+)(++)* Required regulr expression: +(+)(++)* + ol. F = ϵ+= ϵ*=* =+=*+=**
C K Ngpl Forml Lnguges nd utomt Theory F==** Required regulr expression: ** ol. F = ϵ =+= ϵ+=+=* = += ϵ+=+=* F=+=*+* Required regulr expression: *+* ol. () **** () ****(+)* (c) 0011(0011)*(00)*+1100(1100)*(11)* (d) ** (e) 00(0+1)*00 ol. It is DF
C K Ngpl Forml Lnguges nd utomt Theory 1 0 F 1 0 1 C 0 ol. NF corresponding to (0+1)*(00+11)(0+1)* 0, 1 0 0 0, 1 F 1 1 DF corresponding to NF tte Input ymol 0 1 {} {,} {,} {,} {,,F} {,} {,} {,} {,,F} {,,F} {,,F} {,,F} {,,F} {,,F} {,,F} ol. = ϵ =++= ϵ+ ϵ+=++=(+)*
C K Ngpl Forml Lnguges nd utomt Theory F=+F(+)=(+)*+F(+)*=(+)*(+)* Required regulr expression: (+)*(+)* ol. = ϵ =+++F= ϵ+ ϵ++f=+++f F=+F=* =+++*=++(+*)=(+)(+*)* F=(+)(+*)** Required regulr expression: (+)(+*)** ol. = ϵ =+c= ϵ+c=+c == ϵ= =+c F=++F=(+c)++F=((+c)+)* Required regulr expression: ((+c)+)* ol.
C K Ngpl Forml Lnguges nd utomt Theory ϵ C D,, ϵ K ϵ ϵ E F G H I J L,, C L E F G H I () C E, ϵ ϵ D F fter removl of null moves, we hve C E, F ove finite utomton will ccept ll vlid strings in the lnguge, ut it my lso ccept some other strings tht re not in the lnguge. For exmple, it will ccept the repetitions of even fter repetitions of which is not desirle. For exmple, will e vlid string which is not desirle. Hence in the ctul utomton
C K Ngpl Forml Lnguges nd utomt Theory pth is so creted tht there is no wy ck once is reched. Hence, the ove utomton is modified s given elow: C D F E