scispace - formally typeset
Search or ask a question

Showing papers in "Journal of Functional and Logic Programming in 2004"


Journal Article
TL;DR: This paper examines the current approaches to encapsulate non-deterministic computations for the declarative multi-paradigm language Curry, and presents a new approach which combines the advantages but avoids the problems and defines the operational semantics of this new primitive.
Abstract: 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 ∗This work has been partially supported by the DFG under grants Ha 2457/1-2 and Ha 2457/5-1. †Institut fur Informatik, Christian-Albrechts-Universitat zu Kiel, D-24098 Kiel, Germany. {bbr,mh,fhu}@informatik.uni-kiel.de

55 citations


Journal Article
Michael Hanus1
TL;DR: A new concept to deal with dynamic predicates in functional logic programs that is easy to use and has a clear semantics that does not depend on the particular (demand-driven) evaluation strategy of the underlying implementation.
Abstract: In this paper we propose a new concept to deal with dynamic predicates in functional logic programs The definition of a dynamic predicate can change over time, ie, one can add or remove facts that define this predicate Our approach is easy to use and has a clear semantics that does not depend on the particular (demand-driven) evaluation strategy of the underlying implementation In particular, the concept is not based on (unsafe) side effects so that the order of evaluation does not influence the computed results—an essential requirement in non-strict languages Dynamic predicates can also be persistent so that their definitions are saved across invocations of programs Thus, dynamic predicates are a lightweight alternative to the explicit use of external database systems Moreover, they extend one of the classical application areas of logic programming to functional logic programs We present the concept, its use and an implementation in a Prolog-based compiler 1 Motivation and Related Work Functional logic languages [11] aim to integrate the best features of functional and logic languages in order to provide a variety of programming concepts to the programmer For instance, the concepts of demand-driven evaluation, higherorder functions, and polymorphic typing from functional programming can be combined with logic programming features like computing with partial information (logical variables), constraint solving, and non-deterministic search for solutions This combination leads to optimal evaluation strategies [2] and new design patterns [4] that can be applied to provide better programming abstractions, eg, for implementing graphical user interfaces [13] or programming dynamic web pages [14] However, one of the traditional application areas of logic programming is not yet sufficiently covered in existing functional logic languages: the combination ∗This research has been partially supported by the German Research Council (DFG) under grants Ha 2457/1-2 and Ha 2457/5-1 †Institut fur Informatik, CAU Kiel, D-24098 Kiel, Germany mh@informatikuni-kielde

19 citations


Journal Article
TL;DR: This article partitions the call graph of the source program into strongly connected components, based on the simple observation that all functions in each component need the same extra parameters and thus a transitive closure is not needed, and reduces the time complexity of lambda-lifting from O(n3 log n) to O( n2 log n), where n is the size of the program.
Abstract: Lambda-lifting is a program transformation used in compilers and in partial evaluators and that operates in cubic time. In this article, we show how to reduce this complexity to quadratic time.Lambda-lifting transforms a block-structured program into a set of recursive equations, one for each local function in the source program. Each equation carries extra parameters to account for the free variables of the corresponding local function and of all its callees. It is the search for these extra parameters that yields the cubic factor in the traditional formulation of lambda-lifting, which is due to Johnsson. This search is carried out by a transitive closure.Instead, we partition the call graph of the source program into strongly connected components, based on the simple observation that all functions in each component need the same extra parameters and thus a transitive closure is not needed. We therefore simplify the search for extra parameters by treating each strongly connected component instead of each function as a unit, thereby reducing the time complexity of lambda-lifting from O(n3 log n) to O(n2 log n), where n is the size of the program.Since a lambda-lifter can output programs of size O(n2), we believe that our algorithm is close to optimal.

12 citations


Journal Article
TL;DR: The present paper extends earlier work in exploring the notion of declarative pruning by requiring that certain domains must be totally-ordered (as opposed to being partially-ordered) and shows how the search space of solutions can be pruned e‐ciently.
Abstract: Weconsidertheproblemofimprovingthecomputationale‐ciency of a functional query language. Our focus is on aggregate operations which have proven to be of practical interest in database querying. Since aggregate operations are typically non-monotonic in nature, recursiveprogramsmakinguseofaggregateoperationsmustbesuitably restricted in order that they have a well-deflned meaning. In a recent paper we showed that partial-order clauses provide a well-structured means of formulating such queries. The present paper extends earlier work in exploring the notion of declarative pruning. By \declarative pruning" we mean that the programmer can specify declarative information about certain functions in the program without altering the meanings of these functions. Using this information, our proposed execution model provides for more e‐cient program execution. Essentially we require that certain domains must be totally-ordered (as opposed to being partially-ordered). Given this information, we show how the search space of solutions can be pruned e‐ciently. The paper presents examples illustrating the language and its computation model, and also presentsa formal operational semantics.

3 citations


Journal Article
TL;DR: Two declarative semantics for HH(C) based on fixed point techniques are revisited and proved to be equivalent and the corresponding theorems of soundness and completeness, that relate the sequent calculus (and so the operational semantics) with these semantics, are stated and formally proved.
Abstract: The scheme HH(C) emerged as a double extension of traditional Logic Programming. On one hand, extending Horn logic to hereditary Harrop formulas (HH ), in order to improve the expressive power; on the other, incorporating constraints, in order to increase the efficiency. The behavior of such extended CLP programs was explained by means of a sequent calculus that, from every program and set of constraints, exclusively generates uniform proofs —i. e. goal-oriented proofs— for any goal, as well as by means of a goal solving procedure. Hence HH(C) was provided for an operational semantics. Recently, some attempts to define more declarative semantics for HH(C) has been done by the authors. Here such works are enlarged and improved. Two declarative semantics for HH(C) based on fixed point techniques are revisited. They are proved to be equivalent and the corresponding theorems of soundness and completeness, that relate the sequent calculus (and so the operational semantics) with these semantics, are stated and formally proved. Non trivial proofs are included in the current paper, and every technical aspect is developed.

2 citations


Journal Article
TL;DR: Call-time choices are used and the functions are non-deterministic and non-strict, which allows to use a form of lazy narrowing for pruning the search space and avoiding divergence in some cases.
Abstract: We present a proof procedure for functional first-order logic programs. The programs we consider allow first-order goals (including disjunctions, conjunctions, negations, and quantifications on elements of the domain). Atoms are either built-in statements or reduction statements of the form t → s, meaning that t is reducible to s. Call-time choices are used and the functions are non-deterministic and non-strict, which allows to use a form of lazy narrowing for pruning the search space and avoiding divergence in some cases.

2 citations