1 / 38

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:.

roth-roth
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

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

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

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

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

  6. Definition • For primitive regular expressions:

  7. Definition (continued) • For regular expressions and

  8. Example • Regular expression:

  9. Example • Regular expression

  10. Example • Regular expression

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

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

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

  14. and are equivalent regular expr. Example = { all strings without two consecutive 0 }

  15. Regular ExpressionsandRegular Languages

  16. Theorem Languages Generated by Regular Expressions Regular Languages

  17. We will show: Languages Generated by Regular Expressions Regular Languages Languages Generated by Regular Expressions Regular Languages

  18. For any regular expression the language is regular Proof by induction on the size of Proof - Part 1 Languages Generated by Regular Expressions Regular Languages

  19. NFAs regular languages Induction Basis • Primitive Regular Expressions:

  20. Inductive Hypothesis • Assume • for regular expressions and • that • and are regular languages

  21. Inductive Step • We will prove: Are regular Languages

  22. By definition of regular expressions:

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

  24. Therefore: Are regular languages

  25. And trivially: is a regular language

  26. For any regular language there is a regular expression with Proof - Part 2 Languages Generated by Regular Expressions Regular Languages Proof by construction of regular expression

  27. Standard Representations of Regular Languages Regular Languages FAs Regular Expressions NFAs

  28. When we say: We are given a Regular Language We mean: Language is in a standard representation

  29. Elementary QuestionsaboutRegular Languages

  30. Answer: Take the DFA that accepts and check if is accepted Membership Question Question: Given regular language and string how can we check if ?

  31. DFA DFA

  32. Question: Given regular language how can we check if is empty: ? Answer: Take the DFA that accepts Check if there is any path from the initial state to a final state

  33. DFA DFA

  34. Question: Given regular language how can we check if is finite? Answer: Take the DFA that accepts Check if there is a walk with cycle from the initial state to a final state

  35. DFA is infinite DFA is finite

  36. Answer: Find if Question: Given regular languages and how can we check if ?

  37. and

  38. or

More Related