% Data:

optimist(alice).
pessimist(bob).
pessimist(charlie).
optimist(dee).
pessimist(ethan).
optimist(ethan).
optimist(grace).
optimist(kris).








% (A) Find suitable buddies -- one optimist, one pessimist.
buddies(A,B) :- optimist(A), pessimist(B).
buddies(A,B) :- optimist(B), pessimist(A).



%% Try queries for: 
% can alice & bob be buddies?
% can bob & alice be buddies?
% who can be buddies with bob?
% who can bob be buddies with?
% who can be buddies?



% (B) drink preferences

drinks(alice,water).
drinks(alice,gin).
drinks(alice,martini).
drinks(bob,soda).
drinks(charlie,water).
drinks(charlie,soda).
drinks(charlie,whiskey).
drinks(charlie,martini).
drinks(ethan,water).
drinks(kris,soda).
drinks(kris,martini).
drinks(kris,margarita).

% Find every drink that charlie likes.
% Find everybody who likes martinis.
% Find all optimists who like whiskey.

% Write drinksGinWith  -- will two people share a bottle of gin?
  
drinksGinWith(A,B) :- drinks(A,gin), drinks(B,gin), A\=B.

  
% Write drinksWith -- shares a preference
drinksWith(A,B) :- drinks(A,Dr), drinks(B,Dr), A\=B.



% Btw: you can download any of 'xsb', or 'swi-prolog', or 'gnu-prolog'.
%    'xsb' is already installed on rucs, so it doesn't require further work.




% No fundamental difference between facts and rules;
% a fact is just a rule with no variables.
%
%%%  drinks(charlie,X).

%
% Charlie should join AA; he drinks anything.
% [Including other people?!]

% It's weird to name a variable which we never use;
% the special variable `_` can be used.
%
%%% drinks(charlie,_).
%
% Underscore is special because even if you mention it
% two or more times, it can match two *different* values:
%
twoNonTeaTotalers(A,B) :- drinks(A,_), drinks(B,_).
% A and B may not drink the same thing 
% (but they both drink *something*, unlike dee.)



%%%%%%%

