Download presentation
Presentation is loading. Please wait.
Published byAlfred Sutton Modified over 9 years ago
1
1 Properties of Context-Free Languages Is a certain language context-free? Is the family of CFLs closed under a certain operation?
2
2 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 uv i xy i z L for all i 0
3
3 Pumping Lemma Proof: The RL case: S * xA * xyA * xyz The CFL case: S * uAz * uvAyz * uvxyz
4
4 Moves in the Game 1.The opponent picks m 0. 2.We choose w L with |w| m. 3.The opponent chooses the decomposition w = uvxyz such that |vy| 1 and |vxy| m. 4.We pick i such that uv i xy i z L.
5
5 Example Prove L = {ww | w {a, b}*} is not a CFL.
6
6 Moves in the Game 1.The opponent picks m 0.
7
7 Moves in the Game 1.The opponent picks m 0. 2.We choose w = a m b m a m b m.
8
8 Moves in the Game 1.The opponent picks m 0. 2.We choose w = a m b m a m b m. 3.The opponent chooses the decomposition w = uvxyz such that |vy| 1 and |vxy| m. m m m m a... a b... b u v x y z
9
9 Moves in the Game 1.The opponent picks m 0. 2.We choose w = a m b m a m b m. 3.The opponent chooses the decomposition w = uvxyz such that |vy| 1 and |vxy| m. m m m m a... a b... b u v x y z 4.We pick i such that uv i xy i z L.
10
10 Example Prove L = {a n b n c n | n 0} is not a CFL.
11
11 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)
12
12 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 uv i xy i z L for all i 0
13
13 Moves in the Game 1.The opponent picks m 0. 2.We choose w L with |w| m. 3.The opponent chooses the decomposition w = uvxyz such that |vy| 1 and |uvyz| m. 4.We pick i such that uv i xy i z L.
14
14 Example Prove L = {w | n a (w) = n b (w)} is not linear.
15
15 Closure Properties of Context-Free Languages L 1 and L 2 are context-free. How about L 1 L 2, L 1 L 2, L 1 L 2, L 1, L 1 * ?
16
16 Theorem If L 1 and L 2 are context-free, then so are L 1 L 2, L 1 L 2, L 1 *. (The family of context-free languages is closed under union, concatenation, and star-closure.)
17
17 Proof G 1 = (V 1, T 1, S 1, P 1 ) G 2 = (V 2, T 2, S 2, P 2 ) G 3 = (V 1 V 2 {S 3 }, T 1 T 2, S 3, P 1 P 2 {S 3 S 1 | S 2 }) L(G 3 ) = L(G 1 ) L(G 2 )
18
18 Proof G 1 = (V 1, T 1, S 1, P 1 ) G 2 = (V 2, T 2, S 2, P 2 ) G 4 = (V 1 V 2 {S 4 }, T 1 T 2, S 4, P 1 P 2 {S 4 S 1 S 2 }) L(G 4 ) = L(G 1 ).L(G 2 )
19
19 Proof G 1 = (V 1, T 1, S 1, P 1 ) G 5 = (V 1 {S 5 }, T 1, S 5, P 1 {S 5 S 1 S 5 | }) L(G 5 ) = L(G 1 )*
20
20 Theorem The family of context-free languages is not closed under intersection and complement.
21
21 Proof L 1 = {a n b n c m | n 0, m 0} L 2 = {a n b m c m | n 0, m 0} L = {a n b n c n | n 0} = L 1 L 2
22
22 Proof L 1 L 2 = L 1 L 2
23
23 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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.