Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Vector calculus on R3\mathbb{R}^3R3 and Maxwell's microscopic equations (SI)

Definition
MaxwellWiki_Defs

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

electromagnetismmaxwell-equationsvector-calculus

Vector calculus on R3\mathbb{R}^3R3 and Maxwell's microscopic equations in SI units.

  1. Vectors. R3\mathbb{R}^3R3 is represented by coordinate triples x=(x0,x1,x2)x=(x_0,x_1,x_2)x=(x0​,x1​,x2​).
  2. Partial derivatives. For a scalar field f:R3→Rf:\mathbb{R}^3\to\mathbb{R}f:R3→R, ∂if(x)\partial_i f(x)∂i​f(x) is the Fréchet derivative of fff at xxx applied to the iii-th standard basis vector eie_iei​.
  3. Divergence and curl. For a vector field F=(F0,F1,F2)F=(F_0,F_1,F_2)F=(F0​,F1​,F2​),
∇⋅F=∂0F0+∂1F1+∂2F2,∇×F=(∂1F2−∂2F1, ∂2F0−∂0F2, ∂0F1−∂1F0).\nabla\cdot F=\partial_0F_0+\partial_1F_1+\partial_2F_2,\qquad \nabla\times F=\big(\partial_1F_2-\partial_2F_1,\ \partial_2F_0-\partial_0F_2,\ \partial_0F_1-\partial_1F_0\big).∇⋅F=∂0​F0​+∂1​F1​+∂2​F2​,∇×F=(∂1​F2​−∂2​F1​, ∂2​F0​−∂0​F2​, ∂0​F1​−∂1​F0​).
  1. Time derivative. For a time-dependent field F(t,x)F(t,x)F(t,x), ∂tF(t,x)\partial_t F(t,x)∂t​F(t,x) is the derivative of s↦F(s,x)s\mapsto F(s,x)s↦F(s,x) at s=ts=ts=t.
  2. Maxwell's equations. Given constants ε0,μ0\varepsilon_0,\mu_0ε0​,μ0​, fields 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 a charge density ρ:R×R3→R\rho:\mathbb{R}\times\mathbb{R}^3\to\mathbb{R}ρ:R×R3→R, the predicate Maxwell solution asserts that at every time ttt and every point xxx
∇⋅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​).
  1. Flux through a box. For a≤ba\le ba≤b in R3\mathbb{R}^3R3 and the box Ω=[a0,b0]×[a1,b1]×[a2,b2]\Omega=[a_0,b_0]\times[a_1,b_1]\times[a_2,b_2]Ω=[a0​,b0​]×[a1​,b1​]×[a2​,b2​], the outward flux of FFF through ∂Ω\partial\Omega∂Ω is
∮∂ΩF⋅dS=∑i=02(∫face xi=biFi dA−∫face xi=aiFi dA),\oint_{\partial\Omega}F\cdot d\mathbf S=\sum_{i=0}^{2}\Big(\int_{\text{face }x_i=b_i}F_i\,dA-\int_{\text{face }x_i=a_i}F_i\,dA\Big),∮∂Ω​F⋅dS=i=0∑2​(∫face xi​=bi​​Fi​dA−∫face xi​=ai​​Fi​dA),

each face integral being a two-dimensional Lebesgue integral over the remaining two coordinates.

These definitions are shared by every statement of the mission.

Formalization Note Derivatives are Mathlib's fderiv/deriv, which return 000 at points of non-differentiability; all theorems of the mission therefore assume explicit smoothness. The flux is only defined for rectangular boxes, which is the setting in which Mathlib's divergence theorem is available.

Definition code
import Mathlib

namespace MaxwellWiki

/-- Vectors in three-dimensional space, as coordinate triples. -/
abbrev Vec3 := Fin 3 → ℝ

/-- The partial derivative `∂f/∂xᵢ` of a scalar field at `x`. -/
noncomputable def partialDeriv (i : Fin 3) (f : Vec3 → ℝ) (x : Vec3) : ℝ :=
  fderiv ℝ f x (Pi.single i 1)

/-- The divergence `∇ · F` of a vector field. -/
noncomputable def div (F : Vec3 → Vec3) (x : Vec3) : ℝ :=
  ∑ i : Fin 3, partialDeriv i (fun y => F y i) x

/-- The curl `∇ × F` of a vector field. -/
noncomputable def curl (F : Vec3 → Vec3) (x : Vec3) : Vec3 :=
  ![partialDeriv 1 (fun y => F y 2) x - partialDeriv 2 (fun y => F y 1) x,
    partialDeriv 2 (fun y => F y 0) x - partialDeriv 0 (fun y => F y 2) x,
    partialDeriv 0 (fun y => F y 1) x - partialDeriv 1 (fun y => F y 0) x]

/-- The partial time derivative `∂F/∂t` of a time-dependent field at `(t, x)`. -/
noncomputable def timeDeriv {β : Type*} [NormedAddCommGroup β] [NormedSpace ℝ β]
    (F : ℝ → Vec3 → β) (t : ℝ) (x : Vec3) : β :=
  deriv (fun s => F s x) t

/-- Maxwell's microscopic equations in SI units (Gauss's law, Gauss's law for magnetism,
Faraday's law, Ampère–Maxwell law), holding at every time and every point of space. -/
structure IsMaxwellSolution (ε₀ μ₀ : ℝ) (E B J : ℝ → Vec3 → Vec3) (ρ : ℝ → Vec3 → ℝ) :
    Prop where
  gauss : ∀ t x, div (E t) x = ρ t x / ε₀
  gauss_magnetism : ∀ t x, div (B t) x = 0
  faraday : ∀ t x, curl (E t) x = -timeDeriv B t x
  ampere_maxwell : ∀ t x, curl (B t) x = μ₀ • (J t x + ε₀ • timeDeriv E t x)

/-- The outward flux `∯_{∂Ω} F · dS` of a vector field through the boundary of the
rectangular box `Ω = [a₀,b₀] × [a₁,b₁] × [a₂,b₂]`: for each coordinate direction `i`, the
integral of `Fᵢ` over the face `xᵢ = bᵢ` minus its integral over the face `xᵢ = aᵢ`. -/
noncomputable def boxFlux (F : Vec3 → Vec3) (a b : Vec3) : ℝ :=
  ∑ i : Fin 3,
    ((∫ y in Set.Icc (a ∘ i.succAbove) (b ∘ i.succAbove), F (i.insertNth (b i) y) i) -
      ∫ y in Set.Icc (a ∘ i.succAbove) (b ∘ i.succAbove), F (i.insertNth (a i) y) i)

end MaxwellWiki
Source
Wikipedia, "Maxwell's equations", https://en.wikipedia.org/wiki/Maxwell%27s_equations (24-page PDF snapshot supplied by the proposer), section "Summary — Microscopic version in SI units" (p. 2 of the snapshot), "Key to the notation" (pp. 4–5), and "Integral equations" (p. 5).
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.

The file declares, inside the namespace MaxwellWiki:

  • Vec3\mathrm{Vec3}Vec3: functions {0,1,2}→R\{0,1,2\}\to\mathbb{R}{0,1,2}→R (coordinate triples; the ambient norm is Mathlib's sup norm, which does not affect derivatives).
  • ∂if(x)\partial_i f(x)∂i​f(x) for i∈{0,1,2}i\in\{0,1,2\}i∈{0,1,2}, f:Vec3→Rf:\mathrm{Vec3}\to\mathbb{R}f:Vec3→R: the Fréchet derivative Df(x)Df(x)Df(x) (defined to be the zero map if fff is not differentiable at xxx) evaluated at the standard basis vector eie_iei​.
  • (∇⋅F)(x)=∑i=02∂iFi(x)(\nabla\cdot F)(x)=\sum_{i=0}^{2}\partial_i F_i(x)(∇⋅F)(x)=∑i=02​∂i​Fi​(x) for F:Vec3→Vec3F:\mathrm{Vec3}\to\mathrm{Vec3}F:Vec3→Vec3, where Fi(y)F_i(y)Fi​(y) is the iii-th coordinate of F(y)F(y)F(y).
  • (∇×F)(x)=(∂1F2−∂2F1, ∂2F0−∂0F2, ∂0F1−∂1F0)(x)(\nabla\times F)(x)=\big(\partial_1F_2-\partial_2F_1,\ \partial_2F_0-\partial_0F_2,\ \partial_0F_1-\partial_1F_0\big)(x)(∇×F)(x)=(∂1​F2​−∂2​F1​, ∂2​F0​−∂0​F2​, ∂0​F1​−∂1​F0​)(x).
  • ∂tF(t,x)\partial_tF(t,x)∂t​F(t,x), for F:R→Vec3→βF:\mathbb{R}\to\mathrm{Vec3}\to\betaF:R→Vec3→β with β\betaβ any real normed space: the derivative at ttt of s↦F(s,x)s\mapsto F(s,x)s↦F(s,x) (zero if that map is not differentiable at ttt).
  • A proposition IsMaxwellSolution(ε0,μ0,E,B,J,ρ)(\varepsilon_0,\mu_0,\mathbf E,\mathbf B,\mathbf J,\rho)(ε0​,μ0​,E,B,J,ρ), for arbitrary real numbers ε0,μ0\varepsilon_0,\mu_0ε0​,μ0​ (no sign or nonzero condition is built in), 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, meaning that for all t∈Rt\in\mathbb{R}t∈R, x∈Vec3x\in\mathrm{Vec3}x∈Vec3:
∇⋅E(t,⋅)(x)=ρ(t,x)/ε0,∇⋅B(t,⋅)(x)=0,∇×E(t,⋅)(x)=−∂tB(t,x),∇×B(t,⋅)(x)=μ0(J(t,x)+ε0 ∂tE(t,x)).\nabla\cdot\mathbf E(t,\cdot)(x)=\rho(t,x)/\varepsilon_0,\quad \nabla\cdot\mathbf B(t,\cdot)(x)=0,\quad \nabla\times\mathbf E(t,\cdot)(x)=-\partial_t\mathbf B(t,x),\quad \nabla\times\mathbf B(t,\cdot)(x)=\mu_0\big(\mathbf J(t,x)+\varepsilon_0\,\partial_t\mathbf E(t,x)\big).∇⋅E(t,⋅)(x)=ρ(t,x)/ε0​,∇⋅B(t,⋅)(x)=0,∇×E(t,⋅)(x)=−∂t​B(t,x),∇×B(t,⋅)(x)=μ0​(J(t,x)+ε0​∂t​E(t,x)).

Here division by ε0=0\varepsilon_0=0ε0​=0 would give 000. All four equations are required; nothing is assumed about the regularity of the fields.

  • boxFlux(F,a,b)\mathrm{boxFlux}(F,a,b)boxFlux(F,a,b) for F:Vec3→Vec3F:\mathrm{Vec3}\to\mathrm{Vec3}F:Vec3→Vec3 and a,b∈Vec3a,b\in\mathrm{Vec3}a,b∈Vec3: the sum over i∈{0,1,2}i\in\{0,1,2\}i∈{0,1,2} of
∫RiFi(y with bi inserted at slot i) dy−∫RiFi(y with ai inserted at slot i) dy,\int_{R_i}F_i\big(y\text{ with }b_i\text{ inserted at slot }i\big)\,dy-\int_{R_i}F_i\big(y\text{ with }a_i\text{ inserted at slot }i\big)\,dy,∫Ri​​Fi​(y with bi​ inserted at slot i)dy−∫Ri​​Fi​(y with ai​ inserted at slot i)dy,

where yyy ranges over the closed rectangle Ri⊂R2R_i\subset\mathbb{R}^2Ri​⊂R2 of pairs lying between the two remaining coordinates of aaa and of bbb, with respect to Lebesgue measure; a non-integrable integrand contributes 000. No condition a≤ba\le ba≤b is imposed in the definition (an empty rectangle gives integral 000).

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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me