Welcome to the Prolog book. This book can serve as a textbook or tutorial for anyone who wants to learn the Prolog programming language. No prior programming experience is required. Some basic knowledge of logic can come in handy. For those new to the subject, a short introduction to logic is given, but this is not required reading.

The first chapters of the book (under Basics) describe the central syntax and features of the language. The next section, Programming, explores additional concepts that are useful when programming in Prolog. The chapters under Basics and Programming are meant to be read in order.

The section Built-in Predicates deals with the functions available in many Prolog compilers. These and other chapters can be read in any order.

Special pages

Table of contents

Beginning Prolog


Recursive Rules
Math, Functions and Equality
Putting it Together
Solving a Logic Puzzle


Cuts and Negation
Reading and Writing code
Difference Lists
Definite Clause Grammars
Inference Engines

Built-in Predicates:

Testing Terms
Bagof, Setof and Findall
Modifying the Database
Input and Output

Advanced Prolog

Associative map
Search techniques
Graphics: XPCE

Prolog and beyond

Higher Order Programming
Constraint Logic Programming
Definite Clause Grammars
Combining Languages
A selection of interesting usergroup topics
External Links