Prolog error in loop
===

hi i would need a help about prolog.
I posted my code ,the problem is that i do not obtained expected result.
i want planning actions for moving on table all blocks until is possible, for do this i prompt : " do(while(some(x, block(x) & -onTable(x)),pi(x,putOnTable(x))),s0,S)."
i should see response like this : S = do(putOnTable(e), do(putOnTable(b), do(putOnTable(c), s0))) but prolog returns "false" only.
sameone 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!!!
