Language Recognition (12.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the course http://www.cs.rpi.edu/courses/spring05/modcomp/ and …
Three Equivalent Representations Regular expressions Each can describe the others Regular languages Finite automata Kleene’s Theorem: For every regular expression, there is a deterministic finite-state automaton that defines the same language, and vice versa.
EXAMPLE 1 Consider the language { ambn | 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.
Regular Expression Regular Grammar a* S | aS (a+b)* S | aS | bS a* + b* S | A | B A a | aA B b | bB a*b S b | aS ba* S bA A | aA (ab)* S | abS
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 sA, in particular, start symbol S is associated with the start state sS. Every transition is associated with a grammar production: T(sA,a) = sB A aB. Every production B is associated with final state sB.
Equivalent FSA and regular grammar, Ex. 4, p. 772. G=(V,T,S,P) V={S, A, B, 0, 1} with S=s0, A=s1, and B=s2, T={0,1}, and productions are S 0A | 1B | 1 | λ A 0A | 1B | 1 B 0A | 1B | 1 | λ
Kleene’s Theorem Languages Generated by Languages Recognized by FSA Regular Expressions Languages Recognized by FSA
We will show: Languages Generated by Regular Expressions Languages Recognized by FSA Languages Generated by Regular Expressions Languages Recognized by FSA
For any regular expression Proof - Part 1 Languages Generated by Regular Expressions Languages Recognized by FSA For any regular expression the language is recognized by FSA (= is a regular language) Proof by induction on the size of
Induction Basis Primitive Regular Expressions: NFAs regular languages
Inductive Hypothesis Assume for regular expressions and that and are regular languages
Inductive Step We will prove: Are regular Languages
By definition of regular expressions:
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.
Therefore: Are regular languages And trivially: is a regular language
Proof - Part 2 Languages Generated by Languages Recognized by FSA Regular Expressions Languages Recognized by FSA For any regular language there is a regular expression with Proof by construction of regular expression
Since is regular take the NFA that accepts it Single final state
From construct the equivalent Generalized Transition Graph in which transition labels are regular expressions Example:
Another Example:
Reducing the states:
Resulting Regular Expression:
In General Removing states:
The final transition graph: The resulting regular expression:
Three Equivalent Representations Regular expressions Each can describe the others Regular languages Finite automata