Machine-checked proofs of Maxwell's equations, MHD equilibrium, plasma confinement, and incompressible Navier-Stokes in Lean 4 with Mathlib. 135 definitions and theorems, zero sorry.
Physics textbooks derive Maxwell's equations, wave equations, MHD equilibria, and the Navier-Stokes equations with informal arguments that skip steps and rely on unstated assumptions. This project formalizes these derivations in Lean 4, forcing every hypothesis to be stated and every logical step to be verified by the compiler.
The result is a library of 135 machine-checked definitions and theorems covering vector calculus on
R3, electromagnetic wave propagation, plasma confinement physics, and
incompressible fluid dynamics. Every proof compiles with zero sorry (Lean's escape hatch for
unfinished proofs), meaning the Lean type checker has verified the logical correctness of each derivation.
All differential operators are defined from Mathlib's Fréchet derivative fderiv,
giving rigorous meaning to gradient, divergence, curl, and Laplacian on R3.
fderiv R f x (Pi.single i 1)Starting from Maxwell's equations with linear media parameters (ε, μ, σ), derives the general wave equation and specializes to vacuum, dielectric, and conductor cases.
The largest module covers ideal and resistive MHD, equilibrium theory, the Grad-Shafranov equation for tokamak-like configurations, and field-reversed configuration (FRC) equilibria.
Derives the incompressible Navier-Stokes equations and their key consequences including the vorticity transport equation and pressure Poisson equation.
Lean 4 is an interactive theorem prover with a large mathematical library (Mathlib) covering real analysis, topology, and linear algebra. The dependent type system ensures that if a proof compiles, it is logically correct — there is no room for hand-waving.
Mathlib provides the Fréchet derivative, smooth function spaces (ContDiff), and continuous linear maps that serve as the foundation for all vector calculus in this project.
ring/omegafderiv over +, −, scalar * using Mathlib's differentiation APIIsSymmSndFDerivAt to component-level commutativityThe project includes a LeanBlueprint — an interactive dependency graph that shows how every definition and theorem connects. Each node links to the Lean source code, and the graph gives an immediate visual overview of the entire formalization.