/* Murder puzzle in Picat. From NSolver http://www.cs.cityu.edu.hk/~hwchun/nsolver/content/show.shtml?Murder """ Who was the Murderer? Someone was murdered last night, and you are summoned to investigate the murder. The objects found on the spot that do not belong to the victim include: a pistol, an umbrella, a cigarette, a diary, and a threatening letter. There are also witnesses who testify that someone had argued with the victim, someone left the house, someone rang the victim, and some walked past the house several times about the time the murder occurred. The suspects are: Miss Linda Ablaze, Mr. Tom Burner, Ms. Lana Curious, Mrs. Suzie Dulles, and Mr. Jack Evilson. Each suspect has a different motive for the murder, including: being harassed, abandoned, sacked, promotion and hate. Other clues are given below. The cigarette belongs to Mr. Burner. Neither Ms. Curious nor the person who was sacked by the victim is the author of the threatening letter. Also, Ms. Curious does not own the pistol and she did not hate the victim. In fact, the person who hated the victim is the one who owns the diary that disclosed this information. The person who owns the umbrella is the one who left the victim's house without it. It is Mrs. Dulles who walked past the house several times. The person who argued with the victim is the man who stands a good chance of being promoted to the victim's position. As for Miss Ablaze, she had been often harassed by the victim, but she did not write the threatening letter and did not commit the murder. Finally, it is established that the people heard or seen by the witnesses are different people among the suspects and that they did not commit the murder; also each evidence-object belongs to a different suspect. Who was the murderer? And what was the motive, the evidence-object, and the activity associated with each suspect. """ Note: There are 4 different solutions with 2 different murders suspect = Evilson motive = abandoned object = letter suspect = Evilson motive = hate object = diary suspect = Burner motive = abandoned object = cigarette suspect = Burner motive = sacked object = cigarette This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> N = 5, % the evidence objects Objects = [Pistol, Umbrella, Cigarette, Diary, Letter], Objects :: 1..N, ObjectsS = ["pistol", "umbrella", "cigarette", "diary", "letter"], % the actions Actions = [Argue, Leave, _Rang, Walk, Murder], Actions :: 1..N, % ActionsS = ["argue", "leave", "rang", "walk", "murder"], % the motives Motives = [Harassed, _Abandoned, Sacked, Promotion, Hate], Motives :: 1..N, MotivesS = ["harassed", "abandoned", "sacked", "promotion", "hate"], % the suspects Suspects = [Ablaze,Burner,Curious,Dulles,_Evilson], Suspects = 1..N, SuspectsS = ["Ablaze","Burner","Curious","Dulles","Evilson"], all_different(Actions), all_different(Objects), all_different(Motives), Cigarette #= Burner, Letter #!= Curious, Sacked #!= Letter, Pistol #!= Curious, Hate #!= Curious, Hate #= Diary, Umbrella #= Leave, Walk #= Dulles, Argue #= Promotion, Harassed #= Ablaze, Letter #!= Ablaze, Murder #!= Ablaze, Vars = Actions ++ Objects ++ Motives, solve(Vars), % println(actions=Actions), % println(objects=Objects), % println(motives=Motives), nth(Motive,Motives,Murder), nth(Object,Objects,Murder), % nth(Action,Actions,Murder), nth(Suspect,Suspects,Murder), % println(murder=Murder), println(suspect=SuspectsS[Suspect]), println(motive=MotivesS[Motive]), println(object=ObjectsS[Object]), nl, fail, nl. go => true.