home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
files
/
language
/
toyprolo
/
readme.doc
< prev
Wrap
Text File
|
1988-07-23
|
8KB
|
181 lines
TOY Prolog ST - English edition
-------------------------------
Contents of disk
----------------
TOY.PRG ) The TOY Prolog interpreter
SYSFILE.TOY )
PROLOG.DOC 53-page manual, translated from German
README.DOC The file you are reading
BOOTER.TOY ) Auxiliary programs in
EDITOR.TOY ) intermediate code - see
CALLTREE.TOY ) section 4 of manual
TICTAC.TOY Noughts & crosses demo (intermediate
code) (manual, p.42)
\SOURCE\ folder: programs in Prolog (in English originally):
MONITOR.PRO Source code for user interface (p.47)
EDITOR ) Source code for auxiliary programs
CALLTREE ) (pp.38-39)
ALPHA )
TOYSEQ ) Demonstration programs (pp.40-42)
TICTAC.TOE )
\DEMOS\ folder: more Prolog programs (translated from German):
TOYDEMOS graphics demo, access to disk directory,
+ a simple recursive tab function
FAMILY logic of family relationships
COLOURS colouring a map with 4 colours
QUIKSORT sorting lists
Introduction
------------
Welcome to Prolog - PROgramming in LOGic - the 'fifth generation'
language currently replacing LISP as the language of choice for
artificial intelligence programming. A few lines of Prolog can do
things that would take pages of code in a conventional language
like Pascal, C or BASIC. But as it is fundamentally different
from sequential/algorithmic languages like these (and also from
other, less conventional computer languages), you have a whole
set of new concepts to learn before you can make much use of its
power. It is not just the jargon that's weird and unfamiliar, but
the whole philosophy of programming that Prolog terminology
describes.
Let's face it, it takes a book to explain what Prolog is all
about. The manual describes this particular implementation pretty
thoroughly, but it does not set out to be an introductory text -
it assumes you already know what words like 'arity' and
'principal functor' mean. So if you do want to learn Prolog you
will have to get a book about it. The standard text is the one by
Clocksin & Mellish, mentioned in the manual. A short and
comparatively cheap book that I am finding quite helpful, though
it does not cover everything in TOY Prolog, is J.Doores,
A.R.Reiblein & S.Vadera: Prolog - Programming for Tomorrow. Sigma
Press, Wilmslow, Cheshire, 1987. £10-95.
If you do not have a textbook to refer to yet, just in case
reading the manual still leaves you wondering where to start, the
following notes may help you get going with this package.
Using TOY Prolog
----------------
Run TOY.PRG from the desktop, with SYSFILE.TOY present on the
same directory. You should eventually get a message saying the
program is listening and a prompt,
?-
followed by a blinking cursor. Now you are supposed to enter a
valid Prolog clause, terminated by a full stop. This sets Prolog
a goal, which it will attempt to satisfy. In some cases, a lot of
printout can be generated on the way, but eventually the goal
will either succeed or fail, and Prolog will respond 'yes' or
'no' respectively, and give you another '?-' prompt.
E.g. you can set Prolog problems in simple arithmetic such
as
?- sum(27,34,X).
or
?- sum(X,3,-11).
Here X, being a sequence of alphanumeric characters beginning
with a capital letter, is interpreted as a variable, and Prolog
will give it a value. To get a new prompt, type a full stop and
Return. Or you can ask
?- 32*48 > 1024/3.
or
?- 'neil' @< 'margaret'.
and just get 'yes' or 'no'.
To quit TOY Prolog, just type
stop.
Loading a program
-----------------
In principle, you can enter complicated predicates directly like
this, but it is not very convenient. For one thing, if you make a
mistake you have to type the whole line again. It is generally
easier to create a Prolog program outside the interpreter, using
your favourite programming editor, and load it in from disk when
Prolog is running. Once loaded, it can be modified using the
editor provided.
There are two ways of loading programs. A program in Prolog
source code is loaded with 'consult'. E.g. to load the example
program FAMILY from drive B you enter
?- consult('b:\demos\family').
whereupon Prolog will read it in, echoing it all to the screen,
stopping to execute commands (beginning with ':-') when it comes
to them, until it comes to the 'end.'. At that point the goal has
been satisfied, so Prolog prints 'yes' and returns control to the
keyboard.
This is very slow, so another method is also provided. Once
your program is fully debugged, you can translate it into
intermediate code as described in the manual, generating a '.TOY'
file, which can then be loaded very quickly with 'sysload'. E.g.
to load the editor you enter
?- sysload('b:\editor.toy').
Once a program has been loaded, the information it contains
remains in Prolog's built-in database. You can call predicates in
it, and ask questions using the facts and rules it contains. E.g.
after loading FAMILY, you can enter
?- parent(X, jesus).
and Prolog will answer
X is joseph
leaving the cursor on the same line. If you type a semicolon (and
Return), it will resatisfy this goal with another solution,
X is mary
This time, attempting to resatisfy the goal fails, there are no
more solutions.
There is plenty of study material in the example programs, and it
is worth printing listings of them as well as of the manual.
This translation
----------------
TOY Prolog was written in Warsaw and published in an English-
language book, which unfortunately I have not been able to
obtain. This Atari ST version was created in Germany and released
as a public domain package with German documentation. This
English version of the package is the same except that I have
translated the documentation into English and edited it into a
single document, adding a fuller table of contents and two
indexes (one of the GEM functions by their standard names);
translated the comments in the example programs; and added this
README file. One or two little mistakes I happened to spot in the
German documentation have been corrected, but I cannot guarantee
the rest is perfect! Once upon a time, the German documentation
appears to have been in FirstWord format, with some names and
symbols distinguished by bold type. By the time it reached me, it
was in ASCII and this distinction had been lost - sorry if this
adds any confusion. Being a beginner in Prolog, not particularly
familiar with German, and without access to the original source
book, I can hardly have avoided an occasional slip or deviation
from the norms of TOY Prolog terminology, however it seems
preferable to release the translation in its present form rather
than sitting on it just because I might be able to do it better
with another year's experience.
Though my contribution is small compared with that of the
professionals who wrote the program, still translating over 100k
of files as technical as this is by no means a negligible task,
in fact it amounted to several weeks' work all told. And while
they were no doubt paid for their work, I don't get a penny for
mine. So if you would like to encourage me to help make more of
the excellent PD software that comes from Germany available in
English via the ST Club, why not send me a donation?
Martin Willson,
1 Bincleaves Road,
Weymouth, Dorset DT4 8RL.