Coulomb field of a charge density, divergence, and flux through a sphere in
DefinitionCoulombGauss_basicThis file fixes the objects used in the derivation of Gauss's law from Coulomb's law.
- Space. is the Euclidean space of triples with the usual inner product and norm .
- Coulomb kernel. For ,
the field (up to the factor ) of a unit point charge at , evaluated at . 3. Electric field of a charge distribution. For a constant , a charge density and a region ,
the integral being the Lebesgue integral over . 4. Divergence. For a vector field , , computed from the (Fréchet) derivative of each coordinate function at . 5. Flux through a sphere. For a centre and radius , the outward flux of through the sphere is
where is the standard surface-area measure on the unit sphere (total mass ).
These definitions are shared by the goal theorem and all milestones of the mission.
Formalization Note Lean's total-function conventions apply: the kernel takes the value at (where is read as ), a non-integrable integrand integrates to , and the derivative of a function that is not differentiable at a point is taken to be . The surface measure is Mathlib's Measure.toSphere of Lebesgue measure, which assigns the mass .
import Mathlib
namespace CoulombGauss
open MeasureTheory
/-- Physical three-dimensional Euclidean space `ℝ³`. -/
abbrev Vec3 : Type := EuclideanSpace ℝ (Fin 3)
/-- The Coulomb kernel `(r - r') / |r - r'|³`: the field direction-and-falloff of a unit point
charge located at `r'`, evaluated at `r` (without the factor `1 / (4π ε₀)`). At `r = r'` Lean's
conventions give the value `0`. -/
noncomputable def coulombKernel (r r' : Vec3) : Vec3 :=
(‖r - r'‖ ^ 3)⁻¹ • (r - r')
/-- The electrostatic field generated by a charge density `ρ` occupying the region `Ω`:
`E(r) = 1/(4π ε₀) ∫_Ω ρ(r') (r - r') / |r - r'|³ d³r'`. -/
noncomputable def electricField (ε₀ : ℝ) (ρ : Vec3 → ℝ) (Ω : Set Vec3) (r : Vec3) : Vec3 :=
(1 / (4 * Real.pi * ε₀)) • ∫ r' in Ω, ρ r' • coulombKernel r r'
/-- The divergence `∇ · F (r) = ∑ᵢ ∂ Fᵢ / ∂ xᵢ (r)` of a vector field on `ℝ³`, computed from the
Fréchet derivatives of the coordinate functions. -/
noncomputable def divergence (F : Vec3 → Vec3) (r : Vec3) : ℝ :=
∑ i : Fin 3, fderiv ℝ (fun x => F x i) r (EuclideanSpace.single i 1)
/-- The outward flux `∮_{∂B_R(c)} F · dS` of a vector field `F` through the sphere of radius `R`
centred at `c`, written via the standard surface measure `σ` on the unit sphere `S²`
(total mass `4π`): `R² ∫_{S²} F(c + R u) · u dσ(u)`. -/
noncomputable def sphereFlux (F : Vec3 → Vec3) (c : Vec3) (R : ℝ) : ℝ :=
R ^ 2 * ∫ u : Metric.sphere (0 : Vec3) 1,
inner ℝ (F (c + R • (u : Vec3))) (u : Vec3) ∂(volume.toSphere)
end CoulombGauss
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic)
NON-BLIND READ-BACK — NOT INDEPENDENT TESTIMONY. This read-back was written by the same agent that drafted the Lean statements of this proposal (at the explicit direction of the proposal owner), with full knowledge of the source text and of the intended meaning. It is therefore not a blind audit and must not be mistaken for independent testimony. Reviewers should compare the Lean code against the source directly.
The file declares, inside the namespace CoulombGauss, one abbreviation and four noncomputable definitions.
- is the Euclidean space (real coordinates indexed by with the norm and standard inner product).
- . When the inverse of is by convention, so the value is the zero vector; otherwise it is .
- , a Bochner integral against Lebesgue measure restricted to . No hypothesis is built in: is any real (if the prefactor is and the field is identically ), is any real function, any set; if the integrand is not integrable on the integral, hence the field, is .
- , where is the -th coordinate of , is its Fréchet derivative at and the -th standard basis vector. If is not differentiable at , its derivative is taken to be , so the corresponding term is .
- , where is the unit sphere of and is the measure on obtained from Lebesgue measure by the cone construction (Mathlib's
toSphere, total mass ). It is defined for every real (including ), and is if the integrand is not -integrable.