paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Metamorph: Synthesizing Large Objects from Dafny Specifications

Metamorph:从 Dafny 规约合成大型对象
OOPSLA 9(OOPSLA1)2025匹配度 3/10 · 论文属于 Dafny 规格驱动的程序合成/测试输入生成,使用验证器反例、距离度量和 A* 搜索;与用户关注的 LLM/Agent 改进静态分析/形式化验证、静态分析用于 ML/Agentic 程序、浮点或贝叶斯程序分析均无直接交集,仅在形式化验证与工程落地层面边缘相关。引用 0 inbox
Aleksandr Fedchin, Alexander Y. Bai, Jeffrey S. Foster
crossref: 2026-09-10

AI 速览

一句话:提出 Metamorph,利用 Dafny 验证器反例与分段距离度量,将大型对象的长方法调用序列合成化为加权 A* 搜索。

程序合成旨在生成满足规约的代码。本文从形式化 API 规约合成方法调用序列来构造满足性质的对象,用于自动测试生成。连续调用求解代价高,现有方法常限制调用次数。作者提出 Metamorph:用 Dafny 验证器反例逐次分析方法调用效果,降低 SMT 查询复杂度;并用距离度量比较反例指导搜索。其分段距离将对象状态视为原子约束合取,经整数规划组合各调用可满足的约束,给出调用数的可证下界,并把合成化为加权 A* 搜索。在链表、队列、数组、二叉树和图六个基准上,每实例最多合成 57 次调用,优于基线;与 DTest 集成后能覆盖 AWS 加密材料提供者库中 DTest 漏掉的部分,并为简单虚拟机生成可执行字节码。

问题
如何从形式化 API 规约自动合成满足性质的对象,尤其是需要长方法调用序列的复杂数据结构,以支持自动测试生成。
方法
Metamorph 使用 Dafny 验证器返回的反例逐次推理方法调用效果,并以两种距离度量(含基于原子约束与整数规划的分段距离)将合成问题建模为加权 A* 搜索。
评估
在六个数据结构基准上验证,可合成每实例最多 57 次方法调用的程序并优于基线;与 DTest 集成覆盖 AWS 加密材料提供者库中 DTest 未覆盖的部分,并为简单虚拟机生成可执行字节码。
原文摘要(Abstract)

Program synthesis aims to produce code that adheres to user-provided specifications. In this work, we focus on synthesizing sequences of calls to formally specified APIs to generate objects that satisfy certain properties. This problem is particularly relevant in automated test generation, where a test engine may need an object with specific properties to trigger a given execution path. Constructing instances of complex data structures may require dozens of method calls, but reasoning about consecutive calls is computationally expensive, and existing work typically limits the number of calls in the solution. In this paper, we focus on synthesizing such long sequences of method calls in the Dafny programming language. To that end, we introduce Metamorph, a synthesis tool that uses counterexamples returned by the Dafny verifier to reason about the effects of method calls one at a time, limiting the complexity of solver queries. We also aim to limit the overall number of SMT queries by comparing the counterexamples using two distance metrics we develop for guiding the synthesis process. In particular, we introduce a novel piecewise distance metric, which puts a provably correct lower bound on the number of method calls in the solution and allows us to frame the synthesis problem as weighted A* search. When computing piecewise distance, we view object states as conjunctions of atomic constraints, identify constraints that each method call can satisfy, and combine this information using integer programming. We evaluate Metamorph’s ability to generate large objects on six benchmarks defining key data structures: linked lists, queues, arrays, binary trees, and graphs. Metamorph can successfully construct programs that require up to 57 method calls per instance and compares favorably to an alternative baseline approach. Additionally, we integrate Metamorph with DTest, Dafny’s automated test generation toolkit, and show that Metamorph can synthesize test inputs for parts of the AWS Cryptographic Material Providers Library that DTest alone is not able to cover. Finally, we use Metamorph to generate executable bytecode for a simple virtual machine, demonstrating that the techniques described here are more broadly applicable in the context of specification-guided synthesis.

链接与引用

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

BibTeX
@article{paperbot3218,
  title = {Metamorph: Synthesizing Large Objects from Dafny Specifications},
  author = {Aleksandr Fedchin and Alexander Y. Bai and Jeffrey S. Foster},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {9},
  number = {OOPSLA1},
  year = {2025},
  doi = {10.1145/3720448}
}