\documentstyle[epsf,11pt]{article}
\begin{document}
\title{PP User Manual \\ (simple version)}
\author{}
\date{\today}
\maketitle

\section{Machine Environment}

PP is written in KL1 and ESP. It runs on PIMOS ver.3  or Pseudo multi
PSI ver.3, and SIMPOS ver.7.1. 


\section{Compile And Catalogue}

\begin{enumerate}
\item 
Compile all PP program files which have the extension {\em kl1}.
\item 
Catalogue all PP programs files which have the extension {\em esp}.
\end{enumerate}

\section{Creating PP}

To use PP, input the goal  {\tt 'pp:pp'} to PIMOS or Pseudo multi PSI, and the
system window will appear. The system window is the initial state of PP. 

\section{System Window}

There is a system button in the upper right hand corner of the system
window.

\begin{center}
\epsfile{file=fig1.ps}
\\ Figure 4-1, The System Window.\\
\end{center}

A system menu appears as the result of one click of the left mouse
button on the system button.

\begin{center}
\epsfile{file=fig2.ps}
\\ Figure 4-2 The System Menu.\\
\end{center}

The system menu items are:

\begin{description}
\item[run          ]
Runs a KL1 program.
\item[halt         ]  
Exits PP.
\item[define clause]  
Defines a KL1 program.
\item[load         ]  
Loads a KL1 program.
\end{description}

\section{Creating A KL1 Program}

When {\em define clause} is selected from the system menu a clause
window appears. 

\begin{center}
\epsfile{file=fig3.ps}
\\ Figure 5-1, A Clause Window.\\
\end{center}

A clause window is used to create a KL1 program clause. It has two
child windows:


{\em Window 1}
is called the Program window, and is used for inputting,
displaying, and editing  a textual representation of a KL1 program clause.

{\em Window 2}
is called the graphic window, and is used for inputting,
displaying, and editing a graphic representation of a KL1 program clause.

The two child windows are casually connected to each other. If one 
representation is edited, there a change in the other representation to keep 
consistency between both representations. This behaviour is caused by the 
MVC architecture impremented by PP.  In a clause window the model of MVC is a
KL1 program clause. It has two views, textual view and graphic view.

\subsection{Graphic Representation Of KL1}

The Initial state of the graphic representation of a clause is a clause 
picture shown below. The areas each represent parts of a clause, the
head, guard and body.
\begin{center}
\epsfile{file=fig4.ps}
\\ Figure 5.1-1, The Areas Representing Parts Of A Clause.\\
\end{center}
A clause is created by drawing icons which represent the different parts of
a clause such as goals, arguments, data, and linklines and by writing
the names of parts, in a clause picture.

\begin{center}
\epsfile{file=fig5.ps}
\\ Figure 5.1-2, A Clause Picture.\\
\end{center}

The textual representation of the clause picture in Figure 5.1-2 is:
\begin{center}
\epsfile{file=code1.ps}
\end{center}

\subsection{Icons For Parts Of Clauses}

Each part of a clause has an icon. The icons are: 

\begin{description}
\item[Goals    ] 
Goals are represented by an ellipse icon which is shown below. We can
add input argument icons on upperside, and add output arguments icons
on the lowerside. A goal name is written in the center.  
\begin{center}
\epsfile{file=fig6.ps}
\\ Figure 5.2-1, A Goal Icon.\\
\end{center}
\item[Arguments] 
The icons of a goal's arguments are triangular. Input arguments are
black triangles, and output arguments are white triangles. Variable
names can be written beside icons.
\begin{center}
\epsfile{file=fig7.ps}
\\ Figure 5.2-2, Input And Output Argument Icons.\\
\end{center}
Arguments are variables before they are given their values by means of
links to other icon's data. 

\item[Data     ] 
Data have three kinds of icon: 
\begin{enumerate} 
\item[Atomic          ]

Atoms and integers are represented by a rectangle. The value of atoms
and integers are written inside it.
\begin{center}
\epsfile{file=fig8.ps}
\\ Figure 5.2-3, An Atomic Data Icon.\\
\end{center}

\item[Lists \& Vectors ]
List and vector structures are rectangles which can have arguments added. The 
arguments are elements of the structure. On the top edge, input arguments can 
be added. Output arguments are added on the lower edge. Adding arguments is
allowed on only one side in this version. 
\begin{center}
\epsfile{file=fig9.ps}
\\ Figure 5.2-4, List And Vector Icons.\\
\end{center}
\item[Cons \& Consunify]
We call a structure of cons which elements are input mode cons, and output
mode are consunify. Cons and consunify have different icons.
\begin{center}
\epsfile{file=fig10.ps}
\\ Figure 5.2-5, Cons and Consunify Icons\\
\end{center}

Icons of Cons and consunify are already have the required arguments.
\end{enumerate}
\item[Linklines       ]
We can unify arguments ,and arguments and data by drawing a linkline from one 
icon to another.
\end{description}

\subsection{How To Draw Icons On A Clause Picture}

PP has a graphic editor which impliments a modeless design. The user can draw
and edit a graphic representation without being troubled with which mode he is
operating in, and by using the fewest mouse number of button clicks . This is
achieved by a mechanism of switching mode automatically according to
the area in which the mouse button click is attributed by the MCV
controller of the graphic editor.

The graphic editor of PP supports functions for drawing icons, editing
them, and writing names.

Drawing options are obtained by one click of the left mouse button on
the place that the user wants to draw an icon in a clause picture. The
kind of icon required is identified by the controller.

\begin{center}
\epsfile{file=fig4a.ps}
\\ Figure 5.3-1, Areas In The Graphic Editor\\
\end{center}

If the position of click is attributed to the area for creating a goal's
arguments, the goal has been already drawn, the icon to be drawn is
identified as an argument.

The area for creating goal arguments is near the goal.

\begin{center}
\epsfile{file=fig11.ps}
\\ Figure 5.3-2, Argument Areas Near A Goal Icon.\\
\end{center}

One click of the left mouse button in the area for creating input arguments of 
the goal draws an input argument, below this in the area for output arguments 
draws an output argument.

For a output argument on the area of input and a input argument on the 
area of output, double clicks are used.

Data icons are drawn by changing an goal icon into a data icon by:

\begin{enumerate}
\item 
Clicking the left mouse button once to draw a goal icon. 
\item 
Selecting the goal icon to be replaced by a data's icon with one
click of the left mouse button, and the data menu appears.
\item 
Selecting the type of data from atomic, list, vector, cons, consunify. 
\end{enumerate}

List and vector structures can have arguments added to represent
element of structure. Arguments are drawn by one click of the left
mouse button on the area for creating structure arguments. This method
is the same as that used for goal arguments.

Linklines are obtained by a sequence of two clicks, one on each of the
icons to be unified.

\subsection{Writing Of Names}

Parts of a KL1 program,such as clauses, goals and some of arguments
need names.

Names can be input by: 
\begin{enumerate}
\item 
Double clicking the left mouse button on an icon to input a name.
\item 
Input the name using the keyboard and terminated with a new line.
\end{enumerate}

The exception is a head goal name. This is done by double clicking on
the area of the head goal name in a clause picture.

PP allows all variables to have a name.

Two types of variable exist, nameless variables and named variables. A
nameless variable is a variable which has a name that is not important. Its
name is given by the system automatically and not stored. A named
variable is a variable which has a name that important and is stored
in the system. A nameless variable has a name which constructed
using only a large letter or a large letter and integer. A named
variable has a name which can also use small letters. Both types of
variable name need to begin with a large letter to be a KL1 variable.

A variable is a named variable if it is given the name by the user,
otherwise it is a nameless variable in the graphic representation. In
the graphic representation, variable names play the same part as
comments in a KL1 program. Unification is achieved using linklines
only. Variable names do not affect the context of a program. The
following is possible: 

\begin{enumerate}
\item 
Different variables which have same the pointer can have
different variable names. 
\item 
Different variables which have different pointers can have the
same variable names.
\end{enumerate}

\subsection{Move And Remove}

An icon can be moved by selecting the required icon with one click of
the centre mouse button and then selecting the new icon position with
another click of the centre mouse button.

An icon can be removed by being selected with a double click of the
centre mouse button.

Both move and remove functions effect icons which have a relation with
the icon selected. 

\section{Textual Representation}

PP's textual representation of a KL1 program clause is differs from an
ordinary KL1 program clause in that a distinction is made between
input and output arguments. All inout arguments are grouped together and
separated from output arguments by a colon, {\em ':' }.

The textual representation of a KL1 program clause is in the form:
\begin{center}
\epsfile{file=code2.ps}
\end{center}

In the textual representation,a  variable name which is constructed by only 
large letters or large letters and integers is a nameless variable. It is a 
named variable which contains a small letter. 

\subsection {How To Input Textual Representation}

Textual representation input is obtained by one click of the left mouse 
button in the textual input button of the clause window.

When the user clicks the textual input button the program window waits
for the input of a textual representation, which must end with newline. 

\begin{center}
\epsfile{file=fig3a.ps}
\\ Figure 6.1-1, Location Of Textual Input Button On A Clause Window.\\
\end{center}

\section{Running Of A KL1 Program}

When {\em run} is selected form the system menu a queue window is appears. 
The queue window is used for visualizing a scheduling queue used in a
KL1 executor. 

\begin{center}
\epsfile{file=fig12.ps}
\\ Figure 7-1, Queue Window.\\
\end{center}

{\em button 1} and {\em button 2} are used to select the method of scheduling
goals, depth first  or breath first. Button {\em 1} selects the depth
first method that adds reduced goals to the head of the queue, and
{\em button 2} selects the breath first method that adds reduced goals
to the tail of the queue. Selection is by one click of the left mouse button. 

{\em Button 3} executes a KL1 program through one reduction. This
button called the step button. When this button is clicked the following
process is done. 

\begin{enumerate}
\item 
The goal at the head of the queue is removed.
\item 
The goal is reduced  to the body goals of a clause which can be unified 
to the goal and has the guard goals solved.
\item 
The body goals are added to scheduling queue according to the
selected scheduling method. The head goal is indicated by a black
square. In future versions the idicator will be user relocatable to
other goals.
\end{enumerate}

\subsection{Initial State Of The Goals}

The goals being executed can be drawn as graphic representation on the
queue window by the graphic editor in the same way as in the clause
window. 

The order that the goals are putted in the queue is from left to right. 

\begin{center}
\epsfile{file=fig13.ps}
\\Figure 7.1-1, Initial State Of Goals In The Queue Window.\\
\end{center}

\subsection{ Reduction}

When the step button is clicked, the head goal of the queue is removed
from the queue and reduced to the body goals of a clause which can be
unified and has the guard goals solved. The body goals are added to
scheduling queue. The newest resolvants appear in the queue window. 

Suspended goals are added to scheduling queue unreduced. Failed goals
cause the goal {\em fail} to be added to the queue.

In reducing, the unify goal in the body part is executed. The goals which are
added to queue are the user defined goals and system goals except unify goals.
The clause which defines the end of the goal calls only the goal {\em
true} in the body part and no goal is added to queue. 

\begin{center}
\epsfile{file=fig14.ps}\\
\epsfile{file=fig15.ps}\\
\epsfile{file=fig16.ps}
\\ Figure 7.2-1, Reduction In A Queue Window.\\
\end{center}

\subsection{ Editing The Resolvant}

The user can change the contents of the scheduling queue by editing
the graphic representation of it. 

The graphic editor works in the same way as the clause window editor.

The user can add new goals to the queue, instantiate variables by drawing data
and linklines and remove goals that are not required.

\subsection{ The Termination Of A Program}

When an executing goal terminates successfully no goal appears in the
queue window and the scheduling queue is empty.

When the {\em fail} goal is reduced, the execution of the program is stopped.

If all goals are suspended, no detection is done and the execution of
the program does not stop.

\end{document}
