likes(bob,footbool).
likes(bob,beer).
likes(bob,computers).
likes(alice,picnics).
likes(alice,champagne).
likes(alice,flowers).
likes(mark,footbool).
likes(mark,beer).
likes(mark,picnics).

% @< is alpha order to skip reflexive and symmetric variant
match(X,Y,Z) :- likes(X,Z), likes(Y,Z), X@<Y.

% Example queries
?- match(bob,U,V), format('~a likes ~a because of ~a.~n', [bob, U, V]), fail; true.
?- match(alice,U,V), format('~a likes ~a because of ~a.~n', [alice, U, V]), fail; true.

