Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Language Recognition (11.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the courseCostas Busch

Similar presentations


Presentation on theme: "1 Language Recognition (11.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the courseCostas Busch"— Presentation transcript:

1 1 Language Recognition (11.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the courseCostas Busch http://www.cs.rpi.edu/courses/spring05/modcomp/ http://www.cs.rpi.edu/courses/spring05/modcomp/ and …

2 2 Three Equivalent Representations Finite automata Regular expressions Regular languages Each can describe the others Kleene’s Theorem: For every regular expression, there is a deterministic finite-state automaton that defines the same language, and vice versa.

3 3 EXAMPLE 1 Consider the language { a m b n | m, n  N}, which is represented by the regular expression a*b*. A regular grammar for this language can be written as follows: S   | aS | B B  b | bB.

4 4 Regular ExpressionRegular Grammar a*S   | aS (a+b)*S   | aS | bS a* + b*S   | A | B A  a | aA B  b | bB a*bS  b | aS ba*S  bA A   | aA (ab)*S   | abS

5 5 NFAs  Regular grammars Thus, the language recognized by FSA is a regular language Every NFA can be converted into a corresponding regular grammar and vice versa. Each symbol A of the grammar is associated with a non- terminal node of the NFA s A, in particular, start symbol S is associated with the start state s S. Every transition is associated with a grammar production: T(s A,a) = s B  A  aB. Every production B   is associated with final state s B.

6 6 Equivalent FSA and regular grammar, Ex. 4, p. 772. G=(V,T,S,P) V={S, A, B, 0, 1} with S=s 0, A=s 1, and B=s 2, T={0,1}, and productions are S  0A | 1B | 1 | λ A  0A | 1B | 1 B  0A | 1B | 1 | λ

7 7 Kleene’s Theorem Languages Generated by Regular Expressions Languages Recognized by FSA

8 8 Languages Generated by Regular Expressions Languages Recognized by FSA Languages Generated by Regular Expressions Languages Recognized by FSA We will show:

9 9 Proof - Part 1 For any regular expression the language is recognized by FSA (= is a regular language) Languages Generated by Regular Expressions Languages Recognized by FSA Proof by induction on the size of

10 10 Induction Basis Primitive Regular Expressions: NFAs regular languages

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

12 12 Inductive Step We will prove: Are regular Languages

13 13 By definition of regular expressions:

14 14 By inductive hypothesis we know: and are regular languages Regular languages are closed under: Union Concatenation Star We need to show: This fact is illustrated in Fig. 2 on p. 769.

15 15 Therefore: Are regular languages And trivially:is a regular language

16 16 Proof - Part 2 Languages Generated by Regular Expressions Languages Recognized by FSA For any regular language there is a regular expression with Proof by construction of regular expression

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

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

19 19 Another Example:

20 20 Reducing the states:

21 21 Resulting Regular Expression:

22 22 In General Removing states:

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

24 24 Three Equivalent Representations Finite automata Regular expressions Regular languages Each can describe the others


Download ppt "1 Language Recognition (11.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the courseCostas Busch"

Similar presentations


Ads by Google