CD5080 AUBR RCAPIULAION Models of Coputtio, Lguges d Autot Leture 1 Cotext-ree Lguges, CL Pushdow Autot, PDA Pupig Le for CL eleted CL Proles Cotext-ree Lguges Mälrdle Uiversity 00 1 3 Cotext-ree Lguges xple Cotext-ree Grrs Pushdow Autot stk Cotext-ree Grrs A otext-free grr G A derivtio utoto 4 5 6 A otext-free grr G Aother derivtio L G = { : 0} l l xple A otext-free grr G A derivtio 7 8 9
A otext-free grr G Aother derivtio R L G = { ww : w {, }*} xple A otext-free grr G A derivtio 10 11 1 A otext-free grr A derivtio Defiitio: Cotext-ree Grrs Grr G = V,,, P 13 L G = { w : w = w,d v prefix v} l l 14 v Vriles eril syols trt vriles Produtios of the for: A x x is strig of vriles d terils 15 Defiitio: Cotext-ree Lguge L A lguge is otext-free if d oly if there is grr G 1.. 3. 4. 5. AB A A A B B B Derivtio Order 1.. 3. 4. 5. AB Derivtio Order A A A B B B with L = LG 16 Leftost derivtio 1 3 AB AB B B 4 5 17 Rightost derivtio 1 4 5 AB AB AA 3 18
AB A B B Leftost derivtio A AB BB AB BB B AB A B B Rightost derivtio A AB A B A B Derivtio rees 19 0 1 AB A A B B AB A A B B AB A A AB B B AB AB A B AB AB AB A B A B A A B 3 4 AB A A B B AB AB AB B AB A A B B AB AB AB B Derivtio ree AB A A B B AB AB AB B Derivtio ree A B A B A B A B 5 6 A B A B yield = 7
8 Aiguity 9 leftost derivtio derivtio * deotes ultiplitio 30 derivtio leftost derivtio 31 wo derivtio trees 3 he grr is iguous! trig hs two derivtio trees 33 strig hs two leftost derivtios * he grr is iguous: 34 Defiitio A otext-free grr is iguous if soe strig hs two or ore derivtio trees two or ore leftost/rightost derivtios G w LG 35 Why do we re out iguity? = 36 Why do we re out iguity?
37 Why do we re out iguity? 4 6 4 8 6 = 8 = 38 6 = Corret result: 4 6 39 Aiguity is d for progrig lguges We wt to reove iguity! 40 We fix the iguous grr y itroduig pretheses to idite groupig, preedee No-iguous grr expressio; ter; ftor 41 4 Uiue derivtio tree 43 he grr is o-iguous G very strig hs uiue derivtio tree. w LG 44 Iheret Aiguity oe otext free lguges hve oly iguous grrs! xple: } { } { L = 1 1 A A A B B B 1 45 he strig hs two derivtio trees 1 1
Pushdow Autot PDAs 46 Pushdow Autoto - PDA Iput trig tk ttes 47 he tk A PDA write syols o stk d red the lter o. PUH writig syol POP redig syol All ess to the stk oly o the top! tk top is writte leftost i the strig, e.g. yxz A stk is vlule s it hold uliited out of ifortio. he stk llows pushdow utot to reogize soe o-regulr lguges. y x z 48 he ttes, / 1, / 1 Iput syol Pop syol Push syol iput h h h h iput h h h h, / 1 stk top Reple stk e h $ top Push e h $ e h $ e h $ 49 50 51 A ltertive is to strt d fiish with epty stk., / 1 iput h h h h 1, / iput h h h h xple 3.7 llig: A PDA for siple ested prethesis strigs ε Iput tk stk e h $ top Pop e h $ stk e h $ top No Chge e h $ strt, ε /, / ε s, / ε ed 5 53 54
xple 3.7 Iput ε xple 3.7 Iput ε xple 3.7 Iput ε, ε /, / ε tk, ε /, / ε tk, ε /, / ε tk strt s, / ε ed strt s, / ε ed strt s, / ε ed 55 56 57 xple 3.7 Iput ε xple 3.7 Iput ε xple 3.7 Iput ε, ε /, / ε tk, ε /, / ε tk, ε /, / ε tk strt s, / ε ed strt s, / ε ed strt s, / ε ed 58 59 60 xple 3.7 Iput ε tk, ε /, / ε NPDAs 1, / No-Deteriis, / 1 strt s, / ε ed, / 3 trsitio 61 6 63
A strig is epted if: All the iput is osued he lst stte is fil stte tk i the iitil oditio either: epty whe we strted with epty stk, or: otto syol rehed 64 xple NPDA L = { : 0} is the lguge epted y the NPDA:, /, / Σ = {, }, /, /,$ / $ 0 1 3 65 xple NPDA NPDA M, /, / 0 L M = { ww, /, /, / R } Σ = {, } ve-legth plidroes,$ / $ 1 66 Iput syol Pushig trigs Pop syol, / w 1 Push strig 67 xple: iput stk e h top, / df 1 Push 8 d f h e 88 pushed strig NPDA M Aother NPDA exple,$ / 0$, 0 / 00,1/ L M = { w: = },$ /1$,1/11, 0 /, $ / $ 1 Σ = {, } $ $ 68 69 rsitio futio:, / w orl Defiitios for NPDAs, / w 1 rsitio futio: δ 1,, = {, w} 1, / w 3 ew stte δ 1,, = {, w, 3, w} urret stte urret stk top ew stk top urret iput syol 70 71 7
orl Defiitio of NPDA No-Deteriisti Pushdow Autoto orl Defiitio A uspeified trsitio futio is to the ull set d represets A ded ofigurtio for the NPDA. ttes Iput lphet M = Q, Σ, Γ, δ, z, tk lphet rsitio futio il sttes tk strt syol Lguge of NPDA M L M = { w : 0, w, s f,, s' } Iitil stte il stte 73 74 75 Proof - tep 1: NPDAs Aept Cotext-ree Lguges heore Cotext-ree Lguges Grrs Lguges Aepted y NPDAs Cotext-ree Lguges Grrs Covert y otext-free grr to NPDA with L G = L M Lguges Aepted y NPDAs G M 76 77 78 Proof - tep : Cotext-ree Lguges Grrs Lguges Aepted y NPDAs Covert y NPDA to otext-free grr with: G M L G = L M Covertig Cotext-ree Grrs to NPDAs A exple grr: Wht is the euivlet NPDA? 79 80 81
Grr NPDA, /, /, /, /, /, / he NPDA siultes leftost derivtios of the grr LGrr = LNPDA I geerl Give y grr G We ostrut NPDA M, /,$ / $ 0 1 With L G = L M 8 83 84 Costrutig NPDA fro grr op-dow prser or y produtio A w, A/ w M or y teril, / G Grr G geertes strig if d oly if w NPDA M epts w L G = L M herefore: or y otext-free lguge there is NPDA tht epts the se lguge, /,$ / $ 0 1 85 86 87 Covertig NPDAs to Cotext-ree Grrs or y NPDA M we will ostrut otext-free grr G with L M = L G he grr siultes the hie A derivtio i Grr terils labcl l l G vriles Iput proessed tk otets i NPDA M 88 89 90
oe iplifitios irst we odify the NPDA so tht It hs sigle fil stte f It epties the stk whe it epts the iput Origil NPDA pty tk f 91 eod we odify the NPDA trsitios. All trsitios will hve for: i i, B / or, B / CD j j whih es tht eh ove ireses/dereses stk y sigle syol. 9 hose siplifitios do ot ffet geerlity of our rguet. It e show tht for y NPDA there exists euivlet oe hvig ove two properties i.e. the euivlet NPDA with sigle fil stte whih epties its stk whe it epts the iput, d whih for eh ove ireses/dereses stk y sigle syol. 93 or eh trsitio: i, B / j or eh trsitio: i, B / CD j tk otto syol o trt Vrile $ f we dd produtio: ib j we dd produtio: ibk jcl l Dk trt stte igle il stte for ll sttes k, l 94 95 96 Lguge Hierrhy { : 0} No-regulr lguges Cotext-ree Lguges R { } { ww } Deteriisti PDAs DPDAs Regulr Lguges 97 98 99
Allowed DPDAs, w 1 Not llowed, w 1 Allowed, w 1 trsitios, w 1, w 1 1 1 1, w 3, w 3, w 3 100 101 oethig ust e thed fro the stk 10 Not llowed, w 1 1 NPDAs Hve More Power th DPDAs Positive Properties of Cotext-ree Lguges, w 3 103 104 105 L1 is otext free L is otext free Uio Cotext-free lguges re losed uder Uio L1 L is otext-free I geerl: or otext-free lguges with otext-free grrs d strt vriles he grr of the uio hs ew strt vrile L 1, L G 1, G 1, L1 L 1 d dditiol produtio Cotext-free lguges re losed uder Cotetio L1 is otext free L is otext free Cotetio L 1 L is otext-free 106 107 108
I geerl: or otext-free lguges with otext-free grrs d strt vriles 1, L 1, L G 1, G L 1 L he grr of the otetio hs ew strt vrile d dditiol produtio 1 tr Opertio Cotext-free lguges re losed uder str-opertio L is otext free * L is otext free I geerl: or otext-free lguge with otext-free grr d strt vrile L G he grr of the str opertio hs ew strt vrile 1 d dditiol produtio L* 1 1 109 110 111 Negtive Properties of Cotext-ree Lguges Cotext-free lguges re ot losed uder itersetio L1 is otext free L is otext free Itersetio L1 L ot eessrily otext-free Copleet Cotext-free lguges re ot losed uder opleet L is otext free L ot eessrily otext-free 11 113 114 Itersetio of CL d RL Regulr Closure he itersetio of otext-free lguge d regulr lguge is otext-free lguge L1 otext free L regulr L1 L otext-free he Pupig Le for Cotext-ree Lguges 115 116 117
he Pupig Le for CL or ifiite otext-free lguge L there exists iteger suh tht for y strig we write w L, w w = uvxyz vxy vy with legths d 1 i i d uv xy z L, for ll i 0 118 Applitios of he Pupig Le for CL 119 Restritio-free lguges { : 0} Cotext-free lguges { : 0} 10 heore Proof he lguge L = { : 0} is ot otext free Use the Pupig Le for otext-free lguges L = { : 0} Assue for otrditio tht is otext-free ie L is otext-free d ifiite we pply the pupig le L Pupig Le gives uer suh tht: Pik y strig w L with legth We pik: L = { : 0} w = w 11 1 13 L = { : 0} w = We write: w = uvxyz vxy vy 1 with legths d L = { : 0} Pupig Le sys: i w = w = uvxyz i vxy vy 1 uv xy z L for ll i 0 L = { : 0} w = w = uvxyz We exie ll the possile lotios of strig i vxy w vxy vy 1 14 15 16
L = { : 0} Cse 1: vxy is withi......... u vxy w = w = uvxyz vxy vy 1 z 17 C.W GO HROUGH ALL CA L = { : 0} w = w = uvxyz Cse 5: iilr lysis to se 4......... u vxy vy 1 vxy z 18 here re o other ses to osider vxy vxy sie, strig ot overlp, d t the se tie 19 I ll ses we otied otrditio herefore: he origil ssuptio tht L = { : 0} is otext-free ust e wrog {! : 0} { : 0} { : 0} { ww : w {, }} Urestrited grr lguges Cotext-free lguges { : 0} { ww R : w {, }*} eleted xples of C Lguge Proles Colusio: L is ot otext-free Regulr Lguges ** ND O PROO 130 131 13 xple id CG for the followig lguge id CG for the followig lguge id CG for the followig lguge L = { : k = } Let G e the grr with produtios: B B B Cli: LG = L k 133 L = { : k = } Proof: Cosider the followig derivtio: k * B * B where the first * pplies ties, the seod B B ties ie ll words i LG ust follow this ptter i their derivtios, it is ler tht LG L B B B 134 L = { : k = } Cosider w L, w = for soe, 0 he derivtio k * B * B lerly produes w for y,. L LG L LG G is CG for L ND O PROO B B B 135
xple id PDA d CG for the followig lguge L = {, / 3 : N} 3, / L = { 3 CG : 3 : N}, / 3, / xple id PDA d CG for the followig lguge PDA L = { x {, } : = }, /, / i 3, / f Is the utoto deteriisti? Yes. It ts i uiue wy i eh stte. 136 i 3, / f 137, /, /, /, / 138 L = { x {, } : = } CG :, /, /, /, /, /, / 139 xple Prove tht the lguge L is otext-free L = { : is ot ultiple of Cosider the followig two lguges: L 1 ={w : w is de fro s d s d the legth of w is ultiple of 10} L = { : 0} 5} 140 L 1 ={w : w is de fro s d s d the legth of w is ultiple of te} L = { : 0} Let L 1 deote the opleet of L 1. We hve tht L = L 1 L. L 1 is regulr lguge, sie we esily uild fiite utoto with 10 sttes tht epts y strig i this lguge. L 1 is regulr too, sie regulr lguges re losed uder opleet. 141 xple he lguge L is otext-free. he grr is: herefore, the lguge L = L 1 L is lso otext-free, sie otext-free lguges re losed uder regulr itersetio Regulr Closure. ND O PROO 14 id PDA d CG for the followig lguge L = { x : N, x {, }, x } CG Produtio ex. A A A A A A AA AA A A 143 L = { x : N, x {, }, x } PDA i, / f, / A A, A/ A A, /, / 144
xple id PDA d CG for the followig lguge L = { x {, }: >, the strtig d the fiishig syolsre differet} PDA L = { x {, }: >, the strtig d the fiishig syolsre differet}, /, /, /, /, /, /, /, /, /, /,,,, / /, / / /, /, /, /, /,,,, / / / / CG, diret ostrutio trigs strt d fiish with differet syols A A trigs oti t lest oe ore th A A AA AA AA, /, /, / 145 we ust hve AA here s oly oe A just les 146