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 |
|---|---|---|---|---|---|
380 | leanexplore_declaration | leanexplore:377696 | leanexplore_sqlite | leanexplore_declarations | instance (M : Type) [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) :
MulAction ℝ≥0 (DimSet M d) where
smul a f := ⟨a • f.1, fun u1 u2 => by
rw [smul_comm, ← f.2]
rw [MulUnitDependent.scaleUnit_mul]⟩
one_smul f := by
ext
change (1 : ℝ≥0) • f.1 = f.1
simp
mul_smul a b f := by
ext... |
125 | leanexplore_declaration | leanexplore:377697 | leanexplore_sqlite | leanexplore_declarations | instance (M : Type) [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) :
CarriesDimension (DimSet M d) where
d := d |
240 | leanexplore_declaration | leanexplore:377698 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma scaleUnit_dimSet_val {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension)
(m : DimSet M d) (u1 u2 : UnitChoices) :
(scaleUnit u1 u2 m).1 = scaleUnit u1 u2 m.1 := by
rw [HasDim.scaleUnit_apply, m.2]
rfl |
191 | leanexplore_declaration | leanexplore:377699 | leanexplore_sqlite | leanexplore_declarations | lemma DimSet.mem_iff {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) (m : M) :
m ∈ DimSet M d ↔ ∀ u1 u2, scaleUnit u1 u2 m = (UnitChoices.dimScale u1 u2 d) • m := by rfl |
122 | leanexplore_declaration | leanexplore:377700 | leanexplore_sqlite | leanexplore_declarations | /-- The type of areas in the absence of a choice of unit. -/
abbrev DimArea : Type := Dimensionful (WithDim (L𝓭 * L𝓭) ℝ≥0) |
125 | leanexplore_declaration | leanexplore:377701 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional area corresponding to 1 square meter. -/
noncomputable def squareMeter : DimArea := toDimensionful SI ⟨1⟩ |
174 | leanexplore_declaration | leanexplore:377702 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional area corresponding to 1 square foot. -/
noncomputable def squareFoot : DimArea := toDimensionful ({SI with
length := LengthUnit.feet} : UnitChoices) ⟨1⟩ |
175 | leanexplore_declaration | leanexplore:377703 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional area corresponding to 1 square mile. -/
noncomputable def squareMile : DimArea := toDimensionful ({SI with
length := LengthUnit.miles} : UnitChoices) ⟨1⟩ |
130 | leanexplore_declaration | leanexplore:377704 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional area corresponding to 1 are (100 square meters). -/
noncomputable def are : DimArea := toDimensionful SI ⟨100⟩ |
143 | leanexplore_declaration | leanexplore:377705 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional area corresponding to 1 hectare (10,000 square meters). -/
noncomputable def hectare : DimArea := toDimensionful SI ⟨10000⟩ |
189 | leanexplore_declaration | leanexplore:377706 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional area corresponding to 1 acre (1/640 square miles). -/
noncomputable def acre : DimArea := toDimensionful ({SI with
length := LengthUnit.miles} : UnitChoices) ⟨(1/640)⟩ |
111 | leanexplore_declaration | leanexplore:377707 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma squareMeter_in_SI : squareMeter.1 SI = ⟨1⟩ := by
simp [squareMeter, toDimensionful_apply_apply] |
199 | leanexplore_declaration | leanexplore:377708 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma squareFoot_in_SI : squareFoot.1 SI = ⟨0.09290304⟩ := by
simp [squareFoot, dimScale, LengthUnit.feet, toDimensionful_apply_apply]
ext
simp only [NNReal.coe_ofScientific]
norm_num |
204 | leanexplore_declaration | leanexplore:377709 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma squareMile_in_SI : squareMile.1 SI = ⟨2589988.110336⟩ := by
simp [squareMile, dimScale, LengthUnit.miles, toDimensionful_apply_apply]
ext
simp only [NNReal.coe_ofScientific]
norm_num |
89 | leanexplore_declaration | leanexplore:377710 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma are_in_SI : are.1 SI = ⟨100⟩ := by
simp [are, toDimensionful_apply_apply] |
103 | leanexplore_declaration | leanexplore:377711 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma hectare_in_SI : hectare.1 SI = ⟨10000⟩ := by
simp [hectare, toDimensionful_apply_apply] |
184 | leanexplore_declaration | leanexplore:377712 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma acre_in_SI : acre.1 SI = ⟨4046.8564224⟩ := by
simp [acre, dimScale, LengthUnit.miles, toDimensionful_apply_apply]
ext
simp only [NNReal.coe_ofScientific]
norm_num |
202 | leanexplore_declaration | leanexplore:377713 | leanexplore_sqlite | leanexplore_declarations | /-- One acre is exactly `43560` square feet. -/
lemma acre_eq_mul_squareFeet : acre = (43560 : ℝ≥0) • squareFoot := by
apply (toDimensionful SI).symm.injective
simp [toDimensionful]
ext
norm_num |
159 | leanexplore_declaration | leanexplore:377714 | leanexplore_sqlite | leanexplore_declarations | /-- The type `M` carrying an instance of a dimension `d`. -/
structure WithDim (d : Dimension) (M : Type) where
/-- The underlying value of `M`. -/
val : M |
115 | leanexplore_declaration | leanexplore:377715 | leanexplore_sqlite | leanexplore_declarations | @[ext]
lemma ext {d M} (x1 x2 : WithDim d M) (h : x1.val = x2.val) : x1 = x2 := by
cases x1
cases x2
simp_all |
82 | leanexplore_declaration | leanexplore:377716 | leanexplore_sqlite | leanexplore_declarations | @[ext]
lemma ext {d M} (x1 x2 : WithDim d M) (h : x1.val = x2.val) : x1 = x2 := by |
73 | leanexplore_declaration | leanexplore:377717 | leanexplore_sqlite | leanexplore_declarations | instance (d : Dimension) (M : Type) : HasDim (WithDim d M) where
d := d |
85 | leanexplore_declaration | leanexplore:377718 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma dim_apply (d : Dimension) (M : Type) :
dim (WithDim d M) = d := rfl |
220 | leanexplore_declaration | leanexplore:377719 | leanexplore_sqlite | leanexplore_declarations | instance (d : Dimension) (M : Type) [MulAction ℝ≥0 M] : MulAction ℝ≥0 (WithDim d M) where
smul a m := ⟨a • m.val⟩
one_smul m := ext _ _ (one_smul ℝ≥0 m.val)
mul_smul a b m := by
ext
exact mul_smul a b m.val |
132 | leanexplore_declaration | leanexplore:377720 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma smul_val {d : Dimension} {M : Type} [MulAction ℝ≥0 M] (a : ℝ≥0) (m : WithDim d M) :
(a • m).val = a • m.val := rfl |
131 | leanexplore_declaration | leanexplore:377721 | leanexplore_sqlite | leanexplore_declarations | instance {d1 d2 : Dimension} :
HMul (WithDim d1 ℝ) (WithDim d2 ℝ) (WithDim (d1 * d2) ℝ) where
hMul m1 m2 := ⟨m1.val * m2.val⟩ |
127 | leanexplore_declaration | leanexplore:377722 | leanexplore_sqlite | leanexplore_declarations | lemma withDim_hMul_val {d1 d2 : Dimension} (m1 : WithDim d1 ℝ) (m2 : WithDim d2 ℝ) :
(m1 * m2).val = m1.val * m2.val := rfl |
364 | leanexplore_declaration | leanexplore:377723 | leanexplore_sqlite | leanexplore_declarations | instance {d1 d2 : Dimension} :
DMul (WithDim d1 ℝ) (WithDim d2 ℝ) (WithDim (d1 * d2) ℝ) where
mul_dim m1 m2 := by
intro u1 u2
ext
simp only [withDim_hMul_val, dim_apply, map_mul, smul_val]
rw [m1.2 u1, m2.2 u1]
simp only [dim_apply, smul_val, Algebra.mul_smul_comm, Algebra.smul_mul_assoc]
... |
163 | leanexplore_declaration | leanexplore:377724 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma val_mul_eq_mul {d1 d2 : Dimension} (m1 : WithDim d1 ℝ) (m2 : WithDim d2 ℝ) :
m1.val * m2.val = (m1 * m2).val := by
simp only [withDim_hMul_val] |
124 | leanexplore_declaration | leanexplore:377725 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma val_pow_two_eq_mul {d1 : Dimension} (m1 : WithDim d1 ℝ) :
m1.val ^ 2 = (m1 * m1).val := by
rw [sq]
rfl |
302 | leanexplore_declaration | leanexplore:377726 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma scaleUnit_val_eq_scaleUnit_val {d : Dimension} (M : Type) [MulAction ℝ≥0 M]
(u1 u2 : UnitChoices) (m1 m2 : WithDim d M) :
(scaleUnit u1 u2 m1).val = (scaleUnit u1 u2 m2).val ↔ m1.val = m2.val := by
rw [← WithDim.ext_iff]
simp only [scaleUnit_injective]
exact WithDim.ext_iff |
309 | leanexplore_declaration | leanexplore:377727 | leanexplore_sqlite | leanexplore_declarations | lemma scaleUnit_val_eq_scaleUnit_val_of_dim_eq {d1 d2 : Dimension} {M : Type} [MulAction ℝ≥0 M]
{u1 u2 : UnitChoices} {m1 : WithDim d1 M} {m2 : WithDim d2 M}
(h : d1 = d2 := by ext <;> {simp; try ring}) :
(scaleUnit u1 u2 m1).val = (scaleUnit u1 u2 m2).val ↔ m1.val = m2.val := by
subst h
simp |
175 | leanexplore_declaration | leanexplore:377728 | leanexplore_sqlite | leanexplore_declarations | lemma scaleUnit_val {d : Dimension} (M : Type) [MulAction ℝ≥0 M]
(u1 u2 : UnitChoices) (m1 : WithDim d M) :
(scaleUnit u1 u2 m1).val = u1.dimScale u2 d • m1.val := rfl |
147 | leanexplore_declaration | leanexplore:377729 | leanexplore_sqlite | leanexplore_declarations | noncomputable instance (d1 d2 : Dimension) :
HDiv (WithDim d1 ℝ) (WithDim d2 ℝ) (WithDim (d1 * d2⁻¹) ℝ) where
hDiv m1 m2 := ⟨m1.val / m2.val⟩ |
132 | leanexplore_declaration | leanexplore:377730 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma val_div_val {d1 d2 : Dimension} (m1 : WithDim d1 ℝ) (m2 : WithDim d2 ℝ) :
(m1.val / m2.val) = (m1 / m2).val := rfl |
553 | leanexplore_declaration | leanexplore:377731 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma div_scaleUnit {d1 d2 : Dimension} (m1 : WithDim d1 ℝ) (m2 : WithDim d2 ℝ)
(u1 u2 : UnitChoices) :
(scaleUnit u1 u2 m1) / (scaleUnit u1 u2 m2) = scaleUnit u1 u2 (m1 / m2) := by
symm
ext
simp only [← val_div_val, scaleUnit_val]
simp only [map_mul, map_inv, val_div_val]
field_simp
change ... |
212 | leanexplore_declaration | leanexplore:377732 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma scaleUnit_dim_eq_zero {d : Dimension} (m : WithDim d ℝ) (u1 u2 : UnitChoices)
(h : d = 1 := by ext <;> {simp; try ring}) : scaleUnit u1 u2 m = m := by
subst h
ext
rw [scaleUnit_val]
simp |
227 | leanexplore_declaration | leanexplore:377733 | leanexplore_sqlite | leanexplore_declarations | /-- The casting from `WithDim d M` to `WithDim d2 M` when `d = d2`. -/
@[nolint unusedArguments]
def cast {d d2 : Dimension} {M : Type} (m : WithDim d M)
(h : d = d2 := by ext <;> {simp; try ring}) : WithDim d2 M := ⟨m.val⟩ |
96 | leanexplore_declaration | leanexplore:377734 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma cast_refl {d : Dimension} {M : Type} (m : WithDim d M) :
cast m rfl = m := rfl |
218 | leanexplore_declaration | leanexplore:377735 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma cast_scaleUnit {d d2 : Dimension} {M : Type} [MulAction ℝ≥0 M] (m : WithDim d M)
(h : d = d2) (u1 u2 : UnitChoices) :
cast (scaleUnit u1 u2 m) h = scaleUnit u1 u2 (cast m h) := by
subst h
simp |
145 | leanexplore_declaration | leanexplore:377736 | leanexplore_sqlite | leanexplore_declarations | /-- Energy as a dimensional quantity with dimension `MLT⁻2`.. -/
abbrev DimEnergy : Type := Dimensionful (WithDim (M𝓭 * L𝓭 * L𝓭 * T𝓭⁻¹ * T𝓭⁻¹) ℝ) |
119 | leanexplore_declaration | leanexplore:377737 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional energy corresponding to 1 joule, J. -/
noncomputable def joule : DimEnergy := toDimensionful SI ⟨1⟩ |
166 | leanexplore_declaration | leanexplore:377738 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional energy corresponding to 1 electron volt, 1.602176634×10−19 J. -/
noncomputable def electronVolt : DimEnergy := toDimensionful SI ⟨1.602176634e-19⟩ |
133 | leanexplore_declaration | leanexplore:377739 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional energy corresponding to 1 calorie, 4.184 J. -/
noncomputable def calorie : DimEnergy := toDimensionful SI ⟨4.184⟩ |
153 | leanexplore_declaration | leanexplore:377740 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional energy corresponding to 1 kilowatt-hours, (3,600,000 J). -/
noncomputable def kilowattHour : DimEnergy := toDimensionful SI ⟨3600000⟩ |
234 | leanexplore_declaration | leanexplore:377741 | leanexplore_sqlite | leanexplore_declarations | /-- Momentum in `d`-dimensional space in an arbitrary, but given, set of units.
In `(3+1)d` space time this corresponds to `3`-momentum not `4`-momentum. -/
abbrev Momentum (d : ℕ := 3) : Type := WithDim (M𝓭 * L𝓭 * T𝓭⁻¹) (Fin d → ℝ) |
148 | leanexplore_declaration | leanexplore:377742 | leanexplore_sqlite | leanexplore_declarations | /-- Pressure as a dimensional quantity with dimension `ML⁻¹T⁻2`.. -/
abbrev DimPressure : Type := Dimensionful (WithDim (M𝓭 * L𝓭⁻¹ * T𝓭⁻¹ * T𝓭⁻¹) ℝ) |
126 | leanexplore_declaration | leanexplore:377743 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional pressure corresponding to 1 pascal, Pa. -/
noncomputable def pascal : DimPressure := toDimensionful SI ⟨1⟩ |
186 | leanexplore_declaration | leanexplore:377744 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional pressure corresponding to 1 millimeter of mercury (133.322387415 pascals). -/
noncomputable def millimeterOfMercury : DimPressure := toDimensionful SI ⟨133.322387415⟩ |
139 | leanexplore_declaration | leanexplore:377745 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional pressure corresponding to 1 bar (100,000 pascals). -/
noncomputable def bar : DimPressure := toDimensionful SI ⟨100000⟩ |
170 | leanexplore_declaration | leanexplore:377746 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional pressure corresponding to 1 standard atmosphere (101,325 pascals). -/
noncomputable def standardAtmosphere : DimPressure := toDimensionful SI ⟨101325⟩ |
171 | leanexplore_declaration | leanexplore:377747 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional pressure corresponding to 1 torr (1/760 of standard atmosphere pressure). -/
noncomputable def torr : DimPressure := (1/760 : ℝ≥0) • standardAtmosphere |
214 | leanexplore_declaration | leanexplore:377748 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional pressure corresponding to 1 pound per square inch. -/
noncomputable def psi : DimPressure := toDimensionful ({SI with
mass := MassUnit.pounds,
length := LengthUnit.inches} : UnitChoices) ⟨1⟩ |
126 | leanexplore_declaration | leanexplore:377749 | leanexplore_sqlite | leanexplore_declarations | /-- The type of speeds in the absence of a choice of unit. -/
abbrev DimSpeed : Type := Dimensionful (WithDim (L𝓭 * T𝓭⁻¹) ℝ≥0) |
137 | leanexplore_declaration | leanexplore:377750 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional speed corresponding to 1 meter per second. -/
noncomputable def oneMeterPerSecond : DimSpeed := toDimensionful SI ⟨1⟩ |
207 | leanexplore_declaration | leanexplore:377751 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional speed corresponding to 1 mile per hour. -/
noncomputable def oneMilePerHour : DimSpeed := toDimensionful ({SI with
length := LengthUnit.miles, time := TimeUnit.hours} : UnitChoices) ⟨1⟩ |
222 | leanexplore_declaration | leanexplore:377752 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional speed corresponding to 1 kilometer per hour. -/
noncomputable def oneKilometerPerHour : DimSpeed := toDimensionful ({SI with
length := LengthUnit.kilometers, time := TimeUnit.hours} : UnitChoices) ⟨1⟩ |
232 | leanexplore_declaration | leanexplore:377753 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensional speed corresponding to 1 knot, aka, one nautical mile per hour. -/
noncomputable def oneKnot : DimSpeed := toDimensionful ({SI with
length := LengthUnit.nauticalMiles, time := TimeUnit.hours} : UnitChoices) ⟨1⟩ |
189 | leanexplore_declaration | leanexplore:377754 | leanexplore_sqlite | leanexplore_declarations | /-- The dimensionful speed of light corresponding to 299792458 meters per second. -/
noncomputable def speedOfLight : Dimensionful (WithDim (L𝓭 * T𝓭⁻¹) ℝ) :=
toDimensionful SI ⟨299792458⟩ |
127 | leanexplore_declaration | leanexplore:377755 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma oneMeterPerSecond_in_SI : oneMeterPerSecond SI = ⟨1⟩ := by
simp [oneMeterPerSecond, toDimensionful_apply_apply] |
223 | leanexplore_declaration | leanexplore:377756 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma oneMilePerHour_in_SI : oneMilePerHour SI = ⟨0.44704⟩ := by
simp [oneMilePerHour, dimScale, LengthUnit.miles, TimeUnit.hours, toDimensionful_apply_apply]
ext
simp only [NNReal.coe_ofScientific]
norm_num |
222 | leanexplore_declaration | leanexplore:377757 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma oneKilometerPerHour_in_SI :
oneKilometerPerHour SI = ⟨5/18⟩ := by
simp [oneKilometerPerHour, dimScale,
LengthUnit.kilometers, TimeUnit.hours, toDimensionful_apply_apply]
ext
simp only
norm_num |
184 | leanexplore_declaration | leanexplore:377758 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma oneKnot_in_SI : oneKnot SI = ⟨463/900⟩ := by
simp [oneKnot, dimScale, LengthUnit.nauticalMiles, TimeUnit.hours, toDimensionful_apply_apply]
ext
simp only
norm_num |
120 | leanexplore_declaration | leanexplore:377759 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma speedOfLight_in_SI : speedOfLight SI = ⟨299792458⟩ := by
simp [speedOfLight, toDimensionful_apply_apply] |
182 | leanexplore_declaration | leanexplore:377760 | leanexplore_sqlite | leanexplore_declarations | lemma oneKnot_eq_mul_oneKilometerPerHour :
oneKnot = (1.852 : ℝ≥0) • oneKilometerPerHour := by
apply (toDimensionful SI).symm.injective
simp [toDimensionful]
ext
norm_num |
183 | leanexplore_declaration | leanexplore:377761 | leanexplore_sqlite | leanexplore_declarations | lemma oneKilometerPerHour_eq_mul_oneKnot:
oneKilometerPerHour = (250/463 : ℝ≥0) • oneKnot := by
apply (toDimensionful SI).symm.injective
simp [toDimensionful]
ext
norm_num |
196 | leanexplore_declaration | leanexplore:377762 | leanexplore_sqlite | leanexplore_declarations | lemma oneMeterPerSecond_eq_mul_oneMilePerHour :
oneMeterPerSecond = (3125/1397 : ℝ≥0) • oneMilePerHour := by
apply (toDimensionful SI).symm.injective
simp [toDimensionful]
ext
norm_num |
631 | leanexplore_declaration | leanexplore:377763 | leanexplore_sqlite | leanexplore_declarations | /--
We define our own (discrete) probability distribution notion here, instead
of using `PMF` from Mathlib, because that uses ENNReals everywhere to maintain compatibility
with `MeasureTheory.Measure`.
The probabilities internal to a Distribution are NNReals. This lets us more easily
write the statement that they sum ... |
405 | leanexplore_declaration | leanexplore:377764 | leanexplore_sqlite | leanexplore_declarations | /-- Make a distribution, proving only that the values are nonnegative and that the
sum is 1. The fact that the values are at most 1 is derived as a consequence. -/
def mk' (f : α → ℝ) (h₁ : ∀i, 0 ≤ f i) (hN : ∑ i, f i = 1) : ProbDistribution α :=
have h₃ : ∀x, f x ≤ 1 := by
intro x
simp [← hN, Fintype.sum_eq_... |
214 | leanexplore_declaration | leanexplore:377765 | leanexplore_sqlite | leanexplore_declarations | instance instFunLikeProb : FunLike (ProbDistribution α) α Prob where
coe p a := p.1 a
coe_injective' _ _ h :=
Subtype.ext <| funext fun v ↦ by
simpa only [Subtype.mk.injEq, coe_inj] using congrFun h v |
109 | leanexplore_declaration | leanexplore:377766 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem normalized (d : ProbDistribution α) : Finset.sum Finset.univ (fun i ↦ (d i : ℝ)) = 1 :=
d.2 |
54 | leanexplore_declaration | leanexplore:377767 | leanexplore_sqlite | leanexplore_declarations | abbrev prob (d : ProbDistribution α) := (d : α → Prob) |
72 | leanexplore_declaration | leanexplore:377768 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem fun_eq_val (d : ProbDistribution α) : d.val = d :=
rfl |
129 | leanexplore_declaration | leanexplore:377769 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem funlike_apply (d : α → Prob) (h : _) (x : α) :
DFunLike.coe (self := instFunLikeProb) ⟨d, h⟩ x = d x :=
rfl |
98 | leanexplore_declaration | leanexplore:377770 | leanexplore_sqlite | leanexplore_declarations | @[ext]
theorem ext {p q : ProbDistribution α} (h : ∀ x, p x = q x) : p = q :=
DFunLike.ext p q h |
77 | leanexplore_declaration | leanexplore:377771 | leanexplore_sqlite | leanexplore_declarations | @[ext]
theorem ext {p q : ProbDistribution α} (h : ∀ x, p x = q x) : p = q := |
177 | leanexplore_declaration | leanexplore:377772 | leanexplore_sqlite | leanexplore_declarations | /-- A distribution provides a witness that d is nonempty. -/
theorem nonempty (d : ProbDistribution α) : Nonempty α := by
by_contra h
simpa [not_nonempty_iff.mp h] using d.2 |
348 | leanexplore_declaration | leanexplore:377773 | leanexplore_sqlite | leanexplore_declarations | /-- Make an constant distribution: supported on a single element. This is also called, variously, a
"One-point distribution", a "Degenerate distribution", a "Deterministic distribution", a
"Delta function", or a "Point mass distribution". -/
def constant (x : α) : ProbDistribution α :=
⟨fun y ↦ if x = y then 1 else... |
99 | leanexplore_declaration | leanexplore:377774 | leanexplore_sqlite | leanexplore_declarations | theorem constant_def (x : α) : (constant x : α → Prob) = fun y ↦ if x = y then 1 else 0 := by
rfl |
87 | leanexplore_declaration | leanexplore:377775 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem constant_eq (x : α) : constant x y = if x = y then 1 else 0 := by
rfl |
258 | leanexplore_declaration | leanexplore:377776 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem constant_def' (x y : α) : (constant x : α → Prob) y = if x = y then 1 else 0 := by
rw [← Prob.eq_iff_nnreal]
change (Prob.toNNReal ∘ (constant x)) y = (if x = y then 1 else 0 : Prob)
rw [constant_def x]
split_ifs with h
<;> simp [h] |
785 | leanexplore_declaration | leanexplore:377777 | leanexplore_sqlite | leanexplore_declarations | /-- If a distribution has an element with probability 1, the distribution has a constant. -/
theorem constant_of_exists_one {D : ProbDistribution α} {x : α} (h : D x = 1) : D = ProbDistribution.constant x := by
ext y
by_cases h₂ : x = y
· simp [h, ← h₂]
· simp only [constant_eq, h₂, ↓reduceIte, Prob.coe_zero]
... |
266 | leanexplore_declaration | leanexplore:377778 | leanexplore_sqlite | leanexplore_declarations | /-- Make an uniform distribution. -/
def uniform [n : Nonempty α] : ProbDistribution α :=
⟨fun _ ↦ ⟨1 / (Finset.univ.card (α := α)), by
have : 0 < Finset.univ.card (α := α) :=
Finset.Nonempty.card_pos (Finset.univ_nonempty_iff.mpr n)
bound⟩, by simp⟩ |
111 | leanexplore_declaration | leanexplore:377779 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem uniform_def [Nonempty α] (y : α) : ((uniform y) : ℝ) = 1 / (Finset.univ.card (α := α)) :=
rfl |
237 | leanexplore_declaration | leanexplore:377780 | leanexplore_sqlite | leanexplore_declarations | /-- Make a distribution on a product of two Fintypes. -/
def prod (d1 : ProbDistribution α) (d2 : ProbDistribution β) : ProbDistribution (Prod α β) :=
⟨fun x ↦ (d1 x.1) * (d2 x.2), by
simp [← Finset.mul_sum, Fintype.sum_prod_type]⟩ |
87 | leanexplore_declaration | leanexplore:377781 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem prod_def (x : α) (y : β) : prod d1 d2 ⟨x, y⟩ = (d1 x) * (d2 y) :=
rfl |
240 | leanexplore_declaration | leanexplore:377782 | leanexplore_sqlite | leanexplore_declarations | /-- Given a distribution on α, extend it to a distribution on `Sum α β` by giving it no support on `β`. -/
def extend_right (d : ProbDistribution α) : ProbDistribution (α ⊕ β) :=
⟨fun x ↦ Sum.casesOn x d.val (Function.const _ 0), by simp⟩ |
239 | leanexplore_declaration | leanexplore:377783 | leanexplore_sqlite | leanexplore_declarations | /-- Given a distribution on α, extend it to a distribution on `Sum β α` by giving it no support on `β`. -/
def extend_left (d : ProbDistribution α) : ProbDistribution (β ⊕ α) :=
⟨fun x ↦ Sum.casesOn x (Function.const _ 0) d.val, by simp⟩ |
276 | leanexplore_declaration | leanexplore:377784 | leanexplore_sqlite | leanexplore_declarations | /-- Make a convex mixture of two distributions on the same set. -/
instance instMixable : Mixable (α → ℝ) (ProbDistribution α) :=
Mixable.instSubtype (inferInstance) (fun _ _ hab hx hy ↦ by
simp [Mixable.mix_ab, Finset.sum_add_distrib, ← Finset.mul_sum, hab, hx, hy]
) |
269 | leanexplore_declaration | leanexplore:377785 | leanexplore_sqlite | leanexplore_declarations | /-- Given a distribution on type α and an equivalence to type β, get the corresponding
distribution on type β. -/
def relabel (d : ProbDistribution α) (σ : β ≃ α) : ProbDistribution β :=
⟨fun b ↦ d (σ b),
by rw [Equiv.sum_comp σ (fun a ↦ (d a : ℝ))]; exact d.prop⟩ |
512 | leanexplore_declaration | leanexplore:377786 | leanexplore_sqlite | leanexplore_declarations | /-- ProbDistribution on α and β are equivalent for equivalent types α ≃ β. -/
def congr (σ : α ≃ β) : ProbDistribution α ≃ ProbDistribution β := by
constructor
case toFun => exact fun d ↦ relabel d σ.symm
case invFun => exact fun d ↦ relabel d σ
case left_inv =>
intro d
ext i
unfold relabel
simp... |
114 | leanexplore_declaration | leanexplore:377787 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem congr_apply (σ : α ≃ β) (d : ProbDistribution α) (j : β): (congr σ d) j = d (σ.symm j) := by
rfl |
193 | leanexplore_declaration | leanexplore:377788 | leanexplore_sqlite | leanexplore_declarations | /-- The inverse and congruence operations for distributions commute -/
@[simp]
theorem congr_symm_apply (σ : α ≃ β) : (ProbDistribution.congr σ).symm = ProbDistribution.congr σ.symm := by
rfl |
193 | leanexplore_declaration | leanexplore:377789 | leanexplore_sqlite | leanexplore_declarations | /-- The distribution on Fin 2 corresponding to a coin with probability p. Chance p of 1, 1-p of 0. -/
def coin (p : Prob) : ProbDistribution (Fin 2) :=
⟨(if · = 0 then p else 1 - p), by simp⟩ |
75 | leanexplore_declaration | leanexplore:377790 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem coin_val_zero (p : Prob) : coin p 0 = p := by
simp [coin] |
78 | leanexplore_declaration | leanexplore:377791 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem coin_val_one (p : Prob) : coin p 1 = 1 - p := by
simp [coin] |
390 | leanexplore_declaration | leanexplore:377792 | leanexplore_sqlite | leanexplore_declarations | /-- Every distribution on two variable is some coin. -/
theorem fin_two_eq_coin (d : ProbDistribution (Fin 2)) : d = coin (d 0) := by
ext i
fin_cases i
· simp [coin]
· simpa only [coin, Fin.mk_one, funlike_apply, one_ne_zero, ↓reduceIte,
Prob.coe_one_minus, Subtype.ext_iff, Prob.coe_one_minus, eq_sub_iff_ad... |
209 | leanexplore_declaration | leanexplore:377793 | leanexplore_sqlite | leanexplore_declarations | theorem coin_eq_iff (p : Prob) (f : ProbDistribution (Fin 2)) :
ProbDistribution.coin p = f ↔ p = f 0 := by
constructor
· rintro rfl
rfl
· rintro rfl
rw [← ProbDistribution.fin_two_eq_coin f] |
234 | leanexplore_declaration | leanexplore:377794 | leanexplore_sqlite | leanexplore_declarations | /-- A `T`-valued random variable over `α` is a map `var : α → T` along
with a probability distribution `distr : Distribution α`. -/
structure RandVar (α : Type*) [Fintype α] (T : Type*) where
var : α → T
distr : ProbDistribution α |
74 | leanexplore_declaration | leanexplore:377795 | leanexplore_sqlite | leanexplore_declarations | instance instFunctor : Functor (RandVar α) where map f e := ⟨f ∘ e.1, e.2⟩ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.