10 1 1 25 8566
10 1 1 25 8566
10 1 1 25 8566
202. T. Le Provost & M. Wallace, Generalized Constraint Propagation over the CLP
Scheme, Journal of Logic Programming, 16, 319{359, 1993.
203. T. Przymusinski, On the Declarative Semantics of Deductive Databases and
Logic Programs, in: Foundations of Deductive Databases and Logic Programming,
J. Minker (Ed), Morgan Kaufmann, 193-216, 1988.
204. A. Rajasekar, String Logic Programs, draft manuscript, Dept. of Computer Sci-
ence, Univ. of Kentucky, 1993.
205. V. Ramachandran & P. van Hentenryck, Incremental Algorithms for Constraint
Solving and Entailment over Rational Trees, Proc. 13th Conf. on Foundations
of Software Technology and Theoretical Computer Science, LNCS 761, 205{217,
1993.
206. R. Ramakrishnan, Magic Templates: A Spellbinding Approach to Logic Pro-
grams, Journal of Logic Programming, 11, 189{216, 1991.
207. G. Ramalingam & T. Reps, A Categorized Bibliography on Incremental Compu-
tation, Proc. 17th ACM Symp. on Principles of Programming Languages, 502{
510, 1993.
208. P. van Roy & A.M. Despain, The Benets of Global Data
ow Analysis for an
Optimizing Prolog Compiler, Proceedings 1990 North American Conference on
Logic Programming, 501{515, 1990.
209. M. Rueher, A First Exploration of PrologIII's Capabilities, Software{Practice
and Experience 23, 177{200, 1993.
210. K. Sakai, Y. Sato & S. Menju, Boolean Groebner Bases, to appear.
211. Y. Sagiv & M. Vardi, Safety of Datalog Queries over Innite Databases, Proc.
ACM Symp. on Principles of Database Systems, 160{171, 1989.
212. V. Saraswat, CP as a General-purpose Constraint-language, Proc. AAAI-87, 53{
58, 1987.
213. V. Saraswat, A Somewhat Logical Formulation of CLP Synchronization Prim-
itives, Proc. 5th International Conference Symposium on Logic Programming ,
1298{1314, 1988.
214. V. Saraswat, Concurrent Constraint Programming Languages, Ph.D. thesis,
Carnegie-Mellon University, 1989. Revised version appears as Concurrent Con-
straint Programming, MIT Press, 1993.
215. V. Saraswat, The Category of Constraint Systems is Cartesian-Closed, Proc.
Symp. on Logic in Computer Science, 341{345, 1992.
216. V. Saraswat, D. Weinbaum, K. Kahn, & E. Shapiro, Detecting Stable Proper-
ties of Networks in Concurrent Logic Programming Languages, Proc. 7th. ACM
Symp. Principles of Distributed Computing , 210{222, 1988.
217. V. Saraswat, M. Rinard & P. Panangaden, Semantic Foundation of Concurrent
Constraint Programming, Proc. 18th ACM Symp. on Principles of Programming
Languages, 333{352, 1991.
218. V. Saraswat, A Retrospective Look at Concurrent Logic Programming, in prepa-
ration.
83
166. H.F. Leung, Distributed Constraint Logic Programming, Vol. 41, World-Scientic
Series in Computer Science, World-Scientic, 1993.
167. L.L. Li, M. Reeve, K. Schuerman, A. Veron, J. Bellone, C. Pradelles, Z. Palaskas,
D. Stamatopoulos, D. Clark, S. Doursenot, C. Rawlings, J. Shirazi & G. Sardu,
APPLAUSE: Applications Using the ElypSys Parallel CLP System, Proc. 10th
International Conference on Logic Programming, 847{848, 1993.
168. J.W. Lloyd, Foundations of Logic Programming, Springer-Verlag, Second Edi-
tion, 1987.
169. J.W. Lloyd & R.W. Topor, Making Prolog More Expressive, Journal of Logic
Programming, 1, 93{109, 1984.
170. K. McAloon & C. Tretko, 2LP: A Logic Programming and Linear Programming
System, Brooklyn College Computer Science Technical Report No 1989-21, 1989.
171. A. McDonald, P. Stuckey & R.H.C. Yap, Redundancy of Variables in CLP(R),
Proc. International Logic Programming Symposium, 75{93, 1993.
172. J. McKinsey, The Decision Problem for Some Classes of Sentences Without
Quantiers, Journal of Symbolic Logic, 8, 61{76, 1943.
173. M.J. Maher, Logic Semantics for a Class of Committed-Choice Programs, Proc.
4th International Conference on Logic Programming, 858{876, 1987.
174. M.J. Maher, Complete Axiomatizations of the Algebras of Finite, Rational and
Innite Trees, Proc. 3rd. Symp. Logic in Computer Science, 348{357, 1988. Full
version: IBM Research Report, T.J. Watson Research Center.
175. M.J. Maher, A CLP View of Logic Programming, Proc. Conf. on Algebraic and
Logic Programming, LNCS 632, 364{383, 1992.
176. M.J. Maher, A Transformation System for Deductive Database Modules with
Perfect Model Semantics, Theoretical Computer Science 110, 377{403, 1993.
177. M.J. Maher, A Logic Programming View of CLP, Proc. 10th International Con-
ference on Logic Programming, 737{753, 1993. Full version: IBM Research Re-
port, T.J. Watson Research Center.
178. M.J. Maher & P.J. Stuckey, Expanding Query Power in CLP Languages, Proc.
North American Conference on Logic Programming, 1989, 20{36.
179. G.S. Makanin, The Problem of Solvability of Equations in a Free Semigroup,
Math. USSR Sbornik 32(2), 129{198, 1977. (English translation, AMS 1979).
180. H. Mannila & E. Ukkonen, On the Complexity of Unication Sequences, Proc.
3rd International Conference on Logic Programming, 122{133, 1986.
181. A. Mantsivoda, Flang and its Implementation, Proc. Symp. on Programming
Language Implementation and Logic Programming, LNCS 714, 151{166, 1993.
182. K.G. Marriott & P.J. Stuckey, The 3 R's of optimizing constraint logic pro-
grams: Renement, removal and reordering, Proc. 20th ACM Symp. Principles
of Programming Languages, 334{344, 1993.
183. K.G. Marriott & P.J. Stuckey, Semantics of CLP Programs with Optimization,
Technical Report, University of Melbourne, 1993.
81
150. A. Koscielski & L. Pacholski, Complexity of Unication in Free Groups and Free
Semigroups, Proc. 31st Symp. on Foundations of Computer Science, 824{829,
1990.
151. R. Krishnamurthy, R. Ramakrishnan & O. Shmueli, A Framework for Testing
Safety and Eective Computability of Extended Datalog, Proc. ACM Symp. on
Management of Data, 154{163, 1988.
152. C.A.C. Kuip, Algebraic Languages for Mathematical Programming, European
Journal of Operations Research 67, 25{51, 1993.
153. K. Kunen, Negation in Logic Programming, Journal of Logic Programming, 4,
289{308, 1987.
154. D. Ladret & M. Rueher, Contribution of Logic Programming to support Telecom-
munications Protocol Tests, Proc. 10th International Conference on Logic Pro-
gramming, 845{846, 1993.
155. S. Lakmazaheri & W. Rasdorf, Constraint Logic Programming for the Analysis
and Partial Synthesis of Truss Structures, Articial Intelligence for Engineering
Design, Analysis, and Manufacturing 3(3), 157{173, 1989.
156. C. Lassez, Constraint Logic Programming: a Tutorial, in BYTE Magazine, Au-
gust 1987, 171{176.
157. C. Lassez, K. McAloon & R.H.C. Yap, Constraint Logic Programming and Op-
tions Trading, IEEE Expert 2(3), Special Issue on Financial Software, August
1987, 42-50.
158. C. Lassez & J-L. Lassez, Quantier Elimination for Conjunctions of Linear Con-
straints via a Convex Hull Algorithm, in: Symbolic and Numeric Computation
for Articial Intelligence, B. Donald, D. Kapur and J.L. Mundy (Eds), Academic
Press, to appear. Also, IBM Research Report RC16779, T.J. Watson Research
Center, 1991.
159. J-L. Lassez, T. Huynh & K. McAloon, Simplifcation and Elimination of Redun-
dant Linear Arithmetic Constraints, Proc. North American Conference on Logic
Programming, Cleveland, 35{51, 1989.
160. J-L. Lassez, M. Maher & K.G. Marriott, Unication Revisited, in: Foundations
of Deductive Databases and Logic Programming, J. Minker (Ed), Morgan Kauf-
mann, 587{625, 1988.
161. J-L. Lassez & K.G. Marriott, Explicit Representation of Terms Dened by
Counter Examples, Journal of Automated Reasoning, 3, 301{317, 1987.
162. J-L. Lassez & K. McAloon, A Canonical Form for Generalized Linear Con-
straints, Journal of Symbolic Computation 13, 1{24, 1992.
163. J-L. Lassez & K. McAloon, A Constraint Sequent Calculus, Proc. of Symp. on
Logic in Computer Science, 52{62, 1990.
164. J-L. Lauriere, A Language and a Program for Stating and Solving Combinatorial
Problems, Articial Intelligence 10, 29{127, 1978.
165. W. Leler, Constraint Programming Languages: Their Specication and Genera-
tion, Addison-Wesley, 1988.
80
133. J. Jaar, S. Michaylov, P. Stuckey & R.H.C. Yap, The CLP(R) Language and
System, ACM Transactions on Programming Languages, 14(3), 339{395, 1992.
134. J. Jaar, S. Michaylov & R.H.C. Yap, A Methodology for Managing Hard Con-
straints in CLP Systems, Proc. ACM-SIGPLAN Conference on Programming
Language Design and Implementation, 306{316, 1991.
135. J. Jaar, S. Michaylov, P. Stuckey & R.H.C. Yap, An Abstract Machine for
CLP(R), Proceedings ACM-SIGPLAN Conference on Programming Language
Design and Implementation, 128{139, 1992.
136. J. Jaar and P. Stuckey, Canonical Logic Programs, Journal of Logic Program-
ming 3, 143{155, 1986.
137. S. Janson & S. Haridi, Programming Paradigms of the Andorra Kernel Language,
Proc. International Logic Programming Symposium, 167{183, 1991.
138. N. Jorgensen, K. Marriott & S. Michaylov, Some Global Compile-time Opti-
mizations for CLP(R), Proceedings 1991 International Logic Programming Sym-
posium, 420{434, 1991.
139. J. Jourdan & R.E. Valdes-Perez, Constraint Logic Programming Applied to Hy-
pothetical Reasoning in Chemistry, Proceedings North American Conference on
Logic Programming, 154{172, 1990. (Page 161 should follow page 166.)
140. K. Kanchanasut & C. Sumetphong, Floor Planning Applications in CLP(R),
Proc. JICSLP Workshop on Constraint Logic Programming, 36{44, 1992.
141. L.G. Khachian, A polynomial algorithm in linear programming, Soviet Math.
Dokl., 20(1), 191{194, 1979.
142. J. de Kleer and G.J. Sussman, Propagation of Constraints Applied to Circuit
Synthesis, Circuit Theory and Applications 8, 127{144, 1980.
143. P. Kanellakis, J-L. Lassez & V. Saraswat (Eds), Principles and Practice of Con-
straint Programming, MIT Press, to appear.
144. P. Kanellakis, G. Kuper & P. Revesz, Constraint Query Languages, Journal of
Computer and System Sciences, to appear. Preliminary version appeared in Proc.
9th ACM Symp. on Principles of Database Systems, 299{313, 1990.
145. P. Kanellakis, S. Ramaswamy, D.E. Vengro & J.S. Vitter, Indexing for Data
Models with Constraints and Classes, Proc. ACM Symp. on Principles of
Database Systems, 1993.
146. D. Kemp, K. Ramarohanarao, I. Balbin & K. Meenakshi, Propagating Con-
straints in Recursive Deductive Databases, Proc. North American Conference
on Logic Programming, 981{998, 1989.
147. D. Kemp & P. Stuckey, Analysis based Constraint Query Optimization, Proc.
10th International Conference on Logic Programming, 666{682, 1993.
148. V. Klee & G.J. Minty, How good is the Simplex algorithm?, in: Inequalities-III,
O. Sisha (Ed), Academic Press, New York, 159{175, 1972
149. A. Klug, On Conjunctive Queries Containing Inequalities, Journal of the ACM
35, 1, 146{160, 1988.
79
115. P. van Hentenryck, V. Saraswat & Y. Deville, Constraint Processing in cc(F D),
manuscript, 1991.
116. P. van Hentenryck, V. Saraswat & Y. Deville, Design, Implementations and Eval-
uation of the Constraint Language cc(F D), Technical Report CS-93-02, Brown
University, 1993.
117. T. Hickey, Functional Constraints in CLP Languages, in: Constraint Logic Pro-
gramming: Selected Research, F. Benhamou and A. Colmerauer (Eds.), MIT
Press, 355{381, 1993.
118. M. Hohfeld & G. Smolka, Denite Relations over Constraint Languages, LILOG
Report 53, IBM Deutschland, 1988.
119. D. Homiak, A CLP System for Solving Partial Dierential Equations with Ap-
plications to Options Valuation, Masters Project, DePaul University, 1991.
120. H. Hong, RISC-CLP(Real): Logic Programming with Non-linear Constraints
over the Reals, in: Constraint Logic Programming: Selected Research, F. Ben-
hamou and A. Colmerauer (Eds.), MIT Press, 133{159, 1993.
121. A. Horn, On Sentences Which are True of Direct Unions of Algebras, Journal of
Symbolic Logic, 16, 14{21, 1951.
122. T. Huynh & C. Lassez, A CLP(R) Options Trading Analysis System, Proceedings
5th International Conference on Logic Programming, 59{69, 1988.
123. T. Huynh, C. Lassez & J-L. Lassez, Practical Issues on the Projection of Poly-
hedral Sets, Annals of Mathematics and Articial Intelligence 6, 295{315, 1992.
124. J-L. Imbert, Variable Elimination for Disequations in Generalized Linear Con-
straint Systems, The Computer Journal 36, 473{484, 1993.
125. J-L. Imbert, Fourier's Elimination: which to choose? Proc. Workshop on Prin-
ciples and Practice of Constraint Programming, Newport, 119{131, April 1993.
126. J. Jaar, Ecient Unication over Innite Terms, New Generation Computing,
2, 207{219, 1984.
127. J. Jaar, Minimal and Complete Word Unication, Journal of the ACM, 37(1),
47{85, 1990.
128. J. Jaar & J-L. Lassez, Constraint Logic Programming, Technical Report 86/73,
Department of Computer Science, Monash University, 1986.
129. J. Jaar & J-L. Lassez, Constraint Logic Programming, Proc. 14th ACM Sympo-
sium on Principles of Programming Languages, Munich (January 1987), 111{119.
130. J. Jaar, J-L. Lassez & M.J. Maher, A Theory of Complete Logic Programs with
Equality, Journal of Logic Programming 1, 211{223, 1984.
131. J. Jaar, J-L. Lassez & M.J. Maher, A Logic Programming Language Scheme,
in: Logic Programming: Relations, Functions and Equations, D. DeGroot and G.
Lindstrom (Eds), Prentice-Hall, 441{467, 1986.
132. J. Jaar, M.J. Maher, P.J. Stuckey & R.H.C. Yap, Projecting CLP(<) Con-
straints, New Generation Computing, 11, 449{469, 1993.
78
47. M. Carlsson & M. Grindal, Automatic Frequency Assignment for Cellular Tele-
phones Using Constraint Satisfaction Techniques, Proc. 10th International Con-
ference on Logic Programming, 647{665, 1993.
48. S.N. C ernikov, Contraction of Finite Systems of Linear Inequalities (In Russian),
Doklady Akademiia Nauk SSSR, Vol. 152, No. 5, 1075{1078, 1963. (English trans-
lation in Soviet Mathematics Doklady, Vol. 4, No. 5, 1520{1524, 1963.)
49. R. Chadra, O. Cockings & S. Narain, Interoperability Analysis by Symbolic
Simulation, Proc. JICSLP Workshop on Constraint Logic Programming, 55{58,
1992.
50. A. Chamard, F. Deces & A. Fischler, Applying CHIP to a Complex Scheduling
Problem, draft manuscript, Dassualt Aviation, Department of Articial Intelli-
gence, 1992.
51. D. Chan, Constructive Negation based on Completed Database, Proc. 5th Inter-
national Conference on Logic Programming, 111{125, 1988.
52. V. Chandru, Variable Elimination in Linear Constraints, The Computer Journal,
36(5), 463{472, 1993.
53. V. Chandru & J.N. Hooker, Extended Horn Sets in Propositional Logic, Journal
of the ACM, 38, 205{221, 1991.
54. V. Chvatal, Linear Programming, W.H. Freeman and Co., New York, 1983.
55. K.L. Clark, Negation as Failure, in Logic and Databases, H. Gallaire and J.
Minker (Eds.), Plenum Press, New York, 293{322, 1978.
56. P. Codognet & D. Diaz, Boolean Constraint Solving using clp(FD), Proc. Inter-
national Logic Programming Symposium, 525{539, 1993.
57. P. Codognet, F. Fages, J. Jourdan, R. Lissajoux & T. Sola, On the Design of
Meta(F) and its Applications in Air Trac Control, Proc. JICSLP Workshop on
Constraint Logic Programming, 28{35, 1992.
58. J. Cohen, Constraint Logic Programming Languages, CACM, 33, 52{68, July
1990.
59. A. Colmerauer, Prolog-II Manuel de Reference et Modele Theorique, Groupe
Intelligence Articelle, U. d'Aix-Marseille II, 1982.
60. A. Colmerauer, Prolog and Innite Trees, in Logic Programming, K.L. Clark and
S-A. Tarnlund (Eds), Academic Press, New York, 231{251, 1982.
61. A. Colmerauer, Prolog in 10 Figures, Proc. 8th International Joint Conference
on Articial Intelligence, 487{499, 1983.
62. A. Colmerauer, Equations and Inequations on Finite and Innite Trees, Proc.
2nd. Int. Conf. on Fifth Generation Computer Systems, Tokyo, 85{99, 1984.
63. A. Colmerauer, Opening the Prolog III Universe, BYTE Magazine, August 1987.
64. A. Colmerauer, Prolog III Reference and Users Manual, Version 1.1, PrologIA,
Marseilles, 1990.
65. A. Colmerauer, An Introduction to Prolog III, CACM, 33, 69{90, July 1990.
74
31. P. Boizumault, Y. Delon & L. Peridy, Solving a real life exams problem using
CHIP, Proc. International Logic Programming Symposium, 661, 1993.
32. A. Borning, The Programming Language Aspects of ThingLab, a Constraint{
Oriented Simulation Laboratory, ACM Transactions on Programming Languages
and Systems, 3(4), 252{387, October 1981.
33. A. Borning, M.J. Maher, A. Martindale & M. Wilson, Constraint Hierarchies and
Logic Programming, Proc. 6th International Conference on Logic Programming,
149{164, 1989. Fuller version as Technical Report 88-11-10, Computer Science
Department, University of Washington, 1988.
34. A. Bossi, M. Gabbrielli, G. Levi & M.C. Meo, Contributions to the Semantics of
Open Logic Programs, Proc. Int. Conf. on Fifth Generation Computer Systems,
570{580, 1992.
35. A. Brodsky & Y. Sagiv, Inference of Inequality Constraints in Logic Programs,
Proc. ACM Symp. on Principles of Database Systems, 1991.
36. A. Brodsky, J. Jaar & M. Maher, Toward Practical Constraint Databases, Proc.
19th International Conference on Very Large Data Bases, 567{580, 1993.
37. J.M. Broek & H.A.M. Daniels, Application of CLP to Asset and Liability Man-
agement in Banks, Computer Science in Economics and Management, 4(2), 107{
116, May 1991.
38. R. Bryant, Graph Based Algorithms for Boolean Function Manipulation, IEEE
Transactions on Computers 35, 677{691, 1986.
39. C. Brzoska, Temporal Logic Programming and its Relation to Constraint Logic
Programming, Proc. International Logic Programming Symposium, 661{677,
1991.
40. C. Brzoska, Temporal Logic Programming with Bounded Universal Modality
Goals, Proc. 10th International Conference on Logic Programming, 239{256,
1993.
41. J. Burg, C. Hughes, J. Moshell & S.D. Lang, Constraint-based Programming: A
Survey, Technical Report IST-TR-90-16, Dept. of Computer Science, University
of Central Florida, 1990.
42. J. Burg, Parallel Execution Models and Algorithms for Constraint Logic Pro-
gramming over a Real-number Domain, Ph.D. thesis, Dept. of Computer Science,
University of Central Florida, 1992.
43. J. Burg, C. Hughes & S.D. Lang, Parallel Execution of CLP-< Programs, Tech-
nical Report TR-CS-92-20, University of Central Florida, 1992.
44. H-J. Burckert, A Resolution Principle for Clauses with Constraints, Proc. CADE-
10, LNCS 449, 178{192, 1990.
45. W. Buttner & H. Simonis, Embedding Boolean Expressions into Logic Program-
ming, Journal of Symbolic Computation, 4, 191{205, 1987.
46. M. Carlsson, Freeze, Indexing and other Implementation Issues in the WAM,
Proc. 4th International Conference on Logic Programming, 40{58, 1987.
73
Acknowledgements
We would like to thank the following people for their comments on drafts of this
paper and/or help in other ways: M. Bruynooghe, N. Heintze, P. van Hentenryck,
A. Herold, J-L. Lassez, S. Michaylov, C. Palamidessi, K. Shuerman, P. Stuckey, M.
Wallace, R. Yap. We also thank the anonymous referees for their careful reading
and helpful comments.
REFERENCES
1. M. Abadi & Z. Manna, Temporal Logic Programming, Journal of Symbolic Com-
putation, 8, 277{295, 1989.
2. A. Aggoun & N. Beldiceanu, Extending CHIP to Solve Complex Scheduling and
Packing Problems, In Journees Francophones De Programmation Logique, Lille,
France, 1992.
3. A. Aggoun & N. Beldiceanu, Overview of the CHIP Compiler System, in: Con-
straint Logic Programming: Selected Research, F. Benhamou and A. Colmerauer
(Eds.), MIT Press, 421{435, 1993.
4. A. Aiba, K. Sakai, Y. Sato, D. Hawley & R. Hasegawa, Constraint Logic Pro-
gramming Language CAL, Proc. International Conference on Fifth Generation
Computer Systems 1988, 263{276, 1988.
5. H. At-Kaci, An Algebraic Semantics Approach to the Eective Resolution of
Type Equations, Theoretical Computer Science 45, 293{351, 1986.
6. H. At-Kaci, Warren's Abstract Machine: A Tutorial Reconstruction, MIT Press,
1991.
7. H. At-Kaci & R. Nasr, LOGIN: A Logic Programming Language with Built-in
Inheritance, Journal of Logic Programming 3, 185{215, 1986.
8. H. At-Kaci, P. Lincoln & R. Nasr, Le Fun: Logic Equations and Functions, Proc.
Symposium on Logic Programming, 17{23, 1987.
9. H. At-Kaci & A. Podelski, Towards a Meaning of LIFE, Journal of Logic Pro-
gramming, 16, 195{234, 1993.
10. H. At-Kaci & A. Podelski, Entailment and Disentailment of Order-Sorted Fea-
ture Constraints, manuscript, 1993.
11. H. At-Kaci & A. Podelski, A General Residuation Framework, manuscript, 1993.
12. H. At-Kaci, A. Podelski & G. Smolka, A Feature-based Constraint System for
Logic Programming with Entailment, Theoretical Computer Science, to appear.
Also in: Proc. International Conference on Fifth Generation Computer Systems
1992, Vol. 2, 1992, 1012{1021.
13. L. Albert, R. Casas & F. Fages, Average-case Analysis of Unication Algorithms,
Theoretical Computer Science 113, 3{34, 1993.
14. K. Apt, H. Blair & A. Walker, Towards a Theory of Declarative Knowledge, in:
Foundations of Deductive Databases and Logic Programming, J. Minker (Ed),
Morgan Kaufmann, 89-148, 1988.
71
X in 1 - val(Y),
Y in 1 - val(X).
We conclude here by mentioning the authors' claim that this approach has great
eciency. In particular, it is several times faster than each of two Boolean solvers
deployed in CHIP, and some special-purpose stand-alone solvers.
Finally, in the ultimate output of the program, no two pathways are identical,
nor become identical under transformations such as permuting the reactants
or products within a step, or switching the reactants and products in a step.
The program representation of a molecular formula is as a list of numbers, each
of which species the number of atoms of a certain chemical element. We shall
assume that there are only four chemical elements of interest in our presentation,
and hence a molecular formula is a 4-tuple. A species is also represented by a 4-
tuple (n; a; b; f) where n is an arithmetic variable (to be used in the formulation
of the arithmetic formula mentioned above), a and b are Boolean variables (to be
used in expressing the formation dependencies), and f is the species formula. A
step R1 + R2 ?! P1 + P2 is represented by a 4-tuple (r1 ; r2; p1; p2) containing the
identiers of the representations of R1; R2; P1 and P2.
The listing below is a simplied and translated version of the Prolog III program
in [139]. In the main procedure solve, the rst argument is a list of xed size, say n,
in which each element is a species template. The rst three templates are given, and
these represent the two initial reagents R1; R2 and nal target T. Similarly, Steps
is a list of xed size, say m, in which each element is a step template. Thus n and
m are parameters to the program. The undened procedure formula of obtains
the species formula from a species, that is, it projects onto the last element of the
given 4-tuple. Similarly, arith var of, bool var a of and bool var b of project
onto the rst, second and third arguments respectively.
The procedure no duplicates asserts constraints which prevent duplicate species
and steps, and it also prevents symmetrical solutions; we omit the details. Calls to
the procedure formation dependencies generate the formation dependencies. The
procedure both reagents needed imposes two constraints, one for each reagent,
that, in conjunction with the formation dependencies, assert that R1 (respectively
R2 ) alone cannot produce T. Finally, enumerate species is self-explanatory.
solve([R1, R2, T | Species], Steps) :-
no duplicates( ... ),
balanced step( ... ), % for each step in Steps
pathway step consistency( ... ), % for each step in Steps
formation dependencies( ... ), % for each step in Steps
both reagents needed(R1, R2, T),
enumerate species( ... ).
balanced step(R1, R2 , P1 , P2 ) :-
formula of(R1, (C1, H1, N1, O1)), formula of(R2, (C2, H2, N2, O2)),
formula of(P1, (C3, H3, N3, O3)), formula of(P2, (C4, H4, N4, O4)),
C1 + C 2 = C 3 + C 4 ,
H1 + H 2 = H 3 + H 4 ,
N1 + N 2 = N 3 + N 4 ,
O1 + O 2 = O 3 + O 4 .
pathway step consistency(R1, R2, P1, P2) :-
arith var of(R1, N1 ), arith var of(R1, N2 ),
arith var of(P1, N3 ), arith var of(P1, N4 ),
N1 + N 2 = N 3 + N 4 .
formation dependencies(R1, R2 , P1 , P2 ) :-
bool var a of(R1, A1), bool var b of(R1, B1),
68
rsm(A2, B, D2, LenA + Ai, LenB, LenD + Dk, MapA, MapB, MapD).
rsm(A, B, D, LenA, LenB, LenD, MapA, [Bj|MapB], [Dk|MapD]) :-
LenB = LenD, LenB < LenA
Dk <= LenA - LenB, Bj >= Dk,
choose(Dk, D, D2),
choose(Bj, B, B2),
rsm(A, B2, D2, LenA, LenB + Bj, LenD + Dk, MapA, MapB, MapD).
This application of CLP is due to Yap [264, 265] and it is important to note that the
above program is a considerable simplication of Yap's program. A major omission
is the consideration of errors in the fragment lengths (because these lengths are
obtained from experimentation). A major point in Yap's approach is that it gives
a robust and uniform treatment of the experimental errors inherent in the data as
compared with many of the approaches in the literature. Furthermore, [265] shows
how the simple two enzyme problem can be extended to a number of other problem
variations. Because a map solution is just a set of answer constraints returned by
the algorithm, it is easy to combine this with other maps, compare maps, verify
maps, etc. This kind of
exibility is important as the computational problem of
just computing a consistent map is intractable, and hence when dealing with any
substantial amount of data, any algorithm would have to take into account data
from many varieties of mapping experiments, as well as other information specic
to the molecule in question.
13.3. Scheduling
In this class of problems, we are given a number of tasks, and for each task, a
task duration. Each task also requires other resources to be performed, and there
are constraints on precedences of task performance, and on resource usage. The
problem is to schedule the tasks so that the resources are most eciently used (for
example, perform the tasks so that all are done as soon as possible).
Consider now a basic job-shop scheduling problem in which is given a number m
of machines, j sequences of tasks, the task durations and the machine assigned to
each task. The precedence constraints are that the tasks in each sequence (called
a job) are performed in the sequence order. The resource constraints are that each
machine performs at most one task at any given time.
In the program below, precedences sets up the precedence constraints for one
job, and is called with two equally long lists. The rst contains the task variables,
whose values are the start times. The second list contains the durations of the tasks.
Thus precedences is called once for each job. The procedure resources is called
repeatedly, once for each pair of tasks T1 and T2 which must be performed without
overlapping; their durations are given by D1 and D2.
precedences([T1, T2 | Tail], [D1, D2 | Tail2]) :-
T1 + D1 <= T2,
precedences(Tail, Tail2).
precedences([], []).
problem which deals only with the lengths of fragments, instead of the fragments
themselves.
Consider the use of two enzymes. Let the rst enzyme partition the DNA se-
quence into A1 ; ; AN and the second into B1 ; ; BM . Now, a simultaneous use of
the two enzymes also produces a partition D1 ; ; DK corresponding to combining
the previous two partitions. That is,
41 For simplicity we assume that we never have all three partitions aligned except at the
beginning and at the end.
64
The second solution uses the special CHIP constraint element, described above in
Section 9.2. Recall that element(X, List, E) expresses that the Xth element of
List is E. In this second approach to the problem, the variables Xi , 1 i 4,
denote the congurations chosen. Thus 1 Xi 72. Let Ti;j , 1 i 4, 1 j 6,
denote the number of shelves j in conguration i. Let Costi , 1 i 4, denote the
wastage in conguration i. Thus the required shelves are obtained by the constraints
T1;j + +T4;j Rj where 1 j 6, and the total cost is simply Cost1 + +Cost4 .
In the program below, the constraints X1 X2 X3 X4 serve to eliminate
consideration of symmetrical solutions. The following group of 24 element con-
straints serve to compute the Ti;j variables in terms of the (given) Si;j values and
the (computed) Xi values. The next group of 4 element constraints computes the
Costi variables in terms of the (given) Wi variables. The enumerate procedure has
the range f1; 2; ; 72g. Once again, solve is run repeatedly here in the search for
the lowest Cost.
solve(X1, ... , X4, Cost) :-
X1 <= X2, X2 <= X3 , X3 <= X4,
element(X1, [S1;j , ... , S72;j ], T1;j ), % (1 j 6)
element(X2, [S1;j , ... , S72;j ], T2;j ),
element(X3, [S1;j , ... , S72;j ], T3;j ),
element(X4, [S1;j , ... , S72;j ], T4;j ),
element(X1, [W1 , ... W72], Cost1),
element(X2, [W1 , ... W72], Cost2),
element(X3, [W1 , ... W72], Cost3),
element(X4, [W1 , ... W72], Cost4),
T1;j + T2;j + T3;j + T4;j >= Rj , % (1 j 6)
Cost = Cost1 + Cost2 + Cost3 + Cost4,
enumerate(X1, X2, X3, X4).
The second program has advantages over the rst. Apart from a smaller search space
(approximately 107 in comparison with 1043), it was able to avoid encountering
symmetrical solutions. The timings given in [77] showed that the second program
ran much faster. This comparison exemplies the abovementioned fact that the way
a problem is modelled can greatly aect eciency.
sense that whenever unsatisability is reported, the tested constraints are indeed
unsatisable.
In general, the primary eciency issues are:
How complete is the constraint solver? In general, there is tradeo between
the larger cost of a more complete solver and the smaller search space that
such a solver can give rise to.
What constraints to use to model the problem? A special case of this is-
sue concerns the use of redundant constraints, that is, constraints that do
not change the meaning of the constraint store. In general, redundant con-
straints will slow down a CLP system with a complete solver. With partial
solvers, however, redundant constraints may be useful to the solver in case
the equivalent information in the constraint store is not active.
In which order do we choose the decision variables for enumeration? And
should such order be dynamically determined?
In which order do we enumerate the values for a given decision variable?
And should such order be dynamically determined?
In this section, we will outline a number of CLP applications in specic combina-
torial problem areas. In each subsection below, unless otherwise specied, we shall
assume that the underlying constraint system is based on the integers.
The above is just a brief overview of the core ideas behind the work in [157]. Among
the important aspects that are omitted are consideration of option pricing models,
and details of implementing the decision support system OTAS [122]. As in the
circuit modelling application described above, the advantages of using CLP(R)
here are that the program is concise and that the query language is expressive.
interest rate.
h(X, Y, Z) :- Y < X, Z = 0.
h(X, Y, Z) :- Y >= X, Z = 1.
r(X, Y, Z) :- Y < X, Z = 0.
r(X, Y, Z) :- Y >= X, Z = Y - X.
value(Type, Buy or Sell, S, C, P, R, X, B, Payoff) :-
sign(Buy or Sell, Sign),
data(Type, S, C, P, R, X, B, B1, B2, H1, H2, R1, R2),
h(B1, S, T1), h(B2, S, T2), r(B1, S, T3), r(B2, S, T4),
Payoff = Sign*(H1*T1 + H2*T2 + R1*T3 + R2*T4).
The parameters for the piecewise functions can be expressed symbolically in the
following tables, implemented simply as CLP facts.
sign(buy, -1).
sign(sell, 1).
data(stock, S, C, P, R, X, B, 0, 0, S*R, 0, -1, 0).
data(call, S, C, P, R, X, B, 0, X, C*R, 0, 0, -1).
data(put, S, C, P, R, X, B, 0, X, P*R-X, 0, 1, -1).
data(bond, S, C, P, R, X, B, 0, 0, B*R, 0, 0, 0).
This program forms the basis for evaluating option combinations. The following
direct query evaluates the sale of a call option that expires in-the-money38 ,
?- Call = 5, X = 50, R = 1.05, S = 60,
value(call, sell, S, Call, , R, X, , Payoff).
giving the answer, Payoff = -4.75. More general queries make use of the ability
to reason with inequalities. We can ask for what share price does the value exceed
5,
?- Payoff > 5, C = 5, X = 50, R = 1.05, S = 60,
value(call, sell, S, C, , R, X, , Payoff).
The answer constraints returned39 illustrates the piecewise nature of the model,
Payoff = 5.25, S < 50;
Payoff = 55.25 - S, 50 <= S, S <= 50.25.
More complex combinations can be constructed by composing them out of the base
nancial instruments and linking them together with constraints. For example, the
38 That is, when the strike price is less than the share price.
39 We will use `;' to separate dierent sets of answer constraints in the output.
59
The following presentation is due to Yap [266], based in his work using CLP(R).
This material appeared in [157], and the subsequently implemented OTAS system
is described in [122]. There are several main reasons why CLP, and CLP(R) in
particular, are suitable for reasoning about option trading: there are complex trad-
ing strategies used which are usually formulated as rules; there is a combinatorial
aspect to the problem as there are many ways of combining options; a combination
of symbolic and numeric computation is involved; there are well developed math-
ematical valuation models and constraints on the relationships involved in option
pricing, and nally,
exible \what-if" type analysis is required.
A simple mathematical model of valuing options, and other nancial instruments
such as stocks and bonds, is with linear piecewise functions. Let the Heaviside
function h and the ramp function r be dened as follows:
h(x; y) = 0 if x > y and r(x; y) = 0 if x > y
1 otherwise y ? x otherwise
The payo function for call and put options can now be described by the following
matrix product which creates a linear piecewise function:
2 3
h(b1 ; s)
66 h(b2 ; s) 77
payo = [h1 ; h2; r1; r2] 4 r(b ; s) 5
1
r(b2 ; s)
where s is the share price, bi is either the strike price or 0, and hi and ri are
multipliers of the Heaviside and ramp functions. In the following program, the
variables S, X, R respectively denote the stock price, the exercise price and the
58
We close this example application by mentioning that the work in [104] not only
contains further explanation of the above technique, but also addresses other prob-
lems such as the synthesis of networks and digital signal
ow. Not only does the
CLP approach provide a concise framework for modelling circuits (previously done
in a more ad-hoc manner), but it also provides additional functionality because re-
lationships, as opposed to values, are reasoned about. Evidence that this approach
can be practical was given; for example, the modelling can be executed at the rate
of about 100 circuit components per second on an RS6000 workstation.
asks for the voltage value if a current value of 5 is
owing through a network
containing just three identical resistors in series. (The answer is R = 0.0666667*V.)
Additional rules can be added for other devices. For example, the piece-wise linear
model of a diode described by the voltage-current relationship
8
< 10V + 1000 if V < ?100
I = : 0:001V if ? 100 V 0:6
100V ? 60 if V > 0:6
This basic idea can be extended to model AC networks. For example, suppose we
wish to reason about an RLC network in steady-state. First, we dispense with
complex numbers by representing X + iY as a CLP(R) term c(X, Y), and use:
c equal(c(Re, Im), c(Re, Im)).
c add(c(Re1, Im1), c(Re2, Im2), c(Re1 + Re2, Im1 + Im2)).
c mult(c(Re1, Im1), c(Re2, Im2), c(Re3, Im3)) :-
Re3 = Re1 * Re2 - Im1 * Im2,
Im3 = Re1 * Im2 + Re2 * Im1.
Part III
We consider here the use of CLP as a specication language: constraints allow
the declarative interpretation of basic relationships, and rules combine these for
complex relationships.
This presentation is adapted from [104], an early application of CLP(R). Brie
y, the
general methodology for representing properties of circuits is that constraints at a
base level describe the relationship between variables corresponding to a subsystem,
such as Ohm's law, and constraints at a higher level describe the interaction between
these subsystems, such as Kirchho's law.
Consider the following program fragment dening the procedure circuit(N, V,
I) which species that, across an electrical network N, the potential dierence and
current are V and I respectively. The network is specied in an obvious way by a
term containing the functors resistor, series and parallel. In this program,
the rst rule states the required voltage-current relationship for a resistor, and the
55
example, the addpf instruction in CLP(R). During this process, the par-
tially constructed constraint is represented in an accumulator. One of the
solve instructions then passes the constraint to the solver. We can think of
this linear form accumulator as a generalization of the accumulator in classi-
cal computer architectures, accumulating a partially constructed constraint
instead of a number.
but which are required to be added to the store, and checked for consistency. What
makes these constraints special is that after they have been added to the store (and
the store is recomputed into its new internal form), their variables appear in those
parts of the store that are never again referred to. Consider the sum program once
again. The following sequence of constraints arises from executing the goal sum(7,
X):
(1) X1 = X ? 7
(2) X10 = (X ? 7) ? 6
(3) X100 = ((X ? 7) ? 6) ? 5
Upon encountering the second equation X10 = X1 ? 6 and simplifying into (2),
note that the variable X1 will never be referred to in the future. Hence equation
(1) can be deleted. Similarly, upon encountering the third equation X100 = X10 ? 5
and simplifying into (3), the variable X10 will never be referred to in future and
so (2) can be deleted. In short, only one equation involving X need be stored
at any point in the computation. We hence add the class of instructions of the
form add and delete X which informs the solver that after considering the con-
straint associated to X, it may delete all structures associated to X. In CLP(R), the
corresponding instruction is addpf and delete n, X, the obvious variant of the
previously described instruction addpf n, X. Compiling this sum example gives
(1) init pf -7
addpf 1, X
solve no fail eq X1
(2) init pf -6
addpf and delete 1, X1
solve no fail eq X1'
(3) init pf -5
addpf and delete 1, X1'
solve no fail eq X1''
Note that a dierent set of instructions is required for the rst equation from that
required for the remaining equations. Hence the rst iteration needs to be unrolled
to produce the most ecient code. The main challenge for this special case is, as in
special case 2, the detection of the special constraints. We now address this issue.
11.2.2. Techniques for CLP Program Analysis The kinds of program analysis
required to utilize the specialized instructions include those techniques developed
for Prolog, most prominently, detecting special cases of unication and determin-
istic predicates. Algorithms for such analysis have become familiar; see [73, 74]
for example. See [98], for example, for a description of how to extend the general
techniques of abstract interpretation applicable in LP to CLP. Our considerations
above, however, require rather specic kinds of analyses.
Detecting redundant variables and future redundant constraints can in fact be
done without data
ow analysis. One simple method involves unfolding the predi-
cate denition (and typically once is enough), and then, in the case of detecting
redundant variables, simply inspecting where variables occur last in the unfolded
denitions. For detecting a future redundant constraint, the essential step is de-
52
new variable. A direct compilation results in the following. Note that the rightmost
column depicts the current state of the accumulator.
initpf 5 accumulator : 5
addpf 1, X accumulator : 5 + X
addpf -1, Y accumulator : 1:86 + X ? Z
solve eq0 solve : 1:86 + X ? Z = 0
A better compilationcan be obtained by using a specialized instruction solve no fail eq
X which adds the equation X = exp to the store, where exp is the expression in
the accumulator. The main dierence here with solve eq0 is that no satisability
check is performed. For the above example, we now can have
initpf -5 accumulator : ?5
addpf -1, Y accumulator : ?1:86 + Z
solve no fail eq X add : X = ?1:86 + Z
In summary for this special case, for CLP systems in general, we often encounter
constraints which can be organized into a form such that its consistency with the
store is obvious. This typically happens when a new variable appears in an equa-
tion, for example, and new variables are often created in CLP systems. Thus the
instructions of the form solve no fail xxx are justied.
Next consider the special case 2, and the following example CLP(R) program.
sum(0, 0).
sum(N, X) :-
N >= 1,
N1 = N - 1,
X1 = X - N,
sum(N1, X1).
Of concern to us here are constraints that, if added to the store, can be shown to
become redundant as a result of future additions to the store. This notion of future
redundancy was rst described in [138]. Now if we execute the goal sum(N, X) using
the second rule above, we obtain the subgoal
?- N >= 1, N1 = N - 1, X1 = X - N, sum(N1, X1).
Continuing the execution, we now have two choices: choosing the rst rule we
obtain the new constraint N1 = 0, and choosing the second rule we obtain the
constraint N1 1 (among others). In each case the original constraint N 1 is
made redundant. The main point of this example is that the constraint N 1
in the second rule should be implemented simply as a test, and not added to the
constraint store. We hence dene the new class of instructions solve no add xxx.
This example shows that future redundant constraints do occur in CLP systems.
However, one apparent diculty with this special case is the problem of detecting its
occurrence. We will mention relevant work on program analysis below. Meanwhile,
we remark that experiments using CLP(R) have shown that this special case leads
to the most substantial eciency gains compared to the other two kinds of special
cases discussed in this section [188, 266].
Finally consider special case 3. Of concern here are constraints which are neither
entailed by the store as in case 1 nor are eventually made redundant as in case 2,
51
where xxx indicates the kind of constraint and the Xi denotes the arguments. Typi-
cally these arguments are, as in the WAM, stack locations or registers. For example,
in CLP(R), there are instructions of the form initpf n and addpf n, X, where n
is a number and X a (solver) variable. The former initializes a parametric form to
contain just the number n. The latter adds an entry of the form n pf(X) to the
parametric form being stored in an accumulator, where pf(X) is the parametric
form for X in the store. Thus the accumulator in general stores an expression exp
of the form n + n1 X1 + + nk Xk . Then, the instruction solve eq0 tests for
the consistency of exp = 0 in conjunction with the store. If consistent, the solver
adds the equation to the store; otherwise, backtracking occurs. There are similar
instructions for inequalities.
There are important special kinds of constraints that justify making specialized
versions of this basic instruction. While there are clearly many kinds of special cases,
some specic to certain constraint domains, there are three cases which stand out:
1. the constraint is to be added to the store, but no satisability check is needed;
2. the constraint need not be added, but its satisability in conjunction with
the store needs to be checked;
3. the constraint needs to be added and satisability needs to be checked, but
the constraint is never used later.
To exemplify the special case 1, consider adding the constraint 5 + X ? Y = 0
to the store. Suppose that Y = Z + 3:14 is already in the store, and that X is a
50
...
pow(5,y,z) z=#
y=# #<>0
z=1 #<>1
x=0 y=1 #<>1 z=0
pow(y,5,y)
pow(y,x,y)
pow(x,y,z)
and undoing the delay/upgrade of one constraint) is bounded by the (xed) size
of the underlying wakeup system. The total cost of an operation (delaying a new
constraint, processing an entailed constraint, backtracking) on delayed constraints
is proportional to the number of the delayed constraints aected by the operation.
...
pow(y,x,y)
pow(x,y,z)
with a (downward) pointer to C, and nally, (c) construct the new DW -lists
corresponding to C 00 as dened above for the delay operation.
Backtrack Restoring the stack during backtracking is easy because it only re-
quires a series of pops. Restoring the list structure, however, is not as
straightforward because no trailing/saving of the changes was performed.
In more detail, the operation of backtracking is the following: (a) Pop the
stack, and let C denote the constraint just popped. (b) Delete all occurrence
nodes pointed to by C. If there is no pointer from C (and so it was a con-
straint that was newly delayed) to another constraint deeper in the stack,
then nothing more need be done. (c) If there is a pointer from C to another
constraint C 0 (and so C is the reduced form of C 0), then perform the mod-
ications to the access structure as though C 0 were being pushed onto the
stack. These modications, described above, involve computing the guards
pertinent to C 0, inserting occurrence nodes, and setting up reverse pointers.
Note that the index structure obtained in backtracking may not be struc-
turally the same as that of the previous state. What is important, however,
is that it depicts the same logical structure as that of the previous state.
Figure 3 illustrates the entire runtime structure after the two constraints pow(x; y; z)
and pow(y; x; y) are stored, in this order. Figure 4 illustrates the structure after a
new input constraint makes x = 5 entailed.
In summary, a stack is used to store delayed constraints and their reduced forms.
An access structure maps a nite number of guards to lists of delayed constraints.
The constraint solver is assumed to identify those conditions which are entailed.
The cost of one primitive operation on delayed constraints (delaying a constraint,
upgrading the degree of one delayed constraint, including awakening the constraint,
48
Such a meta-language can also be used to specify the wakeup conditions. Thus, for
example, the wakeup condition $2 = #; # <> 0; # <> 1 attached to the bottom-
most degree in gure 2 represents a transition of a constraint pow($1 ; $2; $3) ^ C,
where C does not ground $2 , into pow($1 ; $2; $3) ^ C ^ c, where C ^ c does ground $2
into a number dierent from 0 and 1. The wakeup condition $2 = 1 which represents
a transition to the degree woken, represents the fact that pow($1; 1; $3) is an active
constraint (equivalent to $1 = 1). Similarly, $3 = 1 represents the transition to the
active constraint $1 = $2. Note that there is no wakeup condition $2 = 0 because
pow($1 ; 0; $3) (which is equivalent to ($1 = 0 ^ $3 6= 0) _ ($1 = 1 ^ $3 = 0)) is not
active.
In general, there will be certain requirements on the structure of such an automa-
ton to ensure that it does in fact dene a mapping from p constraints into wakeup
degrees, and that this mapping satises certain properties such as: it denes a par-
tition, it maps only active constraints into woken, it is consistent with the wakeup
conditions specifying the transitions, etc. A starting point will be a formalization of
the meta-language used. These formal aspects are beyond the scope of this survey.
In summary, wakeup systems are an intuitive way to specify the organization
of guard constraints. The wakeup degrees represent the various dierent cases of a
delayed constraint which should be treated dierently for eciency reasons. Asso-
ciated with each degree is a number of wakeup conditions which specify when an
input constraint changes the degree of a delayed constraint. What is intended is that
the wakeup conditions represent all the situations in which the constraint solver can
eciently update its knowledge about what further constraints are needed to wake
the delayed constraint.
Before embarking on the runtime structure to implement delayed constraints
such as pow, we amplify the abovementioned point about the similarities between
delayed constraints and guarded clauses. Consider the guarded clause program:
pow(X,Y,Z) :- Y=1 | X=1.
pow(X,Y,Z) :- ground(X), X6=0, 6= p
ground(Y), Y 1 | Z=log(X)/log(Y).
pow(X,Y,Z) :- ground(X), X 6=0, ground(Z) | Y= Z X.
pow(X,Y,Z) :- ground(Y), Y 6=1, ground(Z) | X=YZ .
pow(X,Y,Z) :- X=0 | Y=0, Z6= 0.
pow(X,Y,Z) :- Z=0 | X=1.
pow(X,Y,Z) :- Z=1 | X=Y.
This program could be compiled into the wakeup system in Figure 2, where the
three intermediate nodes re
ect subexpressions in the guards that might be entailed
without the entire guard being entailed. (More precisely, several woken nodes would
be used, one for each clause body.) Thus wakeup systems express a central part of
the implementation of (
at) guarded clauses. Since a guarded atom can be viewed as
a one-clause guarded clause program for an anonymous predicate, wakeup systems
are also applicable to implementing these constructs.
11.1.2. Runtime Structure Here we present an implementational framework in
the context of a given wakeup system. There are three major operations with de-
layed goals or delayed constraints which correspond to the actions of delaying,
awakening and backtracking:
1. adding a goal or delayed constraint to the current collection;
46
woken
#=3$
$1=#
$2=# $2=#
$1=#
$3=#
$2=1
$1=0
$3=0
$3=1
#<>1
$2=#
$1=# $3=#
#<>0 #<>0,#<>1
pow($1,$2,$3)
such input constraints has already been encountered, the runtime structure should
relate the delayed constraint to (the disjunction of) just the remaining kinds of
constraints which will awaken it.
Second, we require some index structure which allows immediate access to just
the guard constraints aected as the result of a new input constraint. The main
challenge is how to maintain such a structure in the presence of backtracking. For
example, if changes to the structure were trailed using some adaptation of Prolog
techniques [261], then a cost proportional to the number of entries can be incurred
even though no guard constraints are aected.
The following material is a condensation of [134].
11.1.1. Wakeup Systems For the purposes of this section, we will describe an
instance of a constraint in the form p($1 ; ; $n) ^ C where p is the n-ary constraint
symbol at hand, $1; ; $n are distinguished variables used as templates for the
arguments of p, and C is a constraint (which determines the values of $1 ; ; $n).
A wakeup degree represents a subset of the p constraints, and a wakeup system
consists of a set of wakeup degrees, and further, these degrees are organized into
an automaton where transitions between degrees are labelled by constraints called
wakeup conditions35 . Intuitively, a transition occurs when a wakeup condition be-
comes entailed by the store. There is a distinguished degree called woken which
represents active p constraints. We proceed now with an example.
Consider the CLP(R) constraint pow(x; y; z) and see gure 2. A wakeup degree
may be specied by means of constraints containing $1; ; $3 (for describing the
three arguments) and some meta-constants #; #1; #2; (for describing unspecied
values). Thus, for example, $2 = # species that the second argument is ground.
35 These are templates for the guard constraints.
45
straightforward but tedious, and hence are omitted here; see [133] for the case of
the CLP(R) system. A nal remark: this reconstruction approach has the added
advantage of incurring cost only when backtracking actually takes place.
In summary, backtracking in CLP is substantially more complex than in Prolog.
Some useful concepts to be added to the Prolog machinery are as follows: a value
trail (and, in practice, a tagged trail as well because most systems will accommodate
variables of dierent types, for example, the functor and arithmetic variables in
CLP(R)); time stamps, to avoid repeated trailing for a variable during the lifetime
of the same choice point; and nally, reconstruction of cross-references, rather than
trailing.
10.6. Backtracking
The issue here is to restore the state of the constraint solver to a previous state
(or, at least, an equivalent state). The most common technique, following Prolog, is
the trailing of constraints when they are modied by the constraint solver and the
restoration of these constraints upon backtracking. In Prolog, constraints are equa-
tions between terms, represented internally as bindings of variables. Since variables
are implemented as pointers to their bound values31, backtracking can be facili-
tated by the simple mechanism of an untagged trail [261, 6]. This identies the set
of variables which have been bound since the last choice point. Upon backtracking,
these variables are simply reset to become unbound. Thus in Prolog, the only in-
formation to be trailed is which variables have just become bound, and untrailing
simply unbinds these variables.
For CLP in general, it is necessary to record changes to constraints. While in
Prolog a variable's expression simply becomes more and more instantiated during
(forward) execution, in CLP, an expression may be completely changed from its
original form. In <LinEqn, for example, a variable x may have an original linear
form and subsequently another. Assuming that a choice point is encountered just
before the change in x, the original linear form needs to be trailed in case of back-
tracking. This kind of requirement in fact holds in all our sample domains with
the exception of FT and RT . Thus we have our rst requirement on our trailing
mechanism: the trail is a value trail, that is, each variable is trailed together with its
associated expression. (Strictly speaking, we need to trail constraints rather than
the expression to which a variable is associated. However, constraints are typically
represented internally as an association between a variable and an expression. )
Now, the trailing of expressions is in general far more costly than the trailing of
the variables alone. For this reason, it is often useful to avoid trailing when there is
no choice point between the time a variable changes value from one expression to
another. A standard technique facilitating this involves the use of time stamps: a
variable is always time stamped with the time that it last changed value, and every
choice point is also time stamped when created. Now just before a variable's value
is to be changed, its time stamp n is compared with the time stamp m of the most
recent choice point, and if n > m, clearly no trailing is needed32 .
Next consider the use of a cross-reference table for solved forms, such as those
discussed for the arithmetic domains, which use parametric variables. This is an
index structure which maps each parametric variable to a list of its occurrences in
the solved form. Such a structure is particularly useful, and can even be crucial
for eciency, in the process of substituting out a parametric variable (step (c) in
Algorithm 10.1). However, its use adds to the backtracking problem. A straight-
forward approach is to simply trail the entries in this table (according to time
stamps). However, since these entries are in general quite large, and since the cross
reference table is redundant from a semantic point of view, a useful approach is
to reconstruct the table upon backtracking. The details of such reconstruction are
31 Recall that this means that eliminable variables are not explicitly dereferenced on the r.h.s.
of the equations in the solved form.
32 In Prolog, one can think of the stack position of a variable as the time stamp.
43
combination of c and c0 , which does not contain x.29 A Fourier step eliminates x
from a set of constraints C by computing Fx (C) = felimx (c; c0) : c 2 Cx+ ; c0 2 Cx? g.
It is easy to show that 9xC $ Fx(C). Clearly repeated applications of F eliminat-
ing all non-target variables result in an equivalent set of constraints in which the
only variables (if any) are target variables.
The main problem with this algorithm is that the worst-case size of Fx (C)
is O(N 2), where N is the number of constraints in C. (It is in fact precisely
jCx0j + (jCx+ j jCx? j) ? (jCx+ j + jCx?j).) In principle, the number of constraints
needed to describe 9x C using inequalities over variables var(C) ? fxg is far larger
than the number of inequalities in C. In practice, however, the Fourier step gener-
ates many redundant constraints30 . See [159] for a discussion on such redundancy.
Work by C ernikov [48] proposed tests on the generated constraints to detect and
eliminate some redundant constraints. The output module of the CLP(R) system
[132] furthered these ideas, as did Imbert [125]. (Imbert [124] also considered the
more general problem in which there are disequations.) All these redundancy elim-
ination methods are correct in the following sense: if fCigi=1;2;::: is the sequence of
constraints generated during the elimination of variables x1; ; xi from C, then
Ci $ 9x1 : : :xi C , for every i.
The survey [52] contains further perspectives on the Fourier variable elimination
technique. It also contains a discussion on how the essential technique of Fourier can
be adapted to perform projection in other domains such as linear integer constraints
and the Boolean domain.
We nish here by mentioning the non-Fourier algorithms of [123, 158]. In some
circumstances, especially when the matrix representing the constraints is dense, the
algorithm of [123] can be far more ecient. It is, however, believed that typical CLP
programs produce sparse matrices. The algorithm of [158] has the advantageous
property that it can produce an approximation of the projection if the size of the
29 Obtained, for example, by multiplying c by 1=m and c by (?1=m ), where m and m are
0 0 0
the coecients of x in c and c respectively, and then adding the resulting equations together.
0
projecting <Lin constraints onto a single variable x can show if x is bounded, and
if so, this bound can be used in the program. Projection also provides the logical
basis for eliminating variables from the accumulated set of constraints, once it is
known that they will not be referred to again.
There are few general principles that guide the design of projection algorithms
across the various constraint domains. The primary reason is, of course, that these
algorithms have to be intimately related to the domain at hand. We therefore will
simply resort to brie
y mentioning existing approaches for some of our sample
domains.
The projection problem is particularly simple for the domain FT : the result of
projection is x~ = x~ where is the substitution obtained from the solved form
of C. Now, we have described above that this solved form is simply the mgu of
C, that is, equations whose r.h.s. does not contain any variable on the l.h.s. . For
example, x = f(y); y = f(z) would have the solved form x = f(f(z)); y = f(z).
However, the equations x = f(y); y = f(z) are more eciently stored internally
as they are (and this is done in actual implementations). The solved form for x
therefore is obtained only when needed (during unication for example) by fully
dereferencing y in the term f(y). A direct representation of the projection of C on
a variable x, as required in a printout for example, can be exponential in the size
of C. This happens, for example, if C is of the form x = f(x1 ; x1), x1 = f(x2 ; x2),
, xn = f(a; a) because x would contain 2n+1 occurrences of the constant a. A
solution would be to present the several equations equivalent to x = x, such as
the n + 1 equations in this example. This however is a less explicit representation
of the projection; for example, it would not always be obvious if a variable were
ground.
Projection in the domain RT can be done by simply presenting those equations
whose l.h.s. is a target variable and, recursively, all equations whose l.h.s. appears
in anything already presented. Such a straightforward presentation is in general
not the most compact. For example, the equation x = f(f(x; x); f(x; x)) is best
presented as x = f(x; x). In general, the problem of nding the most compact
representation is roughly equivalent to the problem of minimizing states in a nite
state automaton [60].
For <LinEqn the problem is only slightly more complicated. Recall that equa-
tions are maintained in parametric form, with eliminable and parametric variables.
A relatively simple algorithm can be obtained by using a form of Gaussian elimi-
nation, and is informally described in Figure 1. It assumes there is some ordering
on variables, and ensures that lower priority variables are represented in terms of
higher priority variables. This ordering is arbitrary, except for the fact that the
target variables should be of higher priority than other variables. We remark that
a crucial point for eciency is that the main loop in Figure 1 iterates n times, and
this number (the number of target variables) is often far smaller than the total
number of variables in the system. More details on this algorithm can be found in
[132].
For <Lin, there is a relatively simple projection algorithm.Assume all inequalities
are written in a standard form ::: 0. Let Cx+ (Cx? ) denote the subset of constraints
C in which x has only positive (negative) coecients. Let Cx0 denote those inequal-
ities in C not containing x at all. We can now describe an algorithm, due to Fourier
[91], which eliminates a variable x from a given C. If constraints c and c0 have a
positive and a negative coecient of x, we can dene elimx (c; c0) to be a linear
41
to variables in the new constraint. One added feature of this solved form is that it
directly accommodates strict inequalities and disequations.
Next still consider the domain <Lin , but now allow inequalities to be in G. Here
it is not clear how to represent a guard inequality, say x 5, in such a way that its
entailment or refutation is detectable by some simple format in its representation.
Using the Simplex tableau format as a solved form as discussed above, and using
the same intuition as in the discussion of guard equations, we could substitute
out x in x 5 in case x is basic. However, it is not clear to which format(s) we
should limit the resulting expression in order to avoid explicitly checking whether
x 5 is entailed28. Thus an incremental algorithm for checking the entailment of
inequalities is yet to be found.
For BOOL there seems to be a similar problem in detecting the entailment
of Boolean constraints. However, in the case of groundness entailment some of the
algorithms we have previously discussed are potentially incremental. The Prolog III
algorithm, in fact, is designed with the detection of groundness as a criterion. The
algorithm represents explicitly all variables that are grounded by the constraints.
The Groebner basis algorithm will also contain in its basis an explicit representation
of grounded variables. Finally, for the unication algorithms, the issue is clearly
the form of the unier. If the unier is in fully simplied form then every ground
variable will be associated to a ground value.
In summary for this subsection, the problem of detecting entailment is not limited
just to the cost of determining if a particular constraint is entailed. Incrementality
is crucial, and this property can be dened roughly as limiting the cost to depend on
the number of guard constraints aected by each change to the store. In particular,
dealing (even brie
y) with the entire collection of guard constraints each time the
store changes is unacceptable.
Below, in Section 11.1, an issue related to entailment is taken up. Here we have
focussed on how to adapt the underlying satisability algorithm to be incremental
for determining entailment. There we will consider the generic problem, independent
of the constraint domain, of managing delayed goals which awake when certain
constraints become entailed.
10.5. Projection
The problem at hand is to obtain a useful representation of the projection of con-
straints C w.r.t. a given set of variables. More formally, the problem is: given
target variables x~ and constraints C(~x; y~) involving variables from x~ and y~, express
9y~ C(~x; y~) in the most usable form. While we cannot dene usability formally, it
typically means both conciseness and readability. An important area of use is the
output phase of a CLP system: the desired output from running a goal is the pro-
jection of the answer constraints with respect to the goal variables. Here it is often
useful to have only the target variables output (though, depending on the domain,
this is not always possible). For example, the output of x = z + 1; y = z + 2 w.r.t.
to x and y should be x = y ? 1 or some rearrangement of this, but it should not
involve any other variable. Another area of use is in meta-programming where a de-
scription of the current store may be wanted for further manipulation. For example,
28 And this can, of course, be done, perhaps even eciently, but the crucial point is, once again,
that we cannot aord to do this every time the store changes.
40
The algorithm of [201] has some similarities to the previous algorithm, but avoids
the necessity of undoing operations. Instead, operations that might aect C are
delayed and/or performed on a special data-structure separate from C. Strong
incrementality is claimed: if we replace average-case complexity by worst-case com-
plexity, the algorithm satises our criterion for perfect incrementality.
[205] goes beyond the problem of entailing equations to give an algorithm for
entailment when both equations and disequations (6=) are considered constraints.
This algorithm has a rather dierent basis than those discussed above; it involves
memoization of pairs of terms (entailments and disequations) and the use of a
reduction of disequation entailment to several equation entailments.
For <LinEqn, let G contain arbitrary equations e. Add to the algorithm which
constructs the solved form a representation of each such equation e in which all
eliminable variables are substituted out. Note, however, that even though these
equations are stored with the other equations in the constraint store, they are
considered as a distinct collection, and they play no direct role in the question of
satisability of the current store. For example, a constraint store containing x =
z+3; y = z+2 would cause the guard equation y+z = 4 to be represented as z = 1.
It is easy to show that a guard equation e is entailed i its representation reduces
to the trivial form 0 = 0, and similarly, the equation is refuted if its representation
is of the form 0 = n where n is a nonzero number. (In our example, the guard
equation is entailed or refuted just in case z becomes ground.) In order to have
incrementality we must argue that the substitution operation is often applied only
to very few of the guard constraints. This is tantamount to the second assumption
made to argue the incrementality of Algorithm 1. Hence we believe our algorithm
is incremental.
We move now to the domain <Lin, but allow only equations in the guard con-
straints G. Here we can proceed as in the above discussion for <LinEqn to obtain
an incremental algorithm, but we will have the further requirement that the con-
straint store contains all implicit equalities27 explicitly represented as equations. It
is then still easy to show that the entailment of a guard equation e need be checked
only when the representation of e is trivial. The argument for incrementality given
above for <LinEqn essentially holds here, provided that the cost of computing im-
plicit equalities is suciently low.
There are two main works on the detection of implicit equalities in CLP systems
over <Lin. In [243], the existence of implicit equalities is detected by the appearance
of an equation of a special kind in the Simplex tableau at the end of the satisability
checking process. Such an equation indicates some of the implicit equalities, but
more pivoting (which, in turn, can give rise to more special equations) is generally
required to nd all of them. An important characteristic of this algorithm is that
the extra cost incurred is proportional to the number of implicit equalities. This
method is used in CLP(R) and Prolog III. CHIP uses a method based on [114]. In
this method, a solved form which is more restrictive than the usual Simplex solved
form is used. An equation in this form does not contribute to any implicit equality,
and a whole tableau in this solved form implies that there are no implicit equalities.
The basic idea is then to maintain the constraints in the solved form and when a
new constraint is encountered, the search for implicit equalities can be rst limited
27 These are equalities which are entailed by the store because of the presence of inequalities.
For example, the constraint store x + y 3; x + y 3 entails the implicit equality x + y = 3.
39
and there are no clashes of sort. Such solved forms are, in fact, solution forms. The
implied equations are found by congruence closure, treating the features as (partial)
functions, analogously to rule (d) in the algorithm for RT .
In summary for this subsection, an important property for algorithms to decide
satisability is that they have good average case behavior. More important, and
even crucially so, is that the algorithm is incremental. Toward this goal, a common
technique is to use a solved form representation for satisable constraints.
10.4. Entailment
Given satisable C, guard constraints G such that no constraint therein is entailed
by C, and a new constraint c, the problem at hand is to determine the subset G1 of
G of constraints entailed by C ^ c. We will also consider the problem of detecting
groundness which is not, strictly speaking, an entailment problem. However, it is
essentially the same as the problem of detecting groundness to a specic value,
which is an entailment problem. In what follows the distinction is unimportant.
We next present a rule-of-thumb to determine whether an entailment algorithm
is incremental in the sense discussed earlier. The important factor is not the num-
ber of constraints entailed after a change in the store, but instead, the number of
constraints not entailed. That is, the algorithm must be able to ignore the latter
constraints so that the costs incurred depend only on the number of entailed con-
straints, as opposed to the total number of guard constraints. As in the case of
incremental satisability, the property of incremental entailment is a crucial one
for the implementation of practical CLP systems.
We now brie
y discuss modications to some of the previously discussed algo-
rithms for satisability, which provide for incremental entailment.
Consider the domain FT and suppose G contains only guard constraints of the
form x = t where t is some ground term26. Add to a standard implementation of
a unication algorithm an index structure mapping variables x to just those guard
constraints in G which involve x. (See [46] for a detailed description.) Now add to
the process of constructing a solved form a check for groundness when variables are
bound (and this is easily detectable). This gives rise to an incremental algorithm
because the only guard constraints that are inspected are those x = t for which x
has just become ground, and not the entire collection G.
Just as with satisability, testing entailment is essentially the same over the
domains RT and FEAT . Four recent works have addressed this problem, all in the
context of a CLP system, but with slightly diering constraint domains. We will
discuss them all in terms of RT . With some modications, these works can also
apply to FT .
In [235, 12] a theoretical foundation is built. [235] then proposes a concrete
algorithm, very roughly as follows: the to-be-entailed constraint c is added to the
constraint store C. The satisability tester has the capability of detecting whether
c is entailed by or inconsistent with C. If neither is detected then c0 , essentially a
simplied form of c, is stored and the eect of adding c to C is undone. Every time
a constraint is added to C that aects c0 this entailment test is repeated (with c0
instead of c).
26 As mentioned above, this discussion will essentially apply to guard constraints of the form
ground(x).
38
In the Boolean domain, Boolean unication algorithms [185] conform to the
structure of Algorithm 1. One unication algorithm is essentially due to Boole, and
we borrow the following presentation from [109]. Without loss of generality, assume
the constraints are of the form t(x1; ; xn) = 0 where the xi are the variables in
t. Assuming n 2, rewrite t = 0 into the form
g(x1; ; xn?1) ^ xn h(x1; ; xn?1) = 0
so that the problem for t = 0 can be reduced to that of
:g(x1 ; ; xn?1) ^ h(x1 ; ; xn?1) = 0
which contains one less variable. If this equation is satisable, then the \assignment"
xn = h(x1 ; ; xn?1) :g(x1; ; xn?1) ^ yn
where yn is a new variable, describes all the possible solutions for xn . This reduction
clearly can be repeatedly applied until we are left with the straightforward problem
of deciding the satisability of equations of the form t ^ x u = 0 where t and u
are ground. The unier desired is given simply by collecting (and substituting out
all assigned variables in) the assignments, such as that for xn above.
The key eciency problem here is, of course, that the variable elimination pro-
cess gives rise to larger expressions, an increase which is exponential in the number
of eliminated variables, in the worst case. So even though this algorithm satises
the structure of Algorithm 1, it does not satisfy our assumption about the size of
expressions obtained after substitution, and hence our general argument for incre-
mentality does not apply here. Despite this, and the fact that Boole's work dates
far back, this method is still used, for example, in CHIP [45].
Another unication algorithm is due to Lowenhein, and we adapt the presenta-
tion of [185] here. Let f(x1 ; ; xn) = 0 be the equation considered. Let a~ denote
a solution. The unier is then simply given by
xi = yi _ f(~y ) ^ (yi _ ai ); 1 i n
where the yi are new variables. The basic eciency problem is of course to determine
a~. The obtained uniers are only slightly larger than f, in contrast to Boole's
method. Thus Lowenhein's method provides a way of extending a constructive
satisability test into a satisability test which has an incremental form. However,
this method is not, to our knowledge, used in CLP languages.
Other algorithms for testing the satisability of Boolean constraints are con-
siderably dierent from Algorithm 1. The Groebner Basis algorithm produces a
basis for the space of Boolean constraints implied by the constraint store. It is a
solved form but not a solution form. The remaining algorithms mentioned in the
previous subsection do not have a solved form. The algorithm used in Prolog III
retains the set of literals implied to be true by the constraints, but the normal
form does not guarantee solvability: that must be tested beforehand. Enumeration
algorithms have the same behavior: they exhibit a solution, and may retain some
further information, but they do not compute a solved form.
In the domain of feature trees FEAT , equations occur only between variables.
Thus Algorithm 1 does not address the whole problem. Existing algorithms [12, 235]
employ a solved form in which all implied equations between variables are explicit
37
ables, and all numbers in the column vector B are nonnegative. For domains based
on a unitary equality theory [224], the standard representation is the mgu, as in
the case of FT (which corresponds to the most elementary equality theory). Word
equations over WE , however, are associated with an innitary theory, and thus a
unication algorithm for these equations [127] may not terminate. A solved form
for word equations, or any closed form solution for that matter, is not known.
The rst two kinds of solved form above are also examples of solution forms, that
is, a format in which the set of all solutions of the constraints is evident. Here, any
instance of the variables y~ determines values for x~ and thus gives one solution. The
set of all such instances gives the set of all solutions. The Simplex format, however,
is not in solution form: each choice of basis variables depicts just one particular
solution.
An important property of solution forms (and sometimes of just solved forms)
is that they dene a convenient representation of the projection of the solution
space with respect to any set of variables. More specically, each variable can be
equated with a substitution expression containing only parametric variables, that
is, variables whose projections are the entire space. This property, in turn, aids
incrementality as we now show via our sample domains.
In each of the following examples, let C be a (satisable) constraint in solved form
and let c be the new constraint at hand. For FT , the substitution expression for a
variable x is simply x if x is not eliminable; otherwise it is the expression equated
to x in the solved form C. This mapping is generalized to terms in the obvious way.
Similarly we can dene a mapping of linear expressions by replacing the eliminable
variables therein with their substitution expressions, and then collecting like terms.
For the domain <Lin, in which case C is in Simplex form, the substitution expression
for a variable x is simply x if x is not basic; otherwise it is the expression obtained
by writing the (unique) equation in C containing x with x as the subject. Once
again, this mapping can be generalized to any linear expression in an obvious way.
In summary, a solution form denes a mapping which can be used to map any
expression t into an equivalent form t which is free of eliminable variables.
The basic step of a satisability algorithm using a solution form is essentially
this.
Algorithm 10.1. Given C , (a) Replace the newly considered constraint c by c where
is the substitution dened by C . (b) Then write c into equations of the form
x = :::, and this involves choosing the x and rearranging terms. Unsatisability is
detected at this stage. (c) If the previous step succeeds, use the new equations to
substitute out all occurrences of x in C . (d) Finally, simply add the new equations
to C , to obtain a solution form for C ^ c.
Note that the nonappearance of eliminable variables in substitution expressions is
needed in (b) to ensure that the new equations themselves are in solved form, and
in (c) to ensure that C , augmented with the new equations, remains in solution
form.
The belief that this methodology leads to an incremental algorithm is based upon
believing that the cost of dealing with c is more closely related to the size of c
(which is small on average) than that of C (which is very large on average). This,
in turn, is based upon believing that
35
Davis and Putnam, is based upon variable elimination. The essential idea reduces a
normal form representation into two smaller problems, each with one less variable.
Binary decision diagrams [38] provide an ecient representation. One of the two
Boolean solvers of CHIP, for example, uses variable elimination and these diagrams.
A related technique is based on enumeration and propagation. The constraints are
expressed as a conjunction of simple constraints and then local propagation simpli-
es the conjunction after each enumeration step. See [56], for example. The method
used in Prolog III [21] is a modication of SL-resolution whose main element is the
elimination of redundant expressions. Another technique comes from Operations
Research. Here the Boolean formula is restated in arithmetic form, with variables
constrained to be 0 or 1. Then standard techniques for integer programming, for ex-
ample cutting-planes, can be used. See [53] for a further discussion of this technique.
This technique has not been used in CLP systems. A more recent development is
the adaptation of Buchberger's Groebner basis algorithm to Boolean algebras [210],
which is used in CAL. Finally, there is the class of algorithms which perform Boolean
unication; see the survey [185] for example. Here satisability testing is only part
of the problem addressed, and hence we will discuss these algorithms in the next
section.
The satisability problem for feature trees is essentially the same as the satis-
ability problem for rational trees, provided that the number of features that may
occur is bounded by a known constant [12]. (Generally this bounding constant can
be determined at compile-time.) Two dierent sort constraints on the same variable
clash in the same way that dierent function symbols on terms in RT clash. An
equation between two feature tree variables (of the same sort) induces equations
between all the subtrees determined by the features of the variables, in the same
way as occurs in RT . The main dierence is that some sorts or features may be
undetermined (roughly, unbound) in FEAT .
23 The choice of such a data structure should depend on the size of the nite domains. For
example, with small domains a characteristic vector is appropriate.
24 In this case, simply remove from dom(x) all elements bigger than max(y ), and remove from
dom(y) all elements smaller than min(x). We omit the details of similar operationsin the following
discussion.
25 If both are singletons, clearly the constraint reduces to either true or false.
33
where the additional term extra cost(o1 : : :ok ) denotes the extra cost incurred by
the on-line algorithm over the best batch algorithm. Therefore, one possible \de-
nition" of an incremental algorithm, good enough for use in a CLP system, is simply
that its extra cost factor is negligible.
In what follows, we shall tacitly bear in mind this expression to obtain a rough
denition of incrementality21. Although we have dened incrementality for a col-
lection of operations, we will review the operations individually, and discuss incre-
mentality in isolation. This can sometimes be an oversimplication; for example,
[180] has shown that the standard unication problem does not remain linear when
backtracking is considered. In general, however, it is simply too complex, in a
survey article, to do otherwise.
Part II
Implementation Issues
The main innovation required to implement a CLP system is clearly in the manipu-
lation of constraints. Thus the main focus in this part of the survey is on constraint
solver operations, described in the section below. The next section then considers
the problem of extending the LP inference engine to deal with constraints. Here
the discussion is not tied down to a particular constraint domain.
It is important to note that the algorithms and data structures in this part are
presented in view of their use in top-down systems and, in particular, systems with
backtracking. At the present, there is little experience in implementing bottom-up
CLP systems, and so we do not discuss them here. However, some of the algorithms
we discuss can be used, perhaps with modication, in bottom-up systems.
10.1. Incrementality
According to the folklore of CLP, algorithms for CLP implementations must be
incremental in order to be practical. However this prescription is not totally sat-
isfactory, since the term incremental can be used in two dierent senses. On one
hand, incrementality is used to refer to the nature of the algorithm. That is, an
algorithm is incremental if it accumulates an internal state and a new input is
processed in combination with the internal state. Such algorithms are sometimes
called on-line algorithms. On the other hand, incrementality is sometimes used to
refer to the performance of the algorithm. This section serves to clarify the latter
notion of incrementality as a prelude to our discussion of algorithms in the following
subsections. We do not, however, oer a formal denition of incrementality.
We begin by abstracting away the inference engine from the operational seman-
tics, to leave simply the constraint solver and its operations. We consider the state
of the constraint solver to consist of the constraint store C, a collection of con-
straints G that are to be entailed, and some backtrack points. In the initial state,
denoted by
6 , there are no constraints nor backtrack points. The constraint solver
reacts to a sequence of operations, and results in (a) a new state, and (b) a response.
Recall that the operations in CLP languages are:
augment C with c to obtain a new store, determine whether the new store
is satisable, and if so, determine which constraints in G are implied by the
new store;
30
and upper and lower bounds on the value of a variable using the indexical terms
dom(X), max(X) and min(X) respectively. Indexical constraints have an opera-
tional semantics: each constraint denes a method of propagation. For example,
the constraint Y in 0::max(X) continually enforces the upper bound of Y to be
less than or equal to the upper bound of X. This same behavior can be obtained
in a nite domain solver with the constraint Y X, but the advantage of indexical
constraints is that there is greater control over propagation: with Y X we also
propagate changes in the lower bound of Y to X, whereas we can avoid this with
indexical constraints. A discussion of an implementation of indexical constraints
is given in [75]. (One application of this work is a constraint solver for Boolean
constraints [56]; we describe this application in Section 13.5.)
9.4. Negation
Treatments of negation in logic programming lift readily to constraint logic pro-
gramming, with only minor adjustments necessary. Indeed many of the semantics
for programs with negation are essentially propositional, being based upon the col-
lection of ground instances of program rules. The perfect model [203, 14, 100],
well-founded model [101], stable model [102] and Fitting xedpoint semantics [90],
to name but a few, fall into this category. The grounding of variables in CLP
rules by all elements of the domain (i.e. by all terms in L ) and the deletion of
all grounded rules whose constraints evaluate to false produces the desired propo-
sitional rules (see, for example, [176]).
Other declarative semantics, based on Clark's completion P of the program,
also extend to CLP19. The counterpart of comp(P) [55, 168] is T ; P , where T is
satisfaction complete. Interestingly, it is necessary to consider the complete theory
T of the domain if the equivalence of three-valued logical consequences of T ; P
and consequences of nite iterations of Fitting's operator (as shown by Kunen
[153]), continues to hold for CLP programs [244].
SLDNF-resolution and its variants are also relatively untouched by the lifting
to CLP programs, although, of course, they must use a consistency test instead of
unication. The other main modication is that groundness must be replaced by
the concept of a variable being determined by the current constraints (see Section
2). For example, a safe computation rule [168] may select a non-ground negated
atom provided all the variables in the atom are determined by the current collec-
tion of constraints. Similarly, the denition of an allowed rule [168] for a CLP
program requires that every variable either appear in a positive literal in the body
or be determined by the constraints in the body. With these modications, various
soundness and completeness results for SLDNF-resolution and comp(P) extend eas-
ily to ideal CLP systems. An alternative implementation of negation, constructive
negation [51], has been expanded and applied to CLP programs by Stuckey [244],
who gave the rst completeness result for this method.
the use of the convex hull of the regions dened by the two constraints as the
approximation. Note that the constructive disjunction behavior could be obtained
from the clauses for p using the methods of [202].
In the second category, we mention two constructs used with the nite domain
solver of CHIP. element(X; L; T) expresses that T is the X'th element in the list
L. Operationally, it allows constraints on either the index X or element T of the
list to be re
ected by constraints on the other. For example, if X is constrained
so that X 2 f1; 3; 5g then element(X; [1; 1; 2; 3; 5; 8];T) can constrain T so that
T 2 f1; 2; 5g and, similarly, if T is constrained so that T 2 f1; 3; 5g then X is
constrained so that X 2 f1; 2; 4; 5g. Declaratively, the cumulative constraint of
[2] expresses a collection of linear inequalities on its arguments. Several problems
that can be expressed as integer programming problems can be expressed with
cumulative. Operationally, it behaves somewhat dierently from the way CHIP
would usually treat the inequalities.
Guarded atoms and, more generally, guarded goals take the form c ! G where c
is a constraint17 and G is a goal. G is available for execution only when c is implied
by the current active constraints. We call c the guard constraint and G the delayed
goal. Although the underlying mechanisms are very similar, guarded atoms and
guarded rules dier substantially as linguistic features, since guarded atoms can be
combined conjunctively whereas guards in guarded rules are combined disjunctively.
9. Linguistic Extensions
We discuss in this section some additional linguistic features for top-down CLP
languages.
system are:
hA [ a; C i !r hA [ B; C [ (a = h) [ ask [ telli
if h ask : tell j B is a rule of P renamed to new variables x~, h and a have the
same predicate symbol, D j= C ! 9x~ a = h ^ ask and D j= 9~ C ^ a = h ^ ask ^ tell.
Roughly speaking, a transition can occur with such a rule provided the accumulated
constraints imply the ask constraint and do not contradict the tell constraint. Some
languages use only the ask constraint for synchronization. It is shown in [29] that
such languages are strictly less expressive than ask-tell languages.
An operational semantics such as the above is not completely faithful to a real
execution of the language, since it is possible for two atoms to be rewritten si-
multaneously in an execution environment with concurrency. The above semantics
only allows rewritings to be interleaved. A \true concurrency" semantics, based on
graph-rewriting, is given in [191].
All ask-tell CCLP programs have the following monotonicity [216] or stability [96]
property: If hA; C i !r hA0 ; C 0i and D j= C 00 ! C 0 then hA; C 00i !r hA0 ; C 00i. This
property provides for simple solutions to some problems in distributed computing
related to reliability. When looked at in a more general framework [96], stability
seems to be one advantage of CCLP languages over other languages; most programs
in conventional languages for concurrency are not stable. It is interesting to note
that a notion of global failure (as represented in Section 5 by the state fail) destroys
stability. Of course, there are also pragmatic reasons for wanting to avoid this
notion in a concurrent language. A framework which permits non-monotonic CCLP
languages is discussed in [27].
A program is determinate if every reachable state is determinate, where a state
is determinate if every selected atom gives rise to at most one !r transition. Con-
sequently, for every initial state, every fair derivation rewrites the same atoms
with the same rules, or every derivation fails. Thus non-failed derivations by de-
terminate programs from an initial state dier from each other only in the order
of rewriting (and the renaming of rules). Substantial parts of many programs are
determinate16 . The interest in determinate programs arises from an elegant seman-
tics for such programs based upon closure operators [217]. For every collection
of atoms A, the semantics of A is given by the function PA (C) = 9?x~ C 0 where
hA; C i !r hA0 ; C 0i, x~ is the free variables of hA; C i, and hA0 ; C 0i is a nal state.
This semantics is extended in [217] to a compositional and fully abstract semantics
of arbitrary programs. A semantics based on traces is given in [28].
For determinate programs we also have a clean application of the classical logical
semantics of a program [173]. If hA; C i !r hA0 ; C 0i then P ; D j= A ^ C $
9?x~ A0 ^ C 0 where x~ is the free variables of hA; C i. In cases where execution can be
guaranteed not to suspend any atom indenitely, the soundness and completeness
results for success and failure hold (see Section 6).
of the resulting program terminates [151, 211, 35], although most work has ignored
the capability of using constraints in the answers.
Comparatively little work has been done on the nuts and bolts of implementing
bottom-up execution for CLP programs, with all the work addressing the constraint
domain <Lin. [144] suggested the use of intervals, computed as the projection of a
collection of constraints, as the basis for indexing on constrained variables. Several
dierent data structures, originally developed for spatial databases or computa-
tional geometry, have been proposed as appropriate for indexing [144, 236, 36]. A
new data structure was presented in [145] which minimizes accesses to secondary
storage. A sort-join algorithm for joins on constrained variables is given in [36].
That paper also provides a query optimization methodology for conjunctive queries
that can balance the cost of constraint manipulation against the cost of traditional
database operations.
Most of these results are from [128, 129], but there are also some from [95, 173, 177].
Results 8 and 9 of the above theorem (which are equivalent) are the only results,
of those listed above, which require solution compactness. In fact, the properties
shown are equivalent to SC2 , the second condition of solution compactness [177];
as mentioned earlier, SC1 is not needed. In soundness results (2, 3 and half of 6),
T can be replaced by D. If we omit our assumption of a rst-order language of
constraints (see Section 2) then only results 1, 2, 3, 7, 8, 9 and the soundness half
of 6 (replacing T by D where necessary) continue to hold.
The strong form of completeness of successful derivations (result 4) [173] provides
an interesting departure from the conventional logic programming theory. It shows
that in CLP it is necessary, in general, to consider and combine several successful
derivations and their answers to establish that c ! G holds, whereas only one
successful derivation is necessary in standard logic programming. The other results
in this theorem are more direct liftings of results in the logic programming theory.
The CLP Scheme provides a framework in which the lifting of results from LP
to CLP is almost trivial. By replacing the Herbrand universe by an arbitrary con-
straint domain D, uniability by constraint satisfaction, Clark's equality theory
by a corresponding satisfaction-complete theory, etc., most results (and even their
proofs) lift from LP to CLP. The lifting is discussed in greater detail in [177]. Fur-
thermore, most operational aspects of LP (and Prolog) can be interpreted as logical
operations, and consequently these operations (although not their implementations)
also lift to CLP. One early example is matching, which is used in various LP sys-
tems (e.g. GHC, NU-Prolog) as a basis for aecting the computation rule; the
corresponding operation in CLP is constraint entailment [173].
The philosophy of the CLP Scheme [129] gives primacy to the structure D over
which computation is performed, and less prominence to the theory T . We have
followed this approach. However, it is also possible to start with a satisfaction
complete theory T (see, for example [173]) without reference to a structure. We
can arbitrarily choose a model of T as the structure D and the same results ap-
ply. Another variation [118] considers a collection D of structures and denes
consistent(C) to hold i for some structure D 2 D we have D j= 9~ C. Weaker
forms of the soundness and completeness of successful derivations apply in this case.
7. Bottom-Up Execution
Bottom-up execution has its main use in database applications. The set-at-a-time
processing limits the number of accesses to secondary storage in comparison to
tuple-at-a-time processing (as in top-down execution), and the simple semantics
gives great scope for query optimization.
Bottom-up execution is also formalized as a transition system. For every rule r
of the form h c; b1; : : :; bn in P and every set A of facts there is a transition
^n
A ; A[fh c0 j ai ci ; i = 1; : : :; n are elements of A; D j= c0 $ c^ ci ^bi = ai g
i=1
In brief, then, we have A ; A [ SrD (A), for every set A and every rule r in P
(SPD was dened in Section 4). An execution is a sequence of transitions. It is
fair if each rule is applied innitely often. The limit of ground instances of sets
21
collection of atoms and constraints in the rst part of a state during execution. All
major implemented CLP systems are quick-checking and progressive, but most are
not ideal.
A derivation is a sequence of transitions hA1; C1; S1 i ! ! hAi ; Ci; Si i ! .
A state which cannot be rewritten further is called a nal state. A derivation is
successful if it is nite and the nal state has the form h;; C; S i. Let G be a
goal with free variables x~, which initiates a derivation and produces a nal state
h;; C; S i. Then 9?x~ C ^ S is called the answer constraint of the derivation.
A derivation is failed if it is nite and the nal state is fail. A derivation is fair
if it is failed or, for every i and every a 2 Ai , a is rewritten in a later transition. A
computation rule is fair if it gives rise only to fair derivations. A goal G is nitely
failed if, for any one fair computation rule, every derivation from G in an ideal CLP
system is failed. It can be shown that if a goal is nitely failed then every fair
derivation in an ideal CLP system is failed. A derivation
ounders if it is nite and
the nal state has the form hA; C; S i where A 6= ;.
The computation tree of a goal G for a program P in a CLP system is a tree
with nodes labelled by states and edges labelled by !r , !c, !i or !s such that:
the root is labelled by hG; ;; ;i; for every node, all outgoing edges have the same
label; if a node labelled by a state S has an outgoing edge labelled by !c, !i or
!s then the node has exactly one child, and the state labelling that child can be
obtained from S via a transition !c, !i or !s respectively; if a node labelled by
a state S has an outgoing edge labelled by !r then the node has a child for each
rule in P, and the state labelling each child is the state obtained from S by the
!r transition for that rule; for each !r and !c edge, the corresponding transition
uses the atom or constraint selected by the computation rule.
Every branch of a computation tree is a derivation, and, given a computation
rule, every derivation following that rule is a branch of the corresponding computa-
tion tree. Dierent computation rules can give rise to computation trees of radically
dierent sizes. Existing CLP languages use computation rules based on the Prolog
left-to-right computation rule (which is not fair). We will discuss linguistic features
intended to improve on this rule in Section 9.1.
The problem of nding answers to a query can be seen as the problem of search-
ing a computation tree. Most CLP languages employ a depth-rst search with
chronological backtracking, as in Prolog (although there have been suggestions to
use dependency-directed backtracking [71]). Since depth-rst search is incomplete
on innite trees, not all answers are computed. The depth-rst search can be incor-
porated in the semantics in the same way as is done for Prolog (see, for example,
[18, 17]), but we will not go into details here. In Section 8 we will discuss a class of
CLP languages which use a top-down execution similar to the one outlined above,
but do not use backtracking.
Consider the transition
hA; C; S i !g hA; C 0; ;i
where C 0 is a set of equations in L such that D j= C 0 ! (C ^ S) and, for every
variable x occurring in C or S, C 0 contains an equation x = d for some constant d.
Thus !g grounds all variables in the constraint solver. We also have the transitions
hA; C; S i !g fail
19
In a language like CHIP, infer performs less obvious inferences. For example, if
S is x = y +1 and C is 2 x 5 ^ 0 y 3 then infer(C; S) = (C 0 ; S 0 ) where C 0
is 2 x 4 ^ 1 y 3 and S 0 = S. (Note that we could also formulate the nite
domain constraint solving of CHIP as having no passive constraints, but having an
incomplete test for consistency. However the formulation we give seems to re
ect
the systems more closely.) Similarly, in languages employing interval arithmetic
over the real numbers (such as BNR-Prolog) intervals are active constraints and
other constraints are passive. In this case, infer repeatedly computes smaller in-
tervals for each of the variables, based on the constraints in S, terminating when
no smaller interval can be derived (modulo the precision of the arithmetic). Exe-
cution of language constructs such as the cardinality operator [112], \constructive
disjunction" [116] and special-purpose constructs (for example, in [77, 2]) can also
be understood as !i transitions, where these constructs are viewed as part of the
language of constraints.
Generally, the active constraints are determined syntactically. As examples, in
Prolog all equations are active, in CLP(R) all linear constraints are active, on the
nite domains of CHIP all unary constraints (i.e. constraints on just one variable,
such as x < 9 or x 6= 0) are active, and in the interval arithmetic of BNR-Prolog
only intervals are active.
The stronger the collection of active constraints, the earlier failure will be de-
tected, and the less searching is necessary. With this in mind, we might wish infer
to be as strong as possible: for every active constraint c, if infer(C; S) = (C 0 ; S 0 )
and D j= (C ^ S) ! c, then D j= C 0 ! c. However, this is not always possible14.
Even if it were possible, it is generally not preferred, since the computational cost
of a powerful infer function can be greater than the savings achieved by limiting
search.
A CLP system is determined by the constraint domain and a detailed operational
semantics. The latter involves a computation rule and denitions for consistent
and infer. We now dene some signicant properties of CLP systems. We distin-
guish the class of systems in which passive constraints play no role and the global
consistency test is complete. These systems correspond to the systems treated in
[128, 129].
Denition 5.1. Let !ris=!r !i!s and !cis=!c !i!s. We say that a CLP
system is quick-checking if its operational semantics can be described by !ris and
!cis. A CLP system is progressive if, for every state with a nonempty collection
of atoms, every derivation from that state either fails, contains a !r transition
or contains a !c transition. A CLP system is ideal if it is quick-checking,
progressive, infer is dened by infer(C; S) = (C [ S; ;), and consistent(C)
holds i D j= 9~ C.
In a quick-checking system, inference of new active constraints is performed and a
test for consistency is made each time the collection of constraints in the constraint
solver is changed. Thus, within the limits of consistent and infer, it nds incon-
sistency as soon as possible. A progressive system will never innitely ignore the
14 For example, in CLP(R), where linear constraints are active and non-linear constraints are
passive, if S is y = x x then we can take c to be y 2k x ? k2 , for any k. There is no nite
collection C of active constraints which implies all these constraints and is not stronger than S .
0
18
Proposition 4.1. Let P; P1; P2 be CLP programs and Q a set of facts over a con-
straint domain D with corresponding theory T . Then:
5. Top-down Execution
The phrase \top-down execution" covers a multitude of operational models. We
will present a fairly general framework for operational semantics in which we can
describe the operational semantics of some major CLP systems.
We will present the operational semantics as a transition system on states: tuples
hA; C; S i where A is a multiset of atoms and constraints, and C and S are multisets
of constraints. The constraints C and S are referred to as the constraint store and,
in implementations, are acted upon by a constraint solver. Intuitively, A is a
collection of as-yet-unseen atoms and constraints, C is the collection of constraints
which are playing an active role (or are awake), and S is a collection of constraints
playing a passive role (or are asleep). There is one other state, denoted by fail. To
express more details of an operational semantics, it can be necessary to represent
the collections of atoms and constraints more precisely. For example, to express
the left-to-right Prolog execution order we might use a sequence of atoms rather
than a multiset. However we will not be concerned with such details here.
We will assume as given a computation rule which selects a transition type and
an appropriate element of A (if necessary) for each state13 . The transition system
is also parameterized by a predicate consistent and a function infer, which we will
discuss later. An initial goal G for execution is represented as a state by hG; ;; ;i.
12 This proof was performed in the more general class of logic programs with negation.
13 A computation rule is a convenient ction that abstracts some of the behavior of a CLP
system. To be realistic, a computation rule should also depend on factors other than the state
(for example, the history of the computation). We ignore these possibilities for simplicity.
16
Let T denote a satisfaction complete theory for (D; L). The usual logical seman-
tics are based on the D-models of P and the models of P ; T . The least D-model
of a formula Q under the subset ordering is denoted by lm(Q; D), and the great-
est is denoted by gm(Q; D). A solution to a query G is a valuation v such that
v(G) lm(P; D).
4. Fixedpoint Semantics
The xedpoint semantics we present are based on one-step consequence functions
TPD and SPD , and the closure operator [ P]] generated by TPD . The functions TPD and
[ P]] map over D-interpretations. The set of D-interpretations forms a complete
lattice under the subset ordering, and these functions are continuous on BD .
TPD (I) = fp(d)~ j p(~x) c; b1; : : :; bn is a rule of P; ai 2 I; i = 1; : : :; n;
v is a valuation on D such that
D j= v(c); v(~x) = d;~ and v(bi ) = ai; i = 1; : : :; ng
[ P]] is the closure operator generated by TPD . It represents a deductive closure based
on the rules of P. Let Id be the identity function, and dene (f+g)(x) = f(x)[g(x).
Then [ P]](I) is the least xedpoint of TPD +Id greater than I, and the least xedpoint
of TPD[I .
The function SPD is dened on sets of facts, which form a complete lattice under
the subset ordering. We denote the closure operator generated from SPD by hhP ii.
Both these functions are continuous.
SPD (I) = fp(~x) c j p(~x) c0 ; b1; : : :; bn is a rule of P;
ai ci 2 I; i = 1;V: :n:; n; the rule and facts renamed apart,
D j= c $ 9?x~ c0 ^ i=1 ci ^ ai = bi g
We denote the least xedpoint of a function f by lfp(f) and the greatest xedpoint
by gfp(f). These xedpoints exist for the functions of interest, since they are mono-
tonic functions on complete lattices. For a function f mapping D-interpretations
to D-interpretations, we dene the upward and downward iteration of f as follows.
f "0 = ;
f " ( + 1) = f(f S " )
f " = < f " if is a limit ordinal
f #0 = BD
f # ( + 1) = f(f T # )
f # = < f # if is a limit ordinal
We can take as semantics lfp(SPD ) or lfp(TPD ). The two functions involved are
related in the following way: [SPD (I)]D = TPD ([I]D ). Consequently [lfp(SPD )]D =
lfp(TPD ). lfp(SPD ) corresponds to the s-semantics [87] for languages with constraints
[95]. Fixedpoint semantics based on sets of clauses [34] also extend easily to CLP
languages.
Based largely on the facts that the D-models of P are the xedpoints of [ P]] and
the D-models of P are the xedpoints of TPD , we have the following connections
between the logical and xedpoint semantics, just as in standard logic programming.
15
3. Logical Semantics
There are two common logical semantics of CLP programs over a constraint domain
(D; L). The rst interprets a rule
p(~x) b1; : : :; bn
as the logic formula
8x~; y~ p(~x) _ :b1 _ _ :bn
where x~ [ y~ is the set of all free variables in the rule. The collection of all such
formulas corresponding to rules of P gives a theory also denoted by P.
The second logical semantics associates a logic formula to each predicate in .
If the set of all rules of P with p in the head is
p(~x) B1
p(~x) B2
:::
p(~x) Bn
then the formula associated with p is
8x~ p(~x) $ 9y~1 B1
_ 9y~2 B2
_ 9y~n Bn
where y~i is the set of variables in Bi except for variables in x~. If p does not occur
in the head of a rule of P then the formula is
8x~ :p(~x)
The collection of all such formulas is called the Clark completion of P, and is
denoted by P .
A valuation v is a mapping from variables to D, and the natural extension
which maps terms to D and formulas to closed L -formulas. If X is a set of
facts then [X]D = fv(a) j (a c) 2 X; D j= v(c)g. A D-interpretation of a
formula is an interpretation of the formula with the same domain as D and the
same interpretation for the symbols in as D. It can be represented as a subset
of BD where BD = fp(d)~ j p 2 ; d~ 2 Dk g. A D-model of a closed formula is a
D-interpretation which is a model of the formula.
14
Prolog and standard logic programming can be viewed as constraint logic pro-
gramming over the constraint domain of nite trees.
Example 2.2. Let contain a collection of constant and function symbols and
the binary predicate symbol =. Let D be the set of nite trees where: each
node of each tree is labelled by a constant or function symbol, the number of
children of each node is the arity of the label of the node, and the children are
ordered. Let D interpret the function symbols of as tree constructors, where
each f 2 of arity n maps n trees to a tree whose root is labelled by f and
whose subtrees are the arguments of the mapping. The primitive constraints
are equations between terms, and let L be the constraints generated by these
primitive constraints. Then FT = (D; L) is the Herbrand constraint domain, as
used in Prolog. Typical constraints are x = g(y) and 9z x = f(z; z) ^ y = g(z).
(It is unnecessary to write a quantier in Prolog programs because all variables
that appear only in constraints are implicitly existentially quantied.)
It was pointed out in [60] that complete (i.e. always terminating) unication which
omits the occurs check solves equations over the rational trees.
Example 2.3. We take and L as in the previous example. D is the set of rational
trees (see [69] for a denition) and the function symbols are interpreted as tree
constructors, as before. Then RT = (D; L) is the constraint domain of rational
trees.
If we take the set of innite trees instead of rational trees then we obtain a constraint
domain that is essentially the same as RT , in the same way that <Lin and QLin
are essentially the same: they have the same language of constraints and the two
structures are elementarily equivalent [174].
The next domain contains objects similar to the previous domains, but has a
dierent signature and constraint language [12]8 , which results in slightly dierent
expressive power. It can be viewed as the restriction of domains over which LO-
GIN [7] and LIFE [9] compute when all sorts are disjoint. The close relationship
between the constraints and -terms [5] is emphasized by a syntactic sugaring of
the constraints.
Example 2.4. Let = f=g [ S [ F where S is a set of unary predicate symbols
(sorts) and F is a set of binary predicate symbols (features). Let D be the set of
(nite or innite) trees where: each node of each tree is labelled by a sort, each
edge of each tree is labelled by a feature and no node has two outbound edges
with the same label. Such trees are called feature trees. Let D interpret each
sort s as the set of feature trees whose root is labelled by s, and interpret each
feature f as the set of pairs (t1 ; t2) of feature trees such that t2 is the subtree
of t1 that is reached by the edge labelled by f. (If t1 has no edge labelled by
f then there is no pair (t1 ; t2) in the set.) Thus features are essentially partial
functions. The domain of feature trees is FEAT = (D; L). A typical constraint
is wine(x) ^9y region(x; y) ^ rutherglen(y) ^9y color(x; y) ^ red(y), but there is
atom. This involves no loss of generality since a rule such as p(t1; t2) C; q(s1; s2 )
can be replaced by the equivalent rule p(x1 ; x2) x1 = t1 ; x2 = t2 ; y1 = s1 ; y2 =
s2 ; C; q(y1; y2). We also assume that all rules dening the same predicate have the
same head and that no two rules have any other variables in common (this is simply
a matter of renaming variables). However in examples we relax these restrictions.
Programs will be presented in teletype font, and will generally follow the Ed-
inburgh syntax. In particular, program variables begin with an upper-case letter,
[HeadjTail] denotes a list with head Head and tail Tail, and [] denotes an empty
list. In one variation from this standard we allow subscripts on program variables,
to improve readability.
Part I
2. Constraint Domains
For any signature , let D be a -structure (the domain of computation) and L be
a class of -formulas (the constraints). We call the pair (D; L) a constraint domain.
In a slight abuse of notation we will sometimes denote the constraint domain by D.
We will make several assumptions, none of which is strictly necessary, to simplify
the exposition. We assume
The terms and constraints in L come from a rst-order language4.
4 Without this assumption, some of the results we cite are not applicable, since there can be
no appropriate rst-order theory T . The remaining assumptions can be omitted, at the expense
7
Prolog-like trees are essentially part of this domain, instead of being built on top
of the domain. CIL [192] computes over a domain similar to feature trees.
BNR-Prolog [198] computes over three domains: the 2-valued Boolean algebra,
nite domains, and arithmetic over the real numbers. In contrast to other CLP
languages over arithmetic domains, it computes solutions numerically, instead of
symbolically. Trilogy [256, 257] computes over strings, integers, and real numbers.
Although its syntax is closer to that of C, 2LP [170] can be considered to be a
CLP language permitting only a subset of Horn clauses. It computes with linear
constraints over integers and real numbers.
CAL [4] computes over two domains: the real numbers, where constraints are
equations between polynomials, and a Boolean algebra with symbolic values, where
equality between Boolean formulas expresses equivalence in the algebra. Instead
of delaying non-linear constraints, CAL makes partial use of these constraints dur-
ing computation. In the experimental system RISC-CLP(Real) [120] non-linear
constraints are fully involved in the computation.
L [189] and Elf [200] are derived from -Prolog [190] and compute over the
values of closed typed lambda expressions. These languages are not based on Horn
clauses (they include a universal quantier) and were not originally described as
CLP languages. However, it is argued in [187] that their operational behavior is
best understood as the behavior of a CLP language. An earlier language, Le Fun
[8], also computed over this domain, and can be viewed as a CLP language with a
weak constraint solver.
1.4. Synopsis
The remainder of this paper is organized into three main parts. In part I, we
provide a formal framework for CLP. Particular attention will be paid to opera-
tional semantics and operational models. As we have seen in examples, it is the
operational interpretation of constraints, rather than the declarative interpretation,
which distinguishes CLP from LP. In part II, algorithm and data structure con-
siderations are discussed. A crucial property of any CLP implementation is that
its constraint handling algorithms are incremental. In this light, we review several
important solvers and their algorithms for the satisability, entailment, and delay-
ing of constraints. We will also discuss the requirements of an inference engine
for CLP. In part III, we consider CLP applications. In particular, we discuss two
rather dierent programming paradigms, one suited for the modelling of complex
problems, and one for the solution of combinatorial problems.
In this survey, we concentrate on the issues raised by the introduction of con-
straints to LP. Consequently, we will ignore, or pass over quickly, those issues
inherent in LP. We assume the reader is somewhat familiar with LP and basic
rst-order logic. Appropriate background can be obtained from [168] for LP and
[223] for logic. For introductory papers on constraint logic programming and CLP
languages we refer the reader to [63, 65, 156, 94]. For further reading on CLP, we
suggest other surveys [58, 109, 110], some collections of papers [20, 143, 111], and
some books [107, 214]. More generally, papers on CLP appear in various journals
and conference proceedings devoted to computational logic, constraint processing,
or symbolic computation.
5
one for the output. This would mean that each time a constraint is dealt with,
a representation of the entire set of constraints accumulated must be manipulated
and a new representation constructed. But this is tantamount to a meta-level
implementation of CLP in LP. Furthermore, this approach raises new challenges to
ecient implementation.
Since LP is an instance of CLP, in which constraints are equations over terms,
its solver also requires a representation of accumulated constraints. It happens,
however, that there is no need for an explicit representation, such as the extra
arguments discussed above. This is because the accumulated constraints can be
represented by a most general unier, and this, of course, is globally available via
a simple binding mechanism.
constraint languages, but are nevertheless related to CLP languages. The develop-
ment of symbolic algebra systems such as MACSYMA [186] concentrated on the
solving of dicult algebraic problems. The programming language aspects are less
developed. Languages for linear programming [152] provide little more than a prim-
itive documentation facility for the array of coecients which is input into a linear
programming module.
In parallel with the development of these constraint languages, much work was
done on the modelling of combinatorial problems as Constraint Satisfaction Prob-
lems (CSPs) and the development of techniques for solving such problems. The
work was generally independent of any host language. (A possible exception is
ALICE [164] which provided a wide variety of primitives to implement dierent
search techniques.) One important development was the denition and study of
several notions of consistency. This work had a signicant in
uence on the later
development of the CLP language CHIP. We refer the reader to [253] for an intro-
duction to the basic techniques and results concerning CSPs. Finally, we mention
the survey [41] which deals not just with constraint programming languages, but
with constraint-based programming techniques.
where natural numbers n are represented by s(s( (0) )) with n occurrences of
s. Clearly, the meaning of the predicate add(n; m; k) coincides with the relation
n+m = k. However, the query add(N, M, K), add(N, M, s(K)), which is clearly
unsatisable, runs forever in a conventional LP system. The important point here
is that a global test for the satisability of the two add constraints is not done by
the underlying LP machinery.
In this example, the problem is that the add predicate is not invoked with a
representation of the add constraints collected so far, and neither does it return such
a representation (after having dealt with one more constraint). More concretely,
the second subgoal of the query above is not given a representation of the fact that
N + M = K.
A partial solution to this problem is the use of a delay mechanism. Roughly, the
idea is that invocation of the predicate is delayed until its arguments are suciently
instantiated. For example, if invocation of add is systematically delayed until its
rst argument is instantiated, then add behaves as in CLP when the rst argument
is ground. Thus the query N = s(s( s(0) )), add(N, M, K), add(N, M,
s(K)) fails as desired. However, the original query add(N, M, K), add(N, M,
s(K)) will be delayed forever.
A total solution could, in principle, be obtained by simply adding two extra
arguments to the predicate. One would be used for the input representation, and
3
The constraints are static, and were solved by local propagation and relaxation
techniques. (See chapter 2 in [165] for an introduction to these and related tech-
niques.) Subsequent related work was THINGLAB [32] whose language took an
object-oriented
avor. While local propagation and relaxation were also used to
deal with the essentially static constraints, the system considered constraint solving
in two dierent phases. When a graphical object is manipulated, a plan is generated
for quickly re-solving the appropriate constraints for the changed part of the object.
This plan was then repeatedly executed while the manipulation continued. Works
following the THINGLAB tradition included the Filters Project [81] and Animus
[80]. Another graphical system, this one focusing on geometrical layout, was JUNO
[196]. The constraints were constructed, as in THINGLAB, by text or graphical
primitives, and the geometric object could be manipulated. A dierence from the
abovementioned works is that constraint solving was performed numerically using
a Newton-Raphson solver.
Another collection of early works arose from MIT, motivated by applications in
electrical circuit analysis and synthesis, and gave rise to languages for general prob-
lem solving. In the CONSTRAINTS language [240], variables and constraints are
static, and constraint solving was limited to using local propagation. An extension
of this work [241] provided a more sophisticated environment for constraint pro-
gramming, including explanation facilities. Some other related systems, EL/ARS
[238] and SYN [142], used the constraint solver MACSYMA [186] to avoid the re-
strictions of local propagation. It was noted at this period [241] that there was a
conceptual correspondence between the constraint techniques and logic program-
ming.
The REF-ARF system [89] was also designed for problem solving. One compo-
nent, REF, was essentially a procedural language, but with nondeterminism because
of constraints used in conditional statements. The constraints are static. They are,
in fact, linear integer constraints, and all variables are bounded above and below.
The constraint solver ARF used backtracking.
The Bertrand system [165] was designed as a meta-language for the building
of constraint solvers. It is itself a constraint language, based on term rewriting.
Constraints are dynamic here, and are used in control. All constructs of the lan-
guage are based on augmented rewrite rules, and the programmer adds rules for
the specic constraint solving algorithm to be implemented.
Post-CLP, there have been a number of works which are able to deal with dy-
namic constraints. The language 2LP [170] is described to be a CLP language with
a C-like syntax for representing and solving combinatorial problems. Obtaining par-
allel execution is one of the main objectives of this work. The commercial language
CHARME, also based on a procedural framework, arose from the work on CHIP
(by essentially omitting the logic programming part of CHIP). ILOG-SOLVER,
which is also commercial, is a library of constraint algorithms designed to work
with C++ programs. Using a procedural language as a basis, [92] introduced Con-
straint Imperative Programming which has explicit constraints in the usual way,
and also a new kind of constraints obtained by considering variable assignments
such as x = x + 1 as time-stamped. Such assignments are treatable as constraints
of the form xi = xi+1 +1. Finally, we mention Constraint Functional Programming
[70] whose goal is the amalgamation of the ideas of functional programming found
in the HOPE language with constraints.
There is work on languages and systems which are not generally regarded as
2
1. Introduction
Constraint Logic Programming (CLP) began as a natural merger of two declarative
paradigms: constraint solving and logic programming. This combination helps
make CLP programs both expressive and
exible, and in some cases, more ecient
than other kinds of programs. Though a relatively new eld, CLP has progressed in
several and quite dierent directions. In particular, the early fundamental concepts
have been adapted to better serve in dierent areas of applications. In this survey
of CLP, a primary goal is to give a systematic description of the major trends in
terms of common fundamental concepts.
Consider rst an example program in order to identify some crucial CLP con-
cepts. The program below denes the relation sumto(n; 1 + 2 + + n) for natural
numbers n.
sumto(0, 0).
sumto(N, S) :- N >= 1, N <= S, sumto(N - 1, S - N).