If I have the following predicate door, which declare that there is a door between the two rooms:
door(office, hall).
door(kitchen, office).
door(hall, "dining room").
door(kitchen, cellar).
door("dining room", kitchen).
And the predicate doorstate which declares the state of a door:
doorstate(hall, office, closed).
doorstate(hall, "dining room", opened).
doorstate("dining room", kitchen, opened).
doorstate(kitchen, office, opened).
doorstate(kitchen, cellar, opened).
There is a pathway between two rooms if all of the doors between them are open.
How can I write a rule to discover if there is such a pathway between two rooms?