Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Continuity equation ∂tρ+∇⋅J=0\partial_t\rho+\nabla\cdot\mathbf J=0∂t​ρ+∇⋅J=0 from Maxwell's equations

Proved
MaxwellWiki.continuity_equation

by Lucas · Sep 27, 2026 · Mathlib 0df444a (Lean v4.33.1)

electromagnetismmaxwell-equationsvector-calculus

Charge conservation (differential form). Let ε0>0\varepsilon_0>0ε0​>0 and μ0>0\mu_0>0μ0​>0. Let E,B,J:R×R3→R3\mathbf E,\mathbf B,\mathbf J:\mathbb{R}\times\mathbb{R}^3\to\mathbb{R}^3E,B,J:R×R3→R3 and ρ:R×R3→R\rho:\mathbb{R}\times\mathbb{R}^3\to\mathbb{R}ρ:R×R3→R satisfy Maxwell's microscopic equations in SI units at every time and point,

∇⋅E=ρε0,∇⋅B=0,∇×E=−∂B∂t,∇×B=μ0(J+ε0∂E∂t),\nabla\cdot\mathbf E=\frac{\rho}{\varepsilon_0},\qquad \nabla\cdot\mathbf B=0,\qquad \nabla\times\mathbf E=-\frac{\partial\mathbf B}{\partial t},\qquad \nabla\times\mathbf B=\mu_0\Big(\mathbf J+\varepsilon_0\frac{\partial\mathbf E}{\partial t}\Big),∇⋅E=ε0​ρ​,∇⋅B=0,∇×E=−∂t∂B​,∇×B=μ0​(J+ε0​∂t∂E​),

and assume E\mathbf EE and B\mathbf BB are C2C^2C2 jointly in (t,x)(t,x)(t,x). Then for every ttt and xxx,

∂ρ∂t+∇⋅J=0.\frac{\partial\rho}{\partial t}+\nabla\cdot\mathbf J=0 .∂t∂ρ​+∇⋅J=0.

This is the continuity equation the article derives "as a corollary of Maxwell's equations"; it expresses local conservation of electric charge.

Formalization Note No regularity is assumed on ρ\rhoρ and J\mathbf JJ: they are determined by E\mathbf EE and B\mathbf BB through Gauss's law and the Ampère–Maxwell law. The C2C^2C2 assumption on E,B\mathbf E,\mathbf BE,B makes explicit the smoothness the article leaves implicit.

Preamble
import Mathlib
import Definitions.Def_MaxwellWiki_Defs

open MaxwellWiki
Formal statement
namespace MaxwellWiki

theorem continuity_equation (ε₀ μ₀ : ℝ) (hε₀ : 0 < ε₀) (hμ₀ : 0 < μ₀)
    (E B J : ℝ → Vec3 → Vec3) (ρ : ℝ → Vec3 → ℝ)
    (hE : ContDiff ℝ 2 (Function.uncurry E)) (hB : ContDiff ℝ 2 (Function.uncurry B))
    (hM : IsMaxwellSolution ε₀ μ₀ E B J ρ) (t : ℝ) (x : Vec3) :
    timeDeriv ρ t x + div (J t) x = 0 := by sorry

end MaxwellWiki
Source
Wikipedia, "Maxwell's equations", https://en.wikipedia.org/wiki/Maxwell%27s_equations (24-page PDF snapshot supplied by the proposer), section "Charge conservation" (pp. 8–9 of the snapshot): the displayed chain 0=∇⋅(∇×B)=⋯=μ0(∇⋅J+∂ρ/∂t)0=\nabla\cdot(\nabla\times\mathbf B)=\dots=\mu_0(\nabla\cdot\mathbf J+\partial\rho/\partial t)0=∇⋅(∇×B)=⋯=μ0​(∇⋅J+∂ρ/∂t), "i.e., ∂ρ/∂t+∇⋅J=0\partial\rho/\partial t+\nabla\cdot\mathbf J=0∂ρ/∂t+∇⋅J=0"; Maxwell's equations as in section "Summary — Microscopic version in SI units" (p. 2).
Read-back

What the Lean code literally says, in plain math · Aristotle (Harmonic) - non-blind, same agent as the drafter

Non-blind read-back. This read-back was written by the same agent that drafted the Lean statement (Aristotle, by Harmonic), with full knowledge of the source and of the intended meaning. It is not independent testimony and must not be treated as a blind audit; reviewers should compare the Lean code against the source themselves.

For all real numbers ε0>0\varepsilon_0>0ε0​>0 and μ0>0\mu_0>0μ0​>0, all maps E,B,J:R→Vec3→Vec3\mathbf E,\mathbf B,\mathbf J:\mathbb{R}\to\mathrm{Vec3}\to\mathrm{Vec3}E,B,J:R→Vec3→Vec3 and ρ:R→Vec3→R\rho:\mathbb{R}\to\mathrm{Vec3}\to\mathbb{R}ρ:R→Vec3→R such that

  1. (t,x)↦E(t,x)(t,x)\mapsto\mathbf E(t,x)(t,x)↦E(t,x) is C2C^2C2 on R×R3\mathbb{R}\times\mathbb{R}^3R×R3,
  2. (t,x)↦B(t,x)(t,x)\mapsto\mathbf B(t,x)(t,x)↦B(t,x) is C2C^2C2 on R×R3\mathbb{R}\times\mathbb{R}^3R×R3,
  3. IsMaxwellSolution(ε0,μ0,E,B,J,ρ)(\varepsilon_0,\mu_0,\mathbf E,\mathbf B,\mathbf J,\rho)(ε0​,μ0​,E,B,J,ρ) holds, i.e. for all t,xt,xt,x: ∇⋅E(t,⋅)(x)=ρ(t,x)/ε0\nabla\cdot\mathbf E(t,\cdot)(x)=\rho(t,x)/\varepsilon_0∇⋅E(t,⋅)(x)=ρ(t,x)/ε0​, ∇⋅B(t,⋅)(x)=0\nabla\cdot\mathbf B(t,\cdot)(x)=0∇⋅B(t,⋅)(x)=0, ∇×E(t,⋅)(x)=−∂tB(t,x)\nabla\times\mathbf E(t,\cdot)(x)=-\partial_t\mathbf B(t,x)∇×E(t,⋅)(x)=−∂t​B(t,x), ∇×B(t,⋅)(x)=μ0(J(t,x)+ε0∂tE(t,x))\nabla\times\mathbf B(t,\cdot)(x)=\mu_0\big(\mathbf J(t,x)+\varepsilon_0\partial_t\mathbf E(t,x)\big)∇×B(t,⋅)(x)=μ0​(J(t,x)+ε0​∂t​E(t,x)),

and for every t∈Rt\in\mathbb{R}t∈R, x∈Vec3x\in\mathrm{Vec3}x∈Vec3:

∂tρ(t,x)+(∇⋅J(t,⋅))(x)=0,\partial_t\rho(t,x)+\big(\nabla\cdot\mathbf J(t,\cdot)\big)(x)=0,∂t​ρ(t,x)+(∇⋅J(t,⋅))(x)=0,

where ∂tρ(t,x)\partial_t\rho(t,x)∂t​ρ(t,x) is the derivative at ttt of s↦ρ(s,x)s\mapsto\rho(s,x)s↦ρ(s,x) (taken as 000 where it does not exist) and divergence is as in the shared definition file. No regularity is assumed on ρ\rhoρ or J\mathbf JJ. The hypotheses are satisfiable (e.g. all fields identically zero).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me