Professional Documents
Culture Documents
Languages
Regular Languages
Show a language is Regular by building one the following
• DFA
• NFA
• Regular Expression
• Example:
• For k=3:
0 0 0
q0 q
L = {ε, 01, 0011,
1 000111} q2 q3
1 1 1 1
0/1 1 1
0/1 q7 q6 q5 q4
0
0
0
3
Non-Regular Language?
• To understand the power of DFA, apart from knowing what it can do,
we need to know what it cannot do
• Let’s look at the language B = {0n 1n | n >=0}
• If we try to find a DFA to recognize B, the DFA needs to keep track of
the number of 0’s we have seen so far
• However, number of 0’s is unlimited…there are unlimited number of
possibilities
• So, it is NOT POSSIBLE because the DFA just has FINITE number of
states!
Pumping Lemma for Regular Languages
• Pumping Lemma relates the size of string accepted
with the number of states in a DFA
• 1. If the path is longer than the number of states available in the DFA, then
there is a repetition of some state in the path, or a ‘loop’
• 2. If there is such a loop in the path, then the substring on the loop may
appear 0 or more number of times for the corresponding string to be
accepted
• string: 001 10 111, with middle 10 on a loop
q0 001 q5 10 q5
111
• Other corresponding accepted strings are: 7
Pumping Lemma for Regular Languages
8
Use of Pumping Lemma (Example 1)
• Show that the language L1 = {0n1n | 0=<n} is not regular using
pumping lemma
• Proof (by contradiction)
• Assume that L1 is regular. Then let p be the pumping length
• We know that string s = 0p 1p is in L1, |s|>=p
• By pumping lemma, we know that s= 0p 1p can be divided into three
parts, xyz, such that |y|>0, |xy| p
Use of Pumping Lemma (Example 1)
• Case-1: y is a substring of 0p
• x= 0j, for some j>0; z=1p
• y=0m, for some m>0
• j+m=p
• For k=2, xyyz 0j (0m)2 1p 0j+2m 1p 0p+m 1p
• xyyz has more 0’s than 1’s
• Contradiction
Use of Pumping Lemma (Example 1)
• Case-2: y is a substring of 1p
• xyyz has more 1’s than 0’s
• contradiction
• For k=2, xyyz 0p-j (0j 1m)2 1p-m 0p-j 0j 1m0j 1m 1p-m
• xyyz not in L1
• Contradiction
• So L1 is not Regular
Use of Pumping Lemma (Example 2)
L2 = {aibj : i > j}
L2 is not regular.
We prove it using the Pumping Lemma.
L2 = {aibj : i > j}
L2 is not regular.
• Fix an arbitrary pumping length n>0.
L2 = {aibj : i > j}
L2 is not regular.
• Fix an arbitrary pumping length n>0.
• Choose a proper string s in L2.
L2 = {a b : i > j}
i j
L2 is not regular.
• Fix an arbitrary pumping length n>0.
• Choose a proper string s in L2.
|s|≥ n
L2 = {a b : i > j}
i j
L2 is not regular.
• Fix an arbitrary pumping length n>0.
• Choose a proper string s in L2.
• s = an+1bn ϵ L2.
aaa…aabb…b
n+1 n
L2 = {a b : i > j}
i j
L2 is not regular.
• Fix an arbitrary pumping length n>0.
• Choose a proper string s in L2.
• s = an+1bn ϵ L2.
• Consider all possible splittings of s in x,y,z with the
desired properties.
aaa…aabb…b
n+1 n
L2 = {a b : i > j}
i j
L2 is not regular.
• Fix an arbitrary pumping length n>0.
• Choose a proper string s in L2.
|xy|≤ n
• s = an+1bn ϵ L2.
|y|≥ 1
• Consider all possible splittings of s in x,y,z with the
desired properties.
aaa…aabb…b
n+1 n
L2 = {a b : i > j}
i j
L2 is not regular.
• Fix an arbitrary pumping length n>0.
• Choose a proper string s in L2.
|xy|≤ n
• s = an+1bn ϵ L2.
|y|≥ 1
• Consider all possible splittings of s in x,y,z with the
desired properties.
aaa…aabb…b
n+1 n
L2 = {a b : i > j}
i j
L2 is not regular.
• Fix an arbitrary pumping length n>0.
• Choose a proper string s in L2.
|xy|≤ n
• s = an+1bn ϵ L2.
|y|≥ 1
• Consider all possible splittings of s in x,y,z with the
desired properties.
Y
aaa…aabb…b
n+1 n
L2 = {a b : i > j}
i j
L2 is not regular.
• Fix an arbitrary pumping length n>0.
• Choose a proper string s in L2.
• s = an+1bn ϵ L2.
• Consider all possible splittings of s in x,y,z with the
desired properties: y = am, 1 ≤ m ≤ n.
Y
aaa…aabb…b
n+1 n
L2 = {a b : i > j}
i j
abaabba|abaabba
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• First fix an arbitrary number n>0 to be the pumping length.
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Choose wisely!!!
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = a2n
aaa…aaa|aaa…aaa
n n
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = a2n
• For x = ε, y = a2, z = a2n-2
y z
aaa…aaa|aaa…aaa
n n
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = a2n
• For x = ε, y = a2, z = a2n-2
y y z
aaaaa…aa|aaaa…aaa ϵ L
n+1 n+1
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = a2n
• For x = ε, y = a2, z = a2n-2
y y y z
aaaaaaa…a|aaaaa…aaa ϵ L
n+2 n+2
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = a2n
• For x = ε, y = a2, z = a2n-2
z
a…aaaa|aa…aaa ϵ L
n-1 n-1
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = a2n
• For x = ε, y = a2, z = a2n-2, there is no i: xyiz ∉ L!
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = a2n
• For x = ε, y = a2, z = a2n-2, there is no i: xyiz ∉ L!
• s = a2n doesn’t work!!!
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = (ab)2n
abab…abab|abab…abab
n n
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = (ab)2n
• For x = ε, y = abab, z = (ab)2n-2
y z
abab…abab|abab…abab
n n
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = (ab)2n
• For x = ε, y = abab, z = (ab)2n-2
y y z
abababab…ab|ababab…abab ϵ L
n+1 n+1
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = (ab)2n
• For x = ε, y = abab, z = (ab)2n-2
• For any i, xyiz = (ab)2i(ab)2n-2 = (ab)2(i-n-2) ϵ L!
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language. Example: For s = (ab)2n
• For x = ε, y = abab, z = (ab)2n-2
• For any i, xyiz = (ab)2i(ab)2n-2 = (ab)2(i-n-2) ϵ L!
• s = (ab)2n doesn’t work!
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping lemma.
• Pumping length: n
• Choose a proper string in the language.
• Use s = anbanb
aaaa…aab|aaaa...aab
n n
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping
lemma.
• Pumping length: n
• Choose a proper string in the language.
• Use s = anbanb
• For any splitting of s in x,y,z with the desired
properties:
Y
aaaa…aab|aaaa...aab
n n
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping
lemma.
• Pumping length: n
• Choose a proper string in the language
• Use s = anbanb
• For any splitting of s in x,y,z with the desired
properties: y = am with 1 ≤ m ≤ n.
L={ww : w in {a,b}*}
We prove that L is not regular by using the pumping
lemma.
• Pumping length: n
• Choose a proper string in the language
• Use s = anbanb
• For any splitting of s in x,y,z with the desired
properties: y = am with 1 ≤ m ≤ n.
• Observe that xy2z = am+nbanb is not in L