Created
April 9, 2020 12:06
-
-
Save redraiment/c1908ebbc383bf850ed6b43ce2bb3394 to your computer and use it in GitHub Desktop.
通过人物实体、性别事实、父母关系来推算女儿关系。
This file contains hidden or 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
% 知识库 | |
%% 性别的实体 | |
female(ann). | |
female(eve). | |
%% 父母的实体 | |
parent(ann, mary). | |
parent(tom, eve). | |
parent(tom, mary). | |
% 规则 | |
%% 有相同孩子的两个人是配偶关系 | |
spouse(This, That) :- parent(This, Child), parent(That, Child), \+ (This = That). | |
%% 女性的配偶通常是男性 | |
male(Who) :- spouse(Who, Spouse), female(Spouse). | |
%% 女性小孩是女儿,配偶的女性小孩也是女儿 | |
daughter(Parent, Child) :- spouse(Parent, Spouse), (parent(Spouse, Child); parent(Parent, Child)), female(Child). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment