Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Gradient, divergence, curl and tension on R3\mathbb R^3R3

Definition
landreman_vector_calculus

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

mathematical-physicsvector-calculus

This 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 R3\mathbb R^3R3 below, with coordinates x0,x1,x2x_0, x_1, x_2x0​,x1​,x2​ (the xxx, yyy, zzz of the source paper). For a scalar field f:R3→Rf:\mathbb R^3\to\mathbb Rf:R3→R the partial derivative ∂if\partial_i f∂i​f is the Fréchet derivative of fff evaluated on the iii-th standard basis vector, and the gradient is ∇f=(∂0f,∂1f,∂2f)\nabla f=(\partial_0 f,\partial_1 f,\partial_2 f)∇f=(∂0​f,∂1​f,∂2​f).

For a vector field V:R3→R3V:\mathbb R^3\to\mathbb R^3V:R3→R3 with components V0,V1,V2V_0,V_1,V_2V0​,V1​,V2​ the file defines

∇⋅V=∑i∂iVi,∇×V=(∂1V2−∂2V1, ∂2V0−∂0V2, ∂0V1−∂1V0),\nabla\cdot V=\sum_{i} \partial_i V_i,\qquad \nabla\times V=\big(\partial_1 V_2-\partial_2 V_1,\ \partial_2 V_0-\partial_0 V_2,\ \partial_0 V_1-\partial_1 V_0\big),∇⋅V=i∑​∂i​Vi​,∇×V=(∂1​V2​−∂2​V1​, ∂2​V0​−∂0​V2​, ∂0​V1​−∂1​V0​),

the cross product u×wu\times wu×w with its usual components, the squared Euclidean length ∣u∣2=∑iui2|u|^2=\sum_i u_i^2∣u∣2=∑i​ui2​, the directional derivative V⋅∇f=∑jVj ∂jfV\cdot\nabla f=\sum_j V_j\,\partial_j fV⋅∇f=∑j​Vj​∂j​f, and the tension field ((V⋅∇)V)i=V⋅∇Vi\big((V\cdot\nabla)V\big)_i=V\cdot\nabla V_i((V⋅∇)V)i​=V⋅∇Vi​.

These are the operators in which the MHD equilibrium equations (∇×B)×B=∇p(\nabla\times B)\times B=\nabla p(∇×B)×B=∇p and ∇⋅B=0\nabla\cdot B=0∇⋅B=0 are written. They are stated for arbitrary fields, so they are reusable for any development of vector calculus on R3\mathbb R^3R3 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.

Definition code
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
Source
M. Landreman, Analytic toroidal 3D MHD equilibria and steady Euler flows with invariant surfaces, J. Plasma Phys. (submitted), arXiv:2609.26742v1 (2026), https://arxiv.org/abs/2609.26742 , Section 2, eq. (1.1) (operators used to state the equilibrium equations)
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 0,1,20,1,20,1,2; write a point as x=(x0,x1,x2)x=(x_0,x_1,x_2)x=(x0​,x1​,x2​) and call this space R3\mathbb R^3R3.

For a real-valued function fff on R3\mathbb R^3R3 and an index i∈{0,1,2}i\in\{0,1,2\}i∈{0,1,2}, the quantity ∂if(x)\partial_i f(x)∂i​f(x) is defined as the Fréchet derivative of fff at xxx, a linear map, applied to the vector which is 111 in coordinate iii and 000 elsewhere. No differentiability hypothesis is imposed: at points where fff is not differentiable this is the value of the total derivative as defined in the ambient library, which is the zero map there, so ∂if(x)=0\partial_i f(x)=0∂i​f(x)=0 at every point of non-differentiability.

From this: ∇f(x)\nabla f(x)∇f(x) is the point of R3\mathbb R^3R3 whose iii-th coordinate is ∂if(x)\partial_i f(x)∂i​f(x). For a map VVV from R3\mathbb R^3R3 to R3\mathbb R^3R3, (∇⋅V)(x)(\nabla\cdot V)(x)(∇⋅V)(x) is the finite sum ∑i=02∂iVi(x)\sum_{i=0}^{2}\partial_i V_i(x)∑i=02​∂i​Vi​(x), where ViV_iVi​ denotes the function y↦V(y)iy\mapsto V(y)_iy↦V(y)i​. The curl (∇×V)(x)(\nabla\times V)(x)(∇×V)(x) is the triple

(∂1V2(x)−∂2V1(x), ∂2V0(x)−∂0V2(x), ∂0V1(x)−∂1V0(x)).\big(\partial_1 V_2(x)-\partial_2 V_1(x),\ \partial_2 V_0(x)-\partial_0 V_2(x),\ \partial_0 V_1(x)-\partial_1 V_0(x)\big).(∂1​V2​(x)−∂2​V1​(x), ∂2​V0​(x)−∂0​V2​(x), ∂0​V1​(x)−∂1​V0​(x)).

For two points u,wu,wu,w of R3\mathbb R^3R3, their cross product is (u1w2−u2w1, u2w0−u0w2, u0w1−u1w0)\big(u_1w_2-u_2w_1,\ u_2w_0-u_0w_2,\ u_0w_1-u_1w_0\big)(u1​w2​−u2​w1​, u2​w0​−u0​w2​, u0​w1​−u1​w0​), and ∣u∣2|u|^2∣u∣2 is ∑i=02ui2\sum_{i=0}^2 u_i^2∑i=02​ui2​.

Finally, for a vector field VVV and a scalar fff, the directional derivative is the sum ∑j=02V(x)j ∂jf(x)\sum_{j=0}^{2}V(x)_j\,\partial_j f(x)∑j=02​V(x)j​∂j​f(x), and the tension of VVV is the vector field whose iii-th coordinate at xxx is ∑j=02V(x)j ∂jVi(x)\sum_{j=0}^{2}V(x)_j\,\partial_j V_i(x)∑j=02​V(x)j​∂j​Vi​(x).

All seven notions are total functions defined at every point of R3\mathbb R^3R3, with no smoothness, integrability or non-degeneracy assumption anywhere; each is a plain definition and asserts nothing.

Human review
  • Endorsed by Shuze Chen · Sep 24, 2026

    Confirmed by the moderator at approval.

  • Endorsed by LG · Sep 24, 2026

    Confirmed by the mission captain (proposal self-audit).

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