1 / 72

Pumping Lemma for Context-free Languages

Pumping Lemma for Context-free Languages. Take an infinite context-free language. Generates an infinite number of different strings. Example:. In a derivation of a “long” enough string, variables are repeated. A possible derivation:. Derivation Tree. Repeated variable. Derivation Tree.

swann
Download Presentation

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. Pumping LemmaforContext-free Languages Prof. Busch - LSU

  2. Take an infinite context-free language Generates an infinite number of different strings Example: Prof. Busch - LSU

  3. In a derivation of a “long” enough string, variables are repeated A possible derivation: Prof. Busch - LSU

  4. Derivation Tree Repeated variable Prof. Busch - LSU

  5. Derivation Tree Repeated variable Prof. Busch - LSU

  6. Prof. Busch - LSU

  7. Prof. Busch - LSU

  8. Prof. Busch - LSU

  9. Putting all together Prof. Busch - LSU

  10. We can remove the middle part Prof. Busch - LSU

  11. Prof. Busch - LSU

  12. We can repeated middle part two times 1 2 Prof. Busch - LSU

  13. Prof. Busch - LSU

  14. We can repeat middle part three times 1 2 3 Prof. Busch - LSU

  15. Prof. Busch - LSU

  16. Repeat middle part times 1 i Prof. Busch - LSU

  17. For any Prof. Busch - LSU

  18. From Grammar and given string We inferred that a family of strings is in for any Prof. Busch - LSU

  19. Arbitrary Grammars Consider now an arbitrary infinite context-free language Let be the grammar of Take so that it has no unit-productions and no -productions (remove them) Prof. Busch - LSU

  20. Let be the number of variables Let be the maximum right-hand size of any production Example: Prof. Busch - LSU

  21. Claim: Take string with . Then in the derivation tree of there is a path from the root to a leaf where a variable of is repeated Proof: Proof by contradiction Prof. Busch - LSU

  22. Derivation tree of We will show: some variable is repeated Prof. Busch - LSU

  23. First we show that the tree of has at least levels of nodes Suppose the opposite: At most Levels Prof. Busch - LSU

  24. Maximum number of nodes per level Level 0: nodes Level 1: nodes nodes The maximum right-hand side of any production Prof. Busch - LSU

  25. Maximum number of nodes per level Level 0: nodes Level 1: nodes Level 2: nodes nodes nodes nodes Prof. Busch - LSU

  26. Maximum number of nodes per level Level 0: nodes At most Level : nodes Levels Level : nodes Maximum possible string length = max nodes at level = Prof. Busch - LSU

  27. Therefore, maximum length of string : However we took, Contradiction!!! Therefore, the tree must have at least levels Prof. Busch - LSU

  28. Thus, there is a path from the root to a leaf with at least nodes (root) At least Variables Levels symbol (leaf) Prof. Busch - LSU

  29. Since there are at most different variables, some variable is repeated Pigeonhole principle END OF CLAIM PROOF Prof. Busch - LSU

  30. Take now a string with From claim: some variable is repeated subtree of Take to be the deepest, so that only is repeated in subtree Prof. Busch - LSU

  31. We can write yield yield yield yield yield Strings of terminals Prof. Busch - LSU

  32. Example: Prof. Busch - LSU

  33. Possible derivations Prof. Busch - LSU

  34. Example: Prof. Busch - LSU

  35. Remove Middle Part Yield: Prof. Busch - LSU

  36. Repeat Middle part two times 1 2 Yield: Prof. Busch - LSU

  37. Prof. Busch - LSU

  38. Repeat Middle part times 1 i Yield: Prof. Busch - LSU

  39. Prof. Busch - LSU

  40. Therefore, If we know that: then we also know: For all since Prof. Busch - LSU

  41. Observation 1: Since has no unit and -productions At least one of or is not Prof. Busch - LSU

  42. Observation 2: since in subtree only variable is repeated subtree of Explanation follows…. Prof. Busch - LSU

  43. subtree of Various yields since no variable is repeated in Maximum right-hand side of any production Prof. Busch - LSU

  44. Thus, if we choose critical length then, we obtain the pumping lemma for context-free languages Prof. Busch - LSU

  45. The Pumping Lemma: For any infinite context-free language there exists an integer such that for any string we can write with lengths and it must be that: Prof. Busch - LSU

  46. Applicationsof The Pumping Lemma Prof. Busch - LSU

  47. Non-context free languages Context-free languages Prof. Busch - LSU

  48. Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages Prof. Busch - LSU

  49. Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma Prof. Busch - LSU

  50. Let be the critical length of the pumping lemma Pick any string with length We pick: Prof. Busch - LSU

More Related