35 research outputs found
Exact-size Sampling for Motzkin Trees in Linear Time via Boltzmann Samplers and Holonomic Specification
International audienceBoltzmann samplers are a kind of random samplers; in 2004, Duchon, Flajolet, Louchard and Schaeffer showed that given a combinatorial class and a combinatorial specification for that class, one can automatically build a Boltzmann sampler. In this paper, we introduce a Boltzmann sampler for Motzkin trees built from a holonomic specification, that is, a specification that uses the pointing operator. This sampler is inspired by Rémy's algorithm on binary trees. We show that our algorithm gives an exact size sampler with a linear time and space complexity in average
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
Holonomic equations and efficient random generation of binary trees
Holonomic equations are recursive equations which allow computingefficiently
numbers of combinatoric objects. R{\'e}my showed that theholonomic equation
associated with binary trees yields an efficientlinear random generator of
binary trees. I extend this paradigm toMotzkin trees and Schr{\"o}der trees and
show that despite slightdifferences my algorithm that generates random
Schr{\"o}der trees has linearexpected complexity and my algorithm that
generates Motzkin trees is inO(n) expected complexity, only if we can implement
a specific oraclewith a O(1) complexity. For Motzkin trees, I propose a
solution whichworks well for realistic values (up to size ten millions) and
yields anefficient algorithm
Polynomial tuning of multiparametric combinatorial samplers
Boltzmann samplers and the recursive method are prominent algorithmic
frameworks for the approximate-size and exact-size random generation of large
combinatorial structures, such as maps, tilings, RNA sequences or various
tree-like structures. In their multiparametric variants, these samplers allow
to control the profile of expected values corresponding to multiple
combinatorial parameters. One can control, for instance, the number of leaves,
profile of node degrees in trees or the number of certain subpatterns in
strings. However, such a flexible control requires an additional non-trivial
tuning procedure. In this paper, we propose an efficient polynomial-time, with
respect to the number of tuned parameters, tuning algorithm based on convex
optimisation techniques. Finally, we illustrate the efficiency of our approach
using several applications of rational, algebraic and P\'olya structures
including polyomino tilings with prescribed tile frequencies, planar trees with
a given specific node degree distribution, and weighted partitions.Comment: Extended abstract, accepted to ANALCO2018. 20 pages, 6 figures,
colours. Implementation and examples are available at [1]
https://github.com/maciej-bendkowski/boltzmann-brain [2]
https://github.com/maciej-bendkowski/multiparametric-combinatorial-sampler
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