properties of context-free languages
DESCRIPTION
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 - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/1.jpg)
1
Properties of Context-Free Languages
• Is a certain language context-free?
• Is the family of CFLs closed under a certain operation?
![Page 2: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/2.jpg)
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
• uvixyiz L for all i 0
![Page 3: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/3.jpg)
3
Pumping Lemma
Proof:
The RL case: S * xA * xyA * xyz
The CFL case: S * uAz * uvAyz * uvxyz
![Page 4: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/4.jpg)
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 uvixyiz L.
![Page 5: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/5.jpg)
5
Example
Prove L = {ww | w {a, b}*} is not a CFL.
![Page 6: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/6.jpg)
6
Moves in the Game
1. The opponent picks m 0.
![Page 7: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/7.jpg)
7
Moves in the Game
1. The opponent picks m 0.
2. We choose w = ambmambm.
![Page 8: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/8.jpg)
8
Moves in the Game
1. The opponent picks m 0.
2. We choose w = ambmambm.
3. 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
![Page 9: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/9.jpg)
9
Moves in the Game
1. The opponent picks m 0.
2. We choose w = ambmambm.
3. 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
4. We pick i such that uvixyiz L.
![Page 10: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/10.jpg)
10
Example
Prove L = {anbncn | n 0} is not a CFL.
![Page 11: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/11.jpg)
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)
![Page 12: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/12.jpg)
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
• uvixyiz L for all i 0
![Page 13: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/13.jpg)
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 uvixyiz L.
![Page 14: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/14.jpg)
14
Example
Prove L = {w | na(w) = nb(w)} is not linear.
![Page 15: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/15.jpg)
15
Closure Properties of Context-Free Languages
L1 and L2 are context-free.
How about L1L2, L1L2 , L1L2 , L1, L1* ?
![Page 16: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/16.jpg)
16
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.)
![Page 17: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/17.jpg)
17
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)
![Page 18: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/18.jpg)
18
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)
![Page 19: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/19.jpg)
19
Proof
• G1 = (V1, T1, S1, P1)
G5 = (V1{S5}, T1, S5, P1{S5 S1S5 | })
L(G5) = L(G1)*
![Page 20: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/20.jpg)
20
Theorem
The family of context-free languages is not closed under intersection and complement.
![Page 21: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/21.jpg)
21
Proof
• L1 = {anbncm | n 0, m 0}
L2 = {anbmcm | n 0, m 0}
L = {anbncn | n 0} = L1L2
![Page 22: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/22.jpg)
22
Proof
• L1L2 = L1L2
![Page 23: Properties of Context-Free Languages](https://reader033.vdocument.in/reader033/viewer/2022050909/568159a5550346895dc70357/html5/thumbnails/23.jpg)
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