arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2003.01685cs.PL
收藏

纯函数背后的密封指针优化

Sealing Pointer-Based Optimizations Behind Pure Functions

Daniel Selsam, Simon Hudon, Leonardo de Moura

摘要:

函数式程序设计语言特别适合于构建自动推理系统,因为(除其他原因外)逻辑项可以很好地由归纳类型建模,遍历项可以一般地实现为高阶组合子,并且回溯可以通过持久数据结构显着简化。然而,现有的纯函数式程序设计语言在这些领域都有一个主要的限制:遍历一个术语需要的时间与该术语的树大小成比例,而不是其图的大小。当为交互式定理证明器(如Lean和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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑