 Now, we have seen that this language cannot be proved to be not regular by using the pumping lemma that we have studied, we have proved this lemma. Now, I had claimed that this language is not regular, at the same time this particular form of pumping lemma is unable to show that. We can make a generalization which is not too difficult to prove. So, let me state that. So, let me say generalized pumping lemma for regular languages and we state something like this. Let L be a regular language then there is a constant K depending on L such that for all x in the language x is greater than equal to K and instead of saying that there exists u v w and we will say here and x is equal to u v w where the length of v is greater than equal to K. We have no constraint on u and w and of course, these things will change. So, let me remove these. Right now what it is saying that if you say L is a regular language then there is a constant K depending on L such that for all x in L length of x is greater than equal to K and x is of the form u v w where v is of length greater than K. In other words it says that v is a substring of x may be anywhere in x whose length is in greater than equal to K. In fact, let me just this is without loss of generally we can even say this that v is equal to K x is greater than equal to K and x is u v w v is equal to K. We have that there exists v 1 this string v is equal to v 1 v 3 and for all i greater than equal to 0. This string u v 1 v 2 to the power i v 3 w is also in the language L. It is kind of similar to the old statement except what we are saying is that you take any string of length any string in the language L whose length is greater than K and suppose you consider any substring in that string x whose length is equal to K that is v then it is possible to break up that v in terms of v 1 v 2 v 3 such that see originally the string x was u then v then w this was the string. Now, we are breaking this in three part or what we are saying is this v can be broken up in three part v 1 v 2 v 3 such that u v 1 this v 2 any power of it followed by v 3 and w this whole thing will be in the language. Now, the proof is really very similar to the idea that we have used to prove our original form of pumping lemma see v is of length K. So, how did that old proof go old proof use the fact that suppose L is regular there is a DFA in to accept L and we say let m have K 6 and that K was the K that it came here and the whole idea was that we took the first part of the string which is of length K in the old proof and then we said that this string which we had called u v in the old proof and this was we said that look in this if you see the first K symbols of the string then consider the state sequence which takes the machine from q 0 to a final state q f because the entire string is accepted there will be such a sequence of states and consider the working of the machine on the first K symbols in this there are K symbols then the state sequence here q i 1 etcetera they will be up to this point when it is just over the first K symbols are over there will be K plus 1 exactly K plus 1 states and since there are only K states one of the states here must repeat itself without any state repeating I cannot construct a sequence of K plus 1 states using only K states and then we said the part in between these two states the part of the string which took the machine from P to back to P was weak and then the argument was given that if you put any number of V's one after another and leave the first part and the last part this part was w the new string will still be accepted and now the wall all that we are seeing that consider now I am talking of the proof for the general case what we said let this be x and let V be any substring of x which is of length k and then in this for this substring which has K symbols consider the sequence of states the machine will go through first coming here and then coming here in that sequence there will be K plus 1 states the same reason because there are K symbols so one of the states will repeat and that part which will take the machine from the same state P back to the same state P that we identify in this proof as V2 and this part was V1 this part was V3 this is V2 and this part was U and this part was and since V2 was taking the machine from P to P any number of copies after the first V2 will also take the machine from initial state to the final state no total string now then supposing you put V2 twice then it will be U V1 V2 V2 V3 W this string also will be in the language and you can pump V2 any number of times and if you pump it 0 times that means this V V2 you have removed that is all right the string then will be V3 W which will take the machine from P to the final state so that is the proof of the generalized lemma and that can be easily used to prove this particular language to be not regular now we will consider the string so now we are proving that L is not regular by using the generalized pumping lemma proof will go like this that let me it is by contradiction you will say let L be regular and let A be the constant and now consider this string A B to the power K C to the power K which is surely in the language L because if I is equal to 1 then we require the number of B's to be equal to number of C's so this string is in the language now break up this string as this is the U this entire set of B's will constitute the V for generalized lemma and this is your W and this says that they will exist V2 V1 V2 V3 full concatenation is the string V right so we can write this as U V1 V2 V3 then W because W is the C case does all the C there are K such C this whole thing is your B's and this is U is only an A and I should have said this of course very importantly like in the old case old form of the lemma that length of V2 is greater than 0 on the generalized form and remember the reason for that is when in the state sequence the state repeats even if these are consecutive states there will be at least one symbol so repetition means there will be some symbols in between and that those symbols constitute the string V2 therefore length of V2 is greater than 0 so now you can see that on pumping some number of times the number of B's will increase nothing else will change in particular number of A's will not change and number of C's will not change right and therefore will get a string in which I will have on pumping will get the string A B L C A where L is strictly greater than 0 why because we have pumped V let us say twice and therefore originally the string had K B's the V2 part had it had at least one V now we have added one or more B's so the number of B's have increased from K to something higher number and now the lemma states that this will be in the language but that contradicts the definition of the language that there is only one A and yet the length of B's is not same as the length of C so the general form of lemma does indeed prove that the language L is not regular do remember what I initially forgot to write was crucial that the V2 part is non entry but that that I am sure will appreciate comes from the proof once we have it in mind that V2 part is the part of the string within V that takes the machine from the same state to the same state and since these two states are occurring separately V2 part must be non entry our next topic is a generalization of the finite automata that we had seen so far and we call this generalized form of finite automata as non deterministic finite automata and before we keep the definition and see examples of this kind of automata let us appreciate why we are interested in generalizing our automata that we have seen so far we define this class of languages regular languages and we had proved many languages to be regular and we know that by definition a regular language is a language which is accepted by a DFA but we also saw that DFA's are unable to accept some very simple looking languages for example we had this is a very simple looking you would agree that we are just saying the languages in which we have 0's and 1's in that order and the number of 0's is same as number of 1's this is something this is a language no DFA can accept so it is not regular so obviously we would like to generalize the class of languages for which we can have we can define formally automata and other devices for accepting now it is because of that reason we think of generalizing finite automata so the way we think of the generalization although by the way let me just say that although we are saying this is generalized form it will turn out that this form also will not be accept will not be able to accept anything other than regular language and yet this is an important topic because of the reasons that will enumerate later if you go back to DFA definition we had the constraint that call it constraint or call it the way it was defined was that suppose the machine is in some state and then a symbol comes A so this is P then the machine will go to some other say Q in another other words we said that delta P A will be some state Q in our set of states so what is happening is that from a state on when a symbol comes A there is a unique transition that is possible so from every state one and on every symbol there is a unique next that made sense the way we have defined the automata but suppose someone asked this question that what happens if I relax this what happens if I see that from a state on a symbol there can be 0 1 or more transition now let me first give an example to see what we mean by saying that from a state there can be 0 1 or more transitions out on the same symbol to consider this automaton look at this this is certainly not that is all I have not given you all the arrows that I need to define this automaton you see in this state on 0 you could come back to this state because of this transition also there is a transition out of this state on the same symbol 0 to this particular similarly on 1 from this state there is a transition back to the same state also there is a transition to this state so from this state on both 0 and 1 both the symbol 0 as well as 1 we have not 1 but 2 transitions out of that state on the other hand look at this state in this state we have a transition on symbol 1 but there is no transition out of the state on the symbol 0 implicitly I am assuming that the alphabet is binary so let me write it clearly here although my alphabet has 2 symbols in this state for example on 0 we have no transition defined similarly from this state there is on symbol 1 there is no transition defined so at least this particular automaton certainly has that property that we talked of that from 1 state they can be either 0 1 or more transitions on the same symbol once we make this kind of an automaton is defined this kind of an automaton what does it mean to see that this automaton as an input and is doing the computation on the input this we should be clear about what does it mean to see that we have a computation of this now like a DFA this NFA also have some input which is a string over the alphabet so let us say the in our input is 0 1 1 0 and let me name these states so this is q 0 this is q 1 q 2 q 3 q 4 q 5 so there are total 6 states and as before an arrow coming from nowhere it means that this is the initial state so the this NFA this automaton if I name it m initially it is in its state q 0 so that is easy to see so here is this input 0 1 1 0 and initially the machine is in state q 0 now let us say the input is there and the input the first symbol of the input is 0 so what happens in fact this is what the first question will ask that there are two transitions out of initial state on 0 then what happens what does the machine do which state the machine go to on 0 starting from the initial state q 0 well conceptually the way to think about these machines will be that it can go to all these arrows etcetera all what they are saying is that since there are two transitions on 0 out of the state the machine can go to one of these two states either t 0 or q 1 which state it will go to we see non-deterministically machine makes a choice to take one of these two transitions but what so the initial symbol is 0 you can imagine a picture like this if I write out all possibilities so from q 0 on 0 the machine can go to q 0 itself as well as it can go to the state q let me complete this and then we will discuss a little more about what we mean by computation of an essay then the next symbol 1 it from from q 0 on 1 it can remain in q 0 so this is the next symbol 1 that it and on 1 it can also go to q 4 what about q 1 see had it gone to q 1 on the first 0 now it is seeing the second symbol 1 from q 1 on 1 it has to go to q 2 there is no other choice then the third symbol 1 comes and from q 0 as we have seen earlier it has on 1 it can either go to q 0 or also it can of course go to q 4 and from q 4 on 1 where can it go to see this is the state in which it saw 1 and these are the two possible states it could go to from q 4 on 1 if you see there is only unique state it can go to which is q 5 from q 2 had the machine taken this path from q 0 had the machine on the first 0 chose to go to q 1 and then q 1 when it saw 1 it had no choice really except to go to q 2 which is now on q 2 it sees the same one but what happens on q 2 on 1 there is no transition defined what as the machine where which state the machine goes to it is not defined we see that if machine had taken these choices in the computation abort there is this path there is nothing much to do because on q 2 1 had come and there is nothing else to do other than the machine abort by abort what I mean is let me let me make it clear see the suppose the machine was in this in state q 2 and 1 came since no transition is defined then that computation cannot proceed any further and that is what we mean by the computation aborting the computation no more nothing else is defined about the computation now you see another 0 comes the machine supposing it had taken this these choices from q 0 on first 0 it went to q 0 on q 0 on second I mean second symbol which was 1 remaining q 0 and this it can again as two choices from q 0 on 0 it can go to q 0 itself or it can go to q 1 from q 4 on 0 we have a problem again because q 4 you see there is no transition defined on 0 so this path abort this computation abort there is machine could be in q 5 q 5 on the 0 it is remain in q 5 so one thing is clear even if you define it the machine or machine in this way where there can be 0 1 or more transitions out of a state as in this case what we can do is that given an input we can see which all states the machine can be at the end of this tree and you can see this is this is a kind of tree is not it this is a tree and at this level when I have 0 1 1 0 to each level is talking about what are the states that the machine can be after seeing that part that much of the that some initial prefix of the input then I have this tree and this is called the computation tree of the of the non-deterministic machine M on input 0 1 1 0 I would like to emphasize that while talking of non-deterministic machines we of course see that the machine is faced with certain choices at certain points in the computation for example here if the machine was in the state after reading 0 or 1 it has the choice of either going to q 0 or q 4 what happens you may ask what actually happens if I start the machine on this input what actually happens what actually happens is one way of thinking of this is the machine follows one of these parts which part the machine will follow actually we do not see because always the machine can follow this can follow this can follow this this is like a human being right I mean you are walking on the road and the road bifurcates we cannot say which fork you will take I have the choice if I am faced with the road we are going and there is there is a circle and there are two road the road is bifurcating I can either take the left part of the right part I have the choice similarly this machine I mean at least intuitively at a conceptual level we can think in this way that the machine has the choice and sometimes if you run it many times maybe sometimes it follows this part maybe sometimes it follows this part and so on but one more thing that there is no probability involved we are not saying that with certain probability it will take this part this state or it will go to be it is not a probabilistic machine although such a definition is possible we will not consider probabilistic finite automata here so that is possible but here it is not that the we are it is there is any probability etcetera associated with these choices that it takes one transition with certain project another transition with another project it is really really the best way to think of these machines is the machine is making a choice next question that comes is how do we realize such a machine and how do I realize in a machine choice right those of you who know a little bit of electric I mean we have seen some first courses in electrical engineering we have seen flip-flops it is not difficult to see that I can realize a DFA using hardware it is very easy to see I can simulate a DFA I can write a program which will see it simulate the working of DFA but can I write a program to simulate or to work like an NFA I do not know I mean there is no such machine I know of which makes choices so then what good is this kind of machine you may ask see what what what we can do is we can use this theoretical construct of our non non-determinism to define languages now what is the language accepted by NFA right suppose in that definition that definition is clear like in the case of NFA in case of NFA sorry DFA we wrote it we presented a DFA and then we said that there is a unique language associated with this machine which is the language accepted by the DFA that will be the similar is the case even with NFA so let me informally write the language accepted by M L M the language accepted by M NFA M to be the set of all strings over my alphabet all finite strings over my alphabet and what is the qualification on these things that is that x can take the machine and from its initial state one of its now operative or phrases can take x can take the machine M from its initial state to one of its final state well let us look at this computation tree for the example machine that I have drawn is this string in the language accepted by the machine M well which are the states the machine can go to on the input 0 1 1 0 that I have seen q 0 q 1 and q 5 and as it happens q 5 is a final state so do you see that the machine M can go from its initial state q 0 to one of its final states q 5 on the input 0 1 1 0 therefore this string is in the language accepted by the machine M the way we have defined this is an informal definition as I am saying we will formalize it later but let us work with this informal definition for a little while more I have just told you that the string 0 1 1 0 can take the machine M from its initial state q 0 to one of its final states as it happens here to fight therefore we will see that 0 1 1 0 is in the language accepted by M can we see what precisely is this language I claim that ln is the set of all binary strings 0 all finite binary string such that x has as a sub string either 0 1 0 or I claim that this is the language accepted by the machine M the notion of the language accepted by a non-deterministic machine remember is the set of strings which can take each of which can take the machine from its initial state to one of the final states so can we argue this out that using that notion of acceptance the language accepted by M is precisely this alright first of all think of a string which has either 0 1 0 or 1 1 as a sub string so in particular think of a string we do not need this anymore so let us think of a string think of a string which has as a sub string suppose 0 1 this is our string is x so there is some initial part and followed by that sub string there is some other part to call this first part as x 1 and the last part as x now what the machine can do remember I am not saying I can never say about NFS that machine is going to do this or the machine will do precisely this but what I can definitely says the machine can do such and such thing using its choices so what the machine can do that on x 1 it remains in this state imagine x 1 1 was some this is x p or x 1 so what the machine machine of course could have done on 0 it could have right on the first 0 it could have gone to either q 1 but it chose to remain in this state q 0 on this part x 1 now on this 0 which is the first symbol of the substring of interest the machine makes this transition to q r and then a 1 comes it has to go to q 2 it does so then a 0 comes it comes to q 3 and then it remains in q 3 because you know of this loop so do you see that on a string x which has as a sub string 0 1 0 it is possible for the machine to go from the initial state its initial state q 0 to this final state q 3 and similar is the case that on any string which has a substring as a substring 1 1 the machine what it can do on this part it will choose to remain in q 0 and on this 1 now there may be one switch might have occurred before but on all those ones it remained in q 0 and then it on this particular one this 1 1 is the substring of interest it came to q 4 on q 4 then a 1 came it went to q 5 and then the rest of the string it will remain in q 5 then therefore again on this string the machine has the capability machine can go from its initial state to one of its final states in this case it is q 5 so my claim is that if you if you work with this definition of the language accepted by the non-deterministic machine name then all these strings which has as a substring either 0 1 0 or 1 1 such strings will be accepted and therefore what I have really shown to you that the language accepted so let me write it this way that x has I am just repeating that x has as a substring 0 0 1 0 or 1 1 this set this set is a subset of the language accepted by our machine but if I want to show the equality I need to prove the other way I need to prove also along with this I need also to show that suppose a string is accepted by this machine by that what we mean the string takes the machine from such a string can take the machine so any string here by definition is a string which can take the machine from the initial state to one of its final states then such a string has to have either 0 1 0 or 1 1 as a substring again that can be looked at in this manner it imagine that string now that string finally an imagine that those choices which because of which the machine went from q 0 to one of this final states consider in particular that the machine went to q 3 initially it was in q 0 then that string came and the machine exercise its choices and finally at the end of the string it is in this state now do you see that string has to have 0 1 and 0 in succession what because finally we are talking of the path which went from 0 q 0 to q 3 that path then there might be many this loop that path might have taken but since it came from here find at some point in the path q 2 must have come immediately after which q 3 k and that transition is possible only on 0 from q 2 to q 3 and then it came it came to q 2 and the state immediately before that must have been q 1 must have been 1 because the only way the machine can come to this state q 2 is from this state on 1 right see there is that is the only transition and so the machine sometime came to q 1 after which there was a 1 0 and then some part of the string and then it came to now we are saying it came to q 1 but it could come to q 1 only on a 0. So, therefore put together the this 0 1 0 must occur in any path right whose levels of this such symbols you understand what I mean any path from q 0 to q 3 if I think of any path which takes the machine from q 0 to q 3 that path must be labeled with 0 1 0 alright which means that if the machine went to q 0 to q 3 on a string then that string must have 0 1 0 as a substring similarly on another way of accepting a string would be that it finally went to q 5 and for that the string must have 1 1 as a substring. So, that will prove this assertion. So, therefore, I can claim put together that this is a subset of l m and l m is a subset of this therefore, it is an equality. So, let us see another example we will keep this definition here but the example will change. So, consider this machine well this is reminding another machine m which is again a non-deterministic machine it is not a deterministic machine because from this state on one it could go to either here or it can remain in this state and you see there is no transition out of this state which is the only final state the machine has neither on 0 nor on 1 it has a term if I call this machine m and I now claim that l m gain my alphabet is binary I claim that l m is the state of all binary strings binary binary strings that the fourth bit the right end is 1. Now, you have encountered this sort of languages before when you are discussing the DFA and remember that we even proved that for this language to be accepted by a DFA that DFA must have at least 2 to the power 4 states and in fact we showed that 2 to the power 4 states will suffice but no DFA can accept this language with less than 2 to the power 4 states that we proved 2 to the power 4 is of course 16. So, that DFA to accept this language would require 16 states but if I am correct in making this assertion then I have an NFA to accept the same language with much fewer states namely 5 states well imagine I have a string whose fourth bit from the right is 1 and let us say I have some more bits here now it is very easy to see that this string will be accepted by this machine because why this string remember why because this string can take the machine from this state to that state why because you know on up to this point before just the bit before the fourth bit from the right this is the fourth bit from the right 1 2 3 4 all this time the machine chose to remain in this state and now this 1 came it had the choice of being here as well as going there but now it exercise the choice of going to this state now once on this it went to this particular state supposing I name them as 0 2 1 2 2 4 then of course the next one either on 0 or 1 1 from q 1 it will go to q 2 it went to q 2 then this 0 came it went to q 3 and then after q 3 this 1 came it now in q 4 right so this string can take the machine from 0 to 4 so it is fairly easy to see that any string with as 1 as its fourth bit from the right end such a string can take the machine from its initial state to its final state and similarly I can argue the other way round that suppose I have a string which is accepted by this machine that is which is in the language so that string will spell out the path from here to here and you see once the machine reaches here there is no transition out if there was any further symbol then what would have happened the machine computation would have about it right so must be that part must be such that the fourth bit from in that part when I look at the symbol the fourth bit from the right end must be 1 right so you can you can look at this example and convince yourself in the same manner if need be you can draw a few computation trees as we did in the first case for some strings for example let us take a computation tree for a machine for a string which is not in the language my claim language so let us say 0 0 0 0 the fourth bit is not here so in fact on this of course the machine will always remain in q 0 that is clear but let us see it is 0 1 1 something like this to think of 0 1 1 1 this string this should not be in the language because the fourth bit from the right end is a 0 and not 1 so what happens let me just go do this initially the machine is in q 0 the 0 the machine will remain in q 0 on the first 0 and then a 1 came on 1 the machine has the choice to go to either q 1 or q 0 so this is the 1 on the next one again it can go to either q 0 or q 1 which is fine on q 1 so this is the next one that we are talking of and from q 1 on 1 it can go to q 2 in fact it will go to q 2 it has no other choice q 2 and then the final 1 came what is that what will happen to that when this final 1 comes it will be either in q 0 or in q 1 from q 1 when the 1 comes it will go to q 2 and from q 2 when the 1 comes it will go to q 3 so these are the only 3 only states the machine can be either in q 0 q 1 q 2 or q 3 but it will not be in q 4 it cannot be in q 4 on the input 0 1 1 1 so therefore this string will not be will is not a string which can take the machine from its initial state to its final state q 4 so therefore it is not in the language we will see other examples of NFAs but before we leave this example we have seen two examples of NFAs and we have informally described the languages accepted by these two NFAs we will continue but before we continue and take up further examples of NFAs we will need to understand the conceptual way in which most people understand the working of NFAs and that is what we are going to