Explore window
To start an explore tree, type in a term in a text
entry field and click the Explore button. If there is
no clause whose head matches the term, Visual Logic returns an
error. Otherwise, it creates a new single-node tree containing
the term. Place the mouse pointer over the node and hit the <space>
key to expand the entire tree or <return> key to expand
the tree one level.
The currently selected node is indicated by the
node selector (the four small squares at each corner of the current
node). The node selector follows the mouse. Hence, simply point
the mouse to a node to select it. The node selector can also
be moved via the keyboard (see keyboard bindings). All keyboard
commands are directed toward the currently selected node.
As indicated above, the entire tree / subtree can
be expanded at once (<space> key) or one level at a time
(<return> key). Also, branches of the tree can be expanded
in arbitrary order. That is, the user is not restricted to a
depth-first, left-to-right order of expansion as in Prolog.
To avoid indefinite expansion, explore always halts
upon encountering one of the following:
- a blocked node, i.e., one with no matching clause.
- a failed expression, e.g., a comparison which
fails or an 'is' (arithmetic) term which has one or more uninstantiated
argument
- a repeat node, i.e., a node which matches an ancestor node.
The attribute of each node denotes its value as follows:
- green: 'true' or ancestry resolved node.
- blue: evident node.
- bright red: blocked or failed node.
- dark red: repeat node.
Important: unlike query mode, a node's value
in explore mode always pertains to the tree it is a part of.
Hence, supported and conflicted values are not calculated, as
these rely on information not present in a single tree.
In addition, the elevation of the node denotes its
state as follows:
- raised: node is unexpanded (but can be
expanded).
- sunken: node is a choice point, i.e., node has
been expanded but there are more matching clauses that are unused.
- flat: node is either unexpandable or all matching
clauses have been used to expand the node.
Backtracking a node (or 'redoing' in Visual Logic
terminology) performs the following:
- Prune the subtree below the node.
- Revert the tree to the state immediately before
the node was expanded.
- Re-expand the node using (by default) the next
unused matching clause.
There are actually three ways of redoing. The procedure
is the same; the difference lies in which choice point is selected.
- Redo self, then children ( [ key): select the first choice point encountered in a preorder search of the tree, starting from the current node.
- Redo children, then self ( ] key): select the first choice point encountered in a postorder search of the tree, starting from the current node.
- Redo last ( ; key): redo the redoable node that was last expanded.
For example, select a choice point (sunken node)
and press the [ key to redo that particular node.
Since nodes may be expanded and redone in arbitrary
order, it is possible to miss certain solutions. In some circumstances,
this may not be undesirable. That is, if the user chooses not
to expand a certain branch, s/he may not be interested in the
solutions that branch can give. In addition, there is a quicker
way of generating all solutions: by using query mode.
Nevertheless, if the user wants to see all solutions
in explore mode, then s/he must observe the following rules: 1) always expand all nodes before doing a redo; and 2) always redo using the last (latest) choice point. Hint: this can be most easily accomplished by selecting the root node and alternately pressing the and the ; key.
The selector can be moved via the keyboard. The
number keys correspond to the navigation keys on the numeric keypad
(with NumLock turned on).
- 4, 6 key (left/right arrow): move to left/right
sibling.
- 8, 2 key (up/down arrow): move to previous/next
node in preorder traversal.
- 7, 1 key (home/end): move to parent/child node.
- 9, 3 key (pgup/pgdn): move to previous/next tree.
In addition, most commands are given through the
keyboard as follow:
- <space> key: expand entire tree/subtree
from current node.
- <return> key: expand current node one level.
- - (minus) + (plus) key: collapse/uncollapse node.
- ; (semi-colon): redo last.
- [ (left bracket) key: redo self, then children.
- ] (right bracket) key: redo children, then self.
- 5 key: redo last.
- 0 key: expand entire tree starting at root node.
- DEL key: delete current tree.
As in all windows, all the commands listed above
can also be accessed through the pop-up menu (right click on a
node).
Visual Logic provides additional control over expanding
and redoing nodes through watch windows. Each node may
have its own watch window. To open a watch window for a node,
simply click on the node. A sample watch window may look like
this:
who: a(X,Y)
Current value
a( foo, bar) [evident]
Clauses [21,19,20]
(19) a( john, mary)
(20) a( 0, 1)
(21) a( foo, bar)
(22) a( X,Y):-b(X,Y),c(Y).
The first line shows the node's term prior to expansion.
The third line shows its current term and value. The fourth line lists
the clauses that have been used to expand the node, ordered from
last to first. (Each clause in the database is assigned an index
number.) The last 3 lines list all matching clauses for the
node. Clauses that are unused are displayed in a distinct font
and color.
Left click on one of the clauses to perform the following
actions:
- If node is unexpanded, then expand the node using
that clause instead of the first matching clause (as by default)
- If node is expanded and the clause is not
yet used, then expand the node using that clause instead of the
next unused clause (as by default).
- If node is expanded and the clause is already
used, then backtrack to the point prior to node expansion using
that clause. For example, clicking on clause (19) above will
mark clause 19 and 21 as unused.
Other actions in the watch window:
- Click on the first line to flash the node the
watch window belongs to. (In case the user loses track of which
window belongs to which node.)
- Click on the fourth line (Clauses [
])
to restore the node. (Mark all clauses unused.)
These commands can also be accessed through the pop
up menu (right click). The popup menu has two additional commands:
- Show listing: show this clause in the listing.
- Query: switch to the query window and query this
node.
When a node is destroyed, its watch window (if one
exists) is automatically destroyed. A watch window can also be
manually closed in the usual way (the exact method depends on the particular GUI environment being used).
Explore mode provides another way for quickly generating all possible clause trees. Enter a term and click on Step to generate all possible clause trees for that term and display the first tree. Subsequently, point to any node in the tree and press Forward (the 5 or ; key) to cycle through all the trees. Pressing Forward at the end of the cycle will produce a beep and at the same time reset the cycle to the beginning. The next Forward will repeat the cycle over again.
In the explore window, step trees are distinguished from explore trees with a white background. (While cycling through the step trees, the white background will have a shadow until the end of the cycle has been reached.) Note that step trees are different from trees in query mode in that step trees are not necessarily closed. Instead, they are all the possible clause trees that can be generated for a given term.
The results window simply accumulates query results
and list the terms in alphabetical order. Each term is displayed
only once even if there are several clause trees for the term.
The attributes have the same meaning as in the query window.
Click on a term to send it to the query window and
perform a query with the term as goal. Click with the middle
button (or click both buttons if using a 2-button mouse) to send
it to the explore window nd start an explore tree with the term
as the root. Alternatively, right click to invoke the popup menu.
The listing window lists the current clause database.
The clause database does not necessarily contain the same clauses
as the source file, as <- clauses
are converted to contrapositive form (see Format of the source
file). The user may search for a string by entering it in the
text entry field. Click First to search for the first
occurrence and Next to continue searching to the end of
text.
The editor window allows the user to edit the current
source file. The editor is a simplified version of Emacs and
supports the usual navigational and editing keys. For example,
C-v moves to the next screen, C-k kills a line, C-y yanks the
kill buffer, etc. As in the listing window, text search is supported.
Click on Reconsult to save the file and reload
it into the clause database. Note that reconsult will clear out
all previous results in query and explore.
[ Prev: Query, etc. | Up: Contents ]
luutran@cs.sci.csupomona.edu