Costas Busch - RPI 1
Standard Representations of Regular Languages
Regular Languages
DFAs
NFAsRegularExpressions
RegularGrammars
Costas Busch - RPI 2
When we say: We are given a Regular Language
We mean:
L
Language is in a standard representation
L
Costas Busch - RPI 3
Elementary Questions
about
Regular Languages
Costas Busch - RPI 4
Membership Question
Question: Given regular languageand string how can we check if ?
L
Lw w
Answer: Take the DFA that acceptsand check if is accepted
Lw
Costas Busch - RPI 5
DFA
Lw
DFA
Lw
w
w
Costas Busch - RPI 6
Given regular languagehow can we checkif is empty: ?
L
L
Take the DFA that accepts
Check if there is any path from the initial state to a final state
L
)( L
Question:
Answer:
Costas Busch - RPI 7
DFA
L
DFA
L
Costas Busch - RPI 8
Given regular languagehow can we checkif is finite?
L
L
Take the DFA that accepts
Check if there is a walk with cyclefrom the initial state to a final state
L
Question:
Answer:
Costas Busch - RPI 9
DFA
L is infinite
DFA
L is finite
Costas Busch - RPI 10
Given regular languages and how can we check if ?
1L 2L
21 LL Question:
)()( 2121 LLLLFind ifAnswer:
Costas Busch - RPI 11
)()( 2121 LLLL
21 LL 21 LLand
21 LL
1L 2L 1L2L
21 LL 12 LL 2L 1L
Costas Busch - RPI 12
)()( 2121 LLLL
21 LL 21 LLor
1L 2L 1L2L
21 LL 12 LL
21 LL
Costas Busch - RPI 13
Non-regular languages
Costas Busch - RPI 14
Regular languages
ba* acb *
...etc
*)( bacb
Non-regular languages}0:{ nba nn
}*},{:{ bavvvR
Costas Busch - RPI 15
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 !!!
Costas Busch - RPI 16
The Pigeonhole Principle
Costas Busch - RPI 17
pigeons
pigeonholes
4
3
Costas Busch - RPI 18
A pigeonhole mustcontain at least two pigeons
Costas Busch - RPI 19
...........
...........
pigeons
pigeonholes
n
m mn
Costas Busch - RPI 20
The Pigeonhole Principle
...........
pigeons
pigeonholes
n
m
mn There is a pigeonhole with at least 2 pigeons
Costas Busch - RPI 21
The Pigeonhole Principle
and
DFAs
Costas Busch - RPI 22
DFA with states 4
1q 2q 3qa
b
4q
b
b b
b
a a
Costas Busch - RPI 23
1q 2q 3qa
b
4q
b
b
b
a a
a
In walks of strings:
aab
aa
a no stateis repeated
Costas Busch - RPI 24
In walks of strings:
1q 2q 3qa
b
4q
b
b
b
a a
a
...abbbabbabb
abbabb
bbaa
aabb a stateis repeated
Costas Busch - RPI 25
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
Costas Busch - RPI 26
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
Costas Busch - RPI 27
In other words for a string : transitions are pigeons
states are pigeonholesq
a
w
q...... ......
walk of w
Repeated state
Costas Busch - RPI 28
The Pumping Lemma
Costas Busch - RPI 29
Take an infinite regular languageL
There exists a DFA that accepts L
mstates
Costas Busch - RPI 30
Take string with w Lw
There is a walk with label :w
.........
walk w
Costas Busch - RPI 31
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
Costas Busch - RPI 32
q
q...... ......
walk w
Let be the first state repeated in thewalk of w
Costas Busch - RPI 33
Write zyxw
q...... ......
x
y
z
Costas Busch - RPI 34
q...... ......
x
y
z
Observations: myx ||length numberof statesof DFA1|| ylength
Costas Busch - RPI 35
The string is accepted
zxObservation:
q...... ......
x
y
z
Costas Busch - RPI 36
The string is accepted
zyyxObservation:
q...... ......
x
y
z
Costas Busch - RPI 37
The string is accepted
zyyyxObservation:
q...... ......
x
y
z
Costas Busch - RPI 38
The string is accepted
zyx iIn General:
...,2,1,0i
q...... ......
x
y
z
Costas Busch - RPI 39
Lzyx i ∈In General: ...,2,1,0i
q...... ......
x
y
z
Language accepted by the DFA
Costas Busch - RPI 40
In other words, we described:
The Pumping Lemma !!!
Costas Busch - RPI 41
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
Costas Busch - RPI 42
Applications
of
the Pumping Lemma
Costas Busch - RPI 43
Theorem: The language }0:{ nbaL nn
is not regular
Proof: Use the Pumping Lemma
Costas Busch - RPI 44
Assume for contradictionthat is a regular languageL
Since is infinitewe can apply the Pumping Lemma
L
}0:{ nbaL nn
Costas Busch - RPI 45
Let be the integer in the Pumping Lemma
Pick a string such that: w Lw
mw ||length
mmbawWe pick
m
}0:{ nbaL nn
Costas Busch - RPI 46
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:
Costas Busch - RPI 47
From the Pumping Lemma: Lzyx i
...,2,1,0i
Thus:
mmbazyx
Lzyx 2
1, kay k
Costas Busch - RPI 48
From the Pumping Lemma:
Lbabaaaaaaazxy ...............2
x y z
km m
Thus:
Lzyx 2
mmbazyx 1, kay k
y
Lba mkm
Costas Busch - RPI 49
Lba mkm
}0:{ nbaL nnBUT:
Lba mkm
CONTRADICTION!!!
1≥k
Costas Busch - RPI 50
Our assumption thatis a regular language is not true
L
Conclusion: L is not a regular language
Therefore:
Costas Busch - RPI 51
Regular languages
Non-regular languages }0:{ nba nn