properties of context free languages
play

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


  1. Properties of Context-Free Languages Wen-Guey Tzeng Computer Science Department National Chiao Tung University

  2. 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 uv i xy i z  L for all i=0, 1, 2, … 2017 Spring 2

  3. Example: G=({S, A, B, C,}, T, S, P) in CNF, w=bbaabbab • For every path longer than S 5 = |V|+1, there are repetitive internal nodes. C A • S-A-B-A-C-a A S B C b a B B A B b b B C B C b a b a 2017 Spring 3

  4. Abstract: • S  uAz  uvAyz  uvxyz=w • S  uAz  uvAyz  uvvAyyz  …  uv i Ay i z  uv i xy i z for any i  0 • For w to have a high derivation tree with h >= |V|+1, |w| >= 2 |V| =m 2017 Spring 4

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

  6. 2017 Spring 6

  7. Example • Show that L={a n b n c n : n  0} is not context-free. 2017 Spring 7

  8. Example • Show that L={a n b j : n=j 2 } is not context-free. 2017 Spring 8

  9. 2017 Spring 9

  10. Closure Properties • The family of CFL’s are closed under – Union – Concatenation – star closure. • Assume that L 1 and L 2 are two CFL’s with CFG G 1 ={V 1 , T, S 1 , P 1 } and G 1 ={V 2 , T, S 2 , P 2 }. Assume that V 1  V 2 =  . – Construct G 3 for L 3 =L 1  L 2 – Construct G 4 for L 4 =L 1  L 2 – Construct G 5 for L 5 =L 1 * 2017 Spring 10

  11. • G 3 • G 4 • G 5 2017 Spring 11

  12. Non-closed operations • The family of CFL’s are NOT closed under – intersection – complementation • Why? 2017 Spring 12

  13. • Not closed under intersection – Why? – Example, • L 1 ={a n b n c m : n, m  0}, L 2 ={a n b m c m : n, m  0} are both context-free • But, L 3 =L 1  L 2 ={a n b n c n : n  0} is not context-free 2017 Spring 13

  14. • Not closed under complementation. – Otherwise, L 3 = L 1  L 2 = comp(comp(L 1 )  comp(L 2 )) is context-free. – Example • L 2 =Comp(L 1 ) is context-free, where L 1 ={a n b n c n : n  0} • But, Comp(L 2 ) = L 1 is not context-free 2017 Spring 14

  15. Closed: regular intersection • If L 1 is context-free and L 2 is regular, then L 1  L 2 is context-free. • Why? 2017 Spring 15

  16. • Example – Show that L={w  {a, b, c}* : n a (w)=n b (w)=n c (w)} is not context free. – Consider regular language L 2 =L(a*b*c*). – L 3 = L  L 2 = {a n b n c n : n  0} is not context-free – Thus, L is not context-free. 2017 Spring 16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend