File size: 6,784 Bytes
f61e547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Probability.FreeIsing.Brownian.Bridge
import OAI.Probability.FreeIsing.Gaussian.IncrementLikelihood

namespace OAI

noncomputable section

open MeasureTheory ProbabilityTheory
open scoped ENNReal NNReal

namespace Problem367

theorem preBrownian_past_drift_withDensity
    {Omega : Type*} [MeasurableSpace Omega]
    {B : ℝ≥0 → Omega → ℝ} {mu : Measure Omega}
    (hB : IsPreBrownianReal B mu) (hmB : ∀ t, Measurable (B t))
    {T : ℝ≥0} (hT : T ≠ 0) (s : ℝ) :
    Measure.map (fun w (t : Set.Iic T) => (t.val : ℝ) * s + B t w) mu =
      (Measure.map (fun w (t : Set.Iic T) => B t w) mu).withDensity
        (fun y : Set.Iic T → ℝ => ENNReal.ofReal
          (gaussianSignalLikelihood T s (y ⟨T, by simp⟩))) := by
  let : IsProbabilityMeasure mu := hB.isGaussianProcess.isProbabilityMeasure
  let R : Omega → Set.Iic T → ℝ := fun w t => brownianBridge B T t w
  let E : Omega → (Set.Iic T → ℝ) × ℝ := fun w => (R w, B T w)
  let Es : Omega → (Set.Iic T → ℝ) × ℝ :=
    fun w => (R w, (T : ℝ) * s + B T w)
  let F : ((Set.Iic T → ℝ) × ℝ) → Set.Iic T → ℝ :=
    fun z t => z.1 t + ((t.val : ℝ) / (T : ℝ)) * z.2
  let L : ℝ → ℝ≥0∞ := fun x => ENNReal.ofReal (gaussianSignalLikelihood T s x)
  have hR : Measurable R := by
    apply Measurable.of_eval
    intro t
    exact (hmB t).sub ((hmB T).const_mul _)
  have hE : Measurable E := hR.prodMk (hmB T)
  have hEs : Measurable Es := hR.prodMk (measurable_const.add (hmB T))
  have hF : Measurable F := by unfold F; fun_prop
  have hL : Measurable L := by unfold L gaussianSignalLikelihood; fun_prop
  have hind : IndepFun R (B T) mu := preBrownian_bridge_indep_terminal hB hT
  have hlaw : Measure.map E mu = (Measure.map R mu).prod (gaussianReal 0 T) := by
    rw [IndepFun.map_prod_eq_prod_map_map hR.aemeasurable (hmB T).aemeasurable hind,
      (hB.hasLaw_eval T).map_eq]
  have hlaws : Measure.map Es mu =
      (Measure.map R mu).prod (gaussianReal ((T : ℝ) * s) T) := by
    have hshift : Measurable (fun x : ℝ => (T : ℝ) * s + x) := by fun_prop
    have hbt : Measurable (fun w => (T : ℝ) * s + B T w) := by fun_prop
    have hinds : IndepFun R (fun w => (T : ℝ) * s + B T w) mu := by
      simpa only [Function.comp_def, id_eq] using
        hind.comp measurable_id hshift
    change Measure.map (fun w => (R w, (T : ℝ) * s + B T w)) mu = _
    rw [IndepFun.map_prod_eq_prod_map_map hR.aemeasurable
      hbt.aemeasurable hinds]
    congr 1
    simpa only [zero_add] using
      (gaussianReal_const_add (hB.hasLaw_eval T) ((T : ℝ) * s)).map_eq
  have hchange : Measure.map Es mu =
      (Measure.map E mu).withDensity (fun z => L z.2) := by
    rw [hlaws, hlaw, gaussianReal_signal_withDensity T s]
    exact prod_withDensity_right hL
  have hFE : F ∘ E = fun w (t : Set.Iic T) => B t w := by
    funext w t
    dsimp [F, E, R, brownianBridge]
    ring
  have hFEs : F ∘ Es = fun w (t : Set.Iic T) => (t.val : ℝ) * s + B t w := by
    have hT' : (T : ℝ) ≠ 0 := by exact_mod_cast hT
    funext w t
    dsimp [F, Es, R, brownianBridge]
    field_simp
    ring
  have hpast : Measurable (fun w (t : Set.Iic T) => B t w) :=
    Measurable.of_eval (fun t => hmB t)
  calc
    Measure.map (fun w (t : Set.Iic T) => (t.val : ℝ) * s + B t w) mu =
        Measure.map F (Measure.map Es mu) := by rw [Measure.map_map hF hEs, hFEs]
    _ = Measure.map F ((Measure.map E mu).withDensity (fun z => L z.2)) := by
      rw [hchange]
    _ = Measure.map F (Measure.map E (mu.withDensity (fun w => L (B T w)))) := by
      congr 1
      exact (map_withDensity_comp_observation mu E hE (fun z => L z.2)
        (hL.comp measurable_snd)).symm
    _ = Measure.map (fun w (t : Set.Iic T) => B t w)
        (mu.withDensity (fun w => L (B T w))) := by rw [Measure.map_map hF hE, hFE]
    _ = _ := map_withDensity_comp_observation mu _ hpast
      (fun y : Set.Iic T → ℝ => L (y ⟨T, by simp⟩)) (hL.comp (measurable_pi_apply _))

theorem preBrownian_past_vector_drift_withDensity
    {Omega V : Type*} [MeasurableSpace Omega] [Fintype V]
    {B : ℝ≥0 → Omega → ℝ} {mu : Measure Omega}
    (hB : IsPreBrownianReal B mu) (hmB : ∀ t, Measurable (B t))
    {T : ℝ≥0} (hT : T ≠ 0) (s : V → ℝ) :
    Measure.pi (fun v : V =>
      Measure.map (fun w (t : Set.Iic T) => (t.val : ℝ) * s v + B t w) mu) =
      (Measure.pi (fun _ : V =>
        Measure.map (fun w (t : Set.Iic T) => B t w) mu)).withDensity
        (fun y => ENNReal.ofReal
          (gaussianVectorLikelihood T s (fun v => y v ⟨T, by simp⟩))) := by
  classical
  let : IsProbabilityMeasure mu := hB.isGaussianProcess.isProbabilityMeasure
  have hpast : Measurable (fun w (t : Set.Iic T) => B t w) :=
    Measurable.of_eval (fun t => hmB t)
  let : IsProbabilityMeasure
      (Measure.map (fun w (t : Set.Iic T) => B t w) mu) :=
    (Measure.isProbabilityMeasure_map_iff hpast.aemeasurable).mpr inferInstance
  have hshift (v : V) :
      Measurable (fun w (t : Set.Iic T) => (t.val : ℝ) * s v + B t w) := by
    apply Measurable.of_eval
    intro t
    exact measurable_const.add (hmB t)
  let (v : V) : IsProbabilityMeasure
      (Measure.map (fun w (t : Set.Iic T) => (t.val : ℝ) * s v + B t w) mu) :=
    (Measure.isProbabilityMeasure_map_iff (hshift v).aemeasurable).mpr inferInstance
  rw [pi_withDensity_of_probability
    (fun _ : V => Measure.map (fun w (t : Set.Iic T) => B t w) mu)
    (fun v : V => Measure.map (fun w (t : Set.Iic T) => (t.val : ℝ) * s v + B t w) mu)
    (fun v (y : Set.Iic T → ℝ) => ENNReal.ofReal
      (gaussianSignalLikelihood T (s v) (y ⟨T, by simp⟩)))
    (fun v => by unfold gaussianSignalLikelihood; fun_prop)
    (fun v => preBrownian_past_drift_withDensity hB hmB hT (s v))]
  apply withDensity_congr_ae
  filter_upwards [] with y
  rw [← ENNReal.ofReal_prod_of_nonneg (fun v hv => by
    unfold gaussianSignalLikelihood; positivity), prod_gaussianSignalLikelihood]

theorem preBrownian_past_spin_drift_withDensity
    {Omega V : Type*} [MeasurableSpace Omega] [Fintype V]
    {B : ℝ≥0 → Omega → ℝ} {mu : Measure Omega}
    (hB : IsPreBrownianReal B mu) (hmB : ∀ t, Measurable (B t))
    {T : ℝ≥0} (hT : T ≠ 0) (s : V → ℝ) (hs : ∀ v, s v ^ 2 = 1) :
    Measure.pi (fun v : V =>
      Measure.map (fun w (t : Set.Iic T) => (t.val : ℝ) * s v + B t w) mu) =
      (Measure.pi (fun _ : V =>
        Measure.map (fun w (t : Set.Iic T) => B t w) mu)).withDensity
        (fun y => ENNReal.ofReal
          (Real.exp ((∑ v, s v * y v ⟨T, by simp⟩) -
            (T : ℝ) * Fintype.card V / 2))) := by
  simpa only [gaussianVectorLikelihood_of_sq_eq_one _ _ _ hs] using
    preBrownian_past_vector_drift_withDensity hB hmB hT s

end Problem367

end

end OAI