View source with raw comments or as raw
    1% A simple family database
    2
    3% An unrelated program. As full server this is solved. Using the dynamic
    4% calling we only consider  predicates  reachable   from  the  query and
    5% global constraints whose call-tree overlaps with the query.
    6test(X) :- not test2(X, Y).
    7test(X).
    8test2(X, Y) :- (Y \= 1, not test3(X)).
    9test2(X, 1) :- not test3(X).
   10test3(X) :- not test(X).
   11
   12% The family
   13male(bob).
   14male(bo).
   15male(ben).
   16male(jeff).
   17male(ron).
   18male(tim).
   19male(ray).
   20
   21female(may).
   22female(joy).
   23female(jill).
   24female(kathy).
   25female(ali).
   26female(sam).
   27female(beth).
   28
   29father(bob,jill).
   30father(bob,bo).
   31%father(bob,kathy).
   32%father(bo,ron).
   33father(bo,ali).
   34father(ben,sam).
   35%father(jeff,beth).
   36%father(jeff,tim).
   37%father(jeff,ray).
   38
   39mother(may,jill).
   40mother(may,bo).
   41%mother(may,kathy).
   42%mother(joy,ron).
   43mother(joy,ali).
   44mother(jill,sam).
   45%mother(kathy,beth).
   46%mother(kathy,tim).
   47%mother(kathy,ray).
   48
   49
   50parent(X,Y) :- father(X,Y).
   51parent(X,Y) :- mother(X,Y).
   52
   53grandparent(X,Y):-parent(X,Z),parent(Z,Y).
   54
   55ancestor(X,Y) :- parent(X,Y).
   56ancestor(X,Y) :- parent(X,Z),ancestor(Z,Y).
   57
   58sibling(X,Y):-X\=Y,parent(Z,X),parent(Z,Y).
   59
   60sister(X,Y):-sibling(X,Y),female(X).
   61
   62brother(X,Y):-sibling(X,Y),male(X).
   63
   64cousin(X,Y):-parent(P1,X),parent(P2,Y),P1\=P2.%sibling(P1,P2).
   65
   66hardmath(X) :- X is A+(B*C-(D/E-F)*G)*H.
   67
   68
   69
   70?- ancestor(bob,sam).