# Show HN: QED – turn Claude Code into a math researcher with a formal toolchain

> Source: <https://github.com/ObservedObserver/QED>
> Published: 2026-12-02 22:28:44+00:00

**Key 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.

**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.**

QED 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.
Workspaces 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.

**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`.

Use 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.

```
npx qed-agents setup --dry-run
npx qed-agents setup
```

The Quick profile is the default. Allow about 3 GB for Lean and 2.6 GB for `Mathlib.Tactic` and its imports.
For the full Mathlib cache, allow about 7 GB for the cache and select `--profile full`. Use `--yes` to accept the defaults without prompts.

Setup registers skills for detected hosts, prepares SymPy and a Unicode LaTeX engine, and runs a Mathlib smoke build.
The 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`.
You can also install globally with `npm install -g qed-agents && qed setup`. Open a fresh host session after setup.

**Claude Code plugin.** Tested with Claude Code 2.1.332 against `ObservedObserver/QED` on GitHub.
The second command installs the CLI and toolchain while Claude manages the skills.

```
claude plugin install qed --marketplace ObservedObserver/QED
npx -y qed-agents@latest setup --skip agents
```

For 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).

Use 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.

```
# 1. Create the workspace and test the inequality without its lower bound.
qed init --problem "For every natural number n >= 4, 2 * n! < n^n."
cd .math-research
qed falsify --forall "n=range(1,60)" --claim "2*factorial(n) < n**n" --label "all n"

# 2. Write Research.two_mul_factorial_lt in lean/Research/Basic.lean with
#    proof 'sorry'. Review its quantifiers and hypotheses, then lock it.
qed lock -t Research.two_mul_factorial_lt

# 3. Look up candidate lemmas and replace 'sorry' with a Lean proof.
qed search factorial lt pow
qed search --check Nat.pow_succ

# 4. Clean-build the project and save the verdict beside the workspace record.
qed audit --report-dir verdicts/final

# 5. After ACCEPTED, scaffold the paper, fill in paper/sections/, then build.
qed paper init
qed paper build
```

The first check finds failures at `n = 1` and `n = 2`. Both lie outside the proposed theorem's domain.

Given 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`.

Beyond 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:

- **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)
- **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)
- **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)

**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)

After setup, clone the repository to get the example sources and rerun the first audit. The npm package omits `examples/`.

```
git clone https://github.com/ObservedObserver/QED.git && cd QED
qed link examples/shifted-lonely-runner-k4/lean
qed audit --project examples/shifted-lonely-runner-k4/lean
```

Four things can go wrong before anyone reads a proof:

1. A prose argument skips a case that Lean would require.
2. A missing import starts a multi-hour Mathlib build.
3. Parallel Lean processes exhaust the machine's memory.
4. A project compiles with a placeholder, a new axiom or a weaker statement.

The 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.
The 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.

Workspaces 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.

QED sets Lean's `-M` heap limit from host RAM, bounds build concurrency and monitors process-group RSS.
A per-project lock serializes competing builds. Ledger admission rebuilds and replays the target lemma's import closure, so unfinished siblings can stay on disk.

A clean build alone can accept `sorry`. The default audit requires all six checks.

| Gate | What passes | 
|---|---|
| `source_scan` | Project sources contain no forbidden constructs such as `sorry` ,`admit` ,`axiom` or`native_decide` . | 
| `build` | Every project module compiles from a clean state using cached dependencies. | 
| `kernel_sorry` | The kernel axiom closure contains no `sorryAx` . | 
| `axioms` | Only `propext` ,`Classical.choice` and`Quot.sound` are permitted (`sorryAx` is reported separately by`kernel_sorry` ). Project axioms fail the check. | 
| `statement_integrity` | Each target's elaborated statement and its project dependencies match the locked fingerprint. | 
| `kernel_replay` | `leanchecker` replays the compiled modules with declarations in a fresh kernel. | 

`ACCEPTED` (exit 0) admits a proof. A failed check yields `REJECTED` (exit 1).
If replay cannot finish and no check failed, the verdict is `INCOMPLETE` (exit 2).

The 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)

Commands operate on disk and return deterministic exit codes, with `--json` output for agent and script consumption.

| Example | What it does | 
|---|---|
| `qed setup` | Register skills and prepare the local toolchain. | 
| `qed uninstall --dry-run` | Preview removal of managed files. | 
| `qed cache status` | Inspect the shared Mathlib cache. | 
| `qed doctor` | Check the installation and compile a smoke theorem. | 
| `qed init` | Create a research workspace. | 
| `qed link .` | Connect an existing Lake project to the shared packages. | 
| `qed conjecture list` | Track conjecture variants, refutations and literature diffs. | 
| `qed lock -t Research.main` | Fingerprint the agreed target. | 
| `qed audit` | Check the project against its lock. | 
| `qed ledger verify` | Recheck admitted lemmas. | 
| `qed falsify check.py` | Run a counterexample search. | 
| `qed cert verify --kind graph-iso --witness w.json` | Emit and audit a Lean 4 witness certificate. | 
| `qed search factorial` | Look up Mathlib declarations. | 
| `qed lit --id 2506.13379` | Fetch an arXiv record. | 
| `qed paper build` | Audit the project and compile the manuscript. | 

One model attempted the kite lemma three ways. Each submitted proof underwent the same audit.

| Kite lemma | Single prompt, no tools | Plain agent + Lean | QED | 
|---|---|---|---|
| Lean proof accepted | Yes, after adjusting imports to the installed cache | Yes | Yes | 
| Time | 12.8 min | 3.2 min | 32 min to acceptance, 54 min with paper | 
| Tokens | 158 k | 96 k | ≈1.47 M (subagent totals; excludes orchestrator) | 
| Independent review of locked statement | No | No | Yes | 
| Neighbouring claims refuted | 0 | 0 | 7 | 

The plain agent proved the stated lemma in one compiler run. The QED review found that one existence claim already followed from Nash's theorem.
The run also proved the stronger explicit-witness version, recorded nine reusable lemmas, and produced a 28-page manuscript with an audit appendix.
Those 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)

[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)

The 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)

- The kernel verifies the locked Lean statement. A reader must judge whether its formalization captures the mathematical problem.
- A writer with access to `qed-lock.json` can replace it. Keep the agreed fingerprint somewhere the prover cannot write.
- Python falsification reports the cases tested. A search that finds no counterexample leaves the conjecture open.
- Generated manuscripts are unreviewed drafts and carry a mandatory disclosure.
- Example timings describe one model on one machine, with one run per condition.

```
scripts/test.sh                  # unit and adversarial tests
scripts/test.sh --strict         # require Lean, npm and Unicode LaTeX
scripts/verify-npm-package.sh    # package contents, CLI and offline persistence
scripts/verify-mathlib-e2e.sh    # Mathlib setup, lock, ledger, audit and paper
```

Apache-2.0. [License text](https://github.com/ObservedObserver/QED/blob/main/LICENSE)
