Towards AI-Assisted Synthesis of Verified Dafny Methods
Not on the map. Why?
Abstract (arXiv)
Large language models show great promise in many domains, including programming. A promise is easy to make but hard to keep, and language models often fail to keep their promises, generating erroneous code. A promising avenue to keep models honest is to incorporate formal verification: generating programs' specifications as well as code so that the code can be proved correct with respect to the specifications. Unfortunately, existing large language models show a severe lack of proficiency in verified programming. In this paper, we demonstrate how to improve two pretrained models' proficiency in the Dafny verification-aware language. Using 178 problems from the MBPP dataset, we prompt two contemporary models (GPT-4 and PaLM-2) to synthesize Dafny methods. We use three different types of prompts: a direct Contextless prompt; a Signature prompt that includes a method signature and test cases, and a Chain of Thought (CoT) prompt that decomposes the problem into steps and includes retrieval augmentation generated example problems and solutions. Our results show that GPT-4 performs better than PaLM-2 on these tasks and that both models perform best with the retrieval augmentation generated CoT prompt. GPT-4 was able to generate verified, human-evaluated, Dafny methods for 58% of the problems, however, GPT-4 managed only 19% of the problems with the Contextless prompt, and even fewer (10%) for the Signature prompt. We are thus able to contribute 153 verified Dafny solutions to MBPP problems, 50 that we wrote manually, and 103 synthesized by GPT-4. Our results demonstrate that the benefits of formal program verification are now within reach of code generating large language models...
Key facts. Cited by 58 papers in the map (data through 7 Oct 2026). First posted on arXiv 1 Feb 2024.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2024: 11; 2025: 26; 2026: 21.
58 papers.
Sort:
By area:
- 2024Formal Mathematical Reasoning: A New Frontier in AIcited by 80
- 2024DafnyBench: A Benchmark for Formal Software Verificationcited by 54
- 2024AutoVerus: Automated Proof Generation for Rust Codecited by 46
- 2024AlphaVerus: Bootstrapping Formally Verified Code Generation through Self-Improving Translation and Treefinementcited by 33
- 2024Automated Proof Generation for Rust Code via Self-Evolutioncited by 31
- 2025VERINA: Benchmarking Verifiable Code Generationcited by 30
- 2024Towards Neural Synthesis for SMT-Assisted Proof-Oriented Programmingcited by 19
- 2025Proving the Coding Interview: A Benchmark for Formally Verified Code Generationcited by 18
- 2025RL Is Neither a Panacea Nor a Mirage: Understanding Supervised vs. Reinforcement Learning Fine-Tuning for LLMscited by 17
- 2025Propose, Solve, Verify: Self-Play Through Formal Verificationcited by 11
- 2025VeruSAGE: A Study of Agent-Based Verification for Rust Systemscited by 11
- 2026AlgoVeri: An Aligned Benchmark for Verified Code Generation on Classical Algorithmscited by 11
38 more
- 2024Laurel: Unblocking Automated Verification with Large Language Modelscited by 10
- 2025OSVBench: Benchmarking LLMs on Specification Generation Tasks for Operating System Verificationcited by 8
- 2025VeriStruct: AI-assisted Automated Verification of Data-Structure Modules in Veruscited by 8
- 2025ProofWright: Towards Agentic Formal Verification of CUDAcited by 8
- 2026Intent Formalization: A Grand Challenge for Reliable Coding in the Age of AI Agentscited by 8
- 2024New Solutions on LLM Acceleration, Optimization, and Applicationcited by 7
- 2025VeriEquivBench: An Equivalence Score for Ground-Truth-Free Evaluation of Formally Verifiable Codecited by 7
- 2024Synthetic Programming Elicitation for Text-to-Code in Very Low-Resource Programming and Formal Languagescited by 6
- 2025Dafny as Verification-Aware Intermediate Language for Code Generationcited by 6
- 2025Local Success Does Not Compose: Benchmarking Large Language Models for Compositional Formal Verificationcited by 6
- 2025Agentic Verification of Software Systemscited by 5
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMscited by 4
- 2025Towards Repository-Level Program Verification with Large Language Modelscited by 4
- 2025RAG-Verus: Repository-Level Program Verification with LLMs using Retrieval Augmented Generationcited by 3
- 2025Can LLMs Enable Verification in Mainstream Programming?cited by 3
- 2025Inferring multiple helper Dafny assertions with LLMscited by 3
- 2026AutoReSpec: A Framework for Generating Specification using Large Language Modelscited by 3
- 2024Generative transformations and patterns in LLM-native approaches for software verification and falsificationcited by 2
- 2025FormalSpecCpp: A Dataset of C++ Formal Specifications created using LLMscited by 2
- 2026Doc2Spec: Synthesizing Formal Programming Specifications from Natural Language via Grammar Inductioncited by 2
- 2026Spec-Harness: Measuring and Improving Behavioral Adequacy of LLM-Synthesized Formal Specificationscited by 2
- 2024Assured Automatic Programming via Large Language Modelscited by 1
- 2025Towards Automated Formal Verification of Backend Systems with LLMscited by 1
- 2025Proof2Silicon: Prompt Repair for Verified Code and Hardware Generation via Reinforcement Learningcited by 1
- 2025LLM For Loop Invariant Generation and Fixing: How Far Are We?cited by 1
- 2025The 4/δ Bound: Designing Predictable LLM-Verifier Systems for Formal Method Guaranteecited by 1
- 2026Intent-aligned Formal Specification Synthesis via Traceable Refinementcited by 1
- 2026VeriContest: A Competitive-Programming Benchmark for Verifiable Code Generationcited by 1
- 2026AxDafny: Agentic Verified Code Generation in Dafnycited by 1
- 2026Formal Disco: Scalable Open-Ended Generation of Formally Verified Programscited by 1
- 2025From Scientific Texts to Verifiable Code: Automating the Process with Transformerscited by 0
- 2025Accessible Smart Contracts Verification: Synthesizing Formal Models with Tamed LLMscited by 0
- 2025Working Document -- Formalising Software Requirements with Large Language Modelscited by 0
- 2025AutoICE: Automatically Synthesizing Verifiable C Code via LLM-driven Evolutioncited by 0
- 2026Toward an Agentic Infused Software Ecosystemcited by 0
- 2026Can LLMs Reason Like Automated Theorem Provers for Rust Verification? VCoT-Bench: Evaluating via Verification Chain of Thoughtcited by 0
- 2026From Natural Language to Verified Code: Toward AI Assisted Problem-to-Code Generation with Dafny-Based Formal Verificationcited by 0
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generationcited by 0
50 most cited of 58 All 58 (JSON)
- 2026Self-Spec Verifiable Code Generation30 Sep 2026
- 2026Fewer Assumptions by Design: A Reusable Skill for LLM-Assisted Verus Verification28 Sep 2026
- 2026Djinnlang: Higher-Level Programming by Unambiguous Specification with an LLM in the Compiler21 Sep 2026
- 2026SkillForge: Compositional Skill Synthesis with Verification-in-the-Loop for Generating Formally Verified Dafny Programs30 Aug 2026
- 2026Diversifying to Verify: When Task-Equivalent Programs Differ in Verifiability10 Jul 2026
- 2026Formal Disco: Scalable Open-Ended Generation of Formally Verified Programs6 Jul 2026
- 2026AxDafny: Agentic Verified Code Generation in Dafny30 Jun 2026
- 2026An Empirical Study of LLM-Generated Specifications for VeriFast25 Jun 2026
- 2026VeriScale: Adversarial Test-Suite Scaling for Verifiable Code Generation21 May 2026
- 2026Viverra: Text-to-Code with Guarantees14 May 2026
- 2026VeriContest: A Competitive-Programming Benchmark for Verifiable Code Generation8 May 2026
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generation2 May 2026
38 more
- 2026From Natural Language to Verified Code: Toward AI Assisted Problem-to-Code Generation with Dafny-Based Formal Verification24 Apr 2026
- 2026Intent-aligned Formal Specification Synthesis via Traceable Refinement12 Apr 2026
- 2026AutoReSpec: A Framework for Generating Specification using Large Language Models4 Apr 2026
- 2026Spec-Harness: Measuring and Improving Behavioral Adequacy of LLM-Synthesized Formal Specifications31 Mar 2026
- 2026Can LLMs Reason Like Automated Theorem Provers for Rust Verification? VCoT-Bench: Evaluating via Verification Chain of Thought18 Mar 2026
- 2026Intent Formalization: A Grand Challenge for Reliable Coding in the Age of AI Agents17 Mar 2026
- 2026Toward an Agentic Infused Software Ecosystem24 Feb 2026
- 2026AlgoVeri: An Aligned Benchmark for Verified Code Generation on Classical Algorithms10 Feb 2026
- 2026Doc2Spec: Synthesizing Formal Programming Specifications from Natural Language via Grammar Induction30 Jan 2026
- 2025VeruSAGE: A Study of Agent-Based Verification for Rust Systems20 Dec 2025
- 2025Propose, Solve, Verify: Self-Play Through Formal Verification20 Dec 2025
- 2025AutoICE: Automatically Synthesizing Verifiable C Code via LLM-driven Evolution8 Dec 2025
- 2025The 4/δ Bound: Designing Predictable LLM-Verifier Systems for Formal Method Guarantee30 Nov 2025
- 2025Agentic Verification of Software Systems21 Nov 2025
- 2025ProofWright: Towards Agentic Formal Verification of CUDA15 Nov 2025
- 2025LLM For Loop Invariant Generation and Fixing: How Far Are We?9 Nov 2025
- 2025Inferring multiple helper Dafny assertions with LLMs31 Oct 2025
- 2025VeriStruct: AI-assisted Automated Verification of Data-Structure Modules in Verus28 Oct 2025
- 2025VeriEquivBench: An Equivalence Score for Ground-Truth-Free Evaluation of Formally Verifiable Code7 Oct 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
- 2025Towards Repository-Level Program Verification with Large Language Models31 Aug 2025
- 2025RL Is Neither a Panacea Nor a Mirage: Understanding Supervised vs. Reinforcement Learning Fine-Tuning for LLMs22 Aug 2025
- 2025Working Document -- Formalising Software Requirements with Large Language Models17 Jun 2025
- 2025VERINA: Benchmarking Verifiable Code Generation29 May 2025
- 2025OSVBench: Benchmarking LLMs on Specification Generation Tasks for Operating System Verification29 Apr 2025
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMs16 Apr 2025
- 2025Towards Automated Formal Verification of Backend Systems with LLMs13 Apr 2025
- 2025Can LLMs Enable Verification in Mainstream Programming?18 Mar 2025
- 2025FormalSpecCpp: A Dataset of C++ Formal Specifications created using LLMs21 Feb 2025
- 2025Proving the Coding Interview: A Benchmark for Formally Verified Code Generation8 Feb 2025
- 2025RAG-Verus: Repository-Level Program Verification with LLMs using Retrieval Augmented Generation7 Feb 2025
- 2025Accessible Smart Contracts Verification: Synthesizing Formal Models with Tamed LLMs22 Jan 2025
- 2025Dafny as Verification-Aware Intermediate Language for Code Generation10 Jan 2025
- 2025From Scientific Texts to Verifiable Code: Automating the Process with Transformers9 Jan 2025
- 2024Formal Mathematical Reasoning: A New Frontier in AI20 Dec 2024
- 2024AlphaVerus: Bootstrapping Formally Verified Code Generation through Self-Improving Translation and Treefinement9 Dec 2024
- 2024Assured Automatic Programming via Large Language Models24 Oct 2024
50 newest of 58 All 58 (JSON)
- 2025VeruSAGE: A Study of Agent-Based Verification for Rust Systemscited by 11
- 2025ProofWright: Towards Agentic Formal Verification of CUDAcited by 8
- 2026Intent Formalization: A Grand Challenge for Reliable Coding in the Age of AI Agentscited by 8
- 2025Agentic Verification of Software Systemscited by 5
- 2026AxDafny: Agentic Verified Code Generation in Dafnycited by 1
- 2026Toward an Agentic Infused Software Ecosystemcited by 0
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generationcited 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
- 2026AxDafny: Agentic Verified Code Generation in Dafny30 Jun 2026
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generation2 May 2026
- 2026Intent Formalization: A Grand Challenge for Reliable Coding in the Age of AI Agents17 Mar 2026
- 2026Toward an Agentic Infused Software Ecosystem24 Feb 2026
- 2025VeruSAGE: A Study of Agent-Based Verification for Rust Systems20 Dec 2025
- 2025Agentic Verification of Software Systems21 Nov 2025
- 2025ProofWright: Towards Agentic Formal Verification of CUDA15 Nov 2025
- 2024DafnyBench: A Benchmark for Formal Software Verificationcited by 54
- 2024AutoVerus: Automated Proof Generation for Rust Codecited by 46
- 2024Automated Proof Generation for Rust Code via Self-Evolutioncited by 31
- 2025VERINA: Benchmarking Verifiable Code Generationcited by 30
- 2024Towards Neural Synthesis for SMT-Assisted Proof-Oriented Programmingcited by 19
- 2025Proving the Coding Interview: A Benchmark for Formally Verified Code Generationcited by 18
- 2025RL Is Neither a Panacea Nor a Mirage: Understanding Supervised vs. Reinforcement Learning Fine-Tuning for LLMscited by 17
- 2026AlgoVeri: An Aligned Benchmark for Verified Code Generation on Classical Algorithmscited by 11
- 2024Laurel: Unblocking Automated Verification with Large Language Modelscited by 10
- 2025OSVBench: Benchmarking LLMs on Specification Generation Tasks for Operating System Verificationcited by 8
- 2025VeriStruct: AI-assisted Automated Verification of Data-Structure Modules in Veruscited by 8
- 2024New Solutions on LLM Acceleration, Optimization, and Applicationcited by 7
12 most cited of 45 All 45 (JSON)
- 2026Self-Spec Verifiable Code Generation30 Sep 2026
- 2026Fewer Assumptions by Design: A Reusable Skill for LLM-Assisted Verus Verification28 Sep 2026
- 2026Djinnlang: Higher-Level Programming by Unambiguous Specification with an LLM in the Compiler21 Sep 2026
- 2026Diversifying to Verify: When Task-Equivalent Programs Differ in Verifiability10 Jul 2026
- 2026Formal Disco: Scalable Open-Ended Generation of Formally Verified Programs6 Jul 2026
- 2026An Empirical Study of LLM-Generated Specifications for VeriFast25 Jun 2026
- 2026VeriScale: Adversarial Test-Suite Scaling for Verifiable Code Generation21 May 2026
- 2026Viverra: Text-to-Code with Guarantees14 May 2026
- 2026VeriContest: A Competitive-Programming Benchmark for Verifiable Code Generation8 May 2026
- 2026From Natural Language to Verified Code: Toward AI Assisted Problem-to-Code Generation with Dafny-Based Formal Verification24 Apr 2026
- 2026Intent-aligned Formal Specification Synthesis via Traceable Refinement12 Apr 2026
- 2026AutoReSpec: A Framework for Generating Specification using Large Language Models4 Apr 2026
12 newest of 45 All 45 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2025Re:Form -- Reducing Human Annotations in Scalable Formal Software Verification with RL in LLMs: A Preliminary Study on Dafny
- 2025Asking LLMs to Verify First is Almost Free Lunch
- 2024VerMCTS: Synthesizing Multi-Step Programs using a Verifier, a Large Language Model, and Tree Search
- 2026Automating Formal Verification with Reinforcement Learning and Recursive Inference
- 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval
- 2026Evaluating Prompting and Execution-Based Methods for Deterministic Computation in LLMs
- 2026Adaptive Generate-Rank-Verify: Inference-Time Search with Costly Verification
- 2026A Frozen 12B Beats Frontier Models on Verified Work: 100% Accuracy, 0 Tokens, Bit-Exact, Forever