@ARTICLE{Hanus24LOPSTR, author = {Hanus, M.}, title = {Improving Logic Programs by Adding Functions}, year = {2024}, booktitle = {Proceedings of the 34th International Symposium on Logic-Based Program Synthesis and Transformation (LOPSTR 2024)}, pages = {27-44}, publisher = {Springer LNCS 14919}, 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 present a method to use functions to improve the operational behavior of logic programs without loosing the flexibility of logic programming. For this purpose, predicates and goals are transformed into functions and nested expressions. By evaluating these functions in a demand-driven manner wherever possible and taking potential failures into account, we ensure 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, we obtain a systematic method to improve the operational behavior of logic programs without changing their semantics. } }