paperbot · PL 论文追踪

全部论文 待读 收藏

P2 From high to low: Simulating nondeterminism and state with state

从高层到低层:用状态模拟非确定性与状态
JFP vol.342024匹配度 2/10 · 该论文研究代数效应、处理句柄与Prolog局部状态/非确定性的形式语义及正确性证明,属于纯PL理论,与用户聚焦的PL与AI/LLM交叉(静态分析、Agentic程序、浮点程序分析、贝叶斯程序分析)几乎没有直接关联。仅在形式语义与程序验证的理论背景上略有边缘联系。引用 0 inbox
WENHAO TANG, TOM SCHRIJVERS
crossref: 2026-09-10

AI 速览

一句话:用代数效应与处理句柄将 Prolog 式局部状态逐步翻译为低层状态效应,并用程序计算证明各步正确。

高层效应抽象简洁,低层效应便于控制执行与资源,将前者翻译为后者并保持语义是关键。本文以代数效应与处理句柄为框架,研究用低层状态效应模拟高层效应,聚焦 Prolog 中状态与非确定性交互形成的局部状态。作者逐步翻译:先将高层局部状态映射为低层全局状态,回溯时显式恢复更新;再消除非确定性,改用含选择点栈的状态;随后采用增量、可逆更新避免复制状态,并用另一状态效应把更新存入 trail 栈。所有步骤均用程序计算证明正确,处理句柄融合律起核心作用。这表明 Prolog/WAM 风格状态管理可由低层状态效应逐步模拟。

问题
如何把高层效应(如 Prolog 中状态与非确定性交互形成的局部状态)翻译为低层状态效应,同时保持语义并支持低层优化。
方法
基于代数效应与处理句柄,逐步将局部状态翻译为全局状态、选择点栈状态,再到增量可逆更新与 trail 栈,并用程序计算和融合律证明正确性。
评估
通过程序计算逐步骤证明翻译相对于源语义的正确性,以 Prolog 局部状态/WAM 风格状态管理为案例。
原文摘要(Abstract)

Abstract Some effects are considered to be higher level than others. High-level effects provide expressive and succinct abstraction of programming concepts, while low-level effects allow more fine-grained control over program execution and resources. Yet, often it is desirable to write programs using the convenient abstraction offered by high-level effects, and meanwhile still benefit from the optimizations enabled by low-level effects. One solution is to translate high-level effects to low-level ones. This paper studies how algebraic effects and handlers allow us to simulate high-level effects in terms of low-level effects. In particular, we focus on the interaction between state and nondeterminism known as the local state, as provided by Prolog. We map this high-level semantics in successive steps onto a low-level composite state effect, similar to that managed by Prolog’s Warren Abstract Machine. We first give a translation from the high-level local-state semantics to the low-level global-state semantics, by explicitly restoring state updates on backtracking. Next, we eliminate nondeterminism altogether in favour of a lower-level state containing a choicepoint stack. Then we avoid copying the state by restricting ourselves to incremental, reversible state updates. We show how these updates can be stored on a trail stack with another state effect. We prove the correctness of all our steps using program calculation where the fusion laws of effect handlers play a central role.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot2687,
  title = {From high to low: Simulating nondeterminism and state with state},
  author = {WENHAO TANG and TOM SCHRIJVERS},
  journal = {Journal of Functional Programming},
  volume = {34},
  year = {2024},
  doi = {10.1017/s0956796824000133}
}