Solve Einstein five-house puzzle with owlready

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Solve Einstein five-house puzzle with owlready

William
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)
Reply | Threaded
Open this post in threaded view
|

Re: Solve Einstein five-house puzzle with owlready

Jiba
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