Introduction
Formal verification represents the "gold standard" of software reliability, replacing traditional testing with mathematical proofs that guarantee a program's correctness. However, the manual effort required to write these proofs in specialized languages like Verus—a verification-aware extension of Rust—is immense. While Large Language Models (LLMs) have shown promise in automating code generation, their application to formal verification has largely been confined to "function-level" tasks: small, self-contained snippets of code. This paper addresses the critical gap between isolated function verification and the reality of complex, interconnected software repositories.
The Challenge of Repository-Level Verification
Real-world software is rarely self-contained; it is organized into repositories with intricate webs of dependencies. To verify a single function, a developer (or an LLM) must often understand custom data types defined in distant modules or invoke specific "lemmas" (helper proofs) located elsewhere in the codebase. Existing LLM-based verification tools are often "myopic," failing because they lack this global context. When a model cannot see the necessary cross-module dependencies, it cannot satisfy the rigorous requirements of the Verus compiler.
RVBench: A New Standard for Evaluation
To facilitate research in this area, the authors introduced RVBench, the first benchmark specifically designed for repository-level formal verification. RVBench consists of 755 proof-completion tasks derived from four award-winning open-source Verus projects:
- VeriSMo: A security module for virtual machines.
- Anvil: A framework for verifying Kubernetes controllers.
- IronKV: A distributed key-value store.
- Vest: High-performance binary data parsers.
Tasks within RVBench are categorized into "Simple" (requiring only local context) and "Complex" (requiring cross-module dependencies), providing a granular look at where current models succeed and fail.
RagVerus: Context-Aware Proof Generation
To tackle the complexities of RVBench, the authors developed RagVerus, a framework that utilizes Retrieval-Augmented Generation (RAG) to provide LLMs with the necessary repository-wide context. The system operates through three primary stages:
- Code & Metadata Indexing: RagVerus indexes the codebase using both raw code and "informalized" natural language summaries. For example, a complex mathematical function might be indexed with the summary: "This function computes a SHA-256 hash."
- Hybrid Retrieval: When generating a proof, the system retrieves two types of information: few-shot examples to demonstrate the project's specific proof style, and dependency hints containing the signatures and types required for the logic.
- Iterative Refinement: If the initial proof attempt fails the Verus compiler check, RagVerus uses the resulting error messages to iteratively repair the code, mimicking a human developer's workflow.
Key Findings and Insights
The Semantic Gap
The research highlights a "Semantic Gap" in automated verification: raw code similarity does not always correlate with proof similarity. Two functions may appear syntactically similar but require vastly different logical proofs. The authors found that "informalization"—converting code into natural language summaries—significantly improved retrieval by helping the LLM identify functionally analogous examples that raw code search might miss.
Premise Selection as a Bottleneck
In repository-level verification, the primary difficulty is often not writing the logic itself, but "premise selection"—knowing which external lemmas or functions to call. RagVerus addresses this by explicitly retrieving cross-module signatures, which proved vital for solving "Complex" tasks.
Performance Evaluation
RagVerus demonstrated significant improvements over existing baselines:
- VerusBench: On existing function-level benchmarks, RagVerus tripled the proof pass rates compared to standard baselines under constrained inference budgets.
- RVBench: On the more challenging repository-level tasks, RagVerus achieved a 27% relative improvement over state-of-the-art methods like AutoVerus.
- Efficiency: By providing high-quality context upfront, the framework is more sample-efficient, requiring fewer attempts to reach a valid proof.
Future Directions
Despite these advancements, "Complex" tasks remain a formidable challenge, with success rates often hovering below 20%. The authors identify several hurdles for future research:
- Proof Length: Real-world proofs can exceed 80 lines of dense logical annotations, often surpassing the reasoning limits of current LLMs.
- Context Window Limits: Even with RAG, the total pool of necessary premises for a massive system can exceed standard prompt limits.
- Multi-step Reasoning: Future systems must move beyond single-function completion toward synthesizing proofs across multiple interdependent modules simultaneously.
Summary updated