# 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). – Gareth McCaughan Sep 27 '17 at 9:50
• @GarethMcCaughan Thanks, I've corrected the explanation. – Lawrence Sep 27 '17 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 – IanF1 Sep 27 '17 at 8:02
• @IanF1 Jamal ruled out all but the two highlighted rows. – jpmc26 Sep 27 '17 at 8:03
• I don't think that the truth table adds anything useful to the answer in this context. – Sarthak Mittal Sep 27 '17 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. – JBentley Sep 27 '17 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$. – rus9384 Sep 27 '17 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.

• This answer does not add anything to other answers. – Wen1now Sep 27 '17 at 9:10
• I feel I've offered a different way of solving the puzzle and presented it simply. – rabathehutch Sep 27 '17 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 – Wen1now Sep 27 '17 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. – Falco Sep 28 '17 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:

\begin{array} {|c|c|c|c|} \hline A&B&C&out\\ \hline 0&X&0&0\\ \hline 0&X&1&1\\ \hline 0&N&0&1\\ \hline 0&N&1&0\\ \hline 1&X&0&1\\ \hline 1&X&1&0\\ \hline 1&N&0&0\\ \hline 1&N&1&1\\ \hline \end{array}

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$).