1 / 34

Regular Expressions

Regular Expressions. Regular Expressions. Regular expressions describe regular languages Example: describes the language. Given regular expressions and. Are regular expressions. Recursive Definition. Primitive regular expressions:. Not a regular expression:.

adortch
Download Presentation

Regular Expressions

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. Regular Expressions COMP 335

  2. Regular Expressions • Regular expressions • describe regular languages • Example: • describes the language COMP 335

  3. Given regular expressions and Are regular expressions Recursive Definition Primitive regular expressions: COMP 335

  4. Not a regular expression: Examples A regular expression: COMP 335

  5. Languages of Regular Expressions • : language of regular expression • Example: COMP 335

  6. Definition • For primitive regular expressions : COMP 335

  7. Definition (continued) • For regular expressions and COMP 335

  8. Example • Regular expression: COMP 335

  9. Example • Regular expression COMP 335

  10. Example • Regular expression COMP 335

  11. = {all strings with at least two consecutive 0} Example • Regular expression COMP 335

  12. = { all strings without two consecutive 0 } Example • Regular expression COMP 335

  13. Equivalent Regular Expressions • Definition: • Regular expressions and • are equivalent if COMP 335

  14. and are equivalent Reg. expressions Example = { all strings without two consecutive 0 } COMP 335

  15. Regular ExpressionsandRegular Languages COMP 335

  16. Theorem Languages Generated by Regular Expressions Regular Languages COMP 335

  17. 1. For any regular expression the language is regular Theorem - Part 1 Languages Generated by Regular Expressions Regular Languages COMP 335

  18. 2. For any regular language , there is a regular expression with Theorem - Part 2 Languages Generated by Regular Expressions Regular Languages COMP 335

  19. 1. For any regular expression the language is regular Proof by induction on the size of Proof - Part 1 COMP 335

  20. NFAs regular languages Induction Basis • Primitive Regular Expressions: COMP 335

  21. Inductive Hypothesis • Assume for regular expressions and • that and are regular languages COMP 335

  22. Inductive Step • We will prove: are regular Languages. COMP 335

  23. By definition of regular expressions: COMP 335

  24. We also know: Regular languages are closed under: Union Concatenation Star By inductive hypothesis we know: and are regular languages COMP 335

  25. Therefore: Are regular languages COMP 335

  26. And trivially: is a regular language COMP 335

  27. Proof – Part 2 2. For any regular language there is a regular expression with Proof by construction of regular expression COMP 335

  28. Since is regular, take an • NFA that accepts it Single final state COMP 335

  29. From , construct an equivalent • Generalized Transition Graph in which • transition labels are regular expressions Example: COMP 335

  30. Another Example: COMP 335

  31. Reducing the states: COMP 335

  32. Resulting Regular Expression: COMP 335

  33. In General • Removing states: COMP 335

  34. The final transition graph: The resulting regular expression: COMP 335

More Related