There are a number of browsers for examining the state of KnowledgeWorks. They will be introduced here, and again when the Programming Environment is discussed in The Programming Environment.
This may be obtained by choosing
. The defined forward chaining contexts (or rule groups) are displayed in a drop-down list at the top. There is also a special pseudo-context for all the backward chaining rules, which is shown initially. In this case, the only other context is named
DEFAULT-CONTEXT. Below that are listed the rules for the selected context. Choose
DEFAULT-CONTEXT from the drop-down list and click on one of the rules, for example
PLAY, and edit it by choosing
Works > Rule >
from the menu bar. An editor window will appear showing this rule definition.
If the node
?node is the root node of the tree of questions, and there is no current node indicating the question about to be asked, then tell the user to think of an animal and make the root node
?node the current node (so that the top question of the tree will be asked next). This is the rule that starts the game by instructing: "if you haven't got a question you're about to ask, ask the topmost question in the tree of questions". The detailed syntax of forward chaining rule definitions will be explained in Forward chaining.
-- All backward rules --" from the drop-down list and bring up a backward chaining rule definition by clicking on its name in the Rule Browser and choosing
Works > Rule > Find Source
again. The detailed syntax of backward chaining rules is in Backward Chaining.
The Objects Browser is for exploring the contents of the KnowledgeWorks object base. Start it by choosing
. The system knows about the CLOS objects that make up the object base. One class of CLOS objects in this example is the
node class so choose
drop-down. All the node objects in the object base will be displayed in the pane below. Click on one of these objects and the bottom pane will display the slots and slot values of the object.
To make the display clearer and allow input without explicit package qualifiers, change the package of the Objects Browser. Do this via
Tools > Preferences... > Objects Browser > Package
. Edit the Package pane so that it says
KW-USER and press
Now change the
field to read
(node ?object animal ?a) and press
Return. The animals associated with each node are displayed. In this game there is a tree of questions with each node object representing a question. Some nodes have a
nil value for the animal slot; these are the non-terminal nodes in the question tree. The program learns your new animals by adding new nodes to the tree.
?a into the
field (and press
Return). This displays only the animals. The values displayed in the topmost of the two panes is the
field instantiated with every possible object that matches the
field. However, if the
field is empty then the value of the
field is taken to be the pattern.
The Class Browser is obtained by choosing
. This brings up the LispWorks Class Browser with an initial focus on the class
standard-kb-object. Select the Subclasses tab to display the subclasses of
standard-kb-object. Double click on
NODE in the subclasses pane to examine the node class used in this tutorial. Select the Slots tab to display its slots and click on one of the slots in the middle pane, for example the
ANIMAL slot. This displays more information about the slot in the Description pane.
Other useful features of the Class Browser include the Superclasses tab which display a graph of the superclasses; the Hierarchy tab which displays direct superclasses and subclasses; and the Functions tab which displays the generic functions or methods defined on a class either directly or through inheritance. For more information about the Class Browser, see the LispWorks IDE User Guide .
This is obtained by choosing
. If you have just run the tutorial a window will appear of which the left column contains the entry
DEFAULT-CONTEXT. These are all the contexts (rule groups) the forward chaining engine has executed (in this case only one). On the right is a detailed breakdown of what happened in each cycle within this context. You will see the rule names listed down the left, and the cycle numbers along the top. The boxes indicate which rules fired. In the last cycle, you will see a black box indicating that the rule
GAME-FINISHED fired, and a outlined box for the rule
PLAY. This means that the rule
PLAY could have fired, but that
GAME-FINISHED was preferred.
Note: you can remove the package prefixes from displayed symbols by setting the current package of the FC History tool to
KW-USER, in the same way as you did for the Objects Browser tool (see Objects Browser).
Look at the definition for
GAME-FINISHED (find the source using the Rule Browser) and notice that it contains
:priority 15. This means that the
GAME-FINISHED rule has higher priority than the
PLAY rule (which has the default value of
10), and so was preferred. Other methods of conflict resolution are also available.
KnowledgeWorks and Prolog User Guide (Windows version) - 26 Feb 2015