<Section id="u_connect">
<Title/Connecting Finite Domain and Finite Set Constraints/

<P> The propagator in this section involves apart from finite domain
constraints also finite set constraints. Its semantics is
straightforward: it connects a domain variable <Math/D/ and a set
variable <Math/S/ by projecting the changes of the constraints in both
directions. Hereby, the finite domain variable designates an integer
<Math/i/ (as usual) and the set variable designates a singleton set
<Math/\{e\}/ where <Math/i = e/.


<Para><Title/Propagation Rules/ There are three propagation rules:

<List Enum>
<Item> <Math/\#S = 1/
<Item> <Math/D \subseteq S/
<Item> <Math/S \subseteq D/
</List>

The last two rules propagate the changes of the upper bound of the set
constraint to the domain constraint and the other way around.


<SubSection><Title/The Class Definition/

<P> The class definition does not have any particularities. It follows
the scheme known from previous sections. 

<Code.Extern display proglang=cc to="programs/sync.class.cc" class=linenumbers>

Note that set variables are handled the same way as domain variables.

<SubSection><Title/The Propagation Function/

<P> The implementation of the propagation function starts with
retrieving the constrained variables from the constraint store using
the constructors of the classes <<OZ_FDIntVar>> and
<<OZ_FSetVar>>. The class <<OZ_FSetVar>> provides for the same member
functions as <<OZ_FDIntVar>> such that handling set variables does not
differ from handling domain variables.

<Para><Title/Propagation/ The propagation starts with the first
rule. it uses the member function <<OZ_FSetConstraint::putcard(int,
int)>> to impose the cardinality constraint upon <Math/S/. The second
rule implemented by removing all elements from <Math/D/ that are
definitely not in <Math/S/ (see <Ptr.Extern to="ozdoc:cpiref"
key="r_fsc.refl"> for details on
<<OZ_FSetConstraint::getNotInSet()>>). The last propagation rule uses
the operator <<OZ_FSetConstraint::operator <=>> for <Math/S \subseteq
D/. The constructor <<OZ_FSetConstraint>> is used to convert the
<<OZ_Finite Domain>> appropriately. Note that imposing constraints on
<Math/D/ &resp; <Math/S/ are guarded by <<FailOnEmpty>> &resp;
<<FailOnInvalid>> to catch failures. 

<Code.Extern display proglang=cc to="programs/sync.prop.cc" class=linenumbers>

The macro <<FailOnInvalid>> is define as

<Code.Extern display proglang=cc to="programs/sync.failon.cc" class=linenumbers>

since finite set operator return <<OZ_FALSE>> in case an inconsistency
occured.

<P> The propagator closes with calling <<leave()>> for both variables
and returning <<OZ_SLEEP>> &resp; <<OZ_ENTAILED>> depending on whether
not all variables denote values or they do.

<SubSection><Title/The Header Function and Connecting to the Native
Functor Interface/

<P> The header function uses <<OZ_Expect::expectFSetVar>> to check for
a set variable. 

<Code.Extern display proglang=cc to="programs/sync.header.cc" class=linenumbers>

The predefined macro <<OZ_EM_FSET>> is used to produce an appropriate error message in case an type exception has to be risen.

<P> The C part of the native functor interface is given below.

<Code.Extern display proglang=cc to="programs/sync.nfi.cc" class=linenumbers>


<SubSection><Title/Testing the Propagator/

<P>
To make the propagator available on Oz side feed the following code:

<Code.Extern display proglang=oz to="programs/connect.1.oz" class=linenumbers>

The variable <Code proglang=oz/Connect/ refers to the propagator. By
feeding the code below line by line one can observe (&eg; using the
Browser <Ptr.Extern to="ozdoc:browser">), how the propagator works.

<Code.Extern display proglang=oz to="programs/connect.2.oz" class=linenumbers>

The comments at the end of each line indicate the constraints after
feeding that line.
