270 likes | 474 Views
Properties of Context-Free Languages. Is a certain language context-free? Is the family of CFLs closed under a certain operation?. Pumping Lemma. Let L be an infinite CFL. Then there exists m 0 such that any w L with |w| m can be decomposed as w = uvxyz where: |vy| 1
E N D
Properties of Context-Free Languages • Is a certain language context-free? • Is the family of CFLs closed under a certain operation?
Pumping Lemma Let L be an infinite CFL. Then there exists m 0 such that any w L with |w| m can be decomposed as w = uvxyz where: • |vy| 1 • |vxy| m • uvixyiz L for all i 0
Pumping Lemma Proof: The RL case: S * xA * xyA * xyz The CFL case: S * uAz * uvAyz * uvxyz
Moves in the Game • The opponent picks m 0. • We choose w L with |w| m. • The opponent chooses the decomposition w = uvxyz such that |vy| 1 and |vxy| m. • We pick i such that uvixyiz L.
Example Prove L = {ww | w {a, b}*} is not a CFL.
Moves in the Game • The opponent picks m 0.
Moves in the Game • The opponent picks m 0. • We choose w = ambmambm.
Moves in the Game • The opponent picks m 0. • We choose w = ambmambm. • The opponent chooses the decomposition w = uvxyz such that |vy| 1 and |vxy| m. m m m m a . . . a b . . . b a . . . a b . . . b u v x y z
Moves in the Game • The opponent picks m 0. • We choose w = ambmambm. • The opponent chooses the decomposition w = uvxyz such that |vy| 1 and |vxy| m. m m m m a . . . a b . . . b a . . . a b . . . b u v x y z • We pick i such that uvixyiz L.
Example Prove L = {anbncn | n 0} is not a CFL.
Linear Context-Free Languages A CFL L is said to be linear iff there exists a linear CFG G such that L = L(G). (A grammar is linear iff at most 1 variable can occur on the right side of any production)
Pumping Lemma for Linear CFLs Let L be an infinite linear CFL. Then there exists m 0 such that any w L with |w| m can be decomposed as w = uvxyz where: • |vy| 1 • |uvyz| m • uvixyiz L for all i 0
Moves in the Game • The opponent picks m 0. • We choose w L with |w| m. • The opponent chooses the decomposition w = uvxyz such that |vy| 1 and |uvyz| m. • We pick i such that uvixyiz L.
Example Prove L = {w | na(w) = nb(w)} is not linear.
Closure Properties of Context-Free Languages L1 and L2 are context-free. How about L1L2, L1L2, L1L2,L1,L1*?
Theorem If L1 and L2 are context-free, then so are L1L2, L1L2,L1*. (The family of context-free languages is closed under union, concatenation, and star-closure.)
Proof • G1 = (V1, T1, S1, P1) G2 = (V2, T2, S2, P2) G3 = (V1V2{S3}, T1T2, S3, P1P2{S3 S1 | S2}) L(G3) = L(G1)L(G2)
Proof • G1 = (V1, T1, S1, P1) G2 = (V2, T2, S2, P2) G4 = (V1V2{S4}, T1T2, S4, P1P2{S4 S1S2}) L(G4) = L(G1).L(G2)
Proof • G1 = (V1, T1, S1, P1) G5 = (V1{S5}, T1, S5, P1{S5 S1S5 | }) L(G5) = L(G1)*
Theorem The family of context-free languages is not closed under intersection and complement.
Proof • L1 = {anbncm | n 0, m 0} L2 = {anbmcm | n 0, m 0} L = {anbncn | n 0} = L1L2
Proof • L1L2= L1L2
Homework • Exercises: 2, 7, 8, 9, 14, 15, 16 of Section 8.1. • Exercises: 2, 4, 10, 15 of Section 8.2. • Presentations: Section 12.1: Computability and Decidability + Halting Problem Section 13.1: Recursive Functions Post Systems + Church's Thesis Section 13.2: Measures of Complexity + Complexity Classes