Island of Liars and Honest People (a small Prolog example)

-> Home page -> Favourites flag

Once upon a time there was a small island inhabited by a community of people. Every day they lived their lives in peace, mainly sitting and gazing into clear water surrounding the island. Nobody would perceive something strange with the people until trying to communicate with them.

The truth is, that the people were divided into two different tribes - liars and honest people. There was no apparent mark to distinguish the people one from another except their words:

  • Every time the honest people said something, you could bet it was truth
  • On the other hand, you could count on liars to say nothing but lie.
Due to this local speciality travellers always had a tough time, especially when traveling on the base of directions obtained from local people. Not knowing who lies and who is truthful could completely ruin all travel plans and spoil holiday. In order to be able to travel (and survive), travellers should develop an ability to distinguish liars from honest people.

Let's exercise - imagine you talked to a few inhabitants. As a result, you have obtained a few statements. Based on them, it is up to you to decide, who is a liar and who is a honest person.

  • B said: "A claims about himself that he is a liar."
  • C said: "B is a liar."
Question & answer
  • B said: "A said about A, B and C that only one of them is a truthful person."
  • C said: "B is a liar."
Question & answer
  • A said: "One of A and B is a liar."
Question & answer
  • A said: "B is a truthful person or I am a liar."
Question & answer
  • A said: "I am a liar but B is a truthful person."
Question & answer
  • A said: "B is a liar."
  • B said: "A is the same as C."
Question & answer
  • A said: "All of us are liars."
  • B said: "One of A, B and C is a truthful person."
Question & answer
  • A said: "All of us are liars."
  • B said: "One of A, B and C is a liar."
Question & answer
Try to solve the following example:
  • A said: "If B is a truthful person then I am a liar."
or try to solve this one:
  • A said: "B is a truthful person."
  • B said: "If A is a truthful person then C is also a truthful person."

And of course, if you are interested in the program to generate the answers to the above given examples, you can find it here.

If playing with the program is what you want, here it is. For your convenience, the questions relevant to the above given examples are attached as well. Have fun to experiment.


Copyright © MM
Last updated 1.11.2006