Lean Proof Patterns logo

Lean Proof Patterns

Community
scottnarmstrong
lean-proof-patterns

Use when writing, refactoring, or debugging Lean proofs and you need a stable translation from mathematical reasoning into explicit tactics, controlled rewriting, or maintainable proof structure.

Overview

Publisherscottnarmstrong
RepositoryLeanAutoformalizationSkills
Skill namelean-proof-patterns
Stars
66
Forks
7
Bundled files
3
LicenseCC-BY-4.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by scottnarmstrong on GitHub. Read the source before you install it.

Installation

Install the Lean Proof Patterns AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/scottnarmstrong/LeanAutoformalizationSkills/tree/main/skills/lean-proof-patterns
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/scottnarmstrong/LeanAutoformalizationSkills.git /tmp/LeanAutoformalizationSkills
mkdir -p .claude/skills
cp -r /tmp/LeanAutoformalizationSkills/skills/lean-proof-patterns .claude/skills/lean-proof-patterns
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Lean Proof Patterns in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Lean Proof Patterns on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Lean Proof Patterns is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Lean Proof Patterns

Use this skill when the work is primarily about proving things in Lean rather than planning a project or searching for existing lemmas. It is especially useful when translating informal mathematics into Lean, cleaning up a rough proof, or replacing exploratory tactics with checked-in code.

Core Workflow

  1. Classify the proof step before touching tactics.
    • introduction or elimination
    • rewriting or normal-form change
    • case split or induction
    • arithmetic or algebraic closure
    • extensionality or structure unpacking
  2. Start with the simplest explicit proof shape that matches the mathematics.
    • intro, rintro, obtain, constructor, use
    • have, suffices, show, change
    • calc for chains of equalities or inequalities
  3. During exploration, use search tactics freely.
    • exact?, apply?, rw?, simp?, hint
    • do not leave them in finished code
  4. Before finishing, pin the proof down.
    • replace bare simp with simp only [...] when possible
    • replace search tactics with explicit lemmas
    • factor repeated proof fragments into helper lemmas

Production-Proof Rules

  • Prefer small have steps and calc blocks over large opaque tactic scripts.
  • Use automation that matches the goal shape.
    • ring, field_simp, linarith, nlinarith, omega, positivity, norm_num
    • gcongr, fun_prop, continuity, measurability when the domain fits
  • In performance-sensitive proofs, do not leave broad automation in place just because it closes the goal. If a large nlinarith/linarith is only combining already-named inequalities, replace it with monotonicity lemmas and a calc. Prefer linarith only [...] so the hypothesis set stays small. Treat Real.rpow and Real.exp expressions as opaque atoms when possible; extract the algebraic core over abstract reals if unfolding them causes excessive work.
  • Follow the repository's linter policy. Unused proof-locals, dead simp arguments, do-nothing tactics, and <;> applied to a single goal are mechanical fixes. Audit an unused binder in the statement against the source before changing it. A source premise may remain necessary to preserve the approved statement even if this proof does not use it. A frozen signature changes only through an author-approved successor and renewed audits.
  • Keep rewriting intentional.
    • rw for a specific rewrite
    • simp_rw under binders
    • conv only when targeted rewriting is genuinely needed
  • Replace broad definitional bridges like simpa [many, local, definitions] with exact, rfl, or dsimp plus targeted rw when possible.
  • Separate discovery from final form.
    • development proofs may use search and broad automation
    • checked-in proofs should be stable, readable, and predictable

Statement Hygiene

The statement must say what you claim, independently of how far the proof has got. When a step will not close, fix the proof; never reshape the goal into something provable.

  • A genuine predicate defined by the source, such as an induction state, may be a literal def : Prop, provided it takes the objects it constrains as parameters. A theorem-shaped predicate, standing-assumption package, result bundle, or generic “input/bridge/consequence” interface may not replace a source theorem. def myEstimate : Prop := ∀ ... consumed as theorem main (h : myEstimate) : Goal leaves the mathematics untouched and only hides it from the reader and from the status report.
  • No placeholder definition and no fallback body. A definition must already denote the intended object on its whole carrier; do not add a default branch so that a later statement can quantify over an unfinished construction.
  • No hypothesis that is a proof step, estimate, or witness of the target rather than a premise of the source. If the source proves A → B, intermediate claims belong in the proof or in helper lemmas; A → Step → B is a different theorem.
  • No hypothesis that is the conclusion itself at a weaker scale, radius, or domain.

A conditional theorem is legitimate when every hypothesis is a source premise, a separately approved standing assumption, or an external input recorded as a trust boundary. It is not legitimate when a hypothesis is the part of the argument that is unfinished. All of these forms elaborate and pass the build, and naming one honestly in the handoff does not make the statement correct. A text linter that checks placeholders and banned tactics will not catch them, so check project-owned Prop definitions by hand and treat a nullary one as an unproved theorem until shown otherwise. When the input you need does not exist, stop and report the exact missing statement.

Module Files

For repositories using Lean's module system, follow the pinned toolchain's visibility rules and the project's chosen header conventions.

  • Header. The file starts with a copyright comment, then module, then public import for what statements need and plain import for proof-only dependencies. The module docstring follows, then public section.
  • Definition bodies are hidden unless the definition is @[expose]. A public theorem that needs to unfold a definition fails with "Not a definitional equality … must be exposed", even in the same file. This is verified for rfl; expect the same for decide and for cross-module unfolding. Fix it either by proving and using an unfolding lemma (f_def, f_apply), or by exposing a definition whose body is its meaning. Never weaken the statement to avoid the error.
  • Proofs are never exported. Nothing downstream may depend on how a theorem was proved.
  • Registry interfaces. If a publication registry imposes additional visibility rules on comparison, challenge, or solution files, apply those rules only to the relevant export interface.

See the lean-project-architecture skill's references/module-system.md for the full rules.

Debugging Heuristics

  • If Lean is not seeing the goal in the right form, try show, change, or an explicit helper lemma before escalating to clever tactics.
  • If automation nearly works, inspect what it wants and feed it the missing monotonicity, positivity, or side inequalities.
  • If the proof is repeating the same shape, stop and extract a lemma instead of copying tactics.
  • When the task is elaboration cleanup, profile before and after each candidate change, and keep only edits that improve the relevant profiler category. Treat wall time as secondary when the machine is busy.

References

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Lean Proof Patterns AI skill do?

Use when writing, refactoring, or debugging Lean proofs and you need a stable translation from mathematical reasoning into explicit tactics, controlled rewriting, or maintainable proof structure.

Why use Lean Proof Patterns on TypingMind?

Because you install it once and use it with any model. Lean Proof Patterns is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Lean Proof Patterns in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/scottnarmstrong/LeanAutoformalizationSkills/tree/main/skills/lean-proof-patterns. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Lean Proof Patterns?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Lean Proof Patterns?

As many as you like. As long as a model supports skills, you can use Lean Proof Patterns with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Lean Proof Patterns AI skill free?

Yes. It is published on GitHub by scottnarmstrong under the CC-BY-4.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇