P$^{3}$: Joint Program-and-Proof Planning for Verified Code Generation
Zenan Li, Ziran Yang, Peiyang Song, Zhaoyu Li, Kaiyu Yang
NeurIPS 2026
Abstract. Verified code generation asks a large language model (LLM) to generate both an executable program and a machine-checkable proof that the program meets a formal specification, promising software that is correct by construction. The de facto workflow decouples the two halves of the problem: first synthesize a program, then attempt to prove it correct. We observe that this sequential pipeline can be both ineffective and inefficient in practice. A program generated without anticipating its proof can be subtly incorrect or structurally difficult to verify, forcing the LLM into brittle repair loops that alternate between patching the code and patching the proof. Inspired by Dijkstra's view that a program and its correctness argument should be developed hand in hand, we propose , an LLM-based agentic workflow that first derives a unified program-and-proof plan from the specification, then elaborates the implementation and proof scaffold under this shared plan. To evaluate verified code generation in realistic settings, we further introduce Lean4Commit0, a project-level benchmark built by extracting core APIs from real-world software repositories and translating their requirements, including relational specifications across APIs, into Lean tasks. Using four frontier LLM backends, we evaluate on Verina, AlgoVeri, and our Lean4Commit0 benchmark, where it achieves the highest solve rate in every benchmark--model setting. Compared with the stronger baseline, it improves solve rates by 4.6--11.2 percentage points and reduces per-task API cost by up to roughly 40% and wall-clock time by up to roughly 37% on the difficult subset of each benchmark.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:47 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
This paper proposes P³, an agentic workflow for verified code generation that plans the program and its correctness proof jointly before elaborating either component. The shared plan is intended to avoid programs that are functionally plausible but unnecessarily difficult to verify. The paper also introduces Lean4Commit0, a benchmark derived from real repositories and including relational specifications across library APIs. Across Verina, AlgoVeri, and Lean4Commit0 with four LLM backends, P³ achieves the highest solve rate in every reported benchmark–model setting, improving over the stronger sequential baseline by 4.6–11.2 percentage points while reducing cost and runtime on difficult subsets.
Strengths:
The problem is important and clearly motivated: program synthesis and proof construction are tightly coupled, yet existing workflows typically handle them sequentially. The joint-planning formulation is simple but sensible and appears broadly applicable.
The evaluation is a notable strength. Results are consistent across three benchmarks and four models, and the improvements include both solve rate and computational efficiency. Lean4Commit0 is also a useful contribution because it moves evaluation toward repository-derived APIs and cross-functional specifications. The manuscript is reportedly clear and supported by informative examples.
Weaknesses:
The central weakness is that the evaluation does not fully isolate why P³ works. In particular, the paper lacks a planning-only baseline such as Planning → Program → Proof, making it unclear whether gains arise from joint program–proof reasoning or simply from adding a planning stage.
The method also assumes that the model can accurately estimate proof difficulty when selecting a plan, but no statistics are provided on plan quality, incorrect plan selection, or where failed runs break down. Baseline coverage is relatively limited, and details concerning repeated runs, variance, and reproducibility should be strengthened. Finally, the current experiments involve relatively small Lean tasks, leaving scalability to larger software systems uncertain.
Desired Results in the Author Rebuttal:
The response could materially strengthen the acceptance case by providing:
-
A Planning → Program → Proof ablation under the same computational budget.
-
Statistics on plan-selection accuracy and a failure decomposition separating poor plans from failed implementation or proof elaboration.
-
Clarification of the number of runs, variance, reproducibility resources, and relevant omitted baselines.
-
A representative Lean4Commit0 example solved only by P³, together with a clearer discussion of scalability.
Overall, the method is technically straightforward, but the consistent empirical gains and useful benchmark contribution outweigh the current evaluation. Hereby my initial assessment leans toward the acceptance (Poster).
Final justification
After the rebuttal and discussion, the reviews are consistently positive. Therefore, the AC decides to accept the paper.
Read meta-review
Meta-review
This paper proposes P³, an agentic workflow for verified code generation that plans the program and its correctness proof jointly before elaborating either component. The shared plan is intended to avoid programs that are functionally plausible but unnecessarily difficult to verify. The paper also introduces Lean4Commit0, a benchmark derived from real repositories and including relational specifications across library APIs. Across Verina, AlgoVeri, and Lean4Commit0 with four LLM backends, P³ achieves the highest solve rate in every reported benchmark–model setting, improving over the stronger sequential baseline by 4.6–11.2 percentage points while reducing cost and runtime on difficult subsets.
Strengths:
The problem is important and clearly motivated: program synthesis and proof construction are tightly coupled, yet existing workflows typically handle them sequentially. The joint-planning formulation is simple but sensible and appears broadly applicable.
The evaluation is a notable strength. Results are consistent across three benchmarks and four models, and the improvements include both solve rate and computational efficiency. Lean4Commit0 is also a useful contribution because it moves evaluation toward repository-derived APIs and cross-functional specifications. The manuscript is reportedly clear and supported by informative examples.
Weaknesses:
The central weakness is that the evaluation does not fully isolate why P³ works. In particular, the paper lacks a planning-only baseline such as Planning → Program → Proof, making it unclear whether gains arise from joint program–proof reasoning or simply from adding a planning stage.
The method also assumes that the model can accurately estimate proof difficulty when selecting a plan, but no statistics are provided on plan quality, incorrect plan selection, or where failed runs break down. Baseline coverage is relatively limited, and details concerning repeated runs, variance, and reproducibility should be strengthened. Finally, the current experiments involve relatively small Lean tasks, leaving scalability to larger software systems uncertain.
Desired Results in the Author Rebuttal:
The response could materially strengthen the acceptance case by providing:
-
A Planning → Program → Proof ablation under the same computational budget.
-
Statistics on plan-selection accuracy and a failure decomposition separating poor plans from failed implementation or proof elaboration.
-
Clarification of the number of runs, variance, reproducibility resources, and relevant omitted baselines.
-
A representative Lean4Commit0 example solved only by P³, together with a clearer discussion of scalability.
Overall, the method is technically straightforward, but the consistent empirical gains and useful benchmark contribution outweigh the current evaluation. Hereby my initial assessment leans toward the acceptance (Poster).
Final justification
After the rebuttal and discussion, the reviews are consistently positive. Therefore, the AC decides to accept the paper.
- Rating
- 4/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 4/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper proposes a methodology for agentic verified code generation in Lean 4. Instead of the program-then-proof sequential pipeline adopted by most frameworks, it introduces a planning phase where coding agents are instructed to generate a sketch of decomposed program-generation / proof-elaboration tasks; then both program and proof are generated against the same plan. Additionally, the paper introduces a new set of benchmarks that include real-world programs. Experimental results show the methodology is effective compared to the sequential approach.
Strengths and weaknesses
Strengths:
- Targets a relevant problem: how to orchestrate coding agents for verified code generation.
- Good illustrating examples to motivate the coupling of program generation and proof elaboration.
- Proposes real-world benchmarks.
Weaknesses:
- The proposed method is relatively simple and the improvement compared to the baseline is modest, which limits the novelty of the contribution.
- Missing hints on the reproducibility of the results.
Questions
- When prompting coding agents to produce a plan, what are the key technical/algorithmic insights for instructing the agent to construct a program/proof sketch? Could the authors give more detail on the first paragraph of Section 3.1?
- How many runs per benchmark entry were tried? Could the authors comment on the reproducibility of the results, especially for Table 2?
- I appreciate the case study on the red-black tree. Could the authors share an example from the newly proposed real-world benchmark that is not solvable by plain agent calls or the sequential method, but is solvable using the proposed method?
- Can the authors envision how the proposed method might adapt to languages with a less expressive type system but good deductive-verifier support? The paper mentions Rust and Verus — would the same methodology work in that setting?
Limitations
Yes. The paper discusses limitations (Appendix C), including disclosing that statistical significance testing was infeasible.
Formatting concerns
No
1 comment
- Rating
- 4/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper consider verifiable code generation: given a formal specification, generate both code and a proof that the code meets the spec. Current approaches writes code first and then tries to prove it. However, a directly written program is often hard to verify, which pushes the model into heavy proof repair loops. The authors instead let the agent plan the program and proof together, by first presenting a shared sketch, then refinement, therefore the code and proof are improved jointly. They also introduce Lean4Commit0 benchmark built from real repositories. Across three benchmarks and four LLMs, the method (P3) gives the highest solve rate with cost and time savings.
Strengths and weaknesses
Strengths
- The research gap of code-then-proof methods is clearly stated. The proposed fix (planning code and proof jointly) is reasonable and well-motivated.
- The evaluation results show consistent solve-rate gains across all benchmark model combinations, as well as reductions in cost.
Weaknesses
- The comparison only includes the plain agent and the sequential (program-then-proof) baseline. Are there really no other relevant methods to compare against?
- The method assumes that the LLM can correctly predict proof burden without writing the full proof. Judging that "the rebuild route reduces to a list permutation, whereas structural deletion needs a long invariant chain" is itself a nontrivial intuition. On tasks with clean textbook structure the planner can get this right, but on genuinely unfamiliar specs the planner may pick the wrong plan. The approach depends heavily on this LLM capability. Is there any analysis or statistics on this?
- Lean-based verification is limited to small programs. It's unclear how well this transfers to real-world large-scale code.
Questions
- When the planner compares sketches and predicts proof burden, how often is it correct? Do you have any statistics?
- For the tasks P3 fails on, where does it break down? Bad plan, or correct plan but failed elaboration?
Limitations
yes
Final justification
For my questions, authors either explained to me or added new promising evaluation.
Formatting concerns
no
2 comments
Response to Reviewer ANin
We thank the reviewer for recognizing the research gap, the motivation, and P³'s consistent solve-rate gains and cost reductions. We address each concern below.
W1. Other comparison methods
To our knowledge, no existing method targets the same problem, i.e., end-to-end verified code generation, where both the program and its correctness proof must be synthesized under a controlled orchestration order. Existing systems address different problem formulations: WybeCoder and Goedel-Code-Prover generate proofs for given Lean programs and specifications; AutoVerus, VeruSAGE, and ExVerus generate or repair annotations for existing Verus/Rust programs; and Clever, VeriSoftBench, and VeriCodeBench are benchmarks rather than verified code generation methods. Accordingly, we include only PLAIN and SEQ as directly comparable baselines.
In addition, in response to reviewer KMDX, we added a new PLAN-SEQ baseline that isolates generic implementation planning from joint program-and-proof planning. The results are clear: P³ outperforms PLAN-SEQ on all three benchmarks by 3.3–8.3 percentage points, confirming that its gains stem specifically from planning the program and its proof jointly, rather than from planning in general. We will make this scope explicit in the revision.
W2 & Q1. Plan-selection accuracy
We agree this capability should be measured rather than assumed. Because a task may admit multiple valid plans, we report structural plan retention as an observable proxy rather than a direct measure of proof-burden prediction accuracy. Among the 141 successful Verina P³ runs (backend Claude-Opus-4.7), 131 (92.9%) retained the initially selected plan through completion, while 10 (7.1%) required replacement after the original route proved infeasible. The selected route thus usually remained viable through successful elaboration, though retention does not imply a perfect estimate of proof difficulty.
Q2. Failure analysis for P³
Across the 48 failed Verina P³ runs, the cause was an inadequate plan in 4 cases (8.3%), program elaboration in 3 (6.3%), proof elaboration under an otherwise viable plan in 15 (31.3%), and timeout or tool failure in 26 (54.2%). Only 4 of 48 failures were therefore attributable to plan inadequacy; most arose from proof elaboration or from execution-time and tool limits. We will add this breakdown, along with representative examples from the two largest categories.
W3. Scalability to large-scale software systems
We agree that our current evidence does not establish whole-system scalability. That said, Lean4Commit0 already goes beyond single functions: each task represents a library with multiple implementations and relational theorems, totaling 1,030 jointly constrained placeholders across 108 libraries. It nonetheless models core APIs rather than complete builds, and omits very long dependency chains and dynamic features. We will therefore describe it consistently as a repository-derived, library-level evaluation.
A plausible route to larger systems is hierarchical planning: derive an API dependency-and-contract graph, plan modules separately, and use verified interfaces to make completed modules opaque while jointly planning code and proof within each remaining obligation. We will present this as future work rather than as an empirically established capability.
Thanks for your response and new evaluation results (to my and to other reviewers). Please include the revision plan in the next version. I will increase my score.
- Rating
- 5/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 4/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper shows that program verification benefits from generating the program and the proof jointly.This paper also introduces a new benchmark for program verification that takes into account library functions that share post conditions.
Strengths and weaknesses
This paper was easy to follow and well-written. The experiments were thorough and well-thought out. The evaluation used relevant systems. While this is a very active area of research, I could not recall any other papers that focused on jointly generating the proof and program jointly. This work definitely makes a useful contribution to the area.
Questions
Could this benefit from an ablation study? Could you check if only adding planning helps? Namely Planning -> Program -> Proof as a baseline
Limitations
The paper does include limitations but they are restricted to the appendix. It would be nice if they were in the main section of the paper.
Formatting concerns
No issues
1 comment
Response to Reviewer KMDX
Q1. Ablation study
We thank the reviewer for pointing to this ablation. To isolate the contribution of joint program-and-proof planning from generic implementation planning, we add a budget-matched PLAN-SEQ baseline. PLAN-SEQ plans only the program side—algorithm, data representation, program decomposition, termination argument, auxiliary functions, and program-side library choices—and completes the full implementation before any proof generation begins. Crucially, it is not permitted to anticipate proof invariants, proof decomposition, induction strategies, auxiliary lemmas, or the anticipated proof burden. All other settings and budgets match P³.
As shown in the table below, P³ outperforms PLAN-SEQ on all three benchmarks by 3.3–8.3 percentage points. PLAN-SEQ itself improves over SEQ on Verina (+1.5) and AlgoVeri (+4.5), confirming that generic planning helps, but it drops 3.7 points on Lean4Commit0. We attribute this to Lean4Commit0's relational specifications, which connect multiple APIs: a program-only plan may commit to implementations that are locally reasonable yet difficult to relate to one another in the subsequent proof. By planning implementations jointly with their shared proof obligations, P³ avoids this trap and achieves its largest gain over PLAN-SEQ precisely on Lean4Commit0 (+8.3).
| Benchmark (Claude-Opus-4.7) | PLAIN (%) | SEQ (%) | PLAN-SEQ (%) | P³ (%) | Δ vs. PLAN-SEQ (pp) |
|---|---|---|---|---|---|
| Verina | 68.8 | 68.3 | 69.8 | 74.6 | +4.8 |
| AlgoVeri | 39.0 | 40.3 | 44.8 | 48.1 | +3.3 |
| Lean4Commit0 | 13.9 | 17.6 | 13.9 | 22.2 | +8.3 |
Limitations
We thank the reviewer for this comment and will move a condensed limitations paragraph into the main paper. It will cover four points: (i) our experiments currently span only Lean 4 and frontier closed-source models; (ii) Lean4Commit0 models core APIs rather than complete repositories and is skewed toward Python; (iii) our specification checks cannot rule out every form of underconstraint; and (iv) the single-run evaluation does not estimate within-task stochastic variance. The fuller discussion will remain in Appendix C.
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Response to Reviewer GpuC
We thank the reviewer for the positive assessment of the motivation, examples, and real-world benchmark. We address the requested methodological and reproducibility details below.
W1 & Q1. Technical insights behind P³
The planner is not merely instructed to "think first." It must produce an inspectable plan artifact with four explicit commitments:
The plan gate then checks that the program sketch satisfies the algorithmic instruction, that the chosen decomposition preserves the bridging predicate, that the predicate entails the postcondition, and that any required strengthening is stated before code generation. During elaboration, local syntax or type errors may be repaired only while the plan remains unchanged; if a new structural lemma, invariant, or algorithm becomes necessary, the workflow records a plan failure and replans rather than continuing local repair. We will add this schema and compact pseudocode to Section 3.1; the complete executable prompt remains in Appendix E.
W2 & Q2. Reproducibility of the results
Each (task, model, method) configuration in the original Table 2 was run once, owing to the high cost of evaluation. We therefore do not report formal significance tests or within-task variance, and we will state this limitation more prominently.
The anonymized agent harness, prompts, Lean4Commit0 benchmark, and evaluation scripts are already available in the Figshare snapshot cited in Appendix E (https://figshare.com/s/2ab7020cacaffcf0d258). We will make this link more prominent in Section 5.1 and consolidate, in one place, the exact model, API, and CLI versions, sampling settings, Lean 4.28.0 Docker environment, task instructions, and per-run cost, time, and feedback limits needed to reproduce Table 2.
Q3. A Lean4Commit0 case solved only by P³
We will release the complete traces for Memchr, a Lean4Commit0 task that P³ solves but neither PLAIN nor SEQ does under the same backend and budget. The task comprises three APIs (
memchr,memmem, andmemrchr) and four theorems, including the relational requirement that forward and reverse search agree on whether the target byte occurs. PLAIN could not connect theList.idxOflemmas to the optional-index specification and timed out; SEQ committed to an unbounded search and failed final evaluation.P³ instead made the finite witness domain explicit and aligned the first- and last-occurrence proofs with
Nat.findandNat.findGreatest. The relational theorem then follows compositionally frommemchr_specandmemrchr_spec:The converse direction is symmetric. Lean accepted all three implementations and all four proofs without
sorryor custom axioms.Q4. Generalizability to other formal languages (e.g., Rust/Verus)
The scheduling principle is not tied to dependent types; only the contents of the shared proof sketch are verifier-specific. In Rust/Verus, the plan would pair the Rust control and data structures with preconditions, postconditions, loop invariants, decreases clauses, ghost state, and SMT-facing auxiliary lemmas. Code and annotations would then be elaborated under this plan: local verifier errors could be repaired in place, whereas failures that invalidate the shared invariant or decomposition would trigger replanning. Dafny admits an analogous mapping. We will add this concrete discussion, while making clear that transfer beyond Lean remains a hypothesis requiring empirical validation.