The Craft of Prolog

Paperback (Print)
Buy New
Buy New from
Used and New from Other Sellers
Used and New from Other Sellers
from $29.60
Usually ships in 1-2 business days
(Save 29%)
Other sellers (Paperback)
  • All (7) from $29.60   
  • New (6) from $29.60   
  • Used (1) from $33.88   


Hacking your program is no substitute for understanding your problem.

Prolog is different, but not that different. Elegance is not optional. These are the themes that unify Richard O'Keefe's very personal statement on how Prolog programs should be written. The emphasis in The Craft of Prolog is on using Prolog effectively. It presents a loose collection of topics that build on and elaborate concepts learned in a first course. These may be read in any order following the first chapter, "Basic Topics in Prolog," which provides a basis for the rest of the material in the book.Richard A. O'Keefe is Lecturer in the Department of Computer Science at the Royal Melbourne Institute of Technology. He is also a consultant to Quintus Computer Systems, Inc.Contents: Basic Topics in Prolog. Searching. Where Does the Space Go? Methods of Programming. Data Structure Design. Sequences. Writing Interpreters. Some Notes on Grammar Rules. Prolog Macros. Writing Tokenisers in Prolog. All Solutions.

Read More Show Less

Editorial Reviews

Not an introductory textbook. This loose collection of Prolog programming topics is for those who've read one of the introductory books, taken an introductory Prolog course, and written one or two programs, but are wondering why it is still hard to write them well. Annotation c. Book News, Inc., Portland, OR (
Read More Show Less

Product Details

  • ISBN-13: 9780262512275
  • Publisher: MIT Press
  • Publication date: 6/19/1990
  • Series: Logic Programming
  • Edition description: New Edition
  • Pages: 416
  • Sales rank: 530,013
  • Product dimensions: 7.00 (w) x 9.00 (h) x 1.00 (d)

Meet the Author

Richard A. O'Keefe is Lecturer in the Department of Computer Science at the Royal Melbourne Institute of Technology. He is also a consultant to Quintus Computer Systems, Inc.

Read More Show Less

Table of Contents

Series Foreword
1 Basic Topics in Prolog
1.1 Introduction
1.2 Cases and Structural Induction
1.3 Inputs and Outputs
1.4 ConteXt Arguments
1.5 Difference Lists
1.6 Counters
1.7 Backwards Correctness
2 Searching
2.1 Introduction
2.2 Simple DepthFirst Search
2.3 DepthFirst Search with EXplicit Open Set
2.4 BreadthFirst Search
2.5 A Digression on Queues
2.6 Back to BreadthFirst Search
2.7 Digression: Unpacking the 'queue' Records
2.8 Keeping Track of Visited Nodes
2.9 Local Heuristic Ordering
2.10 Global Heuristic Ordering
2.11 An EXample
2.12 Iterative Deepening
2.13 Returning the Method in your Comments
2.14 EXplain the Method in your Comments
2.15 The Algebra of Binary Relations
3 Where Does The Space Go?
3.1 The Clause Store
3.2 Variables
3.3 BoX Diagrams
3.4 Measuring Space Used
3.5 A Hack
3.6 The Trail
3.7 Choice Points and the Cut
3.8 Uses of the Cut
3.9 Cutting away Clauses
3.10 Pruning Alternative Solutions
3.11 RED Cuts
3.12 GRUE Cuts
3.13 How Far Do Cuts Reach?
3.14 Disjunction and IfThenElse
3.15 'repeat' Loops
3.16 IfThenElse
3.17 Tips
4 Methods of Programming
4.1 The Problem of the Dutch National Flag
4.2 The Problem of Merging Two Ordered Lists
4.3 Computing the Size of a Tree
4.4 The Search for the Small Superset
4.5 Rem's Algorithm for the Recording of Equivalence Classes
4.6 Efficient Data Structures
4.7 Keep It Clean!
5 Data Structure Design
5.1 Introduction
5.2 Writing a SetUnion Predicate
5.3 The Importance of Data Structures
5.4 The Problem of Transitive Closure
5.5 GeneralPrinciples
6 Sequences
6.1 Introduction and Notation
6.2 Representing Sequences
6.3 Conversion
6.4 Computing Functions of Lists
6.5 Naming and Calculating Parts of Sequences
6.6 Tree Traversal
6.7 Selecting a Subsequence
6.8 PrefiXes
6.9 Concatenation
6.10 Mapping
6.11 Crossproducts
6.12 Recurrences
6.13 Metaprograms and Objectoriented Programming
6.14 Quantification
6.15 The Importance of Algebra
6.16 Summary
7 Writing Interpreters
7.1 Introduction
7.2 But First, An Easy Case
7.3 Compiling the Interpreter Away
7.4 Multiple Interpretations
7.5 Writing Simple Prolog Interpreters
7.6 Conditional Cuts
7.7 Augmenting Prolog
7.8 Summary
8 Some Notes on Grammar Rules
8.1 Introduction
8.2 A Brief Description of Grammar Rules
8.3 Phrase/[2,3]
8.4 EXamples
8.5 A Notational Convention
8.6 Perspective on a Problem
9 Prolog Macros
9.1 A Digression about print/1
9.2 How eXpand_term/2 works
9.3 Conditional Reading
9.4 Macros
9.5 Problems
10 Writing Tokenisers in Prolog
10.1 Reading a Sentence
10.2 What Tools Already EXist?
10.3 A Simplified Problem
10.4 Programming Definition 1
10.5 Programming Definition 2
10.6 Character Output
10.7 Tokenising Prolog
11 All Solutions
11.1 Introduction
11.2 Some EXamples
11.3 Standard Predicates
11.4 Clocksin & Mellish
11.5 Doing It Right
11.6 findall/3 Reconsidered
11.7 bagof/3 and setof/3
11.8 How Do bagof/3 and setof/3 work?
11.9 Doing It Differently
11.10 In NU Prolog
Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)