 So, far we have discussed some properties of regular languages, particularly we have concentrated on the clotted properties, that is the set of regular languages, that close with respect to certain operations like union concatenation and cleanestar, that is from the definition other than that we have observed some of the operations like homomorphism, substitution, inverse homomorphism and quotient reversal. So, several other properties that we have looked into and understood that the class of regular languages is close with respect to those operations. And these properties are very essential in order to understand new regular languages to see that they are regular, because you may see the new language that you are going to observe that it is regular, you may apply these operations on the known regular languages to come up with this thing. Now, in this lecture I concentrate on talking about non regularity, that means to understand that a given language is non regular. So far we have one tool called the Mehl-Nerode theorem that is actually characteristic property of regular languages. So, what we have observed there you know every regular language you know can be for every regular language the corresponding that right invariant equivalence relation it is a finite index. So, we have observed that the point and through that relation right invariant equivalence relation we have to understand what is the number of equivalence classes and you see the index. If it is finite we say it is regular, if it is not finite we say it is non regular, but that particular result is of course, very fantastic result. But for practical purposes you know sometimes given a language to understand the number of equivalence classes you have to little more you know you have to work and really ascertain that whether it is regular or non regular this kind of. So, in order to you know get this property that non regularity we now look into very practical and very nice tool now called pumping lemma that we will discuss that I will discuss in this lecture. So, first essentially you know this is a property of regular languages. So, given a regular language I propose this pumping lemma and see how this can be used to understand the non regularity. First let me state the lemma, if L is an infinite regular language then there exist a number k associated to L of course, such that for all x in L whose length is bigger than k that string can be written as u v w satisfying the following condition. So, one condition here is the middle portion if you have partition that has u v w the middle portion is non empty and for all i greater than or equal to 0 u v power i w all these strings the infinitely many strings they are all be in L. So, this is what is pumping lemma what I am stating here is for any infinite regular language this property holds first let us look at the proof of this result. Then we will discuss about the application and all those things. Since, given language is regular you can have a d f a let me say a q sigma delta q naught f a d f a accepting L assume the kappa or k whatever you see that the number of states you set it as k. Since, L is infinite you can always find a string a 1 a 2 a n let me call say x a 1 a 2 a n in L whose length is bigger than or equal to k. Here the language is infinite I am using because since it is infinite language you can always find a string whose length is bigger than or equal to k. Now, this string since it is in L you look at the accepting sequence. Let me call the intermediate states to reach to a final state like the accepting sequence q naught q 1 q n when you apply this string a 1 a 2 a n in the d f a. So, that is you can have this kind of situation you have this kind of situation in q naught you are applying a 1 to come to q 1 and then in q 1 you apply a 2 to come to q 2 and so on and so on. By the time you apply a n you are reaching to the state q n and since the string is accepted by the given d f a this is initial state and this is a final state q n is an element of f. So, this is the situation here. Now, as there are only k states in q because the number of states we have assumed that is k by p is in whole principle at least one of the state must be repeated in the accepting sequence of x. That means you see here the number of states I have written because here a 1 a 2 a n when I am supplying as an input I can clearly see here at least n plus here I am seeing exactly n plus 1 states. So, this n plus 1 is bigger than k because n is greater than or equal to k. So, you can see that by p is in whole principle among these states at least one state should be repeated because there are only k distinct states. Now, you notice here that at here there are n plus 1 states and that is bigger than k and hence by p is in whole principle at least one state should be repeated in the sequence. Now, let me assume that q r is equal to q s for r and s there between 0 and n and r is less than s. So, that means the picture now will be looking like this is q r let me say and this is equal to q s. Now, the q r plus 1 and q r because these are coinciding q r plus 2 and so on and so on. Now, this is q s minus 1 this is q s again this is same as q s because q r is equal to q s and now of course, q s plus 1 is here and so on. So, the situation is like this now you have this kind of picture on the accepting sequence on the accepting sequence. Now, because of this because of this I have the facility to break this string in the following form that is the string from here to this situation this place this q r state I will call it as u and the string that is actually in this loop I call it as v and the remaining string I let us write it as w. That means a 1 a 2 a r till a r let me call it as u a r plus 1 to a s that is v and a s plus 1 to a n let us write it as w. Thus x is clearly partitioned as u v w and more over and more over here this v this string v is non-empty because q r is equal to q s q r is equal to q s, but r is different from s because of this at least some string should go in this loop and in this loop and you observe that v is non-empty string. Now, we will prove that u v power I w for all I greater than equal to 0 is a string in l first for given I greater than equal to 0 u v power I w that is essentially a 1 a 2 a r a r plus 1 to a s power I a s plus 1 to a n. In the picture you can clearly observe this property u v power I w is accepted by the DFA the DFA a that you can quickly observe, but of course we have to give an analytical observation here. First you understand very quickly that by avoiding the loop here from q naught to q n you can reach that means v power I where I equal to 0 if you look at that is what is just u w you can clearly see in this picture that if you apply the string u w that means with I equal to 0 v power I w that string if you substitute if you apply in this initial state q naught you see you will go to q r after you gets over you are at q r and w starts from here and you can quickly observe that u w is accepted by this by the given DFA because you are reaching to a reach into the final state q n itself. If I is equal to 1 that is the string x that is clearly in the language if I is equal to 2 essentially you have u v 2 w. Now, u you are reaching here v 2 means essentially you go through this loop once and once again you go through the loop once again you go through this loop. So, that means v square then w similarly in this loop if you keep going for several times here in this loop if you are going several times. So, that much power that you can raise to v and the resultant string that is u v power I w is going to the final state q n and thus you can quickly observe through this diagram that u v power I w for all i greater than equal to 0 is accepted by the DFA. Now, that is what we will demonstrate here analytically since q r is equal to q s we see that there is a computation for u power u v power I w in a as given below how that is you consider the string for arbitrary i q naught u v power I w in finitely many steps of course you are reaching to q r by after finishing u as I had mentioned in this figure. Now, v power I w you will keep going to this v in that loop for that many times as you required that is what is the situation you reach to q s then the rest of the thing is at first once you consume 1 v then the rest is v power I minus 1 w and since you know q r is equal to q s. So, I again take back the state q r and apply once again then I get reduced by 1 more v here and so on you keep reducing that continuing once v is finished the v component is finished in the string when the rest of the string is w then you consider q s and in q s you can apply w to reach to q n and thus the string u v power I w is in l for all i greater than equal to 0 and hence we have that result. Now, let me look at some remarks on pumping lemma if l is a finite regular language then if you choose k to be for example, 1 plus maximum of the length of all maximum of all lengths of all the strings in l they are only finitely many you consider the maximum say plus 1. Now, with this k with this k the language l satisfies the pumping lemma because in pumping lemma it is given that if you take any string whose length is bigger than or equal to k then it can be partitioned into so and so on and the string u power v u v power I w is in l for all i greater than equal to 0. But, there is no string in l whose length is bigger than or equal to k here because we have considered k to be the maximum of all those strings plus 1 length of all those strings plus 1 thus you do not have any string and hence the result is vacuously true. So, for a finite regular language the pumping lemma is a vacuously true and thus I can conclude that this pumping lemma holds good for all regular languages because we have proved for infinite regular languages now from this observation you have see that for a finite regular language the pumping lemma holds and hence this you have. Now, if we write p l the statement l satisfies pumping lemma and if I denote it by l is regular by r l then the pumping lemma for regular languages can be given by r l implies p l because if l is regular then l satisfies pumping lemma. Now, this p l pumping lemma for a regular language can be elaborated by logical formula as follows for all regular languages there is a k such that if you take any string in l whose length is bigger than or equal to k then there exist u v w strings such that x is u v w v non empty for all i u v power i w is in l this is the formulation of p l pumping lemma. Once again you see because this is very important logical formulation what is the observation here if you take any regular language there is a number k such that for all strings whose length is bigger than or equal to k that string can be partitioned such that the so and so happens that is u v power i w is in l for all i greater than or equal to 0. Now, let us look at contra positive form of the pumping lemma because as I had mentioned this pumping lemma we will use it use to understand non regularity that means essentially we look at the contra positive form of the pumping lemma if a language does not satisfy pumping lemma then it is not regular that is written by negation p l implies negation r l. So, now we have to look at this negation p l essentially this negation p l from the above this we can quickly write because of this whenever you have the quantifiers for all are there exist if you apply negation another statement they will be reversed. So, for all becomes there exist and there exist becomes for all look at here. So, for a language that is if you here in pumping lemma it says there exist a number here for all k for all numbers corresponding to this here if you choose you can identify a string that means there exist a string x such that such that the length of x is bigger than or equal to k and for all strings u v w x is such that x is of the form u v w and v non empty that implies there exist an i there exist an i such that u v power i w is not in l. So, this is the contra positive form you can quickly see that whenever you have a statement for example, p arrow q you know that this is negation p r q and when you have the negation of this statement this is equivalent to negation of this this is equivalent to negation of negation p and q. So, that is so we use this logical formula because here you have two things this statement implies this you can call this is p and this is q p arrow q. Now, once you apply that negation what you will be writing that is p and negation q that is what exactly we are writing this is p and negation of this statement. So, using this we have formulated this contra positive form of the pumping lemma thus what you have to do here if you want to observe a language is not regular for all k you have to you are given an arbitrary k you have to identify a string whose length is bigger than or equal to that k and if you partition that string in any you know in any form that u with u v w that means for all choices of u v w with x is equal to u v w and v non empty you have to identify i such that u v power i is not in l. So, this is what is the point we have to observe to understand a language is not regular this can be better explained through an adversarial game for non regularity that means given a language l if you want to show l is not regular then we play as follows. So, that means here an opponent will give us an arbitrary number k because you have to do it for all k. So, you take a number from an from your opponent an arbitrary number then you pick up smartly a string x whose length is bigger than or equal to k once it is the ball is in your court obviously you can behave smartly. So, here k is given by the opponent because this is an arbitrary thing. So, you choose because there exist l there exist x in l that is what is the point here. So, you choose some string smartly whose length is bigger than or equal to k and then since for all choices of u v w where x is of the form u where u v w is equal to x. So, that means since it is for all forms you leave the choice to the opponent. So, opponent will divide as per his wish u v in the form u v w and of course we will maintain that v non empty then you have to identify an i such that u v power i w is not in l. Now, let me give an example to show that the language is non regular if you consider the language because we have already observed this a power n b power n such that n greater than equal to 0 you know this is non regular. This we have observed through Mahill Leroy theorem. Now, let me apply pumping lemma to observe this is not regular. So, you take an arbitrary number k that is given to you now you choose some string because any string is of the form a power n b power n. So, I do not have too much choice only thing is on the length you have the choice, but let me choose a power n b power n such that this length of this that means 2 m is greater than equal to k. We choose this string because this we choose this is given to you. Now, the opponent will divide this is into u v w how he will divide with v not equal to with v non empty. How he will divide that it is of his choice and thus the possibilities of v we have to look at. Now, since v is non empty since v is non empty in the string a power m b power n the possibilities for v is it may be of the form say a power p p greater than equal to 1. Because if v is completely within a or v may be of the form b power p of course p greater than equal to 1 some non empty string or if it is in between then you can have some a's say let me call a power p b power q of course, here p plus q greater than equal to 1, but here since we have assumed that a in case of q is 0 we have already the first case if p is 0 the second case is already there. So, p and q both are greater than equal to 1 here in this case these are the 3 possibilities for the non empty string v to be non empty. Now, let us look at the first case the string a power m b power m a power m b power m what is the situation this the first say let me call p 1 a power p that is the string v and a power let me say p 2 a power p 2 and then a power m. So, here p 1 plus p plus p 2 is m this is m clearly. Now, what do you do this this is now automatically u is a power p 1 v and the rest of the string is w here rest of the string is w if you now raise the power of p 2 for example, say 2 that is the string u v 2 w what will happen here the number of a's here will be a power m plus p then b power m this is the string because the total number of because we since we have in raise we have this to the power 2 this string is nothing else, but u v v w this u v w when you take u v here there are the and the component of w there are m a's and since we have 1 more v here. So, a power p is getting added to this. So, the string is a power m plus m plus p number of a's here. So, number of b's is m, but you see clearly this is not a string in l a power m b power m this the string the number of a's followed by number of b's will be in l if the number of a's is equal to number of b's that is the condition here we have. So, this is not a string in l similarly, if you consider the second case if you consider the second case you can do the same thing because a power m b power m is there now u will be here the v is completely in b's say let me say this is b power p is here now before b power p you can have all the a's. So, that means a power m and some number of a's whatever is possible. So, that is that you can have. So, let me write this case in case 2 same stuff a power m b power m is a power m b power p 1 b power p b power p 2 with p 1 plus p plus p 2 is equal to m of course, p 1 can be 0 then just before this v you do not have any b's. Now, this is u this is v non m t p greater than equal to 1 and the rest of the string is w here again similar to the previous case if you raise the power of v 2 2 you can clearly observe that the number of b's will increase but the number of a's is m only for example, u v square w that is a power m b power m plus p here in this case. In these 2 cases it is not only the power 2 you observe that u v power i w is not in l if i is not equal to 1. Even if you make it is 0 i is 0 then the number of in the first case number of a's will reduce and number of b's is m thus you can quickly see that that is not a string in l. If you raise to the power more than 1 if it is not equal to 1 the number of a's or b's in the first case and second case respectively will increase to observe that the string is not in l in both the cases. Now, in the third case since v is assumed to be of the form say a power p b power q. So, this is the string in between in between if you have some number of a's and then the same number of b's. So, this is a string somewhere in between you have so many number of a's p number of a's say q number of b's you have. Now, once you raise the power here may be square for example, u v square w what will happen since here number of a's is assumed to be greater than equal to 1 and b's is greater than equal to 1. You can clearly see that by raising this power for example, if you have say for example, 1 a and 2 b's in place of v once you write v square here a b b again a b b will come that means after a in the portion of v square this is the portion of v square. Of course, you have the same u and w as it is now in the portion of v square you observe that a b b a b b is coming if v is say a b b and you can clearly see that after a's b's have come after b's again a has come and b's have come. This is not the format of the language the format of a string in the language and thus this is also not a string in L. So, in all the three cases we have observed these are the three possibilities for the string if you pick up an arbitrary string a power m b power m there are three possibilities for non-empty v and you observe that all the three cases we have identified some i such that u v power i w is not in L and hence we can conclude that the language is not regular. Let me give one more example if I consider the language say all the strings of the form w w such that w is in the strings of the form w w now again pick up an arbitrary k this is given to you. Now, you can smartly choose a string of course by taking a string arbitrarily in this the number of cases that you have to argue will increase and you may not have control to understand. So, here smartly for example if I choose say 0 power n 1 power n 0 power n 1 power n you can clearly see this is a string in this language because the same whatever w in the first half I have taken I have written the same thing. So, this is if I choose this string now this string will be divided u v w now the possibilities for v because v non-empty the possibilities for v now you look at carefully this v can be completely in the first block of zeros or may be the first block of ones or the second block of zeros or may be the second block of ones. So, there are four possibilities and then it can be you know in between the first block of zeros and ones that is one more possibility now you see and similarly here another possibility and here another possibility and what else now it can include all this and it can actually intersect this. So, you see there are several possibilities here in fact you can observe that there are ten possibilities there are ten possibilities. So, in each possibility of v we have to observe in each possibility of v we have to observe that there is an i such that u v power i w is not in here. Now, let me quickly discuss one case and then we proceed to understand I leave it as an exercise to understand that in each case you can identify an i such that this is not in l. For example, if v is say 0 power p it is in the first block of zeros such that x is equal to say 0 power k 1 and this is under consideration that is 0 power p this is what is v and the rest of the zeros may be let me call it as k 2 and the remaining string that is 1 power n 0 power n 1 power n. If this is the situation now you choose say again i equal to 2 now the string u v square w that is 0 k 1 here p plus p 2 p 0 k 2 1 power n 0 power n again 1 power n. That means, essentially the number of zeros here is number of zeros here is n plus p 1 power n 0 power n 1 power n. Now, we have to observe that this is not of the form w w for any w if this is of the form w w you can have two strings say x is already used x is a given string say this is y z if you divide y z if you divide with mod y is equal to mod z. Now, observe that this y and z are different y and z are different because if it is of the form w w then we want to observe a contradiction instead what I am doing this string you assume it is of the form say y z with lengths are same unless y equal to z you know this is not of the form w w. So, here now the length you observe this is this is 4 n plus p is the length 4 n plus p is the length. Now, what is the length of z and if you compare with the length of y. So, you divide this mod y is equal to mod z this is 4 n plus p by 2 say let me call it as 2 n plus p by 2 2 n plus p by 2. Now, you look at z is suffix of the resultant string u v u v square w here and thus this length of z is greater than 2 n length of z is greater than 2 n and you observe then this z is of the form z is equal to this because this is there is a shifting here let me say 1 power say p by 2 number of 1's whatever is coming and then this is 0 power n 1 power n this is what is coming and whereas, y will be the prefix of the string y will be prefix of the string. So, y will be now this is 0 power n plus p 1 power n minus p by 2 because this many number of 1's are shifted I mean you have to consider in z. So, you clearly see that these 2 strings are different and hence you conclude that this y z is not in L that is u v square w y z this is not in L. Thus this case we have identified an i such that u v power i w is not in L. Now, if you consider case 2 that means in case 2 in case 2 you can have may be the v is in here the block of 1's case 3 it is in the block of 0's case 4 in the block of 1's likewise you can argue and understand that there is an i such that u v power i w is not in L in each case you can observe that and understand that the language is not regular. So, an exercise here complete the proof to observe that w w such that w is in 0 on star this plus regular expression is not regular. Now, let me make a point here in the first example if you are given a k you choose a string of course you have a choice of choosing, but since the first language 0 power n 1 power n any string is of the form 0 power n 1 power n there are 3 cases to discuss. If you look at the second example the strings of the form w w for any string w in 0 power 0 1 1. Now, given a k you can smartly choose a string here I have the choice say I have chosen 0 power n 1 power n 0 power n 1 power n because this is such a nice string that you can observe the cases very quickly. If you choose an arbitrary w in 0 power 0 1 the situation will be complicated and the cases to discuss will be little bit difficult because the w arbitrarily when you have chosen how you have to argue that the resultant string at some point of i whether it is in whether it is in L or not to say that it is little bit difficult. Still when I have chosen this string I have observed that there are 10 cases all the 10 cases I have to argue and I have to identify an i to prove that it is the language is not regular. Now, I give you some more information about pumping lemma because we can in fact observe more in pumping lemma to understand very quickly that the given language is not regular that is the version of this pumping lemma as follows. If L is an infinite regular language then there exist a number k such that for all x in L with mod x written equal to k x can be written as u v w satisfying the following because everything is same the division. Now, here v non empty as earlier but here one more important point is the length of u v is less than or equal to k. So, you can divide u v w not only satisfying the v is non empty in addition to that the first two strings when you are dividing you can just look at the division of u v u v w such that the length of u v is less than or equal to the given k. So, and of course when you have such a division u v power w is in L for all i greater than equal to 0. So, this version of pumping lemma if you are looking for the proof the proof is essentially same as earlier only thing is when you are looking for the proof I simply mentioned that by p is in whole principle there is r and s such that q r is equal to q s that is what we said in this diagram. Here what I will what I will suggest you instead of just choosing some arbitrary place where q r and q s are coinciding but there wherever the repetition is coming what you do you keep going from the left side keep going from the left side from q naught q 1 q 2 and so on. Whenever the first repetition comes whenever the first repetition comes that repetition you identify that then this u and the loop v the length will always be less than or equal to k I give you this argument when you are applying that p is in whole principle you just concentrate on looking at the p is in whole principle the repetition of the states within the first k plus 1 states of the sequence first k plus 1 states why do you get the repetition with first k plus 1 state because there are only k states once you cross the number k automatically when definitely you can have one state repeated. So, within the first k plus 1 states you should certainly have one state repeated one state repeated since there are only k states and thus you can have the length of u v u v less than or equal to the k. So, this loop you can always identify within the first k plus 1 states. So, that is the reason why you have this condition u v less than or equal to k with this condition with this condition you have an advantage you know that you need not discuss too many cases for example, for example, of the language 0 power n sorry a power m b power m when you have considered. Now, let me give you in case of 0 power n 1 power n we have argued three cases once you give me k what I will do I will choose 0 power k 1 power k this string I will choose. Now, if you divide this u v w this u v the portion as mentioned is length less than or equal to k and hence the v is essentially of the form 0 power p only there is no choice of getting 0 power sorry 1 power p because this u v length is less than or equal to k and you know the first k symbols are 0's only and hence you observe that v is just we can have just 0's only and thus you can discuss the only one case here. Similarly, when you look at the second example w w such that w is in that 0 1 star in this example if you take this example you given k you can choose now this string 0 k 1 k 0 k 1 k smartly you can choose this string. Now, you look at this is an element of this whose length is bigger than or equal to k because the choice of choosing the string is in my hands now you are giving me k and I choose this string I will choose this string clearly this is a string of length greater than or equal to k. Now, whenever you divide this u v w of the form u v w with u v length is less than or equal to k you clearly observe that this entire string u v has to be the first block of 0's only in particular v is of the form only 0 power p for some p positive and hence only one case I will discuss to conclude quickly that this is not regular because again the pumping lemma it is saying that it is not only v non empty whenever you divide u v w because for all choices of u v w with the length of u v is less than or equal to the chosen number k u v power i w belongs to l for all i that is what is pumping lemma saying. So, to observe the non regularity by considering this version you can quickly conclude that you can quickly conclude that language is non regular the number of cases will drastically go down by adding this additional condition. Now, we have observed several closure properties of regular languages and pumping lemma also we have observed as a property of regular language. Now, all these properties are very useful not only you know identifying a language is regular to identify some to a language is non regular also because to understand that a language is suppose you have established certain languages are non regular. You can apply closure properties if you assume some language is not to observe some language is not regular it is not just a pumping lemma you may use you can use the closure properties also. If you assume that is regular some of the closure properties if you apply using the closure properties the resultant language if you can somehow identify that it is non regular then as per the closure properties you can quickly conclude that you can quickly conclude that the using the closure properties and pumping lemma language are non regular. So, earlier I gave example to you using closure properties to observe that certain languages are regular. Now, let me give you one example using that you can see that languages are non regular let me consider the language say x c y that is that x and y strings of a s and b s and c is a fixed symbol length of y is equal to length of x. If I consider this language you can understand any strings x and y you choose in between I put c the symbol and this x and y should be of the same length or symbols of a and b. Now, if you assume l is regular if you assume l is regular now you understand that this language l dash this intersection with a star c b star this is also regular because a star c b star is regular I have assumed l is regular intersection of two regular languages is regular now you understand what is this l dash l dash is then a power n c b power n such that n greater than equal to 0 you can observe this quickly because length of x is equal to length of y. So, x c y is then of the form a power n c b power n form because the lengths only should be same in this c is fixed here you have to choose s here from here b is here from here and since the length should be same that is a power and b power n form. Now, using homomorphism if I send h of a to 0 and say h of b to 1 and say h of c to say empty string suppose we send it like this then the under this homomorphism that means I am essentially mapping from this to 0 1 star. So, the mapping is essentially h is from a b to 0 1 star. So, what is the image of under this homomorphism what is the image of l dash image of l dash if you observe carefully this is 0 power n 1 power n is that n greater than equal to 0 you see clear we know this is a non regular language. So, if you assume l regular if you assume l regular then this l dash that is also regular and l dash if it is since it is regular l dash it is regular homomorphic image of a regular language is regular. So, h of l dash should also be regular, but we have got a non regular language and hence our assumption that l is regular wrong. So, using this closure properties we have concluded that this is a non regular language. So, thus this closure properties are useful to understand non regularity of languages. So, from this discussion you have observed that there is a non regular language coming out of this, but using closure properties of regular language intersection homomorphism we should always have regular language you have got a non regular language and hence our assumption is wrong. So, l is non regular now let me give you an exercise to understand that it is non regular you can apply pumping lemma to prove that all those strings which are palindromes for a b you can observe that this is a non regular language.