Q: small, simple constraint example in Prolog?

Quote:

>A few years ago, I got a license for CLP from IBM and played

>with it (CLP was prolog, plus a constraint solver over intervals).

>I was interested in again playing with constraint programming in Prolog,

>but I would rather start with a very small toy system (1 or 2 pages

>of Prolog code), and build it up myself. Any book references, or

>small example systems would be very much appreciated!

Although I haven't read it cover-to-cover, this is a book on CLP

(in the generic sense, not IBM Reserach's CLP(R) software) that I

can very much recommend. (It is however more formal and mathematically

rigorous than your book "Intelligent Java Applications for the

Internet and Intranets" published by Morgan Kaufmann.)

Kim Marriott, Peter J. Stuckey:

Programming With Constraints: An Introduction.

MIT Press, 1998.

ISBN: 0262133415 (Hardcover, 467 pages)

The following info is from www.clbooks.com:

Summary:

The job of the constraint programmer is to use mathematical constraints

to model real world constraints and objects. In this book, Kim Marriott

and Peter Stuckey provide the first comprehensive introduction to the

discipline of constraint programming and, in particular, constraint logic

programming. The book covers the necessary background material from

artificial intelligence, logic programming, operations research, and

mathematical programming. Topics discussed range from constraint-solving

techniques to programming methodologies for constraint programming

languages. Because there is not yet a universally used syntax for

constraint logic programming languages, the authors present the programs

in a way that is independent of any existing programming language.

Practical exercises cover how to use the book with a number of existing

constraint languages.

TABLE OF CONTENTS

Preface

Introduction

Notes

I Constraints

1 Constraints

1.1 Constraints and Valuations

1.2 Modelling with Constraints

1.3 Constraint Satisfaction

1.4 Tree Constraints

1.5 Other Constraint Domains

1.6 Properties of Constraint Solvers

1.7 (*) Determined Variables and Local Prevention

1.8 Summary

1.9 Exercises

1.10 Practical Exercises

1.11 Notes

2 Simplification, Optimization and Implication

2.1 Constraint Simplification

2.2 Projection

2.3 Constraint Simplifiers

2.4 Optimization

2.5 The Simplex Algorithm

2.6 (*) Canonical Form Simplifiers

2.7 (*) Implication and Equivalence

2.8 Summary

2.9 Exercises

2.10 Practical Exercises

2.11 Notes

3 Finite Constraint Domains

3.1 Constraint Satisfaction Problems

3.2 A Simple Backtracking Solver

3.3 Node and Arc Consistency

3.4 Bounds Consistency

3.5 Generalized Consistency

3.6 Optimization for Arithmetic CSPs

3.7 Summary

3.8 Exercises

3.9 Practical Exercises

3.10 Notes

II Constraint Logic Programming

4 Constraint Logic Programs

4.1 User-Defined Constraints

4.2 Programming with Rules

4.3 Evaluation

4.4 Derivation Trees and Finite Failure

4.5 Goal Evaluation

4.6 Simplified Derivation Trees

4.7 The CLP Scheme

4.8 (*) Independence from Rule Ordering and Literal Selection

4.9 Summary

4.10 Exercises

4.11 Practical Exercises

4.12 Notes

5 Simple Modelling

5.1 Simple Modelling

5.2 Modelling Choice

5.3 Iteration

5.4 Optimization

5.5 Summary

5.6 Practical Exercises

5.7 Notes

6 Using Data Structures

6.1 Records

6.2 Lists

6.3 Association Lists

6.4 Binary Trees

6.5 Hierarchical Modelling

6.6 Tree Layout

6.7 Summary

6.8 Practical Exercises

6.9 Notes

7 Controlling Search

7.1 Estimating the Efficiency of a CLP Program

7.2 Controlling Search: An Example

7.3 Rule Ordering

7.4 Literal Ordering

7.5 Adding Redundant Constraints

7.6 Minimization

7.7 Identifying Deterministic Subgoals

7.8 An Extended Example: Bridge Building

7.9 Summary

7.10 Exercises

7.11 Practical Exercises

7.12 Notes

8 Modelling with Finite Domain Constraints

8.1 Domains and Labelling

8.2 Complex Constraints

8.3 Labelling

8.4 Different Problem Modellings

8.5 An Extended Example: Scheduling

8.6 (*) Arc Consistency

8.7 (*) Library Predicates

8.8 Summary

8.9 Practical Exercises

8.10 Notes

9 Advanced Programming Techniques

9.1 Extending the Constraint Solver

9.2 Combined Symbolic and Arithmetic Reasoning

9.3 Programming Optimization

9.4 Higher-order Predicates

9.5 Negation

9.6 CLP Languages with Dynamic Scheduling

9.7 (*) Meta Programming

9.8 (*) Library Predicates

9.9 Summary

9.10 Practical Exercises

9.11 Notes

10 CLP Systems

10.1 Simple Backtracking Goal Evaluation

10.2 Incremental Constraint Solving

10.3 Efficient Saving and Restoring of the Constraint Store

10.4 Implementing If-Then-Else, Once and Negation

10.5 Optimization

10.6 Other Incremental Constraint Solvers

10.7 (*) Incremental Real Arithmetic Solving

10.8 Summary

10.9 Exercises

10.10 Notes

III Other Constraint Programming Languages

11 Constraint Databases

11.1 Modelling with Constraint Databases

11.2 Bottom Up Evaluation

11.3 Bottom-Up versus Top-Down

11.4 Mimicking Top-Down Evaluation Bottom-Up

11.5 (*) Improving Termination

11.6 (*) Relationship with Relational Databases

11.7 Summary

11.8 Exercises

11.9 Practical Exercises

11.10 Notes

12 Other Constraint Programming Languages

12.1 The CLP Paradigm

12.2 Concurrent Constraint Programming Languages

12.3 Constraint Handling Rules

12.4 Functional Languages

12.5 Term Rewriting

12.6 Imperative Programming Languages

12.7 Constraint Solving Toolkits

12.8 Mathematical Languages

12.9 Notes

References

Index

--

Robert Marti

Institut fur Informationssysteme

ETH-Zentrum

CH-8092 Zurich, Switzerland