[英]What is a mapping between natural numbers and valid simply typed lambda calculus terms?
Is there any efficient algorithm that maps between well-typed, closed terms of the simply typed lambda calculus and natural numbers? 是否有任何有效的算法可以在简单类型的lambda演算和自然数的良好类型,闭合项之间进行映射? For example, using bruijn indexes (and probably on incorrect order): 例如,使用bruijn索引(可能是错误的顺序):
0 → (λ 0)
1 → (λ (λ (0 1)))
2 → (λ (λ (1 0)))
3 → (λ 0 (λ 0))
4 → (λ (λ 0) 0)
5 → (λ (λ 1) 0)
6 → ... so on
Related questions: is there an algorithm that maps between natural numbers and normalized terms of the simply typed lambda calculus? 相关问题:是否存在一种算法,可以在简单类型的lambda演算的自然数和标准化项之间进行映射? Also, the same questions applied to the untyped lambda calculus. 此外,相同的问题适用于无类型的lambda演算。
The Binary Lambda Calculus defines a binary encoding for any closed term in the untyped lambda calculus, and also suggests a bijection between natural numbers and binary strings, but the former is not surjective. 二元Lambda微积分定义了无类型lambda演算中任何闭合项的二进制编码,并且还建议自然数和二进制字符串之间的双射,但前者不是满射的。 Still, the paper http://arxiv.org/abs/1401.0379 "Counting Terms in the Binary Lambda Calculus" might yield efficient ranking/unranking mappings. 尽管如此,论文http://arxiv.org/abs/1401.0379 “计算Binary Lambda微积分中的术语”可能会产生有效的排名/排名映射。
Due to the highly context-sensitive nature of typed lambda calculus I would be surprised if there were an efficient algorithm, or rather a "natural" efficient algorithm. 由于类型化的lambda演算具有高度上下文敏感性,如果有一种有效的算法,或者更确切地说是“自然的”有效算法,我会感到惊讶。
This paper has nice formulae for counting untyped lambda terms and from that they derive a fairly simple function for enumerating untyped terms. 本文有很好的公式来计算无类型的 lambda术语,并从中得出一个相当简单的函数来枚举无类型的术语。 They also provide a counting function for normal forms which should be easy to adapt to a generating function too. 它们还为普通形式提供计数功能,这也很容易适应生成功能。 Unfortunately, they only make a typed generator function by filtering that which is absurdly expensive (one of the results of the paper is just how absurd it is). 不幸的是,他们只通过过滤那些非常昂贵的类型来生成类型生成器功能(该论文的结果之一就是多么荒谬)。
As for a more efficient way to generate typed terms, my advice would be to generate typing derivations instead of terms and then type checking them. 至于生成类型化术语的更有效方法,我的建议是生成类型派生而不是术语,然后键入检查它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.