% AILog representation of DELIVERY ROBOT DOMAIN IN THE SITUATION CALCULUS. % This is the code discussed in Section 14.1 of Poole and Mackworth, Artificial % Intelligence: foundations of computational agents, Cambridge, 2010. % Copyright (c) David Poole and Alan Mackworth 2009. This program % is released under GPL, version 3 or later; see http://www.gnu.org/licenses/gpl.html % To run this in AILog, you should put it in the same directory as AILog and then call % load 'delrob_sitc.ail'. % INITIAL SITUATION sitting_at(rob,o109,init). sitting_at(parcel,lng,init). sitting_at(k1,mail,init). %locked(door1,init). % DERIVED RELATIONS at(Obj,Pos,S) <- sitting_at(Obj,Pos,S). at(Obj,Pos,S) <- carrying(Ag,Obj,S) & at(Ag,Pos,S). adjacent(o109,o103,_). adjacent(o103,o109,_). adjacent(o109,lng,_). adjacent(lng,o109,_). adjacent(o109,o111,_). adjacent(o111,o109,_). adjacent(o103,mail,_). adjacent(mail,o103,_). adjacent(lab2,o109,_). adjacent(P_1,P_2,S) <- blocks(Door,P_1,P_2) & unlocked(Door,S). % STATIC RELATIONS blocks(door1,o103,lab2). opens(k1,door1). autonomous(rob). % ACTION PRECONDITIONS poss(move(Ag,Pos,Pos_1),S) <- autonomous(Ag) & adjacent(Pos,Pos_1,S) & sitting_at(Ag,Pos,S). poss(pickup(Ag,Obj),S) <- autonomous(Ag) & Ag \= Obj & at(Ag,Pos,S) & sitting_at(Obj,Pos,S). poss(putdown(Ag,Obj),S) <- carrying(Ag,Obj,S). poss(unlock(Ag,Door),S) <- autonomous(Ag) & blocks(Door,P_1,_) & at(Ag,P_1,S) & opens(Key,Door) & carrying(Ag,Key,S). % PRIMITIVE PREDICATE DEFINITIONS sitting_at(Obj,Pos,do(move(Obj,Pos_0,Pos),S)) <- poss(move(Obj,Pos_0,Pos),S). sitting_at(Obj,Pos,do(putdown(Ag,Obj),S)) <- poss(putdown(Ag,Obj),S) & at(Ag,Pos,S). sitting_at(Obj,Pos,do(A,S) ) <- poss(A,S) & sitting_at(Obj,Pos,S) & ~ move_action(A,Obj,Pos) & ~ pickup_action(A,Obj). move_action(move(Obj,Pos,_),Obj,Pos). pickup_action(pickup(_,Obj),Obj). carrying(Ag,Obj,do(pickup(Ag,Obj),S)) <- poss(pickup(Ag,Obj),S). carrying(Ag,Obj,do(A,S)) <- carrying(Ag,Obj,S) & poss(A,S) & A \= putdown(Ag,Obj). %locked(Door,do(A,S)) <- % locked(Door,S) & % poss(A,S) & % A \= unlock(Door). unlocked(Door,do(unlock(Ag,Door),S)) <- poss(unlock(Ag,Door),S). unlocked(Door,do(A,S)) <- unlocked(Door,S) & poss(A,S). % TRY the following queries: % bound 12. % ask at(parcel,o111,S). % bound 8. % ask carrying(rob,k1,S). % bound 17. % ask at(rob,lab2,S). % bound 16. % ask at(rob,lab2,S). % warning: this takes a long time % bound 20. % ask at(rob,lab2,S). % what do you think will happen here?