automata and formal languages science/4888/crs...solution: use the pumping lemma !!! 9 take an...
TRANSCRIPT
-
Automata and Formal Languages
Lecture 09
Dr. Ahmed Hassan
Computer Sc ience Department
1
-
Books
2
-
PowerPointhttp://www.bu.edu.eg/staff/ahmedaboalatah14-courses/14767
3
-
Pumping lemmaPUMPING LEMMA
4
-
AgendaPumping lemma1
Example 1
Pumping lemma2
Example 2
Example 3
5
-
6
Non-regular languages
(PUMPING LEMMA)
-
7
Regular languages
ba*acb *
...etc
*)( bacb
Non-regular languagesL={ππππ: n β₯ 0}
L={π£π£π : vΟ΅{π, π}β}
-
8
How can we prove that a languageis not regular?
L
Prove that there is no DFA or NFA or REthat accepts L
Difficulty: this is not easy to prove(since there is an infinite number of them)
Solution: use the Pumping Lemma !!!
-
9
Take an infinite regular language L
There exists a DFA that accepts L
mstates
(contains an infinite number of strings)
-
10
mw ||(number of states of DFA)
then, at least one state is repeated in the walk of w
q...... ......1 2 k
Take string with Lw
kw 21
Walk in DFA of
Repeated state in DFA
-
11
Take to be the first state repeatedq
q....
w
There could be many states repeated
q.... ....
Second
occurrence
First
occurrence
Unique states
One dimensional projection of walk :
1 2 k
i j
1i 1j
-
12
q.... q.... ....
Second
occurrence
First
occurrence
1 2 kij1i 1j
wOne dimensional projection of walk :
ix 1 jiy 1 kjz 1
xyzw We can write
-
13
zyxw
q... ...
x
y
z
In DFA:
...
...
1 ki1ij
1j
contains only first occurrence of q
-
14
Observation: myx ||length numberof statesof DFA
Since, in no state is repeated
(except q)
xy
Unique States
q...
x
y
...
1 i1ij
-
15
Observation: 1|| ylength
Since there is at least one transition in loop
q
y
...
1ij
-
16
The string is accepted
zxAdditional string:
q... ...
x z
...
Do not follow loopy
...
1 ki1ij
1j
-
17
The string is accepted
zyyx
q... ... ...
x z
Follow loop2 times
Additional string:
y
...
1 ki1ij
1j
-
18
The string is accepted
zyyyx
q... ... ...
x z
Follow loop3 times
Additional string:
y
...
1 ki1ij
1j
-
19
The string is accepted
zyx iIn General:
...,2,1,0i
q... ... ...
x z
Follow looptimesi
y
...
1 ki1ij
1j
-
20
Lzyx i Therefore: ...,2,1,0i
Language accepted by the DFA
q... ... ...
x z
y
...
1 ki1ij
1j
-
Pumping lemma(weak) Let L be an infinite regular language over A. then there exist strings
x, y, z β A*, where y β Ζ,
such that
xπ¦πz β L for all i β₯ 0. such that
21
-
Example 1L={ππππ: n β₯ 0}
Let L be is regular and suppose L can be accepted by DFA (M) . Then there exist x , y, z β π΄β , let i=1
By pumping lemma π€ = π₯π¦π§ = ππππ
1. y consists of a's. |xy|=k, y=ππ . xy=ππ
xπ¦2z = ππβπ .π2π . ππβπππ=ππ+πππ is not in L
22
-
Example 12. y consists of b's.
xπ¦2z = ππ .π2π . ππβπππ=ππππ+π not in L
3. y consists of one or more a's followed by one or more b's.
y=ab, x=ππβ1, z= ππβ1
xyz = ππβ1 aπ ππβ1
xπ¦2z = ππβ1 aπππ ππβ1= ππ ππ ππ not in L
23
-
Pumping lemma (strong)Let L be an infinite regular language over A. and suppose L can be accepted by DFA (M) with m states. Then for any string w β L such that |w| β₯ m there exist x , y, z β π΄βsuch that
1. w = xyz , yβ Ζ
2. |xy| β€ m,
3. |y| β₯ 1,
4. π€π = xπ¦πz Ο΅ L for all i β₯0
24
-
Example 1L={ππππ: n β₯ 0}
Let L be is regular and suppose L can be accepted by DFA (M) with m states. Then for any string w β L such that |w| β₯ m there exist x , y, z β π΄βsuch that
w=ππππ w = 2m > m
By pumping lemma π€ = π₯π¦π§ = ππππ
25
-
Example 1w=ππππ w = 2m > m
By pumping lemma π€ = π₯π¦π§ = ππππ
y=ππ , r >0, y >0xy = k β€ π
x= ππβπ , y= ππ, z= ππβπππ
xπ¦2z = ππβπ .π2π . ππβπππ=ππ+πππ
πππ‘ ππ L, Then L is not regular language
26
-
Example 2L={ππ: n is prime} is not regular language
Let L be is regular and suppose L can be accepted by DFA (M) with m states. Then for any string w β L such that |w| β₯ m there exist x , y, z β π΄βsuch that
w=ππ , w = m β₯ m
By pumping lemma w=π₯π¦π§ = ππ
27
-
Example 2w=ππ , w = m=m
By pumping lemma π€ = π₯π¦π§ = ππ, m is prime
y=ππ , r >0, y >0xy = k β€ π
x= ππβπ , y= ππ, z= ππβπ
π€2=xπ¦2z = ππβπ .π2π . ππβπ=ππβπ
π€π+1=xπ¦π+1z = ππβππ(π+1)π . ππβπ
28
-
Example 2π€π+1=xπ¦
π+1z = ππβππ(π+1)π . ππβπ
=πππ+π=ππ(π+1)
r>0 then (r+1)>1 and m is prime then m>1
πππ‘ ππ L, because m(r+1) not prime
Then L is not regular language
29
-
30
?