1 Introduction
1.1 Background
This paper is concerned with two styles of programming: constraint programming and rulebased programming.
In constraint programming the programming process is limited to a generation of constraints and a solution of the so obtained constraint satisfaction problems (CSP’s) by general or domain dependent methods.
In rulebased programming the programming process consists of a repeated application of rules. A theoretical basis for this programming paradigm consists of socalled production rules that were introduced in the seventies, see, e.g., [Luger & Stubblefield, 1998][pages 171186], though the idea goes back to the works of A. Thue and of E. Post in first half of twentieth century. The production rules are conditionaction pairs, where the condition part is used to determine whether the rule is applicable and the action part defines the action to be taken. The most known programming language built around this programming paradigm was OPS5 of [Forgy, 1981].
Recently, there has been a revival of interest in rulebased programming in the context of constraint programming. The earliest example is the CHR language of [Frühwirth, 1995] that is a part of the ECLPS system. (For a more recent and more complete overview of CHR see [Frühwirth, 1998].) The CHR rules extend the syntax of constraint logic programming by allowing two atoms in the conclusion and employing guards. These rules are predominantly used to write constraint solvers.
Another example of a programming language in which rules play an important role is ELAN. It offers a logical environment for specifying and prototyping deduction systems by means of conditional rewrite rules controlled by strategies. ELAN is used to support the design of various rulebased algorithms such as constraints solvers, decision procedures, theorem provers, and algorithms expressed in logic programming languages, and to provide a modular framework for studying their combinations. A general overview of ELAN can be found in [Borovansky et al., 1998], whereas [Kirchner & Ringeissen, 1998] and [Castro, 1998] (to which we shall return in Section 11) describe applications of ELAN to constraint programming and constraint solving.
Also, in the hybrid functional and objectoriented language programming language CLAIRE of [Caseau & Laburthe, 1996] rules are present. CLAIRE was designed to apply constraint programming techniques for operations research problems. The rulebased programming is supported by means of production rules that can be naturally used to express constraint propagation.
It is useful to mention here that also logic programming and constraint logic programming are rulebased formalisms. However, these formalisms use rules differently than rulebased programming described above. This distinction is usually captured by referring to forward chaining and backward chaining. In rulebased programming, as discussed above, forward chaining is used while in logic programming and constraint logic programming backward chaining is employed. Intuitively, forward chaining aims at a simplification of the considered problem and it maintains equivalence, while backward chaining models reasoning by cases, where each case is implicitly represented by a different rule. Both forms of chaining can be combined and in fact such a combination is realized in the CHR language, in which the CHR rules model forward chaining while the usual Prolog rules model backward chaining.
1.2 Overview of Our Approach
The traditional way of solving CSP’s consists of combining constraint propagation techniques with search. Constraint propagation aims at reducing a CSP to an equivalent one but simpler. In case of finite domains the most basic approach to search consists of labeling, a repeated enumeration of the domains of the successive variables.
The aim of this paper is to show that constraint programming can be entirely rendered by means of rulebased programming. To this end we provide a framework in which one computes on CSP’s by means of rules represented by simple firstorder formulas. In this approach the constraint propagation is achieved by repeated application of the rules while search is limited to labeling. This yields a framework for constraint programming more related to logic than the usual one based on algorithms achieving local consistency.
The rules we shall consider are implications built out of simple atomic formulas. In our study we focus on two types of rules. The first type, that we call equality rules, are of the form
where are variables and are elements of the respective variable domains. The computational interpretation of such a rule is:
if for the domain of the variable equals the singleton , then remove the element from the domain of .
The second type of rules, that we call membership rules, are of the form
where

are variables and are subsets of the respective variable domains,

is a variable and is an element of its domain.
The computational interpretation of such a rule is:
if for the domain of the variable is included in the set , then remove the element from the domain of .
To illustrate the use of these rules we study CSP’s that are built out of predefined, explicitly given finite constraints. Such CSP’s often arise in practice. Examples include Boolean constraints, constraints dealing with Waltz’s language for describing polyhedral scenes, Allen’s temporal logic, and constraints in any multivalued logic.
To solve such CSP’s we explore the structure of these explicitly given constraints first. This information is expressed in terms of valid equality and membership rules. The computation process for a CSP built out of these constraints is consists of two phases: a generation of the rules from the explicitly given constraints and a repeated application of these rules, combined with labeling.
To characterize the effect of the generated equality and membership rules we use the notions of local consistency. These notions approximate in a loose sense the notion of “global consistency”, see, e.g., [Tsang, 1993]. We show that the first type of rules leads to a local consistency notion that turns out to be weaker than arc consistency for constraints of arbitrary arity. We call it rule consistency.
When the original domains are all unary or binary, rule consistency coincides with arc consistency. When additionally the predefined constraints are the truth tables of the Boolean connectives, these rules are similar to the wellknown Boolean propagation rules, (see, e.g., [Frühwirth, 1998][page 113]). As a side effect, this shows that the Boolean propagation rules characterize arc consistency. Rule consistency is thus a generalization of the Boolean propagation to nonbinary domains.
We also show that the membership rules lead to a notion of local consistency that coincides with arc consistency. This yields a rulebased implementation of arc consistency.
To show feasibility of this rulebased approach to constraint programming, we automatically generate both types of rules, for an explicitly given finite constraint, as rules in the CHR language. When combined with a labeling procedure such CHR programs constitute automatically derived decision procedures for the considered CSP’s, expressed on the constraint programming language level. In particular, we automatically generate the algorithms that enforce rule consistency and arc consistency.
The availability of the algorithms that enforce rule consistency and arc consistency on the constraint programming language level further contributes to the automation of the programming process within the constraint programming framework. In fact, in the case of such CSP’s built out of predefined, explicitly given finite constraints, the user does not need to write one’s own CHR rules for the considered constraints and can simply adopt all or some of the rules that are automatically generated. In the final example of the paper we also show how using the equality rules and the membership rules, we can implement more powerful notions of local consistency.
Alternatively, the generated equality rules and membership rules could be fed into any of the generic Chaotic Iteration algorithms of [Apt, 1999a] and made available in such systems as the ILOG solver. This would yield rule consistency and an alternative implementation of arc consistency.
The algorithms that for an explicitly given finite constraint generate the appropriate rules that characterize rule consistency and arc consistency have (unavoidably) a running time that is exponential in the number of constraint variables and consequently are in general impractical.
To test the usefulness of these algorithms for small finite domains we implemented them in ECLPS and successfully used them on several examples including the ones mentioned above. The fact that we could handle these examples shows that this approach is of practical value and in particular can be used to automatically derive practical decision procedures for constraint satisfaction problems defined over small finite domains. Also it shows the usefulness of the CHR language for an automatic generation of constraint solvers and of decision procedures.
1.3 Organization of the Paper
The rest of the paper is organized as follows. In the next section we clarify the syntax of the rules and explain how one can compute with them. In Section 3 we illustrate the use of these computations by means of an example. In Section 4 we prove that the outcomes of the computations we are interested in are unique. In Section 5 we introduce some semantic aspects of the rules and in Section 6 we formalize the concept of a CSP is built out of predefined constraints. Next, in Section 7 we introduce the notion of rule consistency and discuss an algorithm that can be used to generate the minimal set of rules that characterize this notion of local consistency. Then, in Section 8 we compare rule consistency with arc consistency. In Section 9 we study membership rules and discuss an algorithm analogous to the one of Section 7. This entails a notion of local consistency that turns out to be equivalent to arc consistency.
In Section 10 we discuss the implementation of both algorithms. They generate from an explicit representation of a finite constraint a set of CHR rules that characterize respectively rule consistency and arc consistency. We also illustrate the usefulness of these implementations by means of several examples. Finally, in Section 11 we discuss other works in which a link was made between constraint programming and rulebased programming and in Section 12 we assess the merits of our approach. In the appendix we summarize the tests carried out by means of our implementation of both algorithms.
2 Computing with Rules
In what follows we introduce specific type of rules and explain how one can compute with them on constraint satisfaction problems. First, we introduce constraints.
Consider a sequence of variables where , with respective domains associated with them. So each variable ranges over the domain . By a constraint on we mean a subset of . Given an element of and a subsequence of we denote by the sequence . In particular, for a variable from , denotes .
Next, we define the rules we are interested in.
Definition 2.1

Let be a variable, an element and a set. By an atomic formula we mean one of the following formulas: , , .

By a rule we mean an expression of the form , where each and is an atomic formula.
In what follows a rule will be always associated with some constraint. Then every atomic formula or (respectively, ) will be such that belongs to the domain of (respectively, is a subset of the domain of ).
Subsequently, we explain how to compute using the rules in presence of constraints. First, we limit our considerations to the rules of the form . We need to explain how to turn the disequality formula into an action. This is done by identifying the disequality with the assignment , where is the current domain of . In other words, we interpret as an action of removing the value from the current domain of the variable .
This leads us to the definition of an application of such a rule. We need some semantic notions first.
Definition 2.2
Consider a constraint on a sequence of variables , a variable of , and a tuple .

Given an atomic formula involving we define the relation as follows:

iff ,

iff ,

iff .


Given a sequence of atomic formulas we define iff for all .
Definition 2.3
Consider a constraint on a finite sequence of variables and a rule of the form involving only variables from .
Suppose that for all we have . Let be the constraint obtained from by removing the element from the domain of the variable and by removing from all tuples such that . Then we call the constraint the result of applying the rule to .
If , then we say that this is a relevant application of the rule to . If coincides with , we say that this application of the rule to maintains equivalence.
So the application of the rule to a constraint on the sequence of variables with respective domains results in the constraint on the variables with respective domains , where

,

.
We say then that the constraint is restricted to the domains .
Now that we defined the result of a single application of a rule we proceed to define computations. To this end we first introduce constraint satisfaction problems.
By a constraint satisfaction problem, in short CSP, we mean a finite sequence of variables with respective domains , together with a finite set of constraints, each on a subsequence of . We write it as , where and .
By a solution to we mean an element such that for each constraint on a sequence of variables we have . We call a CSP consistent if it has a solution. Two CSP’s with the same sequence of variables are called equivalent if they have the same set of solutions.
We now modify the definition of an application of a rule to a constraint to an application of a rule to a CSP. To this end we attach each rule to a constraint to which it is supposed to be applied. Even though the constraints change during the computations we consider, it will be always clear from the context to which constraint a given rule is attached.
Definition 2.4
Consider a CSP and a rule attached to a constraint of . Suppose that for all we have . Define a CSP on the same variables as as follows:

the domain of in equals , where is the domain of in ,

the domains of other variables in are the same as in ,

the constraints of are obtained by restricting the constraints of to the new domains.
We say then that the CSP is the result of applying the rule to . If , then we say that this is a relevant application of the rule to .
Finally, we introduce the crucial notion of a computation.
Definition 2.5
Consider a set of rules of the form and an initial CSP . By a computation by means of starting at we mean a maximal sequence of CSP’s such that each is the result of a relevant application of a rule from to .
Note that when the set of rules is finite or when all domains in are finite, all computations starting at are finite. The reason is that in each of these two cases the number of elements mentioned in the conclusions of the rules in is finite. But each element can be removed from a domain only once and we insist that in computations each rule application is relevant, from which the claim follows. If a computation is finite, then no application of a rule from the considered set of rules to the final CSP is relevant, i.e., this final CSP is closed under the rules in .
The computations are a means to reduce the domains of the variables while preserving the equivalence of the considered CSP. The computations here considered are in general insufficient for solving a CSP and in the case of CSP’s with finite domains they have to be combined with labeling. Labeling can be modeled in the above rulebased framework by introducing a rule that splits a given CSP into two, the union of which is equivalent to the given CSP. The addition of such a rule to the considered framework leads to no conceptual difficulties and is omitted. On the other hand, various forms of labeling strategies, like the one in which variable with the smallest domain is chosen first, cannot be captured on this level.
The above string of definitions allowed us to define computations in which the actions are limited to the applications of rules of the form acting on CSP’s.
By limiting our attention to such type of rules we do not lose any expressiveness. Indeed, consider first a rule of the form . To compute with it we interpret the equality as the assignment , where is the current domain of . Then each rule is equivalent to the conjunction of the rules of the form with , where is the original domain of .
Next, consider a rule of the form . To compute with it we interpret the atomic formula as the assignment , where is the current domain of . Then each rule is equivalent to the conjunction of the rules of the form with , where is the original domain of .
Finally, each rule of the form is equivalent to the conjunction of the rules of the form for .
Note that the rules of the form are more expressive than socalled dependency rules of database systems (see, e.g., [Ullman, 1988]). These are rules of the form . We just explained how to model them by means of rules of the form .
However, modeling in the other direction is not possible, as can be seen by taking the variables , each with the domain , and the constraint on represented by the following table:
Then the rule is not equivalent to a conjunction of the dependency rules.
3 An Example
We now show how we can use the rules for computing by means of an example kindly provided to us by Victor Marek. We solve here a simple logic puzzle from [Fleming, 2000].
Below, given a set of variables , each with the domain we denote the following set of rules:
by . These rules formalize the requirement that the variables are all different. The puzzle is as follows.
To stave off boredom on a rainy Saturday afternoon, Ms. Rojas invented a game for Denise and her two other children to play. Each child selected a different household object (no two of which were in the same room) to describe to the others, who would try to guess the item and its location in the house. Can you match each child with the item he or she selected to describe, as well as the room of the house (one is the living room) in which each is located?
Here are the clues provided:

The three children are Byron, the child who selected the book, and the one whose item is in the den;

The rug is in the dining room;

Felicia selected the picture frame.
To solve this puzzle we use nine variables,

, to denote the three children, Byron, Denise and Felicia,

, to denote the rooms of, respectively, Byron, Denise and Felicia,

, to denote the objects selected by, respectively, Byron, Denise and Felicia.
We postulate that the domain of is , of is and of is . Next, we assume that each variable has the set as its domain and each variable has the set as its domain.
The initial set up of the story is formalized by the following rules:

,

.
This yields 36 rules but we shall group the rules with the same premise, so we shall actually have 18 rules. The rules we shall need below will be, from the first set:
(r1) ,
(r2) ,
(r3) ,
and from the second set:
(r4) ,
(r5) .
Next, the first clue is formalized by means of eight rules out of which the only ones of relevance below will be
(c1.1) ,
(c1.2) .
The second clue is formalized by means of six rules out of which the only one of relevance below will be
(c2) .
Finally, the third clue is formalized by means of two rules:
(c3.1) ,
(c4.1) .
So in total we have 34 rules but we shall use below only the ten rules made explicit. The initial CSP has nine variables as introduced above and one single “universal” constraint that consists of the Cartesian product of all the variable domains. The computation consists of twelve steps and proceeds as follows.

Using the rule (c3.1) the domain of is limited to .

Using the rule (c3.2) the domain of is further limited to . Thus is established.

Using the rule (r5) and the fact just established the domain of is limited to .

Using the rule (c1.1) the domain of is further limited to . Thus is established.

Using the rule (r5) and the fact established in step 2 the domain of is limited to .

Using the rule (r4) and the conclusion of step 4 the domain of is further limited to . Thus is established.

Using the rule (c2) and the fact established in step 4 the domain of is limited to .

Again using the rule (c2) and the fact established in step 4 the domain of is further limited to . Thus is established.

Using the fact established in step 8 and the rule (r1) the domain of is limited to .

Using the fact established in step 6 and the rule (c1.2), the domain of is further limited to . Thus is established.

Using the fact established in step 9 and the rule (r2) the domain of is limited to .

Using the fact established in step 10 and the rule (r3) the domain of is further limited to . Thus is established.
At this stage one can check that the resulting CSP with all singleton domains is closed under all 34 rules. This yields the solution to the puzzle represented by the following table:
4 Outcomes of Computations
A natural question arises whether the outcome of computations using a finite set of rules is unique. The answer is positive. To prove it we need a lemma concerning iterations of inflationary and monotonic functions.
Definition 4.1
Consider a partial ordering with the least element and a finite set of functions on .

By an iteration of we mean an infinite sequence of values defined inductively by
where each is an element of .

We say that an increasing sequence of elements from eventually stabilizes at d if for some we have for .

A function on is called inflationary if for all .

A function on is called monotonic if implies for all .
We now need the following lemma from [Apt, 1999b].
Lemma 4.2
Consider a partial ordering with the least element and a finite set of monotonic functions on . Suppose that an iteration of eventually stabilizes at a common fixpoint of the functions from . Then is the least common fixed point of the functions from .
It follows that all iterations of that eventually stabilize at a common fixpoint stabilize at the same element. We now prove the desired result.
Theorem 4.3
Fix an initial CSP . Consider a finite set of rules of the form . Then all computations by means of starting at yield the same CSP.
We already noted in Section 2 that all such computations are finite. Suppose that . We consider now the following partial ordering . The elements of are the sequences such that for , ordered componentwise w.r.t. the reversed subset ordering . So is the least element in this ordering and
iff for . 
We replace in each rule each premise atom by and by . Since for all we have iff and iff , it follows that the applications of the original and of the resulting rules coincide. This allows us to confine our attention to the rule each premise of which is of the form .
Consider now a membership rule associated with a constraint from defined on a set of variables . We interpret this rule as a function on the just defined set D as follows.
First, denote by
the extension “by padding” of
to all the variables , i.e. and iff . Next, given a constraint and its variable denote the set by . Finally, assume for simplicity that is .The function that corresponds to the rule is defined as follows:
Denote the set of so defined functions by . By definition each function is inflationary and monotonic w.r.t. the componentwise reversed subset ordering .
Now, there is a oneone correspondence between the common fixpoints of the functions from at which the iterations of eventually stabilize and the outcomes of the computations by means of starting at . In this correspondence a common fixpoint is related to the CSP closed under the rules of , where are the constraints from restricted to the domains . The conclusion now follows by Lemma 4.2.
5 Semantic Aspects of Rules
We now introduce a number of semantic notions concerning rules.
Definition 5.1
Consider a constraint .

We say that the rule is valid for if for all tuples
implies . 
We say that the constraint is closed under the rule if

We say that the rule is feasible for if for some tuple we have .

We say that the rule for the constraint extends the rule if contains all variables of and for all tuples
implies . 
Given a set of rules , we call a rule minimal in if it is feasible and it does not properly extend a valid rule in .
To illustrate them consider the following example.
Example 5.2
Take as a constraint the ternary relation that represents the conjunction . It can be viewed as the following table:
In other words, we assume that each of the variables has the domain and view as the constraint on that consists of the above four triples.
It is easy to see that the rule is valid for . Further, the rule extends the rule and is also valid for . However, out of these two rules only is minimal.
Finally, both rules are feasible, while the rules and are not feasible.
Note that the definition of an application of a rule is so designed that a link with semantics is kept in the following sense: if a rule is valid for a constraint , then is closed under . Rules that are not feasible are trivially valid. Note also that a rule that extends a valid rule is valid, as well. So validity extends “upwards”.
Note the use of the condition “ contains all variables of ” in the definition of the relation “the rule extends the rule ”. Without it we would have the following paradoxical situation. Consider the variables , all on the domains , and the constraint on defined by . Then the rules and are both valid for and for all we have that implies . So without the mentioned condition we would have that the rule extends the rule , which would imply that the first rule is not minimal.
In the sequel the following observation will be useful.
Note 5.3
Consider two finite and nonempty constraints and such that and a set of rules . Then is closed under all valid rules from for iff it is closed under all minimal valid rules in for .
Suppose that is closed under all minimal valid rules in for . Take a rule from that is valid for .
Case 1. is feasible for .
Then, because is finite, extends some minimal valid rule in for . But is closed under , so it is closed under , as well.
Case 2. is not feasible for .
Then is not feasible for either since . Consequently, since is nonempty, is closed under .
In what follows we confine our attention to computations involving two types of rules:

equality rules: these are rules of the form ; we abbreviate them to , where and ,

membership rules: these are rules of the form ; we abbreviate them to , where and .
By specializing in the last clause of Definition 5.1, defining a minimal rule, the set of rules to the set of equality rules and to the set of membership rules we obtain the notions of a minimal equality rule and of a minimal membership rule. For equality and membership rules the following straightforward characterization of the “extends” relation will be of use.
Note 5.4

An equality rule extends an equality rule iff is a subsequence of .

A membership rule extends a membership rule iff is a subsequence of and for each we have , where equals .
Given a CSP with finite domains we would like to solve it by considering computations starting at it. But where do we get the rules from? Note that given a constraint and a rule that is valid for , the constraint is trivially closed under . Consequently, an application of to is not relevant, i.e., it does not affect . So to obtain some change we need to use rules that are not valid for the initial constraints. This brings us to the notion of a CSP based on another one.
6 CSP’s Built out of Predefined Constraints
In the introduction we informally referred to the notion of a CSP “being built out of predefined, explicitly given constraints.” Let us make now this concept formal. We need two auxiliary notions first, where in preparation for the next definition we already consider constraints together with the domains over which they are defined.
Definition 6.1

Given a constraint and a permutation of we denote by the relation defined by
and call it a permutation of .

Given two constraints and we say that is based on if

for ,

.

So the notion of “being based on” involves the domains of both constraints. If is based on , then is the restriction of to the domains over which is defined.
Definition 6.2
We assume that the “predefined constraints” are presented as a given in advance CSP . Suppose that each constraint of a CSP is based on a permutation of a constraint of . We say then that is based on .
In the above definition the use of permutations of constraints allows us to abstract from the variable ordering used in . The following example illustrates this notion.
Example 6.3
Consider the wellknown full adder circuit. It is defined by the following formula:
where and are defined in the expected way. We can view the original constraints as the following CSP:
should be viewed just as an “inventory” of the predefined constraints and not as a CSP to be solved. Now, any query concerning the full adder can be viewed as a CSP based on . For example, in Section 10 we shall consider the query . It corresponds to the following CSP based on : .
In what follows we consider computations that start with a CSP based on some CSP . In these computations we wish to maintain equivalence between the successive CSP’s. To this end the following simple observation is crucial.
Note 6.4
Consider two constraints and such that is based on . Let be a rule valid for . Then the application of to maintains equivalence.
Assume that the rule can be applied to , i.e., that for all we have . Suppose now that the rule to does not maintain equivalence. Then for some we have . is based on , so . By the validity of the rule for we get . This yields a contradiction.
This observation provides us with a way of maintaining equivalence during a computation: it suffices to use at each step a rule that is valid for a permutation of a constraint of . Such a rule is then attached (i.e., applied) to the constraint based on . This is what we shall do in the sequel. Depending on the type of rules used we obtain in this way different notions of local consistency.
7 Rule Consistency
In this section we consider a CSP based on some finite CSP and study computations that use exclusively equality rules. The rules are obtained from the constraints of ; each of them is valid for a permutation of a constraint of and is applied to the constraint of based on . By Note 6.4 the successive CSP’s are all equivalent to the initial CSP . The computation ends when a CSP is obtained that is closed under the rules used. This brings us to a natural notion of local consistency expressed in terms of equality rules.
Definition 7.1
Consider a CSP based on a CSP . Let be a constraint of . For some constraint of and a permutation , is based on .

We call the constraint rule consistent (w.r.t. ) if it is closed under all equality rules that are valid for .

We call the CSP rule consistent (w.r.t. ) if all its constraints are rule consistent.
In what follows we drop the reference to if it is clear from the context.
Example 7.2
Take as the base CSP
and consider the following four CSP’s based on it:

,

,

,

,
where is a subset of . We noted in Example 5.2 that the equality rule is valid for . In the first three CSP’s its only constraint is closed under this rule, while in the fourth one it is not closed since 1 is present in the domain of whereas the domain of equals . So the fourth CSP is not rule consistent. One can show that the first two CSP’s are rule consistent, while the third one is not rule consistent since it is not closed under the valid equality rule .
When trying to generate all valid equality rules Note 5.3 allows us to confine our attention to the minimal valid equality rules. We now introduce an algorithm that given a finite constraint generates the set of all minimal valid equality rules for it. We collect the generated rules in a list. We denote below the empty list by empty and the result of insertion of an element into a list by .
By an assignment to a sequence of variables we mean here an element from the Cartesian product of the domains of variables of such that for some we have . Intuitively, if we represent the constraint as a table with rows corresponding to the elements (tuples) of and the columns corresponding to the variables of , then an assignment to is a tuple of elements that appears in some row in the columns that correspond to the variables of . This algorithm has the following form, where we assume that the considered constraint is defined on a sequence of variables VAR of cardinality .
Equality Rules Generation algorithm
L := empty; FOR i:= 0 TO n1 DO FOR each subset X of VAR of cardinality i DO FOR each assignment s to X DO FOR each y in VARX DO FOR each element d from the domain of y DO r := X = s \(\>\rightarrow\>\) y \(\neq\) d; IF r is valid for C and it does not extend an element of L THEN insert(r, L) END END END END END END
The test that one equality rule does not extend another can be easily implemented by means of Note 5.4.i.
The following result establishes correctness of this algorithm.
Theorem 7.3
Given a constraint the Equality Rules Generation algorithm produces in L the set of all minimal valid equality rules for .
First note that in the algorithm all possible feasible equality rules are considered and in the list L only the valid equality rules are retained. Additionally, a valid equality rule is retained only if it does not extend a rule already present in L.
Finally, the equality rules are considered in the order according to which those that use less variables are considered first. By virtue of Note 5.4.i this implies that if a rule extends a rule , then is considered first. As a consequence precisely all minimal valid equality rules are retained in L.
The above algorithm is completely straightforward and consequently inefficient. It is easy to see that given a constraint defined over variables, rules are considered in it, where is the size of the largest variable domain. This shows that in practice this algorithm is impractical for large domains and for constraints with many variables. By representing the rules explicitly one could improve the running time of this algorithm, trading time for space. Then the test that one rule does not extend another could be eliminated from the algorithm by representing explicitly the partial ordering defined by the relation “equality rule extends equality rule ”. Each time an equality rule that is valid for would be found, all the rules that extend it would be now disregarded in further considerations. This would reduce the number of rules considered and improve the average running time. However, it is difficult to quantify the gain obtained and in the worst case still all the rules would have to be considered.
In Section 10 and the appendix we present some empirical results showing when the Equality Rules Generation becomes infeasible.
8 Relating Rule Consistency to Arc Consistency
To clarify the status of rule consistency we compare it now to the notion of arc consistency. This notion was introduced in [Mackworth, 1977a] for binary relations and was extended to arbitrary relations in [Mohr & Masini, 1988]. Let us recall the definition.
Definition 8.1

We call a constraint on a sequence of variables arc consistent if for every variable in and an element in its domain there exists such that . That is, each element in each domain participates in a solution to .

We call a CSP arc consistent if all its constraints are arc consistent.
The following result relates for constraints of arbitrary arity arc consistency to rule consistency.
Theorem 8.2
Consider a CSP based on a CSP . If is arc consistent, then it is rule consistent w.r.t. .
Assume that is arc consistent. Choose a constraint of and consider an equality rule that is valid for , where and are as in Definition 7.1.
Suppose by contradiction that is not closed under this rule. So for and the domain of each variable in equals and moreover , where is the domain of the variable in .
By the arc consistency of there exists such that . Because of the form of the domains of the variables in , also holds. Additionally, because is based on , we have . But by assumption the equality rule is valid for , so . A contradiction.
The converse implication does not hold in general as the following example shows.
Example 8.3
Take as the base the following CSP
where the constraint on that equals the set . So can be viewed as the following table:
Next, take for the set and the set . Then the CSP
Comments
There are no comments yet.