Regular Expressions 1 Regular Expressions Regular expressions describe
Regular Expressions 1
Regular Expressions Regular expressions describe regular languages Example: describes the language 2
Recursive Definition Primitive regular expressions: Given regular expressions and Are regular expressions 3
Examples A regular expression: Not a regular expression: 4
Languages of Regular Expressions : language of regular expression Example 5
Definition For primitive regular expressions: 6
Definition (continued) For regular expressions and 7
Example Regular expression: 8
Example Regular expression 9
Example Regular expression 10
Example Regular expression = { all strings with at least two consecutive 0 } 11
Example Regular expression = { all strings without two consecutive 0 } 12
Equivalent Regular Expressions Definition: Regular expressions and are equivalent if 13
Example = { all strings without two consecutive 0 } and are equivalent regular expr. 14
Regular Expressions and Regular Languages 15
Theorem Languages Generated by Regular Expressions Regular Languages 16
We will show: Languages Generated by Regular Expressions Regular Languages 17
Proof - Part 1 Languages Generated by Regular Expressions Regular Languages For any regular expression the language is regular Proof by induction on the size of 18
Induction Basis Primitive Regular Expressions: NFAs regular languages 19
Inductive Hypothesis Assume for regular expressions and that and are regular languages 20
Inductive Step We will prove: Are regular Languages 21
By definition of regular expressions: 22
By inductive hypothesis we know: and are regular languages We also know: Regular languages are closed under: Union Concatenation Star 23
Therefore: Are regular languages 24
And trivially: is a regular language 25
Proof - Part 2 Languages Generated by Regular Expressions Regular Languages For any regular language there is a regular expression with Proof by construction of regular expression 26
Since NFA is regular take that accepts it Single final state 27
From construct the equivalent Generalized Transition Graph in which transition labels are regular expressions Example: 28
Another Example: 29
Reducing the states: 30
Resulting Regular Expression: 31
In General Removing states: 32
The final transition graph: The resulting regular expression: 33
Standard Representations of Regular Languages FAs NFAs Regular Expressions 34
When we say: We mean: We are given a Regular Language is in a standard representation 35
Elementary Questions about Regular Languages 36
Membership Question: Answer: Given regular language and string how can we check if ? Take the DFA that accepts and check if is accepted 37
DFA 38
Question: Answer: Given regular language how can we check if is empty: ? Take the DFA that accepts Check if there is any path from the initial state to a final state 39
DFA 40
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 41
DFA is infinite DFA is finite 42
Question: Given regular languages how can we check if Answer: and ? Find if 43
and 44
or 45
- Slides: 45