# Logic explanation in "two doors" answer

In one of the answers to this question, reproduced here:

You are a prisoner in a room with 2 doors and 2 guards. One of the doors will guide you to freedom and behind the other is a hangman - you don't know which is which.

One of the guards always tell the truth and the other always lies. You don't know which one is the truth-teller or the liar either.

You have to choose and open one of these doors, but you can only ask a single question from one of the guards.

What do you ask to lead you to the door of freedom?

and the solution:

Here is a twisted solution.

Go to any guard, point at a door and ask: Among the propositions 1. "You are a liar", 2. "You will reply negatively" and 3. "This door leads to freedom", is there an odd number of true propositions?

If you get the answer yes: If the guard is a truthteller, the number of truths is odd, 1. is false, 2. is false, so 3. must be true. If the guard is a liar, the number of truths is even, 1. is true, 2. is false, so 3. must be true.

If you get a negative answer: If the guard is a truthteller, the number of truths is even, 1. is false, 2. is true, so 3. must be true. If the guard is a liar, the number of truths is odd, 1. is true, 2. is true, so 3. must be true.

So regardless of the answer of the guard, the door you pointed at is the door to freedom, you can leave safely.

I fail to follow the logic behind this answer. The answer seems to suggest that no matter what door is pointed to, it becomes the correct door, which does not make sense.

Is there a logical mistake behind this answer, or is there something I missed in my reading?

• Does negatively mean "replying about the door to hell" or "lying"? Jan 19 '15 at 14:49
• I read it as meaning "saying no". Jan 19 '15 at 17:09

There is a fallacy, although quite subtle - "You will reply negatively" leads to a contradiction if the door pointed to leads to the hangman (meaning that neither guard can reply without breaking their rule of always telling the truth or always lying), so a case test of the reply will ignore this possibility. The solution assumes that there is always a possible answer in every situation (where there is not).

Edit: upon rereading the original solution, it seems the lying guard will answer falsely to the entire question, rather than answering falsely to the individual questions and truthfully answering the main question. The fallacy is still the same in each case though.

Case testing the different situations:

If the guard is a truthteller, and the door you pointed to leads to freedom, then 1. is false and 3. is true. If 2. is true, then there are an even number of truths, so the reply is negative. If 2. is false, then there are an odd number of truths, so the reply is positive. Both answers work in this situation.

If the door leads to the hangman however, then 1. is false and 3. is false. If 2. is true, then there are an odd number of truths, which would elicit a positive reply, but 2. being true leads to a contradiction. Similarly, if 2. is false, a contradiction also occurs.

If the guard is a liar, and the door leads to freedom, then 1. is true and 3. is true. If 2. is true, then there are an odd number of truths, so the reply is negative (because the guard always lies). If 2. is false, then there are an even number of truths, so the reply is positive (again because the guard always lies).

If the door leads to the hangman, then 1. is true and 3. is false. If 2. is true, then there are an even number of truths, so the reply is positive, but this once again contradicts the claim in 2. that the reply is negative. Similarly, if 2. is false, a contradiction also occurs.

OK, I wrote the "twisted solution" above. I actually wrote it as a joke.

It is designed in such a way that if you point at the correct door, every answer works. Whether the guard is a truth-teller or a liar, and whether the sentence is assumed to be true or false, it works.

If however you point at the door to death, it results in a paradox of the type "this sentence is a lie". Regardless of your assumptions, it results in a contradiction. Instead of exposing the paradox, I use the contradiction to deduce that it cannot be the door to death.

In fact, if you point at the door to death and ask that question, neither guard will be able to answer the question in accordance to his nature. So the argument fails in the assumption that the guard will always answer, the truth-teller will always tell the truth, and the liar will always lie.

The guards sometimes can't answer when the question refers to itself. It creates a "logical larsen", a loop that makes it impossible to simply evaluate the truth of the proposition. The guard needs to guess the answer, evaluate the truth of the proposition, possibly lie about it, and hope the answer matches his initial guess. Sometimes no answer works.

• On the other hand, if you find yourself entering the Death Door, that means the guards have solved the halting problem. So it's not all bad. May 24 '17 at 2:35

Yes. Let's just take one case - the door is correct, and the guard is a truthteller.

If he says "yes", there is indeed an odd number of true propositions - #3 alone.

If he says "no", there is indeed an even number of true propositions - #2 and #3.

Ergo, his answer is vacuous. The same applies for every other case; the guard can answer either way since changing his answer flips proposition #2 and the parity of the number of true propositions. The solution above is wrong because in each case it assumes the value of #2 (which in reality depends on #3) before determining #3.

• It is true, the answer cannot be computed. The guard needs to figure an answer that works. The paradox relies ont the fact that giving an answer that works is an impossible task if you point at the wrong door. If it were computable there could be no such impossibility. Apr 22 '19 at 15:08

We have:

1. "You are a liar"
3. "This door leads to freedom"


is there an odd number of true propositions?

If 3 is False and guard is T we can have:

=> F T F => F
=> F F F => T


If 3 is True and guard is T we can have:

=> F T T => F
=> F F T => T


If 3 is False and guard is F we can have:

=> T T F => F
=> T F F => T


If 3 is True and guard is F we can have:

=> T T F => F
=> T F F => T


If the guards can deduce how answering 2 should affect their answer, they can choose. If they can't, they will not be able to answer.

TL;DR

The guards know how 2 will affect their answer, and can choose what to say to 2.

• I was under the assumption that the question author intended the "lying" to be applied once, to the final truth value of the answer. Requiring that the liar flip the truth value at every single evaluation would lead to infinite loop in my attempted reading. Jan 19 '15 at 10:21
• No, it will only give a choice. No matter whether the guard is a truth teller or not, he can choose what his answer to 2 will be and answer accordingly. We assume lying about 1 and 3, so we must assume lying about 2 as well. Added a little update to my answer, that will make things more clear.
– dmg
Jan 19 '15 at 10:32
• I wrote the "twisted solution". I assume a liar would tell the opposite of the truth, he would know he would do so and deny it. If asked if he would reply negatively to a true question, he would know he would reply "no", therefore he would deny that he would reply negatively. In effect, one lie will cancel the next. Jan 19 '15 at 21:27
• @FlorianF As you can see, both the liar and the truthteller can choose what their answer to 2 is and affect their final answer.
– dmg
Jan 19 '15 at 23:03

There are always 3 propositions (let's call them "P"). The Ps are well chosen so they will always be answered in a 2:1 ratio (2 true: 1 false or 2 false : 1 true). From the answer we can tell what the ratio was. Now, the problem is that you would always get the same answer from both guards, right?

That's why the P2 is there. The creator of this solution made it hard to understand but try the following.

I think it is easier to switch P2 and P3. So you find your answers to the first 2 Ps and with (the new) P3 ("You will reply negatively") you kind of invert the answer of one guard so that you can distinguish between the liar and the honest guy.

The only problem is that you can't really answer P3 because it is related to the answer the guard should give you. Maybe one can solve this with some differential equation but speaking for myself, I think there is a mistake. You would probably end up in a logical loop where the answers always change and the guard's head explodes :D

I think your proposed questions are not very good, because:

Go to any guard, point at a door and ask:

1. "You are a liar" - Not a very useful question, as both guards will answer this with no

2. "You will reply negatively" - Not a very useful question, as the truth telling guard cannot answer this one:

• if he answers no, he lies
• if he answers yes, he lies
3. "This door leads to freedom" - Not a very useful question, as this can go both ways
• lying guard, good door => No
• lying guard, wrong door => Yes
• truth guard, good door => Yes
• truth guard, wrong door => No
• These are not 3 questions. It is a single question about 3 facts. The original question says: " Among the propositions 1, 2, 3, is there an odd number of true propositions? You removed that part. Jan 20 '15 at 9:19

For another perspective, consider the following puzzle:

You are a prisoner in a room with 2 doors. One of the doors will guide you to freedom and behind the other is a hangman. Also, 2+2=5. How would you get to freedom?

Since the statement of the puzzle contains a necessarily false statement ("2+2=5"), then by the principle of explosion, we can deduce anything we want - in particular, we can deduce that the right hand door is the correct one. So "pick the door on the right" is a valid solution.

Florian F's solution to the original puzzle could arguably be simplified using this idea:

Among the propositions 1. "you are a liar", 2. "you will reply negatively", is exactly one of them true?

No matter whether the guard answers "yes" or "no", a paradox ensues, implying (due to the principle of explosion) that the door on the right leads to freedom.

The problem is that the original wording of the puzzle isn't strict enough to make this paradox inescapable - e.g. maybe if you ask this question, the guards just choose not to answer, and you're stuck.

Simple...

Just go to any one of them and ask this ....

If I go to other guard and ask "Which gate is the gate to freedom" what will he say.

Whatever is the answer of the guard will be (for example: Guard will reply : "He will say the door behind him is door to success")

Just go to the opposite door.

As because asking this type of question will always return you the false statement

• Did you even read the question? Jan 21 '15 at 9:53