# Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.

## Presentation on theme: "Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language."— Presentation transcript:

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 33510 Example Regular expression

Fall 2004COMP 33511 Example Regular expression = {all strings with at least two consecutive 0}

Fall 2004COMP 33512 Example Regular expression = { all strings without two consecutive 0 }

Fall 2004COMP 33513 Equivalent Regular Expressions Definition: Regular expressions and are equivalent if

Fall 2004COMP 33514 Example = { all strings without two consecutive 0 } and are equivalent Reg. expressions

Fall 2004COMP 33515 Regular Expressions and Regular Languages

Fall 2004COMP 33516 Theorem Languages Generated by Regular Expressions Regular Languages

Fall 2004COMP 33517 Theorem - Part 1 1. For any regular expression the language is regular Languages Generated by Regular Expressions Regular Languages

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

Fall 2004COMP 33519 Proof - Part 1 1. For any regular expression the language is regular Proof by induction on the size of

Fall 2004COMP 33520 Induction Basis Primitive Regular Expressions: NFAs regular languages

Fall 2004COMP 33521 Inductive Hypothesis Assume for regular expressions and that and are regular languages

Fall 2004COMP 33522 Inductive Step We will prove: are regular Languages.

Fall 2004COMP 33523 By definition of regular expressions:

Fall 2004COMP 33524 By inductive hypothesis we know: and are regular languages Regular languages are closed under: Union Concatenation Star We also know:

Fall 2004COMP 33525 Therefore: Are regular languages

Fall 2004COMP 33526 And trivially: is a regular language

Fall 2004COMP 33527 Proof – Part 2 2. For any regular language there is a regular expression with Proof by construction of regular expression

Fall 2004COMP 33528 Since is regular, take an NFA that accepts it Single final state

Fall 2004COMP 33529 From, construct an equivalent Generalized Transition Graph in which transition labels are regular expressions Example:

Fall 2004COMP 33530 Another Example:

Fall 2004COMP 33531 Reducing the states:

Fall 2004COMP 33532 Resulting Regular Expression:

Fall 2004COMP 33533 In General Removing states:

Fall 2004COMP 33534 The final transition graph: The resulting regular expression:

Download ppt "Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language."

Similar presentations