Murder Mystery

Another fun puzzle, based on the problem No. 55 in [PFJ86] and published as a challenge by Decision Management Community.

Someone in Dreadsbury Mansion killed aunt Agatha. Agatha, the butler, and Charles live in Dreadsbury Mansion, and are the only ones to live there. A killer always hates, and is no richer than his victim. Charles hates no one that Agatha hates. Agatha hates everybody except the butler. The butler hates everyone not richer than aunt Agatha. The butler hates everyone whom Agatha hates. No one hates everyone. Who killed Agatha?

The idea — as in previous posts — is to use concept of predicates, constraints, relations, and relational operators to solve the problem; this way it is easily implemented in SQL.

The following set of constraints can be extracted from the text:

(c1) Agatha, Charles, and butler are the only ones to live there.
(c2) Agatha hates everybody except the butler.
(c3) Charles hates no one that Agatha hates.
(c4) The butler hates everyone whom Agatha hates.
(c5) No one hates everyone.
(c6) The butler hates everyone not richer than Agatha.
(c7) The killer hates Agatha, and is not richer than Agatha.

From this set of constraints it is now possible to derive predicates and relations to be used in reasoning.

Reasoning

1. From (c1) follows:

[p_01] Person (p) exists.

person {p}

2. From [p_01] and (c2) derive:

[p_02] Agatha hates person (p).

agatha_hates {p}

3. From [p_01], [p_02], and (c3) derive:

[p_03] Charles hates person (p).

charles_hates {p}

4. From [p_02] and (c4) derive

[p_04] The butler hates person (p).

butler_hates {p}

5. From [p_02], [p_03], and [p_04] derive:

[p_05] Person (h) hates person (p).

hate {h, p}

6. From [p_05] derive:

[p_06] Person (h) hates (n) people.

hate_cnt {h, n}

7. From [p_05] derive:

[p_07] Person (x) hates Agatha.

hates_agatha {x}

8. From [p_04] and (c6) derive:

[p_08] Person (x) is not richer than Agatha.

nrt_agatha {x}

9. From [p_07], [p_08], (c7), and (c5) derive the solution:

[p_09] Person (murderer) killed Agatha.

solution {murderer}

Solution

The SQL code is easy to follow in parallel with the reasoning section; it has been tested on PostgreSQL and MS SQL Server.

murderer
--------
Agatha