EXAMINE                                                 Chris Mellish Feb 85

The library program EXAMINE provides a single predicate, 'examine' which takes
one argument. This predicate enables you to examine a Prolog term which is too
complex (perhaps  because it is circular)  to be printed out  in its entirety.
"Examine"ing a term consists of crawling  around the term looking at one small
bit, the "current term", at a time, giving one key commands to navigate around
the structure. At each point, the system displays on your terminal the part of
the structure which you  are currently looking at. If this  is a complex term,
then  all arguments  of  this term  (or all  elements  if it  is  a list)  are
abbreviated  by the  symbol "&"  if they  are themselves  complex. Here  is an
example use of 'examine', looking at a  very simple list. Commands by the user
appear after the "?" signs. Extra comments have been inserted to indicate what
these commands mean.

    ?- examine([a,[b,c],d]).
    examining...
    [a, &, d] ?2        ;;; Look at the second element of this list
    [b, c] ?o           ;;; Move out to the next enclosing term
    [a, &, d] ?1        ;;; Look at the first element
    a ?n                ;;; Move on to the next one
    [b, c] ?n           ;;; and the next one again
    d ?o                ;;; Move out to the next enclosing term
    [a, &, d] ?e        ;;; Exit from the examiner
    ...examined
    yes

Here are the simple commands for moving around the term being examined. Note
that the commands work from single key presses (RETURN is not required):

   <digit>  - go to the nth argument of current term. If the term is a list,
              this is taken to be the nth element of the list. If the list
              ends in something other than [], then the end of the list is
              treated as a final element

   n        - go to the Next argument of the term that the current term is an
              argument of. Thus 'n' can be used for successively stepping
              through the arguments of some complex term

   b        - go Back to the last argument of the term that the current term
              is an argument of (this is the inverse of 'n')

   o        - go back Out of this term to the term which encloses it (this is
              the inverse of the <digit> commands).

Here are some other commands that exist for convenience:

   e        - Exit from the examiner

   h        - give brief Help message on the examiner commands

   w        - Write out whole of current term. Note that this will cause
              problems if the term is circular

The following commands facilitate rapid switching around from one part of the
term to another:

   l        - Label current term with a name. The system prompts you for a
              single word (to be followed by RETURN), and this word is now
              associated with the current term

   g        - Go to term with a given label. The system prompts you for a
              word, as above, and the current term becomes the term
              previously associated with that label (by the 'l' command).

Here is an example of these last two commands in use for examining a parse
tree:

    examining...
    s(&,&) ?1
    np(&,&,&,&) ?l
    ** please type in word to label this term
    ? subject
    np(&,&,&,&) ?o
    s(&,&) ?2
    vp(&,&,&) ?2
    np(&,[],&,&) ?l
    ** please type in word to label this term
    ? object
    np(&,[],&,&) ?w
    np(det(a), [], n(woman), padj(relc(vp(v(smiled), [])), []))
    np(&,[],&,&) ?g
    ** please type in label of term
    ? subject
    np(&,&,&,&) ?w
    np(det(the), adjs(a(big), adjs(a(fat), [])), n(man), padj(pp(on, np(det(the),
     [], n(block), [])), []))
    np(&,&,&,&) ?g
    ** please type in label of term
    ? object
    np(&,[],&,&) ?o
    vp(&,&,&) ?e
    ...examined

--- File: local/plog/help/examine
--- Distribution: all
--- University of Sussex Poplog LOCAL File ------------------------------
