Advertisement
sb8623

ftree.pl

Apr 18th, 2023
1,946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.80 KB | Source Code | 0 0
  1. parent(tom, bob).
  2. parent(pam, bob).
  3. parent(tom, liz).
  4. parent(bob, ann).
  5. parent(bob, pat).
  6. parent(pat, jim).
  7.  
  8. child(X, Y) :-
  9.     parent(Y, X).
  10.  
  11. grandparent(X, Y) :-
  12.     parent(X, Z), parent(Z, Y).
  13.  
  14. grandchild(X, Y) :-
  15.     child(X, Z), child(Z, Y).
  16.  
  17. male(tom).
  18. female(pam).
  19. male(bob).
  20. female(liz).
  21. female(ann).
  22. male(pat).
  23. male(jim).
  24.  
  25. different(X, Y) :-
  26.     X \= Y.
  27.  
  28. father(X, Y) :-
  29.     parent(X, Y), male(X).
  30.  
  31. mother(X, Y):-
  32.     parent(X, Y), female(X).
  33.  
  34. brother(X, Y) :-
  35.     parent(Z, X), parent(Z, Y), male(X), different(X, Y).
  36.  
  37. sister(X, Y) :-
  38.     parent(Z, X), parent(Z, Y), female(X), different(X, Y).
  39.  
  40. predecessor(X, Y) :- parent(X, Y); parent(X, Z), predecessor(Z, Y).
  41.  
  42. sibling(X, Y) :-
  43.     brother(X, Y); sister(X, Y).
  44.  
  45. aunt(X, Y) :-
  46.     parent(Z, Y), sister(X, Z).
Tags: pl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement