arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2512.05262cs.PLcs.LO
收藏

验证的VCG和Dafny验证编译器

Verified VCG and Verified Compiler for Dafny

ETH Zurich Switzerland;Chalmers University of Technology\ of Gothenburg Sweden;Institute for Infocomm Research (I 2 R), A STAR Singapore;Nanyang Technological University Singapore;ETH Zurich;Chalmers University of Technology\ of Gothenburg;Institute for Infocomm Research (I 2 R), A STAR;Nanyang Technological University

Daniel Nezamabadi, Magnus O. Myreen, Yong Kiam Tan

AI总结:

本文提出通过形式化方法验证Dafny语言的VCG和编译器,确保程序的正确性并生成可执行代码。

摘要:

Dafny是一种具有验证意识的编程语言,附带了编译器和静态程序验证器。然而,编译器和验证器本身并未被证明是正确的;事实上,这两个工具中都发现了声音性错误。本文表明,上述Dafny工具可以借助基础的正确性保证来开发。我们为Dafny的一个命令式子集提出了一个函数式大步语义,并基于此语义,提出了一个经过验证的验证条件生成器(VCG)和Dafny的验证编译器。我们形式化了的Dafny子集包括相互递归的方法调用、while循环和数组——这些语言特性足够显著,足以涵盖诸如麦卡锡的91函数和用于教学Dafny的数组程序等具有挑战性的示例。经过验证的VCG允许对注释的Dafny程序进行功能正确性的证明,而经过验证的编译器可以将已验证的Dafny程序编译为CakeML程序。从那里,可以通过(已验证的)CakeML编译器获得可执行的机器代码,同时在证明源级Dafny程序的函数正确性保证的同时保持正确性。我们的工作已在HOL4定理证明器中进行了机械化。

英文摘要:

Dafny is a verification-aware programming language that comes with a compiler and static program verifier. However, neither the compiler nor the verifier is proved correct; in fact, soundness bugs have been found in both tools. This paper shows that the aforementioned Dafny tools can be developed with foundational correctness guarantees. We present a functional big-step semantics for an imperative subset of Dafny and, based on this semantics, a verified verification condition generator (VCG) and a verified compiler for Dafny. The subset of Dafny we have formalized includes mutually recursive method calls, while loops, and arrays -- these language features are significant enough to cover challenging examples such as McCarthy's 91 function and array-based programs that are used when teaching Dafny. The verified VCG allows one to prove functional correctness of annotated Dafny programs, while the verified compiler can be used to compile verified Dafny programs to CakeML programs. From there, one can obtain executable machine code via the (already verified) CakeML compiler, all while provably maintaining the functional correctness guarantees that were proved for the source-level Dafny programs. Our work has been mechanized in the HOL4 theorem prover.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑