-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathontology.asp
162 lines (133 loc) · 10.5 KB
/
ontology.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
% 2-Clause BSD License
%
% Copyright (c) 2018, Patrick Hohenecker
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
% 1. Redistributions of source code must retain the above copyright notice, this
% list of conditions and the following disclaimer.
% 2. Redistributions in binary form must reproduce the above copyright notice,
% this list of conditions and the following disclaimer in the documentation
% and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
% ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
% DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
% ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
% (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
% LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
% ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
% (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
% author: Patrick Hohenecker ([email protected])
% version: 2018.1
% date: May 30, 2018
% The predicate person is needed in order to allow for the use of the default negation rules that are specified at the
% end. However, as we only consider individuals representing persons, this predicate does not provide any insights.
person(X) :- male(X) .
person(X) :- female(X) .
person(X) :- parentOf(X, Y) .
person(Y) :- parentOf(X, Y) .
%%%%%%%% SAFETY RULES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- ~person(X) .
:- male(X), female(X) .
:- ~male(X), ~female(X) .
:- parentOf(X, Y), parentOf(Y, X) .
%%%%%%%% GENDERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
~female(X) :- male(X) .
~male(X) :- female(X) .
%%%%%%%% FAMILY RELATIONSHIPS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Top-down Relationships --------------------------------------------------------------------------------------------
grandparentOf(X, Y) :- parentOf(X, Z), parentOf(Z, Y) .
greatGrandparentOf(X, Y) :- parentOf(X, Z), grandparentOf(Z, Y) .
auntUncleOf(X, Y) :- siblingOf(X, Z), parentOf(Z, Y) .
greatAuntUncleOf(X, Y) :- siblingOf(X, Z), grandparentOf(Z, Y) .
secondAuntUncleOf(X, Y) :- parentOf(Z, X), greatAuntUncleOf(Z, Y) .
%%%% Bottom-up Relationships -------------------------------------------------------------------------------------------
childOf(X, Y) :- parentOf(Y, X) .
grandchildOf(X, Y) :- grandparentOf(Y, X) .
greatGrandchildOf(X, Y) :- greatGrandparentOf(Y, X) .
nieceNephewOf(X, Y) :- auntUncleOf(Y, X) .
%%%% Other/Sideways Relationships --------------------------------------------------------------------------------------
siblingOf(X, Y) :- siblingOf(Y, X) .
siblingOf(X, Y) :- parentOf(Z, X), parentOf(Z, Y), X<>Y .
cousinOf(X, Y) :- cousinOf(Y, X) .
cousinOf(X, Y) :- parentOf(Z, X), auntUncleOf(Z, Y) .
secondCousinOf(X, Y) :- secondCousinOf(Y, X) .
secondCousinOf(X, Y) :- parentOf(Z, X), secondAuntUncleOf(Z, Y) .
firstCousinOnceRemovedOf(X, Y) :- cousinOf(Y, Z), parentOf(Z, X) . % german: Nichte/Neffe 2. Grades
%%%%%%%% GENDERED RELATIONSHIPS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sisterOf(X, Y) :- siblingOf(X, Y), female(X) .
brotherOf(X, Y) :- siblingOf(X, Y), male(X) .
motherOf(X, Y) :- parentOf(X, Y), female(X) .
fatherOf(X, Y) :- parentOf(X, Y), male(X) .
grandmotherOf(X, Y) :- grandparentOf(X, Y), female(X) .
grandfatherOf(X, Y) :- grandparentOf(X, Y), male(X) .
greatGrandmotherOf(X, Y) :- greatGrandparentOf(X, Y), female(X) .
greatGrandfatherOf(X, Y) :- greatGrandparentOf(X, Y), male(X) .
auntOf(X, Y) :- auntUncleOf(X, Y), female(X) .
uncleOf(X, Y) :- auntUncleOf(X, Y), male(X) .
greatAuntOf(X, Y) :- greatAuntUncleOf(X, Y), female(X) .
greatUncleOf(X, Y) :- greatAuntUncleOf(X, Y), male(X) .
secondAuntOf(X, Y) :- secondAuntUncleOf(X, Y), female(X) .
secondUncleOf(X, Y) :- secondAuntUncleOf(X, Y), male(X) .
girlCousinOf(X, Y) :- cousinOf(X, Y), female(X) .
boyCousinOf(X, Y) :- cousinOf(X, Y), male(X) .
girlSecondCousinOf(X, Y) :- secondCousinOf(X, Y), female(X) .
boySecondCousinOf(X, Y) :- secondCousinOf(X, Y), male(X) .
girlFirstCousinOnceRemovedOf(X, Y) :- firstCousinOnceRemovedOf(X, Y), female(X) .
boyFirstCousinOnceRemovedOf(X, Y) :- firstCousinOnceRemovedOf(X, Y), male(X) .
daughterOf(X, Y) :- childOf(X, Y), female(X) .
sonOf(X, Y) :- childOf(X, Y), male(X) .
granddaughterOf(X, Y) :- grandchildOf(X, Y), female(X) .
grandsonOf(X, Y) :- grandchildOf(X, Y), male(X) .
greatGranddaughterOf(X, Y) :- greatGrandchildOf(X, Y), female(X) .
greatGrandsonOf(X, Y) :- greatGrandchildOf(X, Y), male(X) .
nieceOf(X, Y) :- nieceNephewOf(X, Y), female(X) .
nephewOf(X, Y) :- nieceNephewOf(X, Y), male(X) .
%%%%%%%% DEFAULT NEGATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
~parentOf(X, Y) :- not parentOf(X, Y) , person(X), person(Y) .
~grandparentOf(X, Y) :- not grandparentOf(X, Y) , person(X), person(Y) .
~greatGrandparentOf(X, Y) :- not greatGrandparentOf(X, Y) , person(X), person(Y) .
~auntUncleOf(X, Y) :- not auntUncleOf(X, Y) , person(X), person(Y) .
~greatAuntUncleOf(X, Y) :- not greatAuntUncleOf(X, Y) , person(X), person(Y) .
~secondAuntUncleOf(X, Y) :- not secondAuntUncleOf(X, Y) , person(X), person(Y) .
~childOf(X, Y) :- not childOf(X, Y) , person(X), person(Y) .
~grandchildOf(X, Y) :- not grandchildOf(X, Y) , person(X), person(Y) .
~greatGrandchildOf(X, Y) :- not greatGrandchildOf(X, Y) , person(X), person(Y) .
~nieceNephewOf(X, Y) :- not nieceNephewOf(X, Y) , person(X), person(Y) .
~siblingOf(X, Y) :- not siblingOf(X, Y) , person(X), person(Y) .
~cousinOf(X, Y) :- not cousinOf(X, Y) , person(X), person(Y) .
~secondCousinOf(X, Y) :- not secondCousinOf(X, Y) , person(X), person(Y) .
~firstCousinOnceRemovedOf(X, Y) :- not firstCousinOnceRemovedOf(X, Y) , person(X), person(Y) .
~sisterOf(X, Y) :- not sisterOf(X, Y) , person(X), person(Y) .
~brotherOf(X, Y) :- not brotherOf(X, Y) , person(X), person(Y) .
~motherOf(X, Y) :- not motherOf(X, Y) , person(X), person(Y) .
~fatherOf(X, Y) :- not fatherOf(X, Y) , person(X), person(Y) .
~grandmotherOf(X, Y) :- not grandmotherOf(X, Y) , person(X), person(Y) .
~grandfatherOf(X, Y) :- not grandfatherOf(X, Y) , person(X), person(Y) .
~greatGrandmotherOf(X, Y) :- not greatGrandmotherOf(X, Y) , person(X), person(Y) .
~greatGrandfatherOf(X, Y) :- not greatGrandfatherOf(X, Y) , person(X), person(Y) .
~auntOf(X, Y) :- not auntOf(X, Y) , person(X), person(Y) .
~uncleOf(X, Y) :- not uncleOf(X, Y) , person(X), person(Y) .
~greatAuntOf(X, Y) :- not greatAuntOf(X, Y) , person(X), person(Y) .
~greatUncleOf(X, Y) :- not greatUncleOf(X, Y) , person(X), person(Y) .
~secondAuntOf(X, Y) :- not secondAuntOf(X, Y) , person(X), person(Y) .
~secondUncleOf(X, Y) :- not secondUncleOf(X, Y) , person(X), person(Y) .
~girlCousinOf(X, Y) :- not girlCousinOf(X, Y) , person(X), person(Y) .
~boyCousinOf(X, Y) :- not boyCousinOf(X, Y) , person(X), person(Y) .
~girlSecondCousinOf(X, Y) :- not girlSecondCousinOf(X, Y) , person(X), person(Y) .
~boySecondCousinOf(X, Y) :- not boySecondCousinOf(X, Y) , person(X), person(Y) .
~girlFirstCousinOnceRemovedOf(X, Y) :- not girlFirstCousinOnceRemovedOf(X, Y) , person(X), person(Y) .
~boyFirstCousinOnceRemovedOf(X, Y) :- not boyFirstCousinOnceRemovedOf(X, Y) , person(X), person(Y) .
~daughterOf(X, Y) :- not daughterOf(X, Y) , person(X), person(Y) .
~sonOf(X, Y) :- not sonOf(X, Y) , person(X), person(Y) .
~granddaughterOf(X, Y) :- not granddaughterOf(X, Y) , person(X), person(Y) .
~grandsonOf(X, Y) :- not grandsonOf(X, Y) , person(X), person(Y) .
~greatGranddaughterOf(X, Y) :- not greatGranddaughterOf(X, Y) , person(X), person(Y) .
~greatGrandsonOf(X, Y) :- not greatGrandsonOf(X, Y) , person(X), person(Y) .
~nieceOf(X, Y) :- not nieceOf(X, Y) , person(X), person(Y) .
~nephewOf(X, Y) :- not nephewOf(X, Y) , person(X), person(Y) .