Induction puzzles

Logic puzzle

One type of induction puzzle concerns the wearing of colored hats, where each person in a group can only see the color of those worn by others, and must work out the color of their own. Part of a series on

Puzzles

Types

|  Guessing

* Riddle
* Situation

Logic

* Dissection
* Induction
* Logic grid
* Self-reference

Mechanical

* Combination
* Construction
* Disentanglement
* Lock
* Go problems
* Folding
* Stick
* Tiling

* Tour
* Sliding
* Chess

Maze (Logic maze)

Word and Number

* Crossword
* Sudoku

Puzzle video games

* Mazes

Metapuzzles

Topics

* Brain teaser
* Dilemma
* Joke
* Optical illusion
* Packing problems
* Paradox
* Problem solving
* Puzzlehunt
* Syllogism
* Tale

Lists

* Impossible puzzles
* Maze video games
* Nikoli puzzle types
* Puzzle video games
* Puzzle topics

* v
* t
* e

Induction puzzles are logic puzzles, which are examples of multi-agent reasoning, where the solution evolves along with the principle of induction.[1][2]

A puzzle's scenario always involves multiple players with the same reasoning capability, who go through the same reasoning steps. According to the principle of induction, a solution to the simplest case makes the solution of the next complicated case obvious. Once the simplest case of the induction puzzle is solved, the whole puzzle is solved subsequently.

Typical tell-tale features of these puzzles include any puzzle in which each participant has a given piece of information (usually as common knowledge) about all other participants but not themselves. Also, usually, some kind of hint is given to suggest that the participants can trust each other's intelligence — they are capable of theory of mind (that "every participant knows modus ponens" is common knowledge).[3] Also, the inaction of a participant is a non-verbal communication of that participant's lack of knowledge, which then becomes common knowledge to all participants who observed the inaction.

The muddy children puzzle is the most frequently appearing induction puzzle in scientific literature on epistemic logic.[4][5][6] Muddy children puzzle is a variant of the well known wise men or cheating wives/husbands puzzles.[7]

Hat puzzles are induction puzzle variations that date back to as early as 1961.[8] In many variations, hat puzzles are described in the context of prisoners.[9][10] In other cases, hat puzzles are described in the context of wise men.[11][12]

## Muddy Children Puzzle

[edit]

### Description

[edit]

A group of attentive children is told that some of them have muddy faces. Each child can see the faces of the others, but cannot tell if his or her own face is muddy. The children are told that those with muddy faces must step forward, but any child with a clean face who steps forward will be punished. At the count of three, every child who believes that his or her face is muddy must step forward simultaneously; any child who signals to another in any way will be punished. If any child with a muddy face has not stepped forward, the process will be repeated.[4][5][13]

### Logical solution

[edit]

Assuming that each child has—and knows each of the others to have—perfect logic all children with muddy faces ( X {\displaystyle X} ) will step forward together on turn  X {\displaystyle X} . The children have different information, depending on whether their own face is muddy or not. Each member of  X {\displaystyle X} sees  X − 1 {\displaystyle X-1} muddy faces, and knows that those children will step forward on turn  X − 1 {\displaystyle X-1} if they are the only muddy faces. When that does not occur, each member of  X {\displaystyle X} knows that he or she is also a member of  X {\displaystyle X} , and steps forward on turn  X {\displaystyle X} . Each non-member of  X {\displaystyle X} sees  X {\displaystyle X} muddy faces, and will not expect anyone to step forward until at least turn  X {\displaystyle X} .

Assume there are two children, Alice and Bob, and that only Alice is muddy ( X = 1 {\displaystyle X=1} ). Alice knows that "some" children have muddy faces but that nobody else's face is muddy, meaning that her own face must be muddy and she steps forward on turn one. Bob, seeing Alice's muddy face, has no way of knowing on turn one if his own face is muddy or not until Alice steps forward (indicating that his own face must be clean). If both Alice and Bob are dirty ( X = 2 {\displaystyle X=2} ), each is in the position of Bob when  X = 1 {\displaystyle X=1} : neither can step forward on turn one. However, by turn two Bob knows that Alice must have seen that his face is muddy (because she did not step forward on turn one), and so he steps forward on turn two. Using the same logic, Alice also steps forward on turn two.

Assume that there is a third child, Charlie. If only Alice is muddy ( X = 1 {\displaystyle X=1} ), she will see no muddy faces and will step forward on turn one. If both Alice and Bob are muddy ( X = 2 {\displaystyle X=2} ), neither can step forward on turn one but each will know by turn two that the other saw a muddy face—which they can see is not Charlie's—so their own face must be muddy and both will step forward on turn two. Charlie, seeing two muddy faces, does not know on turn two whether his own face is muddy or not until Alice and Bob both step forward (indicating that his own face is clean). If all three are muddy ( X = 3 {\displaystyle X=3} ), each is in the position of Charlie when  X = 2 {\displaystyle X=2} : when two people fail to step forward on turn two, each knows that the other sees two muddy faces meaning that their own face must be muddy, and each steps forward on turn three.

It can be proven that  X {\displaystyle X} muddy children will step forward at turn  X {\displaystyle X} .[4][14]

### Game-theoretic solution

[edit]

Representation of Muddy Children Puzzle for two players in extensive form. The preliminary move by nature is colored green. Alice is colored red and Bob is colored blue. This game has only one single Nash equilibrium. Actions predicted by this equilibrium are colored black.

Muddy children puzzle can also be solved using backward induction from game theory.[13] Muddy children puzzle can be represented as an extensive form game of imperfect information. Every player has two actions — stay back and step forwards. There is a move by nature at the start of the game, which determines the children with and without muddy faces. Children do not communicate as in non-cooperative games. Every stroke is a simultaneous move by children. It is a sequential game of unlimited length. The game-theoretic solution needs some additional assumptions:

1. All children are rational and all children's rationality is common knowledge. This means that Alice is rational, Alice knows that Bob is rational and Alice knows that Bob knows that Charly is rational and so on and vice versa.
2. Stepping forward without having a muddy face results in a big penalty.
3. Stepping forward with a muddy face results in a reward.
4. Every stroke results in minor negative penalty aka discount factor for every child until any of them stepped forward. Any multiple of the minor penalty is always a lesser evil than the big penalty.

If only Alice is muddy, the last assumption makes it irrational for her to hesitate. If Alice and Bob are muddy, Alice knows that Bob's only reason of staying back after the first stroke is the apprehension to receive the big penalty of stepping forward without a muddy face. In the case with  X {\displaystyle X} muddy children, receiving  X {\displaystyle X} times the minor penalty is still better than the big penalty.

## The King's Wise Men hat puzzle

[edit]

### Description

[edit]

The King called the three wisest men in the country to his court to decide who would become his new advisor. He placed a hat on each of their heads, such that each wise man could see all of the other hats, but none of them could see their own. Each hat was either white or blue. The king gave his word to the wise men that at least one of them was wearing a blue hat; in other words, there could be one, two, or three blue hats, but not zero. The king also announced that the contest would be fair to all three men. The wise men were also forbidden to speak to each other. The king declared that whichever man stood up first and correctly announced the colour of his own hat would become his new advisor. The wise men sat for a very long time before one stood up and correctly announced the answer. What did he say, and how did he work it out?[15]

### Solution

[edit]

The King's Wise Men is one of the simplest induction puzzles and one of the clearest indicators to the method used.

* Suppose that there was one blue hat. The person with that hat would see two white hats, and since the king specified that there is at least one blue hat, that wise man would immediately know the colour of his hat. However, the other two would see one blue and one white hat and would not be able to immediately infer any information from their observations. Therefore, this scenario would violate the king's specification that the contest would be fair to each. So there must be at least two blue hats.
* Suppose then that there were two blue hats. Each wise man with a blue hat would see one blue and one white hat. Supposing that they have already realized that there cannot be only one (using the previous scenario), they would know that there must be at least two blue hats and therefore, would immediately know that they each were wearing a blue hat. However, the man with the white hat would see two blue hats and would not be able to immediately infer any information from his observations. This scenario, then, would also violate the specification that the contest would be fair to each. So there must be three blue hats.

Since there must be three blue hats, the first man to figure that out will stand up and say blue.

Alternative solution: This does not require the rule that the contest be fair to each. Rather it relies on the fact that they are all wise men, and that it takes some time before they arrive at a solution. There can only be three scenarios: one blue hat, two blue hats or three blue hats. If there was only one blue hat, then the wearer of that hat would see two white hats, and quickly know that he has to have a blue hat, so he would stand up and announce this straight away. Since this hasn't happened, then there must be at least two blue hats. If there were two blue hats, then either one of those wearing a blue hat would look across and see one blue hat and one white hat, but not know the colour of their own hat. If the first wearer of the blue hat assumed he had a white hat, he would know that the other wearer of the blue hat would be seeing two white hats, and thus the 2nd wearer of the blue hat would have already stood up and announced he was wearing a blue hat. Thus, since this hasn't happened, the first wearer of the blue hat would know he was wearing a blue hat, and could stand up and announce this. Since either one or two blue hats is so easy to solve, and no one has stood up quickly, then they must all be wearing blue hats.

## Josephine's Problem

[edit]

### Description

[edit]

In Josephine's Kingdom every woman has to pass a logic exam before being allowed to marry.[16] Every married woman knows about the fidelity of every man in the Kingdom except for her own husband, and etiquette demands that no woman should be told about the fidelity of her husband. Also, a gunshot fired in any house in the Kingdom will be heard in any other house. Queen Josephine announced that at least one unfaithful man had been discovered in the Kingdom, and that any woman knowing her husband to be unfaithful was required to shoot him at midnight following the day after she discovered his infidelity. How did the wives manage this?

### Solution

[edit]

Josephine's Problem is another good example of a general case.

* If there is only 1 unfaithful husband, then every woman in the Kingdom knows that except for his wife, who believes that everyone is faithful. Thus, as soon as she hears from the Queen that unfaithful men exist, she knows her husband must be unfaithful, and shoots him.
* If there are 2 unfaithful husbands, then both their wives believe there is only 1 unfaithful husband (the other one). Thus, they will expect that the case above will apply, and that the other husband's wife will shoot him at midnight on the next day. When no gunshot is heard, they will realise that the case above did not apply, thus there must be more than 1 unfaithful husband and (since they know that everyone else is faithful) the extra one must be their own husband.
* If there are 3 unfaithful husbands, each of their wives believes there to be only 2, so they will expect that the case above will apply and both husbands will be shot on the second day. When they hear no gunshot, they will realize that the case above did not apply, thus there must be more than 2 unfaithful husbands and as before their own husband is the only candidate to be the extra one.
* In general, if there are n unfaithful husbands, each of their wives will believe there to be n-1 and will expect to hear a gunshot at midnight on the n-1th day. When they do not, they know their own husband was the nth.

This problem is also known as the Cheating Husbands Problem, the Unfaithful Wives Problem, the Muddy Children Problem. It is logically identical to the Blue Eyes Problem.

This problem also appears as a problem involving black hats and white hats in C. L. Liu's classic textbook 'Elements of Discrete Mathematics'.[17]

## Alice at the Convention of Logicians

[edit]

### Description

[edit]

At the Secret Convention of Logicians, the Master Logician placed a band on each attendee's head, such that everyone else could see it but the person themselves could not. There were many different colours of band. The Logicians all sat in a circle, and the Master instructed them that a bell was to be rung in the forest at regular intervals: at the moment when a Logician knew the colour on his own forehead, he was to leave at the next bell. They were instructed not to speak, nor to use a mirror or camera or otherwise avoid using logic to determine their band colour. In case any impostors had infiltrated the convention, anyone failing to leave on time would be gruffly removed at the correct time. Similarly, anyone trying to leave early would be gruffly held in place and removed at the correct time. The Master reassured the group by stating that the puzzle would not be impossible for any True Logician present. How did they do it?[18]

### Solution

[edit]

Alice at the convention of Logicians is general induction plus a leap of logic.

* Leap of logic: Every colour must appear at least twice around the circle. This is because the Master stated that it would not be impossible for any Logician to solve the puzzle. If any colour existed only once around the circle, the Logician who bore it would have no way of knowing that the colour even existed in the problem, and it would be impossible for them to answer.
* Each of the Logicians can look around the circle and count the number of times they see each colour. Suppose that you are one of the Logicians and you see another colour only once. Since you know each colour must exist at least twice around the circle, the only explanation for a singleton colour is that it is the colour of your own band. For the same reason, there can only be one such singleton colour, and so you would leave on the first bell.
* Likewise any Logicians who see another colour only once should be able to determine their own colour, and will either leave with dignity or be thrown out as an infiltrator. Equivalently, any colour for which there are only two bands of that colour will be eliminated after the first bell has rung. Thereafter there must be at least three bands of any remaining colour.
* Suppose you do not see any colour once, but you do see a colour twice. If these were the only bands of this colour, then these two Logicians ought to have left at the first bell. Since they did not, that can only be because your own band is the same colour, so you can leave at the second bell.
* Therefore, every logician would watch until a group of a given colour that they expected to leave failed to leave. Then they would know that they had that colour, and would leave on the next bell.
* When only one colour remained, that colour would all leave on the next bell, because they would know that they could not have any other colour (since then it would be impossible for them to know their colour).

## Basic hat puzzle

[edit]

### Description

[edit]

A number of players are each wearing a hat, which may be of various specified colours. Players can see the colours of at least some other players' hats, but not that of their own. With highly restricted communication or none, some of the players must guess the colour of their hat. The problem is to find a strategy for the players to determine the colours of their hats based on the hats they see and what the other players do. In some versions, they compete to be the first to guess correctly; in others, they can work out a strategy beforehand to cooperate and maximize the probability of correct guesses.[19]

One variation received some new publicity as a result of Todd Ebert's 1998 Ph.D. thesis at the University of California, Santa Barbara.[20] It is a strategy question about a cooperative game, which has connections to algebraic coding theory.[21]

Three players are told that each of them will receive either a red hat or a blue hat. They are to raise their hands if they see a red hat on another player as they stand in a circle facing each other. The first to guess the colour of his or her hat correctly wins.

All three players raise their hands. After the players have seen each other for a few minutes without guessing, one player announces "Red", and wins. How did the winner do it, and what is the color of everyone's hats?

### Solution

[edit]

First, if two people had blue hats, not everyone's hand would have been raised. Next, if player 1 had seen a blue hat on player 2 & a red hat on player 3, then player 1 would have known immediately that his own hat must be red. Thus any player who sees a blue hat can guess at once. Finally, the winner realizes that since no one guesses at once, there must be no blue hats, so every hat must be red.[22]

In the case where every player has to make a guess, but they are free to choose when to guess, there is a cooperative strategy that allows every player to guess correctly unless all the hats are the same colour. Each player should act as follows:

1. Count the numbers b of blue hats and r of red hats that you see.
2. Wait b seconds or r seconds, whichever is sooner.
3. If nobody has yet spoken, guess that your hat is blue if you can see fewer blue hats than red hats, or red if you can see fewer red hats than blue hats.
4. If you have not yet spoken, guess that your hat is of the opposite colour to that of one of the first people to speak.

Suppose that in total there are B blue hats and R red hats. There are three cases.

If B = R then those players wearing blue hats see B − 1 blue hats and B red hats, so wait B − 1 seconds then correctly guess that they are wearing a blue hat. Similarly, those players wearing a red hat will wait R − 1 seconds before guessing correctly that they are wearing a red hat. So all players make a correct guess at the same time.

If B < R then those wearing a blue hat will see B − 1 blue hats and R red hats, whilst those wearing a red hat will see B blue hats and R − 1 red hats. Since B − 1 < B ≤ R − 1, those players wearing a blue hat will be the first to speak, guessing correctly that their hat is blue. The other players then guess correctly that their hat is red.

The case where R < B is similar.

## Two-hat variant

[edit]

### Description

[edit]

Four prisoners each wear a hat which is either black or white. The front prisoner is concealed behind a screen.

Four prisoners are arrested for a crime, but the judge offers to spare them from punishment if they can solve a logic puzzle.[23]

Three of the men stand a line. A faces the wall, B faces A, and C faces B and A. A fourth man is put behind a wall. All four men wear hats; there are two black hats and two white hats, each prisoner is wearing one of the hats, and each of the prisoners see only the hats in front of him but neither on himself nor behind him. The fourth man behind the screen can't see or be seen by any other prisoner. No communication among the prisoners is allowed. If any prisoner can figure out what color hat he has on his own head with 100% certainty (without guessing) he must then announce it, and all four prisoners go free.

### Solution

[edit]

The prisoners know that there are only two hats of each color. So if C observes that A and B have hats of the same color, C would deduce that his own hat is the opposite color. However, if A and B have hats of different colors, then C can say nothing. The key is that prisoner B, after allowing an appropriate interval, and knowing what C would do, can deduce that if C says nothing the hats on A and B must be different; able to see A's hat, he can deduce his own hat color.

In common with many puzzles of this type, the solution relies upon the assumption that all participants are rational and intelligent enough to make the appropriate deductions.

After solving this puzzle, some insight into the nature of communication can be gained by pondering whether the meaningful silence of prisoner C violates the "No communication" rule (given that communication is usually defined as the "transfer of information").[citation needed]

## Three-hat variant

[edit]

### Description

[edit]

In this variant there are 3 prisoners and 3 hats. Each prisoner is assigned a random hat, either red or blue. Each person can see the hats of two others, but not their own. On a cue, they each have to guess their own hat color or pass. They win release if at least one person guessed correctly and none guessed incorrectly (passing is neither correct nor incorrect).

### Solution

[edit]

This puzzle doesn't have a 100% winning strategy, but can be won with a 75% chance. When considering the colors of hats as bits, this problem can be solved using coding theory, for example with hamming codes.[24]

## Four-hat variant

[edit]

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (February 2024) (Learn how and when to remove this message)

|

### Description

[edit]

In a variant of this puzzle, the prisoners know that there are 2 black hats and 2 white hats, and there is a wall in between A and B, yet the prisoners B, C & D can see who's in front of them i.e. D sees B, C and the wall, B sees the wall, and C sees B & the wall. (A again cannot be seen and is only there to wear one of the black hats.) How can they deduce the colours of all of them without communicating?

### Solution

[edit]

There are two cases: in the trivial case, two of the four prisoners wear the black hats. Each of the other two prisoners can see that one prisoner is wearing the off-colour hat. In the non-trivial case, two of the four prisoners wear hats of the same colour, while A and C wear the black hats. After a while, all four prisoners should be able to deduce that, because D and B were not able to state the colour of their own hat, A and C must be wearing the black hats.

## Five-hat variant

[edit]

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (February 2024) (Learn how and when to remove this message)

|

### Description

[edit]

In another variant, only three prisoners and five hats of known colours (in this example two black and three white) are involved. The three prisoners are ordered to stand in a straight line facing the front, with A in front and C at the back. They are told that there will be two black hats and three white hats. One hat is then put on each prisoner's head; each prisoner can only see the hats of the people in front of him and not on his own. The first prisoner that is able to announce the color of his hat correctly will be released. No communication between the prisoners is allowed.

### Solution

[edit]

Assume that A wears a black hat:

* If B wears a black hat as well, C can immediately tell that he is wearing a white hat after looking at the two black hats in front of him.
* If B wears a white hat, C will be unable to tell the color of his hat (because there is a black and a white). So B can quickly deduce from A's black hat and C's lack of response that he (B) is wearing a white hat.

So if A wears a black hat there will be a fairly quick response from B or C.

Assume that A wears a white hat:

* C does not see two black hats, so he is unable to tell his hat color.
* B sees only a white hat, so he can't tell anything about his hat.

In this case A, B and C would remain silent for some time, until A finally deduces that he must have a white hat because C and B have remained silent for some time.

As mentioned, there are three white hats and two black hats in total, and the three prisoners know this. In this riddle, you can assume that all three prisoners are very clever and very smart. If C could not guess the color of his own hat that is because he saw either two white hats or one of each color. If he saw two black hats, he could have deduced that he was wearing a white hat.

## Ten-hat variant

[edit]

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (February 2024) (Learn how and when to remove this message)

|

### Description

[edit]

In this variant there are 10 prisoners and 10 hats. Each prisoner is assigned a random hat, either red or blue, but the number of each color hat is not known to the prisoners. The prisoners will be lined up single file where each can see the hats in front of him but not behind. Starting with the prisoner in the back of the line and moving forward, they must each, in turn, say only one word which must be "red" or "blue". If the word matches their hat color they are released, if not, they are killed on the spot. A sympathetic guard warns them of this test one hour beforehand and tells them that they can formulate a plan where by following the stated rules, 9 of the 10 prisoners will definitely survive, and 1 has a 50/50 chance of survival. What is the plan to achieve the goal?

### Solution

[edit]

The prisoners agree that if the first prisoner sees an odd number of red hats, he will say "red". This way, the nine other prisoners will know their own hat color after the prisoner behind them responds.

## Ten-hat variant without hearing

[edit]

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (February 2024) (Learn how and when to remove this message)

|

### Description

[edit]

As before, there are 10 prisoners and 10 hats. Each prisoner is assigned a random hat, either red or blue, but the number of each color hat is not known to the prisoners. The prisoners are distributed in the room such that they can see the hats of the others but not their own. Now, they must each, simultaneously, say only one word which must be "red" or "blue". If the word matches their hat color they are released, and if enough prisoners resume their liberty they can rescue the others. A sympathetic guard warns them of this test one hour beforehand. If they can formulate a plan following the stated rules, 5 of the 10 prisoners will definitely be released and be able to rescue the others. What is the plan to achieve the goal?

### Solution

[edit]

The prisoners pair off. In a pair (A, B) of the prisoners A says the color he can see on the head of B, who says the opposite color he sees on the head of A. Then, if both wear hats with the same color, A is released (and B is not), if the colors are different, B is released (and A is not). In total, 5 prisoners answer correctly and 5 do not. This assumes the pair can communicate who is A and who is B, which may not be allowed.

Alternatively, the prisoners build two groups of 5. One group assumes that the number of red hats is even, the other assumes that there is an odd number of red hats. Similar to the variant with hearing, they can deduce their hat color out of this assumption. Exactly one group will be right, so 5 prisoners answer correctly and 5 do not.

Note that the prisoners cannot find a strategy guaranteeing the release of more than 5 prisoners. Indeed, for a single prisoner, there are as many distributions of hat colors where he says the correct answer than there are where he does not. Hence, there are as many distributions of hat colors where 6 or more prisoners say the correct answer than there are where 4 or fewer do so.

## Countably infinite-Hat variant without hearing

[edit]

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (February 2024) (Learn how and when to remove this message)

|

### Description

[edit]

In this variant, a countably infinite number of prisoners, each with an unknown and randomly assigned red or blue hat line up single file line. Each prisoner faces away from the beginning of the line, and each prisoner can see all the hats in front of him, and none of the hats behind. Starting from the beginning of the line, each prisoner must correctly identify the color of his hat or he is killed on the spot. As before, the prisoners have a chance to meet beforehand, but unlike before, once in line, no prisoner can hear what the other prisoners say. The question is, is there a way to ensure that only finitely many prisoners are killed?

### Solution

[edit]

If one accepts the axiom of choice, and assumes the prisoners each have the (unrealistic) ability to memorize an uncountably infinite amount of information and perform computations with uncountably infinite computational complexity, the answer is yes. In fact, even if we allow an uncountable number of different colors for the hats and an uncountable number of prisoners, the axiom of choice provides a solution that guarantees that only finitely many prisoners must die provided that each prisoner can see the hats of every other prisoner (not just those ahead of them in a line), or at least that each prisoner can see all but finitely many of the other hats. The solution for the two color case is as follows, and the solution for the uncountably infinite color case is essentially the same:

The prisoners standing in line form a sequence of 0s and 1s, where 0 is taken to represent blue, and 1 is taken to represent red. Before they are put into the line, the prisoners define the following equivalence relation over all possible sequences that they might be put into: Two sequences are equivalent if they are identical after a finite number of entries. From this equivalence relation, the prisoners get a collection of equivalence classes. Assuming the axiom of choice, there exists a set of representative sequences—one from each equivalence class. (Almost every specific value is impossible to compute, but the axiom of choice implies that some set of values exists, so we assume that the prisoners have access to an oracle.)

When they are put into their line, each prisoner can see all but a finite number of hats, and can therefore see which equivalence class the actual sequence of hats belongs to. (This assumes that each prisoner can perform an uncountably infinite number of comparisons to find a match, with each class comparison requiring a countably infinite number of individual hat-comparisons). They then proceed guessing their hat color as if they were in the representative sequence from the appropriate equivalence class. Because the actual sequence and the representative sequence are in the same equivalence class, their entries are the same after some finite number N of prisoners. All prisoners after these first N prisoners are saved.

Because the prisoners have no information about the color of their own hat and would make the same guess whichever color it has, each prisoner has a 50% chance of being killed. It may seem paradoxical that an infinite number of prisoners each have an even chance of being killed and yet it is certain that only a finite number are killed. The solution to this paradox lies in the fact that the function employed to determine each prisoner's guess is not Measurable function.

To see this, consider the case of zero prisoners being killed. This happens if and only if the actual sequence is one of the selected representative sequences. If the sequences of 0s and 1s are viewed as binary representations of a real number between 0 and 1, the representative sequences form a non-measurable set. (This set is similar to a Vitali set, the only difference being that equivalence classes are formed with respect to numbers with finite binary representations rather than all rational numbers.) Hence no probability can be assigned to the event of zero prisoners being killed. The argument is similar for other finite numbers of prisoners being killed, corresponding to a finite number of variations of each representative.

## Countably infinite hat problem with hearing

[edit]

This section does not cite any sources. Please help improve this section by adding citations to reliable sources. Unsourced material may be challenged and removed. (February 2024) (Learn how and when to remove this message)

|

### Description

[edit]

This variant is the same as the last one except that prisoners can hear the colors called out by other prisoners. The question is, what is the optimal strategy for the prisoners such that the fewest of them die in the worst case?

### Solution

[edit]

It turns out that, if one allows the prisoners to hear the colors called out by the other prisoners, it is possible to guarantee the life of every prisoner except the first, who dies with a 50% probability.

To do this, we define the same equivalence relation as above and again select a representative sequence from each equivalence class. Now, we label every sequence in each class with either a 0 or a 1. First, we label the representative sequence with a 0. Then, we label any sequence which differs from the representative sequence in an even number of places with a 0, and any sequence which differs from the representative sequence in an odd number of places with a 1. In this manner, we have labeled every possible infinite sequence with a 0 or a 1 with the important property that any two sequences which differ by only one digit have opposite labels.

Now, when the warden asks the first person to say a color, or in our new interpretation, a 0 or a 1, he simply calls out the label of the sequence he sees. Given this information, everyone after him can determine exactly what his own hat color is. The second person sees all but the first digit of the sequence that the first person sees. Thus, as far as he knows, there are two possible sequences the first person could have been labeling: one starting with a 0, and one starting with a 1. Because of our labeling scheme, these two sequences would receive opposite labels, so based on what the first person says, the second person can determine which of the two possible strings the first person saw, and thus he can determine his own hat color. Similarly, every later person in the line knows every digit of the sequence except the one corresponding to his own hat color. He knows those before him because they were called out, and those after him because he can see them. With this information, he can use the label called out by the first person to determine his own hat color. Thus, everyone except the first person always guesses correctly.

## Ebert's version and Hamming codes

[edit]

### Description

[edit]

Ebert's version of the problem states that all players who guess must guess at the same predetermined time, but that not all players are required to guess. Now not all players can guess correctly, so the players win if at least one player guesses and all of those who guess do so correctly. How can the players maximise their chance of winning?

### Solution

[edit]

One strategy for solving this version of the hat problem employs Hamming codes, which are commonly used to detect and correct errors in data transmission. The probability for winning will be much higher than 50%, depending on the number of players in the puzzle configuration: for example, a winning probability of 87.5% for 7 players.

Similar strategies can be applied to team sizes of N = 2k−1 and achieve a win rate (2k-1)/2k. Thus the Hamming code strategy yields greater win rates for larger values of N.

In this version of the problem, any individual guess has a 50% chance of being right. However, the Hamming code approach works by concentrating wrong guesses together onto certain distributions of hats. For some cases, all the players will guess incorrectly; whereas for the other cases, only one player will guess, but correctly. While half of all guesses are still incorrect, this results in the players winning more than 50% of the time.

A simple example of this type of solution with three players is instructive. With three players, there are eight possibilities; in two of them all players have the same colour hat, and in the other six, two players have one colour and the other player has the other colour.

The players can guarantee that they win in the latter cases (75% of the time) with the following strategy:

1. Any player who observes two hats of two different colours remains silent.
2. Any player who observes two hats of the same colour guesses the opposite colour.

In the two cases when all three players have the same hat colour, they will all guess incorrectly. But in the other six cases, only one player will guess, and correctly, that his hat is the opposite of his fellow players'.[25]

## See also

[edit]

* Epistemic logic
* Common knowledge (logic)

## References

[edit]

1. ^ Stuhlmüller, A.; Goodman, N.D. (June 2014). "Reasoning about reasoning by nested conditioning: Modeling theory of mind with probabilistic programs". Cognitive Systems Research. 28: 80–99\. CiteSeerX 10.1.1.361.5043. doi:10.1016/j.cogsys.2013.07.003. S2CID 7602205.
2. ^ Lucci, Stephen; Kopec, Danny (2015). Artificial Intelligence in the 21st Century. Stylus Publishing, LLC. ISBN 978-1-944534-53-0.
3. ^ Tagiew, Rustam (2008). "Simplest Scenario for Mutual Nested Modeling in Human-Machine-Interaction". KI 2008: Advances in Artificial Intelligence. Lecture Notes in Computer Science. Vol. 5243\. Springer. pp. 364–371\. doi:10.1007/978-3-540-85845-4_45. ISBN 978-3-540-85844-7.
4. ^ a b c Fagin, Ronald; Halpern, Joseph Y.; Moses, Yoram; Vardi, Moshe Y. (March 1999). "Common knowledge revisited". Annals of Pure and Applied Logic. 96 (1–3): 89–105\. arXiv:cs/9809003. doi:10.1016/S0168-0072(98)00033-5. S2CID 59551.1–3&rft.pages=89-105&rft.date=1999-03&rft_id=info:arxiv/cs/9809003&rft_id=https://api.semanticscholar.org/CorpusID:59551#id-name=S2CID&rft_id=info:doi/10.1016/S0168-0072(98)00033-5&rft.aulast=Fagin&rft.aufirst=Ronald&rft.au=Halpern,+Joseph+Y.&rft.au=Moses,+Yoram&rft.au=Vardi,+Moshe+Y.&rfr_id=info:sid/en.wikipedia.org:Induction+puzzles" class="Z3988">
5. ^ a b van der Hoek, Wiebe; van Ditmarsch, Hans (2007). Dynamic epistemic logic. Springer. ISBN 978-1-4020-5838-7.
6. ^ "Google Scholar "Muddy Children Puzzle"". scholar.google.com. Retrieved 11 February 2020.
7. ^ Fagin, Ronald; Halpern, Joseph Y.; Moses, Yoram; Vardi, Moshe (2004). Reasoning about knowledge. MIT Press. ISBN 978-0262562003.
8. ^ Hardin, Christopher; Taylor, Alan D. (2008). "An introduction to Infinite Hat Problems" (PDF). Mathematical Intelligencer. 30 (4): 20–25\. doi:10.1007/BF03038092. S2CID 24613564. Archived from the original (PDF) on 2012-04-05.
9. ^ "The Prisoners' Hats – Puzzles And Riddles". www.puzzlesandriddles.com.
10. ^ "Prisoners and Hats Puzzle". CrazyforCode. 13 August 2013.
11. ^ "Robots pass 'wise-men puzzle' to show a degree of self-awareness". techxplore.com.
12. ^ Leite, João (2005). Computational Logic in Multi-Agent Systems: 5th International Workshop, CLIMA V, Lisbon, Portugal, September 29–30, 2004, Revised Selected and Invited Papers. Springer Science & Business Media. ISBN 978-3-540-28060-6.
13. ^ a b Tagiew, Rustam (2011). Strategische Interaktion realer Agenten Ganzheitliche Konzeptualisierung und Softwarekomponenten einer interdisziplinären Forschungsinfrastruktur (in German). Südwestdeutscher Verlag für Hochschulschriften. pp. 90–95\. ISBN 978-3838125121.
14. ^ Weber, Roberto A. (1 December 2001). "Behavior and Learning in the "Dirty Faces" Game". Experimental Economics. 4 (3): 229–242\. doi:10.1023/A:1013217320474. ISSN 1573-6938. S2CID 123369018.
15. ^ Huth, Michael; Ryan, Mark (26 August 2004). Logic in Computer Science: Modelling and Reasoning about Systems. Cambridge: Cambridge University Press. ISBN 978-0-521-54310-1.
16. ^ Moses, Yoram; Dolet, Danny; HaIpern, Joseph Y. (1985). "Cheating husbands and other stories (Preliminary version)" (PDF). Proceedings of the fourth annual ACM symposium on Principles of distributed computing - PODC '85. pp. 215–223\. doi:10.1145/323596.323616. ISBN 0897911687. S2CID 2519017.
17. ^ Liu, Chung Laung (1985). Elements of Discrete Mathematics (2 ed.). McGraw-Hil. pp. 16–17\. ISBN 9780071005449.
18. ^ Charatonik, Włodzimierz J. (2010). "Alice at the logicians convention" (PDF). Missouri University of Science and Technology. Archived from the original (PDF) on 2010-07-05. Retrieved 2015-07-31.
19. ^ Brown, Ezra; Tanton, James (April 2009). "A Dozen Hat Problems" (PDF). Math Horizons. 16 (4): 22–25\. doi:10.1080/10724117.2009.11974827. S2CID 123345434. Archived from the original (PDF) on 2017-07-17. Retrieved 2011-10-08.
20. ^ Winkler, Peter (2004). Mathematical Puzzles: A Connoisseur's Collection. A K Peters. pp. 125–126. "hat puzzle todd."
21. ^ Biography of Todd Ebert at California State University, Long Beach
22. ^ Gardner, Martin (1978). Aha! Insight. Scientific American. p. 102\. ISBN 0-89454-001-7. Retrieved 2011-10-08.
23. ^ "US Nuclear Regulatory Commission Vol. 1 No. 4" (PDF). Nuclear Regulatory Commission. 2011. Retrieved 2024-10-17.
24. ^ Guo, Wenge; Kasala, Subramanyam; Rao, M. Bhaskara; Tucker, Brian. "The Hat Problem And Some Variations" (PDF).
25. ^ Havil, Julian (2008). Impossible? Surprising Solutions to Counterintuitive Conundrums. Princeton University Press. pp. 50–59\. ISBN 9780691131313. Retrieved 2011-10-08.

*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template