510 likes | 819 Views
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:.
E N D
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: Examples A regular expression:
Languages of Regular Expressions • : language of regular expression • Example
Definition • For primitive regular expressions:
Definition (continued) • For regular expressions and
Example • Regular expression:
Example • Regular expression
Example • Regular expression
= { all strings with at least two consecutive 0 } Example • Regular expression
= { all strings without two consecutive 0 } Example • Regular expression
Equivalent Regular Expressions • Definition: • Regular expressions and • are equivalent if
and are equivalent regular expr. Example = { all strings without two consecutive 0 }
Theorem Languages Generated by Regular Expressions Regular Languages
We will show: Languages Generated by Regular Expressions Regular Languages Languages Generated by Regular Expressions Regular Languages
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
NFAs regular languages Induction Basis • Primitive Regular Expressions:
Inductive Hypothesis • Assume • for regular expressions and • that • and are regular languages
Inductive Step • We will prove: Are regular Languages
We also know: Regular languages are closed under: Union Concatenation Star By inductive hypothesis we know: and are regular languages
Therefore: Are regular languages
And trivially: is a regular language
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
Standard Representations of Regular Languages Regular Languages FAs Regular Expressions NFAs
When we say: We are given a Regular Language We mean: Language is in a standard representation
Answer: Take the DFA that accepts and check if is accepted Membership Question Question: Given regular language and string how can we check if ?
DFA DFA
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
DFA DFA
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
DFA is infinite DFA is finite
Answer: Find if Question: Given regular languages and how can we check if ?