Prev Up
Go backward to Solution to part (c)
Go up to Question 1

Solution to part (d)

Suppose the plugged bath with water flowing in goes from empty to half full in one time step (i.e., in the time it takes to execute one action), and from half-full to full in one time step, and will overflow wetting the floor in the next time step. The unplugged bath empties on one time step. The plugged sink fills up in one time step and, in the next time step it overflows with water flowing in. The unplugged sink empties on one time step. Intuitively, think of the action as doing the command, then waiting a bit (enough time for the sink to fill or the bath to half fill).

The floor, once wet, remains wet.

Axiomatize how the floor can be wet in different situations. You can define whatever predicates you may need.

The tricky thing here is thinking about how the world works; what has to be true before and after the action. For example, the way the problem is stated, the bath fills if it is plugged and water is flowing in.

empty(bath,S) <- 
   unplugged(bath,S).
empty(bath,do(A,S)) <- 
   poss(A,S) &
   empty(sink,S) & 
   noflow(shower,do(A,S)).

halffull(bath,do(A,S)) <-
   poss(A,S) &
   halffull(bath,S) &
   plugged(bath,do(A,S)) &
   noflow(shower,do(A,S)).
halffull(bath,do(A,S)) <-
   poss(A,S) &
   plugged(bath,do(A,S)) &
   empty(bath,S) &
   flow(shower,do(A,S)).

full(bath,do(A,S)) <-
   poss(A,S) &
   plugged(bath,do(A,S)) &
   full(bath,S).
full(bath,do(A,S)) <-
   poss(A,S) &
   plugged(bath,do(A,S)) &
   halffull(bath,S) &
   flow(shower,do(A,S)).

overflow(bath,do(A,S)) <-
   poss(A,S) &
   flow(shower,do(A,S)) &
   full(bath,S).

empty(sink,S) <- 
   unplugged(sink,S).
empty(sink,do(A,S)) <- 
   poss(A,S) &
   empty(sink,S) & 
   noflow(sink,do(A,S)).

full(sink,do(A,S)) <-
   poss(A,S) &
   plugged(sink,do(A,S)) &
   empty(sink,S) &
   flow(sink,do(A,S)).
full(sink,do(A,S)) <-
   poss(A,S) &
   plugged(sink,do(A,S)) &
   full(sink,S).

overflow(sink,do(A,S)) <-
   poss(A,S) &
   flow(sink,do(A,S)) &
   full(sink,S).

wet(floor,S) <- 
   overflow(bath,S).
wet(floor,S) <-
   overflow(sink,S).
wet(floor,do(A,S)) <-
   wet(floor,S) &
   poss(A,S).

David Poole

Prev Up