Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SWI-Prolog proof to "I'm My Own Grandpa"
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).

This comment has been minimized.

Copy link

commented Oct 1, 2018

Congrats Adrian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.