AI 程式開發與形式驗證
CAPRI Adds Editing Contracts to Isabelle Proof Repair, Catching 6 Buildable but Unauthorized Candidates
CAPRI separates “the proof is accepted by Isabelle” from “the model modified only authorized regions” into two independent checks. Across 180 repair experiments, 6 of 144 buildable candidates altered protected text; no further violations occurred after the model was restricted to returning only the proof body.

A successful proof-assistant build does not mean that an AI completed the task it was assigned: a model can weaken a theorem, add assumptions that happen to imply the conclusion, or even delete nearby obligations, while still having Isabelle correctly accept the modified theory. CAPRI therefore treats the model as an untrusted source of patches, using Isabelle to verify the proof and an independent checker to validate modification permissions against a machine-readable contract. A candidate counts as successful only if it satisfies both `Build` and `Conforms`.
The contract specifies the editable files and regions, the target declaration, the Isabelle version, and the session, while prohibiting commands such as `sorry`, `oops`, `axiomatization`, and `oracle`. For protected content outside the proof body, the checker enforces a strict byte-for-byte frame condition and also rejects unauthorized file additions or deletions. For every proposal, the controller applies it to a fresh copy of the original repository and preserves the prompt, model output, candidate tree, Isabelle diagnostics, contract verdict, token counts, and SHA-256 manifest. Recorded proposals can be replayed without calling the hosted model again.
The study covered 12 failing proofs across four Isabelle developments, five workflows, and three repetitions per problem, for a total of 180 runs. Of the terminal candidates, 144 passed Isabelle, but 6 modified protected text; all six came from iterative workflows allowed to edit the entire theory. An interface that permitted only the proof body to be returned produced 29 valid repairs out of 36, slightly fewer than the 31 out of 36 achieved with full-theory editing, but reduced violations from six to zero. The one-shot workflow achieved 22 out of 36, while an iterative workflow with subsequently frozen settings reached 32 out of 36.
The results remind developers of agentic tools that tests or formal proofs can validate an artifact, but cannot by themselves define an agent’s modification authority. The complete set of 180 experiments and exploratory data has been deposited on [Zenodo](https://doi.org/10.5281/zenodo.21917680). However, the benchmark contains only 12 problems, relies primarily on a single hosted model, and does not formally verify the contract checker itself. Although the strict byte-for-byte policy is easy to audit, it also rejects harmless formatting changes.