lean-tutor

Teaches Lean 4 programming and Mathlib proofs through beginner-friendly Japanese tutoring.

Updated Jul 4, 2023
One-click install
npx skills add https://github.com/kohdice/dotfiles --skill lean-tutor-kohdice
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: lean-tutor
Source: https://github.com/kohdice/dotfiles/tree/main/config/agents/skills/lean-tutor
Command: npx skills add https://github.com/kohdice/dotfiles --skill lean-tutor-kohdice

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Learning Lean 4 and Mathlib is hard for beginners who lack background in dependent type theory, and generic coding assistants tend to dump finished proofs without explaining the reasoning. This Skill turns the AI into a persistent tutor that explains why Lean code works, how to read goal states and error messages, and how to eventually write proofs independently. ## Core Features & Use Cases - Structured tutoring persona: Responds in Japanese with conclusion-first answers, minimal runnable code examples, goal-state walkthroughs, and explanations of Lean's mental model (propositions as types, proofs as values). - Error and concept diagnosis: Explains common Lean errors (type mismatch, rewrite failures, termination, missing instances) step by step, and compares confusable concepts like rw vs simp, Prop vs Bool, and term-mode vs tactic-mode proofs. - Toolchain and project guidance: Covers elan, lean-toolchain, Lake projects, and Mathlib setup including lake exe cache get, with version handling based on the latest stable Lean 4 release. - Use Case: A beginner asks why rw [Nat.zero_add] fails on the goal n + 0 = n; the tutor shows the goal state, explains that rw matches syntactic patterns, provides the fix with Nat.add_zero, and teaches how to avoid the mistake using exact?. ## Quick Start Ask the tutor to explain a Lean 4 concept or proof in beginner-friendly Japanese, for example by requesting an explanation of why a specific tactic proof works.

Frequently Asked Questions about lean-tutor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I learn Lean 4 as a beginner?▼

Start with core Lean for functional programming concepts like List.map before adding Mathlib for mathematics. Use #check and #eval to explore types, read the infoview goal state after every tactic, and practice with small single-file examples that run with lean file.lean.

Why does rw fail with 'did not find instance of the pattern' in Lean?▼

The rw tactic matches patterns syntactically, so Nat.zero_add (0 + n) cannot rewrite a goal containing n + 0 even though they are mathematically equal. Check that the lemma's left-hand side appears literally in the goal, or use exact? and rw? to find matching lemmas.

Do I need Mathlib for Lean 4 programming?▼

Core Lean suffices for functional programming with Nat, Int, List, and basic logic. Mathlib is required for real numbers, sets, groups, and tactics like norm_num, ring, and linarith, and it pins its own lean-toolchain version.

What is the difference between term-mode and tactic-mode proofs in Lean?▼

Term-mode proofs build the proof value directly, like ⟨hq, hp⟩ for a conjunction, while tactic mode with by interactively transforms the goal state step by step. Both produce the same checked proof term; tactic mode is usually easier for beginners to follow.

Is it safe to use sorry in a Lean proof?▼

sorry closes any goal without a proof, so a theorem containing it proves nothing and Lean warns with 'declaration uses sorry'. It is acceptable as a placeholder while learning, but you should verify no sorry remains before trusting a result.

How do I set up a Lean 4 project with Mathlib?▼

Install elan, run lake new my_project math to generate a project with Mathlib in lakefile.toml, then run lake exe cache get to download prebuilt Mathlib before lake build. The project's lean-toolchain must match Mathlib's pinned toolchain for the cache to work.