-
Notifications
You must be signed in to change notification settings - Fork 3
/
einsteins_zebra_riddle.owl.yml
429 lines (348 loc) · 9.8 KB
/
einsteins_zebra_riddle.owl.yml
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
---
- iri: https://w3id.org/yet/undefined/einstein-zebra-puzzle-ontology#
- annotation: "This file ist strongly based on the work of Denis Ponomaryov, see https://persons.iis.nsk.su/en/ponom/ontologies"
- annotation: "source1: https://persons.iis.nsk.su/files/persons/pages/einsteins_riddle.owl"
- annotation: "source2: https://github.com/RDFLib/OWL-RL/files/1533408/einsteins_riddle.owl.txt"
# ----------------------------------------------------------------------------------------------------------------------
# Pets:
- owl_individual:
dog:
types:
- "owl:Thing"
- owl_individual:
zebra:
types:
- "owl:Thing"
# shortcut to create multiple individuals of the same kind
- owl_multiple_individuals:
names:
- fox
- horse
- snails
types:
- "owl:Thing"
- owl_class:
Pet:
EquivalentTo:
OneOf:
- dog
- zebra
- snails
- fox
- horse
# ----------------------------------------------------------------------------------------------------------------------
# Persons:
- owl_multiple_individuals:
names: [Englishman, Japanese, Norwegian, Spaniard, Ukrainian]
types:
- "owl:Thing"
- owl_class:
Man:
EquivalentTo:
OneOf: [Englishman, Japanese, Norwegian, Spaniard, Ukrainian]
# ----------------------------------------------------------------------------------------------------------------------
# houses:
- owl_multiple_individuals:
names: [house_1, house_2, house_3, house_4, house_5]
types:
- "owl:Thing"
- owl_class:
House:
EquivalentTo:
OneOf: [house_1, house_2, house_3, house_4, house_5]
# ----------------------------------------------------------------------------------------------------------------------
# Color:
- owl_multiple_individuals:
names: [blue, green, ivory, red, yellow]
types:
- "owl:Thing"
- owl_class:
Color:
EquivalentTo:
OneOf: [blue, green, ivory, red, yellow]
# ----------------------------------------------------------------------------------------------------------------------
# Beverage:
- owl_multiple_individuals:
names: [coffee, milk, orange_juice, tea, water]
types:
- "owl:Thing"
- owl_class:
Beverage:
EquivalentTo:
OneOf: [coffee, milk, orange_juice, tea, water]
# ----------------------------------------------------------------------------------------------------------------------
# Cigarette:
- owl_multiple_individuals:
names: [Chesterfields, Kools, Lucky_Strike, Old_Gold, Parliaments]
types:
- "owl:Thing"
- owl_class:
Cigarette:
EquivalentTo:
OneOf: [Chesterfields, Kools, Lucky_Strike, Old_Gold, Parliaments]
# ----------------------------------------------------------------------------------------------------------------------
# ObjectProperties
# ----------------------------------------------------------------------------------------------------------------------
- owl_object_property:
right_to:
Characteristics:
- Functional
- InverseFunctional
# use Thing instead of House (otherwise there is a conflict with Nothing)
Domain:
- "owl:Thing"
Range:
- "owl:Thing"
- owl_inverse_property:
left_to:
Inverse: right_to
# ---
- owl_object_property:
has_color:
Characteristics:
- Functional
- InverseFunctional
Domain:
- House
Range:
- Color
- owl_inverse_property:
inv_has_color:
Inverse: has_color
# ---
- owl_object_property:
drinks:
Characteristics:
- Functional
- InverseFunctional
Domain:
- Man
Range:
- Beverage
- owl_inverse_property:
inv_drinks:
Inverse: drinks
# ---
- owl_object_property:
lives_in:
Characteristics:
- Functional
- InverseFunctional
Domain:
- Man
Range:
- House
- owl_inverse_property:
inv_lives_in:
Inverse: lives_in
# ---
- owl_object_property:
owns:
Characteristics:
- Functional
- InverseFunctional
Domain:
- Man
Range:
- Pet
- owl_inverse_property:
inv_owns:
Inverse: owns
# ---
- owl_object_property:
smokes:
Characteristics:
- Functional
- InverseFunctional
Domain:
- Man
Range:
- Cigarette
- owl_inverse_property:
inv_smokes:
Inverse: smokes
# ---
# ----------------------------------------------------------------------------------------------------------------------
# Facts
# ----------------------------------------------------------------------------------------------------------------------
# This is for "simple facts"
- property_facts:
right_to:
# connect individuals by this role
Facts:
- house_1: "owl:Nothing"
- house_2: house_1
- house_3: house_2
- house_4: house_3
- house_5: house_4
left_to:
Facts:
- house_5: "owl:Nothing"
# The following restrictions are for "complex facts"
# First, we handle for "implicit facts" which are not stated explicitly in the rules of the puzzle:
- restriction:
# Every Man owns some Pet.
Subject: Man
Body:
owns:
some: Pet
- restriction:
# Every Man drinks some Beverage.
Subject: Man
Body:
drinks:
some: Beverage
- restriction:
# Every Man lives in some House.
Subject: Man
Body:
lives_in:
some: House
- restriction:
# Every House has some Color.
Subject: House
Body:
has_color:
some: Color
# Note: this could also be represented as simple property fact. It is stated as `restriction` for didactic reasons.
- restriction:
# comment: "3. The Spaniard owns the dog."
# owlready-implementation: om.add_restriction_to_individual(n.owns.value(n.dog), n.Spaniard)
Subject: Spaniard
Body:
owns:
value: dog
- restriction:
# comment: "# 2. The Englishman lives in the red house."
# om.add_restriction_to_individual(n.lives_in.some(n.has_color.value(n.red)), n.Englishman)
Subject: Englishman
Body:
lives_in:
some:
has_color:
value: red
- restriction:
# comment: "# 4. Coffee is drunk in the green house."
# om.add_restriction_to_individual(n.Inverse(n.drinks).some(n.lives_in.some(n.has_color.value(n.green))), n.coffee)
Subject: coffee
Body:
Inverse:
drinks:
some:
lives_in:
some:
has_color:
value:
green
- property_facts:
# 5. The Ukrainian drinks tea. (simple fact)
drinks:
Facts:
- Ukrainian: tea
# 10. The Norwegian lives in the first house.
lives_in:
Facts:
- Norwegian: house_1
# 14. The Japanese smokes Parliaments.
smokes:
Facts:
- Japanese: Parliaments
- restriction:
# 6. The green house is immediately to the right of the ivory house.
# om.add_restriction_to_individual(n.Inverse(n.has_color).some(n.right_to.some(n.has_color.value(n.ivory))), n.green)
Subject: green
Body:
Inverse:
has_color:
some:
right_to:
some:
has_color:
value:
ivory
- restriction:
# 7. The Old Gold smoker owns snails.
Subject: Old_Gold
Body:
Inverse:
smokes:
some:
owns:
value: snails
- restriction:
# 8. Kools are smoked in the yellow house.
Subject: Kools
Body:
Inverse:
smokes:
some:
lives_in:
some:
has_color:
value: yellow
- restriction:
# 9. Milk is drunk in the middle house.
Subject: milk
Body:
Inverse:
drinks:
some:
lives_in:
value: house_3
- restriction:
# 11. The man who smokes Chesterfields lives in the house next (right_to) to the man with the fox.
# right_to is additional information
Subject: Chesterfields
Body:
Inverse:
smokes:
some:
lives_in:
some:
right_to:
some:
Inverse:
lives_in:
some:
owns:
value: fox
- restriction:
# 12. Kools are smoked in a house next to the house where the horse is kept.
# left_to is additional information
Subject: Kools
Body:
Inverse:
smokes:
some:
lives_in:
some:
left_to:
some:
Inverse:
lives_in:
some:
owns:
value: horse
- restriction:
# 13. The Lucky Strike smoker drinks orange juice.
Subject: Lucky_Strike
Body:
Inverse:
smokes:
some:
drinks:
value: orange_juice
- restriction:
# 15. The Norwegian lives next to (left_to) the blue house.
# left_to is additional information
Subject: Norwegian
Body:
lives_in:
some:
left_to:
some:
has_color:
value: blue
# this could be a list or simply stating that all individuals are different with special list item `__all__`
- different_individuals:
- __all__