Professional Documents
Culture Documents
Lesson 07 GTG-Kleens Theorem
Lesson 07 GTG-Kleens Theorem
2
Example continued …
a+b a+b
aa+bb
- +
3
Example
4
Example
a+
b+
+ + +
a b+
–
b+ b+
a+
+ +
a+
5
Example
6
Example Continued …
b(a+b)*a
-
a( a+b)* b
b(a+b)*a + a( a+b)* b
- +
8
Example
9
Example Continued …
a+b a+b
aaa+bbb
- +
OR
(a+b)*(aaa+bbb)(a+b)*
- +
10
Nondeterminism
11
Kleene’s Theorem
12
Kleene’s Theorem continued …
13
Kleene’s Theorem continued …
14
Kleene’s Theorem continued …
15
Kleene’s Theorem part II
continued …
b
b
1- 3+
aa
a
a
2- 4+
bb
17
Example Continued ...
b
b
1 3+
Λ aa
- a
Λ a
2 4+
bb
18
Kleene’s Theorem part II
continued …
Step 2:
If a TG has more than one final states, then
introduce a new final state, connecting the old
final states to the new final state by the
transitions labeled by Λ.
This step can be shown by the previous
example of TG, where the step 1 has already
been processed
19
Example
b
b
1 3+
Λ aa
- a
Λ a
2 4+
bb
20
Example continued …
b
b
1 3
Λ aa Λ
- a +
Λ a Λ
2 4
bb
21
Kleene’s Theorem part II
continued …
Step 3:
If a state has two (more than one) incoming
transition edges labeled by the corresponding
REs, from the same state (including the
possibility of loops at a state), then replace all
these transition edges with a single transition
edge labeled by the sum of corresponding REs.
This step can be shown by a part of TG in the
following example
22
Example
r3
r1
…. 4 5 ….
r2
r4
The above TG can be reduced to
r3+r4
r1+r2
…. 4 5 ….
23
Note
The step 3 can be generalized to any finite
number of transitions as shown below
r1
r2
…. 5 ….
….
rn
The above TG can be reduced to
r1+r2 + … +rn
…. 5 ….
24
Kleene’s Theorem part II
continued …
25
Example
r3
r2 r4
…. 4 5 6 ….
r2r3*r4
…. 4 6 ….
r1r2*r3
…. 2 4 ….
27
Example
28
Example continued ...
…. ….
2 4
r6 + r8r5*r4
To eliminate state 4 the above TG can be
reduced to
(r1 +r3 r5* r4 )+(r2 +r3 r5* r7 )(r9 +r8 r5* r7 )*(r6 +r8 r5* r4 )
…. ….
2 29
Note
30
Example
aa,b
2+
aaa
ab,ba
- 1
bba
3+
31
Example continued …
aa+b
2
aaa Λ
ab+ba
- 1
4+
bba Λ
3
- (ab+ba)(aa+b)*(aaa+bba)
+
33
Example
1- 3+
aa
a
a
2- 4+
bb
To have single initial and single final state the
above TG can be reduced to the following
34
Example continued …
b
b
1 3
Λ aa Λ
- a +
Λ a Λ
2 4
bb
To obtain single transition edge between 1 and
3; 2 and 4, the above can be reduced to the
following
35
Example continued …
b
b+aa 3
1 Λ
Λ
- a +
Λ Λ
2 a+bb 4
To eliminate states 1,2,3 and 4, the above TG
can be reduced to the following TG
Λ(b+aa)b*Λ
- +
Λ(a+bb)a*Λ 36
Example continued …
(b+aa)b*
- +
(a+bb)a*
- (b+aa)b*+(a+bb)a* +
aa,bb aa,bb
ab,ba
-+1 2
ab,ba
38
Example continued ...
39
Example continued ...
aa+bb aa+bb
ab+ba
3- Λ 1 2
ab+ba
Λ
4+
To eliminate state 2, the above TG may be
reduced to the following
40
Example continued ...
aa+bb
3- Λ 1 (ab+ba)(aa+bb)*(ab+ba)
4+
41
Example continued ...
(aa+bb)+(ab+ba)(aa+bb)*(ab+ba)
3- Λ 1
4+
42
Example continued ...
Λ(aa+bb+(ab+ba)(aa+bb)*(ab+ba))*Λ
3- 4+
43
Kleene’s Theorem Part III
Statement:
If the language can be expressed by a RE then
there exists an FA accepting the language.
A) As the regular expression is obtained applying
addition, concatenation and closure on the
letters of an alphabet and the Null string, so
while building the RE, sometimes, the
corresponding FA may be built easily, as shown
in the following examples
44
Example
a b
1 - +
a, b
which shows that this FA helps in building an FA
accepting only one letter
45
Example
a, b
±
46
Kleene’s Theorem Part III
Continued …
47
Kleene’s Theorem Part III
Continued …
48
Example
X1 – +
X2
a*
and r2 = (a+b ) aa(a+b ) defines L2 and FA2 be
*
b a,b
a
y2 a
y1- y3+
b 49
Sum of two FAs Continued …
X1 – +
X2
b a a,b
a
y2 a
y1– y3+
b
New states after reading
Old states
a b
53
Example continued …
Z2
a a b
a
b
Z1- a b Z4 + Z5 +
b a
Z3+ b
RE corresponding to the above FA may be
r1+r2 = (a+b)*b + (a+b )*aa(a+b )*
54
Note
Z2
a a b
a
b
Z1- a b Z4 + Z5 +
b a
Z3+ b
X1– X2+
b
also r2 = (a+b)((a+b)(a+b))* or
((a+b)(a+b))*(a+b)
a,b and FA2 be
y1- y2+
a,b 57
Example continued …
b a a
a,b
X1 – +
X2 y1- y2+
a,b
59
Example continued …
z 1- z 2+
b
b b a a
z3+ z4+
b
60
Example
also r2 = (a+b)((a+b)(a+b))* or
((a+b)(a+b))*(a+b)
a,b and FA2 be
y1- y2+
a,b 61
Example continued …
a,b
x1± x2
a,b
a,b
y1- y2+
a,b
63
Example continued …
a,b
z1 ± z2+
a,b
64
Task
x4 a,b
b a b
y1 - y2+
a
65
Kleene’s Theorem Part III
Continued …
66
Example
X1 – +
X2
a
and r2 = (a+b )*aa (a+b )* defines L2 and FA2 be
b a,b
a
y2 a
y1- y3+
b 67
Concatenation of two FAs
Continued …
X1 – +
X2
b a a,b
a
y2 a
y1- y3+
b
New States after reading
Old States
a b
71
Example continued …
b
a
z2 z3
b
b a
a z4+ a
z1-
a
b
b
z6+ z5 + b
a 72
Task
Z2
a a b
a
b
Z1- a b Z4 + Z5 +
b a
Z3+ b
73
Solution of the Task
Z2
a
a a
Z1- a b Z4 +
b b
Z3+ b
74
Task
FA1 x1 - x2 b x3 +
a,b
a
x4 a,b
b a b
y1 - y2+
a
FA2 75
Task solution
x2 b x3 +
x1 - a,b
a
b a b
x4 a,b
y1 - y2+
a
z1
z4 b z5 + b
a
a b
z2+
a a a a
b
b z6+ a z3 b z7+ b
79
Example
y1- y2+
80
a,b
Example continued …
a,b
x1± x2
a,b
a,b
y 1- y2+
a,b
a,b
y1- y2+
a,b
83
Task
x2 b x3 +
FA1 x1 - a,b
a
x4 a,b
b a b
y1 - y2+
a
84
Kleene’s Theorem Part III Continued …
85
Closure of FA Continued …
X1 – X2 +
a
then the FA corresponding to r* may
be determined as under
87
Example continued …
a b b a b
b
–
X1 X2+ X1 – X2+
a a
89
Example continued …
z1±
b a
b a
z3 + z2 a
b
90
Example
91
Example continued …
b a,b
a
y2 a
y1- y3+
b
b a,b
a
y2 a
y 1- y3+
b
New States after reading
Old States
a b
a b
z2y1 y2z3 y1 z2
93
Example continued …
a
b
a a a
z1± z3 z 4+ z5+
a b
b
b
z2
b
94
Example
y4 a,b
95
Example continued …
a,b
y2 b y3 +
y1 - a,b
a
y4 a,b