TL;DR
SkillForge is a novel framework that replaces open-ended, expensive LLM agents with a deterministic "harness" to generate formally verified code. By decomposing code synthesis into atomic, reusable skills and routing errors directly to specialized repair functions, it achieves a 91.6% verification rate in Dafny while drastically reducing token costs and latency.
What Problem Does This Paper Address?
Writing formally verified software—where a machine checks a mathematical proof ensuring the code matches its specification—is notoriously difficult. Languages like Dafny require developers to simultaneously write correct code, tight specifications (preconditions and postconditions), and auxiliary annotations like loop invariants.
While Large Language Models (LLMs) are great at writing standard code, they struggle with formal verification. Current approaches fall into two traps:
- Naive iterative repair: Feeding raw compiler/verifier error messages back to the LLM, which often causes the model to oscillate or introduce new bugs.
- Open-ended agentic reasoning (e.g., ReAct, MCTS): Allowing the LLM to decide its next action autonomously. While flexible, this is non-deterministic, opaque, and incredibly expensive, often wasting compute on trial-and-error exploration in a domain where errors are actually well-categorized.
Methods
Instead of building a flexible but chaotic "agent," the authors engineer a rigid, deterministic verification-driven harness called SkillForge.
The framework breaks down the code generation and repair process into six discrete, atomic skills, each with a clear input/output contract and a decidable success criterion:
The core magic lies in the orchestration:
- Initial Synthesis:
INFERSPECextracts the specification scaffold from natural language, andSYNTHBODYgenerates the code. Crucially, the prompt anchors the specification, forbidding the LLM from weakening the rules just to make verification easy. - Error-Conditioned Routing: If verification fails,
DIAGNOSEERRORcategorizes the failure (e.g., missing invariant vs. logic error). The harness then uses a deterministic mapping to route the code to the exact skill needed for repair (e.g., routing aninvariant_missingerror straight toGENINVARIANT).
Datasets
The authors evaluated SkillForge on a curated benchmark of 178 natural language–Dafny specification pairs compiled from three sources:
- Dafny Standard Library (42 examples): Official tutorials and exercises.
- DafnyBench (86 examples): Mathematical reasoning and quantified logic tasks.
- Open-source verification projects (50 examples): Real-world GitHub repositories.
The benchmark is stratified into three difficulty levels: Simple (no loops/recursion), Medium (recursive definitions, multi-clause specs), and Hard (loops requiring user-written invariants and termination measures).
Key Insights and Ideas
- Structure Beats Flexibility: In formal verification, the error space is finite and the oracle (the verifier) is perfect. Open-ended reasoning is a bug, not a feature. Deterministic routing based on structured verifier feedback eliminates the trial-and-error overhead of traditional agents.
- Specification Anchoring is Vital: LLMs love to cheat. If allowed, they will weaken a program's postconditions so that even empty or broken code "verifies." Separating specification inference from body synthesis prevents this failure mode.
- Test-Time Compute Efficiency: SkillForge shows that structuring test-time compute (structuring how the model iterates) yields better results than simply scaling up unstructured search methods like Monte Carlo Tree Search (MCTS).
Key Results
SkillForge significantly outperformed all traditional and agentic baselines using GPT-5.5 as the backend:
- Highest Verification Rate: It achieved an overall 91.6% verification rate, outperforming the strongest agentic baseline, Proof2Silicon (85.4%), and crushing naive repair (73.6%).
- Widening the Gap on Hard Tasks: On the toughest problems requiring loop invariants, SkillForge achieved a 77.8% success rate, beating the best agent by 13.4 percentage points.
- Rapid Convergence: 71.3% of the programs were verified on the very first pass. When errors did occur, the harness resolved them quickly, averaging just 1.8 iterations overall.
- Massive Cost Savings: Because it avoids open-ended reasoning loops, SkillForge used 48% fewer tokens than ReAct-Verify and 68% fewer tokens than MCTS-Repair, while operating with significantly lower latency.
Limitations and Future Work
While highly effective, SkillForge has a few notable limitations:
- Complex Inductive Proofs: The framework still struggles with lemmas requiring non-trivial induction over recursive data structures (accounting for 7 of its 15 failures).
- Language Specificity: The current skill library is tightly coupled to Dafny's syntax and error taxonomy. Adapting it to other interactive theorem provers like Lean 4 or Coq would require re-engineering the error parser and skill templates.
- Hand-Crafted Templates: The prompt templates are currently hand-written; exploring automatic skill discovery and refinement remains an open area for future research.
Summary updated