Formal-Verification-RSI (Millennium Harness)
A Lean 4 and Dafny proof checker that rejects fake AI-written proofs and supports verified recursive self-improvement for coding agents.
At a Glance
Self-hosted Millennium Harness / Formal-Verification-RSI core released under the MIT license. Free to use, copy, modify and distribute.
Engagement
Available On
Alternatives
Listed Dec 2026
About Formal-Verification-RSI (Millennium Harness)
Formal-Verification-RSI is an open-source project by sahibzada-allahyar that provides Millennium Harness, a model-free gate for checking AI-written Lean 4 and Dafny solutions. It accepts a solution only if the frozen specification kept its meaning and was proved with no escape hatch. The repository also includes Millennium RSI, an agent loop that improves its own harness and keeps changes only when more held-out proofs are certified.
What It Is
Millennium Harness is a verification gate aimed at reward hacking in AI-generated formal proofs. The README describes weaknesses in common checks: Lean accepts sorry with only a warning, Dafny reports 0 errors for assume {:axiom} false, and a solution can leave the specification text untouched while changing its meaning. The harness locks a task's frozen statements and tests, then checks submitted solutions against them and returns a JSON verdict: PROVED, UNPROVED, CHEAT_REJECTED, SPEC_TAMPERED or CHECK_ERROR. The verdict's feedback field is the message shown to an agent.
How the checks work
For Lean, the checker inspects the compiled environment. It compares statements after elaboration, checks axioms against a whitelist, looks for instances and notation reaching frozen declarations, detects compiled-code swaps such as implemented_by and extern, flags code run at elaboration time, and replays the kernel. For Dafny, it requires the frozen specification to resolve unchanged on its own and rejects assume, {:axiom}, bodiless lemmas with ensures, disallowed attributes and captured specification helpers. It then runs dafny audit and a compile check.
Agent loops and Millennium RSI
Benchmark scripts run OpenCode or Claude Code in a sandbox with the gate. When the agent stops, the checker runs, and a failing verdict becomes the next prompt. Plugins for OpenCode and Claude Code are included in the adapters folder.
Millennium RSI treats the harness, a strategy plus a lemma library, as data. Each proposed lemma is kernel-checked before admission. A child harness is scored only on proofs of unchanged statements. An --reward exit0 ablation runs the same loop on the usual exit-code criterion and records how many accepted proofs are fake.
Reported results
The author reports that an audit of 4,219 AI-written solutions published as verified by vericoding found at least 93 fake ones, and that the harness rejects all 69 confirmed fakes. In a 96-cheat red-team suite written alongside the checker, it accepted none of the cheats and all 25 honest solutions. In an agent study with OpenCode and GLM-5.3 Flash, honest proofs rose from 41% to 56% across 93 tasks. The README notes that the red-team suite was written alongside the checker and that gains were 0 to 2 tasks with other models.
Setup path
It requires Python 3.10+ and pinned toolchains: Lean v4.23.0-rc2 via elan and/or Dafny 4.11. Install with pip install -e ".[dev]" after cloning. The checkers make no model calls, while model-driven runs need an OPENROUTER_API_KEY or ANTHROPIC_API_KEY.
Collections
Popular collections
- Local-First Databases
Collection by @joemseifi
- Team of Agents
Collection by @joemseifi
- Pick Up Where Your Agent Left Off
Collection by @caiovalverde
- Read Your Agent's Code Before You Merge
Collection by @presscheck
Add Formal-Verification-RSI (Millennium Harness) to one of your collections.
Community Discussions
Be the first to start a conversation about Formal-Verification-RSI (Millennium Harness)
Share your experience with Formal-Verification-RSI (Millennium Harness), ask questions, or help others learn from your insights.
Pricing
Open Source (MIT)
Self-hosted Millennium Harness / Formal-Verification-RSI core released under the MIT license. Free to use, copy, modify and distribute.
- MIT license (OSI-approved)
- Lean 4 and Dafny proof checker that rejects fake AI proofs
- Millennium RSI agent for verified recursive self-improvement
- Requires Python 3.10+ and Lean v4.23.0-rc2 and/or Dafny 4.11
- Model calls need user's own OPENROUTER_API_KEY or ANTHROPIC_API_KEY (external cost)
Capabilities
Key Features
- Lean 4 checker that detects sorry, spec tampering, shadowing instances, banned axioms and compiled-code swaps
- Dafny checker that rejects assume, {:axiom}, bodiless lemmas and disallowed attributes
- Freezing of task specifications and kernel replay
- JSON verdicts with feedback that is fed back to agents
- Agent-loop gating for OpenCode and Claude Code
- Millennium RSI self-improving harness with kernel-checked lemma admission
- Exit-code reward ablation to measure fake proofs
- Reproducible benchmark audit, red-team and agent study pipelines
