<< Prev | - Up - | Next >> |

As in Prolog, you need only specify your problem and let the search facilities of the language derive its solutions. In contrast to Prolog, search in Oz is *encapsulated*: in particular this means that the search facilities are not implicit as in Prolog, but rather that search engines are explicit objects in the language, that you can create as many as you want, and that they are all independent and may coexist peacefully.

Each search engine can solve a different problem. Consequently a search problem must be encapsulated into a predicate (a procedure) which is passed explicitly to the search engine. We often call such a procedure a *search predicate* and it consists of 2 parts:

a description of what constitutes a solution

a specification of the distribution strategy

More precisely, the search predicate takes one argument, intended to denote a solution, and typically follows the design pattern below:

introduce the local variables of the problem

define a solution term using these variables

post the constraints which the variables must satisfy

apply a distribution strategy to the variables

For example, search predicate `Equations`

describes exactly the solutions of the problem considered above.

` `

declare

proc {Equations Sol}

X Y Z

in

Sol = solution(x:X y:Y z:Z)

% Propagate

[X Y Z] ::: 1#7

X + Y =: 3*Z

X - Y =: Z

% Distribute

{FD.distribute naive [X Y Z]}

end

The definition of `Equations`

in Oz not only specifies a set of objects but also describes how these objects can be searched by propagation and distribution. For computing its solutions in Oz, it is sufficient to pass the definition of `Equations`

to the Oz-Explorer.

`{Explorer.all Equations}`

{Explorer.one Equations}

<< Prev | - Up - | Next >> |

Denys Duchier, Claire Gardent and Joachim Niehren

Version 1.2.4 (20020829)