论文标题

密封基于指针的优化在纯度功能背后

Sealing Pointer-Based Optimizations Behind Pure Functions

论文作者

Selsam, Daniel, Hudon, Simon, de Moura, Leonardo

论文摘要

功能编程语言特别适合构建自动推理系统,因为(除其他原因)逻辑术语是通过电感类型很好地建模的,可以将术语逐渐作为高阶组合器实现,并且通过持续数据构建结构大大简化了回溯。但是,现有的纯功能编程语言在这些域中都遭受了主要限制:穿越术语需要与该术语的树大小成比例的时间,而不是其图形大小。当建立诸如精益和coq之类的交互式定理的自动化时,这种限制尤其是毁灭性的,为此,术语树大小的指数爆炸被证明是常见的,也很难预防。恢复最佳缩放所需的一切都是能够在术语的内存地址上执行简单操作,但允许自由使用这些操作显然会违反参考透明的基本前提。我们展示了如何使用依赖类型来密封必要的指针 - 地址操纵,同时仅需要一定数量的额外信任。我们已经针对Lean即将到来的版本(V4)实施了我们的方法,我们的方法也可以基于依赖类型理论采用其他语言。

Functional programming languages are particularly well-suited for building automated reasoning systems, since (among other reasons) a logical term is well modeled by an inductive type, traversing a term can be implemented generically as a higher-order combinator, and backtracking is dramatically simplified by persistent datastructures. However, existing pure functional programming languages all suffer a major limitation in these domains: traversing a term requires time proportional to the tree size of the term as opposed to its graph size. This limitation would be particularly devastating when building automation for interactive theorem provers such as Lean and Coq, for which the exponential blowup of term-tree sizes has proved to be both common and difficult to prevent. All that is needed to recover the optimal scaling is the ability to perform simple operations on the memory addresses of terms, and yet allowing these operations to be used freely would clearly violate the basic premise of referential transparency. We show how to use dependent types to seal the necessary pointer-address manipulations behind pure functional interfaces while requiring only a negligible amount of additional trust. We have implemented our approach for the upcoming version (v4) of Lean, and our approach could be adopted by other languages based on dependent type theory as well.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源