1 / 75

Reverse of a Regular Language

Reverse of a Regular Language. Proof idea:. Construct NFA that accepts :. invert the transitions of the NFA that accepts. Theorem:. The reverse of a regular language is a regular language. Proof. Since is regular, there is NFA that accepts. Example:.

hollie
Télécharger la présentation

Reverse of a Regular Language

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. Reverse of a Regular Language

  2. Proof idea: Construct NFA that accepts : invert the transitions of the NFA that accepts Theorem: The reverse of a regular language is a regular language

  3. Proof Since is regular, there is NFA that accepts Example:

  4. Invert Transitions

  5. Make old initial state a final state

  6. Add a new initial state

  7. Resulting machine accepts is regular

  8. Grammars

  9. Grammars • Grammars express languages • Example: the English language

  10. A derivation of “the boy walks”:

  11. A derivation of “a dog runs”:

  12. Language of the grammar: L = { “a boy runs”, “a boy walks”, “the boy runs”, “the boy walks”, “a dog runs”, “a dog walks”, “the dog runs”, “the dog walks” }

  13. Notation Variable or Non-terminal Terminal Production rule

  14. Another Example • Grammar: • Derivation of sentence :

  15. Grammar: • Derivation of sentence :

  16. Other derivations:

  17. Language of the grammar

  18. More Notation • Grammar Set of variables Set of terminal symbols Start variable Set of Production rules

  19. Example • Grammar :

  20. More Notation • Sentential Form: • A sentence that contains • variables and terminals • Example: Sentential Forms sentence

  21. We write: • Instead of:

  22. In general we write: • If:

  23. By default:

  24. Example Grammar Derivations

  25. Example Grammar Derivations

  26. Another Grammar Example • Grammar : Derivations:

  27. More Derivations

  28. Language of a Grammar • For a grammar • with start variable : String of terminals

  29. Example • For grammar : Since:

  30. A Convenient Notation

  31. Linear Grammars

  32. Linear Grammars • Grammars with • at most one variable at the right side • of a production • Examples:

  33. A Non-Linear Grammar Grammar :

  34. Another Linear Grammar • Grammar :

  35. Right-Linear Grammars • All productions have form: • Example: or

  36. Left-Linear Grammars • All productions have form: • Example: or

  37. Regular Grammars

  38. Regular Grammars • A regular grammaris any • right-linear or left-linear grammar • Examples:

  39. Observation • Regular grammars generate regular languages • Examples:

  40. Regular Grammars GenerateRegular Languages

  41. Theorem Languages Generated by Regular Grammars Regular Languages

  42. Theorem - Part 1 Languages Generated by Regular Grammars Regular Languages Any regular grammar generates a regular language

  43. Theorem - Part 2 Languages Generated by Regular Grammars Regular Languages Any regular language is generated by a regular grammar

  44. Proof – Part 1 Languages Generated by Regular Grammars Regular Languages The language generated by any regular grammar is regular

  45. The case of Right-Linear Grammars • Let be a right-linear grammar • We will prove: is regular • Proof idea: We will construct NFA • with

  46. Grammar is right-linear Example:

  47. Construct NFA such that • every state is a grammar variable: special final state

  48. Add edges for each production:

More Related