Author:
GRYGIEL KATARZYNA,LESCANNE PIERRE
Abstract
AbstractLambda calculus is the basis of functional programming and higher order proof assistants. However, little is known about combinatorial properties of lambda terms, in particular, about their asymptotic distribution and random generation. This paper tries to answer questions like: How many terms of a given size are there? What is a ‘typical’ structure of a simply typable term? Despite their ostensible simplicity, these questions still remain unanswered, whereas solutions to such problems are essential for testing compilers and optimizing programs whose expected efficiency depends on the size of terms. Our approach toward the aforementioned problems may be later extended to any language with bound variables, i.e., with scopes and declarations. This paper presents two complementary approaches: one, theoretical, uses complex analysis and generating functions, the other, experimental, is based on a generator of lambda terms. Thanks to de Bruijn indices (de Bruijn, N. (1972) Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagat. Math.34(5), 381–392), we provide three families of formulas for the number of closed lambda terms of a given size and we give four relations between these numbers which have interesting combinatorial interpretations. As a by-product of the counting formulas, we design an algorithm for generating λ-terms. Performed tests provide us with experimental data, like the average depth of bound variables and the average number of head lambdas. We also create random generators for various sorts of terms. Thereafter, we conduct experiments that answer questions like: What is the ratio of simply typable terms among all terms? (Very small!) How are simply typable lambda terms distributed among all lambda terms? (A typable term almost always starts with an abstraction.) In this paper, abstractions and applications have size 1 and variables have size 0.
Publisher
Cambridge University Press (CUP)
Reference28 articles.
1. Finding and understanding bugs in C compilers
2. Wang J. (2005) Generating Random Lambda Calculus Terms. Citeseer. Available at: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.95.2624. Accessed October 17, 2013.
3. Wang J. (2004, May) The Efficient Generation of Random Programs and Their Applications, MPhil thesis, Honors Thesis, Wellesley College, Wellesley, MA.
4. Stein W. et al. (2012) Sage Mathematics Software (Version 4.8) (The Sage Development Team). Available at: http://www.sagemath.org. Accessed October 17, 2013.
Cited by
32 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献