 The first step towards construction of the path was that we started looking at something called the handle. And handle is a pattern which might be writing signs for production. And if I find such a pattern, and this pattern also gives me simultaneously a step in the reverse of right-close derivation, then I reduce it to the left-hand side. And then I continue, hoping that I reach the start symbol. And if the string is right, then I reach the start symbol. And if string is incorrect, then I reach in reverse. So, notation-wise, we are saying that start symbol in some steps of right-close derivation gives me a sentential form, alpha AW, where W is string of terminals, alpha is a string of terminals and non-terminals, and A is a non-terminal. And then one more right-close derivation gives me a pattern which is alpha beta W, which means that there is a production which says A goes to beta, which is part of my grammar. Then if I find such a pattern and beta is a handle, then I can reduce beta to A, and this is what is giving me a step in the reverse of right-close derivation. So, A means that starting from W, I should keep on finding such handles and eventually it tends to reach the start symbol. So, we only want to reduce handles and not any right-hand side. And this is very important that... So, the first example we discussed in the shift between the start symbol and the bottom part where I was just matching a pattern without worrying about whether it was giving me a reverse in right-close step that led to a situation where I could not move any... I could not do any further. And therefore, came to a wrong conclusion that the string did not belong to the language. Actually, string was in the language. So, handle pruning is... So, this is the first thing we do, and this is really where we are moving towards. We are saying that handle pruning is a step where if I find a handle and I use this rule to reduce handle to its left-hand side, then eventually parsing is nothing but it will take me to the start symbol. And right-most derivation in reverse order can be obtained by just the handle pruning. So, this is what we were discussing towards the end of the previous class. So, let's look at now some of the properties, because these are the kind of problems I am going to face in the parser, and therefore I should be aware of these. So, one thing that happens is that there are two things which are happening in a shift-reduced parser. There will be two possible actions. One is shift-introduced. Two other actions I will not worry about at this point of time, which is saying that I have reached an error state, and therefore I must do an error recovery. And the fourth action is that I have reached this accept state where I say that this pattern belongs to the language. So, either I can shift something on the stack or I can do a reduction. And in cases where I have more than one choice, so suppose I have a situation where I can do both shift and I can do a reduce. And again, just to recall if I write this grammar, when I was getting into a situation where I had both shift and reduce possibilities, and then we have to make a choice what to do, and that is known as shift-reduced conflict. And normally I would like to design my dramas so that I do not get into conflicts like this. And similarly I can get into a reduced-reduced conflict so that what that means is that if I have a stack and this is top of my stack, either I can find a beta-1 which matches some right-hand side or I can find a beta-2. So, this is, let me just write it properly. So, this may be beta-1 and this may be beta-2. And both match right-hand side of a production and therefore I can get into a conflict saying which means I should do store-reduction. So, normally we would like to design our dramas so that I never get encounter these kinds of conflicts. But these conflicts are leading to a situation where I am open to interpretation. So, conflicts can come because of two reasons. Either my grammar is not written properly or the language is such that it does not fall into this class of languages or hello. So, that is what we want to attempt now. So, let me give you an example of both shift-reduced and reduce-reduced conflicts. So, here is the grammar we discussed. And we have already seen this example that at this point of time I was able to reduce but also I was able to, I could have started slightly differently and I could have first shifted this and could have led to this reduction. So, either I can reach start symbol by two different set of actions and this is what the conflict is. Similarly, so this example we discussed extensively yesterday. Similarly, I may have a situation where I have a grammar like this and this grammar is interesting because this grammar actually corresponds to the machine instructions. And what we are attempting here is at some point of time when we do code generation we will discuss with that even the machine instructions grammar rules. So, this is saying that memory location can be completed by adding either two registers or a register plus a constant or just a register can be loaded into memory location and a constant can be loaded into a register. And if I now try to do code generation for or if I try to reduce this string which is saying add two constants this basically in terms of machine is saying that what are the kind of instruction sequence I want to generate. So, I will try to parse C plus C using the grammar like this. Now, you can clearly see I am going through parsing that I can generate multiple instructions for this. So, I can say load the first constant into a register then add the register to a constant and store that in memory. Or I can say that load this constant into a register load this constant into a register add the two registers and then reduce it to memory. So, these two patterns basically give me the conflict where I can get it to a situation where I do shift reduce parsing. So, I can hear say that reduce by this rule and then have R plus R and then I can say reduce by this rule and here I have another possibility where I directly reduce by this rule. So, I can get into multiple situations but at this point of time this example is not important what is important is that I should be able to now design parsers and write grammars which are not going to be ambiguous. So, this basically idea of just bringing these two examples for us to say that there are some issues and how do we resolve these issues is going to come when we start talking about parsing. Now, here is the same structure or a similar structure to what we saw in a top down parser what I have is a stack I have an input then I have a parser and then I have a parse table only difference is going to be that structure of the parse table is going to be different and then my parsing algorithm is going to be different but basically I need to do certain manipulations and manipulations are going to be now looking at something which is at the top of stack and my input symbol of the look at itself. Now, the first thing that comes here is that the way these parsers are designed and that is why I said that in the beginning it does not appear to as if you give a top down parser I have some concept of a state of the parser so here my top of stack was only a symbol which was a non-terminal symbol or a terminal symbol and depending upon that and my input algorithm took a certain action now I say that my parser goes into certain states and these are states which I can just give a unique number to each state does not matter what the number is as long as this is unique and I say that when I start pushing symbols on the stack at the same time I push more information on the stack which is saying that what is the state of the parser we come to this point slightly later what state means what is it that is capturing but at this point of time just what we need to understand and remember is that there is something called the state of the parser so what we are doing here is that my input is only going to contain of input strings and what does my stack contain so stack contains state symbols and grammar symbols all these s0, s1, sn these are the state symbols and x1, x2, xn, xr grammar symbols so these grammar symbols could either be a terminal or a non-terminal so to begin with my parser is in certain state and whenever a symbol is pushed on the stack then the parser goes into a new state so state symbol is always on the top of the stack there is only thing you need to remember basically this also should give you a hint of what state symbol is capturing if you think of what is being captured by the state symbol we will not worry about how it captures it but does this string give you some hint of what state symbol is what state symbol is capturing no so just strip out everything and when I say my parser is in state x0 what does that mean stack is empty that is the initial state same and when I say some state s1 what that means is that what are the symbols below it so basically I will define at some point of time what are the possible prefixes in my language in my grammar and then I will say that corresponding to each of the prefixes I actually have a state symbol okay so s1 says that if x1 if below s1 I have symbol x1 and then earlier state was s0 then this gives me actually something unique which is known as state so basically if you recall now once again I said that I am going to introduce a special symbol dot and somewhere I was saying that I will have this alpha dot freedom this dot actually corresponds to the state and this says that what are the prefixes it has seen okay and that is what I will try to capture in each of the state symbols okay but as you go along and I will start designing these states then it will become more clear but at this point of time you can clearly see that if I know the state some state number then I can find out immediately just by looking at the state that what is the content of the stack okay and my table contains now two parts one is action part and one is go to part action part is indexed by the state numbers and all the terminal symbols and go to part is indexed by the states and the non-terminal symbols okay and we shortly see an example of this and this is how we do passing so let's first look at an example and then go through this parser and how to process this parsed table okay so here is a parser or a parsed table for grammar like this okay so this grammar is left recursive expression grammar okay I am not keeping minors and division and so on okay so this says e goes to e plus t or t p goes to t star f or f and f goes to bracket expression and i okay now this is clearly the action table this is the go to table these are my possible states this grammar can have only 12 states from 0 to 12 because those are the prefixes which are possible in this grammar and then I have these entries and what do these entries mean what these entries mean are that if I am in state 0 and I see id then I need to shift the symbol on the stack and go to state 5 so either I have these entries as s and some number which is saying shift and go to the new state or I will have entries like saying that reduced by rule number 4 so this says if I am in state 3 and I see plus s symbol that means I have identified reduced by rule number 4 and rule number 4 is this is 1 2 3 4 5 and 6 these are the 6 rules I have so you can see that all my entries the past table are either empty which means that it is error or it is either a shift action or a reduce action except one place where it says that I have reached in accept state which means that this is not valid state and what does this table tell me this says that if I am in state 0 on top of state 0 the non-terminal is e then I must go to state 1 or if I am in state 4 and state the non-terminal on top of state 4 is t then my parcel should be state 2 and so on so we do not know how to construct this table we do not even know how to use this table but that is the interpretation of this table now first thing I want to do is how this table has been constructed I would like to take an example and take you through the steps of shift reduce parcel just keeping this table in mind so suppose I am trying to pass id star id plus id and as dollar indicates that is the special symbol I have put at the end of my input so this is what my input is and what is my stack to begin with is always in state 0 that is where my initial configuration starts and what I need to now check is by going through these actions of this table will I ever reach a situation where my state of the parcel is 1 and look at symbol is dollar if I reach that particular state then I know that I will be in accept state which is a value state so it is clear what we are trying to do here so let us look at this table now also this table should tell you something like what we are looking in the top down parcel if I am in state 0 which is initial state then all valid strings can start either with an identifier or with a left parenthesis anything else gives me an error so if I try to start a string by a plus or a multiplication string so I will not even say that in state 0 if I see an empty string then I should reach accept state I mean that is trivial because all null strings will belong to all graphs so if I am in state 0 and I see id then what do I do I shift the symbol on the stack and I go to a new state which is 5 so my stack becomes 0, id 5 so you can see that initially I was in some state and after this shifting the symbol I changed the new state and what is my input now my input is id plus id 0 okay and now I see that in state 5 if I see star in state 5 if I see star this says reduce value number 6 value number 6 is f goes to id okay now when I say that I am reducing this symbol okay essentially what that means is that both these symbols will have to be popped from the stack okay so after I pop these symbols and how many symbols do I pop now so how did I arrive at this number 1, 2, 3 or whatever so I need to pop twice the length of the right-hand side the number of symbols which have to be popped is twice the length of the right-hand side and why because between every two grammar symbols there is a state symbol so for every grammar symbol if I the length I need to pop another hand state symbols okay so if the length of the right-hand side is 1 I just pop two symbols from the stack and I go into configuration like this okay and then what do I push on the stack the left-hand side of the rule okay so I push left-hand side of the rule on the stack and now I must determine what is the new state of my parser top of stack symbol is this non-terminal and the state symbol just below this is 0 then refer to 0f which says that now parser must be in state 3 and you understood how I arrived from 0id5 to 0f3 is this clear to everyone yes no yes okay so now how do I continue okay now I say let me refer to 3star okay so what is my stack configuration somebody will tell me this stack configuration now when I reduce rule number reduce by rule number 4 rule number 4 says t goes to f 0 and 0t and what will be the state 2 okay so my parser we go into this state okay nothing changes in range right you understood what has happened so I have two symbols I push corresponding to 0t and go into a new state now I look at 2star what is 2star 2star says shift and go to state 7 okay so I now say that I will shift this symbol and go to state 7 and what will be my input my input will be id plus id now so what I have done is I have shifted the symbol on the stack and because this I said I was in 2star right so 2star was taking me to state 7 okay now I look at 7 id and what does 7 id say shift and go to state 5 okay so now I will say 0t 2 parser id 5 and my input becomes what is the next thing now I say I am in state 5 and I see plus what does it mean reduce my number 6 which says as close to id so I am going to pop 2 symbols from the stack okay so I am going to pop these 2 symbols and this is going to give me a configuration like this and then I am going to push left hand side on the stack which is f and then what will be okay what is 10 plus so I look at 10 plus and 10 plus says reduce my number 3 and what is rule number 3 rule number 3 says t goes to t star f so how many symbols do I pop 6 because length of the right hand side is 3 so I am going to pop all these 6 symbols from the stack and I am going to first remain with 0 and then what will be my state now 2 right so 0 is 2 so I go into the state and then I look at 2 plus and 2 plus says reduce by rule number 2 and what is rule number 2 e goes to t so that means I will go into state 0 1 0 e 1 okay and now in 1 if I see plus state 6 so I am going to now 0 e 1 id 6 sorry sorry this should be plus and now if I so my input is now id tall okay and now if I see so let me continue on this part okay and now if I see 6 id what is 6 id 6 id says shift and go to 5 so that will take me to 0 e 1 plus 6 id 5 and my input will be awesome tall okay and now if I look at 5 dollar 5 dollar says reduce by rule number 6 and 6 is f goes to id so that takes me to the state this and what is 6 f 6 f is 3 and my input goes into state 3 and now I look at 3 dollar and 3 dollar says reduce by rule number 4 and rule number 4 is e goes to f so my part now becomes 0 e 1 plus 6 t and what is 6 t 6 t is taking me to state 9 okay and now I look at 9 dollar and 9 dollar says reduce by rule number 1 6 symbols from the stack so I pop 1 2 3 4 5 and 6 and then I push left hand side on the stack and then I go into state 1 and now I look at 1 dollar and what is 1 dollar etc so I reach the final state saying that there is a value you understand how this part table is being interpreted now right okay so you don't know how to take this grammar and encode it into a pass table like this but what we definitely know now is that given a pass table and given an input how do I go through the process pass okay so let me just take you through the same thing we have already seen this okay so we will skip this part okay so what are the actions what are the things I am doing okay so actions like the state symbol of my parser and I am looking at the input symbol and based on these two combinations I was taking actions which said possibly I can shift I can reduce I can accept or I can go into an error state these are only these are only four possibilities I had and what were the possibilities in terms of if I use these symbols if I say my stack is in certain configuration like this where top of stack then action will say that so I am looking at this state symbol and I am looking at ai and I refer to the action table and if I look at action table and entry is corresponding to shift and go to a new state what that means is that after this configuration is going to be that I am going to push ai on top of stack I will go to new state s symbol okay or if it is a reduce action which is corresponding to some rule then what will I do I will find out length of beta I will pop twice this number of symbols of beta so what happens here if length of beta is r then I am going to pop two r symbols from this and after popping two r symbols I will be left with top of stack as xm minus r and then I am going to go to a new state which will be corresponding to go to of sm minus r and a this is what we did okay and then I can either be in the accept state so if this is accept then what do I do I just want saying that I have valid string and if this is error state then we will have to do some invocation clear to everyone okay so if I go back once again to my parser let me take you back to the same figure okay we at least understand how do I manipulate stack how do I manipulate input and what does my parser do okay what I have not understood so far is that how do I construct action table go to pay with respect to this figure this is the everyone is in sync everyone understands how the parser is working okay okay so let's then move on so algorithmically the same thing if I try to write as a block my initial state is as 0 or 0 and my input is W dollar and if action is shift then I push A on the stack I push S prime on the stack I increment input pointer by 1 twice the length of beta symbols from the stack push A and then push go to of S double prime A and where S double prime is the state exposed after popping all these symbols okay and if this is except then I exit otherwise I go into so you can see that actually parsing is very simple straight forward okay so once again okay let's come to this table and try to see how do I construct this table okay so in this table I need to have few more definitions and some more information okay so first information that is going to come is that what do these state symbols mean okay these state symbols as I said what they mean is that what is on the stack okay so it is actually looking at what is on the stack and it cannot be an infinitely long string okay because all the time I'll keep on okay so in this case what could be the maximum height of the stack number of twice the number of tokens plus one right so if my length of the input is n then it is possible that first I do all shift before I do the first deduction okay so corresponding to n symbols I am going to push on the stack I'll have to push state and state symbols and the initial state symbol will be there so that is the it cannot be larger than that so every state symbol what it is capturing is that what is on the stack what is my what we know as viral prefix so parser state is goal is to know what are the valid deductions at any given point of time okay so I can keep on I can keep on shifting but at some point of time I'll have to do reduction and I need to know what is the reduction rule I need to use and state summarizes all possible stack differences in any parser state okay so for example when I say my parser is in state 0 okay what that means is that my parser stack does not have any that's empty okay and similarly each state will capture something over okay so this is parser state is actually defined by again a finite state machine okay and which reads stack okay and this finite state machine right now may not be clear okay if you see something very interesting that the way I am going to come all these states that will actually construct a finite state machine okay so except state or infinite state machines are nothing but unique deductions okay that somewhere I'll be able to uniquely find which is the right reduction rule to use so for example here for example here okay I was able to say I want to reduce here I was shifting where else I was doing reduction so for example in 10 I was doing a reduction and so okay so there are some states in which I was able to find absolute deductions and these deductions were finally telling me that I can eventually reach a start state okay so let's start slowly constructing the parser okay and whatever definitions we need to know for that okay we'll introduce so first step I do is I'm going to augment my grammar okay and what does augmentation of grammar mean augmentation of grammar means this that if I started with some context free grammar and this context free grammar consists of a set of non terminals terminals some start symbol and a set of productions okay then I'm going to modify this and what is the modification so let me call this augmented non terminal which I'm going to call as as fine I'm going to not change the set of my terminals I'll change my start symbol to as fine and I'll change my productions to say that whatever productions I have and I have one word production so what I've introduced is a new non terminal which I'm going to call the new start symbol and I have introduced one rule which says does not right then why I'm doing this manipulation but will not be in a but that's not really the real that as fine should not be in the right side of any production I mean what you're saying is correct observation that as fine will never be on the right side of any production but that's not the reason I'm changing the reason I'm changing it is I am now saying that I've introduced the accept state in earlier cases when I have something like this so for example when I said e goes to e plus t or e goes to t I could reach accept state either by reducing this or by reducing this okay so they could have in multiple entries they could have in multiple states which will take accept state this is a unique situation where I say that only by reducing this state I reach an accept state okay so this change does not change anything in the language I'm dealing with so if g is a grammar which starts symbol s then augmented grammar g prime has a new start symbol s prime and a new rule s prime to s and when faster reduces by this rule it will stop with accept nowhere else I do an accept so this is the first change I made now I define to capture all this information about states okay so now this is saying that suppose I'm doing these reductions okay state has certain symbols and stack has certain symbols and it has certain grammar and the state symbols so prefix is viable prefix is that if I take all possible sentential forms in my language okay then what could be the stack configuration I want to find out all possible stack configurations okay because those are the in my those are the only valid parsing states I can have everything else is okay so this is what I want to define that what are the valid prefixes in any configuration of shift reduce parser and we say that alpha is the viable prefix of the grammar and it depends on not on the language but on the form of the grammar because different grammars will give a different state on stack configuration so what we are saying here is that in the grammar if we have some such w okay such that alpha w is in right sentential form that means if I do a right most derivation then I will get some some string or some string somewhere where alpha w will be the valid sentential form of my grammar okay and also that alpha w is a valid configuration of my shift reduce parser that means if I do reverse of right most derivation I will be able to see alpha on the stack and w as the then only I set that this is a viable prefix okay so you can see now what I am doing okay if I look at this stack okay if you see stack configuration you can see that when I reached state 3 okay what was my prefix my prefix was that my parser initially was in state 0 and the only symbol which could be on the stack was the time being if I ignore all state symbols or here I could say my parser could have t star id I could have t star f okay I cannot have something arbitrary like t star e okay that will never be my parser configuration okay so what I start counting by looking at the grammar is or what I start constructing by looking at the grammar state information okay so as long as parser has only viable prefixes in the stack then I know that parser has not seen an error yet parser is always in a valid state okay but if I try to go into a stack configuration which is not correct then immediately I say that I am not able to compute prefixes is a regular language now this is not an obvious proof okay and this is what actually when you say set of viable prefixes is a regular language that is where we are actually using a deactivation okay so what we are computing are first starting with one correct machine for who devised bottom of parser any idea who gave the lr language design the lr it is not a vertical choice question not give you choices and eliminated no idea but this is something you did with 1960 1964 In fact, his fourth volume of Art of Programming is supposed to be like in seven volumes, only three were published and the fourth one which he is working on is actually his own parsing. So this is the proof which is given in his original paper that if I take any kind of context-free grammar and I try to find viral prefixes for this, in fact, I will find that the type of parsing was so difficult that it was not even implemented for a long time till somebody gave a much better method for DV mode. He gave a method for constructing what we now know as simple error parsers. So we will go through all simple error parsers and then we look at the most complex ones. But what we are talking about is this is what improves that somebody could visualize that if I construct all viral prefixes that actually gives me a regular line. So what we do is once we have constructed all viral prefixes, we just need to construct a finite state machine. If you now recall the parse table, what is my parse table? That is just a finite state machine. It is not doing anything else. So first now, let us start constructing. So first thing I do is I say that and this is my attempt to construct all the viral prefixes. I define something known as LR0i. So now if I look at any rules, if I look at the grammar, suppose this is my grammar and let me just pick up one of the rules of the grammar. Now I say that I can put dot anywhere on the right-hand side. So suppose I put dot anywhere on the right-hand side. Obviously it has to be between two symbols. So I can get something like this. Either I can have a dot in the first position or I can have a dot in the second position or I can have a dot in this position or I can have a dot in this position. Then what is this dot? Dot is the spatial marker we have which sets what is on the stack and what is in the input. So this says that if I want to do reduction by this rule, conceptually what is happening now is I am saying that I am trying to now compute all the viral prefixes. So this says for this what is the viral prefix? Now and for this configuration what is the viral prefix? E and for this this is E plus and for this is E plus T. From this grammar rule I cannot have any other viral prefixes. These are the only combinations I can have. And similarly I need to do it for all the grammar rules I have. So if I have this rule which says E goes to T, then what are the LR0 items from this? So this I call as set of LR0 items. So set of LR0 items are that if I take, now this is not a production but this is an LR0 item. So an LR0 item is that if I take a grammar rule and I put a dot anywhere on the right hand side it becomes an LR0 item. And this is giving me some unique combinations. So what are the LR0 items I can have from this? I can have either this or I can have this. There is nothing else I can do. And what I need to do now is for all the other symbols constructs all possible LR0 items. That is giving me all sets of possible viral prefixes. This is saying that I can, if I want to do this reduction conceptually then this saying that I have not seen anything but I must see a derivation of E plus T. If I want to reduce this to an E and E plus T is a handy. This says if I have already seen E then I am expecting to see a derivation of plus T. And this says if I have already seen E plus then I am expecting to see a derivation of T. And this says if I have seen E plus T then doesn't matter what comes in I am ready to reduce this to the left hand side. So what I said in the end is not entirely correct but I don't want to introduce at this point of time. So what are the situations in which I can do reduction by this rule to E? So what should be, so here says that suppose I am in this configuration. I have seen E then what I am expecting to see is a plus. And if I am in this configuration where I have seen E plus then I am seeing that I should be able to see something which is derivable from T. That means obviously the first symbols of T. And if I have seen E plus T I am ready to reduction on E under what circumstances. So look at my parser what will happen in my parser state. I will have plus T and this is my input and I will say that I am ready to reduce this to E. Now what are the situations under which this reduction can remain valid that this plus this will be a valid sentential form in my language. Is there a property I can attribute to this symbol? Can it be any symbol? Can it be any arbitrary symbol in my grammar? Come on guys this is not a difficult question which I am not able to even visualize. Can I put say ID here? So I must have a symbol which is in follow of E because if I don't have a symbol which is in follow of E then I have a problem obviously because I am not able to reduce any further. So whenever you are ready for reduction by this you say that if I have reached a configuration where dot is in the rightmost position and I have seen the whole of the right-hand side of a production I can reduce it only if my look ahead symbol is in follow of the left-hand side. Otherwise when you give me a wrong sentential form I am not able to proceed from that form. So what we need to do therefore is I need to construct LR0 items and then all possible sets of all LR0 items. So an LR0 item in the grammar is a production in which dot is in some position on the right-hand side and if I have a production of this form it says A goes to XYZ then what are the LR0 items I can get? I can get these possible LR0 items that dot can be on the leftmost position after X after Y or after Z. These are the only LR0 items I can get and conceptually this says that how much of production has been seen at a point and what is it that I am expecting to see? Symbols of the left-hand dot are already on the stack and what I am expecting is that remaining symbols on the right-hand side must be in the input. Or not right-hand side in the input but derivation of the right-hand side in the input because if I say that my right-hand side is in T obviously T will never be in input input consists only of my terminal symbols. So if I see a derivation of T then first I will push those on the stack reduce them to T and then only do the shift. Now to find out all these possible sets of LR0 items one operation I need to introduce is what we know as closure operation. What is closure operation? Closure operation is same and we will keep this part here that somewhere if I say that I have seen something in my input and I am ready to see something more suppose I reach a configuration which is of this form A goes to let's say alpha dot what is my configuration at some point of time this is my LR0 item what this means is that I have seen alpha and I am expecting to see a derivation of B and B happens to be a non-terminal then what I will do is I will say that I am going to define closure set of this and I say that conceptually if I am expecting to see a derivation of B then I must see first derivations of beta derivations corresponding to B that is a non-terminal so if now B has some rule of this form which says B goes to let's say TQR something like this then I must add an item which says B goes to dot TQR so this is my rule this is my LR0 item and this LR0 item must be added into the closure set what is closure trying to do closure is saying that if I have an LR0 item like this and I want to find its closure this LR0 item says that I have seen alpha and I am expecting to see a derivation of B beta but since B is a non-terminal there must be some rules corresponding to B and if this is the rule corresponding to B then I am expecting to see a derivation of starting with dot TQR is it making sense or not so for example here if I say that I am expecting to see a derivation of T then what are the rules corresponding to T rules corresponding to T are T goes to T star F or T goes to F which means that if I am expecting to see a derivation of T then first I must see either this derivation which eventually I can reduce to T so closure operation is saying that starting from an LR0 item if I want to find its closure then add that particular LR0 item into the set and if there is a non-terminal immediately on the right of dot take all its corrections put dot in the leftmost position and those are the LR0 items I am expecting to see that particular state so let's stop here today and tomorrow we will start our discussion from this point onwards and remember that tomorrow we have an extra class starting at 11.45