17 ms·
The Firing Squad Problem
- snake_plissken 13y agoI came here hoping to encounter a rousing debate on why we should use the firing squad for all executions, but this is much more interesting.
- saraid216 13y agoThat does say something about how political HN has become.
- eru 13y agoThis is a nice one to solve for yourself. The two-dimensional (and higher) problems are still research material.
- tzs 13y agoI assume that it is research material if you are trying to find the solution with the minimal number of states or the fastest sync time or something like that? The two (or higher) dimensional problem if you aren't requiring some kind of optimal or minimal solution is a trivial extension of the one dimensional problem. E.g., for two dimensions, you essentially do the one dimensional solution along the top row to sync up all the elements there, and then they simultaneously start the one dimensional solution on the columns.
- eru 13y agoYes, I was talking about solutions with special properties, like eg being optimal or minimal in some sense.
- toufka 13y agoIt's curious - in biology here we see similar problems solved in 3D, but it's not always clear how it's solved. Take the first few divisions during gastrulation [1] and notice that every cell divides synchronously for the first few divisions even though no single signal should be able to propagate from end to end that fast. And in other 3D environments like the sphere of cells in breast tissue you have similar synchronies that must be achieved in an environment that does not allow for rapid signal exchange (such an environment [2]). [1] https://www.youtube.com/watch?v=4La78WtK4n8 https://www.youtube.com/watch?v=4La78WtK4n8 [2] https://www.youtube.com/watch?v=3W10ywd_s6w https://www.youtube.com/watch?v=3W10ywd_s6w
- deleted 13y ago[deleted]
- e12e 13y agoIt would a appear a visual cue by the target would be superior... propagates to all soldiers at the speed of light, assuming normal rifles (range etc), all soldiers are likely to receive the signal at what for practical purposes are the same time -- the signal might be created by way of a mirror reflecting on the wall, so doesn't require any special technology, and can be projected almost instantaneously ... sadly such a practical solution makes for very a trivial fsm...
- barrkel 13y agoOf course, that's not the point. The firing squad metaphor is just to describe the problem of coordinating a synchronous activity given a linear non-zero-time peer to peer communication mechanism.
- RyanZAG 13y agoNot necesserily, it's still good to realize that there would be a more efficient solution. This applies in the real world too: you might be working out the best way to notify servers of an event through P2P, but it may be better to simply notify those servers in some broadcast pattern. (The idea of a mirror to notify all soldiers at once would be a broadcast pattern)
- judk 13y agoNetworks do not have the same physics/geometry as the vacuum of space, latency cannot be assumed to be 0.
- jerf 13y agoThe reason why latency in a network can not be zero is the geometry of space. In the real universe the only possible zero-latency (macroscopic) connection is the one that travels 0 distance.
- pfarrell 13y agoFor n large enough, this visual based solution would not suffice. Light based communication is the fastest on the universe but not instantaneous. Imagine there exists a line of soldiers, 96 million miles long,... -Or- Imagine there exist n datacenters which need to coordinate an action with nanosecond accuracy and are connected by fiber optic cable...
- ChuckMcM 13y agoIts interesting to see people get stuck on the "Firing Squad" aspect of it. There is an insight there about communicating through metaphor effectively. As a synchronization problem this one was a lot of fun, I too encountered it in the Feynman book and later used variants of it in interviewing folks for Google. Basically once you get into the realm of distribution the ability to get large groups of programs working together introduces a lot of complexity into an otherwise straightforward problem space. An interesting variant is that you create a line of students. The teacher asks them to form a line at the door with the tallest student in front and the shortest in the back. How can any given student know its there turn to join the line at the door?
- granfalloon 13y agoI'm assuming that when it says a "fixed number of states," it means that the number of states can't be tied to the number of soldiers in the line? (e.g., a five state solution would have to work for any number of soliders)
- granfalloon 13y agoRealized my question may have come across as rhetorical, but I really am looking for clarification on the rules!
- BlackDeath3 13y ago>Assuming that there is a fixed number of states, regardless of how many soldiers there are in the line... I think that this line may be your best indication. How exactly should you interpret this sentence? I don't know!
- algorias 13y agoYes you have a constant number of states at your disposal. Otherwise, there is a trivial solution that takes n or so time, matching the theoretical lower bound (imposed by the "speed of light" for information propagation in this kind of automaton), rendering the problem thoroughly uninteresting.
- judk 13y agoIt is a bit distracting to place a theoretical problem in an unnecessarily morbid context. We don't have to be dark to be cool. How about a "cheerleader coordination problem" or the "Sing Happy Birthday problem"?
- philwelch 13y agoThat's a decent concern troll. I give you 6 out of 10.
- jmount 13y agoI guess you could go back to 1957 and lecture John Myhill on this, or we could all just ignore the academic priority and rename the problem as you like and after you. For some problems with obvious racist or sexist "jokes" we do need to rename (and the original "jokesters" don't really deserve or respect for their original naming). But is this one really such a problem?
- cordite 13y agoWhy not with guns that put out happy birthday / surprise flags? Like in cartoons!
- nsxwolf 13y agoThose cartoons are now considered offensive.
- packetslave 13y ago
- judk 13y agoThis is one of those problems where the illustration is severely misleading from the intended theoretical problem. The problem assumes that all nodes share a synchronized time step, but do not have a clock, and only communicate by trading notes, which is an incredibly awkward assumption. The problem works better without the title and metaphor. For example, a much better metaphor would be schoolchildren passing notes among neighbors every time the teacher turns their back, coordinating a simultaneous outburst.
- jgrahamc 13y agoIn Hillis' book the clock is provided by a military drummer beating time on a drum.
- thaumasiotes 13y agoThat's an unfortunate metaphor; it completely spoils the problem. Just have the drummer give the signal to fire, and all the soldiers will hear him simultaneously.
- chmike 13y agoI still don't get it because for me the minimal time is n. The general pass a note with the value n to the firts squad, which decrease it by one and pass it to the next squad, etc. If passing the note to the next squad is performed at each clock beat and each suqad decrements the value he got, then they will all reach 0 at the same time. I guess I'm missing some constrains because I don't see why I don't get 2n-2 as minimal time.
- gus_massa 13y agoIIUC the idea is that they want a fixed number of states, that doesn’t depend of n. Another idea is that nobody knows the exact value of n, so the first task of the soldiers is to count themselves. Then the idea is that a signal propagates form one end of the line to the other end and back, and the time is ~2n. Using two signals that propagate with different velocities they can “count” with a finite number of states. For example, see the fist graphic “Anonymous, 3n time, 160 soldiers, 13 states” in http://www-cs-faculty.stanford.edu/~eroberts/courses/soco/projects/2004-05/automata-theory/problem.html#comparison http://www-cs-faculty.stanford.edu/~eroberts/courses/soco/pr... . They first find the middle of the line, and hen they continue doing binary partitions until all the partitions have length 1, and then they fire. The final step is local, each one has to check that they local partition has length 1 and the nearby partitions have length 1, but the binary split is responsible for making all the partitions of roughly the same size.
- grogenaut 13y agoTurn on a light above the target's head. Shoot on target. Demote general for wasting everyone time.
- oh_sigh 13y agoThen the person who is the closest to the light will know that he is the one who killed the individual.
- jordan0day 13y agoArrange the soldiers in an arc (< 180 degrees, hopefully) around the target, rather than a line. Now each soldier is exactly the same distance from the target, and will see the light turn on at exactly the same time.
- CamperBob2 13y agoNo, the way firing squads work is that a randomly-chosen member fires a blank. No one can know for certain if they delivered a lethal round.
- biot 13y agoWhile you may not know if your rifle has a blank, you'll definitely know if your rifle fired a blank due to the different force in recoil because you're accelerating the mass of gunpowder+lead vs gunpowder alone.
- CamperBob2 13y agoNot sure how true that is. How much recoil force is contributed by the bullet versus the gas that propels it?
- e12e 13y ago> Then the person who is the closest to the light will know that he is the one who killed the individual. Apart from the possibility of arranging those firing in an arch (and providing a random selection with blanks[1) -- how on earth would a "soldier" know that? Anyone close enough to see the light above the curvature of the earth/within rifle range would effectively see the light at the same time (just based on the latency of the nervous system)... [1] It seems to me that it would be much easier to tell if you'd fired a blank -- as the recoil would feel different?
- acadien 13y agoFeynman discusses this problem in his "Theory of Computation" book. If I remember correctly, its actually part of a joke he plays on the reader too. In one of the earlier chapters he brings up the problem and then assigns it to the reader as homework they should complete before moving on. I spent maybe a week or two on that problem, discussed it with coworkers... and we came up with nothing. So I gave up and continued reading. Then somewhere in the 4th or 5th Chapter he says something like: Oh I hope you had fun with the Firing Squad Problem, I still work on it from time to time and hope to come up with a solution myself one day. Facepalm. Edit: Here is a link to the book, its enjoyable for experts and laymen alike. http://www.amazon.com/Feynman-Lectures-On-Computation-Richard/dp/0738202967/ref=sr_1_1?ie=UTF8&qid=1391792191&sr=8-1&keywords=theory+of+computation+feynman http://www.amazon.com/Feynman-Lectures-On-Computation-Richar...
- Casseres 13y agoWhen you keep presenting a supposedly unsolvable problem to people who don't know it, then you might get lucky. George Dantzig was one such person. He arrived late to class, saw some problems on the board, assumed they were homework, and solved them. He wasn't constrained by the common thought that these were "unsolvable".
- georgecmu 13y agoThey were not "unsolvable", they were simply not solved yet (at the time Dantzig saw them on the blackboard). http://www.snopes.com/college/homework/unsolvable.asp http://www.snopes.com/college/homework/unsolvable.asp
- javajosh 13y agoThis is an interesting theory problem, but it might be clearer to talk about shooters at a firing range, separated by partitions such that they can each only talk to their neighbors. The barriers eliminates the trivial solution of the shout: "Fire on the count of 3!" that common sense would provide. The simplest solution would be to establish a clock, because with a clock you can say "Fire at 1pm exactly!". But even this is interesting because it requires shooters to know where they are in the line in order to take into account any signal propogation delay. If each person takes 1s to repeat a message that they hear, then it takes n seconds to go down the line, and each shooter must know how to compensate for that delay. E.g. the first shooter hears "it's noon", the next shooter hears "it's noon" but knows that he's 1s away from the source, and can calculate that the time is actually 12:01, the next shooter knows it's 12:02 etc. They could synchronize clocks, specify a time "shoot at 1pm!" and get the job done. But what if we take away their clocks? This is where my intuition fails me, because I don't see how the problem can be solved without clocks. If you don't have clocks, you need to somehow get a signal to every shooter simultaneously, which I think is theoretically impossible, since without a clock the shooter cannot execute instructions on their own. Which probably means I don't fully understand the scenario :)
- dkokelley 13y agoI think the purpose is to solve the scenario where each node has a perfect internal clock, but no external reference clock. A rough solution is to initiate a count from the origin, starting from 0. Each node hears the previous neighbor's count, increments it by 1 and sounds off. When the end node is reached, it knows how far the signal propagated. At this point a reverse count is initiated, terminating in 0 at the origin. Each node along the way back hears the adjacent node begin its countdown, and starts its own countdown from its relative position. The return signal reaches the origin node just as the remainder of the nodes reach 0, and all node execute simultaneously on 0 (with appropriate modification for any fencepost problems). No external reference clock is required, and assuming each node counts at exactly the same rate, all nodes act in unison.
- xenophanes 13y agothe problem is with no clocks, and is possible. you also can't count the soldiers because you don't have unlimited memory (states), so you might run out of memory (states) to count in.
- tzs 13y agoA few years ago, a friend asked me if I had any interesting problems he and a coworker of his could work on for fun. One of the problems I gave him was this (although I presented it as a state machine problem, not a firing square problem). In a burst of over-enthusiasm, I also quickly hacked together a simple state machine simulator that he and his coworker could use to test their proposed solution(s). The problem specification, state machine simulator, and documentation are available here: https://github.com/tzs/problems-state-machine-sync https://github.com/tzs/problems-state-machine-sync I told them I would consider it solved if they could describe the algorithm. They did not need to actually specify fully working state machines that dealt with all the details. Much to my surprise, especially considering that my friend had not studied computer science beyond what was given in a high school programming class, not only did they solve the problem in a few days, they produced fully working state machines. Another puzzle I gave them consisted of several images that show the tracks of a bicycle. One of the wheels is leaving a red track and one a blue track (color assignment was random for each image). Their task: determine in each image whether the bike was traveling left to right or right to left. Here are the images: http://imgur.com/a/hv0b0 http://imgur.com/a/hv0b0 It was also randomly determined for each image whether to draw the front wheel track first or rear wheel track first, so you cannot deduce anything from which track appears to be on top when they cross.
- sys_argv 13y agoOk. I'm stumped. Could you give me a hint
- tzs 13y agoIf you want a hint for the firing squad, start out by limiting the number of participants to powers of two, and think recursively. If you want a hint for the bicycle problem, think about tangents.
- chmike 13y agoAnyone who drives a bycicle knows that the rear wheel follows a smooth path compared to the front wheel. So this image is easy. I guess there might be more tricky images. A straight line for instance ;)
- sramsay 13y ago> At every count, each soldier looks at their neighbors, considers what they themselves were already doing, and decides what to do next, completely according to what they see. Anyone else think this is an incredibly ugly problem statement? It's like they thought firing squads were cool and tried to shoehorn the problem into it any way they could.
- xenophanes 13y agoFeynman gave the firing squad problem in his lectures on computation, so it can't be a modern shoehorn.