 We are discussing finite state automata f finite state automata these are abbreviated as f s is the particular form we are discussing now they are also called deterministic finite state automata deterministic finite state d f a's and as we have mentioned either we call them automata or plain simply machines this f s a or d f a we can call these now and I will tell you later on why it is called deterministic but for the time being our model recall is such a machine m has five components q sigma delta q 0 and f q is a finite set of states sigma is the alphabet delta is the transition function which is a map from q cross sigma to q and q 0 is a one particular element of the set of states this is the initial state and f is a subset of q which we call final states set of final states. This time we also saw how the function delta which was a map from q cross sigma to q in other words which tells me if the present state is something the symbol being scanned is something then what will be the next state this extended to delta hat which was a map from q cross sigma star to q and the idea was delta hat will take as the first component first argument a state the second argument is a string. So, remember x is a string which is an element of sigma star and if it is p then it means the machine goes to state p on scanning the string x starting from the state we given inductive definition for this function delta hat. Now, a very important use of delta hat is to formally define what is the language accepted by a machine will come to that concept, but before that let us also keep in mind what is the our mental picture of such a machine we think of by the way this was an example that we had seen and will discuss some of the concepts which we are going to give now in terms of this machine that we had seen earlier this age was missing. So, this is of course this called the transition diagram of the FSA transition diagram of the machine, but imagine this machine one way of thinking of this is that the input is given written on a tape and this tape has number of squares. So, this tape is nothing, but one square after another. So, they give me something and this symbol here may be a 0 this is a 1 a 2 and this is a n incidentally at this point we should make one standard notational convention clear that when I use. So, let me write this convention here remember sigma is the alphabet and when we write symbols or you know letters like a b a 1 a i etcetera. These are supposed to stand for elements of my alphabet as elements of sigma. So, lower case letters from the beginning of the you know English alphabet a b may be subscripted like a 1 a i these are elements of sigma. So, that means these are symbols whereas, when I use smaller case letters x y z possibly subscripted etcetera these are strings over sigma. So, now this is using this convention you should be able to immediately see when I write this what I mean is these are symbols each square in my tape holds a symbol. So, this first symbol we are calling it a 0 second symbol is a 1 etcetera and now remember we said that the machine starts scanning from the first symbol. So, this is the supposing this is my machine m. So, this is the mental picture that there is some machine which has a head this is called the read head of the machine which at any given time will be at one of the squares of the tape and when it is at that square it is reading that symbol which is held in that square. So, what happens when we start the machine like this of course, that time the machine is in its initial state which is q 0 and it scans the symbol goes to the next state and then it moves one square to the left. So, you can imagine the head is moving one square to the left and so on and also we said that when it finishes scanning the entire string it is obviously it will be in some state and that is the state in which the machine is after scanning the string on the input tape. So, you see there are two sequences one is of course, the sequence of symbols which is in the string which is your input the other is the sequence of states through which the machine is going as it is scanning the symbol one after another. So, let us take this machine in particular and just write some input let us say 0 1 1 0 1 0 right. So, this is supposing you give this as the input to this machine we see this input as this sequence of symbols and it is convenient to think of that the machine is going through a sequence of states and those states will write in this manner initially the machine is in q 0 right in the state q 0 it is seeing the symbol 0 and therefore, it goes to state q 1 right. Now, in q 1 it is seeing 1 and therefore, it comes to q 2 right in q 2 it is seeing 1 so this is going back to the state q 1 in q 1 it sees 0. So, it goes to q 0 and in q 0 it sees a 1 so it comes to q 3 in q 3 it sees a 0 so it comes to q 2 right. So, this is a this is how of course, you can define the sequence of states the machine is going through as it is scanning the input this machine it initially started in its initial state and you see that as the input is over it finds itself in the state q 2 right and in fact, it finds itself in the state q 2 right and in fact, this function delta hat tells me so in this particular example if I use delta hat because the purpose of delta hat was tell me which is the state the machine would be after scanning a string x starting from some particular state q. So, in this case in this example what we had just gone through we can say delta hat for this machine if it takes q 0 and the string is 0 1 1 0 1 0 then it will be in state q 2 right. I would like to point out to you the the number of states in the sequence corresponding to a sequence of symbols which is in the input that number of states in the state sequence is exactly one more than the number of symbols in the input that is easy to see why so from this example or this illustration. One very important definition is the language accepted by a DFA or an FSA and that is done in terms of this function delta hat. So, let me say it right here the language accepted by m, m is as this called l m is defined as all those x and because of our convention x immediately means I am talking of a string over sigma all those x in sigma star such that delta hat of q 0 x is in F. So, what is this definition saying l m is a language language means a set of strings which are the strings which are in the this language it is precisely all those strings which will take the machine from q 0 to one of the states which are designated as final states. Now, either a string takes the machine from q 0 to a final state or it does not. So, this is one specific language this is a unique language associated with the machine m. Now, another definition which is very important which is the notion of regular languages it is very simple the regular language is a language for which there is a DFA to accept it. So, in fact, let me write down the definition we have done with this or here let me write it down a language is called regular. So, let me name this language a language l is called regular if there is a DFA m such that language accepted by m is l if these two l's are confusing. So, let me call it l 1. So, what is the definition for regular languages that a language is regular if you can find a DFA m which will accept that language. For example, what is that language associated with this machine m we know already if you think of any string which has even number of zeros and even number of ones that string will take the machines from q 0 back to q 0. A string which does not have even number of zeros and even number of ones will take the machine finally, to one of these states q 1 q 2 q 3 those are not marked as final states. So, therefore, those strings are not in the language. You can prove it very simply that the language accepted by this machine m is precisely the language that we wanted to accept. In fact, let me quickly go through that proof because this is such a simple thing, but these proof ideas. So, I want to these proof ideas are useful. I want to show that l m is such that x has even zeros and even ones. So, this is an assertion that language accepted by m remember the notion of acceptance we had defined here that language accepted by m is all those strings which take the machine from the initial state to one of the final states. Now, what we are making an assertion we are saying that this set of strings is equal to this set of strings. How do you prove this equality since these are two sets and that is a very standard way of doing this. Suppose, a and b are two set and we are interested in proving a is equal to b then normally I will do two separate proofs that a is a subset of b as well as b is a subset of a. Now, that is fairly easy to see here. So, a is a subset of this says is a subset of this. That means what I take an element from here and show that it is in this set also. Take an element from here what is an element from here is a string that is given by here that in this particular thing that it is a string that takes the machine from q 0 to back to itself. Now, if you you can argue that to come from here back to here it is necessary that the string has even number of zeros and even number of ones and you can go back to the what we said earlier that this is the state in which the machine will be after scanning even zeros and even ones and this is odd zeros and even ones and so on. Remember we had done that and if you do that little carefully then it is not difficult to see that any string accepted by this machine has even number of zeros and even number of ones. So, therefore, l m is a subset of this and now the other way take a string which has even number of zeros and even number of ones clearly. If it has even number of zeros and even number of ones again if you think about the details about the states the assertions that we made then it would be clear that such a string will take the machine back to here. So, basically any string here is also an element of this any string in this set is an element of this set. So, this set is also a subset of this set. So, therefore, this is a subset of this and right hand side set is also a subset of left hand side set. So, these two sets are equal right one against a misconception many students have in the beginning when they start reading these things. Let us just take this case this is also a language. So, let us say this is the language l 2 is this accepted by this is l 2 the question I am asking is is l 2 accepted by now students sometimes argue that look every string here has even number of zeros and even number of ones. So, therefore, l 2 is accepted by m is that a correct argument it is not because you see. So, l m is the language accepted by m and l 2 is this language. Now, the student just said that look every string in l 2 has even number of zeros and even number of ones you told me l m is the language which is even number of zeros and even number of ones all that shows his argument just shows that l 2 is a subset of l m is it clear. So, just because all the strings of l 2 also take the machine from initial state to a final state that does not mean l 2 itself l 2 is not the language which is accepted by l m l m is much more l m is in fact an infinite set and this kind of difficulty students have in another way also the other way also for example, every language l is of course, a subset of sigma star by definition and think of this trivial machine what is the language accepted by m 1 if I look at that definition l m 1 is of course, sigma star because it has exactly one state and that is the final state. So, this is any string a in any symbol a in sigma whatever be the symbol it comes back to this only state the machine has. So, clearly every string takes the machine to this state to itself and that is and find that is the final state and therefore, sigma star is the language accepted by this and now think of another language l 1 which is a strict subset of sigma star of course, every string of l 1 also takes this machine from initial to its initial to the to its final state that does not mean however, that l 1 is accepted by this machine it just shows the same way that l 1 is a subset of l m 1 of course, that is true when I say and the point I am trying to make is that with a machine this is precisely one language which is accepted by that machine and when you say some language is regular you mean that I have a d f a it is that unique set of strings that forms the language not a subset of it not a superset of it. So, please remember this that when I see a language l 1 is regular if there is a d f a such l m is equal to l 1 I am not saying l m is is a subset of l 1 or l m is one I am saying equal to the language l 1 and l m they are identical another way of saying this that this machine m if you take a string which is in l 1 it will take the machine from initial to final state that is clear and if you take a string y which is not in l 1 then that string will take the machine from its initial state to a state which is not final. So, is it clear what I am saying if we say that if m is the machine which accepts l 1 that means now l 1 you see this is the set of all strings sigma star and l 1 is here if you say your machine m is such that l m is equal to l 1 so that means if you take a string from here then that string takes your machine from the its initial state to one of its final states and if you take a string which is not in l 1 then that string will take the machine from its initial state to one of the non final states and this is something we must keep in mind. So, I am repeating again because this is one misconception people have initially sometimes and that misconception will not arise in your mind if you remember that with every machine there is a unique language associated with it which we call is the language accepted by that machine. So, a little more on what we are doing here couple of things follow from this definition of in fact delta hat. Suppose I have a machine name which is again q sigma delta q 0 f and I have two strings x 1 and x 2 in sigma star such that delta hat of q 0 and x 1 and x 2 q 0 x 1 is same as delta hat of in fact this is got nothing to do with the initial state what I want to say q x 2. So, what I am trying what this is asserting in symbols that both strings x 1 and x 2 take the machine m from the state q to some same state. Supposing this is p this is also p the state is p now do you see that this implies that delta hat of q x 1 y is equal to this is delta hat delta hat of q x 2 y for all y it is not very difficult to see because what is happening is q of the machine m from starting from q on x 1 let us see it went to p on x 2 also it will go to the same state because of this equality assertion. So, now from p in either case it is seeing the string y and therefore this final state is going to be that state from which results starting from p and scanning the string y. Then this is a very simple observation it follows directly from the definition of delta hat but it has you know it says something very very important it says that look if two strings took the machine as to the same state then the machine has no way of remembering which of these two strings brought me in this particular state. So, the machine after because the future of the machines behavior will depend on the state current state the machine is in and what is the string ahead in both these cases the string ahead is y. So, you see that it could not distinguish between x 1 y and x 2 y and that something we have to keep in mind when we design a finite state machine that what the machine can keep in its head is a finite amount of information and that information is encoded or kind of there in the in the state where the machine itself now is. So, let us keep this in mind and try to design one or two examples and then we will see more properties of or properties of regular languages. So, let us take so consider this language let us say a which is strings over binary strings such that 0 1 1 0 is a substring of x. So, this is this is the language a so so this is is this in is this in a or not yes because 0 1 1 0 is occurring and in this as a substring in this string and therefore, it is language. On the other hand if I take something like 1 0 1 0 1 1 1 this is not in the language because the substrings are you know four length substrings are this this and so on and none of the 0 1 1 0 is not occurring here as a substring. So, this string is not in the language and what I wish to do is to show now we can use that particular word we want to show that this language a is regular. So, let us say remember what is the definition of a regular language a language is regular if and only if there is and finite state machine to accept that language. So, in order to prove that this language a is regular one way of doing it there are other ways of doing it which you may we will learn later, but one way of doing this would be to actually designer FSA a finite state machine finite state automaton which accepts this language a and remember the notion of acceptance that that DFA which I designed should be such that every string which is the language a that means every string in which 0 1 1 0 is a substring that string should take the machine from its initial state to one of its final states and a string which is not which does not have a substring 0 1 1 0 has to take the machine from its initial state to one of its non-final states only such a DFA is will be considered to be accepting this language. I am belaboring this point because that is an initial problem with some students just this notion that what is the language accepted by a machine. So, let us let us do this problem. So, of course, we must start with an initial state that is clear, but how do I go ahead and design DFA one way of doing it would be one way that most people find it convenient that imagine you yourself as the DFA what you are going to do and in front of you you are starting at the left end of a huge string possibly in this case the alphabet is binary. So, it is a huge binary string and you are stepping from one symbol to the next symbol keeping only finite amount of information in your head and when you finish scanning the entire string you should be in a position to say whether that string is in the language or not in the language. So, this is the initial state and now let us say one comes by the way how what do I what is the kind of information I should keep in my head in order to be sure whether or not the string has the substring 0 1 1 0 in it. So, one way of doing it would be I mean clearly the most obvious way of doing it is whenever I see a prefix of this interesting string. So, 0 1 1 0 is the substring of my interest whose presence I am trying to find out in the input. So, if I see a 0 then I should say oh may be the next 3 bits will be 1 1 0 and then my string is in the language right. So, clearly in that case my states can be something like this yes I have seen a 0 oh I have seen not just 0, but 0 1 oh I have seen 0 1 1 and oh I have seen all 4 bits 0 1 1 0. So, let us think in that manner and so a 0 came you are in this state which remembers that I have seen a 0 then a 1 came in this state which remembers that I have just seen a 0 and 1 and now let me look for the other 2 bits 1 and 0 and now 1 and 0 if this happens then you must be in a final state that is clear. But this is not complete picture of the DFA why because I have not said what happens in this state for example, on input 1 what should you what is the meaning of this state or what is the you can think of what is the intuition behind this state. Well look I have not seen anything interesting no prefix I have seen other than the trivial empty prefix of the substring. So, if a 1 comes you remain in that state right in this state if a 1 comes of course, then that means I have seen 0 and 1, but if a 0 came then what so that means you know there are 2 0s. So, of course, 0 0 is not a prefix of this but however, this could be the second 0 could be the prefix of the interesting string. So, here you should if you see a 0 it remain here in this particular state and now these 2 states are completely specified because I have said what happens in this state when a 0 came and a 1 came in this state when a 1 came and a 0 came I have specified what about this state. So, in this state if a 1 comes yes you have made progress you have just seen 0 1 1, but what happens if I have seen a 0. So, you are in this state that means you have seen something and then 0 1 it came 0 and then in 1 right and now if a 1 comes you will be here what happens if a 0 is there well this 0 could be the beginning see this thing that you have seen the other 0 1 you have seen is of no value because this is not extending to the interesting substring. So, this 0 I have seen now that is indeed a prefix so I come here see this state remember it is saying that I have just seen a 0 which could possibly be extended to 1 1 0 and now in this state if a 1 comes what should you do if a 1 comes what should you do you have. So, basically the situation is the string is something then 0 1 1 and a 1 came then what happens really you have made no progress at all. So, if a 1 came here we will go back to this state hoping that something in future will be the string that some string may be, but right now I started got something, but then it became bad of course in this state if a 0 came then you have seen 0 1 1 0 and then it is fine, but now in this state if a 0 comes or a 1 comes that means what, but then I have already scanned a first part of a string which has 0 1 1 0. So, if any further symbols come that is fine. So, both 0 and 1 I will remain in this state now this machine name is I claim the language accepted if I say this is my machine name then language accepted by this machine is a. Let us quickly see 1 or 2 examples. So, let me call it q 0 q 1 q 2 q 3 and q 4 and we said. So, let us take the same string which is in the language 1 1 0 1 1 0 0 1 0. So, this is the sequence of symbols in the input and we start from here q 0 q 0 on 1 I remain in q 0 q 0 on 1 I remain in q 0 q 0 on 1 I remain in q 0 q 0 q 0 q 0. On 0 I go to q 1 from q 1 on 1 I go to this is q 1 and the next symbol is this 1 q 1 on 1 I go to q 2 q 2 on 1 I go to q 2 on 1 I go to q 3 q 3 on 0 I go to q 4 q 4 on 0 I remain in q 4 q 4 1 q 4 q 4 0 q 4. So, what has happened this string 1 0 1 1 0 0 1 0 this string took the machine from q 0 to q 4 q 4 is the final state and therefore, the string is accepted by this machine and that is what it should be because this has the substring 0 1 1 0 on the other hand consider the other string which was not in the language 1 0 1 0 and let us say 1 1 something. So, you started here q 0 here after 1 it remains in q 0 on 0 it goes to q 1 q 1 on 1 it goes to q 2 q 2 on 0 it comes to back to q 1 q 1 on 1 goes to q 2 q 2 on 1 it goes to q 3 q 3 on 1 q 6 . it comes back to q 0. So, this string took the machine from q 0 to q 0, but q 0 is not a final state. So, therefore, the string is not accepted by the machine. So, therefore, this is what as it should be and the way we proved earlier about the previous example we can formally prove this also that this statement that language accepted by m is precisely this language a.