%**********************************************************************
%
%Murder Mystery Detective's General Knowledge Base
%
% Containts General Rules used by the "Detective" for solving crimes.

% For the detective's problem solving stratedgy
% see the mudermystery_problemsolver program.
%
%    
%
% All these must be declared dynamic for 'fact' and therefore
% better meta interpreter to work.
%
%*********************************************************************

:- dynamic 
	know/2, 
	friend/2, '-friend'/2, 
	with/2, '-with'/2, 
	hate/2, '-hate'/2, 
	inherits/2, 
	motiveToKill/2, 
	absent/1,
	hasMoney/1,
	willed/2.



%-----------------------------------------------
%If X and Y  are friends then it is necessarily the 
% case that X and Y know each other.
%-----------------------------------------------
know(X,Y) :- friend(X,Y).

%-----------------------------------------------
%know(X,Y)
%
%  If X and Y hate eachother then it is necessarily the 
%  case that X and Y know each other.
%-----------------------------------------------
know(X,Y) :- hate(X,Y).

%-----------------------------------------------
%If X and Y were "with" each other then it is necessarily the 
%  case that X and Y know each other.
%-----------------------------------------------
know(X,Y) :- with(X,Y).

%-----------------------------------------------
%If X does not know Y then it is necessarily the 
%  case that X and Y are not friends.
%-----------------------------------------------
'-friend'(X,Y) :- '-know'(X,Y).

%-----------------------------------------------
%If X does not know Y then it is necessarily the 
% case that X and Y were not "with" each other.
%-----------------------------------------------
'-with'(X,Y) :- '-know'(X,Y).


%-----------------------------------------------
%If X was absent it is necessarily the 
% case that X and Y  were not 'with' each other.
%-----------------------------------------------
'-with'(X,Y) :- absent(X).

'-with'(X,Y) :- absent(Y).


%-----------------------------------------------
%If X does not know Y then it is necessarily the 
% case that X and Y  do not hate each other.
%-----------------------------------------------
'-hate'(X,Y) :- '-know'(X,Y).


%------------------------------------------
% motiveToKil(X,Y)
%
%   A person X has a motive to kill Y
%   if Y has money and X inherits from Y
%
%------------------------------------------
motiveToKill(X,Y) :-
       hasMoney(Y),
       inherits(X,Y).

%------------------------------------------
% inherits(X,Y)
%
%  A person X inherits from Y if Y willed
%  X money
%------------------------------------------
inherits(X,Y) :-
        willed(Y,X,money).
