%======================================================
% Basic Constructs
%======================================================


%-------------------
% Facts 
%---------------------
good(prolog).
good(lisp).
bad(fortran).
student(dave).
student(sid).
student(bill).
student(joe).
student_of(sid,rpi).
likes(sid,prolog).
loves(dave,prolog).

father(abraham,issac).
father(issac,sarah).




%---------------------------------------------------------------------
%Simple Queries 
%---------------------------------------------------------------------
%?- good(X).          %Does there exist an  X such that X is good. Binds First Solution
	              %All Solutions


%--------------------------------------------------------------
% Asserting Facts into the database from he interpreter
%--------------------------------------------------------------

% :- assert(father(terach,abraham)).



%--------------------------------------------------------------
% Universal  Facts
% Variables are implicitly Universally Quantified
%--------------------------------------------------------------

between('TacoBell',Loc1,Loc2).      %There is a tacobell between every two locations
likes(X,pizza).                     %Every thing likes pizza.


%--------------------------------------------------------------
%Conjunctive Queries 
%--------------------------------------------------------------
/*
?- student_of(X,rpi), likes(X,prolog).
?- student(X),writenl(X),student_of(X,rpi),writenl(X).
?- student(X),writeseq([X,'is a student']),student_of(X,rpi),writenl('of rpi').
*/

%--------------------------------------------------------------
%Rules
%   -- Complex Queries in terms of simple queries 
%   -- Logical Implication
%--------------------------------------------------------------
goodStudent(X) :- student_of(X,rpi),likes(X,prolog).
goodStudent(X) :- loves(X,prolog).

grandfather(X,Z) :- father(X,Y), father(Y,Z).
