15.7 Reified Constraints

A reified constraint consists of a constraint and a variable which denotes its truth value. For instance, {\it truth}(X=2)=N is equivalent to (X=2 \apc N=1) \vee ( X\not= 2 \apc N=0). Refied constraints are useful for for expressing propositional formulas over constraints. Most typically, they are used for expressing implications or equivalences between arbitrary constraints C and D.

\begin{array}{rcl}
  C \Leftrightarrow D    &\mbox{iff}&{\it truth}(C)={\it truth}(D) \\
  C \Rightarrow D        &\mbox{iff}&{\it truth}(C)\le{\it truth}(D)
\end{array}

Oz provides reified versions of most finite domain constraints and some set constraints directly. Reified versions {\it truth}(C)=N of arbitrary constraints C can be user defined in Oz by or-propagators. The only restriction is that the negation NotC has to be available.

  truth(C)=N    iff  N :: 0#1
                     thread 
                        or C    N=1  
                        [] NotC N=0  
                        end 
                     end

Propagation of reified constraints is bidirectional. For instance, N= {\it truth}(X=1) \wedge N=1 propagates X=1 into the global constraint store, whereas N={\it truth}(X=1) \apc X=1 propagates N=1. Syntactically, reification is written in Oz by paranthesis only. It looks like as if the word \it truth were ommited. A typical example it the implication B=1 \Rightarrow
A\in\{2,4\} which can be written as follows.

declare B A  
[B A]::: 1#27
(B =: 1) =<: (A :: 2#4)
 
{Browse [B A]}
/*
B=1
*/

Alternatively, you may also use the special procedure FD.impl which expresses implication for Boolean variables.

declare B A  
[B A]::: 1#27
{FD.impl (B =: 1) (A :: 2#4)}
 
{Browse [B A]}
/*
B=1
*/

Via reification and arithmetics, one can express disjunctions between arbitrary constraints for which reification is provided. The logical content of the disjunctive propagator {\rm\bf or}_{i=1}^n \wedge_{j=1}^{m(i)} C_{ij} and the reified constraint 1 \le \sum_{i=1}^n {\it truth}\left(m(i) \gleich \sum_{j=1}^{m(i)}
  {\it truth}(C_{ij})\right) are equal. Operationally however, both propagators differ significantly. Reification tests all constraints C_{ij} in isolation for satisfiablity with respect to the global constraint store, whereas the corresponding disjunctive propagator tests the whole conjunctions \wedge_{j=1}^{m(i)} C_{ij}.


Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)