-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextended_family_rules.n3
255 lines (220 loc) · 4.16 KB
/
extended_family_rules.n3
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#gedcom-relations file
#Originally by Jos De Roo
#Revised by Dan Goessling
@prefix gc: <http://www.daml.org/2001/01/gedcom/gedcom#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix ex: <http://www.daml.org/2000/10/daml-ex#> .
@prefix : <#>.
:gender = gc:sex.
#"If a child is a child in a family and a parent is a spouse in the family,
#then the parent is a parent of the child."
{
?child gc:childIn ?family.
?parent gc:spouseIn ?family
} => {
?child gc:parent ?parent
}.
# "If a child has parent and the parent is male, then then the childs's father is the parent."
{
?child gc:parent ?parent.
?parent :gender :M
} => {
?child gc:father ?parent
} .
{
?child gc:parent ?parent.
?parent :gender :F
} => {
?child gc:mother ?parent
}.
{
?child gc:parent ?parent
} => {
?parent gc:child ?child
}.
#"If a child of a parent is male, then the child is the son of the parent."
{
?child gc:parent ?parent.
?child :gender :M
} => {
?parent gc:son ?child
} .
{
?child gc:parent ?parent.
?child :gender :F
} => {
?parent gc:daughter ?child
}.
#Rules about grandparents
{
?child gc:parent ?parent.
?parent gc:parent ?grandparent
} => {
?child gc:grandparent ?grandparent
}.
{
?child gc:grandparent ?grandparent.
?grandparent :gender :M
} => {
?child gc:grandfather ?grandparent
}.
{
?child gc:grandparent ?grandparent.
?grandparent :gender :F
} => {
?child gc:grandmother ?grandparent
}.
{
?child gc:grandparent ?grandparent
} => {
:grandparent gc:grandchild ?child
} .
{
?child gc:grandparent ?grandparent.
?child :gender :M
} => {
:grandparent gc:grandson ?child
}.
{
?child gc:grandparent ?grandparent.
?child :gender :F
} => {
?grandparent gc:granddaughter ?child
}.
#Rules about siblings and brother and sisters
#Thanks to DanCon
#"If child1 is in a family, and child2 is in the family, and child1 is not child2, then child1 and child2 are siblings."
{
?child1 gc:childIn ?family.
?child2 gc:childIn ?family.
?child1 log:notEqualTo ?child2
} => {
?child1 gc:sibling ?child2
}.
{
?child2 gc:sibling ?child1
} => {
?child1 gc:sibling ?child2
}.
{
?child gc:sibling ?sibling.
?sibling :gender :M
} => {
?child gc:brother ?sibling
}.
{
?child gc:sibling ?sibling.
?sibling :gender :F
} => {
?child gc:sister ?sibling
}.
{
?child gc:sister ?sister
} => {
?child gc:sibling ?sister
}.
#Husbands and wives.
#The authors leave same-sex marriages as an exercise for the student.
{
?spouse1 gc:spouseIn ?family.
?spouse2 gc:spouseIn ?family.
?spouse1 log:notEqualTo ?spouse2
} => {
?spouse1 gc:spouse ?spouse2
}.
{
:spouse2 gc:spouse ?spouse1
} => {
:spouse1 gc:spouse ?spouse2
}.
{
?spouse gc:spouse ?husband.
?husband :gender :M
} => {
?spouse gc:husband ?husband
}.
{
?spouse gc:spouse ?wife.
?wife :gender :F
} => {
?spouse gc:wife ?wife
}.
#Aunts and uncles
{
?child gc:parent ?parent.
?parent gc:brother ?uncle
} => {
?child gc:uncle ?uncle
}.
{
?child gc:aunt ?aunt.
?aunt gc:spouse ?uncle
} => {
?child gc:uncle ?uncle
}.
{
?child gc:parent ?parent.
?parent gc:sister ?aunt
} => {
?child gc:aunt ?aunt
}.
{
?child gc:uncle ?uncle.
?uncle gc:spouse ?aunt
} => {
?child gc:aunt ?aunt
}.
#Nieces and Nephews
{
?parent gc:daughter ?child.
?parent gc:sibling ?sibling
} => {
?sibling gc:niece ?child
}.
{
?parent gc:son ?child.
?parent gc:sibling ?sibling
} => {
?sibling gc:nephew ?child
}.
#First Cousins
{
?cousin1 gc:parent ?sibling1.
?cousin2 gc:parent ?sibling2.
?sibling1 gc:sibling ?sibling2
} => {
?cousin1 gc:firstCousin ?cousin2
}.
#Second Cousins (new from Dan G)
{
?scousin1 gc:parent ?cousin1.
?scousin2 gc:parent ?cousin2.
?cousin1 gc:firstCousin ?cousin2
} => {
?scousin1 gc:secondCousin ?scousin2
}.
#ancestors
{
?child gc:parent ?parent
} => {
?child gc:ancestor ?parent
}.
{
?child gc:parent ?parent.
?parent gc:ancestor ?ancestor
} => {
?child gc:ancestor ?ancestor
}.
{
?child gc:ancestor ?ancestor
} => {
?ancestor gc:descendent ?child
}.
#generic cousin
{
?sibling1 gc:sibling ?sibling2.
?sibling1 gc:descendent ?descendent1.
?sibling2 gc:descendent ?descendent2
} => {
?descendent1 gc:cousin ?descendent2
} .