 OK, well thank you and thanks for coming. The idea is to have this every month, the last week of the month. Not in December, but otherwise when we are open. And which day of the week we can adjust according to the speaker and other things. OK, so what I'll talk about is impartial games, which is, I think, is a very nice theory. And it's very elementary. But I think it's something worth knowing if you've never seen it before. So let me start with the mother of all games of this kind called, at least in English, it's called NIM. Maybe you guys from other countries may have seen it and have different names. And so it consists of the following. You can start with any number of objects in piles. So I'll do this example. And this is something actually I played at least once when I was a kid. So you have five piles. And the game consists there is a game with two players. And each player has a possible move. And the move in this game consists of taking any number of objects from one pile. So you choose the pile, and you take whichever you number of objects you want. And in all of these games, the story will be the same that if you cannot play, you lost. Or to put it another way, if you are the last person to play, you win. Is that the rules clear? So I like to play with you with all of you choose. Let's see if I can make this work and see if I can win. Maybe you will win. So why don't you start? Pick any pile, there's five piles with five, four, three, two things in it. And you can choose one pile and take over many you like. No, no, let me repeat. So there's these possible moves you can make, which is to remove from one pile any number of objects you like. So for example, from this pile of five, you can take three out or take five out, whatever you want. And then is the turn for the opponent and repeats. And the game ends when there's nothing left and there's no possible move. In that case, if you face with a situation where you cannot move, you've lost. Remove, yeah. No, no, I mean move as a general idea of something you can do in the game. But in this case, it means remove from the pile. So has anybody seen this game before? Yes? What do you call it in your country? How do you call it in your country? BIM, you call it BIM, OK. So you know the strategy, too? Oh, OK, well, so then you shouldn't play. OK, then you too cannot play something. From this one, you take three. And I'll make a little numerology on the side. And what I'll do is explain what I'm doing later. But if you want to start moving ahead and thinking what the story is, you can look at that. So I'll remove three from here, right? So now I'm going to copy it on the side. So it wasn't such a great move, OK, I'll explain. So I'll try to do a good move now, see if I can do that. I'll change this to 0, 1, 0. So I'll take two out of this. So now it's your turn. Anybody wants to try? Come on, we don't know whether here. Oh, you also want to win, I think. Take all three out of this one. So this one. So unfortunately, if I do this right, now you'll never have a good move. So at this point, if I play this correctly, I'm guaranteed to win. And so what I should do to do that is change, for example, this one to that. So from one of the two, I mean, at this point, it should be easy to see, just eyeballing it. But since I'm bad at that, I'll just do my numbers. And while you look at the game, you should also look at what I'm writing here and try to see what, if anything, is happening. So come on, we're kind of close to the end, I think. So what should you try to do? Remove this one here. So I made a mistake somewhere, no? Oh, now I got lost. So what do we have here? We had a one here, no? Oh yeah, so this became 0. Is that right? So I should just take this one out. So you give out. So on the other hand, what is it that I've been doing over here? Yeah, you tell me? Right, so what I wrote here was the numbers of objects that I had, which I started with 5, 4, 3, 2, 1. And I wrote them in binary. And then what I did is treat these numbers as if they were vectors mod 2. I forget that they were actually binary expanses and I think of them as zeros and ones. And I added with the binary addition, so 1 plus 1 is 0 and so on. So 1 plus 1 plus 1 is 1. 1 plus 1 is 0. 1 plus 1 is 0. So that was the thing you saw. And then you did this move. And it went back to a sum 1, 1, 0. And then I did this move that made it into 0, the sum. OK, that's the point that we're getting to. But so this is my move. So what did I do every time? Well, she already said it. What I managed to do is every time I did a move which resulted in the total sum to be 0. Now, what that meant is that any move you did will make the sum not 0 because you can only move one row and you cannot change a row and keep the sum to be 0. So every time I moved, I managed to get a 0. Every time you moved, you managed to make a non-zero and so on. So this went on until we're done. And so the last position is when there's nothing left. And the sum is 0. I got there. And you are faced with not being able to move. And so you lost. So the idea then, one graphical way to think of this that I think it helps in my mind is that somehow the game schematically consisted of something like a lever like this. And it started off being tilted, so the sum not being 0. And what I always try to do is put it into a level situation. So schematically, every move that I did, because I managed to get to a point where I could, is to put it into an equilibrium. And every time you moved, you took it out of the equilibrium in different forms. The sums, other than 0, were all kinds of things. But having I'd been able to get to 0, I managed you to be forced to move it out of the equilibrium, so to speak. So for example, what would have been a good move for you? This is what you saw. What would have been a move that took it from this non-equilibrium situation to an equilibrium situation? In this case, there's only one offending column. So all you have to do is fix that one. And so you can take any one of these that is a 1 and make it a 0. So that is to take one out of the corresponding column. So you have three good moves to make. Take one out of any one of these three columns. And you could also achieve the 0 by making the 0 equal to a 1. But of course, that's not good because in the game, you can't go up. You always go down. So I think with these thoughts, now you can think of a strategy of how you will always win. As long as the opponent doesn't know the strategy or, by chance, manage to put itself, make you face a 0 position or a level position, then you should be able to get to that equilibrium position. And from then on, always move in this fashion. So the game is nice because it has this complete description of the strategy, and it's very simple. Now, for those of you who have already done a bit of research and so on, you may get a kick out of the fact that this was maybe known earlier, but the paper that describes this mathematically is by a Frenchman called Charles Bouton, who published a paper in 1901 in the Annals of Mathematics, where he describes this. And basically, the theory that I'd like to describe to you is that I'll describe these games, impartial games. And the theorem is that they're all equal to NIM. So once you know the strategy for NIM, you know the strategy for, in principle, all other games that are impartial. So what does that mean to be impartial? An impartial game is that you have two players that alternate playing as we did. The moves are the same for both. So the first line could have included chess. The second one eliminates chess because you can't move the other opponent's pieces. There's complete information, so nothing is hidden. Both players know exactly what's happening. There's no chance. You don't throw a dive or anything like that to play. And the player unable to move loses. This is called normal play. And then there is a completely different thing, which is if you do exactly the opposite, which is that the person unable to play wins. And that's called, so this is opposite opposed to, it's called misere play from French. And this one, interestingly enough, has no strategy. This is a very difficult thing to analyze in general. And so the mathematical theorem here, sort of loosely make it somewhat vague, which is all impartial games. Well, a fancy way to say this would be that they're isomorphic. There's a way to convert a game into one that looks like NIM, for which we discuss the strategy. Now in practice, of course, when things are isomorphic, the isomorphism doesn't mean that they're equal. And computing the isomorphism could be very difficult if you have some very complicated games in which this it's not completely clear how helpful it is. But the theory, anyway, is that is this one. And so this, I think, is a pretty remarkable fact. And I'll illustrate a little bit how this works. And if you like this type of thing, I recommend very highly a book by Guy, so Berlachamp, Conway, and Guy, which discuss many, many things among them this impartial games. It's one of the most idiosyncratic books I ever seen. And sometimes the style is a bit grating, but it has an incredible amount of stuff you can't find anywhere else. So rather than, so anyway, in particular, they have many different kinds of games, many of which were invented by Conway, which are, of course, incredibly sophisticated and subtle. But let me discuss only for now one other type of game, which just to give you a flavor of that, there are many different games that you can discuss, which are fairly simple to describe and they all fit into this category. So a simple example would be a subtraction game. So this is an example where you have a collection of numbers, S, in this case 1 and 2, and you start with one pile of objects. And then you can, the moves are, you can take out of the pile one or two objects. So and again, the rule of ending is the same. If you can't move anymore, you're done. So and you can replace the set S for any other favorite set that you like. And the somewhat, you can see, it has a little bit of the flavor of NIM, but it's more than just the flavor. It's actually, in some way, exactly the same as NIM. So let's see. One way to analyze a game is to think that each state of the game, so every position of the status of the game, you can think of it as a vertex, as a dot. So in this case, the state of the game consists of how many things you have in your pile. There's only one pile and it has some number of objects. So let me make a little graph of the possible states. We can have, if we go up to 6, this will continue on. And so one way to describe the game is to say, well, these are the possible states. And in edge, you put an edge for the possible moves that take you from one state to another state. So since we can take one, we can go from 6 to 5, from 5 to 4, from 4 to 3, and so on. And since we can take two, we can go from 6 to 4, from 4 to 2, and 2 to 0, and from 5 to 3, and from 3 to 1. So the game then, or the impartial game, gets rise to a directed graph where the vertices, the dots, are any given position of the game at a given time. And then the arrows tell you how to go from one position of the game to another. So those are the legal moves of the game. So in this case, that's the graph you'll see. So what I like to do is try to assign to these states of the game a label which will be like the zero, non-zero that we had in the case of NIM. And the traditional way, the labels for that is to call the positions to be P or N. And P is like 0 in the NIM case, and N is like a non-zero. And the way to describe that in terms of the graph is as follows. A P is a position where from it, you can only reach N positions. So P is like the equilibrium. And from an equilibrium, you can only go to non-equilibrium. So from P, you can only reach N's. And from N, you should be able to reach at least one P. So if the thing is tilted, you should be able to put it back. You could also sort of tilt it differently. So there's some N situations, but there should be at least one P. So P goes to only N's, and N goes to N's, but at least one P, maybe more than one P. And so now what we do is we're going to label recursively all the dots in this diagram as N or P. So what should this one be? It's one of these two. Well, where do you go from zero? Nowhere. So it's the empty set of places you can go to. All elements of the empty set are N, because there's no element. So it is a P. It's like when we ended the game, or we didn't quite end it, but if you end the game, you see a P. So P is good for you, is bad for your opponent. Because if you manage to get to a P, it means the other guy will have to go to an N. And if he gives you an N, you can move to a P. So the strategy is try to get to a P position, let the other person take you out to N, and bring you back to P. So every time they move the boost to N, you bring it back to P. You go like this until the end game ends. So that's the strategy. That's what we did with NIM. So let's try to figure out what all of these things are, these positions are. So what is 1? N. You guys agree with this? Don't be shy. So why is N? Because you can go to at least one P, right? That's what N means. You should be able to go to at least one. So about 2, also N. How about 3? You can go from 3 to 1, and from 3 to 2. And they're both N. So that's a P. So if you look at this, you will quickly convince yourself that this is periodically period 3 like this. P N N, P N N, P N N, P N N. So if you want to play this game where you have a million and a one things in your pile, what should you do? Can we do a million more 3? Maybe not. Suddenly I can't here. Can somebody know what a million and one is, more 3? I think we can do that. It's 2, right? So what is it? So a million and one, how do you know what the number is, more 2? Add the digits, more 3. I've learned this in primary school, like the visibility by 3. So this is 2, more 3. So since this is cyclic of a period 3, it looks like if it was just 2, right? So we stand in here, which means there's good luck for us. What should we do? We should move to a P position. So we do what? We take 2, right? So the good guys, the P's, are divisible by 3. So we just take enough to make it 0, more 3. If we are lucky enough to face such a thing. So if the opponent saw that and knew the strategy, they will move to a P and you would be unable to win unless the person makes a mistake. So these are all sort of, now you take your favorite set S, any number you like, and you'll see exactly the same phenomenon. The positions P and N could be, you can label all positions as P and N, and it'll be cyclic. It'll be periodic. And it's actually kind of a complicated thing to figure out what the period is. It could be very long periods in the shape of this thing. So I'll give you one other game to think about. This one, I think, is actually pretty complicated. And it was described by this Dutchman Withof. But according to Martin Gardner, he was known in some of the African cultures before. In any case, it's a bit, so these games are first on really strange kind of, yes, go ahead. I'll get to that. I'll get to that. But at the moment, let me just at least let's agree that we've managed to do somewhat similar what we did before, because we managed to distinguish certain positions as desirable, the ones that added to 0, and those that are not desirable did not add to 0. So like a P is like having the columns add to 0, and an N is having the columns not add to 0. And then once you believe that this is doable, that you can actually recursively starting from the ends of the game up and label every position with either a P or an N, you have a strategy of how to win. And in that strategy, it's the same as in NIM. But I'll make that a little bit more precise, and we'll sort of flesh out this statement. So here's this Withof game, which has one pile of some number of things, and you have two possibilities. You take any number from the pile. No, so there's two piles. Otherwise, this will be a little silly. So you take any number of stones or objects from one of the piles, or you take the same from both. So you decide. Either you take your favorite pile and take whatever you like from it, or you decide that you're actually going to take from both, in which case take the same number from both. This is actually a pretty complicated game to analyze. And the answers of which are N's and one's P positions are very pretty, which I won't tell you, but not now. But if you are interested, we can just cast it after the talk. Let me just point out that it has this nice interpretation. You can describe the position in the game as a pair of integers, positive integers, namely how many things are in one pile and how many things are in the other pile. There's two piles. So this dot here would be that one pile has three and the other pile has two. So what are the possible moves? Well, you can take things out of one pile, which will be moving this way, any number of squares you like, or you can move this way by taking things from the other pile any number of times. Or if you do both at once, then you should be able to, then you can only go diagonally. So this is like having a queen in chess. These are the possible moves of a queen, but except that it only have to go sort of towards the order. And again, the rule of the game are that if you can't move any more, then you lost. And so now if you do the analysis, some of these cells will be p and some of these cells will be n. And you can ask yourself, well, what's the pattern that you see? And there's a very interesting pattern that shows up. So I'll leave it as an intriguing thing for you to think about. But that's sort of a fairly sophisticated game. So now back to this theorem and what Stefan was asking, what do I mean by saying that the games are all isomorphic? So here comes another idea that completes sort of the picture, which is that you can make the sum of two games. And what is, I think, beautiful is that this idea of thinking of the games as if there were numbers, so to speak, exactly led to Conway to define a whole new crazy class of numbers called surreal numbers, which is a whole interesting aspect of mathematics that is clear to me that it came from elaborating on this theory. So what is the sum of games? Suppose you have two games, gamma 1 and gamma 2, impartial games, that is. So just like the kinds we've discussed. So I'm going to define a new game, gamma 1, star, gamma 2. So the positions on this new game are pairs of position, one in this game and one in this. So what are the moves? Well, the moves is very simple. So you either move in gamma 1 and don't do anything with the gamma 2 state, or you move in gamma 2. So what's an example of that? Well, nim. Let me give you a very silly game. One pile, move, take anything you like. So that's a pretty trivial game. You have one pile and you're allowed to take anything you like. So if you face that, what would you do? Take the whole thing out, and you're done. But now take gamma 2 to be the same game and take the sum. Now it became interesting because what does this mean? Well, you have two piles, one from the gamma 1 game and another from the gamma 2 game. But now you face exactly in the nim situation. You can take from one or from the other, but not from both. So now you see that something is somewhat missing in this n and p story because in the gamma 1 or gamma 2 games, just one pile, they're the same game. If we were to do our little p n story, what would it look like? Well, the last one is p. I don't draw the graph because it'll meet too many arrows. You can go from anywhere, anything below. From 6, you can go to 5, to 4, to 3, to 1, to 0. And then anything else is connected to 0. So everything else is n. So that's not a very interesting game. And if you take the sum of the two games, it becomes more interesting. And just knowing that this position in the game 1 is n or p and knowing that this one is n or p doesn't tell you what the position is in the pair. Because if there were more than zero things in each one, both positions in the individual games would be n. But clearly, that doesn't mean that the position in the sum game is n. Because playing with two is maybe easy, but not as trivial as this one pile. And you could, of course, add more games. And then if you added five games, you'll have like the name we started with. Is that clear to everyone what I'm saying? So this operation of constructing a new game out of two, you can know everything about this game and everything about this game. And when you put them together, you still don't know the full story about the new game. So what's missing is that this is somewhat a limited information. What we like to do is get something a little better than that. So remember that in the game, the positions were not just labeled p or n. We had a number. We have the sum of the columns was either 0 or wasn't 0. So what's missing is that we're not just going to label these positions with a letter p or a little n. We're going to give them a number. And that information will be enough to recover the corresponding number in the sum of the games. So let me just do an example. And amazingly enough, so the paper of Buton was in 1901. Whithoff was a few years after that. And then in the 30s, these two guys, Praig and Grundy, came up with exactly the same theory. And so it's called the Praig Grundy theory that allows you to extend this notion to games, to any game. So let me, this will be the last thing I discuss. We're going to give a numerical value to a position of a game, not just a label np, an actual number. And for that, I need a concept that's called the mechs. So this, although Praig was involved too, somehow it's called the Grundy function. So this is to each dot, to each state, we're going to associate a number. So that's the function, the Grundy function. And it's defined recursively using the notion of mechs. And mechs stands for minimum excludant. So it's as follows. If you have a subset S of the numbers 0, 1, 2, 3, and so on, the mechs of S is defined to be the smallest number not in S. So for example, if the set S is 0, 1, 2, 4, 6, 7, 10, and 15, what's the mechs of S? 3. You read it, all these are in order, so you read it from left to right. And you first find the thing, the first gap, the first number not in the list is 3. There may be other things missing, you don't care. And what's the important property of this mechs, which is really somewhat simple, but is what makes the whole thing work? When is the mechs of S equal to 0? How could the mechs of S of a set be 0? Well, how about this set? What's the mechs of that? 1 is not there, but the mechs is still 0. It's just that 0 is not there, right? So this is actually exactly the same as saying that 0 is not in S. So now I'm going to assign to every state of a game a number. And that number is going to be computed recursively, somewhat like what we did, the PN distinction, but a little bit more sophisticated because it will give rise to numbers. So if you have a position V in your game and you have all the possible ways, things you, as an example, all the things you can reach from it, then you define the Grandi value in the game that you're playing of this vertex V to be the mechs of the values of the Grandi function on all the things you can reach. So you start from the bottom, okay, and those are going to get the value of 0, and you move up and you see from each dot where it's connected to, you look at its values, and then you look, you take the mechs of that, and you keep going recursively up. And then because of this property, the 0 value will exactly correspond to be in a P position, and the non-zero value will correspond to be in an N position. But now N got sort of colored. It's not just N, it has a number attached to it, okay? And I'm sure I'll be able to explain this in much detail, but at least I'll give you a bit of the ingredients that go into this. So let's do an example, maybe this is the easiest thing to do. So let's take the subtraction game, the one that we were looking at before, where our set is S equals one and two. So remember that means that from a pile we can either take one thing or two things. Okay, so we take just the diagram we had before, six, five, four, three, two, one, zero, okay? These were, this was P, this was N, N, P, N, N, P. That's what we did before. But now we're gonna give a number to this, okay? So we give the value zero of our function to the terminal vertex. So the one where the game ends. And let's see if we can compute the Grandi function now. So what's the Grandi function of this dot? Well, how do we do it? We look at where we can go from here. From here we can go there, because we can take one out, right? So we can go from here to there. And that's the only place we can go. So the collection of numbers we should mix off consists of the number zero. There's only one number below this one. So we take the mix of the set consisting of the number zero. The mix of that is one. So this has the value of one. What's the value of two? Well, from here we can go there, subtracting one, or we can go there subtracting two. So what is the mix we should be taking? Well, we have two values, the value zero and the value one. So we take the mix of the set zero, one, and that is two. So it looks like it should be pretty easy now. So the next one is three and so on. No, what's the next one? Well, if you believe what I said, you should be able to guess because p should correspond to zero. Well, let's check that. From three we can go to two and we could go to one. So we take the mix of one and two and zero is not there. So it gets the value zero. So now you can trace this up and you'll see that you get this periodicity of now the values of the function, not just the labels of the position. Okay, so then the point here is to make that that there is a recursive way to assign values integers to your positions which follow this recursive rule. And so what we done is that G is defined on all states of gamma in this recursive way. And the statement is that a P position corresponds exactly to the value of the function equal to zero and an N position corresponds to the value of G not equal to zero. So with the analogy of this thing level is like the grantee function some sort of angle if you like. You can have zero angle or you can have any kind of angle which is recorded by this function G in some mysterious way. Okay, and so finally what's the theorem that these guys from Prager-Grandee proved that if you have several games as usual all of these are impartial games that's all I'm talking about. Then the grantee each has a grantee function. So now you make the gain gamma to be the sum in this way that we described of all of these games and tell me what the theorem says. The grantee function of the sum is the sum of the grantee functions. But the sum in a funny way not the sum in the usual sense but in what sense? We've seen it already in a way. A NIM game consists of a sum of these silly games that you take one pile and you take anything you like from them. Okay, maybe let me go slow. So I'll finish with this. So let's just take the one pile any subtraction game. So that was zero, one, two, three, four, five, six. In terms of labels it was simply this but let's compute the grantee values. This is zero was the grantee value of one, one of two. You can go from two to one and two to zero. So it's two, three, four, five, six. So this silly game is just the grantee function is the game. It just tells you how many things you have in its pile. And a NIM game is a sum, let me call this thing gamma zero just to use some notation. So a NIM game consists of this same game added any number of times. Each game represents one pile. So you sum as many as piles as you have. And what did we do to play this game? We took the number of things on the pile. We wrote it in binary and then we added the columns in this funny way. So that's what the addition means. So addition here is this funny addition where you write. So the addition say of the number N with a number M is some number R. And what you do is you write N in binary, M in binary and then you add in this mod two form and that gives you the binary expansion of your sum. And that if you're algebraic in incline is gives you on the set of integer zero one and so on it gives you a structure for a billion group. It's just Z two cross Z two cross Z two cross Z two infinitely many times. And that's what this addition means. And Conway, which cannot possibly be improved in any way calls things like this Nimbres. And this is the number addition. So the way to state the sum is that the grand D function of a sum of games is the number sum of the grand D functions of each individual game. So that I think goes some ways into answering Stefan's question that you can think of a grant of any game is going to consist of well even if it doesn't obviously decompose into some of things it has each position has a grand D value and you can think of that as a pile in one pile in NIM with that many things. Except that the game is funny that maybe you can go up sometimes in size. So moves take you up or down depending on some obscure or the obscure way of how the game has been constructed but is in that sense that every game is like NIM because all you need to know to study the game well is the labels but in more generally you can look at the grand D value and that sort of tells you how it should be thought of as if it were a pile in NIM. And so like anything else that involves an isomorphism the question is well can you actually compute this isomorphism if you have a very large complicated game. If you can't then maybe this theory doesn't help you or if it's expensive or difficult to do. So the question is what how complicated is to compute this NIM sorry this grand D function and well this actually could be fairly complicated or fairly expensive computationally. And in some cases I think the actual values of for every state are not known. So there are some games that are really wickedly sort of devised in which you know how to compute it by an algorithm we discussed this recursively but in order to describe the actual function in some sort of closed form maybe impossible or just very difficult. And for example in this I'm not sure how much is known about subtraction games in general the grand D function is some periodic thing in the size of your pile but the periodicity or the actual values of the grand D function I think are in general not known or not obviously describable is sort of by a formula. And I think I'll stop here thank you. Maybe there's a question so now go home and play with your little brothers and impress them. Okay well we have a little coffee and tea reception at the cafeteria for those who want to stay. Yeah Harry I'm certainly not an expert but as I said I think things like how long it takes to compute the you know algorithmic questions you know those are really open and the nature of the function in this completed games is also maybe not known. But yeah I would say that those are the things I've seen that people still are trying to answer. Yes as far as I can tell this is the operation that works for this for describing the strategy and allowing you to recover strategies when you have several games that you combine. You could try to define multiplication of numbers and if you are Henry's Lensstrom maybe you will be able to. But I don't think it's just sort of a a mathematical challenge I don't know if it has anything implications to the game. Yeah yeah yeah the Miser form. It's what I mentioned at the beginning it's called Miser because it's sort of a nasty kind of game. As far as I what I've read there is no theory it's just in general very difficult to understand how to play it efficiently. So it's a completely different story. Well it's an impartial game with a different way of playing it and the theory that we discuss somehow doesn't seem to say very much for that case. So the I'm repeating the question so that we can hear in the video the only the person who starts is the one has a strategy to win. Well it's like what we what we did right you had a chance to win but you didn't know how. So I took advantage of that and won. If both know the strategy and computed these NMP things before coming to play then they should be able to win if they don't make a mistake. So the first one wins with having done the homework. Well sorry let's be clear if this initial stage of the game is a P position then the first person that plays cannot win right so it depends on what the position you're facing. If you see a P and it's your turn you're likely to lose if the other person know what they're doing. If you have an N then you can win if you know what you're doing. OK thank you very much. See you in October.