Logic Programming

From Spivey's Corner
Jump to: navigation, search

My book, An introduction to logic programming through Prolog was published by Prentice-Hall in 1996, but is long out of print. The book gives a simple introduction to the theory of logic programming, and also describes in detail an implementation of a small Prolog dialect called picoProlog by an interpreter written in Pascal.

I have reclaimed the copyright, and I am delighted to make available here:

The interpreter source is written in a minimal dialect of Pascal, avoiding many features including pointers, but using macros to overcome some of Pascal's limitations, in a style inspired by Kernighan and Plauger's book Software tools in Pascal. It comes with a translator from the Pascal dialect into C that can be used to build the interpreter and also source for the macro processor that is needed.

To build the interpreter on a Linux machine, just extract the tar file and type make. The building happens in several stages:

  1. First, the Pascal-to-C translator ptc is built from C source, including a lexer and parser written with lex and yacc. The file README gives some details of the very restricted Pascal subset accepted by this translator.
  2. Next, ptc is used to build the macro processor ppp.
  3. Finally, the picoProlog interpreter is built from the source code in the file pprolog.x by first expanding macros using ppp to obtain a file pprolog.p, then translating to C with ptc, and lastly compiling the C code.

Text and software copyright © J. M. Spivey, 1996, 2002, 2010.

Please note that I have not placed the copyright of this work in the public domain. Nevertheless, I freely grant permission to make copies of the whole work for any purpose except direct commercial gain. I retain all other rights, including but not limited to the right to make translations and derivative works, and the right to make extracts and copies of parts of the work. Fair quotation is permitted according to usual scholarly conventions.

Personal tools