Slashdot Mirror


Solving Feynman's Unsolved Puzzle?

An anonymous reader asks: "In The Feynman Lectures on Computation, Richard Feynman poses an interesting little puzzle involving the synchronization of finite state machines acting as generals and soldiers. While he was able to find an answer to the problem, the minimum time solution apparently eluded him, and he ended his description of the puzzle with the following Fermat-like declaration: 'Somebody has actually found a solution with this minimum time. That is very difficult though, and you should not be so ambitious. It is a nice problem, however, and I often spend time on airplanes trying to figure it out. I haven't cracked it yet.' My best attempt performs at about 3N, not quite the minimum time of 2N-2. So I'm asking Slashdot: Has anyone ever come across the minimum time solution to this puzzle? Or maybe someone here can figure it out!"

"Here is the full description of the problem, in Feynman's own words. Please remember that these are finite state machines, so you can't use any methods that involve counting the number of soldiers or assigning a number to each soldier.

Problem 3.4: Before turning to Turing machines, I will introduce you to a nice FSM problem that you might like to think about. It is called the 'Firing Squad' problem. We have an arbitrarily long line of identical finite state machines that I call 'soldiers'. Let us say there are N of them. At one end of the line is a 'general', another FSM. Here is what happens. The general shouts 'Fire'. The puzzle is to get all of the soldiers to fire simultaneously, in the shortest possible time, subject to the following constraints: firstly, time goes in units; secondly, the state of each FSM at time T+1 can only depend on the state of its next-door neighbors at time T; thirdly, the method you come up with must be independent of N, the number of soldiers. At the beginning, each FSM is quiescent. Then the general spits out a pulse, 'fire', and this acts as an input for the soldier immediately next to him. This soldier reacts as in some way, enters a new state, and this in turn affects the soldier next to him and so on down the line. All the soldiers interact in some way, yack yack yack, and at some point they become synchronized and spit out a pulse representing their 'firing'. (The general, incidentally, does nothing on his own initiative after starting things off.)

There are different ways of doing this, and the time between the general issuing his order and the soldiers firing is usually found to be between 3N and 8N. It is possible to prove that the soldiers cannot fire earlier than T=2N-2 since there would not be enough time for all the required information to move around. Somebody has actually found a solution with this minimum time. That is very difficult though, and you should not be so ambitious. It is a nice problem, however, and I often spend time on airplanes trying to figure it out. I haven't cracked it yet."

27 of 90 comments (clear)

  1. I'm no math wiz by iq+in+binary · · Score: 2, Insightful

    Define a straight line.....

    Seriously, the straight line might just be the solution to that problem.

    That thought just popped up in my head, feel free to flame me for being open.

    --
    Of all the Universal Constants, here's one I know: Nice guys finish last ;)
  2. A new kind of science by Anonymous Coward · · Score: 5, Interesting

    Stephen Wolfram's "A New Kind of Science" addresses this puzzle with cellular automata. I remember hearing about it at a lecture at CMU. If my memory serves me right, he has found a solution and it is contained inside his book. You might try looking there.

    1. Re:A new kind of science by dillon_rinker · · Score: 2

      What's the difference between cellular automata and finite state machines? Isn't the former just a whole bunch of the latter?

    2. Re:A new kind of science by Mr.+Slippery · · Score: 2, Insightful
      Stephen Wolfram's "A New Kind of Science" addresses this puzzle with cellular automata.

      Cellular automata are exactly what this problem is asking about! A CA is a bunch of FSMs hooked together. More precisely, a quick Googling says:

      On a regular lattice (repeated structure of points have the same kind of neighborhood) one puts a finite-state machine at each point. The input to the machine is the states of all machines in its neighborhood. The behaviour is to change its state based in a determined way, as a function of the states of its neighbors and its own state. The states of all machines in the lattice are updated synchronously (simultaneously).
      --
      Tom Swiss | the infamous tms | my blog
      You cannot wash away blood with blood
    3. Re:A new kind of science by extremely · · Score: 2

      More concisely, CA are a limited group of identical FSMs whos inputs are the current states of their spatial neighbors.

      --

      $you = new YOU;
      honk() if $you->love(perl)

    4. Re:A new kind of science by Paradise+Pete · · Score: 2, Funny
      (someone correct me if I'm wrong)

      This is Slashdot. You don't have to write that part.

    5. Re:A new kind of science by DrLudicrous · · Score: 2

      I have this book- where might I find the treatment of this particular problem? Could someone at least give a chapter, if not page numbers?

  3. An optimum solution ... by Xner · · Score: 3, Informative
    A certain "A. Walkman" claims to have found the optimum solution in 1966, and published it in "Information and Control":

    Waksman, A. An optimum solution to the firing squad synchronization problem. Information and Control 9 (1966), 66--78.

    Unfortunately, the article does not seem to be available online.
    If anyone decides to take a quick trip down to the library, I would be delighted if they could share the answer.

    --
    Pathman, Free (as in GPL) 3D Pac Man
    1. Re:An optimum solution ... by dillon_rinker · · Score: 5, Informative

      You might be looking for this. It's referenced elsewhere in this discussion, so this is technically redundant, but I thought it'd be useful to have the link handy to this particular post.

  4. isn't this the same as by oliverthered · · Score: 2

    The prisoners and the light bulb (which I can't quite remember).
    Where the prisoners get released after each one has switched the light on.
    You get a best of 2n-2 for this
    2n for switching on and off and -2 because of the first and last prisoner.

    The worst case could be infinate.

    --
    thank God the internet isn't a human right.
  5. Solutions by Anonymous Coward · · Score: 4, Informative
  6. The Prisoners and the Light by Xner · · Score: 2, Informative
    If you don't know the puzzle in question (i didn't), here it is:
    100 Prisoners and a Light Bulb There are 100 prisoners, each kept in their own isolated cell. Each day one prisoner is chosen at random and taken into a central room where there is a light. The light is either ON or OFF. The prisoner may view the light and turn it on or off if they like, before being returned to their cell. The prisoner may also guess that all the prisoners have been into the exercise room at some time so far. If they are right then all go free. If they are wrong then everyone is shot. The prisoners are allowed to confer before being imprisoned, but may not communicate once in prison. (You may assume that the light starts OFF) Can you find an algorithm which garauntees release of the prisoners eventually? How many days do you expect to wait for the prisoners to be released? Find an algorithm which has the smallest number of expected days until the prisoners are released. Do this for every possible number of prisoners.
    Thanks to procrastinating.org
    --
    Pathman, Free (as in GPL) 3D Pac Man
    1. Re:The Prisoners and the Light by roju · · Score: 2

      The way the problem is worded, it's impossible to come up with an expected number of days.

      To quote, "Each day one prisoner is chosen at random [...]"
      If the same prisoner happened to be chosen at random EVERY TIME then the prisoners would never be released. Now, the odds of that happening to infinity are 0, but there is a chance that it could happen until the maximum age of the prisoners. It's even more likely that every prisoner gets randomly selected except for one, until they all die.

      To make it possible, we have to assume that each prisoner will only be picked again after every other prisoner has. Perhaps we just shuffle the prisoners into a random order, and loop it. But then the prisoner can just wait until selected again, and then he'll know. Unless we assume that they're all selected before looping back, but that the prisoners don't know that.

      Is that last condition necessary for solving the problem without making it trivial, or did I make a mistake somewhere?

  7. Surely You're Joking by Tuxinatorium · · Score: 3, Funny

    Mr. Feynman!

  8. Re:probably wrong by dmorin · · Score: 4, Informative

    Finite state machines are not allowed to have counters, or do conditional logic (you need a Turing machine for that). At least, that is a condition I understood to be correct in the problem. Otherwise you're right, it is a little easy.

  9. Re:probably wrong by spencerogden · · Score: 2

    The problem with this is that these are finitestate machines, and the problem stated that the solution cannot depend on N. So to implement a counter in a FSM you need at least as many states as the number you need to count to. This means your FSMs change depending on N.

  10. Solutions by cdrudge · · Score: 5, Informative

    For those people wondering about what the 3n solution is, here is a page that describes it: Firing Squad Solution. A decent diagram as to the firing order is here. The page also links to a description about the 2N-2 solution, but claims that it is buggy and only works in certian Ns, not for all values of N.

  11. Re:Conditional logic by dmorin · · Score: 4, Insightful
    You can do conditional logic in FSM's (my statement was a little too broad), you just have to plan it out ahead of time. Base it on what you know. The only communication you have with N-1 or N+1 is the pulse they send you. As far as I know, an FSM isn't even allowed to have a state called "Waiting for pulse" which then turns into a "If pulse is type 1 go here, else go here" node. Instead you have to put yourself into "Waiting for pulse type 2" state, and then when a pulse comes in, you have toa ssume that's what you got. So you have to know ahead of time what state to put yourself in, you can't be surprised by anything.

    This is why this is such a good problem -- because a giant FSM has the overlying assumption that there are no unknowns, but the problem definition seems to have an unknown in N. It's not really unknown once the system is running, though. The problem is just to build the smaller pieces in such a way that when stuck together, they work correctly regardless of what N is. That's different from saying "they work correctly *because* they know what N is, or can otherwise predict it."

  12. Links to several solutions by Linux_ho · · Score: 5, Informative

    Can be found on this page

    --
    include $sig;
    1;
  13. I have a solution... by i_am_nitrogen · · Score: 4, Funny

    But unfortunately it is too large to be contained in this margin.

    1. Re:I have a solution... by StandardDeviant · · Score: 2

      I think I have developed a more concise representation using a perl one-liner, but it is too noisy to be accepted by the lameness filter.




      ;-)

  14. The relationship between FSMs and CAs by LionMage · · Score: 3, Informative

    I did my Bachelor's Thesis on cellular automata and how they can be used to model physical systems. While it's true that any cell's neighbors can provide inputs to a cell's finite state machine, the "output states" can be anything. You aren't limited to a cell being "alive" or "dead." In many CA programs, a given cell's state is often represented by color.

    I've seen many 3- and 4-state CA systems that have been simulated. I've also seen many CA systems with widely divergent definitions of what a "neighbor" is. (The most common cases are where the neighbor is a cell adjacent on one of the four cardinal directions, or where the neighbor is a cell on one of the eight adjacent squares. This assumes a rectilinear or chessboard space.)

    Another error in your description is the statement that cellular automata are a bunch of specialized finite state machines. This implies that each cell could be running a different "program." The truth is, most if not all CA systems run the same "program" on every cell, in lockstep. In other words, cellular automata are a special case of SIMD processing. (I suppose it's possible to construct a MIMD example of CA, but then you run into the problem of how you assign your initial conditions -- i.e., not only do you need to assign an initial state to each cell, but you also need to assign a "program" to each cell.)

  15. Wow! by Hubert_Shrump · · Score: 3, Funny

    I didn't know we could also ask Slashdot stuff that may not even have an answer! This is awesome!

    Do you feel the community, people? Because I am totally feeling it right now.

    There are so many things I'd like to know...

    (waits for the inevitible)

    --
    Keep your packets off my GNU/Girlfriend!
  16. Feeling short by redtail1 · · Score: 4, Funny

    To loosely paraphrase Douglas Adams, I love listening to the sound of stories like these as they whoosh over my head.

  17. Re:Hmm, I tried by dubious9 · · Score: 2

    Reread the problem. The solution has to be independant of N. The same "soldier" should work wether there is 100 or 1000 or them. Thus you can't have a counter dependant on N. BTW where do you go that you don't study FSMs in digital logic, or design classes?

    --
    Why, o why must the sky fall when I've learned to fly?
  18. Re:thoughts by dubious9 · · Score: 2

    as it would have either a 0(no function or no action) or a 1(action) state,

    Why do you assume that there are only two states in the state machine?

    N+1, N for the number of soldiers as the second soldier would of coarse fire as a result of the first soldier fireing and etc, and the general would have a time of 1 to give the order.

    The problem stipulates that all fire at the same time.

    now if the soldiers had logic to decide to "ass it on" AND memory and logic to calculate time decimation and N, then 2N-2

    FSMs only have if-then relationships. They don't have any "memory" to store anything, they only tell you what the next state is going to be based on some input. Nothing about the FSM changes during runtime, thus they can't store arbitrary values.

    Also, I don't follow your logic for saying 2N-2 would be the only solution. Do you actually understand the problem?

    --
    Why, o why must the sky fall when I've learned to fly?
  19. Re:probably wrong by BitterOak · · Score: 2
    well, I am quite sure, that this is the wrong answer, since it is way too simple, but could anybody explain, what exactly is wrong with it:

    Actually, your solution would be quite correct if you knew in advance the maximum number of soldiers that are allowed.

    Contrary to what others have said, you can implement counters and conditional logic in FSMs, but in order for it to be a finite state machine, you must specify in the design of the FSM exactly how many states there are as well as the transition rules. Now each possible value for a counter is a separate state, so they must be enumerated in advance. Your soldiers would have 2k+1 states where k is the maximum value allowed for the counter. There is the initial wait state, plus k states after recieving the first message and waiting to pass it along to the next soldier, plus k decrement states.

    Now, the total number of soldiers must be finite, but unlimited. If you design your soldiers with k counter states, what if there are k+1 soldiers? Then your solution would fail.

    So, if the problem were modified so that the maximum possible number of soldiers were specified in advance, then your solution would be a correct minimum-time solution. But if no such maximum is specified, then the solution must be more complicated.

    --
    If I can be modded down for being a troll, can I be modded up for being an orc, or a balrog?