time(0..n). #domain time(T). location(a). location(b). location(c). location(d). location(m). #domain location(L;L1;L2). object(box). move_able(box). firm_surface(box). object(bananas). eat_able(bananas). grasp_able(bananas). #domain object(O). agent(monkey). #domain agent(A). %% an object is at some location fluent(at(O,L)). %% an agent can stand on some object if the objext %% can support it fluent(on(A,O)):- firm_surface(O). %% an agent is at some location fluent(at(A,L)). %% an agent can be hungry fluent(hungry(A)). %% an agent can hold some object if the object can be grasped fluent(has(A,O)):- grasp_able(O). %% agent A can reach the object O at location L1 fluent(reachable(A,O,L1)). % the monkey can grasp the bananas action(grasp(A,O,L1)):- grasp_able(O). % the monkey can move the box action(push(A,O,L1,L2)):- move_able(O). % the monkey can eat the bananas action(eat(A,O)):- eat_able(O). % the monkey can climb the box action(climb(A,O)):- firm_surface(O). % the monkey can walk around action(walk(A,L1,L2)):- neq(L1,L2). % initial state h(at(bananas, m), 0). h(at(monkey, a), 0). h(at(box, b), 0). h(hungry(monkey), 0). %% this is to state that the initial state is complete h(neg(F), 0):- fluent(F), not h(F, 0). % grasp(A,O,L1) causes has(A,O) if reachable(A,O,L1) h(has(A,O), T+1):- o(grasp(A,O,L1), T), h(reachable(A,O,L1), T). % executable grasp(A,O,L1) if at(A,L1), at(O,L1) :- o(grasp(A,O,L1), T), h(neg(at(A,L1)), T). :- o(grasp(A,O,L1), T), h(neg(at(O,L1)), T). % the monkey can move the box % push(A,O,L1,L2) causes at(A,L2) % push(A,O,L1,L2) causes at(O,L2) h(at(O,L2), T+1):- o(push(A,O,L1,L2), T). h(at(A,L2), T+1):- o(push(A,O,L1,L2), T). % executable push(A,O,L1,L2) if at(A,L1), at(O,L1) :- o(push(A,O,L1,L2), T), h(neg(at(A,L1)), T). :- o(push(A,O,L1,L2), T), h(neg(at(O,L1)), T). :- o(push(A,O,L1,L2), T), h(on(A,O), T). % the monkey can eat the bananas % eat(A,O) causes -hungry(A) h(neg(hungry(A)),T+1):- o(eat(A,O), T). %% executable eat(A,O) if has(A,O) :- o(eat(A,O), T), h(neg(has(A,O)), T). % the monkey can climb the box % climb(A,O) causes on(A,O) h(on(A,O), T+1):- o(climb(A,O), T). % executable climb(A,O) if at(A,L1), at(O,L1) :- o(climb(A,O), T), h(at(A,L1), T), h(at(O, L2), T), neq(L1,L2). % the monkey can walk around % walk(A,L1,L2) causes at(A,L2) h(at(A,L2), T+1):- o(walk(A,L1,L2), T). % executable walk(A,L1,L2) if at(A,L1) :- o(walk(A,L1,L2), T), h(neg(at(A,L1)), T). :- o(walk(A,L1,L2), T), h(on(A,box), T). %%%% static causal laws h(neg(at(A,L1)), T):- h(at(A,L2), T), neq(L1, L2). h(neg(at(O,L1)), T):- h(at(O,L2), T), neq(L1, L2). %%% specific to the domain h(reachable(A,O,L1), T):- h(on(A,box), T), h(at(A, L1), T), h(at(box, L1), T), h(at(O, L1), T). %%% inertial rules h(F, T+1):- fluent(F), h(F,T), not h(neg(F),T+1). h(neg(F), T+1):- fluent(F), h(neg(F),T), not h(F,T+1). %%% %%% generating action 1 {o(Ac,T) : action(Ac) } 1:- T < n. %%% goal :- not h(neg(hungry(monkey)), n). % %o(walk(monkey,a,b), 0). %o(push(monkey,box,b,m), 1). %o(clim(monley,box), 2). %o(grasp(monkey,bananas,m), 3). %o(eat(monkey,bananas), 4). hide h(_,_). hide location(_). hide object(_). hide agent(_). hide move_able(box). hide firm_surface(box). hide object(bananas). hide eat_able(bananas). hide grasp_able(bananas). hide action(_). hide fluent(_). hide time(_).