Skip to content

Commit f889e83

Browse files
committed
all sorrys for total expectation proved
1 parent e15d800 commit f889e83

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

Probability/Probability/Basic.lean

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,19 @@ end Findist
4040

4141
namespace Pr
4242

43-
variable {n : ℕ} (P : Findist n) (B C : FinRV n Bool)
43+
variable {n : ℕ} {P : Findist n} {B C : FinRV n Bool}
44+
4445

4546
theorem prob_compl_sums_to_one : ℙ[B // P] + ℙ[¬ᵣB // P] = 1 :=
46-
by unfold probability
47-
sorry
47+
by rw [Ex.prob_eq_exp_ind, Ex.prob_eq_exp_ind]
48+
rw [←exp_dists_add]
49+
rw [one_of_ind_bool_or_not]
50+
exact exp_one
51+
52+
4853

4954
theorem prob_compl_one_minus : ℙ[¬ᵣB // P] = 1 - ℙ[B // P] :=
50-
by have := prob_compl_sums_to_one P B
55+
by have := prob_compl_sums_to_one (P:=P) (B:=B)
5156
linarith
5257

5358

Probability/Probability/Defs.lean

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,14 @@ theorem ind_le_one : 𝕀∘B ≤ (1 : FinRV n ℚ) :=
193193
theorem one_of_true : 𝕀 ∘ (1 : Fin n → Bool) = (1 : Fin n → ℚ) := by ext; simp [𝕀, indicator]
194194

195195
theorem one_of_bool_or_not : B + (¬ᵣ B) = (1 : FinRV n Bool) := by ext ω; unfold FinRV.not; simp
196-
196+
197+
theorem one_of_ind_bool_or_not : (𝕀∘B) + (𝕀∘(¬ᵣ B)) = (1 : FinRV n ℚ) :=
198+
by ext ω
199+
unfold FinRV.not 𝕀 indicator not
200+
by_cases h : B ω
201+
· simp [h]
202+
· simp [h]
203+
197204
variable {X Y: FinRV n ℚ}
198205

199206
theorem rv_le_abs : X ≤ abs ∘ X := by intro i; simp [le_abs_self (X i)]
@@ -296,6 +303,11 @@ end Ex
296303
section Expectation_properties
297304
variable {P : Findist n} {X Y Z: FinRV n ℚ} {B : FinRV n Bool}
298305

306+
theorem exp_congr : (X = Y) → 𝔼[X // P] = 𝔼[Y // P] :=
307+
by intro h
308+
unfold Ex.expect dotProduct
309+
apply Fintype.sum_congr
310+
simp_all
299311

300312
theorem exp_dists_add : 𝔼[X + Y // P] = 𝔼[X // P] + 𝔼[Y // P] := by simp [Ex.expect]
301313

@@ -312,6 +324,10 @@ theorem exp_const : 𝔼[(fun _ ↦ c) // P] = c :=
312324
rw [dotProduct_comm, P.prob]
313325
simp
314326

327+
theorem exp_one : 𝔼[ 1 // P] = 1 :=
328+
by calc 𝔼[ 1 // P] = 𝔼[ (fun _ ↦ 1) // P] := rfl
329+
_ = 1 := exp_const
330+
315331
theorem exp_prod_const : 𝔼[c • X // P] = c * 𝔼[X // P] := by simp only [Ex.expect, dotProduct_smul, smul_eq_mul]
316332

317333
lemma constant_mul_eq_smul : (fun ω ↦ c * X ω) = c • X := rfl

0 commit comments

Comments
 (0)