Dafny as Verification-Aware Intermediate Language for Code Generation
Not on the map. Why?
Abstract (arXiv)
Using large language models (LLMs) to generate source code from natural language prompts is a popular and promising idea with a wide range of applications. One of its limitations is that the generated code can be faulty at times, often in a subtle way, despite being presented to the user as correct. In this paper, we explore ways in which formal methods can assist with increasing the quality of code generated by an LLM. Instead of emitting code in a target language directly, we propose that the user guides the LLM to first generate an opaque intermediate representation, in the verification-aware language Dafny, that can be automatically validated for correctness against agreed on specifications. The correct Dafny program is then compiled to the target language and returned to the user. All user-system interactions throughout the procedure occur via natural language; Dafny code is never exposed. We describe our current prototype and report on its performance on the HumanEval Python code generation benchmarks.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Builds on 4 of its 8 references that are in the map. First posted on arXiv 10 Jan 2025.
Builds on
4 of 8 references.
References · 4
- 2024A Survey on Large Language Models for Code Generationcited by 646
- 2023Clover: Closed-Loop Verifiable Code Generationcited by 62
- 2024Towards AI-Assisted Synthesis of Verified Dafny Methodscited by 58
- 2024DafnyBench: A Benchmark for Formal Software Verificationcited by 54
Built on by
Citing papers per year: 2025: 3; 2026: 3.
6 papers.
- 2025ProofWright: Towards Agentic Formal Verification of CUDAcited by 8
- 2025Local Success Does Not Compose: Benchmarking Large Language Models for Compositional Formal Verificationcited by 6
- 2025Proof2Silicon: Prompt Repair for Verified Code and Hardware Generation via Reinforcement Learningcited by 1
- 2026Containment Verification: AI Safety Guarantees Independent of Alignmentcited by 1
- 2026Why3-py: A Tool for Formal Verification of Hypothesis Testing and Meta-Analysis in Pythoncited by 0
- 2026SkillForge: Compositional Skill Synthesis with Verification-in-the-Loop for Generating Formally Verified Dafny Programscited by 0
- 2026SkillForge: Compositional Skill Synthesis with Verification-in-the-Loop for Generating Formally Verified Dafny Programs30 Aug 2026
- 2026Why3-py: A Tool for Formal Verification of Hypothesis Testing and Meta-Analysis in Python4 Jul 2026
- 2026Containment Verification: AI Safety Guarantees Independent of Alignment9 May 2026
- 2025ProofWright: Towards Agentic Formal Verification of CUDA15 Nov 2025
- 2025Local Success Does Not Compose: Benchmarking Large Language Models for Compositional Formal Verification27 Sep 2025
- 2025Proof2Silicon: Prompt Repair for Verified Code and Hardware Generation via Reinforcement Learning7 Sep 2025