fork download
  1. % Define parent-child relationships
  2. parent(emma, robert).
  3. parent(kevin, mary).
  4. parent(anne, mary).
  5.  
  6. % Define father and mother relationships using parent predicate
  7. father(Father, Child) :- parent(Father, Child), male(Father).
  8. mother(Mother, Child) :- parent(Mother, Child), female(Mother).
  9.  
  10. % Define male and female family members
  11. male(kevin).
  12. female(emma).
  13. female(anne).
  14. female(mary).
  15.  
  16. % Define a rule to check for siblings
  17. siblings(Person1, Person2) :-
  18. parent(Parent, Person1),
  19. parent(Parent, Person2),
  20. Person1 \= Person2.
  21.  
  22. % Queries you can run to test the relationships
  23. % ?- father(Father, mary).
  24. % ?- mother(Mother, mary).
  25. % ?- siblings(mary, robert).
  26.  
  27.  
Success #stdin #stdout #stderr 0.02s 6720KB
stdin
father(Father, mary).
stdout
Standard output is empty
stderr
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit