Created
September 15, 2018 05:28
-
-
Save adrianwong/93f002ab44bfd92242a7232521e5b083 to your computer and use it in GitHub Desktop.
SWI-Prolog proof to "I'm My Own Grandpa"
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
husband(me, pretty_widow). | |
husband(my_dad, pretty_widow_daughter). | |
wife(X, Y) :- husband(Y, X). | |
father(me, bouncing_baby_boy). | |
father(my_dad, me). | |
father(my_dad, my_dad_new_son). | |
mother(pretty_widow, bouncing_baby_boy). | |
mother(pretty_widow, pretty_widow_daughter). | |
mother(pretty_widow_daughter, my_dad_new_son). | |
married(X, Y) :- husband(X, Y). | |
married(X, Y) :- wife(X, Y). | |
parent(X, Y) :- parent0(X, Y). | |
parent(X, Y) :- step_parent(X, Y). | |
step_parent(X, Z) :- | |
married(X, Y), | |
parent0(Y, Z), | |
\+ parent0(X, Z). | |
parent_in_law(X, Z) :- | |
married(Y, Z), | |
parent(X, Y), | |
\+ parent(X, Z). | |
parent0(X, Y) :- father(X, Y). | |
parent0(X, Y) :- mother(X, Y). | |
grandparent(X, Z) :- | |
parent(X, Y), | |
parent(Y, Z). | |
sibling(X, Y) :- distinct(sibling0(X, Y)). | |
sibling_in_law(X, Y) :- sibling_in_law0(X, Y). | |
sibling_in_law(X, Y) :- sibling_in_law0(Y, X). | |
sibling_in_law0(X, Z) :- | |
married(X, Y), | |
sibling(Y, Z). | |
sibling0(X, Y) :- | |
parent(Z, X), | |
parent(Z, Y), | |
X \= Y. | |
uncle_aunt(X, Z) :- | |
sibling(X, Y), | |
parent(Y, Z). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Congrats Adrian