CS 30 - Leture 8 Properties of Cotext Free Graars Fall 008 Review Laguages ad Graars Alphabets, strigs, laguages Regular Laguages Deteriisti Fiite ad Nodeteriisti Autoata Equivalee of NFA ad DFA Regular Expressios Regular Graars Properties of Regular Laguages Laguages that are ot regular ad the pupig lea Cotext Free Laguages Cotext Free Graars Derivatios: leftost, rightost ad derivatio trees Parsig ad abiguity Siplifiatios ad Noral Fors Nodeteriisti Pushdow Autoata Pushdow Autoata ad Cotext Free Graars Deteriisti Pushdow Autoata Pupig Lea for Cotext Free Graars Today: Closure ad Deidable Properties for Cotext Free Laguages Uio Positive Properties of Cotext-Free laguages L L is otext free is otext free Cotext-free laguages are losed uder: Uio L L is otext-free
Exaple I geeral: Laguage b Graar S as b λ For otext-free laguages with otext-free graars ad start variables L, L G, G S, S L = { ww R Uio R b { ww S as a bsb S S S λ The graar of the uio has ew start variable L L S S S S ad additioal produtio Coateatio Cotext-free laguages are losed uder: Coateatio Laguage b Exaple Graar S as b λ L is otext free L = { ww R S as a bsb λ L is otext free L L is otext-free Coateatio R b { ww S S S
I geeral: For otext-free laguages with otext-free graars ad start variables L, L G, G S, S Star Operatio Cotext-free laguages are losed uder: Star-operatio The graar of the oateatio has ew start variable S ad additioal produtio S S S L L L is otext free * L is otext-free Exaple I geeral: Laguage b Graar S asb λ For otext-free laguage with otext-free graar ad start variable L G S b Star Operatio * S SS λ The graar of the star operatio has ew start variable S ad additioal produtio L* S SS λ 3
Itersetio Negative Properties of Cotext-Free Laguages L Cotext-free laguages are ot losed uder: is otext free itersetio L L L is otext free ot eessarily otext-free b Exaple Cotext-free: Cotext-free: b S AC S AB A aab λ A aa λ C C λ B bb λ L b Itersetio NOT otext-free Copleet Cotext-free laguages are ot losed uder: opleet L is otext free L ot eessarily otext-free 4
b Exaple Cotext-free: Cotext-free: Copleet NOT otext-free L L = L b b S AC S AB A aab λ A aa λ C C λ B bb λ Itersetio of Cotext-free laguages ad Regular Laguages The itersetio of a otext-free laguage ad a regular laguage is a otext-free laguage ahie ahie for L DFA for otext-free regular L L L otext free regular L L otext-free Costrut a ew ahie that aepts L L siulates i parallel ad 5
DFA a, b q q a p p trasitio trasitio DFA λ, b q q p trasitio q, p a, b q, p q, p λ, b q, p trasitio trasitio DFA DFA q 0 p 0 q p p iitial state iitial state fial state fial states q 0, p 0 q, p q, p Iitial state fial states 6
Exaple: otext-free * * L = { w w : w = w, w { a, b, w {, d regular * L = { a, DFA a, λ b, λ, λ d, λ a, q λ, λ λ λ, λ λ λ, λ λ 0 q q q3 p 0 otext-free Autoato for: L L = { a : 0 a, λ, λ λ, λ λ λ, λ λ λ, λ λ q0, p 0 q, p 0 q, p0 q 3, p 0 I Geeral: siulates i parallel ad aepts strig w aepts strig if ad oly if w aepts strig w ad L( ) = L( ) L( ) 7
Therefore: is L( ) L( ) is otext-free Appliatios of Regular Closure L L is otext-free The itersetio of a otext-free laguage ad a regular laguage is a otext-free laguage A Appliatio of Regular Closure Prove that: b : 00, 0 L L otext free regular Regular Closure L L otext-free is otext-free 8
We kow: We also kow: { a b : 0 is otext-free 00 00 L = { a b is regular * 00 00 b L = {( a + b) { a is regular { a b otext-free (regular losure) 00 L = {( a + b) { a b { a b L * 00 regular otext-free Aother Appliatio of Regular Closure Prove that: L = { w: a = b = is ot otext-free { a b L = { a b : 00, 0 = L is otext-free 9
If L = { w: a = b = is otext-free The (regular losure) L { a * b* * = { a b otext-free regular otext-free Ipossible!!! Deidable Properties of Cotext-Free Laguages Therefore, L is ot otext free ebership Questio: for otext-free graar fid if strig w L(G) G Epty Laguage Questio: for otext-free graar fid if L(G) = G ebership Algoriths: Parsers Exhaustive searh parser CYK parsig algorith Algorith:. Reove useless variables. Chek if start variable is useless S 0
Ifiite Laguage Questio: Algorith: for otext-free graar fid if is ifiite L(G). Reove useless variables. Reove uit ad produtios λ 3. Create depedey graph for variables 4. If there is a loop i the depedey graph the the laguage is ifiite G Exaple: S AB A acb a B bb bb C BS Depedey graph A S B Ifiite laguage C S AB A acb a B bb bb C BS S AB acbb absbb abbsbbb S abbsbbb ( abb) ( abb) i S( bbb) i S( bbb) Read What s Next Liz Chapter,.,.,.3, (skip.4), 3, 4, 5, 6., 6., (skip 6.3), 7., 7., 7.3, (skip 7.4), 8, ad 9. JFLAP Chapter,., (skip.), 3, 4, 5, 6, 7, (skip 8), 9., 9. Next Leture Topis Fro 9. Turig ahies Quiz 3 i Reitatio o Wedesday / Covers Liz 7., 7., 7.3, (skip 7.4), 8, ad JFLAP 5,6,7 Closed book, but you ay brig oe sheet of 8.5 x ih paper with ay otes you like. Quiz will take the full hour Hoework Hoework Due Today New Hoework Available Friday New Hoework Due Next Thursday