Why does this answer to “two doors with two guards” work?

On this post: Two doors with two guards - one lies, one tells the truth the most common answer for this riddle is given.

However, while the answer marked as correct is the most common solution I found, it does not seem correct to me. It, as with others in the thread I linked, seem to contradict the initial logic of the riddle. I have not come across the solution I came up with anywhere, so I'm curious if my logic is wrong, or if I'm just dense. Both of which are entirely possible.

This is the original riddle in the most common form I've seen, identical to OP in linked thread...

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 tells 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 to one of the guards.

What do you ask so you can pick the door to freedom?

The most common solution is:

If I asked what door leads to freedom, what door would the other guard point to?

I've seen this solution everywhere, but my problems with it are that..

1. It assumes that the guards will point to doors instead of only responding verbally. Which isn't indicated in the riddle.

2. If we ask this of the truth-guard he will point to the death door, however if we ask the same question of the liar-guard he will point to the freedom door. Otherwise he would be telling the truth about which door his counter part would point to. In essence depending on which guard we asked that question, they would still point to different doors.

Maybe I'm being super dense here, but it seems that doesn't tell us what door to walk through, and a better solution would be to walk up to either guard and ask

Would 'you' walk through this door to freedom?

With this question no matter which guard you ask, if the answer is yes you choose the door you indicated when asking the question. If the guard answers no you choose the opposite door.

Sorry for the long post, but thanks in advance for any responses.

• Maybe it helps to see the liar as the opposite of the truth. First think of the correct answer to your question and invert. – Avigrail Aug 19 '16 at 5:47
• You may be slightly over-thinking parts of the puzzle.  You should consider pointing and speaking to be equivalent and interchangeable forms of communication.  If you have an apple and an orange, and you ask the lying guard, “Which one of these is an apple?”, you should assume that he will identify the orange, either by pointing or verbally.  Now, if you want to split hairs, you could criticize the puzzle you link to and quote for not stating that the guards know which door is which (and that their “knowledge” is correct). – Peregrine Rook Aug 21 '16 at 6:25
• Maybe I’m being “super dense” here, but I don’t see how your idea (third paragraph from the bottom) is any different from asking a randomly selected guard “Does this door lead to freedom?” (referring to a randomly selected door, or the door that the guard is associated with, if applicable).  (Unless you’re assuming that the liar guard is so committed to lying that, if his supervisor told him to go home, he would actually go to the hangman, just to be consistently contrary.) – Peregrine Rook Aug 21 '16 at 6:26

The most common solution is usually stated as

"If I asked the other guard if the left door led to freedom, what would he say?"

This makes the chain of statements "run through" the liar once and the truthteller once, so you know the door indicated is the wrong one. ("Yes" means you should go through the right door, "no" means you should go through the left.)

Your solution is the second most common one, and it's more commonly stated as:

"If I asked you if the left door led to freedom, what would you say?"

This makes the chain of statements "run through" one guard twice, meaning it's either a lying paraphrase of a lie (making it the truth) or just the plain truth. This means the indicated door is the correct one.

Either way, you know the actual correct door and can proceed.

Your problems with the solution given don't really hold up.

• "Point to" can be metaphorical. This is more of a phrasing issue though than an issue with the logic - "indicate" may be a better way to state it.

• The liar guard would also point to the death door. The truth-teller guard would point to the freedom door, so the liar would lie about that pointing, and point to the death door. This ensures that both guards point to the death door when asked that question.

• A possible complaint is that these aren't really yes/no questions, since sure the answer is going to be either a "yes" or "no", but they're the sounds yes and no, rather than the concepts of yes and no. That is, you might argue that a proper yes/no question should be of the form "Is P true?", where P is some proposition, which these are not. But this can be mended by replacing "what would he say?" with "would he say yes?". – Jack M Mar 28 '17 at 18:10
1. This is an unimportant detail to the question and answer. Whether the guards point or verbalize their answer is inconsequential. If you asked the same question, but requested they speak the answer, it would not change their answer.

2. Both guards would point to the same door when given this question, as you are not asking the liar guard what the other guard's answer to this question that you are actually asking is, you are asking him about what his answer to a hypothetical question that you did not directly ask is. You are not asking them to respond to the question you are actually asking, so the other guard's answer will not affect their own.

Your proposed solution, however, makes an assumption that the guards have a sense of self-preservation. This might be a safe assumption normally, but given the initial absurdity of this scenario in the first place, I wouldn't leave room for assuming anything outside of the stated parameters of the problem.

A small piece, but you are injecting an extra layer into your reasoning. Your issue:

If we ask this of the truth-guard he will point to the death door, however if we ask the same question of the liar-guard he will point to the freedom door. Otherwise he would be telling the truth about which door his counter part would point to. In essence depending on which guard we asked that question, they would still point to different doors.

is looking too deep for the liar.

Let's build a table
 |Guard| He Points To| Says Partner Points To| |Truth| Freedom | Death | |Liar | Death | Death |  You are thinking of what the liar guard would say if he was asked what his partner would say he would say. It's a level deeper than what the question is actually asking. In reality, he would say the partner points to death, because he is lying about what he partner points to, which is freedom.

You can think of each guard as a function. There's one guard who always says the opposite of what's true, so we can represent him as O. There's another guard who always says what is true. We can represent him as I. So if you ask O a question whose answer should be "yes", he'll lie and say "no". For instance "Do triangles have three sides?" "No". If you ask something that should be answered "no", he'll lie and say "yes". If you ask I a question, his answer will be the same as how the question "should" be answered.

In function notation, this can be represented as:

I(yes) = yes

I(no) = no

O(yes) = no

O(no) = yes

If you knew which guard you were talking to, you could just take the output you got and see what input corresponds to that. The puzzle is that since you don't know which guard you're talking to, you don't know what input led to the output.

The standard solution is to combine the two functions. In mathematics, f∘g means "apply g, then apply f" (this might seems backwards, but there's a reason for that that I won't get into here). That is, f∘g(x) means f(g(x)). So if we have some question q, and we first ask O the question, then ask I what O said, that can be represented as (I∘O)(q). Now, if the answer to q is "yes", then O will lie and say the answer is "no", and I will then truthfully say that O said "no". So (I∘O)(yes) = no. Similarly, (I∘O)(no) = yes. Now, the thing about ∘ is that one cannot assume in general that the result will be the same regardless of order. But in this case, it is: if you work through what happens if you ask I and then O instead of O then I, you'll find that (O∘I)(yes) = no and (O∘I)(no) = yes.

So we don't need to know which guard is which; we create a situation where we don't know whether we have (O∘I) or (I∘O), but since they give the same result, we don't need to know.

Another solution is to ask "If I were to ask you which door leads to freedom, what would you say?" By asking about what someone would say, I'm applying the function twice. So if I ask the liar this question, this is (O∘O), while for the truth-teller it's (I∘I). We can work through what (O∘O) is:

(O∘O)(yes) = O(O(yes)) = O(no) = yes

(O∘O)(no) = O(O(no)) = O(yes) = no

Similarly, (I∘I)(yes) = yes and (I∘I)(no) = no. (O∘O) and (I∘I) give the same result, so they are actually the same function.So it doesn't matter which one we ask; the answer we get will be the true answer.

There are further, fancier solutions, such as "Between 'You are a liar' and 'This door leads to freedom', is exactly one of those statements true?" or "Is the truth-status of 'You are a truth-teller' the same as the truth-status of 'This door leads to freedom'?" For both of these questions, the answer will be the same as the true answer to the question "Is this the door to freedom?" Basically, you need to somehow "cancel" out the unknown of whether the person you're talking to is a truth-teller or liar.

The answer is as simple as math.

I would ask either guy to put the correct answer to (for example) 9x9 on the door that leads to freedom. If its the guy that always lies he would put the wrong answer on the wrong door because he always lies. If it's the guy that tells the truth he would put the correct answer on the correct door.

• This doesn't tell us why the answer works – boboquack May 3 '17 at 3:04
• Welcome to PSE! You need to put your answer in spoiler tags using '>!' before your content. Hope you already took a tour – Techidiot May 3 '17 at 3:31
• Each guard has 4 options: Put the correct answer on the freedom door, the wrong answer on the freedom door, the correct answer on the hangman's door, and the wrong answer on the hangman's door. The truth telling guard would choose the first option, but a lying guard could choose any of the other three options since they are all lies (since they are not the truth). – Trenin May 3 '17 at 16:51

protected by Community♦Mar 8 '18 at 17:10

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).