 Let us start with another example of a language which is not regular and we prove by pumping lemma that it is not regular language. The language we will consider is this one. Firstly this language is a unary language that means the alphabet for the language has only one symbol. So, therefore, language in this case is a set of strings each of which each string is just a bunch of ones and our language will satisfy this. L is all those strings over the alphabet just one such that x is of the form 1 to the power n square where n is greater than b. So, basically what we are saying is you can take n equal to 1, n equal to 2, n equal to 3 and so on. If n equal to 1 then the string that you get is 1 to the power n square which is 1. So, basically 1. So, this is in the language L when n equal to 2 then n square is 4. So, 1 to the power 4 which is of course, concatenation of 4 ones and this is also in the language L and n equal to 3 this is 9. So, therefore, this is 1, 1, 1, 1, 1, 1, 1, 1, 1. This string is also in the language and so on. On the other hand this string 1, 1, 1, 1, 1, 1 just 5 ones is not in the language or language L because this is 1 power 5 and 5 is not a perfect square. So, you would like to show that this language is not regular and we will use the pumping lemma. You recall pumping lemma statement was this which we have gone through once and this is saying in order to use this lemma to prove this particular language is not regular. We need to first of all select we somebody will when this lemma says that there is a k. So, will our proof should be able to handle any k that might be given. So, we just keep it as an indeterminate and we say that let k be the. So, of course, first we will have to say that our proof we are proving proof that L is not regular and the proof is by contradiction. So, we start by saying suppose L is regular and now we can invoke the pumping lemma for this. So, we see because we have assumed L to be regular and then we derive the contradiction. So, we say let k be the pumping lemma constant for L. Now, we need to select a string in order to invoke non-trivial with this lemma some string in the language whose length is greater than k. So, in fact it will be convenient to consider 1 k square itself and clearly this string is in the language whatever be the k. So, the pumping lemma constant k we are considering the string 1 k to the power k square and now we invoke the pumping lemma. What does the lemma say that this string 1 to the power k square let us say this is my string 1 to the power k square and there is u v w this whole string is u v w and this ring was of course 1 r k square such that u v w of course is the string x and u v together its length is less than equal to k. So, suppose this is u this is v this is w and lemma is saying that length of u v is less than equal to k and from the lemma I get also. So, from here I am getting that length of v is less than equal to k, but of course length of v is strictly greater than 0 the other condition length of v is strictly greater than 0. So, v is a non empty set non empty string its length may be 1 or at most it can be k. So, now consider this string u v v w this particular string is also in the language that is what the lemma is asserting I have used i equal to 2. So, this is in the language l what can we say about the length of the string an upper bound on the length of the string is u v v w u v w is of course that length is k square plus we have added a v that length is at most k. So, this is bounded by k square plus k actually we have got a contradiction already because this the lemma is saying that some string whose length is k square plus k bounded by that and consisting only of one. So, in other words let me write it like this lemma is saying that 1 to the power m is in the language l where length of m this way is strictly greater than k square or rather the m itself is m is strictly greater than k square and less than equal to k square plus k. In other words it is saying that there is a string in the language whose length is greater than strictly greater than 1 to the power k square and that string's length is bounded by k square plus a can that be because you see what is that string which is in the language and whose length is which whose length is greater than the string the very next string after 1 to the power k square will be 1 to the power k plus 1 whole square and this is the next string this is the string in the language of course and the very next string greater than this particular string will have length therefore k square plus 2 k plus 1. On the other hand the lemma is saying that there is a string whose length is at most k square plus k. So, this is strictly less than a square plus 2 k plus 1 and therefore you have the contradiction. So, really speaking what the fact that we are exploiting in this proof that if there is a string in the language supposing this is the set of all strings over the alphabet 1. So, this is the all elements of 1 star if we have a string in the language then the next string comes after a long gap and this gap keeps increasing as we go down because what is the gap here 2 k plus 1 from k it is 2 k plus 1 next one will be even bigger and so on. However lemma says that the next string gap is at most k and that is the fact this particular fact is being contradicted by the implication of the lemma. We have seen couple of examples of how to use the pumping lemma to prove some language to be non regular. Now, let us prove the lemma which we have not done yet so far and the proof is fairly simple because the moment you say L is regular see pumping lemma starts by the from the assumption that L is regular. So, we say since L is regular there is a d f a m to accept n in other words L of m is the language L this is the d f a and let k be the number of states that means the cardinality of the set of states of m is k. Let x is in L and x length of x is greater than equal and the length of x is greater than equal. Now, consider first k symbol so let us see the first k symbol is this part of the string x to the length of this is exactly k and what do we know of x that x is a string in the language therefore if you start the machine m at its initial state q 0 then the machine finally will be some state which is in the final state of one of the final states of or accepting states of the machine m. So, I am using the old notation that m is the d f a m is 5 to the power q sigma delta q 0 f. So far what we have said is x is accepted by m in other words delta hat of q 0 is q f because we are saying that q f is the state it goes to which is an element of f. Now recall one thing that we noticed right in the beginning while discussing d f a suppose I have a string of symbols I do not mean 0 but let me just say these symbols and remember let me write it more carefully. So, this is one symbol this is the next symbol this is the next symbol this is the next symbol this is the next symbol and we consider the sequence of states the machine goes through as it reads this string. So, it reads this from state q 0 it goes to may be a state q i 1 then the next symbol it goes to q i 2 and the way I have written that this sequence has the sequence of states has is of length n plus 1 and what is the in this the length of the sequence of symbols it is n right because on one if the string had only one symbol then the sequence of states the machine goes through will have two states and so on you can see supposing it is 2 the string had only two symbols then the sequence will be 1 2 3 of length 3 and so on. So, if the string had n symbols then the sequence of states through which the machine goes that will have precisely n plus 1 the its length will be n plus 1 the sequence of strings sequence of states for an n length. So, let me write it clearly that for an n length string length of the sequence of states through the DFA goes through is n plus 1 now this part of the string we said is exactly of length k. Now what does it mean the sequence of states through which the machine will go on this part of the string which is of length k this sequence is of length k plus 1. From the fact that we have written now this is the most crucial observation that the sequence of states is of length k plus 1 and totally how many states are there k because that is what we have assumed let k be the number of states in n and the sequence as 1 more than the total number of states 1 more the length of the sequence is 1 more than the total number of states in the machine. Therefore, by pigeon hole principle they will be at least one state which will occur more than once in this sequence which is the sequence we are talking of the sequence of states the machine goes through on the first k symbols of the string x. So, in fact let me see it in picture some kind of picture that this is your string x and this is the sequence of states. Now we are talking of the first k symbols the string consists of string the first prefix of the string x of length k and here it is the sequence of states that we are talking of q 0 sorry some letters q here finally, of course it goes to q f. Now q 0 to some q this sequence of states there must be some state which is which repeats at least once you can see this is a very simple use of the pigeon hole principle that we learned in discrete math. Now again if you look at this you can see between two states even if they are adjacent there will be at least one symbol between two states in the sequence between any two states in the sequence there will be at least one symbol even if the two states are adjacent like in this case. So, what I can say is the following let me say let us focus on this picture and what two things that we already know that delta hat of q 0 x is q f which is in the one of the final states and let me call this to be this part the part of the string which brings me from q 0 brings the d f a from q 0 to p which is this first occurrence of the state which occurs more than once this part let me call and in state p from the very from the very next symbol to this part what is this part of the string doing it is taking the machine from the state p back to p. So, let me write it in this way that delta hat of this is remember this is delta hat delta hat of q 0 u what was u u u was the part of the string the initial part of the string which took the machine from the initial state to the state p which is going to occur once more delta hat to q 0 to u is this p and this part let me call v. So, delta hat of p to v is also p right because this v part is u part took the machine from q 0 to p v part is taking the machine from p to p right. And now we do not care about anything else, but let me call all the rest of the string after v whatever is left in x let me call it w. So, what can I say about w p w will take the machine from the state p q s right. Now we rest of the proof is the simple application of these facts now what will happen on the string u let us say v v w what can we say the behavior of the machine from q 0 to this string. Now let us look at this we will just use these facts. So, q 0 I mean it is easy to see what is going to happen q 0 this is we start from q 0 first we go to look at the part of the string which is u the prefix of the string which is u that takes the machine if this is your u then this is v. Now we have another copy of v and then finally we have said the machine takes the v part of the prefix machine goes from q 0 to p on u machine goes from p to p on v. Now another copy of v is there, but the machine cannot there is no reason for machine to behave differently because this is a deterministic machine which sees v. So, it goes again to p in other words you see this is also going to be q f because now from p on w it will go to q f you can write it like this way that I can say that this is what is this delta hat of q 0 u this is the state the machine goes to after seeing the first part u. Now it is sees v now again it sees. So, this is the state the machine will be after it sees u and v now it sees another copy of v this whole thing is one state and now it sees v. So, delta hat this is going to be the state the machine is going to be after seeing v u v v and then finally we have w we will put another delta hat this is what is this. So, I can I can argue it out using this facts delta hat of q 0 u was p. So, let me substitute p here then delta hat of p of p and v is p. So, this whole thing is this whole thing reduces to again p. So, let me write it then delta hat of p of v is again p. So, you see this is let me write it clearly delta hat of delta hat of p w and this is delta hat of p of v is again p delta hat of p of v is p. So, this becomes p delta hat of p w is q f. So, this is what I had asserted earlier and this is now I have shown you the proof q f is of course an element of it. So, what does this mean that since u v v w takes the machine from q 0 to q f. Therefore, what I have is that u v v w is also in the language and this argument will be true if you have not just one extra copy, but if you put any number of v's. So, let us say I had u v v v w u is going to take q 0 the machine from the state q 0 to p according to this v is going to take the machine from p to p this v will also take the machine from p to p this p to p p to p and w will take the machine. So, therefore, this string is also in the language l we have proved for all i greater than equal to 1 what happens when i equal to 0 that means we are talking of the string u w when i equal to 0 that means we are talking of the string u v 0 w v 0 by definition v to the power of 0 by definition is if you recall in the beginning we talked of this is the empty string u epsilon which is u w. Now, let us look at u w the machine initially in the state q 0 q 0 starting from q 0 on u it will go to the state p p on w it will go to q f. So, again u w is in the language seen language l. So, therefore, for all i as the lemma states greater than equal to 0 the string u v to the power i w is in the language. If you want to be very formal you will redo this proof using induction on i and that is basically you will try to show that for all i you want to prove this use induction on i start by saying suppose i equal to 0 then we are talking of the string u w using this facts we know that u w will be in the language then assume in that induction proof it is going to be that suppose the statement is true for all i up to some n and then you would prove by induction by your induction step that u v to the power n plus 1 w also will be in the language. But, the idea of the proof is very clear this is how we will go about this. Now, several things we need to say about this lemma and we will say these things because sometimes we do not we do not fully understand the content of this lemma what it is saying exactly we make mistakes in applying. Now, let us look at the logic way of looking at this statement how what is this assertion you know it is saying first of all at the top level this lemma is of the form l regular implies certain things. So, let me call that all these things that it implies we are saying this statement goes like this let l be regular then so l is regular implies this whole thing then etcetera this part I am calling it a. Now, look at a now the statement a what is a saying a is basically the statement we start with this there is a constant k there is constant k which depends on the language. So, once you have fixed l this is a constant k there is a constant k then it is saying such that for all x for all x right x is in l and length of x is greater than k after that what you are saying now we are saying there exist u v w there exist u v w and now we are asserting certain things about the relationship between u v w and x and certain conditions on k and then we are saying certain other strings also will be there in the language. So, let us write it in the homilism of logic it is saying that the string x is u v w that is the first thing we said. Then we are saying let me use this notation and already used it here then we are saying that length of u v is less than equal to k and our next conjunct is length of v is greater than 0 finally we are saying for all i u v i w is also in the language for all i greater than equal to 0 right this is the formalism of logic I have just rewritten that the purpose for doing this is clearly tell you when you are giving a proof used to show a particular language to be not regular it is very very necessary to keep these things least intuitively in our mind. Suppose we used to show using this lemma that some language l is not regular what do we do we will first assume in our proof the structure of the proof is what I am trying to tell you we will first assume that let l be regular the moment you say l is regular then this statement is true and that statement says there is a key. Now in my example I prove can I say for example that k is 593 I cannot do that why because this is not in the hand of the prover there is this k therefore this k should be my proof should be ready to use any k which is given to me sometimes this kinds of proofs can be seen as a game. Between two people one is an adversary his goal is to prove you wrong and your goal is to prove l is not regular so what you are going to do you will your adversary is going to give you a k then you will pick up an x right so the so in that game if you the adversary moves are adversary starts with this is the initial quantifier move so he picks any k so you should be ready in your proof to use any k whichever may whatever might be given but then it is your turn in the game you will take some language it is because this part is saying for all x therefore we have complete freedom to choose any x so long that x is in the language and its length is greater than equal to x right. So the discovery part of the proof is to come up with some proper x to given any k right. Any k right we choose an x which is which will satisfy this now what is our goal is to come up with finally on pumping a string which is not in the language by now you have seen the kind of proofs that we have seen it make making use of the pumping lemma so we choose x now these existential quantifiers so sometimes beginners they choose an x and then they say let u be this v be this w be this that will be wrong that proof is wrong what you have to now be prepared to carry out your argument for any break up of u v w of course which will be given by the adversary but adversary has to obey these that u v w together is the string x and length of u v is less than equal to k and the length of v is greater than 0 so once you have chosen x then what is the next part of the proof so this is your x then for any break up of u v w of the string x which which obeys the constraints these two constraints the total length of u v is less than equal to k and v is non empty you should be able to find an i the adversary gives u v v and w so we choose an x now given any u v w satisfying constraints I have already defined constraints you see now it is in my hand to choose an i we find an i and derive the contradiction such that this i should be such that u v i w is not in the language and then therefore I win the game so in the in that model of adversary versus the prover game adversary chooses k the prover chooses some appropriate x in the language now once that x is chosen adversary gives a break up of u v the x in terms of u v w satisfying these constraints then prover chooses an i and he manages to in the game if he finds a u v i w which is not in the language because you got a contradiction because u v i w according to the lemma it has to be in the language but by definition our i is such that you have seen this example that on pumping I am getting a string which the definition of the language tells me could not be in the language so therefore I get a contradiction and therefore the supposition l is regular brings me to a contradiction and therefore I conclude that l is not regular so this is the overall structure of the proof I want to emphasize again in these proofs when we use pumping lemma I should be able to use given any k then I choose an appropriate x then for any break up of u v i w then u v w of that x I should be able to find out an i such that u v i w is not in the language which I would like to show is not regular that is the first thing I said wanted to make the point the structure of the proof making use of the pumping lemma the second thing comes from here just the top state the pumping lemma says that if l is regular then certain conditions will be true the natural question is is the converse so what is the converse if l satisfies a is remember this part of the proof of the lemma then what is the if l satisfies a then this is the converse actually it is not very difficult to see the converse is false and how do I show that con converse is false I actually given counter example in which the language a language will satisfy these conditions a and yet the converse is not regular so proof is by counter example and that counter example language l where l is defined to be a i b j c k first thing is i j a these are all greater than equal to 0 and now the interesting part the constraint is if i is equal to 1 then j is equal to 3 so for example the string a b b b c c c is in the language l why because the converse it is of the form some bunch of a's followed by a bunch of b's followed by a bunch of c's and since there is exactly 1 a right i equal to 1 then the number of b's is equal to the number of c's so this is in the language now on the other hand if I had a bunch of a's more than 1 a's then there is no really constraints on the lengths of b's and c's I could have had 1 b and maybe many c's this will be also in the language it is not too difficult to see what this language is and I would like to show this language satisfies all these which came in the you know remember we are looking at from the then part in fact let me say there is a constant it says there is a constant k let me just say the k is 3 and you take any string which is in the language whose length is 3 or more then what should be the u v w if I assert such that for all i u v i w is in the language and that rule is kind of simple also that if basically consider an x in the language and length of x is greater than equal to 3 and now if x has exactly 2 a's so a a then I have a number of b's according to since it is in the language l if you see that there is no constraints on how many b's how many c's should be there so we have a number of b's number of c's then what I do is in this case u is empty epsilon v is this part a and w is rest of x just let us verify that on pumping we are not going out of the language because if I pump down that means I will take out these both a's because v will be taken out then I have just a bunch of b's bunch of c's which is ok there is no relation on the lengths of b's and c's since i is not equal to 1 there need not be any relation on the other hand if you pump any number of times you will get more and more a's but again you will not get a single a which is when a constraint comes so it is easy to see if I choose v as this part both the a's then we can pump any amount of time and the resultant string still will be in the language if x has exactly 2 a's then this is the situation otherwise u as epsilon v as the first symbol of x and rest as you should be able to verify that this is that even in this case on pumping v which is just one symbol nothing is going to happen now do you see what was the point of here the problem would be let us see with a string like this I had 1 2 a's and here I had 3 b's and 2 c's this will be in the language l according to the definition this is in the language l and now if v was only 1 a for example then when I pump down I will have a 1 a but now I have the length of b's and c's do not match and therefore I will get a string which is not in the language and thereby the condition a will not be satisfied right so overall conclusion is for this language l the conclusion of pumping lemma holds however the language itself is not regular so the converse does not therefore hold here is the language l which satisfies all these things there is a constant k we took that k as 3 then we said take any string in the language whose length is 3 or more and then given such a string in the language we can break it up in u v w such that on pumping v we do not go out of the language therefore this conclusion of pumping lemma holds and yet the language l is not regular actually how do I show that this particular language is not regular I stated that this language l is not regular how do I show because now I know that I cannot use this pumping lemma to prove this particular language to be not regular because why because here is a k which is 3 in fact for which in the conclusion of the pumping lemma holds so we do not get into any contradiction now we can prove this to be not regular by using a slight generalization of this lemma let me state the lemma here is a language l which happens to be not regular but I cannot prove that it is not regular by using this pumping lemma and I just showed you that pumping lemma is not going to give me any contradiction but then how do we show this l is not regular we can show by means of a slight generalization of this lemma which we will consider next.