Improving Logic Programs by Adding Functions
Pages 27 - 44
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.
References
[1]
Antoy S Hanus M, Heering J, and Meinke K Optimal non-deterministic functional logic computations Algebraic and Logic Programming 1997 Heidelberg Springer 16-30
[2]
Antoy S, Echahed R, and Hanus M A needed narrowing strategy J. ACM 2000 47 4 776-822
[3]
Antoy S and Hanus M Kirchner H and Ringeissen C Compiling multi-paradigm declarative programs into Prolog Frontiers of Combining Systems 2000 Heidelberg Springer 171-185
[4]
Antoy, S., Hanus, M.: Set functions for functional logic programming. In: Proceedings of the 11th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP 2009), pp. 73–82. ACM Press (2009).
[5]
Antoy S and Hanus M Functional logic programming Commun. ACM 2010 53 4 74-85
[6]
Baader, F., Nipkow, T.: Term Rewriting and All That. Cambridge University Press (1998)
[7]
Barbosa, J., Florido, M., Santos Costa, V.: Data type inference for logic programming. In: De Angelis, E., Vanhoof, W. (eds.) LOPSTR 2021. LNCS, vol. 13290, pp. 16–37. Springer, Cham (2021).
[8]
Barbuti, R., Bellia, M., Levi, G., Martelli, M.: On the integration of logic programming and functional programming. In: Proceedings IEEE International Symposium on Logic Programming, Atlantic City, pp. 160–166 (1984)
[9]
Braßel B, Hanus M, Peemöller B, and Reck F Kuchen H KiCS2: a new compiler from curry to Haskell Functional and Constraint Logic Programming 2011 Heidelberg Springer 1-18
[10]
Bruynooghe M, De Schreye D, and Krekels B Compiling control J. Log. Program. 1989 6 135-162
[11]
Bry F and Schaffert S Stuckey PJ Towards a declarative query and transformation language for XML and semistructured data: simulation unification Logic Programming 2002 Heidelberg Springer 255-270
[12]
Casas A, Cabeza D, and Hermenegildo MV Hagiya M and Wadler P A syntactic approach to combining functional notation, lazy evaluation, and higher-order in LP systems Functional and Logic Programming 2006 Heidelberg Springer 146-162
[13]
Giesl, J., Raffelsieper, M., Schneider-Kamp, P., Swiderski, S., Thiemann, R.: Automatic termination proofs for Haskell by term rewriting. ACM Trans. Programm. Lang. Syst. 33(2) (2011). Article 7.
[14]
González-Moreno J, Hortalá-González M, López-Fraguas F, and Rodríguez-Artalejo M An approach to declarative programming based on a rewriting logic J. Log. Program. 1999 40 47-87
[15]
Hanus M Analysis of residuating logic programs J. Log. Program. 1995 24 3 161-199
[16]
Hanus, M.: Declarative processing of semistructured web data. In: Technical Communications of the 27th International Conference on Logic Programming, vol. 11, pp. 198–208. Leibniz International Proceedings in Informatics (LIPIcs) (2011).
[17]
Hanus M Voronkov A and Weidenbach C Functional logic programming: from theory to Curry Programming Logics 2013 Heidelberg Springer 123-168
[18]
Hanus, M.: Verifying fail-free declarative programs. In: Proceedings of the 20th International Symposium on Principles and Practice of Declarative Programming (PPDP 2018), pp. 12:1–12:13. ACM Press (2018).
[19]
Hanus M From logic to functional logic programs Theory Pract. Logic Program. 2022 22 4 538-554
[20]
Hanus, M.: Inferring non-failure conditions for declarative programs. In: Gibbons, J., Miller, D. (eds.) FLOPS 2024. LNCS, vol. 14659, pp. 167–187. Springer, Singapore (2024).
[21]
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).
[22]
Hanus, M. (ed.): Curry: an integrated functional logic language (vers. 0.9.0) (2016). http://www.curry-lang.org
[23]
Hermenegildo M et al. An overview of Ciao and its design philosophy Theory Pract. Logic Program. 2012 12 1–2 219-252
[24]
Huet, G., Lévy, J.J.: Computations in orthogonal rewriting systems. In: Lassez, J.L., Plotkin, G. (eds.) Computational Logic: Essays in Honor of Alan Robinson, pp. 395–443. MIT Press (1991)
[25]
Hughes, J.: Why functional programming matters. In: Turner, D. (ed.) Research Topics in Functional Programming, pp. 17–42. Addison Wesley (1990)
[26]
Jiménez-Martin, J., Marino-Carballo, J., Moreno-Navarro, J.: Efficient compilation of lazy narrowing into Prolog. In: Lau, K.K., Clement, T.P. (eds.) LOPSTR 1992, pp. 253–270. Springer, London (1992).
[27]
Kowalski R Algorithm = logic + control Commun. ACM 1979 22 7 424-436
[28]
Lee, C., Jones, N., Ben-Amram, A.: The size-change principle for program termination. In: ACM Symposium on Principles of Programming Languages (POPL 2001), pp. 81–92 (2001).
[29]
Lloyd, J.: Foundations of Logic Programming. 2nd edn. Springer, Heidelberg (1987).
[30]
Loogen R, Fraguas FL, and Artalejo MR Bruynooghe M and Penjam J A demand driven computation strategy for lazy narrowing Progamming Language Implementation and Logic Programming 1993 Heidelberg Springer 184-200
[31]
López Fraguas FJ and Sánchez Hernández J Narendran P and Rusinowitch M TOY: a multiparadigm declarative system Rewriting Techniques and Applications 1999 Heidelberg Springer 244-247
[32]
Naish L Maluszyński J and Wirsing M Adding equations to NU-Prolog Programming Language Implementation and Logic Programming 1991 Heidelberg Springer 15-26
[33]
Narain, S.: A technique for doing lazy evaluation in logic. J. Logic Programm. 3, 259–276 (1986).
[34]
Partain, W.: The nofib benchmark suite of Haskell programs. In: Launchbury, J., Sansom, P. (eds.) Proceedings of the 1992 Glasgow Workshop on Functional Programming, pp. 195–202. Springer, London (1992).
[35]
Peyton Jones, S. (ed.): Haskell 98 Language and Libraries—The Revised Report. Cambridge University Press (2003)
[36]
Reddy, U.: Transformation of logic programs into functional programs. In: Proceedings IEEE International Symposium on Logic Programming, Atlantic City, pp. 187–196 (1984)
[37]
Reddy, U.: Narrowing as the operational semantics of functional languages. In: Proceedings IEEE International Symposium on Logic Programming, Boston, pp. 138–151 (1985)
[38]
Sato T and Tamaki H Enumeration of success patterns in logic programs Theoret. Comput. Sci. 1984 34 227-240
[39]
Schrijvers T, Santos Costa V, Wielemaker J, and Demoen B Garcia de la Banda M and Pontelli E Towards Typed Prolog Logic Programming 2008 Heidelberg Springer 693-697
[40]
Slagle J Automated theorem-proving for theories with simplifiers, commutativity, and associativity J. ACM 1974 21 4 622-642
[41]
Sterling L and Shapiro E The Art of Prolog 1994 2 Cambridge, Massachusetts MIT Press
[42]
Van Roy, P., Haridi, S.: Ideas for the future of Prolog inspired by Oz. CoRR abs/2302.00558 (2023).
[43]
Wadler P How to declare an imperative ACM Comput. Surv. 1997 29 3 240-263
Index Terms
- Improving Logic Programs by Adding Functions
Index terms have been assigned to the content through auto-classification.
Comments
Information & Contributors
Information
Published In
Sep 2024
247 pages
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2024.
Publisher
Springer-Verlag
Berlin, Heidelberg
Publication History
Published: 09 September 2024
Qualifiers
- Article
Contributors
Other Metrics
Bibliometrics & Citations
Bibliometrics
Article Metrics
- 0Total Citations
- 0Total Downloads
- Downloads (Last 12 months)0
- Downloads (Last 6 weeks)0
Reflects downloads up to 06 Jan 2025