Functional logic programming improves logic programs performance
Functional Logic Programming: Improving Logic Programs with Ease
Programming Languages
Summary
Logic programming usually works by defining relationships between things, treating functions as just a simpler way to write these relationships. The authors show that actually using functions directly can make these programs run better and faster without losing their flexibility. They provide a way to change logic programs into function-based programs that only do the necessary calculations and handle failures efficiently. This approach can reduce the time and steps needed to solve problems, sometimes turning endless searches into quick solutions.
What this means in practice
- •For software developers: Improve logic program performance by rewriting predicates as functions to reduce execution steps and avoid infinite searches during computation.
- •For database engineers: Optimize query evaluation by transforming relational logic queries into functional expressions that execute more efficiently and handle failures gracefully.
Authors
Michael Hanus
Abstract
Logic programming is based on defining relations. Functions are often considered as syntactic sugar which can be transformed into predicates so that their logic is not used for computational purposes. In this paper, we show that the use of functions improves the operational behavior of logic programs without loosing the flexibility of logic programming. For this purpose, we present a systematic transformation from predicates and goals into functions and nested expressions, respectively. By evaluating functions in a demand-driven manner and taking potential failures into account, it is ensured that the execution of the transformed programs will never require more steps than the original programs but can decrease the number of steps---in the best case reducing infinite search spaces to finite ones. Thus, functional logic programming provides an adequate basis to improve the operational behavior of logic programs without changing their semantics. This also shows that, from an operational point of view, functional logic programming has clear advantages compared to relation-based logic programming.