Finding Cheryl's Birthday with DEMO

2015-04-20

This report shows how to solve the famous riddle from Singapore (see New York Times) with epistemic model checking. We use DEMO_S5 from http://homepages.cwi.nl/~jve/software/demo_s5 and a modified version of KRIPKEVIS from https://w4eg.de/malvin/illc/kripkevis.

You can also download a PDF version of this report and the source files.

We first define the set of all possibilities:

allpos :: [(Int, String)]
allpos = [ (15,"May"), (16,"May"), (19,"May"), (17,"June"), (18,"June"),
  (14,"July"), (16,"July"), (14,"August"), (15,"August"), (17,"August") ]

This forms the set of worlds in our initial model. Moreover, also the set of actual worlds is the full set, hence allpos occurs twice in the definition below. The two elements of rels define the epistemic relations of Albert and Bernard. Instead of listing explicitly which possibilities they can distinguish we use haskell functions to say that they confuse the same day and the same month, respectively.

This is the initial model with all possibilities:

The formula saying that i knows Cheryl’s birthday is defined as the disjunction over all statements of the form “Agent i knows that the birthday is s”:

Now we update the model three times, using the function upd_pa for public announcements. First with Albert: I don’t know when Cheryl’s birthday is and I know that Bernard does not know.

The second announcement by Bernard: “Now I know when Cheryl’s birthday is.”

Finally, Albert says: “Now I also know when Cheryl’s birthday is.”

Lastly, this helper function uses texModel from KRIPKEVIS to generate the drawings: