%%% -*- prolog -*-

%%% Give input to prolog program = consulting a database.
%%% Prolog = glorified database.

%%% Who works in this factory and drives a Lexus?

%%% Complete world assumption.
%%% Negation by failure, meaning:
%%%    can't show something to be true => treat it as false

% man(aristotle).
% man(socrates).

%%% All men are mortal.
%%% Aristotle is a man.
%%% THEREFORE Aristotle is mortal.

%%% forall X, man(X) => mortal(X).
%%% One way to prove that X is mortal is to prove that X is a man (forall X).

%%% write in prolog as:
mortal(X) :- man(X).
mortal(X) :- woman(X).

% woman(ada).
% woman(noetter).

man(abe).
man(isaac).
man(jacob).
man(esau).
woman(rachael).
parent(abe,isaac).
parent(isaac,jacob).
parent(isaac,esau).
parent(rachael,isaac).				  % rachael is parent of isaac
father(X,Y) :- man(X), parent(X,Y).		  % X is father of Y
mother(X,Y) :- woman(X), parent(X,Y).		  % X is mother of Y
brother(X,Y) :- man(X), parent(Z,X), parent(Z,Y). % X is brother of Y

ancestor(X,Y) :- parent(X,Y).	% X is ancestor of Y
ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y).

%%% Universe of discourse: above used predicates (father, parent, etc)
%%% over atoms (abe, isaac, etc).

%%% define (our own) list datatype.

empty(nil).			% empty list is: nil
%%% structures:
%%%   cons(X,Y) is list whose first elt is X and remaining elts are list Y.

%%% are two lists the same length.
samelen(nil,nil).
%% samelen(cons(E1,L1), cons(E2,L2)) :- samelen(L1,L2).
samelen(cons(_,L1), cons(_,L2)) :- samelen(L1,L2).
