Corretness of Constraint Retration Algorithms Romuald Debruyne1 , Gerard Ferrand2 , Narendra Jussien1 , Willy Lesaint2 , Samir Ouis1 et Alexandre Tessier2 1 Eole des Mines de Nantes 2 Universit e d'Orleans, LIFO Rapport No 2002-09 Abstrat Using a ltering tehnique is ruial to redue the searh spae. Most of the solvers (eg. hip, gnuProlog, Ilog solver, hoo) use redution operators and a propagation mehanism to enfore a loal onsisteny. This sheme is quite universally used on stati sps. But we do not have suh an unanimity when relaxing onstraints. Several tehniques have been proposed to deal with dynamiity. The problem we address here is two-fold. First, we highlight that it is possible to generalize the proposed tehniques to relax onstraints. Seond, we show a suÆient work to do in order to inrementally relax a onstraint. 1 Introdution Enforing a loal onsisteny allows reduing the searh spae. Suh a redution an be performed before searh, to obtain an equivalent problem potentially less ostly to solve. But the main interest is to use ltering tehniques during searh, propagating eah hoie and so eliminating some branhes of the searh tree that annot lead to a solution. Most of the solvers (eg. hip [2℄, gnuProlog [12℄, Ilog solver [19℄, hoo [25℄) use the same sheme: they enfore a loal onsisteny using redution operators and a propagation mehanism. However, the way of handling onstraint relaxation is not that unanimous. With dynami sps, the user an speify its problem alternatively adding and relaxing onstraints. Maintaining global onsisteny is too prohibitive but we an maintain a loal onsisteny to have an evaluation of the existene of a solution. The stronger the loal onsisteny, the better the evaluation. In this ontext, algorithms [7, 11, 23, 15℄ store information in an (a)tms-like [13, 10℄ way or analyze redutions operators [6, 18℄ to be able to identify the past eet of a onstraint and so to inrementally relax it. When dealing with dynamiity during searh, allowing both to relax past hoies and onstraints, explanation sets [23, 24℄ are kept. In this paper, we present a general sheme for all these tehniques, showing the similarities of these approahes to eÆiently relax onstraints. Another ontribution is the determination of a suÆient work to do in order to inrementally relax a onstraint. After some realls on the loal onsisteny propagation mehanisms, we present a general sheme to perform onstraint retration. We then highlight some properties ensuring the orretness of onstraint relaxation, and we show the relations with previous works before onluding remarks. 2 Preliminaries In this setion, the denition of a onstraint satisfation problem is realled. The notations introdued are well-suited to the desription of domain redution in terms of losure. A domain redution aused by a onstraint and a loal onsisteny is formalized by the appliation of some loal onsisteny operators. 1 This work is partially supported by the Frenh RNTL (Reseau National des Tehnolo- gies Logiielles) projet OADymPPaC (Outils pour l'Analyse Dynamique et la mise au Point de Programmes ave Contraintes). http://ontraintes.inria.fr/OADymPPaC/ 2 The propagation mehanism used in the solvers is desribed thanks to iterations of suh operators. 2.1 Notations Following [27℄, a Constraint Satisfation Problem (sp) is made of two parts: a syntati part and a semanti part. The syntati part is a nite set V of variables, a nite set C of onstraints and a funtion var : C ! P (V ), whih assoiates a set related variables to eah onstraint. Indeed, a onstraint may involve only a subset of V . For the semanti part, we need to introdue some preliminary onepts. We onsider various families f = (fi )i2I . Suh a family is referred to by the funtion i 7! fi or by the set f(i; fi ) j i 2 I g. Eah variable is assoiated to a set of possible values. Therefore, we onsider a family (Dx )x2V where eah Dx is S a nite non empty set. We dene the domain by D = x2V (fxg Dx ). This domain allows simple and uniform denitions of (loal onsisteny) operators on a power-set. For domain redution, we onsider subsets d of D . Suh a subset is alled an environment. We denote by djW the restrition of a set d D to a set of variables W V , that is, djW = f(x; e) 2 d j x 2 W g. Any d D is atually a family (dx )x2V with dx Dx : for x 2 V , we dene dx = fe 2 Dx j (x; e) 2 dg and all it the environment of x (in d). Constraints are dened by their set of allowed tuples. A tuple t on W V is a partiular environment suh that eah variable of W appears only one: t D jW and 8x 2 W; 9e 2 Dx ; tjfxg = f(x; e)g. For eah 2 C , T is a set of tuples on var(), alled the solutions of . Note that a tuple t 2 T is equivalent to a family (ex )x2var() and note that t is identied with f(x; ex ) j x 2 var()g. We an now formally dene a sp. Denition 1 A Constraint Satisfation Problem ( sp) is dened by: 2.2 a nite set V of variables; a nite set C of onstraints; a funtion var : C ! P( V ); a family (Dx )x2V (the domains); a family (T )2C (the onstraints semantis). An illustrative onstraint solver From now on, we will illustrate onepts and results using the PaLM onstraint solver [22℄. PaLM is a onstraint solver built on top of the free onstraint solver2 2 hoo is an open soure onstraint engine developed as the kernel of the OCRE projet. The OCRE projet (Outil Contraintes pour la Reherhe et l'Enseignement ) aims at building free Constraint Programming tools that anyone in the Constraint Programming and Constraint Reasoning ommunity an use. http://www.hoo-onstraints.net/ 3 [25℄. The interest of hoo (and therefore PaLM) is that the implemented onepts are generally the same as in \ommerial" onstraint solvers (eg. hip [2℄, gnuProlog [12℄, Ilog solver [19℄). The PaLM objet model (based upon the hoo model) is a diret implementation of the theoretial framework introdued before. Indeed, a onstraint problem in PaLM is dened by a set of variables (with their assoiated domain) and a set of onstraints (dened in extension by a set of allowed tuples). PaLM is an event-based onstraint solver: during propagation, onstraints are awaken (like agents or daemons) through the all to redution operators eah time a variable environment is redued (this is an event) possibly generating new events (value removals). There are therefore two key onepts that needs some details: the domain redution mehanism (the redution operators) and the propagation mehanism itself. hoo 2.3 Domain redution mehanisms In the PaLM model, a onstraint is fully haraterized by its behavior regarding the basi events suh as value removal from the environment of a variable (method awakeOnRem) and environment bound updates (methods awakeOnInf and awakeOnSup). Example 1 (Constraint x y + ) This is one of the basi onstraints in hoo. It is represented by the GreaterOrEqualxy lass. Reating to an upper bound update for this onstraint an be stated as: if the upper bound of x is modied then the upper bound of y should be lowered to the new value of the upper bound of x (taking into aount the onstant ). This is enoded as: [awakeOnSup(:GreaterOrEqualxy,idx:integer) -> if (idx = 1) updateSup(.v2,.v1.sup - .ste)℄ idx is the index of the variable of the onstraint whose bound (the upper bound here) has been modied. This partiular onstraint only reats to modiation of the upper bound of variable x (.v1 in the hoo representation of the onstraint). The updateSup method only modies the value of y (.v2 in the onstraint) when the upper bound is really updated. More generally, we an onsider that some loal onsisteny operators are assoiated with the onstraints. Suh an operator has a type (Win ; Wout ) with Win ; Wout V . For the sake of larity, we will onsider in our formal presentation that eah operator is applied to the whole environment, but, as shown above, it only modies the environments of Wout and this result only depends on the environments of Win . It removes from the environments of Wout some values whih are inonsistent with respet to the environments of Win . In example 1, the awakeOnSup method an be onsidered as a loal onsisteny operator with Win = f:v1g and Wout = f:v2g. Formally: Denition 2 A loal onsisteny operator of type (Win ; Wout ), with Win ; Wout V , is a monotoni funtion r : P (D ) ! P (D ) suh that: 8 D , d 4 ( )jV nW r d out = D j V nW , out ( ) = r(djW ) r d in Classially [15, 28, 5, 4℄, redution operators are onsidered as monotoni, ontratant and idempotent funtions. However, on the one hand, ontratane is not mandatory beause environment redution after applying a given operator r an be fored by interseting its result with the urrent environment, that is d \ r(d). What is important is the operator r and not d 7! d \ r(d) as shown further in the text when dening dual operators. On the other hand, idempotene is useless from a theoretial point of view (it is only useful in pratie for managing the propagation queue). This is generally not mandatory to design eetive onstraint solvers. We an therefore use only monotoni funtions in denition 2. We just need to speify that only the environments of Wout are modied (rst item in denition 2) and that the result only depends on the environments of Win (seond item). The solver semantis is ompletely desribed by the set of suh operators assoiated with the handled onstraints. More or less aurate loal onsisteny operators may be seleted for eah onstraints (eg. handling allDifferent onstraints using Regin's algorithms [26℄ or using liques of dierenes onstraints). Moreover, our framework is not limited to ar-onsisteny but may handle any loal onsisteny whih boils down to domain redution as shown in [16℄. Of ourse loal onsisteny operators should be orret with respet to the onstraints. In pratie, to eah onstraint 2 C is assoiated a set of loal onsisteny operators R(). The set R() is suh that for eah r 2 R(): the type of r is (Win ; Wout ) with Win ; Wout var(); and for eah d D , for eah t 2 T , t d ) t r (d). 2.4 The propagation mehanism: iterations Propagation in PaLM is handled through a propagation queue (ontaining events or onversely operators to awake). Informally, starting from the given initial environment for the problem, a loal onsisteny operator is seleted from the propagation queue (initialized with all the operators) and applied to the environment resulting to a new one. If an environment redution ours, new operators (or new events) are added to the propagation queue. Termination is reahed when: a variable environment is emptied: there is no solution to the assoiated problem; the propagation queue is emptied: a ommon x-point (or a desired onsisteny state) is reahed ensuring that further propagation will not modify the result. The resulting environment is atually obtained by sequentially applying a given sequene of operators. To formalize this result, let onsider iterations. The following denition is taken from Apt [3℄. 5 Denition 3 The iteration from the initial environment to an innite sequene of operators of R: r ; r ; : : : environments d0 ; d1 ; d2 ; : : : indutively dened by: 1 1. d 0 2 D with respet is the innite sequene of d = d; 2. for eah i 2 IN, d i+1 = di \ r i+1 (di ). Its limit is \i2IN di . A haoti iteration is an iteration with respet to a sequene of operators of R (with respet to R in short) where eah r 2 R appears innitely often. The most aurate set whih an be omputed using a set of loal onsisteny operators in the framework of domain redution is the downward losure. Chaoti iterations have been introdued for this aim in [14℄. Denition 4 The downward losure of d by a set of operators j 0 8 2 D d d; r R; d 0 r(d0 )g and is denoted by CL #( #( d; R ). R is maxfd0 Note that C L # (d; ;) = d and, if R0 R, then C L d; R) C L # (d; R0 ). Obviously, eah solution to the problem is in the downward losure. It is easy to hek that T C L # (d; R) exists and an be obtained by iteration of the operator d0 7! d0 \ r2R r(d0 ). Using haoti iteration provides another way to ompute C L # (d; R) [9, 15℄. Iterations proeed by elementary steps, using only one loal onsisteny operator at eah step. Chaoti iterations is a onvenient theoretial denition but in pratie eah iteration is nite and fair in some sense. Lemma 1 The limit of every haoti iteration of the set of loal onsisteny operators r 1 R from d D is the downward losure of d by R . Proof: Let d0 ; d1 ; d2 ; : : : be a haoti iteration of R from d with respet to 2 1 be the limit of the haoti iteration. ; r ; : : : Let d CL #( ) )) 1 : For eah i, C L # (d; R) di , by indution: C L # d = d. Assume C L # (d; R) di , C L # (d; R) ri+1(C L # i+1 (di ) by monotoniity. Thus, C L # (d; R) di \ ri+1 (di ) = r d; R ) d (d; R (d; R i+1 . d 1 C L # (d; R): There exists k 2 IN suh that d1 = dk beause d is a well-founded ordering. The iteration is haoti, hene dk is a ommon x-point of the set of redution operators assoiated with R, thus dk C L # (d; R) (the greatest ommon x-point). 0 The previous well-known result of onuene [9, 14, 4℄ ensures that any haoti iteration reahes the losure. Notie that, sine is a well-founded ordering (i.e. D is a nite set), every iteration from d D (obviously dereasing) is stationary, that is, 9i 2 IN; 8j i; dj = di : in pratie omputation ends when a ommon x-point is reahed (eg. using a propagation queue). 6 3 Constraint retration Constraint retration is a ommonly addressed issue in onstraint programming: it helps handling dynami problems. Several approahes have been proposed: using a (a)tms-like [13, 10℄ mehanism [7, 11, 23, 15℄ or only analyzing redution operators [6, 18℄. A ommon behavior an be identied for both approahes. 3.1 Performing onstraint retration Following [18℄, onstraint retration is a two-phases proess: enlarging the urrent environment (in order to undo past eets of the retrated onstraint) and restoring a given onsisteny for the resulting onstraint network. More preisely, the inremental retration of a given onstraint is performed through the following steps [21℄: 1. Disonneting The rst step is to ut from the onstraint network. needs to be ompletely disonneted (and therefore will never get propagated again in the future). 2. Setting bak values The seond step, is to undo the past eets of the onstraint. Both diret (eah time the onstraint operators have been applied) and indiret (further onsequenes of the onstraint through operators from other onstraints) eets of that onstraint. This step results in the enlargement of the environment: values are put bak. 3. Controlling what has been done Some of the put bak values an be removed applying other ative operators (i.e. operators assoiated with non retrated onstraints). Those environment redutions need to be performed. 4. Repropagation Those new environment redutions need to be propagated. At the end of this proess, the system is in a onsistent state. It is exatly the state that would have been obtained if the retrated onstraint would not have been introdued into the system. This proess enompasses both (a)tms-like methods and tms-free methods. The only dierene relies on the way values to set bak are determined. 3.2 Computing domain enlargements (a)tms-like methods reord information to allow an easy omputation of values to set bak into the environment upon a onstraint retration. [7℄ and [11℄ use justiations : for eah value removal the applied responsible onstraint is reorded. [15℄ uses a dependeny graph to determine the portion of past omputation to be reset upon onstraint retration. More generally, those two methods amount to reord some dependeny information about past omputation. A generalization [23, 24℄ of both previous 7 tehniques rely upon the use of explanation-sets : a set (subset of all the existing operators) of operators responsible for a value removal during omputation. Denition 5 Let R be the set of all existing loal onsisteny operators in the onsidered problem. Let h 2 D and d D . We all explanation-set for h w.r.t. d a set of loal onsisteny operators E R suh that h 62 C L # (d; E ). Sine E R, C L # (d; R) C L # (d; E ). Hene, if E is an explanation-set for h then eah super-set of E is an explanation-set for h. An explanation-set E is independent of any haoti iteration with respet to R in the sense of: if the explanation-set is responsible for a value removal then whatever the haoti iteration used, the value will always be removed. Notie that when h 62 d, d being the initial environment, ; is an explanation-set for h. Explanation-sets allow a diret aess to diret and indiret onsequenes of a given onstraint . For eah h 62 C L # (d; R) an explanation-set is hosen and denoted by expl(h). To retrat a onstraint amounts to retrat some operators. The new set S 3 new of operators is R = 2C nfg R(0 ). The environment enlargement to be done (value removal to undo) onsidering the retration of onstraint is the set: 0 f 2 j9 2 n h d r R R new ; r 2 expl(h)g (1) Notie that both the justiations of [7, 11℄ and the dependeny graph of [15℄ give a (often strit) super-set of the set of equation 1. Moreover, the tehniques used in tms-free approahes [6, 18℄ amount to ompute a super-set of equation 1 on demand. 3.3 Operational omputation of explanation-sets The most interesting explanations (and onits) are those whih are minimal regarding inlusion. Those explanations allow highly foused information about dependeny relations between onstraints and variables. Unfortunately, omputing suh an explanation an be exponentially ostly [20℄. Several explanations generally exist for the removal of a given value. [24, 23, 21℄ show that a good ompromise between preision and ease of omputation of explanation-sets is to use the solver-embedded knowledge. Indeed, onstraint solvers always know, although it is sarely expliit, why they remove values from the environments of the variables. By making that knowledge expliit and therefore kind of traing the behavior of the solver, quite preise explanationsets an be omputed. Explanation-sets for value removals need to be omputed when the removal is atually performed i.e. within the propagation ode of the onstraints (namely in the denition of the loal onsisteny operators { the awakeOnXXX 3 The original set of operators R is S ( 0 ) where 0 2C R operators assoiated with the onstraint 0 . 8 ( 0 ) is the set of loal onsisteny R methods of PaLM). Extra information needs to be added to the updateInf or updateSup alls: the atual explanation-set. Example 2 shows how suh an explanation-set an be omputed and what the resulting ode is for a basi onstraint. Example 3 gives another point of view on explanations for lassial binary sp (onsidering ar-onsisteny enforement). Example 2 (Modifying the solver) It is quite simple to make modiations onsidering example 1. Indeed, all the information is at hand in the awakeOnSup method. The modiation of the upper bound of variable .v2 (y ) is due to: (a) the all to the onstraint (operator) itself (it will be added to the omputed explanation); (b) the previous modiation of the upper bound of variable .v1 (x) that we aptured through the alling variable (idx). The soure ode is therefore modied in the following way (the additional third parameter for updateSup ontains the explanation-set attahed to the intended modiation): [awakeOnSup(:GreaterOrEqualxy,idx:integer) -> if (idx = 1) updateSup(.v2, .v1.sup - .ste, beauseOf(, theSup(.v1)))℄ The beauseOf method builds up an explanation from its event-parameters. Example 3 (Explanation-sets for ar-onsisteny enforement) Explanation-sets for lassial binary sp (onsidering ar-onsisteny enforement) an be easily stated. When applying onstraint xy between variables x and y , we want to remove value a from the environment of x if and only if all supporting values for a (fb j f(x; a); (y; b)g 2 Txy g) in the environment of y regarding onstraint xy have been removed. This an be expressed this way: [ expl(x; a) = fxy g [ b 4 supp: expl(y; b) a Corretness of onstraint retration In order to give a proof of the orretness of a family of onstraint retration algorithms, inluding PaLM algorithm, rule systems assoiated with loal onsisteny operators are going to be dened. Proofs (trees) of value removal are dedued from these rules and alled explanation-trees. Explanation-trees are the basi tools of this theoretial framework. 4.1 Explanation-trees Denition 6 A dedution rule of type (Win ; Wout ) is a rule h h 2 D jW out and B D jW in . 9 B suh that A dedution rule h B an be understood as follows: if all the elements of B are removed from the environment, then h does not appear in any solution of the sp and may be removed harmlessly. A set of dedution rules Rr may be assoiated with eah loal onsisteny operator r. It is intuitively obvious that this is true for ar-onsisteny but it has been proved in [17℄ that for any loal onsisteny whih boils down to domain redution it is possible to assoiate suh a set of rules. Moreover there exists a natural set of rules for lassial loal onsistenies [16℄. It is important to note that, in the general ase, there may exist several rules with the same head but dierent bodies. A set of rules assoiated with a loal onsisteny operator r denes its dual operator [1℄. The dual operator of r is d 7! r(d). It is the reason why r has been dened and not the ontratant operator (d 7! d \ r(d)). We onsider the set R of all the dedution rules for all the loal onsisteny operators of R dened by R = [r2R Rr . The initial environment must be taken into aount in the set of dedution rules. The iteration starts from an environment d D , then it is neessary to add fats (dedution rules with an empty body) in order to diretly dedue the elements of d: let Rd = fh ; j h 2 dg be this set. Denition 7 A proof tree [1℄ with respet to a set of rules R [ Rd is a nite tree suh that for eah node labeled by h, let B be the set of labels of its hildren, d B 2 R [R . h Proof trees are losely related to the omputation of environment redution. Let d = d0 ; : : : ; di ; : : : be an iteration. For eah i, if h 62 di then h is the root of a proof tree with respet to R [ Rd . More generally, C L # (d; R) is the set of the roots of proof trees with respet to R [ Rd (see [17℄). Eah dedution rule used in a proof tree omes from a paket of dedution rules, either from a paket Rr dening a loal onsisteny operator r, or from Rd . A set of loal onsisteny operators an be assoiated with a proof tree: Denition 8 Let t be a proof tree. A set of loal onsisteny operators assoiated with t is a set X suh that, for eah node of t: let h be the label of the node and B the set of labels of its hildren: either h 62 d (and or there exists r B 2 = ;); X; h B 2 Rr . Note that there may exist several sets assoiated with a proof tree, for example a same dedution rule may appear in several pakets. Moreover, eah super-set of a set assoiated with a proof tree is also onvenient (R is assoiated with all proof trees). It is important to reall that the root of a proof tree does not belong to the losure of the initial environment d by the set of loal onsisteny operators R. So there exists an explanation-set (denition 5) for this value. 10 Lemma 2 If t is a proof tree, then eah set of loal onsisteny operators assoiated with t is an explanation-set for the root of t. Proof: Beause C L # (d; R) is the set of the roots of proof trees with respet to R [ Rd and denition 5. From now on a proof tree with respet to R [ Rd is therefore alled an explanation-tree. We proved that we an nd explanation-sets in explanationtrees. So it remains to nd explanation-trees. We are interested in those whih an be dedued from a omputation. From now on, we onsider a xed iteration d = d0 ; d1 ; : : : ; di ; : : : of R with respet to r1 ; r2 ; : : :. In order to inrementally dene explanation-trees during an iteration, let (S i )i2IN be the family reursively dened as, where ons(h; T ) is the tree dened by h is the label of its root and T is the set of its subtrees, and where root(ons(h; T )) = h: S S = fons(h; ;) j h 62 dg, 0 i+1 = S i [ fons(h; T ) j h 2 di ; T froot( ) j 2 g 2 Rr +1 g. i S ;h t t T i It is important to note that some explanation-trees do not orrespond to any iteration, but when a value is removed there always exists an explanation-tree S i in i S for this value removal. It is easy to show (see [16℄ for the details) that: Lemma 3 froot(t) j t 2 S i g = di . Proof: By indution on i. S Note that when the iteration is haoti (i.e. fair) i di = C L # (d; R). Among the explanation-sets assoiated with an explanation-tree t 2 S i , one is preferred. This explanation-set is denoted by expl(t) and dened as follows: where t = ons(h; T ) if 2 then expl( ) = ;, else exists 0 suh that 2 S there 0 expl( ). t S 0 t i > t 2T 0 t S i n S i 1 , then expl(t) = f ig [ r t In fat, expl(t) is expl(h) dened in setion 3.2) where t is rooted by h. Note that there an exist several explanation-trees for the removal of an element Sh. But there an also exists several explanation-trees with the same root in i S i (see [16℄). Indeed for a given operator, there an exist several appliable rules with the same head4 h. But here, it is suÆient to retain only one of them. A way to formalize this is to keep only one of them in the denition of S i when several appliable rules have the same head. In the following, we will assoiate a single explanation-tree, and therefore a single explanation-set, to eah element h removed during the omputation. This set will be denoted by expl(h). 4 In the partiular ase of ar onsisteny, for eah element h there exists at most one rule of head h assoiated with an operator. 11 4.2 Constraint retration Let us onsider a nite iteration from an initial environment d with respet to a set of operators R. At the step i of this iteration, the omputation is stopped. The urrent environment is di . Note that this environment is not neessarily the losure of d by R (we have C L # (d; R) di d). At this ith step of the omputation, some onstraints have to be retrated. Following setion 3.1, performing onstraint retration amounts to: 4.2.1 disonneting of operators to onsider is new , where new = SThat is the( ),new0 set is the set of retrated onstraints. Constraint retration R R R 2C nC amounts to ompute the losure of d by Rnew . 0 R C 4.2.2 setting bak values That is, instead of starting a new iteration from d, we want to benet from the previous omputation of di . Thanks to explanation-sets, we know the values of d n di whih have been removed beause of a retrated operator (that is an operator of R n Rnew ). This set of values is dened by d0 = fh 2 d j 9r 2 new ; r 2 expl(h)g and must be re-introdued in the domain. The next R n R theorem ensures that we obtain the same losure if the omputation starts from d or from di [ d0 . That is, it ensures the orretness of all the algorithms whih re-introdue a super-set of d0 . Theorem 1 CL #( d; R new ) = C L # (di [ d0 ; Rnew ) Proof: : beause di [ d0 d and the losure operator is monotoni. : we prove C L # (d; Rnew ) di [ d0. Redutio ad absurdum: let h 2 C L # (d; Rnew ) but h 62 di [ d0 . h 62 di , so expl(h) exists. either expl(h) Rnew , so h 62 C L # (d; Rnew ): ontradition. either expl(h) 6 Rnew , so h 2 d0 : ontradition. Thus, C L # (d; Rnew ) di [ d0 and so, by monotoniity: new C L # (C L # (d; R ); Rnew ) C L # (di [ d0 ; Rnew ). qed. We have proved that when a set of operators is removed, we do not have to re-ompute the losure from the initial environment. But we just have to add some values to the urrent environment and to ontinue the omputation from this point. The resulting environment will be the same. i.e. the enlargement step of onstraint retration as implemented in PaLM is valid. For any loal onsisteny, as said before, the omputed explanation-set is not unique. In this setion, we onsider that we always keep only one explanationset for eah element removed. But it ould be possible to keep all the (omputed) explanation-sets for eah removed element. In this ase, if there exists an explanation-set whih ontains only operators of Rnew then this explanation-set 12 remains valid. Then, the set d0 of elements to re-introdue in the environment should be the set of elements for whih all the explanation-sets ontains at least one operator of R n Rnew . A seond improvement is that we do not need to put all the operators in the propagation queue. 4.2.3 Controlling what has been done and repropagation In pratie the iteration is done with respet to a sequene of operators whih is dynamially omputed thanks to a propagation queue. At the ith step, before setting values bak, the set of operators whih are in the propagation queue is i i new must stay in the propagation queue. R . Obviously, the operators of R \ R new i The other operators (R n R ) annot remove any element of di, but they may remove an element of d0 (the set of re-introdued values). So we have to put bak in the propagation queue some of them: the operators of the set 0 new j 9h 0 R = fr 2 R B 2 Rr ; h 2 d g. The next theorem ensures that the i 0 operators whih are not in R [ R do not modify the environment di [ d0 , so it is useless to put them bak into the propagation queue. That is it ensures the orretness of all algorithms whih re-introdue a super-set of R0 in the propagation queue. Theorem 2 8 2 r R new n( i[ R R 0 ); di [ d0 r(di [ d0 ) Proof: we prove di r(di [ d0 ): i r (di ) d beause Rnew n (Ri [ R0 ) Rnew n Ri i 0 r(d [ d ) beause r is monotoni we prove d0 r(di [ d0 ): Redutio ad absurdum: let h 2 d0 but h 62 r(di [ d0 ). Then there exists 0 new h B 2 Rr , that is r 2 fr 2 R j 9h B 2 Rr ; h 2 d0 g, then r 62 new R n (Ri [ R0): ontradition. Thus d0 r(di [ d0). Therefore, by the two theorems, eah algorithm whih restarts with a propagation queue inluding Ri [ R0 and an environment inluding di [ d0 is proved orret. Among others the PaLM algorithm for onstraint retration is orret. 0 5 Disussion Another way to perform onstraint retration has been proposed in [18℄. The main dierene with our work is that they do not modify the solver mehanism. Indeed, onstraints dependenies are omputed only when a onstraint has to be removed. In these onditions, the omparison with our work is diÆult. Nevertheless, the orretion of their proposed algorithms is ensured by three lemmas. It is important to note that these three lemmas are veried here. The method we have hosen to perform onstraint retration onsists in reording dependenies during the omputation. Suh a method has also been used in [15℄ thanks to a dependeny graph. They say: \Note that the onstraint dependeny graph is not optimal in the sense that it forgets whih onstraint removed whih value from a variable domain". In other words, if the relaxed 13 onstraint has removed values of a variable x, then all these values are restored. Next, if another onstraint has removed values of another variable y beause of an environment redution of x then all of them are put bak even if the removal of a value of y is the onsequene of the removal of a value of x whih has not been removed by . So thanks to our more preise notion of explanation, less values are restored. Note that sine [8℄ uses a simpler dependeny graph for intelligent baktraking, the same remark an be done about preision. Furthermore, beause of dynami baktraking, onstraints are relaxed only when a failure ours. Thus their algorithms are members of the family of algorithms proved orret here. Like PaLM, DnAC-* algorithms (DnAC-4 [7℄, DnAC-6 [11℄) perform a onstraint relaxation in two phases. First, they ompute an overestimation of d0 , then they remove the restored values that are not ar-onsistent. To determine the set of values to restore, DnAC-* algorithms store a justiation, namely the rst enountered onstraint on whih the value has no support, for eah value deletion. The aim of this data struture is the same than the one of the explanation-sets, but justiations store only the diret eets of a onstraint: the indiret eets have to be omputed by propagation. DnAC-* algorithms restore the values whose deletion was diretly justied by the relaxed onstraint, or that have a restored support on their justiation. The values that are not restored still have a valid justiation, namely a onstraint on whih they have no support. Therefore, all the values diretly or indiretly deleted beause of the relaxed onstraint are restored and espeially all the values of d0 . So, aording to theorem 1, DnAC-* algorithms obtain the losure they would have obtained restarting from the initial environment. To reinfore ar-onsisteny, DnAC-* algorithms do no look for a support for eah value on eah onstraint. They only hek whether the restored values still have at least one support on eah onstraint, and obviously propagate the eventual removals. Therefore, DnAC-* begin the propagation looking for supports only when this an lead to the deletion of a restored values. However, the theorem 2 ensures that this is suÆient. 6 Conlusion The paper fouses on the orretness of onstraint retration algorithms in the framework of domain redution and is illustrated by the onstraint solver PaLM. Furthermore, a suÆient work to do in order to relax onstraints is given. Constraint retration is addressed as a two phase proess: enlarging the urrent environment and re-propagating. Of ourse, for a onstraint retration algorithm, the less values and operators re-introdued, the more eÆient the algorithm. The proof of orretness proposed here uses the notions of explanation dened in an adapted theoretial framework. Explanations are used by the proof, but the proof obviously apply to algorithms whih do not use explanations insofar as they re-introdue a good set of values in the environment and a good set of operators in the propagation queue. 14 The preision obtained in the paper is due to the dedution rules. Any loal onsisteny operator an be dened by suh a set. A dedution rule allows to desribe the withdrawal of a value as the onsequene of others value removals. The linking of these rules ompletely denes, in terms of proof trees, explanations of value removals. For a onstraint retration, it is then easy to know the set of values diretly or indiretly removed by this onstraint (and so to re-introdue them during the phase of enlargement of the urrent environment). Furthermore, the operators to add to the propagation queue an learly be identied thanks to the dedution rules whih dene them (that is if one of them has a head whih is a re-introdued element). This preision allows us to prove the orretness of a large family of onstraint retration algorithms whih has been disussed in the previous setion. Referenes [1℄ Peter Azel. An introdution to indutive denitions. In Jon Barwise, editor, Handbook of Mathematial Logi, volume 90 of Studies in Logi and the Foundations of Mathematis, hapter C.7, pages 739{782. NorthHolland Publishing Company, 1977. [2℄ Abderrahmane Aggoun, M. Dinbas, A. Herold, H. Simonis, and P. Van Hentenryk. The CHIP System. Tehnial Report TR-LP-24, ECRC, Munih, Germany, June 1987. [3℄ Krzysztof R. Apt. The essene of onstraint propagation. Theoretial Computer Siene, 221(1{2):179{210, 1999. [4℄ Krzysztof R. Apt. The role of ommutativity in onstraint propagation algorithms. ACM TOPLAS, 22(6):1002{1034, 2000. [5℄ Frederi Benhamou. Heterogeneous onstraint solving. In Mihael Hanus and Mario Rofrguez-Artalejo, editors, International Conferene on Algebrai and Logi Programming, volume 1139 of Leture Notes in Computer Siene, pages 62{76. Springer-Verlag, 1996. [6℄ Pierre Berlandier and Bertrand Neveu. Ar-onsisteny for dynami onstraint problems: A rms-free approah. In Thomas Shiex and Christian Bessiere, editors, Proeedings ECAI'94 Workshop on Constraint Satisfation Issues raised by Pratial Appliations, Amsterdam, August 1994. [7℄ Christian Bessiere. Ar onsisteny in dynami onstraint satisfation problems. In Proeedings AAAI'91, 1991. [8℄ Philippe Codognet, Franois Fages, and Thierry Sola. A metalevel ompiler of lp(fd) and its ombination with intelligent baktraking. In Frederi Benhamou and Alain Colmerauer, editors, Constraint Logi Programming: Seleted Researh, Logi Programming, hapter 23, pages 437{456. MIT Press, 1993. 15 [9℄ Patrik Cousot and Radhia Cousot. Automati synthesis of optimal invariant assertions mathematial foundation. In Symposium on Artiial Intelligene and Programming Languages, volume 12(8) of ACM SIGPLAN Not., pages 1{12, 1977. [10℄ Johan de Kleer. An assumption-based tms. Artiial Intelligene, 28:127{ 162, 1986. [11℄ Romuald Debruyne. Ar-onsisteny in dynami CSPs is no more prohibitive. In 8th Conferene on Tools with Artiial Intelligene (TAI'96), pages 299{306, Toulouse, Frane, 1996. [12℄ Daniel Diaz and Philippe Codognet. The GNU prolog system and its implementation. In ACM Symposium on Applied Computing, Villa Olmo, Como, Italy, 2000. [13℄ Jon Doyle. A truth maintenane system. Artiial Intelligene, 12:231{272, 1979. [14℄ Franois Fages, Julian Fowler, and Thierry Sola. A reative onstraint logi programming sheme. In International Conferene on Logi Programming. MIT Press, 1995. [15℄ Franois Fages, Julian Fowler, and Thierry Sola. Experiments in reative onstraint logi programming. Journal of Logi Programming, 37(1-3):185{ 212, 1998. [16℄ Gerard Ferrand, Willy Lesaint, and Alexandre Tessier. Theoretial foundations of value withdrawal explanations in onstraints solving by domain redution. Tehnial Report 2001-05, LIFO, University of Orleans, 2001. [17℄ Gerard Ferrand, Willy Lesaint, and Alexandre Tessier. Theoretial foundations of value withdrawal explanations for domain redution. In Moreno Falashi, editor, International Worshop on Funtional and (Constraint) Logi Programming, page to appear, 2002. [18℄ Yan Georget, Philippe Codognet, and Franesa Rossi. Constraint retration in lp(fd): Formal framework and performane results. Constraints, an International Journal, 4(1):5{42, 1999. [19℄ Ilog. Solver referene manual, 2001. [20℄ Ulrih Junker. QUICKXPLAIN: Conit detetion for arbitrary onstraint propagation algorithms. In IJCAI'01 Workshop on Modelling and Solving problems with onstraints, Seattle, WA, USA, August 2001. [21℄ Narendra Jussien. e-onstraints: explanation-based onstraint programming. In CP01 Workshop on User-Interation in Constraint Satisfation, Paphos, Cyprus, 1 Deember 2001. 16 [22℄ Narendra Jussien and Vinent Barihard. The palm system: explanationbased onstraint programming. In Proeedings of TRICS: Tehniques foR Implementing Constraint programming Systems, a post-onferene workshop of CP 2000, pages 118{133, Singapore, September 2000. [23℄ Narendra Jussien and Patrie Boizumault. Best-rst searh for property maintenane in reative onstraints systems. In International Logi Programming Symposium, pages 339{353, Port Jeerson, N.Y., USA, Otober 1997. MIT Press. [24℄ Narendra Jussien, Romuald Debruyne, and Patrie Boizumault. Maintaining ar-onsisteny within dynami baktraking. In Priniples and Pratie of Constraint Programming (CP 2000), number 1894 in Leture Notes in Computer Siene, pages 249{261, Singapore, September 2000. Springer-Verlag. [25℄ Franois Laburthe. Choo: implementing a p kernel. In CP00 Post Conferene Workshop on Tehniques for Implementing Constraint programming Systems (TRICS), Singapore, September 2000. [26℄ Jean-Charles Regin. A ltering algorithm for onstraints of dierene in CSPs. In AAAI 94, Twelth National Conferene on Artiial Intelligene, pages 362{367, Seattle, Washington, 1994. [27℄ Edward Tsang. Foundations of Constraint Satisfation. Aademi Press, 1993. [28℄ Pasal Van Hentenryk. Constraint Satisfation in Logi Programming. Logi Programming. MIT Press, 1989. 17