KnowledgeWorks and Prolog User Guide > 6 Advanced Topics > 6.1 Control Flow > 6.1.1 Meta Rule Protocol

NextPrevUpTopContentsIndex 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
          (conflict-set ?conflict-set)
          (test ?conflict-set)    
                   ; are there any instantiations?
          ((select-instantiation ?conflict-set)
          (test ?instantiation)   
                   ; did the user pick one?
          (fire-rule ?instantiation)

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 (Unix version) - 22 Dec 2009