learn-math-by-lean-notebook
Skill0 starsChanged 8 months agoMITView on GitHub
Generate Jupyter notebooks that teach mathematics through Lean 4 and mathlib by interleaving compact bilingual-capable explanations, runnable Lean code cells, proof experiments, and small exercises. Use when the user asks to learn a math topic with Lean, wants a Lean 4/mathlib tutorial notebook, requests Chinese or English math-learning notebooks, or wants a theory-plus-formalization lesson in .ipynb form.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ccswitchSkill
- code-rulesSkill
- leanmgr-cache-managerSkill
- lmfdb-cliSkill
- mathlib-styleSkill
- mathlib-workflowSkill
- openclaw-rssSkill
- pre-initSkill
- pr-worktree-workflowSkill
- sshSkill
- tmuxSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 4 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Create a real .ipynb tutorial for a user-chosen mathematics topic using Lean 4 and mathlib as the executable medium.
- Very specific: line 15
Read references/notebook-style.md before generating a notebook unless the task is only a quick outline.
- Very specific: line 27
When the user asks to register, create, debug, or document a project-specific Lean 4 Jupyter kernel, use …
- Distinctive: line 31
Keep markdown cells short.
- Very specific: line 32
Put every abstract idea near a runnable Lean example, #check, #eval, example, lemma, or theorem.
- Very specific: line 33
Prefer mathlib's existing names and APIs.
- Distinctive: line 34
Avoid fake Lean. If a proof is likely hard, mark it as an exercise or use an honest intermediate theorem instead of inventing unsupported …
- Distinctive: line 35
Keep code cells focused. One cell should introduce one definition, API, proof move, or theorem.
- Distinctive: line 36
Use comments only where they orient the learner.
- Very specific: line 41
Use Lean 4 syntax: fun x => ..., <| when it improves readability, and no empty lines inside declarations.
- Very specific: line 43
Prefer small proofs with by, simp, rw, ring, omega, linarith, and explicit intermediate lemmas when appropriate.
- Very specific: line 44
Do not hide hard formalization gaps behind set_option maxHeartbeats.
- Very specific: line 48
Read references/notebook-style.md for the recommended notebook shape, language modes, Lean cell patterns, and validation checklist.
≈ “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.
Files
Learn Math by Lean Notebook
Create a real .ipynb tutorial for a user-chosen mathematics topic using Lean 4 and mathlib as the executable medium. Match the rhythm of a theory-practice notebook: explain one idea, run or inspect a small Lean fragment, then build toward a modest theorem or proof pattern.
Default to Chinese prose when the user writes in Chinese, English prose when the user writes in English, and bilingual prose only when the user asks for it or says "中英文", "bilingual", or similar. Lean code, theorem names, identifiers, comments, and error labels should stay in English.
Workflow
- Infer the topic, target level, and requested language. If unclear, assume a curious beginner who can read basic Lean syntax.
- Read
references/notebook-style.mdbefore generating a notebook unless the task is only a quick outline. - Choose one concrete end point: a formalized theorem, a reusable proof pattern, a small computation, a structure/API tour, or a Lean/mathlib translation of a familiar mathematical argument.
- Build the notebook as a sequence:
- Title cell with the topic and language-appropriate subtitle.
- Environment cell explaining the expected Lean 4/Jupyter setup.
- Roadmap cell with 3-6 steps.
- Concept blocks: short math explanation, then a focused Lean cell.
- Proof blocks: definitions or examples first, lemmas next, final theorem last.
- Debugging blocks: common Lean errors and how to read them.
- Exercises: 3-5 small modifications or proofs.
- Save a valid
.ipynbfile. Prefer notebook-native JSON over prose-only drafts when the user asks to create the notebook.
When the user asks to register, create, debug, or document a project-specific Lean 4 Jupyter kernel, use scripts/register_lean4_jupyter_kernel.py as the canonical helper and read the kernel registration section in references/notebook-style.md.
Notebook Rules
- Keep markdown cells short. Do not write a textbook chapter before the first Lean cell.
- Put every abstract idea near a runnable Lean example,
#check,#eval,example,lemma, ortheorem. - Prefer mathlib's existing names and APIs. Use
#check,#find, or local search when working in a real Lean project. - Avoid fake Lean. If a proof is likely hard, mark it as an exercise or use an honest intermediate theorem instead of inventing unsupported code.
- Keep code cells focused. One cell should introduce one definition, API, proof move, or theorem.
- Use comments only where they orient the learner.
- Include expected outcomes in markdown near cells that may require an external Lean kernel.
Lean Style
- Use Lean 4 syntax:
fun x => ...,<|when it improves readability, and no empty lines inside declarations. - Name examples and lemmas in English when names matter.
- Prefer small proofs with
by,simp,rw,ring,omega,linarith, and explicit intermediate lemmas when appropriate. - Do not hide hard formalization gaps behind
set_option maxHeartbeats.
Bundled Reference
Read references/notebook-style.md for the recommended notebook shape, language modes, Lean cell patterns, and validation checklist.
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
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.

