Skip to content

Commit 81a48f5

Browse files
sgouezelYaelDillies
authored andcommitted
fix
1 parent b64c366 commit 81a48f5

File tree

6 files changed

+109
-76
lines changed

6 files changed

+109
-76
lines changed

PFR/Examples.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ variable (X : Ω → S) (hX : Measurable X) (Y : Ω → T) (hY : Measurable Y) (
119119

120120
/-- $H[X]$ is the Shannon entropy of $X$. -/
121121
example : H[X] =
122-
- ∑ x, ((ℙ : Measure Ω).map X {x}).toReal * Real.log ((ℙ : Measure Ω).map X {x}).toReal := by
122+
- ∑ x, ((ℙ : Measure Ω).map X).real {x} * Real.log (((ℙ : Measure Ω).map X).real {x}) := by
123123
rw [entropy_eq_sum ℙ, ← Finset.sum_neg_distrib, tsum_eq_sum]
124124
· congr with x
125125
unfold Real.negMulLog

PFR/ImprovedPFR.lean

+8-6
Original file line numberDiff line numberDiff line change
@@ -133,38 +133,40 @@ lemma gen_ineq_aux2 :
133133
ext p; simp
134134
rw [this]
135135
have J : IndepFun (Z₁ + Z₃) (Z₂ + Z₄) := by exact I.comp measurable_add measurable_add
136-
rw [J.measureReal_inter_preimage_eq_mul (.singleton x) (.singleton y), ENNReal.toReal_mul]
137-
rcases eq_or_ne (ℙ ((Z₁ + Z₃) ⁻¹' {x})) 0 with h1|h1
136+
rw [J.measureReal_inter_preimage_eq_mul (.singleton x) (.singleton y)]
137+
rcases eq_or_ne (Measure.real ℙ ((Z₁ + Z₃) ⁻¹' {x})) 0 with h1|h1
138138
· simp [h1]
139-
rcases eq_or_ne (ℙ ((Z₂ + Z₄) ⁻¹' {y})) 0 with h2|h2
139+
rcases eq_or_ne (Measure.real ℙ ((Z₂ + Z₄) ⁻¹' {y})) 0 with h2|h2
140140
· simp [h2]
141141
congr 1
142142
have A : IdentDistrib Z₁ Z₁ (ℙ[|(Z₁ + Z₃) ⁻¹' {x} ∩ (Z₂ + Z₄) ⁻¹' {y}])
143143
(ℙ[|(Z₁ + Z₃) ⁻¹' {x}]) := by
144144
rw [← cond_cond_eq_cond_inter']
145-
have : IsProbabilityMeasure (ℙ[|(Z₁ + Z₃) ⁻¹' {x}]) := cond_isProbabilityMeasure h1
145+
have : IsProbabilityMeasure (ℙ[|(Z₁ + Z₃) ⁻¹' {x}]) := cond_isProbabilityMeasure_of_real h1
146146
apply (IndepFun.identDistrib_cond _ (.singleton _) hZ₁ (by fun_prop) _).symm
147147
· have : IndepFun (⟨Z₁, Z₃⟩) (⟨Z₂, Z₄⟩) (ℙ[|(⟨Z₁, Z₃⟩) ⁻¹' {p | p.1 + p.2 = x}]) :=
148148
I.cond_left (measurable_add (.singleton x))
149149
(hZ₁.prodMk hZ₃)
150150
exact this.comp measurable_fst measurable_add
151151
· rw [cond_apply, J.measure_inter_preimage_eq_mul _ _ (.singleton x) (.singleton y)]
152-
simp [h1, h2]
152+
· simp only [ne_eq, measure_ne_top, not_false_eq_true, measureReal_eq_zero_iff] at h1 h2
153+
simp [h1, h2]
153154
· exact hZ₁.add hZ₃ (.singleton _)
154155
· exact hZ₁.add hZ₃ (.singleton _)
155156
· exact hZ₂.add hZ₄ (.singleton _)
156157
· finiteness
157158
have B : IdentDistrib Z₂ Z₂ (ℙ[|(Z₁ + Z₃) ⁻¹' {x} ∩ (Z₂ + Z₄) ⁻¹' {y}])
158159
(ℙ[|(Z₂ + Z₄) ⁻¹' {y}]) := by
159160
rw [Set.inter_comm, ← cond_cond_eq_cond_inter']
160-
have : IsProbabilityMeasure (ℙ[|(Z₂ + Z₄) ⁻¹' {y}]) := cond_isProbabilityMeasure h2
161+
have : IsProbabilityMeasure (ℙ[|(Z₂ + Z₄) ⁻¹' {y}]) := cond_isProbabilityMeasure_of_real h2
161162
apply (IndepFun.identDistrib_cond _ (.singleton _) hZ₂ (hZ₁.add hZ₃) _).symm
162163
· have : IndepFun (⟨Z₂, Z₄⟩) (⟨Z₁, Z₃⟩) (ℙ[|(⟨Z₂, Z₄⟩) ⁻¹' {p | p.1 + p.2 = y}]) :=
163164
I.symm.cond_left (measurable_add (.singleton y))
164165
(hZ₂.prodMk hZ₄)
165166
exact this.comp measurable_fst measurable_add
166167
· rw [Pi.add_def, cond_apply (hZ₂.add hZ₄ (.singleton y)), ← Pi.add_def, ← Pi.add_def,
167168
J.symm.measure_inter_preimage_eq_mul _ _ (.singleton _) (.singleton _)]
169+
simp only [ne_eq, measure_ne_top, not_false_eq_true, measureReal_eq_zero_iff] at h1 h2
168170
simp [h1, h2]
169171
· exact hZ₂.add hZ₄ (.singleton _)
170172
· exact hZ₁.add hZ₃ (.singleton _)

PFR/Kullback.lean

+11-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ lemma KLDiv_eq_zero_iff_identDistrib [Fintype G] [MeasurableSingletonClass G]
115115
and ${\bf P}(X=x) = \sum_{s\in S} w_s {\bf P}(X_s=x)$, ${\bf P}(Y=x) =
116116
\sum_{s\in S} w_s {\bf P}(Y_s=x)$ for all $x$, then
117117
$$D_{KL}(X\Vert Y) \le \sum_{s\in S} w_s D_{KL}(X_s\Vert Y_s).$$ -/
118-
lemma KLDiv_of_convex [Fintype G] [IsFiniteMeasure μ''']
118+
lemma KLDiv_of_convex [Fintype G]
119119
{ι : Type*} {S : Finset ι} {w : ι → ℝ} (hw : ∀ s ∈ S, 0 ≤ w s)
120120
(X' : ι → Ω'' → G) (Y' : ι → Ω''' → G)
121121
(hconvex : ∀ x, (μ.map X).real {x} = ∑ s ∈ S, w s * (μ''.map (X' s)).real {x})
@@ -244,6 +244,16 @@ lemma ProbabilityTheory.IndepFun.map_add_singleton_eq_sum
244244
simp
245245
abel
246246

247+
lemma ProbabilityTheory.IndepFun.real_map_add_eq_sum [IsFiniteMeasure μ]
248+
[Fintype G] [AddCommGroup G] [DiscreteMeasurableSpace G]
249+
{X Z : Ω → G} (h_indep : IndepFun X Z μ)
250+
(hX : Measurable X) (hZ : Measurable Z) (S : Set G) :
251+
(μ.map (X + Z)).real S = ∑ s, (μ.map Z).real {s} * (μ.map X).real ({-s} + S) := by
252+
rw [measureReal_def, h_indep.map_add_eq_sum hX hZ, ENNReal.toReal_sum (by finiteness)]
253+
congr with s
254+
simp only [singleton_add, image_add_left, neg_neg, ENNReal.toReal_mul]
255+
rfl
256+
247257
lemma ProbabilityTheory.IndepFun.real_map_add_singleton_eq_sum
248258
[Fintype G] [AddCommGroup G] [DiscreteMeasurableSpace G] [IsFiniteMeasure μ]
249259
{X Z : Ω → G} (h_indep : IndepFun X Z μ)

PFR/Mathlib/Probability/UniformOn.lean

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Mathlib.Probability.UniformOn
2+
import Mathlib.MeasureTheory.Measure.Real
23

34
open Function MeasureTheory Measure
45

@@ -13,9 +14,17 @@ lemma uniformOn_apply_singleton_of_mem (hx : x ∈ s) (hs : s.Finite) :
1314
this, Measure.count_singleton', smul_eq_mul, mul_one, one_div, inv_inj]
1415
rw [Measure.count_apply_finite _ hs, Nat.card_eq_card_finite_toFinset hs]
1516

17+
lemma real_uniformOn_apply_singleton_of_mem (hx : x ∈ s) (hs : s.Finite) :
18+
(uniformOn s).real {x} = 1 / Nat.card s := by
19+
simp [measureReal_def, uniformOn_apply_singleton_of_mem hx hs]
20+
1621
lemma uniformOn_apply_singleton_of_not_mem (hx : x ∉ s) : uniformOn s {x} = 0 := by
1722
simp [uniformOn, cond, hx]
1823

24+
lemma real_uniformOn_apply_singleton_of_not_mem (hx : x ∉ s) :
25+
(uniformOn s).real {x} = 0 := by
26+
simp [measureReal_def, uniformOn_apply_singleton_of_not_mem hx]
27+
1928
theorem uniformOn_apply_eq_zero (hst : s ∩ t = ∅) : uniformOn s t = 0 := by
2029
rcases Set.finite_or_infinite s with hs | hs
2130
· exact (uniformOn_eq_zero_iff hs).mpr hst

0 commit comments

Comments
 (0)