Advertisement
LeeeeT

Untitled

Oct 16th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.63 KB | None | 0 0
  1. male(john).
  2. male(jack).
  3. male(peter).
  4. male(sam).
  5.  
  6. female(mary).
  7. female(linda).
  8. female(lisa).
  9. female(susan).
  10.  
  11. parent(john, jack).
  12. parent(john, linda).
  13. parent(mary, jack).
  14. parent(mary, linda).
  15. parent(jack, sam).
  16. parent(lisa, sam).
  17. parent(peter, susan).
  18. parent(susan, linda).
  19.  
  20. father(X, Y) :- male(X), parent(X, Y).
  21.  
  22. mother(X, Y) :- female(X), parent(X, Y).
  23.  
  24. sibling(X, Y) :- parent(P, X), parent(P, Y), X \= Y.
  25.  
  26. grandparent(X, Y) :- parent(X, Z), parent(Z, Y).
  27.  
  28. grandchild(X, Y) :- grandparent(Y, X).
  29.  
  30. uncle_or_aunt(X, Y) :- sibling(X, Z), parent(Z, Y).
  31.  
  32. cousin(X, Y) :- parent(P1, X), parent(P2, Y), sibling(P1, P2).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement