23
arXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt 1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam, the Netherlands [email protected] 2 University of Amsterdam, the Netherlands Abstract. We provide here a simple, yet very general framework that allows us to explain several constraint propagation algorithms in a systematic way. In particular, using the notions commutativity and semi-commutativity, we show how the well-known AC-3, PC-2, DAC and DPC algorithms are instances of a single generic algorithm. The work reported here extends and simplifies that of Apt [1]. 1 Introduction Constraint programming in a nutshell consists of formulating and solving so-called constraint satisfaction problems. One of the most important techniques developed in this area is constraint propagation that aims at reducing the search space while maintaining equivalence. We call the corresponding algorithms constraint propagation algorithms but sev- eral other names have also been used in the literature: consistency, local consistency, consistency enforcing, Waltz, filtering or narrowing algorithms. These algorithms usu- ally aim at reaching some form of “local consistency”, a notion that in a loose sense approximates the notion of “global consistency”. Over the last twenty few years several constraint propagation algorithms were pro- posed and many of them are built into the existing constraint programming systems. In Apt [1] we introduced a simple framework that allows us to explain many of these algorithms in a uniform way. In this framework the notion of chaotic iterations, so fair iterations of functions, on Cartesian products of specific partial orderings played a cru- cial role. In Monfroy and R´ ety [13] this framework was modified to study distributed chaotic iterations. This resulted in a general framework for distributed constraint prop- agation algorithms. We stated in Apt [1] that “the attempts of finding general principles behind the constraint propagation algorithms repeatedly reoccur in the literature on constraint sat- isfaction problems spanning the last twenty years” and devoted three pages to survey this work. Two references that are perhaps closest to our work are Benhamou [2] and Telerman and Ushakov [16]. These developments led to an identification of a number of mathematical properties that are of relevance for the considered functions, namely monotonicity, inflationarity and idempotence (see, e.g., Saraswat, Rinard and Panangaden [15] and Benhamou and

The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

arX

iv:c

s/99

0900

9v1

[cs.

AI]

8 S

ep 1

999

The Rough Guide to Constraint Propagation

Krzysztof R. Apt1,2

1 CWIP.O. Box 94079, 1090 GB Amsterdam, the Netherlands

[email protected] University of Amsterdam, the Netherlands

Abstract. We provide here a simple, yet very general framework that allowsus to explain several constraint propagation algorithms ina systematic way. Inparticular, using the notions commutativity and semi-commutativity, we showhow the well-knownAC-3, PC-2, DAC andDPC algorithms are instances of asingle generic algorithm. The work reported here extends and simplifies that ofApt [1].

1 Introduction

Constraint programming in a nutshell consists of formulating and solving so-calledconstraint satisfaction problems. One of the most important techniques developed in thisarea is constraint propagation that aims at reducing the search space while maintainingequivalence.

We call the corresponding algorithms constraint propagation algorithms but sev-eral other names have also been used in the literature: consistency, local consistency,consistency enforcing, Waltz, filtering or narrowing algorithms. These algorithms usu-ally aim at reaching some form of “local consistency”, a notion that in a loose senseapproximates the notion of “global consistency”.

Over the last twenty few years several constraint propagation algorithms were pro-posed and many of them are built into the existing constraintprogramming systems.In Apt [1] we introduced a simple framework that allows us to explain many of thesealgorithms in a uniform way. In this framework the notion of chaotic iterations, so fairiterations of functions, on Cartesian products of specific partial orderings played a cru-cial role. In Monfroy and Rety [13] this framework was modified to study distributedchaotic iterations. This resulted in a general framework for distributed constraint prop-agation algorithms.

We stated in Apt [1] that “the attempts of finding general principles behind theconstraint propagation algorithms repeatedly reoccur in the literature on constraint sat-isfaction problems spanning the last twenty years” and devoted three pages to surveythis work. Two references that are perhaps closest to our work are Benhamou [2] andTelerman and Ushakov [16].

These developments led to an identification of a number of mathematical propertiesthat are of relevance for the considered functions, namely monotonicity, inflationarityand idempotence (see, e.g., Saraswat, Rinard and Panangaden [15] and Benhamou and

Page 2: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

Older [3]). Here we show that also the notions of commutativity and so-called semi-commutativity are important.

As in Apt [1], to explain the constraint propagation algorithms, we proceed herein two steps. First, we introduce a generic iteration algorithm on partial orderings andprove its correctness in an abstract setting. Then we instantiate this algorithm with spe-cific partial orderings and functions. The partial orderings will be related to the consid-ered variable domains and the assumed constraints, while the functions will be the onesthat characterize considered notions of local consistencyin terms of fixpoints.

This presentation allows us to clarify which properties of the considered functionsare responsible for specific properties of the corresponding algorithms. The resultinganalysis is simpler than that of Apt [1] because we concentrate here on constraint prop-agation algorithms that always terminate. This allows us todispense with the notion offairness. On the other hand, we can now prove stronger results by taking into accountthe commutativity and semi-commutativity information.

This article is organized as follows. First, in Section 2, drawing on the approach ofMonfroy and Rety [13], we introduce a generic algorithm forthe case when the partialordering is not further analyzed. Next, in Section 3, we refine it for the case when thepartial ordering is a Cartesian product of component partial orderings and in Section4 explain how the introduced notions should be related to theconstraint satisfactionproblems.

In the next four sections we instantiate the algorithm of Section 2 or some of its re-finements to obtain specific constraint propagation algorithms. In particular, in Section5 we derive algorithms for arc consistency and hyper-arc consistency. These algorithmscan be improved by taking into account information on commutativity. This is done inSection 6 and yields the well-knownAC-3 algorithm. Next, in Section 7 we derive analgorithm for path consistency and in Section 8 we improve it, again by using informa-tion on commutativity. This yields thePC-2 algorithm.

In Section 9 we clarify under what assumptions the generic algorithm of Section2 can be simplified to a simplefor loop statement. Then we instantiate this simplifiedalgorithm to derive in Section 10 theDAC algorithm for directional arc consistency andin Section 11 theDPC algorithm for directional path consistency. Finally, in Section 12we briefly discuss possible future work.

So we deal here only with the classical algorithms that establish (directional) arcconsistency and (directional) path consistency and that are more than twenty, respec-tively ten, years old. However, several more “modern” constraint propagation algo-rithms can also be explained in this framework. In particular, in Apt [1, page 203] wederived from a generic algorithm a simple algorithm that achieves the notion of rela-tional consistency of Dechter and van Beek [7]. In turn, we can use the framework ofSection 9 to derive the adaptive consistency algorithm of Dechter and Pearl [6]. Now,Dechter [5] showed that this algorithm can be formulated in avery general frameworkof bucket elimination that in turn can be used to explain suchwell-known algorithmsas directional resolution, Fourier-Motzkin elimination,Gaussian elimination, and alsovarious algorithms that deal with belief networks.

Due to lack of space we do not define here formally the considered local consistencynotions and refer the interested reader instead to the original papers or to Tsang [17].

Page 3: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

2 Generic Iteration Algorithms

Our presentation is completely general. Consequently, we delay the discussion of con-straint satisfaction problems till Section 4. In what follows we shall rely on the follow-ing concepts.

Definition 1. Consider a partial ordering(D, ⊑ ) with the least element⊥ and a finiteset of functionsF := {f1, . . ., fk} onD.

– By an iteration ofF we mean an infinite sequence of valuesd0, d1, . . . definedinductively by

d0 := ⊥,

dj := fij (dj−1),

where eachij is an element of[1..k].– We say that an increasing sequenced0 ⊑ d1 ⊑ d2 . . . of elements fromD eventually

stabilizes at dif for somej ≥ 0 we havedi = d for i ≥ j. ✷

In what follows we shall consider iterations of functions that satisfy some specificproperties.

Definition 2. Consider a partial ordering(D, ⊑ ) and a functionf onD.

– f is calledinflationaryif x ⊑ f(x) for all x.– f is calledmonotonicif x ⊑ y impliesf(x) ⊑ f(y) for all x, y. ✷

The following simple observation clarifies the role of monotonicity. The subsequentresult will clarify the role of inflationarity.

Lemma 1 (Stabilization).Consider a partial ordering(D, ⊑ ) with the least element⊥ and a finite set of monotonic functionsF onD.

Suppose that an iteration ofF eventually stabilizes at a common fixpointd of thefunctions fromF . Thend is the least common fixed point of the functions fromF .

Proof. Consider a common fixpointe of the functions fromF . We prove thatd ⊑ e. Letd0, d1, . . . be the iteration in question. For somej ≥ 0 we havedi = d for i ≥ j.

It suffices to prove by induction oni that di ⊑ e. The claim obviously holds fori = 0 sinced0 = ⊥. Suppose it holds for somei ≥ 0. We havedi+1 = fj(di) for somej ∈ [1..k].

By the monotonicity offj and the induction hypothesis we getfj(di) ⊑ fj(e), sodi+1 ⊑ e sincee is a fixpoint offj . ✷

We fix now a partial ordering(D, ⊑ )with the least element⊥ and a set of functionsF := {f1, . . ., fk} onD. We are interested in computing the least common fixpoint ofthe functions fromF . To this end we study the following algorithm that is inspired bya similar algorithm of Monfroy and Rety [13].

Page 4: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

GENERIC ITERATION ALGORITHM (GI)

d := ⊥;G := F ;while G 6= ∅ do

chooseg ∈ G;G := G− {g};G := G ∪ update(G, g, d);d := g(d)

od

where for allG, g, d the set of functionsupdate(G, g, d) fromF is such that

A. {f ∈ F −G | f(d) = d ∧ f(g(d)) 6= g(d)} ⊆ update(G, g, d),B. g(d) = d implies thatupdate(G, g, d) = ∅.

Intuitively, assumptionA states thatupdate(G, g, d) at least contains all the func-tions fromF −G for which d is a fixpoint butg(d) is not. The idea is that such func-tions are repeatedly added to the setG. In turn, assumptionB states that no functionsare added toG in case the value ofd did not change.

An obvious example of anupdate function that satisfies assumptionsA andB is

update(G, g, d) := {f ∈ F −G | f(d) = d ∧ f(g(d)) 6= g(d)}.

However, this choice of theupdate function is computationally expensive because foreach functionf in F − G we would have to compute the valuesf(g(d)) andf(d). Inpractice, we are interested in some approximations of the aboveupdatefunction. Weshall deal with this matter in the next section.

We now prove correctness of this algorithm in the following sense.

Theorem 1 (GI).(i) Every terminating execution of theGI algorithm computes ind a common fixpoint

of the functions fromF .(ii) Suppose that all functions inF are monotonic. Then every terminating execution

of theGI algorithm computes ind the least common fixpoint of the functions fromF .

(iii) Suppose that all functions inF are inflationary and that(D, ⊑ ) is finite. Thenevery execution of theGI algorithm terminates.

Proof.

(i) Consider the predicateI defined by:

I := ∀f ∈ F −G f(d) = d.

Note thatI is established by the assignmentG := F . Moreover, it is easy to check thatI is preserved by eachwhile loop iteration. ThusI is an invariant of thewhile loop ofthe algorithm. Hence upon its termination

(G = ∅) ∧ I

Page 5: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

holds, that is∀f ∈ F f(d) = d.

(ii) This is a direct consequence of(i) and the Stabilization Lemma 1.

(iii) Consider the lexicographic ordering of the partial orderings(D,⊒) and(N ,≤),defined on the elements ofD ×N by

(d1, n1) ≤lex (d2, n2) iff d1 ❂ d2 or (d1 = d2 and n1 ≤ n2).

We use here the inverse ordering❂ defined by:d1 ❂ d2 iff d2 ⊑ d1 andd2 6= d1.Given a finite setGwe denote bycardG the number of its elements. By assumption

all functions inF are inflationary so, by virtue of assumptionB, with eachwhile loopiteration of the modified algorithm the pair

(d, card G)

strictly decreases in this ordering≤lex. But by assumption(D, ⊑ ) is finite, so(D,⊒)is well-founded and consequently so is(D ×N ,≤lex). This implies termination. ✷

In particular, we obtain the following conclusion.

Corollary 1 (GI). Suppose that(D, ⊑ ) is a finite partial ordering with the leastelement⊥. Let F be a finite set of monotonic and inflationary functions onD. Thenevery execution of theGI algorithm terminates and computes ind the least commonfixpoint of the functions fromF . ✷

In practice, we are not only interested that theupdatefunction is easy to computebut also that it generates small sets of functions. Therefore we show how the functionupdate can be made smaller when some additional information about the functions inF is available. This will yield specialized versions of theGI algorithm. First we needthe following simple concepts.

Definition 3. Consider two functionsf, g on a setD.

– We say thatf andg commuteif f(g(x)) = g(f(x)) for all x.– We callf idempotentif f(f(x)) = f(x) for all x. ✷

The following result holds.

Theorem 2 (Update).

(i) If update(G, g, d) satisfies assumptionsA andB, then so does the function

update(G, g, d)− {g | g is idempotent}.

(ii) Suppose that for eachg ∈ F the set of functionsComm(g) fromF is such that– g 6∈ Comm(g),– each element ofComm(g) commutes withg.

Page 6: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

If update(G, g, d) satisfies assumptionsA andB, then so does the function

update(G, g, d)− Comm(g).

Proof. It suffices to establish in each case assumptionA.

(i) Suppose thatg is idempotent. Then any functionf such thatf(g(d)) 6= g(d) differsfrom g.

(ii)Consider a functionf fromF−G such thatf(d) = d andf(g(d)) 6= g(d). Supposethatf ∈ Comm(g). Thenf(g(d)) = g(f(d)) = g(d) which is a contradiction. Sof 6∈Comm(g). Consequently,f ∈ update(G, g, d) − Comm(g) by virtue of assumptionA for update(G, g, d). ✷

We conclude that given an instance of theGI algorithm that employs a specificupdate function, we can obtain other instances of it by usingupdate functions modifiedas above. Note that both modifications are independent of each other and therefore canbe applied together. In particular, when each function is idempotent and the functionComm satisfied the assumptions of(ii), then ifupdate(G, g, d) satisfies assumptionsA andB, then so does the functionupdate(G, g, d)− (Comm(g) ∪ {g}).

3 Compound Domains

In the applications we study the iterations are carried out on a partial ordering that isa Cartesian product of the partial orderings. So assume now that the partial ordering(D, ⊑ ) is the Cartesian product of some partial orderings(Di, ⊑ i), for i ∈ [1..n],each with the least element⊥i. SoD = D1 × · · · ×Dn.

Further, we assume that each function fromF depends from and affects only certaincomponents ofD. To be more precise we introduce a simple notation and terminology.

Definition 4. Consider a sequence of partial orderings(D1, ⊑ 1), . . ., (Dn, ⊑ n).

– By ascheme(onn) we mean a growing sequence of different elements from[1..n].– Given a schemes := i1, . . ., il onn we denote by(Ds, ⊑ s) the Cartesian product

of the partial orderings(Dij , ⊑ ij ), for j ∈ [1..l].– Given a functionf onDs we say thatf is with schemes and say thatf depends

on i if i is an element ofs.– Given ann-tupled := d1, . . ., dn fromD and a schemes := i1, . . ., il on n we

denote byd[s] the tupledi1 , . . ., dil . In particular, for j ∈ [1..n] d[j] is thej-thelement ofd. ✷

Consider now a functionf with schemes. We extend it to a functionf+ fromD toD as follows. Taked ∈ D. We set

f+(d) := e

wheree[s] = f(d[s]) ande[n− s] = d[n− s], and wheren− s is the scheme obtainedby removing from1, . . ., n the elements ofs. We callf+ thecanonic extensionof f tothe domainD.

Page 7: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

Sof+(d1, . . ., dn) = (e1, . . ., en) impliesdi = ei for anyi not in the schemes of f .Informally, we can summarize it by saying thatf+ does not change the components onwhich it does not depend. This is what we meant above by stating that each consideredfunction affects only certain components ofD.

We now say that two functions,f with schemes andg with schemet commuteifthe functionsf+ andg+ commute.

Instead of defining iterations for the case of the functions with schemes, we ratherreduce the situation to the one studied in the previous section and consider, equivalently,the iterations of the canonic extensions of these functionsto the common domainD.However, because of this specific form of the considered functions, we can use now asimple definition of theupdate function. More precisely, we have the following obser-vation.

Note 1 (Update).Suppose that each function inF is of the formf+. Then the followingfunctionupdate satisfies assumptionsA andB:

update(G, g+, d) :={f+ ∈ F −G | f depends on somei in s such thatd[i] 6= g+(d)[i]},

whereg is with schemes.

Proof. To deal with assumptionA take a functionf+ ∈ F − G such thatf+(d) = d.Thenf(e) = e for anye that coincides withd on all components that are in the schemeof f .

Suppose now additionally thatf+(g+(d)) 6= g+(d). By the aboveg+(d) differsfrom d on some componenti in the scheme off . In other words,f depends on someisuch thatd[i] 6= g+(d)[i]. Thisi is then in the scheme ofg.

The proof for assumptionB is immediate. ✷

This, together with theGI algorithm, yields the following algorithm in which weintroduced a variabled′ to hold the value ofg+(d), and usedF0 := {f | f+ ∈ F} andthe functions with schemes instead of their canonic extensions toD.

GENERIC ITERATION ALGORITHM FOR COMPOUND DOMAINS (CD)

d := (⊥1, . . .,⊥n);d′ := d;G := F0;while G 6= ∅ do

chooseg ∈ G; supposeg is with schemes;G := G− {g};d′[s] := g(d[s]);G := G ∪ {f ∈ F0 −G | f depends on somei in s such thatd[i] 6= d′[i]};d[s] := d′[s]

od

The following corollary to theGI Theorem 1 and the Update Note 1 summarizesthe correctness of this algorithm.

Page 8: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

Corollary 2 (CD). Suppose that(D, ⊑ ) is a finite partial ordering that is a Carte-sian product of n partial orderings, each with the least element⊥i with i ∈ [1..n]. LetF be a finite set of functions onD, each of the formf+.

Suppose that all functions inF are monotonic and inflationary. Then every execu-tion of theCD algorithm terminates and computes ind the least common fixpoint of thefunctions fromF . ✷

In the subsequent presentation we shall deal with the following two modificationsof theCD algorithm:

– CDI algorithm. This is the version of theCD algorithm in which all the functionsare idempotent and the functionupdate defined in the Update Theorem 2(i) isused.

– CDC algorithm. This is the version of theCD algorithm in which all the functions areidempotent and the combined effect of the functionsupdate defined in the UpdateTheorem 2 is used for some functionComm.

For both algorithms the counterparts of theCD Corollary 2 hold.

4 From Partial Orderings to Constraint Satisfaction Problems

We have been so far completely general in our discussion. Recall that our aim is toderive various constraint propagation algorithms. To be able to apply the results ofthe previous section we need to relate various abstract notions that we used there toconstraint satisfaction problems.

This is perhaps the right place to recall the definition and tofix the notation. Con-sider a finite sequence of variablesX := x1, . . ., xn, wheren ≥ 0, with respectivedomainsD := D1, . . ., Dn associated with them. So each variablexi ranges over thedomainDi. By aconstraintC onX we mean a subset ofD1 × . . .×Dn.

By a constraint satisfaction problem, in short CSP, we mean a finite sequence ofvariablesX with respective domainsD, together with a finite setC of constraints, eachon a subsequence ofX . We write it as〈C ; x1 ∈ D1, . . ., xn ∈ Dn〉, whereX :=x1, . . ., xn andD := D1, . . ., Dn.

Consider now an elementd := d1, . . ., dn of D1 × . . . × Dn and a subsequenceY := xi1 , . . ., xiℓ of X . Then we denote byd[Y ] the sequencedi1 , . . ., diℓ .

By a solution to 〈C ; x1 ∈ D1, . . ., xn ∈ Dn〉 we mean an elementd ∈ D1 ×. . . × Dn such that for each constraintC ∈ C on a sequence of variablesY we haved[Y ] ∈ C. We call a CSPconsistentif it has a solution. Two CSP’sP1 andP2 with thesame sequence of variables are calledequivalentif they have the same set of solutions.This definition extends in an obvious way to the case of two CSP’s with the samesetsof variables.

Let us return now to the framework of the previous section. Itinvolved:

(i) Partial orderings with the least elements;These will correspond to partial orderings on the CSP’s. In each of them the originalCSP will be the least element and the partial ordering will bedetermined by thelocal consistency notion we wish to achieve.

Page 9: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

(ii) Monotonic and inflationary functions with schemes;These will correspond to the functions that transform the variable domains or theconstraints. Each function will be associated with one or more constraints.

(iii) Common fixpoints;These will correspond to the CSP’s that satisfy the considered notion of local con-sistency.

In what follows we shall discuss two specific partial orderings on the CSP’s. In eachof them the considered CSP’s will be defined on the same sequences of variables.

We begin by fixing for each setD a collectionF(D) of the subsets ofD that in-cludesD itself. SoF is a function that given a setD yields a set of its subsets to whichD belongs.

When dealing with the hyper-arc consistencyF(D) will be simply the setP(D) ofall subsets ofD but for specific domains only specific subsets ofD will be chosen. Forexample, to deal with the the constraint propagation for thelinear constraints on integerinterval domains we need to choose forF(D) the set of all subintervals of the originalintervalD.

When dealing with the path consistency, for a constraintC the collectionF(C)will be also the setP(C) of all subsets ofC. However, in general other choices maybe needed. For example, to deal with the cutting planes method, we need to limit ourattention to the sets of integer solutions to finite sets of linear inequalities with integercoefficients (see Apt [1, pages 193-194]).

Next, given two CSP’s,φ := 〈C ; x1 ∈ D1, . . ., xn ∈ Dn〉 andψ := 〈C′ ; x1 ∈D′

1, . . ., xn ∈ D′

n〉, we writeφ ⊑d ψ iff

– D′

i ∈ F(Di) (and henceD′

i ⊆Di) for i ∈ [1..n],– the constraints inC′ are the restrictions of the constraints inC to the domainsD′

1, . . ., D′

n.

Soφ ⊑d ψ if ψ can be obtained fromφ by a domain reduction rule and the domainsof ψ belong to the appropriate collections of setsF(D).

Next, given two CSP’s,φ := 〈C1, . . ., Ck ; DE〉 andψ := 〈C′

1, . . ., C′

k ; DE〉, wewrite φ ⊑c ψ iff

– C′

i ∈ F(Ci) (and henceC′

i ⊆ Ci) for i ∈ [1..k].

In what follows we call⊑d the domain reduction orderingand⊑c the constraintreduction ordering. To deal with the arc consistency, hyper-arc consistency and direc-tional arc consistency notions we shall use the domain reduction ordering, and to dealwith path consistency and directional path consistency notions we shall use the con-straint reduction ordering.

We consider each ordering with some fixed initial CSPP as the least element. Inother words, each domain reduction ordering is of the form

({P ′ | P ⊑d P ′},⊑d)

and each constraint reduction ordering is of the form

({P ′ | P ⊑c P ′},⊑c).

Page 10: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

Note that〈C ; x1 ∈ D′

1, . . ., xn ∈ D′

n〉 ⊑d 〈C′ ; x1 ∈ D′′

1 , . . ., xn ∈ D′′

n〉 iffD′

i ⊇ D′′

i for i ∈ [1..n].This means that forP = 〈C ; x1 ∈ D1, . . ., xn ∈ Dn〉 we can identify the domain

reduction ordering({P ′ | P ⊑d P ′},⊑d) with the Cartesian product of the partial or-derings(F(Di),⊇), wherei ∈ [1..n]. Additionally, each CSP in this domain reductionordering is uniquely determined by its domains and by the initial P .

Similarly,

〈C′

1, . . ., C′

k ; DE〉 ⊑c 〈C′′

1 , . . ., C′′

k ; DE〉 iff C′

i ⊇ C′′

i for i ∈ [1..k].

This allows us forP = 〈C1, . . ., Ck ; DE〉 to identify the constraint reduction ordering({P ′ | P ⊑c P

′},⊑c) with the Cartesian product of the partial orderings(F(Ci),⊇), wherei ∈ [1..k]. Also, each CSP in this constraint reduction ordering is uniquelydetermined by its constraints and by the initialP .

In what follows instead of the domain reduction ordering andthe constraint reduc-tion ordering we shall use the corresponding Cartesian products of the partial orderings.So in these compound orderings the sequences of the domains (respectively, of the con-straints) are ordered componentwise by the reversed subsetordering⊇. Further, in eachcomponent ordering(F(D),⊇) the setD is the least element.

Consider now a functionf on some Cartesian productF(E1)× . . .×F(Em). Notethat f is inflationary w.r.t. the componentwise ordering⊇ if for all (X1, . . ., Xm) ∈F(E1) × . . . × F(Em) we haveYi ⊆ Xi for all i ∈ [1..m], wheref(X1, . . ., Xm) =(Y1, . . ., Ym).

Also, f is monotonic w.r.t. the componentwise ordering⊇ if for all (X1, . . ., Xm),(X ′

1, . . ., X′

m) ∈ F(E1) × . . . × F(Em) such thatXi ⊆ X ′

i for all i ∈ [1..m], thefollowing holds: if

f(X1, . . ., Xm) = (Y1, . . ., Ym) andf(X ′

1, . . ., X′

m) = (Y ′

1 , . . ., Y′

m),

thenYi ⊆ Y ′

i for all i ∈ [1..m].In other words,f is monotonic w.r.t.⊇ iff it is monotonic w.r.t.⊆. This reversal of

the set inclusion of course does not hold for the inflationarity notion.

5 A Hyper-arc Consistency Algorithm

We begin by considering the notion of hyper-arc consistencyof Mohr and Masini [12](we use here the terminology of Marriott and Stuckey [10]). The more known notionof arc consistency of Mackworth [9] is obtained by restricting one’s attention to binaryconstraints.

To employ theCDI algorithm of Section 3 we now make specific choices involvingthe items (i), (ii) and (iii) of the previous section.

Re: (i) Partial orderings with the least elements.As already mentioned in the previous section, for the function F we choose the

powerset functionP , so for each domainD we putF(D) := P(D).Given a CSPP with the sequenceD1, . . ., Dn of the domains we take the domain

reduction ordering withP as its least element. As already noted we can identify this

Page 11: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

ordering with the Cartesian product of the partial orderings (P(Di),⊇), wherei ∈[1..n]. The elements of this compound ordering are thus sequences(X1, . . ., Xn) ofrespective subsets of the domainsD1, . . ., Dn ordered componentwise by the reversedsubset ordering⊇.

Re: (ii) Monotonic and inflationary functions with schemes.Given a constraintC on the variablesy1, . . ., yk with respective domainsE1, . . ., Ek,

we abbreviate for eachj ∈ [1..k] the set{d[j] | d ∈ C} to Πj(C). ThusΠj(C) con-sists of allj-th coordinates of the elements ofC. Consequently,Πj(C) is a subset ofthe domainEj of the variableyj .

We now introduce for eachi ∈ [1..k] the following functionπi onP(E1) × · · · ×P(Ek):

πi(X1, . . ., Xk) := (X1, . . ., Xi−1, X′

i, Xi+1, . . ., Xk)

whereX ′

i := Πi(C ∩ (X1 × · · · ×Xk)).

That is,X ′

i = {d[i] | d ∈ X1 × · · · ×Xk andd ∈ C}. Each functionπi is associatedwith a specific constraintC. Note thatX ′

i ⊆Xi, so each functionπi boils down to aprojection on thei-th component.

Re: (iii) Common fixpoints.Their use is clarified by the following lemma that also lists the relevant properties

of the functionsπi.

Lemma 2 (Hyper-arc Consistency).(i) A CSP〈C ; x1 ∈ D1, . . ., xn ∈ Dn〉 is hyper-arc consistent iff(D1, . . ., Dn) is a

common fixpoint of all functionsπ+

i associated with the constraints fromC.(ii) Each projection functionπi associated with a constraintC is

– inflationary w.r.t. the componentwise ordering⊇,– monotonic w.r.t. the componentwise ordering⊇,– idempotent. ✷

By taking into account only the binary constraints we obtainan analogous charac-terization of arc consistency. The functionsπ1 andπ2 can then be defined more directlyas follows:

π1(X,Y ) := (X ′, Y ),

whereX ′ := {a ∈ X | ∃ b ∈ Y (a, b) ∈ C}, and

π2(X,Y ) := (X,Y ′),

whereY ′ := {b ∈ Y | ∃a ∈ X (a, b) ∈ C}.Fix now a CSPP . By instantiating theCDI algorithm with

F0 := {f | f is aπi function associated with a constraint ofP}

and with each⊥i equal toDi we get theHYPER-ARC algorithm that enjoys followingproperties.

Page 12: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

Theorem 3 (HYPER-ARCAlgorithm). Consider a CSPP := 〈C ; x1 ∈ D1, . . ., xn ∈Dn〉 where eachDi is finite.

TheHYPER-ARC algorithm always terminates. LetP ′ be the CSP determined byP and the sequence of the domainsD′

1, . . ., D′

n computed ind. Then

(i) P ′ is the⊑d-least CSP that is hyper-arc consistent,(ii) P ′ is equivalent toP . ✷

Due to the definition of the⊑d ordering the item(i) can be rephrased as follows.Consider all hyper-arc consistent CSP’s that are of the form〈C′ ; x1 ∈ D′

1, . . ., xn ∈D′

n〉 whereD′

i ⊆Di for i ∈ [1..n] and the constraints inC′ are the restrictions of theconstraints inC to the domainsD′

1, . . ., D′

n. Then among these CSP’sP ′ has the largestdomains.

6 An Improvement: the AC-3 Algorithm

In this section we show how we can exploit an information about the commutativity oftheπi functions. Recall that in Section 3 we modified the notion of commutativity forthe case of functions with schemes. We now need the followinglemma.

Lemma 3 (Commutativity). Consider a CSP and two constraints of it,C on the vari-ablesy1, . . ., yk andE on the variablesz1, . . ., zℓ.

(i) For i, j ∈ [1..k] the functionsπi andπj of the constraintC commute.(ii) If the variablesyi and zj are identical then the functionsπi of C and πj of E

commute. ✷

Fix now a CSP. We derive a modification of theHYPER-ARC algorithm by in-stantiating this time theCDC algorithm. As before we use the set of functionsF0 :={f | f is aπi function associated with a constraint ofP} and each⊥i equal toDi. Ad-ditionally we employ the following functionComm, whereπi is associated with a con-straintC:

Comm(πi) := {πj | i 6= j andπj is associated with the constraintC}∪ {πj | πj is associated with a constraintE and

thei-th variable ofC and thej-th variable ofE coincide}.

By virtue of the Commutativity Lemma 3 each setComm(g) satisfies the assump-tions of the Update Theorem 2(ii).

By limiting oneself to the set of functionsπ1 andπ2 associated with the binaryconstraints, we obtain an analogous modification of the corresponding arc consistencyalgorithm.

Using now the counterpart of theCDCorollary 2 for theCDC algorithm we concludethat the above algorithm enjoys the same properties as theHYPER-ARC algorithm, thatis the counterpart of theHYPER-ARC Algorithm Theorem 3 holds.

Let us clarify now the difference between this algorithm andtheHYPER-ARC al-gorithm when both of them are limited to the binary constraints.

Page 13: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

Assume that the considered CSP is of the form〈C ; DE〉. We reformulate the abovealgorithm as follows. Given a binary relationR, we put

RT := {(b, a) | (a, b) ∈ R}.

ForF0 we now choose the set of theπ1 functions of the constraints or relations fromthe set

S0 := {C | C is a binary constraint fromC}∪ {CT | C is a binary constraint fromC}.

Finally, for eachπ1 function of someC ∈ S0 onx, y we define

Comm(π1) := {f | f is theπ1 function ofCT }∪ {f | f is theπ1 function of someE ∈ S0 onx, z wherez 6≡ y}.

Assume now that

for each pair of variablesx, y at most one constraint exists onx, y. (1)

Consider now the corresponding instance of theCDC algorithm. By incorporatinginto it the effect of the functionsπ1 on the corresponding domains, we obtain the fol-lowing algorithm known as theAC-3 algorithm of Mackworth [9].

We assume here thatDE := x1 ∈ D1, . . ., xn ∈ Dn.

AC-3 ALGORITHM

S0 := {C | C is a binary constraint fromC}∪ {CT | C is a binary constraint fromC};

S := S0;while S 6= ∅ do

chooseC ∈ S; supposeC is onxi, xj ;Di := {a ∈ Di | ∃ b ∈ Dj (a, b) ∈ C};if Di changedthen

S := S ∪ {C′ ∈ S0 | C′ is on the variablesy, xi wherey 6≡ xj}fi;S := S − {C}

od

It is useful to mention that the corresponding reformulation of theHYPER-ARCalgorithm differs in the second assignment toS which is then

S := S ∪ {C′ ∈ S0 | C′ is on the variablesy, z wherey is xi or z is xi}.

So we “capitalized” here on the commutativity of the corresponding projectionfunctionsπ1 as follows. First, no constraint or relation onxi, z for somez is addedto S. Here we exploited part(ii) of the Commutativity Lemma 3.

Second, no constraint or relation onxj , xi is added toS. Here we exploited part(i)of the Commutativity Lemma 3, because by assumption (1)CT is the only constraintor relation onxj , xi and itsπ1 function coincides with theπ2 function ofC.

Page 14: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

In case the assumption (1) about the considered CSP is dropped, the resulting algo-rithm is somewhat less readable. However, once we use the following modified defini-tion ofComm(π1):

Comm(π1) := {f | f is theπ1 function of someE ∈ S0 onx, z wherez 6≡ y}

we get an instance of theCDC algorithm which differs from theAC-3 algorithm inthat the qualification “wherey 6≡ xj ” is removed from the definition of the secondassignment to the setS.

7 A Path Consistency Algorithm

The notion of path consistency was introduced in Montanari [14]. It is defined for spe-cial type of CSP’s. For simplicity we ignore here unary constraints that are usuallypresent when studying path consistency.

Definition 5. We call a CSPnormalizedif it has only binary constraints and for eachpair x, y of its variables exactly one constraint on them exists. We denote this constraintbyCx,y. ✷

Every CSP with only unary and binary constraints is trivially equivalent to a normal-ized CSP. Consider now a normalized CSPP . Suppose thatP = 〈C1, . . ., Ck ; DE〉.

We proceed now as in the case of hyper-arc consistency. First, we choose for thefunctionF the powerset function. For the partial ordering we choose the constraintreduction ordering of Section 4, or rather its counterpart which is the Cartesian productof the partial orderings(P(Ci),⊇), wherei ∈ [1..k].

Second, we introduce appropriate monotonic and inflationary functions with schemes.To this end, given two binary relationsR andS we define their composition· by

R · S := {(a, b) | ∃c ((a, c) ∈ R, (c, b) ∈ S)}.

Note that ifR is a constraint on the variablesx, y andS a constraint on the variablesy, z, thenR · S is a constraint on the variablesx, z.

Given a subsequencex, y, z of the variables ofP we now introduce three functionsonP(Cx,y)× P(Cx,z)× P(Cy,z):

fzx,y(P,Q,R) := (P ′, Q,R),

whereP ′ := P ∩Q ·RT ,

fyx,z(P,Q,R) := (P,Q′, R),

whereQ′ := Q ∩ P · R, and

fxy,z(P,Q,R) := (P,Q,R′),

whereR′ := R ∩ PT ·Q.Finally, we introduce common fixpoints of the above defined functions. To this end

we need the following counterpart of the Hyper-arc Consistency Lemma 2.

Page 15: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

Lemma 4 (Path Consistency).

(i) A normalized CSP〈C1, . . ., Ck ; DE〉 is path consistent iff(C1, . . ., Ck) is a com-mon fixpoint of all functions(fz

x,y)+, (fy

x,z)+ and(fx

y,z)+ associated with the sub-

sequencesx, y, z of its variables.(ii) The functionsfz

x,y, fyx,z andfx

y,z are– inflationary w.r.t. the componentwise ordering⊇,– monotonic w.r.t. the componentwise ordering⊇,– idempotent. ✷

We now instantiate theCDI algorithm with the set of functions

F0 := {f | x, y, z is a subsequence of the variables ofP andf ∈ {fzx,y, f

yx,z, f

xy,z}},

n := k and each⊥i equal toCi.Call the resulting algorithm thePATH algorithm. It enjoys the following properties.

Theorem 4 (PATHAlgorithm). Consider a normalized CSPP := 〈C1, . . ., Ck ; DE〉.Assume that each constraintCi is finite.

ThePATH algorithm always terminates. LetP ′ := 〈C′

1, . . ., C′

k ; DE〉, where thesequence of the constraintsC′

1, . . ., C′

k is computed ind. Then

(i) P ′ is the⊑c-least CSP that is path consistent,(ii) P ′ is equivalent toP . ✷

As in the case of theHYPER-ARCAlgorithm Theorem 3 the item(i) can be rephrasedas follows. Consider all path consistent CSP’s that are of the form〈C′

1, . . ., C′

k ; DE〉whereC′

i ⊆ Ci for i ∈ [1..k]. Then among themP ′ has the largest constraints.

8 An Improvement: the PC-2 Algorithm

As in the case of the hyper-arc consistency we can improve thePATH algorithm bytaking into account the commutativity information.

Fix a normalized CSPP . We abbreviate the statement “x, y is a subsequence of thevariables ofP” to x ≺ y. We now have the following lemma.

Lemma 5 (Commutativity). Suppose thatx ≺ y and letz, u be some variables ofPsuch that{u, z} ∩ {x, y} = ∅. Then the functionsfz

x,y andfux,y commute. ✷

In other words, two functions with the same pair of variablesas a subscript commute.

We now instantiate theCDC algorithm with the same set of functionsF0 as in Sec-tion 7. Additionally, we use the functionComm defined as follows, wherex ≺ y andwherez 6∈ {x, y}:

Comm(fzx,y) = {fu

x,y | u 6∈ {x, y, z}}.

Thus for each functiong the setComm(g) contains preciselym − 3 elements,wherem is the number of variables of the considered CSP. This quantifies the maximal

Page 16: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

“gain” obtained by using the commutativity information: ateach “update” stage of thecorresponding instance of theCDC algorithm we add up tom− 3 less elements than inthe case of the corresponding instance of theCDI algorithm considered in the previoussection.

By virtue of the Commutativity Lemma 5 each setComm(g) satisfies the assump-tions of the Update Theorem 2(ii). We conclude that the above instance of theCDC

algorithm enjoys the same properties as the originalPATH algorithm, that is the coun-terpart of thePATHAlgorithm Theorem 4 holds. To make this modification of thePATH

algorithm easier to understand we proceed as follows.Each function of the formfu

x,y wherex ≺ y andu 6∈ {x, y} can be identified withthe sequencex, u, y of the variables. (Note that the “relative” position ofu w.r.t. x andy is not fixed, sox, u, y does not have to be a subsequence of the variables ofP .) Thisallows us to identify the set of functionsF0 with the set

V0 := {(x, u, y) | x ≺ y, u 6∈ {x, y}}.

Next, assuming thatx ≺ y, we introduce the following set of triples of differentvariables ofP :

Vx,y := {(x, y, u) | x ≺ u} ∪ {(y, x, u) | y ≺ u}∪ {(u, x, y) | u ≺ y} ∪ {(u, y, x) | u ≺ x}.

Informally, Vx,y is the subset ofV0 that consists of the triples that begin or endwith eitherx, y or y, x. This corresponds to the set of functions in one of the followingforms:fy

x,u, fxy,u, f

xu,y andfy

u,x.The above instance of theCDC algorithm then becomes the followingPC-2 algo-

rithm of Mackworth [9]. Here initiallyEx,y = Cx,y.

PC-2 ALGORITHM

V0 := {(x, u, y) | x ≺ y, u 6∈ {x, y}};V := V0;while V 6= ∅ do

choosep ∈ V ; supposep = (x, u, y);applyfu

x,y to its current domains;if Ex,y changedthen

V := V ∪ Vx,y;fi;V := V − {p}

od

Here the phrase “applyfux,y to its current domains” can be made more precise if the

“relative” position ofu w.r.t.x andy is known. Suppose for instance thatu is “before”x andy. Thenfu

x,y is defined onP(Cu,x)× P(Cu,y)× P(Cx,y) by

fux,y(Eu,x, Eu,y, Ex,y) := (Eu,x, Eu,y, Ex,y ∩ E

Tu,x ·Eu,y),

Page 17: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

so the above phrase “applyfux,y to its current domains” can be replaced by the assign-

mentEx,y := Ex,y ∩ E

Tu,x · Eu,y.

Analogously for the other two possibilities.The difference between thePC-2 algorithm and the corresponding representation

of thePATH algorithm lies in the way the modification of the setV is carried out. Inthe case of thePATH algorithm the second assignment toV is

V := V ∪ Vx,y ∪ {(x, u, y) | u 6∈ {x, y}}.

9 Simple Iteration Algorithms

Let us return now to the framework of Section 2. We analyze here when thewhile loopof the GENERIC ITERATION ALGORITHM GI can be replaced by afor loop. First, weweaken the notion of commutativity as follows.

Definition 6. Consider a partial ordering(D, ⊑ ) and functionsf andg onD. We saythatf semi-commutes withg (w.r.t. ⊑ ) if f(g(x)) ⊑ g(f(x)) for all x. ✷

The following lemma provides an answer to the question just posed. Here and else-where we omit brackets when writing repeated applications of functions to an argument.

Lemma 6 (Simple Iteration). Consider a partial ordering(D, ⊑ ) with the least ele-ment⊥. LetF := f1, . . ., fk be a finite sequence of monotonic, inflationary and idem-potent functions onD. Suppose thatfi semi-commutes withfj for i > j, that is,

fi(fj(x)) ⊑ fj(fi(x)) for all x. (2)

Thenf1f2. . .fk(⊥) is the least common fixpoint of the functions fromF . ✷

Proof. We prove first that fori ∈ [1..k] we have

fif1f2. . .fk(⊥) ⊑ f1f2. . .fk(⊥).

Indeed, by the assumption (2) we have the following string ofinclusions, where the lastone is due to the idempotence of the considered functions:

fif1f2. . .fk(⊥) ⊑ f1fif2. . .fk(⊥) ⊑ . . . ⊑ f1f2. . .fifi. . .fk(⊥) ⊑ f1f2. . .fk(⊥).

Additionally, by the inflationarity of the considered functions, we also have fori ∈[1..k]

f1f2. . .fk(⊥) ⊑ fif1f2. . .fk(⊥).

So f1f2. . .fk(⊥) is a common fixpoint of the functions fromF . This means thatthe iteration ofF that starts with⊥, fk(⊥), fk−1fk(⊥), . . ., f1f2. . .fk(⊥) eventuallystabilizes atf1f2. . .fk(⊥). By the Stabilization Lemma 1 we get the desired conclusion.

Page 18: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

The above lemma provides us with a simple way of computing theleast commonfixpoint of a set of finite functions that satisfy the assumptions of this lemma, in par-ticular condition (2). Namely, it suffices to order these functions in an appropriate wayand then to apply each of them just once, starting with the argument⊥.

To this end we maintain the considered functions not in a set but in a list. Given anon-empty listL we denote its head byhead(L) and its tail bytail(L). Next, given asequence of elementsa1, . . ., an with n ≥ 0, we denote by[a1, . . ., an] the list formedby them. Ifn = 0, then this list is empty and is denoted by[ ] and if n > 0, thenhead([a1, . . ., an]) = a1 andtail([a1, . . ., an]) = [a2, . . .an].

The following algorithm is a counterpart of theGI algorithm. We assume in it thatcondition (2) holds for the functionsf1, . . ., fk.

SIMPLE ITERATION ALGORITHM (SI)

d := ⊥;L := [fk, fk−1, . . ., f1];for i := 1 to k do

g := head(L);L := tail(L);d := g(d)

od

The following immediate consequence of the Simple Iteration Lemma 6 is a coun-terpart of theGI Corollary 1.

Corollary 3 (SI). Suppose that(D, ⊑ ) is a partial ordering with the least element⊥. LetF := f1, . . ., fk be a finite sequence of monotonic, inflationary and idempotentfunctions onD such that (2) holds. Then theSI algorithm terminates and computes ind the least common fixpoint of the functions fromF . ✷

Note that in contrast to theGI Corollary 1 we do not require here that the partial or-dering is finite. Because at each iteration of thefor loop exactly one element is removedfrom the listL, at the end of this loop the listL is empty. Consequently, this algorithmis a reformulation of the one in which the line

for i := 1 to k do

is replaced bywhile L 6= [ ] do.

So we can view theSI algorithm as a specialization of theGI algorithm of Section2 in which the elements of the set of functionsG (here represented by the listL) areselected in a specific way and in which theupdate function always yields the emptyset.

In Section 3 we refined theGI algorithm for the case of compound domains. Ananalogous refinement of theSI algorithm is straightforward and omitted. In the nexttwo sections we show how we can use this refinement of theSI algorithm to derive twowell-known constraint propagation algorithms.

Page 19: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

10 DAC: a Directional Arc Consistency Algorithm

We consider here the notion of directional arc consistency of Dechter and Pearl [6]. Toderive an algorithm that achieves this local consistency notion we first characterize itin terms of fixpoints. To this end, given aP and a linear ordering≺ on its variables,we rather reason in terms of the equivalent CSPP≺ obtained fromP by reordering itsvariables along≺ so that each constraint inP≺ is on a sequence of variablesx1, . . ., xksuch thatx1 ≺ x2 ≺ . . . ≺ xk.

The following characterization holds.

Lemma 7 (Directional Arc Consistency).Consider a CSPP with a linear ordering≺ on its variables. LetP≺ := 〈C ; x1 ∈ D1, . . ., xn ∈ Dn〉. ThenP is directionally arcconsistent w.r.t.≺ iff (D1, . . ., Dn) is a common fixpoint of the functionsπ+

1 associatedwith the binary constraints fromP≺. ✷

We now instantiate in an appropriate way theSI algorithm for compound domainswith all theπ1 functions associated with the binary constraints fromP≺. In this waywe obtain an algorithm that achieves forP directional arc consistency w.r.t.≺. First,we adjust the definition of semi-commutativity to functionswith different schemes. Tothis end consider a sequence of partial orderings(D1, ⊑ 1), . . ., (Dn, ⊑ n) and theirCartesian product(D, ⊑ ). Take two functions,f with schemes andg with schemet.We say thatf semi-commutes withg (w.r.t. ⊑ ) if f+ semi-commutes withg+ w.r.t.⊑ , that is if

f+(g+(Q)) ⊑ g+(f+(Q)).

for all Q ∈ D.The following lemma is crucial.

Lemma 8 (Semi-commutativity).Consider a CSP and two binary constraints of it,C1 onu, z andC2 onx, y, wherey ≺ z.

Then theπ1 function ofC1 semi-commutes with theπ1 function ofC2 w.r.t. thecomponentwise ordering⊇. ✷

Consider now a CSPP with a linear ordering≺ on its variables and the corre-sponding CSPP≺. To be able to apply the above lemma we order theπ1 functions ofthe binary constraints ofP≺ in an appropriate way. Namely, given twoπ1 functions,fassociated with a constraint onu, z andg associated with a constraint onx, y, we putfbeforeg if y ≺ z.

More precisely, letx1, . . ., xn be the sequence of the variables ofP≺. Sox1 ≺ x2 ≺. . . ≺ xn. Let form ∈ [1..n] the listLm consist of theπ1 functions of those binaryconstraints ofP≺ that are onxj , xm for somexj . We order each listLm arbitrarily.Consider now the listL resulting from appendingLn, Ln−1, . . ., L1, in that order, sowith the elements ofLn in front. Then by virtue of the Semi-commutativity Lemma 8 ifthe functionf precedes the functiong in the listL, thenf semi-commutes withg w.r.t.the componentwise ordering⊇.

We instantiate now the refinement of theSI algorithm for the compound domainsby the above-defined listL and each⊥i equal to the domainDi of the variablexi. Weassume thatL hask elements. We obtain then the following algorithm.

Page 20: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

DIRECTIONAL ARC CONSISTENCYALGORITHM (DARC)

d := (⊥1, . . .,⊥n);for i := 1 to k do

g := head(L); supposeg is with schemes;L := tail(L);d[s] := g(d[s])

od

This algorithm enjoys the following properties.

Theorem 5 (DARC Algorithm). Consider a CSPP with a linear ordering≺ on itsvariables. LetP≺ := 〈C ; x1 ∈ D1, . . ., xn ∈ Dn〉.

TheDARC algorithm always terminates. LetP ′ be the CSP determined byP≺ andthe sequence of the domainsD′

1, . . ., D′

n computed ind. Then

(i) P ′ is the⊑d-least CSP in{P1 | P≺ ⊑d P1} that is directionally arc consistentw.r.t.≺,

(ii) P ′ is equivalent toP . ✷

Note that in contrast to theHYPER-ARC Algorithm Theorem 3 we do not need toassume here that each domain is finite.

Assume now that for each pair of variablesx, y of the original CSPP there existsprecisely one constraint onx, y. The same holds then forP≺. Suppose thatP≺ :=〈C ; x1 ∈ D1, . . ., xn ∈ Dn〉. Denote the unique constraint ofP≺ on xi, xj by Ci,j .The aboveDARC algorithm can then be rewritten as the following algorithm known astheDAC algorithm of Dechter and Pearl [6]:

for j := n to 2 by −1 dofor i := 1 to j − 1 do

Di := {a ∈ Di | ∃ b ∈ Dj (a, b) ∈ Ci,j}od

od

11 DPC: a Directional Path Consistency Algorithm

In this section we deal with the notion of directional path consistency defined in Dechterand Pearl [6]. As before we first characterize this local consistency notion in terms offixpoints. To this end, as in the previous section, given a normalized CSPP we ratherconsider the equivalent CSPP≺. The variables ofP≺ are ordered according to≺ andon each pair of its variables there exists a unique constraint.

The following is a counterpart of the Directional Arc Consistency Lemma 7.

Lemma 9 (Directional Path Consistency).Consider a normalized CSPP with a lin-ear ordering≺ on its variables. LetP≺ := 〈C1, . . ., Ck ; DE〉. ThenP is directionallypath consistent w.r.t.≺ iff (C1, . . ., Ck) is a common fixpoint of all functions(fz

x,y)+

associated with the subsequencesx, y, z of the variables ofP≺. ✷

Page 21: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

To obtain an algorithm that achieves directional path consistency we now instantiatein an appropriate way theSI algorithm. To this end we need the following lemma.

Lemma 10 (Semi-commutativity).Consider a normalized CSP and two subsequencesof its variables,x1, y1, z andx2, y2, u. Suppose thatu ≺ z.

Then the functionfzx1,y1

semi-commutes with the functionfux2,y2

w.r.t. the compo-nentwise ordering⊇. ✷

Consider now a normalized CSPP with a linear ordering≺ on its variables and thecorresponding CSPP≺. To be able to apply the above lemma we order in an appropriateway thef t

r,s functions, where the variablesr, s, t are such thatr ≺ s ≺ t. Namely, weputfz

x1,y1beforefu

x2,y2if u ≺ z.

More precisely, letx1, . . ., xn be the sequence of the variables ofP≺, that isx1 ≺x2 ≺ . . . ≺ xn. Let for m ∈ [1..n] the list Lm consist of the functionsfxm

xi,xjfor

somexi andxj . We order each listLm arbitrarily and consider the listL resulting fromappendingLn, Ln−1, . . ., L1, in that order. Then by virtue of the Semi-commutativityLemma 9 if the functionf precedes the functiong in the listL, thenf semi-commuteswith g w.r.t. the componentwise ordering⊇.

We instantiate now the refinement of theSI algorithm for the compound domainsby the above-defined listL and each⊥i equal to the constraintCi. We assume thatL hask elements. This yields the DIRECTIONAL PATH CONSISTENCY ALGORITHM

(DPATH) that, apart from of the different choice of the constituentpartial orderings,is identical to the DIRECTIONAL ARC CONSISTENCYALGORITHM DARC of the pre-vious section. Consequently, theDPATH algorithm enjoys analogous properties as theDARC algorithm. They are summarized in the following theorem.

Theorem 6 (DPATH Algorithm). Consider a CSPP with a linear ordering≺ on itsvariables. LetP≺ := 〈C1, . . ., Ck ; DE〉.

TheDPATH algorithm always terminates. LetP ′ := 〈C′

1, . . ., C′

k ; DE〉, where thesequence of the constraintsC′

1, . . ., C′

k is computed ind. Then

(i) P ′ is the⊑c-least CSP in{P1 | P≺ ⊑d P1} that is directionally path consistentw.r.t.≺,

(ii) P ′ is equivalent toP . ✷

As in the case of theDARC Algorithm Theorem 5 we do not need to assume herethat each domain is finite.

Assume now that thatx1, . . ., xn is the sequence of the variables ofP≺. Denote theunique constraint ofP≺ onxi, xj byCi,j .

The aboveDPATH algorithm can then be rewritten as the following algorithm knownas theDPC algorithm of Dechter and Pearl [6]:

for m := n to 3 by −1 dofor j := 1 to m− 1 do

for i := 1 to j − 1 doCi,j := Ci,m · CT

j,m

odod

od

Page 22: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

12 Conclusions

In this article we introduced a general framework for constraint propagation. It allowedus to present and explain various constraint propagation algorithms in a uniform way.Using such a single framework we can easier verify, compare,modify, parallelize orcombine these algorithms. The last point has already been made to large extent in Ben-hamou [2]. Additionally, we clarified the role played by the notions of commutativityand semi-commutativity.

The line of research presented here could be extended in a number of ways. First, itwould be interesting to find examples of existing constraintpropagation algorithms thatcould be improved by using the notions of commutativity and semi-commutativity.

Second, as already stated in Apt [1], it would be useful to explain in a similar wayother constraint propagation algorithms such as theAC-4 algorithm of Mohr and Hen-derson [11], thePC-4 algorithm of Han and Lee [8], or theGAC-4 algorithm of Mohrand Masini [12]. The complication is that these algorithms operate on some extensionof the original CSP.

Finally, it would be useful to apply the approach of this paper to derive constraintpropagation algorithms for the semiring-based constraintsatisfaction framework ofBistarelli, Montanari and Rossi [4] that provides a unified model for several classesof “nonstandard” constraints satisfaction problems.

References

1. K. R. Apt. The essence of constraint propagation.Theoretical Computer Science, 221(1–2):179–210, 1999. Available viahttp://xxx.lanl.gov/archive/cs/.

2. F. Benhamou. Heterogeneous constraint solving. In M. Hanus and M. Rodriguez-Artalejo,editors, Proceeding of the Fifth International Conference on Algebraic and Logic Pro-gramming (ALP 96), Lecture Notes in Computer Science 1139, pages 62–76, Berlin, 1996.Springer-Verlag.

3. F. Benhamou and W. Older. Applying interval arithmetic toreal, integer and Boolean con-straints.Journal of Logic Programming, 32(1):1–24, 1997.

4. S. Bistarelli, U. Montanari, and F. Rossi. Semiring-based constraint satisfaction and opti-mization.Journal of the ACM, 44(2):201–236, March 1997.

5. R. Dechter. Bucket elimination: A unifying framework forstructure-driven inference.Arti-ficial Intelligence, 1999. To appear.

6. R. Dechter and J. Pearl. Network-based heuristics for constraint-satisfaction problems.Ar-tificial Intelligence, 34(1):1–38, January 1988.

7. R. Dechter and P. van Beek. Local and global relational consistency.Theoretical ComputerScience, 173(1):283–308, 20 February 1997.

8. C. Han and C. Lee. Comments on Mohr and Henderson’s path consistency algorithm.Arti-ficial Intelligence, 36:125–130, 1988.

9. A. Mackworth. Consistency in networks of relations.Artificial Intelligence, 8(1):99–118,1977.

10. K. Marriott and P. Stuckey.Programming with Constraints. The MIT Press, Cambridge,Massachusetts, 1998.

11. R. Mohr and T.C. Henderson. Arc-consistency and path-consistency revisited.ArtificialIntelligence, 28:225–233, 1986.

Page 23: The Rough Guide to Constraint PropagationarXiv:cs/9909009v1 [cs.AI] 8 Sep 1999 The Rough Guide to Constraint Propagation Krzysztof R. Apt1,2 1 CWI P.O. Box 94079, 1090 GB Amsterdam,

12. R. Mohr and G. Masini. Good old discrete relaxation. In Y.Kodratoff, editor,Proceedingsof the 8th European Conference on Artificial Intelligence (ECAI), pages 651–656. PitmanPublishers, 1988.

13. E. Monfroy and J.-H. Rety. Chaotic iteration for distributed constraint propagation. InJ. Carroll, H. Haddad, D. Oppenheim, B. Bryant, and G. Lamont, editors,Proceedings of The1999 ACM Symposium on Applied Computing, SAC’99, pages 19–24, San Antonio, Texas,USA, March 1999. ACM Press.

14. U. Montanari. Networks of constraints: Fundamental properties and applications to pictureprocessing.Information Science, 7(2):95–132, 1974. Also Technical Report, Carnegie Mel-lon University, 1971.

15. V.A. Saraswat, M. Rinard, and P. Panangaden. Semantic foundations of concurrent constraintprogramming. InProceedings of the Eighteenth Annual ACM Symposium on Principles ofProgramming Languages (POPL’91), pages 333–352, 1991.

16. V. Telerman and D. Ushakov. Data types in subdefinite models. In J. A. Campbell J. Calmetand J. Pfalzgraf, editors,Artificial Intelligence and Symbolic Mathematical Computations,Lecture Notes in Computer Science 1138, pages 305–319, Berlin, 1996. Springer-Verlag.

17. E. Tsang.Foundations of Constraint Satisfaction. Academic Press, 1993.