 Today, we will start with the notions of language acceptance by PDAs. There are two ways in which PDA can accept languages, but before that we need to define a concept which is called the instantaneous description of a PDA. The idea behind this is something like this that suppose a PDA is working and as you know we saw an example also last time that it works in discrete steps at every steps the machine is in some state scanning an input symbol top of the stack symbol and depending on that it changes the state changes the top symbol of the stack by something. Now imagine that as the PDA is working after a certain step we halted the kind of information that we need to restart the PDA once it is halted that is called the instantaneous description. So, I will define it properly. So, let us say I have a PDA remember PDA is a 7 tuple it has a set of states Q then the set of input symbol sigma gamma the set of stack alphabet or the gamma is the stack alphabet transition function the initial state the initial stack symbol and the set of final states. So, that defines some defines a PDA and imagine that at some point of time the of the input the portion which is left is W the machine is in some state Q and the stack contains is something gamma the entire contents of the stack is a string of overs gamma and that I am denoting by small gamma. So, if you give me this much of information it is clear that I can now from that step onwards simulate the PDA or PDA can PDA can work now again. So, suppose that something happened then we stop the PDA then some input symbols left the machine is in some state Q and the contents of the stack. If these three pieces of information I have then we can see how the PDA will evolve in time in future. So, the description which captures this the overall state of the PDA at a certain instance is called the instantaneous description of PDA and as you can see that an I D instantaneous description a three tuple. So, the state W and gamma where Q is the state in which the PDA is of course and W is the portion of the input string yet to be consumed input yet to be consumed and this gamma is the stack contents clearly what we are saying it did not matter really for what happens to the PDA in future that does not depend on the symbols it had seen already how did it come to the state or the evolution you know or history through which the current contents of the stack happened. So, once we have all this we have enough information to carry on and in fact we can define something which is a binary relation over the set of all I D's. So, what will be the set of all I D's all tuples of the kind in which the first component is a state second component is a string over sigma third component is a string over the stack alphabet right. So, so what I am what we are trying to do now is to define a binary relation and it is denoted like this symbol is borrowed from logic and it is called turn style you know I do not know whether you have seen such gates where you know you you pull this and the gate opens. So, anyway this is called turn style this symbol. So, we are defining a binary relation that is using this symbol I mean that binary relation will be denoted by this symbol and over the set of I D's of a particular PDA there is some PDA and we are talking of the set of all I D's of that PDA and we are defining a binary relation. Now this binary relation I should say what what the which which two I D's are related by this binary relation. So, we say that q A w and then let us say x gamma that is related this particular this as you can see is an I D this I D is related to P w beta gamma holds this fact holds if the transition function delta is such that P beta is contained in delta of q A and x where before that I should say that we we call that delta of you know delta is a function transition function which maps a state an input symbol or epsilon A can be also epsilon and a stack symbol and that contains tuples like this and of course it means that if the machine is in state q and the symbol it wants to consume is or you know current either the input symbol is the the the where the input head is is the symbol A or A is epsilon and x is the top of the stack symbol then delta gives the possibilities of what will be the next state and what will be the string which will replace this top of the stack symbol. So, you know this this phrase makes sense that this tuple is contained in this because in general this is a set of such tuples right. So, so now is now maybe I should write this down where A is an element of sigma union epsilon right and other things are clear from the context that P and q are states beta is a string over the stack alphabet gamma and the A as we said can be an input symbol that is an element of sigma or it can be epsilon x is stack alphabet sorry stack symbol and and now you can see that this has to be a string over the stack alphabet and this beta is also a string over stack alphabet is a notation looks unfamiliar in the beginning, but what it is saying is very simple that suppose at some point of time the instantaneous description of the PDA is given by this three tuple which means as we know that the current state is q and the input yet to be consumed is A w and the contents of the stack is x gamma. I think I told you that the way we suppose we read the stack always this way top to bottom because normally when we write the stack contents it will be a string we write it from left to right. So, the left will left of the string left most symbol of that string corresponds to the top most symbol of the stack right. So, in particular suppose the stack was A B B A C left to right the contents will write like this A B B A C. So, therefore, when I when we write like this it is quite clear that capital X is the top of the stack symbol from this ID now we can give a kind of name that we can read it as that this ID from this ID the machine can go to this ID. So, you can see that you can write it as derives or can derive in one step you see this is how we may read it if you wish that this ID I can derive in one step this ID why are we saying that can derive instead of saying derives because we remember that in general our machine is a non-deterministic machine. So, from some point of time so that means when this particular ID holds in general there will be several IDs next ID which is possible. So, in particular we are saying that next ID can be this next instantaneous description can be this and that is the reason is very simple because we go from this ID to this ID following a legal move because delta Q A X contains P beta. Now, we will define the two notions of acceptance before that again will what we will do is let me denote by this symbol you know read this symbol as can derive in one step if we write I 1, I 2 and put this symbol in between what I am trying to say is that this is also a binary relation over IDs, but this binary relation is derived from this particular binary relation which is can derive in one step and this really means that I 1 can derive in zero or more steps the ID I 2. So, let me write it down this actually is saying by definition I 1 can derive in zero or more steps the ID I 2. So, in other words you see that those of you who would like to put it that way that this particular relation is nothing, but the reflexive transitive closure of that relation. So, in other words for every ID it is the case is not it because in zero step you can go from this ID to itself that is all it means and suppose I had I going to I 1, I 2, I 3, I 4, I 4, I 4, I 4, I 4, I 4, I 4, I 4, I 1 to I 2 dot dot dot I n 2. So, this is I 0 and this is I. So, what we are saying is that the or machine is such that that from the ID I 0 it can go to the ID I 1, from I 1 it i d i 1 from i 1 it can go to the i d i 2 and so on. Then this situation we can write it as i 0 in 0 or more steps can go to or can derive the i d i. So, this is the concept we will use to define the notion of acceptance and I should also say that when there is a possibility of confusion when there are more number of more than one PDA you are talking about simultaneously or considering simultaneously. So, then under to say that which you know which set of which i d is you are talking of you mention the machine name for which these i d is are. So, if I recall that our machine we said this machine M and if you are talking about the basically that fact that M can derive in one step something and more technically one writes M below this and similarly this means the machine M can derive in 0 or more steps the i d i 2 starting from the i d i 1. Now, we will define as we said the two notions of acceptance by PDAs. The first notion is the kind of no acceptance notion we are used to. So, PDA acceptance by final states again let me write down PDA or PDA M as q sigma gamma delta q 0 z 0 and some set of final states f and now the language accepted by M by final states. So, l m the language accepted by by final states is defined in this manner that l m is the set of all strings w of course, they have to be input strings. So, the set of all strings w such that from the i d q 0 remember q 0 is the initial state q 0 w and z 0 in 0 or more steps we go to P epsilon and any beta for some P in f and beta in gamma star. So, now what it is saying it is saying that look the language accepted by this machine M by so called final states is the set of all strings w such that initially when you have on the input that string w and of course, the initially what will you have the machine will have initial state is q 0 and the only stack symbol only thing in the stack is the initial stack symbol namely z 0. So, this is the initial i d initial instantaneous description if the machine can go from this initial description to an i d where the state is one of the final states f is remember the set of final states of the machine M having consumed the input. So, remember that second component is what is left in the input. So, now it says that there is nothing left in the input to be consumed no symbol. So, that string empty it is right now the input entire input has been consumed. So, what is left is an empty string and any stack contains we do not care some beta. So, so long in other words so long the machine can go from its initial i d to an i d where it is in the final state is in some final state having consumed the entire input such a string w will be in the language accepted by M. As I said there is another notion of acceptance and that is called acceptance by let me by empty stack. So, we say for the same machine M N M is the language accepted by by empty stack stack where this N M is defined like this that this N M is again the set of all input means such that again from the initial i d which is q 0 w z 0 this is of course the initial i d the machine can go to some q and having consumed the input entirely. So, here it is epsilon and the stack is empty right. So, that means see third component gives the contents of the stack. So, stack is also empty correct. So, I should write that for any q in q in other words we do not care where the state finally is so long the input is consumed and the stack is empty right. So, all those strings which can take the machine from the initial i d to an i d where the entire input is consumed and simultaneously the stack is empty such strings are in the language accepted by the machine M by empty stack. So, these two notions you know this notion of course looks pretty usual you know finite state machine also we said strings which can take the machine from initial state to final state and this that this is a kind of you know the same way this particular definition has been different you know we define this particular notion of acceptance and this notion seems new the reason is actually we will find that this notion is more easy to use. And we will also show that if for a particular language we have PDA which accepts that language by final state then there is some other PDA which will accept it by empty stack and vice versa. So, in that sense both these notions are equivalent. So, in other words if a PDA or let me put it this way PDA can accept a language by final state if and only if some PDA can accept that same language by empty stack. So, these two are kind of they are equivalent notions and depending on the situation whichever is convenient we use one of the two notions last time in the last lecture we had given an example of a PDA to accept the language if you recall the language was W W reverse and W was a string in 0 1 star this is the language it is kind of even length palindrome the language of all even length palindromes and we described the PDA and the same PDA if you recall it had 3 states q 0 q 1 and q 2 and we give the transition diagram or not diagram but the transition function and that machine I am redescribing here and in a tabular form I am this is the delta right delta of m and what I would like to kind of argue or convince you that l m the language accepted by final state is this particular language. So, this is what I would like to convince you but we just recall this is essentially what it was doing is that initially during the W part it is in more or less in the state q 0 entire time it is it is scanning the W part and depending on a 0 it would push an a depending on a 1 it would push a b on the stack without taking off the top symbol and then once the this part comes then it will check off the input symbol 0 with the top of the stack symbol a see that is that time it is in state q 1 there it is in state either is q 1 q 1 and the input symbol is 0 top of the stack is a remains in q 1. So, it is basically removing that tops stack symbol meaning that this 0 has been checked off and this is how we do and by the way how did we go from this part to that part how does the machine go from state q 0 to q 1 it essentially guesses that now that W part is over and we should go over to the W R part we are now we are going to scan the W R part once that guess is reflected by you know it is in q 0 on epsilon whatever be the top of the stack symbol z 0 a or b it moves to the state q 1 and without disturbing the top of the stack symbol and you know of course one could describe the transition function in this manner, but a tabular format is somewhat not very very easy to view there is a graphical way of representing at PDA which I will describe. The way to represent such a PDA is you know somewhat familiar way that we represented our finite state machines see it is also going to be a graph with nodes and each node is a state and each arrow will each arrow will represent a transition. So, this has three states, but maybe first of all I should clearly write what the machine is that it has three states as we can see there q 0 q 1 q 2 what is the input alphabet is of course 0 1 what is the stack alphabet stack alphabet is z 0 a b and what is the initial state is q 0 what is the initial stack symbol z 0 and of course we had the transition function which I had put down as a table and the set of final states here the set of final states that set consists only of one state and that is q 2. So, this is our machine and delta is elaborated in this table. So, all that information we can capture nicely in a diagram and it is called that this kind of diagram will be called the transition diagram of PDA's and so as we said that for each state will have node in the graph. So, let me say this is q 0 this is q 1 this is q 2. So, let us see for example take this from q 0 take the first one very first one q 0 on input 0 top of the stack symbol is z 0 it can go to q 0 and the writing a and that of course retaining the top of the stack symbol this situation this is you know from q 0 it is going back to q 0. So, it is as you can imagine it is a self-loop and here what what we what this arrow has you know I must mention the what is the input symbol. So, on what input is this transition possible we said 0 and now the other two information is the what is the top of the stack symbol z 0 and that is going to be replaced by the string a z 0 right. So, you can see this. So, let us take the next one that is again such a such a loop and you know I will just write one more possibility here that if it input is 1 and top of the stack symbol is z 0 then it writes basically corresponds to this maybe this is getting crowded. So, I will write it here 3. So, is the notation clear now that we go from state q 0 back to q 0 on input 0 when the top of the stack symbol is z 0 and we replace the top of the stack z 0 by this string. In other words if I have a in more generally. So, let me write this supposing this is p and q and I had a and comma right x that x stroke beta what does it mean that q beta is in delta of p a x. So, suppose this is the situation that on state from state p on input a input symbol a with this top of the stack symbol x the machine can go to state q replacing the top of the stack x by the stack string beta such a this thing we are writing like this. It is clear that we are going from state p to q the symbol on input symbol a clearly it can be epsilon also you know if this was epsilon this particular thing will be epsilon and you know we are saying what is the string that replaces the top of the stack symbol. So, in these cases if you see we are not removing anything we are just pushing another symbol. So, another way of saying that is that z 0 is replaced by a z 0 and so on. So, maybe let me write one more thing. So, q 0 0 a. So, q 0 from q 0 on 0 and if the top of the stack is a then we replace it by a a right then third one is 0 b we replace it by a b and maybe I can complete it q 0 1 a 1 a we go back to q 0 writing b and then of course we are just pushing b on this 1 b will be b b right and so on. And finally, q 0 from q 0 you see on epsilon we are just pushing b on this 1 b will be b b right and so on. And finally, q 0 from q 0 you see on epsilon whatever be the stack symbol we can go to q 1 and we do not change the stack that same symbol remains. So, this we can write like this that it is saying that on epsilon we can always go from q 0 to q 1 if the top of the stack symbol is top of the stack symbol is top of the stack symbol is z 0 we do not change it similarly epsilon a a epsilon b b and when we go you can see that there is only one I am. So, this part I am not writing you see that from q 1 this is actually easy right. So, maybe I can write it there are only 2 such things going from q 1 to q 1. So, on 0 if the top is basically epsilon here that means this a is being popped 1 b is epsilon and here we will go taking this transition and that is on epsilon if it is z 0 we can write it as z 0 right. And the fact that q 2 is the only accepting state we you know denoted the way we mark the final states or accepting states of a finite state machine by putting this concentric circles 2 concentric circles same way any state in which you know this kind of 2 circles are there then such a state is the final state or an accepting state this is not part of the diagram right this is I was explaining the what in general a transition is right. If this is the transition this is the corresponding diagram right and I would now like to explain that this machine accepts by final state the language w w r. So, we remember by definition for that machine m p d a m the language accepted by final states is the set of all binary strings such that you know each of those strings you know that is this this I d from this I d the machine can go to that I d what is the initial I d of course the initial state is q 0 this is the initial state by the way we mark the initial state the same way as we did in case of finite state machines the initial state of a p d a will be marked by an arrow coming from nowhere into the state. So, that is q 0 w z 0 initially only the stack contains z 0 and all those strings which can take the machine from the initial state to the final state having consumed the input entirely and it is not too difficult to see that this machine is like that. So, for example, let us take an first of all what happens when a string is in the language. So, let us say 0 1 1 and correspondingly we will have. So, this particular string is in the language L right. We define this language L to be the set of all strings which are of the form w w r and clearly that this particular string is in the language what happens. So, if I if I see you know. So, let me write the initial I d q 0 0 1 1 1 1 0 then I will have z 0 0 0. Now, which of there are several things which are possible actually if you see on state q 0 when the our first input symbol is 0. So, therefore, this particular this particular transition is applicable in the diagram 0 0 0 0 0 0 0 0 0. I have z 0 here and this therefore, I should can do this but also see this another transition is possible. So, non-deterministically we need to choose the machine need to choose for that string to accept which one of this it should use. You can see that in the first phase in the when it is in q 0 the idea is that it should push on the stack a string which is equivalent to or you know really a an encoding or another rendering of the w part. So, instead of taking this particular transition let us say that machine non-deterministically chooses to remain in q 0 consuming this 1 1 1 I mean consuming this 0. So, what is left of the string is this particular string and it pushes the symbol a on the stack. So, I will have a z 0 then again instead of going from q 0 to epsilon I mean q 1 because it kind of guessed guesses that as yet the w part is not over. So, from here it will go to q 0 it will consume this symbol. So, 1 1 1 0 then for this corresponding to this 1 it will write b a z 0. Do you see which transition it is taking? It is taking that I have 1 and the top of the things stack symbol is a and therefore this a is replaced by the string b a that is what we did this a is replaced by this b a right. And again the third again in the same manner it will remain in q 0 this is the particular computation path and so it is it consumes this 1. So, what is left in this input is 1 1 0 and corresponding to this 1 symbol b is pushed. So, b a a z 0 right and now non-deterministically the machine guesses that it should move to state q 1. I should I mean once more remind you this non-deterministic machine working is not really anything mysterious all it means simultaneously all these paths are possible and we are just talking of the accepting path. So, really speaking the remember that we said that non-determinism means that whenever there is a choice machine makes two copies of itself and pursues both the possibilities simultaneously. We are just looking at that possibility which will take the machine to the accepting situation. So, now in that path the machine will go from q 0 to q 1 without the non-deterministic consuming any symbol from the input and without disturbing anything which is on top of the stack right. So, this is the one that we are this transition is what we are using. So, here the top of the stack symbol is b that is fine. So, it will remain as b in fact nothing else will get changed. So, q 1 1 1 0 then b 1 1 0 and then a a z 0 and now in q 1 you will keep using the positions which are there on 0 if the top of the stack symbol is a you will remove that and consume this 0 on 1 if the top of the stack symbol is b you will consume that consume the input and pop off the symbol and that is exactly what will happen. So, one top of the stack is you have made I think a mistake because. So, let us see there are 0 1 1. So, when the so this a and I you know for this another b should be put and I wrote here and a this a is corresponds to this a. So, let us see when that was a mistake, but can see what is happening q 0 1 1 1 0. So, the symbol is 1 top of the stack symbol is b under this situation if it wishes to remain in q 0 what it should it do. So, 1 top of the stack symbol is b 1 b. So, it would replace this b by b b that is what it is doing here. So, this will be also b I am sorry, but now you can see things will work out. So, q 1 it sees 1 top of the stack symbol is b. So, if you go to that you will see that it is machine will can do this that consume this. So, in the input all will have is 1 0 this is popped of b a and q 1 this 1 is consumed. So, only thing left on the input will be the chest symbol this and this will be a and of course, is z 0 here always right from here it can take come to this I d q 1 0 a. So, this 0 you can check off with the top top of the stack symbol a. So, so it may write it here q 1 epsilon this is over. So, z 0 and in q 1 you can always go to q 2 without consuming any symbol. So, it is q 2 there is nothing left in the input. So, it remains. So, and this is z 0. So, what has happened? So, you see we can see that from this initial I d the machine on. So, in so many steps can go to q 2 epsilon right and z 0. So, therefore, clearly this particular string 0 1 1 1 1 1 0 is in the language accepted by the machine by final state m because this state is the final state and so on. And therefore, it is not difficult to see that any string in this language will be accepted by that machine, but that is not enough you know we can convince ourselves of the of that any string of l will indeed be accepted by the machine m by final state. But we need also to show that a string which is not in the language cannot be accepted by the machine right and that part is a little more involved possibly to argue formally. But you see what it means is that if I take a string which is not of the form w w r then what can this machine do? You know let us just informally argue what can this machine do on a string which is not of the form w w r. So, let us take a simple string which is not of the form w w r and let us see what we can do. Let me let me argue what happens on a string which is not in the language right. So, on such a string the we should be able to argue the machine can never go from q 0 to q 2 totally consuming the input epsilon right. See for example, take take this string 0 1 1 1 right. So, this is not of the form w w r because when you chop it in the middle this is 0 1 and that is not same as that. Now you see what can this machine do on on on this machine do on the string? It can go to the state q 2 can it you see it look at this initially this first of all can it go can can on this string the machine go from q 0 to q 2 yes actually it can you see what it can do is initially the stack is is z 0 remember initially the only thing in the stack is this thing and the machine is in q 0. So, on q 0 on epsilon right it is without consuming anything it you know goes to q 1 and this is there and in q 1 again on z 0 it goes to q 2. So, it can indeed. So, right in the without doing anything without consuming any symbol the machine can move from q 0 to q 2, but is the string accepted? No, because if you recall it has to consume totally the input string and also simultaneously go from the initial state q 0 to q 2. So, just because it can go from q 0 to q 2 is not sufficient reason for the string to be accepted the string must be consumed and now you can see that. So, so that that does not work. So, therefore, what it can do of course is the many other things it can do remember it is a non-deterministic machine it can keep pushing the symbols corresponding to 0 and 1. So, you know z 0 then a z 0 then b right and suppose it at this point it was in q 0. So, it chose to move to q 1 then again this symbol can be you know it can consume this symbol having removed the top symbol b and now the input is 1 and the machine is in a. See there is in q 1 if u 1 is 0 then you have the input symbol 1 and the top of the stack is a it is not defined and we do not have a you know machine cannot do anything in fact no transition is defined. So, you can see that this will not lead to q 2 and this way you can argue wherever it may go from it has to start from q 0 you know it has to sometime move to q 1 and then finally to q 2 and the only way it can do so move from q 0 to q 2 having totally consume the input and the you know take this transition and go to q 2 is only for those strings which are in the language and the next lecture we are going to talk about the acceptance by empty stack with some example and the equivalence of these two notions.