Abstract:A uniform representation, as binary trees with empty leaves, is given to expressions built with Rosser's X-combinator, natural numbers, lambda terms and simple types. Type inference, normalization of combinator expressions and lambda terms in de Bruijn notation, ranking/unranking algorithms and tree-based natural numbers are described as a literate Prolog program.With sound unification and compact expression of combinatorial generation algorithms, logic programming is shown to conveniently host a declarative p… Show more
“…However, the concepts of closable and typable skeletons of lambda terms and their uniquely closable and typable variants are new and have not been studied previously. The second author has used extensively Prolog as a metalanguage for the study of combinatorial and computational properties of lambda terms in papers like [16,11] covering different families of terms and properties, but not in combination with the precise analytic methods as developed in this paper.…”
Section: Related Workmentioning
confidence: 99%
“…We will follow the interleaving of term generation, checking for closedness and type inference steps shown in [11], but split it into a two stage program, with the first stage generating code to be executed, via Prolog's metacall by the second, while also ensuring that the terms generated by the second stage are closed.…”
Section: Typable and Untypable Closable Skeletonsmentioning
confidence: 99%
“…Note that this is a specialization of a general type inferencer to the case when exactly one type variable is available for each leaf node. in papers like [16,11] covering different families of terms and properties, but not in combination with the precise analytic methods as developed in this paper. It has been a long tradition in logic programming to use step-by-step program transformations to derive semantically simpler as well as more efficient code, going back as far as [17], that we have informally followed.…”
Section: Uniquely Typable Skeletons and Their Relation To Uniquely Cl...mentioning
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 3n + 1 are in a bijection with binary trees of size n.
“…However, the concepts of closable and typable skeletons of lambda terms and their uniquely closable and typable variants are new and have not been studied previously. The second author has used extensively Prolog as a metalanguage for the study of combinatorial and computational properties of lambda terms in papers like [16,11] covering different families of terms and properties, but not in combination with the precise analytic methods as developed in this paper.…”
Section: Related Workmentioning
confidence: 99%
“…We will follow the interleaving of term generation, checking for closedness and type inference steps shown in [11], but split it into a two stage program, with the first stage generating code to be executed, via Prolog's metacall by the second, while also ensuring that the terms generated by the second stage are closed.…”
Section: Typable and Untypable Closable Skeletonsmentioning
confidence: 99%
“…Note that this is a specialization of a general type inferencer to the case when exactly one type variable is available for each leaf node. in papers like [16,11] covering different families of terms and properties, but not in combination with the precise analytic methods as developed in this paper. It has been a long tradition in logic programming to use step-by-step program transformations to derive semantically simpler as well as more efficient code, going back as far as [17], that we have informally followed.…”
Section: Uniquely Typable Skeletons and Their Relation To Uniquely Cl...mentioning
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 3n + 1 are in a bijection with binary trees of size n.
“…As a fortunate synergy, Prolog's sound unification of logic variables, backtracking and definite clause grammars have been shown to provide compact combinatorial generation algorithms for various families of lambda terms [11,12,13,14].…”
Contrary to several other families of lambda terms, no closed formula or generating function is known and none of the sophisticated techniques devised in analytic combinatorics can currently help with counting or generating the set of simply-typed closed lambda terms of a given size. Moreover, their asymptotic scarcity among the set of closed lambda terms makes counting them via brute force generation and type inference quickly intractable, with previous published work showing counts for them only up to size 10. By taking advantage of the synergy between logic variables, unification with occurs check and efficient backtracking in today's Prolog systems, we climb 4 orders of magnitude above previously known counts by deriving progressively faster Horn Clause programs that generate and/or count the set of closed simply-typed lambda terms of sizes up to 14. A similar count for closed simply-typed normal forms is also derived up to size 14.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.