math / data /lean /OAI /Probability /ProjectionMoments /StoppingKernel.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
21.8 kB
import OAI.Probability.ProjectionMoments.Realization
namespace OAI
noncomputable section
open MeasureTheory ProbabilityTheory Set Filter
open scoped ENNReal NNReal RealInnerProductSpace
namespace NoiselessRegression
section
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Nontrivial E]
lemma capWeight_mass_mixed (y : E) {Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅) (hΞ΅1 : Ξ΅ ≀ 1)
(a : β„•) {b : ℝ} (hb : 0 ≀ b) (hab : (a:ℝ)+b ≀ (Module.finrank ℝ E-1:β„•)) :
PolynomialMass ((ambientSphereLaw (E := E)).withDensity (capWeight y Ξ΅)) a
(ENNReal.ofReal ((3 : ℝ)*4^Module.finrank ℝ E) * ENNReal.ofReal (Ξ΅^b)) := by
change PolynomialMass ((ambientSphereLaw (E := E)).withDensity ((Metric.closedBall y Ξ΅).indicator 1)) a _
rw [withDensity_indicator_one Metric.isClosed_closedBall.measurableSet]
intro z r hr
rw [Measure.restrict_apply Metric.isClosed_closedBall.measurableSet]
by_cases h : r ≀ Ξ΅
Β· apply (measure_mono Set.inter_subset_left).trans
apply (ambientSphereLaw_closedBall z hr (Module.finrank ℝ E-1) le_rfl).trans
rw [mul_assoc, ← ENNReal.ofReal_mul (Real.rpow_nonneg hΞ΅.le _)]
apply mul_le_mul' le_rfl
apply ENNReal.ofReal_le_ofReal
have hpow : r^(Module.finrank ℝ E-1) ≀ r^((a:ℝ)+b) := by
rw [← Real.rpow_natCast]
exact Real.rpow_le_rpow_of_exponent_ge hr (h.trans hΞ΅1) hab
apply hpow.trans
rw [Real.rpow_add hr,Real.rpow_natCast,mul_comm]
exact mul_le_mul_of_nonneg_right (Real.rpow_le_rpow hr.le h hb) (pow_nonneg hr.le _)
Β· apply (measure_mono Set.inter_subset_right).trans
apply (ambientSphereLaw_closedBall y hΞ΅ (Module.finrank ℝ E-1) le_rfl).trans
rw [mul_assoc, ← ENNReal.ofReal_mul (Real.rpow_nonneg hΞ΅.le _)]
apply mul_le_mul' le_rfl
apply ENNReal.ofReal_le_ofReal
have hpow : Ξ΅^(Module.finrank ℝ E-1) ≀ Ξ΅^((a:ℝ)+b) := by
rw [← Real.rpow_natCast]
exact Real.rpow_le_rpow_of_exponent_ge hΞ΅ hΞ΅1 hab
apply hpow.trans
rw [Real.rpow_add hΞ΅,Real.rpow_natCast,mul_comm]
exact mul_le_mul_of_nonneg_left (pow_le_pow_leftβ‚€ hΞ΅.le (le_of_not_ge h) a) (Real.rpow_nonneg hΞ΅.le _)
variable {J : Type*} [Fintype J] [MeasurableSpace J] [MeasurableSingletonClass J] [Nonempty J]
lemma continuation_mixed_integral_bound {Ξ΄ : β„• β†’ J β†’ (E Γ— ℝ) β†’ J}
(hΞ΄ : βˆ€ n j, Measurable (Ξ΄ n j)) (y : β„• β†’ J β†’ E)
{Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅) (hΞ΅1 : Ξ΅ ≀ 1) {a q : β„•} {b : ℝ}
(hb : 0 ≀ b) (hab : (a:ℝ)+b ≀ (Module.finrank ℝ E-1:β„•))
(hq : 2 ≀ q) (hqa : 2*q ≀ a) (n k : β„•) (j : J) :
(∫⁻ s, continuation Ξ΄ (fun n j => capWeight (y n j) Ξ΅) n k j s βˆ‚ambientSphereLaw) ≀
(ENNReal.ofReal ((3 : ℝ)*4^Module.finrank ℝ E) * ENNReal.ofReal (Ξ΅^b)) *
streamFactor (E := E) (J := J) q ^ ((k+q-1)/q) := by
have ha : a ≀ Module.finrank ℝ E := by
have : (a:ℝ) ≀ (Module.finrank ℝ E:ℝ) := by
have hh : ((Module.finrank ℝ E-1:β„•):ℝ) ≀ Module.finrank ℝ E := by exact_mod_cast Nat.sub_le (Module.finrank ℝ E) 1
linarith
exact_mod_cast this
apply ambient_mass_bound
apply continuation_mass_bound_ceil _ hΞ΄ (fun n j => measurable_capWeight _ _)
(fun n j s => capWeight_le_one _ _ _)
(mul_ne_zero (by positivity) (by positivity)) (ENNReal.mul_ne_top ENNReal.ofReal_ne_top ENNReal.ofReal_ne_top)
(fun n j => capWeight_mass_mixed (y n j) hΞ΅ hΞ΅1 a hb hab)
(Module.finrank_pos (R := ℝ) (M := E)) ha hq hqa
lemma route_mixed_bound {Ξ΄ : β„• β†’ J β†’ (E Γ— ℝ) β†’ J}
(hΞ΄ : βˆ€ n j, Measurable (Ξ΄ n j)) (y : J β†’ E)
{Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅) (hΞ΅1 : Ξ΅ ≀ 1) {a q : β„•} {b : ℝ}
(hb : 0 ≀ b) (hab : (a:ℝ)+b ≀ (Module.finrank ℝ E-1:β„•))
(hq : 2 ≀ q) (hqa : 2*q ≀ a) (k : β„•) (j : J) :
((sphereLaw (E := E)).prod (Measure.pi (fun _ : Fin k => stdGaussian E)))
{z | dist z.1.val (y (streamRoute Ξ΄ 0 k j (z.2,fun i => βŸͺz.1.val,z.2 i⟫))) ≀ Ξ΅} ≀
(ENNReal.ofReal ((3 : ℝ)*4^Module.finrank ℝ E) * ENNReal.ofReal (Ξ΅^b)) *
streamFactor (E := E) (J := J) q ^ ((k+q-1)/q) := by
let w : β„• β†’ J β†’ E β†’ ℝβ‰₯0∞ := fun _ j => capWeight (y j) Ξ΅
have hV := measurable_continuation (w := w) hΞ΄ (fun _ j => measurable_capWeight (y j) Ξ΅) 0 k j
have he (s : E) : continuation Ξ΄ w 0 k j s =
∫⁻ A : Fin k β†’ E, capWeight (y (streamRoute Ξ΄ 0 k j (A,fun i => βŸͺs,A i⟫))) Ξ΅ s
βˆ‚Measure.pi (fun _ => stdGaussian E) := by
simpa [w, blockValue, continuation] using continuation_unroll (w := w) hΞ΄ 0 k 0 j s
let S : Set ((Metric.sphere (0 : E) 1) Γ— (Fin k β†’ E)) :=
{z | dist z.1.val (y (streamRoute Ξ΄ 0 k j (z.2,fun i => βŸͺz.1.val,z.2 i⟫))) ≀ Ξ΅}
have hS : MeasurableSet S := by
apply measurableSet_le _ measurable_const
exact measurable_subtype_coe.comp measurable_fst |>.dist
((measurable_of_finite y).comp ((measurable_streamRoute hΞ΄ 0 k j).comp (by fun_prop)))
change ((sphereLaw (E := E)).prod _) S ≀ _
rw [← one_mul (((sphereLaw (E := E)).prod _) S), ← lintegral_indicator_const hS 1,
lintegral_prod _ (measurable_const.indicator hS).aemeasurable]
have hf : βˆ€ s : Metric.sphere (0 : E) 1,
(∫⁻ A, S.indicator (fun _ => (1 : ℝβ‰₯0∞)) (s,A) βˆ‚Measure.pi (fun _ => stdGaussian E)) =
continuation Ξ΄ w 0 k j s.val := by
intro s
rw [he]
apply lintegral_congr
intro A
classical
change (if dist s.val (y (streamRoute Ξ΄ 0 k j (A,fun i => βŸͺs.val,A i⟫))) ≀ Ξ΅ then 1 else 0) = _
unfold capWeight
rw [Set.indicator_apply]
rfl
simp_rw [hf]
rw [← lintegral_map hV measurable_subtype_coe]
exact continuation_mixed_integral_bound hΞ΄ (fun _ => y) hΞ΅ hΞ΅1 hb hab hq hqa 0 k j
end
namespace Learner
section
variable {d M : β„•}
def haltShift {k : β„•} : TaggedState M k β†’ TaggedState M (k+1)
| .inl j => .inl j
| .inr (t,j) => .inr (t.succ,j)
def haltRoute (Ο„ : β„• β†’ State M β†’ (Vector d Γ— ℝ) β†’ Bool Γ— State M) (n : β„•) :
(k : β„•) β†’ State M β†’ ((Fin k β†’ Vector d) Γ— (Fin k β†’ ℝ)) β†’ TaggedState M k
| 0, j, _ => .inl j
| k+1, j, X =>
let a := Ο„ (n+1) j (X.1 0,X.2 0)
if a.1 then .inr (⟨1,by omega⟩,a.2)
else haltShift (haltRoute Ο„ (n+1) k a.2 (Fin.tail X.1,Fin.tail X.2))
lemma measurable_haltRoute {Ο„ : β„• β†’ State M β†’ (Vector d Γ— ℝ) β†’ Bool Γ— State M}
(hΟ„ : βˆ€ t j, Measurable (Ο„ t j)) (n k : β„•) (j : State M) :
Measurable (haltRoute Ο„ n k j) := by
induction k generalizing n j with
| zero => exact measurable_const
| succ k ih =>
let h : (Bool Γ— State M) β†’ ((Fin (k+1) β†’ Vector d) Γ— (Fin (k+1) β†’ ℝ)) β†’ TaggedState M (k+1) :=
fun a X => if a.1 then .inr (⟨1,by omega⟩,a.2)
else haltShift (haltRoute Ο„ (n+1) k a.2 (Fin.tail X.1,Fin.tail X.2))
change Measurable (fun X => h (Ο„ (n+1) j (X.1 0,X.2 0)) X)
apply measurable_select (J := Bool Γ— State M) _ ((hΟ„ (n+1) j).comp (by fun_prop))
intro a
dsimp [h]
split_ifs
Β· exact measurable_const
Β· exact (measurable_of_finite haltShift).comp ((ih (n+1) a.2).comp (by
change Measurable (fun X : ((Fin (k+1) β†’ Vector d) Γ— (Fin (k+1) β†’ ℝ)) =>
((fun i : Fin k => X.1 i.succ),(fun i : Fin k => X.2 i.succ)))
fun_prop))
def haltChild (w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞)
(v : State M β†’ Vector d β†’ ℝβ‰₯0∞) (n : β„•) {k : β„•} : TaggedState M k β†’ Vector d β†’ ℝβ‰₯0∞
| .inl j => v j
| .inr (t,j) => w (n+t) j
def stoppedContinuation (Ο„ : β„• β†’ State M β†’ (Vector d Γ— ℝ) β†’ Bool Γ— State M)
(w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞) (n : β„•) : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞
| 0, j, s => w n j s
| k+1, j, s => ∫⁻ x, let a := Ο„ (n+1) j (x,βŸͺs,x⟫)
if a.1 then w (n+1) a.2 s else stoppedContinuation Ο„ w (n+1) k a.2 s βˆ‚stdGaussian (Vector d)
lemma measurable_stoppedContinuation {Ο„ : β„• β†’ State M β†’ (Vector d Γ— ℝ) β†’ Bool Γ— State M}
{w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞}
(hΟ„ : βˆ€ t j, Measurable (Ο„ t j)) (hw : βˆ€ n j, Measurable (w n j)) (n k : β„•) (j : State M) :
Measurable (stoppedContinuation Ο„ w n k j) := by
induction k generalizing n j with
| zero => exact hw n j
| succ k ih =>
apply Measurable.lintegral_prod_left
change Measurable (fun z : Vector d Γ— Vector d =>
if (Ο„ (n+1) j (z.1,βŸͺz.2,z.1⟫)).1 then w (n+1) (Ο„ (n+1) j (z.1,βŸͺz.2,z.1⟫)).2 z.2
else stoppedContinuation Ο„ w (n+1) k (Ο„ (n+1) j (z.1,βŸͺz.2,z.1⟫)).2 z.2)
apply measurable_select (J := Bool Γ— State M) (h := fun a (z : Vector d Γ— Vector d) =>
if a.1 then w (n+1) a.2 z.2 else stoppedContinuation Ο„ w (n+1) k a.2 z.2) _
((hΟ„ (n+1) j).comp (by fun_prop))
intro a
split_ifs
Β· exact (hw (n+1) a.2).comp measurable_snd
Β· exact (ih (n+1) a.2).comp measurable_snd
lemma stoppedContinuation_le_one
{Ο„ : β„• β†’ State M β†’ (Vector d Γ— ℝ) β†’ Bool Γ— State M}
{w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞}
(hw : βˆ€ n j s, w n j s ≀ 1) (n k : β„•) (j : State M) (s : Vector d) :
stoppedContinuation Ο„ w n k j s ≀ 1 := by
induction k generalizing n j with
| zero => exact hw n j s
| succ k ih =>
change (∫⁻ x, (if (Ο„ (n+1) j (x,βŸͺs,x⟫)).1 then w (n+1) (Ο„ (n+1) j (x,βŸͺs,x⟫)).2 s else stoppedContinuation Ο„ w (n+1) k (Ο„ (n+1) j (x,βŸͺs,x⟫)).2 s) βˆ‚stdGaussian (Vector d)) ≀ 1
apply (lintegral_mono (g := fun _ => (1:ℝβ‰₯0∞)) (fun x => ?_)).trans_eq (by simp)
split_ifs
Β· exact hw _ _ _
Β· exact ih _ _
lemma stoppedContinuation_unroll
{Ο„ : β„• β†’ State M β†’ (Vector d Γ— ℝ) β†’ Bool Γ— State M}
{w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞}
(hΟ„ : βˆ€ t j, Measurable (Ο„ t j)) (n m k : β„•) (j : State M) (s : Vector d) :
stoppedContinuation Ο„ w n (m+k) j s =
blockValue (haltChild w (stoppedContinuation Ο„ w (n+m) k) n) (haltRoute Ο„ n m j) s := by
induction m generalizing n j with
| zero => simp [blockValue,haltRoute,haltChild]
| succ m ih =>
rw [Nat.succ_add,stoppedContinuation]
unfold blockValue
have hf : Measurable (fun X : Fin (m+1) β†’ Vector d =>
haltChild w (stoppedContinuation Ο„ w (n+(m+1)) k) n
(haltRoute Ο„ n (m+1) j (X,fun i => βŸͺs,X i⟫)) s) :=
(measurable_of_finite (fun a => haltChild w (stoppedContinuation Ο„ w (n+(m+1)) k) n a s)).comp
((measurable_haltRoute hΟ„ n (m+1) j).comp (by fun_prop))
rw [lintegral_pi_cons _ _ hf]
apply lintegral_congr
intro x
have htail (X : Fin m β†’ Vector d) : Fin.tail (fun i : Fin (m+1) => βŸͺs,(Fin.cons x X : Fin (m+1) β†’ Vector d) i⟫) = (fun i => βŸͺs,X i⟫) := by funext i; rfl
simp only [haltRoute,Fin.cons_zero,Fin.tail_cons,htail]
split_ifs with h
Β· simp [haltChild]
Β· rw [ih]
unfold blockValue
apply lintegral_congr
intro X
have h1 : n+(m+1) = n+1+m := by omega
rw [h1]
generalize haltRoute Ο„ (n+1) m (Ο„ (n+1) j (x,βŸͺs,x⟫)).2 (X,fun i => βŸͺs,X i⟫) = a
cases a with
| inl j => rfl
| inr done =>
simp only [haltShift,haltChild,Fin.val_succ]
rw [show n+1+done.1.val = n+(done.1.val+1) by omega]
lemma stoppedContinuation_mass_bound {Ο„ : β„• β†’ State M β†’ (Vector d Γ— ℝ) β†’ Bool Γ— State M}
{w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞}
(hΟ„ : βˆ€ t j, Measurable (Ο„ t j)) (hw : βˆ€ n j, Measurable (w n j))
(hw1 : βˆ€ n j s, w n j s ≀ 1)
{a q : β„•} {C : ℝβ‰₯0∞} (hC : C β‰  0) (hCt : C β‰  ∞)
(hlocal : βˆ€ n j, PolynomialMass (ambientSphereLaw.withDensity (w n j)) a C)
(hd : 1 ≀ d) (ha : a ≀ d) (hq : 2 ≀ q) (hqa : 2*q ≀ a)
(n k : β„•) (j : State M) :
PolynomialMass (ambientSphereLaw.withDensity (stoppedContinuation Ο„ w n k j)) a
(C * streamFactor (E := Vector d) (J := TaggedState M q) q ^ ((k+q-1)/q)) := by
let : NeZero d := ⟨by omega⟩
let K := streamFactor (E := Vector d) (J := TaggedState M q) q
have hK1 : 1 ≀ K := one_le_streamFactor (by omega)
have hK0 : K β‰  0 := ne_of_gt (lt_of_lt_of_le zero_lt_one hK1)
have hKt : K β‰  ∞ := streamFactor_ne_top _
have hden : ((q-1 : β„•) : ℝ)+1 = (q : ℝ) := by rw [Nat.cast_sub (by omega),Nat.cast_one]; ring
have hq0 : 0 < q := by omega
change PolynomialMass _ a (C*K^_)
induction k using Nat.strong_induction_on generalizing n j with
| h k ih =>
by_cases hk0 : k = 0
Β· subst k
simpa only [Nat.zero_add,Nat.div_eq_of_lt (by omega : q-1 < q),pow_zero,mul_one,stoppedContinuation] using hlocal n j
let m := min k q
have hm0 : 0 < m := by dsimp [m]; omega
have hm : m ≀ q := min_le_right _ _
have hmk : m ≀ k := min_le_left _ _
have hki : k-m < k := by omega
let C' := C*K^((k-m+q-1)/q)
have hC' : C' β‰  0 := mul_ne_zero hC (pow_ne_zero _ hK0)
have hC't : C' β‰  ∞ := ENNReal.mul_ne_top hCt (ENNReal.pow_ne_top hKt)
have hCC' : C ≀ C' := le_mul_of_one_le_right' (one_le_powβ‚€ hK1)
let f := haltChild w (stoppedContinuation Ο„ w (n+m) (k-m)) n (k := m)
have hf (a : TaggedState M m) : Measurable (f a) := by
cases a with
| inl j => exact measurable_stoppedContinuation hΟ„ hw _ _ _
| inr done => exact hw _ _
have hf1 (a : TaggedState M m) (s : Vector d) : f a s ≀ 1 := by
cases a with
| inl j => exact stoppedContinuation_le_one hw1 _ _ _ _
| inr done => exact hw1 _ _ _
have hflocal (a' : TaggedState M m) : PolynomialMass (ambientSphereLaw.withDensity (f a')) a C' := by
cases a' with
| inl j => exact ih (k-m) hki (n+m) j
| inr done =>
intro z r hr
exact (hlocal (n+done.1) done.2 z r hr).trans (mul_le_mul' hCC' le_rfl)
have hb := blockValue_mass_bound ambientSphereLaw hf hf1 hflocal hC' hC't
(by simpa using hd) (by simpa using ha) (by simpa using (show m ≀ d by omega))
(by omega : 1 ≀ q-1) (by omega : q-1+m ≀ a) (measurable_haltRoute hΟ„ n m j)
have he : stoppedContinuation Ο„ w n k j = blockValue f (haltRoute Ο„ n m j) := by
funext s
simpa [f,Nat.add_sub_of_le hmk] using stoppedContinuation_unroll hΟ„ n m (k-m) j s
rw [he]
intro z r hr
apply (hb z r hr).trans
apply mul_le_mul' _ le_rfl
have hdiv : (k+q-1)/q = (k-m+q-1)/q+1 := by
by_cases hqk : q ≀ k
Β· have hme : m = q := min_eq_right hqk
rw [hme]
have he : k+q-1 = q+(k-q+q-1) := by omega
rw [he,Nat.add_div_left _ hq0]
Β· have hme : m = k := min_eq_left (by omega)
rw [hme,Nat.sub_self,Nat.zero_add,Nat.div_eq_of_lt (by omega : q-1 < q)]
have he : k+q-1 = q+(k-1) := by omega
rw [he,Nat.add_div_left _ hq0,Nat.div_eq_of_lt (by omega : k-1 < q)]
rw [hden]
have hcard : (Fintype.card (TaggedState M m):ℝβ‰₯0∞)^(1/(q:ℝ)) ≀
(Fintype.card (TaggedState M q):ℝβ‰₯0∞)^(1/(q:ℝ)) := by
apply ENNReal.rpow_le_rpow _ (by positivity)
exact_mod_cast (show Fintype.card (TaggedState M m) ≀ Fintype.card (TaggedState M q) by
rw [card_taggedState,card_taggedState]
exact Nat.mul_le_mul_right _ (Nat.add_le_add_right hm 2))
calc
_ ≀ K*C' := mul_le_mul' (mul_le_mul' le_rfl hcard) le_rfl
_ = _ := by rw [hdiv,pow_succ]; dsimp [C']; ring
end
variable {d M T : β„•}
def taggedWeight (w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞) (n : β„•) : TaggedState M T β†’ Vector d β†’ ℝβ‰₯0∞
| .inl j => w n j
| .inr (t,j) => w t j
lemma measurable_taggedWeight {w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞}
(hw : βˆ€ n j, Measurable (w n j)) (n : β„•) (j : TaggedState M T) :
Measurable (taggedWeight w n j) := by cases j <;> exact hw _ _
lemma continuation_tagged_eq {Ο„ : β„• β†’ State M β†’ (Vector d Γ— ℝ) β†’ Bool Γ— State M}
{w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞}
(n k : β„•) (hnk : n+k ≀ T) (j : TaggedState M T) (s : Vector d) :
continuation (taggedStep Ο„) (taggedWeight w) n k j s =
match j with
| .inl a => stoppedContinuation Ο„ w n k a s
| .inr (t,a) => w t a s := by
induction k generalizing n j with
| zero => cases j <;> rfl
| succ k ih =>
cases j with
| inl j =>
simp only [continuation,stoppedContinuation]
apply lintegral_congr
intro x
rw [ih (n+1) (by omega)]
simp only [taggedStep,dite_eq_left (by omega : n+1 ≀ T)]
split_ifs <;> rfl
| inr done =>
simp only [continuation,taggedStep]
simp only [ih (n+1) (by omega),lintegral_const,measure_univ,mul_one]
lemma tagged_continuation_mass {Ο„ : β„• β†’ State M β†’ (Vector d Γ— ℝ) β†’ Bool Γ— State M}
{w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞}
(hΟ„ : βˆ€ t j, Measurable (Ο„ t j)) (hw : βˆ€ n j, Measurable (w n j))
(hw1 : βˆ€ n j s, w n j s ≀ 1)
{a q : β„•} {C : ℝβ‰₯0∞} (hC : C β‰  0) (hCt : C β‰  ∞)
(hlocal : βˆ€ n j, PolynomialMass (ambientSphereLaw.withDensity (w n j)) a C)
(hd : 1 ≀ d) (ha : a ≀ d) (hq : 2 ≀ q) (hqa : 2*q ≀ a)
(j : TaggedState M T) :
PolynomialMass (ambientSphereLaw.withDensity
(continuation (taggedStep Ο„) (taggedWeight w) 0 T j)) a
(C * streamFactor (E := Vector d) (J := TaggedState M q) q ^ ((T+q-1)/q)) := by
have he := fun s => continuation_tagged_eq (Ο„ := Ο„) (w := w) 0 T (by omega) j s
cases j with
| inl j =>
have he' : continuation (taggedStep (T := T) Ο„) (taggedWeight w) 0 T (.inl j) = stoppedContinuation Ο„ w 0 T j :=
funext he
rw [he']
exact stoppedContinuation_mass_bound hΟ„ hw hw1 hC hCt hlocal hd ha hq hqa 0 T j
| inr done =>
have he' : continuation (taggedStep (T := T) Ο„) (taggedWeight w) 0 T (.inr done) = w done.1 done.2 :=
funext he
rw [he']
intro z r hr
apply (hlocal _ _ z r hr).trans
apply mul_le_mul' _ le_rfl
exact le_mul_of_one_le_right' (one_le_powβ‚€ (one_le_streamFactor (by omega)))
variable [NeZero d]
lemma stopped_route_mixed_bound {Ο„ : β„• β†’ State M β†’ (Vector d Γ— ℝ) β†’ Bool Γ— State M}
(hΟ„ : βˆ€ t j, Measurable (Ο„ t j)) (y : β„• β†’ State M β†’ Vector d)
{Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅) (hΞ΅1 : Ξ΅ ≀ 1) {a q : β„•} {b : ℝ}
(hb : 0 ≀ b) (hab : (a:ℝ)+b ≀ (d-1:β„•))
(hq : 2 ≀ q) (hqa : 2*q ≀ a) (j : TaggedState M T) :
((uniformSphere d).prod (sampleLaw d T))
{z | dist z.1.val
(match streamRoute (taggedStep (T := T) Ο„) 0 T j (z.2,fun i => βŸͺz.1.val,z.2 i⟫) with
| .inl a => y T a
| .inr (t,a) => y t a) ≀ Ξ΅} ≀
(ENNReal.ofReal ((3:ℝ)*4^d)*ENNReal.ofReal (Ξ΅^b)) *
streamFactor (E := Vector d) (J := TaggedState M q) q ^ ((T+q-1)/q) := by
let w : β„• β†’ State M β†’ Vector d β†’ ℝβ‰₯0∞ := fun n j => capWeight (y n j) Ξ΅
let Ξ΄ := taggedStep (T := T) Ο„
let w' : β„• β†’ TaggedState M T β†’ Vector d β†’ ℝβ‰₯0∞ := taggedWeight w
let yy : TaggedState M T β†’ Vector d := fun a => match a with
| .inl a => y T a
| .inr (t,a) => y t a
have hw' (n : β„•) (a : TaggedState M T) : Measurable (w' n a) :=
measurable_taggedWeight (fun n j => measurable_capWeight _ _) n a
have hΞ΄ := measurable_taggedStep (T := T) hΟ„
have hV := measurable_continuation hΞ΄ hw' 0 T j
have he (s : Vector d) : continuation Ξ΄ w' 0 T j s =
∫⁻ A : Fin T β†’ Vector d, capWeight (yy (streamRoute Ξ΄ 0 T j (A,fun i => βŸͺs,A i⟫))) Ξ΅ s
βˆ‚Measure.pi (fun _ => stdGaussian (Vector d)) := by
have hu := continuation_unroll (w := w') hΞ΄ 0 T 0 j s
simp only [Nat.add_zero,continuation] at hu
rw [hu]
unfold blockValue
apply lintegral_congr
intro A
cases streamRoute Ξ΄ 0 T j (A,fun i => βŸͺs,A i⟫) <;> simp [w',w,yy,taggedWeight]
let S : Set (UnitSphere d Γ— Samples d T) :=
{z | dist z.1.val (yy (streamRoute Ξ΄ 0 T j (z.2,fun i => βŸͺz.1.val,z.2 i⟫))) ≀ Ξ΅}
have hS : MeasurableSet S := by
apply measurableSet_le _ measurable_const
exact (measurable_subtype_coe.comp measurable_fst).dist
((measurable_of_finite yy).comp ((measurable_streamRoute hΞ΄ 0 T j).comp (by fun_prop)))
change ((sphereLaw (E := Vector d)).prod _) S ≀ _
rw [← one_mul (((sphereLaw (E := Vector d)).prod _) S), ← lintegral_indicator_const hS 1,
lintegral_prod _ (measurable_const.indicator hS).aemeasurable]
have hf : βˆ€ s : UnitSphere d,
(∫⁻ A, S.indicator (fun _ => (1:ℝβ‰₯0∞)) (s,A) βˆ‚sampleLaw d T) = continuation Ξ΄ w' 0 T j s.val := by
intro s
rw [he]
apply lintegral_congr
intro A
classical
change (if dist s.val (yy (streamRoute Ξ΄ 0 T j (A,fun i => βŸͺs.val,A i⟫))) ≀ Ξ΅ then 1 else 0) = _
unfold capWeight
rw [Set.indicator_apply]
rfl
simp_rw [hf]
rw [← lintegral_map hV measurable_subtype_coe]
apply ambient_mass_bound (a := a)
have ha : a ≀ d := by
have hdn : ((d-1:β„•):ℝ) ≀ (d:ℝ) := by exact_mod_cast Nat.sub_le d 1
have : (a:ℝ) ≀ d := by linarith
exact_mod_cast this
have hl (n : β„•) (j : State M) : PolynomialMass (ambientSphereLaw.withDensity (w n j)) a
(ENNReal.ofReal ((3:ℝ)*4^d)*ENNReal.ofReal (Ξ΅^b)) := by
simpa only [finrank_euclideanSpace_fin] using capWeight_mass_mixed (y n j) hΞ΅ hΞ΅1 a hb (by simpa using hab)
exact tagged_continuation_mass hΟ„ (fun n j => measurable_capWeight _ _)
(fun n j s => capWeight_le_one _ _ _)
(mul_ne_zero (by positivity) (by positivity))
(ENNReal.mul_ne_top ENNReal.ofReal_ne_top ENNReal.ofReal_ne_top)
hl
(Nat.pos_of_ne_zero (NeZero.ne d)) ha hq hqa j
end Learner
end NoiselessRegression
end
end OAI