Download An Introductory Course on Constraint Logic Programming
Transcript
Contents
1 What is Constraint (Logic) Programming?
1.1
1.2
1.3
1.4
1.5
1.6
1.7
Introduction . . . . . . . . . . . . . . . . . . . .
Typical Applications and Approaches . . . . .
Constraints: Representation and Solving . . . .
Constraints as (Extended) Equations . . . . . .
Why Constraints and Programming? . . . . . .
Constraint{Programming Language Interfaces .
An Example: SEND + MORE = MONEY . .
1.7.1 Prolog: Generate and Test . . . . . . .
1.7.2 ILOG Solver (C++ Version) . . . . . .
1.7.3 ILOG Solver (Le Lisp Version) . . . . .
1.7.4 Eclipse Version . . . . . . . . . . . . . .
1.8 Use Prolog as Host Language? . . . . . . . . .
1.9 How Does a CLP System Work? . . . . . . . .
1.9.1 Modeling the Problem . . . . . . . . . .
1.9.2 Be a Solver . . . . . . . . . . . . . . . .
1.9.3 Don't Be a Solver! . . . . . . . . . . . .
2 A Basic Language
2.1 A Basic Constraint Language . . . . . . . .
2.1.1 Clauses . . . . . . . . . . . . . . . .
2.1.2 Implicit Equality . . . . . . . . . . .
2.1.3 Facts . . . . . . . . . . . . . . . . . .
2.1.4 Predicates . . . . . . . . . . . . . . .
2.1.5 Programs and Queries . . . . . . . .
2.2 Searching . . . . . . . . . . . . . . . . . . .
2.3 Logical Variables . . . . . . . . . . . . . . .
2.4 The Execution Mechanism . . . . . . . . . .
2.5 Database Programming . . . . . . . . . . .
2.6 Datalog and the Relational Database Model
3 Adding Computation Domains
3.1
3.2
3.3
3.4
Domains . . . . . . . . . . . . .
Linear (Dis)Equations . . . . .
Linear Problems with Prolog IV
Fibonacci Numbers . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
i
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.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