Categories Pricing Corporate
Free Textbook

Prolog Techniques

2 reviews
Language:  English
The book Prolog Techniques is the first of two volumes by the author on the programming language Prolog and its applications; the second, forthcoming, textbook is entitled Applications of Prolog.
Download free PDF textbooks or read online. Less than 15% adverts
Business subscription free for the first 30 days, then $5.99/mo

The book Prolog Techniques is the first of two volumes by the author on the programming language Prolog and its applications; the second, forthcoming, textbook is entitled Applications of Prolog. In the first volume you can read about the accumulator technique, difference lists, program manipulations and exploratory code development.

The book refers different source files.

Click here to see the files.

Prolog is considered difficult by students. Usually, by the time they learn Prolog, which is most likely to happen in preparation for a course in Artificial Intelligence (AI) or Expert Systems, they will have studied imperative programming and/or the object oriented paradigm. Unfortunately, this prior experience is not always conducive to learning Prolog. Even though there is a good provision of traditional Prolog textbooks (for example [2]), students still find it hard to write solutions in Prolog to problems of any notable complexity. In my experience this holds also (and in particular) for problems for which Prolog should be the natural choice.

This book is intended to relieve the problem by providing a good collection of programming projects, case studies and exercises of various complexity. It will be useful for three kinds of students.

- Those whose prime source of information is a traditional introductory lecture course in Prolog. For these people my book will serve to show in context how the various programming techniques and language elements may be employed. The book may be used to accompany such a course as a workbook and the student should find in it a wealth of information to answer questions concerning the aspects of Prolog taught in the course.

- Those who want to refresh and extend their knowledge of Prolog, perhaps with some field of application in mind.

- Students of AI learning about search algorithms in particular. Most AI books present search algorithms by pseudocode and are not concerned with details of implementation. In my experience, however, anything seen implemented is more likely to be retained (beyond the exam).

There is a deeper reason also why such a book is felt timely. Programming is a creative activity and it is an innate human need to take pleasure (and pride) in the object of one’s creation, be it a sculpture, a painting, a piece of music, or indeed, a computer program. The opportunity is provided here for students to learn (and experience the said intellectual satisfaction) by creating their own solutions in Prolog to a host of interesting, challenging and varied programming problems. Many of the problems and the way they are approached here are believed to be novel.

Sadly, it is felt that the creative aspect of learning is not given enough room in today’s educational environment in the UK.1 It is hoped that this book will help the student to rediscover Prolog programming as a worthwhile and enjoyable activity.

The core of the material in this book grew out of laboratory classes and coursework prepared by the author for second year computer science students at Bradford University, as part of the lecture course Symbolic and Declarative Computing – Artificial Intelligence. This is a two-semester course with an introduction to Functional Programming with Haskell, Logic Programming with Prolog and the basics of AI. The choice of examples and topics for this book is of course tinged by the context in which Prolog was presented. For example, I discuss the functional programming style since it is useful in producing concise, readable and elegant implementations also in Prolog. The selection of topics for the examples was influenced in part by the AI element of the course though much new material has found its way into the book. To make set problems more easily accessible for the reader, I subdivide the overall task into managable portions indicating in each the desired outcome (if applicable, in form of a sample session in Prolog) with suggestions for how best to attack the subtasks.

The working style advocated here is best described by the following attributes:

- example based,

- interactive,

- exploratory and experimental,

- incremental,

- progressing from the specific to the more general,

- identifying patterns of computation with a view to generalization.

It will be seen from the list of contents that the material, by its very nature, is not ordered in a linear fashion but is grouped in topics deemed important for programming in Prolog.

The work comprises two parts: the present volume Prolog Techniques and the forthcoming Applications of Prolog. This first volume is in four chapters and illustrates special Prolog programming techniques. The second volume will concentrate on applications of Prolog, mainly from Artificial Intelligence.

The order in which the books may be studied is fairly free even though an example introduced somewhere may serve in a later chapter to illustrate the generalization or improvement afforded by the material just covered.

The SWI-Prolog compiler is used throughout: it has been around for quite some time; it is well documented; it is free; and, it is being maintained with new, improved versions becoming available all the time. Furthermore, there is an object oriented extension to SWI-Prolog (XPCE) for building graphical applications, useful if one wants to pursue this line further.

Solutions for a selection of exercises are discussed in the appendices. All Prolog source code produced in the course of this book project (including model solutions for all the exercises) can be downloaded from the Ventus website.

I am grateful to Dr. Coxhead of Birmingham University for discussions and extensive comments on initial versions of several of the chapters. My colleague Dr. Fretwell gave me many tips concerning LATEX, the typesetting system used to produce the books.

Attila Csenki


April 2009

  1. Accumulator Technique
    1. A Simple Example
    2. Hand Computations
    3. Further Examples
    4. Pseudocodes
    5. Generalization
    6. Case Study: The Perceptron Training Algorithm
  2. Difference Lists
    1. Implementations of List Concatenation
    2. Implementations of List Flattening
    3. Implementations of List Reversal
    4. Case Study: Dijkstra’s Dutch Flag Problem
    5. Rotations
  3. Program Manipulations
    1. Simple Database Operations
    2. Case Study: Automated Unfolding
    3. Dijkstra’s Dutch Flag Problem Revisited
  4. Exploratory Code Development
    1. A Nursery Rhyme
    2. Project: ’One Man Went to Mow ...’
    3. Chapter Notes
  5. Solutions of Selected Exercises
    1. Chapter 1 Exercises
    2. Chapter 2 Exercises
    3. Chapter 3 Exercises
    4. Chapter 4 Exercises
  6. Software
  7. Glossary
  8. References
  9. Index
Es un texto muy importante para iniciar en el mundo de la inteligencia artificial.
Very practical and down to earth. With fine explanations of the techniques presented.
More reviews
About the Author

Attila Csenki