Counting and generating lambda terms - Archive ouverte HAL Access content directly
Preprints, Working Papers, ... Year :

Counting and generating lambda terms

(1) , (2, 3)
1
2
3

Abstract

Lambda 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 afore-mentioned 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, 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 lambda 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.
Fichier principal
Vignette du fichier
KG_PL_Counting_Lambdas.pdf (558.15 Ko) Télécharger le fichier
Origin : Files produced by the author(s)

Dates and versions

ensl-00740034 , version 1 (09-10-2012)
ensl-00740034 , version 2 (14-12-2012)
ensl-00740034 , version 3 (06-01-2013)
ensl-00740034 , version 4 (04-02-2013)
ensl-00740034 , version 5 (11-04-2013)
ensl-00740034 , version 6 (24-04-2013)
ensl-00740034 , version 7 (03-07-2013)

Identifiers

Cite

Katarzyna Grygiel, Pierre Lescanne. Counting and generating lambda terms. 2012. ⟨ensl-00740034v7⟩
209 View
632 Download

Altmetric

Share

Gmail Facebook Twitter LinkedIn More