The Lean library for numerical methods
Numerical methods,
proved.
A Lean 4 library of numerical analysis with machine-checked proofs of convergence, stability, and error bounds — built on Mathlib.
Open source · Apache-2.0 · every method ships with its proof ∎
/-- Newton's method converges quadratically near a simple root. -/ theorem newton_quadratic_convergence {f : ℝ → ℝ} {r : ℝ} (hf : ContDiff ℝ 2 f) (hr : f r = 0) (hr' : deriv f r ≠ 0) : ∃ δ > 0, ∃ C, ∀ x₀ ∈ ball r δ, ∀ n, ‖newton f x₀ (n + 1) - r‖ ≤ C * ‖newton f x₀ n - r‖ ^ 2 := by -- error at step n+1 is bounded by the square of the error at step n ∎
NumLib
A shared, proof-carrying foundation for numerical computing.
Numerical methods are approximate and iterative; their guarantees are exact and provable. NumLib is where the two meet — every algorithm is paired with theorems about what it actually delivers, checked by the Lean kernel.
Proofs, not just code
A method without a theorem about its behavior is incomplete. NumLib formalizes consistency, convergence order, stability, conditioning, and error bounds — and proves them.
Reuse over reinvention
Built on Mathlib's analysis, topology, and linear algebra, and organized around reusable abstractions so results connect across the library instead of standing alone.
NumLib.*
What's inside
Areas grow with contributions. Each ships definitions and the proofs that justify them.
Numerical linear algebra
Classical and modified Gram–Schmidt orthogonalization with machine-checked proofs of orthogonality, span preservation, and nonzero outputs.
lake
Get started
Add NumLib to your Lean 4 project by requiring it in your lakefile.toml, then fetch it with lake update. It tracks a recent Lean toolchain and Mathlib.
Browse everything, fully cross-referenced, in the API reference.
Open the API docs →[[require]] name = "NumLib" scope = "mohittkr" rev = "main"
# fetch the dependency lake update NumLib
Support the project
Sponsors keep the proofs compiling.
NumLib is community-built and independent. Sponsorship funds maintenance, continuous integration, and the infrastructure behind the public API docs — so the library stays green against every new Lean and Mathlib release.
Institutional partners
Sponsors
Become a sponsor
Back formally verified numerical computing. Sponsors are credited here and in the repository; institutional partners can be featured with a logo and link.