paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Narcissus: correct-by-construction derivation of decoders and encoders from binary formats

Narcissus:从二进制格式构造即正确地推导解码器与编码器
ICFP 3(ICFP)2019匹配度 3/10 · 论文属于形式化方法与程序推导/DSL方向,使用Coq保证编解码器互逆,并有MirageOS工程落地,这与用户对“理论形式化+工程实现”的偏好部分吻合;但它不涉及LLM/Agent、静态分析用于ML/Agentic程序、浮点程序分析或贝叶斯程序分析,因此与核心研究方向匹配度较低。引用 27 inbox
Benjamin Delaware, Sorawit Suriyakarn, Clément Pit-Claudel, Qianchuan Ye, Adam Chlipala
crossref: 2026-09-10

AI 速览

一句话:用 Coq 策略从无冗余二进制格式规范自动推导互为逆的解码器与编码器,并重实现网络协议栈。

本文关注从二进制格式规范同时生成解码器与编码器的问题。尽管函数式 parser combinator 能快速构造解码器,但面对真实网络协议包格式时,既有方法通常难以处理,或需要在语法中手工添加冗余提示。作者提出 Narcissus,允许使用自然且无冗余的格式规范,并借助 Coq 证明助手与 tactic 自动推导解码器和编码器,且保证二者互为逆。该方法覆盖常见网络包格式,并已用于重新实现完整 Internet 协议栈的数据包处理,替换进基于 OCaml 的 MirageOS unikernel 中,性能下降很小。

问题
真实二进制/网络包格式复杂,传统 parser combinator 难以直接支持,或需在解析器程序中分散加入冗余手工提示。
方法
以自然无冗余的二进制格式规范为输入,用 Coq tactic 自动派生互为逆的解码器和编码器,并保证构造正确。
评估
覆盖主流网络包格式,重实现完整 Internet 协议栈并集成到 MirageOS unikernel,性能退化极小。
原文摘要(Abstract)

It is a neat result from functional programming that libraries of parser combinators can support rapid construction of decoders for quite a range of formats. With a little more work, the same combinator program can denote both a decoder and an encoder. Unfortunately, the real world is full of gnarly formats, as with the packet formats that make up the standard Internet protocol stack. Most past parser-combinator approaches cannot handle these formats, and the few exceptions require redundancy – one part of the natural grammar needs to be hand-translated into hints in multiple parts of a parser program. We show how to recover very natural and nonredundant format specifications, covering all popular network packet formats and generating both decoders and encoders automatically. The catch is that we use the Coq proof assistant to derive both kinds of artifacts using tactics, automatically, in a way that guarantees that they form inverses of each other. We used our approach to reimplement packet processing for a full Internet protocol stack, inserting our replacement into the OCaml-based MirageOS unikernel, resulting in minimal performance degradation.

链接与引用

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

BibTeX
@article{paperbot580,
  title = {Narcissus: correct-by-construction derivation of decoders and encoders from binary formats},
  author = {Benjamin Delaware and Sorawit Suriyakarn and Clément Pit-Claudel and Qianchuan Ye and Adam Chlipala},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {3},
  number = {ICFP},
  year = {2019},
  doi = {10.1145/3341686}
}