courtesy costas busch - rpi1 non-regular languages
Post on 21-Dec-2015
228 views
TRANSCRIPT
Courtesy Costas Busch - RPI 1
Non-regular languages
Courtesy Costas Busch - RPI 2
Regular languages
ba* acb *
...etc
*)( bacb
Non-regular languages}0:{ nba nn
}*},{:{ bavvvR
Courtesy Costas Busch - RPI 3
How can we prove that a languageis not regular?
L
Prove that there is no DFA that accepts L
Problem: this is not easy to prove
Solution: the Pumping Lemma !!!
Courtesy Costas Busch - RPI 4
The Pigeonhole Principle
Courtesy Costas Busch - RPI 5
pigeons
pigeonholes
4
3
Courtesy Costas Busch - RPI 6
A pigeonhole mustcontain at least two pigeons
Courtesy Costas Busch - RPI 7
...........
...........
pigeons
pigeonholes
n
m mn
Courtesy Costas Busch - RPI 8
The Pigeonhole Principle
...........
pigeons
pigeonholes
n
m
mn There is a pigeonhole with at least 2 pigeons
Courtesy Costas Busch - RPI 9
The Pigeonhole Principle
and
DFAs
Courtesy Costas Busch - RPI 10
DFA with states 4
1q 2q 3qa
b
4q
b
b b
b
a a
Courtesy Costas Busch - RPI 11
1q 2q 3qa
b
4q
b
b
b
a a
a
In walks of strings:
aab
aa
a no stateis repeated
Courtesy Costas Busch - RPI 12
In walks of strings:
1q 2q 3qa
b
4q
b
b
b
a a
a
...abbbabbabb
abbabb
bbaa
aabb a stateis repeated
Courtesy Costas Busch - RPI 13
If string has length :
1q 2q 3qa
b
4q
b
b
b
a a
a
w 4|| w
Thus, a state must be repeated
Then the transitions of string are more than the states of the DFA
w
Courtesy Costas Busch - RPI 14
In general, for any DFA:
String has length number of states w
A state must be repeated in the walk of wq
q...... ......
walk of w
Repeated state
Courtesy Costas Busch - RPI 15
In other words for a string : transitions are pigeons
states are pigeonholesq
a
w
q...... ......
walk of w
Repeated state
Courtesy Costas Busch - RPI 16
The Pumping Lemma
Courtesy Costas Busch - RPI 17
Take an infinite regular languageL
There exists a DFA that accepts L
mstates
Courtesy Costas Busch - RPI 18
Take string with w Lw
There is a walk with label :w
.........
walk w
Courtesy Costas Busch - RPI 19
If string has length w mw || (number of statesof DFA)
then, from the pigeonhole principle: a state is repeated in the walkw
q...... ......
walk w
Courtesy Costas Busch - RPI 20
q
q...... ......
walk w
Let be the first state repeated in thewalk of w
Courtesy Costas Busch - RPI 21
Write zyxw
q...... ......
x
y
z
Courtesy Costas Busch - RPI 22
q...... ......
x
y
z
Observations: myx ||length numberof statesof DFA1|| ylength
Courtesy Costas Busch - RPI 23
The string is accepted
zxObservation:
q...... ......
x
y
z
Courtesy Costas Busch - RPI 24
The string is accepted
zyyxObservation:
q...... ......
x
y
z
Courtesy Costas Busch - RPI 25
The string is accepted
zyyyxObservation:
q...... ......
x
y
z
Courtesy Costas Busch - RPI 26
The string is accepted
zyx iIn General:
...,2,1,0i
q...... ......
x
y
z
Courtesy Costas Busch - RPI 27
Lzyx i ∈In General: ...,2,1,0i
q...... ......
x
y
z
Language accepted by the DFA
Courtesy Costas Busch - RPI 28
In other words, we described:
The Pumping Lemma !!!
Courtesy Costas Busch - RPI 29
The Pumping Lemma:
• Given a infinite regular language L
• there exists an integer m
• for any string with length Lw mw ||
• we can write zyxw
• with andmyx || 1|| y
• such that: Lzyx i ...,2,1,0i
Courtesy Costas Busch - RPI 30
Applications
of
the Pumping Lemma
Courtesy Costas Busch - RPI 31
Theorem:The language }0:{ nbaL nn
is not regular
Proof: Use the Pumping Lemma
Courtesy Costas Busch - RPI 32
Assume for contradictionthat is a regular languageL
Since is infinitewe can apply the Pumping Lemma
L
}0:{ nbaL nn
Courtesy Costas Busch - RPI 33
Let be the integer in the Pumping Lemma
Pick a string such that: w Lw
mw ||length
mmbawWe pick
m
}0:{ nbaL nn
Courtesy Costas Busch - RPI 34
it must be that length
From the Pumping Lemma 1||,|| ymyx
babaaaaabaxyz mm ............
1, kay k
x y z
m m
Write: zyxba mm
Thus:
Courtesy Costas Busch - RPI 35
From the Pumping Lemma: Lzyx i
...,2,1,0i
Thus:
mmbazyx
Lzyx 2
1, kay k
Courtesy Costas Busch - RPI 36
From the Pumping Lemma:
Lbabaaaaaaazxy ...............2
x y z
km m
Thus:
Lzyx 2
mmbazyx 1, kay k
y
Lba mkm
Courtesy Costas Busch - RPI 37
Lba mkm
}0:{ nbaL nnBUT:
Lba mkm
CONTRADICTION!!!
1≥k
Courtesy Costas Busch - RPI 38
Our assumption thatis a regular language is not true
L
Conclusion: L is not a regular language
Therefore:
Courtesy Costas Busch - RPI 39
Regular languages
Non-regular languages }0:{ nba nn
Courtesy Costas Busch - RPI 40
Regular languages
Non-regular languages *}:{ vvvL R
Courtesy Costas Busch - RPI 41
Theorem:The language
is not regular
Proof: Use the Pumping Lemma
*}:{ vvvL R },{ ba
Courtesy Costas Busch - RPI 42
Assume for contradictionthat is a regular languageL
Since is infinitewe can apply the Pumping Lemma
L
*}:{ vvvL R
Courtesy Costas Busch - RPI 43
mmmm abbaw We pick
Let be the integer in the Pumping Lemma
Pick a string such that: w Lw
mw ||length
m
and
*}:{ vvvL R
Courtesy Costas Busch - RPI 44
Write zyxabba mmmm
it must be that length
From the Pumping Lemma
ababbabaaaaxyz ..................
x y z
m m m m
1||,|| ymyx
1, kay kThus:
Courtesy Costas Busch - RPI 45
From the Pumping Lemma: Lzyx i
...,2,1,0i
Thus: Lzyx 2
1, kay kmmmm abbazyx
Courtesy Costas Busch - RPI 46
From the Pumping Lemma:
Lababbabaaaaaazxy ∈.....................=2
x y z
km + m m m
1, kay k
y
Lzyx 2
Thus:
mmmm abbazyx
Labba mmmkm
Courtesy Costas Busch - RPI 47
Labba mmmkm
Labba mmmkm
BUT:
CONTRADICTION!!!
1k
*}:{ vvvL R
Courtesy Costas Busch - RPI 48
Our assumption thatis a regular language is not true
L
Conclusion: L is not a regular language
Therefore:
Courtesy Costas Busch - RPI 49
Regular languages
Non-regular languages
}0,:{ lncbaL lnln
Courtesy Costas Busch - RPI 50
Theorem:The language
is not regular
Proof: Use the Pumping Lemma
}0,:{ lncbaL lnln
Courtesy Costas Busch - RPI 51
Assume for contradictionthat is a regular languageL
Since is infinitewe can apply the Pumping Lemma
L
}0,:{ lncbaL lnln
Courtesy Costas Busch - RPI 52
mmm cbaw 2We pick
Let be the integer in the Pumping Lemma
Pick a string such that: w Lw
mw ||length
m
}0,:{ lncbaL lnln
and
Courtesy Costas Busch - RPI 53
Write zyxcba mmm 2
it must be that length
From the Pumping Lemma
cccbcabaaaaaxyz ..................
x y z
m m m2
1||,|| ymyx
1, kay kThus:
Courtesy Costas Busch - RPI 54
From the Pumping Lemma: Lzyx i
...,2,1,0i
Thus:
mmm cbazyx 2
Lxzzyx ∈=0
1, kay k
Courtesy Costas Busch - RPI 55
From the Pumping Lemma:
Lcccbcabaaaxz ...............
x z
km m m2
mmm cbazyx 2 1, kay k
Lxz
Thus: Lcba mmkm 2
Courtesy Costas Busch - RPI 56
Lcba mmkm 2
Lcba mmkm 2
BUT:
CONTRADICTION!!!
}0,:{ lncbaL lnln
1k
Courtesy Costas Busch - RPI 57
Our assumption thatis a regular language is not true
L
Conclusion: L is not a regular language
Therefore:
Courtesy Costas Busch - RPI 58
Regular languages
Non-regular languages }0:{ ! naL n
Courtesy Costas Busch - RPI 59
Theorem:The language
is not regular
Proof: Use the Pumping Lemma
}0:{ ! naL n
nnn )1(21!
Courtesy Costas Busch - RPI 60
Assume for contradictionthat is a regular languageL
Since is infinitewe can apply the Pumping Lemma
L
}0:{ ! naL n
Courtesy Costas Busch - RPI 61
!mawWe pick
Let be the integer in the Pumping Lemma
Pick a string such that: w Lw
mw ||length
m
}0:{ ! naL n
Courtesy Costas Busch - RPI 62
Write zyxam !
it must be that length
From the Pumping Lemma
aaaaaaaaaaaxyz m ...............!
x y z
m mm !
1||,|| ymyx
mkay k 1,Thus:
Courtesy Costas Busch - RPI 63
From the Pumping Lemma: Lzyx i
...,2,1,0i
Thus:
!mazyx
Lzyx 2
mkay k 1,
Courtesy Costas Busch - RPI 64
From the Pumping Lemma:
Laaaaaaaaaaaazxy ..................2
x y z
km mm !
Thus:
!mazyx mkay k 1,
Lzyx 2
y
La km !
Courtesy Costas Busch - RPI 65
La km !
!! pkm
}0:{ ! naL nSince:
mk 1
There must exist such that: p
Courtesy Costas Busch - RPI 66
However:
)!1(
)1(!
!!
!!
!
m
mm
mmm
mm
mmkm ! for 1m
)!1(! mkm
!! pkm for any p
Courtesy Costas Busch - RPI 67
La km !
La km !
BUT:
CONTRADICTION!!!
}0:{ ! naL n
mk 1
Courtesy Costas Busch - RPI 68
Our assumption thatis a regular language is not true
L
Conclusion: L is not a regular language
Therefore:
69
SummaryShowing regularconstruct DFA, NFAconstruct regular expressionshow L is the union, concatenation, intersection (regular operations) of regular languages.
Showing non-regularpumping lemmaassume regular, apply closure properties of regular languages and obtain a known non-regular language.