Generalizing a problem can make the solution simpler or more complicated, and it’s often hard to predict which beforehand. Here’s a mini-example of a puzzle and four generalizations which alternately make it simpler or more complicated.
Warning: The solutions are given right after the puzzles. If you want to think about them, cover the screen.
Puzzle: There are 10 prisoners labeled . A malicious warden puts a black or white hat on each. Prisoner can see prisoner ‘s hat iff . The warden has each prisoner guess the hat color on their head, in order starting from prisoner 1. The prisoners can hear previous guesses.
If a prisoner guesses right, they are freed, otherwise they are sent back to jail. Given that the prisoners can strategize as a group beforehand, for how many prisoners can they guarantee freedom in the worst case?
It turns out that the prisoners can guarantee the freedom of all prisoners except prisoner 1: Prisoner 1 first counts the number of black hats, then guesses black if it’s even and white if it’s odd. Now prisoner 2 knows their hat color, since they heard prisoner 1’s guess and they can count the number of black hats they see. Once prisoner 2 guesses correctly, prisoner 3 can guess correctly using prisoner 1 and 2’s answer, and so forth.
Generalization 1:What if there are 3 hat colors? What if there are hat colors? What if the hat colors are drawn from an arbitrary, possibly infinite set ?
This generalization makes the solution simpler, since it reveals something about what was going on in the first solution.
As long as the prisoners can put a group structure on the hat colors, they can run the same strategy as before: Player 1 adds up all the colors and announces that. Each subsequent player adds up all the colors they can see and the correct guesses, and subtracts that from the sum that player 1 announced.
Generalization 2: What if , i.e., there are infinitely many prisoners, arranged like ?
The solution to this generalization makes things more complicated: it uses a trick which is not related to the previous problems, and which is not clear how to generalize.
It turns out there is still a strategy to free all but the first prisoner.
Here’s the new trick: Consider the set of all possible assignments of hat colors to prisoners. Let for iff agrees with for all but finitely many prisoners. This is an equivalence relation. Beforehand, the prisoners choose a representative from each equivalence class (this requires the axiom of choice).
Since each prisoner can see all but finitely many of the other prisoner’s hats, each prisoner knows which equivalence class they’re in. Then the solution is similar to before: The first prisoner adds up the finitely many differences between the hat colors and the chosen representative, and the subsequent ones can then all correctly deduce their own hat color.
Generalization 3: What if is an arbitrary ordinal? What if is an arbitrary linear ordering?
This solution makes things simpler, as it reveals what was going on in the previous solution. This problem was solved by Chris Hardin and Alan Taylor.
The answer is that, for an arbitrary linear order, the prisoners have a strategy that does not use communication (i.e., nobody can hear anyone else’s guess) and guarantees that the set of prisoners who guess wrong does not have an infinite ascending chain.
If is an ordinal, this guarantees that is finite, and then the prisoners can use communication to save all but the first prisoner. If is the reals, then this guarantees that they can free all prisoners except those in a set of measure zero.
The solution is surprisingly simple. The prisoners agree beforehand on a well-ordering of the set of assignments of hat colors to prisoners, then each prisoner takes the -least assignment consistent with what they can see, and guesses the hat color they have in that assignment.
As an exercise, try showing that an infinite ascending sequence of wrong guesses would translate into an infinite descending sequence of hat color assignments, and thus contradict well-ordering.
Generalization 4: What if is just a relation, not necessarily transitive?
Chris Hardin and Alan Taylor considered this generalization in this paper. It turns out that things become complicated again.
For example, suddenly the number of different hat colors matters. Hardin and Taylor prove the following striking theorem:
Theorem: Suppose the prisoners are labeled and that each even can see all higher-numbered odds and each odd can see all higher-numbered evens. Suppose that no prisoner can hear anyone else’s guess. Then:
- If there are 2 hat colors, the prisoners have a strategy guaranteed to save infinitely many prisoners.
- If there are hat colors, the prisoners have no strategy guaranteed to save anybody.
- If there are hat colors, whether or not the prisoners have a strategy that can save anybody is independent of ZFC.