22 of 22 people found the following review helpful
Serves its purpose well
June 19 2001
By
Dr. Lee D. Carlson
- Published on Amazon.com
Format: Paperback
For those who have experience in logic programming, either with Prolog or some other language, such as Lisp, or even a high-level symbolic programming language like Mathematica or Maple, this book could serve as a first course or a summary of Prolog programming. Research in logic programming is still an active area, and the approach taken in logic programming languages seems more natural from the standpoint of mathematical (predicate) logic. The author, in this short book, gives the reader an appreciation of Prolog and the philosophy and constructions behind logic programming. Many examples are employed that illustrate how to code in Prolog and how useful it can be in real-world applications.
In the first chapter, the author gives some justification for programming in Prolog, such as its symbol manipulation capability, automatic backtracking, the view that data structures and programs are of the same form, and the relational form of clauses. The syntax of Prolog is then discussed, and examples given of the three kinds of terms in Prolog. Readers with some background in category theory will appreciate the discussion more, as the author does employ some of this in the discussion, for example the view of addition as being a functor of a term. Terms are drawn in tree form in this chapter and throughout the book. The author then characterizes a Prolog program as a set of procedures, with each defining a predicate, and consisting of one or more (Horn) clauses. Unification of terms is discussed as a basic operation that determines when two clauses can be made equivalent by a substitution of variables. The execution of a program is viewed as a querying of the clauses, and the goal or e nd of the program is a proof that the goal is true.
Data structures in Prolog are discussed in chapter 2 as generalizations of programs using compound terms instead of just constants and variables. Lists are defined and their syntax discussed, along with dot and bracket notation. The implementation of simple arithmetic in Prolog is discussed. Several effective examples are given to illustrate arithmetic and list manipulation in Prolog.
Mappings, which are relations between two data structures, are the topic of chapter 3, and the author gives many examples illustrating how it is used to compose Prolog programs and how they act an both lists and more general trees.
The built-in predicate "cut" is discussed in the next chapter as a predicate to allow backtracking control of the program. The author gives many examples illustrating the problems involved with the use of "cut".
Difference structures are discussed in chapter 5 as a tool to simplify and increase program efficiency. A generalization of the idea of an accumulator, they allow one to work with "holes" in data structures during actual program execution. A list for example, can be viewed as "open" with its elements known only up to a point. It can then be filled in with an empty or a proper list. A difference list, discussed in the chapter, is then a list represented as a pair of "front" and "back", with the back being variable.
Applications of term rewriting are given in chapter 6, with symbolic differentiation launching the discussion. This is the more popular example of what Prolog-type languages can do, and is usually the reason given for beginning the use of symbolic programming languages. The author also discussed matrix multiplication in this chapter.
The next two chapters discuss the representation and manipulation of logical circuits using Prolog, including shift registers and coding circuits. This is followed in chapter 9 by an interesting discussion on how to write a compiler in Prolog, with the author discussing compilation for a single-accumulator computer, a RISC machine, and a stack machine. This is followed in chapter 10 by an even more interesting discussion on how to write a Fast Fourier transform in Prolog.
The last chapter of the book discusses how to use higher-order functional programming techniques in Prolog. For individuals, like myself, who are convinced that functional and logic programming are the most effective programming paradigms, this chapter is very interesting reading. The author defines an evaluator written in Prolog for these higher-order functional programs. Functional programming views computation as a collection of function applications on an expression representing a particular problem, and these functions can then be viewed as arguments to other functions. The lambda calculus from mathematical logic serves as the foundation for functional programming, and the author reviews this quickly, along with the technique of currying, in order to obtain facilities for functional programming in Prolog. Although short, this chapter introduces the reader to a fascinating area, and helpful references are given at the end of the chapter.