Forl Lguges The Pupig Le for CFLs
Review: pupig le for regulr lguges
Tke ifiite cotext-free lguge Geertes ifiite uer of differet strigs Exple: 3
I derivtio of log strig, vriles re repeted derivtio: 4
Derivtio tree strig 5
Derivtio tree strig repeted 6
* 7
Repeted Prt * 8
other possile derivtio fro * * * 9
* * ( ) ( ) ( ) ( ) * 10
Derivtio fro * * * 11
* * * 0 ( ) ( ) 0 1
* * * 0 ( ) ( ) 0 ( ) 0 ( ) 0 L( G) 13
Derivtio fro * * * 14
* * * * 15
16 * * ) ( ) ( ) ( ) ( * *
17 * * ) ( ) ( ) ( ) ( * *
* * * ( ) ( ) ( ) ( ) L( G) 18
Derivtio fro * * * ( ) ( ) 19
0 3 3 * * ) ( ) ( ) ( ) ( * *
1 3 3 3 3 * ) ( ) ( ) ( ) ( * *
* * * 3 ( ) ( ) 3 ( ) 3 ( ) 3 L( G)
I Geerl: * * * ( ) i ( ) i i ( ) ( ) L( G) i i 0 3
Cosider ow ifiite cotext-free lguge L Let G e the grr of L {} Tke G so tht it hs o uit-productios o -productios 4
Let p = (Nuer of productios) x (Lrgest right side of productio) Let p 1 Exple : G p 43 1 p 113 5
Tke strig with legth wl(g) w We will show: i the derivtio of w vrile of is repeted G 6
* w v 1 v v k w v 1 7
v 1 v v k w vi vi 1 f xiu right hd side of y productio w k f w k f p k f 8
v 1 v v k w p k f k p f Nuer of productios i grr 9
30 Nuer of productios i grr k oe productio ust e repeted w v v v k 1 1 r r r Repeted vrile w v 4 3 1 1
w L(G) w Derivtio of strig w 1 34 w oe vrile is repeted 31
Derivtio tree of strig w u Lst repeted vrile w uvxy v repeted y u, v, x, y, : trigs of terils x 3
Possile derivtios: u u vy v y x x 33
We kow: u vy x This strig is lso geerted: u * ux uv 0 xy 0 34
We kow: u vy x This strig is lso geerted: * uuvyuvxy * The origil w uv 1 xy 1 35
We kow: u vy x This strig is lso geerted: * * uuvyuvvyy uvvxyy * uv xy 36
We kow: u vy x This strig is lso geerted: * u uvy * uvvyy uvvvyyyuvvvxyyy uv * 3 xy 3 * 37
We kow: u vy x This strig is lso geerted: * u uvy uvvvyyy * * * * * uvvvvyyyy * uvvvvxy yyy uvvyy * * uv i xy i 38
Therefore, y strig of the for uv i xy i i 0 is geerted y the grr G 39
Therefore, kowig tht uvxy L(G) i i we lso kow tht uv xy L(G) L( G) L { } uv i xy i L 40
u v y x Oservtio: vxy ice is the lst repeted vrile 41
u v y Oservtio: x vy 1 ice there re o uit or -productios 4
The Pupig Le: For ifiite cotext-free lguge L there exists iteger such tht for y strig we c write w L, w w uvxy with legths vxy d vy 1 d it ust e: uv i xy i L, for ll i 0 43
pplictios of The Pupig Le 44
No-cotext free lguges { c : 0} Cotext-free lguges { : 0} 45
Theore: The lguge L { c : 0} is ot cotext free Proof: Use the Pupig Le for cotext-free lguges 46
L { c : 0} ssue for cotrdictio tht is cotext-free L ice L is cotext-free d ifiite we c pply the pupig le 47
L { c : 0} Pupig Le gives gic uer such tht: Pick y strig w L with legth w We pick: w c 48
L { c : 0} w c We c write: w uvxy with legths vxy vy 1 d 49
L { c : 0} w c w uvxy vxy vy 1 Pupig Le sys: uv i xy i L for ll i 0 50
L { c : 0} w c w uvxy vxy vy 1 We exie ll the possile loctios of strig vxy i w 51
L { c : 0} w c w uvxy vxy vy 1 Cse 1: vxy is withi...... ccc... ccc u vxy 5
L { c : 0} w c w uvxy vxy vy 1 Cse 1: v d y oly coti...... ccc... ccc u vxy 53
L { c : 0} w c w uvxy vxy vy 1 Cse 1: Repetig v d y k 1 k...... ccc... ccc u xy v 54
L { c : 0} w c w uvxy vxy vy 1 Cse 1: Fro Pupig Le: uv xy L k 1 k...... ccc... ccc u xy v 55
L { c : 0} w c w uvxy vxy vy 1 Cse 1: Fro Pupig Le: uv xy L k 1 However: uv xy k c L Cotrdictio!!! 56
L { c : 0} w c w uvxy vxy vy 1 Cse : vxy is withi...... ccc... ccc u vxy 57
L { c : 0} w c w uvxy vxy vy 1 Cse : e lysis s i cse 1...... ccc... ccc u vxy 58
L { c : 0} w c w uvxy vxy vy 1 Cse 3: vxy is withi c...... ccc... ccc u vxy 59
L { c : 0} w c w uvxy vxy vy 1 Cse 3: e lysis s i cse 1...... ccc... ccc u vxy 60
L { c : 0} w c w uvxy vxy vy 1 Cse 4: vxy overlps d...... ccc... ccc u vxy 61
L { c : 0} w c w uvxy vxy vy 1 Cse 4: ucse 1: v y cotis oly cotis oly...... ccc... ccc u vxy 6
L { c : 0} w c w uvxy vxy vy 1 Cse 4: ucse 1: k 1 k k 1 1 v y k cotis oly cotis oly...... ccc... ccc u xy v 63
L { c : 0} w c w uvxy vxy vy 1 Cse 4: Fro Pupig Le: uv xy L k 1 k k 1 1 k...... ccc... ccc u xy v 64
L { c : 0} w c w uvxy vxy vy 1 Cse 4: Fro Pupig Le: uv xy L k1 k 1 However: uv xy k1 k c L Cotrdictio!!! 65
L { c : 0} w c w uvxy vxy vy 1 Cse 4: ucse : v cotis d y oly cotis...... ccc... ccc u vxy 66
L { c : 0} w c w uvxy vxy vy 1 Cse 4: k1 k k v y ucse : cotis d oly cotis 1 k1 k k...... ccc... ccc u xy v 67
L { c : 0} w c w uvxy vxy vy 1 Cse 4: Fro Pupig Le: uv xy L k1 k k 1 k1 k k...... ccc... ccc u xy v 68
L { c : 0} w c w uvxy vxy vy 1 Cse 4: Fro Pupig Le: uv xy L However: k1 k k 1 uv xy k 1 k k c L Cotrdictio!!! 69
L { c : 0} w c w uvxy vxy vy 1 Cse 4: ucse 3: v y oly cotis cotis d...... ccc... ccc u vxy 70
L { c : 0} w c w uvxy vxy vy 1 Cse 4: ucse 3: v y oly cotis cotis d e lysis s for sucse 71
L { c : 0} w c w uvxy vxy vy 1 Cse 5: vxy overlps d c...... ccc... ccc u vxy 7
L { c : 0} w c w uvxy vxy vy 1 Cse 5: e lysis s i cse 4...... ccc... ccc u vxy 73
There re o other cses to cosider vxy (sice, strig cot vxy overlp, d c t the se tie) 74
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 75