# Solve the following knights and knaves problem

A says:

“B is a knave.”

B says:

“A and C are of the same type.”

Knights tell the truth and Knaves lie.

What is C? (i.e. a knight, or a knave?)

# Determining C analytically

Let $$a,b,c$$ be booleans that mean "A, B or C (respectively) tells the truth". Also assume that if X says Y, then either both X and Y are true or both are false (i.e. X=Y). Then your statements are:

1. $$a = \bar{b}$$, from A says "B is a knave"; and
2. $$b = (a=c)$$, from B says "A and C are of the same type".

Substituting (1) into (2) gives us

$$\bar{a} = (a = c)$$. This reduces to $$\bar{c}$$ for $$a=T$$ as well as for $$a=F$$.

So

C is a knave.

• Pedantic note: it really isn't transitivity of "=" that you're appealing to (or if it is, you're right only by coincidence)! Transitivity means "if a = b and b = c then a = c" and so far as I can see that really isn't relevant here. What's relevant is that (a=b)=c turns out to be equivalent to "an odd number of a,b,c are true", and of course then the same holds for a=(b=c). Commented Sep 27, 2017 at 9:50
• @GarethMcCaughan Thanks, I've corrected the explanation. Commented Sep 27, 2017 at 10:10

Use truth table to find out what is C

If A is knight, then B is knave, means A and C are different type. A is knight so C is Knave
If A is knave, then B is knight, means A and C are same type. A is knave so C is Knave

• It's not clear how you used the truth table to get to the answer. On first glance it looks like you just highlighted the rows in the truth table that you had already worked out correctly above? But +1 for the explanation itself Commented Sep 27, 2017 at 8:02
• @IanF1 Jamal ruled out all but the two highlighted rows. Commented Sep 27, 2017 at 8:03
• I don't think that the truth table adds anything useful to the answer in this context. Commented Sep 27, 2017 at 10:26
• @IanF1 It seems like a useful visual guide to help run through all the possibilities without making a mistake or missing out any combinations. For example I can read the first row like this, "A is telling the truth, which means B is a knave, which means B lies, which contradicts the row, so this row is not correct". Continue until you've eliminated all the impossible rows. Commented Sep 27, 2017 at 14:34
• @SarthakMittal, for me it does. I constructed a formula $(A\oplus B)\land(B\rightarrow(A=C))\land(\overline B\rightarrow(A\oplus C))$ and checked it's truthtable (but then found this answer). Of course there is another way to solve it just by substituting $\overline A$ instead of $B$. Commented Sep 27, 2017 at 15:11

We are given:

• A: B is knave

• B: A = C.

If A is knight: then B is knave and AC so C is knave.
If A is knave: then B is knight and A = C so C is knave.
Therefore C is knave.

• I feel I've offered a different way of solving the puzzle and presented it simply. Commented Sep 27, 2017 at 9:22
• "If A is knight, then B is knave, means A and C are different type. A is knight so C is Knave If A is knave, then B is knight, means A and C are same type. A is knave so C is Knave" is what Jamal has answered; it is practically identical to your solution Commented Sep 27, 2017 at 10:01
• This answer uses a different approach to present and justify the solution - and frankly I think Jamals Truth-Table is just confusing and this one here is a simpler and better answer. Commented Sep 28, 2017 at 13:34

Assume that B is a knight (telling the truth). Therefore, A and C are the same type. A has asserted that B is a knave (lies). But this is false, by the assumption. Therefore, A is a knave (lies). Since A and C are the same type, C is a knave (lies).

Assume now that B is a knave (lies). Therefore, A and C are of different types. A has asserted that B is a knave (lies). This is true, by the assumption. Therefore, A is a knight (telling the truth). Since A and C are of different types, C is a knave (lies).

Since regardless of what we assume B to be, C is deduced to be a knave (lies), we conclude that C is a knave.

Note that we make no assumptions about A; we only make assumptions about B, and reason from the consequence of that assumption. Further, we ultimately do not know anything about A or B.

If C is a Knight, and so is B, then A is too, but A would be lying.
If C is a Knight, and B is a Knave, then A is a Knave, but then B is a Knight. Contradiction.
Conclusion: C is a Knave

### Sketch

$$A$$ says $$B$$ is a Knave is equivalent to $$B$$ says $$A$$ is a Knave - exactly one of $$A$$ and $$B$$ is a Knight.

Define a new operator $$[X=]$$, with $$X$$ a Boolean variable. If $$X$$ is true, $$[X=]$$ becomes $$=$$, otherwise it becomes $$\ne$$.

Now we have $$B\implies \lnot A$$ and $$B\implies (A\;\;[B=]\;\;C)$$.

And $$(A\;\;[\lnot A=]\;\;C)\implies C=\text{false}$$ - so C is a Knave.

### Tech stuff

$$(A\;\;[B=]\;\;C)$$ is a boolean ternary operator, written $$\triangle(A,B,C)$$. $$B$$ can be seen as switching between a XOR gate (X,0,false) and a NXOR gate (N,1,true).

The truth table is:

A B C out
0 X 0 0
0 X 1 1
0 N 0 1
0 N 1 0
1 X 0 1
1 X 1 0
1 N 0 0
1 N 1 1

It can also be written as:

$$(\lnot A \land \lnot B \land C) \lor (\lnot A \land B \land \lnot C) \lor (A \land \lnot B \land \lnot C) \lor (A \land B \land C)$$

and:

$$A+B+C-AB-BC-CA+ABC$$

### Proof

Rows $$3$$ and $$5$$ give the result for this question ($$A=\lnot B$$ and out is true imply $$C=0$$).

Let’s look at every possible scenario. First, we assume…

Scenario 1: A is a knight. They are telling the truth.

Then, it is true that B is a knave, and they are lying. So, A and C are not of the same type. Then, if A is a knight, then C is a knave.

Now we will assume…

Scenario 2: A is a knave. They are lying.

Then, it is false that B is a knave. So, B is a knight, and they tell the truth. That means A and C are of the same type. If A is a knave, then so is C.

So, we conclude that:

No matter whether A and B are knights or knaves, C will be a knave.

Another way of looking at it: if C were a knight, B's statement would be tantamount to claiming that A is a knight, which would be tantamount to claiming that B is a knave. But that's impossible, as no knight or knave can ever claim to be a knave. Therefore C must be a knave.