NextPrevUpTopContentsIndex

6.1.1.2 A Simple Example

This meta-rule displays the conflict set in a menu to the user and asks for one to be selected by hand on each cycle. Note that we have to check both that there were some instantiations available, and that the user selected one (rather than clicking on the Abort button).

(defrule manual-context :backward
         ((manual-context)
          <--
          (start-cycle)
          (conflict-set ?conflict-set)
          (test ?conflict-set)    
                   ; are there any instantiations?
          ((select-instantiation ?conflict-set)
           ?instantiation)
          (test ?instantiation)   
                   ; did the user pick one?
          (fire-rule ?instantiation)
          (cut)
          (manual-context)))

where the function select-instantiation could be defined as

(defun select-instantiation (conflict-set)
        (tk:scrollable-menu conflict-set
            :title "Select an Instantiation:"
            :name-function #'(lambda (inst)
                              (format nil "~S: ~S"
                                (inst-rulename inst)
                                (inst-bindings inst))))

Now a context could be defined by

(defcontext a-context :strategy () 
                     :meta ((manual-context)))

KnowledgeWorks and Prolog User Guide (Windows version) - 29 Feb 2008

NextPrevUpTopContentsIndex