Skip to main content

Boltzmann Samplers for Closed Simply-Typed Lambda Terms

  • Conference paper
  • First Online:
Practical Aspects of Declarative Languages (PADL 2017)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 10137))

Included in the following conference series:

Abstract

Simply-typed lambda terms are often used in the internal language of compilers and proof assistants, for which generation of large, uniformly distributed random terms is instrumental for testing correctness and scalability. Recently, Boltzmann samplers have enabled uniform random generation of large terms belonging to several families of combinatorial objects that have a regular structure, amenable to methods from analytic combinatorics. Unfortunately, no closed formula or generating function facilitating such methods is known for closed simply-typed lambda terms. Moreover, given their asymptotic sparsity in the family of closed lambda terms, filtering simply-typed terms in the much larger set of terms generated by a Boltzmann sampler becomes quickly intractable. By taking advantage of the synergy between logic variables, unification with occurs check and efficient backtracking in today’s Prolog systems we advance this technique to term sizes interesting not only for correctness but also for scalability tests, by deriving Boltzmann samplers returning in a few seconds simply-typed random lambda terms of size 120 and above. We also apply our techniques to the generation of uniformly random closed simply-typed normal forms and give some hints on pushing them further via parallel execution algorithms.

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    A lambda term is called closed if it has no free variables and open otherwise. A term is called plain if it is either closed or open.

References

  1. Hindley, J.R., Seldin, J.P.: Lambda-Calculus and Combinators: An Introduction, vol. 13. Cambridge University Press, Cambridge (2008)

    Book  MATH  Google Scholar 

  2. Barendregt, H.P.: Lambda calculi with types. In: Handbook of Logic in Computer Science, vol. 2. Oxford University Press (1991)

    Google Scholar 

  3. Grygiel, K., Lescanne, P.: Counting and generating lambda terms. J. Funct. Program. 23(5), 594–628 (2013)

    Article  MathSciNet  MATH  Google Scholar 

  4. Bodini, O., Gardy, D., Gittenberger, B.: Lambda terms of bounded unary height. In: 2011 Proceedings of the Eighth Workshop on Analytic Algorithmics and Combinatorics (ANALCO), pp. 23–32 (2011)

    Google Scholar 

  5. David, R., Grygiel, K., Kozik, J., Raffalli, C., Theyssier, G., Zaionc, M.: Asymptotically almost all \(\lambda \)-terms are strongly normalizing. Logical Meth. Comput. Sci. 9(1:02), 1–30 (2013)

    MathSciNet  MATH  Google Scholar 

  6. Flajolet, P., Sedgewick, R.: Analytic Combinatorics, 1st edn. Cambridge University Press, New York (2009)

    Book  MATH  Google Scholar 

  7. Sloane, N.J.A.: The On-Line Encyclopedia of Integer Sequences (2014). https://oeis.org/

  8. 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). doi:10.1007/978-3-319-19686-2_9

    Chapter  Google Scholar 

  9. Grygiel, K., Lescanne, P.: Counting and generating terms in the binary lambda calculus. J. Funct. Program. 25, e24 (2015)

    Article  MathSciNet  Google Scholar 

  10. Bendkowski, M., Grygiel, K., Lescanne, P., Zaionc, M.: A natural counting of lambda terms. In: Freivalds, R.M., Engels, G., Catania, B. (eds.) SOFSEM 2016. LNCS, vol. 9587, pp. 183–194. Springer, Heidelberg (2016). doi:10.1007/978-3-662-49192-8_15

    Chapter  Google Scholar 

  11. de Bruijn, N.G.: Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagationes Math. 34, 381–392 (1972)

    Article  MathSciNet  MATH  Google Scholar 

  12. Duchon, P., Flajolet, P., Louchard, G., Schaeffer, G.: Boltzmann samplers for the random generation of combinatorial structures. Comb. Probab. Comput. 13(4–5), 577–625 (2004)

    Article  MathSciNet  MATH  Google Scholar 

  13. Claessen, K., Hughes, J.: QuickCheck: a lightweight tool for random testing of Haskell programs. In: Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming, ICFP 2000, pp. 268–279. ACM, New York (2000)

    Google Scholar 

  14. Koopman, P., Alimarine, A., Tretmans, J., Plasmeijer, R.: Gast: generic automated software testing. In: Peña, R., Arts, T. (eds.) IFL 2002. LNCS, vol. 2670, pp. 84–100. Springer, Berlin (2003). doi:10.1007/3-540-44854-3_6

    Chapter  Google Scholar 

  15. Palka, M.H., Claessen, K., Russo, A., Hughes, J.: Testing an optimising compiler by generating random lambda terms. In: Proceedings of the 6th International Workshop on Automation of Software Test, AST 2011, pp. 91–97. ACM, New York (2011)

    Google Scholar 

  16. Koopman, P., Plasmeijer, R.: Systematic synthesis of functions, pp. 68–83. The University of Nottingham (2006)

    Google Scholar 

  17. Tarau, P.: On Type-directed Generation of Lambda Terms. In: De Vos, M., Eiter, T., Lierler, Y., Toni, F. (eds.) 31st International Conference on Logic Programming (ICLP 2015), Technical Communications, Cork, Ireland, CEUR (2015). http://ceur-ws.org/Vol-1433/

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Paul Tarau .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this paper

Cite this paper

Bendkowski, M., Grygiel, K., Tarau, P. (2017). Boltzmann Samplers for Closed Simply-Typed Lambda Terms. In: Lierler, Y., Taha, W. (eds) Practical Aspects of Declarative Languages. PADL 2017. Lecture Notes in Computer Science(), vol 10137. Springer, Cham. https://doi.org/10.1007/978-3-319-51676-9_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-51676-9_8

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-51675-2

  • Online ISBN: 978-3-319-51676-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics