CS533: Homework 1 Solutions: ----------------------------------------------------------------------- Exercise 11.4: There are many possible answers. I generally accepted any answer that did not violate the intended semantics of the domain. Here is one. a) The initial state is: At(Monkey,A), At(Bananas,B), At(Box,C), Height(Monkey,Low), Height(Box,Low), Height(Bananas,High), Pushable(Box), Climbable(Box) b) The actions are: Go(x,y) Pre: At(Monkey,x) Add: At(Monkey,y) Del: At(Monkey,x) Push(b,x,y) Pre: At(Monkey,x),Pushable(b) Add: At(b,y),At(Monkey,y) Del: At(b,x),At(Monkey,x) ClimbUp(b,x) Pre: At(Monkey,x),At(b,x),Climbable(b),Height(Monkey,Low) Add: On(Monkey,b),Height(Monkey,High) Del: Height(Monkey,Low) Grasp(b) Pre: Height(Monkey,High), Height(b,High) Add: Have(Monkey,b) Del: ClimbDown(b) Pre: On(Monkey,b), Height(Monkey,High) Add: Height(Monkey,Low) Del: On(Monkey,b), Height(Monkey,High) UnGrasp(b) Pre: Have(Monkey,b) Add: Del: Have(Monkey,b) c) In situation calculus, the goal is a state s such that: Have(Monkey,Bananas,s) & (exists x At(Box,x,s0) & At(Box,x,s)) where s0 is the initial state situation. In STRIPS, we can only talk about the goal state; there is no way of representing the fact that there must be some relation (such as equality of locations of an object) between two states within the plan. So there is no way to represent this goal via a standard STRIPS planning problem. d) Actually, we did include the Pushable precondition. This is an example of the qualification problem. Exercise 11.10: A forward state-space planner maintains a partial plan that is a strict linear sequence of actions. Each search node corresponds to an action sequence. The initial search node is the empty sequence. The search, or refinement, operators add "applicable" actions to the end of a sequence. An action is applicable to an action sequence if it can be taken in the state that results from executing the action sequence from the initial state. The goal nodes of the search space are any nodes where the result of executing the action sequence from the initial state satisfies the goal condition of the planning problem. Similarly, a backward state-space planner maintains a partial plan that is a reversed sequence of actions. The refinement operator is to add an action to the beginning of the sequence as long as the actions effects are compatible with the state at the beginning of the sequence. The goal nodes are defined in the same way as for forward state-space search. Exercise 11.11: The initial state is: On(B,Table), On(C,A), On(A,Table), Clear(B), Clear(C) The goal is: On(A,B), On(B,C) First we'll explain why it is an anomaly for a noninterleaved planner. There are two subgoals. Suppose we decide to work on On(A,B) first. We can clear C off of A and then move A on to B. But then there is no way to achieve On(B,C) without undoing the work we have done. Similarly, if we work on the subgoal On(B,C) first we can immediately achieve it in one step, but then we have to undo it to get A on B. Exercises 11.13 There are many possible answers. I generally accepted any answer that did not violate the intended semantics of the domain. Here is one. go(x,y) PRE: at(x),on(FLOOR),same-room(x,y) ADD: at(y) DEL: at(x) push(b,x,y) PRE: at(x),on(FLOOR),box-at(b,x),same-room(x,y) ADD: at(y),box-at(b,y) DEL: at(x),box-at(b,x) climb-up(b,x) PRE: at(x),box-at(b,x),on(FLOOR) ADD: on(b) DEL: on(FLOOR) climb-down(b,x) PRE: on(b),at(x) ADD: on(FLOOR) DEL: on(b) turn-on(s,b) PRE: on(b),box-at(b,s),switch(s) ADD: switch-on(s) DEL: turn-off(s,b) PRE: on(b),box-at(b,s),switch(s) ADD: DEL: switch-on(s) Note that I treated switches as locations. To encode Figure 11.17 as a planning problem we will use the following constants: boxes: b1,b2,b3,b4 rooms: r1,r2,r3,r4 switches: s1,s2,s3,s4 doors: d1,d2,d3,d4 Doors, rooms, and switches will be viewed as locations. We will have the following facts describing the initial state: same-room(di,ri),same-room(di,ri) for i=1,2,3,4 same-room(ri,si),same-room(si,ri) for i=1,2,3,4 same-room(di,dj) for i=1,2,3,4; j=1,2,3,4 box-at(bi,r1) for i=1,2,3,4 at(r3) The plan for Shakey to get b2 to r2 is as follows: go(r3,d3),go(d3,d1),go(d1,r1),push(b2,r1,d1),push(b2,d1,d2),push(b2,d2,r2) --------------------------------------------------------------------------- Exercise A: A standard propositional STRIPS planning problem (as described in class) specifies: 1) a goal condition, 2) an initial state, and 3) a set of propositional STRIPS actions with positive preconditions. We will refer to the set of all standard STRIPS problems as STANDARD. i) Let NEG-PRE be the class of problems that are specified as above, except that actions are allowed to have negative preconditions. (Note that NEG-PRE is a strict superset of STANDARD.) Show how to convert any problem p1 in NEG-PRE to a problem p2 in STANDARD such that p1 has a solution iff p2 has a solution. In other words, give a reduction from Plan-SAT for NEG-PRE to Plan-SAT for STANDARD. Prove your answer for full credit. I gave 6 points for the correct construction and 4 points for the correct proof. The correctness of the construction may seem obvious, but it is important to be able to set up a formal argument. Sometimes these obvious constructions have holes that only show up in the proof (though this is not one of those cases). Construction: Given a problem P in NEG-PRE we will create a new problem P' in STANDARD as follows: Let I be the initial state of P, G be the goal, and A be the set of propositional strips actions. Also let PROPS be the set of propositions involved in P. For each proposition p in P introduce a new proposition not-p. The initial state I' of P' is equal to I' = I \union {not-p | p \in PROPS - I} The goal G' of P' will just be G. For each action a in P we will add the following action a' to P': PRE(a') = {p | p is in PRE(a)} \union {not-p | p is a negative precondtion of a} ADD(a') = ADD(a) \union {not-p | p in DEL(a)} DEL(a') = DEL(a) \union {not-p | p in ADD(a)} These action definition will effectively maintain the not-p propositions so that they are part of the state whenever p is false. Proof of correctness: Let P be a problem in NET-PRE and P' be the corresponding standard problem as obtained from the above construction. We want to show that P is satisfiable iff P' is satisfiable. For action a in P we will denote the corresponding action in P' as a'. Also for any sates s (i.e. a set of positive propositions) let s'=s \union {not-p | p \in PROPS - s}. That is s' explicitly lists the negative facts that are not in s'. The trickiest part of the proof is to select a good inductive hypothesis. After that, it is straightforward. To form the inductive hypothesis we introduce the concept of state-action sequence. A state action sequence is simply an alternating sequence of states and actions. We say that a state-action sequence s1,a1,s2,a2,...,a_{n-1},sn is "legal" iff for each i, the preconditions of ai are satisfied in si and s_{i+1} is the result of applying ai in si. Given a state-action sequence S involving actions and proposition in P we define S' to be the corresponding action sequence that results by replacing each action a by a' and each state s by s'. So S' is a state-action sequence involving actions and proposition in P'. We will prove the following statement about state-action sequences: For any state-action sequence S involving actions and proposition in P, if S is a legal sequence then so is S'. Proof: Use induction on the number of actions n in the state-action sequence. Base Case: n=0 is trivially true Inductive Case: Assume that the statement holds for all state-action sequences with fewer than n actions. Show that it holds for sequences with n actions. Let A=s1,a1,...,a_n,s_{n+1}. We have the following, s1,a1,...,a_n,s_{n+1} is legal iff both 1) s1,a1,...,a_{n-1},s_n is legal, and 2) a_n is applicable in s_n and results in state s_{n+1} iff both 1) (s1)',(a1)',...,(a_{n_1})',(s_n)' is legal [by the inductive hypothesis], and 2) (a_n)' is applicable in (s_n)' and yields (s_{n+1})' [this is a simple case analysis that follow from the way we have defined (s_n)' and (s_{n+1})'] iff (s1)',(a1)',...,(a_n)',(s_{n+1})' is legal That completes the proof. From this fact we can prove what we want. P is satisfiable iff P has a legal state-action sequence that begins with I and ends with s such that G is a subset of s. iff P' has a legal state-action sequence that begins with I' and ends with a state s' where G is a subset of s' iff P' is satisfiable The last fact follows because s' is by definition a superset of s. That completes the proof. ------------------------------------------------------------------------ ii) Let DISJ-GOAL be the class of problems that are standard STRIPS problems only they have disjunctive goals. A disjunctive goal is a disjunction of standard goals, where a standard goal is a set of propositions. For example, the following is a disjunctive goal: {on(a,b),on(b,c)} or {on(c,b),on(b,a)} We say that a problem in DISJ-GOAL is solvable iff there is an action sequence from the initial state to some state that satisfies at least one of the goal disjuncts. So in our example above we must reach a state with either the tower (a,b,c) or (c,b,a). Repeat part (a) for DISJ-GOAL. Construction: Intuitively we will add a new action for each disjunct of the goal. Each of these actions will have the corresponding goal as a precondition and will add a new proposition GOAL. The goal of our new problem is simply GOAL. Given a problem P in DISJ-GOAL we will create a new problem P' in STANDARD as follows: Let I be the initial state of P, G=g1 or g2 or ... or gn be the goal, and A be the set of propositional strips actions. Create a new proposition GOAL that we will use to define P'. Define the action ACTi as follows, ACTi PRE: gi ADD: GOAL DEL The initial state I' of P' is equal to I The goal of P' is GOAL The action set of P' is A \union {ACTi | i=1,...,n} We now prove that P has a solution iff P' has a solution. Proof: To prove the forward direction, assume that P has a solution. This means that there is a sequence of actions a1,...,an from A that lead from I to a state s that satisfies one of the gi. Consider the action sequence a1,...,an,ACTi where i is the index of the satisfied goal. It is clear that ACTi can be executed in s and that it leads to a goal state of P'. Thus P' has a solution. To prove the backward direction, assume that P is not solvable, and thus that there is no action sequence involving actions in A that achieve one of the gi. For the sake of contradition assume that P' is solvable. This means that the is some action sequence that achieves GOAL. But his can only be done by executing one of the ACTi actions, which depends on having one of the gi achievable by actions in A. Thus we get a contradiction.