Let's start our discussion from where we left off. We start looking at the methods where we can associate the parsing method with the evaluation of that. And we looked at four possibilities. And we're saying that if we draw a grid, so we have synthesized depth-to-depth groups, and we had inherited depth-to-depth groups, and then we were looking at two parsing methods, some top-down and bottom-up parsing. And at least on one, we agreed that when it comes to bottom-up parsing, it's synthesized depth-to-depth groups. This was something which was simple to do. And when it came to top-down and inherited, then we said that at least in some cases, we may be able to do it. That means if I only have inherited depth-to-depth groups, I'm actually only a reference to nodes which have already been created. But we don't know how to do that. So this was slight question mark. But top-down and synthesized was a big question mark. And bottom-up and inherited was another issue. But since we have two parsing methods and two kind of attributes, we cannot put a restriction on what kind of attribute equations compiler writers may decide to use. We have to crack all these problems. Ultimately, the goal is that I should be able to put all the attributes that are taken in every box. So let's look at at least the one which is the simplest, which is the bottom-up and synthesized attributes only. And how do I now change my parser so that I can evaluate all the synthesized attributes? Because now we are talking of implementation. No longer just the specifications.  What did state stack contain in bottom-up parser? State's visited so far which have not been reduced. State's visited so far which have not been reduced. Whatever has been shifted is on the state stack. So we have some state symbols and we have some grammar symbols. Now, state symbols are only capturing the information there. Now, there are implementations where you will not have to worry about grammar symbols at all. And you will just work with the state symbols because that's the only information you require. But assume that for logical reasons, we have all the information about the grammar symbols of the stack. When it is equivalent, so it really doesn't matter. Now, suppose I have a rule like this. It says a goes to xy. This is my grammar rule. And corresponding to this, I have an active root equation which says that active root of a is the function of active root of x and active root of y. And these are all not synthesized at the end because we are talking about S-active root definitions. Now we need to do this evaluation as we are going through the reduction.  Suppose this is my top-up stack. What will be my state? What will be the top-2 entries in the stack? Before this reduction happens, my knowledge should be under your fingertips. We have exam on right this day. What will be the symbols in the top of the state stack before reduction? X and Y. And after reduction, I am going to top these two symbols and I am going to push A on the stack. Now suppose in addition to state stack, I also have what we do as a value stack. I am now looking at the implementation and corresponding to every symbol, what I can do is I can have a value and a state in the same stack pointer. That means attributes of X can be kept here and attribute of Y can be kept here before reduction. And now when I do reduction, what do I need to do? I need to take these two values and then I compute A using this function and then after reduction, I just push attribute of Y on the stack, which is the value stack. Then my problem is solved because all I need to do is contain additional stack, make an additional stack which contains all the values of the attributes and this stack pointer will work for this and as I am pushing the symbol, simultaneously in this stack, I push the corresponding attribute. So how will my equations look? Now I can say that if this is the kind of equation I have, this is the kind of attribute equation I have for this grammar rule, if I want to write it in terms of value stack, what will I do? I will say that suppose I am computing now value which is, value which will come at the new top which will come here. How will I compute that? I am just going to say that this is nothing but a function of value at the top and value at top minus 1. And what is new top? New top obviously is before reduction if I take top and if I then say that length that I inside R then I have to reduce this top by R and then I have to add 1 to this. So if this is where my stack pointer was and this length is 2, then I subtract 2 from the stack pointer and add 1 to this to push this value of A here. And after reduction what happens? Top becomes, so this is before reduction, after reduction top becomes new top. So now I can take all my attribute equations and I can give an implementation in terms of values stack pointer. And now suppose they are symbols which do not have a corresponding attribute. And what will I do? Just perform this thing. I do not have to do anything, just push another value. So this is to begin with this is empty, if I find there is no corresponding attribute I just leave that empty. So that I have the same stack pointer which is manipulating both state and value stack. Is that all? Yes, no. Is this clear? How we implement at least this part that for synthesized attributes and bottom of parser, how can I implement this? Now some parsers will provide built-in facilities for this. So like parsers like that will provide you all these but basically this is the implementation. So this is how it happens that I am going to evaluate all these attributes while I am parsing and whenever reduction is made value of the new synthesized attribute is computed from the attributes of the right-hand side which are already on the stack. And then all we are going to do is we are going to extend the stack to the value. So I have a state stack and I have a value stack. The state stack we have already seen when we were doing a bottom of parsing and value stack is what we produce now and current top of stack is created by the pointer top. And then we say that if there is a kind of attribute equation I have and this is associated with some production then before reducing x, y, z to a value of z is in the top and value of y to the top minus some value of x is in top minus 2. This is how it is going to be pushed left-hand side lower and the right-hand side at the top of the stack. And if symbol has no attribute and np is just left as undefined. And after reduction top is decremented by 2 and state which covers a which is now the left-hand side of the production after reduction that is push at top. So if this is the kind of grammar I have and this is some grammars I started with, suppose I was to write all the actions now in terms of the values how will I do that so use similar logic and write the rules here so that you have already seen this example of best calculator that when I do reduction by this rule I want to have the value of the expression that means value of expression when I do this reduction what will be at the top of the stack top of stack will contain and everything has been reduced to the start symbol and therefore the value stack corresponding to that must have the value of that. So what kind of action rules I will write here what about this when I say f is a scientific there is no f well now there is only a stack there are no attributes attributes have been changing in terms of the stack here I have written about no right so top only in terms of as if there is a value stack there is a stack pointer and then keep adding these values on the stack so what about this let's see this when I have this rule value stack does not change of course it does there are three symbols on the right hand side top value top value is so new top is top minus top minus so this is my stack this is where the value of e is right and after I pop this this and this this value should appear here okay so value of n top is going to be value of top minus 1 that is before reduction and after reduction top is same as n top n top will be top minus 3 plus 1 that is top minus 2 here so that is where the value will come after reduction the new value will be here because after reduction all these three symbols are going to be popped and f is going to be pushed here so this is how rules will appear that if I say for bracketed expression value of n top is going to be value of top minus 1 which is coming because of this because right bracket is on the top this is a top minus 1 this is a top minus 2 what about this okay here I will say that n top is nothing but I will have to take top and I will have to take top minus 2 and multiply the two values okay and what about this okay same thing but the multiplication will be replaced by addition okay what about action of this this and this what will happen here so what about action of this e going to be okay so I have to do anything here so I do not write any action here because what is happening here is that my stack is containing t and then this is value of t then I replace this value okay the value is the same so I do not have to write an action at all so remember that in default when you had yak dollar dollar is never assigned anything there is a single reduction by default what does what is the value of dollar dollar dollar dollar right okay that is the default value so you do not have to write an action for that okay so for rest of it I do not write any value and here I am just saying that whatever is on top of the stack so this is a unit reduction this is a unit reduction this is a unit reduction and all that is happening is that whenever I am pushing digit on the stack okay I am pushing digit well so only I have to do on the value stack in fact digit becomes f what do I do nothing because now digit is being replaced by f and only thing that is happening is that now the stack point is pointing to the same thing where is the value of digit so you can assume that to begin with my stack contains only null values so when I add star I do not change it so everything is undefined so whenever I define value I initialize it otherwise it remains undefined because I will never access it right there is implementation here okay so before reduction top is and top is top minus half plus one and after reduction top is nothing but and top okay and here is an example we can go through this example of saying if this is the input we have and if I want to look at my state stack and value stack okay since I have already seen you can see quickly that first I am going to put digit on this state stack and the value is going to be 3 so this is the input which is going to be pushed here okay this is the value stack and then I will say digit goes to f and 3 remains here and this is the reduction and you can see that I have not used any rule here okay and then I can say that I have t going to f so t comes on the stack and 3 remains there and then star gets pushed on the stack and corresponding to that value stack contains a value which is undefined so dash is undefined on minus and then again digit comes on the stack so 3 undefined 5 is the value stack and then when I do a reduction by this rule when this digit goes to f my value stack remains the same okay and then I will say that t star f gets reduced so what will I do now I will say that 3 undefined 5 are going to be popped and 15 is going to be pushed on the stack so that becomes value of t and I can continue in the same manner and finally I am going to get value of e of the stack which is going to be 19 and when final reduction happens it says l goes to e followed by new line symbol I am going to just print this value doing exactly what I have done here this is clear to everyone this part is clear now let's come to this box where we say that I have a top down parser and inherited activities and we started some discussion on this and let me then just try to refresh your memories on what we are trying to do here so first thing it appears is that if I use a top down parser and dealing with inherited groups then I should be able to do simultaneously value for my except a small catch and the catch is that when I say that a is let's say I have a production of this form a goes to xyz top down in top down parser this is how my parse is going to get created and now if I look at inherited activities the way I am defining my inherited activities are that inherited attribute of a symbol can be defined in terms of inherited attributes of it and attributes of it that means potentially I can now write an equation which says x inherited is a function of a y and z some attributes of a y and z as far as my inherited activities are concerned this is a valid equation except the catch that even when I start constructing my parse tree what will happen is that I said that I am going to expand the left most non-terminal all the time therefore before I go and start expanding this part I will say let me go and expand this and I will keep on expanding this tree till I hit the leaf nodes and then only I will come and start expanding this now if I say that I want to compute inherited attribute of x in terms of some attribute of y no corresponding to y has not even been created and therefore those attributes are not available to me now suppose I restrict my definitions such that if I have an equation like this or let me slightly change it so you can keep this part here and use this part of the board suppose I have an attribute equation of this form grammar rule of this form and now I say that for any x i if I am computing attributes it can only be a function of inherited attribute of a and any attribute attribute of any symbol on the left hand side that means x 1 up to x i minus 1 now also what is important to note here is I am saying that as far as parent node is concerned I can only use inherited attribute of the parent node and as far as x 1 to x i minus 1 are concerned I can use either inherited or synthesized attributes of this then doesn't matter in top down parser if I restrict my equations to this form then I will always be able to compute x i I will never get into a problem because I am now saying that all my attributes have already been computed remember that I cannot violate my defendants now so these are known as elitributed definitions so now I am restricting my class of inherited attributes to elitributed definitions and saying that I can compute this in certain manner the translation takes place during parsing order of evaluation is going to be linked to order in which the nodes are created and that is really the order that I am creating my nodes starting from the left and that is really the parsing order and which is the for both whether it is top down or bottom up that is the depth first traversal order if I make this restriction then I say that elitributed definitions are where attributes can be evaluated in depth first traversal order so I am now restricting my class of languages once again and saying that if I have only elitributed definitions then I can do this computation if I have general elitributed equations then I can so elitributed definitions are that if I have an attribute a production of this form then we say that attributes of any symbol they depend only on if I take xj then xj which is somewhere between 1 and n the inherited attribute of xj depends only on inherited attribute of a and attributes of x12x j-1 this is j-1 and this form is not very clear not i-1 so now if we look at the transcript okay so if we look at let us say this so here is a production and here are some attribute equations so first question is this elitributed so let us look at this if I say l inherited is a function of a inherited that is fine does not violate anything then I say m inherited is a function of l synthesized is that okay yes no that is fine because it is looking at attribute of left inside does not matter whether left sibling this is in terms of the inherited attribute of synthesized attribute of the left sibling this is an attribute of the left sibling remember definition once again I am saying that inherited attribute of the parent and all attributes of the left siblings whether it is inherited or synthesized does not matter okay so this is fine if I look at a synthesized which is a function of m synthesized that also is okay there is no problem with that okay so this definition is elitributed definition what about this if I have a rule like this which says if a production says a goes to qr and does an attribute equation which says r's inherited is a function of a inherited is that okay any violations of elitributed definitions here now what about this q inherited is a function of r synthesized no means what it is a violation of elitributed definition because now inherited attribute of q is being defined in terms of attributes of a right sibling so this is not elitributed definition and if I look at a synthesized which is a function of q synthesized that is fine there is no problem now you can see that as far as if I restrict my inherited attributes to elitributes then I can even do this then I can write a top down parser by restricting this so although this was the question mark but we know that now this can be at least on factually done okay we will see how to do it but at least conceptually this problem is gone that I am dealing with a situation where I have certain attributes which are not even present so at least one more box has been packed okay we will see how to crack other two boxes but at least this part is clear so let me introduce now a new notion okay remember in the beginning I talked about two ways of writing your attribute equations one was I had certain attributes which are only specifications okay so I have only had attribute equations but I also said that we are going to have something known as translation scheme where I have attribute equations but I will try to impose an evaluation order on those attribute equations okay and these are not going to be pro specifications but they will try to capture the implementation somewhere okay so these are called translation schemes and basically translation scheme is nothing but same attribute equations but now I am putting these attribute equations not just on the right-hand side like some specifications but I can put them anywhere on the right-hand side between the grammar symbols okay so I can have something like this that I can write a production like this and then I can say a translation scheme may have x1 x2 and then some x1 and x3 and so on okay so you can see that here I am forcing some action which is a code or which is an attribute equation in the middle of the grammar symbols not just the right-hand side but let's see what power what additional power it gives me because now I am saying that I am actually doing something with the implementation okay now the way I am doing this or the motivation for doing this is I will say that as I go through this creation of the power stream then at this point of time I don't want to wait till I have seen all the symbols to evaluate an attribute equation I want to evaluate this attribute equation right here as soon as I encounter it okay so this is really forcing an evaluation order they are saying that you do evaluations at certain points of time and not only at end okay so here is a small grammar and can you see the strings which are being generated by this grammar you can see that a start symbol is a term followed by rest of it and term is a number and what is rest of it rest of it is some operator which is an additional operation followed by a term and followed by rest of it okay so you can see that this is a right because the grammar is the right and finally how will I terminate my production by saying that r goes to a sign okay so what it gives me r if I say adopt is plus or minus this is giving me some infix expression this is creating now a parse before expression where numbers are separated by plus or minus okay so really you can write things like minus 5 okay where I am assuming at top is only plus or minus okay these are the kind of strings which can be generated by this okay and it is easy to see that what will be the parse before this this will be e going to t and r and p will go to then p r will be plus p and r and this p will go to 4 and then this will be minus p and r and this p will go to 5 and this r will go to epsilon this is the kind of parse we will give now what we want to do is we want to when so one kind of problem we looked at was that when we reach at the top and we reduce by this symbol at that point of time we want to say that whatever is the value that should be printed now I am changing the problems slightly and I am changing the problem to say that whenever I reach the top whenever I do this reduction at that point of time equivalent infix instead of infix or let us say post fix expression will be printed okay so what will be post fix of this that is going to solve take this expression tree and then just do post order traversal so this is the post fix and what I want now is that I want to now whenever I reach the start symbol I want to print this not the value so there is another problem so as I said attitude equations are really for solving certain problems so what we do here now is that we want to use the mechanism translation scheme and I want to add certain actions in the middle of the ground okay so let us create some space for adding action and let me add an action here which I say that I want to print adopt okay and then I am adding another action now action can be anywhere it could be in the right post position it could be in the left post position or between two grammars okay so I have added two actions here one is here which says print adopt and another is in the right now okay and now let me take you to implementation of this so what you want to do to begin with this that let me say that each of these actions is going to be treated as a dummy grammar symbol a leaf node of course okay it cannot be non-terminal it can only be a terminal but it is treated like grammar symbol and I create my parse in the same manner okay so if I now say that I want to parse let's say 9-5 plus 2 and I want to print a post fix for this first thing I will do is I will create this parse okay so this is the parse before 9-5 plus 2 okay I have already seen this okay now if I say that this is also being treated as a leaf node a token okay then my parse tree will change and my parse tree will change by putting this action because now I am saying that T goes to num followed by this print num print num now is a dummy leaf node okay so this is how it will change that T goes to num and print num at this point of time I am not executing any action but I am saying that this is just a leaf node and similarly I will put for all these a print num and for all these productions which says R goes to minus TR I had introduced an action here which said R goes to minus T print adopt followed by R okay adopt here and this is how my parse tree will be okay so I have taken this parse tree and I have introduced corresponding actions also as leaf nodes yes okay now suppose I do a depth first traversal of this tree and whenever I encounter a leaf node corresponding corresponding to an action I execute so what will happen now what will be the first node that will get printed 9 then 5 then minus then 2 and then plus is that the post fix track out the post fix out of it so now I am using slightly different mechanism I am actually talking about a implementation I am saying that so why implementation and translation schemes are important because now I am saying that I want to execute these actions at certain points okay I am not just leaving it to specification but I know only at a location where I say that now I want to execute it execute it now execute it now and if I keep on doing those executions then my job is done okay now let's see how do I implement translation scheme because at this point of time I mean we really don't want to create this parse tree and then have another traversal whole idea was that I should be able to do all these translations as I am parsing so I don't want to create parse tree first and then say that these dummy nodes part of the parse tree then traverse parse tree once again and then execute these dummy nodes that's really not the intent that's only the logic okay intent is really to go into the implementation why should be able to now have this implementation okay so what we are assuming here are actions are nothing but terminal symbols and when I perform a depth first traversal order to obtain when I perform that first traversal order whenever I reach this action that whenever I will reach this terminal corresponding action is going to get executed and when we design translation schemes we therefore have to ensure that when I say that print num here this value of num is available okay suppose I put it at a wrong place okay and value of num is not available then what will happen my data dependent graph will get violated so I have certain data inconsistencies remember so that we get violated if I don't put my action in the right place okay so when I said for example I was trying to parse an expression grammar of trying to parse not to think what was that grammar was not an expression grammar that was a declaration right a declaration of type followed by a list okay so when I was trying to parse that string in some way I said L inherited this t type okay now L inherited this t type there is a dependence there it says that it depends on t type and unless t type has been evaluated I really cannot evaluate this equation so this equation cannot be arbitrary at any point of time but it can be evaluated only at the position t type becomes available okay so for example if I say print num here instead of this print num I put it somewhere else by then value of num may have changed so that will really be not the right place to do that so finding out the right place is very important in translation now let me pick up another example so suppose I have a production of this form okay and I want to compute let's say I have two equations with this I have some computation of a inherited okay which is function of something and I have a computation of b inherited okay which is let's say function f1 function f2 okay these are my attributes and I want to and what is important in translation where should I compute a inherited now I want to put an action here I have multiple places where I can put actions so if I say s goes to a b I have these three places where I can put actions where should I put a inherited computation this box or this box and you will also have to give me a logic why we are putting it somewhere so where should I put this middle one this one right okay so this is where I compute a inherited and where do I compute b inherited yes everyone agrees with this yes very good so now let's start to make a parse tree and let's see whether it works or not so suppose a and b are also non-terminals in general they can be so let's say that I have productions which say a goes to a and b goes to b okay and then I say that here so I am now computing some attribute I can compute attribute for this a so now I compute an attribute for this a and I say that this is a function of a inherited is that valid equation because this is defined in terms of its inherited attributes of the parent mode okay so if that is correct then what will happen let's look at my parse tree my parse tree will look something like this I have a I have b this goes to a this goes to b these are the kind of strings I will generate and then I say here I am computing a inherited right this is where you suggested between a and b and now I say an equation corresponding to this is saying that a goes to a i which is a function of a inherited will this work in depth first I was allowed I will reach this load and say give me value of a i but a i has not been computed as it this won't work right you see the problem why I am not able to compute a i in the setting position what does a i depend upon a inherited depends only on the settling software or at the attributes of its left siblings okay so why I can't compute a inherited here does it permit me from doing any computation here can I compute a inherited here yes okay so if I compute a inherited here okay then I don't have to worry about this problem because in that case what will happen is that I will now compute a inherited at this place and in depth first I was allowed to when I say now give me this value this value has already been computed okay so thumb rule is I will have inherited attribute compute it in the position on the immediate left of the row then I will not have a problem at all okay so when I am trying to compute a inherited and b inherited they must be computed in the place which is immediately to the left of a and immediately to the left of b what about synthesized attribute because in an attributed definition I can have both inherited and synthesized attributes so what are the places where I can compute synthesized attributes I can compute here and here or here what are the right places right of what right of the symbol number so suppose I want to compute a synthesized where should I compute after a I am not going to put a synthesized in this grammar rule at all I will compute a synthesized only in the grammar rule on which a is on the left hand side because a synthesized depends only on its right why should I compute a synthesized here those grammar symbols are not available to me if I say I want to compute a synthesized what are the kind of situations you are going to write you will say a synthesized is a function of and these are attributes of children node of a do I have access to children node of a here so how can I compute a synthesized here after small way yes so I will always compute a synthesized in a rule in which a and in this equation I can only compute a synthesized right and where can I compute a synthesized what should be the position of a synthesized computation so thumb rule is that all synthesized attributes must be computed in the right post position and all inherited attributes must be computed in the position immediately to the left of the grammar symbol then I never have problem of evaluation of right is this point clear so if I just do these computations then I can handle my attitude equations without violating any of the dependence problems so in case of synthesized attribute this is trivial because I am computing synthesized attribute in the right post position but in case of both inherited and synthesized attributes inherited attribute of a symbol on the right hand side must be computed in the action before that symbol immediately left of this so if this is the kind of attribute equations I have you can see that I make a parsley like this and I put all attributes in this position when I am saying that I want to print a1 inherited a1 inherited has not even been initialized and therefore a1 inherited should have been computed in this position which is immediately on the left of it then I would not have get into any of these violations similarly a2 inherited must have been computed on the left of it then this equation would have been fine so depth first traversal order in this case is going to give an undefined error and synthesized attribute for non-terminal on the left hand side can be computed after all the attributes of the reference have been computed an action normally should be placed at the end of a right hand side and immediately it is immediately on the left so now let us look at a translation scheme and try to create a translation scheme and suppose this is the okay let us write this first okay let me give you now specification and what I will ask you to do is I will ask you to compute the translation scheme or write the translation scheme for this this actually is a grammar for equation types of the system which says that start symbol is a block a block can consist of two consecutive blocks or a block can consist of a block and subscript another block very like saying that if I am trying to do type setting I can have two blocks and I can put them next to each other I can have a block and then I can have a subscript block to this only thing that happens in case of subscript block is that the font size of this will be smaller okay so you can say that subscript is going to be 75% smaller than this font size and this will be slightly displaced so that now the total height of the block changes okay and this is the kind of computation I am trying to do that if I say that my font size is an inherited attribute so I have two kind of attributes now so let me remove synthesized attribute if I say that my font size is an inherited attribute so when I start doing type setting system I say that I want to type set this document in 10 font size okay we have done enough of data to know this okay that write in the beginning to declare the font size and then you say that your font size are determined by this so b1 point size is b point size and b2 point size is b point size okay but when it comes to a rule like this which says that b is a block which consists of b1 and a subscript block b2 then b1 point size is same as b point size but b2 point size is slightly smaller and depending on your type setting system you will have a string fraction so string thing may be like 75% 80% 70% does not matter and therefore we use this function now what we really the height so there we say that the height of this text is going to be b height is going to be determined by the text height multiplied by font size so some function here right and then how will I determine height of this b now you can see that I have height of b1 and I have height of b2 but slight displacement so total height will actually go up and therefore we say that b height is nothing but with some displacement okay so you can determine what is the displacement factor whether you want to align it in the middle and so on okay but the total height is going to be more than height of b1 and b2 and therefore I say that b height is displacement of some b1 height and b2 height some displacement function what about b height here b height is going to be simple that whatever is the max of the two okay that will become the b height I have been assuming that at least there is going to be alignment at least of the start symbol or the whole text that is going to be the b height right now suppose I want to convert this into a translation scheme that means I want to put all the attribute equations in a place that I will not have any violation of evaluation whenever I am trying to do that computation all that attribute it depends upon will be available to no such violation to take place where should I put all these attribute will remain in the right position that we have agreed so where should I put this equation if I am writing a translation scheme where will this go b point size left of b so my attribute equation should look something like this after converting this into a translation scheme it should be something like saying that b point size is 10 that becomes the action and then I have b and then I say that s height is right this rt what about this how will this equation change this rule and these equations in terms of translation scheme how will they look b goes to b1 point size is 5 b point size followed by b1 followed by b2 point size is signed b point size followed by b2 followed by p height is max of this becomes my translation similarly so now I can do the same thing here I evaluate it on the left hand side so the way to read this is left to right top to bottom so b1 point size left of b1 b2 point size left of b2 and then this at the end and similarly b1 point size on left of b1 and b2 point size on left of b2 and this and then this is my translation scheme now let me pose a question to you suppose I instead of this I say evaluate it here does it change anything when I always be able to do this evaluation by attributes it is in right here in this case it may not matter but we cannot have a general rule and therefore rather than looking at what is the attribute it depends upon we have a general rule which says that compute it always on the immediately left of the grammar symbol so you do not have to look at what does it depend upon because in this case now you are saying oh it depends only on the inherited attribute and therefore I could have computed but then it will change from case to case and therefore I do not want to take that kind of analysis and I will say that always compute this equation on left of b1 and this equation on left of b2 and so on and then I will do then I will do the problem now that we understand translation schemes we are going to attack these two problems we are going to attack this box and this box and say that with the help of translation schemes can I now use electric booted definitions for a bottom up parser and synthesized definitions for a top down parser right these two boxes were left in these two we have understood so now we are going to attack these problems okay so let's stop here today and this we will take out in the week that follows the western example okay


Hi, I'm Mark Thornton from the Mises Institute. Today, the Swedish Central Bank awarded the Nobel Prize in Economics to three American professors Professor Robert Schiller of Yale Professor Eugene Fama of Chicago and Professor Lars Peter Anderson also of the University of Chicago The award was given for their contributions to asset pricing Professor Schiller made correct predictions regarding the tech bubble and the housing bubble But he of course is coming from the behavioral finance Area where everything is the result of psychology Eugene Fama is famous for the efficient market hypothesis Which says all information all relevant information is already built into the prices of assets and that markets basically Can't go wrong because they contain all relevant information And so there really aren't any bubbles or any bust in the economy and of course that just doesn't seem to be true in reality Professor Lars Peter Hansen is an econometrician who's Developed new methods of statistical and empirical analysis That allow economists to study much more complex things and more complex environments Using simpler models. Unfortunately, this has given a lot of economists just that much more faith and empirical analysis and Less interested in studying the world as it truly is But most problematic Overall, I think is Robert Schiller and his contribution the notion that booms and bubbles are Just a matter of psychology as well as the fact that he actually did make a couple of correct predictions This leads people to believe that he is the way to go in terms of economic analysis But you know, everybody agrees that psychology is an element in markets both in the upward and downward direction But the Austrians show that it's money that matters that the Federal Reserve is the ultimate cause of the business cycle and Schiller completely denies that and as a result he Sets off with a bunch of policy recommendations where he doesn't recognize the central bank as the problem He actually thinks it's the first line of defense In economic booms and busts so for for that many other reasons his policy recommendations are to regulate everything in our daily lives and With the Austrians our view is that the Federal Reserve is the cause and yes indeed it does set off psychop psychological reactions but psychology is not the cause of the business cycle and More government regulation is not the key to solving the business cycle and that's the Mises view


Hi, I'm Zor. Welcome to a new Zor education. We continue doing what I consider to be the most important part of this whole course, which is solving problems. Now, this is the fifth set of problems on zero probabilities. These I call easy problems. There will be some more advanced ones, hopefully. This is part of the whole course of advanced mathematics for teenagers presented on Unizor.com. That's where I suggest you to watch this lecture, but before doing that, I strongly recommend you to go to the website and look at the notes to this lecture. Notes basically contain all these problems and solutions, but don't pay attention to solutions first, try to solve yourself all these problems. Then you can read the solution, you can listen to my lecture, where I will explain the solutions, how I understand it. So, basically, let's start. Okay, the problem number one.  I don't know how it's all inside the box. Now, I am randomly choosing N balls from the box and randomly it means basically that the probability to pick any one of these balls is exactly the same. Now, I choose N balls. Now, I'm interested in the probability of having S red balls, where S is obviously from 0 to R. I cannot draw less than 0 and I cannot draw more than R red balls. So, for these S and for this N, N is obviously greater than 0, I have to determine the probability of taking among my N balls exactly S red balls. Alright, let's just think about this. What's the sample space? Sample space is all the different groups of N balls which I can pick from this box.  So, many different groups of N exist, obviously number of combinations from R plus B by N. So, this is the total number of elementary events in my sample space and they are all equally probable which means that the probability of each one of them is 1 over this number. Now, all I have to determine now is how many good elementary events satisfy this particular condition.  Well, let's just consider. We have N balls, right? S of them are red and correspondingly N minus S is the number of black balls, obviously, right? So, I have a freedom of choice to have S balls out of R.  Now, with each of them I can have a freedom of choice of the black balls, right?   And obviously, with each of these combinations I have each one of those combinations, so that's why I'm multiplying them. And each one has the probability one over this, so the total probability is this. This is the answer. Now, obviously, my conditions should be that, well, S is supposed to be from 0 to R. Now, also, S cannot be greater than N. Obviously, I cannot, if I choose four balls, I cannot have seven red or something like this. So, this is all for all these conditions which basically are necessitated by the formula here. Okay, that's it. That's problem number one. Okay, problem number two. I have a standard deck of 52 cards. There are four different suits, as we know, and the cards have different ranks. Now, for each suit I have cards from 2 to 10, Jack, Queen, King and Ace. Now, I will call these cards of all different suits, doesn't really matter, numerics. And these cards I will call pictures. This is basically my way to divide the total of 52 cards in two groups, two categories. I have 36 numerics and 16 pictures, obviously, because I have four different suits. So, for each one I have all these cards. Alright, now, now I'm randomly picking two cards out of the deck. And I'm interested in all the different probabilities that I have two numerics, I have two pictures, or I have one plus one, one numeric and one picture. Now, I'm picking two cards, doesn't really matter the order. I'm just picking a pair, alright? So, there are three different events. I have both numeric, both pictures, or one numeric and one picture. And I need the probability of picking each one of these. Well, first of all, let me just point out that there are no other cases. So, these three are mutually exclusive events and together they basically spend the whole set of different choices. If I have two cards, I can have only these three choices, either two numerics or two pictures or one of them numeric and one picture. There are no other choices in this particular case. So, now let's talk about the probabilities. Now, again, the elementary events which comprise our sample space are all the different pairs which I can take from the 52 cards, which is number of combinations from 52 by 2. Now, let's think about the first case. So, two numerics, the probability of two numerics is equal. Now, obviously in the denominator, I have to have this. Now, what do I have to have in the numerator? Number of different pairs where both of them are numeric. There are only 36 numerics, so how many different pairs can I get? Well, obviously this number of combinations of two cards out of 36. Now, similarly, the probability to have two pictures would be equal to number of combinations of two out of 16 pictures divided by the same denominator. Because this is one over this is the probability of each pair. And finally, if I have numeric and picture in any order, I'm not really suggesting that this is first and this is second. It doesn't really matter. So, I have a group of 36 numeric and I'm picking only one of them which is number of combinations from 36 by 1 times number of combinations from 16 by 1 divided by the same denominator. Well, obviously this is 36 and this is 16. So, anyway, this is basically the answer to the problem. But as a prudent man, I would like to check my answer. In this particular case, how can I check the answer? Well, I should really add up these three probabilities and check if it's equal to 1, the result of this. So, in other words, I will just add all the numerators together and see if they, because they share the same denominator. So, I will add numerators and I will check if I will have the same denominator. So, I need to calculate C 52 2 which is 52 times 51 divided by 1 times 2. Okay, this is equal to, I have already calculated it somewhere, 13 26. Now, this one, 36 by 2 is 36 times 35 divided by 1 2 which is 16 2 which is 16 times 15 divided by 2. It is equal to 130 and finally this one which is times C 16 by 1 which is actually 36 times 16 is equal to 576. Now, you add these three numbers, 6 0 0 6 7 2 5 2 2 1 goes 6 13, yes. So, balance is out, so to speak, right? So, it actually gives me assurance that my calculations are correct. Now, the third one. Alright, the third one is a very simple one. There is a deadly game of Russian roulette. One takes the revolver, let's say we have seven, capacity of seven bullets in the revolver. Puts only one bullet, spins the cylinder and shoots. My question is what's the probability of shooting twice in a row and not firing both times? So, both times we are not getting the bullet in the proper place to make a shot, okay? So, let's just think about it. If I have only one bullet out of seven and hopefully revolver is very symmetrical, so it's basically a random when I'm spinning the revolver, the probability of getting the bullet in that specific place for the firing is equal to one cell, right? So, that's the probability of fire one bullet. Now, if I don't, the probability of not firing is obviously six-sevenths, because there are six different empty spaces, empty spots. So, I'm doing it once and then I'm doing it another time. Now, these both times are independent, which means that the probability of happening both is actually equal to the product of their probabilities, which means that I have to multiply six over seven by six over seven, and this is my probability of not firing two times in a row. Well, significantly greater than half, so it's good chances. For three, by the way, it would be, well, for three it would be what, thirty-six times two-sixteen, and this would be three-fifth times seven, three-forty-three, something like this. Well, it's still better than half. So, even three times in a row you have better than fifty percent chances of not really firing the revolver. Okay. Now, my last problem is, all right, there is a legend about King Arthur and the Knights of the Round Table. So, let's consider we have, by the way, there are many Knights of the Round Table. I checked the Wikipedia and there are names, names, names, there are many different names, but I do know two main kind of people in this set. One is King Arthur and another is Sir Lancelot. He is a very famous Knight. So, let's consider that all the Knights of the Round Table and there are, let's say, N Knights, N Knights of the Round Table, they are coming and they are taking randomly the places around the table. So, let's assume that the chairs are not assigned. So, whenever they come, everybody sits randomly, basically. So, the probability of any permutation is exactly the same. So, my question is, what's the probability these two, King Arthur and Sir Lancelot, to sit next to each other? I suggest two different solutions. Solution number one, let one of them take any place, doesn't really matter which one. Then, let's consider how many choices for the second guy exist. Well, if, let's say, King Arthur took one place, there are N-1 other choices. Now, only two of these N-1 choices, this is King Arthur, then only two choices are next. So, here is one choice, here is another choice where Sir Lancelot can take the spot to be next to King. So, all others are basically not satisfactory. So, we have two out of N-1 choices good in some way, right? So, the probability should be two over N-1. So, out of N-1 spots, only two spots are considered to be good. Well, if you have some doubts about this approach, because I basically say, okay, let King Arthur choose any place. Let's think about this more, I know, more theoretically, if you wish. So, I was saying that any permutation of knights around the table is equally probable and there are N factorial permutations, which means every one of them has the same probability one over N factorial. Now, let's see how many different combinations are considered to be good combinations. Well, King Arthur and Lancelot can sit, there are N-different spots for King and for each one of them, two spots for Sir Lancelot on both sides of the King and that's different permutations obviously, right? We are considering all the different permutations. So, it's two times N positions for these two. So, any of N positions of the King and for each one of them, two positions of the Sir Lancelot are around this, right? Now, all other N-2 knights can sit whatever way they want. So, the permutations are N-2 factorial. So, that's the answer basically. But if you think about it, what is N factorial? N factorial is N, the previous one N-1, previous one is N-2, etc., etc., up to 1, right? So, N-2 up to 1 is canceling this one, N canceling this one and we still have 2 divided by N-1, the same answer. Alright, that concludes this particular lecture. I do suggest you to go to unison.com to this particular lecture and again, go through the notes, try to solve all the problems yourself if you didn't do it before and I think it's just very beneficial for you to go through these problems and any other problems yourself. Because again, that's the purpose of this course. You would feel much more comfortable if you will solve all these problems yourself. That's the purpose actually. Okay, that's it for today. Thanks very much and good luck.