kb是
parent_of(john,ann).
parent_of(mary,ann).
parent_of(mary,sylvia).
parent_of(brian,sylvia).
female(sylvia).
female(ann).
?-Half_sister_of(X,Y).
X=ann
X=sylvia ;
X=sylvia
X=ann
答案 0 :(得分:0)
half_sister_of(X,Y) :-
parent_of(A,X),
parent_of(A,Y),
parent_of(B,X),
parent_of(C,Y),
not(A = B),
not(A = C),
not(B = C),
female(Y).
为了使Y成为X的同父异母,他们必须分享一个父母(A),而不与其他父母分享(B和C),Y必须是女性。