-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmusketeers_solution.pro
46 lines (40 loc) · 1.89 KB
/
musketeers_solution.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
%!bp -g "['musketeers_solution.pro']"
%
% @author Manuel Ebert
% @system b-prolog
place(hotel).
place(jardin).
place(estate).
action(clean).
action(meet).
action(duel).
who_did_what([ArDo, ArWh], [PaDo, PaWh], [AthDo, AthWh]) :-
All = [[ArDo, ArWh], [PaDo, PaWh], [AthDo, AthWh]], % For simplicity
action(ArDo), place(ArWh), % Aramis' stuff
action(AthDo), place(AthWh), % Athos' stuff
action(PaDo), place(PaWh), % Pathos' stuff
not(ArDo=PaDo), not(ArDo=AthDo), not(PaDo=AthDo), % Everyone is doing something different
not(ArWh=PaWh), not(ArWh=AthWh), not(PaWh=AthWh), % Everyone is at a different place
% "If either Aramis or Athos was in the Jardin, then someone cleaned his musket in the hotel"
% => Either Aramis was not in the Jardin or the cleaning happened in the hotel OR
% Either Athos was not in the Jardin or the cleaning happened in the hotel
(
(not(ArWh=jardin) ; member([clean, hotel], All)) ;
(not(AthWh=jardin) ; member([clean, hotel], All))
),
% "Pathos was not involved in a duel and the duel did not take place in the Jardin."
not(PaDo=duel), not(member([duel, jardin], All)),
% "Aramis lost his musket some days ago, and he was certainly not in the hotel."
not(ArDo=clean), not(ArWh=hotel),
% "If Pathos cleaned his musket then Constance has not been to the Jardin."
% => Either Pathos wasn't cleaning or the meeting did not happen in the Jardin
(
not(PaDo=clean) ; not(member([meet, jardin], All))
),
% "Cardinal Richelieu has been seen in Villier's estate if and only if Pathos was in Hotel."
(
(member([duel, estate], All) , PaWh=hotel) ;
(not(member([duel, estate], All)) , not(PaWh=hotel))
),
% "Women are not allowed in Treville's Hotel."
not(member([meet, hotel], All)), !.