 Well, welcome everyone, it's a pleasure for me to introduce Professor Fernando Llegas. He will talk about Bled, a mathematical puzzle. Thank you. So, this is a puzzle that I worked on many years ago with two of my colleagues at the time and UT Austin, Lorenzo Sadun and Felipe Voloch. And if you are worried or curious about the name, you see there my daughter Malena is being thanked for providing the name and it's a complicated story why that happened. This puzzle, we were pleased with my colleagues at the time, made it to this website, puzzles.com. They even made this little logo, but anyway, what I'd like to tell you is some mathematics that's behind it. This was part of a course that I taught in Austin where the, with the excuse of discussing various puzzles, I discussed some mathematics behind them. So this is one, probably the more sophisticated in the sense of what mathematics it involves. So let me first tell you what the puzzle is then. You start with a sequence of A pairs A and B arranged in a circle, say N is the number of A's and B's, going to be an even number. And this is the starting configuration and there's two rules that you can use. If you see a pattern of the form A, B, A, then you can change it to the pattern B, A, B. And conversely, if you see the pattern B, A, B, you can convert it to, to change it to the, to the A, to A, B, A. And the, so this is the allowable moves and the goal is to maximize the number of A's or maximize the number of B's or maximize, minimize either one because it's, it's all very symmetrical. And this is a clear direction in which goes towards your goal. If you see a pattern of the form B, A, B, this has only one A and if you change it by the pattern A, B, A, now you have two A's. So this direction is the, is the greedy direction that will increase the number of A's. And this puzzle, I don't think or claim to be particularly interesting in itself. I mean, and if the only interesting I have, if you actually try it on your own a little bit and see what is behind it, but unfortunately then that would mean that I couldn't give the talk. So I'll spoil the little fun there might be and tell you what's behind it myself. But it's an illustration of this problem that greed is not the answer, typically. Because if we have an implementation that I, I'm not sure I'll be able to show you right now, but so an implementation just to illustrate has N equals 28, so you, you click, so one way to think of this is that you can click on such a pattern on the B and it converts it into this or you click on this pattern on the A and it gets you the other one. So that's an implementation of this idea. And if you're greedy, you only get the number of A's to go to 21, but in fact the maximum possible is 23. So this, let me just say a little bit about the, the type of problem. Okay so first, first of all, I don't know if you, if you seen, you must have seen something like this. This is peg solitaire and the, this is sort of a similar type of idea. So you can say that this puzzles are all involved replacing a pattern by another one following specific rules. So if you think of peg solitaire is, if you have this A's now correspond to two pegs in blue and B a blank. So you can move this peg over to the blank and take this blue one in the middle out. So it goes from B, A, A, B to B, B, A. But this, in this puzzle, you only go in one direction. You can't go back. Once you do a move, you're done. You can't undo it. And here the goal is also similar is to minimize the number of A's which would be the number of blue pegs and in this game you can actually achieve one. It's one of those things that I played this when I was a kid about 10 and I managed to be able to solve it. And then later on I got interested in this type of connection between mathematics and puzzles and I even had a book in John Conway of Cambridge is famous in many, many aspects and one of them is interesting this type of stuff. And as soon as he wrote a really nice book which I refused to read until I could solve the puzzle again and I just never could. So I don't know, progress it doesn't seem to always go with age. So in any case the issue here is we have a space of possibilities, yes? What is not allowed? You can only change this pattern to this one or backwards. In the other game you only find the sun correctly. You just do the puzzles the way the pegs, the way I illustrated. If you have two blues with a space ahead then you can move one peg over the other one and remove the one in the middle. That's all you can do. You can do it horizontally or vertically. And the idea is every time you do this you have one lead speg and you have to keep doing this and the goal is to get to just one peg at the end which of course you cannot take because there's no other move possible. And if you try this you'll quickly find out that to get to one peg is not completely trivial at all. So the general picture here is that we have some kind of space of configurations which is typically very big. In something like this I haven't been able to recall how many, I have computed how many of these configurations possible there were but it's some big number of states and we are sort of navigating through this to try to minimize some functions. So we try to minimize a function on a discrete space and that's a difficult problem. There's no calculus here to help us. So let me just say a little bit about the question of minimizing discrete functions which is again I view this as an excuse to discuss this topic. And when I first started with this puzzle I used this method to try to understand what was happening before we eventually found with my colleagues a solution. So this is in a sense unusual typically if you have a problem of this kind there wouldn't necessarily be a way to actually solve it completely which is what we have in this case which in a sense is the topic of the talk. But let me take a parenthesis and discuss very, very superficially this question of maximizing or let's say minimizing a discrete function. By that I mean I have a large discrete set and some function on that set that we want to find a minimum value of. So to just schematically let's think of the X variables which are the possibilities in our space. I think of it just to do a graph as a one dimensional thing but you should think of this as some big space and then we have a function which from the point of view physics would be energy so call it E and then the graph may look like this and what we're trying to do is find the minimum values or one minimum value let's say it's only one so we're trying to reach this point by moving in this space. So we don't really have much way to guide us as to you can't quite see as this is the minimum this is where we should be going. So let's say you start at some point or maybe the point is given to you and this is where you should start and so what we could do is so schematically let's think of the state that you're at X zero here then you make some move towards a neighboring point which you could do perhaps randomly and what you do is you compare the energy at the neighboring point and the energy at the point you were at and if the energy at the neighboring point is smaller than the one you're at then you're happy because that's a better point and so you take it it's typical this is one up one way to do it and now the question becomes what happens if you, if the point that you pick is actually worse well if you are greedy you always want to go down and you will only take it in this case and in this case you just don't take it and try a new one so what happens with that idea of greedy is that for example if you start here and you keep moving then you're gonna get stuck at this point so greedy may result in stuck at local minima. You take not a random point but a neighboring point the move you think of it as something that is sort of nearby yeah but even then yeah so yeah you should think that the moves is something that takes you reasonably close by you do a small modification of your problem like here you can have you sort of think of this is a huge circle they do a tiny modification you move to a neighboring configuration so the idea that comes from from physics is resulted in an algorithm in this in a sort of vague sense not not too specific got the name of simulated annealing so when you annealing is a process where you take a say a metal and you heat it to a high high temperature and then you let it cool very very slowly okay and so the heating kind of freeze the atoms to do whatever they want and the cooling kind of lets them sit and arrange themselves in a better way that they were before you heated it up very very simply explained so you do something similar here and the idea is okay we take it if we if we are have an advantage but if we have a disadvantage that looks like this is a bad thing to be doing you take it with a certain probability so in a certain sense you flip a coin and you say okay look this looks like a bad move but I'll take it anyway and so if you stuck at this local minima then if you allow yourself to take some steps in the sort of wrong direction maybe you will climb out of the local minima and fall in to the next one and so this is a very basic idea that resulted in a very useful very interesting algorithms to minimize discrete functions so as I said this is a tangent it's not quite how we going to discuss this puzzle but it was how I came up with some ideas about it so let me show you an example so this is an example so there is a probability and the probability you can the sophisticated way to think of this is that the probability will change with the iterations so you think of a of temperature as something that you have at your disposal in this in the sense of annealing so if you have very large temperature then basically you take anything you like you just go anywhere and if you cool off you then are becoming much more greedy if the temperature was zero you're totally greedy and you let the temperature kind of slowly low slow down so at first you basically move around randomly completely with any no control and then you slowly cool down so this is an example of this and here the energy is measured let me just say that what you will want to see at the end are black and white strips one next to each other because you measure whether the guys vertically are of your same color and the guys on the on the sides are the opposite color and so this wonderful simulation lets you do this and there's a cooling rate which is how is the temperature going to be slowly decreasing so we're going to see in this graph global energy this energy measure then it should be going down and we'll see the temperature starting at one and going down to zero okay well we didn't quite get white black white black strips but for many purposes that result is good enough no there's a probability involved in the temperature so the temperature there's a cooling rate here this is a cooling rate tells you how the temperature is going to change and here's the temperature we start at temperature one I haven't explained but it basically measures how good your configuration is by measuring what your vertical neighbors look like and how you horizontal neighbors look like so you so if if you if you were in exactly the position all white and black strips one next to each other the 10 the energy would be zero okay so we are in that kind of picture with with a met and with a measure that is that the only solution to it is this black and white strips one next to each other okay so it's I don't know exactly I don't want to get too much into it but some some sort of switching of of the colors of the neighbors some particular exchange of of white and black yeah the radius is is how far how around it are you supposed to I think it's just a swap of of black and white neighbors it precise neighbors I just wanted to show you the picture the one I get too much into the specifics of this example but anyway let's write again so this clearly doesn't look like white and black strips so we didn't we don't like this and what looks like a reasonably small amount of iterations it produces something that at least you probably can live with okay and you see how the energy has gone down to what looks like is not going to come down from that anymore yeah is what sorry yeah I mean I the talk is not about the system it's just I wanted to just uses an excuse to bring this up and hopefully it will entice you to to explore it on your own I mean you probably can teach it but others have seen it before so it's just that I want to put the the puzzle itself in the in a context but what we're gonna do now is something that sort of appeals at least to me mathematician of wanting precise answers that in this particular instance that I'm erasing we have a way to understand this minimum quite precisely and that's really the topic of the talk so what I'm gonna do then is and try to understand this maximization problem in in this bled puzzle by relating the question to something else so we started with this cycle of a's and b's but let me sort of cut it out and think of a string and now let's take w to be any string any string of word in a and b and I will associate to this a certain path in the plane so this will be a polygonal path z squared in the lattice and this also somehow has to do with physics and it was suggested to me by Harald Skarky and so what I'm going to do is describe the motion by this this a's and b's are going to be instructions for something to move in the plane apart I think of a particle moving in the plane and there'll be two variables and perversely the physicist is called q the position which I'll try to remember to use the right letters and p the momentum and there will be at any given time there'll be two two vectors that tell you where the particle is and what would be the next thing it would do and there's two ways that this will move there'll be an a and a b will will correspond to that if we do an a will be to actually move one step in the direction of the momentum and keep the momentum as it is and a b will be keep the position as it is and change the momentum already miss this up keep the position as it is and change the momentum by minus one unit of the position okay and so here's an implementation of this idea I will start my initial state would be that I start at the vector one zero I think I'll use row vectors so it's one zero and the momentum is zero one so you see the red arrow is the position and the blue arrow is the momentum so if I do an a I just moved in one one step in the direction of the blue arrow if I now do a b then I change my momentum vector by minus one unit of the position okay so it was up here and now is it was pointing up to here now it's pointing this way so if I do a and b and I repeat this these are vectors I have two vectors at every time two two two dimensional vectors and my moves are for a I change the red vector by one by adding one blue vector and in this case I change the blue vector by subtracting one red vector well they keep moving I start here and they'll be whatever they are we'll explore and see what what happens so let me do a and b and I'll iterate it that I have to put it here okay so this is what happens if you iterate a and b let's try a b b see I think maybe a a b so let's just get a sense of this so somebody give me a string some short string and iterate and see what we get a a a you're never turning right you have to use a b b is changing the velocities if you never turn this will just keep going up okay what else b a b one more a a b b that's yeah a b b so it's not always the case that this thing closes up yeah okay I'm gonna come back to this so then associated to a sequence a word in a b we have a path in the plane what we could do so to keep track of what's happening we let the matrix mk be the matrix where these are the rows we start with m zero as the initial state as the identity matrix and then doing a is nothing but multiplying by the matrix 1 1 0 1 and doing b multiplying by the matrix 1 0 minus 1 1 so you can call these the state matrices and the path that we see is the what we the queues are the positions so if we look at our matrices what we see are the the first rows are the positions but we also have the second rows which are the momentum and they move themselves and then their own copy of z squared so let's do an example let me do this so for example I can we can get something with five vertices to do a b a b a a b a b b a b b a b so so what we see is this so these are what we're seeing here the dots here correspond to the q vectors the positions but there is a corresponding picture for the piece and the piece we can read off by looking at the tangents so if I start here I mean there's some ambiguity what I start but say let's say we start here so the first vector is 1 0 or actually they start the same place so we the first vector is vertical so I have a 1 0 1 there then is horizontal to the left and you keep following this and you see that this is the path that the piece do so this is some path gamma and this is some path we can call the dual and they both come from projecting this path of matrices to the first row and the second row the key observation first key observation that will allow us to understand this minimum on this game is to notice the following if we look at the length of this path by which I mean how many dots there are on the path 5 and I look at the length of the dual there's 7 and 7 plus 5 is 12 and one of the theorems of math method theories of mathematics is that all the 12 are the same and in fact any path they do will have the same statement so any path that you construct out of following these rules will produce a dual path that has a number of dots in it which is complementary to 12 from the one you start so what's this what is the smallest path you can do how many is the smallest number of dots you could have is 3 yeah and the dual of this will have 9 which is the biggest you can have the dual will be we can get it this way oops missed up enjoy the time no I sort of been an a and then you get this big triangle so this is a theorem that we proved with Bjorn Poonen and maybe Don will recognize this 12 of having to do with the delta function he just talked spoke about a year about a half an hour ago the proof that we gave of the statement is in fact using the delta function of Ramanujan but the statement in general is the following if you count the number of points in the path plus the number of points in the dual you get 12 times the winding number of either one of them so by the one day number I mean how many times it goes around which could be any any integer we're moving always count a clockwise so what this amounts to is so what we see here so let me maybe you should write this pentagon again a b a b a b b a b so the word in question is in this example is a b a b b a b b a b so if we look at the a's those are exactly the five of them that's exactly the number of dots on the path gamma and the number of bees is 7 is the number of points on the dual is every time you do an a you change your position and that creates one more dot in your path and on the b side if you use a b you creating you changing the momentum exactly by adding one more point and so what this says is if you want something that close around only once you'll you will have to use 12 letters and so it's a theorem of Scott so what other properties I mean what kind of properties those these paths that we see they're not completely random things that we see so how would you characterize what these paths are that I get by playing this game this particular game this a and b story if they close they close once what about the area well it what is a little misleading is this looks like we're talking about an equidium problem but it's not an euclidean problem it's more than a hyperbolic problem and so things that are really the same in the sudden have will have will look very different because the group that we're using here is SL 2 z not not not preserving distances so what what the condition turns out to be is the gammas that we see contain a unique only the origin as a lattice point internal lattice point and it turns out this is almost caught that if in any dimension if you fix a polyhedron convex polyhedron with lattice points at the vertices and you you require that it has a certain number of number of points inside a positive number of points then there's finally many possible such polytopes up to the group of a change of variables so let me show you what happens in the case of two dimensions there's a 16 of them and this is these are all up to changes of coordinates so they may look like different if you look if you do this yourself or you do you look somewhere else but this is an example of this these are all distinct I think up to SL 2 and so these are all paths all the paths that contain exactly one interior point and you see there's a guy here with nine as the biggest guy and this the corresponding dual up in the top left corner which is the one that has exactly three points so how do you prove this theorem well I mean for when the number one you just check one by one which be a pretty silly proof and that's what I was my original proof is just noticed that this statement seemed to always hold now if you want to do this for a higher winding number of course then you have there'll be finally many for a given one number but that will not allow you to find a proof for all cases and so you'll have to do something else and and as I said the proof that we have in the paper with your opponent uses the eta function of that again okay so this will turn out to be the key ingredient to bound the maximum or the minimum number of a some bees you can have in this game so let me a sketch for you how that goes so what is the key fact well one other key fact recall that we had those matrices a and b there you can check for yourself very easily that the matrices a and b satisfy this so what will happen is that the paths that you get by using this rule in the game will look different but they will all lead to the same final state matrix and so this will allow us to get the bounce that I'm going to tell you now so the theorem is the following then suppose that gamma our path is eventually closed by which I mean that as we were trying to do some examples in this simulation you have a string and if you repeated a certain number of times it will give you a path that comes back exactly the same initial state both the momentum and the position are exactly the same so this as we saw an example not always happens and in fact if you start typing randomly a's and b's in this you will get past the do not close so suppose the gamma is eventually closed then the number of a's let's call la the number of a's in the path and the word that corresponds to the path and L the total number of letters is bounded above and below by 1 6 and 5 6 so this is for a but this is all very symmetrical so this and holds for b so this will put a limit on the possible number of a's that you can have because the path that we have in our game is a path that is eventually closed so note a b a b n times is eventually closed because a b done six times as we saw is closed that gives you a hexagon yeah so let's do it again so we do a b well let's iterate this six times okay so the pair a b repeated six times is closed so the pair a b is eventually closed and so the pair a b to the n or the n over 2 rather if I do this six times this is the same as a b to the 6 n over 2 times and a b to the 6 is closed so the path that we're talking about is closed is eventually closed so it will this statement will apply and it limits how many a's of b's you can have because any modification by the rule of the game as I said will change the path itself but it won't change the fact that he's eventually closed because the end point remains the same okay so let's let's see how we can prove that I'll come back to that let me let me first prove this well the final state matrix a word is a series of instructions so if you follow all of them there's a final state you know let me sketch the proof of this which is I like because it uses the geometry of this path I mean a priori we start with the game would seem like a completely discrete thing not connected to anything else but with this path business now it becomes something we can use some elementary geometry for so the first observation so let's let's say let's say that gamma itself is closed the idea then will be more or less the same and let v1 to vr be the vertices okay by vertex I mean a corner so in this case there's six but we saw squares other things so the number of vertices is not the same as the number of ASOB's in fact what is a corner a corner in this path is a place where instead of moving forward we decided to change the momentum so it has to correspond to a bee at least one bee so in fact the vertices correspond exactly to blocks of bees now let's look at the vertex so we're coming in from here coming out there and let's define the exterior angle to be the angle here and one small thing to convince yourself is that the sum of these angles is equal to what well if we went around one time it should be 2 pi if we went twice it would be 2 pi times 2 and so on it's 2 pi 2 pi times the winding number but by this theorem that I erased the winding number is the number of a's plus the number of bees divided by 12 so that means that this is pi times the length over 6 and on the other hand the number this theta's each angle is at most pi and each vertex corresponds to blocks of bees and each block of bee has to have at least a bee so this is majorized by pi and bee so we get that yeah so it's strictly bigger so we get that lb over l is bigger than 1 6 and now we do this symmetrically with this with the a's and you get that is less than 5 6 so it's just a quick idea but but the key thing is to use the geometry of this path to understand how many possible bees in this setting there can be because the bees correspond to vertices and vertices are where you turn and so there's an angle involved and there's a limitation for those angles anyway I understand it's quicker than it could have been but I want to get to to the final point so what I was saying before about being eventually closed is that so let me use a little notation so we have a word consisting of a's and b's so a word in in a a and b and we can let me define row of w to be the state matrix at the end if I were to do it in that thing I will look at the string and click as many times as these letters indicate and at the end I'll be somewhere with some red vector some blue vector that's my state matrix M yes that's what I do yes and then take the product yeah indeed yeah I just look at the string and now replace as Don says the letters by the matrices and that's take the product of all of those and that's indeed and so the point is that the this thing is the identity and there's a little bit of work to do but I think I'll skip it that if you modify so let's say w prime is a modification of w by the games rule then if one of them is eventually closed then so is the other so in the initial word w consists of a b a b a b that's eventually closed and so the theorem applies and because of this statement every other sequence that comes from having done a modification to the original game starting point is also eventually closed and therefore the theorem applies for it sorry yes in fact it is yes yes indeed yeah that's maybe even better clearly just because the matrices themselves satisfy the the rules of the game so in a certain sense if you think back to the original question I mean you can take this puzzle as being okay there's some configurations of that you're allowed to change by another one and you can imagine zillions of puzzles of this kind and this one happens to be analyzable in this form because this replacement rule is exactly something that is has is very tied to this particular geometry of this group and just I want to say just a couple last things what is the geometric meaning of doing the rule well let's just do a small the justice case a b a itself so we go up then we turn and then we go so an a b portion if we started from the beginning will look like this and the corresponding replacement a b a a b a b will be we first turn then we move and then we turn again so what happens is in general what you'll see is that one of the paths w might have a piece like this and w prime will have be replaced by that so one way to interpret what this rule of the game is is that in the path you can chop off a corner but the corner has to be such that there is no other lattice point involved and so I'll finish with this example should have done something with this so let's do a b b a b b a b a a so here's a an example and if we look just at the at the path there's only one corner we can chop off which is down here here every other corner will necessarily have either goes through the middle or something's wrong yeah that's all there is there's no other corner we can chop off without sort of including one extra lattice point and if we look at the at this at the string here there's only one string a b a that we can actually change to the b a b which is right here at the bottom no there should be only one is it where they can last no this one you cannot join to that one no but that's just a segment no I think I think this is the only one so let me do this let me replace the a b a by b a b now run it again and we get the same thing with the corner chopped off so if you look at these pictures what there's the greedy algorithm will be to always chop corners off what we would like to do is to get this to be as small as possible and what we found well maybe in the case of only one turn there's so few things that you don't really see it but if you add more you will not be able to chop it off to the smallest possible way by just always chop it in corners sometimes you have to add a corner which would be the inverse of this and to to cut a corner somewhere else so yeah so this was this puzzle that I wanted to discuss which I kind of think of it as a puzzle with a moral the greed doesn't always you should not have you should not cut corners good point but or you should cut the good corners and greed may not always lead you to what you want so thank you