Created
July 5, 2018 23:11
-
-
Save mindcrime/d2f9bdad1f3ed7603d041c8f23ecc4f1 to your computer and use it in GitHub Desktop.
Prolog samples from Chapter 1 of Clocksin & Mellish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff(X,Y) :- X \== Y. | |
male(albert). | |
male(edward). | |
female(alice). | |
female(victoria). | |
parents(edward, victoria, albert ). | |
parents(alice, victoria, albert). | |
sister_of(X,Y) :- | |
female(X), | |
diff(X,Y), | |
parents(X, Mum, Dad ), | |
parents(Y, Mum, Dad ). | |
conceived(victoria, edward). | |
conceived(albert, edward). | |
conceived(victoria,alice). | |
conceived(albert, alice). | |
father(Dad,Child) :- male(Dad),conceived(Dad,Child). /* X is the father of Y */ | |
mother(Mum,Child) :- female(Mum),conceived(Mum,Child). /* X is the mother of Y */ | |
parent(Parent,Child) :- father(Parent,Child). | |
parent(Parent,Child) :- mother(Parent,Child). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment