Skip to content

Instantly share code, notes, and snippets.

@ckazu
Created June 6, 2018 07:38
Show Gist options
  • Save ckazu/06697521ab2baee81344bda1904daee9 to your computer and use it in GitHub Desktop.
Save ckazu/06697521ab2baee81344bda1904daee9 to your computer and use it in GitHub Desktop.
% facts. 磯野家
male(波平).
male(カツオ).
male(タラ).
male(マスオ).
female(フネ).
female(ワカメ).
female(サザエ).
parent(波平, サザエ).
parent(波平, カツオ).
parent(波平, ワカメ).
parent(フネ, サザエ).
parent(フネ, カツオ).
parent(フネ, ワカメ).
parent(サザエ, タラ).
parent(マスオ, タラ).
% rules.
grandparent(X, Z):-
parent(X, Y),
parent(Y, Z).
father(X, Y):-
parent(X, Y),
male(X).
mother(X, Y):-
parent(X, Y),
female(X).
grandfather(X, Z):-
grandparent(X, Z),
male(X).
grandmother(X, Z):-
grandparent(X, Z),
female(X).
sibling(X, Y):-
father(A, X),
father(A, Y),
mother(B, X),
mother(B, Y),
X \= Y.
% 親戚関係
male(波平の父).
female(波平の母).
parent(波平の父, 波平).
parent(波平の父, 海平).
parent(波平の父, なぎえ).
parent(波平の母, 波平).
parent(波平の母, 海平).
parent(波平の母, なぎえ).
parent(なぎえ, ノリスケ).
parent(ノリスケ, イクラ).
parent(タイ子, イクラ).
いとこ(X, Y):-
parent(A, X),
parent(B, Y),
sibling(A, B).
はとこ(X, Y):-
grandparent(A, X),
grandparent(B, Y),
sibling(A, B).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment