1 Let’s Recapitulate
Apr 01, 2015
1
Let’s Recapitulate
2
Regular Languages
DFAs
NFAsRegularExpressions
RegularGrammars
3
A standard representationof a regular language :
L
A DFA that accepts M L
A NFA that accepts M L
A regular expression that generates
RL
A regular grammar that generates
GL
4
When we say:
“We are given a Regular Language “
We mean:
L
Language in a standard representation
5
Elementary Questions
about
Regular Languages
6
Question:Given regular languagehow can we checkif a string ?
L
Lw
7
Question:Given regular languagehow can we checkif a string ?
L
Lw
Answer: Take the DFA that acceptsand check if is accepted
Lw
8
Question:Given regular languagehow can we checkif is empty, finite, infinite ?
L
L
Answer: Take the DFA that accepts
Then check the DFA
L
)( L
9
If there is a walk from the start stateto a final state then: is not emptyL
If the walk contains a cycle then:
is infiniteL
Otherwise finite
Otherwise empty
10
Question:
Given regular languages and how can we check if ?
1L 2L
21 LL
11
Question:
Given regular languages and how can we check if ?
1L 2L
21 LL
Answer:
)()( 2121 LLLLL take
And find if L
12
Question:
Given languagehow can we checkif is not a regular language ?
L
L
13
Question:
Given languagehow can we checkif is not a regular language ?
L
L
Answer: The answer is not obvious
We need the Pumping Lemma
14
The Pigeonhole Principle
15
4 pigeons
3 pigeonholes
16
A pigeonhole musthave two pigeons
17
...........
...........
pigeons
pigeonholes
n
m
mn
18
The Pigeonhole Principle
...........
pigeons
pigeonholes
n
m
mn There is a pigeonhole with at least 2 pigeons
19
The Pigeonhole Principle
and
DFAs
20
DFA with states 4
1q 2q 3qa
b
2q
b
b b
b
a a
21
1q 2q 3qa
b
2q
b
b
b
a a
a
In walks of strings:
aab
aa
a no stateis repeated
22
In walks of strings:
1q 2q 3qa
b
2q
b
b
b
a a
a
...abbbabbabb
abbabb
bbaa
aabba stateis repeated
23
If the walk of string has length
1q 2q 3qa
b
2q
b
b
b
a a
a
w 4|| w
Then a state is repeated
24
If in a walk: transitions states
Then: A state is repeated
1q 2q 3qa
b
2q
b
b
b
a a
a
The pigeonhole principle:
25
In other words: transitions are pigeons
states are pigeonholes
1q 2q 3qa
b
2q
b
b
b
a a
a
q
a
26
In general:
A string has length number of states w
A state must be repeated in the walk wq
q...... ......
27
The Pumping Lemma
28
Take an infinite regular languageL
DFA that accepts L
mstates
29
Take string
with
w
Lw
There is a walk with label :w
.........
30
If string has length w mw || number of states
Then, from the pigeonhole principle: A state is repeated in the walkq w
q...... ......
31
Write zyxw
q...... ......
x
y
z
32
q...... ......
x
y
z
Observations : myx ||length numberof states
1|| ylength
33
The string is accepted zxObservation:
q...... ......
x
y
z
34
The string is accepted
zyyxObservation:
q...... ......
x
y
z
35
The string is accepted
zyyyxObservation:
q...... ......
x
y
z
36
The string is accepted
zyx iIn General:
q...... ......
x
y
z
...,2,1,0i
37
In other words, we described:
The Pumping Lemma
38
The Pumping Lemma:
1. Given a infinite regular language L
2. There exists an integer m
3. For any string with length Lw mw ||
4. We can write zyxw
5. With andmyx || 1|| y
6. Such that: string Lzyx i
...,2,1,0i
39
Applications of
the Pumping Lemma
40
Claim:
The language }0:{ nbaL nn
is not regular
Proof:
Use the Pumping Lemma
41
Proof:
Assume for contradictionthat is a regular languageL
Since is infinitewe can apply the Pumping Lemma
L
42
mLet be the integerin the Pumping Lemma
Pick a string such that: w Lw
mw ||length
Example: mmbawpick
43
Write zyxba mm
it must be that length
From the Pumping Lemma myx ||
Therefore:babaaaa ............
kay x y z
m m
44
From the Pumping Lemma: Lzyx i
...,2,1,0i
Thus:
mmbazyx kay
Lbazyyxzyx mkm 2
Lzyx 2
45
Lba mkm Therefore,
}0:{ nbaL nnBUT:
and
Lba mkm
CONTRADICTION!!!
46
Our assumption thatis a regular languagecannot be true
L
CONCLUSION:
L is not a regular language
Therefore:
47
Claim:
The language *}:{ wwwL R
is not regular
Proof:
Use the Pumping Lemma
48
Proof:
Assume for contradictionthat is a regular languageL
Since is infinitewe can apply the Pumping Lemma
L
49
mLet be the integerin the Pumping Lemma
Pick a string such that: w Lw
mw ||length
Example: mmmm abbawpick
50
Write zyxabba mmmm
it must be that length
From the Pumping Lemma myx ||
Therefore:ababbabaaaa ..................
kay x y z
m m m m
51
From the Pumping Lemma: Lzyx i
...,2,1,0i
Thus:
mmmm abbazyx kay
Labbazyyxzyx mmmkm 2
Lzyx 2
52
Labba mmmkm Therefore,
BUT:
and
Labba mmmkm
CONTRADICTION!!!
*}:{ wwwL R
53
Our assumption thatis a regular languagecannot be true
L
CONCLUSION:
L is not a regular language
Therefore: