# Solving the Trunk Puzzle

This is my solution to a logic puzzle from *Discrete Mathematics and Its Applications* by Kenneth H. Rosen, which I recently picked up and am working through. It’s exercise 17c from Section 1.2.

## Question

As a reward for saving his daughter from pirates, the King has given you the opportunity to win a treasure hidden inside one of three trunks. The two trunks that do not hold the treasure are empty. To win, you must select the correct trunk.

The trunks are inscribed with the messages:

- Trunk 1: “The treasure is in Trunk 3”
- Trunk 2: “The treasure is in Trunk 1”
- Trunk 3: “This trunk is empty”

“Exactly two of the inscriptions are true,” says the Queen.

… determine whether the Queen who never lies could state this, and if so, which trunk the treasure is in.

## Solution

### Compound Proposition

Let’s assign each trunk a propositional variable *p _{1}*,

*p*, or

_{2}*p*with a true value if the trunk contains the treasure and a false value if it does not. Using these variable the inscriptions on trunk 1, trunk 2, and trunk 3 can be written

_{3}*p*,

_{3}*p*, and ¬

_{1}*p*, respectively.

_{3}The Queen’s proposition that “exactly two of the inscriptions are true” can be written in English as “one of either the first inscription is false, or the second inscription is false, or the third inscription is false”. That sentence can be expressed as the compound proposition:

(¬*p _{3}* ∧

*p*∧ ¬

_{1}*p*) ⊕ (

_{3}*p*∧ ¬

_{3}*p*∧ ¬

_{1}*p*) ⊕ (

_{3}*p*∧

_{3}*p*∧ ¬(¬

_{1}*p*))

_{3}That can be simplified by removing the duplication of ¬*p _{3}* and the contradiction (

*p*∧ ¬

_{3}*p*∧ ¬

_{1}*p*). Finally we can remove the double negation ¬(¬

_{3}*p*) because ¬(¬

_{3}*p*) ≡

_{3}*p*.

_{3}(¬*p _{3}* ∧

*p*

_{1}*p*

_{3}*p*∧ ¬

_{3}*p*∧ ¬

_{1}*p*) ⊕

_{3}*p*∧

_{3}*p*

_{1}*p*)

_{3}The remaining compound proposition is:

(¬*p _{3}* ∧

*p*) ⊕ (

_{1}*p*∧

_{3}*p*)

_{1}### Truth Table

Our compound proposition can be used to construct a truth table:

# | p_{1} |
p_{2} |
p_{3} |
¬p_{3} |
¬p ∧ _{3}p_{1} |
p ∧ _{3}p_{1} |
(¬p ∧ _{3}p) ⊕ (_{1}p ∧ _{3}p)_{1} |
---|---|---|---|---|---|---|---|

1 | T | T | T | F | F | T | T |

2 | T | T | F | T | T | F | T |

3 | T | F | T | F | F | T | T |

4 | T | F | F | T | T | F | T |

5 | F | T | T | F | F | F | F |

6 | F | T | F | T | F | F | F |

7 | F | F | T | F | F | F | F |

8 | F | F | F | T | F | F | F |

Examining the truth table, row 4 is the only row that is both satisfiable and where the treasure exists in only one of *p _{1}*,

*p*, or

_{2}*p*, or in other words where

_{3}*p*⊕

_{1}*p*⊕

_{2}*p*. Therefore trunk 1 contains the treasure.

_{3}