2
6
7test1(X) :- not test2(X, Y).
8test1(X).
9test2(X, Y) :- (Y \= 1, not test3(X)).
10test2(X, 1) :- not test3(X).
11test3(X) :- not test1(X).
12
14
15male(bob).
16male(bo).
17male(ben).
18male(jeff).
19male(ron).
20male(tim).
21male(ray).
22
23female(may).
24female(joy).
25female(jill).
26female(kathy).
27female(ali).
28female(sam).
29female(beth).
30
31father(bob,jill).
32father(bob,bo).
35father(bo,ali).
36father(ben,sam).
40
41mother(may,jill).
42mother(may,bo).
45mother(joy,ali).
46mother(jill,sam).
50
51
52parent(X,Y) :- father(X,Y).
53parent(X,Y) :- mother(X,Y).
54
55grandparent(X,Y):-parent(X,Z),parent(Z,Y).
56
57ancestor(X,Y) :- parent(X,Y).
58ancestor(X,Y) :- parent(X,Z),ancestor(Z,Y).
59
60sibling(X,Y):-X\=Y,parent(Z,X),parent(Z,Y).
61
62sister(X,Y):-sibling(X,Y),female(X).
63
64brother(X,Y):-sibling(X,Y),male(X).
65
66cousin(X,Y):-parent(P1,X),parent(P2,Y),P1\=P2. 67
68hardmath(X) :- X is A+(B*C-(D/E-F)*G)*H.
69
70
71
72?- ancestor(bob,sam).