
GENERAL REMARKS
---------------


This directory contains several example programs.  The programs
are intended to let you try out CORAL easily on a variety of
problems, and to illustrate the syntax of programs.  
(Several additional examples are in the directory
MORE_EXAMPLES, which is a link to the directory /doc/examples.
These additional examples are discussed in the tutorial introduction.)

Programs are, by convention, in files whose names terminate in ".P". 
Datasets (typically sets of facts as in parent.c160.F, sometimes queries
as in nrev.F) are in files with names terminated by ".F".
If a file contains a set of facts for a relation, the name of 
the file is usually either relname.F or relname.xxx.F, where
xxx is a string that describes the contents of the file
(e.g. edge.cyc.F and edge.acyc.F).  Sometimes, the .F files are
named after the associated program files (e.g. bom1.F, bomtree.F).
Note that facts can also be included with programs in a single file
(e.g. as in algebra.P).

A series of CORAL command line statements can be put in a file
and executed by consulting the file at the CORAL prompt.
An example is the file runlcs.

After the initial phase of just trying out these programs, you
may want to try running variations of these programs, typically
by trying different combinations of annotations.  Many of the programs
contain comments to give you some ideas about interesting variations.

Consulting a .P file from the CORAL prompt compiles its contents,
and generates a -M.P file with the rewritten program.  It is
sometimes useful to look at the -M.P file.


GUIDE TO PROGRAMS
-----------------

Non-Recursive Programs:
-----------------------

grades.P  contains a CORAL application for analysing student grades,
and has several non-recursive queries with grouping (< > in
the head of a rule).

join.P  contains some simple joins that can be used to compare
several execution alternatives.

Transitive Closure and Related Programs:
----------------------------------------

The file anc.P contains several programs for computing transitive closure.
It contains extensive comments
on variants of the programs and should let you get a feel for some
of the evaluation alternatives available to you in CORAL.

The files bom.P and
shortestpath.P contain transitive-closure related programs,
namely bill-of-materials and, of course, shortest path.
They also illustrate the use of grouping in recursion.
(shortestpath.P actually contains function symbols in lists to
construct the paths.)

sg.P contains the well-known same-generation program.


Arithmetic Functions:
---------------------

A number of recursive function definitions are there, including:

ackermann.P  	the Ackermann function
fac.P  		factorial
fib.P  		fibonacci
tak.P  		takeuchi


List Manipulation:
------------------

append.P  	appending one list to another
append.opt.P  	an optimized version
append.pipe.P  	using pipelined evaluation
nrev.P  	naive reverse
nodups.P  	removes duplicates from a list
qsort.P  	quicksort
msort.P  	mergesort
make_seq.P   	contains code for transforming lists into relations

Negation:
---------

The file even.P contains several defitions of an even number, and
illustrates the use of negation in CORAL.

(A number of additional examples are presented in the manual.)

Sequence Analysis:
------------------

palin.P  	contains a program for finding palindromes
lcs.P  		contains a program for finding longest common subsequences
parse.P  	contains a simple sentence parser
run.P		finds increasing/decreasing "runs" in a sequence
avgs.P		computes n-day moving average for a sequence
volatility.P    several measures of volatility are defined for a sequence
peaks.P		computes peaks in a sequence that just precede some event

N-Queens:
---------

nqueens.P	contains a program due to Kiessling, evaluated bottom-up
nqueens.pipe.P  contains a program due to Fruewirth, evaluated top-down
nqueens.pipe2.P contains a program due to Pereira, evaluated top-down

Dynamic Programming:
--------------------

mcp.P		contains a program for the matrix chain product problem
		(see, e.g., Sedgewick's Algorithms text)
knap.P		contains a program for the integer knapsack problem 
		(see, e.g., Sedgewick's Algorithms text)
knap2.P		a less elegant, but instructive, variant of knap.P
game.P  	contains a program that generates a dataflow graph for 
		computing winning probabilities in a two-player game, 
		due to Clocksin.
hanoi.P		contains a program for the Towers of Hanoi problem

Other:
-------

algebra1.P, algebra2.P and algebra.opt.P  present versions of a program
to generate an algebra of 27 elements, due to Fleck.  

cife.P  contains a version of a scheduling program for tasks in a construction
project, due to Gupta, Tiwari and Derr.

model.P  contains an ecological modeling program from the book Ecologic by
Robertson et al.

comparators.h  is an example of a file that can be included in other
modules; see lcs.P for an example of its use.

runlcs  is an example of a CORAL script file, and can be executed
by consulting it at the CORAL prompt.


