AGENT SKILL

lean-bridge

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.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 81
Forks
17

01 前言 Front Matter

name
lean-bridge
description
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.

02 资源文件 3

03 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 statement Lean name (fully qualified) file modelling notes
    Lemma 3.2 (support stability) Proj.Support.stable Support.lean coefficient 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)

need tool tip
quick compile of a snippet lean_run_code self-contained with imports; the server needs lake on PATH
goal at a line lean_goal omit the column to see the state before and after the line
errors lean_diagnostic_messages "no goals to be solved" means delete tactics
lemma by name fragment lean_local_search use before guessing a name
lemma by meaning lean_leansearch / lean_leanfinder rate-limited
lemma by type lean_loogle rate-limited, a few calls per 30 s
try tactics lean_multi_attempt ["simp", "ring", "omega", "decide", "norm_num"]
which hypotheses are needed lean_minimal_hypotheses
axiom audit lean_verify fully qualified name
after adding imports lean_build slow; fetch_cache=true only for missing oleans

04 同仓库更多 Skills

jiayaoqijia
jiayaoqijia/cryptoskill

troves

Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say "Troves" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

trade

Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say "swap".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

staking

Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say "stake" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

send

Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say "pay 10 STRK to 0x...".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

portfolio

View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks "what do I have", "show me everything", "how much am I worth", "my positions", "my investments", "rebalance my portfolio", "I want 50% ETH", "optimize my holdings", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say "portfolio".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

multi-swap

Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions "two swaps", "three swaps", "swap X and Y at the same time", or wants to convert multiple tokens in a single call.

★ 81