Upload
meljun-cortes-mbampa
View
218
Download
0
Embed Size (px)
Citation preview
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
1/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 1 of 12
TOPIC TITLE: The Pumping Lemma
Specific Objectives:
At the end of the topic session, the students are expected to:
Cognit ive:
1. Discuss the details of the pumping lemma.2. Use the pumping lemma to prove the non-regularity of
languages.
Affective:
1. Listen to others with respect.
2. Participate in class discussions actively.
MATERIALS/EQUIPMENT:
o topic slideso OHP
TOPIC PREPARATION:
o
Have the students review related topics that were discussed inprevious courses.o Prepare the slides to be presented in class.o It is imperative for the instructor to incorporate various kinds of
teaching strategies while discussing the suggested topics. o Prepare additional examples on the topic to be presented.
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
2/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 2 of 12
The Pumping LemmaPage 1 of 21
The Pumping Lemma
Introduction
The previous lesson showed that all regular languages have this special propertythat if all their strings that are long enough (their length is greater than or equal tothe number of states of the DFA that recognizes them), then each of these stringshas at least one substring that is repeated an arbitrary number of times, and theresulting string is still in the language.
This stems from the fact that when a DFA processes long strings, there will beseveral states that will be traversed. If the number of states traversed is more thanthe number of states in the DFA, then the pigeonhole principle guarantees thatthere will be at least one state that will be traversed at least twice. In other words,at least one state will be repeated. This repeated state will form a loop or a cycle.The substring that caused this cycle can now be repeated any number of times andthe DFA will still end up accepting the string.
This property can be used to prove the non-regularity of languages and is the basisof the pumping lemma.
The Pumping LemmaPage 2 of 21
As an example, consider the following hypothetical DFA:
q 0 q 5q 1 q 2 q 3 q 40 0 1 1 1
1 1
0
0 0, 1
0
Assume that the input string w = 001100. Let m be the number of states of the
DFA. Hence, m = 6 and w = 6.
Recall from the previous lesson that the length of the string + 1 is equal to thenumber of states traversed.
Since w ≥ m (the length of the string is greater than or equal to the number of DFAstates), then there will be more states that will be traversed than there are states inthe DFA. Therefore, at least one state will be traversed at least twice.
The states that will be traversed during the computation are
q 0
0
q 1
0
q 2
1
q 3
1
q 4
0
q 2
0
q 5
Since the computation ended in the final state, the input string 001100 is acceptedand is therefore part of the language of the DFA.
Observe that state q2 is the repeated state since it appeared twice during thecomputation.
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
3/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 3 of 12
The Pumping LemmaPage 3 of 21
In this example, state q2 was traversed twice thereby forming a loop or a cycleconsisting of states q2, q3, and q4. Specifically,
q 2 q 3 q 4
If the state traversals were to be drawn, it would look like:
0q 0
0q 1 q 2
q 3q 4
1
1
0
q 50
The DFA then moved from q0 to q1 to q2 to q3 to q4 to q2 and to q5. The substring ofthe input string 001100 that caused the loop is the substring 110 as shown below:
0 0 1 1 0
this part
caused the
loop
0
At this point, take note that the first loop or cycle of the given input string appearedwithin the first five input symbols (00110). Generalizing this, it can be said that thefirst repeated state (the first loop or cycle) of the input string will usually appearwithin the first m symbols of the input string. The reason for this is again thepigeonhole principle. Having m input symbols means that there will be m + 1traversed states. Since the number of traversed states is greater than the numberof DFA states (m), then there will be a repeated state.
The Pumping LemmaPage 4 of 21
Therefore, the substring 110 can be repeated an arbitrary number of times(pumped) and the resulting string will still be part of the language. These includestrings such as 001101100, 001101101100, and 001101101101100. In otherwords, even when the loop q2 to q3 to q4 to q2 is repeated any number of times, theDFA will still eventually end up in the final state thereby accepting the resultingstring.
Now take note that the input string in the example can actually be viewed as beingcomposed of three parts or substrings. Let these substrings be x , y , and z asshown below:
0 0 1 1 0
y
0
x z
Substring x will be equal to the first two input symbols (00). Substring y will beequal to the next three input symbols (110), and substring z will be equal to the lastinput symbol (0).
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
4/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 4 of 12
The Pumping LemmaPage 5 of 21
Specifically:
Substring x is the first part of the input string that is composed of the symbolsbefore the first repeated state appeared. In the example given, the first repeatedstate (q2) appeared upon the arrival of the third input symbol so x = 00 (the first two
symbols only).
Substring y is the second part of the input string that contains the input symbolsbetween the first appearance of the repeated state and its second appearance. Inthis example, the repeated state q2 made its first appearance upon the arrival ofthe third input symbol while its second appearance happened upon arrival of thefifth input symbol so y = 110. In other words, substring y represents the loop orcycle within the input string.
Substring z is composed of the remaining symbols of the input string that willeventually lead to the final state.
The input string w can then be written as the concatenation of the substrings x , y ,and z :
w = xyz
The Pumping LemmaPage 6 of 21
Hence, w = 001100 with y = 110. Since y can be repeated an arbitrary number oftimes, with the resulting string still being a part of the language, then w can begeneralized as
w = xy iz for i ≥ 0
Recall that y 1 = y , y
2 = yy , y
3 = yyy , etc. This represents that fact that substring y
can be repeated any number of times and the input string w will still be recognizedby the DFA. So even though w = xyyyyyyyy…yyyyyyz , the input string will still beaccepted by the DFA because of the presence of substring z which leads to thefinal state in the end.
Examples of strings that will be accepted by the given DFA are
w = xy 1z = 001100
w = xy 2z = 001101100
w = xy 3z = 001101101100
w = xy 4z = 001101101101100
Very important note: It was mentioned earlier that the first loop or cycle of the inputstring will usually appear within the first m symbols of the input string. Since theloop or cycle happens in substring y , this implies that the length of substring xy must be within the first m symbols. Therefore,
xy ≤ m
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
5/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 5 of 12
The Pumping LemmaPage 7 of 21
To summarize this special property of a regular language:
1. Let w be any string of language L whose length is greater than or equal tothe number of states m of the DFA that recognizes language L.
Specifically, w ≥ m.
This emphasizes that this property is true only for all strings of a regularlanguage whose length is greater than or equal to the number of states ofthe DFA. In other words, string w must be long enough for this propertyto be observed.
2. String w can be divided into three parts xyz where y contains the inputsymbols from the first occurrence of a repeated state to its secondoccurrence.
This emphasizes that strings that are long enough will always have asubstring that will cause a loop or cycle when the states of the DFA are
traversed.
The Pumping LemmaPage 8 of 21
3. The length of substring xy will always be less than or equal to the number
of states of the DFA ( xy ≤ m).
This emphasizes that the first loop or cycle of the computation will appearwithin the first m symbols of the input string.
4. The length of y ≥ 1.
This emphasizes that substring y cannot be the empty string. In otherwords, there has to be a loop or a cycle. Otherwise, there is no substringto pump. It is possible though for substrings x and z to be empty strings.
5. Substring y can be repeated or pumped any number of times and theresulting string is still a member of language L.
This emphasizes that w = xy iz for all i ≥ 0 will always be accepted by the
DFA and hence a member of the language L. This property is true for thesufficiently long strings of all regular languages.
The summary given is an informal statement of the pumping lemma.
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
6/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 6 of 12
The Pumping LemmaPage 9 of 21
The Pumping Lemma
The following is the formal statement of the Pumping Lemma:
If L is a regular language, then there is a number p (the pumping length ) where, if
w is any string in L whose length is greater than or equal to p, then w may bedivided into three parts, w = xyz , satisfying the following conditions:
1. for each i ≥ 0, xy iz L
2. y ≥ 1, and
3. xy p.
Take note that the pumping length p actually refers to the number of states of theDFA recognizing the language being analyzed. The length of string w should be
greater than or equal to p ( w ≥ p) in order for the string to be long enough forloops or cycles to occur.
The Pumping LemmaPage 10 of 21
The pumping lemma has three major conditions:
1. Condition 1 states that the string w = xy iz L for each i ≥ 0. This again
emphasizes that strings that are long enough can be divided into threeparts. The middle part (y ) contains the loop or cycle within the inputstring and this can be pumped or repeated any number of times and thestring w will still be a member of the language L.
2. Condition 2 states that y ≥ 1. This refers to the fact that substring y cannot be an empty string. Before applying the pumping lemma, therehas to be a loop or cycle within the input string that can be pumped.However, it is possible for substrings x and/or z to be empty.
3. Condition 3 states that xy p. This refers to the fact that the loop orcycle that will be pumped should be the first one encountered from thestart of the input string. Recall that if there are exactly p symbols in theinput string, the number of states that will be traversed will be p + 1. Bythe pigeonhole principle, the first state to be repeated will appear withinthe first p + 1 states that will be traversed. In other words, the part to bepumped is within the first p symbols of the input string.
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
7/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 7 of 12
The Pumping LemmaPage 11 of 21
The pumping lemma is not used to prove if a language is regular. This requiresthat all long strings of the language be tested to determine if they satisfy thepumping lemma. This is obviously a tedious process. To show if a language isregular, it is easier to find a finite automaton that recognizes it or a regularexpression that describes it.
However, the pumping lemma can be used to prove the non-regularity oflanguages.
Applying the pumping lemma to prove if a language L is not regular requires usingproof by contradiction. The procedure is as follows:
1. First assume that the language L is regular.
2. Since L is regular, the pumping lemma states that ALL strings of L that are long enough can be pumped and the resulting strings arealso members of L.
3. Now find a string w that is long enough that cannot be pumped (at
least one of the three conditions of the pumping lemma should not besatisfied).
4. If there is such a string, then the pumping lemma was contradicted.It can then be concluded that language L is not regular.
The Pumping LemmaPage 12 of 21
Example 1: Prove that the language L1 = {0 x 1 x
x > 0} is not regular.
Assume first that L1 is regular. Take note that L1 is a language that iscomposed of strings that start with a block of x consecutive 0s followed by ablock of x consecutive 1s. In other words, this language is composed of allstrings wherein the total number of consecutive 0s is equal to the total numberof consecutive 1s following it. These include strings such as 01, 0011,000111, and 00001111.
Let p be the pumping length of L1. Now choose a string w (that is a memberof L1 and whose length is greater than or equal to p) that will be pumped. Thisrequires a little creativity.
Let the string to be pumped be w = 0p1
p. Obviously, the length of w is greater
than p since it has p 0s and p 1s—its length is actually 2 p. Hence, w is longenough to be pumped.
Now consider various ways in which w can be divided into x , y , and z substrings.
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
8/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 8 of 12
The Pumping LemmaPage 13 of 21
Option 1: Let y be all 0s.
If y is composed of all 0s, then the division of the input string can be viewed as
00...000...000...011...111...111...1
x y z
p 0s p 1s
Pumping the substring y (repeating it several times) would create a string in whichthere are more consecutive 0s than 1s. Since the language L1 is composed of allstrings wherein the total number of consecutive 0s is equal to the total number ofconsecutive 1s following it, the resulting string is not in L1. This violates condition 1of the pumping lemma. Hence, a different way of dividing w is needed.
Option 2: Let y be all 1s.
If y is composed of all 1s, then the division of the input string can be viewed as
00...000...000...011...111...111...1
x y z
p 0s p 1s
Pumping the substring y would create a string in which there are more consecutive
1s than 0s. Hence, the resulting string is also not in L1. This also violatescondition 1 of the pumping lemma.
In addition, condition 3 is also violated because by making substring y becomposed of all 1s, the length of substring xy will be greater than p (as seen in thediagram above).
The Pumping LemmaPage 14 of 21
Option 3: Let y be composed of 0s and 1s.
If y is composed of 0s and 1s, then the division of the input string can be viewed as
00...000...000...011...111...111...1
x y z
p 0s p 1s
Pumping the substring y would create a string that may have the same number of0s and 1s, but they will be out of order with some 0s after 1s. This violatescondition 1 of the pumping lemma.
In addition, condition 3 is also violated because the length of the substring xy isgreater than p (as seen in the diagram above).
Since language L1 has a string that is long enough but cannot be pumped, then thiscontradicts the original assumption that L1 is regular. Therefore, L1 is not regular.
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
9/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 9 of 12
The Pumping LemmaPage 15 of 21
Example 2: Prove that the language L2 = {ww w {0,1}*} is not regular.
Assume first that L2 is regular. Take note that L2 is a language that iscomposed of strings that are concatenations of the same string. In otherwords, the first half of the string is equal to its second half.
Let p be the pumping length of L2. Now choose a string w (that is a memberof L2 and whose length is greater than or equal to p) that will be pumped.
Let the string to be pumped be w = 0p10
p1. Obviously, the length of w is
greater than p since each half has p + 1 symbols—Its length is actually2( p + 1). Hence, w is long enough to be pumped.
Condition 3 states that the length of the substring xy should be less than orequal to the pumping length p. If condition 3 is enforced, substring y can onlybe composed of 0s that belong to the first half of the input string as shownbelow:
000...0001000...0001
x y z
p 0s p 0s
Making substring y include symbols that belong to the second half of the inputstring would already violate condition 3.
Therefore, if y is pumped, then there will be more 0s in the first half of thestring compared to its second half, thereby creating an imbalance. Theresulting string will no longer be a member of L2.
Since L2 has a string that is long enough but cannot be pumped, then thiscontradicts the original assumption that L2 is regular. Therefore, L2 is notregular.
The Pumping LemmaPage 16 of 21
Example 3: Prove that the language L3 = {w {0,1}* w = w } is not regular.
Assume first that L3 is regular. Take note that L3 is a language that iscomposed of strings that are palindromes. A palindrome is a word whichreads the same backward or forward. Examples of words that arepalindromes are level, madam, and racecar. Examples of strings that arepalindromes are 00100, 110011, and 110111011.
Let p be the pumping length of L3. Now choose a string w (that is a memberof L3 and whose length is greater than or equal to p) that will be pumped.
Let the string to be pumped be w = 0p10p. Obviously, the length of w isgreater than p since there are two blocks of consecutive p 0s with a single inbetween them—its length is actually 2 p + 1. Hence, w is long enough to bepumped.
Because of condition 3 which restricts the length of the substring xy to beingless than or equal to the pumping length p, substring y can only be composedof 0s that belong to the first block of consecutive 0s (to the left of the single 1)of the input string as shown below:
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
10/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 10 of 12
000...0001000...000
x y z
p 0s p 0s
Therefore, if y is pumped, then the string will no longer be a palindrome. Theresulting string is no longer a member of L3.
Since L3 has a string that is long enough but cannot be pumped, then thiscontradicts the original assumption that L3 is regular. Therefore, L3 is notregular.
The Pumping LemmaPage 17 of 21
Example 4: Prove that the language L4 = {01 i > j } is not regular.
Assume first that L4 is regular. Take note that L4 is a language that is
composed of strings that start with a block of consecutive 0s followed by ablock of consecutive 1s. The total number of consecutive 0s is always greaterthan the total number of consecutive 1s.
Let p be the pumping length of L4. Now choose a string w (that is a memberof L4 and whose length is greater than or equal to p) that will be pumped.
Let the string to be pumped be w = 0p+1
1p. Take note that there are more
consecutive 0s than consecutive 1s. Obviously, the length of w is greaterthan p since there are p + 1 0s followed by p 1s—Its length is actually 2 p + 1.Hence, w is long enough to be pumped.
Because of condition 3 which restricts the length of substring xy to being lessthan or equal to the pumping length p, substring y can only be composed of0s that belong to the block of consecutive 0s of the input string as shownbelow:
000...0000111...111
x y z
p +1 0s p 0s
If y is pumped, then there are still be more consecutive 0s than consecutive1s. Hence, the string is still in language L4.
The question is, is the language regular? The answer is no since the pumping
lemma states that ALL strings of the language that are long enough can bepumped. This is just one string. To prove the non-regularity of language L4, adifferent approach is needed.
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
11/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 11 of 12
The Pumping LemmaPage 18 of 21
Condition 1 of the pumping lemma states that w = xy z L for each i ≥ 0. If i is increased to 2 or 3, the string w becomes xyyz or xyyyz respectively.Substring y is therefore repeated once or twice. Substring y is said to bepumped. More accurately, y is said to be pumped up .
However, condition 2 also states that i can made equal to 0, therefore makingw = xy
iz = xy
0z = xz . This is called pumping down the substring y .
If y is pumped down (y disappears), then there are now more consecutive 1sthan 0s. Hence, the resulting string will no longer be in L4.
Since L4 has a string that cannot be pumped, then this contradicts the originalassumption that L4 is regular. Therefore, L4 is not regular.
Important Note: Pumping down y does not conflict with condition 2 of thepumping lemma that states that the length of y cannot be equal to 0.Condition 2 is simply saying that before pumping the string, there should be asubstring y that can be pumped. When the actual pumping occurs, pumpingdown y is therefore allowed.
The Pumping LemmaPage 19 of 21
Example 5: Prove that the language L5 = { i ≥ 0} is not regular.
Assume first that L5 is regular. Take note that L5 is a language that is madeup of strings composed only of 0s whose length is a perfect square. Hence,strings of this language have lengths equal to 0, 1, 4, 9, 16, 25, 36, 49, 64,etc.
Let p be the pumping length of L5. Condition 3 states that xy p. Hence, ifthe length of substring xy is less than or equal to p, then the length of y alone
would also be less than or equal to p. Therefore, y p.
Let the string to be pumped be w = . The length of w is p2 which is long
enough to be pumped.
Therefore, w = xyz = p2. If y is pumped once, then w = xyyz or xy
2z . The
length of string xy 2z is just equal to the length of xyz plus the length of y . And
since it was established earlier that y p, the length of w will now be
xy 2z p
2 + p.
The Pumping Lemma
Page 20 of 21If xy
2z p
2 + p, then this inequality can be rewritten as
xy 2z < ( p + 1)
2
Observe that replacing p2
+ p with ( p + 1)2
does not invalidate the inequalitybecause p
2 + p < ( p + 1)
2. In other words, if a b and b < c , then a < c .
The length of string xy 1z is equal to p
2, which is a perfect square number. This
implies that the length of the next string after xy 1z should be ( p + 1)
2, which is the
next perfect square number after p2.
2
0i
2
0 p
8/21/2019 MELJUN CORTES Automata Lecture the Pumping Lemma 2
12/12
Theory of Computation (With Automata Theory)
The Pumping Lemma *Property o f STIPage 12 of 12
The Pumping LemmaPage 21 of 21
However, the next string after xy z is xy z and its length is less than ( p + 1) .Therefore, the length of xy
2z is not a perfect square because there is no other
perfect square number between p2 and ( p + 1)
2. Hence, xy
2z does not belong to
L5.
Since L5 has a string that cannot be pumped, then this contradicts the originalassumption that L5 is regular. Therefore, L5 is not regular.
[The Pumping Lemma, Pages 1 –
21 of 21]