mathlibable

A command for deciding whether a Lean declaration belongs in mathlib, the shared library of formally checked mathematics for Lean. It searches existing mathlib results and relevant mathematical literature before giving a verdict.

In plain words
What is it for?
Use it to assess one declaration or all public declarations in one or more files, search for existing results and literature, compare possible levels of generality, and decide whether a contribution fits mathlib.
Why use it?
A theorem can be true and useful yet still be unsuitable for the library if it is too specific, not general enough, or already available in another form. The workflow supplies evidence for choosing the right statement and avoiding duplicates.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/cbirkbeck/mathlib-quality/mathlibable
Clone the repo
git clone --depth 1 https://github.com/CBirkbeck/mathlib-quality
Per session 190 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 16,696 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00190 $0.16696
Opus 5 $0.00095 $0.08348
Sonnet 5 $0.00038 $0.03339
Haiku 4.5 $0.00019 $0.01670

Measured 2d ago against content hash 4beeb5d910a7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mathlibable scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/mathlibable.md · 1,360 lines

How it starts

The opening of the file, as written. The whole thing — 1,360 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/mathlibable — Should this declaration be in mathlib?

Take one Lean declaration and answer the question: should mathlib have this? The answer is rarely obvious. The skill exists to do the search work that makes the answer well-founded — and to refuse to produce a verdict without the evidence.

This is a hard, slow workflow. Mathlib's bar isn't "is this true and useful"; it is "is this the right statement at the right level of generality, and not already there in some form we should be reusing?" Getting that right takes thorough literature + mathlib search. Skipping the search produces wrong verdicts.

Usage

/mathlibable <Foo.bar>                          # Mode A: one declaration; full 10-phase workflow
/mathlibable <file.lean>                        # Mode B: every public decl in this file; orchestrator-worker
/mathlibable <file1.lean> <file2.lean> ...      # Mode B: same, across multiple files

There is no --quick flag and no --exhaustive flag. Every invocation runs the full exhaustive literature search. Mathlib is Bourbaki 2.0 — adding the right declaration in the right form requires doing the thorough work every time. Producing a verdict in five minutes by skipping channels is exactly the failure mode this skill exists to prevent.

Mode B is slow by design. Each public declaration in the file(s) gets its own full 10-phase workflow (one Agent per decl). On a 30-decl file with the exhaustive lit search, plan on hours. The orchestrator narrates a one-line scoreboard between dispatches so you can leave it running. If you only want to know which declarations are worth investing this kind of work in, run /overview first — its Step 9 mathlibable triage assigns each decl to SKIP / LIKELY-NO / LIKELY-YES / WORTH-FULL-CHECK based on cheap signals only.

Prerequisites

  • lake build clean (the declaration must elaborate; we read its full elaborated type, not a sorry-placeholder).
  • The declaration exists in the current Lean project. Mathlib-tree decls aren't in scope — if you want to ask "should this mathlib decl be more general?", use /generalise instead.
  • Optional but highly valuable: a .mathlib-quality/references/ directory of source-paper PDFs / notes. The literature search reads these first; with them, the standard-form question is often answered in seconds. Without them, the skill falls back to WebSearch + ChatGPT MCP + nLab/Stacks; still works, takes longer.

Read the full file on GitHub · 1,360 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 1,360 lines · 0 tokens per session scan A 4beeb5d910a7

Subscribe to this mod's changes

mathlibable is a command published in the GitHub repository CBirkbeck/mathlib-quality (32 stars, last pushed 13d ago), licensed MIT. It adds 190 tokens to every session and 16,696 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.