Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 8ab1b3b

Browse files
committed
feat(measure_theory/probability_mass_function): Calculate supports of pmf constructions (#10371)
This PR gives explicit descriptions for the `support` of the various `pmf` constructions in mathlib. This also tries to clean up the variable declarations in the different sections, so that all the lemmas don't need to specify them explicitly.
1 parent 678566f commit 8ab1b3b

File tree

2 files changed

+186
-88
lines changed

2 files changed

+186
-88
lines changed

src/measure_theory/probability_mass_function/basic.lean

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ lemma summable_coe (p : pmf α) : summable p := (p.has_sum_coe_one).summable
4949
/-- The support of a `pmf` is the set where it is nonzero. -/
5050
def support (p : pmf α) : set α := function.support p
5151

52-
@[simp] lemma mem_support_iff (p : pmf α) (a : α) :
53-
a ∈ p.support ↔ p a ≠ 0 := iff.rfl
52+
@[simp] lemma mem_support_iff (p : pmf α) (a : α) : a ∈ p.support ↔ p a ≠ 0 := iff.rfl
5453

55-
lemma apply_eq_zero_iff (p : pmf α) (a : α) :
56-
p a = 0 ↔ a ∉ p.support :=
54+
lemma apply_eq_zero_iff (p : pmf α) (a : α) : p a = 0 ↔ a ∉ p.support :=
5755
by rw [mem_support_iff, not_not]
5856

5957
lemma coe_le_one (p : pmf α) (a : α) : p a ≤ 1 :=
@@ -66,10 +64,13 @@ section pure
6664
The value of `pure a` is `1` at `a` and `0` elsewhere. -/
6765
def pure (a : α) : pmf α := ⟨λ a', if a' = a then 1 else 0, has_sum_ite_eq _ _⟩
6866

69-
@[simp] lemma pure_apply (a a' : α) : pure a a' = (if a' = a then 1 else 0) := rfl
67+
variables (a a' : α)
7068

71-
lemma mem_support_pure_iff (a a' : α) : a' ∈ (pure a).support ↔ a' = a :=
72-
by simp
69+
@[simp] lemma pure_apply : pure a a' = (if a' = a then 1 else 0) := rfl
70+
71+
@[simp] lemma support_pure : (pure a).support = {a} := set.ext (λ a', by simp [mem_support_iff])
72+
73+
lemma mem_support_pure_iff: a' ∈ (pure a).support ↔ a' = a := by simp
7374

7475
instance [inhabited α] : inhabited (pmf α) := ⟨pure (default α)⟩
7576

@@ -96,8 +97,15 @@ def bind (p : pmf α) (f : α → pmf β) : pmf β :=
9697
(ennreal.coe_tsum p.summable_coe).symm]
9798
end
9899

99-
@[simp] lemma bind_apply (p : pmf α) (f : α → pmf β) (b : β) : p.bind f b = ∑'a, p a * f a b :=
100-
rfl
100+
variables (p : pmf α) (f : α → pmf β)
101+
102+
@[simp] lemma bind_apply (b : β) : p.bind f b = ∑'a, p a * f a b := rfl
103+
104+
@[simp] lemma support_bind : (p.bind f).support = {b | ∃ a ∈ p.support, b ∈ (f a).support} :=
105+
set.ext (λ b, by simp [mem_support_iff, tsum_eq_zero_iff (bind.summable p f b), not_or_distrib])
106+
107+
lemma mem_support_bind_iff (b : β) : b ∈ (p.bind f).support ↔ ∃ a ∈ p.support, b ∈ (f a).support :=
108+
by simp
101109

102110
lemma coe_bind_apply (p : pmf α) (f : α → pmf β) (b : β) :
103111
(p.bind f b : ℝ≥0∞) = ∑'a, p a * f a b :=

0 commit comments

Comments
 (0)