Hướng dẫn sử dụng OPS5
Using the Workbench Copyright (C) Inference Engine Technologies 1988,89. All rights reserved. Tools in the Workbench The Workbench has been designed to make the development of OPS5 programs easier. The Workbench ...
Using the Workbench
Copyright (C) Inference Engine Technologies 1988,89. All rights reserved.
Tools in the Workbench
The Workbench has been designed to make the development of OPS5 programs easier. The Workbench display consists of a top line displaying the product name and version, and the current active rule set name. The top line also functions as a message display line.
The second line on the screen is the main choice list. The choice list allows easy selection of one of the built in tools. When the Workbench is first entered, the Interp choice is highlighted. To select a choice, use either the left or right cursor keys to move the highlight to the desired choice. Then type enter, and the highlighted choice will be activated. To exit from any active choice, simply type Esc. You are then free to select another choice.
All choices may also be selected from within the active interpreter by typing cntl and the capitalized letter in the desired choice. For instance, to get help, type Ctrl-l. Choice list options prefixed by an exclamation point are 'Alt' commands and may be executed from within the interpreter by typing alt and the capitalized letter of the desired choice.
The following is a list of the possible choices:
Interp The main Sienna OPS5 interpreter
Edit The Sienna Editor
heLp Sienna OPS5 language summary
Wm Pop-up window to display working memory
Cs Pop-up window to display the conflict set
Options Pop-up window to display and alter options
!Run Alt command to run OPS5
!Step Alt command to single step OPS5
!Halt Alt command to abort a running program
!Back Alt command to back up 1 rule firing
Pbreak Pop-up window to display all current break points
Rules Pop-up window to display active rules and operators
exit Exit the Sienna OPS5 Workbench
1. The Two Sections of the Screen.
In addition to the top two workbench lines, the main window is divided into upper and lower sections, separated by a double horizontal line. The upper window is where all screen output from a running program is displayed (via WRITE), and where all input to the program (via ACCEPT or ACCEPTLINE) is read from. The lower window is where all interaction with the interpreter occurs. This is where top-level commands are entered and where trace and debugging information is displayed.
Each window is actually the full size of a screen, with only a portion being displayed at any one time. The position of the double horizontal line may be adjusted at any time that input can be entered. To move the line up, type ctrlÄu, and to move the line down, type Ctrl-D Function key F-2 will swap the position of the line about the center of the screen.
To display the entire program output screen (upper window) with nothing else displayed, type F-4. To display the entire lower window, type F-5.
Key Summary:
Ctrl-L Display the HELP screen
Ctrl-E Invoke the full screen editor
Ctrl-W Pop-up the working memory brouse window
Ctrl-C Pop-up the conflict set browser
Ctrl-O Pop-up the Options window
Ctrl-P Pop-up the Breakpoint window
Ctrl-R Pop-up the Rules window
ALT-R Run the rules
ALT-S Single step
ALT-H Halt rule firings
ALT-B Back the interpreter up one rule firing
Ctrl-D Move the double dividing line down
Ctrl-U Move the double dividing line up
F1 Display the OPS5 help window
F2 Flip the dividing line about the center of the screen
F4 Display the upper screen only
F5 Display the lower screen only
2. Interp: The OPS5 Interpreter
The OPS5 interpreter is where you will spend most of your time. It can be entered only by moving the highlight to the Interp choice and typing enter.
If you have had experience with LISP implementations of OPS5, then you should feel comfortable in the Sienna OPS5 interpreter environment, since all of the same top-level commands are available, and work the same way. In addition to the standard commands are a few that are unique to Sienna OPS5, and among the standard commands are some that are additionally available through pop-up windows.
Choice list functions which are preceded by an exclamation point -- !Run !Step !Halt !Back; are top level 'Alt' commands, and produce an immediate action. To invoke one of these commands, type alt and the first letter of the desired 'alt' command. The other entries on the choice list are 'Ctrl' commands (except for Interp and exit) which can be invoked by typing ctrl followed by the capitalized letter in the command name. The ctrl commands cause a pop-up window to be displayed containing information specific to the command. alt and ctrl commands are dispatched immediately. Even if an OPS5 command has been entered at the command prompt, if a ctrl/alt command is invoked, it is immediately executed. The command that was typed at the OPS5 prompt will not be evaluated until the enter key is pressed. Both alt and ctrl commands are further described below.
3. Edit: How and When to Enter the Editor
The editor may be invoked by any one of four methods:
1. By moving the choice menu highlight to Edit and typing enter.
2. When in the interpreter, by typing Ctrl-E.
3. When in the Rules window, by selecting the Edit option, selecting a rule, and typing enter.
4. When loading a file into the interpreter, if a syntax error is found and the second parameter of the load function is 'T', the editor is invoked automatically with the cursor placed on the line where the error was detected.
When the first two methods are used, the editor buffer which was last displayed, or last loaded, will be the active buffer. If no files have been loaded into the system, then the default scratch buffer will be active.
When the third method is used to invoke the editor, the buffer containing the selected rule is made active and the top of the screen is positioned at the beginning of the selected rule. The editor can be exited at any time by pressing esc.
4. Help: Using the Help Screen
The help screen provides one screen of help, which is available either by selecting the help option on the choice list and pressing enter, or, when the interpreter is active, by typing Ctrl-L. Information on the Help screen is divided into three categories: commands, actions, and RHS functions. The commands category includes commands that can be entered at the top-level. In addition to those listed, any action preceded by an asterisk in the actions list can also be entered at the top level. The actions category are those actions that can be entered in the right hand side of a rule. The RHS function category are functions which can be placed withinmost RHS actions. The notational conventions of the help screen are as follows:
n an integer number
p1 the name of a production
s a symbol
v a variable
< x x ...> optional arguments
/ select one of the listed
[ .. ] one of the included options is required.
The heLp screen is meant to be a reminder of the most-used language elements and gives an indication of the syntax.
Press any key to exit the help window.
5. Options: Setting OPS5 Options
The Options window may be selected by either moving the choice list highlight to Options and pressing enter, or, when in the interpreter, by typing Ctrl-O. The Options window displays the current settings of the strategy, watch level, delay level, echo status, and the default file settings.
The strategy, watch, delay and echo status may be changed in the options window. You can select the item to change by pressing either the cursor up or cursor down keys. When you have selected the item to change, one of the allowable values for that item may be selected by pressing the left or right cursor keys. The strategy, watch and delay options are also top level commands.
The default files section displays the currently active files for the trace, accept and write files.
To change these values you must use the OPENFILE and DEFAULT actions at the top-level. To leave the Options window, press the esc or enter key.
6. Wm: Displaying the Contents of Working Memory
The Wm (Working Memory) window may be displayed by selecting the Wm option from the choice list and pressing enter, or by typing Ctrl-W whenever text input can be entered, when the Cs window is displayed, or when the Rules window (but no other) is displayed.
The current contents of working memory are displayed in order of recency, with the latest addition to, or change of, working memory being displayed first.
The bottom of the window lists the active keys for the window. If there are more WMEs in working memory than can be displayed in the window, the cursor up, cursor down, page up, page down, home and end keys can be used to move through the rest of working memory. If the WMEs are too long to be displayed in the window, the left cursor and right cursor keyscan be used to shift the window contents left and right. To exit the window press esc.
7. Cs: Displaying the Conflict Set Entries
The Cs window is invoked by selecting the CS option from the choice list, by typing ctrl-c whenever text input can be entered, or when the Wm or Rules window, but no other are displayed. The Cs window displays the contents of the current conflict set, sorted in the order in which the rule instantiations would fire. Displayed with the name of the instantiated rule is the list of time tags of instantiating WMEs for the rule. Given the instantiating WME time tags, the Wm window can be invoked to look up the actual working memory elements.
If there are more conflict set entries than can be displayed in the window at one time, the cursor up, cursor down, page up, page down, home and end keys may be used to view the rest of the entries. The cursor left and cursor right keys can be used to scroll the window to the left and right as needed.
To exit the window, press esc.
8. !Run -- Using the Run Choice
The !Run choice can be selected with the choice list highlight, or can be invoked by typing Alt-R from within the interpreter. This has the same effect as typing "(RUN)" at the OPS5 prompt. The interpreter begins running and continues until no productions are instantiated or a halt action or break point is encountered.
Note that, when within the interpreter, typing alt-R causes the interpreter to be run immediately. Commands which may have been entered at the OPS5 prompt are not evaluated unless enter has been first pressed from within the interpreter.
9. !STEP -- Single Stepping Through Your Program
The !Step commands can be invoked by moving the highlight to that option and pressing enter, or by typing alt-s from within the interpreter.
The action of the !Step command is to fire 1 production from the conflict set. It is functionally equivalent to typing (RUN 1) at the OPS5 prompt, but somewhat more convenient.
Commands entered but not evaluated are not evaluated by the !Step command.
10. !HALT: How to Stop a Runaway Program
The !Halt commands can be invoked either by selecting it in the choice list menu, or by typing Alt-H while a program is running. However, since the !Halt commands is useful only while the interpreter is running, and it is not possible to select an option with the highlight during that time, the only meaningful way that the command can be invoked is by typing Alt-H.
The !Halt command is functionally equivalent to the evaluation of a Halt action in the RHS of a production. When the !Halt command is executed the interpreter is halted immediately after the current rule has completed firing, and control returns to the top level.
11. !BACK: Running Backwards -- Undoing Rule Firings
The !Back commands can be selected from the choice list by moving the highlight to the option and pressing enter, or by typing alt-b from within the interpreter.
The !Back command is functionally equivalent to typing (BACK 1) at the OPS5 prompt. The interpreter is backed up one rule firing and the system is restored to the state prior to the last rule firing.
The action of this command is immediate. Any commands entered at the OPS5 prompt but not yet evaluated by typing enter are not evaluated by invoking this command.
12. PBREAK: Listing Break Points
The Pbreak option opens a window which displays all currently set break points. The option can be selected from the menu by highlighting the option and pressing enter, or by typing CNTl-p from within the interpreter.
Break points cannot be set or cleared with this option, use the Rule window instead. If no break points have been set then the message "** no break points set **" is displayed in the window. To close the window and exit, press Esc. To set or clear break points use either the rules window or the pbreak command.
13. RULES: Displaying and Manipulating Rules
1. How to use the Rules screen
The Rules window can be invoked by selecting the Rules choice with the highlight and pressing enter, or by typing Ctrl-R whenever text input can be entered or while the Wm or Cs windows are displayed.
The Rules window displays a list of the compiled rules and allows one r of four operations: Edit, Matches, Pbreak, and Excise, to be applied r to the selected rule. To select a rule, use the cursor up and cursor r down keys to highlight the desired rule. When there are more rules r than can fit on one rules screen, you can also use the page up, page r down, home and end keys to view the rest of the rules. If rule names r are too long to fit within the window, the Ctrl-Cursor-Left and r Ctrl-Cursor-Right keys can be used to view the truncated portion of r the rule names.
To select one of the four operations to apply to the selected rule, r uses the Cursor-Left and Cursor-Right keys to make you choice, and r then press enter. To summarize the Rules window keys and their actions:
Cursor up move rules highlight bar up
Cursor down move rules highlight down Page up scroll up one window
Page down scroll down one window
Home to top of rules
End to bottom of rules
Ctrl cursor left scroll window left
Ctrl cursor right scroll window right
2. EDIT: Editing a rule
A rule may be edited by selecting the edit option along with a r particular rule. When enter is pressed Sienna Edit is entered. The r buffer that contains the rule is made the active buffer, and the top r of the buffer window is placed at the top of the selected rule. If r the rule cannot be found, then an error message is displayed.
A rule will not be found if the edit buffer containing the rule does r not exist, or if the rule text has been deleted.
3. MATCHES: Displaying WMEs that match a rule
The Matches option performs the same task as the matches command r from the OPS5 prompt. When the Matches option is used from the rules r window is used, however, a window is opened and the matches for the r rule are displayed in the window. If there is more information than r can be displayed at one time in the window, then any of the special r keys listed at the bottom of the window can be used to browse through r the display.
Some care should be exercised when using the Matches option. The r matches information, when displayed in the window, must be formatted r into a data structure in order to allow browsing through the list. If r the matches of a rule which creates large cross products of objects is r displayed, the resulting space needed to preformat the information r could exceed available memory. If you suspect that this will be the r case, then use the matches command at the OPS5 prompt instead.
To close the Matches window, press esc.
4. PBREAK: Setting and clearing break points
The Pbreak option allows you to easily set and clear break points r on rules. To set or clear a break point, select Pbreak with the r highlight, select the rule you want to set/clear, and press the enter r key. A message will be displayed at the top of the screen.
When a rule has a break point set on it, an asterisk is visible to the r left of the rule name. When the break point is cleared, the asterisk ris cleared also.
5. EXCISE: Purging rules from the Knowledge Base
The Excise option can be used to purge a rule from the RETE network. To excise a rule,select the rule in the Rules window, select the Excise option, and press enter. A window will appear to verify that you want the rule excised. If you do, then type 'Y'. If not, just press enter or esc to cancel the operation.
Excising a rule from the RETE network does NOT delete the rule text from the edit buffer, if it exists in one.
14. EXIT: Leaving the Workbench
To exit the workbench you must select the exit option on the main choice list, and then press enter. If you are in the interpreter, the editor, or any other selection, then you must first return to the choice list by pressing esc.
Upon exit, if any edit buffers have been altered since being last saved, a warning is given along with the chance to abort the exit. You may then enter the editor and save the modified buffers by pressing F-4 within each buffer.