Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Application: Logic Puzzles

Logic puzzles are almost everywhere. They’re found in supermarket puzzle books to viral posts on social media. Some are well known, like the Zebra Puzzle and Sudoku puzzles. Some are lesser known, including the Knights and Knaves puzzle.

Regardless of which puzzle is being tackled, the logical tools we’ve explored throughout this chapter can be used to come up with the solution. In this section, we’ll explore different kinds of logic puzzles, and use mathematical logic to solve them.

Who Did It?

These kinds of puzzles involve a series of statements produced by an equal number of suspects. What is known is that some number of suspects are telling the truth, and the goal is to try and determine which of the suspects is the culprit.

Example 1.11.1

After receiving a large amount of money, gems, paintings, and gold, the bank closes and attempts to secure its vault. Over the weekend, a bank heist is carried out, leaving the bank with non of the deposit.

The bank hires a detective to determine which of four suspects – Adam, Billy, Chelsey, and Darla – is the thief. After questioning each suspect, the detective has collected the following statements:

Adam:Chelsey performed the heist.
Billy:I did not perform the heist.
Chelsey:Darla performed the heist.
Darla:Chelsey lied when she said I performed the heist.

The detective knows that only one of the four suspects performed the heist, and that only one of the suspects is telling the truth. So, who performed the heist?

One thing we can do is come up with four statements representing who is telling the truth:

a:Adam performed the heist.
b:Billy performed the heist.
c:Chelsey performed the heist.
d:Darla performed the heist.

The next thing we can do is represent each of the given statements with a letter:

α:Chesley performed the heist.
β:Billy did not perform the heist.
γ:Darla performed the heist.
δ:Statement γ is false

Now we’re in a position to examine each of the statements in turn. We have four scenarios to check.

Case 1: Assume Adam is the culprit

First, we check what happens when assuming Adam performed the heist and everyone else is innocent (remember, the detective knows that only one person is performed the heist, which is why we don’t have to test for several combinations.)

A = 1B = 0C = 0D = 0
α = 0β = 1γ = 0δ = 1

The above table has two statements which evaluate to true (those being β and δ.) But remember that the detective knows that only one of the statements is true (because only one person is telling the truth.) Thus, assuming Adam performed the heist produces a situation that contradicts previous knowledge. This means that Adam could not have performed the heist.

Case 2: Assume Billy is the culprit

Now we check what happens when we assume that Billy performed the heist.

A = 0B = 1C = 0D = 0
α = 0β = 0γ = 0δ = 1

Here, only one of the statements is true, which is compatible with our previous knowledge. So right now, it seems like Billy was the one who performed the heist. Just to be sure, let’s check what happens when we assume Chelsey performed the heist.

Case 3: Assume Chelsey is the culprit

A = 0B = 0C = 1D = 0
α = 1β = 1γ = 0δ = 1

Here, three statements are true, which contradicts the fact that the detective knows that only one statement is true. Let’s check the last case where we assume Darla performed the heist.

Case 4: Assume Darla is the culprit

A = 0B = 0C = 0D = 1
α = 0β = 1γ = 1δ = 0

Again, with more than one statement being true, we know that assuming Darla performed the heist leads to contradictions.

Only one case did not yield a contradiction with our prior knowledge, that being the case where we assume Billy performed the heist.

Thus, Billy performed the heist. Now the detective knows who to arrest.

As a recap, our solution to this puzzle involved checking several cases for compatibility with some known prior knowledge. The case that’s compatible with the prior knowledge offers the solution.

The Knights and Knaves Puzzle

Knights and Knaves puzzles were originally posed by Raymond Smullyan. The premise is that on a certain island, there are two kinds of inhabitants: knights (who always tell the truth), and knaves (who always lie.) Every inhabitant on the island is either a knight, or a knave (but obviously not both.)

Example 1.11.2

On an island, inhabitants are either knights (who always tell the truth) or knaves (who always lie) but not both.

You encounter two people A and B on this island. What are they if person A says “B is a knight.” and B says “The two of us are opposite types.”?

To answer this question we craft two propositions as follows:

a:Person A is a knight
b:Person B is a knight

Since there are only two types of people, we would then have that

¬a:Person A is a knave
¬b:Person B is a knave

Just as before, we could check cases.

Case 1: A is a knight, B is a knight

When A is a knight, we know that proposition a is true (a = 1.) But also remember that person A is asserting that B is a knight (meaning that proposition b is true, or that b = 1.)

But if B is also a knight, then since B would be telling the truth, that would have to make A a knave since person B is asserting that A and B are opposite types. This means that proposition a is false (a = 0.) This contradicts our earlier discovery that a = 1.

This case leads to contradictions, and as such must not be correct.

Case 2: A is a knave, B is a knight

Here, by assuming A is a knave, we have that a = 0 (alternatively, ¬a = 1.) Furthermore, since A is a knave, A must be lying about B being a knight. This tells us that B is a knave. This contradicts the initial assumption of this case where B is assumed to be a knight.

As such, this is also a false case.

Case 3: A is a knight, B is a knave

Here, since A is a knight, we have that a = 1. Furthermore, since A is a knight, A is telling the truth when claiming that B is a knight. But again, this contradicts our initial assumption that B is a knave.

Thus, this is also a false case.

That leaves only the last case, which must therefore be the correct case (A and B are both knaves) but lets examine it anyway just to be sure.

Case 4: A is a knave, B is a knave

Since A is a knave, we have that a = 0. Furthermore, A is lying when claiming that B is a knight, and so we must have that b = 0. So far, this is consistent with our assumptions for this case (A is a knave, and B is a knave.)

Now let’s examine B’s claim that A and B are opposite types. Since B is a knave, this means that B is lying about A and B being opposite types. Hence, A and B must be of the same type. Again, this is consistent with our initial assumptions.

Thus, since assuming that A and B are both knaves is consistent with all previous statements, it must be the case that both A and B are knaves.

The Muddy Children Puzzle

This is another logic puzzle posed by Raymond Smullyan. Here, a father asks his two children whether or not they know if they have a muddy forehead.

Example 1.11.3

A father gives permission for his two children (a boy and a girl) to play outside, but requests that they do not get dirty. However, during play, they both get muddy foreheads.

After the father confronts the two children, the father tells them

“At least one of you has a muddy forehead.”

The father then proceeds to simultaneously ask the children

“Do you know if you have a muddy forehead?”

The father asks the question twice, and both children are to respond at the same time. The question is, what do the children say each time?

Before we start to answer the question, let’s craft the following propositions:

b:The boy has a muddy forehead
g:The girl has a muddy forehead

Before even asking the children if they know if they have a muddy forehead the first time, both children know that at least one of them has a muddy forehead, meaning from the perspective of the children, we have that

b ∨ g = 1

Before the First Question

Before being asked the first time, here’s what the boy knows:

b ∨ g = 1
g = 1

This is not enough information to determine what b must be equal to because whether or not b = 1, the fact that g = 1 means the disjunction is true.

The girl knows something similar. From her perspective, she knows the following two things:

b ∨ g = 1
b = 1

Again, the girl does not have enough information to determine if she has a muddy forehead.

At this point, since neither child has enough information, they both answer “no.”

After the First Question

Now that the question was asked the first time, let’s examine things from the boy’s perspective.

Before the first time being asked, the boy knew the following things:

b ∨ g = 1
g = 1

However, he also learns that the girl is unsure if she has a muddy forehead. The only way the girl could be sure she did have a muddy forehead was if the boy did not have a muddy forehead, because the father said that at least one of them had a muddy forehead. Then if the boy did not have a muddy forehead that would mean that b = 0. The only way to have b ∨ g = 1 when b = 0 is to have g = 1.

The girl knows that b = 1, so even if g = 0, that would still mean that b ∨ g = 1.

In essence, the girl knew that there were two possibilities,

b ∨ g = 1 with b = 1 and g = 0
b ∨ g = 1 with b = 1 and g = 1

but did not have enough information to determine if she had a muddy forehead.

The same logic applies from the girl’s perspective.

Hence, after being asked the second time, both children knew that they each had a muddy forehead. Thus, they both answer “yes” after being asked the second time.

The Common Theme

Notice that in the first two puzzles we discussed, the main strategy we employed was to essentially perform case work. For each case, we look to see if that particular case was consistent with prior knowledge. We also looked for any cases that contradicted prior knowledge, any of which were immediately discarded.

It was the case that was accordant with the prior knowledge that provided the answer to the puzzle.

The last puzzle was solved by working through stages. Each stage, an additional piece of information was added. Accumulating new information in each additional stage was enough to solve the problem.

The common theme in each solution was breaking up the puzzle into several parts, and examining each part, whether that part was a stage or a case. Breaking up logic puzzles into stages or cases, and then examining each stage or case with an appropriate analysis is the key to solving almost any logic puzzle.