1 / 36

Lecture 22 Pumping Lemma for Context Free Languages

Lecture 22 Pumping Lemma for Context Free Languages. CSCE 355 Foundations of Computation. Topics: Normal forms Pumping Lemma for CFLs Closure properties. November 19, 2008. Last Time: Useless symbols: generating symbols, useful symbols Algorithm for generating and reachable symbols

millsb
Download Presentation

Lecture 22 Pumping Lemma for Context Free Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 22Pumping Lemma forContext Free Languages CSCE 355 Foundations of Computation Topics: • Normal forms • Pumping Lemma for CFLs • Closure properties November 19, 2008

  2. Last Time: • Useless symbols: • generating symbols, • useful symbols • Algorithm for generating and reachable symbols • Removal of useless symbols • Removal of epsilon productions; • Removal of unit productions • Chomsky normal form New: • Chomsky normal form • Chomsky Hierarchy • Pumping Lemma for Context Free Languages

  3. Useless symbols: • generating symbols, • useful symbols • Algorithm for generating and reachable symbols • Removal of useless symbols • Removal of epsilon productions; • Removal of unit productions • Chomsky normal form

  4. Chomsky Normal Form A CFG (Context Free Grammar) is in Chomsky Normal form if productions are one of the following two forms: • A  BC • A  a References http://www.chomsky.info/

  5. Conversion to Chomsky Normal Form • Remove: ε-productions, unit productions • A  BCDE • A  abc • In general • For each terminal ‘a’ create a new non-terminal Na with Na a added as a production • A  B1B2…Bk create a new non-terminals C1C2…Ck and replace the production with • A  B1C1 and • Ci  Bi+1Ci+1 for i=1,…k-3 • Ck-2  Bk-1Bk

  6. Example

  7. Regular Grammars A CFG is regular if all productions are of the form: A  a or A  aB Note sentential forms in a derivation based on a regular grammar have a unique form! What is it ? Grammar  NFA construction • Create a state for each nonterminal. • A  aB means δ(A, a) = B and • A  a means δ(A, a) = Qfinal and

  8. Example

  9. Chomsky Hierarchy http://en.wikipedia.org/wiki/Chomsky_hierarchy

  10. Chomsky Hierarchy Venn Diagram

  11. Backus Naur Form (BNF) • Backus Naur Form • N ::= α | … | β (just a CFG) • http://en.wikipedia.org/wiki/Backus-Naur_form • John Backus • Fortran compiler • http://en.wikipedia.org/wiki/John_Backus • Peter Naur • http://en.wikipedia.org/wiki/Peter_Naur

  12. Greibach Normal Form • Each production RHS starts with a terminal • A  aα or S ε • http://en.wikipedia.org/wiki/Greibach_normal_form

  13. Showing Languages are not CFLs Recursive productions A  a A | b B  B a | b D  aDb | d A * α A β

  14. Pumping Lemma for CFLs Let L be a CFL. Then there exists a constant n such that if z is a string in L of length at least n, then we can write z = uvwxy such that • |vwx| =< n • |vx| > 0 • uviwxiy is in L for all i >= 0.

  15. Idea behind proof • Assume CNF (or do for L(G)-{ε}) • Consider Parse Tree • Sufficiently long string z, means the parse tree must be sufficiently big.

  16. Similarities to Pumping Lemma for Regular Languages • Given an arbitrary n. • Carefully choose z in L (depending on n) with |z| >= n. • Then for any partition z = uvwxy that satisfies • |vx| > 0 • |vwx| <= n • We must be able to “pump”, i.e. • uviwxiy is in L for all i >= 0

  17. Example L = {anbncn | n > 0} • Given L as above, suppose we chose n for the Pumping Lemma (for CFLs). • Choose z = • Consider arbitrary partition of z = uvwxy satisfying • | vwx| =< n • |vx| > 0 • Then show …

  18. Example

  19. Homework • 7.1.4 • 7.1.3 • 7.1.6

More Related