一阶公式中变量的有效重命名
编辑2:考虑到 de Bruijn 指数可能更容易使用,我重新制定了公式的大部分内部表示形式,以使用混合 de Bruijn 表示< em>ala Connor McBride 的论文。这极大地简化了一些必须处理 α 等价的语法算法,但也使其他算法变得更加复杂。无论如何,这意味着自由变量可以被标准化,而绑定变量具有由其绑定距离表示的规范名称。这并不完全令人满意,但至少是一个更好的开始。
编辑1:我意识到问题约束不足以保证变量的标准化。特别是,量词的迭代意味着绑定器中的变量必须首先标准化。因此,可能无法避免需要多次遍历每个抽象语法树的解决方案。使用 de Bruijn 指数的建议通常是一个相当好的解决方案,但它不会在不破坏符号及其实用性的情况下轻松实现标准化。
原文: 设V是由自然数索引的无限变量集,fv(φ)表示φ的自由变量,bv(φ ) 表示 φ 的约束变量,对于任何一阶公式 φ。我试图解决的问题如下。
设 φ 和 ψ 为一阶公式。找到替换 θ1 和 θ2 使得: (a) fv(θ1(φ)), fv(θ2(φ))、bv(θ1(φ)) 和 bv(θ2(ψ)) 是不相交; (b) fv(θ1(φ)), fv(θ2(φ)) 的并集)、bv(θ1(φ)) 和 bv(θ2(ψ)) 是同构的到自然数的初始段; (c) bv(θ1(φ)) 中的所有变量均小于 bv(θ2< /sub>(ψ)) 小于 fv(θ1(ψ)) 中的所有变量 小于 fv( θ2(ψ))。
困难在于公式中的绑定变量和自由变量集不一定是不相交的,并且量词可能会迭代,这意味着朴素替换会产生意外的变量捕获,等等。
一个低效的解决方案如下。给定 φ 和 ψ,首先将 φ 和 ψ 的自由变量标准化,使得标准化项中的所有自由变量都大于最大绑定变量加上 φ 和 ψ 中的绑定算子的数量,得到 φ' 和 ψ'。然后从 x0 开始重命名 φ' 的绑定变量。然后是ψ'的绑定变量。然后是 φ' 的自由变量。然后是ψ'的自由变量。
我想要的是一种更有效的方法来满足问题约束。也就是说,解决方案不需要重命名自由变量的初始标准化。有效地标准化变量并不是问题。然而,额外的限制给我带来了麻烦。
edit2: Taking the hint that de Bruijn indices might be easier to work with, I've reformulated much of the internal representation of formulae to use a mixed de Bruijn representation ala Connor McBride's paper. This greatly simplified some algorithms regarding syntax that had to deal with α-equivalence, but made others more complicated. In any case, this means that free variables can be standardized apart and bound variables have canonical names represented by their binding distance. This isn't totally satisfactory, but it's at least a better start.
edit1: I realized the problem constraints aren't sufficient to guarantee standardization of variables. In particular, iteration of quantifiers means that variables in binders must be standardized apart first. So there is probably no escaping a solution that requires multiple passes over each abstract syntax tree. The suggestion to use de Bruijn indices is a fairly good solution generally, but it won't give standardization easily without breaking the notation and its utility.
original:
Let V be an infinite set of variables indexed by the natural numbers, fv(φ) denote the free variables of φ, and bv(φ) denote the bound variables of φ, for any first-order formula φ. The problem I'm trying to solve is the following.
Let φ and ψ be first-order formulae. Find substitutions θ1 and θ2 such that: (a) fv(θ1(φ)), fv(θ2(φ)), bv(θ1(φ)), and bv(θ2(ψ)) are disjoint; (b) the union of fv(θ1(φ)), fv(θ2(φ)), bv(θ1(φ)), and bv(θ2(ψ)) is isomorphic to an initial segment of the natural numbers; and (c) all variables in bv(θ1(φ)) are less than all variables in bv(θ2(ψ)) are less than all variables in fv(θ1(ψ)) are less than all variables in fv(θ2(ψ)).
The difficulty is that the set of bound and free variables in a formula isn't necessarily disjoint, and quantifiers may be iterated, meaning that naive substitution produces accidental variable capture, and so forth.
An inefficient solution is the following. Given φ and ψ, first standardize apart the free variables of φ and ψ such that all free variables in the standardized terms are greater than the largest bound variable plus the number of binding operators in φ and ψ, giving φ' and ψ'. Then rename the bound variables of φ' starting from x0. Then the bound variables of ψ'. Then the free variables of φ'. Then the free variables of ψ'.
What I would like is a more efficient method of satisfying the problem constraints. That is, a solution that doesn't require the initial standardization that renames free variables. Standardizing variables apart efficiently isn't a problem. However, the additional constraint is giving me trouble.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一定要使用 De Bruijn idices。另外,请注意它们都是积极的。然后您可以在统一过程中使用负数。如果您想使用新索引,请使用全局索引。
Use De Bruijn idices for sure. Also, notice that they all positive. Then you can use the negative numbers during the unification process. If you want to use fresh indices, use a global one.