|
I try to solve the well-known Einstein's five-house puzzle with owlready (http://udel.edu/~os/riddle-solution.html). But I met so much problem.
First I am not sure that it can be solved with how many statements. Second I do not know what is the best way to translate sentence such as "The person who lives in the green house likes drinking coffee". Third in 'lives in the side of the blue house', side means left or right, but I can not define it as `side = left | right`. Does anybody can solve it with owlready? I finished part of the puzzle. with puzzle: class Person(Thing): # define content pass class Pet(Thing): pass class House(Thing): no = 0 class Drink(Thing): pass class Smoke(Thing): pass class care(Person >> Pet, FunctionalProperty): pass class live(Person >> House, FunctionalProperty): pass class drink(Person >> Drink, FunctionalProperty): pass class take(Person >> Smoke, FunctionalProperty): pass class left(House >> House, FunctionalProperty): pass class right(House >> House, FunctionalProperty): inverse = left class side(House >> House): # right | left e = Person('English') s = Person('Sweden') ... red = House('RedHouse') ... dog = Pet('Dog') ... coffee = Drink('Coffee') ... pall = Smoke('PallMal') ... e.live = red s.care = dog d.drink = tea white.left = green n.live.left = [] g.smoke = prince n.live.side = blue print(n.live) |
|
Administrator
|
Hi,
I think this puzzle can be solved with an ontology (and thus with Owlready), using the reasoner. For side, you can assert e.g.: n.is_a.append( live.some( left.some(blue) | right.some(blue) ) ) Best regards, Jiba |
|
I am reactivating this old question because I think it has great didactic potential. In fact others did also try to tackle this, e.g. see: <https://github.com/RDFLib/OWL-RL/issues/3>. There are two owl-files linked but with none of them I was able to get a meaningful solution. For easier comprehension of my steps I documented them in this notebook: <https://github.com/cknoll/demo-material/blob/master/expertise_system/einstein-zebra-puzzle-owlready-solution-attempt.ipynb>.
Conclusion: I can load the ontologies but I cannot confirm that the concepts are defined as `owl:oneOf`-objects nor can find where statements like ### statement 10 :Norwegian :livesIn :House1 . or ### statement 15 :Norwegian :livesIn [ :isNextTo [ :hasColor :Blue ] ] . ended up. I would be glad for some hints. I think, once the ontology is correctly represented the solution could be obtained via something like sync_reasoner_pellet(infer_property_values=True, infer_data_property_values=True) Best, Carsten |
|
Update:
The first ontology which was provided as XML works (my error on beforehand). Documented solution: https://github.com/cknoll/demo-material/blob/master/expertise_system/einstein-zebra-puzzle-owlready-solution1.ipynb However the second ontology file (provided in n3 turtle syntax) does not work. More precisely: a) Direct loading: no classes or roles are loaded. b) conversion to xml syntax with ontospy and then loading to owlready: classes and roles are loaded but no individuals. Probably something in the file is wrong, but I would owlready expect to report some error then... |
| Free forum by Nabble | Edit this page |
