Lean 4 (4.31)

This assessment applies the coupling account — coupling as access to a shared resource, and the coupling floor [1], [2] — and the knowledge-embodiment theorem [3]; the language is assessed against its official reference [4].

Snapshot Lean 4 (4.31) — released 13 June 2026 · lifecycle superseded (successor release 4.34 (September 2026))

Family Lean — shelf: Verification and Proof

The language’s purpose is to make a machine check a claim about a program. A shelf groups; it does not classify — the tags below carry every use, paradigm, and platform of this snapshot.

Trajectory Lean 1 (2013 — project begins) · Lean 4.0 (April 2023 — first stable Lean 4) · 4.31 (13 June 2026 — assessed release)

Tags

Use — Verification

Paradigm — Functional

Platform — Native

Lifecycle — Superseded

Memory — Reference counted

Typing — Static, strong

Resources

The language’s official entry points, and the documents that name the release this page assesses. A link marked this release pins the document to Lean 4 (4.31); an unmarked link is the current reference for the language.

Landing page

Specification and reference

API documentation

Tutorial

Package registry

1 Assessment

This page assesses Lean 4 in five parts: core coupling — what the language’s own constructs force; ecosystem coupling — what the surrounding platform, tooling, and community cost; engineering readiness — whether the artifact can be reproduced, verified, observed, worked in quickly, connected to other languages, and governed openly; the profile — the unscored facts a score cannot express; and the scoring detail — the mechanism marks and the arithmetic behind every score. A ✅ bullet marks a construct that helps. A ⚠️ or ❌ bullet marks a cost; the scoring model does not price every cost named here.

Core coupling 94.6/100 · Ecosystem coupling 86.3/100 · Engineering readiness 56.7/100

1.1 Core coupling

1.1.1 Type

  • ✅ Dependent types let a type name a value: Vector α n and Fin n carry the length in the type, so a length mismatch and an out-of-range index are rejected at elaboration
  • ✅ Propositions are types, so a proof is a term: The Curry–Howard correspondence puts a theorem and a program in one system, and the same kernel checks both
  • ✅ A structure type names its fields and their types: structure with typeclass fields gives a record whose construction is checked, and where supplies the values by name
  • ✅ Typeclass resolution is checked instance search: An instance is found by the declared class at compile time, so a missing instance is an elaboration error rather than a run-time lookup
  • ✅ Subtype couples a value to its proof: {x // p x} is a pair of a value and a proof that the predicate holds, so an invariant is carried by the term itself
  • ✅ unsafe marks the one escape from the logic: A declaration that bypasses the kernel must be named unsafe, so the boundary is visible in the source

1.1.2 Construction

  • ✅ Construction runs through the kernel, so an invariant cannot be skipped: A value of an inductive type is built by its constructors, and a term that does not fit the type fails elaboration
  • ✅ where puts the field values beside the type: An instance of a structure is written with named fields, so a reader does not count an argument list
  • ✅ macro and syntax extend the surface at the definition site: A notation for the domain is declared once and then used like a built-in
  • ✅ deriving generates the mechanical instances: Repr, BEq, Hashable, and Inhabited are produced by the elaborator, so a type does not repeat boilerplate
  • ✅ do notation builds the effectful value: Construction in IO, Option, or Except is written as a sequence of binds
  • ⚠️ Termination is an obligation on every definition: A recursive def must be shown to terminate structurally or by a decreasing measure, so a natural formulation of an algorithm can need a proof before it compiles

1.1.3 Memory

  • ✅ The compiler inserts the reference counting: Borrow inference decides which arguments are borrowed and which are owned, and emits the retain and release operations, so a pure definition never writes one
  • ✅ There is no tracing collector: A value is reclaimed when its last reference goes away, so there is no collection pause to plan around
  • ✅ A value of an inductive type is immutable: No term updates a field in place, so sharing is safe by construction
  • ⚠️ A reference cycle is not collected: A mutable reference cell (IO.Ref) whose value points back to the cell keeps its storage alive, because reference counting has no cycle detector
  • ⚠️ Allocation is not controllable from the source: The allocator is not a parameter and there is no placement control, so a program cannot choose where a value lives
  • ⚠️ A deeply shared structure still pays a count per reference: A persistent structure that shares a subtree is counted at every edge, and the compiler removes many but not all of those operations

1.1.4 Error

  • ✅ Option α and Except ε α are the error types: A partial function returns a value that states the failure, and do notation sequences the recovery path
  • ✅ A total function cannot fail by definition: In the pure fragment the type states that the function returns, and partial is required to opt out of that guarantee
  • ✅ Decidable turns a proposition into a branch that is total: if h : p then ... else ... computes from a proof of decidability, so the two branches cover the cases by construction
  • ✅ There are no exceptions in the logic: An error is a value in the return type, so a computation that can fail carries the failure in its signature rather than raising out of it
  • ⚠️ panic! and an IO failure leave the kernel’s guarantee: An abort at run time is not a term in the logic, and the type of the function does not mention it
  • ⚠️ Error-freedom is a theorem, not an automatic result: To state that a function never fails, you prove it; the compiler does not derive the property

1.1.5 Concurrency

  • ✅ The pure fragment has no shared mutable state: A mathematical term is a value with no location, so two proofs cannot race by construction
  • ✅ Task gives structured, joinable parallelism in IO: A task is a value that can be awaited, so a spawned computation is joined through its result
  • ⚠️ There is no concurrency construct in the language: Parallelism lives in the IO monad through Task and the promise cell, so a concurrent program is an IO program like any other
  • ⚠️ A promise carries a value between tasks and the program orders its use: Nothing in the type states when the value becomes available
  • ✅ The runtime owns the thread pool: The scheduler and its thread count are runtime settings, so the language does not expose a thread object
  • ⚠️ The kernel says nothing about a task’s behaviour: A theorem about a function does not constrain the parallel schedule that runs it

1.1.6 Platform

  • ❌ Lean 4 is the only implementation: The language is defined by its own elaborator and kernel, so there is no second independent compiler to test the specification against (P1)
  • ✅ The trusted kernel is small and portable: The elaborator is written in Lean and the kernel is a compact checker, so the language does not rest on a large run-time
  • ✅ @[extern] and @[export] make the foreign boundary a declaration: A call out to C is written and recorded, so the escape from the language is visible in the source
  • ✅ The output is C, so the target set is the C compiler’s: The compiler emits C and hands it to a C back end, so a Lean program runs where a C program runs
  • ⚠️ A native build needs a C toolchain and the Lean runtime: The build environment is part of the platform, and a deployed binary carries the runtime
  • ⚠️ The toolchain moves in nightly steps: A project pins its version in lean-toolchain, and a dependency may require a different one

1.1.7 Trade-offs (not coupling)

  • Proof work is a separate effort from programming: A def is not obliged to carry a proof, and requiring one is the author’s decision
  • The kernel is deliberately small and the tactics are not trusted: A tactic produces a term that the kernel rechecks, which is a decision about where trust sits
  • partial and unsafe are the intended escape hatches: A non-terminating or pointer-touching definition is expressible, at the cost of its guarantee
  • Typeclass search is a proof search with a cost: An instance can be ambiguous or expensive to find, and that is an elaboration property rather than a run-time coupling
  • The library is one large shared body: mathlib’s definitions belong to the community, so a development inherits its choices instead of buying a library
  • The audience is mathematics and verification: The adoption of the language follows from that, and it is a market fact rather than a mechanism of the language

1.2 Ecosystem coupling

1.2.1 Performance

  • ✅ The compiler emits C, and a native optimiser then compiles it: The generated C passes through a mature C back end, so the run-time cost benefits from that pipeline
  • ✅ Borrow inference removes most reference-count traffic: The compiler’s borrow analysis turns many retain and release pairs into nothing, so a pure functional definition stays close to imperative cost
  • ✅ @[inline] and @[specialize] remove an abstraction at the seam: A monomorphic specialisation of a polymorphic definition is generated on request
  • ✅ Compile-time evaluation removes run-time work: A proof discharged by decide or native_decide is computed while the project is built
  • ⚠️ Elaboration dominates the build time: Typeclass search, tactic execution, and proof checking are spent at compile time, so a large development builds slowly even when its binary is small
  • ⚠️ A count is not free on a shared structure: A persistent structure counted at each edge still pays for the sharing the compiler cannot prove away

1.2.2 Ecosystem

  • ❌ The package universe is small: Dependencies are resolved from git by lake, and the practical library set is mathlib, the core library, and a few support packages (Ec3)
  • ✅ lake is a standard build tool and dependency resolver: lakefile.lean or lakefile.toml declares a package, lake build builds it, and lake-manifest.json records the resolved revisions
  • ✅ The editor integration is first class: The Lean 4 server speaks LSP and the infoview shows the goal, the hypotheses, and the diagnostics beside the source
  • ✅ mathlib is one of the largest libraries of formalised mathematics: It is developed in the open and its continuous integration checks every proof
  • ⚠️ The community is academic and small: The centre of gravity is mathlib, the Zulip chat, and the university groups, and industrial use is rare
  • ⚠️ A project’s revision set is tight against the toolchain: mathlib tracks recent Lean releases, so a project that pins an older toolchain cannot use the current mathlib

1.2.3 Evolution

  • ✅ A project pins its toolchain and its dependency revisions: lean-toolchain names the version and lake-manifest.json names the commits, so a build is reproducible without a separate lock convention
  • ✅ Lean 4 is the stable line and its minor releases are backward compatible: A project on a pinned version is not moved by a release it did not take
  • ✅ The language and its libraries are open and publicly discussed: The request-for-comments archive and the community chat record why a feature changed
  • ⚠️ Lean 4 replaced Lean 3 with a different language: A Lean 3 development is a porting project, and the mathematical libraries moved with the new language
  • ⚠️ The ecosystem moves in nightly steps: A feature can land in a nightly build and reach a stable release later, so a dependency may require a version the project has not taken

1.2.4 Domain

  • ✅ Proof engineering and formalised mathematics are the native domain: theorem, by, simp, and mathlib are built for that work
  • ✅ Verified systems programming is supported: A verified algorithm compiles to C and ships as an ordinary binary, which is the growing use of the language
  • ✅ It is a general-purpose functional language beside the proof assistant: A def with no proof obligation is ordinary functional code
  • ❌ The domain lock-in is the point of the tool: The language expects a proof-carrying artifact, and a program that states no theorem gets little from the system (D1)
  • ⚠️ mathlib is a shared global body rather than a set of packages: A mathematical development is expected to build on its definitions, so the notation and the lemma names belong to the community
  • ⚠️ A formalisation is a research and maintenance commitment: A proof tracks the definitions it is about, so a change to one of them can invalidate a development

1.2.5 Learning

  • ❌ The curve is very steep: Dependent types, the elimination rules, and the elaborator’s inference model are new to a working programmer (L1)
  • ❌ Proof writing is a second skill on top of programming: Tactic scripts, the simp sets, and the explicit proof term are a subject of their own
  • ❌ The elaboration is not visible in the source: Why a by simp succeeded, or why an instance was not found, must be read from the goal state and the options (L3)
  • ✅ The infoview shows the goal and the hypotheses at the cursor: The state is displayed rather than inferred by the reader
  • ✅ The libraries supply the lemmas: An algebra or order fact is used without being reproved
  • ⚠️ The documentation trail is uneven: The reference manual is complete for the language, but much elaboration behaviour is documented in the source, and the community’s books are a growth area

1.2.6 Syntax

  • ✅ Term syntax reads like mathematics: ∀ x, P x → Q x, ∃, fun x => ..., and infix notation for the relations the library defines
  • ✅ Notation is declared and hygienic: notation, infix, and macro add a form where it is defined, so the surface can match the domain
  • ✅ do notation sequences effects as statements: let, if, and for inside do read like an imperative body over a monad
  • ✅ Pattern matching is checked for exhaustiveness: A missing constructor is a compile-time error, so a case is not forgotten
  • ⚠️ Layout is significant: do, by, and where blocks are delimited by indentation, so a re-indentation changes the parse
  • ⚠️ A macro can change what a line means: macro and elab rewrite the surface, so the reader must know the notation the library installed

1.2.7 Testing

  • ✅ #eval runs a term in the file: A definition can be evaluated and printed beside its proof, and #check reports its type
  • ✅ example and by decide state a checked claim inline: A decidable proposition is proved by evaluation, and an example block is a test the elaborator runs
  • ✅ lake test runs the project’s test executable: A test driver is declared in the package and run by the build tool
  • ✅ #print axioms reports the assumptions behind a theorem: A proof that used sorry or an extra axiom shows the dependency, so an unchecked step is discoverable
  • ⚠️ native_decide extends the trusted base: It closes a goal by evaluating compiled code, so the compiler and the runtime, not only the kernel, are relied on
  • ⚠️ An IO program is outside the logic: The behaviour of a program that reads a file or a socket is tested as an ordinary program rather than proved

1.2.8 Security

  • ✅ The kernel rechecks every proof term: A theorem that elaborates cannot be invalid, so a claimed property is a checked one
  • ✅ sorry is visible and reportable: The placeholder closes any goal with a warning, and #print axioms shows that it was used, so an unfinished proof is discoverable rather than hidden
  • ✅ unsafe names the escape from the logic: A declaration that bypasses the kernel is marked, so the boundary can be found in the source
  • ✅ No pointer type exists in the language surface: A term written without unsafe cannot express an address, so the memory-safety class of bugs is outside the pure fragment
  • ⚠️ The trusted base is wider than the kernel in a native binary: The runtime, the C compiler, and the runtime’s primitives are all in the path of a compiled program
  • ⚠️ There is no capability model: IO gives a program the authority of the operating system, and the sandbox is the operating system’s

1.2.9 Delivery targets

What ships from a producer to a consumer, and whether the interface across a release boundary is promised. Ec8 is present when one compiled target crosses with no promise.

Target Ships as Crosses a producer boundary Cross-release promise
lake package source source no lake builds the package and regenerates its .olean cache on the target toolchain

1.3 Engineering readiness

1.3.1 Reproducibility

  • ❌ Lake resolves dependency versions from the manifest at build time. (Y1)

1.3.2 Supply chain

  • ❌ Reservoir packages carry no signed provenance. (Y3)
  • ❌ The package registry is a flat name space. (Y4)
  • ❌ No advisory feed covers Lean packages. (Y16)

1.3.3 Observability

  • ❌ No tracing standard exists in the language. (Y5)
  • ❌ IO.println carries no structure. (Y6)
  • ❌ A panic prints a message and exits; no post-mortem is written. (Y15)

1.3.4 Feedback

  • ❌ No debugger ships with the toolchain. (Y13)

1.3.5 Interop

  • ❌ The artifact runs on the platforms the release toolchains cover. (Y10)

1.3.6 Governance

  • ✅ The Lean FRO and the community govern in the open. (Y11)
  • ✅ The reference manual is public. (Y12)
  • ✅ The compiler and the theorem prover are public source. (Y19)

1.4 Profile

Unscored, and kept separate from every score on purpose. The profile records what a mechanism price cannot express: what a running program costs, how well a coding model and an agent work in the language, and whether a safety-critical path exists.

1.4.1 Energy and cost

What this axis asks: what does a running program cost in energy and time?

  • ✅ Compiles to native code: the fastest class in the language energy and time benchmarks [5], [6]. A causal re-analysis attributes the difference to execution time [7].

1.4.2 AI and agent readiness

What this axis asks: how well does a coding model and an agent work in this language?

  • ❌ Sparse training data: models write it unreliably [8].

1.4.3 Safety certification

What this axis asks: is there a certified or standards-qualified path to a safety-critical system?

  • ⚠️ No certified or standards-qualified path for safety-critical systems.

1.5 Scoring detail

1.5.1 Core coupling Dimensions

Dimension Mechanism Description Imposed by Present Weight
Type T1 dynamic no static check language — 0
T2 weak static language — 0
T3 dynamic/duck dispatch language — 0
T4 no sum types language — 0
T5 no generics language — 0
T6 no namespaces language — 0
T7 type erasure/reflection language — 0
T8 operator overloading language — 0
T9 inheritance required for polymorphism language — 0
T10 no null-safety language — 0
T11 no module boundary language — 0
T12 no effect tracking language — 0
T13 async/sync colouring language — 0
T14 unchecked foreign boundary language ✅ −4
T15 chars are encoding units language — 0
Type cost −1.1 (−4)
Construction C1 global mutable state by default language — 0
C2 no immutability by default language — 0
C3 constructors coupled to allocation language — 0
C4 no constructor/validation language — 0
C5 unpinned collection order language — 0
C6 aliasing by default language — 0
C7 undeclared control transfer language — 0
C8 no source-visible init order language — 0
Construction cost 0
Memory M1 manual deallocation runtime — 0
M2 GC non-deterministic pauses runtime — 0
M3 no RAII language — 0
M4 no ownership model language — 0
M5 uninitialized reads language — 0
M6 unchecked reinterpretation language — 0
Er6 uncatchable runtime fault language — 0
M7 reference cycles leak runtime — 0
Memory cost 0
Error Er1 no structured path language — 0
Er2 unchecked exceptions only language — 0
Er3 errors ignored/non-exhaustive language — 0
Er4 no composable result type language — 0
Er5 no isolation unit for a fault runtime — 0
Error cost 0
Concurrency K1 GIL/no parallel runtime — 0
K2 shared mutable state default language — 0
K3 manual sync no race detection runtime — 0
K4 no structured concurrency language — 0
K5 no primitives language — 0
K6 thread-per-task cost runtime — 0
Concurrency cost 0
Platform P1 cannot function outside one vendor/domain context ✅ −15
P2 single-vendor but other uses context — 0
P3 legacy/discontinued platform context — 0
P4 poor domain fit context — 0
Platform cost −4.3 (−15)

Core coupling score: 94.6/100 — 19 of the 350 inventory points are present, so the axis cost is 100 × 19 ÷ 350 = 5.4 and the score is 100 − 5.4. Each dimension’s cost above is its share of the same denominator, and the raw weight sum follows in parentheses.

1.5.2 Ecosystem coupling Dimensions

Dimension Mechanism Description Imposed by Present Weight
Performance R1 interpreted no AOT/JIT runtime — 0
R2 GC pauses runtime — 0
R3 JIT warmup runtime — 0
Performance cost 0
Ecosystem Ec1 no package manager context — 0
Ec2 fragmented tooling context — 0
Ec3 small/niche/discontinued context ✅ −8
Ec4 proprietary context — 0
Ec5 platform-locked tooling context — 0
Ec6 monoculture context — 0
Ec7 legacy burden context — 0
Ec8 unpromised binary boundary context — 0
Ec9 unpromised data boundary context — 0
Ecosystem cost −3.1 (−8)
Evolution V1 breaking changes language — 0
V2 frozen context — 0
V3 discontinued context — 0
V4 glacial standards context — 0
V5 silent default drift runtime — 0
V7 build-variant state space context — 0
Evolution cost 0
Domain D1 domain/vendor lock-in context ✅ −15
D3 framework forces architecture context — 0
Domain cost −5.9 (−15)
Learning L1 steep context ✅ −8
L2 large surface/multi-paradigm context — 0
L3 sparse docs context ✅ −4
Learning cost −4.7 (−12)
Syntax S1 verbose language — 0
S2 inconsistent language — 0
S3 punctuation-heavy language — 0
Syntax cost 0
Testing G1 weak tooling context — 0
G2 poor debugging context — 0
G3 runtime-only errors context — 0
G4 no published monotonic clock runtime — 0
Testing cost 0
Security Q1 memory-unsafe language — 0
Q2 dynamic/weak typing risk language — 0
Q3 known vulnerability/injection context — 0
Q4 silent integer overflow language — 0
Security cost 0

Ecosystem coupling score: 86.3/100 — 35 of the 256 inventory points are present, so the axis cost is 100 × 35 ÷ 256 = 13.7 and the score is 100 − 13.7. Each dimension’s cost above is its share of the same denominator, and the raw weight sum follows in parentheses.

1.5.3 Engineering readiness Dimensions

Dimension Mechanism Description Imposed by Present Weight
Reproducibility Y1 build not reproducible context ✅ −15
Y2 dependencies not pinned context — 0
Y14 no toolchain version pin context — 0
Y18 no machine-read project contract context — 0
Reproducibility cost −8.8 (−15)
Supply chain Y3 no signed provenance context ✅ −15
Y4 registry without namespacing context ✅ −4
Y16 no advisory feed context ✅ −8
Supply chain cost −15.8 (−27)
Observability Y5 no stable tracing standard context ✅ −8
Y6 no structured logging context ✅ −4
Y15 no post-mortem diagnostics runtime ✅ −8
Observability cost −11.7 (−20)
Feedback Y7 slow build context — 0
Y8 no fast in-editor analysis context — 0
Y13 no bundled debugger context ✅ −8
Feedback cost −4.7 (−8)
Interop Y9 no foreign-function interface language — 0
Y10 no portable target context ✅ −4
Interop cost −2.3 (−4)
Governance Y11 single-vendor governance context — 0
Y12 closed specification context — 0
Y17 no conformance mechanism context — 0
Y19 no published parser context — 0
Governance cost 0

Engineering readiness score: 56.7/100 — 74 of the 171 inventory points are present, so the axis cost is 100 × 74 ÷ 171 = 43.3 and the score is 100 − 43.3. Each dimension’s cost above is its share of the same denominator, and the raw weight sum follows in parentheses.

Verdict: Lean 4’s design produces the highest core score here, because its constructs are separating by construction. Dependent types let a type state a property of a value, propositions-as-types puts the specification and the program in one term, and the kernel rechecks every proof, so an invalid claim does not elaborate. Reference counting with borrow inference keeps the memory story deterministic and out of the source. Main strengths: an exact fit to mathematics and verification, a small trusted kernel, and a first-class editor and library. Main weaknesses: the language has a single implementation, the library universe beyond mathlib is small, the toolchain moves in nightly steps, and the curve is among the steepest.


The formal development. The definitions, theorems, and proofs behind this page are published in:

All published papers

References

[1]
Y. Loth, “On the nature of coupling: All coupling as shared resource access.” Zenodo, Aug. 2026. doi: 10.5281/zenodo.21925121.
[2]
Y. Loth, “Coupling as a consequence of cohesion: Decomposition, the coupling floor, and domain-imposed coupling.” Zenodo, Aug. 2026. doi: 10.5281/zenodo.21925201.
[3]
Y. Loth, “On the nature of cohesion: Cohesion as correctness relative to a partitioning rule.” Zenodo, Jul. 2026. doi: 10.5281/zenodo.20492912.
[4]
Lean Focused Research Organization, “Lean language reference.” Lean, 2024. Available: https://lean-lang.org/doc/reference/latest/
[5]
R. Pereira et al., “Energy efficiency across programming languages: How do energy, time, and memory relate?” in Proceedings of the 10th ACM SIGPLAN international conference on software language engineering (SLE), 2017, pp. 256–267. doi: 10.1145/3136014.3136031.
[6]
R. Pereira et al., “Ranking programming languages by energy efficiency,” Science of Computer Programming, 2021, doi: 10.1016/j.scico.2021.102609.
[7]
N. van Kempen, H.-J. Kwon, D. T. Nguyen, and E. D. Berger, “It’s not easy being green: On the energy efficiency of programming languages,” in Proceedings of the 40th IEEE/ACM international conference on automated software engineering (ASE), 2025. doi: 10.1109/ASE63991.2025.00131.
[8]
S. Joel, J. J. Wu, and F. H. Fard, “A survey on LLM-based code generation for low-resource and domain-specific programming languages,” ACM Transactions on Software Engineering and Methodology, 2025, doi: 10.1145/3770084.