1 / 23

Introduction to Computability Theory

Introduction to Computability Theory. Lecture9: The Pumping Lemma for Context Free Languages Prof. Amos Israeli. Introduction and Motivation. In this lecture we present the Pumping Lemma for Context Free Languages .

pahana
Download Presentation

Introduction to Computability Theory

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. Introduction to Computability Theory Lecture9: The Pumping Lemma for Context Free Languages Prof. Amos Israeli

  2. Introduction and Motivation In this lecture we present the Pumping Lemma for Context Free Languages. This lemma enables us to prove that some languages are not CFL and hence are not recognizable by any PDA.

  3. The Pumping Lemma Let A be a context free language. There exists a number p such that for every , if then w may be divided into five parts, satisfying: • for each , it holds that . • . • . Note: Without req. 2 the Theorem is trivial.

  4. Proof Idea If w is “long enough” (to be precisely defined later) it has a large parse tree which has a “long enough” path from its root to one of its leaves. Under these conditions, some variable on should appear twice. This enables pumping of w as demonstrated in the next slide:

  5. Proof Idea R R R R R R R Pumping up Pumping down

  6. Reminder Let T be a binary tree. The 0 -th level of T has nodes. The 1 -th level of T has at most nodes. … The i-th level of T has at most nodes. If T’ is a b-aritree then itsi-thlevel has at most nodes.

  7. The Proof Let G be a grammar for the language L. Let b be the maximum number of symbols (variables and constants) in the right hand side of a rule of G. (Assume ). In any parse tree, T, for generating w from G, a node of T may have no more than b children. If the height of T is h then .

  8. The Proof (cont.) If the height of T is h then . Conversely, If then the height of T is at least . Assume that G has variables. Then we set . Conclusion: For any , if , then the height of any parse tree of w is at least .

  9. The Proof (cont.) To see how pumping works let be the parse tree of with a minimal number of nodes. The height of the tree , is at least , so it has a path, with at least nodes, from its root until some leaf. The path has at least variables and a single terminal.

  10. The Proof (cont.) Since G has variables and has at least variables, there exists a variable, R ,that repeats itself among the lowest variables of , as depictedin the following picture: R R

  11. The Proof (cont.) Each occurrence of R has a sub-tree rooted at it:Let be the word generated by the upper occurrence of R and letx be the word generated by the lower occurrence of R . R R

  12. The Proof (cont.) Since both sub-trees are generated by the same variable, each of thesesub-trees can be replaced by another . This tree is obtained from by substituting the upper sub-tree at the lower occurrence of R. R R R R

  13. The Proof (cont.) The word generated is , and since It is generated by a parse tree ofGwe get . Additionalsubstitutions of the upper sub-tree at the lower occurrence of , yield the conclusion for each R R R R

  14. The Proof (cont.) Substitution of the lower sub-tree atthe upper occurrence of Ryields this pars tree whose generated word is .Since once again this is a legitimate parse tree weget . R

  15. The Proof (cont.) To see that , assume that this isthe situation. In this case, thistree is a parse tree for w with less nodes then , incontradiction with the choice of as a parse treefor w with a minimal number of nodes. R

  16. The Proof (cont.) In order to show that recall that we chose R so that both its occurrences fall within the bottom nodes of the path , where is the longest path of the tree so the height of the red sub-tree is at most and thenumber of its leaves is at most R R

  17. Using the Pumping Lemma Now we use the pumping lemma for CFL to show that the language is not CFL. Assume towards a contradiction that L is CFL and let p be the pumping constant. Consider . Obviously .

  18. Using the Pumping Lemma By the pumping lemma, there exist a partition where , and for each , it holds that . Case 1: Both v and y contain one symbol each:Together they may hold 2 symbols, so in , the third symbol appears less than the other two.

  19. Using the Pumping Lemma Case 2: Either v or y contain two symbols:In this case, the word has more than three blocks of identical letters: In other words: , Q.E.D. quoderatdemonstrandum (Wiktionary) which was to be proved; which was to be demonstrated. Abbreviation: QED

  20. Discussion Some weeks ago we started our quest to find out “What can be computed and what cannot?” So far we identified two classes: RL-s and CFL-s and found some examples which do not belong in neither class

  21. Discussion This is what we got so far: ??? RL-s Ex: CFL-s Ex: Non CFL-s Ex:

  22. Discussion Moreover: Our most complex example, namely, the language is easily recognizable by your everyday computer, so we did not get so far yet.Our next attempt to grasp the essence of “What’s Computable?” are Turing Machines. Some surprises are awaiting…

  23. Recap In this lecture we introduced and proved the Pumping Lemma for CFL-s Using this lemma we managed to prove that the fairly simple language , is not CFL. The next step is to define Turing Machines.

More Related