Encapsulating Non-Determinism in Functional Logic Computations.
Bernd Braßel, Michael D. Hanus, Frank Huch · 2004
One of the key features of the integration of functional and logic languages is the access to non-deterministic computations from the functional part of the program. In order to ensure the determinism of top-level computations in a functional logic program, which is usually a monadic sequence of I/O operations, one has to encapsulate the non-determinism (i.e., search for solutions) occurring in logic computations. However, an appropriate approach to encapsulation can be quite subtle if subexpressions are shared, as in lazy evaluation strategies. In this paper we examine the current approaches to encapsulate non-deterministic computations for the declarative multi-paradigm language Curry, show their relative advantages and the problems they induce. Furthermore, we present a new approach which combines the advantages but avoids the problems. Our proposal is based on providing a primitive I/O action for encapsulation from which various specialized search operators can be derived. In order to provide a formal foundation for this new approach to encapsulation, we define the operational semantics of this new primitive. 1 Why Encapsulate and How (Not) To Functional logic languages are intended to integrate the best features provided in functional and logic languages (see [7] for a survey). They also form a base to improve the evaluation strategies of existing languages due to the existence of optimal evaluation strategies for functional logic languages [3]. However, there is one subtle problem when combining the worlds of functional and logic programming. Usually, the top-level of a realistic functional (logic) program is a monadic sequence of I/O operations that should be applied to the outside world (e.g., see [23]). Since the outside world cannot be copied, all non-determinism in logic computations must be encapsulated, as proposed in [11] for the declarative