 Welcome back, we continue our study on impartial games. So in this session we start discussing the spring Grundy theory of impartial games. For this we need to introduce the graphical games. We have already seen how these graphical games look like but let us recall them once again. So a game consists graph G is equals to XF, what is XF? X is the set of all positions. XF is a function gives for each X in X a subset of possible positions followers. So I will explain in a while, then here further we need to say that if FX is empty then X is terminal position, the start position is X naught which is in X, the player 1 moves from and of course as we have been discussing players alternate position X chooses some Y in FX. The player confronted with empty set FX loses. So what did we say? The game actually there are set of some positions which are denoted by X and F is specifying once you are at a position X what are all the positions it will lead to. Because if a player makes some move the game moves to some position and all those positions which can be moved from X are given by FX. For some position X if FX turns out to be empty then X becomes a terminal position. The game starts with an initial position called X naught and at that position the player 1 makes his move. Then the players alternate their moves and it means that at a position if the current position is X the player who is making a move he will choose some move which leads to a position which has to be something from FX. If a player confirms with an empty set FX he becomes loser. In other words we are in a normal play. Let us see some examples. We will start with a very simple game called chomp which we have discussed already we take a simple setup of this. So let us take only 2 by 2 square this is the poisonous. So initial position is this, this is nothing but our initial position. Now from here there are what are all the possible it is possible that it leads to so this is occupied it can also move to this position or it can go to this position. Now once in this position so it can go to 2 possibilities or it can go to this and from here it goes to this is going to be a terminal position and from here also it will come to terminal position. Now we would like to point out that this is same as this position. So in other words this is nothing but this. So in a sense from here one position is this and this position is this. So if I rewrite this position this game what we have is the simpler. So let me write it again here this is the initial position from here it can go to we will reach to a terminal position and from here it can lead to this position or it can lead to this position. So this is the game. So in this setup what the set X is nothing but these positions there are 4 positions possibility 1, 2, 3, 4, 5, 5 positions. And F for example this is nothing but there are 3 things 3 positions. So this is basically how this impartial games can be described by graphs. So now one can think about we can work out variety of examples for example if we take subtraction game the take away games 5 coins if I take and let us take a player can remove 1, 2 or 3 coins at any point of time. In this case the 5 is a position is a start position and from 5 one can go to 4 from 4 from 5 I can go to 3 from 5 I can go to 2. From 4 let me put this from 4 I can go to 3, from 4 I can go to 2, from 4 I can also come to 1, from 3 I can go to 1, from 3 I also can go to 2, from 2 I will come to 1 and from 1 it is a terminal position there are no more you can remove it. So this is an example we are interested in progressively bounded. So what it means from any position is finite that means if you start with some position some initially and then the players are alternatively making their choices then look at how long it takes to the terminal position so which is basically known as the length the maximum possible there that is the length and that length has to be finite. If we look at this thing from 5 I can go to 4 from 4 I can go to 3, 3 to 2, 2 to 1 this is in first one step 2, 3, 4 steps I can go to the terminal positions. So the path here is 4 and we want that path the length of that any path should be finite. So such games are known as progressively bounded. So we are interested in only those games. So in fact it also immediately implies this also implies that the graph has no cycle. So if there is a cycle for example from a position if it goes to another position from this it goes to another position and then it comes and then it goes there then what happens that it can cycle along this path and in such a case it will have an infinite path and we do not want this one. So no cycle is a important property of these graphical games which are progressively bounded. We are interested only in this thing. So we consider progressively bounded impartial games. So let me recall what is an impartial game here. In an impartial game the choices available the positions available to players are same that means you cannot distinguish that this position belongs to only player 1 or player 2 like in chess. So that is important we have already discussed about this. So we are only looking at such games. Now I would like to introduce Sprague Grundy function. So Sprague Grundy function is defined on x which takes non-negative integers it can take any integer which is defined inductively as follows g of x is nothing but minimum of n greater than equals to 0 such that n not equals to gy for y in fx. It is exactly like what we have defined earlier when we are proving the NIM game. So the gx is the smallest integer which is not equals to any of this gy and y is in fx. So in fact this also this is defined in a recursive fashion. So we need to the way we have to introduce this definition is recursively first we have to go to the terminal nodes and start defining what exactly is the terminal node and for them the Sprague Grundy value we have to define and then inductively we have to do it. For example if x is a terminal position then gx has to be because there is no follower no following position from x that means fx is not empty that means this set consists of all integers and minimum of them is going to be 0. So for a terminal position gx is going to be 0 then we have to define inductively once we know the terminal positions so go to the previous ones the position that go previously and then you go on recursively we will start with some examples. So how to define this in fact I would also like to say that gx is nothing but the minimum excluded value which we have defined earlier of gy y in fx this if you recall the proof of this NIM game and the strategy of it we have introduced this max function there so g of x is nothing but the max of g of y y in fx. So this is now we will try working out how to define of it so let us say let us take a simple game which will take this is the position that it takes this there is another position here and from here let us say it goes to here and from here I can go to here from here I can go to here from here I can go to here from there I can go to this and this this is basically the a simple game where this thing. So what are N positions here? So we call the N and P positions so these are the terminal nodes that means after this no more move so therefore the if a player is already here that means that person he cannot make any more decisions so he will be loser so therefore this is a P position these two are P positions. The previous move how for example from here I have come to here so therefore this is going to be N position and to this I have come from here so therefore these two are going to be N positions and this is going to be P position and this is going to be N position so this we have already worked out earlier so we will now all the terminal positions have gx0 so this these two are the terminal positions so that they will have zero value here now these two are going to be zero so this position if you look at it this position its followers are only zero here the g value of these two positions are zero so therefore this position will have a value one. Now look at this position from this position the followers are this and this so it takes zero and one here so the minimum excluded value here is two. Now you look at this position here the followers from this position is one and two the minimum excluded value is zero and when I take here the followers for this position are two zero and one so the minimum excluded value is three. Now an interesting thing here is that all the P positions here have zero value so if you recall the NIM game and the strategy there we also have a same thing so in fact you can see that if the green d value of any position is zero they are going to be P positions and for N positions the green d value is going to be different from this. So this is an interesting thing in fact what we are really going to do is essentially follow the strategy of NIM here. So now I need to introduce another important aspect here which is known as adding games. So for this let me recall this NIM game so if you take the NIM game what we have really is that so NIM game let us say there are two heaps. So at any point of time when a player is making a move he can remove the coins from any of these two heaps. So if I only take one this thing people the players have to alternately remove from this one when there are two heaps at any point of time the player has a choice of choosing which heap and how much to choose. So this is essentially the idea of this adding games so let me go. Now let us take the root x1 f1 x2 f2. Now we are interested in let us say g, g1 this one and g2 this one we are interested in defining what is called g1 plus g2 this I will write it as g of course the corresponding graph structure is given by x at f. So what is x? This x has to specify all possible positions if you go back to this NIM game what are the positions the sizes of the heaps in this heap and how many are there in this heap therefore it is like the possibilities of this and possibility thus of possibilities of this heap there are two heaps and all possible combinations of it. So in other words this x is nothing but x1 cross x2 the combination of all possible positions. Now how do we define f? Again the idea comes from here itself in the NIM game itself. Suppose if at any point of time if the NIM size let us say here it is 5 and here it is 7. So from 5 and 7 what are all the possible positions? From I can remove from 5 this any number let us say 3, 7 is possible or it could be 5, 4. So I remove either from here or from here. So in other words suppose if I have a position x1, x2 there I need to look at what are the positions that can be moved in this game. Suppose it goes to y1, x2 where y1 is in fx1 or f1, x1 this is possible or it can go to x1, y2 where y2 is in f2, x2. So you look at the possible moves from this game and this game and then we need to do it. So formally let me write it this one this fx1, x2 is nothing but so this will be f1, x1 cross x2 these are all the possible positions possible and not only this it also can take x1 cross f2, x2. So these are all the positions possible. So in particular we can actually make it multiple these things. Suppose let us say games are g1, x1, f1, g2, x2, f2 let us say there are n games I define g2b which is g1 plus g2 plus gn this here x is defined as x1 cross x2 cross xn and fx1, x2, xn is nothing but fx1 cross singleton x2 this is one then union x1 cross fx2 cross like this up to singleton x1 singleton xn minus 1 cross fxn. So this is the f these are all the positions that are possible from any position of x1, x2, xn. Now we need to define the terminal positions. So terminal position is nothing but it is a position where in any of the games from there you cannot move to any other position in any of the games. So that means that will be simply a Cartesian product of the terminal positions in the individual games. So the terminal positions nothing but the Cartesian product of terminal positions in the individual games. So once we define this thing the what we will see in the next session is how to find the spray Grundy function of this thing spray Grundy function g of g and I also want to understand the spray Grundy function of the game 1, game 2, game gn how they are related. So we are going to find a relation between these things that is basically the spray Grundy theorem which we will prove in the next session. We will continue this in the next session.