|
| 1 | +/- |
| 2 | +Copyright (c) 2019 Johannes Hölzl. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Johannes Hölzl |
| 5 | +
|
| 6 | +Giry monad: `measure` is a monad in the category of `measurable_space` and `measurable` functions. |
| 7 | +-/ |
| 8 | +import measure_theory.integration data.sum |
| 9 | +noncomputable theory |
| 10 | +local attribute [instance, priority 0] classical.prop_decidable |
| 11 | + |
| 12 | +open classical set lattice filter |
| 13 | + |
| 14 | +variables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} {ε : Type*} |
| 15 | + |
| 16 | +namespace measure_theory |
| 17 | + |
| 18 | +namespace measure |
| 19 | + |
| 20 | +variables [measurable_space α] [measurable_space β] |
| 21 | + |
| 22 | +/-- Measurability structure on `measure`: Measures are measurable w.r.t. all projections -/ |
| 23 | +instance : measurable_space (measure α) := |
| 24 | +⨆ (s : set α) (hs : is_measurable s), (borel ennreal).comap (λμ, μ s) |
| 25 | + |
| 26 | +lemma measurable_coe {s : set α} (hs : is_measurable s) : measurable (λμ : measure α, μ s) := |
| 27 | +measurable_space.comap_le_iff_le_map.1 $ le_supr_of_le s $ le_supr_of_le hs $ le_refl _ |
| 28 | + |
| 29 | +lemma measurable_of_measurable_coe (f : β → measure α) |
| 30 | + (h : ∀(s : set α) (hs : is_measurable s), measurable (λb, f b s)) : |
| 31 | + measurable f := |
| 32 | +supr_le $ assume s, supr_le $ assume hs, measurable_space.comap_le_iff_le_map.2 $ |
| 33 | + by rw [measurable_space.map_comp]; exact h s hs |
| 34 | + |
| 35 | +lemma measurable_map (f : α → β) (hf : measurable f) : |
| 36 | + measurable (λμ : measure α, μ.map f) := |
| 37 | +measurable_of_measurable_coe _ $ assume s hs, |
| 38 | + suffices measurable (λ (μ : measure α), μ (f ⁻¹' s)), |
| 39 | + by simpa [map_apply, hs, hf], |
| 40 | + measurable_coe (hf.preimage hs) |
| 41 | + |
| 42 | +lemma measurable_dirac : |
| 43 | + measurable (measure.dirac : α → measure α) := |
| 44 | +measurable_of_measurable_coe _ $ assume s hs, |
| 45 | + begin |
| 46 | + simp [hs, lattice.supr_eq_if], |
| 47 | + exact measurable_const.if hs measurable_const |
| 48 | + end |
| 49 | + |
| 50 | +lemma measurable_integral (f : α → ennreal) (hf : measurable f) : |
| 51 | + measurable (λμ : measure α, μ.integral f) := |
| 52 | +suffices measurable (λμ : measure α, |
| 53 | + (⨆n:ℕ, @simple_func.integral α { μ := μ } (simple_func.eapprox f n)) : _ → ennreal), |
| 54 | +begin |
| 55 | + convert this, |
| 56 | + funext μ, |
| 57 | + exact @lintegral_eq_supr_eapprox_integral α {μ := μ} f hf |
| 58 | +end, |
| 59 | +measurable.supr $ assume n, |
| 60 | + begin |
| 61 | + dunfold simple_func.integral, |
| 62 | + refine measurable_finset_sum (simple_func.eapprox f n).range _, |
| 63 | + assume i, |
| 64 | + refine ennreal.measurable_mul measurable_const _, |
| 65 | + exact measurable_coe ((simple_func.eapprox f n).preimage_measurable _) |
| 66 | + end |
| 67 | + |
| 68 | +/-- Monadic join on `measure` in the category of measurable spaces and measurable |
| 69 | +functions. -/ |
| 70 | +def join (m : measure (measure α)) : measure α := |
| 71 | +measure.of_measurable |
| 72 | + (λs hs, m.integral (λμ, μ s)) |
| 73 | + (by simp [integral]) |
| 74 | + begin |
| 75 | + assume f hf h, |
| 76 | + simp [measure_Union h hf], |
| 77 | + apply lintegral_tsum, |
| 78 | + assume i, exact measurable_coe (hf i) |
| 79 | + end |
| 80 | + |
| 81 | +@[simp] lemma join_apply {m : measure (measure α)} : |
| 82 | + ∀{s : set α}, is_measurable s → join m s = m.integral (λμ, μ s) := |
| 83 | +measure.of_measurable_apply |
| 84 | + |
| 85 | +lemma measurable_join : measurable (join : measure (measure α) → measure α) := |
| 86 | +measurable_of_measurable_coe _ $ assume s hs, |
| 87 | + by simp [hs]; exact measurable_integral _ (measurable_coe hs) |
| 88 | + |
| 89 | +lemma integral_join {m : measure (measure α)} {f : α → ennreal} (hf : measurable f) : |
| 90 | + integral (join m) f = integral m (λμ, integral μ f) := |
| 91 | +begin |
| 92 | + transitivity, |
| 93 | + apply lintegral_eq_supr_eapprox_integral, |
| 94 | + { exact hf }, |
| 95 | + have : ∀n x, |
| 96 | + @volume α { μ := join m} (⇑(simple_func.eapprox (λ (a : α), f a) n) ⁻¹' {x}) = |
| 97 | + m.integral (λμ, @volume α { μ := μ } ((⇑(simple_func.eapprox (λ (a : α), f a) n) ⁻¹' {x}))) := |
| 98 | + assume n x, join_apply (simple_func.measurable_sn _ _), |
| 99 | + conv { |
| 100 | + to_lhs, |
| 101 | + congr, |
| 102 | + funext, |
| 103 | + rw [simple_func.integral] }, |
| 104 | + simp [this], |
| 105 | + transitivity, |
| 106 | + have : ∀(s : ℕ → finset ennreal) (f : ℕ → ennreal → measure α → ennreal) |
| 107 | + (hf : ∀n r, measurable (f n r)) (hm : monotone (λn μ, (s n).sum (λ r, r * f n r μ))), |
| 108 | + (⨆n:ℕ, (s n).sum (λr, r * integral m (f n r))) = |
| 109 | + integral m (λμ, ⨆n:ℕ, (s n).sum (λr, r * f n r μ)), |
| 110 | + { assume s f hf hm, |
| 111 | + symmetry, |
| 112 | + transitivity, |
| 113 | + apply lintegral_supr, |
| 114 | + { exact assume n, |
| 115 | + measurable_finset_sum _ (assume r, ennreal.measurable_mul measurable_const (hf _ _)) }, |
| 116 | + { exact hm }, |
| 117 | + congr, funext n, |
| 118 | + transitivity, |
| 119 | + apply lintegral_finset_sum, |
| 120 | + { exact assume r, ennreal.measurable_mul measurable_const (hf _ _) }, |
| 121 | + congr, funext r, |
| 122 | + apply lintegral_const_mul, |
| 123 | + exact hf _ _ }, |
| 124 | + specialize this (λn, simple_func.range (simple_func.eapprox f n)), |
| 125 | + specialize this |
| 126 | + (λn r μ, @volume α { μ := μ } (⇑(simple_func.eapprox (λ (a : α), f a) n) ⁻¹' {r})), |
| 127 | + refine this _ _; clear this, |
| 128 | + { assume n r, |
| 129 | + apply measurable_coe, |
| 130 | + exact simple_func.measurable_sn _ _ }, |
| 131 | + { change monotone (λn μ, @simple_func.integral α {μ := μ} (simple_func.eapprox f n)), |
| 132 | + assume n m h μ, |
| 133 | + apply simple_func.integral_le_integral, |
| 134 | + apply simple_func.monotone_eapprox, |
| 135 | + assumption }, |
| 136 | + congr, funext μ, |
| 137 | + symmetry, |
| 138 | + apply lintegral_eq_supr_eapprox_integral, |
| 139 | + exact hf |
| 140 | +end |
| 141 | + |
| 142 | +/-- Monadic bind on `measure`, only works in the category of measurable spaces and measurable |
| 143 | +functions. When the function `f` is not measurable the result is not well defined. -/ |
| 144 | +def bind (m : measure α) (f : α → measure β) : measure β := join (map f m) |
| 145 | + |
| 146 | +@[simp] lemma bind_apply {m : measure α} {f : α → measure β} {s : set β} |
| 147 | + (hs : is_measurable s) (hf : measurable f) : bind m f s = m.integral (λa, f a s) := |
| 148 | +by rw [bind, join_apply hs, integral_map (measurable_coe hs) hf] |
| 149 | + |
| 150 | +lemma measurable_bind' {g : α → measure β} (hg : measurable g) : measurable (λm, bind m g) := |
| 151 | +measurable.comp (measurable_map _ hg) measurable_join |
| 152 | + |
| 153 | +lemma integral_bind {m : measure α} {g : α → measure β} {f : β → ennreal} |
| 154 | + (hg : measurable g) (hf : measurable f) : |
| 155 | + integral (bind m g) f = integral m (λa, integral (g a) f) := |
| 156 | +begin |
| 157 | + transitivity, |
| 158 | + exact integral_join hf, |
| 159 | + exact integral_map (measurable_integral _ hf) hg |
| 160 | +end |
| 161 | + |
| 162 | +lemma bind_bind {γ} [measurable_space γ] {m : measure α} {f : α → measure β} {g : β → measure γ} |
| 163 | + (hf : measurable f) (hg : measurable g) : |
| 164 | + bind (bind m f) g = bind m (λa, bind (f a) g) := |
| 165 | +measure.ext $ assume s hs, |
| 166 | +begin |
| 167 | + rw [bind_apply hs hg, bind_apply hs (hf.comp $ measurable_bind' hg), integral_bind hf], |
| 168 | + { congr, funext a, |
| 169 | + exact (bind_apply hs hg).symm }, |
| 170 | + exact hg.comp (measurable_coe hs) |
| 171 | +end |
| 172 | + |
| 173 | +lemma bind_dirac {f : α → measure β} (hf : measurable f) (a : α) : bind (dirac a) f = f a := |
| 174 | +measure.ext $ assume s hs, by rw [bind_apply hs hf, integral_dirac a (hf.comp (measurable_coe hs))] |
| 175 | + |
| 176 | +lemma dirac_bind {m : measure α} : bind m dirac = m := |
| 177 | +measure.ext $ assume s hs, |
| 178 | +begin |
| 179 | + rw [bind_apply hs measurable_dirac], |
| 180 | + simp [dirac_apply _ hs], |
| 181 | + transitivity, |
| 182 | + apply lintegral_supr_const, |
| 183 | + assumption, |
| 184 | + exact one_mul _ |
| 185 | +end |
| 186 | + |
| 187 | +end measure |
| 188 | + |
| 189 | +end measure_theory |
0 commit comments