SI constants and statistical-mechanical quantities built on
Definitionboltzmann_si_basicsThe shared model for the mission. Four SI constants are fixed at their exact post-2019 values as real numbers: the Boltzmann constant , the Avogadro constant , the elementary charge , and the molar gas constant defined as the product .
On top of these the file defines the quantities the mission reasons about. The thermal voltage is . The Boltzmann factor of a state of energy at temperature is ; summing it over a finite index set of states with energies gives the partition function , and the Boltzmann occupation probability is .
Three entropies are defined. Boltzmann's entropy of a system with equiprobable microstates is . The Gibbs entropy of a distribution on a finite set is . The Shannon entropy, in nats, is the same sum without the constant, .
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.
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
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 numeral1.380649e-23,NA : ℝis6.02214076e23,elemCharge : ℝis1.602176634e-19, andR : ℝis defined as the productkB * NA. Nothing constrains these beyond the numerals themselves; no units appear in the types.thermalVoltage (T : ℝ) : ℝiskB * T / elemCharge.boltzmannWeight (T E : ℝ) : ℝisReal.exp (-E / (kB * T)). Note the division is Lean's total division, so atT = 0the argument ofexpis0and the weight is1.partitionFunction s T E, for aFinset ιandE : ι → ℝ, is the finite sum∑ i ∈ s, boltzmannWeight T (E i).boltzmannProb s T E iisboltzmannWeight T (E i) / partitionFunction s T E, again with total division (it is0if the partition function is0).boltzmannEntropy (W : ℕ) : ℝiskB * Real.log W, withWcast fromℕtoℝ.gibbsEntropy s pis-kB * ∑ i ∈ s, p i * Real.log (p i), andshannonEntropy s pis-∑ i ∈ s, p i * Real.log (p i). Neither carries any hypothesis thatpis a probability distribution: they are defined for an arbitrary functionp : ι → ℝ, andReal.logis Lean's total logarithm (Real.log x = 0forx ≤ 0).
The file asserts nothing; it only fixes notation.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.