SLIDE 1
Properties of Context-Free Languages Wen-Guey Tzeng Computer - - PowerPoint PPT Presentation
Properties of Context-Free Languages Wen-Guey Tzeng Computer - - PowerPoint PPT Presentation
Properties of Context-Free Languages Wen-Guey Tzeng Computer Science Department National Chiao Tung University Pumping Lemma for CFL Let L be a CFL. There is a constant integer m. For any w L, |w| m, we can decompose w into
SLIDE 2
SLIDE 3
Pumping Lemma for CFL
- Let L be a CFL.
– There is a constant integer m. – For any wL, |w|m, we can decompose w into u, v, x, y, z with
- w=uvxyz
- |vxy|m
- |vy| 1
– such that uvixyiz L for all i=0, 1, 2, …
2 2017 Spring
SLIDE 4
Example: G=({S, A, B, C,}, T, S, P) in CNF, w=bbaabbab
3
- For every path longer than
5 = |V|+1, there are repetitive internal nodes.
- S-A-B-A-C-a
S C A A S B C B A B C B B b a b b a b B C b a
2017 Spring
SLIDE 5
Abstract:
- S uAz uvAyz uvxyz=w
- S uAz uvAyz
uvvAyyz … uviAyiz uvixyiz for any i 0
- For w to have a high derivation
tree with h >= |V|+1, |w| >= 2|V|=m
4 2017 Spring
SLIDE 6
SLIDE 7
Example
- Show that L={: {a, b}*} is not context-free.
5 2017 Spring
SLIDE 8
6 2017 Spring
SLIDE 9
SLIDE 10
Example
- Show that L={anbncn : n0} is not context-free.
7 2017 Spring
SLIDE 11
Example
- Show that L={anbj : n=j2 } is not context-free.
8 2017 Spring
SLIDE 12
9 2017 Spring
SLIDE 13
SLIDE 14
Closure Properties
- The family of CFL’s are closed under
– Union – Concatenation – star closure.
- Assume that L1 and L2 are two CFL’s with CFG
G1={V1, T, S1, P1} and G1={V2, T, S2, P2}. Assume that V1V2=.
– Construct G3 for L3=L1L2 – Construct G4 for L4=L1L2 – Construct G5 for L5=L1
*
10 2017 Spring
SLIDE 15
- G3
- G4
- G5
11 2017 Spring
SLIDE 16
Non-closed operations
- The family of CFL’s are NOT closed under
– intersection – complementation
- Why?
12 2017 Spring
SLIDE 17
- Not closed under intersection
– Why? – Example,
- L1={anbncm : n, m0}, L2={anbmcm : n, m0} are both
context-free
- But, L3=L1L2={anbncn : n0} is not context-free
13 2017 Spring
SLIDE 18
- Not closed under complementation.
– Otherwise, L3= L1L2 = comp(comp(L1)comp(L2)) is context-free. – Example
- L2=Comp(L1) is context-free, where L1={anbncn : n0}
- But, Comp(L2) = L1 is not context-free
14 2017 Spring
SLIDE 19
Closed: regular intersection
- If L1 is context-free and L2 is regular, then
L1L2 is context-free.
- Why?
15 2017 Spring
SLIDE 20
SLIDE 21
- Example
– Show that L={w{a, b, c}* : na(w)=nb(w)=nc(w)} is not context free. – Consider regular language L2=L(a*b*c*). – L3 = LL2 = {anbncn : n0} is not context-free – Thus, L is not context-free.
16 2017 Spring
SLIDE 22