agentleFS
acprkacprk/crypto-research-agents/skills/lean-bridge/SKILL.md

lean-bridge

Skill15 starsChanged 8 days agoMITView on GitHub

Connect paper propositions to Lean4/Mathlib theorems with a proposition-to-Lean-name table, a zero-sorry policy and an axiom audit. Use when formalising the algebraic core of a paper, when a reviewer questions a proof, or before claiming "machine-checked" anywhere. Covers Mathlib cache pitfalls and the lean-lsp MCP tools.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If a quantity is only *modelled*, say so in the table and in the paper.

    line 14
  2. Very specific:

    Start from lib/lean-template/.

    line 21
  3. Distinctive:

    Keep each file under a few hundred lines, with one namespace per paper section.

    line 58

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

lean-bridge: paper proposition ↔ Lean theorem

Scope: what to formalise

Formalise the finite algebraic core: identities, support and character arguments, counting bounds, injectivity and admissibility conditions, cost-ratio identities and limits. Do not try to formalise lattice hardness, concrete noise distributions or performance.

If a quantity is only modelled, say so in the table and in the paper. An example is a noise bound taken as a definition rather than derived from ciphertext semantics. The paper may then claim only "operation/level counts are machine-checked relative to the model". It may not claim "noise growth is machine-checked".

Procedure

  1. Start from lib/lean-template/. Copy it and keep lean-toolchain and the Mathlib rev in sync.
  2. Run a numeric check first (skills/sage-check). Never start formalising a statement that has not survived toy parameters.
  3. For each proposition, write the Lean statement first, with the proof as a placeholder on a WIP branch. Get the statement reviewed against the paper text. Most mismatches are in the statement, not the proof. Common ones: the Lean version is weaker, uses ℕ where the paper needs ℤ, or adds a hypothesis the paper omits.
  4. Prove it. Useful tactics: decide for tiny concrete finite facts; ring, field_simp, linear_combination for identities; omega for linear ℕ/ℤ arithmetic; norm_num, simp for evaluation. Avoid native_decide.
  5. Fill in the table, which is kept in the Lean project README and mirrored in THEORY.md:

    paper statementLean name (fully qualified)filemodelling notes
    Lemma 3.2 (support stability)Proj.Support.stableSupport.leancoefficient level
  6. Gate (all must pass before the table is cited in the paper):
    • lake build is green on a clean checkout at the recorded commit;
    • scripts_check_no_sorry.sh reports no sorry/admit/axiom/native_decide;
    • an axiom audit of every headline theorem (#print axioms T or lean_verify) shows only propext, Classical.choice, Quot.sound;
    • the table rows match the paper numbering on the final PDF.
  7. Record the Lean commit and the "green build" log in EVIDENCE.md, for example "N results, zero sorry" as the printed fact and the lake build log as its source.

Lessons

  • Lean often finds redundant or insufficient hypotheses. Run lean_minimal_hypotheses on key theorems. Sometimes a hypothesis the paper states is not needed, which gives a stronger theorem. Sometimes the Lean proof needs one the paper forgot, which is a correctness fix. Report both to theorist and falsifier.
  • Formalising the coefficient-level statement is usually much easier than the polynomial-ring statement. Prove a bridge lemma (for example, the coefficient of P.comp (C a * X)) once and reuse it.
  • Keep each file under a few hundred lines, with one namespace per paper section.
  • A cost-ratio "→ 2 as d → ∞" claim can be formalised with Filter.Tendsto. Pair it with an explicit finite bound, because reviewers care about concrete sizes.

Mathlib cache pitfalls

See lib/lean-template/README.md. In short: match the toolchain and the Mathlib rev; run lake exe cache get after every lake update; never import Mathlib in project files; allow minutes for the first cold import; look up renamed lemmas with search tools, not from memory.

lean-lsp MCP tools (if configured)

needtooltip
quick compile of a snippetlean_run_codeself-contained with imports; the server needs lake on PATH
goal at a linelean_goalomit the column to see the state before and after the line
errorslean_diagnostic_messages"no goals to be solved" means delete tactics
lemma by name fragmentlean_local_searchuse before guessing a name
lemma by meaninglean_leansearch / lean_leanfinderrate-limited
lemma by typelean_looglerate-limited, a few calls per 30 s
try tacticslean_multi_attempt["simp", "ring", "omega", "decide", "norm_num"]
which hypotheses are neededlean_minimal_hypotheses
axiom auditlean_verifyfully qualified name
after adding importslean_buildslow; fetch_cache=true only for missing oleans

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.