When a language model is asked to write verified code, it has to produce three things. It writes the program, it writes a formal specification (a precise logical statement of what the program must do), and it writes a machine-checked proof that the program meets that specification. Current agents fail in a revealing way. They do not mainly fail to prove things. They write specifications that are too weak to be worth proving. On VeriBench, compiler-feedback retries raise overall scores by about 14.3%, yet theorem coverage, which measures how much of the intended behavior the proved statements actually capture, stays at or below 0.11 (VeriBench). The proof checker cannot catch this, because a trivially true statement is perfectly provable. We propose a two-agent debate over the specification, with one hard rule: an agent may object only by producing a concrete witness. A witness is an input-output pair or execution trace that the specification allows but the reference model forbids, or one that the specification forbids but the reference model allows. The witness is checked mechanically before it counts. The specification may be edited only to fix a checked witness, and every accepted witness joins a permanent regression suite that later edits must not break.
The design treats specification writing as a form of model-to-logic translation. A reference model, such as a Python program, a reference implementation with tests, or an executable state machine, is compiled into a logical statement. The design uses debate only where debate can be kept honest, and it runs iterative code and proof refinement afterward, against a specification that has already survived attack. The central bet is that most known failures of LLM debate come from arguments nobody checks. These failures include false consensus, scope creep, and the collapse of quality after two or three rounds. If every move must carry a checked witness, those failures should mostly disappear.
Core Claim
Our claim is that a refuter agent whose only allowed move is a mechanically checked witness will produce specifications with substantially higher coverage of intended behavior than three alternatives: single-agent verifier feedback, natural-language debate, and automated mutation testing of specifications. We make this claim at matched compute. Two further predictions follow, and both are falsifiable. First, specification quality should rise or stay flat as the number of debate rounds grows. It should not peak at two or three rounds and then fall, as it does in MAD-Logic. Second, the stronger specifications should raise end-to-end verified-code success, and should not merely make proofs harder. If the second prediction fails, we will report that stronger specifications merely shift the bottleneck to proving, which is itself a useful negative result.
Where This Sits in Prior Work
Two lines of work motivate the gap. The Lean 4 benchmarks show that single-agent iteration stalls. VERINA reports o3 reaching 52.3% pass@1 on specification generation and only 3.2% end to end, with 64 rounds of compiler feedback lifting proofs to about 20% while models loop on the same failed attempts ("thrashing"). Vero shows agents committing to their first implementation and even downgrading algorithms to ones that are easier to prove. VeriBench isolates the specification gap directly. Independently, the failure taxonomy in Why Do Multi-Agent LLM Systems Fail? attributes 23.5% of failures to verification that checks shallow properties rather than the actual task, and finds that adding high-level task verification helps coding by 15.6%. Our witness check is a concrete, mechanical form of that high-level verification.
Two debate systems are the closest existing work, and both leave open exactly what we target. MAD-Logic has agents debate translations of logic puzzles into solver languages, and it prunes messages with a confidence-based score. Its debate content is still unchecked argument, and it finds that quality degrades past 2–3 rounds. We replace persuasion with witnesses and test whether that degradation is really caused by unchecked argument. Adversarial Review structures a Reviewer–Critic debate with typed moves such as DISAGREE_EVIDENCE. In that system, evidence means citing code lines, which an agent can still misread, and the authors report scope creep, where speculative objections lead to over-engineered patches. We keep their frozen-artifact inner loop, in which the artifact is not edited while the agents argue. We then tighten "evidence" to something the machine decides.
Other work supplies the method. LLM-Vectorizer shows that a formal checker (Alive2) can serve as the non-negotiable arbiter in an LLM loop, turning 24 single-shot failures into correct vectorizations. It uses a fixed pipeline, not an adversary searching for weaknesses. The Simulink study in Evaluating model testing and model checking for finding requirements violations in Simulink models finds that concrete testing uncovered 17 violations that model checking missed. This is the reason our witnesses are concrete executions rather than symbolic claims. Hand-built translators such as RoboTool (Formal design, verification and implementation of robotic controller software via RoboChart and RoboTool) are precise but only accept their own modeling languages, and they cannot repair a specification. We do not try to replace them. They show what a trusted translation looks like, and our pilot uses a machine-checked executable semantics (Machine-Checked Executable Semantics of Stateflow) as the witness oracle for state-machine models.
Some prior work constrains the design. SlopCodeBench finds that iterative agent edits bloat and erode code in about three quarters of trajectories. This is why edits are gated: a change is accepted only if it fixes a witness and keeps the regression suite passing. We also measure whether specifications bloat anyway. A Diagnostic Study of Multi-Agent LLMs for Real-World Debates shows that consensus is a poor proxy for correctness. We therefore never use agreement as a stopping signal. Debate ends when the refuter fails to produce a valid witness within a budget.
Research Program
The system has two roles and an arbiter. The translator reads the reference model and writes a Lean 4 precondition and postcondition. The refuter reads the specification and the reference model, and it has tool access to an evaluator and to a mutation engine. It proposes witnesses of two kinds. A soundness witness is an input and output that the specification rejects but the reference model produces. A completeness witness is an input and wrong output that the specification accepts.
The arbiter is deterministic code. It runs the reference model on the input and evaluates the Lean specification on the concrete values. It uses decide or evaluation where the specification is decidable, and otherwise a bounded attempt with standard automation, such as simp and omega, to prove or disprove the concrete instance. A witness it cannot decide is rejected as inconclusive. We will report this rate, because a high rate would mean the method only works on decidable specification fragments.
Accepted witnesses enter a ledger. The translator may edit the specification only to fix the current witness while passing all prior ones. A refuter turn that produces no valid witness ends the specification phase. After that, standard iterative code and proof refinement runs against the frozen specification. The ledger is also available to the prover as test cases.
The key analysis separates what the refuter finds from what cheap mutants find. We tag each accepted witness by whether a random output mutation on an existing test input would have exposed the same weakness. If nearly all witnesses are of that kind, the debate is unnecessary. The pilot extension applies the same loop to Stateflow charts, translated into temporal properties, with witnesses given as simulated traces under the executable semantics. No benchmark in our file reports numbers for this setting, so it is exploratory.
Baselines
The naive reference point is single-shot specification generation with the same base model, with no feedback. For calibration, VERINA reports o3 at 52.3% pass@1 on its SpecGen task and 3.2% end to end. We rerun this baseline with our own base model rather than borrowing those figures.
The strongest existing single-agent method is iterative self-correction with verifier feedback and access to the visible tests, which is the regime VeriBench evaluates. There, Codex (GPT-5.4) leads with an SCSC of 0.417, the benchmark's combined score of consistency, proof completeness and coverage. Retries add about 14.3%, while theorem coverage stays at or below 0.11. It is the strongest competitor because it already uses a checker and tests, so any gain we show must come from the adversarial search itself. Beating it means a statistically reliable improvement in theorem coverage and held-out specification soundness and completeness at equal token budget, without lower proof completeness.
The strongest debate baseline is a reimplementation of Adversarial Review's Reviewer–Critic protocol with typed natural-language objections. It is adapted to specifications, with the same model and budget. Adversarial Review reports 87% on LiveCodeBench and 75.2% on SWE-bench Verified, versus 82% and 72.6% for a five-agent round-table. We found no reported result on Lacuna for Adversarial Review or MAD-Logic on Lean specification benchmarks, so both are run by us. MAD-Logic's multi-translation debate with sparse communication is the second debate baseline.
Mutation-only specification checking is the most dangerous baseline. It uses the same arbiter and ledger, but witnesses come purely from automated output mutations and input fuzzing, with no LLM refuter. We found no reported result on Lacuna for this.
Two ablations isolate the key ingredient. In the first, the refuter's witnesses are passed to the translator without being checked. In the second, witnesses are checked but there is no ledger. The first isolates mechanical grounding and the second isolates the anti-thrashing rule.
For fairness, all systems share the base model, the prompts' task text, the visible and held-out test split, a fixed token budget per task, and the same number of tuning runs on a development slice.
Why not just…?
Why not just give a single agent the tests and verifier feedback? This is what the Lean benchmarks already measure, and it is where the coverage gap was found. VeriBench's retries improve consistency but leave theorem coverage at or below 0.11. VERINA's 64-round loop thrashes. A single agent writing its own specification has no incentive to make it harder to satisfy. The compute-matched single-agent baseline tests this directly. If it matches the refuter at equal tokens, the adversarial role adds nothing.
Why not just mutation-test the specifications automatically? This is a real threat, and it could plausibly capture most of the benefit on simple tasks, since many weak postconditions are exposed by perturbing one output. Our bet is that the important weaknesses concern inputs outside the visible tests, such as empty collections, duplicates and boundary values. A refuter that reads the specification's structure can target these, and blind fuzzing reaches them rarely. For this reason the refuter is given the mutation engine as a tool rather than competing with it. The witness-tagging analysis will show what fraction of accepted witnesses mutation alone would have found. If that fraction is near one, we will report mutation testing as the recommended method.
Why not just use an existing debate protocol like Adversarial Review or MAD-Logic? Both let agents win arguments with claims that are never executed. Adversarial Review reports scope creep, and MAD-Logic reports degradation past 2–3 rounds. The unchecked-witness ablation and the rounds-versus-quality curve test whether mechanical checking is what removes these failures. If natural-language debate keeps pace, our explanation is wrong.
Why not just use a hand-built translator? Where one exists, as with RoboTool for RoboChart or HHLPy for Simulink, the translation itself should be trusted over an LLM. Such tools do not address specifications written from informal intent or ordinary code, which is the setting of VERINA and VeriBench. They also offer no repair path when the specification is wrong. Our Stateflow pilot uses the trusted semantics as the arbiter, not as a competitor.
Proposed Experiments
The primary benchmarks are VERINA's 189 Lean tasks (dataset) and VeriBench's 896 tasks, including its 282-task IndustrySet. Reference tests are split into a visible set, which the arbiter uses, and a held-out set, which is used only for evaluation. This keeps the refuter from overfitting the metric. Metrics are VERINA SpecGen soundness and completeness on held-out tests, VeriBench SCSC and theorem coverage against human reference theorems, and end-to-end verified-code success. We also track specification length, to test for the kind of bloat SlopCodeBench reports, the rate of inconclusive witnesses, and cost per solved task.
Three checks are decisive. The first is whether the witness-only refuter beats verifier-feedback self-correction on theorem coverage at matched tokens. The second is whether the rounds-versus-quality curve stays monotone where natural-language debate peaks at 2–3 rounds. The third is whether its witnesses include a substantial share that mutation testing cannot find. A secondary check is whether end-to-end success rises rather than falls once specifications are strengthened. Finally, the Stateflow pilot asks whether the same loop transfers to state-machine models when trace simulation serves as the arbiter.
References
- VeriBench: An End-to-End Formal Verification Benchmark for AI Coding Agents in Lean 4
- MAD-Logic: Multi-Agent Debate Enhances Symbolic Translation and Reasoning
- VERINA: Benchmarking Verifiable Code Generation
- Vero: Can AI Agents Build Formally Verified Software Repositories?
- Why Do Multi-Agent LLM Systems Fail?
- Adversarial Review: Structured Disagreement for Grounded Agentic Code Review
- LLM-Vectorizer: LLM-Based Verified Loop Vectorizer
- Evaluating model testing and model checking for finding requirements violations in Simulink models
- Formal design, verification and implementation of robotic controller software via RoboChart and RoboTool
- Machine-Checked Executable Semantics of Stateflow
- SlopCodeBench: Measuring Code Erosion Under Iterative Specification Refinement
- A Diagnostic Study of Multi-Agent LLMs for Real-World Debates