1

I would need help about Prolog. I posted my code, the problem is that i do not obtain the expected result. I want planning actions for moving on table all blocks until is possible. To do this I prompt :

?- do(while(some(x, block(x) & -onTable(x)),pi(x,putOnTable(x))),s0,S).

I expect to see a response like :

S = do(putOnTable(e), do(putOnTable(b), do(putOnTable(c), s0)))

but Prolog returns "false" only. Someone can help me??

% Golog interpreter
%:- [golog_swi].

:- discontiguous clear/2, on/3, onTable/2.

:- op(800,xfy,[&]).

do(E,S,do(E,S)):- primitive_action(E),poss(a,S).

% Primitive Action Declarations.
primitive_action(putOn(_,_)).
primitive_action(putOnTable(_)).


poss(putOn(X,Y),S) :- clear(X,S), clear(Y,S), \+ on(X,Y,S), \+ X=Y.
poss(putOnTable(X),S):- clear(X,S), \+(onTable(X,S)).

% Successor State Axioms.
on(X,Y,do(A,S)):- A = putOn(X,Y); on(X,Y,S), \+ (A = putOnTable(X); A = putOn(X,_)).
onTable(X,do(A,S)) :- A = putOnTable(X); onTable(X,S), \+ A= putOn(X,_).
clear(X,do(A,S)) :- on(Y,X,S), (A = putOn(Y,_) ; A = putOnTable(Y)); clear(X,S), \+ A = putOn(_,X).

% Restore suppressed situation arguments
restoreSitArg(onTable(X),S,onTable(X,S)).
restoreSitArg(on(X,Y),S,on(X,Y,S)).
restoreSitArg(clear(X),S,clear(X,S)).

block(X):- member(X,[a,b,c,d,e]).

% iniTial COndition
onTable(a,s0).
on(b,a,s0).
on(c,b,s0).
clear(c,s0).
onTable(d,s0).
on(e,d,s0).
clear(3,s0).

thank you!!!

false
  • 10,264
  • 13
  • 101
  • 209
angelius
  • 493
  • 2
  • 5
  • 9

2 Answers2

1

Your predicate do/3 cannot succeed because the goal primitive_action/1 will fail with your query.

Currently, while/2 is not described in primitive_action/1 and it seems it is missing also from your program. So you need to extend primitive_action/1 by further facts, or add a new rule to do/3. And in addition to that you need to describe what while/2 means.

false
  • 10,264
  • 13
  • 101
  • 209
  • i tryed to add these definition for : and while but the results always is the same.... % : definition do(E1 : E2,S,S1) :- do(E1,S,S1),do(E2,S,S1). % while definition do(while(P,E),S,S1) :- do(star(?(P) : E) : ?(-P),S,S1). others suggestions? please!!! – angelius Jul 24 '12 at 15:24
1

This question is actually about Golog. Your mistake is pretty mundane: you didn't copy the Golog interpreter code into your source file/directory.

Golog defines a number of high-level programming constructs, including while-loops and non-deterministic picks (pi), used here. I'm sure you don't want to reinvent Golog, so just go and get it. I'm assuming that your question is part of an assignment of sorts, and your teacher probably pointed you to the Golog interpreter. Otherwise, you can always find it on the pages of the cognitive robotics group at the Univ. of Toronto: http://www.cs.toronto.edu/cogrobo/main/systems/index.html

Christian Fritz
  • 20,641
  • 3
  • 42
  • 71