Przejdź do treści
Biblioteka skilli
Nauka i badania · Budowanie i kod

lean-proof-patterns

/lean-proof-patterns

Przekłada rozumowanie matematyczne na jawne taktyki Lean, kontrolowane przepisywanie i czytelną strukturę dowodu przy pisaniu i poprawianiu.

Licencja
Apache-2.0
Ostatnia zmiana repozytorium
13.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
4
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 13.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Przekłada rozumowanie matematyczne na jawne taktyki Lean, kontrolowane przepisywanie i czytelną strukturę dowodu przy pisaniu i poprawianiu.

Oryginalny opis (EN)

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.

Jak działa

  1. Core Workflow
  2. Production-Proof Rules
  3. Statement Hygiene
  4. Module Files
  5. Debugging Heuristics
  6. References
Sekcje z nagłówków SKILL.md, w oryginale · 124 linii, 1 045 słów
Podgląd SKILL.md
---
name: lean-proof-patterns
description: 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.
---

# 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

- Read [references/math-to-lean.md](references/math-to-lean.md) when you need a phrasebook from informal proof language to Lean proof moves.
- Read [references/tactics-and-automation.md](references/tactics-and-automation.md) when choosing tactics, deciding between exploration and production proofs, or debugging automation/performance issues.
Pliki w paczce (4)
  • SKILL.md 7 KB
  • agents/openai.yaml 1 KB
  • references/math-to-lean.md 6 KB
  • references/tactics-and-automation.md 16 KB

Wersje

W bazie nie ma innych skilli o nazwie lean-proof-patterns.

Migawka bazy z 13.11.2026 · wersja paczki 1ec23f200c40 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100writing-lean-proofs
    Pomaga projektować, pisać, recenzować, refaktoryzować i lintować dowody, biblioteki i taktyki w Lean 4 oraz diagnozować ich wydajność.
  • 100writing-lean-proofs
    Pisze i sprawdza uporządkowane dowody w Lean 4 oraz projektuje biblioteki zgodne z konwencjami Mathlib.
  • 100lean-proofs
    Pisze i naprawia dowody Lean 4 w projekcie LeanTheory: automatyzację grind, sprawdzanie konkretnych faktów liczbowych i budowę dużych dowodów jako termów.
  • 90lean-search-discovery
    Szuka w Mathlib istniejących deklaracji, nazw twierdzeń i plików przed napisaniem nowego dowodu w Lean.
  • 100lean-formalize
    Rozwija i weryfikuje dowód matematyczny w Lean, dokańcza niedokończony projekt lub sprawdza, czy dowód dotyczy oryginalnego twierdzenia.
  • 100lean-formalize
    Rozwija i weryfikuje dowód matematyczny w Lean, kontynuuje niedokończony projekt lub sprawdza, czy dowodzi on pierwotnego twierdzenia, łącząc lematy, sprawdzając aksjomaty i przygotowując powtarzalne przekazanie.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.