1 / 77

Applications of Regular Closure

Applications of Regular Closure. The intersection of a context-free language and a regular language is a context-free language. Regular Closure. context free. regular. context-free. An Application of Regular Closure. Prove that:. is context-free.

mckile
Download Presentation

Applications of Regular Closure

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. Applications of Regular Closure

  2. The intersection of a context-free language and a regular language is a context-free language Regular Closure context free regular context-free

  3. An Application of Regular Closure Prove that: is context-free

  4. We know: is context-free

  5. We also know: is regular is regular

  6. context-free regular (regular closure) is context-free context-free

  7. Another Application of Regular Closure Prove that: is not context-free

  8. Therefore, is not context free is context-free If (regular closure) Then context-free regular context-free Impossible!!!

  9. Decidable Propertiesof Context-Free Languages

  10. Parsers Membership Algorithms: • Exhaustive search parser • CYK parsing algorithm Membership Question: for context-free grammar find if string

  11. Algorithm: • Remove useless variables • Check if start variable is useless Empty Language Question: for context-free grammar find if

  12. Infinite Language Question: Algorithm: 1. Remove useless variables 2. Remove unit and productions 3. Create dependency graph for variables 4. If there is a loop in the dependency graph then the language is infinite for context-free grammar find if is infinite

  13. Example: Infinite language Dependency graph

  14. The Pumping LemmaforContext-Free Languages

  15. Take an infinite context-free language Generates an infinite number of different strings Example:

  16. A derivation:

  17. Derivation tree string

  18. Derivation tree string repeated

  19. Repeated Part

  20. Another possible derivation

  21. Therefore, the string is also generated by the grammar

  22. We know: We also know this string is generated:

  23. We know: Therefore, this string is also generated:

  24. We know: Therefore, this string is also generated:

  25. We know: Therefore, this string is also generated:

  26. Therefore, knowing that is generated by grammar , we also know that is generated by

  27. In general: We are given an infinite context-free grammar Assume has no unit-productions no -productions

  28. Take a string with length bigger than > (Number of productions) x (Largest right side of a production) Consequence: Some variable must be repeated in the derivation of

  29. String Last repeated variable repeated

  30. Possible derivations:

  31. We know: This string is also generated:

  32. We know: This string is also generated: The original

  33. We know: This string is also generated:

  34. We know: This string is also generated:

  35. We know: This string is also generated:

  36. Therefore, any string of the form is generated by the grammar

  37. Therefore, knowing that we also know that

  38. Observation: Since is the last repeated variable

  39. Observation: Since there are no unit or productions

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

  41. Applicationsof The Pumping Lemma

  42. Non-context free languages Context-free languages

  43. Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages

  44. Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma

  45. Pumping Lemma gives a magic number such that: Pick any string with length We pick:

More Related