Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Cslib/Probability/PMF.lean
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,30 @@ theorem posteriorDist_eq_prior_of_outputIndist (p : PMF α) (f : α → PMF β)
exact ENNReal.mul_div_cancel_right ((PMF.mem_support_iff _ _).mp (hbind ▸ hb))
(PMF.apply_ne_top _ _)

/-- Real-valued probability masses are summable, even on an infinite ambient type. -/
theorem summable_toReal (p : PMF α) : Summable (fun a => (p a).toReal) :=
ENNReal.summable_toReal p.tsum_coe_ne_top

/-- The real-valued masses of any discrete distribution sum to one. -/
@[simp] theorem tsum_toReal (p : PMF α) : ∑' a, (p a).toReal = 1 := by
rw [← ENNReal.tsum_toReal_eq p.apply_ne_top, p.tsum_coe, ENNReal.toReal_one]

/-- The real-valued probabilities of a finite distribution sum to one. -/
theorem sum_toReal [Fintype α] (p : PMF α) :
∑ a, (p a).toReal = 1 := by simpa using tsum_toReal p

/-- Randomized postprocessing averages the outcome probabilities over any discrete input. -/
theorem bind_apply_toReal_tsum (p : PMF α) (kernel : α → PMF β) (b : β) :
(p.bind kernel b).toReal = ∑' a, (p a).toReal * (kernel a b).toReal := by
rw [PMF.bind_apply, ENNReal.tsum_toReal_eq (fun a =>
ENNReal.mul_ne_top (p.apply_ne_top a) ((kernel a).apply_ne_top b))]
simp

/-- The probability of an outcome after a finite random choice is its weighted average. -/
theorem bind_apply_toReal [Fintype α] (p : PMF α)
(kernel : α → PMF β) (b : β) :
(p.bind kernel b).toReal =
∑ a, (p a).toReal * (kernel a b).toReal := by
simpa using bind_apply_toReal_tsum p kernel b

end Cslib.Probability.PMF
Loading