arXiv:2608.29841cs.CLcs.PL2026-08中稿 · EMNLP

用可复用技能库生成经形式化验证的Dafny代码,自动修复错误并确保正确性。

SkillForge: Compositional Skill Synthesis with Verification-in-the-Loop for Generating Formally Verified Dafny Programs

  • 将代码合成拆解为原子技能,如规范推断、代码生成、错误诊断等。
  • 在基准测试中优于主流方法,首次尝试即通过率高,耗时更少。
  • 适合需要高可靠性代码的开发者或自动化验证系统使用。

从自然语言生成形式化验证的程序仍具挑战:现有方法要么单次生成失败后无补救,要么依赖非确定性、不透明的代理推理。我们提出SKILLFORGE框架,将形式化代码合成分解为一组原子化、可复用的技能,每项技能针对特定子任务(如规范推断、主体生成、不变量生成、错误诊断或定向修复),由提示模板、工具绑定和可判定的成功标准定义。一个验证驱动的调度器协调这些技能:向Dafny验证器提交候选代码,将失败归类为结构化类别,确定性地路由至相应修复技能,并迭代直至形式正确或达到预算。在精心构建的自然语言到Dafny规范对基准上,SKILLFORGE显著优于当前最优的代理方法(包括ReAct式代理、基于MCTS的修复和强化学习引导的验证)及传统迭代基线,同时所需令牌数更少、延迟更低。消融实验表明每项技能均有可观贡献,且调度器多数情况下首次尝试即完成验证。

原文摘要 · Abstract (English)

Generating formally verified programs from natural language remains challenging: existing approaches either produce code in a single pass without recourse when verification fails, or rely on open-ended agentic reasoning that is non-deterministic and opaque. We introduce SKILLFORGE, a framework that decomposes formal code synthesis into a library of atomic, reusable skills, each targeting a specific subtask such as specification inference, body synthesis, invariant generation, error diagnosis, or targeted repair, and defined by a prompt template, tool binding, and decidable success criterion. A verification-driven harness orchestrates these skills: it submits candidates to the Dafny verifier, diagnoses failures into structured categories, deterministically routes to the appropriate repair skill, and iterates until formal correctness is proved or a budget is exhausted. On a curated benchmark of natural language to Dafny specification pairs, SKILLFORGE substantially outperforms both state-of-the-art agentic approaches (including ReAct-style agents, MCTS-based repair, and RL-guided verification) and traditional iterative baselines, while requiring fewer tokens and lower latency. Ablation studies confirm that every skill contributes measurably, and the harness converges rapidly with the majority of programs verified on the first attempt.

形式化验证代码生成智能修复Dafny

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。