Skip to content

Instantly share code, notes, and snippets.

@veer66
Created February 2, 2023 01:23
Show Gist options
  • Save veer66/0ff150d726e81ac4f2e863813b388c94 to your computer and use it in GitHub Desktop.
Save veer66/0ff150d726e81ac4f2e863813b388c94 to your computer and use it in GitHub Desktop.
male(tom).
male(bob).
male(jim).
female(liz).
female(pat).
female(ann).
female(pam).
parent(pam,bob).
parent(tom,bob).
parent(tom,liz).
parent(bob,ann).
parent(bob,pat).
father(X,Y) :- parent(X,Y), male(X).
mother(X,Y) :- parent(X,Y),female(X).
grandparent(X,Z) :- parent(X,Y), parent(Y,Z).
sister(X,Y) :- parent(Z,X), parent(Z,Y), female(X), X\=Y.
same(X,Y) :- X=Y.
diff(X,Y) :- not(same(X,Y)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment