Przejdź do treści
Biblioteka skilli
Programowanie · Nauka i wyjaśnianie

vibe-types:lean

/vibe-types:lean

Podpowiada techniki kontroli w czasie kompilacji w Lean 4: typy zależne, typy indukcyjne, klasy typów i dowody terminacji.

Repozytorium
vibe-types ↗
Licencja
Apache-2.0
Ostatnia zmiana repozytorium
01.08.2026

Ocena i bezpieczeństwo

90/ 100Klasa: dobry
Format15 / 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
70
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 01.08.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

Podpowiada techniki kontroli w czasie kompilacji w Lean 4: typy zależne, typy indukcyjne, klasy typów i dowody terminacji.

Oryginalny opis (EN)

Lean 4 compile-time safety techniques — dependent types, inductive types, type classes, termination checking, propositions as types, proof automation. Use this skill whenever the user writes Lean 4 code, mentions dependent types, asks about theorem proving, discusses inductive types, type classes, tactics (simp, omega, decide), subtypes, termination proofs, or any Lean type system feature. Also use when formalizing invariants, writing proof-carrying code, or porting type patterns from Scala, Rust, or Haskell to Lean.

Jak działa

  1. Core tenets
  2. Full catalog (type system features → constraints they enforce)
  3. Use cases (problem → which features help)
Sekcje z nagłówków SKILL.md, w oryginale · 83 linii, 1 968 słów
Podgląd SKILL.md
---
name: vibe-types:lean
description: Lean 4 compile-time safety techniques — dependent types, inductive types, type classes, termination checking, propositions as types, proof automation. Use this skill whenever the user writes Lean 4 code, mentions dependent types, asks about theorem proving, discusses inductive types, type classes, tactics (simp, omega, decide), subtypes, termination proofs, or any Lean type system feature. Also use when formalizing invariants, writing proof-carrying code, or porting type patterns from Scala, Rust, or Haskell to Lean.
version: 0.2.0
---

# Lean 4 — Compile-Time Safety Techniques

> **Base path:** `${CLAUDE_PLUGIN_ROOT}/skills/lean`

## Core tenets

Let the type checker carry as much of correctness as it can. The idea is to move guarantees out of runtime checks, tests, and discipline and into the types, so that holding a value is itself evidence that its invariants hold. Wherever you can, make a bad state impossible to express instead of checking for it later. Treat these as defaults to apply with judgment, not as absolute rules.

- **Make illegal states unrepresentable.** Model the data so that an invalid combination of values does not typecheck. → `usecases/UC01-invalid-states.md`
- **Parse, don't validate.** At the boundary, turn a check into a value of a refined type that proves the check ran, rather than returning a boolean and discarding what you learned. → `catalog/T26-refinement-types.md`
- **Keep a functional core and an imperative shell.** Put the decisions and computation in pure functions that take values and return values, and push the effects (input and output, network calls, database access, the clock, randomness) out to a thin outer layer that calls into that core. The core stays deterministic and easy to test and reason about, and the shell is the only part that talks to the outside world. → `usecases/UC11-effect-tracking.md`
- **Upgrade information at the edges; never re-acquire it in the core.** Every parse, check, or branch gains information. Capture it in a type at the boundary and pass it inward, so that the core relies on the evidence it already has instead of re-deriving it by checking or parsing again. This is the second half of parse-don't-validate, applied to every decision point and not just to input. → `catalog/T58-witness-evidence.md`
- **Prefer a more precise type over a less precise one.** A type is more precise when its inhabitants (the distinct values it can hold, so `Bool` has two and a three-case enum has three) match the values that are legal for the job, holding every value that should occur and as few as possible that should not. A practical rule: among the types that can represent every legal value, choose the one with the fewest inhabitants, since the extra inhabitants are exactly the values that should never occur and that you would otherwise have to check for. For a yes or no choice, `Bool` is more precise than `Int`; a closed enum is more precise than a `String`; `NonEmptyList` is more precise than `List`. A newtype covers a second case: `UserId` and `OrderId` may have the same number of inhabitants as the integer underneath, but as distinct types they can no longer be passed in place of one another. The limiting case, a type with no illegal inhabitants at all, is just make illegal states unrepresentable. → `catalog/T03-newtypes-opaque.md`
- **Add precision where a wrong value would do real harm, and leave low-stakes values plain.** A precise type costs some friction to introduce and use, so add it where that cost is worth it. Reach for one when a wrong value would pass unnoticed (nothing fails to signal it), when it would be expensive (money, access, lost data), when the value crosses a boundary (untrusted input, a public API, anything stored or sent), or when the same fact is relied on in many places or far from where it was first established. Leave a value plain when it is used once, locally, never branched on, and a wrong value would be obvious and harmless, such as a string you only display, a log message, or a one-off script. Before introducing a new type, ask which never-legal value it rules out and what it would cost if that value occurred; if it rules nothing out, keep the plain type.
- **Prefer types over tests to capture invariants.** If the compiler can enforce a property, do not write a test for it. Keep tests for the behavior that types cannot express.
- **Make functions total, and let the compiler force every case.** A total function is defined for every input its parameter types allow: no input makes it throw, hang, or return a meaningless result. There are two ways to get there. Widen the output, returning `Option` or `Result` so that "no answer" becomes a case the caller has to handle. Or narrow the input, for example taking a `NonEmptyList` so that `head` always has an answer. When you match, cover every constructor and avoid a catch-all case unless the set of cases is genuinely open, so that adding a variant later becomes a compile error instead of a silent fall-through. For a branch that genuinely cannot occur, close it with a value of an empty type (the uninhabited type, written `Nothing`, `Never`, `!`, or `Empty` depending on the language), which has no inhabitants and so proves the branch unreachable, rather than throwing a "can't happen" error that a later change can turn into a real crash. Finally, prefer a definition that provably terminates over one you only expect to terminate. → `catalog/T51-totality.md`, `catalog/T28-termination.md`, `catalog/T34-never-bottom.md`
- **Make immutability the default, and mark mutation as the exception.** A value that cannot change after it is constructed cannot quietly become invalid behind the check that vouched for it. Require an explicit, visible marker to opt into mutation or shared aliasing, so that the type records which values are allowed to change. → `catalog/T32-immutability-markers.md`
- **Use state machines when appropriate.** When an object has a lifecycle or a protocol, encode its states as types so that an invalid transition does not compile. These are the invariants that hold across time, between calls, rather than inside a single value. → `usecases/UC13-state-machines.md`
- **Pass authority as a typed value instead of reaching for ambient power.** The right to do something powerful or effectful is itself a value, and a function should receive it as an argument rather than reach for it on its own. Treat as authority the ability to use the filesystem, make a network call, read the clock or a source of randomness, read an environment variable or a secret, start a subprocess, or move money. A function that needs one of these should take it as a parameter (a `Clock`, an `HttpClient`, a `PaymentGateway`, and so on) instead of calling a global or a singleton. A function whose type does not name a given authority then cannot use it, the caller decides what to pass down, and the code becomes easy to test by passing a different value. → `catalog/T12-effect-tracking.md`

## Full catalog (type system features → constraints they enforce)

- **Inductive types & pattern matching** — closed type hierarchies with exhaustive matching; compiler rejects incomplete matches → `catalog/T01-algebraic-data-types.md`
- **Dependent types & Pi types** — return/field types depend on values; compiler checks index consistency → `catalog/T09-dependent-types.md`
- **Structures, inheritance, constructors** — named-field product types with single-constructor guarantees; `extends` for inheritance → `catalog/T31-record-types.md`
- **Type classes & instance resolution** — constrain generic functions to types with required capabilities → `catalog/T05-type-classes.md`
- **Universes & universe polymorphism** — prevent type-in-type paradoxes; `Sort u`, `Type u`, `Prop` → `catalog/T35-universes-kinds.md`
- **Propositions as types (Prop)** — encode invariants as `Prop`; compiler requires proof terms as evidence → `catalog/T29-propositions-as-types.md`
- **Termination & well-founded recursion** — every recursive function must terminate; structural recursion or `termination_by` proof → `catalog/T28-termination.md`
- **Totality, partial functions** — functions must handle all inputs; `partial` opts out but taints the result → `catalog/T51-totality.md`
- **Monads, do-notation, IO** — side effects tracked via monadic types; `IO` demarcates impure computation → `catalog/T12-effect-tracking.md`
- **Coercions & Coe** — automatic safe conversions between types; compiler inserts coercions where declared → `catalog/T18-conversions-coercions.md`
- **Auto-bound implicits & instances** — compiler infers implicit arguments; `[inst : C a]` constrains to types with evidence → `catalog/T38-implicits-auto-bound.md`
- **Macros, elaboration, syntax** — compile-time metaprogramming via `syntax`, `macro_rules`, and `elab` → `catalog/T17-macros-metaprogramming.md`
- **Proof automation (simp, decide, omega)** — automate proof obligations; state what must hold, let tactics verify it → `catalog/T30-proof-automation.md`
- **Subtypes & refinement types** — attach predicates to types (`{ n : Nat // n > 0 }`); construction requires proof → `catalog/T26-refinement-types.md`
- **Opaque definitions & reducibility** — `opaque def` prevents unfolding outside the module; definitional encapsulation → `catalog/T21-encapsulation.md`
- **Notation, attributes, options** — `@[simp]`, `@[inline]`, `@[reducible]` control how the checker treats definitions → `catalog/T39-notation-attributes.md`
- **Literal types** — dependent types subsume literal types; any value can appear in a type via indexing → `catalog/T52-literal-types.md`
- **Path-dependent types** — dependent types subsume path dependence; structures with type-valued fields → `catalog/T53-path-dependent-types.md`
- **Newtypes & opaque definitions** — single-field structures, `abbrev`, `opaque` for hidden definitions → `catalog/T03-newtypes-opaque.md`
- **Null safety** — no null in Lean; `Option α` is the standard pattern → `catalog/T13-null-safety.md`
- **Type narrowing** — pattern matching narrows types; dependent match refines per branch → `catalog/T14-type-narrowing.md`
- **Compile-time computation** — everything is compile-time; `#eval`, `decide`, `simp`, `native_decide` → `catalog/T16-compile-time-ops.md`
- **Equality safety** — `BEq`/`DecidableEq` are opt-in; propositional vs boolean equality → `catalog/T20-equality-safety.md`
- **Callable typing** — first-class functions, dependent function types, automatic currying → `catalog/T22-callable-typing.md`
- **Type aliases** — `abbrev` (reducible), `def` (semireducible), `opaque` (irreducible) → `catalog/T23-type-aliases.md`
- **Erased types & Prop** — `Prop` universe is erased at runtime; zero-cost proof evidence → `catalog/T27-erased-phantom.md`
- **Immutability** — everything immutable by default; `IO.Ref` for controlled mutation → `catalog/T32-immutability-markers.md`
- **Empty & False** — `Empty` type and `False` proposition; `absurd` for impossible cases → `catalog/T34-never-bottom.md`
- **Type lambdas** — type-level functions are just functions; no special syntax needed → `catalog/T40-type-lambdas.md`
- **Match on types** — dependent match works at the type level naturally → `catalog/T41-match-types.md`
- **Const generics** *(via dependent types)* — dependent types subsume value-parameterized types → `catalog/T15-const-generics.md`
- **Union types** *(via inductives)* — `Sum α β` or custom inductives for alternatives → `catalog/T02-union-intersection.md`
- **Generics** *(via type classes)* — instance arguments `[Ord α]` serve as bounds → `catalog/T04-generics-bounds.md`
- **Derivation** *(limited)* — `deriving Repr, BEq, Inhabited`; Mathlib extends further → `catalog/T06-derivation.md`
- **Extension methods** *(via scoped instances)* — namespaced dot notation, `open ... in` → `catalog/T19-extension-methods.md`
- **Coherence** *(via scoping)* — instance priority, `scoped instance`, overlap handling → `catalog/T25-coherence-orphan.md`
- **Self type** *(via dependent types)* — no `Self` keyword; dependent types express this naturally → `catalog/T33-self-type.md`
- **Instance resolution** — synthesis, backtracking, priority ordering → `catalog/T37-trait-solver.md`
- **Context functions** *(via instance arguments)* — `[Ord α]` is automatically supplied → `catalog/T42-context-functions.md`
- **Associated types** *(via structure fields)* — type-valued fields with `outParam` → `catalog/T49-associated-types.md`
- **Runtime polymorphism** *(via coercions + type classes)* — heterogeneous collections, existential wrappers for open dispatch → `catalog/T36-trait-objects.md`

- **Functor / Applicative / Monad** — native type classes; do-notation desugars to bind → `catalog/T54-functor-applicative-monad.md`
- **Monad transformers** — StateT, ReaderT, ExceptT; MonadLift between layers → `catalog/T55-monad-transformers.md`
- **Tagless final** *(via type class abstraction)* — polymorphic interpretation → `catalog/T56-tagless-final.md`
- **Typestate pattern** — indexed inductive types for protocol states → `catalog/T57-typestate.md`
- **Witness & evidence types** — Prop proofs as evidence; Decidable for runtime → `catalog/T58-witness-evidence.md`
- **Existential types** — Sigma types, existential quantification → `catalog/T59-existential-types.md`
- **Recursive types** — inductive types ARE recursive types; termination checked → `catalog/T61-recursive-types.md`
## Use cases (problem → which features help)

- **Preventing invalid states** — make illegal states unrepresentable at compile time (inductive types, subtypes, dependent types) → `usecases/UC01-invalid-states.md`
- **Domain modeling with dependent types** — model domain invariants as type-level constraints the compiler enforces → `usecases/UC02-domain-modeling.md`
- **Totality & exhaustiveness** — every function handles all inputs; no unmatched cases → `usecases/UC03-exhaustiveness.md`
- **Compile-time invariants** — attach invariants to data; compiler verifies them via proofs → `usecases/UC12-compile-time.md`
- **Safe effectful programming** — track side effects via IO and monads; prevent untracked mutation → `usecases/UC11-effect-tracking.md`
- **Generic programming with type classes** — constrain generic code to types with required capabilities → `usecases/UC04-generic-constraints.md`
- **Safe recursion & termination** — all recursion terminates; structural or well-founded proof → `usecases/UC24-termination.md`
- **Encapsulation & module boundaries** — control what leaks across module boundaries → `usecases/UC10-encapsulation.md`
Pliki w paczce (70)
  • README.md 5 KB
  • SKILL.md 15 KB
  • catalog/00-overview.md 9 KB
  • catalog/T01-algebraic-data-types.md 8 KB
  • catalog/T02-union-intersection.md 7 KB
  • catalog/T03-newtypes-opaque.md 6 KB
  • catalog/T04-generics-bounds.md 6 KB
  • catalog/T05-type-classes.md 10 KB
  • catalog/T06-derivation.md 6 KB
  • catalog/T09-dependent-types.md 9 KB
  • catalog/T12-effect-tracking.md 8 KB
  • catalog/T13-null-safety.md 6 KB
  • catalog/T14-type-narrowing.md 7 KB
  • catalog/T15-const-generics.md 7 KB
  • catalog/T16-compile-time-ops.md 7 KB
  • catalog/T17-macros-metaprogramming.md 9 KB
  • catalog/T18-conversions-coercions.md 11 KB
  • catalog/T19-extension-methods.md 8 KB
  • catalog/T20-equality-safety.md 7 KB
  • catalog/T21-encapsulation.md 12 KB
  • catalog/T22-callable-typing.md 7 KB
  • catalog/T23-type-aliases.md 8 KB
  • catalog/T25-coherence-orphan.md 9 KB
  • catalog/T26-refinement-types.md 9 KB
  • catalog/T27-erased-phantom.md 7 KB
  • catalog/T28-termination.md 10 KB
  • catalog/T29-propositions-as-types.md 9 KB
  • catalog/T30-proof-automation.md 10 KB
  • catalog/T31-record-types.md 9 KB
  • catalog/T32-immutability-markers.md 9 KB
  • catalog/T33-self-type.md 8 KB
  • catalog/T34-never-bottom.md 6 KB
  • catalog/T35-universes-kinds.md 10 KB
  • catalog/T36-trait-objects.md 7 KB
  • catalog/T37-trait-solver.md 8 KB
  • catalog/T38-implicits-auto-bound.md 9 KB
  • catalog/T39-notation-attributes.md 9 KB
  • catalog/T40-type-lambdas.md 7 KB
  • catalog/T41-match-types.md 7 KB
  • catalog/T42-context-functions.md 9 KB
  • catalog/T49-associated-types.md 9 KB
  • catalog/T51-totality.md 10 KB
  • catalog/T52-literal-types.md 10 KB
  • catalog/T53-path-dependent-types.md 10 KB
  • catalog/T54-functor-applicative-monad.md 9 KB
  • catalog/T55-monad-transformers.md 7 KB
  • catalog/T56-tagless-final.md 7 KB
  • catalog/T57-typestate.md 10 KB
  • catalog/T58-witness-evidence.md 7 KB
  • catalog/T59-existential-types.md 7 KB
  • catalog/T61-recursive-types.md 8 KB
  • usecases/00-overview.md 1 KB
  • usecases/UC01-invalid-states.md 5 KB
  • usecases/UC02-domain-modeling.md 3 KB
  • usecases/UC03-exhaustiveness.md 3 KB
  • usecases/UC04-generic-constraints.md 3 KB
  • usecases/UC06-immutability.md 4 KB
  • usecases/UC07-callable-contracts.md 4 KB
  • usecases/UC08-error-handling.md 5 KB
  • usecases/UC09-builder-config.md 5 KB
  • usecases/UC10-encapsulation.md 3 KB
  • usecases/UC11-effect-tracking.md 3 KB
  • usecases/UC12-compile-time.md 3 KB
  • usecases/UC13-state-machines.md 5 KB
  • usecases/UC14-extensibility.md 6 KB
  • usecases/UC15-equality.md 4 KB
  • usecases/UC16-nullability.md 4 KB
  • usecases/UC18-type-arithmetic.md 5 KB
  • usecases/UC19-serialization.md 5 KB
  • usecases/UC24-termination.md 3 KB

Wersje

W bazie nie ma innych skilli o nazwie vibe-types:lean.

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

Pobrania w ostatnich 30 dniach: 1 · ranking

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

Podobne skille

  • 90vibe-types:scala
    Podpowiada techniki kontroli typów w Scali 3: typy nieprzezroczyste, ADT, givens, typy dopasowań i wzorce przeniesione z Rust, Pythona lub Haskella.
  • 90vibe-types:rust
    Podpowiada techniki kontroli typów w Rust w czasie kompilacji: własność, pożyczanie, czasy życia, cechy i Send oraz Sync.
  • 85Scala Type System
    Omawia system typów Scali: generyki, wariancję, ograniczenia typów, konwersje niejawne, type classes, typy wyższego rzędu, typy zależne od ścieżki i abstrakcyjne składowe typów.
  • 100writing-lean-proofs
    Pisze i sprawdza uporządkowane dowody w Lean 4 oraz projektuje biblioteki zgodne z konwencjami Mathlib.
  • 100writing-lean-proofs
    Pomaga projektować, pisać, recenzować, refaktoryzować i lintować dowody, biblioteki i taktyki w Lean 4 oraz diagnozować ich wydajność.
  • 100lean
    Wspiera pracę w Lean 4: naprawa dowodów, rozwój twierdzeń, programy weryfikowane, projekt modeli i specyfikacji, dowody terminacji, wyszukiwanie w Std i mathlib, diagnostyka Lake oraz audyty zaufania.

Uwagi i zgłoszenia

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