From Natural Language to Verified Code: Toward AI Assisted Problem-to-Code Generation with Dafny-Based Formal Verification
Not on the map. Why?
Abstract (arXiv)
Large Language Models (LLMs) show promise in automated software engineering, yet their guarantee of correctness is frequently undermined by erroneous or hallucinated code. To enforce model honesty, formal verification requires LLMs to synthesize implementation logic alongside formal specifications that are subsequently proven correct by a mathematical verifier. However, the transition from informal natural language to precise formal specification remains an arduous task. Our work addresses this by providing the NaturalLanguage2VerifiedCode (NL2VC)-60 dataset: a collection of 60 complex algorithmic problems. We evaluate 11 randomly selected problem sets across seven open-weight LLMs using a tiered prompting strategy: contextless prompts, signature prompts providing structural anchors, and self-healing prompts utilizing iterative feedback from the Dafny verifier. To address vacuous verification, where models satisfy verifiers with trivial specifications, we integrate the uDebug platform to ensure functional validation. Our results show that while contextless prompting leads to near-universal failure, structural signatures and iterative self-healing facilitate a dramatic performance turnaround. Specifically, Gemma 4-31B achieved a 90.91% verification success rate, while GPT-OSS 120B rose from zero to 81.82% success with signature-guided feedback. These findings indicate that formal verification is now attainable for open-weight LLMs, which serve as effective apprentices for synthesizing complex annotations and facilitating high-assurance software development.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 20 of its 75 references that are in the map. First posted on arXiv 24 Apr 2026.
Builds on
20 of 75 references.
References · 20
- 2023GPT-4 Technical Reportcited by 18,132
- 2024The Llama 3 Herd of Modelscited by 14,192
- 2025Qwen3 Technical Reportcited by 8,195
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2025Gemma 3 Technical Reportcited by 1,686
- 2021Prompt Programming for Large Language Models: Beyond the Few-Shot Paradigmcited by 599
- 2019SPoC: Search-based Pseudocode to Codecited by 176
- 2022Language Models of Code are Few-Shot Commonsense Learnerscited by 160
- 2022Thor: Wielding Hammers to Integrate Language Models and Automated Theorem Proverscited by 97
- 2025CWM: An Open-Weights LLM for Research on Code Generation with World Modelscited by 87
- 2024Towards AI-Assisted Synthesis of Verified Dafny Methodscited by 58
8 more
- 2024DafnyBench: A Benchmark for Formal Software Verificationcited by 54
- 2025Control the Temperature: Selective Sampling for Diverse and High-Quality LLM Outputscited by 15
- 2020QED at Large: A Survey of Engineering of Formally Verified Softwarecited by 13
- 2026DafnyPro: LLM-Assisted Automated Verification for Dafny Programscited by 11
- 2023Automating Code-Related Tasks Through Transformers: The Impact of Pre-trainingcited by 8
- 2018Concrete Semantics with Coq and CoqHammercited by 2
- 2022More Programming Than Programming: Teaching Formal Methods in a Software Engineering Programmecited by 2
- 2023Formal and Executable Semantics of the Ethereum Virtual Machine in Dafnycited by 2
Built on by
Not cited yet.