mathlib-lookup

mathlib-lookup is a skill for Claude Code, Codex from nasqret/lean-interact. It costs 170 tokens per session (2,369 once invoked), scanned A, original, MIT.

A procedure for finding the exact name and full type of a mathematical result in Mathlib, Lean 4’s mathematics library. It verifies the result before recommending it.

In plain words
What is it for?
Use it when looking for a Mathlib lemma, theorem, definition, instance, tactic, namespace API, or the precise hypotheses of a result.
Why use it?
It prevents relying on a guessed theorem name or overlooking required assumptions. The full type shows how the result must actually be used in a proof.

Skill for Claude CodeCodex

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 skills/nasqret/lean-interact/mathlib-lookup
Any agent
npx skills add nasqret/lean-interact --skill mathlib-lookup
Clone the repo
git clone --depth 1 https://github.com/nasqret/lean-interact

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mathlib-lookup

README.md
[![agentmods](https://agentmods.dev/badge/skills/nasqret/lean-interact/mathlib-lookup.svg)](https://agentmods.dev/skills/nasqret/lean-interact/mathlib-lookup)
Your own site
<a href="https://agentmods.dev/skills/nasqret/lean-interact/mathlib-lookup"><img src="https://agentmods.dev/badge/skills/nasqret/lean-interact/mathlib-lookup.svg" alt="Measured on agentmods" height="20"></a>
Per session 170 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,369 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.00170 $0.02369
Opus 5 $0.00085 $0.01184
Sonnet 5 $0.00034 $0.00474
Haiku 4.5 $0.00017 $0.00237

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

Security

Grade A, and why

mathlib-lookup 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 3d 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.

.claude/skills/mathlib-lookup/SKILL.md · 184 lines

How it starts

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

mathlib-lookup

This skill exists for the user's single stated pain point: they know the mathematics and not the Mathlib name. Two consequences govern everything below.

  1. A name is a claim, and claims get checked. Nothing unverified is ever reported, used, or written - not even hedged with "I think". A hedge disappears the moment the name is repeated.
  2. A name alone is not an answer. Report the real elaborated type. The user needs the hypotheses and their order to use the lemma; the name is only the handle.

Repository root: /path/to/lean-interact.


The escalation, in order of cost

Stop at the first step that yields a verified name.

1. Dot completion (free, when a hypothesis exists)

If the user has h : Nat.Coprime a b in context, the whole Nat.Coprime namespace is reachable as h.something, and the editor's completion list is guaranteed correct for this Mathlib. Tell the user to type h. in the VS Code infoview pane. The programmatic equivalent is step 2's --namespace.

2. Guess from the naming grammar (seconds)

Read vault/Naming Conventions.md. Construct the name rather than recall it:

  • Say the statement in Mathlib's vocabulary: "modEq iff dvd", "le of dvd", "prime dvd mul".
  • Conclusion first, hypotheses after of_; symbols become fragments (+ -> add, -> dvd, -> iff, -> le, ^ -> pow, % -> mod/emod).
  • Namespace = the type of the distinguished hypothesis, or the head of the conclusion.
  • Casing migration: natCast not nat_cast, intCast not int_cast. Pre-2024 sources and mathlib3 names are systematically wrong.
  • Always try the primed variant too; ' means different hypotheses or argument order (Nat.modEq_iff_dvd vs Nat.modEq_iff_dvd').

Then verify (step 4). A guess that verifies costs one command.

3. Search with tools/mlq.py (seconds)

python3 tools/mlq.py "modEq iff dvd"          # free text over names and statements
python3 tools/mlq.py --about "chinese remainder"   # by informal topic
python3 tools/mlq.py --concept ModEq          # by the concept appearing in the statement
python3 tools/mlq.py --namespace Nat.Prime    # the whole API of a namespace or type
python3 tools/mlq.py --help                   # authoritative; the tool wins over this note

Read the full file on GitHub · 184 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. 3d ago First seen · 184 lines · 170 tokens per session scan A 0e8b13c4663c

Subscribe to this mod's changes

mathlib-lookup is a skill published in the GitHub repository nasqret/lean-interact (10 stars, last pushed 26d ago), licensed MIT. It adds 170 tokens to every session and 2,369 once invoked, about $0.0009 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-31.

Related

Other skills, from other repositories

screen

Screen informal↔Lean 4 statement pairs for faithfulness defects. Use whenever writing, editing, translating, or reviewing Lean 4 theorem or definition statements that are meant to formalize informal mathematics: after drafting a statement, before committing formalizations, when auditing a benchmark file, or when the…

ibrahimmian36/leanscreen · 0 tokens

learn-from-math-agent-trajectories

Review completed or paused mathematical agent transcripts, visible reasoning, code, searches, tool calls, corrections, and final claims to extract evidence-backed lessons for Jacobian operations, discovery, contracts, skills, evaluations, and documentation. Use for mathematical workflow retrospectives and "what should…

morluto/jacobian · 87 tokens

mathlib-api

Evidence-driven workflow for designing a Mathlib definition and the API around it. Use when adding a new structure/def intended for mathlib; when choosing between design alternatives (index type as field vs parameter, Set vs indexed family, coarse set vs finer indexed structure and when the fine one should exist at…

homeowmorphism/mathlib-api · 234 tokens

lean-probe

Fast Lean 4 proof verification for coding agents via the LeanProbe MCP server's warm REPL. Use when you need to know whether Lean 4 code compiles (no errors, no sorry), iterate on a declaration inside a Lake/Mathlib project, test a replacement proof candidate, or explore a goal tactic by tactic — far faster than lake…

epfl-lara/LeanProbe · 139 tokens

book-mirror

Take any book (EPUB/PDF), produce a personalized chapter-by-chapter analysis. Each chapter is preserved in detail (The Chapter) and mirrored back to the reader's actual life (The Mirror) using brain context. The mirror observes and resonates — a friend pointing out parallels, NOT a consultant rearranging the reader's…

garrytan/gbrain · 138 tokens

ljg-learn

Deep concept anatomist that deconstructs any concept through 8 exploration dimensions (history, dialectics, phenomenology, linguistics, formalization, existentialism, aesthetics, meta-philosophy) and compresses insights into an epiphany. Use when user asks to explain, dissect, or deeply understand a concept, term, or…

lijigang/ljg-skills · 113 tokens