*The hardest logic puzzle ever* is a riddle by the logicians Raymond Smullyan and
John McCarthy that became famous in the 1990s.

Who is True, who is False, and who is Random?

Imagine there are three oracles called True, False, and Random. True always tells the truth, False always lies and Random randomly tells the truth or lies. Your task is to find out which oracle is which by asking them some yes/no questions. But there is an additional difficulty: the oracles will reply in their mystic language, either saying "DA" or "BAL" and you don't know which one of these words means yes and which one means no.

Surprisingly, three questions are enough to solve the riddle.

Before you start pondering this, here are three things that are important to know:

- The random oracle will decide whether or not to lie or tell the truth by secretly tossing a coin.
- You can ask any yes/no question to any oracle of your choice.
- You do not have to ask all questions at once. In fact, you can make use of the previous answers to adapt your questions and choose the oracle that you ask them to.

If you are struggling to find the solution, don't despair. After all, it's called the hardest logic puzzle ever. Here is the general idea behind the solution. With the first question you identify an oracle X which is not Random. You then ask the two further questions of X. The second question identifies whether X is True or False, and the third question identifies the other two oracles.

### If and only if

The solution makes use of the logical concept of *if and
only if*, which works as follows: given two statements A and B, the statement *A if and only if B* is true whenever A and B are both true or both false, otherwise it is false.
This means that the statement

*2+2=4 if and only if the Moon
is made of cheese*

is false because one component is true and one is false. On the other hand the statement

*2+2=5 if and only if the Moon
is made of cheese*

is true because both components are false. These examples don't quite chime with our intuitive interpretation of what "if and only if" might mean, but try not to worry about this. Just keep in mind the logical definition given above. (*If and only if* is the negation of something called XOR, which you can read about here.)

### Starting simple

Now let's go back to our riddle and start with a simplification. Let's suppose that DA means "yes" and BAL means "no".

First suppose you have already asked the first question to some oracle, which has identified a different oracle X that isn't Random. Can you then think of a simple question that will reveal who X is? Afterwards, can you think of a simple question for X which will reveal who the other two oracles are?

If not, then here are the answers. To find out if X is True or False you simply ask a question to which you already know the answer, such as:

*Is 2 plus 2 equal to 4?*

To identify the other two oracles you can then ask X:

*Is this oracle (pointing at the oracle you asked the first question) Random?*

Since you know if X is True or False, you can determine whether the oracle you asked the first question is Random or not. By elimination you identify the third oracle as well.

### The first question

Suppose again that DA means "yes" and BAL means "no" (we will take care about the language issue later on) and let us turn to the crucial first question, which is the most difficult one. Pick any oracle O and ask:

*Are you True if and only if this oracle (where you point at one oracle P different from O) is Random?*

The Moon is not made from cheese, and neither does it have rings.

Suppose the answer you get from O is "yes". If O is True, then the oracle P must be random. That's because the statement

*O is True if and only if P is Random*

is true whenever both components are true, or both components are false.

If the answer is "yes" and O is False, then the true answer should have been "no, the statement 'O is True if and only if P is Random' is false". Since the first part of the statement, "O is true" is false, the second part of the statement, "P is Random" must be true (from the definition of *if and only if*).

So whether O is True or False, an answer of "yes" tells us that P is Random, which means that the third oracle, call it Q, is not Random.

What does an answer of "yes" tell us if O is Random? Well, it doesn't tell us with certainty what P is, but that doesn't matter. In this case, because O is Random, the third oracle Q is definitely not Random.

In summary, then, an answer of "yes" tells us with certainty that the third oracle Q is not Random, no matter what O is.

What if O answers "no"? Then if O is True this implies that P is not Random. If O is False, then the true answer should have been "yes, the statement is true". Since the first part of the statement

*O is True if and only if P is Random*

is false in this case, this means that the second part "P is Random" is also false.

So whether O is True or False, an answer of "no" tells us that P is not Random.

What does an answer of "no" tell us if O is Random? Well, it tells us that P can't be Random, because O already is.

In summary, then, an answer of "no" tells us with certainty that P is not Random, no matter what O is.

In both cases, whether O answers "yes" or "no", we have identified one oracle as not being Random. If O answers "yes", then the third oracle Q is not Random. And if O answers "no", then the oracle P is not random. This identifies our non-Random oracle X from above. We can now proceed with the other two questions as described to solve the riddle. The diagram below illustrates the answers our three questions will give us.

This diagram illustrates how the various answers to the three questions allow us to identify all three oracles. Here T stands for True, F stands for False, and R stands for Random.

Note that the role of the *if and only if* here was to get certainty from the answers of O without knowing whether O is True, False or Random.

### DA and BAL

Now consider the original riddle, where you do not know the meaning of DA and
BAL. Here we need to introduce another layer of *if and only if*, which will allow us to elicit the same information as we did before, without knowing which of DA and BAL means "yes" and which means "no". Namely, by adding "if and only if DA means yes" at the end of all the three questions it turns out that we can interpret the answer DA as a positive answer to the original question, and the answer BAL as a negative answer to the original question. In the next section we see an example of this, now we are going to state the general solution to the riddle.

You start by picking an oracle O and ask it, while pointing to another oracle P,

*Are you True if and only if P is Random, if and only if DA means yes?*

This statement is true whenever the two statements

*Are you True if and only if P is Random*

and

*DA means yes*

are both true or both false, otherwise it is false.

As before, this question will identify an oracle X, different from O, that is not Random.

Then you ask of X:

*Is 2 plus 2 equal to 4 if and only if DA means yes?*

This will tell you whether X is True or False. Finally you ask of X:

*Is this oracle (pointing at the oracle O you asked the first question of) Random if and only if
DA means yes?*

As before, this will tell you whether O is Random or not, and since you already know what X is, it solves the riddle.

### Really?

To convince you that this works, let's look at the last question. You already know at this point whether X is True or False. Let's assume X is True. You are asking X about O, the oracle you asked the first question of.

This painting by John Collier depicts Pythia, the oracle of Delphi (who could say more than just DA and BAL).

Suppose that X answers DA and that DA means "yes". Then O is Random. Now suppose that DA means "no". Then O is also Random. That's because in this case the statement

*DA means yes*

is false, so since X said DA, which means "no", the statement

*O is Random*

is true.

What if X says BAL and that BAL means "yes". Then O is not Random. That's because in this case the statement

*DA means yes*

is false, so since X said BAL, which means "yes", the statement

*O is Random*

must also be false.

Similarly, if BAL means "no" then O is also not Random. That's because in this case the statement

*DA means yes*

is true, so since X said BAL, which means "no", the statement

*O is Random*

must be false.

What we have just shown is that, if X is True, then an answer of DA tells us that O is Random and an answer of BAL tells us that O is not Random, even though we don't know what DA and BAL mean.

A very similar argument shows that when X is False, then an answer of DA means that O is not Random and an answer of BAL means that O is Random. In summary, we can work out whether O is Random or not from X's answer without knowing which of DAL and BAL means "yes" and which means "no".

It is also possible to show that the answer to the first question identifies an oracle X that is not Random and the answer to the second question identifies whether X is True of False, even though you don't know which of DAL and BAL means "yes" and which means "no". We will leave this to you as an exercise.

### Another puzzle for you

In a TV show you are shown two envelopes. If you open the correct envelope you win a huge prize, while if you open the wrong one you win nothing. There are two people and you can ask one of them a yes/no question. One person will tell the truth and the other will lie (and you don't know who is the truth-teller and who is the liar). Which question can you ask in order to identify the envelopes?

You can see the solution here.

### About the author

Antonella Perucca is Professor for Mathematics and its Didactics at the University of Luxembourg. She is a researcher in number theory and invents mathematical exhibits. To find out more, explore her webpage.

## Comments

## Easy solution with 4 questions

As pointed out to me by Tianyu (Tierry) Wang from Beihang University, there is a solution where the questions are very easy, but there are four of them.

You first ask to all three Oracles: "Does DA mean Yes?"

Independently of the meaning of DA, True answers DA and False answers BAL. So if exactly one Oracle replies DA, it is True, while if exactly one Oracle replies BAL, it is False.

Then you fix some Oracle X between the two which are still unknown to you. And you ask to the Oracle which you have identified "Would you answer DA when asked if X is Random?"

The answer DA means that X is Random, while the answer BAL means that X is not Random. To see why this is the case, try out all possibilities (asking True or False, the answer being DA or BAL, DA meaning Yes or No).

Notice that True and False give the same answer because False is wrongly describing the answer which it would give, so it presents the answer that True would give.

For example if you ask a liar: "Would you say Yes to 1+1=2 ?" The liar would of course reply No to "1+1=2 ?", so the correct answer to your question would be No, and the liar answers Yes. And if you ask the liar instead: "Would you say Yes to 1+1=3 ?" The liar would of course reply Yes to "1+1=3 ?", so the correct answer to your question would be Yes, and the liar answers No.

## ChatGPT

OpenAI ChatGPT be like...

To determine the identities of the gods A, B, and C, you could ask the following three questions:

"If I asked you whether C is Random, would you say 'da'?"

"If I asked you whether A is False, would you say 'da'?"

"If I asked you whether B is True, would you say 'da'?"

Here's how you can use the answers to these questions to determine the identities of the gods:

If the first god answers "da" to the first question, then C is Random.

If the second god answers "da" to the second question, then A is False.

If the third god answers "da" to the third question, then B is True.

If any of the gods answer "ja" to their respective question, then the opposite is true. For example, if the first god answers "ja" to the first question, then C is not Random.

Using this method, you can determine the identities of the gods with three questions.

## CHATGPT answers

To solve this problem, you can use a process of elimination and logical reasoning. Here is one possible solution:

Ask the True oracle if the Random oracle is Random. If the True oracle says "DA", then you know that "DA" means "yes" and "BAL" means "no". If the True oracle says "BAL", then you know that "BAL" means "yes" and "DA" means "no".

Ask the False oracle if the Random oracle is Random. If the False oracle says "DA", then you know that "BAL" means "yes" and "DA" means "no". If the False oracle says "BAL", then you know that "DA" means "yes" and "BAL" means "no".

Now that you know the meaning of "DA" and "BAL", you can ask the Random oracle if he is Random. If he says "DA", then you know that he is the Random oracle. If he says "BAL", then you know that he is the False oracle.

Now that you know who the Random oracle is, you can ask him a question to which you know the answer and see whether he answers truthfully or not. If he answers truthfully, then the True oracle is the one who said the Random oracle was Random. If he answers falsely, then the False oracle is the one who said the Random oracle was Random.

You now know the identity of all three oracles.

Keep in mind this is one way of solving the problem, and there may be other ways to approach it as well.

## Simpler Questions:

Here are three simple questions you can ask:

1. Are you speaking the truth right now? Everyone will answer with "Yes" or the according da or bal so now you know which is which

2. Are you the random oracle speaking the truth now?

Random oracle in any case says yes. Lying oracle in any case says yes. True oracle says no

if answer no: you already got your true oracle

if answer yes: a) is Lying or Random oracle meaning b) and c) are the true oracle plus lying or random oracle. To determine which one is which ---->

3. Now asking b): are you the random oracle speaking the truth now?

true oracle will say no. Lying or random oracle will say yes.

if answer is yes: c) is the true oracle

if answer no: b) is the true oracle