/* Minos and aminos: we are both married in Picat. From Adrian Groza "Modelling Puzzles in First Order Logic" """ Puzzle 75. Minos and aminos: we are both married News has reached me, Auspicious King, of a curious town in which every inhabitant is either a Mino or an Amino. "Oh my goodness, what are they?" asked the king. "The Minos are worshipers of a good god; whereas the Aminos worship an evil god. The Minos always tell the truth-they never lie. The Aminos never tell the truth-they always lie. All members of one family are of the same type. Thus given any pair of brothers, they are either both Minos or both Aminos. Now, I heard a story of two brothers, Bah- man and Perviz, who were once asked if they were married. They gave the following replies: Bahman: We are both married. Perviz: I am not married. Is Bahman married or not? And what about Perviz? (taken from Smullyan (1996)) """ [bahman = 0,perviz = 0,bahman_married = 0,pervis_married = 1] Bahman:Amino (married: false) Perviz:Amino (married: true) This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> % Amino: Always lies % Mino: Always tells the truth Amino = 0, Mino = 1, [Bahman,Perviz] :: [Amino,Mino], [BahmanMarried,PervizMarried] :: 0..1, % Thus given any pair of brothers,they are either both Minos or both Aminos. Bahman #= Perviz, % Bahman: We are both married. Bahman #<=> (BahmanMarried #= 1 #/\ PervizMarried #= 1), % Perviz: I am not married. Perviz #<=> PervizMarried #= 0, Vars = [bahman=Bahman,perviz=Perviz,bahman_married=BahmanMarried,pervis_married=PervizMarried], solve(Vars), println(Vars), Map = new_map([0="Amino",1="Mino"]), printf("Bahman:%w (married: %w) Perviz:%w (married: %w)\n", Map.get(Bahman),cond(BahmanMarried==1,true,false), Map.get(Perviz),cond(PervizMarried==1,true,false)), nl, fail, nl. go => true.