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 |
|---|---|---|---|---|---|
138 | leanexplore_declaration | leanexplore:377796 | leanexplore_sqlite | leanexplore_declarations | instance instLawfulFunctor : LawfulFunctor (RandVar α) where
map_const {α} {β} := by rfl
id_map _ := by rfl
comp_map _ _ _ := by rfl |
725 | leanexplore_declaration | leanexplore:377797 | leanexplore_sqlite | leanexplore_declarations | /-- `Distribution.exp_val` is the expectation value of a random variable `X`. Under the hood,
it is the "convex combination over a finite family" on the type `T`, afforded by the `Mixable` instance,
with the probability distribution of `X` as weights. -/
def expect_val (X : RandVar α T) : T := by
let u : U := ∑ i ∈ F... |
839 | leanexplore_declaration | leanexplore:377798 | leanexplore_sqlite | leanexplore_declarations | /-- The expectation value of a random variable over `α = Fin 2` is the same as `Mixable.mix`
with probabiliy weight `X.distr 0` -/
theorem expect_val_eq_mixable_mix (d : ProbDistribution (Fin 2)) (x₁ x₂ : T) : expect_val ⟨![x₁, x₂], d⟩ = Mixable.mix (d 0) x₁ x₂ := by
apply Mixable.to_U_inj
simp only [Mixable.mix, e... |
430 | leanexplore_declaration | leanexplore:377799 | leanexplore_sqlite | leanexplore_declarations | /-- The expectation value of a random variable with constant probability distribution `constant x` is its value at `x` -/
theorem expect_val_constant (x : α) (f : α → T) : expect_val ⟨f, (constant x)⟩ = f x := by
apply Mixable.to_U_inj
simp only [expect_val, constant, DFunLike.coe, Mixable.to_U_of_mkT, apply_ite, P... |
349 | leanexplore_declaration | leanexplore:377800 | leanexplore_sqlite | leanexplore_declarations | /-- The expectation value of a nonnegative real random variable is also nonnegative -/
theorem zero_le_expect_val (d : ProbDistribution α) (f : α → ℝ) (hpos : 0 ≤ f) : 0 ≤ expect_val ⟨f, d⟩ := by
simp only [expect_val, Mixable.mkT, Mixable.to_U, id]
apply Fintype.sum_nonneg
intro x
specialize hpos x
exact mul... |
662 | leanexplore_declaration | leanexplore:377801 | leanexplore_sqlite | leanexplore_declarations | /-- `T`-valued random variables on `α` and `β` are equivalent if `α ≃ β` -/
def congrRandVar (σ : α ≃ β) : RandVar α T ≃ RandVar β T := by
constructor
case toFun => exact fun X ↦ { var := X.var ∘ σ.symm, distr := ProbDistribution.congr σ X.distr }
case invFun => exact fun X ↦ { var := X.var ∘ σ, distr := ProbDist... |
271 | leanexplore_declaration | leanexplore:377802 | leanexplore_sqlite | leanexplore_declarations | /-- Given a `T`-valued random variable `X` over `α`, mapping over `T` commutes with the equivalence over `α` -/
def map_congr_eq_congr_map {S : Type _} [Mixable U S] (f : T → S) (σ : α ≃ β) (X : RandVar α T) :
f <$> congrRandVar σ X = congrRandVar σ (f <$> X) := by rfl |
433 | leanexplore_declaration | leanexplore:377803 | leanexplore_sqlite | leanexplore_declarations | /-- The expectation value is invariant under equivalence of random variables -/
@[simp]
theorem expect_val_congr_eq_expect_val (σ : α ≃ β) (X : RandVar α T) : expect_val (congrRandVar σ X) = expect_val X := by
apply Mixable.to_U_inj
simp only [expect_val, congrRandVar, Equiv.coe_fn_mk, Function.comp_apply, Mixable.... |
115 | leanexplore_declaration | leanexplore:377804 | leanexplore_sqlite | leanexplore_declarations | /-- The one-event entropy function, H₁(p) = -p*ln(p). Uses nits. -/
def H₁ : Prob → ℝ :=
fun x ↦ Real.negMulLog x |
79 | leanexplore_declaration | leanexplore:377805 | leanexplore_sqlite | leanexplore_declarations | /-- H₁ of 0 is zero.-/
@[simp]
def H₁_zero_eq_zero : H₁ 0 = 0 := by
simp [H₁] |
78 | leanexplore_declaration | leanexplore:377806 | leanexplore_sqlite | leanexplore_declarations | /-- H₁ of 1 is zero.-/
@[simp]
def H₁_one_eq_zero : H₁ 1 = 0 := by
simp [H₁] |
187 | leanexplore_declaration | leanexplore:377807 | leanexplore_sqlite | leanexplore_declarations | /-- Entropy is nonnegative. -/
theorem H₁_nonneg (p : Prob) : 0 ≤ H₁ p := by
rw [H₁, Real.negMulLog, neg_mul, Left.nonneg_neg_iff]
exact Real.mul_log_nonpos p.zero_le_coe p.coe_le_one |
305 | leanexplore_declaration | leanexplore:377808 | leanexplore_sqlite | leanexplore_declarations | /-- Entropy is less than 1. -/
theorem H₁_le_1 (p : Prob) : H₁ p < 1 := by
rw [H₁]
by_cases h : p = 0
· norm_num [h]
· have hp0 : 0 < p := lt_of_le_of_ne' p.zero_le h
have h₂ := Real.abs_log_mul_self_lt p hp0 p.coe_le_one
rw [mul_comm, ← abs_neg, ← neg_mul] at h₂
exact lt_of_abs_lt h₂ |
135 | leanexplore_declaration | leanexplore:377809 | leanexplore_sqlite | leanexplore_declarations | /-- Entropy is at most 1/e. -/
theorem H₁_le_exp_m1 (p : Prob) : H₁ p ≤ Real.exp (-1) :=
Real.negMulLog_le_rexp_neg_one p.zero_le_coe |
877 | leanexplore_declaration | leanexplore:377810 | leanexplore_sqlite | leanexplore_declarations | theorem H₁_concave : ∀ (x y : Prob), ∀ (p : Prob), p[H₁ x ↔ H₁ y] ≤ H₁ (p[x ↔ y]) := by
intros x y p
simp only [H₁, smul_eq_mul, Prob.coe_one_minus, Mixable.mix, Mixable.mix_ab, Mixable.mkT_instUniv,
Prob.mkT_mixable, Prob.to_U_mixable, Mixable.to_U_instUniv, Prob.to_U_mixable]
by_cases hxy : x = y
· subst ... |
160 | leanexplore_declaration | leanexplore:377811 | leanexplore_sqlite | leanexplore_declarations | /-- The Shannon entropy of a discrete distribution, H(X) = ∑ H₁(p_x). -/
def Hₛ (d : ProbDistribution α) : ℝ :=
Finset.sum Finset.univ (fun x ↦ H₁ (d.prob x)) |
154 | leanexplore_declaration | leanexplore:377812 | leanexplore_sqlite | leanexplore_declarations | /-- Shannon entropy of a distribution is nonnegative. -/
theorem Hₛ_nonneg (d : ProbDistribution α) : 0 ≤ Hₛ d :=
Finset.sum_nonneg' fun _ ↦ H₁_nonneg _ |
1,152 | leanexplore_declaration | leanexplore:377813 | leanexplore_sqlite | leanexplore_declarations | /-- Shannon entropy of a distribution is at most ln d. -/
theorem Hₛ_le_log_d (d : ProbDistribution α) : Hₛ d ≤ Real.log (Fintype.card α) := by
--Thanks Aristotle
by_cases h : Fintype.card α = 0
· simp_all [Hₛ, Fintype.card_eq_zero_iff.mp h]
-- Since the sum of the probabilities is 1, we can apply Jensen's ineq... |
170 | leanexplore_declaration | leanexplore:377814 | leanexplore_sqlite | leanexplore_declarations | /-- The shannon entropy of a constant variable is zero. -/
@[simp]
theorem Hₛ_constant_eq_zero {i : α} : Hₛ (ProbDistribution.constant i) = 0 := by
simp [Hₛ, apply_ite] |
234 | leanexplore_declaration | leanexplore:377815 | leanexplore_sqlite | leanexplore_declarations | /-- Shannon entropy of a uniform distribution is ln d. -/
theorem Hₛ_uniform [Nonempty α] :
Hₛ (ProbDistribution.uniform (α := α)) = Real.log (Finset.univ.card (α := α)) := by
simp [Hₛ, ProbDistribution.prob, H₁, Real.negMulLog] |
224 | leanexplore_declaration | leanexplore:377816 | leanexplore_sqlite | leanexplore_declarations | /-- Shannon entropy of two-event distribution. -/
theorem Hₛ_coin (p : Prob) : Hₛ (ProbDistribution.coin p) = Real.binEntropy p := by
simp [Hₛ, H₁, ProbDistribution.coin, Real.binEntropy_eq_negMulLog_add_negMulLog_one_sub] |
334 | leanexplore_declaration | leanexplore:377817 | leanexplore_sqlite | leanexplore_declarations | lemma Hₛ_eq_of_multiset_map_eq (d₁ : ProbDistribution α) (d₂ : ProbDistribution β)
(h : Multiset.map d₁.prob Finset.univ.val = Multiset.map d₂.prob Finset.univ.val) :
Hₛ d₁ = Hₛ d₂ := by
convert congr_arg (fun m ↦ m.map (fun x ↦ -Real.log x.1 * x.1 ) |> Multiset.sum ) h using 1
<;> simp [Hₛ, H₁, mul_comm, R... |
348 | leanexplore_declaration | leanexplore:377818 | leanexplore_sqlite | leanexplore_declarations | theorem negMulLog_strictMonoOn : StrictMonoOn Real.negMulLog (Set.Icc 0 (exp (-1))) := by
apply strictMonoOn_of_deriv_pos
· exact convex_Icc 0 (exp (-1))
· exact continuous_negMulLog.continuousOn
· intro x hx
rw [interior_Icc, Set.mem_Ioo] at hx
linarith only [log_exp (-1), log_lt_log hx.left hx.right, ... |
396 | leanexplore_declaration | leanexplore:377819 | leanexplore_sqlite | leanexplore_declarations | theorem negMulLog_strictAntiOn : StrictAntiOn Real.negMulLog (Set.Ici (exp (-1))) := by
apply strictAntiOn_of_deriv_neg
· exact convex_Ici (exp (-1))
· exact continuous_negMulLog.continuousOn
· intro x hx
rw [interior_Ici' Set.nonempty_Iio, Set.mem_Ioi] at hx
have hx' : x ≠ 0 := by grind [exp_nonneg]
... |
385 | leanexplore_declaration | leanexplore:377820 | leanexplore_sqlite | leanexplore_declarations | theorem negMulLog_le_rexp_neg_one {x : ℝ} (hx : 0 ≤ x) : negMulLog x ≤ exp (-1) := by
by_cases hp : x < exp (-1)
· grw [negMulLog_strictMonoOn.monotoneOn (by grind) (by grind) hp.le]
simp [negMulLog]
by_cases hp' : Real.exp (-1) < x
· grw [negMulLog_strictAntiOn.antitoneOn (by grind) (by grind) hp'.le]
... |
222 | leanexplore_declaration | leanexplore:377821 | leanexplore_sqlite | leanexplore_declarations | /-- `Prob` is a real number in the interval [0,1]. Similar to NNReal in many definitions, but this
allows other nice things more 'safely' such as convex combination. -/
@[reducible]
def Prob := { p : ℝ // 0 ≤ p ∧ p ≤ 1 } |
91 | leanexplore_declaration | leanexplore:377823 | leanexplore_sqlite | leanexplore_declarations | instance canLift : CanLift ℝ Prob Subtype.val fun r => 0 ≤ r ∧ r ≤ 1 :=
Subtype.canLift _ |
47 | leanexplore_declaration | leanexplore:377824 | leanexplore_sqlite | leanexplore_declarations | instance instZero : Zero Prob :=
⟨0, by simp⟩ |
45 | leanexplore_declaration | leanexplore:377825 | leanexplore_sqlite | leanexplore_declarations | instance instOne : One Prob :=
⟨1, by simp⟩ |
117 | leanexplore_declaration | leanexplore:377826 | leanexplore_sqlite | leanexplore_declarations | instance instMul : Mul Prob :=
⟨fun x y ↦ ⟨x.1 * y.1,
⟨mul_nonneg x.2.1 y.2.1, mul_le_one₀ x.2.2 y.2.1 y.2.2⟩⟩⟩ |
65 | leanexplore_declaration | leanexplore:377827 | leanexplore_sqlite | leanexplore_declarations | @[simp, norm_cast]
theorem coe_zero : (0 : Prob).val = 0 :=
rfl |
64 | leanexplore_declaration | leanexplore:377828 | leanexplore_sqlite | leanexplore_declarations | @[simp, norm_cast]
theorem coe_one : (1 : Prob).val = 1 :=
rfl |
86 | leanexplore_declaration | leanexplore:377829 | leanexplore_sqlite | leanexplore_declarations | @[simp, norm_cast]
theorem coe_mul (x y : Prob) : (x * y).val = x.val * y.val :=
rfl |
86 | leanexplore_declaration | leanexplore:377830 | leanexplore_sqlite | leanexplore_declarations | @[simp, norm_cast]
theorem coe_inf (x y : Prob) : (x ⊓ y).val = x.val ⊓ y.val :=
rfl |
86 | leanexplore_declaration | leanexplore:377831 | leanexplore_sqlite | leanexplore_declarations | @[simp, norm_cast]
theorem coe_sup (x y : Prob) : (x ⊔ y).val = x.val ⊔ y.val :=
rfl |
295 | leanexplore_declaration | leanexplore:377832 | leanexplore_sqlite | leanexplore_declarations | instance instCommMonoidWithZero : CommMonoidWithZero Prob where
mul_assoc := by intros; ext; simp [mul_assoc]
one_mul := by intros; ext; simp
mul_one := by intros; ext; simp
mul_comm := by intros; ext; simp [mul_comm]
mul_zero := by intros; ext; simp
zero_mul := by intros; ext; simp |
116 | leanexplore_declaration | leanexplore:377833 | leanexplore_sqlite | leanexplore_declarations | instance instDenselyOrdered : DenselyOrdered Prob :=
show DenselyOrdered (Set.Icc 0 1) from Set.instDenselyOrdered |
103 | leanexplore_declaration | leanexplore:377834 | leanexplore_sqlite | leanexplore_declarations | instance instCompleteLinearOrder : CompleteLinearOrder Prob :=
instCompleteLinearOrderElemIccOfFactLe |
60 | leanexplore_declaration | leanexplore:377835 | leanexplore_sqlite | leanexplore_declarations | instance instInhabited : Inhabited Prob where
default := 0 |
197 | leanexplore_declaration | leanexplore:377836 | leanexplore_sqlite | leanexplore_declarations | instance : LinearOrderedCommMonoidWithZero Prob where
mul_lt_mul_of_pos_left := by
intros a ha b h hb
rw [← Subtype.coe_lt_coe]
exact mul_lt_mul_of_pos_left hb ha
zero_le a := a.2.1 |
63 | leanexplore_declaration | leanexplore:377837 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem zero_le_coe {p : Prob} : 0 ≤ (p : ℝ) :=
p.2.1 |
62 | leanexplore_declaration | leanexplore:377838 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem coe_le_one {p : Prob} : (p : ℝ) ≤ 1 :=
p.2.2 |
59 | leanexplore_declaration | leanexplore:377839 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem zero_le {p : Prob} : 0 ≤ p :=
zero_le_coe |
57 | leanexplore_declaration | leanexplore:377840 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem le_one {p : Prob} : p ≤ 1 :=
coe_le_one |
86 | leanexplore_declaration | leanexplore:377841 | leanexplore_sqlite | leanexplore_declarations | @[ext] protected theorem ext {n m : Prob} : (n : ℝ) = (m : ℝ) → n = m :=
Subtype.ext |
91 | leanexplore_declaration | leanexplore:377843 | leanexplore_sqlite | leanexplore_declarations | theorem ne_iff {x y : Prob} : (x : ℝ) ≠ (y : ℝ) ↔ x ≠ y :=
not_congr <| Prob.ext_iff.symm |
115 | leanexplore_declaration | leanexplore:377844 | leanexplore_sqlite | leanexplore_declarations | @[simp, norm_cast]
theorem toReal_mul (x y : Prob) : (x * y : Prob) = (x : ℝ) * (y : ℝ) := by
simp only [coe_mul] |
96 | leanexplore_declaration | leanexplore:377845 | leanexplore_sqlite | leanexplore_declarations | /-- Coercion `Prob → ℝ≥0`. -/
@[coe] def toNNReal : Prob → ℝ≥0 :=
fun p ↦ ⟨p.val, zero_le_coe⟩ |
108 | leanexplore_declaration | leanexplore:377846 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem toNNReal_mk : toNNReal { val := x, property := hx} = { val := x, property := hx.1 } :=
rfl |
101 | leanexplore_declaration | leanexplore:377848 | leanexplore_sqlite | leanexplore_declarations | instance canLiftNN : CanLift ℝ≥0 Prob toNNReal fun r => r ≤ 1 :=
⟨fun x hx ↦ ⟨⟨x, ⟨x.2, hx⟩⟩, rfl⟩⟩ |
176 | leanexplore_declaration | leanexplore:377849 | leanexplore_sqlite | leanexplore_declarations | protected theorem eq_iff_nnreal (n m : Prob) : (n : ℝ≥0) = (m : ℝ≥0) ↔ n = m := by
obtain ⟨n,hn⟩ := n
obtain ⟨m,hn⟩ := m
simp only [toNNReal_mk, Subtype.mk.injEq, NNReal] |
74 | leanexplore_declaration | leanexplore:377850 | leanexplore_sqlite | leanexplore_declarations | @[simp, norm_cast]
theorem toNNReal_zero : (0 : Prob) = (0 : ℝ≥0) :=
rfl |
73 | leanexplore_declaration | leanexplore:377851 | leanexplore_sqlite | leanexplore_declarations | @[simp, norm_cast]
theorem toNNReal_one : (1 : Prob) = (1 : ℝ≥0) :=
rfl |
136 | leanexplore_declaration | leanexplore:377852 | leanexplore_sqlite | leanexplore_declarations | theorem ofNNReal_toNNReal : ENNReal.ofNNReal (toNNReal p) = ENNReal.ofReal (p : ℝ) := by
simp [toNNReal, ENNReal.ofReal_eq_coe_nnreal] |
67 | leanexplore_declaration | leanexplore:377853 | leanexplore_sqlite | leanexplore_declarations | def NNReal.asProb (p : ℝ≥0) (hp : p ≤ 1) : Prob :=
⟨p, ⟨p.2, hp⟩⟩ |
70 | leanexplore_declaration | leanexplore:377854 | leanexplore_sqlite | leanexplore_declarations | def NNReal.asProb' (p : ℝ≥0) (hp : p.1 ≤ 1) : Prob :=
⟨p, ⟨p.2, hp⟩⟩ |
122 | leanexplore_declaration | leanexplore:377855 | leanexplore_sqlite | leanexplore_declarations | theorem zero_lt_coe {p : Prob} (hp : p ≠ 0) : (0 : ℝ) < p :=
lt_of_le_of_ne' p.zero_le (unitInterval.coe_ne_zero.mpr hp) |
382 | leanexplore_declaration | leanexplore:377856 | leanexplore_sqlite | leanexplore_declarations | /-- Subtract a probability from another. Truncates to zero, so this is often not great
to work with, for the same reason that Nat subtraction is a pain. But, it lets you write
`1 - p`, which is sufficiently useful on its own that this seems worth having. -/
instance instSub : Sub Prob where
sub p q := ⟨(p - q) ⊔ (0 :... |
86 | leanexplore_declaration | leanexplore:377857 | leanexplore_sqlite | leanexplore_declarations | theorem coe_sub (p q : Prob) : (p - q : Prob) = (p.val - q.val) ⊔ (0 : ℝ) := by
rfl |
105 | leanexplore_declaration | leanexplore:377858 | leanexplore_sqlite | leanexplore_declarations | @[simp, norm_cast]
theorem coe_one_minus (p : Prob) : (1 - p : Prob) = 1 - (p : ℝ) := by
simp [coe_sub] |
71 | leanexplore_declaration | leanexplore:377859 | leanexplore_sqlite | leanexplore_declarations | theorem add_one_minus (p : Prob) : p.val + (1 - p).val = 1 := by
simp |
77 | leanexplore_declaration | leanexplore:377860 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem one_minus_inv (p : Prob) : 1 - (1 - p) = p := by
ext
simp |
93 | leanexplore_declaration | leanexplore:377861 | leanexplore_sqlite | leanexplore_declarations | instance : OrderTopology Prob :=
orderTopology_of_ordConnected (ht := Set.ordConnected_Icc) |
221 | leanexplore_declaration | leanexplore:377862 | leanexplore_sqlite | leanexplore_declarations | @[simp, norm_cast]
theorem coe_iInf {ι : Type*} [Nonempty ι] (f : ι → Prob) : ↑(⨅ t, f t) = (⨅ t, f t : ℝ) := by
apply Monotone.map_ciInf_of_continuousAt
· fun_prop
· exact fun _ _ ↦ id
· exact OrderBot.bddBelow _ |
84 | leanexplore_declaration | leanexplore:377863 | leanexplore_sqlite | leanexplore_declarations | instance : Nontrivial Prob where
exists_pair_ne := ⟨0, 1, by simp [← Prob.ne_iff]⟩ |
55 | leanexplore_declaration | leanexplore:377864 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem top_eq_one : (⊤ : Prob) = 1 := by
rfl |
76 | leanexplore_declaration | leanexplore:377865 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem sub_zero (p : Prob) : p - 0 = p := by
ext1; simp [coe_sub] |
106 | leanexplore_declaration | leanexplore:377866 | leanexplore_sqlite | leanexplore_declarations | @[fun_prop]
theorem toNNReal_Continuous : Continuous Prob.toNNReal := by
unfold Prob.toNNReal
fun_prop |
197 | leanexplore_declaration | leanexplore:377867 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem mul_eq_one_iff (p q : Prob) : p * q = 1 ↔ p = 1 ∧ q = 1 := by
cases p
cases q
refine ⟨fun h ↦ ?_, fun h ↦ by simp [h]⟩
simp [Prob.ext_iff] at h ⊢
constructor <;> nlinarith |
1,676 | leanexplore_declaration | leanexplore:377868 | leanexplore_sqlite | leanexplore_declarations | /-- A `Mixable T` typeclass instance gives a compact way of talking about the action of probabilities
for forming linear combinations in convex spaces. The notation `p [ x₁ ↔ x₂ ]` means to take a convex
combination, equal to `x₁` if `p=1` and to `x₂` if `p=0`.
Mixable is defined by an "underlying" data type `U`... |
251 | leanexplore_declaration | leanexplore:377869 | leanexplore_sqlite | leanexplore_declarations | @[reducible]
def mix_ab [inst : Mixable U T] {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) (x₁ x₂ : T) : T :=
inst.mkT <| inst.convex
(x := to_U x₁) (exists_apply_eq_apply _ _)
(y := to_U x₂) (exists_apply_eq_apply _ _)
ha hb hab |
350 | leanexplore_declaration | leanexplore:377870 | leanexplore_sqlite | leanexplore_declarations | /-- `Mixable.mix` represents the notion of "convex combination" on the type `T`, afforded by the `Mixable`
instance. It takes a `Prob`, that is, a `Real` between 0 and 1. For working directly with a Real, use `mix_ab`. -/
def mix [inst : Mixable U T] (p : Prob) (x₁ x₂ : T) : T :=
inst.mix_ab p.zero_le_coe (1 - p).zer... |
119 | leanexplore_declaration | leanexplore:377871 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem to_U_of_mkT [inst : Mixable U T] (u : U) {h} : inst.to_U (mkT (u := u) h).1 = u :=
(mkT (u := u) h).2 |
46 | leanexplore_declaration | leanexplore:377872 | leanexplore_sqlite | leanexplore_declarations | notation p "[" x₁:80 "↔" x₂ "]" => mix p x₁ x₂ |
64 | leanexplore_declaration | leanexplore:377873 | leanexplore_sqlite | leanexplore_declarations | notation p "[" x₁:80 "↔" x₂ ":" M "]" => mix (inst := M) p x₁ x₂ |
142 | leanexplore_declaration | leanexplore:377874 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem mix_zero [inst : Mixable U T] (x₁ x₂ : T) : (0 : Prob) [ x₁ ↔ x₂ : inst] = x₂ := by
apply inst.to_U_inj
simp [mix, mix_ab] |
292 | leanexplore_declaration | leanexplore:377875 | leanexplore_sqlite | leanexplore_declarations | /--When T is the whole space, and T is a suitable vector space over ℝ, we get a Mixable instance.-/
instance instUniv [AddCommMonoid T] [Module ℝ T] : Mixable T T where
to_U := id
to_U_inj := id
convex := by
convert convex_univ
simp only [Set.range_id]
mkT := fun _ ↦ ⟨_, rfl⟩ |
128 | leanexplore_declaration | leanexplore:377876 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem mkT_instUniv [AddCommMonoid T] [Module ℝ T] {t : T} (h : ∃ t', to_U t' = t) : instUniv.mkT h = ⟨t, rfl⟩ :=
rfl |
99 | leanexplore_declaration | leanexplore:377877 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem to_U_instUniv [AddCommMonoid T] [Module ℝ T] {t : T} : instUniv.to_U t = t :=
rfl |
304 | leanexplore_declaration | leanexplore:377878 | leanexplore_sqlite | leanexplore_declarations | theorem instPi.lem_1 {D : Type*} {T U : D → Type*} [∀i, AddCommMonoid (U i)] [∀ i, Module ℝ (U i)] [inst : ∀i, Mixable (U i) (T i)]
{u : (i : D) → U i} (h : ∃ (t : (i : D) → T i), (fun d => to_U (t d)) = u) (d : D) : ∃ (t : T d), to_U t = u d := by
obtain ⟨t, h⟩ := h
use t d
exact congrFun h d |
498 | leanexplore_declaration | leanexplore:377879 | leanexplore_sqlite | leanexplore_declarations | /-- Mixable instance on Pi types. -/
instance instPi : Mixable ((i:D) → U i) ((i:D) → T i) where
to_U x := fun d ↦ (inst d).to_U (x d)
to_U_inj h := funext fun d ↦ (inst d).to_U_inj (congrFun h d)
mkT := fun {u} h ↦ ⟨fun d ↦ (inst d).mkT (u := u d) (instPi.lem_1 h d),
by funext d; simp⟩
convex := by
sim... |
175 | leanexplore_declaration | leanexplore:377880 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem val_mkT_instPi (D : Type*) [inst : Mixable U T] {u : D → U} (h : ∃ t, to_U t = u) : (instPi.mkT h).val =
fun d ↦ (inst.mkT (instPi.lem_1 h d)).val :=
rfl |
125 | leanexplore_declaration | leanexplore:377881 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem to_U_instPi (D : Type*) [inst : Mixable U T] {t : D → T} : (instPi).to_U t = fun d ↦ inst.to_U (t d) :=
rfl |
927 | leanexplore_declaration | leanexplore:377882 | leanexplore_sqlite | leanexplore_declarations | /-- Mixable instances on subtypes (of other mixable types), assuming that they
have the correct closure properties. -/
@[reducible]
def instSubtype {T : Type*} {P : T → Prop} (inst : Mixable U T)
(h : ∀{x y:T},
∀⦃a b : ℝ⦄, (ha : 0 ≤ a) → (hb : 0 ≤ b) → (hab : a + b = 1) →
P x → P y → P (inst.mix_ab ha ... |
347 | leanexplore_declaration | leanexplore:377883 | leanexplore_sqlite | leanexplore_declarations | /-- Probabilities `Prob` themselves are convex. -/
instance instMixable : Mixable ℝ Prob where
to_U := Subtype.val
to_U_inj := Prob.ext
mkT := fun h ↦ ⟨⟨_, Exists.casesOn h fun t ht => ht ▸ t.prop⟩, rfl⟩
convex := by
simp [Convex, StarConvex]
intro x hx0 hx1 y hy0 hy1 a b ha hb hab
constructor
·... |
106 | leanexplore_declaration | leanexplore:377884 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem to_U_mixable [AddCommMonoid T] [SMul ℝ T] (t : Prob) : instMixable.to_U t = t.val :=
rfl |
151 | leanexplore_declaration | leanexplore:377885 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem mkT_mixable (u : ℝ) (h : ∃ t : Prob, Mixable.to_U t = u) : Mixable.mkT h =
⟨⟨u,Exists.casesOn h fun t ht ↦ ht ▸ t.2⟩, rfl⟩ :=
rfl |
230 | leanexplore_declaration | leanexplore:377886 | leanexplore_sqlite | leanexplore_declarations | /-- `Prob.mix` is an alias of `Mixable.mix` so it can be accessed from a probability with
dot notation, e.g. `p.mix x y`. -/
abbrev mix [AddCommMonoid U] [Module ℝ U] [inst : Mixable U T] (p : Prob) (x₁ x₂ : T) := inst.mix p x₁ x₂ |
296 | leanexplore_declaration | leanexplore:377887 | leanexplore_sqlite | leanexplore_declarations | /-- Map a probability [0,1] to [0,+∞] with -log p. Special case that 0 maps to +∞ (not 0, as Real.log
does). This makes it `Antitone`.
-/
noncomputable def negLog : Prob → ENNReal :=
fun p ↦ if p = 0 then ∞ else .ofNNReal ⟨-Real.log p,
Left.nonneg_neg_iff.mpr (Real.log_nonpos p.2.1 p.2.2)⟩ |
522 | leanexplore_declaration | leanexplore:377889 | leanexplore_sqlite | leanexplore_declarations | theorem negLog_Antitone : Antitone negLog := by
intro x y h
dsimp [negLog]
split_ifs with h₁ h₂ h₂
· rfl
· subst y
exfalso
change x.1 ≤ 0 at h
have : ¬(x.1 = 0) := unitInterval.coe_ne_zero.mpr (by assumption)
have : 0 ≤ x.1 := zero_le
linarith +splitNe
· exact OrderTop.le_top _
· rw [E... |
71 | leanexplore_declaration | leanexplore:377890 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem negLog_zero : —log (0 : Prob) = ⊤ := by
simp [negLog] |
61 | leanexplore_declaration | leanexplore:377891 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem negLog_one : —log 1 = 0 := by
simp [negLog] |
87 | leanexplore_declaration | leanexplore:377892 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem negLog_eq_top_iff {p : Prob} : —log p = ⊤ ↔ p = 0 := by
simp [negLog] |
170 | leanexplore_declaration | leanexplore:377893 | leanexplore_sqlite | leanexplore_declarations | theorem negLog_pos_ENNReal {p : Prob} (hp : p ≠ 0) : —log p = .ofNNReal ⟨-Real.log p,
Left.nonneg_neg_iff.mpr (Real.log_nonpos p.2.1 p.2.2)⟩ := by
simp [negLog, hp] |
137 | leanexplore_declaration | leanexplore:377894 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem negLog_pos_Real {p : Prob} : (—log p).toReal = -Real.log p := by
rw [negLog]
split_ifs with hp
· simp [hp]
· simp |
815 | leanexplore_declaration | leanexplore:377895 | leanexplore_sqlite | leanexplore_declarations | theorem le_negLog_of_le_exp {p : Prob} {x : ℝ} (h : p ≤ Real.exp (-x)) : ENNReal.ofReal x ≤ —log p := by
by_cases hx : 0 ≤ x
· rw [negLog]
split_ifs with hp
· exact le_top
· replace hp : 0 < p := lt_of_le_of_ne' p.zero_le hp
rw [le_iff_lt_or_eq] at h
rcases h with h|h
· apply le_of_lt
... |
151 | leanexplore_declaration | leanexplore:377896 | leanexplore_sqlite | leanexplore_declarations | @[aesop (rule_sets := [finiteness]) safe apply]
theorem negLog_ne_top {p : Prob} (hp : 0 < p.val) : —log p ≠ ∞ := by
simpa [negLog] using ne_of_gt hp |
297 | leanexplore_declaration | leanexplore:377897 | leanexplore_sqlite | leanexplore_declarations | theorem negLog_eq_neg_ENNReal_log (p : Prob) : —log p = -ENNReal.log p := by
rw [negLog]
split_ifs with hp
· simp [hp]
· rw [log, if_neg, if_neg]
· norm_cast
· finiteness
· rw [Subtype.ext_iff] at hp
rw [toNNReal, ENNReal.coe_eq_zero]
exact NNReal.coe_ne_zero.mp hp |
266 | leanexplore_declaration | leanexplore:377898 | leanexplore_sqlite | leanexplore_declarations | theorem negLog_eq_ofReal_neg_log {p : Prob} (hp : 0 < p) :
ENNReal.ofReal (-Real.log p) = —log p := by
rcases p with ⟨p, p0, p1⟩
rw [negLog]
split_ifs with h
· simp_all
· exact ENNReal.ofReal_eq_coe_nnreal (neg_nonneg_of_nonpos (Real.log_nonpos p0 p1)) |
560 | leanexplore_declaration | leanexplore:377899 | leanexplore_sqlite | leanexplore_declarations | @[simp]
theorem zero_lt_negLog {p : Prob} : 0 < —log p ↔ p ≠ 1 := by
--This is messy enough it's probably a sign we're missing other simp lemmas
rw [negLog]
split_ifs with h
· simp [h]
constructor <;> intro h₂ <;> contrapose! h₂
· simp [h₂]
simp only [nonpos_iff_eq_zero, ENNReal.coe_eq_zero] at h₂
rw [S... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.