Abbott@AEROSPACE@sri-unix.UUCP (07/26/83)
From: Abbott at AEROSPACE (Russ Abbott) The Association for Automatic Reasoning (AAR) presented the following version of The Truthtellers and Liars Problem in its most recent newsletter. On a certain island the inhabitants are partitioned into those who always tell the truch and those who always lie. I landed on the island and met three inhabitants A, B, and C. I asked A, "Are you a truth-teller or a liar?" He mumbled something which I couldn't make out. I asked B what A had said. B replied, "A said he was a liar." C then volunteered, "Don't believe B, he's lying." What can you tell about A, B, and C? Use the following predicate: p(X): X is true. Use the following structures: says(X, Y): X said by Y. t(X): the truthteller X. l(X): the liar X. Structures are used instead of predicates so that they can be used as arguments. In these terms, you may assume the following: p(t(X)); p(l(X)) % Everyone is either a truthteller \+ p(t(X)); \+ p(l(X)) % or a liar, but not both. p(t(X)), p(says(X, Y)) -> p(Y) % If a truthteller says something, p(l(X)), p(says(X, Y)) -> \+ p(Y) % it is true, and if a liar says p(y), p(says(X, Y)) -> p(t(X)) % something, it is not true, and vice \+ p(y), p(says(X, Y)) -> p(l(X)) % or versa. (Note it is necessary to use t, l, and says were used as structures, as in: p(t(X)) for "it is true that X is a truthteller.") What was said: says(a, mumble). says(b, says(a, l(a))). says(c, l(b)) Can you rephrase this in Prolog and derive: p(l(b)) and p(t(c))