chars
int64
40
24k
content_type
stringclasses
9 values
id
stringlengths
13
64
source
stringclasses
5 values
subset
stringclasses
31 values
text
stringlengths
40
24k
288
leanexplore_declaration
leanexplore:377492
leanexplore_sqlite
leanexplore_declarations
/-- The type `Temperature` represents the temperature in a given (but arbitrary) set of units (preserving zero). It currently wraps `ℝ≥0`, i.e., absolute temperature in nonnegative reals. -/ structure Temperature where /-- The nonnegative real value of the temperature. -/ val : ℝ≥0
76
leanexplore_declaration
leanexplore:377493
leanexplore_sqlite
leanexplore_declarations
/-- Coercion to `ℝ≥0`. -/ instance : Coe Temperature ℝ≥0 := ⟨fun T => T.val⟩
136
leanexplore_declaration
leanexplore:377494
leanexplore_sqlite
leanexplore_declarations
/-- The underlying real-number associated with the temperature. -/ noncomputable def toReal (T : Temperature) : ℝ := NNReal.toReal T.val
78
leanexplore_declaration
leanexplore:377495
leanexplore_sqlite
leanexplore_declarations
/-- Coercion to `ℝ`. -/ noncomputable instance : Coe Temperature ℝ := ⟨toReal⟩
175
leanexplore_declaration
leanexplore:377496
leanexplore_sqlite
leanexplore_declarations
/-- Topology on `Temperature` induced from `ℝ≥0`. -/ instance : TopologicalSpace Temperature := TopologicalSpace.induced (fun T : Temperature => (T.val : ℝ≥0)) inferInstance
111
leanexplore_declaration
leanexplore:377498
leanexplore_sqlite
leanexplore_declarations
@[ext] lemma ext {T₁ T₂ : Temperature} (h : T₁.val = T₂.val) : T₁ = T₂ := by cases T₁; cases T₂; cases h; rfl
328
leanexplore_declaration
leanexplore:377500
leanexplore_sqlite
leanexplore_declarations
/-- The inverse temperature defined as `1/(kB * T)` in a given, but arbitrary set of units. This has dimensions equivalent to `Energy`. -/ noncomputable def β (T : Temperature) : ℝ≥0 := ⟨1 / (kB * (T : ℝ)), by apply div_nonneg · exact zero_le_one · apply mul_nonneg · exact kB_nonneg · simp [...
263
leanexplore_declaration
leanexplore:377501
leanexplore_sqlite
leanexplore_declarations
/-- The temperature associated with a given inverse temperature `β`. -/ noncomputable def ofβ (β : ℝ≥0) : Temperature := ⟨⟨1 / (kB * β), by apply div_nonneg · exact zero_le_one · apply mul_nonneg · exact kB_nonneg · exact β.2⟩⟩
172
leanexplore_declaration
leanexplore:377502
leanexplore_sqlite
leanexplore_declarations
lemma ofβ_eq : ofβ = fun β => ⟨⟨1 / (kB * β), by apply div_nonneg · exact zero_le_one · apply mul_nonneg · exact kB_nonneg · exact β.2⟩⟩ := by rfl
110
leanexplore_declaration
leanexplore:377503
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma β_ofβ (β' : ℝ≥0) : β (ofβ β') = β' := by ext simp [β, ofβ, toReal] field_simp [kB_ne_zero]
280
leanexplore_declaration
leanexplore:377504
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma ofβ_β (T : Temperature) : ofβ (β T) = T := by ext change ((1 : ℝ) / (kB * ((β T : ℝ)))) = (T : ℝ) have : (β T : ℝ) = (1 : ℝ) / (kB * (T : ℝ)) := rfl simpa [this] using show (1 / (kB * (1 / (kB * (T : ℝ))))) = (T : ℝ) from by field_simp [kB_ne_zero]
266
leanexplore_declaration
leanexplore:377505
leanexplore_sqlite
leanexplore_declarations
/-- Positivity of `β` from positivity of temperature. -/ lemma beta_pos (T : Temperature) (hT_pos : 0 < T.val) : 0 < (T.β : ℝ) := by unfold Temperature.β have h_prod : 0 < (kB : ℝ) * T.val := mul_pos kB_pos hT_pos simpa [Temperature.β] using inv_pos.mpr h_prod
1,228
leanexplore_declaration
leanexplore:377506
leanexplore_sqlite
leanexplore_declarations
lemma ofβ_continuousOn : ContinuousOn (ofβ : ℝ≥0 → Temperature) (Set.Ioi 0) := by rw [ofβ_eq] refine continuousOn_of_forall_continuousAt ?_ intro x hx have h1 : ContinuousAt (fun t : ℝ => 1 / (kB * t)) x.1 := by refine ContinuousAt.div₀ ?_ ?_ ?_ · fun_prop · fun_prop · simp constructor ...
504
leanexplore_declaration
leanexplore:377507
leanexplore_sqlite
leanexplore_declarations
lemma ofβ_differentiableOn : DifferentiableOn ℝ (fun (x : ℝ) => ((ofβ (Real.toNNReal x)).val : ℝ)) (Set.Ioi 0) := by refine DifferentiableOn.congr (f := fun x => 1 / (kB * x)) ?_ ?_ · refine DifferentiableOn.fun_div ?_ ?_ ?_ · fun_prop · fun_prop · intro x hx have hx0 : x ≠ 0 := ne_of_gt (by s...
500
leanexplore_declaration
leanexplore:377508
leanexplore_sqlite
leanexplore_declarations
/-- Eventually, `ofβ β` is positive as β → ∞`. -/ lemma eventually_pos_ofβ : ∀ᶠ b : ℝ≥0 in atTop, ((Temperature.ofβ b : Temperature) : ℝ) > 0 := by have hge : ∀ᶠ b : ℝ≥0 in atTop, (1 : ℝ≥0) ≤ b := Filter.eventually_ge_atTop 1 refine hge.mono ?_ intro b hb have hbpos : 0 < (b : ℝ) := (zero_lt_one.trans_le hb) ...
516
leanexplore_declaration
leanexplore:377509
leanexplore_sqlite
leanexplore_declarations
/-- Core convergence: as β → ∞, `toReal (ofβ β) → 0` in `ℝ`. -/ lemma tendsto_toReal_ofβ_atTop : Tendsto (fun b : ℝ≥0 => (Temperature.ofβ b : ℝ)) atTop (𝓝 (0 : ℝ)) := by have hform : (fun b : ℝ≥0 => (Temperature.ofβ b : ℝ)) = (fun b : ℝ≥0 => (1 : ℝ) / (kB * (b : ℝ))) := by funext b; simp ...
569
leanexplore_declaration
leanexplore:377510
leanexplore_sqlite
leanexplore_declarations
/-- As β → ∞, T = ofβ β → 0+ in ℝ (within Ioi 0). -/ lemma tendsto_ofβ_atTop : Tendsto (fun b : ℝ≥0 => (Temperature.ofβ b : ℝ)) atTop (nhdsWithin 0 (Set.Ioi 0)) := by have h_to0 := tendsto_toReal_ofβ_atTop have h_into : Tendsto (fun b : ℝ≥0 => (Temperature.ofβ b : ℝ)) atTop (𝓟 (Set.Ioi (0 : ℝ))) :=...
114
leanexplore_declaration
leanexplore:377511
leanexplore_sqlite
leanexplore_declarations
/-- Build a `Temperature` directly from a nonnegative real. -/ @[simp] def ofNNReal (t : ℝ≥0) : Temperature := ⟨t⟩
66
leanexplore_declaration
leanexplore:377512
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma ofNNReal_val (t : ℝ≥0) : (ofNNReal t).val = t := rfl
88
leanexplore_declaration
leanexplore:377513
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma coe_ofNNReal_coe (t : ℝ≥0) : ((ofNNReal t : Temperature) : ℝ≥0) = t := rfl
80
leanexplore_declaration
leanexplore:377514
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma coe_ofNNReal_real (t : ℝ≥0) : ((⟨t⟩ : Temperature) : ℝ) = t := rfl
187
leanexplore_declaration
leanexplore:377515
leanexplore_sqlite
leanexplore_declarations
/-- Convenience: build a temperature from a real together with a proof of nonnegativity. -/ @[simp] noncomputable def ofRealNonneg (t : ℝ) (ht : 0 ≤ t) : Temperature := ofNNReal ⟨t, ht⟩
98
leanexplore_declaration
leanexplore:377516
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma ofRealNonneg_val {t : ℝ} (ht : 0 ≤ t) : (ofRealNonneg t ht).val = ⟨t, ht⟩ := rfl
240
leanexplore_declaration
leanexplore:377517
leanexplore_sqlite
leanexplore_declarations
/-- Map a real `t` to the inverse temperature `β` corresponding to the temperature `Real.toNNReal t` (`max t 0`), returned as a real number. -/ noncomputable def betaFromReal (t : ℝ) : ℝ := ((Temperature.ofNNReal (Real.toNNReal t)).β : ℝ)
416
leanexplore_declaration
leanexplore:377518
leanexplore_sqlite
leanexplore_declarations
/-- Explicit closed-form for `Beta_fun_T t` when `t > 0`. -/ lemma beta_fun_T_formula (t : ℝ) (ht : 0 < t) : betaFromReal t = 1 / (kB * t) := by have ht0 : (0 : ℝ) ≤ t := ht.le have : ((Temperature.ofNNReal (Real.toNNReal t)).β : ℝ) = 1 / (kB * t) := by simp [Temperature.β, Temperature.ofNNReal, Temperature...
198
leanexplore_declaration
leanexplore:377519
leanexplore_sqlite
leanexplore_declarations
/-- On `Ioi 0`, `Beta_fun_T t` equals `1 / (kB * t)`. -/ lemma beta_fun_T_eq_on_Ioi : EqOn betaFromReal (fun t : ℝ => 1 / (kB * t)) (Set.Ioi 0) := by intro t ht exact beta_fun_T_formula t ht
1,455
leanexplore_declaration
leanexplore:377520
leanexplore_sqlite
leanexplore_declarations
lemma deriv_beta_wrt_T (T : Temperature) (hT_pos : 0 < T.val) : HasDerivWithinAt betaFromReal (-1 / (kB * (T.val : ℝ)^2)) (Set.Ioi 0) (T.val : ℝ) := by let f : ℝ → ℝ := fun t => 1 / (kB * t) have h_eq : EqOn betaFromReal f (Set.Ioi 0) := beta_fun_T_eq_on_Ioi have hTne : (T.val : ℝ) ≠ 0 := ne_of_gt hT_pos ha...
1,177
leanexplore_declaration
leanexplore:377521
leanexplore_sqlite
leanexplore_declarations
/-- Chain rule for β(T) : d/dT F(β(T)) = F'(β(T)) * (-1 / (kB * T^2)), within `Ioi 0`. -/ lemma chain_rule_T_beta {F : ℝ → ℝ} {F' : ℝ} (T : Temperature) (hT_pos : 0 < T.val) (hF_deriv : HasDerivWithinAt F F' (Set.Ioi 0) (T.β : ℝ)) : HasDerivWithinAt (fun t : ℝ => F (betaFromReal t)) (F' * (-1 / (kB * ...
256
leanexplore_declaration
leanexplore:377522
leanexplore_sqlite
leanexplore_declarations
/-- The choices of translationally-invariant metrics on the temperature-manifold. Such a choice corresponds to a choice of units for temperature. -/ structure TemperatureUnit where /-- The underlying scale of the unit. -/ val : ℝ property : 0 < val
103
leanexplore_declaration
leanexplore:377523
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma val_ne_zero (x : TemperatureUnit) : x.val ≠ 0 := by exact Ne.symm (ne_of_lt x.property)
61
leanexplore_declaration
leanexplore:377524
leanexplore_sqlite
leanexplore_declarations
lemma val_pos (x : TemperatureUnit) : 0 < x.val := x.property
72
leanexplore_declaration
leanexplore:377525
leanexplore_sqlite
leanexplore_declarations
instance : Inhabited TemperatureUnit where default := ⟨1, by norm_num⟩
155
leanexplore_declaration
leanexplore:377526
leanexplore_sqlite
leanexplore_declarations
noncomputable instance : HDiv TemperatureUnit TemperatureUnit ℝ≥0 where hDiv x t := ⟨x.val / t.val, div_nonneg (le_of_lt x.val_pos) (le_of_lt t.val_pos)⟩
139
leanexplore_declaration
leanexplore:377527
leanexplore_sqlite
leanexplore_declarations
lemma div_eq_val (x y : TemperatureUnit) : x / y = (⟨x.val / y.val, div_nonneg (le_of_lt x.val_pos) (le_of_lt y.val_pos)⟩ : ℝ≥0) := rfl
129
leanexplore_declaration
leanexplore:377528
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma div_ne_zero (x y : TemperatureUnit) : ¬ x / y = (0 : ℝ≥0) := by rw [div_eq_val] refine coe_ne_zero.mp ?_ simp
155
leanexplore_declaration
leanexplore:377529
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma div_pos (x y : TemperatureUnit) : (0 : ℝ≥0) < x/ y := by apply lt_of_le_of_ne · exact zero_le (x / y) · exact Ne.symm (div_ne_zero x y)
109
leanexplore_declaration
leanexplore:377530
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma div_self (x : TemperatureUnit) : x / x = (1 : ℝ≥0) := by simp [div_eq_val, x.val_ne_zero]
134
leanexplore_declaration
leanexplore:377531
leanexplore_sqlite
leanexplore_declarations
lemma div_symm (x y : TemperatureUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by rw [div_eq_val, inv_eq_one_div, div_eq_val] simp
132
leanexplore_declaration
leanexplore:377532
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma div_mul_div_coe (x y z : TemperatureUnit) : (x / y : ℝ) * (y /z : ℝ) = x /z := by simp [div_eq_val] field_simp
185
leanexplore_declaration
leanexplore:377533
leanexplore_sqlite
leanexplore_declarations
/-- The scaling of a temperature unit by a positive real. -/ def scale (r : ℝ) (x : TemperatureUnit) (hr : 0 < r := by norm_num) : TemperatureUnit := ⟨r * x.val, mul_pos hr x.val_pos⟩
154
leanexplore_declaration
leanexplore:377534
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma scale_div_self (x : TemperatureUnit) (r : ℝ) (hr : 0 < r) : scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by simp [scale, div_eq_val]
226
leanexplore_declaration
leanexplore:377535
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma self_div_scale (x : TemperatureUnit) (r : ℝ) (hr : 0 < r) : x / scale r x hr = (⟨1/r, _root_.div_nonneg (by simp) (le_of_lt hr)⟩ : ℝ≥0) := by simp [scale, div_eq_val] ext simp only [coe_mk] field_simp
82
leanexplore_declaration
leanexplore:377536
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma scale_one (x : TemperatureUnit) : scale 1 x = x := by simp [scale]
261
leanexplore_declaration
leanexplore:377537
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma scale_div_scale (x1 x2 : TemperatureUnit) {r1 r2 : ℝ} (hr1 : 0 < r1) (hr2 : 0 < r2) : scale r1 x1 hr1 / scale r2 x2 hr2 = (⟨r1, le_of_lt hr1⟩ / ⟨r2, le_of_lt hr2⟩) * (x1 / x2) := by refine NNReal.eq ?_ simp [scale, div_eq_val] field_simp
191
leanexplore_declaration
leanexplore:377538
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma scale_scale (x : TemperatureUnit) (r1 r2 : ℝ) (hr1 : 0 < r1) (hr2 : 0 < r2) : scale r1 (scale r2 x hr2) hr1 = scale (r1 * r2) x (mul_pos hr1 hr2) := by simp [scale] ring
103
leanexplore_declaration
leanexplore:377539
leanexplore_sqlite
leanexplore_declarations
/-- The definition of a temperature unit of kelvin. -/ def kelvin : TemperatureUnit := ⟨1, by norm_num⟩
137
leanexplore_declaration
leanexplore:377540
leanexplore_sqlite
leanexplore_declarations
/-- The temperature unit of degrees nanokelvin (10^(-9) kelvin). -/ noncomputable def nanokelvin : TemperatureUnit := scale (1e-9) kelvin
139
leanexplore_declaration
leanexplore:377541
leanexplore_sqlite
leanexplore_declarations
/-- The temperature unit of degrees microkelvin (10^(-6) kelvin). -/ noncomputable def microkelvin : TemperatureUnit := scale (1e-6) kelvin
139
leanexplore_declaration
leanexplore:377542
leanexplore_sqlite
leanexplore_declarations
/-- The temperature unit of degrees millikelvin (10^(-3) kelvin). -/ noncomputable def millikelvin : TemperatureUnit := scale (1e-3) kelvin
214
leanexplore_declaration
leanexplore:377543
leanexplore_sqlite
leanexplore_declarations
/-- The temperature unit of degrees fahrenheit ((5/9) of a kelvin). Note, this is fahrenheit starting at `0` absolute temperature. -/ noncomputable def absoluteFahrenheit : TemperatureUnit := scale (5 / 9) kelvin
305
leanexplore_declaration
leanexplore:377544
leanexplore_sqlite
leanexplore_declarations
/-- The choice of units. -/ @[ext] structure UnitChoices where /-- The length unit. -/ length : LengthUnit /-- The time unit. -/ time : TimeUnit /-- The mass unit. -/ mass : MassUnit /-- The charge unit. -/ charge : ChargeUnit /-- The temperature unit. -/ temperature : TemperatureUnit
583
leanexplore_declaration
leanexplore:377545
leanexplore_sqlite
leanexplore_declarations
@[ext] structure UnitChoices where /-- The length unit. -/ length : LengthUnit /-- The time unit. -/ time : TimeUnit /-- The mass unit. -/ mass : MassUnit /-- The charge unit. -/ charge : ChargeUnit /-- The temperature unit. -/ temperature : TemperatureUnit namespace UnitChoices /-- Given two choi...
784
leanexplore_declaration
leanexplore:377547
leanexplore_sqlite
leanexplore_declarations
/-- Given two choices of units `u1` and `u2` and a dimension `d`, the element of `ℝ≥0` corresponding to the scaling (by definition) of a quantity of dimension `d` when changing from units `u1` to `u2`. -/ noncomputable def dimScale (u1 u2 : UnitChoices) :Dimension →* ℝ≥0 where toFun d := (u1.length / u2.lengt...
336
leanexplore_declaration
leanexplore:377548
leanexplore_sqlite
leanexplore_declarations
lemma dimScale_apply (u1 u2 : UnitChoices) (d : Dimension) : dimScale u1 u2 d = (u1.length / u2.length) ^ (d.length : ℝ) * (u1.time / u2.time) ^ (d.time : ℝ) * (u1.mass / u2.mass) ^ (d.mass : ℝ) * (u1.charge / u2.charge) ^ (d.charge : ℝ) * (u1.temperature / u2.temperature) ^ (d.tempera...
110
leanexplore_declaration
leanexplore:377549
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma dimScale_self (u : UnitChoices) (d : Dimension) : dimScale u u d = 1 := by simp [dimScale]
99
leanexplore_declaration
leanexplore:377550
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma dimScale_one (u1 u2 : UnitChoices) : dimScale u1 u2 1 = 1 := by simp [dimScale]
857
leanexplore_declaration
leanexplore:377551
leanexplore_sqlite
leanexplore_declarations
lemma dimScale_transitive (u1 u2 u3 : UnitChoices) (d : Dimension) : dimScale u1 u2 d * dimScale u2 u3 d = dimScale u1 u3 d := by simp [dimScale] trans ((u1.length / u2.length) ^ (d.length : ℝ) * (u2.length / u3.length) ^ (d.length : ℝ)) * ((u1.time / u2.time) ^ (d.time : ℝ) * (u2.time / u3.time) ^ (d.time ...
163
leanexplore_declaration
leanexplore:377552
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma dimScale_mul_symm (u1 u2 : UnitChoices) (d : Dimension) : dimScale u1 u2 d * dimScale u2 u1 d = 1 := by rw [dimScale_transitive, dimScale_self]
231
leanexplore_declaration
leanexplore:377553
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma dimScale_coe_mul_symm (u1 u2 : UnitChoices) (d : Dimension) : (toReal (dimScale u1 u2 d)) * (toReal (dimScale u2 u1 d)) = 1 := by trans toReal (dimScale u1 u2 d * dimScale u2 u1 d) · rw [NNReal.coe_mul] simp
119
leanexplore_declaration
leanexplore:377554
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma dimScale_ne_zero (u1 u2 : UnitChoices) (d : Dimension) : dimScale u1 u2 d ≠ 0 := by simp [dimScale]
351
leanexplore_declaration
leanexplore:377555
leanexplore_sqlite
leanexplore_declarations
lemma dimScale_symm (u1 u2 : UnitChoices) (d : Dimension) : dimScale u1 u2 d = (dimScale u2 u1 d)⁻¹ := by simp only [dimScale_apply, mul_inv] congr · rw [LengthUnit.div_symm, inv_rpow] · rw [TimeUnit.div_symm, inv_rpow] · rw [MassUnit.div_symm, inv_rpow] · rw [ChargeUnit.div_symm, inv_rpow] · rw [Temp...
171
leanexplore_declaration
leanexplore:377556
leanexplore_sqlite
leanexplore_declarations
lemma dimScale_of_inv_eq_swap (u1 u2 : UnitChoices) (d : Dimension) : dimScale u1 u2 d⁻¹ = dimScale u2 u1 d := by simp only [map_inv] conv_rhs => rw[dimScale_symm]
297
leanexplore_declaration
leanexplore:377557
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma smul_dimScale_injective {M : Type} [MulAction ℝ≥0 M] (u1 u2 : UnitChoices) (d : Dimension) (m1 m2 : M) : (u1.dimScale u2 d) • m1 = (u1.dimScale u2 d) • m2 ↔ m1 = m2:= by refine IsUnit.smul_left_cancel ?_ refine isUnit_iff_exists_inv.mpr ?_ use u1.dimScale u2 d⁻¹ simp
176
leanexplore_declaration
leanexplore:377558
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma dimScale_pos (u1 u2 : UnitChoices) (d : Dimension) : 0 < (dimScale u1 u2 d) := by apply lt_of_le_of_ne · simp · exact Ne.symm (dimScale_ne_zero u1 u2 d)
316
leanexplore_declaration
leanexplore:377559
leanexplore_sqlite
leanexplore_declarations
/-- The choice of units corresponding to SI units, that is - meters, - seconds, - kilograms, - coulombs, - kelvin. -/ noncomputable def SI : UnitChoices where length := LengthUnit.meters time := TimeUnit.seconds mass := MassUnit.kilograms charge := ChargeUnit.coulombs temperature := TemperatureUnit.kelvin
62
leanexplore_declaration
leanexplore:377560
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma SI_length : SI.length = LengthUnit.meters := rfl
57
leanexplore_declaration
leanexplore:377561
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma SI_time : SI.time = TimeUnit.seconds := rfl
59
leanexplore_declaration
leanexplore:377562
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma SI_mass : SI.mass = MassUnit.kilograms := rfl
64
leanexplore_declaration
leanexplore:377563
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma SI_charge : SI.charge = ChargeUnit.coulombs := rfl
77
leanexplore_declaration
leanexplore:377564
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma SI_temperature : SI.temperature = TemperatureUnit.kelvin := rfl
475
leanexplore_declaration
leanexplore:377565
leanexplore_sqlite
leanexplore_declarations
/-- A `UnitChoices` which is related to `SI` by a prime scaling of each of the underlying units. This is useful in proving that a result is not dimensionally correct. -/ noncomputable def SIPrimed : UnitChoices where length := LengthUnit.scale 2 LengthUnit.meters time := TimeUnit.scale 3 TimeUnit.seconds mass...
310
leanexplore_declaration
leanexplore:377566
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma dimScale_SI_SIPrimed (d : Dimension) : dimScale SI SIPrimed d = (2⁻¹ : ℝ≥0) ^ (d.length : ℝ) * (3⁻¹ : ℝ≥0) ^ (d.time : ℝ) * (5⁻¹ : ℝ≥0) ^ (d.mass : ℝ) * (7⁻¹ : ℝ≥0) ^ (d.charge : ℝ) * (11⁻¹ : ℝ≥0) ^ (d.temperature : ℝ) := by simp [dimScale, SI, SIPrimed] rfl
300
leanexplore_declaration
leanexplore:377567
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma dimScale_SIPrimed_SI (d : Dimension) : dimScale SIPrimed SI d = (2 : ℝ≥0) ^ (d.length : ℝ) * (3 : ℝ≥0) ^ (d.time : ℝ) * (5 : ℝ≥0) ^ (d.mass : ℝ) * (7 : ℝ≥0) ^ (d.charge : ℝ) * (11 : ℝ≥0) ^ (d.temperature : ℝ) := by simp [dimScale, SI, SIPrimed] rfl
206
leanexplore_declaration
leanexplore:377568
leanexplore_sqlite
leanexplore_declarations
/-- This typeclass indicates that there is a dimension `dim M : Dimension` associated with the type `M`. -/ class HasDim (M : Type) where /-- The dimension associated with a type `M`. -/ d : Dimension
231
leanexplore_declaration
leanexplore:377570
leanexplore_sqlite
leanexplore_declarations
/-- A type `M` carries a dimension `d` if every element of `M` is supposed to have this dimension. For example, the type `Time` will carry a dimension `T𝓭`. -/ class abbrev CarriesDimension (M : Type) := HasDim M, MulAction ℝ≥0 M
338
leanexplore_declaration
leanexplore:377571
leanexplore_sqlite
leanexplore_declarations
/-- A quantity of type `M` which depends on a choice of units `UnitChoices` is said to be of dimension `d` if it scales by `UnitChoices.dimScale u1 u2 d` under a change in units. -/ def HasDimension {M : Type} [CarriesDimension M] (f : UnitChoices → M) : Prop := ∀ u1 u2 : UnitChoices, f u2 = UnitChoices.dimScale u1...
187
leanexplore_declaration
leanexplore:377572
leanexplore_sqlite
leanexplore_declarations
lemma hasDimension_iff {M : Type} [CarriesDimension M] (f : UnitChoices → M) : HasDimension f ↔ ∀ u1 u2 : UnitChoices, f u2 = UnitChoices.dimScale u1 u2 (dim M) • f u1 := by rfl
193
leanexplore_declaration
leanexplore:377573
leanexplore_sqlite
leanexplore_declarations
/-- The subtype of functions `UnitChoices → M`, for which `M` carries a dimension, which `HasDimension`. -/ def Dimensionful (M : Type) [CarriesDimension M] := Subtype (HasDimension (M := M))
120
leanexplore_declaration
leanexplore:377574
leanexplore_sqlite
leanexplore_declarations
instance {M : Type} [CarriesDimension M] : CoeFun (Dimensionful M) (fun _ => UnitChoices → M) where coe := Subtype.val
161
leanexplore_declaration
leanexplore:377575
leanexplore_sqlite
leanexplore_declarations
@[ext] lemma Dimensionful.ext {M : Type} [CarriesDimension M] (f1 f2 : Dimensionful M) (h : f1.val = f2.val) : f1 = f2 := by cases f1 cases f2 simp_all
128
leanexplore_declaration
leanexplore:377576
leanexplore_sqlite
leanexplore_declarations
@[ext] lemma Dimensionful.ext {M : Type} [CarriesDimension M] (f1 f2 : Dimensionful M) (h : f1.val = f2.val) : f1 = f2 := by
355
leanexplore_declaration
leanexplore:377577
leanexplore_sqlite
leanexplore_declarations
instance {M : Type} [CarriesDimension M] : MulAction ℝ≥0 (Dimensionful M) where smul a f := ⟨fun u => a • f.1 u, fun u1 u2 => by simp only rw [f.2 u1 u2] rw [smul_comm]⟩ one_smul f := by ext u change (1 : ℝ≥0) • f.1 u = f.1 u simp mul_smul a b f := by ext u change (a * b) • f.1 u =...
159
leanexplore_declaration
leanexplore:377578
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma Dimensionful.smul_apply {M : Type} [CarriesDimension M] (a : ℝ≥0) (f : Dimensionful M) (u : UnitChoices) : (a • f).1 u = a • f.1 u := rfl
547
leanexplore_declaration
leanexplore:377579
leanexplore_sqlite
leanexplore_declarations
/-- For `M` carrying a dimension `d`, the equivalence between `M` and `Dimension M`, given a choice of units. -/ noncomputable def CarriesDimension.toDimensionful {M : Type} [CarriesDimension M] (u : UnitChoices) : M ≃ Dimensionful M where toFun m := { val := fun u1 => (u.dimScale u1 (dim M)) • m pr...
189
leanexplore_declaration
leanexplore:377580
leanexplore_sqlite
leanexplore_declarations
lemma CarriesDimension.toDimensionful_apply_apply {M : Type} [CarriesDimension M] (u1 u2 : UnitChoices) (m : M) : (toDimensionful u1 m).1 u2 = (u1.dimScale u2 (dim M)) • m := by rfl
348
leanexplore_declaration
leanexplore:377581
leanexplore_sqlite
leanexplore_declarations
/-- The foundational dimensions. Defined in the order ⟨length, time, mass, charge, temperature⟩ -/ structure Dimension where /-- The length dimension. -/ length : ℚ /-- The time dimension. -/ time : ℚ /-- The mass dimension. -/ mass : ℚ /-- The charge dimension. -/ charge : ℚ /-- The temperature dim...
253
leanexplore_declaration
leanexplore:377582
leanexplore_sqlite
leanexplore_declarations
@[ext] lemma ext {d1 d2 : Dimension} (h1 : d1.length = d2.length) (h2 : d1.time = d2.time) (h3 : d1.mass = d2.mass) (h4 : d1.charge = d2.charge) (h5 : d1.temperature = d2.temperature) : d1 = d2 := by cases d1 cases d2 congr
223
leanexplore_declaration
leanexplore:377583
leanexplore_sqlite
leanexplore_declarations
@[ext] lemma ext {d1 d2 : Dimension} (h1 : d1.length = d2.length) (h2 : d1.time = d2.time) (h3 : d1.mass = d2.mass) (h4 : d1.charge = d2.charge) (h5 : d1.temperature = d2.temperature) : d1 = d2 := by
179
leanexplore_declaration
leanexplore:377584
leanexplore_sqlite
leanexplore_declarations
instance : Mul Dimension where mul d1 d2 := ⟨d1.length + d2.length, d1.time + d2.time, d1.mass + d2.mass, d1.charge + d2.charge, d1.temperature + d2.temperature⟩
90
leanexplore_declaration
leanexplore:377585
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma time_mul (d1 d2 : Dimension) : (d1 * d2).time = d1.time + d2.time := rfl
98
leanexplore_declaration
leanexplore:377586
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma length_mul (d1 d2 : Dimension) : (d1 * d2).length = d1.length + d2.length := rfl
90
leanexplore_declaration
leanexplore:377587
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma mass_mul (d1 d2 : Dimension) : (d1 * d2).mass = d1.mass + d2.mass := rfl
98
leanexplore_declaration
leanexplore:377588
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma charge_mul (d1 d2 : Dimension) : (d1 * d2).charge = d1.charge + d2.charge := rfl
118
leanexplore_declaration
leanexplore:377589
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma temperature_mul (d1 d2 : Dimension) : (d1 * d2).temperature = d1.temperature + d2.temperature := rfl
55
leanexplore_declaration
leanexplore:377590
leanexplore_sqlite
leanexplore_declarations
instance : One Dimension where one := ⟨0, 0, 0, 0, 0⟩
68
leanexplore_declaration
leanexplore:377591
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma one_length : (1 : Dimension).length = 0 := rfl @[simp]
56
leanexplore_declaration
leanexplore:377592
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma one_time : (1 : Dimension).time = 0 := rfl
56
leanexplore_declaration
leanexplore:377593
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma one_mass : (1 : Dimension).mass = 0 := rfl
60
leanexplore_declaration
leanexplore:377594
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma one_charge : (1 : Dimension).charge = 0 := rfl
70
leanexplore_declaration
leanexplore:377595
leanexplore_sqlite
leanexplore_declarations
@[simp] lemma one_temperature : (1 : Dimension).temperature = 0 := rfl