% some facts about US relations mother(x,y). mother(y,z). brother(z,a). sister(a,b). mother(c,b). wife(f,c). father(d,z). wife(e,d). %1) we need basic facts to compute sex for the sake of a sister: sex(X,male) :- husband(_,X). sex(X,male) :- brother(_,X). sex(X,male) :- father(_,X). sex(X,male) :- wife(X,_). sex(X,female) :- wife(_,X). sex(X,female) :- sister(_,X). sex(X,female) :- mother(_,X). sex(X,female) :- husband(X,_). % 2) we will need to know parentage bio_parent(X,Y) :- mother(X,Y). bio_parent(X,Y) :- father(X,Y). bio_parent(X,Y) :- mother(Y,X),!,fail. bio_parent(X,Y) :- father(Y,X),!,fail. parent(X,Y) :- bio_parent(X,Y). % 3) we need to know about siblings bio_sibling(X,Y) :- sister(X,Y). bio_sibling(X,Y) :- brother(X,Y). sibling(X,Y) :- bio_sibling(X,Y). sibling(X,X) :- !,fail. % now we can add the inference rules: % RULE 1: What an AUNT is: aunt(Pers,Aunt) :- parent(Pers,Par), is_sister(Par,Aunt). is_sister(Pers,Sis) :- sex(Sis,female), sibling(Pers,Sis). %rule 2: Sibling commutativity % cannot use: % sibling(Pers,Sib2) :- sibling(Pers,Sib), sibling(Sib,Sib2). %but: we only care about the real siblings at first (rest will be % automatically inferred), so: sibling(Pers,Sib2) :- bio_sibling(Pers,Sib1), sibling(Sib1,Sib2). %rule 3: shared parents: sibling(Pers,Sib) :- parent(Pers,Par), parent(Sib,Par). %rule 4: parent siblings: sibling(Me, Pers) :- parent(Me, Par), sibling(Par, Pers).