paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Certifying derivation of state machines from coroutines

从协程到状态机的可认证推导
POPL 6(POPL)2022匹配度 2/10 · 论文属于形式化验证与编译正确性方向,用 Coq 策略将高阶协程编译为显式状态机,但未涉及静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析,与画像的核心交叉方向不匹配。引用 2 inbox
Mirai Ikebuchi, Andres Erbsen, Adam Chlipala
crossref: 2026-09-10

AI 速览

一句话:提出在 Coq 中以策略形式实现的编译器,将高阶协程自动可验证地编译为显式状态机。

安全关键网络协议常包含嵌套状态机,手工低层实现易隐藏缺陷,而依赖线程等高层抽象又可能牺牲性能与平台 ABI 兼容性。本文提出一种基于编译器的技术:用 freer monad 将嵌套协程写成自然的高层协议代码,再自动编译为带显式状态的低层代码。编译器实现在 Coq 证明助手中,作为策略将编译过程组织为寻找源程序与目标程序等价证明的搜索;因此可安全地通过新提示扩展,例如支持协程查找的数据结构。案例研究实现足以支持主流浏览器的 TLS 核心,提取出的 Haskell 代码达到合理性能。

问题
如何在资源受限平台上以高层嵌套协程编写安全关键协议,同时获得显式状态机实现的性能与兼容性,并保证编译正确。
方法
用 freer monad 表示嵌套协程,在 Coq 中以策略实现编译器,将编译转化为源程序与目标程序等价证明的搜索,并支持提示扩展。
评估
实现 TLS 核心案例研究,提取为 Haskell 代码并与主流浏览器兼容,实验显示其性能合理。
原文摘要(Abstract)

One of the biggest implementation challenges in security-critical network protocols is nested state machines. In practice today, state machines are either implemented manually at a low level, risking bugs easily missed in audits; or are written using higher-level abstractions like threads, depending on runtime systems that may sacrifice performance or compatibility with the ABIs of important platforms (e.g., resource-constrained IoT systems). We present a compiler-based technique allowing the best of both worlds, coding protocols in a natural high-level form, using freer monads to represent nested coroutines , which are then compiled automatically to lower-level code with explicit state. In fact, our compiler is implemented as a tactic in the Coq proof assistant, structuring compilation as search for an equivalence proof for source and target programs. As such, it is straightforwardly (and soundly) extensible with new hints, for instance regarding new data structures that may be used for efficient lookup of coroutines. As a case study, we implemented a core of TLS sufficient for use with popular Web browsers, and our experiments show that the extracted Haskell code achieves reasonable performance.

链接与引用

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

BibTeX
@article{paperbot1559,
  title = {Certifying derivation of state machines from coroutines},
  author = {Mirai Ikebuchi and Andres Erbsen and Adam Chlipala},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {POPL},
  year = {2022},
  doi = {10.1145/3498685}
}