Abstract
Residuation is an operational principle to evaluate functions in logic-oriented languages. Residuation delays function calls until the arguments are sufficiently instantiated in order to evaluate the function deterministically. It has been proposed as an alternative to the non-deterministic narrowing principle and is useful to connect externally defined operations. Residuation can be implemented in Prolog systems supporting coroutining, but this comes with a price: the coroutining mechanism causes a considerable overhead even if it is not used. To overcome this dilemma, we propose a compile-time analysis which approximates the run-time residuation behavior. Based on the results of this analysis, we improve an existing implementation of residuation and evaluate the potential efficiency gains by a number of benchmarks.
The research described in this paper has been partially supported by the German Federal Ministry of Education and Research (BMBF) under Grant No. 01IH15006B.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
- 2.
The predicate computes the head normal form of its first argument. It can be defined by a case distinction on all function and constructor symbols in the program. The use of instead of simply flattening nested function calls is essential to implement lazy evaluation.
- 3.
One could also refine the abstract domain in order to distinguish between residuation and non-ground results, but this does not seem to provide better results in practice.
- 4.
- 5.
Although the control arguments and are superfluous in non-residuating computations, we leave them in the code in order to simplify the interaction of residuating and non-residuating code. Improving this scheme is a topic for future work.
References
Aït-Kaci, H.: An overview of life. In: Schmidt, J.W., Stogny, A.A. (eds.) EWDW 1990. LNCS, vol. 504, pp. 42–58. Springer, Heidelberg (1991). https://doi.org/10.1007/3-540-54141-1_4
Aït-Kaci, H., Lincoln, P., Nasr, R.: Le fun: logic, equations, and functions. In: Proceedings of the 4th IEEE International Symposium on Logic Programming, San Francisco, pp. 17–23 (1987)
Albert, E., Hanus, M., Huch, F., Oliver, J., Vidal, G.: Operational semantics for declarative multi-paradigm languages. J. Symb. Comput. 40(1), 795–829 (2005)
Antoy, S., Echahed, R., Hanus, M.: A needed narrowing strategy. J. ACM 47(4), 776–822 (2000)
Antoy, S., Hanus, M.: Compiling multi-paradigm declarative programs into Prolog. In: Kirchner, H., Ringeissen, C. (eds.) FroCoS 2000. LNCS (LNAI), vol. 1794, pp. 171–185. Springer, Heidelberg (2000). https://doi.org/10.1007/10720084_12
Antoy, S., Hanus, M.: Functional logic programming. Commun. ACM 53(4), 74–85 (2010)
Bonnier, S., Maluszynski, J.: Towards a clean amalgamation of logic programs with external procedures. In: Proceedings of the 5th Conference on Logic Programming and 5th Symposium on Logic Programming, Seattle, pp. 311–326. MIT Press, Cambridge (1988)
Braßel, B., Hanus, M., Peemöller, B., Reck, F.: KiCS2: a new compiler from Curry to Haskell. In: Kuchen, H. (ed.) WFLP 2011. LNCS, vol. 6816, pp. 1–18. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-22531-4_1
Casas, A., Cabeza, D., Hermenegildo, M.V.: A syntactic approach to combining functional notation, lazy evaluation, and higher-order in LP systems. In: Hagiya, M., Wadler, P. (eds.) FLOPS 2006. LNCS, vol. 3945, pp. 146–162. Springer, Heidelberg (2006). https://doi.org/10.1007/11737414_11
Hanus, M.: On the completeness of residuation. In: Proceedings of the 1992 Joint International Conference and Symposium on Logic Programming, pp. 192–206. MIT Press, Cambridge (1992)
Hanus, M.: A unified computation model for functional and logic programming. In: Proceedings of the 24th ACM Symposium on Principles of Programming Languages, pp. 80–93 (1997)
Hanus, M.: Functional logic programming: from theory to Curry. In: Voronkov, A., Weidenbach, C. (eds.) Programming Logics. LNCS, vol. 7797, pp. 123–168. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-37651-1_6
Hanus, M.: Semantic versioning checking in a declarative package manager. In: Technical Communications of the 33rd International Conference on Logic Programming (ICLP 2017), Open Access Series in Informatics (OASIcs), pp. 6:1–6:16. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik (2017)
Hanus, M., et al.: PAKCS: The Portland Aachen Kiel Curry System (2017). http://www.informatik.uni-kiel.de/~pakcs/
Hanus, M., Skrlac, F.: A modular and generic analysis server system for functional logic programs. In: Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation (PEPM 2014), pp. 181–188. ACM Press (2014)
Hanus, M. (ed.): Curry: An integrated functional logic language (vers. 0.9.0) (2016). http://www.curry-language.org
Lloyd, J.W.: Combining functional and logic programming languages. In: Proceedings of the International Logic Programming Symposium, pp. 43–57 (1994)
Loogen, R., Fraguas, F.L., Artalejo, M.R.: A demand driven computation strategy for lazy narrowing. In: Bruynooghe, M., Penjam, J. (eds.) PLILP 1993. LNCS, vol. 714, pp. 184–200. Springer, Heidelberg (1993). https://doi.org/10.1007/3-540-57186-8_79
Marriott, K., Søndergaard, H., Dart, P.: A characterization of non-floundering logic programs. In: Proceedings of the 1990 North American Conference on Logic Programming, pp. 661–680. MIT Press, Cambridge (1990)
Naish, L.: Adding equations to NU-Prolog. In: Maluszyński, J., Wirsing, M. (eds.) PLILP 1991. LNCS, vol. 528, pp. 15–26. Springer, Heidelberg (1991). https://doi.org/10.1007/3-540-54444-5_84
Peyton Jones, S. (ed.): Haskell 98 Language and Libraries—The Revised Report. Cambridge University Press, Cambridge (2003)
Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proceedings of the ACM Annual Conference, pp. 717–740. ACM Press (1972)
Smolka, G.: The Oz programming model. In: van Leeuwen, J. (ed.) Computer Science Today: Recent Trends and Developments. LNCS, vol. 1000, pp. 324–343. Springer, Heidelberg (1995). https://doi.org/10.1007/BFb0015252
Van Roy, P., Haridi, S.: Concepts, Techniques, and Models of Computer Programming. MIT Press, Cambridge (2004)
Warren, D.H.D.: Higher-order extensions to Prolog: are they needed? Mach. Intell. 10, 441–454 (1982)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2019 Springer Nature Switzerland AG
About this paper
Cite this paper
Hanus, M. (2019). Improving Residuation in Declarative Programs. In: Alferes, J., Johansson, M. (eds) Practical Aspects of Declarative Languages. PADL 2019. Lecture Notes in Computer Science(), vol 11372. Springer, Cham. https://doi.org/10.1007/978-3-030-05998-9_6
Download citation
DOI: https://doi.org/10.1007/978-3-030-05998-9_6
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-05997-2
Online ISBN: 978-3-030-05998-9
eBook Packages: Computer ScienceComputer Science (R0)