Hostname: page-component-76fb5796d-r6qrq Total loading time: 0 Render date: 2024-04-26T06:01:41.707Z Has data issue: false hasContentIssue false

Random generation of closed simply typed λ-terms: A synergy between logic programming and Boltzmann samplers*

Published online by Cambridge University Press:  13 October 2017

MACIEJ BENDKOWSKI
Affiliation:
Theoretical Computer Science Department, Faculty of Mathematics and Computer Science, Jagiellonian University, ul. Prof. Łojasiewicza 6, 30-348 Kraków, Poland (e-mail: bendkowski@tcs.uj.edu.pl, grygiel@tcs.uj.edu.pl)
KATARZYNA GRYGIEL
Affiliation:
Theoretical Computer Science Department, Faculty of Mathematics and Computer Science, Jagiellonian University, ul. Prof. Łojasiewicza 6, 30-348 Kraków, Poland (e-mail: bendkowski@tcs.uj.edu.pl, grygiel@tcs.uj.edu.pl)
PAUL TARAU
Affiliation:
Department of Computer Science and Engineering, University of North Texas, Denton, TX, USA (e-mail: paul.tarau@unt.edu)

Abstract

A natural approach to software quality assurance consists in writing unit tests securing programmer-declared code invariants. Throughout the literature, a great body of work has been devoted to tools and techniques automating this labour-intensive process. A prominent example is the successful use of randomness, in particular, random typable λ-terms, in testing functional programming compilers such as the Glasgow Haskell Compiler. Unfortunately, due to the intrinsically difficult combinatorial structure of typable λ-terms, no effective uniform sampling method is known, setting it as a fundamental open problem in the random software testing approach. In this paper, we combine the framework of Boltzmann samplers, a powerful technique of random combinatorial structure generation, with today's Prolog systems offering a synergy between logic variables, unification with occurs check and efficient backtracking. This allows us to develop a novel sampling mechanism able to construct uniformly random closed simply typed λ-terms of up size 120. We apply our techniques to the generation of uniformly random closed simply typed normal forms and design a parallel execution mechanism pushing forward the achievable term size to 140.

Type
Technical Note
Copyright
Copyright © Cambridge University Press 2017 

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Footnotes

*

The first two authors have been partially supported by the Polish National Science Center grant 2013/11/B/ST6/00975. The third author has been supported by NSF grant 1423324. A conference version of the present paper appears in the proceedings of PADL 2017 (PC chairs: Yuliya Lierler and Walid Taha).

References

Barendregt, H. P. 1991. Lambda calculi with types. In Handbook of Logic in Computer Science, Vol. 2, Oxford University Press.Google Scholar
Bendkowski, M., Grygiel, K., Lescanne, P. and Zaionc, M. 2016. A natural counting of lambda terms. In SOFSEM 2016: Theory and Practice of Computer Science - Proc. of 42nd International Conference on Current Trends in Theory and Practice of Computer Science, Freivalds, R. M., Engels, G. and Catania, B., Eds. Lecture Notes in Computer Science, vol. 9587. Springer, Harrachov, Czech Republic, January 23–28, 2016, 183194.Google Scholar
Bendkowski, M., Grygiel, K. and Tarau, P. 2017. Boltzmann samplers for closed simply-typed lambda terms. In Proc. of Practical Aspects of Declarative Languages – 19th International Symposium, PADL 2017. Paris, France, January 16–17, 2017.Google Scholar
Bodini, O., Gardy, D. and Gittenberger, B. 2011. Lambda terms of bounded unary height. In Proc. of the 8th Workshop on Analytic Algorithmics and Combinatorics (ANALCO), 23–32.Google Scholar
Bodini, O., Genitrini, A. and Rolin, N. 2015. Pointed versus singular Boltzmann samplers: A comparative analysis. Pure Mathematics and Applications 25, 2, 115131.CrossRefGoogle Scholar
Claessen, K. and Hughes, J. 2000. QuickCheck: A lightweight tool for random testing of Haskell programs. In ICFP '00: Proc. of 5th ACM SIGPLAN International Conference on Functional Programming, ACM, New York, NY, USA, 268–279.Google Scholar
David, R., Grygiel, K., Kozik, J., Raffalli, C., Theyssier, G. and Zaionc, M. 2013. Asymptotically almost all λ-terms are strongly normalizing. Logical Methods in Computer Science 9, 1:02, 130.Google Scholar
de Bruijn, N. G. 1972. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church–Rosser Theorem. Indagationes Mathematicae 34, 381392.CrossRefGoogle Scholar
Duchon, P., Flajolet, P., Louchard, G. and Schaeffer, G. 2004. Boltzmann samplers for the random generation of combinatorial structures. Combinatorics, Probability and Computing 13, 4–5, 577625.CrossRefGoogle Scholar
Flajolet, P. and Sedgewick, R. 2009. Analytic Combinatorics, 1 ed. Cambridge University Press, New York, NY, USA.CrossRefGoogle Scholar
Grygiel, K. and Lescanne, P. 2013. Counting and generating lambda terms. Journal of Functional Programming 23, 5, 594628.CrossRefGoogle Scholar
Grygiel, K. and Lescanne, P. 2015. Counting and generating terms in the binary lambda calculus. Journal of Functional Programming 25, 125.CrossRefGoogle Scholar
Hindley, J. R. and Seldin, J. P. 2008. Lambda-Calculus and Combinators: An Introduction, vol. 13. Cambridge University Press.CrossRefGoogle Scholar
Koopman, P., Alimarine, A., Tretmans, J. and Plasmeijer, R. 2003. Gast: Generic automated software testing. In Implementation of Functional Languages: 14th International Workshop, IFL 2002, Madrid, Spain, September 16–18, Springer, Berlin, Heidelberg, 84100.CrossRefGoogle Scholar
Koopman, P. and Plasmeijer, R. 2006. Systematic synthesis of functions. In The University of Nottingham, Nilsson, H. (ED.), Selected Papers of the 7th Symposium on Trends in Functional Programming, TFP 2006, Nottingham, UK, 68–83, Intellect Books.Google Scholar
Pałka, M. H., Claessen, K., Russo, A. and Hughes, J. 2011. Testing an optimising compiler by generating random lambda terms. In Proc. of the 6th International Workshop on Automation of Software Test, AST'11. ACM, New York, NY, USA, 91–97.Google Scholar
Sloane, N. J. A. 2014. The on-line encyclopedia of integer sequences. URL: https://oeis.org/. [Accessed on August 6, 2017].Google Scholar
Tarau, P. 2015a. On logic programming representations of lambda terms: de Bruijn indices, compression, type inference, combinatorial generation, normalization. In Proc. 7th International Symposium on Practical Aspects of Declarative Languages PADL'15, E. Pontelli and Son, T. C., Eds. Lecture Notes in Computer Science, vol. 8131. Springer, Portland, Oregon, USA, 115–131.Google Scholar
Tarau, P. 2015b. On type-directed generation of lambda terms. In 31st International Conference on Logic Programming (ICLP 2015), Technical Communications, De Vos, M., Eiter, T., Lierler, Y. and Toni, F., Eds. CEUR, Cork, Ireland. URL: http://ceur-ws.org/Vol-1433/.Google Scholar
Wilf, H. S. 2006. Generatingfunctionology. A. K. Peters, Ltd., Natick, MA, USA.Google Scholar