{"slug": "show-hn-qed-turn-claude-code-into-a-math-researcher-with-a-formal-toolchain", "title": "Show HN: QED – turn Claude Code into a math researcher with a formal toolchain", "summary": "A developer released QED v0.2, an npm package named qed-agents that turns coding agents such as Claude Code into math researchers by combining counterexample search, Lean 4 proof writing, and a six-gate audit. The toolchain pins Lean v4.36.0 and Mathlib v4.36.0, requires Python 3.9 or later and Node.js 18 or later for the npm route, and needs about 3 GB for Lean plus 2.6 GB for Mathlib.Tactic, or about 7 GB for the full Mathlib cache under the --profile full option. In one archived run, Codex CLI reached an ACCEPTED verdict in 40 minutes on the shifted lonely runner problem (k = 4) with bound 1/5, a result proved by Alcántara, Criado, and Santos in June 2025 (arXiv:2506.13379) but absent from the pinned Mathlib.", "body_md": "**Give your coding agent a conjecture. With QED, it searches for counterexamples, writes a Lean 4 proof, and hands you an audit you can rerun.**\n\nQED pairs a stdlib-only CLI with three Markdown skills. Its installer has eight targets, including one shared skill directory. The [host support matrix](https://github.com/ObservedObserver/QED/blob/main/docs/hosts.md) records the evidence for each.\nWorkspaces share a precompiled Mathlib cache. Builds run with memory limits, a six-gate audit checks the proof, and the LaTeX manuscript identifies which statements Lean verified.\n\n**v0.2** · npm package `qed-agents`. The CI workflow checks Linux (` ubuntu-latest`) and macOS (Apple silicon) with Lean `v4.36.0`. Research workspaces pin Mathlib to `v4.36.0`.\n\nUse macOS or Linux, or WSL2 on Windows. Setup needs Git, curl and Python 3.9 or later. The npm route also needs Node.js 18 or later.\n\n```\nnpx qed-agents setup --dry-run\nnpx qed-agents setup\n```\n\nThe Quick profile is the default. Allow about 3 GB for Lean and 2.6 GB for `Mathlib.Tactic` and its imports.\nFor the full Mathlib cache, allow about 7 GB for the cache and select `--profile full`. Use `--yes` to accept the defaults without prompts.\n\nSetup registers skills for detected hosts, prepares SymPy and a Unicode LaTeX engine, and runs a Mathlib smoke build.\nThe npm bootstrap installs a persistent runtime in `~/.qed/app`, linking `~/.local/bin/qed` (unless another working `qed` is already on `PATH`) and providing a fallback at `~/.qed/bin/qed`.\nYou can also install globally with `npm install -g qed-agents && qed setup`. Open a fresh host session after setup.\n\n**Claude Code plugin.** Tested with Claude Code 2.1.332 against `ObservedObserver/QED` on GitHub.\nThe second command installs the CLI and toolchain while Claude manages the skills.\n\n```\nclaude plugin install qed --marketplace ObservedObserver/QED\nnpx -y qed-agents@latest setup --skip agents\n```\n\nFor other hosts, the Node-free archive, cache management and uninstall instructions, see the [host guide and support matrix](https://github.com/ObservedObserver/QED/blob/main/docs/hosts.md).\n\nUse the qed-research skill. Prove that for every natural number n ≥ 4, 2·n! < nⁿ. Give me the locked Lean statement, the final audit and a PDF.\n\n```\n# 1. Create the workspace and test the inequality without its lower bound.\nqed init --problem \"For every natural number n >= 4, 2 * n! < n^n.\"\ncd .math-research\nqed falsify --forall \"n=range(1,60)\" --claim \"2*factorial(n) < n**n\" --label \"all n\"\n\n# 2. Write Research.two_mul_factorial_lt in lean/Research/Basic.lean with\n#    proof 'sorry'. Review its quantifiers and hypotheses, then lock it.\nqed lock -t Research.two_mul_factorial_lt\n\n# 3. Look up candidate lemmas and replace 'sorry' with a Lean proof.\nqed search factorial lt pow\nqed search --check Nat.pow_succ\n\n# 4. Clean-build the project and save the verdict beside the workspace record.\nqed audit --report-dir verdicts/final\n\n# 5. After ACCEPTED, scaffold the paper, fill in paper/sections/, then build.\nqed paper init\nqed paper build\n```\n\nThe first check finds failures at `n = 1` and `n = 2`. Both lie outside the proposed theorem's domain.\n\nGiven a problem statement, a full QED run leaves locked Lean targets, a ledger of kernel-verified lemmas, an independent audit report, and a LaTeX manuscript whose verification badges and Appendix A are generated directly from `qed audit`.\n\nBeyond the [kite-lemma manuscript](https://github.com/ObservedObserver/QED/blob/main/examples/kite-lemma/qed-run/paper/paper.pdf) shown above, three archived runs illustrate how QED behaves across proved, refuted, and open-ceiling targets:\n\n- **Shifted lonely runner (`k = 4`), bound `1/5`.** Four runners move around a unit circle at distinct positive integer speeds; is there a time when all four are at least`1/5` of a turn from zero? Alcántara, Criado, and Santos proved this in June 2025 ([arXiv:2506.13379](https://arxiv.org/abs/2506.13379) ), absent from the pinned Mathlib. Codex CLI reached`ACCEPTED` in 40 minutes using the partial`Mathlib.Tactic` cache across a 28-module project, with`leanchecker` replaying all 27 declaration-bearing modules in a fresh kernel.[Problem](https://github.com/ObservedObserver/QED/blob/main/examples/shifted-lonely-runner-k4/problem.md) ·[Audit](https://github.com/ObservedObserver/QED/blob/main/examples/shifted-lonely-runner-k4/verdicts/final/audit.md) ·[JSON](https://github.com/ObservedObserver/QED/blob/main/examples/shifted-lonely-runner-k4/verdicts/final/audit.json)\n- **Stronger bound, `0.21`.** A Python falsification check found a counterexample in 0.03 s for speeds`(1, 2, 3, 4)` at radius`1/5 + 1/100` . The ledger records the Python result as an excluded dead end.[Falsify log](https://github.com/ObservedObserver/QED/blob/main/examples/shifted-lonely-runner-k4/falsify/003-stronger-radius.json) ·[Ledger](https://github.com/ObservedObserver/QED/blob/main/examples/shifted-lonely-runner-k4/verified_ledger.md)\n- **An unfinished theorem.** On the main theorem of a 47-page edge-reconstruction paper, both a plain agent and QED stopped honestly. QED's audit returned`REJECTED` :`source_scan` and`kernel_sorry` both failed. The run left a locked target and 20 kernel-verified lemmas.[Experiment](https://github.com/ObservedObserver/QED/blob/main/examples/edge-reconstruction-ceiling) ·[Rejected audit](https://github.com/ObservedObserver/QED/blob/main/examples/edge-reconstruction-ceiling/qed-run/verdicts/final/audit.md) ·[Ledger](https://github.com/ObservedObserver/QED/blob/main/examples/edge-reconstruction-ceiling/qed-run/verified_ledger.md)\n\n**Overhead.** On an approachable lemma with Lean already installed, QED took ~10× the plain agent's time and ~15× its tokens. [When is QED worth the overhead?](#when-is-qed-worth-the-overhead)\n\nAfter setup, clone the repository to get the example sources and rerun the first audit. The npm package omits `examples/`.\n\n```\ngit clone https://github.com/ObservedObserver/QED.git && cd QED\nqed link examples/shifted-lonely-runner-k4/lean\nqed audit --project examples/shifted-lonely-runner-k4/lean\n```\n\nFour things can go wrong before anyone reads a proof:\n\n1. A prose argument skips a case that Lean would require.\n2. A missing import starts a multi-hour Mathlib build.\n3. Parallel Lean processes exhaust the machine's memory.\n4. A project compiles with a placeholder, a new axiom or a weaker statement.\n\nThe CLI checks these conditions on disk and emits machine-readable reports. Three Markdown skills tell the agent when to falsify, lock, review, audit and write.\nThe research loop follows *Cogentic*'s division of work among provers and adversarial reviewers ([Cogentic paper](https://arxiv.org/abs/2609.40324)), adding Python counterexample checks and Lean kernel verification across a hard boundary between unverified exploration and machine-checked evidence.\n\nWorkspaces symlink their Lake packages to a single Lean base. QED checks for precompiled imports before building a project. A workspace costs megabytes beyond the shared cache.\n\nQED sets Lean's `-M` heap limit from host RAM, bounds build concurrency and monitors process-group RSS.\nA per-project lock serializes competing builds. Ledger admission rebuilds and replays the target lemma's import closure, so unfinished siblings can stay on disk.\n\nA clean build alone can accept `sorry`. The default audit requires all six checks.\n\n| Gate | What passes | \n|---|---|\n| `source_scan` | Project sources contain no forbidden constructs such as `sorry` ,`admit` ,`axiom` or`native_decide` . | \n| `build` | Every project module compiles from a clean state using cached dependencies. | \n| `kernel_sorry` | The kernel axiom closure contains no `sorryAx` . | \n| `axioms` | Only `propext` ,`Classical.choice` and`Quot.sound` are permitted (`sorryAx` is reported separately by`kernel_sorry` ). Project axioms fail the check. | \n| `statement_integrity` | Each target's elaborated statement and its project dependencies match the locked fingerprint. | \n| `kernel_replay` | `leanchecker` replays the compiled modules with declarations in a fresh kernel. | \n\n`ACCEPTED` (exit 0) admits a proof. A failed check yields `REJECTED` (exit 1).\nIf replay cannot finish and no check failed, the verdict is `INCOMPLETE` (exit 2).\n\nThe adversarial suite exercises 22 cheats, including a custom tactic hiding a placeholder and a changed definition beneath an identical theorem statement. [Audit details](https://github.com/ObservedObserver/QED/blob/main/docs/audit.md) · [Adversarial tests](https://github.com/ObservedObserver/QED/blob/main/tests/test_audit_adversarial.py)\n\nCommands operate on disk and return deterministic exit codes, with `--json` output for agent and script consumption.\n\n| Example | What it does | \n|---|---|\n| `qed setup` | Register skills and prepare the local toolchain. | \n| `qed uninstall --dry-run` | Preview removal of managed files. | \n| `qed cache status` | Inspect the shared Mathlib cache. | \n| `qed doctor` | Check the installation and compile a smoke theorem. | \n| `qed init` | Create a research workspace. | \n| `qed link .` | Connect an existing Lake project to the shared packages. | \n| `qed conjecture list` | Track conjecture variants, refutations and literature diffs. | \n| `qed lock -t Research.main` | Fingerprint the agreed target. | \n| `qed audit` | Check the project against its lock. | \n| `qed ledger verify` | Recheck admitted lemmas. | \n| `qed falsify check.py` | Run a counterexample search. | \n| `qed cert verify --kind graph-iso --witness w.json` | Emit and audit a Lean 4 witness certificate. | \n| `qed search factorial` | Look up Mathlib declarations. | \n| `qed lit --id 2506.13379` | Fetch an arXiv record. | \n| `qed paper build` | Audit the project and compile the manuscript. | \n\nOne model attempted the kite lemma three ways. Each submitted proof underwent the same audit.\n\n| Kite lemma | Single prompt, no tools | Plain agent + Lean | QED | \n|---|---|---|---|\n| Lean proof accepted | Yes, after adjusting imports to the installed cache | Yes | Yes | \n| Time | 12.8 min | 3.2 min | 32 min to acceptance, 54 min with paper | \n| Tokens | 158 k | 96 k | ≈1.47 M (subagent totals; excludes orchestrator) | \n| Independent review of locked statement | No | No | Yes | \n| Neighbouring claims refuted | 0 | 0 | 7 | \n\nThe plain agent proved the stated lemma in one compiler run. The QED review found that one existence claim already followed from Nash's theorem.\nThe run also proved the stronger explicit-witness version, recorded nine reusable lemmas, and produced a 28-page manuscript with an audit appendix.\nThose extra results account for what the longer run delivered. [Comparison and controls](https://github.com/ObservedObserver/QED/blob/main/examples/README.md) · [Manuscript](https://github.com/ObservedObserver/QED/blob/main/examples/kite-lemma/qed-run/paper/paper.pdf)\n\n[Documentation index](https://github.com/ObservedObserver/QED/blob/main/docs/README.md) · [Host guide](https://github.com/ObservedObserver/QED/blob/main/docs/hosts.md) · [Architecture](https://github.com/ObservedObserver/QED/blob/main/docs/architecture.md) · [Audit contract](https://github.com/ObservedObserver/QED/blob/main/docs/audit.md) · [Example runs](https://github.com/ObservedObserver/QED/blob/main/examples/README.md)\n\nThe same instructions the hosts load are available here. [Research skill](https://github.com/ObservedObserver/QED/blob/main/skills/qed-research/SKILL.md) · [Setup skill](https://github.com/ObservedObserver/QED/blob/main/skills/qed-setup/SKILL.md) · [Paper skill](https://github.com/ObservedObserver/QED/blob/main/skills/qed-paper/SKILL.md)\n\n- The kernel verifies the locked Lean statement. A reader must judge whether its formalization captures the mathematical problem.\n- A writer with access to `qed-lock.json` can replace it. Keep the agreed fingerprint somewhere the prover cannot write.\n- Python falsification reports the cases tested. A search that finds no counterexample leaves the conjecture open.\n- Generated manuscripts are unreviewed drafts and carry a mandatory disclosure.\n- Example timings describe one model on one machine, with one run per condition.\n\n```\nscripts/test.sh                  # unit and adversarial tests\nscripts/test.sh --strict         # require Lean, npm and Unicode LaTeX\nscripts/verify-npm-package.sh    # package contents, CLI and offline persistence\nscripts/verify-mathlib-e2e.sh    # Mathlib setup, lock, ledger, audit and paper\n```\n\nApache-2.0. [License text](https://github.com/ObservedObserver/QED/blob/main/LICENSE)", "url": "https://wpnews.pro/news/show-hn-qed-turn-claude-code-into-a-math-researcher-with-a-formal-toolchain", "canonical_source": "https://github.com/ObservedObserver/QED", "published_at": "2026-12-02 22:28:44+00:00", "updated_at": "2026-12-02 22:46:57.909546+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "large-language-models", "ai-research"], "entities": ["QED", "qed-agents", "Claude Code", "Lean 4", "Mathlib", "Codex CLI", "ObservedObserver", "Alcántara, Criado, and Santos"], "also_reported_by": [], "takeaway": "QED v0.2's qed-agents CLI chains falsify, lock, search, audit and paper build into one workflow on pinned Lean v4.36.0 and Mathlib v4.36.0, requiring about 3 GB for Lean and 2.6 GB for Mathlib.Tactic in the default Quick profile.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-qed-turn-claude-code-into-a-math-researcher-with-a-formal-toolchain", "markdown": "https://wpnews.pro/news/show-hn-qed-turn-claude-code-into-a-math-researcher-with-a-formal-toolchain.md", "text": "https://wpnews.pro/news/show-hn-qed-turn-claude-code-into-a-math-researcher-with-a-formal-toolchain.txt", "jsonld": "https://wpnews.pro/news/show-hn-qed-turn-claude-code-into-a-math-researcher-with-a-formal-toolchain.jsonld"}}