Alexandru's Birthday Puzzle

2022-01-15

Malvin: What a great idea to have a workshop on the birthday of Alexandru. But I must confess that I do not know how old he gets.

Hans: I also do not know.

Sonja: Of course I know. But instead of just telling you his age, let me give you a puzzle. In fact, on the day of the workshop Alexandru will have an age that is a product of two prime numbers.

Malvin: Oh, nice, an age that can be used for Cryptography!

Hans: But probably the numbers are too low - I guess he must be between 40 and 90?

Sonja: Correct. Let me now tell each of you one of the prime numbers. Malvin will get a prime number between 1 and 10, and Hans will get a prime number between 10 and 20.

[ Sonja secretly tells Malvin and Hans a number. ]

Hans: I do not know the age and I do not know whether you know it.

Malvin: Aha! I did not know it before, but now I know it!

Hans: Oh, good, now I also know it!

Sonja: Great, and because all our readers are perfect logicians, they will also know it now.

Malvin and Hans: Happy Birthday Alexandru!


Written for the occasion of Alexandru Baltag’s birthday workshop. For information about the workshop and many other birthday wishes, see https://tinyurl.com/thebaltagworkshop (spoiler alert!).


The puzzle above can be solved using SMCDEL as follows.

-- Alexandru's Birthday Puzzle in SMCDEL

VARS 2,3,5,7,     -- first prime
     11,13,17,19  -- second prime

LAW  AND (
  -- one of each list must be true:
  OR ( 2, 3, 5, 7),
  OR ( 11, 13, 17, 19 ),
  -- but not more than one from each list
  AND ( ~(2 & 3), ~(2 & 5), ~(2 & 7)
      , ~(3 & 5), ~(3 & 7)
      , ~(5 & 7)
      ),
  AND ( ~(11 & 13), ~(11 & 17), ~(11 & 19)
      , ~(13 & 17), ~(13 & 19)
      , ~(17 & 19)
      ),
  -- manually exclude products below 40 and above 90:
  ~2,
  (3 -> (~11 & ~13)),
  (5 -> ~19),
  (7 -> ~13 & ~17 & ~19)
  )

OBS  hans:   11, 13, 17, 19
     malvin: 2, 3, 5, 7

-- list all states
WHERE?
  Top

-- list all states where the dialogue is true
WHERE?
  -- Hans: I do not know the age:
  ~ (AND ( hans knows whether 2, hans knows whether 3, hans knows whether 5) )
  &
  -- ... and I do not know whether you know it:
  ~ (hans knows whether AND (malvin knows whether 11, malvin knows whether 13, malvin knows whether 17))
  &
  -- Malvin: Aha! I did not know it before ...
  ~ AND (malvin knows whether 11, malvin knows whether 13, malvin knows whether 17)
  &
  -- ... but now I know it!
  < ! ~ (AND (hans knows whether 2, hans knows whether 3, hans knows whether 5) )
      & ~ (hans knows whether (AND ( malvin knows whether 11, malvin knows whether 13, malvin knows whether 17 )))
  >
    (AND ( malvin knows whether 11, malvin knows whether 13, malvin knows whether 17))