On a related note, Raymond Smullyan used this story's premise as setting for a series of logic puzzles in a book with the same title (that I really enjoyed as an adolescent). Smullyan's a famous logician, and the puzzles become increasingly difficult as the book goes on-- I could barely even work out how to begin thinking about the stuff in the latter half of the book, let alone solve the puzzles.
https://en.wikipedia.org/wiki/Raymond_Smullyan?useskin=vector