From a declarative variant of Rémy's algorithm for uniform random generation of binary trees, we derive a generalization to term algebras of an arbitrary signature. With trees seen as sets of edges connecting vertices labeled with logic variables, we use Prolog's multiple-answer generation mechanism to derive a generic algorithm that ...
Full Text:
Declarative
Algorithms for
Generation, , Counting and Random Sampling of
Term AlgebrasDeclarative
Algorithms for
Generation, , Counting and RandomSampling of
Term AlgebrasPaul TarauDepartment of Computer Science and EngineeringUniversity of North TexasDenton, ... EngineeringUniversity of North TexasDenton,
[email protected] a declarative variant of R my’s
algorithm for uniform ran-dom
generation of binary trees, we derive a
generalization to termalgebras of an arbitrary signature. With trees seen as ... of edgesconnecting vertices labeled with logic variables, we use Prolog’smultiple-answer
generation mechanism to derive a
generic algo-rithm that counts
terms of a given size,
generates them all, orsamples a random
term given the signature of a
term algebra.As applications, we implement
generators for
term algebrasdefining Motzkin trees, use all-
term and random-
term generationfor mutual cross-testing and describe an extension mechanism thattransforms a ... trees into one for closedlambda terms.CCS CONCEPTS• Theory of computation?
Generating random combinato-rial structures; Lambda calculus; • Software and its engineer-ing ... its engineer-ing ? Constraint and logic languages; Software testing anddebugging;KEYWORDSdeclarative
algorithms, , combinatorial
generation, , random termgeneration, edge-based tree representations,
term algebras, Motzkintrees,
generation of random lambda termsACM Reference format:Paul Tarau. 2018. Declarative
Algorithms for
Generation, , Counting andRandom Sampling of
Term Algebras. In Proceedings of SAC 2018: Symposiumon Applied Computing , ... Pau, France, April 9–13, 2018 (SAC 2018), 8 pages.https://doi.org/10.1145/3167132.31672621 INTRODUCTIONR my’s
algorithm [10] elegantly
generates random binary treesof a given size. It is a uniform ... treesof a given size. It is a uniform random sampling
algorithm as anytree of a given size is equally likely to ... anytree of a given size is equally likely to be
generated. . It is also anexact sampler as the random trees ... Associa-tion for Computing Machinery.ACM ISBN 978-1-4503-5191-1/18/04. . . $15.00https://doi.org/10.1145/3167132.3167262R my’s original
algorithm works by grafting new leaves at inter-nal or leaf nodes ... and extend the array. Whileone could easily transliterate such procedural
algorithms by usingnon-backtrackable destructive assignments on arrays representedas compound
terms in Prolog, we have chosen to design a declar-ative
algorithm as this usually reveals the intuitive idea behindthe construction process ... . This leads us to a declarative implemen-tation of an
algorithm that
generates trees representing elementsof a
term algebra specified by a given signature (i.e., the set offunction-symbols ... constant symbolsof arity 0), with its most obvious application being
generation ofrandom Prolog
terms for testing purposes.Furthermore, one cannot avoid noticing that the
generation ofall trees of a given size, and the random
generation of a tree, canshare exactly the same
algorithm, , when seen as Prolog code, exceptthat multiple-answer predicates like ... this fortunate sharing of the declarative descrip-tion of the two
generation mechanisms suggests means for checkingthe correctness of each other and ... observe some of their otherwiseintractable properties. For instance, if the all-
term generator wouldmiss
terms, , it would entail that the random
generator would alsodo the same. On the other hand, the distribution ... distribution obtained by count-ing the function-symbols and constants on random
terms at sizesunreachable by all-
term generators is a good estimate of what islikely to happen to ... a good estimate of what islikely to happen to the all-
term generators asymptotically.As applications, Motzkin trees (also called binary-unary trees)are of special ... trees)are of special importance as they are close to lambda
terms ... as shown in [3]). We will add tothem an extension
algorithm that “completes” a Motzkin tree toa closed lambda
term involving very few or most of the time noretries for ... very few or most of the time noretries for random
terms above size 1000.The main contributions of the paper are:• a ... are:• a new, declarative implementation of a variant of R my’salgorithm• all-
terms and random
term generation in
term algebras of agiven signature, in particular for Prolog
terms built from aset of constants and function-symbols of given arities1203• ... of given arities1203• mutual correctness checking by sharing the code betweenall-
terms and random
generators• • an
algorithm to derive closed lambda
terms from MotzkintreesThe rest of the paper is organized as follows. ... of the paper is organized as follows. Section 2 revisitsR my’s
algorithm and proposes a simplified implementation basedon extending edges holding vertices ... extending edges holding vertices represented as logic variables.Section 3 describes
generators for
term algebras of a given signature.Section 4 overviews applications to
generate Motzkin trees andshows mechanisms to cross-validate all-
term and random termgenerators. Section 5 describes an
algorithm that extends Motzkintrees to closed lambda
terms. . Section 6 overviews related workand discusses some properties of ... Section 6 overviews related workand discusses some properties of our
algorithms, , including theirlimitations and possible future
generalizations. . Section 7 concludesthe paper.The paper is structured as a ... easily replicable, concise and declarative expression of our con-cepts and
algorithms. . The code extracted from it is at http://www.cse.unt.edu/~tarau/research/2017/ranalg.pro with ... at http://www.cse.unt.edu/~tarau/research/2017/lpgen.tar.gz ,tested with SWI-Prolog [13] version 7.4.2.2 REVISITING R MY’S
ALGORITHM, ,DECLARATIVELYOne might wonder why binary trees cannot be
generated ... by ran-domly adding nodes at their leaves, as a naive
algorithm wouldproceed. As thoroughly explained, for instance in [6], this wouldnot ... given sizewould have the same chance to be generated.R my’s original
algorithm [10] grows binary trees by graftingnew leaves with equal probability ... given tree. Anelegant procedural implementation is given in [6] as
algorithm R,by using destructive assignments in an array representing the tree.While ... the paper, we provide specific files toparameterize either random or all-
term generation that include a shared genericalgorithm, as close to an object-oriented ... a language like Prolog.They contain also, specific signatures supporting the
generalization of the algorithmto several
term algebras.left_or_right(I,J):-choice_of(2,Dice),left_or_right(Dice,I,J).choice_of(N,K):-K is random(N).% choice_of(N,K):-N>0,N1 is N-1,between(0,N1,K).left_or_right(0,left,right).left_or_right(1,right,left).This avoids adding the actual ... as its first argument. Note also, thatcontrary to R my’s original
algorithm, , our tree grows “downward”as new edges are inserted at ... does not change any of the correctnessassumptions of R my’s original
algorithm, , as proven in [10].The new node C, connected to ...
left_or_right(I,J).This leads us the basic step of the
algorithm, , where a set ofedges Es is rewritten as a ... K=1 by callingremy_init.remy_loop(0,[],0).remy_loop(1,Es,2) :-remy_init(Es).remy_loop(K,NewEs,N3):-K>1, K1 is K-1,remy_loop(K1,Es,N2),1204remy_step(Es,NewEs,N2,N3).Example 1. illustrates the
generation of a random list of edges ofsize 4:?- remy_loop(2,Edges,N).Edges =[e(left,A,B),e(right,A,C),e(right,C,D),e(left,C,E)],N ... termsThe final step, “unleashing”the power of logic variables, extractsa Prolog
term representing the binary tree from the list of edgeslabeled with ... given the order-independence of thebinding of logical variables, the same
term is built independentlyof the order of the edges.Next, the predicate ... remy_term/2 puts the two main steps together.remy_term(K,B):-remy_loop(K,Es,_),bind_nodes(Es,B).Example 2. illustrates the
generation of a random
term with 4internal nodes as well timings for a larger random ... .?- time(remy_term(1000,_)).1,025,950 inferences,0.085 CPU in 0.098 seconds (12113466 Lips)While the
algorithm handles fairly large
terms in reasonable time,we do not claim that its average performance ... with a dynamically growing array rep-resentation using arbitrary arity compound
terms as containers.3 A
GENERAL ALGORITHM FOR TERMALGEBRAS OF GIVEN SIGNATURECombinatorial
algorithms (as shown for instance in [4]) are a natu-ral match ... and definite clause grammars (DCGs). We will start witha simple
generator, ... , that we will use as a reference implementationfor an
algorithm generating term ... algebras of a given signature, thatcan be seen as a
generalization of R my’s
algorithm. .3.1 A simple
generator, , using DCGsAs we want to ensure that
terms of an exact size are
generated, ,for a given “size” definition, we spend some “Fuel” at ... we consume N units of“Fuel”. This will result in a
term having a size proportional to the sizethat a Prolog
term has when represented on the heap.We will use Prolog’s DCG ... the argumentscontrolling the size consumed at each step. The predicate gen(Fs,T)
generates a
term T using the list Fs of function-symbol/arity pairs(including constants seen ... which iterates with Prolog’s arg/3over each argument of a compound
term created with Prolog’sgeneric
term ... mention that the 2 extraarguments constraining the size of the
terms are added when the“-->” clause constructor is used. We expose ... added when the“-->” clause constructor is used. We expose the
generator via thepredicate gen/3, that given input arguments N=intended size of ... of size N built using Fs.gen(N,Fs, T):-gen(Fs,T,N,0).Example 3. illustrates the
generation of all binary trees of size 6seen as defined by ... ;1205T = a(a(a(v,v),v),v) .3.2 A unified “choice definition” for all-termand random-
term generatorsWe start by observing that by replacing in our variant ... section 2 the predicate choice_of/2 bychoice_of(N,K):-N>0,N1 is N-1,between(0,N1,K).we obtain a
generator for all
terms of a given size. Let us note that itis a ... feature of Prolog that an one-line code change turnsa random
term generator into an all-
term generator. . This brings usto design our choice operator to be ... over allchoices or picking a choice randomly. For a random
term generatorwe define the following “customized” choice operators:member_choice(Choice,Choices):-length(Choices,L),L>0,I is random(L),nth0(I,Choices,Choice).select_choice(Choice,Choices,ChoicesLeft):-length(Choices,L),L>0,I is ... an element of a list.It could also be defined in
terms of select_choice/3 that picksan element randomly and returns the remaining ... which are used if one wants to iterate over all
terms of agiven size:member_choice(Choice,Choices):-member(Choice,Choices).select_choice(Choice,Choices1,Choices2):-select(Choice,Choices1,Choices2).between_choice(From,To,I):-between(From,To,I).As we will see, except for these alternatives ... the same Prolog code can be used to implement our
general- -ization of R my’s
algorithm. . Moreover, the number of solutions ofthe
generator provides a counting mechanism, of interest especiallywhen no closed formulas ... a counting mechanism, of interest especiallywhen no closed formulas or
generator functions exist for it (e.g.,the case of simply-typed lambda
terms) ).Note that we do not expect the random sampler to ... other hand, the resulting samplers are always exhaus-tive, with every
term in the set of
terms of a given size having achance to be selected. In ... selected. In the case of binary trees, as for R my’soriginal
algorithm, , this chance is the same for all
terms of a givensize, while, for instance, in the case of ... for instance, in the case of Motzkin trees, much moreintricate
algorithms, , as shown in [1] are needed for uniformity.While we ... with which functionsymbols are picked, for instance, to customize the
generators tomatch their frequency in a segment of code for which ... tester.3.3 Parameterizing with the signatureLike in the case of the
generator defined in subsection 3.1, we willparameterize our program with a ... = [2-[f, g, t], 3-[h, s]].3.4 Distilling some essence :
generating thearity-skeletonAs multiple function-symbols may share the same arity, we chooseto ... same arity, we chooseto abstract away an ‘‘arity-skeleton” of the
generated term, , thatwill be fleshed out later with the actual function-symbols. ...
... variant of R my’s algorithmin section 2. We insert a new
term A by splitting edge X->Y intoX->A and A->Y, and then ... the set ofedges.filter_smaller([],_,[]).filter_smaller([I|_Is],D,[]):-I>D. % they are sorted!filter_smaller([I|Is],D,[I|Js]):-I=<D,filter_smaller(Is,D,Js).We can test the
generation of edges driven by “arity-skeletons” withthe predicate ext_test, that, given ... illustrates its work the predicate ext_test that, giventhe signature [v/0,l/1,a/2],
generates a random set of edges of size5.?- ext_test(5,[v/0,l/1,a/2],Root-Edges).Root=A,Edges=[e(2,1,A,B),e(2,1,B,C),e(2,0,B,D),e(2,0,A,E),e(1,0,E,F)] .3.5 Fleshing-it ... at leavesLike in the case of our variant of R my’s
algorithm in section2, we extract a
term by iterating over the edges and binding thelogic variables according ... predicate edge2fun/2 selects among function-symbols usingmember_choice/2 before building the corresponding
terms. . To en-sure that in the case of random
generation two edges originatingfrom the same node do not try to ... originatingfrom the same node do not try to build different
terms when mul-tiple function-symbols of the same arity are present, we ...
... togetherThe predicate gen_terms(M,FCs,T) takes as input the desired sizeof a
generated term M and a set of function-symbol / arity pairs FCswith ... FCswith constants represented as having arity 0. It returns a
term T ofsize M, based on a size definition that weights ... the set of edges to size M and finallyextracting the
terms from the set of edges. Note that the algorithmgenerates a ... set of edges. Note that the algorithmgenerates a multiset of
terms in the case we define the all-termschoice predicates, that can ... does not make any difference when a unique random termis
generated, , we expose the overall functionality of our algorithmthrough a ... the predicate gen_term/3.Example 6. illustrates some uses of gen_term/3 to
generate all-
term terms. .?- gen_term(3,[v/0,l/1,a/2],T).T = l(l(l(v))) ;T = l(a(v, v)) ;T = ... a(v, l(v)) .Example 7. illustrates some uses of gen_term/3 to
generate ran-dom
terms. .?- gen_term(30,[0/0,1/0,(~)/1,(*)/2,(+)/2],T).T = ~((~(0*0)* ~(~(~(~(~(~(~(~(1))))*(1+1)*0))+0*1))+ ~(1))* ~(1)) .?- time(gen_term(4000,[v/0,a/2],_)).% 2,192,586 ... binary trees is comparablethan with the specialized variant of R my’s
algorithm described insection 2.4 APPLICATIONS4.1 Motzkin treesWe can specialize our
generators to a given set of function symbols.As an example, Motzkin ... (also called binary-unary trees) aredescribed bymot_funs([v/0,l/1,a/2]).Then, as each of our
generators is parameterized by the signatureof the
term algebra, we obtain:mot(N,T):-mot_funs(CFs),gen(N,CFs,T).for
generating plain Motzkin trees. In section 5, we will use theMotzkin ... Motzkin trees. In section 5, we will use theMotzkin tree
generator as a skeleton to be extended to lambdaterms.4.2 Correctness cross-checks ... to be extended to lambdaterms.4.2 Correctness cross-checks between all-termsgenerators and random-
term generatorsOne of the fallouts of having the same code work ... of having the same code work as an all-termsand random
term generator is that we can do some cross-checkingof properties that we ... expect to hold in both cases.4.2.1 Testing the equivalence between all-
term generators. . First,we can check the empirical soundness of the
generator by compar-ing the
terms of a given size it outputs with those of the ... in subsection 3.1. While this can bedone for a few
terms with human eyes, the faster than exponentialgrowth with respect to ... termsgenerated for successive sizes. We will do that for two
term algebras- one for binary trees and the other for Motzkin ... 5,0, 14, 0, 42, 0, 132, 0, 429 ... with
terms in even posi-tions corresponding to the Catalan numbers, counted by ... Motzkin numbers that are counted by sequence A001006 in[11].As in all-
terms generation mode our
generic code works signifi-cantly slower than the depth-first
generator gen/2 of subsection3.1, once we trust their equivalence, we can ... can rely on comparingassertions that should hold for the random
terms as well as termsprovided by our more efficient depth-first
term generator gen/2.4.2.2 No
term left behind: checking that any
term can be thechosen one. As we use the same code ... thechosen one. As we use the same code for the all-
terms and randomterm
generators, , equivalence of the former with as the standardgen/2
generator entails that, in principle, all
terms have a chanceto be
generated when running the
generator in random mode. But,as a side note, one should keep ... the humungous sizeof the space of possibilities for a random
term of, say, size 1000,cannot be matched by the period of ... size 1000,cannot be matched by the period of the random
generators we use.Consequently, only as many distinct
terms as the period of theconcrete random
generator have a chance to be
generated. .4.3 Function-symbol counts: checking theingredients of the random recipeCombinatorial proofs ... of the random recipeCombinatorial proofs of properties of a R my-like
generator for aterm algebra of a given signature are fairly intricate ... couldindicate that a similar, “close-enough” empirical distribution existsfor the random
terms ... count of the function-symbols occurring in the output of random
term and in all-termgenerators. In the case of all-
terms of a given size we compute thatby summing them up ... size we compute thatby summing them up over all the
generated terms. . Given their largenumber, even for small sizes, it is ... we can trust the largercounts reachable by our equivalent standard
generators we obtain:Total counts for size 14:[a/2-4343160,l/1-4969152,v/0-5196627]Relative percentages:[a/2-0.2993,l/1-0.3424,v/0-0.3581]Counts for random
term of size 4000:[a/2-1334,l/1-1332,v/0-1335]Relative percentages:[a/2-0.3334,l/1-0.3329,v/0-0.3336]Note that the first two counts indicate ... compare distributions corresponding to Boltz-mann samplers with those of our
generators for any concretefunction-symbol / arity pairs set.5 ONE MORE LIFT: ... LIFT: DECORATINGMOTZKIN TREES TO CLOSED LAMBDATERMSBy starting from our random
generator for Motzkin trees, or, ifone prefers a uniform distribution for ... given size, by using aBoltzmann sampler as the one automatically
generated by [2], onecan “decorate” it to lambda
terms in de Bruijn notation [5] simply bylabeling its leaves with ... free variables left overwhen called with a size N and
generating a lambda
term T.plain_gen(N,T,FreeVars):-mot_gen(N,B),decorate(B,0,T,FreeVars,[]).To ensure that a
term is closed, one restarts until the list of freevariables is ... restarts are managed by the predicate try_closed_gen/5,which, when the decorated
term is not closed, tries
generating anew term.try_closed_gen(Lim,I,J,N,T):- I<Lim,( mot_gen(N,B),decorate(B,0,T,[],[])*->J=I; I1 is I+1, try_closed_gen(Lim,I1,J,N,T)).As an interesting ... notmore than 2 or 3.Example 8. illustrates random closed lambda
terms obtained bydecorating motzkin trees.?- closed_gen(10,T,I).T = a(l(1), l(l(l(a(a(2, 1), 1))))), ... 1))))), I = 0 .?- closed_gen(5000,_,I).I = 3 .6 RELATEDWORKR my’s
algorithm [10], procedurally implemented as
algorithm Rin [6] has
generated a significant number of attempts to adapt it touniformly
generate similar data types. Among themwe mention [1]where it is also ... de Bruijn indices for the study of combinatorial properties oflambda
terms In [9] a “type-directed” mecha-nism for the
generation of random
terms is introduced, resulting inmore realistic (while not uniformly random)
terms, , used success-fully in discovering some bugs in the Glasgow ... in discovering some bugs in the Glasgow Haskell Compiler(GHC).For uniform
generation ... of arbitrary data-types specified by acontext-free grammar, the Boltzmann sampler
generator ... of [2]stands out, as it produces efficient Haskell programs generatinguniformly
terms of an expected size or above. By contrast to [4], ... above. By contrast to [4], thatuses data computed by the
generator ... in [2] to build a Boltzmannsampler for simply-typed closed lambda
terms, , this paper uses avariant of R my’s
algorithm that is also
generalized to
term algebrasof an arbitrary signature, and thus directly useful for generatingrandom ... an arbitrary signature, and thus directly useful for generatingrandom Prolog
terms for test automation of logic programs.In [12] an serialization
algorithm for Prolog
terms using a bijec-tion from a
term algebra to to natural numbers is described, thatcan, in principle, ... is described, thatcan, in principle, also be used for the
generation of random
terms, ,although at a much smaller scale, given the limitations on ... on the size ofthe integers used as encodings for the
terms and the computationaleffort involved in the decoding of integers to ... we have dropped the uniformity requirement in our gen-eralization to
term algebras, we have ensured that the generatorsare exhaustive - i.e., ... have ensured that the generatorsare exhaustive - i.e., that every
term of a given size has a chance tobe chosen. Given ... size has a chance tobe chosen. Given that the same
generator is used for all-
term andrandom
term generation, , depending only on the choice of selectionpredicates, our random ... increase the frequency ofsymbols with smaller arities in a random
term. . Thus, in a randomtesting application, one can mimic the ... program to be tested.7 CONCLUSIONSOur declarative implementations of random and all-
term generationalgorithms, show that logic programming languages, often seenoutside our field ... “domain specific”, can provide means for im-plementing simple and naturally
generic algorithms, , thought to beexclusively in the realm of procedural or ... multiple answer,without any other change in the code. Data type
genericity” ” hasspread these days from functional languages like ML and ... procedural world, ranging from mechanisms like standardtemplates in C++ and
generic types in Java, Scala or Swift. Whilealso supported indirectly by ... code deterministicexecution for random sampling and non-derministic execution formultiple answer
generation, , happens with no notational clutter orsemantic complexity in a ... clutter orsemantic complexity in a logic programming language like Prolog.Our
generator for
term ... algebras can be useful, as a practicalapplication for automating the
generation of random tests for logicprogramming languages. The decoration
algorithm lifting randomMotzkin trees into closed lambda
terms can be further specializedto simply-typed
terms as shown in [4] and can be useful for testingcorrectness ... the fact that we are able to generatevery large such
terms. . The “edge-splitting” mechanism used forR my’s
algorithm and its
generalization is likely to be also usablefor
generation of random graphs, and in particular for generatingcyclic
terms relevant when testing compilers, run-time systems andlibraries of Prolog implementations.ACKNOWLEDGEMENTThis ... Holonomic Specification. In 2013Proceedings of the Tenth Workshop on Analytic
Algorithmics and Combinatorics(ANALCO), Markus E. Nebel and Wojciech Szpankowski (Eds.). SIAM, ... Pierre Lescanne, and Marek Zaionc. 2016.A Natural Counting of Lambda
Terms. . In SOFSEM 2016: Theory and Practice ofComputer Science - ...
... and Paul Tarau. 2017. Boltzmann Sam-plers for Closed Simply-Typed Lambda
Terms. . In Practical Aspects of Declara-tive Languages - 19th International ... Knuth. 2006. The Art of Computer Programming, Volume 4, Fascicle4:
Generating All Trees–History of Combinatorial
Generation (Art of ComputerProgramming). Addison-Wesley Professional.[7] Pierre Lescanne. 2013. On counting ... ComputerProgramming). Addison-Wesley Professional.[7] Pierre Lescanne. 2013. On counting untyped lambda
terms. . Theoretical ComputerScience 474 (2013), 80 – 97. https://doi.org/10.1016/j.tcs.2012.11.019[8] Pierre ... – 97. https://doi.org/10.1016/j.tcs.2012.11.019[8] Pierre Lescanne. 2014. Boltzmann samplers for random
generation of lambdaterms. CoRR abs/1404.3875 (2014). http://arxiv.org/abs/1404.3875[9] Michal H. Palka, Koen ... Alejandro Russo, and John Hughes. 2011. Testingan Optimising Compiler by
Generating Random Lambda
Terms. . In Proceedingsof the 6th International Workshop on Automation of ... proc d it ratif de d nombrement d’arbres binaires etson application leur
g n ration al atoire. RAIRO - Theoretical Informatics andApplications - Informatique Th orique et ... electronically at https://oeis.org/.[12] Paul Tarau. 2013. Compact Serialization of Prolog
Terms (with Catalan Skele-tons, Cantor Tupling and G del Numberings) . Theory ...
Abstract:
<p>From a declarative variant of Rémy's
algorithm for uniform random
generation of binary trees, we derive a
generalization to
term algebras of an arbitrary signature. With trees seen as sets ... connecting vertices labeled with logic variables, we use Prolog's multiple-answer
generation mechanism to derive a
generic algorithm that counts
terms of a given size,
generates them all, or samples a random
term given the signature of a
term algebra.</p> <p>As applications, we implement
generators for
term algebras defining Motzkin trees, use all-
term and random-
term generation for mutual cross-testing and describe an extension mechanism that transforms ... random sampler for Motzkin trees into one for closed lambda
terms.
References:
Pierre Lescanne. 2014. Boltzmann samplers for random
generation of lambda
terms.
CoRR abs/1404.3875 (2014). http://arxiv.org/abs/1404.3875
Michal H. Palka, Koen Claessen, Alejandro Russo, and John Hughes. 2011. Testing an Optimising Compiler by
Generating Random Lambda
Terms. In
Proceedings of the 6th International Workshop on Automation of Software Test (AST'11). ACM, New York, NY, USA, 91--97.
A. Bacher, O. Bodini, and A. Jacquot. 2013. Exact-size Sampling for Motzkin Trees in Linear Time via Boltzmann Samplers and Holonomic Specification. In
2013 Proceedings of the Tenth Workshop on Analytic Algorithmics and Combinatorics (ANALCO), Markus E. Nebel and Wojciech Szpankowski (Eds.). SIAM, 52--61.
Maciej Bendkowski, Katarzyna Grygiel, Pierre Lescanne, and Marek Zaionc. 2016. A Natural Counting of Lambda
Terms. In
SOFSEM 2016: Theory and Practice of Computer Science - 42nd International Conference on Current Trends in Theory and Practice of Computer Science, Harrachov, Czech Republic, January 23-28, 2016, Proceedings (Lecture Notes in Computer Science), Rusins Martins Freivalds, Gregor Engels, and Barbara Catania (Eds.), Vol. 9587. Springer, 183--194.
Maciej Bendkowski, Katarzyna Grygiel, and Paul Tarau. 2017. Boltzmann Samplers for Closed Simply-Typed Lambda
Terms. In
Practical Aspects of Declarative Languages - 19th International Symposium, PADL 2017, Paris, France, January 16-17, 2017, Proceedings (Lecture Notes in Computer Science), Yuliya Lierler and Walid Taha (Eds.), Vol. 10137. Springer, 120--135. Best student paper award.
Donald E. Knuth. 2006.
The Art of Computer Programming, Volume 4, Fascicle 4: Generating All Trees-History of Combinatorial Generation (Art of Computer Programming). Addison-Wesley Professional.
Pierre Lescanne. 2013. On counting untyped lambda
terms.
Theoretical Computer Science 474 (2013), 80 -- 97.
Jean-Luc Rémy. 1985. Un procédé itératif de dénombrement d'arbres binaires et son application à leur
génération aléatoire.
RAIRO - Theoretical Informatics and Applications - Informatique Théorique et Applications 19, 2 (1985), 179--195.
Paul Tarau. 2013. Compact Serialization of Prolog
Terms (with Catalan Skeletons, Cantor Tupling and Gödel Numberings).
Theory and Practice of Logic Programming 13, 4-5 (2013), 847--861.
Primary CCS:
Generating random combinatorial structures
General programming languages
CCS:
Generating random combinatorial structures
General programming languages
Keywords:
generation of random lambda
terms random
term generation combinatorial
generation declarative
algorithms term algebras
Title:
Declarative
algorithms for
generation, counting and random sampling of
term algebras