Gradient, divergence, curl and tension on
Definitionlandreman_vector_calculusThis file fixes the vector-calculus vocabulary used throughout the mission.
Cartesian three-space is modelled as the space of coordinate functions on three indices, written below, with coordinates (the , , of the source paper). For a scalar field the partial derivative is the Fréchet derivative of evaluated on the -th standard basis vector, and the gradient is .
For a vector field with components the file defines
the cross product with its usual components, the squared Euclidean length , the directional derivative , and the tension field .
These are the operators in which the MHD equilibrium equations and are written. They are stated for arbitrary fields, so they are reusable for any development of vector calculus on that does not need differential forms.
Formalization Note. Every derivative is taken in the sense of the Fréchet derivative, which returns a junk value when the function is not differentiable at the point; statements using these operators therefore always carry a hypothesis placing the point in the open domain where the fields are smooth. Squared length is defined by the explicit sum rather than by a norm, so no inner-product structure is imposed on the coordinate space.
import Mathlib
namespace Landreman3DEquilibria
/-- Cartesian three-space, coordinates indexed by `Fin 3` (`0 = x`, `1 = y`, `2 = z`). -/
abbrev LVec : Type := Fin 3 → ℝ
/-- The `i`-th partial derivative of a scalar field. -/
noncomputable def partialD (f : LVec → ℝ) (i : Fin 3) (x : LVec) : ℝ :=
fderiv ℝ f x (Pi.single i 1)
/-- The gradient `∇ f` of a scalar field. -/
noncomputable def grad (f : LVec → ℝ) (x : LVec) : LVec := fun i => partialD f i x
/-- The divergence `∇ · V` of a vector field. -/
noncomputable def divg (V : LVec → LVec) (x : LVec) : ℝ :=
∑ i : Fin 3, partialD (fun y => V y i) i x
/-- The curl `∇ × V` of a vector field. -/
noncomputable def curl (V : LVec → LVec) (x : LVec) : LVec :=
![partialD (fun y => V y 2) 1 x - partialD (fun y => V y 1) 2 x,
partialD (fun y => V y 0) 2 x - partialD (fun y => V y 2) 0 x,
partialD (fun y => V y 1) 0 x - partialD (fun y => V y 0) 1 x]
/-- The cross product `u × w` in Cartesian three-space. -/
def cross3 (u w : LVec) : LVec :=
![u 1 * w 2 - u 2 * w 1, u 2 * w 0 - u 0 * w 2, u 0 * w 1 - u 1 * w 0]
/-- The squared Euclidean length `|u|²`. -/
def normSq (u : LVec) : ℝ := ∑ i : Fin 3, u i ^ 2
/-- The directional derivative `V · ∇ f` of a scalar field along a vector field. -/
noncomputable def advect (V : LVec → LVec) (f : LVec → ℝ) (x : LVec) : ℝ :=
∑ j : Fin 3, V x j * partialD f j x
/-- The tension term `(V · ∇) V` of a vector field. -/
noncomputable def tension (V : LVec → LVec) (x : LVec) : LVec :=
fun i => advect V (fun y => V y i) x
end Landreman3DEquilibria
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic)
Disclosure — non-blind read-back. This read-back was written by the same agent that drafted the Lean statement it describes, at the explicit instruction of the proposal owner. It is therefore not independent testimony from a blind auditor: the author already knew what the statement was intended to say, so it cannot be relied on to expose an unfaithful formalization. Reviewers should compare the Lean code against the cited source directly rather than treating this text as corroboration.
The file introduces a space of points described by three real coordinates indexed by ; write a point as and call this space .
For a real-valued function on and an index , the quantity is defined as the Fréchet derivative of at , a linear map, applied to the vector which is in coordinate and elsewhere. No differentiability hypothesis is imposed: at points where is not differentiable this is the value of the total derivative as defined in the ambient library, which is the zero map there, so at every point of non-differentiability.
From this: is the point of whose -th coordinate is . For a map from to , is the finite sum , where denotes the function . The curl is the triple
For two points of , their cross product is , and is .
Finally, for a vector field and a scalar , the directional derivative is the sum , and the tension of is the vector field whose -th coordinate at is .
All seven notions are total functions defined at every point of , with no smoothness, integrability or non-degeneracy assumption anywhere; each is a plain definition and asserts nothing.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.