Mathlib.Probability.ProbabilityMassFunction.Monad
35 declarations. Mathlib docs · Source
def PMF.pure E1 #
{α : Type u_1} → α → PMF α
The pure PMF is the PMF where all the mass lies in one point.
The value of pure a is 1 at a and 0 elsewhere.
theorem PMF.pure_apply E0 #
∀ {α : Type u_1} (a a' : α), (PMF.pure a) a' = if a' = a then 1 else 0
theorem PMF.support_pure E0 #
∀ {α : Type u_1} (a : α), (PMF.pure a).support = {a}
theorem PMF.mem_support_pure_iff E0 #
∀ {α : Type u_1} (a a' : α), a' ∈ (PMF.pure a).support ↔ a' = a
theorem PMF.pure_apply_self E1 #
∀ {α : Type u_1} (a : α), (PMF.pure a) a = 1
theorem PMF.pure_apply_of_ne E1 #
∀ {α : Type u_1} (a a' : α), a' ≠ a → (PMF.pure a) a' = 0
instance PMF.instInhabited E0 #
{α : Type u_1} → [Inhabited α] → Inhabited (PMF α)
theorem PMF.toOuterMeasure_pure_apply E0 #
∀ {α : Type u_1} (a : α) (s : Set α), (PMF.pure a).toOuterMeasure s = if a ∈ s then 1 else 0
theorem PMF.toMeasure_pure_apply E0 #
∀ {α : Type u_1} (a : α) (s : Set α) [inst : MeasurableSpace α],
MeasurableSet s → (PMF.pure a).toMeasure s = if a ∈ s then 1 else 0
The measure of a set under pure a is 1 for sets containing a and 0 otherwise.
theorem PMF.toMeasure_pure E1 #
∀ {α : Type u_1} (a : α) [inst : MeasurableSpace α], (PMF.pure a).toMeasure = MeasureTheory.Measure.dirac a
theorem PMF.toPMF_dirac E0 #
∀ {α : Type u_1} (a : α) [inst : MeasurableSpace α] [inst_1 : Countable α] [h : MeasurableSingletonClass α],
(MeasureTheory.Measure.dirac a).toPMF = PMF.pure a
def PMF.bind E1 #
{α : Type u_1} → {β : Type u_2} → PMF α → (α → PMF β) → PMF β
The monadic bind operation for PMF.
theorem PMF.bind_apply E0 #
∀ {α : Type u_1} {β : Type u_2} (p : PMF α) (f : α → PMF β) (b : β), (p.bind f) b = ∑' (a : α), p a * (f a) b
theorem PMF.support_bind E0 #
∀ {α : Type u_1} {β : Type u_2} (p : PMF α) (f : α → PMF β), (p.bind f).support = ⋃ a ∈ p.support, (f a).support
theorem PMF.mem_support_bind_iff E0 #
∀ {α : Type u_1} {β : Type u_2} (p : PMF α) (f : α → PMF β) (b : β),
b ∈ (p.bind f).support ↔ ∃ a ∈ p.support, b ∈ (f a).support
theorem PMF.pure_bind E0 #
∀ {α : Type u_1} {β : Type u_2} (a : α) (f : α → PMF β), (PMF.pure a).bind f = f a
theorem PMF.bind_pure E0 #
∀ {α : Type u_1} (p : PMF α), p.bind PMF.pure = p
theorem PMF.bind_const E0 #
∀ {α : Type u_1} {β : Type u_2} (p : PMF α) (q : PMF β), (p.bind fun x ↦ q) = q
theorem PMF.bind_bind E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (p : PMF α) (f : α → PMF β) (g : β → PMF γ),
(p.bind f).bind g = p.bind fun a ↦ (f a).bind g
theorem PMF.bind_comm E1 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (p : PMF α) (q : PMF β) (f : α → β → PMF γ),
(p.bind fun a ↦ q.bind (f a)) = q.bind fun b ↦ p.bind fun a ↦ f a b
theorem PMF.toOuterMeasure_bind_apply E0 #
∀ {α : Type u_1} {β : Type u_2} (p : PMF α) (f : α → PMF β) (s : Set β),
(p.bind f).toOuterMeasure s = ∑' (a : α), p a * (f a).toOuterMeasure s
theorem PMF.toMeasure_bind_apply E0 #
∀ {α : Type u_1} {β : Type u_2} (p : PMF α) (f : α → PMF β) (s : Set β) [inst : MeasurableSpace β],
MeasurableSet s → (p.bind f).toMeasure s = ∑' (a : α), p a * (f a).toMeasure s
The measure of a set under p.bind f is the sum over a : α
of the probability of a under p times the measure of the set under f a.
instance PMF.instMonad E0 #
Monad PMF
def PMF.bindOnSupport E1 #
{α : Type u_1} → {β : Type u_2} → (p : PMF α) → ((a : α) → a ∈ p.support → PMF β) → PMF β
Generalized version of bind allowing f to only be defined on the support of p.
p.bind f is equivalent to p.bindOnSupport (fun a _ ↦ f a), see bindOnSupport_eq_bind.
theorem PMF.bindOnSupport_apply E0 #
∀ {α : Type u_1} {β : Type u_2} {p : PMF α} (f : (a : α) → a ∈ p.support → PMF β) (b : β),
(p.bindOnSupport f) b = ∑' (a : α), p a * if h : p a = 0 then 0 else (f a h) b
theorem PMF.support_bindOnSupport E0 #
∀ {α : Type u_1} {β : Type u_2} {p : PMF α} (f : (a : α) → a ∈ p.support → PMF β),
(p.bindOnSupport f).support = ⋃ a, ⋃ (h : a ∈ p.support), (f a h).support
theorem PMF.mem_support_bindOnSupport_iff E0 #
∀ {α : Type u_1} {β : Type u_2} {p : PMF α} (f : (a : α) → a ∈ p.support → PMF β) (b : β),
b ∈ (p.bindOnSupport f).support ↔ ∃ a, ∃ (h : a ∈ p.support), b ∈ (f a h).support
theorem PMF.bindOnSupport_eq_bind E0 #
∀ {α : Type u_1} {β : Type u_2} (p : PMF α) (f : α → PMF β), (p.bindOnSupport fun a x ↦ f a) = p.bind f
bindOnSupport reduces to bind if f doesn't depend on the additional hypothesis.
theorem PMF.bindOnSupport_eq_zero_iff E0 #
∀ {α : Type u_1} {β : Type u_2} {p : PMF α} (f : (a : α) → a ∈ p.support → PMF β) (b : β),
(p.bindOnSupport f) b = 0 ↔ ∀ (a : α) (ha : p a ≠ 0), (f a ha) b = 0
theorem PMF.pure_bindOnSupport E0 #
∀ {α : Type u_1} {β : Type u_2} (a : α) (f : (a' : α) → a' ∈ (PMF.pure a).support → PMF β),
(PMF.pure a).bindOnSupport f = f a ⋯
theorem PMF.bindOnSupport_pure E1 #
∀ {α : Type u_1} (p : PMF α), (p.bindOnSupport fun a x ↦ PMF.pure a) = p
theorem PMF.bindOnSupport_bindOnSupport E0 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (p : PMF α) (f : (a : α) → a ∈ p.support → PMF β)
(g : (b : β) → b ∈ (p.bindOnSupport f).support → PMF γ),
(p.bindOnSupport f).bindOnSupport g = p.bindOnSupport fun a ha ↦ (f a ha).bindOnSupport fun b hb ↦ g b ⋯
theorem PMF.bindOnSupport_comm E1 #
∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (p : PMF α) (q : PMF β)
(f : (a : α) → a ∈ p.support → (b : β) → b ∈ q.support → PMF γ),
(p.bindOnSupport fun a ha ↦ q.bindOnSupport (f a ha)) =
q.bindOnSupport fun b hb ↦ p.bindOnSupport fun a ha ↦ f a ha b hb
theorem PMF.toOuterMeasure_bindOnSupport_apply E0 #
∀ {α : Type u_1} {β : Type u_2} {p : PMF α} (f : (a : α) → a ∈ p.support → PMF β) (s : Set β),
(p.bindOnSupport f).toOuterMeasure s = ∑' (a : α), p a * if h : p a = 0 then 0 else (f a h).toOuterMeasure s
theorem PMF.toMeasure_bindOnSupport_apply E0 #
∀ {α : Type u_1} {β : Type u_2} {p : PMF α} (f : (a : α) → a ∈ p.support → PMF β) (s : Set β)
[inst : MeasurableSpace β],
MeasurableSet s → (p.bindOnSupport f).toMeasure s = ∑' (a : α), p a * if h : p a = 0 then 0 else (f a h).toMeasure s
The measure of a set under p.bindOnSupport f is the sum over a : α
of the probability of a under p times the measure of the set under f a _.
The additional if statement is needed since f is only a partial function.