Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.

Similar presentations


Presentation on theme: "1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language."— Presentation transcript:

1 1 Regular Expressions

2 2 Regular expressions describe regular languages Example: describes the language

3 3 Recursive Definition Are regular expressions Primitive regular expressions: Given regular expressions and

4 4 Examples A regular expression: Not a regular expression:

5 5 Languages of Regular Expressions : language of regular expression Example

6 6 Definition For primitive regular expressions:

7 7 Definition (continued) For regular expressions and

8 8 Example Regular expression:

9 9 Example Regular expression

10 10 Example Regular expression

11 11 Example Regular expression = { all strings with at least two consecutive 0 }

12 12 Example Regular expression = { all strings without two consecutive 0 }

13 13 Equivalent Regular Expressions Definition: Regular expressions and are equivalent if

14 14 Example = { all strings without two consecutive 0 } and are equivalent regular expr.

15 15 Regular Expressions and Regular Languages

16 16 Theorem Languages Generated by Regular Expressions Regular Languages

17 17 Languages Generated by Regular Expressions Regular Languages Generated by Regular Expressions Regular Languages We will show:

18 18 Proof - Part 1 For any regular expression the language is regular Languages Generated by Regular Expressions Regular Languages Proof by induction on the size of

19 19 Induction Basis Primitive Regular Expressions: NFAs regular languages

20 20 Inductive Hypothesis Assume for regular expressions and that and are regular languages

21 21 Inductive Step We will prove: Are regular Languages

22 22 By definition of regular expressions:

23 23 By inductive hypothesis we know: and are regular languages Regular languages are closed under: Union Concatenation Star We also know:

24 24 Therefore: Are regular languages

25 25 And trivially: is a regular language

26 26 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

27 27 Since is regular take the NFA that accepts it Single final state

28 28 From construct the equivalent Generalized Transition Graph in which transition labels are regular expressions Example:

29 29 Another Example:

30 30 Reducing the states:

31 31 Resulting Regular Expression:

32 32 In General Removing states:

33 33 The final transition graph: The resulting regular expression:

34 34 Standard Representations of Regular Languages Regular Languages FAs NFAs Regular Expressions

35 35 When we say: We are given a Regular Language We mean:Language is in a standard representation

36 36 Elementary Questions about Regular Languages

37 37 Membership Question Question:Given regular language and string how can we check if ? Answer:Take the DFA that accepts and check if is accepted

38 38 DFA

39 39 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 Question: Answer:

40 40 DFA

41 41 Given regular language how can we check if is finite? Take the DFA that accepts Check if there is a walk with cycle from the initial state to a final state Question: Answer:

42 42 DFA is infinite DFA is finite

43 43 Given regular languages and how can we check if ? Question: Find if Answer:

44 44 and

45 45 or


Download ppt "1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language."

Similar presentations


Ads by Google