2

I am working on a Knights and Knaves logic puzzle, and I have formulated a solution using a truth table. However, I'm wondering if there's a more efficient or faster way to arrive at the solution without having to manually create a large truth table, especially in cases with many statements.

The puzzle I'm working on involves five locals, A, B, C, D, and E, each making specific statements. The rules are as follows:

Knights always tell the truth. Knaves always lie. The statements from the locals are as follows:

A: "D is a knight, or E is a knave."

B: "Me and E are different."

C: "I am a knight or E is a knave."

D: "A is a knight or E is a knight."

E: "B is a knave or I am a knight."

My current solution involved creating a truth table with 32 combinations, but I'm looking for a more efficient approach to determine which locals are knights and which are knaves.

After my lengthy process, I concluded that everyone except E is a knight.

Is there a more efficient way to solve this puzzle without the need for a truth table? If so, I would appreciate any guidance or insights on how to approach such problems more effectively.

Bram28
  • 100,612
  • 6
  • 70
  • 118
  • 1
    Clearly the status of $E$ matters to everyone's claim, so I would start by testing both cases for $E$. – lulu Oct 18 '23 at 15:49
  • I use a bunch of different methods to solve a knights and knaves puzzle here: https://math.stackexchange.com/questions/3240256/is-there-a-general-effective-method-to-solve-smullyan-style-knights-and-knaves-p/3240280#3240280 – Bram28 Oct 18 '23 at 16:50
  • Some more: https://math.stackexchange.com/questions/3041917/knights-and-knaves-i-could-say/3041987#3041987 , https://math.stackexchange.com/questions/2672759/logic-knights-and-knaves-problem-involving-implication-question/2674252#2674252 , https://math.stackexchange.com/questions/2780292/how-to-obtain-quad-p-rightarrow-q-equiv-p-wedge-q-equiv-p/2780682#2780682 , https://math.stackexchange.com/questions/2086657/how-to-represent-this-situation-with-logic-propositions/2086794#2086794 – Bram28 Oct 18 '23 at 17:28

2 Answers2

7

Whenever anyone in a knight-or-knave problem says a statement $P$, we can read it as the guaranteed to be true statement

"Either I am a knight and $P$ is true, or I am a knave and $P$ is false."

Usually, though this is guaranteed to be true, it is also more complicated. But this has a good chance of simplifying nicely when anyone makes a self-referential statement. In this case, B is saying "Me and E are different". We can fix the grammar error at the same time as we deduce the true statement

True version of B's statement: "Either I am a knight and E is different from me, or I am a knave and E is the same as me."

In other words, "Either I am a knight and E is a knave, or I am a knave and E is a knave". No matter what's up with B, we deduce that E is a knave!


This is the "break-in". Now that we know that E is a knave, the five statements simplify to:

  • A: "(true statement)."

  • B: "I am a knight."

  • C: "(true statement)."

  • D: "A is a knight."

  • E: "B is a knave."

A and C are both knights because they make true statements. D is a knight because D claims that A is a knight, which is true. Finally, since E's statement must be false, B must be a knight.


Here are some general tips that can help us arrive at this particular solution.

  1. Turn assertions made by people in the puzzle into statements that you know are true. Another way to think about the operation we began with is that whenever person A says statement P, this tells us "P xor (A is a knave)".
  2. Look for statements we can understand with a smaller truth table. When B says, "E is different from me", we can do just a 4-case truth table to analyze this statement completely: we just need to know whether B is a knight, and whether E is a knight. This is true to a lesser extent for everyone else: when A says "D is a knight or E is a knave", we need only an 8-case truth table to deal with A, D, and E. B and C are irrelevant.
  3. Look for break-in deductions. This is a tip that has to do with puzzle-solving, rather than logic in general. In a well-written puzzle, there should be some way to solve it that doesn't require brute force.
  4. When you've made progress, simplify. Once we deduce that E is a knave, everyone else's statements become simpler to analyze.
  5. If you must do casework, think about valuable cases to choose. An alternate solution path here is to realize that everyone's statements hinge on whether E is a knight or a knave. So if we consider the two cases "E is a knight" and "E is a knave", then in both cases we can simplify considerably. In one case, we solve the problem; in the other, we arrive at a contradiction.
Misha Lavrov
  • 142,276
0

From $B$'s statement you can quickly figure out that $E$ is a knave, and then the rest trivially follows.

So, for this particular puzzle, no truth-table is needed. Or any formal method, for that matter,

However, other knights and knaves puzzles can be a good less straightforward, and for those, some formal method could be more helpful. In particular, it turns out that Boolean algebra is always good for these Knights and Knaves puzzles! For example, take a look here, where I use boolean algebra to solve a more complicated knights and knaves puzzle.

Let's see what boolean algebra can do with your puzzle.

Use $A$ to represent the claim that $A$ is a knight ... and use $B$, $C$, $D$, and $E$ accordingly.

Now, $A$ is a knight if and only if what $A$ says is true, and so $A$'s statement that '$D$ is a knight, or $E$ is a knave' can be represented as $A \leftrightarrow (D \lor \neg E)$

There are several ways to express $B$'s claim that $B$ and $E$ are different, but probably the most intuitive is to use $\neg (B \leftrightarrow E)$, and so given $B$'s statement we get:

$B \leftrightarrow \neg (B \leftrightarrow E)$

The rest is straightforward:

$C \leftrightarrow (C \lor \neg E)$

$D \leftrightarrow (A \lor E)$

$E \leftrightarrow (\neg B \lor E)$

Let's work with $B \leftrightarrow \neg (B \leftrightarrow E)$ first. Using a few basic equivalence principles regarding the $\leftrightarrow$, we get:

$B \leftrightarrow \neg (B \leftrightarrow E) \Leftrightarrow$

$B \leftrightarrow (B \leftrightarrow \neg E) \Leftrightarrow$

$(B \leftrightarrow B) \leftrightarrow \neg E \Leftrightarrow$

$\top \leftrightarrow \neg E \Leftrightarrow$

$\neg \top \leftrightarrow \neg \neg E \Leftrightarrow$

$\bot \leftrightarrow E \Leftrightarrow$

$\neg E$

Now use $\top \leftrightarrow \neg E \Leftrightarrow$ and $\bot \leftrightarrow E$ to substitute $\top$ and $\bot$ for any instances of $E$ and $\neg E$ respectively, giving us:

$A \leftrightarrow (D \lor \neg E) \Leftrightarrow A \leftrightarrow (D \lor \top) \Leftrightarrow A \leftrightarrow \top \Leftrightarrow A$

$C \leftrightarrow (C \lor \neg E) \Leftrightarrow C \leftrightarrow (C \lor \top) \Leftrightarrow C \leftrightarrow \top \Leftrightarrow C$

Also, since we now also have $A \leftrightarrow \top$:

$D \leftrightarrow (A \lor E) \Leftrightarrow D \leftrightarrow (\top \lor \bot) \Leftrightarrow D \leftrightarrow \top \Leftrightarrow D$

$E \leftrightarrow (\neg B \lor E) \Leftrightarrow \bot \leftrightarrow (\neg B \lor \bot) \Leftrightarrow \bot \leftrightarrow \neg B \Leftrightarrow \top \leftrightarrow B \Leftrightarrow B$

So there you have it: $A,B,C,D$ are all knights, and $E$ is a knave.

OK, so that was still a good number of steps, but once you get used to this method (especially once you get to know how to 'work' the $\leftrightarrow$), you will be able to do the above taking lots of short-cuts, and do things a lot more quickly.

But more importantly, this boolean algebra method really works well for far more complicated knights and knaves puzzles as well. For example, here is a website that has 382 knights and knaves puzzles, with the number of individuals in the puzzles ranging from 2 to 9. And with that many individuals, truth-tables are obviously no longer very practical, but the puzzles can also be too complicated to figure out without any symbolic method.

Bram28
  • 100,612
  • 6
  • 70
  • 118