
S
Spivak Lean
Open Sourceπ Alt to MetamathSpivak's classic Calculus formalized entirely in Lean 4
π³ Self-Hostableπ No Sign-upβ‘ Editorial Signal: 77/100β
46 Stars
git clone https://github.com/stormj-UH/spivak-lean.gitThis repository provides a complete formalization of Michael Spivak's legendary Calculus textbook using the Lean 4 theorem prover. It rigorously verifies every single theorem and problem from the text, serving as an invaluable resource for mathematicians and students learning interactive theorem proving.
Covers every theorem and problem from Spivak's foundational Calculus text.
Built on the modern Lean 4 theorem prover for fast execution and robust tactics.
Guarantees absolute mathematical correctness through rigorous computer verification.
Learning interactive theorem proving and formal verification using familiar calculus concepts
Verifying complex epsilon-delta proofs and mathematical analysis arguments automatically
Creating machine-checkable curriculum materials for undergraduate analysis courses
Unlike general mathematical libraries, this project targets a specific, beloved textbook curriculum, making formal methods vastly more approachable for students.
Mathematicians, computer science researchers, and students bridging formal methods with classical analysis.
Spivak Lean is engineered to eliminate critical operational friction in open source alternatives. From an architectural standpoint, the system adopts a local-first, self-contained deployment posture, ensuring streamlined onboarding and minimal setup overhead.
Because the underlying code is fully open-source, engineering teams can audit security implementations, inspect telemetry vectors, and extend functionality via custom fork without risk of sudden vendor deprecation.
Spivak Lean is architected as an exhaustive mathematical formalization repository targeting Michael Spivakβs classic single-variable Calculus treatise, implemented entirely within the Lean 4 interactive theorem prover. The codebase relies upon Lean 4's foundational Calculus of Inductive Constructions (CIC), incorporating proof irrelevance, universe polymorphism, and impredicative proposition typing. The parsing and elaboration pipeline translates mathematical definitions and theorems into strictly typed abstract syntax trees, where dependent function types encode both mathematical propositions and computational transformations. The kernel executes independent proof checking, ensuring that no informal hand-waving or implicit mathematical leaps bypass computational verification. Rather than operating in isolation, the project heavily integrates with Lean 4βs mathematical library (Mathlib4), consuming formalized topologies, filter convergence structures, and the axiomatic definition of real numbers (β) constructed via Dedekind cuts or Cauchy sequences. Limit definitions are formalized using rigorous epsilon-delta formulations alongside filter bases. Automated decision tactics, including linarith for linear integer and real arithmetic, ring for commutative ring equalities, norm_num for numerical evaluations, and simp for term rewriting, are systematically deployed. The entire repository compiles into modular object files (.olean) managed by the Lake build system, ensuring deterministic proof artifact generation.
Developer ergonomics in Spivak Lean are tailored for mathematicians, logicians, and computer scientists working within modern proof-assistant environments. The primary interface is powered by the Lean 4 Language Server Protocol (LSP) integrated into Visual Studio Code or Neovim, featuring an interactive infoview sidebar. As users navigate proofs, the infoview displays real-time tactical state introspection, detailing active hypotheses, open proof goals, and typeclass resolution traces. The repository organizes source files mirroring the textbookβs chronological pedagogical structure, spanning foundational axioms, limits, continuity, differentiation, and the Fundamental Theorem of Calculus. The command-line workflow centers on Lake, Lean's native package and build orchestrator. Developers execute lake build to verify all proofs concurrently across available CPU cores, or lake clean to purge cached compilation artifacts. Diagnostic error reporting is precise, highlighting exact source coordinates where tactic synthesis fails, goals remain unsolved, or type mismatches occur between expected and synthesized terms. Proof refactoring is enhanced by structured tactic blocks using have, show, and calc environments, allowing transparent calculation chains. However, steep learning curves exist for practitioners unfamiliar with functional programming or dependent type theory, necessitating familiarity with Mathlib4's vast hierarchical typeclass taxonomy.
Spivak Lean is distributed under the permissive open-source Apache 2.0 license, allowing educators, researchers, and software engineers to study, adapt, and integrate the formalization without commercial royalties or proprietary restrictions. From a Total Cost of Ownership perspective, direct financial costs are negligible, but computational and operational overheads are substantial. The formalization relies extensively on Mathlib4, a colossal mathematical library comprising millions of lines of Lean code. Compiling Mathlib4 dependencies from scratch requires significant compute: workstations typically demand at least 16 gigabytes of system RAM and a multi-core CPU, with cold compilation times often exceeding one hour unless pre-compiled Lake binary caches (lake exe cache get) are fetched. Continuous integration workflows on platforms like GitHub Actions consume noticeable runner minutes, mandating aggressive artifact caching strategies. Operational maintenance demands continuous alignment with the rapidly evolving Lean 4 compiler toolchain. The project maintains a lean-toolchain pinning file to prevent breaking language regressions and API deprecations in upstream Lean releases. The project operates with zero external network tracking, zero analytical telemetry, and complete offline verifiability, ensuring permanent preservation of formalized mathematical truth without reliance on cloud services.
Spivak Lean is production-ready for educational institutions, formal methods researchers, and university mathematics departments seeking an authoritative, machine-checked reference curriculum for rigorous undergraduate analysis. It provides an unassailable gold standard for automated homework verification, interactive theorem proving pedagogy, and algorithmic mathematics exploration, far surpassing the mechanical expressiveness of legacy systems like Metamath, Isabelle/HOL, or Coq/Rocq for classical calculus pedagogy. Conversely, it is completely unsuitable for engineering teams seeking quick numerical calculus calculations, symbolic algebraic manipulation, or runtime scientific computation, where established numerical suites like NumPy, SciPy, or Julia are appropriate. The primary failure mode stems from upstream toolchain drift: upgrading Lean 4 or Mathlib4 minor versions frequently introduces breaking tactic changes, necessitating periodic manual lemma rewrites and proof repairs. Furthermore, onboarding developers requires substantial training in dependent types and formal analysis. For production deployment in pedagogical settings, instructors should distribute standardized Docker development containers with pre-fetched Lake caches, or host browser-based Lean 4 WebAssembly environments to shield students from local Lake build complexities. When deployed as a structured reference guide, Spivak Lean represents a monumental triumph of modern proof verification over traditional pencil-and-paper mathematical literature.
Spivak Lean is 100% free and open-source under an open software license. There are no mandatory monthly subscription fees to access the source code or run it locally.
Unlike general mathematical libraries, this project targets a specific, beloved textbook curriculum, making formal methods vastly more approachable for students.
Yes. Spivak Lean is designed for self-hosting via Docker or direct server deployment. Running on your own infrastructure allows you to maintain direct control over your local compute, database storage, and operational environment.
No account creation or credit card is required to evaluate Spivak Lean. You can immediately access core features or run it locally without onboarding friction.
You can launch or test Spivak Lean quickly using the following command: git clone https://github.com/stormj-UH/spivak-lean.git Visit the official portal at https://github.com/stormj-UH/spivak-lean for documentation and guides.
ToolsRadar maintains strict editorial independence. This review of Spivak Lean was conducted using our standardized 5-pillar evaluation framework (Setup, Code Auditability, Maintenance Vitality, Cost Advantage, and Community Signal). We do not accept paid placements to inflate benchmark scores.
Maintainers of Spivak Lean and community advocates can display this real-time verification badge in your GitHub README, official documentation, or landing page.
[](https://lordorange.top/tool/spivaks-calculus-formalized-in-lean-4-every-theorem-every-pr)<a href="https://lordorange.top/tool/spivaks-calculus-formalized-in-lean-4-every-theorem-every-pr" target="_blank"><img src="https://lordorange.top/badge/spivaks-calculus-formalized-in-lean-4-every-theorem-every-pr.svg" alt="Featured on ToolsRadar" /></a>Compare other trending developer tools and open-source projects in this space.
Cross-referenced architectural playbooks and category rankings featuring Spivak Lean.
High-signal, production-tested utilities with transparent codebases and active communities.
Take back data ownership by replacing expensive monthly cloud subscriptions with self-hosted software.
The definitive guide to escaping SaaS subscription sprawl with Coolify, Traefik, Tailscale, and automated S3 backup pipelines.
Replace sluggish 1970s Unix utilities with blisteringly fast, memory-safe Rust and Go modern CLI powerhouses.