The divergence theorem (Gauss–Green) on a box
ProvedFamousTheorems.divergence_theorem_boxThe divergence theorem (Gauss–Green) on a box. Let be a closed box and a vector field with values in a Banach space . Suppose is continuous on , differentiable on the interior of the box outside a countable set, and its divergence is integrable on . Then
This is the divergence theorem, the higher-dimensional form of the fundamental theorem of calculus. It is fundamental in vector calculus, physics (Gauss's law, conservation laws) and partial differential equations. Green's theorem in the plane is its two-dimensional case.
Formalization note. Mathlib's MeasureTheory.integral_divergence_of_hasFDerivAt_off_countable. Points are functions Fin (n + 1) → ℝ, and f' x is the derivative of f at x, so the divergence is with Pi.single i 1 the basis vector . The face is parametrised by Fin n → ℝ via Fin.insertNth into the box Set.Icc (a ∘ i.succAbove) (b ∘ i.succAbove). The hypothesis allows a countable exceptional set where f need not be differentiable.
import Mathlib
namespace FamousTheorems
open MeasureTheory
theorem divergence_theorem_box {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {n : ℕ} (a b : Fin (n + 1) → ℝ) (hle : a ≤ b)
(f : (Fin (n + 1) → ℝ) → Fin (n + 1) → E)
(f' : (Fin (n + 1) → ℝ) → (Fin (n + 1) → ℝ) →L[ℝ] Fin (n + 1) → E)
(s : Set (Fin (n + 1) → ℝ)) (hs : s.Countable) (Hc : ContinuousOn f (Set.Icc a b))
(Hd : ∀ x ∈ (Set.univ.pi fun i => Set.Ioo (a i) (b i)) \ s, HasFDerivAt f (f' x) x)
(Hi : IntegrableOn (fun x => ∑ i, f' x (Pi.single i 1) i) (Set.Icc a b)) :
∫ x in Set.Icc a b, ∑ i, f' x (Pi.single i 1) i =
∑ i : Fin (n + 1),
((∫ x in Set.Icc (a ∘ i.succAbove) (b ∘ i.succAbove), f (i.insertNth (b i) x) i) -
∫ x in Set.Icc (a ∘ i.succAbove) (b ∘ i.succAbove), f (i.insertNth (a i) x) i) := by sorry
end FamousTheorems