HoarePrompt: Structural Reasoning About Program Correctness in Natural Language
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
While software requirements are often expressed in natural language, verifying the correctness of a program against such requirements is a hard and underexplored problem. Large language models (LLMs) are promising candidates for addressing this challenge, however our experience shows that they are ineffective in this task, often failing to detect even straightforward bugs. To address this gap, we introduce HoarePrompt, a novel approach that adapts fundamental ideas from program verification to natural language artifacts. Inspired from the strongest postcondition calculus, HoarePrompt employs a systematic, step-by-step process in which an LLM generates natural language descriptions of reachable program states at various code points. To manage loops, we propose few-shot-driven k-induction, an adaptation of the k-induction method widely used in model checking. Once program states are described, HoarePrompt leverages the LLM to assess whether the program, annotated with these state descriptions, conforms to the natural language requirements. For evaluating the quality of classifiers of program correctness with respect to natural language requirements, we constructed CoCoClaNeL, a challenging dataset of solutions to programming competition problems. Our experiments show that HoarePrompt improves the MCC by 61% compared to directly using Zero-shot-CoT prompts for correctness classification. Furthermore, HoarePrompt outperforms a classifier that assesses correctness via LLM-based test generation by an MCC increase of 106%. The inductive reasoning mechanism contributes a 26% boost to MCC, underscoring its effectiveness in managing loops.
Key facts. Cited by 7 papers in the map (data through 7 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 31 of its 60 references that are in the map. First posted on arXiv 25 Mar 2025.
Builds on
31 of 60 references.
Closest ancestors · 8
Same direction, newest first
- 2025ProBench: Benchmarking Large Language Models in Competitive Programming28 Feb
- 2025CodeElo: Benchmarking Competition-level Code Generation of LLMs with Human-comparable Elo Ratings2 Jan
- 2024GroupDebate: Enhancing the Efficiency of Multi-Agent Debate Using Group Discussion21 Sep
- 2024NExT: Teaching Large Language Models to Reason about Code Execution23 Apr
- 2024Reasoning Runtime Behavior of a Program with LLM: How Far Are We?25 Mar
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Code12 Mar
- 2024CodeMind: Evaluating Large Language Models for Code Reasoning15 Feb
- 2023CodeCoT: Tackling Code Syntax Errors in CoT Reasoning for Code Generation17 Aug
Other references · 23
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Can LLMs Express Their Uncertainty? An Empirical Evaluation of Confidence Elicitation in LLMscited by 946
- 2023Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design or: How I learned to start worrying about prompt formattingcited by 778
- 2022CodeT: Code Generation with Generated Testscited by 369
- 2022Draft, Sketch, and Prove: Guiding Formal Theorem Provers with Informal Proofscited by 278
- 2022Ask Me Anything: A simple strategy for prompting language modelscited by 155
- 2024On Memorization of Large Language Models in Logical Reasoningcited by 114
- 2024Faithful Logical Reasoning via Symbolic Chain-of-Thoughtcited by 99
- 2023No More Manual Tests? Evaluating and Improving ChatGPT for Unit Test Generationcited by 82
- 2024Can Language Models Solve Olympiad Programming?cited by 70
- 2024What is the Role of Small Models in the LLM Era: A Surveycited by 41
- 2023ClarifyGPT: Empowering LLM-based Code Generation with Intention Clarificationcited by 37
11 more
- 2023AgentCoder: Multi-Agent-based Code Generation with Iterative Testing and Optimisationcited by 31
- 2024CodeJudge-Eval: Can Large Language Models be Good Judges in Code Understanding?cited by 29
- 2024Large Language Models as Test Case Generators: Performance Evaluation and Enhancementcited by 27
- 2024Training on the Benchmark Is Not All You Needcited by 24
- 2024Verified Code Transpilation with LLMscited by 15
- 2023The Program Testing Ability of Large Language Models for Codecited by 11
- 2024Can Large Language Models Act as Symbolic Reasoners?cited by 8
- 2023Towards General Loop Invariant Generation: A Benchmark of Programs with Memory Manipulationcited by 7
- 2024CoCoST: Automatic Complex Code Generation with Online Searching and Correctness Testingcited by 7
- 2025Verifying LLM-Generated Code in the Context of Software Verification with Ada/SPARKcited by 3
- 2024Towards Automated Verification of LLM-Synthesized C Programscited by 1
Built on by
Citing papers per year: 2025: 1; 2026: 6.
7 papers.
- 2025Evaluating Code Reasoning Abilities of Large Language Models Under Real-World Settingscited by 3
- 2026Teaching Code LLMs to Reason with Intermediate Formal Specificationscited by 1
- 2026Viverra: Text-to-Code with Guaranteescited by 0
- 2026Inferring Code Correctness from Specificationcited by 0
- 2026Rethinking Complexity Metrics for LLM-Integrated Applications: Beyond Source Codecited by 0
- 2026Grounding AI Agents in Contracts: An Empirical Evaluation of Spec-Driven Test Generationcited by 0
- 2026SkillSpec: Intent-Masked Specification Reasoning for Agent Skill Correctnesscited by 0
- 2026SkillSpec: Intent-Masked Specification Reasoning for Agent Skill Correctness5 Sep 2026
- 2026Grounding AI Agents in Contracts: An Empirical Evaluation of Spec-Driven Test Generation17 Aug 2026
- 2026Teaching Code LLMs to Reason with Intermediate Formal Specifications5 Jul 2026
- 2026Rethinking Complexity Metrics for LLM-Integrated Applications: Beyond Source Code2 Jul 2026
- 2026Inferring Code Correctness from Specification28 May 2026
- 2026Viverra: Text-to-Code with Guarantees14 May 2026
- 2025Evaluating Code Reasoning Abilities of Large Language Models Under Real-World Settings16 Dec 2025
Similar, not cited
Close in wording, no citation either way
- 2026SWE-Proof: Can Language Models Resolve Real-World Issues with Machine-Checked Proofs?
- 2025VeriEquivBench: An Equivalence Score for Ground-Truth-Free Evaluation of Formally Verifiable Code
- 2026An Execution-Verified Multi-Language Benchmark for Code Semantic Reasoning
- 2025Evaluating Program Semantics Reasoning with Type Inference in System F
- 2025Generating Verifiable Chain of Thoughts from Exection-Traces
- 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checking
- 2026Where Do Large Language Models Fail on Competitive Programming? A Taxonomy of Failures by Algorithm Type and Difficulty Rating ↗
- 2026Automated Lemma Discovery in Agentic Program Verification