Applictios of Regulr Closure 1
The itersectio of cotext-free lguge d regulr lguge is cotext-free lguge L1 L2 cotext free regulr Regulr Closure L1 L 2 cotext-free 2
Liz 6 th, sectio 8.2, exple 8.7, pge 227 L={^ ^ 0, 100} is cotext free 3
A Applictio of Regulr Closure Prove tht: L { : 100} is cotext-free 4
We kow: { } is cotext-free 5
We lso kow: 100 L1 { 100 } is regulr L1 {( ) } { * 100 100 } is regulr 6
{ } cotext-free 100 L1 {( ) } { * regulr 100 } (regulr closure) { } L 1 is cotext-free { } L1 { : 100} L is cotext-free 7
Liz 6 th, sectio 8.2, exple 8.8, pge 227 L={w # (w) = # (w) = # c (w)} is ot cotext free 8
Aother Applictio of Regulr Closure Prove tht: L { w: c } is ot cotext-free 9
If L { w: c } is cotext-free (regulr closure) The L { * * c*} { c } cotext-free regulr cotext-free Ipossile!!! Therefore, L is ot cotext free 10
Decidle Properties of Cotext-Free Lguges 11
Meership Questio: for cotext-free grr fid if strig w L(G) G Meership Algoriths: Prsers Exhustive serch prser CYK prsig lgorith 12
Epty Lguge Questio: for cotext-free grr fid if L(G) G Algorith: 1. Reove useless vriles 2. Check if strt vrile is useless S 13
Ifiite Lguge Questio: for cotext-free grr fid if L(G) is ifiite G Algorith: 1. Reove useless vriles 2. Reove uit d productios 3. Crete depedecy grph for vriles 4. If there is loop i the depedecy grph the the lguge is ifiite 14
Exple: S A A C C cs Depedecy grph Ifiite lguge A C S 15
S A C A C cs S => A => => => i => i 16
17 cs C C A A S cs cs C A S i i S c S c cs S ) ( ) ( ) ( ) ( 2 2
There is o lgorith to deterie whether two cotext-free grrs geerte the se lguge. For the oet we do ot hve the techicl chiery for defiig the eig of there is o lgorith. 18
The Pupig Le for Cotext-Free Lguges 19
Tke ifiite cotext-free lguge Geertes ifiite uer of differet strigs Exple: S A A S 20
S A A S A derivtio: Vriles re repeted S A S A 21
Derivtio tree S strig A S A 22
Derivtio tree S strig A S A repeted 23
S A S A 24
Repeted Prt S A 25
Aother possile derivtio S A S A 26
S A S A S 27
S A S A S A S 28
S A S A S A S 29
S Therefore, the strig is lso geerted y the grr 30
We kow: S We lso kow this strig is geerted: S 31
We kow: S Therefore, this strig is lso geerted: S 32
We kow: S Therefore, this strig is lso geerted: S ( ) ( ) ( ) ( ) 2 2 ( ) ( ) 2 2 33
We kow: S Therefore, this strig is lso geerted: S ( ) ( ) i i ( ) ( ) i i 34
Therefore, kowig tht is geerted y grr, we lso kow tht G ( ) i ( ) i is geerted y G 35
I geerl: We re give ifiite cotext-free grr G Assue G hs o uit-productios o -productios 36
Tke strig w L(G) with legth igger th > (Nuer of productios) x (Lrgest right side of productio) Cosequece: Soe vrile ust e repeted i the derivtio of w 37
Strig u, v, x, y, z w uvxyz : strigs of S terils u Lst repeted vrile A z v repeted A y x 38
S Possile derivtios: u z S uaz A vay v A A y A x x 39
We kow: S uaz AvAy A x This strig is lso geerted: S uaz * uxz uv 0 xy 0 z 40
We kow: S uaz AvAy A x This strig is lso geerted: S * uazuvayzuvxyz * The origil w uv 1 xy 1 z 41
We kow: S uaz AvAy A x This strig is lso geerted: S * * uazuvayzuvvayyzuvvxyyz * uv 2 xy 2 z 42
We kow: S uaz AvAy A x This strig is lso geerted: * S uaz uvayz * uvvayyz uvvvayyyzuvvvxyyyz uv * 3 xy 3 z * 43
We kow: S uaz AvAy This strig is lso geerted: S * * * uaz * uvvvayyyz uvayz * * uvvv vay yyyz * uvvv vxy yyyz uvvayyz * * A x uv i xy i z 44
Therefore, y strig of the for uv i xy i z i 0 is geerted y the grr G 45
Therefore, kowig tht uvxyz L(G) i i we lso kow tht uv xy z L(G) 46
S u A z v A y x Oservtio: Sice A vxy is the lst repeted vrile 47
S u A z v A y Oservtio: x vy 1 Sice there re o uit or productios 48
The Pupig Le: For ifiite cotext-free lguge L there exists iteger such tht for y strig we c write w L, w w uvxyz with legths vxy d vy 1 d it ust e: uv i xy i z L, for ll i 0 49
Applictios of The Pupig Le 50
No-cotext free lguges { c : 0} Cotext-free lguges { : 0} 51
Liz 6 th, sectio 8.1, exple 8.1, pge 216 { c 0 } 52
Theore: The lguge L { c : is ot cotext free 0} Proof: Use the Pupig Le for cotext-free lguges 53
L { c : 0} Assue for cotrdictio tht is cotext-free L Sice L is cotext-free d ifiite we c pply the pupig le 54
L { c : 0} Pupig Le gives gic uer such tht: Pick y strig w L with legth w We pick: w c 55
L { c : 0} w c We c write: w uvxyz with legths vxy vy 1 d 56
L { c : 0} c w uvxyz w vxy vy 1 Pupig Le sys: uv i xy i z L for ll i 0 57
L { c : 0} c w uvxyz w vxy vy 1 We exie ll the possile loctios of strig vxy i w 58
L { c : 0} c w uvxyz w vxy vy 1 Cse 1: vxy is withi...... ccc... ccc u vxy z 59
L { c : 0} c w uvxyz w vxy vy 1 Cse 1: v d y cosist fro oly...... ccc... ccc u vxy z 60
L { c : 0} c w uvxyz w vxy vy 1 Cse 1: Repetig v d y k 1 k...... ccc... ccc u 2 xy 2 v z 61
L { c : 0} c w uvxyz w vxy vy 1 Cse 1: Fro Pupig Le: uv 2 xy 2 z L k 1 k...... ccc... ccc u 2 xy 2 v z 62
L { c : 0} c w uvxyz w vxy vy 1 Cse 1: Fro Pupig Le: uv 2 xy 2 z L k 1 However: uv 2 xy 2 z k c L Cotrdictio!!! 63
L { c : 0} c w uvxyz w vxy vy 1 Cse 2: vxy is withi...... ccc... ccc u vxy z 64
L { c : 0} c w uvxyz w vxy vy 1 Cse 2: Siilr lysis with cse 1...... ccc... ccc u vxy z 65
L { c : 0} c w uvxyz w vxy vy 1 Cse 3: vxy is withi c...... ccc... ccc u vxy z 66
L { c : 0} c w uvxyz w vxy vy 1 Cse 3: Siilr lysis with cse 1...... ccc... ccc u vxy z 67
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: vxy overlps d...... ccc... ccc u vxy z 68
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: Possiility 1: v y cotis oly cotis oly...... ccc... ccc u vxy z 69
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: Possiility 1: k1 k2 1 v y cotis oly cotis oly k 1 k2...... ccc... ccc u 2 xy 2 v z 70
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: Fro Pupig Le: uv 2 xy 2 z L k1 k2 1 k 1 k2...... ccc... ccc u 2 xy 2 v z 71
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: Fro Pupig Le: uv 2 xy 2 z L k1 k2 1 However: uv 2 xy 2 z k1 k2 c L Cotrdictio!!! 72
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: Possiility 2: v cotis d y cotis oly...... ccc... ccc u vxy z 73
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: k1 k2 k v y Possiility 2: cotis d cotis oly 1 k1 k2 k...... ccc... ccc u 2 xy 2 v z 74
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: Fro Pupig Le: uv 2 xy 2 z L k1 k2 k 1 k1 k2 k...... ccc... ccc u 2 xy 2 v z 75
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: Fro Pupig Le: uv 2 xy 2 z L However: k1 k2 k 1 uv 2 xy 2 z k 1 k 2 k c L Cotrdictio!!! 76
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: Possiility 3: v y cotis oly cotis d...... ccc... ccc u vxy z 77
L { c : 0} c w uvxyz w vxy vy 1 Cse 4: Possiility 3: v y cotis oly cotis d Siilr lysis with Possiility 2 78
L { c : 0} c w uvxyz w vxy vy 1 Cse 5: vxy overlps d c...... ccc... ccc u vxy z 79
L { c : 0} c w uvxyz w vxy vy 1 Cse 5: Siilr lysis with cse 4...... ccc... ccc u vxy z 80
There re o other cses to cosider vxy (sice, strig cot vxy overlp, d c t the se tie) 81
I ll cses we otied cotrdictio Therefore: The origil ssuptio tht L { c : 0} is cotext-free ust e wrog Coclusio: L is ot cotext-free 82