/* Who is telling the truth in Picat. From Tanay Sarin https://medium.com/puzzle-sphere/only-a-few-can-solve-this-f4276b9810b5 """ Who is telling the truth? Harry says that Herminone is a liar. Herminone says the Ron is a liar. Ron says that both Harry and Herminone are liars. Here, we have to figure out who is telling truth and who is lying based only on the given statements. """ In this specific - and probably fictious - story, there is only one person that is telling the truth: Herminone, and both Harry and Ron are liars. 1. It cannot be true what Ron says (that both Harry and Herminone are liars), since it would then implicate that Herminone is telling the truth that Ron is a liar. This means that Ron is a liar which is not consistent with the assumption that Ron is telling the truth. 2. If Ron is a liar, this means that Herminone is telling the truth. 3. If Herminone is telling truth this means that Harry is also a liar. This model gives the same result: [0,1,0] I.e. that Herminone is the only one telling the truth. Note that neither the reasoning nor the model assumes that there are any specific number of truth tellers (or liars). This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import util. import cp. main => go. go ?=> P = [Harry,Herminone,Ron], P :: 0..1, Harry #<=> Herminone #= 0, Herminone #<=> Ron #= 0, Ron #<=> (Harry #= 0 #/\ Herminone #= 0), solve(P), println(P), fail, nl. go => true.