
RULES

;;; Actions

(puton
 if
 (clear ?obj ?s)
 (clear ?dst ?s)
 (on ?obj ?src ?s)
 ($neq? ?obj ?dst)
 ($neq? ?obj ?src)
 ($neq? ?src ?dst)
 then
 (on ?obj ?dst (move ?obj ?src ?dst ?s)))

#|(clear1
 if
 (on ?obj ?src ?s)
 (clear ?obj ?s)
 (clear ?dst ?s)
 ($neq? ?obj ?dst)
 ($neq? ?obj ?src)
 ($neq? ?src ?dst)
 then
 (clear ?src (move ?obj ?src ?dst ?s)))
|#

(clear
 if 
 (block ?x)
 ($not (on ?x ?y ?s))
 then (clear ?y ?s))

;;; Frame axioms

(frame-table
 if 
 then
 (clear table ?s))

(frame-clear
 if
 (on ?obj ?src ?s)
 (clear ?dst ?s)
 (clear ?obj ?s)
 ($neq? ?obj ?dst)
 ($neq? ?obj ?src)
 ($neq? ?src ?dst)
 (clear ?x ?s)
 ($neq? ?x ?dst)
 then
 (clear ?x (move ?obj ?src ?dst ?s)))

(frame-on
 if
 (on ?obj ?src ?s)
 (clear ?dst ?s)
 (clear ?obj ?s)
 ($neq? ?obj ?dst)
 ($neq? ?obj ?src)
 ($neq? ?src ?dst)
 (on ?x ?y ?s)
 ($neq? ?x ?obj) 
 then
 (on ?x ?y (move ?obj ?src ?dst ?s)))

ASSERTIONS

(clear table initial)
(clear b initial)
(on b c initial)
(on c a initial)
(on a table initial)
(block a)
(block b)
(block c)

CODE

(define (ask-plan-simple)
  (backchain-and
   '((on c table (? plan)) (on b table (? plan)) (on a table (? plan)))
	))

(define (ask-plan-hard)
  (backchain-and
   '((on c table (? plan)) (on b c (? plan)) (on a b (? plan)))
	))