Created
September 29, 2011 19:09
-
-
Save MirkoBonadei/1251629 to your computer and use it in GitHub Desktop.
The Art of Prolog - Exercise 2.1 Pag. 34
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
% The Art of Prolog - 2nd Edition | |
% Exercise 2.1 pag. 34 | |
father(terach, abraham). | |
father(terach, nachor). | |
father(terach, haran). | |
father(abraham, isaac). | |
father(haran, lot). | |
father(haran, milcah). | |
father(haran, yiscah). | |
mother(sarah, isaac). | |
male(terach). | |
male(abraham). | |
male(nachor). | |
male(haran). | |
male(isaac). | |
male(lot). | |
female(sarah). | |
female(milcah). | |
female(yiscah). | |
married_couple(sarah, abraham). | |
% Rules | |
parent(X, Y) :- father(X, Y). | |
parent(X, Y) :- mother(X, Y). | |
uncle(Uncle, Person) :- | |
brother(Uncle, Parent), | |
parent(Parent, Person). | |
niece(Niece, Person) :- | |
sibling(Parent, Person), | |
parent(Parent, Niece), | |
female(Niece). | |
sibling(Sib1, Sib2) :- | |
parent(Parent, Sib1), | |
parent(Parent, Sib2), | |
Sib1 =\= Sib2. | |
full_sibling(Sib1, Sib2) :- | |
father(Father, Sib1), | |
father(Father, Sib2), | |
mother(Mother, Sib1), | |
mother(Mother, Sib2), | |
Sib1 =\= Sib2. | |
brother(Brother, Sib) :- | |
parent(Parent, Brother), | |
parent(Parent, Sib), | |
male(Brother), | |
Brother =\= Sib. | |
sister(Sister, Sib) :- | |
parent(Parent, Sister), | |
parent(Parent, Sib), | |
female(Sister), | |
Sister =\= Sib. | |
% This is what in Italian we call 'Suocera', so she is the mother of the Wife or | |
% the mother of the husband. | |
mother_in_law(MotherInLaw, Husband) :- | |
married_couple(Wife, Husband), | |
mother(MotherInLaw, Wife). | |
mother_in_law(MotherInLaw, Wife) :- | |
married_couple(Wife, Husband), | |
mother(MotherInLaw, Husband). | |
% This is what in Italian we call 'Genero', so he is the husband of a female. | |
son_in_law(SonInLaw, Parent) :- | |
married_couple(Wife, SonInLaw), | |
parent(Parent, Wife). | |
% This is wht in Italian we call 'Cognato', so he is the: | |
% 1- brother of the husband | |
brother_in_law(BrotherInLaw, Wife) :- | |
married_couple(Wife, Husband), | |
brother(BrotherInLaw, Husband). | |
% 2- brother of the wife | |
brother_in_law(BrotherInLaw, Husband) :- | |
married_couple(Wife, Husband), | |
brother(BrotherInLaw, Wife). | |
% 3- the husband of the sister (it is not legally possible to have the opposite) | |
brother_in_law(BrotherInLaw, Sister) :- | |
married_couple(Wife, BrotherInLaw), | |
sister(Wife, Sister). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment