The following sections describe the use of Explain.

The Main Window

When the user starts up Explain, s/he is presented with the
Main Window. This window keeps track of all dump files that can be used
by the system. The files are listed in the file browser, which is an
InterViews StringChooser class. The StringChooser is a composite class
that allows an array of strings to be scrolled through and selected.
The file browser allows the user to scroll through any number of files
that have been loaded. There are two menus available in the Main
Window: File, and Modules.

The File menu has four menu items. About shows the name of the program
and the authors' names. "Load New Dump Directory" allows the user to
load all files in a directory by selecting a file in that directory.
Load Module Dump allows the user to load a single file into the file
browser. Finally, Quit allows the user to exit the program.

The Modules menu allows the user to manipulate the items in the file
browser, and load and reload files into CORAL. The Consult and
ReConsult menu items will load or re-load the file or files selected
in the file browser. The menu item "Show Selected Modules" will bring
up a "definition" window, described later, for each of the files
selected in the file browser. The user can also bring up a
"definition" window by double clicking on a file name in the file
browser. Finally, "Remove Selected Modules allows the user to remove
files from the file browser, and "Clear All Modules" removes all of
the modules from the file browser.

There is also a command line option, "-f", which takes a file
name. This can be used to load files into the file browser when the
application starts up. If the file name is a file, it will put the
file name into the file browser. If the file is a directory, it will
attempt to load all of the files in the directory into the file
browser. 

The Definition Window

The Definition window displays the derivation of the selected
predicate for the module chosen in the Main Window. Note, we are
show the derivations in their re-written form; that is, after the
Magic Set transformation has been applied to them. This representation
bears little resemblance to the original module, but it shows the user
exactly what happened at execution time with respect to the
transformed rules.

There are two scrolling StringChoosers in the Definition window. The
top StringChooser, labelled "Predicates," shows a list of all the
unique predicate names found in the dump file. The Coral code for this
is shown below. When the user selects one of the predicates, all of
the instances of that predicate are shown in the second StringChooser
labelled "Instances." This is achieved by executing a CORAL query.
When an instance of a predicate is selected, its derivation is shown
in the drawing window.  The derivation is obtained by querying the
appropriate "def" relation for the module being displayed.


module instance.
export instances(bbf).
@check_subsumption ".
     instances(Rel,Fun,X) :- member(Rel,X,Z),univ(X,[Fun|T]).
end_module.

An example of a loaded CORAL module.

There are two active menu items in the menus in the ModuleWindow. The
"Close" menu item allows the user to remove the window from the
screen. The other menu item is "Undo", in the "Edit" menu.
The Definition window maintains a one level "undo" operation for all
derivation trees that get removed from the screen.

To navigate among the derivations, the user simply clicks in the Node
box of interest, which causes a pop-up menu to appear. This menu has
four options. First, "Go Up 1 Level" will erase the current
Derivation and all its children, saving the entire chain so that it can
be undone. Second, "Go Down 1 Level" will expand the current Node
into its derivation(if it has any). Third,
"Next Derivation" will show the next derivation of the current
Node if multiple derivations exist for that predicate. Fourth,
"Show Where Uses", will bring up a Uses window for the predicate
contained in the current Node. The Uses window is described in the
next section.

The Uses Window

The Use Window shows the rules where the predicate existed in the body
of the rule. The Definition window and the Uses window, taken
together, will show all the Derivations in which a predicate is used.

The window has the same layout as the Definition window, though the
meaning of the StringChoosers is different. The top StringChooser
shows the predicate whose uses are being displayed. The bottom
StringChooser shows the rules where the predicate is used. To display
a derivation, the user clicks on a rule in the bottom StringChooser,
and the corresponding tree is displayed. The window then behaves
similarly to the Definition window, in terms of selecting nodes, and
the operation of the pop-up menu.


