%% Family example %% brother: one can be his own brother %% brother1: one can not be his own brother %% To run this program under smodels %% lparse example.pl | smodels 0 | mkatoms father(ric, john). mother(jamie, john). father(ric, peter). mother(jamie, peter). father(john, sam). mother(mary, sam). father(john, bill). mother(mary, bill). gender(ric, male). gender(peter, male). gender(jamie, famale). gender(john, male). gender(sam, male). gender(bill, male). gender(mary, female). parent(X, Y) :- father(X, Y). parent(X, Y) :- mother(X, Y). child(X, Y) :- parent(Y, X). brother(X, Y) :- gender(X, male), father(F, X), father(F, Y), mother(M, X), mother(M, Y). brother1(X, Y) :- gender(X, male), father(F, X), father(F, Y), mother(M, X), mother(M, Y), neq(X, Y). %% The definition of uncle % X is an uncle of Y if X is a brother of Y's father uncle(X, Y) :- father(F, Y), brother1(X, F). % X is an uncle of Y if X is a brother of Y's mother uncle(X, Y) :- mother(M, Y), brother1(X, M). %% A hide declaration has two forms: %% #hide. %% smodels will not show any atom of the answer sets. %% or %% #hide p(X, Y). %% smodels will NOT show the atoms p(X,Y) of the answer sets. %% --- %% #show p(X, Y). %% smodels will show the atoms p(X, Y) of the answer sets. #hide. #show uncle(X, Y).