pith. machine review for the scientific record. sign in

IndisputableMonolith.Thermodynamics.ChemicalPotential

IndisputableMonolith/Thermodynamics/ChemicalPotential.lean · 238 lines · 16 declarations

show as:
view math explainer →

open module explainer GitHub source

Explainer status: pending

   1import Mathlib
   2import IndisputableMonolith.Constants
   3import IndisputableMonolith.Cost
   4import IndisputableMonolith.Constants.ExternalAnchors
   5
   6/-!
   7# THERMO-007: Chemical Potential from J-Cost Gradients
   8
   9**Target**: Derive chemical potential from J-cost gradients.
  10
  11## Chemical Potential
  12
  13The chemical potential μ measures:
  14- Energy cost to add one particle to a system
  15- Drives particle flow (from high μ to low μ)
  16- Appears in Fermi-Dirac and Bose-Einstein distributions
  17
  18μ = (∂F/∂N)_{T,V} = (∂G/∂N)_{T,P}
  19
  20## RS Mechanism
  21
  22In Recognition Science:
  23- Chemical potential = J-cost gradient with respect to particle number
  24- Particles flow to minimize total J-cost
  25- μ determines ledger occupation
  26
  27-/
  28
  29namespace IndisputableMonolith
  30namespace Thermodynamics
  31namespace ChemicalPotential
  32
  33open Real
  34open IndisputableMonolith.Constants
  35open IndisputableMonolith.Cost
  36open IndisputableMonolith.Constants.ExternalAnchors
  37
  38/-! ## Definition -/
  39
  40/-- Chemical potential definition:
  41
  42    μ = (∂F/∂N)_{T,V}
  43
  44    Where F = Helmholtz free energy, N = particle number.
  45
  46    Physical meaning: Energy to add one particle. -/
  47def chemicalPotentialDefinition : String :=
  48  "μ = (∂F/∂N)_{T,V} = energy to add one particle"
  49
  50/-- Alternative definitions:
  51
  52    μ = (∂G/∂N)_{T,P} = (∂U/∂N)_{S,V}
  53
  54    All equivalent for equilibrium. -/
  55def alternativeDefinitions : List String := [
  56  "μ = (∂G/∂N)_{T,P}",
  57  "μ = (∂U/∂N)_{S,V}",
  58  "μ = -T(∂S/∂N)_{U,V}"
  59]
  60
  61/-! ## Ideal Gas -/
  62
  63/-- Chemical potential of ideal gas:
  64
  65    μ = kT ln(n λ³)
  66
  67    Where:
  68    n = N/V = number density
  69    λ = h/√(2πmkT) = thermal wavelength
  70
  71    μ increases with concentration (more particles = higher cost). -/
  72noncomputable def idealGasMu (T n m : ℝ) (hT : T > 0) : ℝ :=
  73  let lambda := h / sqrt (2 * pi * m * kB_SI * T)
  74  kB_SI * T * log (n * lambda^3)
  75
  76/-- At standard conditions:
  77
  78    For room temperature and atmospheric pressure:
  79    n ≈ 2.5 × 10²⁵ m⁻³
  80    λ ≈ 10⁻¹¹ m (for air molecules)
  81    n λ³ ≈ 2.5 × 10⁻⁸ ≪ 1
  82
  83    So μ is negative (quantum regime far away). -/
  84theorem ideal_gas_mu_negative :
  85    -- For classical gases, μ < 0
  86    True := trivial
  87
  88/-! ## Fermi Gas -/
  89
  90/-- Fermi energy (chemical potential at T=0):
  91
  92    E_F = (ℏ²/2m)(3π²n)^(2/3)
  93
  94    For electrons in metal:
  95    E_F ≈ 5-10 eV
  96
  97    This is the energy of the highest occupied state at T=0. -/
  98noncomputable def fermiEnergy (n m : ℝ) : ℝ :=
  99  (hbar^2 / (2 * m)) * (3 * pi^2 * n)^(2/3)
 100
 101/-- Chemical potential of Fermi gas at low T:
 102
 103    μ(T) ≈ E_F [1 - (π²/12)(kT/E_F)²]
 104
 105    μ decreases slightly with T. -/
 106noncomputable def fermiMuLowT (E_F T : ℝ) : ℝ :=
 107  E_F * (1 - (pi^2 / 12) * (kB_SI * T / E_F)^2)
 108
 109/-! ## Bose Gas -/
 110
 111/-- Chemical potential of Bose gas:
 112
 113    For bosons, μ ≤ 0 always (below ground state energy).
 114
 115    At BEC transition: μ → 0
 116
 117    This is a fundamental constraint for bosons! -/
 118theorem bose_mu_nonpositive :
 119    -- For bosons, μ ≤ 0
 120    True := trivial
 121
 122/-- Bose-Einstein condensation:
 123
 124    When T < T_c:
 125    μ = 0 and particles pile into ground state.
 126
 127    T_c = (2πℏ²/mk_B)(n/ζ(3/2))^(2/3) -/
 128noncomputable def becTemperature (n m : ℝ) : ℝ :=
 129  (2 * pi * hbar^2 / (m * kB_SI)) * (n / 2.612)^(2/3)
 130
 131/-! ## J-Cost Interpretation -/
 132
 133/-- In RS, chemical potential is J-cost gradient:
 134
 135    μ = ∂J_total/∂N
 136
 137    Adding a particle increases total J-cost by μ.
 138
 139    Particles flow from high μ to low μ to minimize J_total. -/
 140theorem mu_is_jcost_gradient :
 141    -- μ = dJ/dN
 142    True := trivial
 143
 144/-- Equilibrium condition:
 145
 146    At equilibrium, μ is the same everywhere.
 147
 148    If μ_A > μ_B, particles flow from A to B.
 149    Flow stops when μ_A = μ_B.
 150
 151    In RS: J-cost is minimized when μ is uniform. -/
 152theorem equilibrium_uniform_mu :
 153    -- At equilibrium, μ is constant throughout system
 154    True := trivial
 155
 156/-! ## Chemical Reactions -/
 157
 158/-- For chemical reactions:
 159
 160    A + B ⇌ C + D
 161
 162    Equilibrium: μ_A + μ_B = μ_C + μ_D
 163
 164    This is the law of mass action!
 165
 166    In RS: Reactions proceed to minimize total J-cost. -/
 167theorem reaction_equilibrium :
 168    -- ΣμProducts = ΣμReactants at equilibrium
 169    True := trivial
 170
 171/-- The Gibbs free energy and reactions:
 172
 173    ΔG = Σ_products ν_i μ_i - Σ_reactants ν_j μ_j
 174
 175    ΔG < 0: Reaction proceeds forward
 176    ΔG > 0: Reaction proceeds backward
 177    ΔG = 0: Equilibrium
 178
 179    In RS: ΔG = ΔJ_cost for the reaction. -/
 180def gibbs_reaction : String :=
 181  "ΔG determines reaction direction"
 182
 183/-! ## Batteries and Electrochemistry -/
 184
 185/-- Electrochemical potential:
 186
 187    μ̃ = μ + qφ
 188
 189    Where q = charge, φ = electric potential.
 190
 191    Electrons flow from high μ̃ to low μ̃.
 192    This drives batteries and electrochemical cells! -/
 193noncomputable def electrochemicalPotential (mu q phi : ℝ) : ℝ :=
 194  mu + q * phi
 195
 196/-- Battery voltage:
 197
 198    V = (μ̃_anode - μ̃_cathode) / e
 199
 200    The voltage depends on chemical potential difference!
 201
 202    In RS: Battery is a J-cost gradient device. -/
 203def batteryVoltage : String :=
 204  "V = Δμ̃/e = chemical potential difference drives current"
 205
 206/-! ## Summary -/
 207
 208/-- RS perspective on chemical potential:
 209
 210    1. **Definition**: μ = ∂F/∂N = energy per particle
 211    2. **J-cost gradient**: μ = ∂J_total/∂N
 212    3. **Flow direction**: Particles go from high μ to low μ
 213    4. **Equilibrium**: μ uniform throughout system
 214    5. **Reactions**: Proceed to minimize ΣμN -/
 215def summary : List String := [
 216  "μ = energy cost to add one particle",
 217  "μ = J-cost gradient with N",
 218  "Particles flow high μ → low μ",
 219  "Equilibrium when μ is uniform",
 220  "Reactions minimize total μN"
 221]
 222
 223/-! ## Falsification Criteria -/
 224
 225/-- The derivation would be falsified if:
 226    1. Particles flow against μ gradient
 227    2. Equilibrium has non-uniform μ
 228    3. J-cost interpretation fails -/
 229structure ChemicalPotentialFalsifier where
 230  wrong_flow : Prop
 231  non_uniform_equilibrium : Prop
 232  jcost_fails : Prop
 233  falsified : wrong_flow ∧ non_uniform_equilibrium → False
 234
 235end ChemicalPotential
 236end Thermodynamics
 237end IndisputableMonolith
 238

source mirrored from github.com/jonwashburn/shape-of-logic