Abstract
The paper describes an application of logic programming to the modeling of difficult combinatorial properties of lambda terms, with focus on the class of simply typed terms.
Lambda terms in de Bruijn notation are Motzkin trees (also called binary-unary trees) with indices at their leaves counting up on the path to the root the steps to their lambda binder.
As a generalization of affine lambda terms, we introduce k-colored lambda terms obtained by labeling their lambda nodes with counts of the variables they bind. We define the skeleton of a k-colored lambda term as the Motzkin tree obtained by erasing the de Bruijn indices labeling its leaves. A new bijection between 2-colored skeletons and binary trees reveals their connection to the Catalan family of combinatorial objects.
After a statistical study of properties of k-colored lambda terms and their skeletons, we focus on the case of simply-typed closed k-colored lambda terms for which a new combinatorial generation algorithm is given and some interesting relations between maximal coloring, size of type expressions and typability are explored.
The paper is structured as a literate Prolog program to facilitate an easily replicable, concise and declarative expression of our concepts and algorithms.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Functional programmers might notice here the analogy with the use of monads encapsulating state changes with constructs like Haskell’s do notation.
References
de Bruijn, N.G.: Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagationes Mathematicae 34, 381–392 (1972)
Kostrzycka, Z., Zaionc, M.: Asymptotic densities in logic and type theory. Stud. Logica. 88(3), 385–403 (2008)
Tarau, P.: A hiking trip through the orders of magnitude: deriving efficient generators for closed simply-typed lambda terms and normal forms. In: Hermenegildo, M.V., Lopez-Garcia, P. (eds.) LOPSTR 2016. LNCS, vol. 10184, pp. 240–255. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-63139-4_14. Best paper award
Bendkowski, M., Grygiel, K., Tarau, P.: Boltzmann samplers for closed simply-typed lambda terms. In: Lierler, Y., Taha, W. (eds.) PADL 2017. LNCS, vol. 10137, pp. 120–135. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-51676-9_8
Wielemaker, J., Schrijvers, T., Triska, M., Lager, T.: SWI-Prolog. Program. Theor. Pract. Logic 12, 67–96 (2012)
Deutsch, E., Shapiro, L.W.: A bijection between ordered trees and 2-motzkin paths and its many consequences. Discrete Math. 256(3), 655–670 (2002)
Rémy, J.L.: Un procédé itératif de dénombrement d’arbres binaires et son application à leur génération aléatoire. RAIRO - Theor. Inf. Appl. Informatique Théorique et Applications 19(2), 179–195 (1985)
Tarau, P.: On a uniform representation of combinators, arithmetic, lambda terms and types. In: Albert, E. (ed.) PPDP 2015: Proceedings of the 17th International ACM SIGPLAN Symposium on Principles and Practice of Declarative Programming, pp. 244–255. ACM, New York, July 2015
Lescanne, P.: Quantitative aspects of linear and affine closed lambda terms. CoRR abs/1702.03085 (2017)
Bodini, O., Tarau, P.: On Uniquely Closable and Uniquely Typable Skeletons of Lambda Terms. CoRR abs/1709.04302, September 2017
Tarau, P.: On logic programming representations of lambda terms: de bruijn indices, compression, type inference, combinatorial generation, normalization. In: Pontelli, E., Son, T.C. (eds.) PADL 2015. LNCS, vol. 9131, pp. 115–131. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-19686-2_9
Barendregt, H.P.: The Lambda Calculus Its Syntax and Semantics, vol. 103, Revised edn. North Holland, Amsterdam (1984)
Barendregt, H.P.: Lambda calculi with types. In: Handbook of Logic in Computer Science, vol. 2. Oxford University Press, New York (1991)
Lescanne, P.: On counting untyped lambda terms. Theoret. Comput. Sci. 474, 80–97 (2013)
Grygiel, K., Lescanne, P.: Counting and generating lambda terms. J. Funct. Program. 23(5), 594–628 (2013)
David, R., Raffalli, C., Theyssier, G., Grygiel, K., Kozik, J., Zaionc, M.: Some properties of random lambda terms. Logical Methods Comput. Sci. 9(1) (2009)
Bodini, O., Gardy, D., Jacquot, A.: Asymptotics and random sampling for BCI and BCK lambda terms. Theoret. Comput. Sci. 502, 227–238 (2013)
Genitrini, A., Kozik, J., Zaionc, M.: Intuitionistic vs. classical tautologies, quantitative comparison. In: Miculan, M., Scagnetto, I., Honsell, F. (eds.) TYPES 2007. LNCS, vol. 4941, pp. 100–109. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-68103-8_7
Acknowledgement
This research has been supported by NSF grant 1423324. We thank the reviewers of PADL’18 for their careful reading of the paper and their valuable suggestions to improve its presentation. We thank the participants of the CLA’2017 workshop (https://cla.tcs.uj.edu.pl/programme.html) for illuminating discussions and their comments on our talk covering the main ideas of this paper.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer International Publishing AG
About this paper
Cite this paper
Tarau, P. (2018). On k-colored Lambda Terms and Their Skeletons. In: Calimeri, F., Hamlen, K., Leone, N. (eds) Practical Aspects of Declarative Languages. PADL 2018. Lecture Notes in Computer Science(), vol 10702. Springer, Cham. https://doi.org/10.1007/978-3-319-73305-0_8
Download citation
DOI: https://doi.org/10.1007/978-3-319-73305-0_8
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-73304-3
Online ISBN: 978-3-319-73305-0
eBook Packages: Computer ScienceComputer Science (R0)