21 research outputs found
On Uniquely Closable and Uniquely Typable Skeletons of Lambda Terms
Uniquely closable skeletons of lambda terms are Motzkin-trees that
predetermine the unique closed lambda term that can be obtained by labeling
their leaves with de Bruijn indices. Likewise, uniquely typable skeletons of
closed lambda terms predetermine the unique simply-typed lambda term that can
be obtained by labeling their leaves with de Bruijn indices.
We derive, through a sequence of logic program transformations, efficient
code for their combinatorial generation and study their statistical properties.
As a result, we obtain context-free grammars describing closable and uniquely
closable skeletons of lambda terms, opening the door for their in-depth study
with tools from analytic combinatorics.
Our empirical study of the more difficult case of (uniquely) typable terms
reveals some interesting open problems about their density and asymptotic
behavior.
As a connection between the two classes of terms, we also show that uniquely
typable closed lambda term skeletons of size are in a bijection with
binary trees of size .Comment: Pre-proceedings paper presented at the 27th International Symposium
on Logic-Based Program Synthesis and Transformation (LOPSTR 2017), Namur,
Belgium, 10-12 October 2017 (arXiv:1708.07854
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
Normal-order reduction grammars
We present an algorithm which, for given , generates an unambiguous
regular tree grammar defining the set of combinatory logic terms, over the set
of primitive combinators, requiring exactly normal-order
reduction steps to normalize. As a consequence of Curry and Feys's
standardization theorem, our reduction grammars form a complete syntactic
characterization of normalizing combinatory logic terms. Using them, we provide
a recursive method of constructing ordinary generating functions counting the
number of -combinators reducing in normal-order reduction steps.
Finally, we investigate the size of generated grammars, giving a primitive
recursive upper bound
Counting Terms in the Binary Lambda Calculus
International audienceIn 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
A correspondence between rooted planar maps and normal planar lambda terms
A rooted planar map is a connected graph embedded in the 2-sphere, with one
edge marked and assigned an orientation. A term of the pure lambda calculus is
said to be linear if every variable is used exactly once, normal if it contains
no beta-redexes, and planar if it is linear and the use of variables moreover
follows a deterministic stack discipline. We begin by showing that the sequence
counting normal planar lambda terms by a natural notion of size coincides with
the sequence (originally computed by Tutte) counting rooted planar maps by
number of edges. Next, we explain how to apply the machinery of string diagrams
to derive a graphical language for normal planar lambda terms, extracted from
the semantics of linear lambda calculus in symmetric monoidal closed categories
equipped with a linear reflexive object or a linear reflexive pair. Finally,
our main result is a size-preserving bijection between rooted planar maps and
normal planar lambda terms, which we establish by explaining how Tutte
decomposition of rooted planar maps (into vertex maps, maps with an isthmic
root, and maps with a non-isthmic root) may be naturally replayed in linear
lambda calculus, as certain surgeries on the string diagrams of normal planar
lambda terms.Comment: Corrected title field in metadat
Pragmatic Isomorphism Proofs Between Coq Representations: Application to Lambda-Term Families
There are several ways to formally represent families of data, such as lambda terms, in a type theory such as the dependent type theory of Coq. Mathematical representations are very compact ones and usually rely on the use of dependent types, but they tend to be difficult to handle in practice. On the contrary, implementations based on a larger (and simpler) data structure combined with a restriction property are much easier to deal with.
In this work, we study several families related to lambda terms, among which Motzkin trees, seen as lambda term skeletons, closable Motzkin trees, corresponding to closed lambda terms, and a parameterized family of open lambda terms. For each of these families, we define two different representations, show that they are isomorphic and provide tools to switch from one representation to another. All these datatypes and their associated transformations are implemented in the Coq proof assistant. Furthermore we implement random generators for each representation, using the QuickChick plugin
Combinatorics of explicit substitutions
is an extension of the -calculus which
internalises the calculus of substitutions. In the current paper, we
investigate the combinatorial properties of focusing on the
quantitative aspects of substitution resolution. We exhibit an unexpected
correspondence between the counting sequence for -terms and
famous Catalan numbers. As a by-product, we establish effective sampling
schemes for random -terms. We show that typical
-terms represent, in a strong sense, non-strict computations
in the classic -calculus. Moreover, typically almost all substitutions
are in fact suspended, i.e. unevaluated, under closures. Consequently, we argue
that is an intrinsically non-strict calculus of explicit
substitutions. Finally, we investigate the distribution of various redexes
governing the substitution resolution in and investigate the
quantitative contribution of various substitution primitives