Skip to content

Commit e6d59b2

Browse files
committed
cleanup
1 parent f3bfedb commit e6d59b2

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

Probability/Probability/Basic.lean

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,19 +479,18 @@ section Expectation
479479

480480
variable {n : ℕ} {P : Findist n}
481481
variable {k : ℕ} {X : FinRV n ℚ} {B : FinRV n Bool} {L : FinRV n (Fin k)}
482-
variable (g : Fin k → ℚ)
482+
variable (g : Fin k → ℚ)
483483

484484
/-- LOTUS: The law of the unconscious statistician (or similar) -/
485485
theorem LOTUS : 𝔼[g ∘ L // P ] = ∑ i, ℙ[L =ᵣ i // P] * (g i) :=
486486
by rewrite [exp_decompose (X := g ∘ L) (L := L) ]
487487
apply Fintype.sum_congr
488488
intro i
489-
rewrite [←indi_eq_indr]
490-
rewrite [←exp_cond_eq_def (X := g ∘ L) ]
489+
rewrite [←indi_eq_indr, ←exp_cond_eq_def (X := g ∘ L) ]
491490
by_cases! h : ℙ[L =ᵣ i // P] = 0
492491
· rw [h]; simp
493492
· rw [exp_cond_const i h ]
494-
ring
493+
ring
495494

496495
theorem law_total_exp : 𝔼[𝔼[X |ᵣ L // P] // P] = 𝔼[X // P] :=
497496
let g i := 𝔼[X | L =ᵣ i // P]
@@ -502,6 +501,12 @@ theorem law_total_exp : 𝔼[𝔼[X |ᵣ L // P] // P] = 𝔼[X // P] :=
502501
_ = ∑ i : Fin k, 𝔼[X * (L =ᵢ i) // P] := by apply Fintype.sum_congr; intro i; apply exp_congr; rw[indi_eq_indr]
503502
_ = 𝔼[X // P] := by rw [←exp_decompose]
504503

504+
505+
/-- Shows that our definition of expectation is correct -/
506+
theorem expect_def_correct : 𝔼[ X // P] = ∑ y ∈ (Finset.univ.image X), (ℙ[ X =ᵣ y // P] * y) := by
507+
-- TODO: Can we use FinEnum and Quotient to reduce it to LOTUS
508+
sorry
509+
505510
end Expectation
506511

507512
section Probability

Probability/Probability/Defs.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ variable {k : ℕ} {g : Fin k → ℚ} {L : FinRV n (Fin k)}
408408

409409
theorem exp_decompose : 𝔼[X // P] = ∑ i, 𝔼[X * (L =ᵢ i) // P] :=
410410
by nth_rewrite 1 [rv_decompose X L]
411-
rewrite [exp_additive]
412-
simp
411+
rw [exp_additive]
413412

414413
/-- Expectation of a conditional constant. Only when probability is positive. -/
415414
theorem exp_cond_const : ∀ i, ℙ[L =ᵣ i // P] ≠ 0 → 𝔼[g ∘ L | L =ᵣ i // P] = g i :=

0 commit comments

Comments
 (0)