CS计算机代考程序代写 prolog database % Simple Database about a family

% Simple Database about a family
% CPSC 312 2021

% To load in Prolog,
% swipl
%?- [family].

% father(X, Y) means X is the father of Y
father(pierre, justin).
father(pierre, alexandre).
father(pierre, michel).
father(justin, xavier).
father(justin, ella_grace).
father(jean,sophie).

% mother(X, Y) means X is the mother of Y
mother(margaret, justin).
mother(margaret, alexandre).
mother(margaret, michel).
mother(sophie, xavier).
mother(sophie, ella_grace).
mother(estelle,sophie).

% parent(X,Y) means X is a parent of Y
parent(X,Y) :- mother(X,Y).
parent(X,Y) :- father(X,Y).

% grandmother(GP,C) means GP is a grandparent of C
grandmother(X,Z) :- mother(X,Y), parent(Y,Z).

sib(A,B) :-
parent(X,A),
parent(X,B).

% sibling(X,Y) means X is a sibling of Y
sibling(X,Y) :- parent(Z,X), parent(Z,Y), different(X,Y).

% different(A,B) means A is a different person than B
different(xavier,ella_grace).
different(ella_grace,justin).

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

% Some example queries:
% father(justin, xavier).
% mother(grace, pierre).
% father(justin, pierre).
% mother(M,justin).
% mother(M,pierre).
% father(pierre,C).
% parent(P,justin).
% parent(pierre,C).
% parent(X,Y).
% grandmother(GM,xavier).
% father(pierre,Y), parent(Y,Z).
% parent(X,Y), parent(Y,xavier).
% ancestor(X,xavier).
% ancestor(margaret,C).