Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Cartesian vector calculus on R3\mathbb R^3R3 (Clausius–Duhem mission)

Definition
ClausiusDuhem_field_calculus

by Lucas · Oct 9, 2026 · Mathlib 0df444a (Lean v4.33.1)

continuum-mechanicsmathematical-physicsthermodynamics

Vector calculus on physical space R3\mathbb R^3R3 in Cartesian coordinates x=(x0,x1,x2)x=(x_0,x_1,x_2)x=(x0​,x1​,x2​).

  1. Partial derivative of a scalar field fff: ∂f/∂xj(x)\partial f/\partial x_j(x)∂f/∂xj​(x), the Fréchet derivative of fff at xxx applied to the unit vector eje_jej​.
  2. Gradient ∇f=(∂f/∂x0,∂f/∂x1,∂f/∂x2)\nabla f = (\partial f/\partial x_0, \partial f/\partial x_1, \partial f/\partial x_2)∇f=(∂f/∂x0​,∂f/∂x1​,∂f/∂x2​); divergence ∇⋅F=∑j∂Fj/∂xj\nabla\cdot F = \sum_j \partial F_j/\partial x_j∇⋅F=∑j​∂Fj​/∂xj​; dot product u⋅w=∑iuiwiu\cdot w=\sum_i u_i w_iu⋅w=∑i​ui​wi​.
  3. Velocity gradient (∇v)ij=∂vi/∂xj(\nabla \mathbf v)_{ij} = \partial v_i/\partial x_j(∇v)ij​=∂vi​/∂xj​ and double contraction A:B=∑i,jAijBijA:B=\sum_{i,j}A_{ij}B_{ij}A:B=∑i,j​Aij​Bij​.
  4. Partial time derivative ∂φ/∂t\partial\varphi/\partial t∂φ/∂t and material time derivative
φ˙=∂φ∂t+∇φ⋅v.\dot\varphi = \frac{\partial\varphi}{\partial t} + \nabla\varphi\cdot\mathbf v.φ˙​=∂t∂φ​+∇φ⋅v.
  1. Outward flux through the boundary of the box Ω=[a,b]=∏i[ai,bi]\Omega=[a,b]=\prod_i[a_i,b_i]Ω=[a,b]=∏i​[ai​,bi​]:
∫∂ΩF⋅n dA=∑i(∫{xi=bi}Fi dA−∫{xi=ai}Fi dA).\int_{\partial\Omega}F\cdot\mathbf n\,dA=\sum_{i}\Big(\int_{\{x_i=b_i\}}F_i\,dA-\int_{\{x_i=a_i\}}F_i\,dA\Big).∫∂Ω​F⋅ndA=i∑​(∫{xi​=bi​}​Fi​dA−∫{xi​=ai​}​Fi​dA).

These are the operators in which every statement of the mission is written.

Formalization Note Space is Fin 3 → ℝ. Derivatives are Fréchet derivatives (Mathlib fderiv, deriv), which return 000 at points of non-differentiability; all theorems of the mission assume enough differentiability that this convention is never used. Each box face is parametrized by the two remaining coordinates and carries two-dimensional Lebesgue measure.

Definition code
import Mathlib

/-!
Vector calculus on Euclidean 3-space `ℝ³ = Fin 3 → ℝ`, in Cartesian coordinates,
as used in the Wikipedia article "Clausius–Duhem inequality" (oldid=1182390552).
-/

namespace ClausiusDuhem

/-- Physical space `ℝ³`, with Cartesian coordinates `x 0, x 1, x 2`. -/
abbrev Space := Fin 3 → ℝ

/-- The partial derivative `∂f/∂x_j` of a scalar field `f` at the point `x`. -/
noncomputable def partialDeriv (f : Space → ℝ) (j : Fin 3) (x : Space) : ℝ :=
  fderiv ℝ f x (Pi.single j (1 : ℝ))

/-- The gradient `∇f(x) = (∂f/∂x_0, ∂f/∂x_1, ∂f/∂x_2)` of a scalar field. -/
noncomputable def grad (f : Space → ℝ) (x : Space) : Fin 3 → ℝ :=
  fun j => partialDeriv f j x

/-- The divergence `∇ · F(x) = ∑_j ∂F_j/∂x_j` of a vector field `F`. -/
noncomputable def div (F : Space → Fin 3 → ℝ) (x : Space) : ℝ :=
  ∑ j : Fin 3, partialDeriv (fun y => F y j) j x

/-- The Euclidean dot product `u · w = ∑_i u_i w_i`. -/
def dot (u w : Fin 3 → ℝ) : ℝ :=
  ∑ i : Fin 3, u i * w i

/-- The velocity gradient `(∇v)_{ij} = ∂v_i/∂x_j` of a vector field `v`. -/
noncomputable def velocityGradient (v : Space → Fin 3 → ℝ) (x : Space) :
    Matrix (Fin 3) (Fin 3) ℝ :=
  fun i j => partialDeriv (fun y => v y i) j x

/-- The double contraction `A : B = ∑_{i,j} A_{ij} B_{ij}` of two second-order tensors. -/
def doubleDot (A B : Matrix (Fin 3) (Fin 3) ℝ) : ℝ :=
  ∑ i : Fin 3, ∑ j : Fin 3, A i j * B i j

/-- The partial time derivative `∂φ/∂t (t, x)` of a time-dependent scalar field. -/
noncomputable def timeDeriv (φ : ℝ → Space → ℝ) (t : ℝ) (x : Space) : ℝ :=
  deriv (fun τ => φ τ x) t

/-- The material time derivative `φ̇ = ∂φ/∂t + ∇φ · v` of a scalar field `φ`
following the velocity field `v`. -/
noncomputable def materialDeriv (φ : ℝ → Space → ℝ) (v : ℝ → Space → Fin 3 → ℝ)
    (t : ℝ) (x : Space) : ℝ :=
  timeDeriv φ t x + dot (grad (φ t) x) (v t x)

/-- The outward flux `∫_{∂Ω} F · n dA` of a vector field `F` through the boundary of the
closed rectangular box `Ω = [a, b] = ∏_i [a_i, b_i]`.  The face `x_i = b_i` has outward
normal `e_i` and the face `x_i = a_i` has outward normal `-e_i`; each face is parametrised by
the two remaining coordinates and carries two-dimensional Lebesgue (area) measure. -/
noncomputable def boxOutwardFlux (F : Space → Fin 3 → ℝ) (a b : Space) : ℝ :=
  ∑ 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 ClausiusDuhem
Source
Wikipedia, "Clausius–Duhem inequality", revision oldid=1182390552, https://en.wikipedia.org/w/index.php?title=Clausius%E2%80%93Duhem_inequality&oldid=1182390552, sections "Clausius–Duhem inequality in terms of the specific entropy" (integral form, proof) and "Clausius–Duhem inequality in terms of specific internal energy" (index notation).
Read-back

What the Lean code literally says, in plain math · Aristotle (Harmonic) - non-blind, same agent as the drafter

Non-blind read-back — not independent testimony. This read-back was written by the same agent (Aristotle, by Harmonic) that drafted the Lean statements, with full knowledge of the source article and of the intended meaning. It was not produced by a blind, independent auditor, so it must not be mistaken for independent testimony; reviewers should compare it against the Lean code themselves.

This file introduces, inside the namespace ClausiusDuhem, the following objects, where space means the set of functions {0,1,2}→R\{0,1,2\}\to\mathbb R{0,1,2}→R (i.e. R3\mathbb R^3R3 with its product structure).

  1. Partial derivative. For f:R3→Rf:\mathbb R^3\to\mathbb Rf:R3→R, j∈{0,1,2}j\in\{0,1,2\}j∈{0,1,2} and x∈R3x\in\mathbb R^3x∈R3: ∂jf(x):=Df(x)[ej]\partial_j f(x) := Df(x)[e_j]∂j​f(x):=Df(x)[ej​], the Fréchet derivative of fff at xxx evaluated on the jjj-th standard basis vector. If fff is not differentiable at xxx, the Fréchet derivative is by convention the zero map, so ∂jf(x)=0\partial_j f(x)=0∂j​f(x)=0.
  2. Gradient. ∇f(x):=(∂0f(x),∂1f(x),∂2f(x))\nabla f(x) := (\partial_0 f(x),\partial_1 f(x),\partial_2 f(x))∇f(x):=(∂0​f(x),∂1​f(x),∂2​f(x)).
  3. Divergence. For F:R3→R3F:\mathbb R^3\to\mathbb R^3F:R3→R3: ∇⋅F(x):=∑j=02∂jFj(x)\nabla\cdot F(x) := \sum_{j=0}^{2}\partial_j F_j(x)∇⋅F(x):=∑j=02​∂j​Fj​(x), where FjF_jFj​ is the jjj-th component function.
  4. Dot product. u⋅w:=∑i=02uiwiu\cdot w := \sum_{i=0}^2 u_i w_iu⋅w:=∑i=02​ui​wi​.
  5. Velocity gradient. For v:R3→R3v:\mathbb R^3\to\mathbb R^3v:R3→R3: the 3×33\times33×3 real matrix (∇v(x))ij:=∂jvi(x)(\nabla v(x))_{ij} := \partial_j v_i(x)(∇v(x))ij​:=∂j​vi​(x).
  6. Double contraction. For 3×33\times33×3 real matrices: A:B:=∑i∑jAijBijA:B := \sum_{i}\sum_{j}A_{ij}B_{ij}A:B:=∑i​∑j​Aij​Bij​.
  7. Time derivative. For φ:R×R3→R\varphi:\mathbb R\times\mathbb R^3\to\mathbb Rφ:R×R3→R (curried as φ(t)(x)\varphi(t)(x)φ(t)(x)): ∂tφ(t,x):=ddτφ(τ,x)∣τ=t\partial_t\varphi(t,x) := \frac{d}{d\tau}\varphi(\tau,x)\big|_{\tau=t}∂t​φ(t,x):=dτd​φ(τ,x)​τ=t​, the one-variable derivative; it is 000 if τ↦φ(τ,x)\tau\mapsto\varphi(\tau,x)τ↦φ(τ,x) is not differentiable at ttt.
  8. Material derivative. For φ\varphiφ as above and v:R×R3→R3v:\mathbb R\times\mathbb R^3\to\mathbb R^3v:R×R3→R3:
φ˙(t,x):=∂tφ(t,x)+∇(φ(t,⋅))(x)⋅v(t,x).\dot\varphi(t,x) := \partial_t\varphi(t,x) + \nabla\big(\varphi(t,\cdot)\big)(x)\cdot v(t,x).φ˙​(t,x):=∂t​φ(t,x)+∇(φ(t,⋅))(x)⋅v(t,x).
  1. Box outward flux. For F:R3→R3F:\mathbb R^3\to\mathbb R^3F:R3→R3 and a,b∈R3a,b\in\mathbb R^3a,b∈R3:
Φ[a,b](F):=∑i=02(∫RiFi(ιi(bi,y)) dy−∫RiFi(ιi(ai,y)) dy),\Phi_{[a,b]}(F) := \sum_{i=0}^{2}\left(\int_{R_i}F_i\big(\iota_i(b_i,y)\big)\,dy - \int_{R_i}F_i\big(\iota_i(a_i,y)\big)\,dy\right),Φ[a,b]​(F):=i=0∑2​(∫Ri​​Fi​(ιi​(bi​,y))dy−∫Ri​​Fi​(ιi​(ai​,y))dy),

where Ri⊂R2R_i\subset\mathbb R^2Ri​⊂R2 is the closed rectangle ∏k≠i[ak,bk]\prod_{k\ne i}[a_k,b_k]∏k=i​[ak​,bk​] (coordinates other than iii, in increasing order), ιi(c,y)∈R3\iota_i(c,y)\in\mathbb R^3ιi​(c,y)∈R3 is the point whose iii-th coordinate is ccc and whose other two coordinates are yyy, and dydydy is two-dimensional Lebesgue measure. The integrals are Bochner integrals, equal to 000 when the integrand is not integrable. No condition a≤ba\le ba≤b is imposed by the definition itself (if ak>bka_k>b_kak​>bk​ for some k≠ik\ne ik=i, RiR_iRi​ is empty).

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