Language Recognition
Language Recognition
4)
Longin Jan Latecki
Temple University
1
Three Equivalent Representations
Regular
expressions
Each
can
describe
the others Regular
Finite
languages
automata
Kleene’s Theorem:
For every regular expression, there is a deterministic
finite-state automaton that defines the same
language, and vice versa.
2
EXAMPLE 1
S | aS | B
B b | bB.
3
Regular Regular Grammar
Expression
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
4
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.
5
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 | λ
6
Kleene’s Theorem
Languages
Generated by
Regular Expressions
Languages
Recognized
by FSA
7
We will show:
Languages
Generated by Languages
Recognized
Regular Expressions by FSA
Languages
Generated by Languages
Recognized
Regular Expressions by FSA
8
Proof - Part 1
Languages
Generated by Languages
Recognized
Regular Expressions by FSA
L( M1 ) L( )
regular
L( M 2 ) {} L( )
languages
a
L( M 3 ) {a} L(a )
10
Inductive Hypothesis
Assume
for regular expressions r1 andr2
that
L(r1 ) and L(r2 ) are regular languages
11
Inductive Step
We will prove:
Lr1 r2
Lr1 r2
Are regular
Languages
Lr1 *
Lr1
12
By definition of regular expressions:
Lr1 Lr1
13
By inductive hypothesis we know:
L(r1 )and L(r2 ) are regular languages
We need to show:
Regular languages are closed under:
Union Lr1 Lr2
Concatenation Lr1 Lr2
Star Lr1 *
This fact is illustrated in Fig. 2 on p. 769.
14
Therefore:
Lr1 r2 Lr1 Lr2
Are regular
Lr1 r2 Lr1 Lr2
languages
Languages
Generated by Languages
Recognized
Regular Expressions by FSA
L ( M ) L
Example:
M
a c a c
a, b a b
18
b b
Another Example:
a
q0 q1 a, b q2
b
b b
a
q0 q1 a b q2
b
19
b b
Reducing the states:
a
q0 q1 a b q2
b
bb * a b
q0 bb * (a b) q2
20
Resulting Regular Expression:
bb * a b
q0 bb * (a b) q2
r (bb * a ) * bb * (a b)b *
L ( r ) L ( M ) L
21
In General
Removing states: e
d c
qi q qj
a b
ae * d ce * b
ce * d
qi qj
ae * b
22
The final transition graph:
r1 r4
r3
q0 qf
r2
L ( r ) L ( M ) L
23
Three Equivalent Representations
Regular
expressions
Each
can
describe
the others Regular
Finite
languages
automata
24