Self-Spec Verifiable Code Generation
Jiaru Qian, Yihong Dong, Yongmin Li, Hao Zhu, Bin Gu, Ge Li
Key points
From the paper's conclusion- We introduce VeriCodeBench, a benchmark for self-spec verifiable code generation, where the LLM relies solely on its own generated specification and code throughout the entire process.
- VeriCodeBench contains 400 language-native problems across C, Java, Rust, and Python, covering practical concerns in software development.
- Experimental results reveal that self-generated specifications remain a major bottleneck, while CodeNova substantially improves performance across all evaluation metrics, enabling Claude Sonnet 5 to achieve the strongest results under the self-spec protocol.
Abstract
Large language models (LLMs) may generate unreliable code on corner cases missed by testing, while formal verification can provide machine-checkable guarantees. Recently, researchers have proposed several benchmarks to evaluate the capabilities of LLMs in generating formally verifiable code, where LLMs need to formulate formal specifications, generate the corresponding code, and verify its correctness. However, existing benchmarks have two key limitations: (I) They primarily evaluate specification and code generation stage-wise, with code generation typically conditioned on an oracle specification. This setup overlooks whether strong stage-wise performance translates into end-to-end success. (II)They mainly focus on a single proof-oriented language and mathematically structured tasks, offering limited coverage of tasks common in software development. In this paper, we introduce VeriCodeBench, a benchmark for self-spec verifiable code generation, where the LLM relies solely on its own generated specification and code throughout the entire process. VeriCodeBench contains 400 language-native problems across C, Java, Rust, and Python, covering practical concerns in software development. We evaluate specification coverage, code validity, and joint problem-level success. We further introduce CodeNova to enhance the capabilities of LLMs in self-spec verifiable code generation. CodeNova makes requirements explicit through constraint-guided specification and uses verifier feedback to guide targeted implementation repairs. Experimental results reveal that self-generated specifications remain a major bottleneck, while providing more sophisticated specifications may not necessarily lead to higher verification success rates. CodeNova substantially improves performance across all evaluation metrics, enabling Claude Sonnet 5 to achieve the strongest results under the self-spec protocol.
Read the paper
Discussion · 1
Science Skim's AI key points, plus readers' public thoughts
- We introduce VeriCodeBench, a benchmark for self-spec verifiable code generation, where the LLM relies solely on its own generated specification and code throughout the entire process.
- VeriCodeBench contains 400 language-native problems across C, Java, Rust, and Python, covering practical concerns in software development.
- Experimental results reveal that self-generated specifications remain a major bottleneck, while CodeNova substantially improves performance across all evaluation metrics, enabling Claude Sonnet 5 to achieve the strongest results under the self-spec protocol.
Readers' thoughts
No reader thoughts yet.
Related papers
- Beyond Type-checking: Towards Holistic Evaluation of Formal Specification GenerationarXiv · 2026
- Are LLM-Generated Formal Specifications Faithful to Their Requirements? A Study on Bimodal Formal Specification GenerationarXiv · 2026
- Verified but Vacuous: Three Failure Surfaces of LLM-Driven Verified Code GenerationarXiv · 2026
- From Natural Language to Verified C: Verification-Guided Generation with ACSL SpecificationsarXiv · 2026
- SPARK: Semantic-preserving Prompt Mutation for Code Generation using Consensus-based Verification FrameworkarXiv · 2026
- Path2Spec: Path-Aware Specification Generation via Large Language ModelsarXiv · 2026