Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1 Fall 2004COMP 3351 Regular Expressions

2 Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language

3 Fall 2004COMP 3353 Recursive Definition Are regular expressions Primitive regular expressions: Given regular expressions and

4 Fall 2004COMP 3354 Examples A regular expression: Not a regular expression:

5 Fall 2004COMP 3355 Languages of Regular Expressions : language of regular expression Example:

6 Fall 2004COMP 3356 Definition For primitive regular expressions :

7 Fall 2004COMP 3357 Definition (continued) For regular expressions and

8 Fall 2004COMP 3358 Example Regular expression:

9 Fall 2004COMP 3359 Example Regular expression

10 Fall 2004COMP 33510 Example Regular expression

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

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

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

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

15 Fall 2004COMP 33515 Regular Expressions and Regular Languages

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

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

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

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

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

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

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

23 Fall 2004COMP 33523 By definition of regular expressions:

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

25 Fall 2004COMP 33525 Therefore: Are regular languages

26 Fall 2004COMP 33526 And trivially: is a regular language

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

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

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

30 Fall 2004COMP 33530 Another Example:

31 Fall 2004COMP 33531 Reducing the states:

32 Fall 2004COMP 33532 Resulting Regular Expression:

33 Fall 2004COMP 33533 In General Removing states:

34 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


Ads by Google