One interesting feature of this problem - and you don't appreciate it unless you have the English to hand -
is that the original formulation of the facts does not mention fish at all. So the question is answered by a process
of elimination in which 'fish' is unified to a variable. It should work for any animal not mentioned - the German has
quite a menagerie. It really is custom made for showing the power of Prolog.
Here are the contents of the houses (derived by adding (member [_ fish _ _ _] Houses) (return Houses) to the literals
in riddle.
(pprint (prolog? (riddle)))
[
[norwegian cat dunhill water yellow]
[dane horse blends tea blue]
[brit bird pallmall milk red]
[german fish prince coffee green]
[swede dog bluemaster beer white]]
In Edinburgh syntax
riddle() :-
house(A), house(B), house(C), house(D), house(E), Houses = [A, B, C, D, E],
member([brit, _, _, _, red], Houses),
member([swede, dog, _, _, _], Houses),
member([dane, _, _, tea, _], Houses),
left([_, _, _, _, green], [_, _, _, _, white], Houses),
member([_, _, _, coffee, green], Houses),
member([_, bird, pallmall, _, _], Houses),
member([_, _, dunhill, _, yellow], Houses),
C = [_, _, _, milk, _],
A = [norwegian, _, _, _, _],
next([_, _, blends, _, _], [_, cat, _, _, _], Houses),
next([_, horse, _, _, _], [_, _, dunhill, _, _], Houses),
member([_, _, bluemaster, beer, _], Houses),
member([german, _, prince, _, _], Houses),
next([norwegian, _, _, _, _], [_, _, _, _, blue], Houses),
next([_, _, blends, _, _], [_, _, _, water, _], Houses),
member([_, fish, _, _, _], Houses),
print(Houses).
house([Nationality, Pet, Cigarette, Drink, Colour]).
next(X, Y, List) :- left(X, Y, List).
next(X, Y, List) :- left(Y, X, List).
left(L, R, [L, R | _]).
left(L, R, [_ | Houses]) :- left(L, R, Houses).
Mark