69 research outputs found
Boltzmann samplers for random generation of lambda terms
Randomly generating structured objects is important in testing and optimizing
functional programs, whereas generating random -terms is more specifically
needed for testing and optimizing compilers. For that a tool called QuickCheck
has been proposed, but in this tool the control of the random generation is
left to the programmer. Ten years ago, a method called Boltzmann samplers has
been proposed to generate combinatorial structures. In this paper, we show how
Boltzmann samplers can be developed to generate lambda-terms, but also other
data structures like trees. These samplers rely on a critical value which
parameters the main random selector and which is exhibited here with
explanations on how it is computed. Haskell programs are proposed to show how
samplers are actually implemented
Counting and Generating Terms in the Binary Lambda Calculus (Extended version)
In a paper entitled Binary lambda calculus and combinatory logic, John Tromp
presents a simple way of encoding lambda calculus terms as binary sequences. In
what follows, we study the numbers of binary strings of a given size that
represent lambda terms and derive results from their generating functions,
especially that the number of terms of size n grows roughly like 1.963447954.
.. n. In a second part we use this approach to generate random lambda terms
using Boltzmann samplers.Comment: extended version of arXiv:1401.037
Unary profile of lambda terms with restricted De Bruijn indices
In this paper we present an average-case analysis of closed lambda terms with restricted values of De Bruijn indices in the model where each occurrence of a variable contributes one to the size. Given a fixed integer k, a lambda term in which all De Bruijn indices are bounded by k has the following shape: It starts with k De Bruijn levels, forming the so-called hat of the term, to which some number of k-colored Motzkin trees are attached. By means of analytic combinatorics, we show that the size of this hat is constant on average and that the average number of De Bruijn levels of k-colored Motzkin trees of size n is asymptotically Θ(√ n). Combining these two facts, we conclude that the maximal non-empty De Bruijn level in a lambda term with restrictions on De Bruijn indices and of size n is, on average, also of order √ n. On this basis, we provide the average unary profile of such lambda terms
Statistical properties of lambda terms
We present a quantitative, statistical analysis of random lambda terms in the
de Bruijn notation. Following an analytic approach using multivariate
generating functions, we investigate the distribution of various combinatorial
parameters of random open and closed lambda terms, including the number of
redexes, head abstractions, free variables or the de Bruijn index value
profile. Moreover, we conduct an average-case complexity analysis of finding
the leftmost-outermost redex in random lambda terms showing that it is on
average constant. The main technical ingredient of our analysis is a novel
method of dealing with combinatorial parameters inside certain infinite,
algebraic systems of multivariate generating functions. Finally, we briefly
discuss the random generation of lambda terms following a given skewed
parameter distribution and provide empirical results regarding a series of more
involved combinatorial parameters such as the number of open subterms and
binding abstractions in closed lambda terms.Comment: Major revision of section 5. In particular, proofs of Lemma 5.7 and
Theorem 5.
Statistical properties of lambda terms
We present a quantitative, statistical analysis of random lambda terms in the De Bruijn notation. Following an analytic approach using multivariate generat-ing functions, we investigate the distribution of various combinatorial parameters of random open and closed lambda terms, including the number of redexes, head abstractions, free variables or the De Bruijn index value profile. Moreover, we con-duct an average-case complexity analysis of finding the leftmost-outermost redex in random lambda terms showing that it is on average constant. The main technical
ingredient of our analysis is a novel method of dealing with combinatorial paramet-ers inside certain infinite, algebraic systems of multivariate generating functions. Finally, we briefly discuss the random generation of lambda terms following a given skewed parameter distribution and provide empirical results regarding a series of more involved combinatorial parameters such as the number of open subterms and binding abstractions in closed lambda terms
- …