Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
25 lines
532 B
Prolog
25 lines
532 B
Prolog
%% family — facts + transitive ancestor + derived relations.
|
|
%% Five-generation tree: tom -> bob -> {ann, pat} -> jim, plus tom's
|
|
%% other child liz.
|
|
|
|
parent(tom, bob).
|
|
parent(tom, liz).
|
|
parent(bob, ann).
|
|
parent(bob, pat).
|
|
parent(pat, jim).
|
|
|
|
male(tom).
|
|
male(bob).
|
|
male(jim).
|
|
male(pat).
|
|
female(liz).
|
|
female(ann).
|
|
|
|
father(F, C) :- parent(F, C), male(F).
|
|
mother(M, C) :- parent(M, C), female(M).
|
|
|
|
ancestor(X, Y) :- parent(X, Y).
|
|
ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y).
|
|
|
|
sibling(X, Y) :- parent(P, X), parent(P, Y), \=(X, Y).
|