Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

SI constants and statistical-mechanical quantities built on kBk_BkB​

Definition
boltzmann_si_basics

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

information-theorymathematical-physicsstatistical-mechanics

The shared model for the mission. Four SI constants are fixed at their exact post-2019 values as real numbers: the Boltzmann constant kB=1.380649×10−23 J K−1k_B = 1.380649\times10^{-23}\ \mathrm{J\,K^{-1}}kB​=1.380649×10−23 JK−1, the Avogadro constant NA=6.02214076×1023 mol−1N_A = 6.02214076\times10^{23}\ \mathrm{mol^{-1}}NA​=6.02214076×1023 mol−1, the elementary charge q=1.602176634×10−19 Cq = 1.602176634\times10^{-19}\ \mathrm{C}q=1.602176634×10−19 C, and the molar gas constant defined as the product R=kBNAR = k_B N_AR=kB​NA​.

On top of these the file defines the quantities the mission reasons about. The thermal voltage is VT(T)=kBT/qV_T(T) = k_B T / qVT​(T)=kB​T/q. The Boltzmann factor of a state of energy EEE at temperature TTT is e−E/(kBT)e^{-E/(k_B T)}e−E/(kB​T); summing it over a finite index set sss of states with energies EiE_iEi​ gives the partition function Z=∑i∈se−Ei/(kBT)Z = \sum_{i \in s} e^{-E_i/(k_B T)}Z=∑i∈s​e−Ei​/(kB​T), and the Boltzmann occupation probability is Pi=e−Ei/(kBT)/ZP_i = e^{-E_i/(k_B T)}/ZPi​=e−Ei​/(kB​T)/Z.

Three entropies are defined. Boltzmann's entropy of a system with WWW equiprobable microstates is S=kBlog⁡WS = k_B \log WS=kB​logW. The Gibbs entropy of a distribution ppp on a finite set is S=−kB∑ipilog⁡piS = -k_B \sum_i p_i \log p_iS=−kB​∑i​pi​logpi​. The Shannon entropy, in nats, is the same sum without the constant, −∑ipilog⁡pi-\sum_i p_i \log p_i−∑i​pi​logpi​.

All quantities are plain real numbers: units are carried by convention in the prose, not by the type system, and every formula is read in SI units (joules, kelvin, coulombs, volts). Logarithms are natural logarithms, so entropies are measured in nats.

Definition code
import Mathlib

namespace BoltzmannConstant

/-- The Boltzmann constant `k_B`, in joules per kelvin.  Since the 2019 revision of
the SI its value is exact. -/
noncomputable def kB : ℝ := 1.380649e-23

/-- The Avogadro constant `N_A`, per mole (exact since the 2019 revision of the SI). -/
noncomputable def NA : ℝ := 6.02214076e23

/-- The molar gas constant `R = k_B N_A`, in J·K⁻¹·mol⁻¹. -/
noncomputable def R : ℝ := kB * NA

/-- The elementary charge `q`, in coulombs (exact since the 2019 revision of the SI). -/
noncomputable def elemCharge : ℝ := 1.602176634e-19

/-- The thermal voltage `V_T = k_B T / q` at absolute temperature `T`. -/
noncomputable def thermalVoltage (T : ℝ) : ℝ := kB * T / elemCharge

/-- The Boltzmann factor `exp(-E / (k_B T))` of a state of energy `E` at temperature `T`. -/
noncomputable def boltzmannWeight (T E : ℝ) : ℝ := Real.exp (-E / (kB * T))

/-- The partition function `Z = ∑ exp(-E i / (k_B T))` of a finite set of states `s`. -/
noncomputable def partitionFunction {ι : Type*} (s : Finset ι) (T : ℝ) (E : ι → ℝ) : ℝ :=
  ∑ i ∈ s, boltzmannWeight T (E i)

/-- The Boltzmann occupation probability `P i = exp(-E i / (k_B T)) / Z`. -/
noncomputable def boltzmannProb {ι : Type*} (s : Finset ι) (T : ℝ) (E : ι → ℝ) (i : ι) : ℝ :=
  boltzmannWeight T (E i) / partitionFunction s T E

/-- Boltzmann's entropy `S = k_B log W` of a system with `W` equiprobable microstates. -/
noncomputable def boltzmannEntropy (W : ℕ) : ℝ := kB * Real.log W

/-- The Gibbs entropy `S = -k_B ∑ p log p` of a distribution `p` on a finite set `s`. -/
noncomputable def gibbsEntropy {ι : Type*} (s : Finset ι) (p : ι → ℝ) : ℝ :=
  -kB * ∑ i ∈ s, p i * Real.log (p i)

/-- The Shannon entropy `-∑ p log p` (in nats) of a distribution `p` on a finite set `s`. -/
noncomputable def shannonEntropy {ι : Type*} (s : Finset ι) (p : ι → ℝ) : ℝ :=
  -∑ i ∈ s, p i * Real.log (p i)

end BoltzmannConstant
Source
Wikipedia, "Boltzmann constant" (uploaded PDF), https://en.wikipedia.org/wiki/Boltzmann_constant, sections "Roles of the Boltzmann constant", "Role in Boltzmann factors", "Role in the statistical definition of entropy", "Thermal voltage"
Read-back

What the Lean code literally says, in plain math · non-independent self-read-back by the drafting agent (no independent auditor)

Disclosure — this read-back is NOT blind and NOT independent. It was written by the same agent that drafted the Lean statement it describes, at the explicit instruction of the proposal owner. It is therefore self-testimony, not independent auditor testimony: the author knew what the statement was intended to say, so it cannot detect the class of error a blind read-back exists to catch. No reviewer should count it as independent verification; it should be replaced by, or checked against, a genuinely blind read-back before this proposal is submitted.

The file opens import Mathlib and works inside namespace BoltzmannConstant. It introduces eleven noncomputable declarations, all valued in ℝ.

  • kB : ℝ is the numeral 1.380649e-23, NA : ℝ is 6.02214076e23, elemCharge : ℝ is 1.602176634e-19, and R : ℝ is defined as the product kB * NA. Nothing constrains these beyond the numerals themselves; no units appear in the types.
  • thermalVoltage (T : ℝ) : ℝ is kB * T / elemCharge.
  • boltzmannWeight (T E : ℝ) : ℝ is Real.exp (-E / (kB * T)). Note the division is Lean's total division, so at T = 0 the argument of exp is 0 and the weight is 1.
  • partitionFunction s T E, for a Finset ι and E : ι → ℝ, is the finite sum ∑ i ∈ s, boltzmannWeight T (E i).
  • boltzmannProb s T E i is boltzmannWeight T (E i) / partitionFunction s T E, again with total division (it is 0 if the partition function is 0).
  • boltzmannEntropy (W : ℕ) : ℝ is kB * Real.log W, with W cast from ℕ to ℝ.
  • gibbsEntropy s p is -kB * ∑ i ∈ s, p i * Real.log (p i), and shannonEntropy s p is -∑ i ∈ s, p i * Real.log (p i). Neither carries any hypothesis that p is a probability distribution: they are defined for an arbitrary function p : ι → ℝ, and Real.log is Lean's total logarithm (Real.log x = 0 for x ≤ 0).

The file asserts nothing; it only fixes notation.

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