Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Virial theorem: kinetic energy, moment of inertia, virial GGG, time averages, pair forces

Definition
virial_theorem_defs

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

classical-mechanicsmathematical-physics

Basic objects for NNN point particles in three-dimensional Euclidean space R3\mathbb R^3R3. Particle k∈{1,…,N}k\in\{1,\dots,N\}k∈{1,…,N} has a constant mass mkm_kmk​, a position trajectory rk:R→R3r_k:\mathbb R\to\mathbb R^3rk​:R→R3 and a velocity trajectory vk:R→R3v_k:\mathbb R\to\mathbb R^3vk​:R→R3.

  1. Kinetic energy. T(t)=12∑kmk ∥vk(t)∥2T(t)=\frac12\sum_{k} m_k\,\|v_k(t)\|^2T(t)=21​∑k​mk​∥vk​(t)∥2.
  2. Moment of inertia about the origin. I(t)=∑kmk ∥rk(t)∥2I(t)=\sum_k m_k\,\|r_k(t)\|^2I(t)=∑k​mk​∥rk​(t)∥2.
  3. Virial scalar. G(t)=∑kpk(t)⋅rk(t)G(t)=\sum_k p_k(t)\cdot r_k(t)G(t)=∑k​pk​(t)⋅rk​(t) with pk=mkvkp_k=m_kv_kpk​=mk​vk​.
  4. Time average over a duration τ\tauτ. ⟨f⟩τ=1τ∫0τf(t) dt\langle f\rangle_\tau=\frac1\tau\int_0^\tau f(t)\,dt⟨f⟩τ​=τ1​∫0τ​f(t)dt.
  5. Pair force from a distance potential. Given pair potentials Vjk:R→RV_{jk}:\mathbb R\to\mathbb RVjk​:R→R and a configuration x=(x1,…,xN)x=(x_1,\dots,x_N)x=(x1​,…,xN​), the force of particle jjj on particle kkk is
Fjk=−∇xk Vjk(∥xk−xj∥)(j≠k),Fkk=0.F_{jk}=-\nabla_{x_k}\,V_{jk}\big(\|x_k-x_j\|\big)\quad (j\ne k),\qquad F_{kk}=0 .Fjk​=−∇xk​​Vjk​(∥xk​−xj​∥)(j=k),Fkk​=0.
  1. Net force. Fk=∑jFjkF_k=\sum_j F_{jk}Fk​=∑j​Fjk​.
  2. Total potential energy. VTOT=∑k∑j<kVjk(∥xk−xj∥)V_{\mathrm{TOT}}=\sum_k\sum_{j<k}V_{jk}(\|x_k-x_j\|)VTOT​=∑k​∑j<k​Vjk​(∥xk​−xj​∥).
  3. Power-law potentials. Vjk(s)=αjk snV_{jk}(s)=\alpha_{jk}\,s^{n}Vjk​(s)=αjk​sn with a real exponent nnn.

These are the objects in terms of which every statement of the mission is phrased.

Formalization Note Space is EuclideanSpace ℝ (Fin 3). The time average is τ−1∫0τ\tau^{-1}\int_0^\tauτ−1∫0τ​, which Lean evaluates to 000 at τ=0\tau=0τ=0. The gradient is Mathlib's gradient, which returns 000 where the function is not differentiable. sns^nsn is the real power Real.rpow. The coefficients αjk\alpha_{jk}αjk​ are allowed to depend on the pair, which covers the article's single constant α\alphaα as well as gravity, where αjk=−Gmjmk\alpha_{jk}=-Gm_jm_kαjk​=−Gmj​mk​.

Definition code
import Mathlib

namespace VirialTheorem

/-- Physical space: three-dimensional Euclidean space `ℝ³`. -/
abbrev Space := EuclideanSpace ℝ (Fin 3)

variable {N : ℕ}

/-- Total kinetic energy `T(t) = ½ ∑ₖ mₖ ‖vₖ(t)‖²` of `N` particles with masses `m`
and velocity trajectories `v`. -/
noncomputable def kineticEnergy (m : Fin N → ℝ) (v : Fin N → ℝ → Space) (t : ℝ) : ℝ :=
  (1 / 2 : ℝ) * ∑ k, m k * ‖v k t‖ ^ 2

/-- Scalar moment of inertia about the origin, `I(t) = ∑ₖ mₖ ‖rₖ(t)‖²`. -/
noncomputable def momentOfInertia (m : Fin N → ℝ) (r : Fin N → ℝ → Space) (t : ℝ) : ℝ :=
  ∑ k, m k * ‖r k t‖ ^ 2

/-- The virial scalar `G(t) = ∑ₖ pₖ(t) · rₖ(t)`, where `pₖ = mₖ vₖ` is the momentum. -/
noncomputable def virialG (m : Fin N → ℝ) (r v : Fin N → ℝ → Space) (t : ℝ) : ℝ :=
  ∑ k, inner ℝ (m k • v k t) (r k t)

/-- The time average `⟨f⟩_τ = (1/τ) ∫₀^τ f(t) dt` of `f` over the duration `τ`. -/
noncomputable def timeAverage (f : ℝ → ℝ) (τ : ℝ) : ℝ :=
  τ⁻¹ * ∫ t in (0 : ℝ)..τ, f t

/-- The force `F_{jk}` exerted by particle `j` on particle `k` in the configuration
`x : Fin N → Space`, derived from pair potentials `V j k : ℝ → ℝ` depending only on the
interparticle distance: `F_{jk} = -∇_{r_k} V_{jk}(‖r_k - r_j‖)`, and `F_{kk} = 0`
(no particle acts on itself). -/
noncomputable def pairForce (V : Fin N → Fin N → ℝ → ℝ) (x : Fin N → Space) (j k : Fin N) :
    Space :=
  if j = k then 0 else -gradient (fun y : Space => V j k (dist y (x j))) (x k)

/-- Net force on particle `k`: `F_k = ∑ⱼ F_{jk}`. -/
noncomputable def netPairForce (V : Fin N → Fin N → ℝ → ℝ) (x : Fin N → Space) (k : Fin N) :
    Space :=
  ∑ j, pairForce V x j k

/-- Total potential energy `V_TOT = ∑ₖ ∑_{j<k} V_{jk}(‖r_k - r_j‖)`. -/
noncomputable def totalPotential (V : Fin N → Fin N → ℝ → ℝ) (x : Fin N → Space) : ℝ :=
  ∑ k, ∑ j ∈ Finset.univ.filter (fun j => j < k), V j k (dist (x k) (x j))

/-- Power-law pair potentials `V_{jk}(s) = α_{jk} s^n` (real exponent `n`). -/
noncomputable def powerLawPotential (α : Fin N → Fin N → ℝ) (n : ℝ) :
    Fin N → Fin N → ℝ → ℝ :=
  fun j k s => α j k * s ^ n

end VirialTheorem
Source
Wikipedia, "Virial theorem" (article supplied as Virial_theorem.pdf), https://en.wikipedia.org/wiki/Virial_theorem, sections 'Statement and derivation', 'Connection with the potential energy between particles', 'Special case of power-law forces', 'Time averaging'
Read-back

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

Non-blind read-back. This read-back is not independent testimony. It was written by the same agent that drafted the Lean statements, with full knowledge of the source article and of the intended meaning. Reviewers must not treat it as a blind audit; an independent read-back should still be obtained before relying on it.

The file fixes physical space as R3\mathbb R^3R3 with its Euclidean inner product and norm, and for a natural number NNN (possibly 000) introduces the following, where particles are indexed by {0,…,N−1}\{0,\dots,N-1\}{0,…,N−1}, mmm assigns to each particle an arbitrary real number (no sign condition), and r,vr, vr,v assign to each particle a function R→R3\mathbb R\to\mathbb R^3R→R3.

  • T(t)=12∑kmk∥vk(t)∥2T(t)=\tfrac12\sum_k m_k\|v_k(t)\|^2T(t)=21​∑k​mk​∥vk​(t)∥2.
  • I(t)=∑kmk∥rk(t)∥2I(t)=\sum_k m_k\|r_k(t)\|^2I(t)=∑k​mk​∥rk​(t)∥2.
  • G(t)=∑k⟨mkvk(t), rk(t)⟩G(t)=\sum_k \langle m_k v_k(t),\, r_k(t)\rangleG(t)=∑k​⟨mk​vk​(t),rk​(t)⟩.
  • For f:R→Rf:\mathbb R\to\mathbb Rf:R→R and τ∈R\tau\in\mathbb Rτ∈R: ⟨f⟩τ=τ−1∫0τf\langle f\rangle_\tau=\tau^{-1}\int_0^\tau f⟨f⟩τ​=τ−1∫0τ​f, an oriented interval integral (for τ<0\tau<0τ<0 it is −∫τ0-\int_\tau^0−∫τ0​); at τ=0\tau=0τ=0 the value is 000 because 0−1=00^{-1}=00−1=0; if fff is not integrable the integral is 000.
  • Given Vjk:R→RV_{jk}:\mathbb R\to\mathbb RVjk​:R→R for every ordered pair (j,k)(j,k)(j,k) and a configuration x∈(R3)Nx\in(\mathbb R^3)^Nx∈(R3)N: the pair force Fjk(x)F_{jk}(x)Fjk​(x) is 000 when j=kj=kj=k, and otherwise is minus the gradient at the point xkx_kxk​ of the function y↦Vjk(∥y−xj∥)y\mapsto V_{jk}(\|y-x_j\|)y↦Vjk​(∥y−xj​∥) on R3\mathbb R^3R3; where that function is not differentiable the gradient is 000 by convention.
  • The net force Fk(x)=∑jFjk(x)F_k(x)=\sum_j F_{jk}(x)Fk​(x)=∑j​Fjk​(x), summing over all jjj including j=kj=kj=k (which contributes 000).
  • VTOT(x)=∑k∑j<kVjk(∥xk−xj∥)V_{\mathrm{TOT}}(x)=\sum_k\sum_{j<k}V_{jk}(\|x_k-x_j\|)VTOT​(x)=∑k​∑j<k​Vjk​(∥xk​−xj​∥), with j<kj<kj<k in the index order; note it uses VjkV_{jk}Vjk​ with the smaller index first.
  • For real αjk\alpha_{jk}αjk​ and real nnn: the power-law family Vjk(s)=αjksnV_{jk}(s)=\alpha_{jk}s^{n}Vjk​(s)=αjk​sn, where sns^nsn is the real power function (for s>0s>0s>0 the usual power; for s=0s=0s=0 it is 111 if n=0n=0n=0 and 000 otherwise).
Human review
  • Endorsed by Shuze Chen · Oct 8, 2026

    Confirmed by the moderator at approval.

  • Endorsed by LG · Oct 8, 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