File size: 8,791 Bytes
a2ee19a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import Mathlib
import OAI.Probability.GaussianRegression.Main
import OAI.Probability.MemoryPrecision.FiniteDensity

namespace OAI

open MeasureTheory ProbabilityTheory Set Filter EuclideanGeometry
open scoped ENNReal NNReal RealInnerProductSpace Topology Pointwise

noncomputable section
universe u v


open MeasureTheory ProbabilityTheory Set Filter
open scoped ENNReal NNReal RealInnerProductSpace Topology Pointwise
namespace MemoryPrecision

section TestTransfer
variable {X : Type*} [mX : MeasurableSpace X]

lemma original_le_completion (ν : Measure X) :
    mX ≤ (inferInstance : MeasurableSpace (NullMeasurableSpace X ν)) :=
  fun _ hs => hs.nullMeasurableSet

lemma trim_completion (ν : Measure X) :
    ν.completion.trim (original_le_completion ν) = ν := by
  unfold NullMeasurableSpace at *
  apply Measure.ext
  intro S hS
  exact trim_measurableSet_eq (original_le_completion ν) hS

lemma lintegral_completion (ν : Measure X) {f : X → ℝ≥0∞} (hf : AEMeasurable f ν) :
    (∫⁻ x, f x ∂ν.completion) = ∫⁻ x, f x ∂ν := by
  have ht : @Measure.trim X mX (inferInstance : MeasurableSpace (NullMeasurableSpace X ν))
      ν.completion (original_le_completion ν) = ν := trim_completion ν
  have h := lintegral_trim_ae (α := X) (μ := ν.completion) (original_le_completion ν)
    (f := f) (by rwa [ht])
  rw [ht] at h
  exact h.symm

lemma eLpNorm_completion (ν : Measure X) (F : X → ℝ) (hF : Measurable F) (p : ℕ)
    (hp : p ≠ 0) : eLpNorm F (p:ℝ≥0∞) ν.completion = eLpNorm F (p:ℝ≥0∞) ν := by
  have hFc : @Measurable (NullMeasurableSpace X ν) ℝ _ _ F :=
    hF.mono (original_le_completion ν) le_rfl
  erw [eLpNorm_eq_lintegral_rpow_enorm_toReal (by exact_mod_cast hp) (by finiteness)
      hFc.aestronglyMeasurable,
    eLpNorm_eq_lintegral_rpow_enorm_toReal (by exact_mod_cast hp) (by finiteness)
      hF.aestronglyMeasurable,
    lintegral_completion ν (by fun_prop)]

lemma density_test_bound (ν : Measure X) (F : X → ℝ) (hF : Measurable F)
    (hF0 : ∀ x, 0 ≤ F x) (p : ℕ) (hp : 2 ≤ p) (B : ℝ≥0∞)
    (hnorm : eLpNorm F (p:ℝ≥0∞) ν ≤ B) (S : Set X) (hS : MeasurableSet S)
    (hsupp : ∀ᵐ x ∂ν, x ∉ S → F x = 0)
    (φ : X → ℝ≥0∞) (hφ : AEMeasurable φ ν) (hφ1 : ∀ x, φ x ≤ 1) :
    (∫⁻ x, φ x ∂ν.withDensity (fun x => ENNReal.ofReal (F x))) ≤
      B * (∫⁻ x in S, φ x ∂ν)^(1-1/(p:ℝ)) := by
  have hp' : 1 < (p:ℝ) := by exact_mod_cast (by omega : 1 < p)
  have hpq := Real.HolderConjugate.conjExponent hp'
  have hq : 1 / Real.conjExponent (p:ℝ) = 1-1/(p:ℝ) := by
    simpa only [one_div] using (eq_sub_of_add_eq' hpq.inv_add_inv_eq_one)
  let K := S.indicator φ
  have hK : AEMeasurable K ν := hφ.indicator hS
  have hK1 : ∀ x, K x ≤ 1 := by
    intro x
    exact (Set.indicator_le (g := fun _ => 1) (fun _ _ => hφ1 _)) x
  rw [lintegral_withDensity_eq_lintegral_mul₀ (hF.ennreal_ofReal.aemeasurable) hφ]
  have he : (fun x => ENNReal.ofReal (F x) * φ x) =ᵐ[ν]
      (fun x => ENNReal.ofReal (F x) * K x) := by
    filter_upwards [hsupp] with x hx
    by_cases hxS : x ∈ S
    · simp [K, Set.indicator_of_mem hxS]
    · simp [K, Set.indicator_of_notMem hxS, hx hxS]
  simp only [Pi.mul_apply]
  rw [lintegral_congr_ae he]
  have hholder := ENNReal.lintegral_mul_le_Lp_mul_Lq ν hpq hF.ennreal_ofReal.aemeasurable hK
  have hnormeq : (∫⁻ x, ENNReal.ofReal (F x) ^ (p:ℝ) ∂ν) ^ (1/(p:ℝ)) =
      eLpNorm F (p:ℝ≥0∞) ν := by
    rw [eLpNorm_eq_lintegral_rpow_enorm_toReal (by exact_mod_cast (by omega : p ≠ 0))
      (by finiteness) hF.aestronglyMeasurable]
    simp only [ENNReal.toReal_natCast, Real.enorm_eq_ofReal (hF0 _)]
  rw [hnormeq, hq] at hholder
  refine hholder.trans (mul_le_mul' hnorm ?_)
  apply ENNReal.rpow_le_rpow _ (by rw [← hq]; exact hpq.symm.one_div_nonneg)
  calc
    (∫⁻ x, K x ^ Real.conjExponent (p:ℝ) ∂ν) ≤ ∫⁻ x, K x ∂ν :=
      lintegral_mono (fun x => ENNReal.rpow_le_self_of_le_one (hK1 x) hpq.symm.lt.le)
    _ = _ := lintegral_indicator hS _

lemma density_set_bound (ν : Measure X) (F : X → ℝ) (hF : Measurable F)
    (hF0 : ∀ x, 0 ≤ F x) (p : ℕ) (hp : 2 ≤ p) (B : ℝ≥0∞)
    (hnorm : eLpNorm F (p:ℝ≥0∞) ν ≤ B) (E : Set X) (hE : MeasurableSet E) :
    ν.withDensity (fun x => ENNReal.ofReal (F x)) E ≤ B * (ν E)^(1-1/(p:ℝ)) := by
  have h := density_test_bound ν F hF hF0 p hp B hnorm Set.univ MeasurableSet.univ
    (by simp) (E.indicator 1) (measurable_one.indicator hE).aemeasurable
    (fun x => (Set.indicator_le (g := fun _ => (1:ℝ≥0∞)) (fun _ _ => le_rfl)) x)
  simpa only [lintegral_indicator hE, Measure.restrict_apply_univ,
    setLIntegral_const, Pi.one_apply, one_mul, Measure.restrict_univ] using h

lemma withDensity_completion_apply (ν : Measure X) (F : X → ℝ) (hF : Measurable F)
    (E : Set X) (hE : NullMeasurableSet E ν) :
    ν.completion.withDensity (fun x => ENNReal.ofReal (F x)) E =
      ν.withDensity (fun x => ENNReal.ofReal (F x)) E := by
  erw [withDensity_apply _ hE, withDensity_apply₀ _ hE,
    ← lintegral_indicator hE, ← lintegral_indicator₀ hE,
    lintegral_completion ν (hF.ennreal_ofReal.aemeasurable.indicator₀ hE)]
end TestTransfer

def MeasurableTestStatement : Prop :=
  let two : ℝ := @OfNat.ofNat ℝ 2 (@instOfNatAtLeastTwo ℝ 2 Real.commRing.toNatCast
    (Mathlib.Meta.NormNum.instAtLeastTwo (nat_lit 0)))
  let exponent : ℝ≥0∞ := @OfNat.ofNat ℝ≥0∞ 2
    (@instOfNatAtLeastTwo ℝ≥0∞ 2 ENNReal.instAddCommMonoidWithOne.toNatCast
      (Mathlib.Meta.NormNum.instAtLeastTwo (nat_lit 0)))
  ∀ d m p : ℕ,
  letI : MeasurableSpace (Space d) := WithLp.measurableSpace exponent (Fin d → ℝ)
  1 ≤ d → 1 ≤ m → 2 ≤ p →
  ∀ β H R : ℝ, (m : ℝ)+(p : ℝ)-two < β → 0 < H → 0 < R →
  ∀ z : Space d, ∀ μ : Measure (Space d), IsFiniteMeasure μ →
    @Measure.support (Space d)
      (PiLp.topologicalSpace (p := exponent) (β := fun _ : Fin d => ℝ))
      (WithLp.measurableSpace exponent (Fin d → ℝ)) μ ⊆
      @Metric.closedBall (Space d)
        (PiLp.instPseudoMetricSpace (p := exponent) (β := fun _ : Fin d => ℝ)) z R →
    AmbientBallBound μ H β →
    let ν := MatrixLabelReference d m
    let η := ProjectionLaw μ m
    let B := ENNReal.ofReal (ProjectionNormScale m p H β R)
    let α := 1-1/(p:ℝ)
    (∀ E, MeasurableSet E → ν E ≠ ∞ → η E ≤ B * (ν E)^α) ∧
    η ≪ ν ∧
    ∃ ηc : Measure (NullMeasurableSpace ((Fin m → Space d) × (Fin m → ℝ)) ν),
      (∀ E, NullMeasurableSet E ν → ηc E = η E) ∧
      (∀ E, NullMeasurableSet E ν → ν.completion E ≠ ∞ →
        ηc E ≤ B * (ν.completion E)^α) ∧
      (∀ φ : NullMeasurableSpace ((Fin m → Space d) × (Fin m → ℝ)) ν → ℝ≥0∞,
        Measurable φ → (∀ x, φ x ≤ 1) →
        (∫⁻ x, φ x ∂ηc) ≤ B * (∫⁻ x in ProjectedEllipsoid z R, φ x ∂ν.completion)^α)
theorem measurable_test : MeasurableTestStatement := by
  intro d m p hd hm hp β H R hgap hH hR z μ hμ hs hb
  let := hμ
  obtain ⟨F, hF, hF0, hden, hsupp, hnorm⟩ :=
    exact_finite_density d m p hp hm β H R hgap hH hR z μ hs hb
  dsimp only
  let ν := MatrixLabelReference d m
  let B := ENNReal.ofReal (ProjectionNormScale m p H β R)
  refine ⟨?_, ?_, ?_⟩
  · intro E hE _
    rw [← hden]
    exact density_set_bound ν F hF hF0 p hp B hnorm E hE
  · rw [← hden]
    exact withDensity_absolutelyContinuous _ _
  · let ηc := ν.completion.withDensity (fun x => ENNReal.ofReal (F x))
    refine ⟨ηc, ?_, ?_, ?_⟩
    · intro E hE
      calc
        ηc E = ν.withDensity (fun x => ENNReal.ofReal (F x)) E :=
          withDensity_completion_apply ν F hF E hE
        _ = ProjectionLaw μ m E := congrArg (fun q => q E) hden
    · intro E hE _
      have hFc : @Measurable (NullMeasurableSpace _ ν) ℝ _ _ F :=
        hF.mono (original_le_completion ν) le_rfl
      have hnormc : eLpNorm F (p:ℝ≥0∞) ν.completion ≤ B := by
        erw [eLpNorm_completion ν F hF p (by omega)]
        exact hnorm
      exact density_set_bound ν.completion F hFc hF0 p hp B hnormc E hE
    · intro φ hφ hφ1
      have hFc : @Measurable (NullMeasurableSpace _ ν) ℝ _ _ F :=
        hF.mono (original_le_completion ν) le_rfl
      have hnormc : eLpNorm F (p:ℝ≥0∞) ν.completion ≤ B := by
        erw [eLpNorm_completion ν F hF p (by omega)]
        exact hnorm
      exact density_test_bound ν.completion F hFc hF0 p hp B hnormc
        (ProjectedEllipsoid z R) (isClosed_projectedEllipsoid z R).measurableSet.nullMeasurableSet
        hsupp φ hφ.aemeasurable hφ1
end MemoryPrecision


end

end OAI