Fall 2004COMP 3351 Regular Expressions
Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language
Fall 2004COMP 3353 Recursive Definition Are regular expressions Primitive regular expressions: Given regular expressions and
Fall 2004COMP 3354 Examples A regular expression: Not a regular expression:
Fall 2004COMP 3355 Languages of Regular Expressions : language of regular expression Example:
Fall 2004COMP 3356 Definition For primitive regular expressions :
Fall 2004COMP 3357 Definition (continued) For regular expressions and
Fall 2004COMP 3358 Example Regular expression:
Fall 2004COMP 3359 Example Regular expression
Fall 2004COMP Example Regular expression
Fall 2004COMP Example Regular expression = {all strings with at least two consecutive 0}
Fall 2004COMP Example Regular expression = { all strings without two consecutive 0 }
Fall 2004COMP Equivalent Regular Expressions Definition: Regular expressions and are equivalent if
Fall 2004COMP Example = { all strings without two consecutive 0 } and are equivalent Reg. expressions
Fall 2004COMP Regular Expressions and Regular Languages
Fall 2004COMP Theorem Languages Generated by Regular Expressions Regular Languages
Fall 2004COMP Theorem - Part 1 1. For any regular expression the language is regular Languages Generated by Regular Expressions Regular Languages
Fall 2004COMP Theorem - Part 2 Languages Generated by Regular Expressions Regular Languages 2. For any regular language, there is a regular expression with
Fall 2004COMP Proof - Part 1 1. For any regular expression the language is regular Proof by induction on the size of
Fall 2004COMP Induction Basis Primitive Regular Expressions: NFAs regular languages
Fall 2004COMP Inductive Hypothesis Assume for regular expressions and that and are regular languages
Fall 2004COMP Inductive Step We will prove: are regular Languages.
Fall 2004COMP By definition of regular expressions:
Fall 2004COMP By inductive hypothesis we know: and are regular languages Regular languages are closed under: Union Concatenation Star We also know:
Fall 2004COMP Therefore: Are regular languages
Fall 2004COMP And trivially: is a regular language
Fall 2004COMP Proof – Part 2 2. For any regular language there is a regular expression with Proof by construction of regular expression
Fall 2004COMP Since is regular, take an NFA that accepts it Single final state
Fall 2004COMP From, construct an equivalent Generalized Transition Graph in which transition labels are regular expressions Example:
Fall 2004COMP Another Example:
Fall 2004COMP Reducing the states:
Fall 2004COMP Resulting Regular Expression:
Fall 2004COMP In General Removing states:
Fall 2004COMP The final transition graph: The resulting regular expression: