
% The Zebra Puzzle
% ================
% (TR/ALE User's Guide, page 34)
%
% Three different houses each contain 
%
% a different pet, 
% a different drink, and 
% an inhabitant of a different nationality.
% 
% The following six facts are true about these houses:
%
% 1) The man in the third house drinks milk.
% 2) The Spaniard owns the dog.
% 3) The Ukranian drinks the tea.
% 4) The Norwegian lives in the first house.
% 5) The Norwegian lives next to the tea drinker.
% 6) The juice-drinker owns the fox.
%
%
% Who owns the zebra? Who drinks juice?


signature(signature).

ext([norwegian,ukranian,spaniard,fox,dog,zebra,juice,tea,milk]).


background *>
(house1:nationality:N1,
 house2:nationality:(N2,(=\=N1)),
 house3:nationality:((=\=N1),(=\=N2)),

 house1:animal:A1,
 house2:animal:(A2,(=\=A1)),
 house3:animal:((=\=A1),(=\=A2)),

 house1:beverage:B1,
 house2:beverage:(B2,(=\=B1)),
 house3:beverage:((=\=B1),(=\=B2))).


clue *>
(house3:beverage:milk,                              % clue1

 (house1:nationality:spaniard,house1:animal:dog     % clue2
 ;house2:nationality:spaniard,house2:animal:dog
 ;house3:nationality:spaniard,house3:animal:dog),

 (house1:nationality:ukranian,house1:beverage:tea   % clue3
 ;house2:nationality:ukranian,house2:beverage:tea
 ;house3:nationality:ukranian,house3:beverage:tea),

 house1:nationality:norwegian,                      % clue4

 (house1:nationality:norwegian,house2:beverage:tea  % clue5
 ;house2:nationality:norwegian,house3:beverage:tea
 ;house2:nationality:norwegian,house1:beverage:tea
 ;house3:nationality:norwegian,house2:beverage:tea),

 (house1:beverage:juice,house1:animal:fox           % clue6
 ;house2:beverage:juice,house2:animal:fox
 ;house3:beverage:juice,house3:animal:fox)).


maximality *>                                       % maximality constraints
(house1:nationality:(norwegian;ukranian;spaniard),
 house2:nationality:(norwegian;ukranian;spaniard),
 house3:nationality:(norwegian;ukranian;spaniard),

 house1:animal:(fox;dog;zebra),
 house2:animal:(fox;dog;zebra),
 house3:animal:(fox;dog;zebra),

 house1:beverage:(juice;tea;milk),
 house2:beverage:(juice;tea;milk),
 house3:beverage:(juice;tea;milk)).
   