Properties of Context-Free Languages Wen-Guey Tzeng Computer - - PowerPoint PPT Presentation

properties of context free languages
SMART_READER_LITE
LIVE PREVIEW

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-1
SLIDE 1

Properties of Context-Free Languages

Wen-Guey Tzeng Computer Science Department National Chiao Tung University

slide-2
SLIDE 2
slide-3
SLIDE 3

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 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
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
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 6
slide-7
SLIDE 7

Example

  • Show that L={: {a, b}*} is not context-free.

5 2017 Spring

slide-8
SLIDE 8

6 2017 Spring

slide-9
SLIDE 9
slide-10
SLIDE 10

Example

  • Show that L={anbncn : n0} is not context-free.

7 2017 Spring

slide-11
SLIDE 11

Example

  • Show that L={anbj : n=j2 } is not context-free.

8 2017 Spring

slide-12
SLIDE 12

9 2017 Spring

slide-13
SLIDE 13
slide-14
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 V1V2=.

– Construct G3 for L3=L1L2 – Construct G4 for L4=L1L2 – Construct G5 for L5=L1

*

10 2017 Spring

slide-15
SLIDE 15
  • G3
  • G4
  • G5

11 2017 Spring

slide-16
SLIDE 16

Non-closed operations

  • The family of CFL’s are NOT closed under

– intersection – complementation

  • Why?

12 2017 Spring

slide-17
SLIDE 17
  • Not closed under intersection

– Why? – Example,

  • L1={anbncm : n, m0}, L2={anbmcm : n, m0} are both

context-free

  • But, L3=L1L2={anbncn : n0} is not context-free

13 2017 Spring

slide-18
SLIDE 18
  • Not closed under complementation.

– Otherwise, L3= L1L2 = comp(comp(L1)comp(L2)) is context-free. – Example

  • L2=Comp(L1) is context-free, where L1={anbncn : n0}
  • But, Comp(L2) = L1 is not context-free

14 2017 Spring

slide-19
SLIDE 19

Closed: regular intersection

  • If L1 is context-free and L2 is regular, then

L1L2 is context-free.

  • Why?

15 2017 Spring

slide-20
SLIDE 20
slide-21
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 = LL2 = {anbncn : n0} is not context-free – Thus, L is not context-free.

16 2017 Spring

slide-22
SLIDE 22