<<

J to app ear

Constraint Logic Programming A Survey

Joxan Jaffar and Michael J Maher

Constraint Logic Programming CLP is a merger of two declarativepara

digms constraint solving and logic programming Though a relatively new

eld CLP has progressed in several quite dierent directions In particu

lar the early fundamental concepts have b een adapted to b etter servein

dierent areas of applications In this survey of CLP a primary goal is to

give a systematic description of the ma jor trends in terms of common fun

damental concepts The three main parts cover the theory implementation

issues and programming for applications 

Intro duction

Constraint Logic Programming CLP b egan as a natural merger of two declarative

paradigms constraint solving and logic programming This combination helps

make CLP programs b oth 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 b een adapted to b etter serve in dierent areas of applications In this survey

of CLP a primary goal is to give a systematic description of the ma jor trends in

terms of common fundamental concepts

Consider rst an example program in order to identify some crucial CLP con

cepts The program b elow denes the relation sumton n for natural

numb ers n

sumto

sumtoN S N N S sumtoN S N

The query S sumtoN S gives rise to three answers N S

Address correspondenceto Joxan Jaar and Michael Maher IBM Thomas J Watson Research

Center PO Box Yorktown Heights NY USA Email fjoxanmjmgwatsonibmcom

FINAL DRAFT Comments esp ecially ab out errors are solicited

N S andN S and terminates The computation sequence

of states for the third answer for example is

S sumtoN S

S N N S S N N S

sumtoN S N

S N N S S N N S

N N S N S N N S

    

N S N sumto

  

S N N S S N N S

N N S N S N N S

    

N S N

  

The constraints in the nal state imply the answer N S Termination is

reasoned as follows Any innite computation must use only the second program

rule for state transitions This means that its rst three states mustbeasshown

ab ove and its fourth state must b e

S N N S S N N S

N N S N S N N S

    

N N S N S N N S

       

sumto

We note nowthatthiscontains an unsatisable set of constraints and in CLPno

further reductions are allowed

This example shows the following key features in CLP

Constraints are used to sp ecify the query as well as the answers

During execution new variables and constraints are created

The collection of constraints in every state is tested as a whole for satisa

bility b efore execution pro ceeds further

In summary constraints are used for inputoutput dynamically generated and

globally tested in order to control execution

Constraint Languages

Considerable work on constraint programming languages preceded logic program

ming and constraint logic programming Weno w briey survey some imp ortant

works with a view toward the following features Are constraints used for in

putoutput Can new variables andor constraints b e dynamically generated Are

constraints used for control What is the constraint solving and to what

extent is it complete What follows is adapted from the survey in

SKETCHPAD was p erhaps the earliest work that one could classify as a

constraint language It was in fact an interactive drawing system allowing the user

to build geometric ob jects from language primitives and certain constraints The

constraints are static and were solved by lo cal propagation and relaxation tech

niques See chapter in for an intro duction to these and related techniques

Subsequent related work was THINGLAB whose language to ok an ob ject

oriented avor While lo cal 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 ob ject is manipulated a plan was generated

for quickly resolving the appropriate constraints for changed part of the ob ject

This plan was then rep eatedly executed while the manipulation continued Works

following the THINGLAB tradition included the Filters Pro ject and Animus

Another graphical system this one fo cusing on geometrical layout was JUNO

The constraints were constructed as in THINGLAB by text or graphical

primitives and the geometric ob ject could b e manipulated A dierence from the

ab ovementioned works is that constraint solving was p erformed numerically using

a NewtonRaphson solver

Another collection of early works arose from MIT motivated by applications in

electrical circuit analysis and synthesis gave rise to languages for general problem

solving In the CONSTRAINTS language variables and constraints are static

and constraint solving was limited to using lo cal propagation An extension of this

work provided a more sophisticated environment for constraint programming

including explanation facilities Some other related systems ELARS and

SYN used the constraintsolver MACSYMA toavoid the restrictions of

that there was a conceptual lo cal propagation It was noted at this p erio d

corresp ondence b etween the constrainttechniques and logic programming

The REFARF system was also designed for problem solving One comp o

nent REF was essentially a pro cedural language but with nondeterminism b ecause

of constraints used in conditional statements The constraints are static They are

in fact linear integer constraints and all variables are b ounded ab ove and b elow

The constraint solver ARF used

The Bertrand system was designed as a metalanguage 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 sp ecic constraint solving algorithm to b e implemented

PostCLP there have b een a numberofworks which are able to deal with dy

namic constraints The language LP is describ ed to b e a CLP language with

a Clike syntax for representing and solving combinatorial problems Obtaining

parallel execution is one of the main ob jectives of this work The commercial lan

guage CHARME also based on a pro cedural framework arose from the work on

CHIP by essentially omitting the logic programming part of CHIP The subse

quentwork ILOG which is also commercial is a library of constraint

designed to work with C programs Using a pro cedural language as a basis

intro duced Constraint Imp erative Programming which has explicit constraints in

the usual way and also a new kind of constraints obtained by considering variable

assignments suchasx x as timestamp ed Such assignments are treatable

as constraints of the form x x Finallywe mention ConstraintFunc

i i

tional Programming 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

constraint languages but are nevertheless related to CLP languages The develop

ment of symb olic algebra systems suchasMACSYMA concentrated on the

solving of dicult algebraic problems The programming language asp ects are less

develop ed Languages for linear programming provide little more than a prim

itive do cumentation facility for the array of co ecients whichisinputinto a linear

programming mo dule

In parallel with the development of these constraint languages muchwork was

done on the mo delling of combinatorial problems as Prob

lems CSPs and the development of techniques for solving such problems The

work was generally indep endentofany host language A p ossible exception is

ALICE which provided a wide variety of primitives to implement dierent

search techniques One imp ortantdevelopmentwas the denition and study of

several notions of consistencyThiswork had a signicant inuence on the later

development of the CLP language CHIPWe refer the reader to foranintro

duction to the basic techniques and results concerning CSPs Finallywe mention

the survey which deals not just with constraint programming languages but

constraintbased programming techniques

Logic Programming

Next we consider conventional logic programming LP and argue by example that

hanges to LP systems the p ower of CLP cannot b e obtained by making simple c

The question at hand is whether predicates in a logic program can b e meaningfully

regarded as constraints That is is a predicate with the same declarative semantics

as a constraint a sucient implementation of the constraint as p er CLP Consider

for example the logic program

add N N

addsN M sK addN M K

where natural numb ers n are represented by ss with n o ccurrences of

s Clearly the meaning of the predicate addn m k coincides with the relation

n m k However the query addN M K addN M sKwhich is clearly

unsatisable runs forever in a conventional LP system The imp ortant p oint here

is that a global test for the satisabilityofthetwo 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 do es it return such

a representation after having dealt with one more constraint More concretely

the second subgoal of the query ab ove is not given a representation of the fact that

N M K

A partial solution to this problem is the use of a delaymechanism Roughlythe

idea is that in vo cation of the predicate is delayed until its arguments are suciently

instantiated For example if invo cation 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 ss s addN M K addN M

sK fails as desired However the original query addN M K addN M

sK will b e delayed forever

A total solution could in principle b e obtained by simply adding two extra

arguments to the predicate One would b e used for the input representation and

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 b e manipulated

and a new representation constructed But this is tantamount to a metalevel

implementation of CLP in LPFurthermore this approach raises new challenges to

ecient implementation

Since LP is an instance of CLPinwhich constraints are equations over terms

its solver also requires a representation of accumulated constraints It happ ens

however that there is no need for an explicit representation such as the extra

arguments discussed ab ove This is b ecause the accumulated constraints can b e

represented by an mgu and this of course is globally available via a simple binding

mechanism

CLP Languages

Viewing the sub ject rather broadly constraint logic programming can b e said to

involve the incorp oration of constraints and constraint solving metho ds in a logic

based language This characterization suggests the p ossibilityofmanyinteresting

languages based on dierent constraints and dierent logics However to this

p oint work on CLP has almost exclusively b een devoted to languages based on

Horn clauses Wenow briey describ e these languages concentrating on those

that have received substantial development eort

ts are equations can b e said to b e a CLP language where the constrain

over the algebra of terms also called the algebra of nite trees or the Herbrand



domain The equations are implicit in the use of unication Almost every lan

guage we discuss incorp orates Prologlike terms in addition to other terms and

constraints so we will not discuss this asp ect further Prolog I I employs equa

tions and disequations over rational trees an extension of the nite trees of

Prolog to cyclic structures It was the rst logic language explicitly describ ed as

using constraints

CLPR has linear arithmetic constraints and computes over the real num

b ers Nonlinear constraints are ignored delayed until they b ecome eectively

linear CHIP and Prolog I I I compute over several domains Both compute

over Bo olean domains Prolog I I I over the wellknown valued Bo olean algebra

and CHIP over a larger Bo olean algebra that contains symbolic values Both CHIP

and Prolog I I I p erform linear arithmetic over the rational numb ers Separately

domains cannot b e mixed CHIP also p erforms linear arithmetic over b ounded

subsets of the integers known as nite domains Prolog I I I also computes over

a domain of strings There are now several languages which compute over nite

domains in the manner of CHIP including clpFD Echidna and Flang

ccFD isessentially a secondgeneration CHIP system

LOGIN and LIFE compute over an ordersorted domain of feature trees

This domain provides a limited notion of ob ject in the ob jectoriented sense The

languages supp ort a term syn tax which is not rstorder although every term can b e

interpreted through rstorder constraints Unlike other CLP languagesdomains

We note however some work combining constraints and resolution in rstorder automated

theoremproving



The language Absys whichwas very similar to Prolog used equations explicitly making

it more obviously a CLP language

Prologlike trees are essentially part of this domain instead of b eing built on top

of the domain CIL computes over a domain similar to feature trees

BNRProlog computes over three domains the valued Bo olean algebra

nite domains and arithmetic over the real numb ers In contrast to other CLP

languages over arithmetic domains it computes solutions numerically instead of

symb olicallyTrilogy computes over strings integers and real numbers

Although its syntax is closer to that of C LP can b e considered to b e a

CLP language p ermitting only a subset of Horn clauses It computes with linear

constraints over integers and real numb ers

CAL computes over two domains the real numb ers where constraints are

equations b etween p olynomials and a Bo olean algebra with symbolic values where

equalitybetween Bo olean formulas expresses equivalence in the algebra Instead

of delaying nonlinear constraints CAL makes partial use of these constraints dur

ing computation In the exp erimental system RISCCLPReal nonlinear

constraints are fully involved in the computation

L andElf are derived from Prolog and compute over the

values of closed typ ed lamb da expressions These languages are not based on Horn

clauses they include a universal quantier and were not originally describ ed as

er it is argued in that their op erational b ehavior is CLP languages Howev

b est understo o d as the b ehavior of a CLP language An earlier language Le Fun

also computed over this domain and can b e viewed as a CLP language with a

weak constraint solver

Synopsis

The remainder of this pap er is organized into three main parts In part one we

provide a formal framework for CLPParticular attention will b e paid to op era

tional semantics and op erational mo dels As wehave seen in examples it is the

op erational interpretation of constraints rather than the declarativeinterpretation

which distinguishes CLP from LPInparttwo algorithm and data structure con

siderations are discussed A crucial prop ertyofany CLP implementation is that

its constraint handling algorithms are incremental In this lightwe review several

imp ortantsolvers and their algorithms for the satisabilityentailment and delay

ing of constraints We will also discuss the requirements of an inference engine for

CLP In part three we consider CLP applications In particular we discuss two

rather dierent programming paradigms one suited for the mo delling of complex

problems and one for the solution of combinatorial problems

In this survey we concentrate on the issues raised bytheintro duction of con

straints to LP Consequently we will ignore or pass over quickly those issues inher

entinLPWe assume the reader is somewhat familiar with LP and basic rstorder

logic Appropriate background can b e obtained from for LP and for logic

For intro ductory pap ers on constraint logic programming and CLP languages we

refer the reader to For further reading on CLP we suggest other

surveys some collections of pap ers and some b o oks

More generally pap ers on CLP app ear in various journals and confer

ence pro ceedings devoted to computational logic constraint pro cessing or symb olic computation

Notation and Terminology

This pap er will hop efully keep to the following conventions Upp er case letters

generally denote collections of ob jects while lower case letters generally denote

individual ob jects u v w x y z will denote variables s t will denote terms p q

will denote predicate symb ols f g will denote function symb ols a will denote a

constant a b h will denote atoms A will denote a collection of atoms will

denote substitutions c will denote a constraint C S will denote collections of

constraints r will denote a rule P Q will denote programs G will denote a goal

D will denote a structure D will denote its set of elements and d will denote an

elementofD These symb ols may b e subscripted or haveanovertildex denotes

a sequence of distinct variables x x x for an appropriate ns denotes a

 n

sequence of not necessarily distinct terms s s s for an appropriate ns t

 n

s t s t denotes the existential closure abbreviates s t

  n n x

of the formula except for the variablesx which remain unquantied denotes

the full existential closure of the formula

A signature denes a set of function and predicate symb ols and asso ciates an arity



with each symbol If is a signature a structure D consists of a set D and an

assignment of functions and relations on D to the symb ols of whichrespectsthe

arities of the symb ols A rstorder formula is built from variables function and

predicate symb ols of the logical connectives and quantiers over

variables in the usual way A formula is closed if all variable o ccurrences

ariable A theory in the formula are within the scop e of a quantier over the v

is a collection of closed formulas A model of a theory T is a structure D

such that all formulas of T evaluate to tr ue under the interpretation provided by

D AD model of a theory T is a mo del of T extending D this requires that the

signature of D be contained in the signature of T We write T Dj to denote

that the formula is valid in all D mo dels of T

In this pap er the set of function and predicate symb ols dened in the constraint

domain is denoted by and the set of predicate symb ols denable by a program

is denoted byAprimitive constraint has the form pt t where t t

n n

are terms and p is a predicate symbol Every constraint is a rstorder

formula built from primitive constraints The class of constraints will varybutwe

will generally consider only a subset of formulas to b e constraints An atom has

the form pt t where t t are terms and p A CLP program is a

n n

collection of rules of the form a b b where a is an atom and the b s are

n i

atoms or constraints a is called the head of the rule and b b is called the

n

body Sometimes we represent the rule by a c B where c is the conjunction of

constraints in the b o dy and B is the collection of atoms in the b o dy and sometimes

we represent the rule by a B where B is the collection of atoms and constraints

in the b o dy In one subsection we will also consider programs with negated atoms

in the b o dyAgoal or query G is a conjunction of constraints and atoms A fact

we will identify conjunction and is a rule a c where c is a constraint Finally

multiset union

To simplify the exp osition we assume that the rules are in a standard form

where all arguments in atoms are variables and eachvariable o ccurs in at most one



In a manysorted language this would include asso ciating a sort with each argument and the

result of eachsymb ol However we will not discuss such details in this survey

atom This involves no loss of generality since a rule suchaspt t C qs s

 

can b e replaced by the equivalentrulepx x x t x t y s y

   

s Cqy y We also assume that all rules dening the same predicate havethe

 

same head and that no two rules haveany other variables in common this is simply

a matter of renaming variables However in examples we relax these restrictions

Programs will b e presented in teletype font and will generally follow the Ed

inburgh syntax In particular program variables b egin with an upp ercase letter

HeadjT ail 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

The Semantics of CLP Languages

Many languages based on denite clauses have quite similar semantics The crucial

insight of the CLP Scheme and the earlier scheme of was

that a logicbased programming language its op erational semantics its declarative

semantics and the relationships b etween these semantics could all b e parameterized

byachoice of domain of computation and constraints The resulting scheme denes

the class of languages CLP X obtained by instantiating the parameter X

We take the view that the parameter X stands for a tuple D L T Here

is a signature D is a structure L is a class of formulas and T is a rstorder

theoryIntuitively determines the predened predicate and function symb ols and

their arities D is the structure over which computation is to b e p erformed L is the

class of constraints which can b e expressed and T is an axiomatization of some

prop erties of D In the following section we dene some imp ortant relationships

between the elements of the tuple and give some examples of constraint domains

We then give declarative and op erational semantics for CLP programs para

meterized by X The declarativesemantics are quite similar to the corresp onding

semantics of logic programs and wecover them quickly There are manyvariations

of the resolutionbased op erational semantics and we present the main ones We

also present the main soundness and completeness results that relate the twostyles

of semantics Finallywe discuss some linguistic features that have b een prop osed

as extensions to the basic CLP language

Constraint Domains

For any signature let D b e a structure the domain of computation and L be

a class of formulas the constraints We call the pair D Laconstraint domain

In a slight abuse of notation we will sometimes denote the constraint domain by D

We will makeseveral assumptions none of which is strictly necessary to simplify

the exp osition We assume



The terms and constraints in L come from a rstorder language



Without this assumption some of the results we cite are not applicable since there can b e

no appropriate rstorder theory T The remaining assumptions can b e omitted at the exp ense

The binary predicate symb ol is contained in and is interpreted as iden



tityin D

There are constraints in L which are resp ectivelyidentically true and iden

tically false in D

The class of constraints L is closed under variable renaming conjunction

and existential quantication

We will denote the smallest set of constraints which satises these assumptions

and contains all primitive constraints the constrain ts generated by the primitive

constraints b y L In general L may b e strictly larger than L since for example

 

universal quantiers or disjunction are p ermitted in L it also maybesmalleras

in example b elow However we will usually take L L On o ccasion wewill



consider an extension of and Lto and L resp ectively so that there is a

constantin for every elementofD

Wenow present some example constraint domains In practice these are not

always fully implemented but weleave discussion of that until later Most gen

eral purp ose CLP languages incorp orate some arithmetic domain including BNR

Prolog CAL CHIP CLPR Prolog I I I RISCCLPReal

Example Let contain the constants and the binary function symb ols

and and the binary predicate symb ols and LetD b e the set of real

numb ers and let D interpret the symb ols of as usual ie is interpreted as

addition etc Let L b e the constraints generated by the primitive constraints

Then D L is the constraint domain of arithmetic over the real numb ers If

we omit from the symbol then the corresp onding constraint domain

Lin

D L is the constraint domain of linear arithmetic over the real numbers If

the domain is further restricted to the rational numb ers then wehave a further

constraint domain Q In constraints in and Q we will write terms

Lin Lin Lin



suchasandx as abbreviations for and x x x x x resp ectively

Thus y x y z y is a constraintin and Q whereas

Lin Lin

x x y is a constraintonlyinIfweextend L to allow negated equations

we will use the symbol then the resulting constraint domains and

Lin

p ermit constraints suchasx y x y Finallyifwe restrict to Q

Lin

ts f g we obtain the constraintdomain where the only constrain

LinE q n

are linear equations

and Q and and Q are essentially the same constraintdomain

Lin Lin

Lin Lin

they have the same language of constraints and the two structures are elementarily

equivalent In particular a constraintsolver for one is also a constraint solver

for the other

of a messier reformulation of denitions and results



This assumption is unnecessary when terms have a most general unier in D as o ccurs in

Prolog Otherwise is needed to express parameter passing



Other syntactic sugar such as the unary and binary minus symbol are allowed Rational

numb er co ecients can b e used all terms in the sugared constraintneedonlybemultiplied by

an appropriate numb er to reduce the co ecients to integers



Sometimes called disequations

Prolog and standard logic programming can b e viewed as constraint logic pro

gramming over the constraint domain of nite trees

Example Let contain a collection of constant and function symb ols and

the binary predicate symbol Let D b e the set of nite trees where each

no de of each tree is lab elled by a constant or function symb ol the number of

children of each no de is the arityofthelabelofthenodeandthechildren are

ordered Let D interpret the function symb ols of as tree constructors where

each f ofarity n maps n trees to a tree whose ro ot is lab elled by f and

whose subtrees are the arguments of the mapping The primitive constraints

are equations b etween terms and let L b e 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 zx f z z y g z

It is unnecessary to write a quantier in Prolog programs b ecause all variables

that app ear only in constraints are implicitly existentially quantied

It was p ointed out in that complete ie alw ays terminating unication which

omits the o ccurs checksolves equations over the rational trees

Example WetakeandL as in example D is the set of rational trees

see for a denition and the function symb ols are interpreted as tree con

structors as b efore 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 inthesameway that and Q

Lin Lin

are essentially the same they have the same language of constraints and the two

structures are elementarily equivalent

The next domain contains ob jects similar to the previous domains but has a

dierent signature and constraint language which results in slightly dierent

expressivepower It can b e viewed as the restriction of domains over whichLO

GIN and LIFE compute when all sorts are disjoint The close relationship

between the constraints and terms is emphasized by a syntactic sugaring of

the constraints

is a set of unary predicate symb ols Example Let fgS F where S

sorts and F is a set of binary predicate symb ols features Let D b e the set of

nite or innite trees where eachnodeofeach tree is lab elled by a sort each

edge of each tree is lab elled by a feature and no no de has two outb ound edges

with the same lab el Such trees are called featuretreesLetD interpret each

sort s as the set of feature trees whose ro ot is lab elled by sandinterpret each

feature f as the set of pairs t t of feature trees such that t is the subtree

 

of t that is reached by the edge lab elled by f Ift has no edge lab elled by

f then there is no pair t t in the set Thus features are essentially partial



functions The domain of feature trees FEAT D L A typical constraintis

w inex y r eg ionx y r uther g l eny ycolorx y redy but there is



Avariant of this domain with a slightly dierent signature is used in

also a sugared syntax whichwould represent this constraintas x wineregion

r uther g l en col or red

The next constraint domain takes strings as the basic ob jects It is used in Prolog

III

Example Let contain the binary predicate symb ol the binary function

symbol a constant andanumb er of other constants D is the set of nite

strings of the constants The symbol is interpreted in D as string concatenation

and is interpreted as the empty string L is the set of constraints generated by

equations b etween terms Then WE D L is the constraint domain of equa

tions on strings sometimes called the domain of word equations An example

constraintisxa bx

The constraint domain of Bo olean values and functions is used in BNRProlog

CAL CHIP and Prolog I I I CAL and CHIP employ a more general

constraint domain which includes symb olic Bo olean values

Example Let contain the constants and the unary function symbol

and the binary predicate symbol the binary function symb ols

Let D be the set ftr ue f al seg and let D interpret the symb ols of as

the usual Bo olean functions ie is interpreted as conjunction is exclu

sive or etc Let L b e the constraints generated by the primitive constraints

Then BOOL D L is the twovalued Bo olean constraint domain An ex

ample constraintisx y y In a slight abuse of notation we allowa

constraint t to b e written simply as t so that for example x y y

denotes the constraint x y y For the more general constraintdomain

let fa a g where the a are constants Let L b e the con

i i

straints generated by the primitive constraints and let D b e the free Bo olean

algebra generated by fa a g Then BOOL D L is the Bo olean

i

constraint domain with innitely manysymbolic values A constraint cx ais

satisable in BOOL i Dj xyc x y

The nite domains of CHIP are b est viewed as having the integers as the underlying

structure with a limitation on the language of constraints

Example Let D Z and ff m ng gFor every pair of

mn

m x n integers m and ntheinterval constraint x m n denotes that

The other symbols in have their usual meaning Let L b e the constraints c

generated by the primitive constraints restricted so that every variable in c is

sub ject to an interval constraint Then FD D L is the constraint domain

referred to as nite domains The domain of a variable x is the nite set of

values which satisfy all unary constraints involving x Atypical constraintin



Only nitely many constants are used in any one program so it can b e argued that a nite

Bo olean algebra is a more appropriate domain of computation However the two alternatives agree

on satisability and constraintentailment although not if an expanded language of constraints

is p ermitted and it is preferable to view the constraint domain as indep endent of the program

Currently it is not clear whether the alternatives agree on other constraint op erations

FD is x y x x y x y The domain of x is

f g

There are several other constraint domains of interest that we cannot exemplify

here for lack of space They include pseudoBo olean constraints for example

which are intermediate b etween Bo olean and integer constraints ordersorted

feature algebras domains consisting of regular sets of strings domains of

nite sets domains of CLPFunD which employ a function variable

domains of functions expressed by expressions etc

It is also p ossible to form a constraint domain directly from ob jects and op er

ations in an application instead of more generalpurp ose domains suchasthose

ab ove This p ossibility has only b een pursued in a limited form where a general

purp ose domain is extended by the ad ho c addition of primitive constraints For

example in some uses of CHIP the nite domain is extended with a predicate sym

bol el ement The relation el ementx l t expresses that t is the xth elemen t

in the list l We discuss such extensions further in Section

These constraint domains are exp ected to supp ort p erhaps in a weakened form

the following tests and op erations on constraints whichhave a ma jor imp ortance in

CLP languages The rst op eration is the most imp ortant it is almost obligatory

while the others might not b e used in some CLP languages

The rst is a test for consistency or satisability Dj c

The second is the implication or entailment of one constraintby another

Dj c c More generallywemay ask whether a disjunction of con

W

n

straints is implied by a constraint Dj c c

i

i

The third is the projection of a constraint c onto variablesx to obtain a

ys p ossible to take c to constraint c such that Dj c c It is alwa

x

be c but the aim is to compute the simplest c with fewest quantiers

x

In general it is not p ossible to eliminate all uses of the existential quantier

The fourth is the detection that given a constraint c there is only one

value that a variable x can take that is consistent with cThatisDj

cx z cy w x y or equivalently Dj z x yc x y x z We

say x is determined or groundedby c

In Section we will discuss problems and techniques which arise when imple

epoint out here that some menting these op erations in a CLP system However w

implementations of these op erators in particular the test for satisabilit yare

incomplete In some cases it has b een argued that although an algo

rithm is incomplete with resp ect to the desired constraint domain it is complete

with resp ect to another articially constructed constraint domain

Wenow turn to some prop erties of constraint domains which will b e used later

The rst two solution compactness and satisfaction completeness w ere intro

duced as part of the CLP Scheme

Denition Let d range over elements of D and c c range over constraints

i

in L and let I b e a p ossibly innite index set A constraintdomainD Lis

solution compact if it satises the following conditions

V

c x SC d fc g st Dj xx d

i i iI

iI

W

c x SC c fc g st Dj x cx

i  i iI

iI

Roughly sp eaking SC is satised i every element d of D can b e dened bya

p ossibly innite conjunction of constraints and SC is satised i the complement



of each constraint c in L can b e describ ed by a p ossibly innite disjunction of

constraints

The denition of SC in is not quite equivalent to the denition in which



we paraphrase ab ove see It turns out that SC is not necessary for the results

we present we include it only for historical accuracy There is no known natural

constraint domain for which SC do es not hold There are however some articial



constraint domains for which it fails



Example Let denote the constraint domain obtained from by

Lin

Lin

adding the unary primitive constraint x The negation of this constraint



ie x cannot b e represented as a disjunction of constraints in Thus

Lin



is not solution compact

Lin

The theory T in the parameter of the CLP scheme is intended to axiomatize some

of the prop erties of D We place some conditions on D and T to ensure that

T reects D suciently The rst two conditions ensure that D and T agree on

satisability of constraints while the addition of the third condition guarantees

that every unsatisabilityin D is also detected by T The theory T and these

conditions mainly play a role in the completeness results of Section

Denition For a given signature let D L b e a constraint domain with

signature and T b e a theoryWesaythatD and T correspond on L if

D is a mo del of T and

for every constraint c L Dj c i Tj c

Wesay T is satisfaction complete with resp ect to L if for every constraint c L

c or Tj c either Tj

Satisfaction completeness is a weakening of the notion of a complete theory

Thus for example the theory of the real closed elds corresp onds and is

satisfaction complete with resp ect to since the domain is a mo del of this theory

and the theory is complete Clarks axiomatization of unication denes a

satisfaction complete theory with resp ect to FT which is not complete when there

are only nitely many function symb ols

e constraints plays a signicantroleincon The notion of indep endence of negativ

straint logic programming In Colmerauer used indep endence of inequations

to simplify the test for satisability of equations and inequations on the rational

It is also closely related to the mo deltheoretic prop erties that led to an interest in Horn

formulas

trees The indep endence of inequations states if a conjunction of p ositive and neg

ative equational constraints are inconsistent then one of the negative constraints

is inconsistent with the p ositive constraints Indep endence of negative constraints

has b een investigated in greater generalityin The prop erty has b een shown

to hold for several classes of constraints including equations on nite rational and

innite trees linear real arithmetic constraints where only equa

tions may b e negated sort and feature constraints on feature trees and

innite Bo olean algebras with p ositive constraints among others We

consider a restricted form of indep endence of negative constraints

Denition A constraint domain D L has the Indep endence of Negated Con

straints prop erty if for all constraints c c c L

n

Dj c c c i Dj c c for i n

n i

The fact that L is assumed to b e closed under conjunction and existential quan

tication is an imp ortant restriction in the ab ove denition For example Colmer

auers work is not applicable in this setting since that dealt only with primitive

y of the other results cited ab ove at least not in their constraints Neither are man

full generalityHowever there are still several useful constraint domains known to

have this prop erty including the algebras of nite rational and innite trees with

equational constraints when there are innitely many function symb ols

feature trees with innitely many sorts and features linear arithmetic equa

tions over the rational or real numb ers and innite Bo olean algebras with p ositive

constraints

Example In the Herbrand constraint domain FT with only two function

symb ols a constant a and a unary function f it is easily seen that the fol

lowing statements are true FT j x y z x f y y a y f z

FT j x y x f y y a FT j x y z x f y y f z This

is an example of the indep endence of inequations for FT However when we

consider the full class of constraints of FT wehave the following facts The

statement FT j x y x f y y a zy f z is not true since

every nite tree y is either the constant a or has the form f z for some

nite tree z On the other hand b oth FT j x y x f y y a and

FT j x y z x f y zy f z are true Thus for these function

symb ols and it is easy to see ho w to extend this example to any nite set of

function symb ols the indep endence of negated constrain ts do es not hold

As is clear from constraint domains and constraints are closely related to

t his domain the information systems and their elements used by Scott to presen

theory Information systems co dify notions of consistency and entailmentamong

elements which can b e interpreted as satisability and implication of constraints

on a single variable Saraswat extended the notion of information system

to constraint systems which allow manyvariables and showed that some of the

motivating prop erties of information systems continue to hold

although do es not treat consistencyonlyentailment

Constraint systems we will not give a formal denition here can b e viewed as

abstractions of constraint domains which eliminate consideration of a particular

structure D the relation Dj c c c among constraints c c c

n n

is abstracted to the relation c c c and the satisability relation Dj

n

c c among constraints can b e abstracted to a set Con of all consistent

n

nite sets of constraints fc c g Many of the essential semantic

n

details of a constraint domain are still present in the corresp onding constraint

system although prop erties such as solution compactness and indep endence of

negated constraints cannot b e expressed without more detail than a constraint

system provides

Logical Semantics

There are two common logical semantics of CLP programs over a constraint domain

D L The rst interprets a rule

px b b

n

as the logic formula

x yp x b b

n

wherex y is the set of all free variables in the rule The collection of all such

formulas corresp onding to rules of P gives a theory also denoted by P

The second logical semantics asso ciates a logic formula to eachpredicatein

If the set of all rules of P with p in the head is

px B

px B



px B

n

then the formula asso ciated with p is

xp x y B

y B

 

y B

n n

wherey is the set of variables in B except for v ariables inx Ifp do es not o ccur

i i

in the head of a rule of P then the formula is

x px

The collection of all suchformulas is called the Clark completion of P andis

denoted by P

A valuation 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 fv a j a c X Dj v cgAD interpretation of a formula is an D

interpretation of the formula with the same domain as D and the same interpre

tation for the symb ols in as D It can b e represented as a subset of B where

D

k

B fpd j p d D gAD mo del of a closed formula is a D interpretation

D

which is a mo del of the formula

Let T denote a satisfaction complete theory for D L The usual logical seman

tics are based on the D mo dels of P and the mo dels of P T The least D mo del

of a formula Q under the subset ordering is denoted by lmQ D and the great

est is denoted by gmQ D A solution to a query G is a valuation v suchthat

v G lmP D

tics Fixedp oint Seman

The xedp oint semantics we present are based on onestep consequence functions

D D D D

T and S and the closure op erator P generated by T The functions T and

P P P P

P map over D interpretations The set of D interpretations forms a complete

lattice under the subset ordering and these functions are continuous on B

D

D

T I fpd j px c b b is a rule of P a I i n

n i

P

v is a valuation on D such that

ing Dj v cvx d and v b a

i i

D

It represents a deductive closure based P is the closure op erator generated by T

P

on the rules of P Let Id b e the identity function and dene f g xf x g x

D

Id greater than I and the least xedp oint Then P I is the least xedp ointofT

P

D

of T

P I

D

The function S is dened on sets of facts which form a complete lattice under

P

D

the subset ordering We denote the closure op erator generated from S by hhP ii

P

Both these functions are continuous

D

I fpx c j p S x c b b is a rule of P

n

P

a c I i n the rule and facts renamed apart

i i

V

n

c a b g Dj c c

i i i

i

We denote the least xedp oint of a function f by lf pf and the greatest xedp oint

by gf pf These xedp oints exists for the functions of interest since they are mo

notonic 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

f f f

S

f f if is a limit ordinal

f B

D

f f f

T

f f if is a limit ordinal

D D

We can takeassemantics lf pS orlf pT The two functions involved are

P P

D D D

related in the following way S I T I Consequently lf pS

D D D

P P P

D D

lf pT lf pS corresp onds to the ssemantics for languages with constraints

P P

Fixedp oint semantics based on sets of clauses also extend easily to CLP

languages

Based largely on the facts that the D mo dels of P are the xedp oints of P and

D

the D mo dels of P are the xedp oints of T wehave the following connections

P

between the logical and xedp ointsemantics just as in standard logic programming

Proposition Let P P P beCLPprograms and Q a set of facts over a con



straint domain D with corresponding theory T Then

D D D

T lf pT lf pS P

D

P P P

Djh cg fh c j P Tjh cg lmP D fh c j P

D D

D

lmP D lmP D lf pT

P

D

gmP D gf pT

P

P Q P Q lmP Q D

D

D

hhP iiQhhP Q ii lf pS

P Q

Dj P P i P P

 

We will need the following terminology later P is said to b e D Lcanonical i

D D

gf pT T Canonical logic programs but not constraint logic programs

P P

were rst studied by who showed that every logic program is equivalentwrt

the success and nite failure sets to a canonical logic program The pro of here

was not constructive but subsequently provided an algorithm to generate



the canonical logic program Like many other kinds of results in traditional logic

programming these results are likely to extend to CLP in a straightforward way

Topdown Execution

The phrase topdown execution covers a multitude of op erational mo dels We

will present a fairly general framework for op erational semantics in whichwecan

describ e the op erational semantics of some ma jor CLP systems

We will present the op erational semantics as a transition system on states tuples

hA C S i where A isamultiset of atoms and constraints and C and S are multisets

of constraints The constraints C and S are referred to as the constraint stor e and

in implementations are acted up on by a constraintsolver Intuitively A is a

collection of asyetunseen 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 failTo

express more details of an op erational semantics it can b e necessary to represent

the collections of atoms and constraints more preciselyFor example to express

the lefttoright Prolog execution order wemight use a sequence of atoms rather

than a multiset However we will not b e concerned with such details here



This pro of was p erformed in the more general class of logic programs with negation

We will assume as given a computation rule which selects a transition typ e and



an appropriate elementof A if necessary for each state The transition system

is also parameterized by a predicate consistent and a function inf er whichwe will

discuss later An initial goal G for execution is represented as a state by hG i

The transitions in the transition system are

hA a C S i hA B C S a hi

r

if a is selected by the computation rule a is an atom h B isaruleofP renamed

to new variables and h and a have the same predicate symb ol The expression

a h is an abbreviation for the conjunction of equations b etween corresp onding

arguments of a and hWesay a is rewritten in this transition

hA a C S i f ail

r

if a is selected by the computation rule a is an atom and for every rule h B of

P h and a have dierent predicate symb ols

hA c C S i hA C S ci

c

if c is selected by the computation rule and c is a constraint

hA C S i hA C S i

i

if C S inf er C S

hA C S i hA C S i

s

if consistentC

hA C S i f ail

s

if consistentC

The transitions arise from resolution transitions intro duce constraints

r c

into the constraint solver transitions test whether the active constraints are

s

transitions infer more active constraints and p erhaps mo dify consistent and

i

the passive constraints from the current collection of constraints We write to

refer to a transition of arbitrary typ e

The predicate consistentC expresses a test for consistency of C Usually it

is dened by consistentC iDj C that is a complete consistency test

However systems may employ a conservative but incomplete or partial test if

Dj C then consistentC holds but sometimes consistentC holds although

Dj C One example of such a system is CAL which computes over the

domain of real numb ers but tests consistency over the domain of complex numbers

The function inf er C S computes from the current sets of constraints a new set

of active constraints C and passive constraints S Generally it can b e understo o d

as abstracting from S or relaxing S in the presence of C to obtain more active

constraints These are added to C to form C and S is simplied to S We require



A computation rule is a convenient ction that abstracts some of the b ehavior of a CLP

system To b e realistic a computation rule should also dep end on factors other than the state

for example the history of the computationWe ignore these p ossibilities for simplicity

that DjC S C S so that information is neither lost nor guessed by

inf er The role that inf er plays varies widely from system to system In Prolog

there are no passive constraints and we can dene inf er C S C S In

CLPR nonlinear constraints are passive and inf er simply passes the linearized

version of a constraint from S to C when the constraint b ecomes linear in the

context of C and deletes the constraint from S For example if S is x y

z z y and C is x z then inf er C S C S where C is

x z y z and S is z y

In a language like CHIP inf er p erforms less obvious inferences For example if

S is x y and C is x y then inf er C S C S where C

is x y and S 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 consistencyHowever the formulation wegive seems to reect

the systems more closely Similarly in languages employing interval arithmetic

over the real numb ers such as BNRProlog intervals are active constraints and

other constraints are passive In this case inf er rep eatedly computes smaller in

tervals for each of the variables based on the constraints in S terminating when

no smaller interval can b e derived mo dulo the precision of the arithmetic Exe

cution of language constructs such as the cardinality op erator constructive

disjunction and sp ecialpurp ose constructs for example in can also

be understood as transitions where these constructs are viewed as part of the

i

language of constraints

Generally the active constraints are determined syntactically As examples in

Prolog all equations are active in CLPR all linear constraints are active on the

nite domains of CHIP all unary constraints ie constraints on just one variable

suchasx or x are activeandintheinterval arithmetic of BNRProlog

only intervals are active

The stronger the collection of active constraints the earlier failure will b e de

tected and the less searching is necessary With this in mind we mightwish inf er

to b e as strong as p ossible for every active constraint cifinf er C S C S



and DjC S c then Dj C cHowever this is not always p ossible

Even if it were p ossible it is generally not preferred since the computational cost

of a p owerful inf er function can b e greater than the savings achieved by limiting

search

A CLP system is determined by the constraint domain and a detailed op erational

semantics The latter involves a computation rule and denitions for consistent

and inf er Wenow dene some signicant prop erties of CLP systems We distin

guish the class of systems in which passive constraints playnoroleandtheglobal

consistency test is complete These systems corresp ond to the systems treated in

Denition Let and Wesay that a CLP

ris r i s cis c i s

system is quickchecking if its op erational semantics can b e describ ed by and

ris

A CLP system is progressive if for every state with a nonempty collection

cis

of atoms every derivation from that state either fails contains a transition

r



For example in CLPR where linear constraints are active and nonlinear constraints are



passive if S is y x x then we can take c to b e y kx k for any k There is no nite

collection C of active constraints which implies all these constraints and is not stronger than S

or contains a transition A CLP system is ideal if it is quickchecking

c

progressive inf er is dened by inf er C S C S and consistentC

holds i Dj C

In a quickchecking system inference of new active constraints is p erformed 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 inf er it nds incon

sistency as so on as p ossible A progressive system will never innitely ignore the

collection of atoms and constraints in the rst part of a state during execution All

ma jor implemented CLP systems are quickchecking and progressive but most are

not ideal

A derivation is a sequence of transitions hA C S ihA C S i

i i i

A state which cannot b e rewritten further is called a nal state A derivation is

successful if it is nite and the nal state has the form hCSi Let G be a

goal with free variablesx which initiates a derivation and pro duces a nal state

hCSi Then C S is called the answer constraint of the derivation

x

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 A a is rewritten in a later transition A

i

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 b e 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

The computation tree of a goal G for a program P in a CLP system is a tree

or such that with no des lab elled by states and edges lab elled by

s r c i

the ro ot is lab elled by hG i for every no de all outgoing edges have the same

lab el if a no de lab elled by a state S has an outgoing edge lab elled by or

c i

then the no de has exactly one child and the state lab elling that child can b e

s

obtained from S via a transition or resp ectively if a no de lab elled by

c i s

a state S has an outgoing edge lab elled by then the no de has a child for each

r

rule in P and the state lab elling eachchild is the state obtained from S bythe

transition for that rule for each and edge the corresp onding transition

r r c

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 corresp onding 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

lefttoright computation rule which is not fair We will discuss linguistic features

intended to improve on this rule in Section

The problem of nding answers to a query can b e seen as the problem of searc h

ing a computation tree Most CLP languages employ a depthrst search with

chronological backtracking as in Prolog although there have b een suggestions to

use dep endencydirected backtracking Since depthrst search is incomplete

on innite trees not all answers are computed The depthrst search can b e incor

p orated in the semantics in the same way as is done for Prolog see for example

but we will not go into details here In Section we will discuss a class of

CLP languages which use a topdown execution similar to the one outlined ab ove

but do not use backtracking

Consider the transition

hA C S i hA C i

g

where C is a set of equations in L such that Dj C C S and for every

variable x o ccurring in C or S C contains an equation x d for some constant d

Thus grounds all variables in the constraintsolver We also have the transitions

g

hA C S i f ail

g

if no such C exists ie C S is unsatisable in D A ground derivation is a

derivation comp osed of and

r g c g

Wenow dene three sets that crystallize three asp ects of the op erational se

ts to simple goals mantics The success set SSP collects the answer constrain

px The nite failure set FFP collects the set of simple goals which are nitely

failed The ground nite failure set GF F P collects the set of grounded atoms

all of whose fair ground derivations are failed

SSP fpx c jhpx i hc c i Dj c c c g

x

FFP fpx c j for every fair derivation hpxci failg

d i failg GF F P fpd j for every fair ground derivation hp

Soundness and Completeness Results

Wenow present the main relationships b etween the declarative semantics and the

topdown op erational semantics Tokeep things simple we consider only ideal CLP

systems However many of the results hold much more generally The soundness

results hold for any CLP system b ecause of restrictions we place on consistent and

inf er Completeness results for successful derivations require only that the CLP

system b e progressive

Theorem Consider a program P in the CLP language determinedbyatuple

D LT where D and T correspond on L and executing on an ideal CLP

system Then

D

andSSP lmP D SSP lf pS

D

P

If the goal G has a successful derivation with answer constraint c then

P Tj c G

Supp ose T is satisfaction complete wrt LIfG has a nite computation tree

with answer constraints c c then P Tj G c c

n n

If P Tj c G then there are derivations for the goal G with answer

W

n

constraints c c such that Tj c c If in addition D L

n i

i

has indep endence of negated constraints then the result holds for n ie

without disjunction

Supp ose T is satisfaction complete wrt LIfP Tj G c c then

n

G has a computation tree with answer constraints c c and p ossibly

m

others such that Tj c c c c

n

m

Supp ose T is satisfaction complete wrt L

The goal G is nitely failed for P i P Tj G

gmP D B GF F P

D

D

Supp ose D L is solution compact T B FFP

D D

P

Supp ose D L is solution compact

P is D Lcanonical i FFP fh c j P Dj h cg

D D

Most of these results are from but there are also some from

Results and of the ab ove theorem which are equivalent are the only results

of those listed ab ove which require solution compactness In fact the prop erties

shown are equivalentto SC the second condition of solution compactness



SC is not needed In soundness results and half of as mentioned earlier

T can b e replaced by D Ifwe omit our assumption of a rstorder language of

constraints see Section then only results and the soundness half

of replacing T by D where necessary continue to hold

The strong form of completeness of successful derivations result provides

an interesting departure from the conventional logic programming theoryItshows

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 uniabilityby constraint satisfaction Clarks equality theory

by a corresp onding satisfactioncomplete theory etc most results and even their

pro ofs lift from LP to CLP The lifting is discussed in greater detail in Fur

thermore most op erational asp ects of LP and Prolog can b e interpreted as logical

op erations and consequently these op erations although not their implementations

also lift to CLP One early example is matching which is used in various LP sys

tems eg GHC NUProlog as a basis for aecting the computation rule the

corresp onding op eration in CLP is constraintentailment

The philosophy of the CLP Scheme gives primacy to the structure D over

ve which computation is p erformed and less prominence to the theory T Weha

followed this approach However it is also p ossible to start with a satisfaction

complete theory T see for example without reference to a structure We

can arbitrarily cho ose a mo del of T as the structure D and the same results ap

ply Another variation considers a collection D of structures and denes

consistentC to hold i for some structure DD wehave Dj C Weaker

forms of the soundness and completeness of successful derivations apply in this case

BottomUp Execution

Bottomup execution has its main use in database applications The setatatime

pro cessing limits the numb er of accesses to secondary storage in comparison to

tupleatatime pro cessing as in topdown execution and the simple semantics

gives great scop e for query optimization

Bottomup execution is also formalized as a transition system For every rule r

of the form h c b b in P and every set A of facts there is a transition

n

n

A  Afh c j a c i n are elements of A Dj c c c b a g

i i i i i

i

D

In brief then wehave A  A S A for every set A and every rule r in P

r

D

S was dened in Section An execution is a sequence of transitions It is

P

fair if each rule is applied innitely often The limit of ground instances of sets

generated by fair executions is indep endentoftheorderinwhich transitions are

applied and is regarded as the result of the b ottomup execution If Q is an initial

set of facts and P is a program and A is the result of a fair b ottomup execution

then A SSP Q hhP iiQandP Q A

D D

An execution Q X  X  X  terminates if for some m and every

i

im X X Wesay P is nitary if for every nite initial set of facts Q and

i m

every fair execution there is a k suchthatX X for all i k However

i D k D

execution can b e nonterminating even when the program is nitary and the initial

set is nite

Example Consider the following program P on the constraint domain

Lin

pX pX

pX X

pX X

Straightforward b ottomup computation gives fpx x px x

px x g and px x gfpx x px x

D D

fpd j d g T do es not terminate Wealsohave lf pT

P P

A necessary technique is to test whether a new fact is subsumed by the current set

of facts and accumulate only unsubsumed facts A fact px c is subsumed by

W

n

c The the facts px c i n with resp ect to D L if Dj c

i i

i

transitions in the mo died b ottomup execution mo del are

D

AA A  A r educeS

P

where r educeX Y eliminates from X all elements subsumed by Y Under this

execution mo del every nitary program terminates on every nite initial set Q

Unfortunatelychecking subsumption is computationally exp ensive in general

If the constraint domain D L do es not satisfy the indep endence of negated con

straints then the problem of showing that a new fact is not subsumed is at least

NPhard see for the pro of in one constraint domain In constraint domains

with indep endence of negated constraints the problem is not so bad the new fact

only needs to b e checked against one fact at a time Classical database

optimizations are also more dicult without indep endence of negated constraints

A pragmatic approach to the problem of subsumption in is given

Lin

in Some work avoids the problem of subsumption by allowing only ground

facts in the database and intermediate computations

Even with subsumption there is still the problem that execution mightnot

terminate for example if P is not nitary The approach of is to restrict

the constraint domains D to those which only p ermit the computation of nitely

representable relations from nitely representable relations This requirementis

slightly weaker than requiring that all programs are nitary but it is not clear that

there is a practical dierence Regrettablyvery few constraint domains satisfy this

condition and those whichdohave limited expressivepower

The alternative is to takeadvantage of P and a sp ecic query or a class of

queries A transformation technique such as magic templates pro duces a

mg

program P that is equivalenttoP for the sp ecic query Other techniques

attempt to further limit execution by placing constraints at

appropriate p oints in the program Analyses can b e used to check that execution

of the resulting program terminates although most work has ignored

the capability of using constraints in the answers

Comparatively little work has b een done on the nuts and b olts of implementing

b ottomup execution for CLP programs with all the work addressing the constraint

domain suggested the use of intervals computed as the pro jection of a

Lin

collection of constraints as the basis for indexing on constrained variables Several

dierent data structures originally develop ed for spatial databases or computa

tional geometryhave b een prop osed as appropriate for indexing A

new data structure was presented in which minimizes accesses to secondary

storage A sortjoin algorithm for joins on constrained variables is given in

That pap er also provides a query optimization metho dology for conjunctive queries

that can balance the cost of constraint manipulation against the cost of traditional

database op erations

Concurrent Constraint Logic Programming

Concurrent programming languages are languages which allow the description of

collections of pro cesses whichmayinteract with each other In concurrentcon

straint logic programming CCLP languages communication and synchronization

are p erformed by asserting and testing for constraints The op erational semantics

of these languages are quite similar to the topdown execution describ ed in Sec

ever the dierentcontext in which they are used results in a lesser tion How

imp ortance of the corresp onding logical semantics

For this discussion we will consider only the at asktell CCLP languages which

were dened in based on ideas from We further restrict our atten

tion to languages with only committedchoice nondeterminism sometimes called

dontcare nondeterminism more general languages will b e discussed in Section

For more details of CCLP languages see

Just as Prolog can b e viewed as a kind of CLP language obtained by a particular

choice of constraint domain so most concurrent logic languages can b e viewed as



concurrent CLP languages

A program rule takes the form

h ask tel l j B

where h is an atom B is a collection of atoms and ask and tel l are constraints

Many treatments of concurrent constraint languages employ a language based on a

pro cess algebra involving ask and tell primitives but weusethesyntax ab ove

to emphasize the similarities to other CLP languages

For the sake of brevitywepresent a simpler transition system to describ e the op

erational semantics than the transition system in Section However implemented

languages can make the same pragmatic compromises on testing consistency and



Concurrent Prolog is not an asktell language but shows how it can b e t inside

the CCLP framework

implication as reected in that transition system The states in this transition

system have the form hA C i where A is a collection of atoms and C is a collection

of constraints Any state can b e an initial state The transitions in the transition

system are

hA a C i hA B C a h ask tel l i

r

if h ask tel l j B is a rule of P renamed to new variablesx h and a havethe

same predicate symb ol Dj C xa h ask and Dj C a h ask tel l

Roughly sp eaking a transition can o ccur 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 that

such languages are strictly less expressive than asktell languages

An op erational semantics such as the ab ove is not completely faithful to a real

execution of the language since it is p ossible for two atoms to b e rewritten si

multaneously in an execution environment with concurrency The ab ove semantics

only allows rewritings to b e interleaved A true concurrency semantics based on

graphrewriting is given in

All asktell CCLP programs have the following monotonicity orstability

prop erty If hA C i hA C i and Dj C C then hA C i hA C iThis

r r

prop erty provides for simple solutions to some problems in distributed computing

related to reliabilityWhenlooked at in a more general framework stability

seems to b e 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 by the state fail destroys

stability Of course there are also pragmatic reasons for wanting to a void this

notion in a concurrent language A framework which p ermits nonmonotonic CCLP

languages is discussed in

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 transition Con

r

sequently for every initial state every fair derivation rewrites the same atoms

with the same rules or every derivation fails Thus nonfailed derivations byde

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



determinate The interest in determinate programs arises from an elegant seman

tics for such programs based up on closure op erators For every collection

of atoms A the semantics of A is given by the function P C C where

A x

hA C i hA C ix is the free variables of hA C iandhA C i is a nal state

r

This semantics is extended in to a comp ositional and fully abstract semantics

of arbitrary programs A semantics based on traces is given in

For determinate programs we also have a clean application of the classical logical

semantics of a program If hA C i hA C i then P Dj A C

r

A C wherex is the free variables of hA C i In cases where execution can b e

x



For the programs we consider determinate programs can b e characterized syntactically

by the following condition for every pair of rules renamed apart except for identical heads

h ask tell j B and h ask tell j B in the program wehave Dj ask ask tell

   

or Dj ask ask tell In languages where pro cedures can b e hidden as in manyprocess

 

algebra formulations or there is a restriction on the initial states the class of determinate programs

is larger but is not so easily characterized

guaranteed not to susp end any atom indenitely the soundness and completeness

results for success and failure hold see Section

Linguistic Extensions

We discuss in this section some additional linguistic features for topdown CLP

languages

Shrinking the Computation Tree

The aim of transitions is to extract as much information as is reasonable from

i

the passive constraints so that the branching of transitions is reduced There

r

are several other techniques used or prop osed for achieving this result

In it is suggested that information can also b e extracted from the atoms in

a state The constraint extracted would b e an approximation of the answers to the

atom This op eration can b e expressed by an additional transition rule

hA a C S i hA a C S ci

x

where extr acta C c Here extr act is a function satisfying P Dja C c

The evaluation of extr act p erformed at runtime involves an abstract or approx

imate execution of ha C iFor example if P denes p with the facts p and

p then the constraint extracted by extr actpx y mightbe y x

A more widespread technique is to mo dify the order in which atoms are selected

Most CLP systems employ the Prolog lefttoright computation rule This improves

the programmability byproviding a predictable owofcontrol However when

an appropriate owofcontrol is datadep endentorvery complex for example in

combinatorial search problems greater exibility is required

One solution to this problem is to incorp orate a datadep endent computation

rule in the language The Andorra principle involves selecting determinate

atoms if p ossible A determinate atom is an atom which only gives rise to one

ris

transition A second approachistoallow the programmer to annotate parts of the

program atoms predicates clauses to provide a more exible computation

rule that is nonetheless programmed This approachwas pioneered in Prolog

I I and MUProlog The automatic annotation of programs brings

this approach closer to the rst A third approachistointro duce constructs from

concurrent logic programming into the language There are basically twovarieties

of this approach guarded rules and guarded atoms The former intro duces a

committedchoice asp ect into the language whereas the latter is a variantofthe

second approach All these approaches originated for conventional logic programs

but the ideas lift to constraint logic programs and there are nowseveral prop osals

based on these ideas

One p otential problem with using guarded rules is that the completeness of the

op erational semantics with resp ect to the logical semantics of the program can b e

lost This incompleteness was shown to b e avoided in ALPS mo dulo innitely

delayed atoms but that work was heavily reliant on determinacy Smolka

discusses a language of guarded rules which extends ALPS and a metho dology for

extending a predicate denition with new guarded rules such that completeness can

b e retained even though execution would involve indeterminate committedchoice

The Andorra Kernel Language AKL also combines the Andorra principle

with guarded rules There the interest is in providing a language which subsumes

the expressivepower of CCLP languages and CLP languages

Guarded atoms and more generally guarded goals take the form c G where c

is a constraint and G is a goal G is available for execution only when c is implied

by the current active constraints Wecallc the guardconstraint 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 b e

combined conjunctively whereas guards in guarded rules are combined disjunctively

Complex Constraints

Several language constructs that can b e said simply to b e complex constraints have

b een added to CLP languages We can classify them as follows those whichim

plement Bo olean combinations of generally simple constraints and those which

describ e an ad ho c often applicationsp ecic relation Falling into the rst cate

gory are some implementations of constraint disjunction sometimes called

constructive disjunction and the cardinality op erator Into the second cat

constraint and the cumulative constraint of among egory fall the el ement

others These constraints are already accounted for in the op erational semantics

of Section since they can b e considered passive constraints in LHowever it

also can b e useful to view them as additions to a b etterknown constraint domain

indeed this is how they arose

The cardinality op erator can b e used to express any Bo olean combination of

constraints A use of this combinator has the form L c c U where the

n

c are constraints and L and U are variables This use expresses that the number

i

of constraints c that are true lies b etween the value of L and the value of U lower

i

and upp er b ound resp ectively By constraining L the combinator represents

the disjunction of the constraints by constraining U the combinator represents

the conjunction of the negations of the constraints The cardinality combinator

is implemented by testing whether the constraints are entailed by or inconsistent

with the constraint store and comparing the numb ers of entailed and inconsistent

constraints with the values of L and U When L and U are not ground the

cardinality constraint can pro duce a constraint on these variables For example

after one constraint is found to b e inconsistent U can b e constrained by U n

In constraint languages without disjunction an intended disjunction c x c x



must b e represented by a pair of clauses

px c x

px c x



In a simple CLP language this representation forces a choicetobemadebetween

the two disjuncts Constructive disjunction refers to the direct use of a disjunctive

constraint without immediately making a choice Instead an active constraintis

computed which is a safe approximation to the disjunction in the context of the

current constraintstoreC In the constraint domain FD suggests two p ossible



We also p ermit the constraint g r oundx

approximations one based on approximating each constraint C c using the domain

i

of eachvariable and the other less accurately approximating each constraint using

the interval constraints for eachvariable The disjunctions of these approximations

is easily expressed as an active constraint For linear arithmetic suggests the use

of the convex hull of the regions dened bythetwo constraints as the approximation

Note that the constructive disjunction b ehavior could b e obtained from the clauses

for p using the metho ds of

In the second categorywe mention two constructs used with the nite domain

solver of CHIP el ementX L T expresses that T is the X th element in the list

L Op erationally it allows constraints on either the index X or element T of the

list to b e reected by constraints on the other For example if X is constrained

so that X f g then el ementX T can constrain T so that

T f g and similarlyif T is constrained so that T f g then X is

constrained so that X f g Declaratively the cumul ativ e constraintof

expresses a collection of linear inequalities on its arguments Several problems

that can b e expressed as integer programming problems can b e expressed with

cumul ativ e Op erationallyitbehaves somewhat dierently from the way CHIP

would usually treat the inequalities

UserDened Constraints

Complex constraints are generally built in to the language There are prop osals

to extend CLP languages to allow the user to dene new constraints together with

inference rules sp ecifying how the new constraints react with the constraint store

A basic approach is to use guarded clauses The new constraint predicate is

dened with guarded clauses where the guards sp ecify the cases in which the con

straint is to b e simplied and the b o dy is an equivalent conjunction of constraints

Using g r oundx or a similar construct as a guard constraint it is straightfor

ward to implement lo cal propagation ie propagation of ground values Wegive

an example of this use in Section and has other examples Some more

general forms of propagation can also b e expressed with guarded clauses

The w ork can b e seen as an extension of this metho d The new constraints

o ccur as predicates and guarded rules called constraint simplication rules are

used to simplify the new constraints However the guarded rules mayhavetwoor

more atoms in the head Execution matches the head with a collection of constraint

atoms in the goal and reduces to an equivalent conjunction of constraints This

metho d app ears able to express more p owerful solving metho ds than the guarded

clauses For example transitivity of the userdened constraint leq can b e sp ecied

by the rule

leqX Y leqY Z true leqX Z

whereas it is not clear how to express this in a oneatomp erhead guarded clause

Adrawbackofhaving multiple atoms however is ineciency In particular it is

not clear whether constraint simplication rules can pro duce incremental in the

sense dened in Section constraintsolvers except in simple cases

A dierentapproach prop oses the intro duction of indexical terms which

refer to asp ects of the state of the constraint solver thus providing a limited form

of reection Constraints containing these terms are called indexical constraints

and from these indexical constraints userdened constraints are built Sp ecically

discusses a language over nite domains which can access the current domain

and upp er and lower b ounds on the value of a variable using the indexical terms

domX maxX andminX resp ectively Indexical constraints have an op era

tional semantics each constraint denes a metho d of propagation For example

the constraint YinmaxX continually enforces the upp er b ound of Y to b e

less than or equal to the upp er b ound of X This same b ehavior can b e obtained

in a nite domain solver with the constraint Y X buttheadvantage of indexical

constraints is that there is greater control over propagation with Y X we also

propagate changes in the lower b ound of Y to X whereas wecanavoid this with

indexical constraints A discussion of an implementation of indexical constraints

is given in One application of this work is a constraint solver for Bo olean

ts we describ e this application in Section constrain

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 prop ositional b eing based up on the col

lection of ground instances of program rules The p erfect mo del

wellfounded mo del stable mo del and Fitting xedp ointsemantics

to name but a few fall into this category The grounding of variables in CLP

rules by all elements of the domain ie by all terms in L and the deletion of

all grounded rules whose constraints evaluate to false pro duces the desired prop o

sitional rules see for example

Other declarativesemantics based on Clarks completion P of the program

also extend to CLP Thecounterpart of compP 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 threevalued logical consequences of T P

and consequences of nite iterations of Fittings op erator as shown by Kunen

continues to hold for CLP programs

SLDNFresolution 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 mo dication is that groundness must b e replaced by

the concept of a variable b eing determined by the current constraints see Section

For example a safe computation rule may select a nonground 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 for a CLP

program requires that every variable either app ear in a p ositive literal in the b o dy

or b e determined by the constraints in the b o dy With these mo dications various

soundness and completeness results for SLDNFresolution and compP extend eas

ily to ideal CLP systems An alternative implementation of negation constructive

negation has b een expanded and applied to CLP programs byStuckey

who gave the rst completeness result for this metho d



This approach has b een called a glassb ox approach



For example the extension to allow arbitrary rstorder formulas in the b o dies of rules

Preferred Solutions

Often it is desirable to express an ordering or preference on solutions to a goal

This can provide a basis for computing only the b est solutions to the query

One approach is to adapt the approach of mathematical programming op erations

research and employ an ob jective function An optimization primitive



is added to the language to compute the optimal value of the ob jective function

CHIP and ccFDhavesuch primitives but they have a nonlogical b ehavior

Tworecent pap ers discuss optimization primitives based up on the following

logical characterization

m is the minimum value of f x suchthatGx holds i

x Gx f xm y Gy f y m

Optimization primitives can b e implemented by a branch and b ound approach

pruning the computation tree of G based on the current minimum A similar

ve logical behavior can b e obtained through constructive negation using the ab o

formulation although a sp ecialpurp ose implementation is more ecient

gives a completeness result for such an implementation based on Kunens

semantics for negation

A second approach is to admit constraints which are not required to b e satised

by a solution but express a preference for solutions which do satisfy them Such

constraints are sometimes called soft constraints The most develop ed use of this ap

proach is in hierarchical constraint logic programming HCLP In HCLP

soft constraints have dierent strengths and the constraints accumulated during a

derivation form a constraint hierarchy based on these strengths There are many

p ossible ways to compare solutions using these constraint hierarchies

dierent metho ds b eing suitable for dierent problems The hierarchy dictates that

anynumber of weak constraints can b e overruled by a stronger constraint Thus

for example default b ehavior can b e expressed in a program byweak constraints

which will b e overruled by stronger constraints when nondefault b ehavior is re

quired The restriction to b est solutions of a constraint hierarchy can b e viewed as

a form of circumscription

Each of the ab ove approaches has some programming advantages over the other

in certain applications but b oth have problems as generalpurp ose metho ds While

the rst approachworks well when there is a natural choice of ob jective function

suggested by the problem in general there is no natural choice The second ap

proach provides a higherlevel expression of preference but it cannot b e so easily

netuned and it can pro duce an exp onential numberofbestanswers if not used

carefully The approaches have the advantages and disadvantages of explicit re

sp ectively implicit representations of preference In the rst approach it can b e

dicult to reect intended preferences In the second approach it is easier to reect

intended preferences but harder to detect inconsistency in these preferences It is

also p ossible to weight soft constraints whichprovides a combination of b oth

approaches



We discuss only minimization maximization is similar

Part I I

Implementation Issues

The main innovation required to implement a CLP system is clearly in the manipu

lation of constraints Thus the main fo cus in this part of the survey is on constraint

solver op erations describ ed in the section b elow 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 constraintdomain

It is imp ortant to note that the algorithms and data structures in this part are

presented in view of their use in topdown systems and in particular systems with

backtracking At the present there is little exp erience in implementing b ottomup

CLP systems and so we do not discuss them here However some of the algorithms

we discuss can b e used p erhaps with mo dication in b ottomup systems

Algorithms for Constraint Solving

In view of the op erational semantics presented in part I there are several op erations

involving constraints to b e implemented These include a satisability test to

implement consistent and inf er anentailment test to implement guarded goals

and the pro jection of the constraintstoreonto a set of variables to compute the

answer constraint from a nal state The constraintsolver must also b e able to

undo the eects of adding constraints when the inference engine backtracks In

this section we discuss the core eciency issues in the implementation of these

op erations

Incrementality

According to the folklore of CLP algorithms for CLP implementations must b e

incremental in order to b e practical However this prescription is not totally sat

isfactory since the term incremental can b e used in two dierent senses On one

hand incremen tality 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

pro cessed in combination with the internal state Such algorithms are sometimes

called online 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 Wedonothowever oer a formal denition of incrementality

We b egin by abstracting away the inference engine from the op erational seman

tics to leave simply the constraint solver and its op erations We consider the state

of the constraint solver to consist of the constraint store C a collection of con

straints G that are to b e entailed and some backtrackpoints In the initial state

denoted by there are no constraints nor backtrack p oints The constraint solver

reacts to a sequence of op erations and results in a a new state and b a resp onse

Recall that the op erations 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 bythe new store

add a new constrainttoG

set a backtrack p oint and asso ciate with it the current state of the system

backtrack to the previous backtrackpoint ie return the state of the system

to that asso ciated with the backtrack p oint

pro ject C onto a xed set of variables

Only the rst and last of these op erations can pro duce a resp onse from the con

straint solver

Consider the application of a sequence of op erations o o on a state denote

k

the up dated state by F o o and the sequence of resp onses to the op erations

k

by G o o In what follows we shall b e concerned with the average cost of

k

computing F and G Using standard denitions this cost is parameterized bythe

distribution of sequences of op erations see for example We use average

cost assuming the true distribution the distribution that reects what o ccurs in

practice Even though this distribution is almost always not known we often have

some hyp otheses ab out it For example one can identify typical and often o ccurring

op eration sequences and hence can approximate the true distribution accordingly

The informal denitions b elow therefore are intended to b e a guide as opp osed to

a formal to ol for cost analysis

AV expo to b e the For an expression expo denoting a function ofo dene

average value of expo over all sequences of op erationso Note that the denition

of average here is also dep endent on the distribution of theo For example let

costo denote the cost of computing F oby some algorithm for each xed

sequenceo ThenAV costo denotes the average cost of computing F oover

all o

Let b e shorthand for F o o Let A denote an algorithm which

k

applies a sequence of op erations on the initial state giving the same resp onse as

do es the constraint solver but not necessarily computing the new state That is A

is the batch or oline version of our constraintsolver In what follows we discuss

what it means for an algorithm to b e incremental relative to some algorithm A

Intuitively A represents the b est available batch algorithm for the op erations

At one extreme we consider that an algorithm for F and G is nonincremental

relativetoA if the average cost of applying an extra op eration o to isnobetter

k

than the cost of the straightforward approach using A on o o We express this

k

as

AV costo AV cost o o

k A k

At the other extreme we consider that an algorithm for F and G is p erfectly

incremen tal relativeto A if its cost is no worse than that of A In other words

no cost is incurred for the incremental nature of the algorithm We express this as

AV cost o o costo AV cost o o

k k A k

In general any algorithm lies somewhere in b etween these two extremes For ex

ample it will not b e p erfectly incremental as indicated by the cost formula ab ove

but instead wehave

costo o AV cost o o costo AV cost o o extr a

k k k A k

where the additional term extr a costo o denotes the extra cost incurred by

k

the online algorithm over the b est batch algorithm Therefore one p ossible den

ition of an incremental algorithm go o d enough for use in a CLP system is simply

that its extr a cost factor is negligible

In what follows we shall tacitly b ear in mind this expression to obtain a rough



denition of incrementality Although wehave dened incrementality for a col

lection of op erations we will review the op erations individually and discuss incre

mentality in isolation This can sometimes b e an oversimplication for example

has shown that the standard unication problem do es not remain linear when

backtracking is considered In general however it is simply to o complex in a

survey article to do otherwise

Satisability Nonincremental

We consider rst the basic problem of determining satisability of constraints in

dep endent of the requirement for incrementalityAswe will see in the brief tour

below of our sample domains the dominant criteria used by system implementers

is not the worstcase time complexity of the algorithm

For the domain FT linear time algorithms are known and for RT the

b est known algorithms are almost linear time Even so most Prolog systems



implement an algorithm for the latter b ecause the bestcase complexity of uni

cation in FT is also linear whereas it is often the case that unication in RT can

b e done without insp ecting all parts of the terms b eing unied Hence in practice

Prolog systems are really implementations of CLPRT rather than CLPFT

In fact many Prolog systems cho ose to use straightforward algorithms whichare

slower in the worst case than these almost linear time algorithms The reason for

er in the worst case is this choice of algorithms which are quadratic time or slow

the b elief that these algorithms are faster on average

For the arithmetic domain of the most straightforward algorithm is

LinE q n

based on Gaussian elimination and this has quadratic worstcase complexityFor

the more general domain p olynomial time algorithms are also known

Lin

but these algorithms are not used in practical CLP systems Instead the Sim

plex algorithm see eg despite its exp onential time worst case complexity

is used as a basis for the algorithm However since the Simplex algorithm

works over nonnegativenumb ers and nonstrict inequalities it must b e extended

for use in CLP systems While such an extension is straightforward in principle

implementations must b e carefully engineered to avoid signicantoverhead The

main dierences b etween the Simplexbased solvers in CLP systems is in the sp e

cic realization of this basic algorithm For example the CLPR system uses a

oatingp oint representation of numb ers whereas the solversofCHIPandProlog

I I I use exact precision rational numb er arithmetic As another example in the

CLPR system a ma jor design decision was to separately deal with equations and



There are similar notions found in the nonCLP literature see the bibliography



This is often realized simply by omitting the o ccurcheck op eration from a standard uni

cation algorithm for FT Some Prolog systems p erform such an omission naivelyandthus obtain

an incomplete algorithm whichmay not terminate in certain cases These cases are considered

pathological and hence are ignored Other systems guarantee termination at slightly higher cost

but enjoy the new feature of cyclic data structures

inequalities enjoying a faster Gaussianelimination based algorithm for equations

but enduring a cost for communication b etween the two kinds of algorithms

Some elements of the CHIP solver are describ ed in Disequality constraints

can b e handled using entailment of the corresp onding equation discussed in Section

since an indep endence of negative constraints holds

For the domain of word equations WE an algorithm is known butno

ecient algorithm is known In fact the general problem though easily provable

to b e NPhard is not known to b e in NP The most ecient algorithm known still

has the basic structure of the Makanin algorithm but uses a far b etter b ound for

termination Systems using word equations Prolog I I I for example thus resort

to partial constraint solving using a standard delaytechnique on the lengths of word

variables Ra jasekars string logic programs also uses a partial solution of

word equations First solutions are found for equations over the lengths of the

word variables app earing in the constraint only then is the word equation solved

As with word equations the satisability problem in nite domains suchasFD

is almost always NPhard Partial constraint solving is once again required and

here is a typical approach Attachtoeachvariable x a data structure representing



domx its current p ossible values Clearly domx should b e a sup erset of the

xandmaxx to b e the smallest and largest pro jection space wrt x Dene min

numb ers in domx resp ectivelyNow assume that every constraint is written in so

that each inequality is of the form xy or x y each disequalityisoftheform

x y andeach equation is of the form x n x y x y z where x y z are

variables and n anumb er Clearly every constraintinFD can b e rewritten into a

conjunction of these constraints

The algorithm considers one constraint at a time and has two main phases

First it p erforms an action which is determined by the form of the constraint a

for constraints x y ensure that minx maxy by mo difying domx andor



domy appropriately b for x y ensure that min x maxy c for

x y consider three sub cases if domx domy then the constraint reduces

to true otherwise if domx fng then remove n from domy and similarly for



the case when domy is a singleton otherwise nothing more need b e done d

for x n simple make domx fng e for x y make domx domy

domx domy f for x y z ensure that maxx miny minz and

minx maxy maxz If at any time during steps a through f the domain

ofavariable b ecomes empty then unsatisability has b een detected The second

phase of this algorithm is that for each x such that domxthatischanged bysome

action in steps a through f all constraints but the current one that gaverise

to this action that contain x are reconsidered for further action Termination is

of course assured simply b ecause the domains are nite

In the domain of Bo olean algebra BOOL there are a varietyoftechniques for

testing satisability Since the problem is NPcomplete none of these can b e ex

p ected to p erform eciently over all constraints An early technique pioneered by



The choice of such a data structure should dep end on the size of the nite domains For

example with small domains a characteristicvector is appropriate



In this case simply removefromdomx all elements bigger than maxy and removefrom

domy all elements smaller than minx We omit the details of similar op erations in the following

discussion



If b oth are singletons clearly the constraint reduces to either true or false

Davis and Putnam is based up on variable elimination The essential idea reduces a

normal form representation into two smaller problems each with one less variable

Binary decision diagrams provide an ecient representation One of the two

Bo olean 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 lo cal propagation simpli

es the conjunction after eachenumeration step See for example The metho d

used in Prolog I I I is a mo dication of SLresolution whose main elementisthe

elimination of redundant expressions Another technique comes from Op erations

Research Here the b o olean formula is restated in arithmetic form with variables

constrained to b e and Then standard techniques for integer programming

for example cuttingplanes can b e used See for a further discussion of this

technique This technique has not b een used in CLP systems A more recentde

velopment is the adaptation of Buchb ergers Gro ebner basis algorithm to Bo olean

algebras which is used in CAL Finally there is the class of algorithms which

p erform b o olean unication see the survey for example Here satisability

testing is only part of the problem addressed and hence we will discuss these algo

rithms 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 numb er of features that may

o ccur is b ounded by a known constant Generally this b ounding constantcan

b e determined at compiletime Two dierent sort constraints on the same variable

clash in the same way that dierent function symb ols on terms in RT clash An

equation b etween t wo 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 o ccurs in RT The main dierence is that some sorts or features maybe

undetermined roughlyunb ound in FEAT

Satisability Incremental

As alluded to ab ove it is crucial that the algorithm that determines the satisability

of a tentatively new constraint store b e incremental For example a lineartime

algorithm for a satisability problem is often as go o d as one can get Consider a

sequence of constraints c c of approximately equal size N A naive application

k

of this lineartime algorithm to decide c then c c and nally c





onaverage In contrast a p erfectly c could incur a cost prop ortional to Nk

k

incremental algorithm as discussed in Section has a cost of O Nk on average

In practice most algorithms represent constraints in some kind of solvedform

a format in which the satisability of the constraints is evident Thus the satis

ability problem is essentially that of reducibilityinto solved form For example

t constraints byonevariantof standard unication algorithms for FT represen

its mgu that is in the form x t y x t y where each t y denotes

n n i

a term structure containing variables fromy and no variable x app ears iny

i

Similarly linear equations in are often represented in parametric form

LinE q n

x le y x le y where each le y denotes a linear expression contain

n n i

ing variables fromy andnovariable x app ears iny In b oth these examples call

i

the x eliminable variables and the y parametric variables For linear inequalities

i i

ts in an n m matrix form in the Simplex algorithm represents the constrain

Lin

Ax B where A contains an n n identity submatrix dening the basis vari

ables and all numb ers in the column vector B are nonnegative For domains based

on a unitary equality theory the standard representation is the mgu as in

the case of FT which corresp onds to the most elementary equality theory Word

equations over WE however are asso ciated with an innitary theoryandthus a

unication algorithm for these equations 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 ab ove are also examples of solution formsthat

is a format in which the set of all solutions of the constraints is evident Here any

instance of the variablesy determines values forx 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 eachchoice of basis variables depicts just one particular

solution

An imp ortant prop erty of solution forms and sometimes of just solved forms

is that they dene a convenient representation of the projection of the solution

space with resp ect to any set of variables More sp ecicallyeachvariable can b e

equated with a substitution expression containing only parametric variables that

is variables whose pro jections are the entire space This prop erty in turn aids

enowshow via our sample domains incrementalityasw

In each of the following examples let C b e a satisable constraintinsolved form

and let c b e 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 in which case C is in Simplex form the substitution expression

Lin

for a variable x is simply x if x is not basic otherwise it is the expression obtain

by writing the unique equation in C containing x with x as the sub ject Once

again this mapping can b e generalized to any linear expression in an obvious way

In summary a solution form denes a mapping which can b e used to map any

expression t into an equivalentformt which is free of eliminable variables

The basic step of a satisability algorithm using a solution form is essentially

this

Algorithm Given C aReplacethenewlyconsideredc onstraint c by c where

is the substitution denedbyC 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 al l occurrences of x in C d Final ly 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 ensurethatC augmented with the new equations remains in solution

form

The b elief that this metho dology leads to an incremental algorithm is based up on

b elieving 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 whichisvery large on average This

in turn is based up on b elieving that

the substitution expressions for the eliminable variables in c which largely

determine the size of c oftenhave a size that is indep endent of the size of

C and

the numb er of o ccurrences of the new eliminable variable x in C which

largely determines the cost of substituting out x in C is small in comparison

to the size of C

The domain FT provides a particularly go o d example of a solved form for whichthe

basic algorithm is incremental Consider a standard implementation in which

there is only one lo cation for eachvariable and all references to x are implemented

by p ointers Given C in solved form and given a new constraint c there is really

nothing to do to obtain c since the eliminable or in this case b ound variables

in c are already p ointers to their substitution expressions Nowifc is satisable

and we obtain the new equations x then just one p ointer setting of x to its

substitution expression is required and we are done In other words the cost of

this p ointerbased algorithm is fo cussed on determining the satisabilityof c and

extracting the new equations in contrast step c of global substitution using the

new equations incurs no cost

For the size of c can b e large even though the nally obtain equations

LinE q n

u v x v w x w uand maynotbeFor example if C contained just x

 

c were y x x x then c is as big as C Up on rearrangement however the

 

nally obtained new equation is simply y Next the substitution phase using

the new equation also can enlarge the equations in C even if temp orarily and

rearrangement is needed in each equation substituted up on In general however

the b eliefs ab ove hold in practice and the algorithm b ehaves incrementally

We next consider the domain RT whose universally used solved form due to

is like that of FT with one imp ortantchange constraints are represented in

the form x t x t where each t is an arbitrary term structure Thus this

n n i

solved form diers from that of FT in that the t can contain the variables x and

i j

hence algorithm is not directly applicable It is easy to show that a constraintis

satisable i it has suchasolved form and further the solved form is fairly explicit

representation of the set of all solutions though not as explicit as the solution

forms for FT or A straightforward satisability algorithm is roughly

LinE q n

as follows Let x stand for a variable and s and t stand for nonvariable terms

Now p erform the following rewrite rules until none are applicable a discard each

x x b for any x y replace x by y throughout c replace t x by x t

d replace f s s f t t n by n equations s t i n

n n i i

e replace f g by false and thus the entire collection of constraints is

unsatisable f replace every pair of equations x t x t and say t is not



bigger than t by x t t t Termination needs to b e argued but we will leave

 

the details to

Wenow discuss algorithms which do not t exactly with Algorithm but which

employa solved form Consider rst the Simplex algorithm for the domain

Lin

The basic step of one pivoting op eration within this algorithm is essentially the same

as Algorithm The arguments for incrementality for Algorithm thus applyThe

main dierence from Algorithm is that in general several pivoting op erations are

required to pro duce the nal solved form However empirical evidence from CLP

systems has shown that often the numberofpivoting op erations is small

In the Bo olean domain Bo olean unication algorithms conform to the

structure of Algorithm One unication algorithm is essentially due to Bo ole and

weborrow the following presentation from Without loss of generality assume

the constraints are of the form tx x where the x are the variables in

n i

t Assuming n rewrite t into the form

g x x x hx x

n n n

so that the problem for t can b e reduced to that of

g x x hx x

n n

whichcontains one less variable If this equation is satisable then the assignment

g x x y x hx x

n n n n

where y is a new variable describ es all the p ossible solutions for x This reduction

n n

clearly can b e rep eatedly applied until we are left with the straightforward problem

of deciding the satisability of equations of the form t x u 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 x ab ove

n

The key eciency problem here is of course that the variable elimination pro cess

gives rise to larger expressions an increase whichisexponential in the number of

eliminated variables in the worst case So even though this algorithm satises

the structure of Algorithm it do es not satisfy our assumption ab out the size of

expressions obtained after substitution and hence our general argument for incre

mentality do es not apply here Despite this and the fact that Bo oles work dates

far back this metho d is still used for example in CHIP

Another unication algorithm is due to Lowenhein and we adapt the presenta

tion of here Let f x x b e the equation considered Leta denote

n

a solution The unier is then simply given by

x y f y y a i n

i i i i

where the y are new variables The basic eciency problem is of course to determine

i

a The obtained uniers are only slightly larger than f incontrast to Bo oles

metho d Thus Lowenheins metho d provides a way of extending a constructive

satisabilitytestinto a satisability test which has an incremental form However

this metho d is not to our knowledge used in CLP languages

Other algorithms for testing the satisability of Bo olean constraints are con

siderably dierent from Algorithm The Gro ebner Basis algorithm pro duces a

basis for the space of Bo olean 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 havea solved form The algorithm used in Prolog I I I

retains the set of literals implied to b e true by the constraints but the normal

form do es not guarantee solvability that must b e tested b eforehand Enumeration

algorithms have the same b ehavior 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 o ccur only b etween variables

Thus Algorithm do es not address the whole problem Existing algorithms

employasolved form in which all implied equations b etween variables are explicit

hsolved forms are in fact solution forms The and there are no clashes of sort Suc

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 imp ortant prop erty for algorithms to decide

satisability is that they have good average case b ehavior More imp ortant 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

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 G of

G of constraints entailed by C cWe will also consider the problem of detecting

groundness which is not strictly sp eaking an entailment problem Howeveritis

essentially the same as the problem of detecting groundness to a sp ecic value

whichisanentailment problem In what follows the distinction is unimp ortant

We next present a ruleofthumb to determine whether an entailment algorithm

is incremental in the sense discussed earlier The imp ortant factor is not the num

b er of constraints entailed after a change in the store but instead the number of

constraints not entailed That is the algorithm must b e able to ignore the latter

ber of entailed con constraints so that the costs incurred dep end only on the num

straints as opp osed to the total numb er of guard constraints As in the case of

incremental satisability the prop erty of incremental entailment is a crucial one

for the implementation of practical CLP systems

Wenow briey discuss mo dications to some of the previously discussed algo

rithms for satisability which provide for incremental entailment

Consider the domain FT and supp ose G contains only guard constraints of the



form x t where t is some ground term Add to a standard implementation of

a unication algorithm an index structure mapping variables x to just those guard

constraints in G whichinvolve x See for a detailed description Now add to

the pro cess of constructing a solved form a check for groundness when variables are

b ound and this is easily detectable This gives rise to an incremental algorithm

b ecause the only guard constraints that are insp ected are those x t for which x

has just b ecome ground and not the entire collection G

Just as with satisability testing entailment is essentially the same over the

domains RT and FEAT Four recentworks have addressed this problem all in the

context of a CLP system but with sligh tly diering constraint domains We will

discuss them all in terms of RT With some mo dications these works can also

apply to FT

In a theoretical foundation is built then prop oses a concrete

algorithm very roughly as follows the tob eentailed 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 c 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 c this entailment test is rep eated with c

instead of c



As mentioned ab ove this discussion will essentially apply to guard constraints of the form

g r oundx

The algorithm of has some similarities to the previous algorithm but avoids

the necessity of undoing op erations Instead op erations that might aect C are

delayed andor p erformed on a sp ecial datastructure separate from C Strong

incrementalityisclaimedifwe replace averagecase complexitybyworstcase com

plexity the algorithm satises our criterion for p erfect incrementality

goesbeyond the problem of entailing equations to give an algorithm for

entailment when b oth equations and disequations are considered constraints

This algorithm has a rather dierent basis than those discussed ab ove it involves

memoization of pairs of terms entailments and disequations and the use of a

reduction of disequation entailmenttoseveral equation entailments

For and let G contain arbitrary equations e Add to the algorithm

LinE q n

which constructs the solved form a representation of eachsuch 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 y z would cause the guard equation y z to b e represented as z

It is easy to show that a guard equation e is entailed i its representation reduces

to the trivial form and similarly the equation is refuted if its representation

is of the form n where n is a nonzero numb er In our example the guard

equation is entailed or refuted just in case z b ecomes ground In order to have

incrementalitywemust argue that the substitution op eration 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 Hence we b elieve our algorithm

is incremental

Wemovenow to the domain but allow only equations in the guard con

Lin

straints G Here we can pro ceed as in the ab ove discussion for to obtain

LinE q n

an incremental algorithm but we will have the further requirementthatthecon



straint store contains all implicit equalities explicitly represented as equations It

is then still easy to show that the entailment of a guard equation e need b e checked

only when the representation of e is trivial The argument for incrementalitygiven

ab ove for essentially holds here provided that the cost of computing im

LinE q n

plicit equalities is suciently low

There are twomainworks on the detection of implicit equalities in CLP systems

over In the existence of implicit equalities is detected by the app earance

Lin

of an equation of a sp ecial kind in the Simplex tableau at the end of the satisability

checking pro cess Such an equation indicates some of the implicit equalities but

more pivoting which in turn can give rise to more sp ecial equations is generally

required to nd all of them An imp ortantcharacteristic of this algorithm is that

the extra cost incurred is prop ortional to the numb er of implicit equalities This

metho d is used in CLPR and Prolog I I I CHIP uses a metho d based on In

this metho d a solved form which is more restrictive than the usual Simplex solved

form is used An equation in this form do es 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 b e rst limited



These are equalities whichareentailed by the store b ecause of the presence of inequalities

For example the constraintstore x y x y entails the implicit equality x y

to variables in the new constraint One added feature of this solved form is that

directly accomo dates strict inequalities and disequations

Next consider still the domain butnow allow inequalities to b e in GHere

Lin

it is not clear how to represent a guard inequalitysay x in suchaway 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 ab ove and using

the same intuition as in the discussion of guard equations we could substitute

out x in x incase x is basic However it is not clear to which formats we

should limit the resulting expression in order to avoid explicitly checking whether



x isentailed Thus an incremental algorithm for checking the entailmentof

inequalities is yet to b e found

For BOOL there seems to b e a similar problem in detecting the entailment

of Bo olean constraints However in the case of groundness entailment some of the

algorithms wehave previously discussed are p otentially incremental The Prolog I I I

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 Gro ebner 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 b e asso ciated 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 constraintisentailed Incrementality

is crucial and this prop erty can b e dened roughly as limiting the cost to dep end on

the numb er of guard constraints aected by eachchange to the store In particular

dealing even briey with the entire collection of guard constraints each time the

store changes is unacceptable

Below in Section an issue related to entailmentistaken up Here wehave

fo cussed on how to adapt the underlying satisability algorithm to b e incremental

for determining entailment There we will consider the generic problem indep endent

of the constraint domain of managing delayed goals whichawake when certain

constraints b ecome entailed

Projection

The problem at hand is to obtain a useful representation of the pro jection of con

straints C wrt a given set of variables More formally the problem is given

target variablesx and constraints C x yinvolving variables fromx andy express

yC x y in the most usable form While we cannot dene usability formallyit

typically means b oth conciseness and readability An imp ortant area of use in the

output phase of a CLP system the desired output from running a goal is the pro

jection of the answer constraints with resp ect to the goal variables Here it is often

useful to have only the target variables output though dep ending on the domain

this is not always p ossible For example the output of x z y z wrt

to x and y should b e x y or some rearrangement of this but it should not

involveany other variable Another area of use is in metaprogramming where a de

scription of the current store maybewanted for further manipulation For example



And this can of course b e done p erhaps even eciently but the crucial p oint is once again

that we cannot aord to do this every time the store changes

pro jecting constraints onto a single variable x can showifx is b ounded and

Lin

if so this b ound can b e used in the program Pro jection also provides the logical

basis for eliminating variables from the accumulated set of constraintsonceitis

known that they will not b e referred to again

There are few general principles that guide the design of pro jection algorithms

across the various constraint domains The primary reason is of course that these

algorithms havetobeintimately related to the domain at hand We therefore will

simply resort to briey mentioning existing approaches for some of our sample

domains

The pro jection problem is particularly simple for the domain FT the result of

pro jection isx x where is the substitution obtained from the solved form

of C Now wehave describ ed ab ove that this solved form is simply the mgu of

C that is equations whose rhs do es not contain anyvariable on the lhs For

example x f y y f z would havethesolved form x f f z y f z

y f z are more eciently stored internally However the equations x f y

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 pro jection of C on

avariable x as required in a printout for example can b e exp onential in the size

of C This happ ens for example if C is of the form x f x x x f x x

 

n

x f a a b ecause x would contain o ccurrences of the constant aA

n

solution would b e to present the several equations equivalenttox x suchas

the n equations in this example This however is a less explicit representation

of the pro jection for example it would not always b e obviousifavariable were

ground

Pro jection in the domain RT can b e done by simply presenting those equations

whose lhs is a target variable and recursively all equations whose lhs app ears

in anything already presented Such a straightforward presentation is in general

not the most compact For example the equation x f f x xfx x is b est

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

For the problem is only slightly more complicated Recall that equa

LinE q n

tions are maintained in parametric form with eliminable and parametric variables

A relatively simple algorithm can b e obtained by using a form of Gaussian elimi

nation and is informally describ ed in Figure It assumes there is some ordering

on variables and ensures that lower priorityvariables are represented in terms of

higher priorityvariables This ordering is arbitrary except for the fact that the

target variables should b e of higher priority than other variables We remark that

a crucial p oint for eciency is that the main lo op in Figure iterates n times and

this numb er the numb er of target variables is often far smaller than the total

number of variables in the system More details on this algorithm can b e found in

For there is a relatively simple pro jection algorithm Assume all inequalities

Lin



C denote the subset of constraints are written in a standard form Let C

x x

C in which x has only p ositive negative co ecients Let C denote those inequal

x

ities in C not containing x at all Wecannow describ e an algorithm due to Fourier

which eliminates a variable x from a given C If constraints c and c havea

p ositive and a negative co ecientofxwe can dene el im c c to b e a linear x

let x x b e the target variables

n

for i i n i i f

if x is a parameter continue

i

let e denote the equation x rhsx athand

i i

if rhsx contains a variable z of lower prioritythanx f

i i

cho ose the z of lowest priority

rewrite the equation e into the form z t

if z is a target variable mark the equation e as nal

substitute t for z in the other equations

g else mark the equation e as nal

g

return all nal equations

Figure Projection Algorithm for Linear Equations



combination of c and c which do es not contain x A Fourier step eliminates x



from a set of constraints C by computing F C fel im c c c C c C g

x x

x x

It is easy to show that xC F C Clearly rep eated applications of F eliminat

x

ing all nontarget variables result in an equivalent set of constraints in whichthe

only variables if any are target variables

The main problem with this algorithm is that the worstcase size of F C

x



is O N where N is the numberofconstraints in C It is in fact precisely

 

j jC j jC j jC j jC j In principle the numb er of constraints jC

x x x x x

needed to describ e C using inequalities over variables varC fxg is far larger

than the numb er of inequalities in C In practice however the Fourier step gen



erates many redundant constraints See for discussion on such redundancy

Work by Cernikov prop osed tests on the generated constraints to detect and

eliminate some redundant constraints The output mo dule of the CLPR system

furthered these ideas as did Imb ert Imb ert also considered the

more general problem in which there are disequations All these redundancy elim

ination metho ds are correct in the following sense if fC g is the sequence of

i i 

constraints generated during the elimination of variables x x from C then

i

C x x C forevery i

i i

The survey contains further p ersp ectives on the Fourier variable elimination

techique It also contains a discussion on how the essential technique of Fourier can

b e adapted to p erform pro jection in other domains such as linear integer constraints

and the b o olean domain

We nish here bymentioning the nonFourier algorithms of In some

circumstances esp ecially when the matrix representing the constraints is dense the

algorithm of can b e far more ecient It is however b elieved that typical CLP

programs pro duce sparse matrices The algorithm of has the advantageous

prop erty that it can pro duce an approximation of the pro jection if the size of the



Obtained for example bymultiplying c bym and c bym where m and m are

the co ecients of x in c and c resp ectively and then adding the resulting equations together



A constraint c C is redundantin C if C C fcg

pro jection is unmanageably large

Backtracking

The issue here is to restore the state of the constraintsolver to a previous state

or at least an equivalent state The most common technique following Prolog is

the trailing of constraints when they are mo died by the constraintsolver and the

restoration of these constraints up on backtracking In Prolog constraints are equa

tions b etween terms represented internally as bindings of variables Since variables



are implemented as p ointers to their b ound values backtracking can b e facili

tated by the simple mechanism of an untagged trail This identies the set

of variables whichhave b een b ound since the last choice p oint Up on backtracking

these variables are simply reset to b ecome unb ound Thus in Prolog the only in

formation to b e trailed is whichvariables have just b ecome b ound and untrailing

simply unbinds these variables

For CLP in general it is necessary to record changes to constraints While in

Prolog a variables expression simply b ecomes more and more instantiated during

forward execution in CLP an expression may b e completely changed from its

original form In for example a variable x mayhave an original linear

LinE q n

form and subsequently another Assuming that a choice p ointisencountered just

b efore the change in x the original linear form needs to b e trailed in case of back

t in fact holds in all our sample domains with tracking This kind of requiremen

the exception of FT and RT Thus wehave our rst requirement on our trailing

mechanism the trail is a value trail that is eachvariable is trailed together with

its asso ciated expression Strictly sp eaking we need to trail constraints rather

than the expression a variable is asso ciated to However constraints are typically

represented internally as an asso ciation b etween 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 p ointbetween the time a variable changes value from one expression to

another A standard technique facilitating this involves the use of time stampsa

variable is always time stamp ed with the time that it last changed value and every

choice p oint is also time stamp ed when created Now just b efore a variables value

is to b e changed its time stamp n is compared with the time stamp m of the most



recentchoice p oint and if n m clearly no trailing is needed

Next consider the use of a crossreference 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 o ccurrences in

the solved form Suc h a structure is particularly useful and can even b e crucial

for eciency in the pro cess of substituting out a parametric variable step c in

algorithm 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 p oint of view a useful approachis

to reconstruct the table up on backtracking The details of such reconstruction are



Recall that this means that eliminable variables are not explicitly dereferenced in the rhs

of the equations in the solved form



In Prolog one can think of the stackpositionofavariable as the time stamp

straightforward but tedious and hence are omitted here see for the case of

the CLPR system A nal remark this reconstruction approach has the added

advantage of incurring cost only when backtracking actually takes place

In summarybacktracking in CLP is substantially more complex than in Prolog

Some useful concepts to b e added to the Prolog machinery are as follows a value

trail and in practice a tagged trail as well b ecause most systems will accommo date

variables of dierenttyp es for example the functor and arithmetic variables in

CLPR time stamps to avoid rep eated trailing for a variable during the lifetime

of the same choice p oint and nally reconstruction of crossreference s rather than

trailing

Inference Engine

This section deals with extensions to the basic inference engine for logic program

ming needed b ecause of constraints What follows contains two main sections In

the rst we consider the problem of an incremental algorithm to manage a col

lection of delayed goals and constraints This problem discussed indep endently of

the particular constraint domain at hand reduces to the problem of determining

which of a given set of guard constraints cf Section are aected as a result of

change to the constraint store The next section discusses extensions to the WAM

in b oth the design of instruction set as well as to the main elements of the runtime

structure Finallywe give a brief discussion of work on parallel implementations

DelayingWakeup of Goals and Constraints

The problem at hand is to determine when a delayed goal is to b e woken or when

a passive constraint b ecomes active The criteria for suchaneventisgiven by

ate the constraint when the a guard constraint that is awaken the goal or activ



guard constraintisentailed by the store In what follows we use shall use the

term delayed constrainttobesynonymous with passive constraint to emphasize the

similarities with delayed goals

The underlying implementation issue as far as the constraintsolver is concerned

is how to eciently pro cess just those guard constraints that are aected as a



result of a new input constraint Sp ecicallytoachieve incrementality the cost of

pro cessing a change to the current collection of guard constraints should b e related

to the guard constraints aected bythechange and not to all the guard constraints

The following two items seem necessary to achievethisend

First is a representation of what further constraints are needed so that a given

guard constraintisentailed For example consider the delayed CLPR constraint

z

pow x y z meaning x y which in general awaits the grounding of twoof

the three variables x y z In constrast the constraint pow yz only awaits the

grounding of y to a nonzero numb er or z to In general a delayed constraintis

awoken by not one but a conjunction of several input constraints When a subset of



For guarded clauses the problem is extended to determining whichclauseistobechosen



However signicantchanges to the inference engine is needed to handle delayed goals and

guarded clauses But these issues are the same as those faced by extending logic programming

systems to implement delayed goals andor guarded clauses see for example

woken $3=# $1=#

$2=# $2=# $1=# $3=#

pow(#,$2,$3) pow($1,#,$3) pow($1,$2,#) $3=0 $3=1 $2=1 $1=0 #<>1 $2=# $1=# $3=# #<>0 #<>0,#<>1

pow($1,$2,$3)

Figure Wakeup system for pow

such input constraints has already b een 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 then a cost prop ortional to the number of entries can b e incurred

even though no guard constraints are aected

The following material is a condensation of

Wakeup Systems For the purp oses of this section we will describ e an

instance of a constraint in the form p C where p is the nary constraint

n

symb ol at hand are distinguished variables used as templates for the

n

arguments of p and C is a constraint which determines the values of

n

wakeup degree represents a subset of the p constraints and a wakeup system A

consists of a set of wakeup degrees and further these degrees are organized into

an automaton where transitions b etween degrees are lab elled by constraints called



wakeup conditions Intuitively a transition o ccurs when a wakeup condition b e

comes entailed by the store There is a distinguished degree called woken which

represents active p constraints We pro ceed now with an example

Consider the CLPR constraint pow x y z and see gure A wakeup degree

maybespeciedby means of constraints containing for describing the



three arguments and some metaconstants for describing unsp ecied



values Thus for example sp ecies that the second argument is ground





These are templates for the guard constraints

Such a metalanguage can also b e used to sp ecify the wakeup conditions Thus for

example the wakeup condition attached to the b ottom



most degree in gure represents a transition of a constraint pow C

 

where C do es not ground into pow C c where C c do es ground

   

into a numb er dierent from and The wakeup condition which represents



a transition to the degree woken represents the fact that pow is an active



constraint equivalentto Similarly represents the transition to the



active constraint Note that there is no wakeup condition b ecause

 

pow which is equivalentto is not

  

active

In general there will b e certain requirements on the structure of suchanau

tomaton to ensure that it do es in fact dene a mapping from p constraints into

wakeup degrees and that this mapping satises certain prop erties like it denes

a partition it maps only active constraints into woken it is consistent with the

wakeup conditions sp ecifying the transitions etc A starting p oint will b e a formal

ization of metalanguage used These formal asp ects are b eyond the scop e of this

survey

In summarywakeup systems are an intuitiveway to sp ecify the organization

of guard constraints The wakeup degrees represent the various dierentcasesofa

delayed constraint which should b e treated dierently for eciency reasons Asso

ciated with each degree is a number of wakeup conditions which sp ecify when an

input constraintchanges the degree of a delayed constraint What is intended is that

eup conditions represent all the situations in which the constraint solver can the wak

eciently up date its knowledge ab out what further constraints are needed to wake

the delayed constraint

Before embarking on the runtime structure to implement delayed constraints

suchaspow we amplify the ab ovementioned p oint ab out the similarities b etween

delayed constraints and guarded clauses Consider the guarded clause program

powXYZ Y X

powXYZ groundX X groundY Y ZlogXlogY

p

Z

powXYZ groundX X groundZ Y X

Z

powXYZ groundY Y groundZ XY

powXYZ X Y Z

powXYZ Z X

powXYZ Z XY

This program could b e compiled into the wakeup system in Figure where the

three intermediate no des reect sub expressions in the guards that mightbeentailed

without the entire guard b eing entailed More precisely several woken no des would

b e used one for each clause b o dy Thus wakeup systems express a central part of

the implementation of at guarded clauses Since a guarded atom can b e viewed as

a oneclause guarded clause program for an anonymous predicate wakeup systems

are also applicable to implementing these constructs

Runtime Structure Here we present an implementational framework in

the context of a given wakeup system There are three ma jor op erations with de

layed goals or delayed constraints which corresp ond to the actions of delaying

awakening and backtracking

adding a goal or delayed constraint to the current collection

awakening a delayed goal or delayed constraint as the result of inputting a

new active constraint and

restoring the entire runtime structure to a previous state that is restor

ing the collection of delayed goals and delayed constraints to some earlier

collection and restoring all auxiliary structures accordingly

In what follows we concentrate on delayed constraints as mentioned ab ove the

constraint solver op erations to handle delayed goals and guarded clauses are essen

tially the same

The rst of our two ma jor structures is a stackcontaining the delayed constraints

Thus implementing op eration simply requires a push op eration Additionally

the stack contains constraints which are newer forms of constraints deep er in the

stack For example if the constraint pow x y z were in the stack and if the input

constraint y were encountered then the new constraint pow x zwould

b e pushed together with a p ointer from the latter to the former In general the

collection of delayed constraints contained in the system is describ ed bythesub

ked constraints whichhavenoinb ound p ointers collection of stac

Now consider op eration In order to implement this eciently it is necessary

to have some access structure mapping an entailed constraint to just those delayed

constraints aected Since there are in general an innite numb er of p ossible en

tailed constraints a nite classication of them is required A guard constraint or

simply guard for short is an instance of a wakeup condition obtained by renam

ing the distinguished argumentvariables into runtime variables It is used as a

i

template for describing the collection of entailed constraints its instances which

aect the same subcollection of delayed constraints For example supp ose that the

only delayed constraintispow yz whose degree is pow with wakeup

 

conditions and Then only two guards need b e considered y

 

and z

Wenow sp ecify an index structure which maps a delayed constraintinto a doubly

linked list of o ccurence no des Eachnodecontains a p ointer to a stack elementcon



taining a delayed constraint Corresp onding to eac h o ccurrence no de is a reverse

p ointer from the stack element to the o ccurrence no de Call the list asso ciated with

adelayed constraint DW a DW list and call eachnodeinthelistaDW occurrence

node

Initially the access structure is empty The following sp ecies what is done for

the basic op erations

Delay Push the constraint C onto the stack and for eachwakeup condition asso

ciated with the degree of C create the corresp onding guard and DW list

All o ccurrence no des here are p ointed to C

Pro cess Entailment Say x isnowentailed Find all guards which are implied

by x Iftherearenonewe are done Otherwise for each DW list

L corresp onding to each of these conditions and for each constraint C

p C p ointed to in L a delete all o ccurrence no des p ointing to C using

C x the reverse p ointers push the new delayed constraint C p



The total numb er of o ccurrence no des is generally larger than the numb er of delayed con

straints

...

x=# y=# z=# #<>0 #<>1 x=0 y=1 #<>0 z=0 z=1 #<>1 pow(y,x,y)

pow(x,y,z)

Figure The index structure

with a downward p ointer to C and nally c construct the new DW lists

corresp onding to C as dened ab ove for the delay op eration

Backtrack Restoring the stack during backtracking is easy b ecause it only re

quires a series of p ops Restoring the list structure however is not so

straightforward b ecause no trailingsaving of the changes was p erformed

In more detail the op eration of backtracking is the following a p op the

stack and let C denote the constraint just p opp ed b Delete all o ccurrence

no des p ointed to by C If there is no p ointer from C and so it was a con

straint that was newly delayed to another constraint deep er in the stack

then nothing more need b e done c If there is a p ointer from C to another

constraint C and so C is the reduced form of C then p erform the mo d

ications to the access structure as though C were b eing pushed onto the

stack These mo dications describ ed ab ove involve computing the guards

p ertinenttoC inserting o ccurrence no des and setting up reverse p ointers

Note that the index structure obtained in backtracking may not b e struc

t however turally the same as that of the previous state What is imp ortan

is that it depicts the same logical structure as that of the previous state

Figure illustrates the entire runtime structure after the two constraints pow x y z

and pow y x y are stored in this order Figure illustrates the structure after a

new input constraint makes x entailed

In summary a stack is used to store delayed constraints and their reduced forms

An access structure maps a nite numb er of guards to lists of delayed constraints

The constraint solver is assumed to identify those conditions whichareentailed

The cost of one primitive op eration on delayed constraints delaying a constraint

upgrading the degree of one delayed constraint including awakening the constraint

and undoing the delayupgrade of one constraint is b ounded by the xed size

...

pow(5,y,z) z=# y=# #<>0 #<>1 x=0 y=1 z=0 z=1 pow(y,5,y) #<>1

pow(y,x,y)

pow(x,y,z)

Figure The index structure after x isentailed

of the underlying wakeup system The total cost of an op eration delaying a new

constraint pro cessing an entailed constraint backtracking on delayed constraints

is prop ortional to the number of the delayed constraints aected by the op eration

Abstract Machine

This section discusses some ma jor issues in the design of an abstract machine for

the execution of CLP programs The primary fo cus here will b e on the design of the

instruction set with emphasis on the interaction b etween their use and information

obtained from a p otential program analyzer Some elements of the runtime structure

will also b e mentioned

In general the essential features of the parts of an abstract machine dealing

with constraints will dier greatly over CLP languages using dierent constraint

domains This is exemplied in the literature on CLPR CHIP and

CLPFD The following presentation though based on one work con

tains material that is relevant to abstract machines for many CLP languages

We b egin by arguing that an abstract machine is the right approach in the rst

place Abstract machines have b een used for implementing programming languages

for many reasons Portability is one only an implementation of the abstract ma

chine needs to b e made available on each platform Another is simply convenience

it is easier to write a native co de compiler if the task is rst reduced to compiling

for an abstract machine that is semantically closer to the source language The b est

abstract machines sit at just the rightpoin t on the sp ectrum b etween the concep

tual clarity of the highlevel source language and the details of the target machine

In doing so they can often b e used to express programs in exactly the right form for

tackling the eciency issues of a source language For example the Warren Abstract

Machine revolutionized the execution of Prolog since translating programs

to the WAM exp osed many opp ortunities for optimization that were not apparent

at the source level The b enet from designing an appropriate abstract machine for

agiven source language can b e so great that even executing the abstract instruc

tion co de byinterpretation can lead to surprisingly ecient implementations of a

language Many commercial Prolog systems compile to WAMlike co de Certainly

more eciency can b e obtained from native co de compilation but the step that

made Prolog usable was that of compiling to the WAM

While the WAM made Prolog practical global analysis shows the p otential of

making another ma jor leap For example and used fairly ecient ana

lyzers to generate high quality native co de Based on certain examples they showed

that the co de qualitywas comparable to that obtained from a C compiler In the

case of CLP the opp ortunities for obtaining valuable information from analysis are

even greater than in Prolog This is b ecause the constraint solving step is in general

far more involved than the unication step

Instructions Next we consider the design of an abstract machine instruc

tion set in addition to the basic instruction set of the WAM While the examples

presented will b e for CLPR the discussions are made for CLP systems in general

More details on this material can obtained from the theses

Our rst requirement is a basic instruction for invoking the constraintsolver

The format can b e of the form

xxx X X X solve

 n

where xxx indicates the kind of constraint and the X denotes the arguments Typi

i

cally these arguments are as in the WAM stack lo cations or registers For example

in CLPR there are instructions of the form initpf n and addpf nXwhere n

isanumb er 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 tothe

parametric form b eing 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 n X n X Then the instruction solve eq tests for

k k

the consistency of exp in conjunction with the store If consistent the solver

adds the equation to the store otherwise backtracking o ccurs There are similar

instructions for inequalities

There are imp ortant sp ecial kinds of constraints that justify making sp ecialized

versions of this basic instruction While there are clearly many kinds of sp ecial cases

some sp ecic to certain constraint domains there are three cases which stand out

the constraint is to b e added to the store but no satisabilitycheck is needed

the constraint need not b e added but its satisability in conjunction with

the store needs to b e checked

the constraint needs to b e added and satisability needs to b e checked but

the constraint is never used later

To exemplify the sp ecial case consider adding the constraintX Y

to the store Supp ose that Y Z is already in the store and that X is a

new variable A direct compilation results in the following Note that the rightmost

column depicts the current state of the accumulator

initpf accumul ator

addpf X accumul ator X

addpf Y accumul ator X Z

solve eq sol v e X Z

A b etter compilation can b e obtained by using a sp ecialized instruction solve no fail eq

X which adds the equation X exp to the store where exp is the expression in

eq is that no satisability the accumulator The main dierence here with solve

check is p erformed For the ab ove example wenowcanhave

initpf accumul ator

addpf Y accumul ator Z

solve no fail eq X add X Z

In summary for this sp ecial case for CLP systems in general we often encounter

constraints which can b e organized into a form such that its consistency with the

store is obvious This typically happ ens when a new variable app ears 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 sp ecial case and the following example CLPR program

sum

sumN X

N

NN

XXN

sumN X

Of concern to us here are constraints that if added to the store can b e shown to

b ecome redundant as a result of future additions to the store This notion of future

redundancy was rst describ ed in Nowifwe execute the goal sumN X using

the second rule ab ove we obtain the subgoal

N N N X X N sumN X

Continuing the execution wenowhavetwochoices cho osing the rst rule we

obtain the new constraint N and cho osing the second rule we obtain the

constraint N among others In each case the original constraint N is

made redundant The main p oint of this example is that the constraint N

in the second rule should b e implemented simply as a test and not added to the

no add xxx constraintstoreWe hence dene the new class of instructions solve

This example shows that future redundant constraints do o ccur in CLP systems

However one apparent diculty with this sp ecial case is the problem of detecting its

o ccurrence We will mention relevantwork on program analysis b elow Meanwhile

we remark that exp eriments using CLPRhaveshown that this sp ecial case leads

to the most substantial eciency gains compared to the other two kinds of sp ecial

cases discussed in this section

Finally consider sp ecial case Of concern here are constraints which are neither

entailed by the store as in case nor are eventually made redundant as in case

but which are required to b e added to the store and checked for consistencyWhat

makes these constraints sp ecial is that after they have b een added to the store and

the store is recomputed into its new internal form their variables app ear in those

parts of the store that are never again referred to Consider the sum program once

again The following sequence of constraints arise from executing the goal sum

X

X X

X X

X X

Up on encountering the second equation X X and simplifying into note

that the variable X will never b e referred to in future Hence equation can b e

deleted Similarly up on encountering the third equation X X and simpli

fying into the variable X will never b e referred to in future and so can b e

deleted In short only one equation involving X need b e stored at any p ointinthe

and delete computation We hence add the class of instructions of the form add

X which informs the solver that after considering the constraint asso ciated to Xit

may delete all structures asso ciated to X In CLPR the corresp onding instruc

and delete nXtheobvious variant of the previously describ ed tion is addpf

instruction addpf nX Compiling this sum example gives

init pf

addpf X

solve no fail eq X

init pf

addpf and delete X

solve no fail eq X

init pf

addpf and delete X

solve no fail eq X

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 b e unrolled

to pro duce the most ecient co de The main challenge for this sp ecial case is as in

sp ecial case the detection of the sp ecial constraints Wenow address this issue

Techniques for CLP Program Analysis The kinds of program analysis

required to utilize the sp ecialized instructions include those techniques develop ed

for Prolog most prominently detecting sp ecial cases of unication and determin

istic predicates Algorithms for such analysis have b ecome familiar see

for example See for example for a description of how to extend the general

techniques of abstract interpretation applicable in LP to CLP Our considerations

ab ove however require rather sp ecic kinds of analyses

Detecting redundantvariables and future redundant constraints can in fact b e

done without dataow analysis One simple metho d involves unfolding the predi

cate denition and typically once is enough and then in the case of detecting

redundantvariables simply insp ecting where variables o ccur last in the unfolded

denitions For detecting a future redundant constraint the essential step is de

termining whether the constraints in an unfolded predicate denition imply the

constraint b eing analyzed

An early work describing these kinds of optimizations is and some further

discussion can also b e found in The latter rst describ ed the abstract ma

chine CLAM for CLPR and the former rst dened and examined the problem

of our sp ecial case that of detecting and exploiting the existence of future redun

dant constraints in CLPR More recently rep orted new algorithms for the

problem of sp ecial case that of detecting redundantvariables in CLPR The

work describ es in a more general setting a collection of techniques entitled

renement removal and reordering for optimization in CLP systems See also

for an overview of the status of CLPR optimization and for detailed

empirical results

Despite the p otential of optimization as rep orted in these works the lack of full

implementations leaves op en the practicality of using these and other sophisticated

optimization techniques for CLP systems in general

Runtime Structure A CLP abstract machine requires the same basic

runtime supp ort as the WAM Some data structures needed are a routine extension

of those for the WAM the usual register stack heap and trail organization

The main new structures p ertain to the solver Variables involved in constraints

typically haveasolver identier which is used to refer to that variables lo cation

in the solver data structures

The mo dications to the basic WAM architecture typically would b e

Solver identiers

It is often necessary to haveaway to index from a variable to the constraints

it is involved in Since the WAM structure provides stack lo cations for the

dynamically created variables it remains just to haveatagandvalue struc

ture to resp ectively a identify the variable as a solver variable and b

access the constraints asso ciated with this variable Note that the basic

unication algorithm assuming functors are used in the constraint system

needs to b e augmented to deal with this new typ e

Taggedtrail

As mentioned in Section the trail in the WAM merely consists of a

stack of addresses to b e reset on backtracking In CLP systems in general

the trail is also used to store changes to constraints Hence a tagged value

trail is required The tags sp ecify what op eration is to b e reversed and the

value comp onent if present contains any old data to b e restored

Timestamped data structures

Time stamps have b een briey discussed in Section The basic idea

here is that the data structure representing a constraintmay go through

several changes without there b eing a new choice p oint encountered during

this activity Clearly only one state of the structure need b e trailed for each

choice p oint

Constraint accumulator

A constraintistypically built up using a basic instruction rep eatedly for

example the addpf instruction in CLPR During this pro cess 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

Paral lel Implementations

We briey outline the main works involving CLP and parallelism The opp ortunities

for parallelism in CLP languages are those that arise and have already b een ad

dressed in the logic programming context such as orparallelism andparallelism

streamparallelism and those that arise b ecause of the presence of a p otentially

computationally costly constraintsolver

The rst work in this area was an exp erimental implementation of an or

parallel for a CLP language with domain FD That approach has b een pursued

with the development of the ElipSys system which is the most develop ed of

the parallel implementations of CLP languages

Atay presents the orparallelization of LP a language that computes

with linear inequalities over reals and integers but in which rules do not have



lo cal variables Another work deals with the orparallel implementation of a CLP

language over FD on massively parallel SIMD computers However the basis

for the parallelism is not the nondeterministic choice of rules as in conventional

LP orparallelism but the nondeterministic choice of values for a variable

Work on andparallelism in logic programming dep ends heavily on notions of

indep endence of atoms in a goal addresses this notion in a CLP context

and identify notions of indep endence for constraint solvers whichmust hold if the

advantages of andparallelism in LP are to b e fully realized in CLP languages

However there has not to our knowledge b een an y attempt to pro duce an and

parallel implementation of a CLP language

Twoworks address b oth streamparallelism and parallelism in constraint solving

GDCC is a committedchoice language that can b e crudely characterized as a

committedchoice version of CAL It uses constraints over domains of nite trees

Bo oleans real numb ers and integers mainly discusses the parallelization of the

Gro ebner basis algorithms which are the core of the solversfortherealnumb er and

Bo olean constraint domains and a parallel branchandb ound metho d that is used

in the integer solver Leung addresses the incorp oration of constraint solving

in b oth a committedchoice language and a language based on the Andorra mo del

of computation He presents distributed solvers for nite domains the Bo olean

domain and linear inequalities over the reals The nite domain solver is based on

the solver for the reals parallelizes the Simplex algorithm and the Bo olean

solver parallelizes the unication algorithm of

Finally rep orts the design and initial implementationofCLPR with

an execution mo del in which the inference engine and constraint solver compute

concurrently and asynchronously One of the issues addressed is backtracking which

is dicult when the engine and solver are so lo osely coupled



Wesaythatavariable in a rule is local if it app ears in the b o dy of the rule but not in the head

Part I I I

Programming and Applications

In this nal part we discuss the practical use of CLP languages The format here

is essentially a selected list of successful applications across a variety of problem

domains Each application is given an overview with emphasis on the particular

and CLP features used

It seems useful to classify CLP applications broadly into two classes In one class

the essential CLP technique is to use constraints and rules to obtain a transparent

representation of the relationships underlying the problem Here the constraints

also provideapowerful query language The other class caters for the many prob

lems which can b e solved byenumeration algorithms the combinatorial search

problems Here the LP asp ect of CLP is useful for providing the enumeration facil

ity while constraints servetokeep the search space manageable

Mo delling of Complex Problems

We consider here the use of CLP as a sp ecication language constraints allow

the declarativeinterpretation of basic relationships and rules combine these for

complex relationships

Analysis and Synthesis of AnalogCircuits

This presentation is adapted from an early application of CLPR Brieythe

general metho dology for representing prop erties of circuits are that constraints at a

base level describ e the relationship b etween variables corresp onding to a subsystem

such as Ohms law and constraints at a higher level describ e the interaction b etween

these subsystems such as Kircho s law

Consider the following program fragment dening the pro cedure circuitN V

the p otential dierence and I which sp ecies that across an electrical network N

current are V and I resp ectively The network is sp ecied in an obvious waybya

term containing the functors resistor series and parallel In this program

the rst rule states the required voltagecurrent relationship for a resistor and the

remaining rules combine such relationships in a network of resistors

circuitresistorRVIVI R

circuitseriesN N V I

I I

I I

V V V

circuitN V I

circuitN V I

circuitparallelNNVI

V V V V

I I I

circuitN V I

circuitN V I

For example the query

circuitseriesseriesresistorRresistorRresistorRV

asks for the voltage value if a currentvalue of is owing through a network

containing just three identical resistors in series The answer is R V

Additional rules can b e added for other devices For example the piecewise linear

mo del of a dio de describ ed by the voltagecurrent relationship

V if V

V if V

I

V if V

is captured by the rules

circuitdiode V V V

circuitdiode V V V V

circuitdiode V V V

This basic idea can b e extended to mo del AC networks For example supp ose we

wish to reason ab out an RLC network in steadystate First we disp ense with

bers by representing X iY as a CLPR term cX Y and use complex num

c equalcRe Im cRe Im

c addcRe Im cRe Im cRe Re Im Im

c multcRe Im cRe Im cRe Im

Re Re Re Im Im

Im Re Im Re Im

to implement the basic complex arithmetic op erations of equality addition and

multiplication

Now consider the following pro cedure circuitN V I W whichislikeits

namesakeabove except that the voltage and currentvalues are now complex num

b ers and the new parameter W a real numb er is the angular frequency It is note

worthy that this signicant extension of the previous program fragmentfor circuit

has b een obtained so easily

circuitresistorRVIWcmultV I cR

circuitinductorLVIWcmultV I c W L

circuitcapacitorC V I W c multV I c W C

circuitseriesN N V I W

c equalI I c equalI I

c addV V V

circuitN V I W

circuitN V I W

circuitparallelNNVIW

c equalV V c equalV V

addI I I c

V V V V

I I I

circuitN V I W

circuitN V I W

We close this example application bymentioning that the work in notonly

contains further explanation of the ab ovetechnique but also addresses other prob

lems suchasthesynthesis of networks and digital signal ow Not only do es the

CLP approach provide a concise framework for mo delling circuits previously done

in a more adho c manner but it also provides additionality functionality b ecause

relationships as opp osed to values are reasoned ab out Evidence that this approach

can b e practical was given for example the mo delling can b e executed at the rate

of ab out a hundred circuit comp onents p er second on a RS workstation

Options Trading Analysis

Options are contracts whose value is contingent up on the value of some underlying

asset The most common typ e of option are those on company shares A cal l option

gives the holder the righttobuyaxednumb er of shares at a xed exercise price

until a certain maturityexpiration date Converselyaput option gives the holder

the right to sell at a xed price The option itself may b e b ought or sold For

example consider a call option costing which gives the righttopurchase

shares at p er share within some p erio d of time This call option can b e sold at

the current market price or exercised at a cost of Nowifthepriceofthe

share is then the option may b e exercised to obtain a prot of p er share

taking the price of the option into account the net gain is After the sp ecied

p erio d the call option if not exercised b ecomes worthless Figure shows payo

diagrams which are a simple mo del of the relationship b etween the value of a call

option and the share price Sell options have similar diagrams Note that c denotes

the cost of the option and x the exercise price

Options can b e combined in arbitrary ways to form articial nancial instru

mentsThisallows one to tailor risk and return in exible ways For example the

buttery strategy in gure consists of buying two calls one at a lower strike price

x and one at a higher price z and selling two calls at the middle strike price y This

makes a prot if the share stays around the middle strike price and limits the loss

if the movement is large

Payoff Payoff Payoff

c

x Stock Stock Stock Price x Price Price x y z

c

Buy a Call Sell a Call Butterfly

Figure Payo Diagrams

The following presentation is due to Yap based in his work using CLPR

This material app eared in and the subsequently implemented OTAS system

is describ ed in There are several main reasons why CLP and CLPRin

particular are suitable for reasoning ab out option trading there are complex trad

ing strategies used which are usually formulated as rules there is a combinatorial

asp ect to the problem as there are manyways of combining options a combination

of symb olic and numeric computation is involved there are well develop ed math

ematical valuation mo dels and constraints on the relationships involved in option

pricing and nally exible whatif typ e analysis is required

A simple mathematical mo del of valuing options and other nancial instruments

suchasstocks and b onds is with linear piecewise functions Let the heavyside

function h and the ramp function r b e dened as follows

if x y if x y

hx y and r x y

otherwise y x otherwise

The payo function for call and put options can now b e describ ed by the following

matrix pro duct which creates a linear piecewise function

hb s

hb s



h r r payo h

 

r b s

r b s



where s is the share price b is either the strike price or and h and r are

i i i

multipliers of the heavyside and ramp functions In the following program the

variables S X R resp ectively denote the sto ck price the exercise price and the

interest rate

hX Y Z Y X Z

hX Y Z Y X Z

rX Y Z Y X Z

rX Y Z Y X Z Y X

valueType Buy or Sell S C P R X B Payoff

signBuy or Sell Sign

dataType S C P R X B B B H H R R

hB S T hB S T rB S T rB S T

Payoff SignHT HT RT RT

The parameters for the piecewise functions can b e expressed symb olically in the

following tables implemented simply as CLP facts

signbuy

signsell

datastock S C P R X B SR

datacall S C P R X B X CR

dataput S C P R X B X PRX

databond S C P R X B BR

This program forms the basis for evaluating option combinations The following



direct query evaluates the sale of a call option that expires inthemoney

Call X R S

RX Payoff valuecall sell S Call

giving the answer Payoff More general queries make use of the ability

to reason with inequalities We can ask for what share price do es the value exceed

Payoff C X R S

valuecall sell S C RX Payoff



The answer constraints returned illustrates the piecewise nature of the mo del

Payoff S

Payoff S S S

More complex combinations can b e constructed by comp osing them out of the base

nancial instruments and linking them together with constraints For example the



That is when the strike price is less than the share price



We will use to separate dierent sets of answer constraints in the output

following is a combination of two calls and two puts

R Payoff Payoff Payoff Payoff Payoff

P K valueput sell S P R K Payoff

P K valueput buy S P R K Payoff

C K valuecall buy S C RK Payoff

C K valuecall sell S C RK Payoff

The answer obtained illustrates howcombinations of options can b e tailored to

pro duce a custom linear piecewise payo function

Payoff S

Payoff S S S

Payoff S S

Payoff S S S

Payoff S

The ab ove is just a brief overview of the core ideas b ehind the work in

Amongst the imp ortant asp ects that are omitted are consideration of option pricing

mo dels and details of implementing the decision supp ort system OTAS As in

the circuit mo delling application describ ed ab ove the advantages of using CLPR

here are that the program is concise and that the query language is expressive

Temporal Reasoning

It is natural and common to mo del time as an arithmetic domain and indeed we

do this in everyday life Dep ending up on the application a discrete representation

such as the integers or a continuous representation such as the reals maybe

appropriate and varying amounts of the arithmetic signature are needed for ex

ample we might use only the ordering or use only a successor function In this

brief discussion we assume that time is linearly ordered although this is not a

universally accepted choice

Temp oral logic is often used as a language for expressing timerelated con

cepts Temp oral logic adds to standard rstorder logic such constructs as next



meaning roughly in the next time instant always meaning in every future

time instant and sometime meaning in some future time instant The lan

guage Templog was designed based on a Hornlike subset of temp oral logic in

which the meaning of function symb ols do es not vary with time but the meaning

of predicate symb ols do es It was shown in that the op erational b ehavior of

Templog could b e mimicked by a CLP language via the following natural transla

tion every predicate receives another argument representing time Then at time

t next is represented by t t and the future for always and sometimeis

represented by t t In later work Brzoska has presented a more p owerful

temp oral logic language which also can b e viewed as and implemented through a

CLP language

Often we wish to manipulate the time parameter more directly than is p ossible in

conventional temp oral logic For example wemay wish to express durations as well

as times We can do this if we include in the signature of our domain mo delling



We assume that time is mo delled by the integers

time This is used in applications to scheduling among others as discussed in

section

The use of simple constraint domains to mo del time has b een explored exten

sively in the context of temp oral databases In this situation an item of data might

incorp orate the time interval for whichitisvalid Simple domains have b een con

sidered b ecause of overriding requirements for quick and terminating execution of

queries as discussed in section Furthermore often the restriction is made that

only one or two arguments in a tuple are timevalued with the other arguments

taking constantvalues surveys work in this area using an integer mo del of

time

Combinatorial Search Problems

CLP oers an easy realization of enumeration algorithms for the solving of com

binatorial problems Given decision variables x x one uses a CLP program

n

schema of the form

solveX Xn

constraintsX Xn

enumerateX Xn

to implement a constrainandgenerate enumeration strategy also called implicit

enumeration as opp osed to naiveenumerateandtest strategy to curtail the search

space We refer to the basic text chapter for further intro ductory material

to this CLP approach

The ab oveschema is used to represent the set of all solutions to the constraints

Often one desires an optimal solution according to some criteria say the solu

tion a a to x x that minimizes some giv en function costx x

n n n

The simplest strategy to obtain this solution is simply to obtain and check each

and every solution of solve An easy improvement is obtained by augmenting the

search with a branchandbound strategy Briey the cost of the b est solution en

countered so far is stored and the continuing search is constrained to nd only

new solutions of b etter cost More concretely CLP systems typically provide predi

cates suchasminimizesolveX Xn Cost BestCost and similarly

maximize where solveX Xn Cost serves to obtain one solution

as explained ab ove with cost CostandBestCost is a numb er representing the

cost of the b est solution found so far Initiallythisnumber can be any suciently

large numb er It is assumed here that the pro cedure solveX Xn Cost

maintains a lower b ound for a variable Costwhich is computed as the values of the

decision variables are determined The minimize pro cedure then essentially b ehaves

as a rep eated invo cation of the goal Cost BestCost solveX Xn

Cost In general the choice of a suitable cost function can b e dicult Finallywe

refer the reader to the text section for more a detailed explanation of

howbranchandb ound is used in CLP systems

ypically nite since the enumer The constraint domain at hand is discrete and t

ation must cover all candidate values for the sequence x x and therefore

n

constraint solving is almost always NPhard This in turn restricts implementa

tions to the use of partial solvers that is not all constraints will b e considered

active Recall that partial solvers are however required to b e conservativeinthe

sense that whenever unsatisability is rep orted the tested constraints are indeed

unsatisable

In general the primary eciency issues are

How complete is the constraintsolver In general there is tradeo b etween

the larger cost of a more complete solver and the smaller search space that

suchasolver can give rise to

What constraints to use to mo del the problem A sp ecial 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 redundantcon

straints will slowdown a CLP system with a complete solver With partial

solvers however redundant constraints may b e useful to the solver in case

the equivalent information in the constraint store is not active

In which order do wecho ose the decision variables for enumeration And

should such order b e dynamically determined

In which order do weenumerate the values for a given decision variable

And should such order b e dynamically determined

In this section we will outline a numb er of CLP applications in sp ecic combina

torial problem areas In each subsection b elow unless otherwise sp ecied weshall

assume that the underlying constraint system is based on the integers

Cutting Stock

The following describ es a twodimensional cutting sto ck problem p ertaining to fur

niture manufacturing an early application of CHIP We are givenasawing

ood into a numb er of dierent sized shelves The machine which cuts a b oard of w

machine is able to cut in several congurations eachofwhich determines the num

ber of each kind of shelf and some amountofwood wasted Let there b e N dierent

kinds of shelves and M dierent congurations Let S i M j N

ij

denote the numb er of shelves j cut in conguration iLetW i M denote

i

the wastage in conguration i Let R i N denote the number of shelves i

i

required The problem now can b e stated as nding the congurations suchthat

the required numb er of shelves are obtained and the wastage minimized

In there were kinds of shelves congurations and the number of

b oards to b e cut was xed at Two solutions were then presented whichwenow

paraphrase

Let X i denote the numb er of b oards cut according to conguration i

i

Thus X X The requirements on the numb er of shelves are expressed



via the constraints X S X S for j N The ob jective

j  j

function to b e minimized is X W X W The straightforward program

 

representation of all this is given b elow The enumerate pro cedure has the range

f g Note that solve is run rep eatedly in the search for the solution of lowest

Cost

solveX X Cost



X X



S R X S X

 

X S X S R

   

X S X S R

   

Cost X W X W

 

enumerateX X



The second solution uses the sp ecial CHIP constraint element describ ed ab ovein

th

section Recall that elementX List E expresses that the X elementof

List is E In this second approach to the problem the variables X i

i

denote the congurations chosen Thus X Let T i j

i ij

denote the number of shelves j in conguration iLet Cost i denote

i

the wastage in conguration X Thus the required shelves are obtained by the

i

constraints T T R where j and the total cost is simply

j j j

Cost C ost



In program b elow the constraints X X X X serve to eliminate con

  

sideration of symmetrical solutions The following group of element constraints

serve to compute the T variables in terms of the given S values and the com

ij ij

puted X values The next group of element constraints computes the Cost

i i

variables in terms of the given W variables The enumerate pro cedure has the

i

range f g Once again solve is run rep eatedly here in the search for the

lowest Cost

solveX X Cost



X X X X X X

    

elementX S S T j

j j j

elementX S S T

 j j j

elementX S S T

 j j j

elementX S S T

 j j j

elementX W W Cost



elementX W W Cost

  

elementX W W Cost

  

elementX W W Cost

  

T T T T R j

j j j j i

Cost Cost Cost Cost Cost

  

enumerateX XXX

  

The second program has advantages over the rst Apart from a smaller searchspace



in comparison with it was able to avoid encountering approximately

symmetrical solutions The timings given in showed that the second program

ran much faster This comparison exemplies the ab ovementioned fact that the way

a problem is mo delled can greatly aect eciency

DNA Sequencing

We consider a simplied version of the problem of restriction site mapping RSM

Briey a DNA sequence is a nite string over the letters fA C G T g and a restric

tion enzyme partitions a DNA sequence into certain fragments The problem is then

to reconstruct the original DNA sequence from the fragments and other information

obtained through exp eriments In what follows we consider an abstraction of this

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 A A and the second into B B Now a simultaneous use of

N M

the two enzymes also pro duces a partition D D corresp onding to combining

K

the previous two partitions That is

ij A A D D and ij B B D D and conversely

i j i j

j i D D A A D D B B

j i j i

Let a denote the length of A similarly for b and d Leta denote the subsequence

i i i i i

a a i N Similarly dene b and d The problem at hand nowcan

i i i

b e stated as given the multisets a fa a g b fb b g and d

N M

b b and fd d g construct the sequences a a a b

M K N N M

d d d

K K

Our basic algorithm generates d d in order and extends the partitions for



a and b using the following invariant prop ertywhich can b e obtained from the

problem denition ab ove Either

d is aligned with a that is d d a a or

k i k i



d is aligned with b but not with a that is d d b b

k j i k j

In the program b elow the main pro cedure solve takes as input three lists repre

b and d in the rst three arguments and outputs in the remaining three sentinga

arguments Enumeration is done bycho osing at each recursive step of the rsm

pro cedure one of two cases mentioned ab ove Hence the two rules for rsmNote

that the three middle arguments of rsm maintains the length of the subsequences

found so far and in all calls either lenA lenD lenB or lenB lenD lenA

holds the pro cedure choose initial cho oses the rst fragment and makes the

rst call to rsm with this invariant holding Finally the pro cedure choose deletes

some element from the given list and returns the resultant list Note that one more

rule for rsm is needed in case the A and B fragments do align anywhere except at

the extreme ends wehave omitted this p ossibility for simplicity

solveA B D AFragMapA BFragMapB DFragMapD

choose initialA B D AFrag BFrag DFrag A B D

rsmA B D AFrag BFrag DFrag MapA MapB MapD

rsmA B D LenA LenB LenD MapA MapB MapD

emptyA emptyB emptyD

MapA MapB MapD

rsmA B D LenA LenB LenD AiMapA MapB DkMapD

LenA LenD LenA LenB

Dk LenB LenA Ai Dk

chooseDk D D

chooseAi A A

rsmA B D LenA Ai LenB LenD Dk MapA MapB MapD

rsmA B D LenA LenB LenD MapA BjMapB DkMapD

LenB LenD LenB LenA



For simplicitywe assume that wenever have all three partitions aligned except at the b eginning and at the end

Dk LenA LenB Bj Dk

chooseDk D D

chooseBj B B

rsmA B D LenA LenB Bj LenD Dk MapA MapB MapD

This application of CLP is due to Yap and it is imp ortant to note that the

ab ove program is a considerable simplication of Yaps program A ma jor omission

is the consideration of errors in the fragment lengths b ecause these lengths are

obtained from exp erimentation A ma jor p ointinYaps approachisthatitgives

a robust and uniform treatment of the exp erimental errors inherent in the data

as compared with many of the approaches in the literature Furthermore

shows how the simple two enzyme problem can b e extended to a numb er 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 imp ortant as the computational

problem of just computing a consistent map is intractable and hence when dealing

with any substantial amount of data would havetotakeinto accountdatafrom

manyvarieties of mapping exp eriments as well as other information sp ecic to the

molecule in question

Scheduling

In this class of problems we are given a numb er of tasks and for each task a

task duration Each task also requires other resources to b e p erformed and there

are constraints on precedences of task p erformance and on resource usage The

problem is to schedule the tasks so that the resources are most eciently used for

example p erform the tasks so that all are done as so on as p ossible

Consider now a basic jobshop scheduling problem in whichisgiven a number m

of machines j sequences of tasks the task durations and the machine assigned to

tsarethatthetasksineach sequence called each task The precedence constrain

a job are p erformed in the sequence order The resource constraints are that each

machine p erforms at most one task at anygiven time

In the program b elow 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 pro cedure resources is called

rep eatedly once for each pair of tasks T and T whichmust p erformed without



overlapping their durations are given by D and D



precedencesT T Tail D D Tail

 

T D T



precedencesTail Tail

precedences

resourcesT DTDT D T

  

resourcesT DTDT D T

   

A simple wa y to pro ceed is to x an ordering of the tasks p erformed on eachma

chine This corresp onds to cho osing one of the two resources rules for eachpair

of tasks assigned to the same machine This forms the basis of the enumerate pro

cedure b elow Once an ordering of tasks is xed it is a simple matter to determine

the b est start times for each task

This can b e done in the manner indicated in the solve pro cedure b elow An

imp ortant eciency p ointisthatbycho osing a precedence b etween two tasks the

new constraints created by the use of resources in conjunction with the precedence

constraints can reduce the numb er of p ossible choices for the remaining pairs

We assume that the pro cedure define cost denes Cost in suchaway that in

conjunction with other constraints it provides a conservativelowerboundofthe

real cost of the schedule determined so far Its precise denition omitted here can

b e obtained in a similar way as in the second program of the cuttingsto ck example

ab ove

solveT T T Cost

 n

precedences one per job

precedences

costT T T Cost define

 n

enumerateT T T

 n

generate start timesT T T

 n

enumerateT T T

 n

resources one per pair of tasks assigned to same machine

resources

Finally this solve pro cedure can b e rep eatedly run within a branchandb ound

framework with a sp ecial minimize predicate mechanism as explained ab ove to

obtain the b est solution over all p ossible orderings

In this presentation of the program wehavechosen to simply list all calls to

precedences in the pro cedure solve to fo cus on the imp ortant pro cedures in

the program A real program would use an auxilliary predicate to iterate over the

jobs and generate the calls to precedences Similarly enumerate would iterate

to generate calls to resourcesThus the program would b e indep endentofthe

numb er of jobs or the pattern in which tasks are assigned to machines Similar

comments apply to other programs in this section

There are variations and sp ecializations of CLP approaches to this problem Sec

tion of and section of on which this presentation is based further

discuss the problem and how particular features of CHIP can b e useful Another

CHIP approach but this time to a sp ecic and practical scheduling problem is

rep orted in In the fo cus is on a new feature of CHIP and how it can b e

used to obtain an optimal solution to a particular jobs and machine problem

which remained op en until recently

Real scheduling problems can involve more kinds of constraints than just those

men tioned ab ove For example one could require that there is at most a certain time

elapsed b etween the completion of one task and the commencement of another See

for a more complete discussion of the CLP approach to the general scheduling problem

Chemical Hypothetical Reasoning

This Prolog I I I application describ ed in some detail in uses b oth arithmetic

and b o olean constraints The problem at hand is that of elucidating chemical

reaction pathways and we quote given an instantiation of the tworeagent

reaction schema A B  T P P determine the pathway that is the set

k

of constituent reaction stepsaswell as other molecules or species formed during

the reaction

The reaction step considered in contains at most two reactant molecules

and at most two pro duct molecules and so can b e describ ed in the form R

R P P where R R P P are p ossibly empty molecular formulas The

   

problem then is to determine given an overall reaction a collection of basic steps or

pathway which explain the overall reaction For example given C H N CH 



C H N H O the following is a pathwaywhich explains the reaction

 

C H N H O C H N



C H N C H N C H N

 

C H N C H N C H N C H N

  

Here C H N and C H N are the previously unidentied sp ecies

 

ts to express requirements for a chemical reaction The program imp oses constrain

and to exclude uninteresting reactions In addition to the constraints on the number

of molecules there are two other constraints on reaction steps for eachchemical

element the numb er of reactant atoms equals the numb er of pro duct atoms ie

the step is chemical ly balanced and no molecular formula app ears in b oth sides of

a step

There are also constraints on the pathway Let the reaction schema under con

sideration b e A B  T P P Then

k

All pathway sp ecies must b e formable from the tworeagents A and B

Neither A nor B alone is sucient to form the target pro duct T Here b o olean

variables are used to express the dep endency relation can b e formed from

For each pathway step R R P P we state the b o olean constraint

 

a a a a where a a a a are b o olean variables asso ciated with

     

R R P P resp ectively The constraint expresses that b oth P and P

  

can b e formed if b oth R and R can b e formed Let B denote the b o olean



formulas thus constructed over all the steps in a pathway Then expressing

that sp ecies R do es not by itself pro duce sp ecies P is tantamounttothe

satisability of the b o olean constraint Ba a where a and a

R P R P

are the b o olean variables asso ciated with R and P resp ectively Since we

havetwo original reagents we will need two sets of b o olean variables and

oid anyinterference b etween the two sets of dep endency constraints to av

two conditions

There is a notion of pathway consistency which is dened to b e the satis

ability of a certain arithmetic formula constructed from the o ccurrences of

sp ecies in the pathway Essentially this formula is a conjunction of formulas

n n n n for each pathwaystep R R P P where

    

n n are the arithmetic variables of R R P P resp ectively

  

Finally in the ultimate output of the program no two pathways are identical

nor b ecome identical under transformations suchaspermuting the reactants

or pro ducts within a step or switching the reactants and pro ducts in a step

The program representation of a molecular formula is as a list of numb ers each

of which sp ecies the numb er of atoms of a certain chemical element Weshall

assume that there are only four chemical elements of interest in our presentation

and hence a molecular formula is a tuple A sp ecies is also represented bya

tuple n a b f where n is an arithmetic variable to b e used in the formulation

of the arithmetic formula mentioned ab ove a and b are b o olean variables to b e

used in expressing the formation dep endencies and f is the sp ecies formula A

step R R P P is represented by a tuple r r p p containing the

   

identiers of the representations of R R P and P

 

The listing b elow is simplied and translated version of the Prolog I I I program

in In the main pro cedure solve the rst argument is a list of xed size say n

in whicheach element is a sp ecies template The rst three templates are given and

these represent the two initial reagents R R and nal target T Similarly Steps



is a list of xed size say minwhicheach element is a step template Thus n and

of obtains m are parameters to the program The undened pro cedure formula

the sp ecies formula from a sp ecies that is it pro jects onto the last elementofthe

given tuple Similarly arith var of bool var a of and bool var b of pro ject

onto the rst second and third arguments resp ectively

duplicates asserts constraints which prevent duplicate sp ecies The pro cedure no

and steps and it also prevents symmetrical solutions we omit the details Calls to

the pro cedure formation dependencies generate the formation dep endencies The

pro cedure both reagents needed imp oses two constraints one for each reagent

that in conjunction with the formation dep endencies assert that R resp ectively

R alone cannot pro duce T Finally enumerate species is selfexplanatory



solveR R 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 neededR R T



enumerate species

balanced stepR RPP

 

formula ofR CHNO formula ofR CHNO

    

ofP CHNO formula ofP CHNO formula

        

C C C C

  

H H H H

  

N N N N

  

O O O O

  

pathway step consistencyR RPP

 

arith var ofR N arith var ofR N



arith var ofP N arith var ofP N

 

N N N N

  

formation dependenciesR RPP

 

bool var a ofR A bool var b ofR B

var a ofR A bool var b ofR B bool

  

bool var a ofP A bool var b ofP B

 

bool var a ofP A bool var b ofP B

  

A A A A

  

B B B B

  

both reagents neededR RT



bool var a ofR A bool var b ofR B

bool var a ofR A bool var b ofR B

   

bool var a ofT A bool var b ofT B

 

R T

R T



Propositional Solver

As mentioned ab ove in the discussion ab out the b o olean constraint domain one

approach to solving b o olean equations is to use clpFD representing the input

formulas in a straightforward way using variables constrained to b e or See

section of and for example What follows is from

Assuming without losing generality that the input is a conjunction of equations

of the form Z X Y Z X Y or X Y the basic algorithm is simply to

representeach equation

Z X Y bythe FD constraints Z X Y

Z X Z Y Y

Z Y Z X X

X Y by Z X Y X Y Z

Z Y X Z

Z X X Z

X Y by X Y

Y X

The following is a clpFD program fragmentwhich realizes these representations

What is not shown is a pro cedure which takes the input equation and calls the

and or and not pro cedures appropriatelyandanenumeration pro cedure over the

values and for all variables In this program valX delays execution of an FD

constraint containing it until X is ground at which time valX denotes the value

ely the currentlower and of X The meaning of minX andmaxX are resp ectiv

upp er b ounds on X maintained by the constraintsolver as discussed in Section

A constraint Xinstexpresses that s and t are resp ectivelylower and upp er

b ounds for X

andX Y Z

Z in minXminY maxXmaxY

X in minZ maxZmaxY minY

Y in minZ maxZmaxX minX

orX Y Z

Z in minX minY minXminY maxX maxY maxXmaxY

X in minZ maxY maxZ

Y in minZ maxX maxZ

notX Y

X in valY Y in valX

We conclude here bymentioning the authors claim that this approach has great

eciency In particular it is several times faster than eachoftwo b o olean solvers

deployed in CHIP and some sp ecialpurp ose standalone solvers

Further Applications

The applications discussed in the previous two sections are but a sample of CLP ap

plications Here we briey mention some others to indicate the breadth of problems

that have b een addressed using CLP languages and techniques

Wehave exemplied the use of CLP to mo del analog circuits ab ove A con

siderable amountofwork has also b een done on digital circuits in particular on

verication diagnosis synthesis and testpattern

generation Much of these works used the CHIP system See also fora

description of a large application In civil engineering used CLPR for the

analysis and partial synthesis of truss structures As with electrical circuits the

constraints implementphysical mo delling and are used to verify truss and supp ort

comp onents as well as to generate spatial congurations There is also work in me

chanical engineering used CLPR to design gear b oxes and combined

techniques from qualitativephysics and CLPR to design mechanical systems from

behaviour sp ecications In general engineering applications such as these use CLP

to sp ecify a hierarchical comp osition of complex systems and for rulebased reason

ing

Another imp ortant application area for CLP is nance Wementioned the OTAS

work ab ove Some further work is which also deals with option valuations and

which deal with nancial planning These nancial applications have

tended to take the form of exp ert systems involving sophisticated mathematical

mo dels

There havebeenvarious prop osals for including certainty measures and proba

bilities in logic programs to provide some builtin evidential reasoning that can b e

useful when writing exp ert systems Original prop osals intended Prolog

as the underlying language but it is clear that CLP languages provide for more

exible execution of such exp ert systems

The Applause Pro ject has develop ed applications that use the ElipSys

system a parallel implemen tation of a CLP language for man ufacturing planning

tourist advice molecular biology and environment monitoring and control

Finallywe mention work on applying CLP languages to music car se

quencing aircraft trac control building visual language parsers

awarehousing problem safety analysis frequency assignment for cellu

lar telephones timetabling o or planning spacecraft attitude con

trol interop erability of bre optic communications equipment interest

rate risk management in banking failure mo de and eect analysis of complex

systems development of digitally controlled analog systems testing of

telecommunication proto cols causal graph management factory sched

uling etc The Applause Pro ject has develop ed applications that use the

ElipSys system for manufacturing planning tourist advice molecular biology and

environment monitoring and control

Acknow ledgeme nts

Wewould like to thank the following p eople for their comments on drafts of this

pap er andor help in other ways M Bruyno oghe N Heintze Pvan Hentenryck

A Herold JL Lassez S Michaylov C Palamidessi K Shuerman PStuckeyM

Wallace R Yap We also thank the anonymous referees for their careful reading

and helpful comments

REFERENCES

M Abadi Z Manna Temp oral Logic Programming Journal of Symbolic Com

putation

A Aggoun N Beldiceanu Extending CHIP to Solve Complex Scheduling and

Packing Problems In Journees Francophones De Programmation Logique Lille

France

A Aggoun N Beldiceanu Overview of the CHIP Compiler System in Con

straint Logic Programming SelectedResearch F Benhamou and A Colmerauer

Eds MIT Press

A Aiba K Sakai Y Sato D Hawley R Hasegawa Constraint Logic Pro

gramming Language CAL Proc International Conference on Fifth Generation

Computer Systems

H AtKaci An Algebraic Semantics Approach to the Eective Resolution of

Typ e Equations Theoretical

H AtKaci Warrens Abstract Machine A Tutorial Reconstruction MIT Press

H AtKaci R Nasr LOGIN A Logic Programming Language with Builtin

Inheritance Journal of Logic Programming

H AtKaci P Lincoln R Nasr Le Fun Logic Equations and Functions Proc

Symposium on Logic Programming

H AtKaci A Po delski Towards a Meaning of LIFE Journal of Logic Pro

gramming

H AtKaci A Po delski Entailment and Disentailment of OrderSorted Fea

ture Constraints manuscript

H AtKaci A Po delski A General Residuation Framework manuscript

H AtKaci A P o delski G Smolka A Featurebased Constraint System for

Logic Programming with Entailment Theoretical Computer Science to app ear

Also in Proc International Conference on Fifth Generation Computer Systems

Vol

L Alb ert R Casas F Fages Averagecase Analysis of Unication Algorithms

Theoretical Computer Science

K Apt H Blair A Walker Towards a Theory of DeclarativeKnowledge in

FoundationsofDeductive Databases and Logic ProgrammingJMinker Ed

Morgan Kaufmann

C AtayA Paralleliza tion of the Constraint Logic Programming Language LP

PhD thesis City University of New York

C Atay K McAlo on C Tretko LP A Highly Parallel ConstraintLogic

Programming Language Proc th SIAM Conf on Paral lel Processing for Sci

entic Computing

R Barbuti M Co dish R Giacobazzi MJ Maher Oracle Semantics for Pro

ogramming LNCS log Proc rd ConferenceonAlgebraic and Logic Pr

M Baudinet Proving Termination Prop erties of Prolog A Semantic Approach

Proc rd Symp Logic in Computer Science

M Baudinet J Chomicki PWolp er Temp oral Deductive Databases in Tem

poral Databases Theory Design and ImplementationATansel J Cliord S

Gadia S Ja jo dia A Segev and R Sno dgrass Eds BenjaminCummings

F Benhamou A Colmerauer Eds Constraint Logic Programming Selected

Research MIT Press

F Benhamou Bo olean Algorithms in PROLOG III in Constraint Logic Pro

gramming SelectedResearch F Benhamou and A Colmerauer Eds MIT

Press

F Benhamou JL Massat Bo olean Pseudoequations in ConstraintLogic

Programming Proc th International ConferenceonLogic Programming

F Berthier A Financial Mo del using Qualitative and QuantitativeKnowledge

Proceeedings of the InternationalSymposium on Computational Intel ligence

Milano Septemb er

F Berthier Solving Financial Decision Problems with CHIP Proceeedings of the

nd ConferenceonEconomics and A rticial Intel ligence CECIOAParis

June

R Bisdor S Laurent Industrial Disp osing Problem Solved in CHIP Proc

th International ConferenceonLogic Programming

A Bo ckmayr Logic Programming with PseudoBo olean Constraints in Con

straint Logic Programming SelectedResearch F Benhamou and A Colmerauer

Eds MIT Press

F de Bo er J Kok C Palamidessi J Rutten Nonmonotonic Concurrent

Constraint Programming Proc International Logic Programming Symposium

FS de Bo er C Palamidessi A Fully Abstract Mo del for Concurrent Con

straint Programming Proc of TAPSOFTCAAP LNCS

FS de Bo er C Palamidessi EmbeddingasaTo ol for Language Comparison

Information and Computation to app ear

FS de Bo er C Palamidessi From Concurrent Logic Programming to Con

current Constraint Programmingin Advanc es in Logic Programming Theory

Oxford University Press to app ear

P Boizumault Y Delon L Peridy Solving a real life exams problem using

CHIP Proc International Logic Programming Symposium

A Borning The Programming Language Asp ects of ThingLab a Constraint

Oriented Simulation Lab oratory ACM Transactions on Programming Languages

and Systems Octob er

A Borning MJ Maher A Martindale M Wilson Constraint Hierarchies and

Logic Programming Proc th International ConferenceonLogic Programming

Fuller version as Technical Rep ort Computer Science

Department UniversityofWashington

A Bossi M Gabbrielli G Levi MC Meo Contributions to the Semantics of

Op en Logic Programs Proc Int Conf on Fifth Generation Computer Systems

A Bro dsky Y Sagiv Inference of Inequality Constraints in Logic Programs

Proc ACM Symp on Principles of Database Systems

A Bro dsky J Jaar M Maher Toward Practical Constraint Databases Proc

th International ConferenceonVery Large Data Bases

JM Bro ek HAM Daniels Application of CLP to Asset and Liability Man

agement in Banks Computer ScienceinEconomics and Management

May

R Bryant Graph Based Algorithms for Bo olean Function Manipulati on IEEE

Transactions on Computers

C Brzoska Temp oral Logic Programming and its Relation to ConstraintLogic

Programming Proc International Logic Programming Symposium

C Brzoska Temp oral Logic Programming with Bounded Universal Mo dality

Goals Proc th International ConferenceonLogic Programming

J Burg C Hughes J Moshell SD Lang Constraintbased Programming A

SurveyTechnical Rep ort ISTTR Dept of Computer Science University

of Central Florida

J Burg Parallel Execution Mo dels and Algorithms for Constraint Logic Pro

gramming over a Realnumb er Domain PhD thesis Dept of Computer Science

UniversityofCentral Florida

J Burg C Hughes SD Lang Parallel Execution of CLP Programs Tech

nical Rep ort TRCS University of Central Florida

HJ Burc kert A Resolution Principle for Clauses with Constraints Proc CADE

LNCS

W Buttner H Simonis Emb edding Bo olean Expressions into Logic Program

ming Journal of Symbolic Computation

M Carlsson Freeze Indexing and other Implementation Issues in the WAM

enceonLogic Programming Proc th International Confer

M Carlsson M Grindal Automatic Frequency Assignment for Cellular Tele

phones Using Constraint Satisfaction Techniques Proc th InternationalCon

ferenceonLogic Programming

SN Cernikov Contraction of Finite Systems of Linear Inequalities In Russ

ian Doklady Akademiia Nauk SSSRVol No English

translation in Soviet Mathematics DokladyVol No

R Chadra O Co ckings S Narain Interop erability Analysis bySymbolic

Simulation Proc JICSLP Workshop on Constraint Logic Programming

A Chamard F Deces A Fischler Applying CHIP to a Complex Scheduling

Problem draft manuscript Dassualt Aviation Department of Articial Intelli

gence

D Chan Constructive Negation based on Completed Database Proc th Inter

national ConferenceonLogic Programming

V Chandru Variable Eliminatio n in Linear Constraints The Computer Journal

V Chandru JN Ho ok er Extended Horn Sets in Prop ositional Logic Journal

of the ACM

V Chvatal Linear Programming WH Freeman and Co New York

KL Clark Negation as Failure in Logic and Databases H Gallaire and J

Minker Eds Plenum Press New York

P Co dognet D Diaz Bo olean Constraint Solving using clpFD Proc Inter

national Logic Programming Symposium

P Co dognet F Fages J Jourdan R Lissa joux T Sola On the Design of

MetaF and its Application s in Air Trac Control Proc JICSLP Workshop on

Constraint Logic Programming

J Cohen Constraint Logic Programming Languages CACM July

A Colmerauer PrologI I Manuel de Reference et Mo dele Theorique Group e

Intelligence Articelle U dAixMarseille I I

A Colmerauer Prolog and Innite Trees in Logic Programming KL Clark and

SA Tarnlund Eds Academic Press New York

A Colmerauer Prolog in Figures Proc th International Joint Conference

on Articial Intel ligence

A Colmerauer Equations and Inequations on Finite and Innite Trees Proc

nd Int Conf on Fifth Generation Computer SystemsTokyo

A Colmerauer Op ening the Prolog I I I Universe BYTE Magazine August

A Colmerauer Prolog I I I Reference and Users Manual Version PrologIA

Marseilles

A Colmerauer An Intro duction to Prolog I I I CACM July

A Colmerauer Naive Solving of Nonlinear Constraints in Constraint Logic

Programming SelectedResearch F Benhamou and A Colmerauer Eds MIT

Press

A Colmerauer invited talk at Workshop on the Principles PracticeofCon

straint Programming Newp ort RI April

MM Corsini A Rauzy Safety Analysis by means of Fault Trees an Appli

cation for Op en Bo olean Solvers Proc th International ConferenceonLogic

Programming

B Courcelle Fundamental Prop erties of Innite Trees Theoretical Computer

Science March

J Darlington and YK Guo A New Persp ectiv eonIntegrating Functions and

Logic Languages Proceedings of the rd International Conference on Fifth Gen

eration Computer SystemsTokyo

B De Backer H Beringer Intelligent Backtracking for CLP Languages An Ap

plication to CLPR Proc InternationalLogic Programming Symposium

B De Backer H Beringer A CLP Language Handling Disjunctions of Linear

Constraints Proc th International ConferenceonLogic Programming

S K Debray Static Inference of Mo des and Data Dep endencies in Logic Pro

grams ACM Transactions on Programming Languages and Systems

S K Debray DS Warren Functional Computations in Logic Programs ACM

Transactions on Programming Languages and Systems

c D Diaz P Co dognet A Minimal Extension of the WAM for clpFD Pro

th International ConferenceonLogic Programming

M Dincbas PVan Hentenryck H Simonis A Aggoun The ConstraintLogic

Programming Language CHIP Proceedings of the nd International Conference

on Fifth Generation Computer Systems

M Dincbas H Simonis Pvan Hentenryck Solving a Cuttingsto ck Problem

th

in CLP Proceedings International ConferenceonLogic Programming MIT

Press

M Dincbas H Simonis PVan Hentenryck Solving Large Combinatorial

Problems in Logic Programming Journal of Logic Programming

A Dovier G Rossi Emb edding Extensional Finite Sets in CLP Proc Inter

national Logic Programming Symposium

R Duisburg Constraintbased Animation Temp oral Constraints in the Animus

ektronix Lab oratories August System Technical Rep ort CR T

R Ege D Maier A Borning The Filter Browser Dening Interfaces Graphi

cally Proc of the European Conf on ObjectOrientedProgrammingParis

E Elco ck Absys The First Logic Programming Language A Retrosp ective

and Commentary Journal of Logic Programming

M van Emden Quantitative Deduction and its Fixp oint Theory Journal of

Logic Programming

E Emerson Temp oral and Mo dal Logic in Handbook of Theoretical Computer

Science Vol B Chapter

O Evans Factory Scheduling using Finite Domains in Logic Programming in

Action LNCS SpringerVerlag

F Fages On the Semantics of Optimization Predicates in CLP Languages Proc

th Conf on Foundations of SoftwareTechnology and Theoretical Computer

Science

M Falaschi G Levi M Martelli C Palamidessi Declarative Mo delling of

the Op erational Behavior of Logic Languages Theoretical Computer Science

T Filkorn R Schmid E Tiden PWarkentin Exp eriences from a Large

Industrial Circuit Design Application Proc InternationalLogic Programming

Symposium

RE Fikes REFARF A system for solving problems stated as pro cedures

Articial Intel ligence

M Fitting A KripkeKleene Semantics for Logic Programs Journal of Logic

Programming

JBJ Fourier Rep orted in Analyse des travaux de lAcadamie Royale des Sci

ences p endant lannee Partie mathematique Histoire de lAcademie Royale

des Sciences de lInstitut de FranceVol xlviilv Partial English trans

lation in DA Kohler Translation of a Rep ort byFourier on his work on Linear

Inequalities OpsearchVol

BN FreemanBenson Constraint Imp erative Programming PhD thesis De

partment of Computer Science and Engineering UniversityofWashington

T Fruwirth Constraint Simplicatio n Rules Technical Rep ort ECRC

ECRC

T Fruwirth A Herold V Kuc henho T Le Provost PLimMWallace Con

straint Logic Programming An Informal Intro duction in Logic Programming

in Action LNCS SpringerVerlag

M Gabbriell i G Levi Mo deling Answer Constraints in Constraint Logic Pro

grams Proc th International ConferenceonLogic Programming

H Gaifman MJ Maher E Shapiro ReplayRecovery Replication and Snap

shots of Nondeterministic Concurrent Programs Proc th ACM Symposium

on Principles of Distributed Computation

PJ Gailly W Krautter C Bisiere S Bescos The Prince pro ject and its

Applications in Logic Programming in Action LNCS SpringerVerlag

M Garca de la Banda M Hermenegildo A Practical Approach to the Global

Analysis of Constraint Logic Programs Proc InternationalLogic Programming

Symposium

M Garca de la Banda M Hermenegildo K Marriott Indep endence in

Constraint Logic Programs Proc International Logic Programming Symposium

A van Gelder Negation as Failure Using Tight Derivations for General Logic

Programs in Foundations of Deductive Databases and Logic ProgrammingJ

Minker Ed Morgan Kaufmann

A van Gelder K Ross JS Schlipf Unfounded Sets and WellFounded Se

mantics for General Logic Programs Journal of the ACM

M Gelfond V Lifschitz The Stable Mo del Semantics for Logic Programming

Pr oc th International ConferenceonLogic Programming

W Havens S Sideb ottom G Sideb ottom J Jones R Ovans Echidna A

Constraint Logic Programming Shell Proc Pacic Rim International Confer

enceonArticial Intel ligence

N Heintze S MichaylovPJ Stuckey CLPR and Some Electrical Engineer

ing Problems Journal of AutomatedReasoning

R Helm K Marriott M Odersky Building Visual Language Parsers Proc

CHI

R Helm K Marriott M Odersky Constraintbased Query Optimization for

Spatial Databases Proc th ACM Symp on Principles of Database Systems

Pvan Hentenryck Constraint Satisfaction in Logic Programming MIT Press

Pvan Hentenryck Parallel Constraint Satisfaction in Logic Programming Pre

liminary Results of CHIP within PEPSys Proc th International Conferenceon

Logic Programming

Pvan Hentenryck Constraint Logic Programming The Know ledge Engineering

Review

Pvan Hentenryck Constraint Satisfaction using Constraint Logic Programming

Articial Intel ligenc e

Pvan Hentenryck Ed Sp ecial Issue on Constraint Logic Programming Journal

of Logic Programming

Pvan Hentenryck Y Deville The Cardinality Op erator A New Logical Con

nective and its Application to Constraint Logic Programming Proc Interna

tional ConferenceonLogic Programming

Pvan Hentenryck Y Deville Op erational Semantics of ConstraintLogic

Programming over Finite Domains Proc Symp on Programming Language Im

plementation and Logic Programming LNCS

Pvan Hentenryck T Graf Standard Forms for Rational Linear Arithmetics

in Constraint Logic Programming Annals of Mathematics and Articial Intel li

gence

Pvan Hentenryck V Saraswat Y Deville Constraint Pro cessing in ccFD

manuscript

Pvan Hentenryck V Saraswat Y Deville Design Implementations and Eval

uation of the Constrain t Language ccFD Technical Rep ort CS Brown

University

T HickeyFunctional Constraints in CLP Languages in Constraint Logic Pro

gramming SelectedResearch F Benhamou and A Colmerauer Eds MIT

Press

M Hohfeld G Smolka Denite Relations over Constraint Languages LILOG

Rep ort IBM Deutschland

D Homiak A CLP System for Solving Partial Dierential Equations with Ap

plications to Options Valuation Masters Pro ject DePaul University

H Hong RISCCLPReal Logic Programming with Nonlinear Constraints

over the Reals in Constraint Logic Programming SelectedResearch F Ben

hamou and A Colmerauer Eds MIT Press

A Horn On Sentences Which are True of Direct Unions of Algebras Journal of

Symbolic Logic

T Huynh C Lassez A CLPR Options Trading Analysis System Proceedings

amming th International ConferenceonLogic Progr

T Huynh C Lassez JL Lassez Practical Issues on the Pro jection of Poly

hedral Sets Annals of Mathematics and Articial Intel ligence

JL Imb ert Variable Elimination for Disequations in Generalized Linear Con

straint Systems The Computer Journal

JL Imbert Fouriers Elimination whichtocho ose Proc st Workshop on

Principles and PracticeofConstraint Programming Newp ort April

J Jaar Ecient Unication over Innite Terms New Generation Computing

J Jaar Minimal and Complete Word Unication Journal of the ACM

J Jaar JL Lassez Constraint Logic Programming Technical Rep ort

Department of Computer Science Monash University

J Jaar JL Lassez Constraint Logic Programming Proc th ACM Sympo

sium on Principles of Programming Languages Munich January

J Jaar JL Lassez MJ Maher A Theory of Complete Logic Programs with

Equality Journal of Logic Programming

J Jaar JL Lassez MJ Maher A Logic Programming Language Scheme

in Logic Programming Relations Functions and Equations D DeGro ot and G

Lindstrom Eds PrenticeHall

J Jaar MJ Maher PJ StuckeyRHCYap Pro jecting CLP Con

straints New Generation Computing

J Jaar S Michaylov PStuckey R Yap The CLPR Language and System

amming Languages ACM Transactions on Progr

J Jaar S Michaylov R Yap A Metho dology for Managing Hard Constraints

in CLP Systems Proc ACMSIGPLAN ConferenceonProgramming Language

Design and Implementation

J Jaar S Michaylov P StuckeyRHCYap An Abstract Machine for

CLPR Proceedings ACMSIGPLAN ConferenceonProgramming Language

Design and Implementation

J Jaar and P Stuckey Canonical Logic Programs Journal of Logic Program

ming

S Janson S Haridi Programming Paradigms of the Andorra Kernel Language

Proc International Logic Programming Symposium

N Jorgensen K Marriott S Michaylov Some Global Compiletime Opti

mizations for CLPR Proceedings InternationalLogic Programming Sym

posium

J Jourdan RE ValdesPerez Constraint Logic Programming Applied to Hy

p othetical Reasoning in Chemistry Proceedings North American Conferenceon

Logic Programming Page should follow page

K Kanchanasut C Sumetphong Flo or Planning Applications in CLPR

Proc JICSLP Workshop on Constraint Logic Programming

LG Khachian A p olynomial algorithm in linear programming Soviet Math

Dokl

J de Kleer and GJ Sussman Propagation of Constraints Applied to Circuit

Synthesis Circuit Theory and Applications

P Kanellakis JL Lassez V Saraswat Eds Principles and PracticeofCon

straint Programming MIT Press to app ear

P Kanellakis G Kup er P Revesz Constraint Query Languages Journal of

Computer and System Sciences to app ear Preliminary version app eared in Proc

th ACM Symp on Principles of Database Systems

P Kanellakis S Ramaswamy DE V engro JS Vitter Indexing for Data

Mo dels with Constraints and Classes Proc ACM Symp on Principles of Data

base Systems

D Kemp K Ramarohanarao I Balbin K Meenakshi Propagating Con

straints in Recursive Deductive Databases Proc North American Conference

on Logic Programming

D Kemp P Stuckey Analysis based Constraint Query Optimization Proc

th International ConferenceonLogic Programming

V Klee GJ MintyHow go o d is the Simplex algorithm in InequalitiesIII

O Sisha Ed Academic Press New York

A Klug On Conjunctive Queries Containing Inequalities Journal of the ACM

A Koscielski L Pacholski Complexity of Unication in Free Groups and Free

Semigroups Proc st Symp on Foundations of Computer Science

R Krishnamurthy R Ramakrishnan O Shmueli A Framework for Testing

Safety and Eective Computability of Extended Datalog Proc ACM Symp on

Management of Data

CAC Kuip Algebraic Languages for Mathematical Programming European

Journal of

K Kunen Negation in Logic Programming Journal of Logic Programming

D Ladret M Rueher Contribution of Logic Programming to supp ort Telecom

munications Proto col Tests Proc th InternationalConferenceonLogic Pro

gramming

S Lakmazaheri W Rasdorf Constraint Logic Programming for the Analysis

and Partial Synthesis of Truss Structures Articial Intel ligence for Engineering

Design Analysis and Manufacturing

C Lassez Constraint Logic Programming a Tutorial in BYTE MagazineAu

gust

C Lassez K McAlo on R Yap Constraint Logic Programming and Options

Trading IEEE Expert Sp ecial Issue on Financial Software August

C Lassez JL Lassez Quantier Elimination for Conjunctions of Linear Con

straints via a Convex Hull Algorithm in Symbolic and Numeric Computation

for Articial Intel ligence B Donald D Kapur and JL Mundy Eds Academic

Press to app ear Also IBM ResearchReportRC TJ Watson Research

Center

JL Lassez T Huynh K McAlo on Simplifcatio n and Elimination of Redun

dant Linear Arithmetic Constraints Proc North American ConferenceonLogic

ProgrammingCleveland

JL Lassez M Maher KG Marriott Unication Revisited in Foundations

of Deductive Databases and Logic ProgrammingJMinker Ed Morgan Kauf

mann

JL Lassez KG Marriott Explicit Representation of Terms Dened by

Counter Examples Journal of AutomatedReasoning

JL Lassez K McAlo on A Canonical Form for Generalized Linear Con

straints Journal of Symbolic Computation to app ear

JL Lassez K McAlo on A Constraint Sequent Calculus Pro c of Symp on

Logic in Computer Science

JL Lauriere A Language and a Program for Stating and Solving Combinatorial

Problems Articial Intel ligence

W Leler Constraint Programming Languages Their Specication and Genera

tion AddisonWesley

HF Leung Distributed Constraint Logic ProgrammingVol WorldScienti c

Series in Computer Science WorldScienti c

LiangLiang etal APPLAUSE Applications Using the ElypSys Parallel CLP

System Proc th International ConferenceonLogic Programming

JW Lloyd Foundations of Logic Programming SpringerVerlag Second Edi

tion

JW Lloyd RW Top or Making Prolog More Expressive Journal of Logic

Programming

K McAlo on C Tretko LP A Logic Programming and Linear Programming

System Bro oklyn College Computer Science Technical Rep ort No

A McDonald P Stuckey R Yap Redundancy of Variables in CLPR Proc

International Logic Programming Symposium

J McKinsey The Decision Problem for Some Classes of Sentences Without

Quantiers Journal of Symbolic Logic

MJ Maher Logic Semantics for a Class of CommittedChoice Programs Proc

th International ConferenceonLogic Programming

MJ Maher Complete Axiomatizations of the Algebras of Finite Rational and

Innite Trees Proc rd Symp Logic in Computer Science Full

version IBM Research Rep ort TJ Watson ResearchCenter

MJ Maher A CLP View of Logic Programming Proc Conf on Algebraic and

Logic Programming LNCS

MJ Maher A Transformation System for Deductive Database Mo dules with

Perfect Mo del Semantics Theoretical Computer Science

MJ Maher A Logic Programming View of CLP Proc th International Con

ferenceonLogic Programming Full version IBM ResearchRe

p ort TJ Watson ResearchCenter

MJ Maher PJ Stuckey Expanding Query Power in CLP Languages Proc

North American ConferenceonLogic Programming

GS Makanin The Problem of Solvabili ty of Equations in a Free Semigroup

Math USSR Sbornik English translation AMS

H Mannila E Ukkonen On the Complexity of Unication Sequences Proc

rd International ConferenceonLogic Programming

A Mantsivo da Flang and its Implementation Proc Symp on Programming

Language Implementation and Logic Programming LNCS

key The Rs of optimizing constraint logic pro KG Marriott PJ Stuc

grams Renement removal and reordering Proc th ACM Symp Principles

of Programming Languages

KG Marriott PJ StuckeySemantics of CLP Programs with Optimization

Technical Rep ort University of Melb ourne

K Marriott H Sndergaard PJ StuckeyRHCYap Optimising Compilation

for CLPR Proc Australian Computer Science Conf

U Martin T Nipkow Bo olean Unication The Story So Far Journal of

Symbolic Computation

MathLab MACSYMA Reference Manual The MathLab Group Lab oratory for

Computer Science MIT

S Michaylov F Pfenning HigherOrder Logic Programming as Constraint

Logic Programming st Workshop on Principles and Practice of Constraint

Programming

S Michaylov Design and Implementation of Practical Constraint Logic Pro

gramming Systems PhD Thesis Carnegie Mellon University Rep ort CMU

CS August

D Miller A Logic Programming Language with Lamb daabstraction Function

Variables and Simple Unication in Extensions of Logic Pro gramming Inter

national Workshop SpringerVerlag LNCS

D Miller G Nadathur HigherOrder Logic Programming Proc rd Interna

tional ConferenceonLogic Programming

U Montanari F Rossi Graph Rewriting for a Partial Ordering Semantics of

Concurrent Constraint Programming Theoretical Computer Science

K Mukai Anadic Tuples in Prolog Technical Rep ort TR ICOT Tokyo

IS Mumick SJ Finkelstein H Pirahesh R Ramakrishnan Magic Condi

tions Proc th ACM Symp on Principles of Database Systems

L Naish Automating Control for Logic Programs Journal of Logic Program

ming

L Naish Negation and Control in PROLOG Lecture Notes in Computer Science

SpringerVerlag

G Nelson JUNO A Constraint Based Graphics System Computer Graphics

A Nero de W Kohn Hybrid Systems and Constraint Logic Programming

Proc th International ConferenceonLogic Programming

W Older F Benhamou Programming in CLPBNR st Workshop on Prin

ciples and Practice of Constraint Programming

MS Paterson MN Wegman Linear Unication Journal of Computer and

System Sciences

F Pfenning Logic Programming in the LF Logical Framework in Logical

Frameworks G Huet and G Plotkin Eds Cambridge University Press

A Po delski Pvan Roy The Beauty and the Beast Algorithm Testing Entail

tailment Incrementally draft manuscript ment and Disen

T Le Provost M Wallace Generalized Constraint Propagation over the CLP

Scheme Journal of Logic Programming

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

A Ra jasekar String Logic Programs draft manuscript Dept of Computer Sci

ence Univ of Kentucky

V Ramachandran Pvan Hentenryck Incremental Algorithms for Constraint

Solving and Entailmentover Rational Trees Proc th Conf on Foundations

of SoftwareTechnology and Theoretical Computer Science

R Ramakrishnan Magic Templates A Sp ellbin di ng ApproachtoLogicPro

grams Journal of Logic Programming

G Ramalingam T Reps A Categorized Bibliography on Incremental Compu

tation Proc th ACM Symp on Principles of Programming L anguages

Pvan Roy AM Despain The Benets of Global Dataow Analysis for an

Optimizing Prolog Compiler Proceedings North American Conferenceon

Logic Programming

M Rueher A First Exploration of PrologI I Is Capabiliti es SoftwarePractice

and Experience

K Sakai Y Sato S Menju Bo olean Gro ebner Bases to app ear

Y Sagiv M Vardi Safety of Datalog Queries over Innite Databases Proc

ACM Symp on Principles of Database Systems

V Saraswat CP as a Generalpurp ose Constraintlanguage Pro c AAAI

V Saraswat A Somewhat Logical Formulation of CLP Synchronizati on Prim

itives Proc th International Conference Symposium on Logic Programming

V Saraswat Concurrent Constraint Programming Languages PhD thesis

CarnegieMellon University Revised version app ears as Concurrent Con

straint Programming MIT Press

Proc V Saraswat The Category of Constraint Systems is CartesianClosed

Symp on Logic in Computer Science

V Saraswat D Weinbaum K Kahn E Shapiro Detecting Stable Prop er

ties of Networks in Concurrent Logic Programming Languages Proc th ACM

Symp Principles of Distributed Computing

V Saraswat M Rinard PPanangaden Semantic Foundation of Concurrent

Constraint Programming Proc th ACM Symp on Principles of Programming

Languages

V Saraswat A Retrosp ective Lo ok at Concurrent Logic Programming in prepa

ration

K Satoh A Aiba Computing Soft Constraints by Hierarchical Constraint

Logic Programming Journal of Information Processing to app ear

D Scott Domains for denotational semantics Proc ICALP LNCS

E Shapiro A Subset of Concurrent Prolog and its Technical Rep ort

CS Dept of Applied Mathematics Weizmann Institute of Science

E Shapiro Logic Programs with Uncertainties A To ol for Implementing Exp ert

Systems Proc th IJCAI

JR Sho eneld Mathematical Logic AddisonWesley

J Siekmann Unication Theory Journal of Symbolic Computation

H Simonis M Dincbas Prop ositional Calculus Problems in CHIPin Con

straint Logic Programming SelectedResearch F Benhamou and A Colmerauer

Eds MIT Press

H Simonis Formal Verication of Multipli ers Proceedings of the IFIP

TCWGWG Workshop on AppliedFormal Methods for Correct

VLSI DesignLeuven Belgium Novemb er

H Simonis Test Generation using the Constraint Logic Programming language

CHIP Proc th International ConferenceonLogic Programming

H Simonis M Dincbas Using an extended prolog for digital circuit design

IEEE International Workshop on AI Applications to CAD Systems for Electron

ics Munich WGermany Octob er

H Simonis M Dincbas Using Logic Programming for Fault Diagnosis in Dig

ital Circuits German Workshop on Articial Intel ligenceGWAI Geseke

W Germany Septemb er

H Simonis T Graf Technology Mapping in CHIPTechnical Rep ort TRLP

ECRC Munich

H Simonis H N Nguyen M Dincbas Verication of digital circuits using

CHIP Proc eedings of the IFIP WG International Working Conferenceon

the Fusion of Hardware Design and Verication Glasgow Scotland July

H Simonis T Le Provost Circuit verication in chip Benchmark results

Proceedings of the IFIP TCWGWG Workshop on AppliedFormal

Methods for Correct VLSI DesignLeuven Belgium Novemb er

R Skuppin T Buckle CLP and Spacecraft Attitude Control Proc JICSLP

Workshop on Constraint Logic Programming

G Smolka Residuation and Guarded Rules for Constraint Logic Programming

in Constraint Logic Programming SelectedResearch F Benhamou and A

Colmerauer Eds MIT Press

G Smolka R Treinen Records for Logic Programming Journal of Logic Pro

gramming to app ear Also in Proceedings of the Joint International Conference

and Symposium on Logic Programming

D Srivastava Subsumption and Indexing in Constraint Query Languages with

ts Annals of Mathematics and Articial Intel ligence Linear Arithmetic Constrain

D Srivastava R Ramakrishnan Pushing Constraint Selections Journal of

Logic Programming

RM Stallman GJ Sussman Forward Reasoning and Dep endency Directed

Backtracking in a System for Computer Aided Circuit Analysis Articial Intel

ligence

T Sthanusubramoni an A Transformational Approach to Conguration Design

Masters thesis Engineering Design ResearchCenter Carnegie Mellon Univer

sity

G Steele GJ Sussman CONSTRAINTS A Language for Expressing Almost

Hierarchical Descriptions Articial Intel ligence

GL Steele The Implementation and Denition of a Computer Programming

Language Based on Constraints PhD Dissertation MITAI TR Dept of

Electrical Engineering and Computer Science MIT

M Stickel Automated Deduction by Theory Resolution Journal of Automated

Reasoning

PJ Stuckey Incremental Linear Constraint Solving and Detection of Implicit

Equalities ORSA Journal of Computing

P Stuckey Constructive Negation for Constraint Logic Programming Proc

Logic in Computer Science Conference

D Subramanian CS Wang Kinematic synthesis with conguration spaces

Proc Qualitative Reasoning DWeld ed

unication System PhD thesis I Sutherland A ManMachine Graphical Comm

Massachusetts Institute of TechnologyJanuary

A Tarski ADecision Method for Elementary AlgebraandGeometry University

of California Press

A Taylor LIPS on a MIPS Results from a Prolog Compiler for a RISC Pro

ceedings th International ConferenceonLogic Programming

S Terasaki DJ HawleyHSawada K Satoh S Menju T Kawagishi N

Iwayama A Aiba Parallel Constraint Logic Programming Language GDCC

and its Parallel Constraint Solvers Proc InternationalConference on Fifth Gen

eration Computer Systems Volume I

E Tick The Deevolution of Concurrent Logic Programming Languages draft

manuscript

JC Tobias I I Knowledge Representation in the Harmonyintellig ent tutoring

system Masters thesis Department of Computer Science University of Califor

nia at Los Angeles

BM Tong HF Leung Concurrent Constraint Logic Programming on Mas

sively Parallel SIMD Computers Proc InternationalLo gic Programming Sym

posium

E Tsang Foundations of Constraint Satisfaction Academic Press

A Veron K Schuerman M Reeve LL Li WhyandHow in the ElipSys

ORparallel CLP system Proc Conf on Paral lel Architectures and Languages

Europe

JS Vitter Ph Fla jolet Averagecase Analysis of Algorithms and Data Struc

tures Handbook of Theoretical Computer ScienceVol A Elsevier Science Pub

lishers Amsterdam

PVo da The Constraint Language Trilogy Semantics and Computations Tech

nical Rep ort Complete Logic Systems

PVo da Typ es of Trilogy Proc th International ConferenceonLogic Program

ming

C Walinsky CLP Constraint Logic Programming with Regular Sets Proc

th International ConferenceonLogic Programming

M Wallace A Computable Semantics for General Logic Programs Journal of

Logic Programming

M Wallace Applying Constraints for Scheduling in Constraint Programming

B Mayoh E Tyugu and J Penjaam Eds NATO Advanced Science Institute

Series SpringerVerlag

DHD Warren An Abstract PROLOG Instruction Set Technical note AI

Center SRI International Menlo Park Octob er

DHD Warren The Andorra Principle presented at the Gigalips Workshop

M Wilson A Borning Hierarchical Constraint Logic Programming Journal

of Logic Programming

th

Roland Yap Restriction Site Mapping in CLPR Proceedings International

ConferenceonLogic Programming MIT Press June

Roland Yap A Constraint Logic Programming Framework for Constructing

DNA Restriction Maps Articial Intel ligenceinMedicine

Roland Yap Contributions to CLPR PhD thesis Department of Computer

Science Monash UniversityJanuary exp ected