Sync from openai/math@faee2cf485a8 (part 15)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- lean/OAI/Probability/SKValue/GroundState/GaussianTree.lean+149-149
- lean/OAI/Probability/SKValue/GroundState/GramSchmidtLimit.lean+182-182
- lean/OAI/Probability/SKValue/GroundState/GumbelMax.lean+152-152
- lean/OAI/Probability/SKValue/GroundState/GumbelReplacement.lean+132-132
- lean/OAI/Probability/SKValue/GroundState/LiteralLower.lean+153-153
- lean/OAI/Probability/SKValue/GroundState/LogComparison.lean+165-165
- lean/OAI/Probability/SKValue/GroundState/MainConclusions.lean+32-32
- lean/OAI/Probability/SKValue/GroundState/PredictableNormalizer.lean+294-294
- lean/OAI/Probability/SKValue/GroundState/QuadraticSK.lean+199-199
- lean/OAI/Probability/SKValue/GroundState/RandomColumn.lean+155-155
- lean/OAI/Probability/SKValue/GroundState/RandomGuerra.lean+178-178
- lean/OAI/Probability/SKValue/GroundState/RotatedCoefficients.lean+396-396
- lean/OAI/Probability/SKValue/GroundState/RoundingSpin.lean+126-126
- lean/OAI/Probability/SKValue/GroundState/StandardGaussian.lean+384-384
- lean/OAI/Probability/SKValue/GroundState/TreeGuerra.lean+161-161
- lean/OAI/Probability/SKValue/GroundState/TreeProductLaw.lean+204-204
- lean/OAI/Probability/SKValue/GroundState/TreeWidths.lean+119-119
- lean/OAI/Probability/SKValue/GroundState/WeakGuerra.lean+147-147
- lean/OAI/Probability/SKValue/Main.lean+28-28
- lean/OAI/Probability/SKValue/Model.lean+165-165
- lean/OAI/Probability/SKValue/Processes/CrossMesh.lean+153-153
- lean/OAI/Probability/SKValue/Processes/CrossMeshComparison.lean+90-90
- lean/OAI/Probability/SKValue/Processes/CrossValueBound.lean+108-108
- lean/OAI/Probability/SKValue/Processes/CurvatureNonneg.lean+43-43
- lean/OAI/Probability/SKValue/Processes/DiffusionExistence.lean+84-84
- lean/OAI/Probability/SKValue/Processes/DiffusionGradientCondExp.lean+143-143
- lean/OAI/Probability/SKValue/Processes/DiffusionGradientWeakMartingaleLocal.lean+131-131
- lean/OAI/Probability/SKValue/Processes/EulerL1.lean+202-202
- lean/OAI/Probability/SKValue/Processes/EulerLimitProcess.lean+128-128
- lean/OAI/Probability/SKValue/Processes/EulerMemLp.lean+151-151
- lean/OAI/Probability/SKValue/Processes/Feedback.lean+299-299
- lean/OAI/Probability/SKValue/Processes/FiniteGaussianFixedStrip.lean+55-55
- lean/OAI/Probability/SKValue/Processes/FiniteProfileLaw.lean+40-40
- lean/OAI/Probability/SKValue/Processes/ForcedDiffusion.lean+66-66
- lean/OAI/Probability/SKValue/Processes/ForcedExpectation.lean+202-202
- lean/OAI/Probability/SKValue/Processes/GradientSquareIntegral.lean+96-96
- lean/OAI/Probability/SKValue/Processes/Measurable.lean+147-147
- lean/OAI/Probability/SKValue/Processes/MeshBrownian.lean+343-343
- lean/OAI/Probability/SKValue/Processes/MeshMaxError.lean+87-87
- lean/OAI/Probability/SKValue/Processes/MeshMeanBound.lean+145-145
- lean/OAI/Probability/SKValue/Processes/MeshRaw.lean+143-143
- lean/OAI/Probability/SKValue/Processes/StripPaths.lean+78-78
- lean/OAI/Probability/SKValue/Processes/TerminalCondExp.lean+105-105
- lean/OAI/Probability/SKValue/Processes/TestDiffusion.lean+57-57
- lean/OAI/Probability/SKValue/Processes/TestExpectation.lean+191-191
- lean/OAI/Probability/SKValue/Processes/UnitMomentMartingale.lean+396-396
- lean/OAI/Probability/SKValue/Processes/ValueEulerOneStep.lean+91-91
- lean/OAI/Probability/SKValue/Processes/VariableTestLaw.lean+32-32
- lean/OAI/Probability/SKValue/Processes/Volterra.lean+131-131
- lean/OAI/Probability/SKValue/Processes/WeightedTerminalExpectation.lean+78-78
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149import Mathlibimport OAI.Probability.SKValue.GroundState.AffineComparisonnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGstructure TreeLevel wherebranchExcess : ℕendpoint : ℝheight : ℝabbrev GaussianTree := List TreeLevelabbrev TreeLeaves : GaussianTree → Type| [] => PUnit| l::T => Fin (l.branchExcess+1) × TreeLeaves Tabbrev TreeEdges : GaussianTree → Type| [] => PEmpty| l::T => Fin (l.branchExcess+1) ⊕ (Fin (l.branchExcess+1) × TreeEdges T)instance treeLeavesFintype (T : GaussianTree) : Fintype (TreeLeaves T) := byinduction T with| nil => exact inferInstanceAs (Fintype PUnit)| cons l T ih => exact inferInstanceAs (Fintype (Fin (l.branchExcess+1) × TreeLeaves T))instance treeLeavesNonempty (T : GaussianTree) : Nonempty (TreeLeaves T) := byinduction T with| nil => exact inferInstanceAs (Nonempty PUnit)| cons l T ih => exact inferInstanceAs (Nonempty (Fin (l.branchExcess+1) × TreeLeaves T))instance treeEdgesFintype (T : GaussianTree) : Fintype (TreeEdges T) := byinduction T with| nil => exact inferInstanceAs (Fintype PEmpty)| cons l T ih => exact inferInstanceAs (Fintype (Fin (l.branchExcess+1) ⊕ (Fin (l.branchExcess+1) × TreeEdges T)))noncomputable def treePathCoeff (c : ℝ → TreeLevel → ℝ) (q : ℝ) :(T : GaussianTree) → TreeLeaves T → TreeEdges T → ℝ| [],_,e => PEmpty.elim e| l::T,α,e => match e with| Sum.inl i => if α.1=i then c q l else 0| Sum.inr (i,e) => if α.1=i then treePathCoeff c l.endpoint T α.2 e else 0noncomputable def treeOverlap (q : ℝ) : (T : GaussianTree) → TreeLeaves T → TreeLeaves T → ℝ| [],_,_ => q| l::T,α,β => if α.1=β.1 then treeOverlap l.endpoint T α.2 β.2 else qdef ValidTreeGrid (q : ℝ) : GaussianTree → Prop| [] => q=1| l::T => q≤l.endpoint ∧ ValidTreeGrid l.endpoint Tlemma treePath_inner_node (c : ℝ → TreeLevel → ℝ) (q : ℝ) (l : TreeLevel) (T : GaussianTree)(α β : TreeLeaves (l::T)) :(∑ e,treePathCoeff c q (l::T) α e*treePathCoeff c q (l::T) β e)=if α.1=β.1 then (c q l)^2+∑ e,treePathCoeff c l.endpoint T α.2 e*treePathCoeff c l.endpoint T β.2 e else 0 := byclassicalchange (∑ e : Fin (l.branchExcess+1) ⊕ (Fin (l.branchExcess+1) × TreeEdges T),_)=_rw [Fintype.sum_sum_type,Fintype.sum_prod_type]simp only [treePathCoeff]by_cases h : α.1=β.1· simp only [h,ite_true]simp [←h,ite_mul,mul_ite,sq]· simp only [h,ite_false]have he (i : Fin (l.branchExcess+1)) : ¬(α.1=i ∧ β.1=i) := byrintro ⟨ha,hb⟩; exact h (ha.trans hb.symm)simp_rw [ite_mul,zero_mul]simp only [mul_ite,mul_zero]have hzero (i : Fin (l.branchExcess+1)) (r s : ℝ) :(if α.1=i then if β.1=i then r*s else 0 else 0)=0 := bysplit_ifs with ha hb <;> try rflexact (he i ⟨ha,hb⟩).elimsimp only [hzero,Finset.sum_const_zero,add_zero]noncomputable def treeFieldVector (q : ℝ) (T : GaussianTree) : TreeLeaves T → TreeEdges T → ℝ :=treePathCoeff (fun q l ↦ Real.sqrt (l.endpoint-q)) q Tnoncomputable def treeAuxVector (n : ℕ) (q : ℝ) (T : GaussianTree) : TreeLeaves T → TreeEdges T → ℝ :=treePathCoeff (fun q l ↦ Real.sqrt ((n : ℝ)/2)*Real.sqrt (l.endpoint^2-q^2)) q Tlemma treeField_inner (q : ℝ) (T : GaussianTree) (hT : ValidTreeGrid q T)(α β : TreeLeaves T) :(∑ e,treeFieldVector q T α e*treeFieldVector q T β e)=treeOverlap q T α β-q := byinduction T generalizing q with| nil =>simp only [treeFieldVector,treePathCoeff,treeOverlap,sub_self]exact Finset.sum_eq_zero (by intro e he; exact PEmpty.elim e)| cons l T ih =>change q≤l.endpoint ∧ ValidTreeGrid l.endpoint T at hTrw [treeFieldVector,treePath_inner_node]dsimp [treeOverlap]split_ifs with h· rw [Real.sq_sqrt (sub_nonneg.mpr hT.1)]have hh := ih l.endpoint hT.2 α.2 β.2change (l.endpoint-q)+(∑ e,treeFieldVector l.endpoint T α.2 e*treeFieldVector l.endpoint T β.2 e)=_rw [hh]; ring· ringlemma treeAux_inner (n : ℕ) (q : ℝ) (hq : 0≤q) (T : GaussianTree) (hT : ValidTreeGrid q T)(α β : TreeLeaves T) :(∑ e,treeAuxVector n q T α e*treeAuxVector n q T β e)=((n : ℝ)/2)*((treeOverlap q T α β)^2-q^2) := byinduction T generalizing q with| nil =>simp only [treeAuxVector,treePathCoeff,treeOverlap,sub_self,mul_zero]exact Finset.sum_eq_zero (by intro e he; exact PEmpty.elim e)| cons l T ih =>change q≤l.endpoint ∧ ValidTreeGrid l.endpoint T at hTrw [treeAuxVector,treePath_inner_node]dsimp [treeOverlap]split_ifs with h· rw [mul_pow,Real.sq_sqrt (by positivity),Real.sq_sqrt (by nlinarith [hT.1])]have hh := ih l.endpoint (hq.trans hT.1) hT.2 α.2 β.2change ((n : ℝ)/2)*(l.endpoint^2-q^2)+(∑ e,treeAuxVector n l.endpoint T α.2 e*treeAuxVector n l.endpoint T β.2 e)=_rw [hh]; ring· ringlemma treeOverlap_self (q : ℝ) (T : GaussianTree) (hT : ValidTreeGrid q T) (α : TreeLeaves T) :treeOverlap q T α α=1 := byinduction T generalizing q with| nil => exact hT| cons l T ih => simp only [treeOverlap,ite_true]; exact ih l.endpoint hT.2 α.2lemma treeField_unit (T : GaussianTree) (hT : ValidTreeGrid 0 T) (α : TreeLeaves T) :(∑ e,(treeFieldVector 0 T α e)^2)=1 := bysimp only [sq]rw [treeField_inner 0 T hT,treeOverlap_self 0 T hT]norm_numlemma treeAux_distance (n : ℕ) (T : GaussianTree) (hT : ValidTreeGrid 0 T)(α β : TreeLeaves T) :(∑ e,(treeAuxVector n 0 T α e-treeAuxVector n 0 T β e)^2)=(n : ℝ)*(1-(treeOverlap 0 T α β)^2) := byrw [sq_distance_sum]simp only [sq]rw [treeAux_inner n 0 (by norm_num) T hT,treeAux_inner n 0 (by norm_num) T hT,treeAux_inner n 0 (by norm_num) T hT,treeOverlap_self 0 T hT,treeOverlap_self 0 T hT]ringend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149import Mathlibimport OAI.Probability.SKValue.GroundState.AffineComparisonnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGstructure TreeLevel wherebranchExcess : ℕendpoint : ℝheight : ℝabbrev GaussianTree := List TreeLevelabbrev TreeLeaves : GaussianTree → Type| [] => PUnit| l::T => Fin (l.branchExcess+1) × TreeLeaves Tabbrev TreeEdges : GaussianTree → Type| [] => PEmpty| l::T => Fin (l.branchExcess+1) ⊕ (Fin (l.branchExcess+1) × TreeEdges T)instance treeLeavesFintype (T : GaussianTree) : Fintype (TreeLeaves T) := byinduction T with| nil => exact inferInstanceAs (Fintype PUnit)| cons l T ih => exact inferInstanceAs (Fintype (Fin (l.branchExcess+1) × TreeLeaves T))instance treeLeavesNonempty (T : GaussianTree) : Nonempty (TreeLeaves T) := byinduction T with| nil => exact inferInstanceAs (Nonempty PUnit)| cons l T ih => exact inferInstanceAs (Nonempty (Fin (l.branchExcess+1) × TreeLeaves T))instance treeEdgesFintype (T : GaussianTree) : Fintype (TreeEdges T) := byinduction T with| nil => exact inferInstanceAs (Fintype PEmpty)| cons l T ih => exact inferInstanceAs (Fintype (Fin (l.branchExcess+1) ⊕ (Fin (l.branchExcess+1) × TreeEdges T)))noncomputable def treePathCoeff (c : ℝ → TreeLevel → ℝ) (q : ℝ) :(T : GaussianTree) → TreeLeaves T → TreeEdges T → ℝ| [],_,e => PEmpty.elim e| l::T,α,e => match e with| Sum.inl i => if α.1=i then c q l else 0| Sum.inr (i,e) => if α.1=i then treePathCoeff c l.endpoint T α.2 e else 0noncomputable def treeOverlap (q : ℝ) : (T : GaussianTree) → TreeLeaves T → TreeLeaves T → ℝ| [],_,_ => q| l::T,α,β => if α.1=β.1 then treeOverlap l.endpoint T α.2 β.2 else qdef ValidTreeGrid (q : ℝ) : GaussianTree → Prop| [] => q=1| l::T => q≤l.endpoint ∧ ValidTreeGrid l.endpoint Tlemma treePath_inner_node (c : ℝ → TreeLevel → ℝ) (q : ℝ) (l : TreeLevel) (T : GaussianTree)(α β : TreeLeaves (l::T)) :(∑ e,treePathCoeff c q (l::T) α e*treePathCoeff c q (l::T) β e)=if α.1=β.1 then (c q l)^2+∑ e,treePathCoeff c l.endpoint T α.2 e*treePathCoeff c l.endpoint T β.2 e else 0 := byclassicalchange (∑ e : Fin (l.branchExcess+1) ⊕ (Fin (l.branchExcess+1) × TreeEdges T),_)=_rw [Fintype.sum_sum_type,Fintype.sum_prod_type]simp only [treePathCoeff]by_cases h : α.1=β.1· simp only [h,ite_true]simp [←h,ite_mul,mul_ite,sq]· simp only [h,ite_false]have he (i : Fin (l.branchExcess+1)) : ¬(α.1=i ∧ β.1=i) := byrintro ⟨ha,hb⟩; exact h (ha.trans hb.symm)simp_rw [ite_mul,zero_mul]simp only [mul_ite,mul_zero]have hzero (i : Fin (l.branchExcess+1)) (r s : ℝ) :(if α.1=i then if β.1=i then r*s else 0 else 0)=0 := bysplit_ifs with ha hb <;> try rflexact (he i ⟨ha,hb⟩).elimsimp only [hzero,Finset.sum_const_zero,add_zero]noncomputable def treeFieldVector (q : ℝ) (T : GaussianTree) : TreeLeaves T → TreeEdges T → ℝ :=treePathCoeff (fun q l ↦ Real.sqrt (l.endpoint-q)) q Tnoncomputable def treeAuxVector (n : ℕ) (q : ℝ) (T : GaussianTree) : TreeLeaves T → TreeEdges T → ℝ :=treePathCoeff (fun q l ↦ Real.sqrt ((n : ℝ)/2)*Real.sqrt (l.endpoint^2-q^2)) q Tlemma treeField_inner (q : ℝ) (T : GaussianTree) (hT : ValidTreeGrid q T)(α β : TreeLeaves T) :(∑ e,treeFieldVector q T α e*treeFieldVector q T β e)=treeOverlap q T α β-q := byinduction T generalizing q with| nil =>simp only [treeFieldVector,treePathCoeff,treeOverlap,sub_self]exact Finset.sum_eq_zero (by intro e he; exact PEmpty.elim e)| cons l T ih =>change q≤l.endpoint ∧ ValidTreeGrid l.endpoint T at hTrw [treeFieldVector,treePath_inner_node]dsimp [treeOverlap]split_ifs with h· rw [Real.sq_sqrt (sub_nonneg.mpr hT.1)]have hh := ih l.endpoint hT.2 α.2 β.2change (l.endpoint-q)+(∑ e,treeFieldVector l.endpoint T α.2 e*treeFieldVector l.endpoint T β.2 e)=_rw [hh]; ring· ringlemma treeAux_inner (n : ℕ) (q : ℝ) (hq : 0≤q) (T : GaussianTree) (hT : ValidTreeGrid q T)(α β : TreeLeaves T) :(∑ e,treeAuxVector n q T α e*treeAuxVector n q T β e)=((n : ℝ)/2)*((treeOverlap q T α β)^2-q^2) := byinduction T generalizing q with| nil =>simp only [treeAuxVector,treePathCoeff,treeOverlap,sub_self,mul_zero]exact Finset.sum_eq_zero (by intro e he; exact PEmpty.elim e)| cons l T ih =>change q≤l.endpoint ∧ ValidTreeGrid l.endpoint T at hTrw [treeAuxVector,treePath_inner_node]dsimp [treeOverlap]split_ifs with h· rw [mul_pow,Real.sq_sqrt (by positivity),Real.sq_sqrt (by nlinarith [hT.1])]have hh := ih l.endpoint (hq.trans hT.1) hT.2 α.2 β.2change ((n : ℝ)/2)*(l.endpoint^2-q^2)+(∑ e,treeAuxVector n l.endpoint T α.2 e*treeAuxVector n l.endpoint T β.2 e)=_rw [hh]; ring· ringlemma treeOverlap_self (q : ℝ) (T : GaussianTree) (hT : ValidTreeGrid q T) (α : TreeLeaves T) :treeOverlap q T α α=1 := byinduction T generalizing q with| nil => exact hT| cons l T ih => simp only [treeOverlap,ite_true]; exact ih l.endpoint hT.2 α.2lemma treeField_unit (T : GaussianTree) (hT : ValidTreeGrid 0 T) (α : TreeLeaves T) :(∑ e,(treeFieldVector 0 T α e)^2)=1 := bysimp only [sq]rw [treeField_inner 0 T hT,treeOverlap_self 0 T hT]norm_numlemma treeAux_distance (n : ℕ) (T : GaussianTree) (hT : ValidTreeGrid 0 T)(α β : TreeLeaves T) :(∑ e,(treeAuxVector n 0 T α e-treeAuxVector n 0 T β e)^2)=(n : ℝ)*(1-(treeOverlap 0 T α β)^2) := byrw [sq_distance_sum]simp only [sq]rw [treeAux_inner n 0 (by norm_num) T hT,treeAux_inner n 0 (by norm_num) T hT,treeAux_inner n 0 (by norm_num) T hT,treeOverlap_self 0 T hT,treeOverlap_self 0 T hT]ringend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182import Mathlibimport OAI.Probability.SKValue.GroundState.GaussianColumnnamespace OAIsectionopen Filter Set InnerProductSpaceopen scoped Topology BigOperators RealInnerProductSpacenamespace SKValueGvariable {E : ℕ → Type*} [∀ n, NormedAddCommGroup (E n)] [∀ n, InnerProductSpace ℝ (E n)]lemma inner_approx_tendsto {x x' y : (n : ℕ) → E n} {a b : ℝ}(hx : Tendsto (fun n ↦ ‖x n-x' n‖) atTop (𝓝 0))(hy : Tendsto (fun n ↦ ‖y n‖) atTop (𝓝 b))(hxy : Tendsto (fun n ↦ ⟪x' n,y n⟫) atTop (𝓝 a)) :Tendsto (fun n ↦ ⟪x n,y n⟫) atTop (𝓝 a) := byhave hdiff : Tendsto (fun n ↦ ⟪x n,y n⟫-⟪x' n,y n⟫) atTop (𝓝 0) := byapply squeeze_zero_norm (fun n ↦ ?_) (by simpa using hx.mul hy)rw [←inner_sub_left,Real.norm_eq_abs]exact abs_real_inner_le_norm _ _simpa only [sub_add_cancel,zero_add] using hdiff.add hxyomit [∀ n, InnerProductSpace ℝ (E n)] inlemma norm_approx_tendsto {x x' : (n : ℕ) → E n} {a : ℝ}(hx : Tendsto (fun n ↦ ‖x n-x' n‖) atTop (𝓝 0))(hx' : Tendsto (fun n ↦ ‖x' n‖) atTop (𝓝 a)) :Tendsto (fun n ↦ ‖x n‖) atTop (𝓝 a) := byhave hd : Tendsto (fun n ↦ ‖x n‖-‖x' n‖) atTop (𝓝 0) := byexact squeeze_zero_norm (fun n ↦ by simpa only [Real.norm_eq_abs] using abs_norm_sub_norm_le (x n) (x' n)) hxsimpa only [sub_add_cancel,zero_add] using hd.add hx'theorem gramSchmidt_approx (a : (n : ℕ) → ℕ → E n) (K : ℕ)(hn : ∀ i≤K,Tendsto (fun n ↦ ‖a n i‖) atTop (𝓝 1))(hi : ∀ i j,i<j → j≤K → Tendsto (fun n ↦ ⟪a n i,a n j⟫) atTop (𝓝 0))(j : ℕ) (hj : j≤K) :Tendsto (fun n ↦ ‖gramSchmidt ℝ (a n) j-a n j‖) atTop (𝓝 0) := byinduction j using Nat.strong_induction_on with| h j ih =>have hnorm (i : ℕ) (hij : i<j) :Tendsto (fun n ↦ ‖gramSchmidt ℝ (a n) i‖) atTop (𝓝 1) :=norm_approx_tendsto (ih i hij (hij.le.trans hj)) (hn i (hij.le.trans hj))have hinner (i : ℕ) (hij : i<j) :Tendsto (fun n ↦ ⟪gramSchmidt ℝ (a n) i,a n j⟫) atTop (𝓝 0) :=inner_approx_tendsto (ih i hij (hij.le.trans hj)) (hn j hj) (hi i j hij hj)have hterm (i : ℕ) (hij : i<j) :Tendsto (fun n ↦ ‖(⟪gramSchmidt ℝ (a n) i,a n j⟫ /‖gramSchmidt ℝ (a n) i‖^2) • gramSchmidt ℝ (a n) i‖) atTop (𝓝 0) := bysimp only [norm_smul,Real.norm_eq_abs]have h := ((hinner i hij).div ((hnorm i hij).pow 2) (by norm_num)).abs.mul (hnorm i hij)simpa using hhave hs : Tendsto (fun n ↦ ∑ i∈Finset.range j,‖(⟪gramSchmidt ℝ (a n) i,a n j⟫/‖gramSchmidt ℝ (a n) i‖^2) •gramSchmidt ℝ (a n) i‖) atTop (𝓝 0) := bysimpa only [Finset.sum_const_zero] using tendsto_finsetSum (Finset.range j)(fun i hi ↦ hterm i (Finset.mem_range.mp hi))apply squeeze_zero (fun n ↦ norm_nonneg _) (fun n ↦ ?_) hshave he := gramSchmidt_def'' ℝ (a n) jhave he' : gramSchmidt ℝ (a n) j-a n j =-(∑ i∈Finset.range j,(⟪gramSchmidt ℝ (a n) i,a n j⟫ /‖gramSchmidt ℝ (a n) i‖^2) • gramSchmidt ℝ (a n) i) := bysimp only [Nat.Iio_eq_range] at hecalc_ = gramSchmidt ℝ (a n) j-(gramSchmidt ℝ (a n) j+_) := congrArg (fun x ↦ gramSchmidt ℝ (a n) j-x) he_ = _ := by abelrw [he',norm_neg]exact norm_sum_le _ _theorem gramSchmidtNormed_approx (a : (n : ℕ) → ℕ → E n) (K : ℕ)(hn : ∀ i≤K,Tendsto (fun n ↦ ‖a n i‖) atTop (𝓝 1))(hi : ∀ i j,i<j → j≤K → Tendsto (fun n ↦ ⟪a n i,a n j⟫) atTop (𝓝 0))(j : ℕ) (hj : j≤K) :Tendsto (fun n ↦ ‖gramSchmidtNormed ℝ (a n) j-a n j‖) atTop (𝓝 0) := byhave hg := gramSchmidt_approx a K hn hi j hjhave hgn := norm_approx_tendsto hg (hn j hj)have hscale : Tendsto (fun n ↦ |‖gramSchmidt ℝ (a n) j‖⁻¹-1| *‖gramSchmidt ℝ (a n) j‖) atTop (𝓝 0) := bysimpa using ((hgn.inv₀ (by norm_num)).sub_const 1).abs.mul hgnapply squeeze_zero (fun n ↦ norm_nonneg _) (fun n ↦ ?_) (by simpa using hscale.add hg)calc_ ≤ ‖gramSchmidtNormed ℝ (a n) j-gramSchmidt ℝ (a n) j‖+‖gramSchmidt ℝ (a n) j-a n j‖ := bycalc_ = ‖(gramSchmidtNormed ℝ (a n) j-gramSchmidt ℝ (a n) j)+(gramSchmidt ℝ (a n) j-a n j)‖ := by congr 1; abel_ ≤ _ := norm_add_le _ __ = _ := bycongr 1change ‖‖gramSchmidt ℝ (a n) j‖⁻¹ • gramSchmidt ℝ (a n) j-gramSchmidt ℝ (a n) j‖ = _have he : ‖gramSchmidt ℝ (a n) j‖⁻¹ • gramSchmidt ℝ (a n) j-gramSchmidt ℝ (a n) j =(‖gramSchmidt ℝ (a n) j‖⁻¹-1) • gramSchmidt ℝ (a n) j := by rw [sub_smul,one_smul]rw [he,norm_smul,Real.norm_eq_abs]end SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueGvariable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]noncomputable def orthogonalRemainder (v : ℕ → E) (w : E) (j : ℕ) : E :=w-∑ i∈Finset.range j,(⟪v i,w⟫ : ℝ) • v ilemma inner_orthogonalRemainder (v : ℕ → E) (w : E) (j : ℕ)(ho : ∀ i<j,⟪v j,v i⟫=0) :⟪v j,orthogonalRemainder v w j⟫=⟪v j,w⟫ := bysimp only [orthogonalRemainder,inner_sub_right,inner_sum,real_inner_smul_right]have hz : (∑ i∈Finset.range j,⟪v i,w⟫*⟪v j,v i⟫)=0 := byapply Finset.sum_eq_zerointro i hisimp [ho i (Finset.mem_range.mp hi)]rw [hz,sub_zero]lemma orthogonalRemainder_succ (v : ℕ → E) (w : E) (j : ℕ) :orthogonalRemainder v w (j+1)=orthogonalRemainder v w j-⟪v j,w⟫ • v j := bysimp only [orthogonalRemainder,Finset.sum_range_succ]abellemma columnResidual_orthogonalRemainder {κ : Type*} [Fintype κ](v : ℕ → EuclideanSpace ℝ κ) (w : EuclideanSpace ℝ κ) (j : ℕ)(ho : ∀ i<j,⟪v j,v i⟫=0) :columnResidual (v j) (orthogonalRemainder v w j)=orthogonalRemainder v w (j+1) := byrw [columnResidual,inner_orthogonalRemainder v w j ho,orthogonalRemainder_succ]lemma column_revealed_energy {κ : Type*} [Fintype κ](v : ℕ → EuclideanSpace ℝ κ) (w z : EuclideanSpace ℝ κ) (j : ℕ)(ho : ∀ i<j,⟪v j,v i⟫=0) :⟪columnVector (v j) (orthogonalRemainder v w j),z⟫=⟪v j,w⟫*⟪orthogonalRemainder v w (j+1),z⟫+(⟪v j,w⟫^2/Real.sqrt 2)*⟪v j,z⟫ := bysimp only [columnVector,inner_add_left,real_inner_smul_left]rw [inner_orthogonalRemainder v w j ho,columnResidual_orthogonalRemainder v w j ho]section Limitvariable {E' : ℕ → Type*} [∀ n,NormedAddCommGroup (E' n)] [∀ n,InnerProductSpace ℝ (E' n)]lemma orthogonalRemainder_inner_tendsto (v : (n : ℕ) → ℕ → E' n)(w z : (n : ℕ) → E' n) (K : ℕ) (A : ℕ → ℝ) (B : ℝ)(ha : ∀ j<K,Tendsto (fun n ↦ ⟪v n j,w n⟫) atTop (𝓝 (A j)))(hz : ∀ j<K,Tendsto (fun n ↦ ⟪v n j,z n⟫) atTop (𝓝 0))(hwz : Tendsto (fun n ↦ ⟪w n,z n⟫) atTop (𝓝 B)) :Tendsto (fun n ↦ ⟪orthogonalRemainder (v n) (w n) K,z n⟫) atTop (𝓝 B) := byhave hs : Tendsto (fun n ↦ ∑ j∈Finset.range K,⟪v n j,w n⟫*⟪v n j,z n⟫) atTop (𝓝 0) := byhave hh := tendsto_finsetSum (s:=Finset.range K)(fun j hj ↦ (ha j (Finset.mem_range.mp hj)).mul (hz j (Finset.mem_range.mp hj)))simpa using hhhave ht := hwz.sub hssimpa only [orthogonalRemainder,inner_sub_left,sum_inner,real_inner_smul_left,sub_zero] using httheorem normalized_column_energy_tendsto (a : (n : ℕ) → ℕ → E' n)(w z : (n : ℕ) → E' n) (K : ℕ) (A : ℕ → ℝ) (B : ℝ)(hn : ∀ i≤K,Tendsto (fun n ↦ ‖a n i‖) atTop (𝓝 1))(hi : ∀ i j,i<j → j≤K → Tendsto (fun n ↦ ⟪a n i,a n j⟫) atTop (𝓝 0))(hwn : Tendsto (fun n ↦ ‖w n‖) atTop (𝓝 1))(hzn : Tendsto (fun n ↦ ‖z n‖) atTop (𝓝 1))(ha : ∀ j≤K,Tendsto (fun n ↦ ⟪a n j,w n⟫) atTop (𝓝 (A j)))(hz : ∀ j≤K,Tendsto (fun n ↦ ⟪a n j,z n⟫) atTop (𝓝 0))(hb : Tendsto (fun n ↦ ⟪w n,z n⟫) atTop (𝓝 B)) :Tendsto (fun n ↦⟪gramSchmidtNormed ℝ (a n) K,w n⟫*⟪orthogonalRemainder (gramSchmidtNormed ℝ (a n)) (w n) (K+1),z n⟫+(⟪gramSchmidtNormed ℝ (a n) K,w n⟫^2/Real.sqrt 2)*⟪gramSchmidtNormed ℝ (a n) K,z n⟫) atTop (𝓝 (A K*B)) := byhave hp (j : ℕ) (hj : j≤K) :Tendsto (fun n ↦ ‖gramSchmidtNormed ℝ (a n) j-a n j‖) atTop (𝓝 0) :=gramSchmidtNormed_approx a j (fun i h ↦ hn i (h.trans hj))(fun i l hil hl ↦ hi i l hil (hl.trans hj)) j le_rflhave ha' (j : ℕ) (hj : j≤K) := inner_approx_tendsto (hp j hj) hwn (ha j hj)have hz' (j : ℕ) (hj : j≤K) := inner_approx_tendsto (hp j hj) hzn (hz j hj)have hr := orthogonalRemainder_inner_tendsto (fun n ↦ gramSchmidtNormed ℝ (a n)) w z(K+1) A B (fun j hj ↦ ha' j (by omega)) (fun j hj ↦ hz' j (by omega)) hbsimpa only [mul_zero,add_zero] using((ha' K le_rfl).mul hr).add (((ha' K le_rfl).pow 2 |>.div_const _).mul (hz' K le_rfl))end Limitend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182import Mathlibimport OAI.Probability.SKValue.GroundState.GaussianColumnnamespace OAIsectionopen Filter Set InnerProductSpaceopen scoped Topology BigOperators RealInnerProductSpacenamespace SKValueGvariable {E : ℕ → Type*} [∀ n, NormedAddCommGroup (E n)] [∀ n, InnerProductSpace ℝ (E n)]lemma inner_approx_tendsto {x x' y : (n : ℕ) → E n} {a b : ℝ}(hx : Tendsto (fun n ↦ ‖x n-x' n‖) atTop (��� 0))(hy : Tendsto (fun n ↦ ‖y n‖) atTop (𝓝 b))(hxy : Tendsto (fun n ↦ ⟪x' n,y n⟫) atTop (𝓝 a)) :Tendsto (fun n ↦ ⟪x n,y n⟫) atTop (𝓝 a) := byhave hdiff : Tendsto (fun n ↦ ⟪x n,y n⟫-⟪x' n,y n⟫) atTop (𝓝 0) := byapply squeeze_zero_norm (fun n ↦ ?_) (by simpa using hx.mul hy)rw [←inner_sub_left,Real.norm_eq_abs]exact abs_real_inner_le_norm _ _simpa only [sub_add_cancel,zero_add] using hdiff.add hxyomit [∀ n, InnerProductSpace ℝ (E n)] inlemma norm_approx_tendsto {x x' : (n : ℕ) → E n} {a : ℝ}(hx : Tendsto (fun n ↦ ‖x n-x' n‖) atTop (𝓝 0))(hx' : Tendsto (fun n ↦ ‖x' n‖) atTop (𝓝 a)) :Tendsto (fun n ↦ ‖x n‖) atTop (𝓝 a) := byhave hd : Tendsto (fun n ↦ ‖x n‖-‖x' n‖) atTop (𝓝 0) := byexact squeeze_zero_norm (fun n ↦ by simpa only [Real.norm_eq_abs] using abs_norm_sub_norm_le (x n) (x' n)) hxsimpa only [sub_add_cancel,zero_add] using hd.add hx'theorem gramSchmidt_approx (a : (n : ℕ) → ℕ → E n) (K : ℕ)(hn : ∀ i≤K,Tendsto (fun n ↦ ‖a n i‖) atTop (𝓝 1))(hi : ∀ i j,i<j → j≤K → Tendsto (fun n ↦ ⟪a n i,a n j⟫) atTop (𝓝 0))(j : ℕ) (hj : j≤K) :Tendsto (fun n ↦ ‖gramSchmidt ℝ (a n) j-a n j‖) atTop (𝓝 0) := byinduction j using Nat.strong_induction_on with| h j ih =>have hnorm (i : ℕ) (hij : i<j) :Tendsto (fun n ↦ ‖gramSchmidt ℝ (a n) i‖) atTop (𝓝 1) :=norm_approx_tendsto (ih i hij (hij.le.trans hj)) (hn i (hij.le.trans hj))have hinner (i : ℕ) (hij : i<j) :Tendsto (fun n ↦ ⟪gramSchmidt ℝ (a n) i,a n j⟫) atTop (𝓝 0) :=inner_approx_tendsto (ih i hij (hij.le.trans hj)) (hn j hj) (hi i j hij hj)have hterm (i : ℕ) (hij : i<j) :Tendsto (fun n ↦ ‖(⟪gramSchmidt ℝ (a n) i,a n j⟫ /‖gramSchmidt ℝ (a n) i‖^2) • gramSchmidt ℝ (a n) i‖) atTop (𝓝 0) := bysimp only [norm_smul,Real.norm_eq_abs]have h := ((hinner i hij).div ((hnorm i hij).pow 2) (by norm_num)).abs.mul (hnorm i hij)simpa using hhave hs : Tendsto (fun n ↦ ∑ i∈Finset.range j,‖(⟪gramSchmidt ℝ (a n) i,a n j⟫/‖gramSchmidt ℝ (a n) i‖^2) •gramSchmidt ℝ (a n) i‖) atTop (𝓝 0) := bysimpa only [Finset.sum_const_zero] using tendsto_finsetSum (Finset.range j)(fun i hi ↦ hterm i (Finset.mem_range.mp hi))apply squeeze_zero (fun n ↦ norm_nonneg _) (fun n ↦ ?_) hshave he := gramSchmidt_def'' ℝ (a n) jhave he' : gramSchmidt ℝ (a n) j-a n j =-(∑ i∈Finset.range j,(⟪gramSchmidt ℝ (a n) i,a n j⟫ /‖gramSchmidt ℝ (a n) i‖^2) • gramSchmidt ℝ (a n) i) := bysimp only [Nat.Iio_eq_range] at hecalc_ = gramSchmidt ℝ (a n) j-(gramSchmidt ℝ (a n) j+_) := congrArg (fun x ↦ gramSchmidt ℝ (a n) j-x) he_ = _ := by abelrw [he',norm_neg]exact norm_sum_le _ _theorem gramSchmidtNormed_approx (a : (n : ℕ) → ℕ → E n) (K : ℕ)(hn : ∀ i≤K,Tendsto (fun n ↦ ‖a n i‖) atTop (𝓝 1))(hi : ∀ i j,i<j → j≤K → Tendsto (fun n ↦ ⟪a n i,a n j⟫) atTop (𝓝 0))(j : ℕ) (hj : j≤K) :Tendsto (fun n ↦ ‖gramSchmidtNormed ℝ (a n) j-a n j‖) atTop (𝓝 0) := byhave hg := gramSchmidt_approx a K hn hi j hjhave hgn := norm_approx_tendsto hg (hn j hj)have hscale : Tendsto (fun n ↦ |‖gramSchmidt ℝ (a n) j‖⁻¹-1| *‖gramSchmidt ℝ (a n) j‖) atTop (𝓝 0) := bysimpa using ((hgn.inv₀ (by norm_num)).sub_const 1).abs.mul hgnapply squeeze_zero (fun n ↦ norm_nonneg _) (fun n ↦ ?_) (by simpa using hscale.add hg)calc_ ≤ ‖gramSchmidtNormed ℝ (a n) j-gramSchmidt ℝ (a n) j‖+‖gramSchmidt ℝ (a n) j-a n j‖ := bycalc_ = ‖(gramSchmidtNormed ℝ (a n) j-gramSchmidt ℝ (a n) j)+(gramSchmidt ℝ (a n) j-a n j)‖ := by congr 1; abel_ ≤ _ := norm_add_le _ __ = _ := bycongr 1change ‖‖gramSchmidt ℝ (a n) j‖⁻¹ • gramSchmidt ℝ (a n) j-gramSchmidt ℝ (a n) j‖ = _have he : ‖gramSchmidt ℝ (a n) j‖⁻¹ • gramSchmidt ℝ (a n) j-gramSchmidt ℝ (a n) j =(‖gramSchmidt ℝ (a n) j‖⁻¹-1) • gramSchmidt ℝ (a n) j := by rw [sub_smul,one_smul]rw [he,norm_smul,Real.norm_eq_abs]end SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueGvariable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]noncomputable def orthogonalRemainder (v : ℕ → E) (w : E) (j : ℕ) : E :=w-∑ i∈Finset.range j,(⟪v i,w⟫ : ℝ) • v ilemma inner_orthogonalRemainder (v : ℕ → E) (w : E) (j : ℕ)(ho : ∀ i<j,⟪v j,v i⟫=0) :⟪v j,orthogonalRemainder v w j⟫=⟪v j,w⟫ := bysimp only [orthogonalRemainder,inner_sub_right,inner_sum,real_inner_smul_right]have hz : (∑ i∈Finset.range j,⟪v i,w⟫*⟪v j,v i⟫)=0 := byapply Finset.sum_eq_zerointro i hisimp [ho i (Finset.mem_range.mp hi)]rw [hz,sub_zero]lemma orthogonalRemainder_succ (v : ℕ → E) (w : E) (j : ℕ) :orthogonalRemainder v w (j+1)=orthogonalRemainder v w j-⟪v j,w⟫ • v j := bysimp only [orthogonalRemainder,Finset.sum_range_succ]abellemma columnResidual_orthogonalRemainder {κ : Type*} [Fintype κ](v : ℕ → EuclideanSpace ℝ κ) (w : EuclideanSpace ℝ κ) (j : ℕ)(ho : ∀ i<j,⟪v j,v i⟫=0) :columnResidual (v j) (orthogonalRemainder v w j)=orthogonalRemainder v w (j+1) := byrw [columnResidual,inner_orthogonalRemainder v w j ho,orthogonalRemainder_succ]lemma column_revealed_energy {κ : Type*} [Fintype κ](v : ℕ → EuclideanSpace ℝ κ) (w z : EuclideanSpace ℝ κ) (j : ℕ)(ho : ∀ i<j,⟪v j,v i⟫=0) :⟪columnVector (v j) (orthogonalRemainder v w j),z⟫=⟪v j,w⟫*⟪orthogonalRemainder v w (j+1),z⟫+(⟪v j,w⟫^2/Real.sqrt 2)*⟪v j,z⟫ := bysimp only [columnVector,inner_add_left,real_inner_smul_left]rw [inner_orthogonalRemainder v w j ho,columnResidual_orthogonalRemainder v w j ho]section Limitvariable {E' : ℕ → Type*} [∀ n,NormedAddCommGroup (E' n)] [∀ n,InnerProductSpace ℝ (E' n)]lemma orthogonalRemainder_inner_tendsto (v : (n : ℕ) → ℕ → E' n)(w z : (n : ℕ) → E' n) (K : ℕ) (A : ℕ → ℝ) (B : ℝ)(ha : ∀ j<K,Tendsto (fun n ↦ ⟪v n j,w n⟫) atTop (𝓝 (A j)))(hz : ∀ j<K,Tendsto (fun n ↦ ⟪v n j,z n⟫) atTop (𝓝 0))(hwz : Tendsto (fun n ↦ ⟪w n,z n⟫) atTop (𝓝 B)) :Tendsto (fun n ↦ ⟪orthogonalRemainder (v n) (w n) K,z n⟫) atTop (𝓝 B) := byhave hs : Tendsto (fun n ↦ ∑ j∈Finset.range K,⟪v n j,w n⟫*⟪v n j,z n⟫) atTop (𝓝 0) := byhave hh := tendsto_finsetSum (s:=Finset.range K)(fun j hj ↦ (ha j (Finset.mem_range.mp hj)).mul (hz j (Finset.mem_range.mp hj)))simpa using hhhave ht := hwz.sub hssimpa only [orthogonalRemainder,inner_sub_left,sum_inner,real_inner_smul_left,sub_zero] using httheorem normalized_column_energy_tendsto (a : (n : ℕ) → ℕ → E' n)(w z : (n : ℕ) → E' n) (K : ℕ) (A : ℕ → ℝ) (B : ℝ)(hn : ∀ i≤K,Tendsto (fun n ↦ ‖a n i‖) atTop (𝓝 1))(hi : ∀ i j,i<j → j≤K → Tendsto (fun n ↦ ⟪a n i,a n j⟫) atTop (𝓝 0))(hwn : Tendsto (fun n ↦ ‖w n‖) atTop (𝓝 1))(hzn : Tendsto (fun n ↦ ‖z n‖) atTop (𝓝 1))(ha : ∀ j≤K,Tendsto (fun n ↦ ⟪a n j,w n⟫) atTop (𝓝 (A j)))(hz : ∀ j≤K,Tendsto (fun n ↦ ⟪a n j,z n⟫) atTop (𝓝 0))(hb : Tendsto (fun n ↦ ⟪w n,z n⟫) atTop (𝓝 B)) :Tendsto (fun n ↦⟪gramSchmidtNormed ℝ (a n) K,w n⟫*⟪orthogonalRemainder (gramSchmidtNormed ℝ (a n)) (w n) (K+1),z n⟫+(⟪gramSchmidtNormed ℝ (a n) K,w n⟫^2/Real.sqrt 2)*⟪gramSchmidtNormed ℝ (a n) K,z n⟫) atTop (𝓝 (A K*B)) := byhave hp (j : ℕ) (hj : j≤K) :Tendsto (fun n ↦ ‖gramSchmidtNormed ℝ (a n) j-a n j‖) atTop (𝓝 0) :=gramSchmidtNormed_approx a j (fun i h ↦ hn i (h.trans hj))(fun i l hil hl ↦ hi i l hil (hl.trans hj)) j le_rflhave ha' (j : ℕ) (hj : j≤K) := inner_approx_tendsto (hp j hj) hwn (ha j hj)have hz' (j : ℕ) (hj : j≤K) := inner_approx_tendsto (hp j hj) hzn (hz j hj)have hr := orthogonalRemainder_inner_tendsto (fun n ↦ gramSchmidtNormed ℝ (a n)) w z(K+1) A B (fun j hj ↦ ha' j (by omega)) (fun j hj ↦ hz' j (by omega)) hbsimpa only [mul_zero,add_zero] using((ha' K le_rfl).mul hr).add (((ha' K le_rfl).pow 2 |>.div_const _).mul (hz' K le_rfl))end Limitend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152import Mathlibimport OAI.Probability.SKValue.GroundState.RotatedCoefficientsimport OAI.Probability.SKValue.GroundState.ExponentialMomentsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology ENNReal NNReal BigOperatorsnamespace SKValueGlemma finiteMaximum_le_iff {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (t : ℝ) :finiteMaximum x ≤ t ↔ ∀ i, x i≤t := byconstructor· intro h i; exact (le_finiteMaximum x i).trans h· intro h; obtain ⟨i,hi⟩ := exists_finiteMaximum x; simpa only [←hi] using h inoncomputable def logSumExp {ι : Type*} [Fintype ι] (d : ι → ℝ) : ℝ :=Real.log (∑ i, Real.exp (d i))lemma exp_sum_pos {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) :0<∑ i, Real.exp (d i) := Finset.sum_pos (fun _ _ ↦ Real.exp_pos _) Finset.univ_nonemptylemma gumbel_shift_cdf (d t : ℝ) :cdf (gumbelLaw.map (fun x ↦ x+d)) t=Real.exp (-Real.exp (-(t-d))) := byhave : IsProbabilityMeasure (gumbelLaw.map (fun x ↦ x+d)) := inferInstancerw [cdf_eq_real,measureReal_def,Measure.map_apply (by fun_prop) measurableSet_Iic]have he : (fun x : ℝ ↦ x+d) ⁻¹' Iic t=Iic (t-d) := by ext x; simp only [mem_preimage,mem_Iic]; constructor <;> intro h <;> linarithrw [he,←measureReal_def,←cdf_eq_real,gumbel_cdf]lemma gumbel_max_cdf {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) (t : ℝ) :cdf ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) t=Real.exp (-Real.exp (-(t-logSumExp d))) := byhave hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurablehave : IsProbabilityMeasure ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := inferInstancerw [cdf_eq_real,measureReal_def,Measure.map_apply hm measurableSet_Iic]have he : (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) ⁻¹' Iic t=univ.pi (fun i ↦ Iic (t-d i)) := byext zsimp only [mem_preimage,mem_Iic,finiteMaximum_le_iff,mem_univ_pi]exact forall_congr' (fun i ↦ by constructor <;> intro h <;> linarith)rw [he,Measure.pi_pi,ENNReal.toReal_prod]simp only [←measureReal_def,←cdf_eq_real,gumbel_cdf]rw [←Real.exp_sum]congr 1simp only [logSumExp]rw [show -(t-Real.log (∑ i, Real.exp (d i)))=-t+Real.log (∑ i, Real.exp (d i)) by ring,Real.exp_add,Real.exp_log (exp_sum_pos d)]simp_rw [show ∀ i, -(t-d i)=-t+d i by intro i; ring,Real.exp_add]rw [Finset.sum_neg_distrib,←Finset.mul_sum]theorem gumbel_max_law {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) :(Measure.pi (fun _ : ι ↦ gumbelLaw)).map(fun z ↦ finiteMaximum (fun i ↦ d i+z i))=gumbelLaw.map (fun x ↦ x+logSumExp d) := byhave hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurablehave : IsProbabilityMeasure ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := inferInstancehave : IsProbabilityMeasure (gumbelLaw.map (fun x ↦ x+logSumExp d)) := inferInstanceapply prob_measure_eq_of_cdfintro trw [gumbel_max_cdf,gumbel_shift_cdf]lemma gumbel_max_integrable {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) :Integrable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i))(Measure.pi (fun _ : ι ↦ gumbelLaw)) := byhave hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurablehave h : Integrable (fun x : ℝ ↦ x) ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := byrw [gumbel_max_law,integrable_map_measure (by fun_prop) (by fun_prop)]exact gumbel_integrable.add (integrable_const _)exact (integrable_map_measure (by fun_prop) hm.aemeasurable).mp hlemma integral_gumbel_max {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) :(∫ z, finiteMaximum (fun i ↦ d i+z i) ∂Measure.pi (fun _ : ι ↦ gumbelLaw))=gumbelMean+logSumExp d := byhave hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurablehave h := congrArg (fun μ : Measure ℝ ↦ ∫ x, x ∂μ) (gumbel_max_law d)rw [integral_map hm.aemeasurable (by fun_prop),integral_map (by fun_prop) (by fun_prop)] at hrw [h,integral_add gumbel_integrable (integrable_const _)]simp only [integral_const,probReal_univ,smul_eq_mul,one_mul,gumbelMean]end SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology BigOperators ENNReal NNRealnamespace SKValueGlemma log_tangent_bound {x m : ℝ} (hx : 0<x) (hm : 0 < m) :Real.log x ≤ x/m-1+Real.log m := byhave h := Real.log_le_sub_one_of_pos (div_pos hx hm)rw [Real.log_div hx.ne' hm.ne'] at hlinarithlemma log_mean_lower {ι : Type*} [Fintype ι] [Nonempty ι](x : ι → ℝ) (hx : ∀ i, 0<x i) :(∑ i, Real.log (x i))/(Fintype.card ι : ℝ) ≤Real.log ((∑ i, x i)/(Fintype.card ι : ℝ)) := bylet c : ℝ := Fintype.card ιhave hc : 0<c := by dsimp [c]; positivitylet m : ℝ := (∑ i, x i)/chave hm : 0 < m := div_pos (Finset.sum_pos (fun i _ ↦ hx i) Finset.univ_nonempty) hchave h := Finset.sum_le_sum (s := Finset.univ) (fun i _ ↦ log_tangent_bound (hx i) hm)have hs : (∑ i, x i) ≠ 0 := (Finset.sum_pos (fun i _ ↦ hx i) Finset.univ_nonempty).ne'have he : (∑ i, (x i/m-1+Real.log m))=c*Real.log m := byrw [Finset.sum_add_distrib,Finset.sum_sub_distrib,←Finset.sum_div]simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul]dsimp [m,c]field_simp [hs]ringrw [he] at hexact (div_le_iff₀ hc).mpr (by nlinarith)lemma integral_log_le_log_integral {Ω : Type*} [MeasurableSpace Ω]{μ : Measure Ω} [IsProbabilityMeasure μ] {f : Ω → ℝ}(hf : Integrable f μ) (hl : Integrable (fun ω ↦ Real.log (f ω)) μ)(hp : ∀ᵐ ω ∂μ, 0<f ω) :(∫ ω, Real.log (f ω) ∂μ) ≤ Real.log (∫ ω, f ω ∂μ) := byhave hm : 0<∫ ω, f ω ∂μ := integral_pos_iff_support_of_nonneg_ae (hp.mono (fun _ h ↦ h.le)) hf |>.mpr (byhave hs : Function.support f =ᵐ[μ] univ := hp.mono (fun ω hω ↦ by apply propext; change (f ω≠0) ↔ True; simp [hω.ne'])rw [measure_congr hs]simp)have h := integral_mono_ae hl(((hf.div_const (∫ ω, f ω ∂μ)).sub (integrable_const 1)).add(integrable_const (Real.log (∫ ω, f ω ∂μ))))(hp.mono (fun ω hω ↦ log_tangent_bound hω hm))have he : (∫ ω, (f ω/(∫ ω, f ω ∂μ)-1)+Real.log (∫ ω, f ω ∂μ) ∂μ)=Real.log (∫ ω, f ω ∂μ) := byrw [integral_add (f := fun ω ↦ f ω/(∫ ω, f ω ∂μ)-1)(g := fun _ ↦ Real.log (∫ ω, f ω ∂μ))((hf.div_const _).sub (integrable_const 1)) (integrable_const _),integral_sub (f := fun ω ↦ f ω/(∫ ω, f ω ∂μ)) (g := fun _ ↦ (1 : ℝ))(hf.div_const _) (integrable_const 1),integral_div]simp [hm.ne']exact h.trans_eq heend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152import Mathlibimport OAI.Probability.SKValue.GroundState.RotatedCoefficientsimport OAI.Probability.SKValue.GroundState.ExponentialMomentsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology ENNReal NNReal BigOperatorsnamespace SKValueGlemma finiteMaximum_le_iff {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (t : ℝ) :finiteMaximum x ≤ t ↔ ∀ i, x i≤t := byconstructor· intro h i; exact (le_finiteMaximum x i).trans h· intro h; obtain ⟨i,hi⟩ := exists_finiteMaximum x; simpa only [←hi] using h inoncomputable def logSumExp {ι : Type*} [Fintype ι] (d : ι → ℝ) : ℝ :=Real.log (∑ i, Real.exp (d i))lemma exp_sum_pos {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) :0<∑ i, Real.exp (d i) := Finset.sum_pos (fun _ _ ↦ Real.exp_pos _) Finset.univ_nonemptylemma gumbel_shift_cdf (d t : ℝ) :cdf (gumbelLaw.map (fun x ↦ x+d)) t=Real.exp (-Real.exp (-(t-d))) := byhave : IsProbabilityMeasure (gumbelLaw.map (fun x ↦ x+d)) := inferInstancerw [cdf_eq_real,measureReal_def,Measure.map_apply (by fun_prop) measurableSet_Iic]have he : (fun x : ℝ ↦ x+d) ⁻¹' Iic t=Iic (t-d) := by ext x; simp only [mem_preimage,mem_Iic]; constructor <;> intro h <;> linarithrw [he,←measureReal_def,←cdf_eq_real,gumbel_cdf]lemma gumbel_max_cdf {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) (t : ℝ) :cdf ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) t=Real.exp (-Real.exp (-(t-logSumExp d))) := byhave hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurablehave : IsProbabilityMeasure ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := inferInstancerw [cdf_eq_real,measureReal_def,Measure.map_apply hm measurableSet_Iic]have he : (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) ⁻¹' Iic t=univ.pi (fun i ↦ Iic (t-d i)) := byext zsimp only [mem_preimage,mem_Iic,finiteMaximum_le_iff,mem_univ_pi]exact forall_congr' (fun i ↦ by constructor <;> intro h <;> linarith)rw [he,Measure.pi_pi,ENNReal.toReal_prod]simp only [←measureReal_def,←cdf_eq_real,gumbel_cdf]rw [←Real.exp_sum]congr 1simp only [logSumExp]rw [show -(t-Real.log (∑ i, Real.exp (d i)))=-t+Real.log (∑ i, Real.exp (d i)) by ring,Real.exp_add,Real.exp_log (exp_sum_pos d)]simp_rw [show ∀ i, -(t-d i)=-t+d i by intro i; ring,Real.exp_add]rw [Finset.sum_neg_distrib,←Finset.mul_sum]theorem gumbel_max_law {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) :(Measure.pi (fun _ : ι ↦ gumbelLaw)).map(fun z ↦ finiteMaximum (fun i ↦ d i+z i))=gumbelLaw.map (fun x ↦ x+logSumExp d) := byhave hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurablehave : IsProbabilityMeasure ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := inferInstancehave : IsProbabilityMeasure (gumbelLaw.map (fun x ↦ x+logSumExp d)) := inferInstanceapply prob_measure_eq_of_cdfintro trw [gumbel_max_cdf,gumbel_shift_cdf]lemma gumbel_max_integrable {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) :Integrable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i))(Measure.pi (fun _ : ι ↦ gumbelLaw)) := byhave hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurablehave h : Integrable (fun x : ℝ ↦ x) ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := byrw [gumbel_max_law,integrable_map_measure (by fun_prop) (by fun_prop)]exact gumbel_integrable.add (integrable_const _)exact (integrable_map_measure (by fun_prop) hm.aemeasurable).mp hlemma integral_gumbel_max {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) :(∫ z, finiteMaximum (fun i ↦ d i+z i) ∂Measure.pi (fun _ : ι ↦ gumbelLaw))=gumbelMean+logSumExp d := byhave hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurablehave h := congrArg (fun μ : Measure ℝ ↦ ∫ x, x ∂μ) (gumbel_max_law d)rw [integral_map hm.aemeasurable (by fun_prop),integral_map (by fun_prop) (by fun_prop)] at hrw [h,integral_add gumbel_integrable (integrable_const _)]simp only [integral_const,probReal_univ,smul_eq_mul,one_mul,gumbelMean]end SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology BigOperators ENNReal NNRealnamespace SKValueGlemma log_tangent_bound {x m : ℝ} (hx : 0<x) (hm : 0 < m) :Real.log x ≤ x/m-1+Real.log m := byhave h := Real.log_le_sub_one_of_pos (div_pos hx hm)rw [Real.log_div hx.ne' hm.ne'] at hlinarithlemma log_mean_lower {ι : Type*} [Fintype ι] [Nonempty ι](x : ι → ℝ) (hx : ∀ i, 0<x i) :(∑ i, Real.log (x i))/(Fintype.card ι : ℝ) ≤Real.log ((∑ i, x i)/(Fintype.card ι : ℝ)) := bylet c : ℝ := Fintype.card ιhave hc : 0<c := by dsimp [c]; positivitylet m : ℝ := (∑ i, x i)/chave hm : 0 < m := div_pos (Finset.sum_pos (fun i _ ↦ hx i) Finset.univ_nonempty) hchave h := Finset.sum_le_sum (s := Finset.univ) (fun i _ ↦ log_tangent_bound (hx i) hm)have hs : (∑ i, x i) ≠ 0 := (Finset.sum_pos (fun i _ ↦ hx i) Finset.univ_nonempty).ne'have he : (∑ i, (x i/m-1+Real.log m))=c*Real.log m := byrw [Finset.sum_add_distrib,Finset.sum_sub_distrib,←Finset.sum_div]simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul]dsimp [m,c]field_simp [hs]ringrw [he] at hexact (div_le_iff₀ hc).mpr (by nlinarith)lemma integral_log_le_log_integral {Ω : Type*} [MeasurableSpace Ω]{μ : Measure Ω} [IsProbabilityMeasure μ] {f : Ω → ℝ}(hf : Integrable f μ) (hl : Integrable (fun ω ↦ Real.log (f ω)) μ)(hp : ∀ᵐ ω ∂μ, 0<f ω) :(∫ ω, Real.log (f ω) ∂μ) ≤ Real.log (∫ ω, f ω ∂μ) := byhave hm : 0<∫ ω, f ω ∂μ := integral_pos_iff_support_of_nonneg_ae (hp.mono (fun _ h ↦ h.le)) hf |>.mpr (byhave hs : Function.support f =ᵐ[μ] univ := hp.mono (fun ω hω ↦ by apply propext; change (f ω≠0) ↔ True; simp [hω.ne'])rw [measure_congr hs]simp)have h := integral_mono_ae hl(((hf.div_const (∫ ω, f ω ∂μ)).sub (integrable_const 1)).add(integrable_const (Real.log (∫ ω, f ω ∂μ))))(hp.mono (fun ω hω ↦ log_tangent_bound hω hm))have he : (∫ ω, (f ω/(∫ ω, f ω ∂μ)-1)+Real.log (∫ ω, f ω ∂μ) ∂μ)=Real.log (∫ ω, f ω ∂μ) := byrw [integral_add (f := fun ω ↦ f ω/(∫ ω, f ω ∂μ)-1)(g := fun _ ↦ Real.log (∫ ω, f ω ∂μ))((hf.div_const _).sub (integrable_const 1)) (integrable_const _),integral_sub (f := fun ω ↦ f ω/(∫ ω, f ω ∂μ)) (g := fun _ ↦ (1 : ℝ))(hf.div_const _) (integrable_const 1),integral_div]simp [hm.ne']exact h.trans_eq heend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132import Mathlibimport OAI.Probability.SKValue.GroundState.FiniteBranchingnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology ENNReal NNReal BigOperatorsnamespace SKValueGlemma lipschitz_integrable_comp {Ω : Type*} [MeasurableSpace Ω]{μ : Measure Ω} [IsFiniteMeasure μ] {f : Ω → ℝ} (hi : Integrable f μ){ψ : ℝ → ℝ} {L : ℝ≥0} (hψ : LipschitzWith L ψ) : Integrable (fun ω ↦ ψ (f ω)) μ := byapply ((hi.norm.const_mul (L : ℝ)).add (integrable_const ‖ψ 0‖)).mono'(hψ.continuous.comp_aestronglyMeasurable hi.aestronglyMeasurable)exact Eventually.of_forall (fun ω ↦ byhave h : ‖ψ (f ω)-ψ 0‖ ≤ (L : ℝ)*‖f ω‖ := by simpa only [sub_zero] using hψ.norm_sub_le (f ω) 0have htri := norm_add_le (ψ (f ω)-ψ 0) (ψ 0)simp only [sub_add_cancel] at htrichange ‖ψ (f ω)‖ ≤ (L : ℝ)*‖f ω‖+‖ψ 0‖linarith)noncomputable def gumbelSmooth (m : ℝ) (ψ : ℝ → ℝ) (s : ℝ) : ℝ :=∫ g, ψ (g/m+s) ∂gumbelLawlemma gumbelSmooth_lipschitz {m : ℝ} {ψ : ℝ → ℝ} {L : ℝ≥0}(hψ : LipschitzWith L ψ) : LipschitzWith L (gumbelSmooth m ψ) := byrw [lipschitzWith_iff_dist_le_mul]intro x yhave hix := lipschitz_integrable_comp ((gumbel_integrable.div_const m).add (integrable_const x)) hψhave hiy := lipschitz_integrable_comp ((gumbel_integrable.div_const m).add (integrable_const y)) hψchange |(∫ g, ψ (g/m+x) ∂gumbelLaw)-(∫ g, ψ (g/m+y) ∂gumbelLaw)|≤L*|x-y|rw [←integral_sub (f := fun g ↦ ψ (g/m+x)) (g := fun g ↦ ψ (g/m+y)) hix hiy]have hbound (g : ℝ) : ‖ψ (g/m+x)-ψ (g/m+y)‖≤(L : ℝ)*|x-y| := bysimpa only [Real.norm_eq_abs,add_sub_add_left_eq_sub] using hψ.norm_sub_le (g/m+x) (g/m+y)simpa using norm_integral_le_of_norm_le_const (μ := gumbelLaw) (Eventually.of_forall hbound)lemma integral_comp_diff_le {Ω : Type*} [MeasurableSpace Ω]{μ : Measure Ω} [IsProbabilityMeasure μ] {s : Ω → ℝ} (hi : Integrable s μ){ψ : ℝ → ℝ} {L : ℝ≥0} (hψ : LipschitzWith L ψ) (c : ℝ) :|(∫ ω,ψ (s ω) ∂μ)-ψ c|≤(L : ℝ)*(∫ ω,|s ω-c| ∂μ) := byhave his := lipschitz_integrable_comp hi hψhave hie : Integrable (fun ω ↦ |s ω-c|) μ := (hi.sub (integrable_const c)).abscalc_ = |∫ ω,ψ (s ω)-ψ c ∂μ| := by rw [integral_sub his (integrable_const _)]; simp_ ≤ ∫ ω,|ψ (s ω)-ψ c| ∂μ := by simpa only [Real.norm_eq_abs] usingnorm_integral_le_integral_norm (fun ω ↦ ψ (s ω)-ψ c)_ ≤ ∫ ω,(L : ℝ)*|s ω-c| ∂μ := integral_mono(his.sub (integrable_const _)).abs (hie.const_mul _)(fun ω ↦ by simpa only [Real.norm_eq_abs] using hψ.norm_sub_le (s ω) c)_ = _ := integral_const_mul _ _lemma scaled_gumbel_test_integral {ι : Type*} [Fintype ι] [Nonempty ι](d : ι → ℝ) {m : ℝ} (hm : 0 < m) (ψ : ℝ → ℝ) (hψ : Measurable ψ) :(∫ z,ψ (finiteMaximum (fun i ↦ d i+z i/m)-Real.log (Fintype.card ι : ℝ)/m)∂Measure.pi (fun _ : ι ↦ gumbelLaw))=gumbelSmooth m ψ (Real.log ((∑ i,Real.exp (m*d i))/(Fintype.card ι : ℝ))/m) := byhave hmmax : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ m*d i+z i)) :=(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurablehave ht : Measurable (fun y : ℝ ↦ ψ (y/m-Real.log (Fintype.card ι : ℝ)/m)) := by fun_prophave h := congrArg (fun μ : Measure ℝ ↦ ∫ y,ψ (y/m-Real.log (Fintype.card ι : ℝ)/m) ∂μ)(gumbel_max_law (fun i ↦ m*d i))rw [integral_map hmmax.aemeasurable ht.aestronglyMeasurable,integral_map (by fun_prop) ht.aestronglyMeasurable] at hhave he (z : ι → ℝ) : finiteMaximum (fun i ↦ d i+z i/m)=finiteMaximum (fun i ↦ m*d i+z i)/m := byrw [←finiteMaximum_div_pos _ hm]congr 1; ext i; field_simpsimp_rw [he]rw [h]apply integral_congr_aeexact Eventually.of_forall (fun g ↦ byapply congrArg ψrw [Real.log_div (exp_sum_pos _).ne' (by positivity)]dsimp [logSumExp]ring)theorem marked_branching_limit {Ω : Type*} [MeasurableSpace Ω]{μ : Measure Ω} [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ){m : ℝ} (hm : 0 < m) (hi : Integrable (X 0) μ)(he : Integrable (fun ω ↦ Real.exp (m*X 0 ω)) μ)(hind : Pairwise (Function.onFun (fun x1 x2 ↦ x1 ⟂ᵢ[μ] x2) X))(hid : ∀ i,IdentDistrib (X i) (X 0) μ μ){ψ : ℝ → ℝ} {L : ℝ≥0} (hψ : LipschitzWith L ψ) :Tendsto (fun n ↦ ∫ ω,(∫ z,ψ (finiteMaximum (fun i : Fin (n+1) ↦ X i ω+z i/m)-Real.log (n+1 : ℝ)/m)∂Measure.pi (fun _ : Fin (n+1) ↦ gumbelLaw)) ∂μ)atTop (𝓝 (gumbelSmooth m ψ (Real.log (∫ ω,Real.exp (m*X 0 ω) ∂μ)/m))) := bylet Y := fun i ω ↦ Real.exp (m*X i ω)have hf : Measurable (fun x : ℝ ↦ Real.exp (m*x)) := by fun_prophave hl : Integrable (fun ω ↦ Real.log (Y 0 ω)) μ := bysimpa only [Y,Real.log_exp] using hi.const_mul mhave hiY (i) : Integrable (Y i) μ := ((hid i).comp hf).integrable_iff.mpr hehave hilogY (i) : Integrable (fun ω ↦ Real.log (Y i ω)) μ :=(((hid i).comp hf).comp Real.measurable_log).integrable_iff.mpr hlhave hpY (i) : ∀ᵐ ω ∂μ,0<Y i ω := Eventually.of_forall (fun ω ↦ Real.exp_pos _)have hlim := log_empiricalMean_L1 Y he hl hpY(fun i j hij ↦ (hind hij).comp hf hf) (fun i ↦ (hid i).comp hf)let c := Real.log (∫ ω,Y 0 ω ∂μ)/mlet s := fun n ω ↦ Real.log (empiricalMean Y n ω)/mhave his (n) : Integrable (s n) μ :=(empiricalMean_log_integrable Y hiY hilogY hpY n).div_const mhave herr (n) : (∫ ω,|s n ω-c| ∂μ)=(∫ ω,|Real.log (empiricalMean Y n ω)-Real.log (∫ ω,Y 0 ω ∂μ)| ∂μ)/m := byrw [←integral_div]apply integral_congr_aeexact Eventually.of_forall (fun ω ↦ by dsimp [s,c]; rw [←sub_div,abs_div,abs_of_pos hm])have ht : Tendsto (fun n ↦ ∫ ω,|s n ω-c| ∂μ) atTop (𝓝 0) := bysimpa only [herr,zero_div] using hlim.div_const mhave hg := gumbelSmooth_lipschitz (m := m) hψhave hb (n) := integral_comp_diff_le (his n) hg chave hx : Tendsto (fun n ↦ |(∫ ω,gumbelSmooth m ψ (s n ω) ∂μ)-gumbelSmooth m ψ c|)atTop (𝓝 0) := squeeze_zero (fun n ↦ abs_nonneg _) hb (by simpa using ht.const_mul (L : ℝ))have hconv : Tendsto (fun n ↦ ∫ ω,gumbelSmooth m ψ (s n ω) ∂μ) atTop(𝓝 (gumbelSmooth m ψ c)) := tendsto_iff_norm_sub_tendsto_zero.mpr (bysimpa only [Real.norm_eq_abs] using hx)have heq (n : ℕ) : (∫ ω,(∫ z,ψ (finiteMaximum (fun i : Fin (n+1) ↦ X i ω+z i/m)-Real.log (n+1 : ℝ)/m) ∂Measure.pi (fun _ : Fin (n+1) ↦ gumbelLaw)) ∂μ)=∫ ω,gumbelSmooth m ψ (s n ω) ∂μ := byapply integral_congr_aeexact Eventually.of_forall (fun ω ↦ byhave hh := scaled_gumbel_test_integral (fun i : Fin (n+1) ↦ X i ω) hm ψ hψ.continuous.measurablerw [Fin.sum_univ_eq_sum_range (fun i ↦ Real.exp (m*X i ω))] at hhsimpa only [Fintype.card_fin,Nat.cast_add,Nat.cast_one,empiricalMean,Y,s] using hh)simpa only [heq,c,Y] using hconvend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132import Mathlibimport OAI.Probability.SKValue.GroundState.FiniteBranchingnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology ENNReal NNReal BigOperatorsnamespace SKValueGlemma lipschitz_integrable_comp {Ω : Type*} [MeasurableSpace Ω]{μ : Measure Ω} [IsFiniteMeasure μ] {f : Ω → ℝ} (hi : Integrable f μ){ψ : ℝ → ℝ} {L : ℝ≥0} (hψ : LipschitzWith L ψ) : Integrable (fun ω ↦ ψ (f ω)) μ := byapply ((hi.norm.const_mul (L : ℝ)).add (integrable_const ‖ψ 0‖)).mono'(hψ.continuous.comp_aestronglyMeasurable hi.aestronglyMeasurable)exact Eventually.of_forall (fun ω ↦ byhave h : ‖ψ (f ω)-ψ 0‖ ≤ (L : ℝ)*‖f ω‖ := by simpa only [sub_zero] using hψ.norm_sub_le (f ω) 0have htri := norm_add_le (ψ (f ω)-ψ 0) (ψ 0)simp only [sub_add_cancel] at htrichange ‖ψ (f ω)‖ ≤ (L : ℝ)*‖f ω‖+‖ψ 0‖linarith)noncomputable def gumbelSmooth (m : ℝ) (ψ : ℝ → ℝ) (s : ℝ) : ℝ :=∫ g, ψ (g/m+s) ∂gumbelLawlemma gumbelSmooth_lipschitz {m : ℝ} {ψ : ℝ → ℝ} {L : ℝ≥0}(hψ : LipschitzWith L ψ) : LipschitzWith L (gumbelSmooth m ψ) := byrw [lipschitzWith_iff_dist_le_mul]intro x yhave hix := lipschitz_integrable_comp ((gumbel_integrable.div_const m).add (integrable_const x)) hψhave hiy := lipschitz_integrable_comp ((gumbel_integrable.div_const m).add (integrable_const y)) hψchange |(∫ g, ψ (g/m+x) ∂gumbelLaw)-(∫ g, ψ (g/m+y) ∂gumbelLaw)|≤L*|x-y|rw [←integral_sub (f := fun g ↦ ψ (g/m+x)) (g := fun g ↦ ψ (g/m+y)) hix hiy]have hbound (g : ℝ) : ‖ψ (g/m+x)-ψ (g/m+y)‖≤(L : ℝ)*|x-y| := bysimpa only [Real.norm_eq_abs,add_sub_add_left_eq_sub] using hψ.norm_sub_le (g/m+x) (g/m+y)simpa using norm_integral_le_of_norm_le_const (μ := gumbelLaw) (Eventually.of_forall hbound)lemma integral_comp_diff_le {Ω : Type*} [MeasurableSpace Ω]{μ : Measure Ω} [IsProbabilityMeasure μ] {s : Ω → ℝ} (hi : Integrable s μ){ψ : ℝ → ℝ} {L : ℝ≥0} (hψ : LipschitzWith L ψ) (c : ℝ) :|(∫ ω,ψ (s ω) ∂μ)-ψ c|≤(L : ℝ)*(∫ ω,|s ω-c| ∂μ) := byhave his := lipschitz_integrable_comp hi hψhave hie : Integrable (fun ω ↦ |s ω-c|) μ := (hi.sub (integrable_const c)).abscalc_ = |∫ ω,ψ (s ω)-ψ c ∂μ| := by rw [integral_sub his (integrable_const _)]; simp_ ≤ ∫ ω,|ψ (s ω)-ψ c| ∂μ := by simpa only [Real.norm_eq_abs] usingnorm_integral_le_integral_norm (fun �� ↦ ψ (s ω)-ψ c)_ ≤ ∫ ω,(L : ℝ)*|s ω-c| ∂μ := integral_mono(his.sub (integrable_const _)).abs (hie.const_mul _)(fun ω ↦ by simpa only [Real.norm_eq_abs] using hψ.norm_sub_le (s ω) c)_ = _ := integral_const_mul _ _lemma scaled_gumbel_test_integral {ι : Type*} [Fintype ι] [Nonempty ι](d : ι → ℝ) {m : ℝ} (hm : 0 < m) (ψ : ℝ → ℝ) (hψ : Measurable ψ) :(∫ z,ψ (finiteMaximum (fun i ↦ d i+z i/m)-Real.log (Fintype.card ι : ℝ)/m)∂Measure.pi (fun _ : ι ↦ gumbelLaw))=gumbelSmooth m ψ (Real.log ((∑ i,Real.exp (m*d i))/(Fintype.card ι : ℝ))/m) := byhave hmmax : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ m*d i+z i)) :=(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurablehave ht : Measurable (fun y : ℝ ↦ ψ (y/m-Real.log (Fintype.card ι : ℝ)/m)) := by fun_prophave h := congrArg (fun μ : Measure ℝ ↦ ∫ y,ψ (y/m-Real.log (Fintype.card ι : ℝ)/m) ∂μ)(gumbel_max_law (fun i ↦ m*d i))rw [integral_map hmmax.aemeasurable ht.aestronglyMeasurable,integral_map (by fun_prop) ht.aestronglyMeasurable] at hhave he (z : ι → ℝ) : finiteMaximum (fun i ↦ d i+z i/m)=finiteMaximum (fun i ↦ m*d i+z i)/m := byrw [←finiteMaximum_div_pos _ hm]congr 1; ext i; field_simpsimp_rw [he]rw [h]apply integral_congr_aeexact Eventually.of_forall (fun g ↦ byapply congrArg ψrw [Real.log_div (exp_sum_pos _).ne' (by positivity)]dsimp [logSumExp]ring)theorem marked_branching_limit {Ω : Type*} [MeasurableSpace Ω]{μ : Measure Ω} [IsProbabilityMeasure μ] (X : ℕ → Ω → ℝ){m : ℝ} (hm : 0 < m) (hi : Integrable (X 0) μ)(he : Integrable (fun ω ↦ Real.exp (m*X 0 ω)) μ)(hind : Pairwise (Function.onFun (fun x1 x2 ↦ x1 ⟂ᵢ[μ] x2) X))(hid : ∀ i,IdentDistrib (X i) (X 0) μ μ){ψ : ℝ → ℝ} {L : ℝ≥0} (hψ : LipschitzWith L ψ) :Tendsto (fun n ↦ ∫ ω,(∫ z,ψ (finiteMaximum (fun i : Fin (n+1) ↦ X i ω+z i/m)-Real.log (n+1 : ℝ)/m)∂Measure.pi (fun _ : Fin (n+1) ↦ gumbelLaw)) ∂μ)atTop (𝓝 (gumbelSmooth m ψ (Real.log (∫ ω,Real.exp (m*X 0 ω) ∂μ)/m))) := bylet Y := fun i ω ↦ Real.exp (m*X i ω)have hf : Measurable (fun x : ℝ ↦ Real.exp (m*x)) := by fun_prophave hl : Integrable (fun ω ↦ Real.log (Y 0 ω)) μ := bysimpa only [Y,Real.log_exp] using hi.const_mul mhave hiY (i) : Integrable (Y i) μ := ((hid i).comp hf).integrable_iff.mpr hehave hilogY (i) : Integrable (fun ω ↦ Real.log (Y i ω)) μ :=(((hid i).comp hf).comp Real.measurable_log).integrable_iff.mpr hlhave hpY (i) : ∀ᵐ ω ∂μ,0<Y i ω := Eventually.of_forall (fun ω ↦ Real.exp_pos _)have hlim := log_empiricalMean_L1 Y he hl hpY(fun i j hij ↦ (hind hij).comp hf hf) (fun i ↦ (hid i).comp hf)let c := Real.log (∫ ω,Y 0 ω ∂μ)/mlet s := fun n ω ↦ Real.log (empiricalMean Y n ω)/mhave his (n) : Integrable (s n) μ :=(empiricalMean_log_integrable Y hiY hilogY hpY n).div_const mhave herr (n) : (∫ ω,|s n ω-c| ∂μ)=(∫ ω,|Real.log (empiricalMean Y n ω)-Real.log (∫ ω,Y 0 ω ∂μ)| ∂μ)/m := byrw [←integral_div]apply integral_congr_aeexact Eventually.of_forall (fun ω ↦ by dsimp [s,c]; rw [←sub_div,abs_div,abs_of_pos hm])have ht : Tendsto (fun n ↦ ∫ ω,|s n ω-c| ∂μ) atTop (𝓝 0) := bysimpa only [herr,zero_div] using hlim.div_const mhave hg := gumbelSmooth_lipschitz (m := m) hψhave hb (n) := integral_comp_diff_le (his n) hg chave hx : Tendsto (fun n ↦ |(∫ ω,gumbelSmooth m ψ (s n ω) ∂μ)-gumbelSmooth m ψ c|)atTop (𝓝 0) := squeeze_zero (fun n ↦ abs_nonneg _) hb (by simpa using ht.const_mul (L : ℝ))have hconv : Tendsto (fun n ↦ ∫ ω,gumbelSmooth m ψ (s n ω) ∂μ) atTop(𝓝 (gumbelSmooth m ψ c)) := tendsto_iff_norm_sub_tendsto_zero.mpr (bysimpa only [Real.norm_eq_abs] using hx)have heq (n : ℕ) : (∫ ω,(∫ z,ψ (finiteMaximum (fun i : Fin (n+1) ↦ X i ω+z i/m)-Real.log (n+1 : ℝ)/m) ∂Measure.pi (fun _ : Fin (n+1) ↦ gumbelLaw)) ∂μ)=∫ ω,gumbelSmooth m ψ (s n ω) ∂μ := byapply integral_congr_aeexact Eventually.of_forall (fun ω ↦ byhave hh := scaled_gumbel_test_integral (fun i : Fin (n+1) ↦ X i ω) hm ψ hψ.continuous.measurablerw [Fin.sum_univ_eq_sum_range (fun i ↦ Real.exp (m*X i ω))] at hhsimpa only [Fintype.card_fin,Nat.cast_add,Nat.cast_one,empiricalMean,Y,s] using hh)simpa only [heq,c,Y] using hconvend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import Mathlibimport OAI.Probability.SKValue.Equations.LiteralNormalizerimport OAI.Probability.SKValue.Control.Regularityimport OAI.Probability.SKValue.GroundState.RoundingSpinnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuetheorem shiftedCoefficientSum_le_groundState (W : BrownianSpace) (γ : OrderParameter){T : ℝ} (hT : 0≤T) (hT1 : T<1) {N : ℕ} (hN : 0<N)(hpos : ∀ j<N,0<∫ z,(rawCoefficient W γ T N j z)^2 ∂gaussianProduct (Fin (N+1))) :shiftedCoefficientSum W γ T N≤groundStateValue := byobtain ⟨Kv,Lv,K,L,D,Lu,La,hV,hG,hD,hLu,hLa,hDb,hu,ha⟩ := sourceStripRegularity W γ T ⟨hT,hT1⟩rw [literal_shiftedCoefficientSum]exact normalized_shifted_sum_le_groundState(fun j : Fin N ↦ meshRaw T N γ.coeff (gradient W γ) j)(meshTerminal T N γ.coeff (gradient W γ))(fun j ↦ mesh_raw_measurable hT hG hN j.isLt.le)(fun j ↦ mesh_raw_depends T j.isLt.le γ.coeff (gradient W γ))(fun j ↦ mesh_raw_memLp hT hG hDb hN j.isLt.le)(fun j ↦ hpos j j.isLt)(mesh_terminal_measurable hT hG hN) (mesh_terminal_depends T N γ.coeff (gradient W γ))end SKValueendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma finiteMaximum_prod_add {ι Λ : Type*} [Fintype ι] [Nonempty ι][Fintype Λ] [Nonempty Λ] (f : ι → ℝ) (g : Λ → ℝ) :finiteMaximum (fun p : ι×Λ ↦ f p.1+g p.2)=finiteMaximum f+finiteMaximum g := byapply le_antisymm· obtain ⟨p,hp⟩ := exists_finiteMaximum (fun p : ι×Λ ↦ f p.1+g p.2)rw [←hp]exact add_le_add (le_finiteMaximum f p.1) (le_finiteMaximum g p.2)· obtain ⟨i,hi⟩ := exists_finiteMaximum fobtain ⟨a,ha⟩ := exists_finiteMaximum grw [←hi,←ha]exact le_finiteMaximum (fun p : ι×Λ ↦ f p.1+g p.2) (i,a)lemma finiteMaximum_prod_curry {ι Λ : Type*} [Fintype ι] [Nonempty ι][Fintype Λ] [Nonempty Λ] (f : ι×Λ → ℝ) :finiteMaximum f=finiteMaximum (fun a ↦ finiteMaximum (fun i ↦ f (i,a))) := byapply le_antisymm· obtain ⟨p,hp⟩ := exists_finiteMaximum frw [←hp]exact (le_finiteMaximum (fun i ↦ f (i,p.2)) p.1).trans(le_finiteMaximum (fun a ↦ finiteMaximum (fun i ↦ f (i,a))) p.2)· obtain ⟨a,ha⟩ := exists_finiteMaximum (fun a ↦ finiteMaximum (fun i ↦ f (i,a)))obtain ⟨i,hi⟩ := exists_finiteMaximum (fun i ↦ f (i,a))rw [←ha,←hi]exact le_finiteMaximum f (i,a)lemma spinMaximum_eq_sum_abs {ι : Type*} [Fintype ι] (x : ι → ℝ) :finiteMaximum (fun σ : ι → Bool ↦ ∑ i, spin (σ i)*x i)=∑ i, |x i| := byclassicalapply le_antisymm· obtain ⟨σ,hσ⟩ := exists_finiteMaximum (fun σ : ι → Bool ↦ ∑ i, spin (σ i)*x i)rw [←hσ]apply Finset.sum_le_sumintro i _calc_ ≤ |spin (σ i)*x i| := le_abs_self __ = _ := by rw [abs_mul,abs_spin,one_mul]· let σ : ι → Bool := fun i ↦ decide (0≤x i)have he (i : ι) : spin (σ i)*x i=|x i| := byby_cases h : 0≤x i· simp [σ,spin,h,abs_of_nonneg h]· simp [σ,spin,h,abs_of_neg (lt_of_not_ge h)]simpa only [he] using le_finiteMaximum (fun σ : ι → Bool ↦ ∑ i, spin (σ i)*x i) σnoncomputable def leafField {Λ κ : Type*} [Fintype κ] {n : ℕ}(v : Λ → κ → ℝ) (z : Fin n×κ → ℝ) (α : Λ) (i : Fin n) : ℝ :=∑ k, v α k*z (i,k)lemma linearProcess_leafField {Λ κ : Type*} [Fintype κ] (n : ℕ)(v : Λ → κ → ℝ) (z : Fin n×κ → ℝ) (p : (Fin n → Bool)×Λ) :linearProcess (leafFieldCoeff n v) z p=∑ i, spin (p.1 i)*leafField v z p.2 i := bysimp only [linearProcess,leafFieldCoeff,Fintype.sum_prod_type,leafField,Finset.mul_sum]apply Finset.sum_congr rflintro i _apply Finset.sum_congr rflintro k _ringlemma leafField_max {Λ κ : Type*} [Fintype Λ] [Nonempty Λ] [Fintype κ](n : ℕ) (v : Λ → κ → ℝ) (d : Λ → ℝ) (z : Fin n×κ → ℝ) :finiteMaximum (fun p ↦ linearProcess (leafFieldCoeff n v) z p+d p.2)=finiteMaximum (fun α ↦ (∑ i, |leafField v z α i|)+d α) := byrw [finiteMaximum_prod_curry]simp only [linearProcess_leafField,finiteMaximum_add_const,spinMaximum_eq_sum_abs]lemma expected_guerra_max {Λ κ : Type*} [Fintype Λ] [Nonempty Λ] [Fintype κ](n : ℕ) (v : Λ → κ → ℝ) (d : Λ → ℝ) :(∫ z, finiteMaximum (fun p ↦ linearProcess (guerraCoeff n v) z p+d p.2)∂gaussianProduct ((Fin n×Fin n)⊕(κ×κ))) = expectedMaximum n+∫ z, finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n v) z α+d α)∂gaussianProduct (κ×κ) := byhave he := measurePreserving_sumPiEquivProdPi_symm(fun _ : (Fin n×Fin n)⊕(κ×κ) ↦ standardGaussian)change (∫ z, finiteMaximum (fun p ↦ linearProcess (guerraCoeff n v) z p+d p.2)∂Measure.pi (fun _ : (Fin n×Fin n)⊕(κ×κ) ↦ standardGaussian)) = _rw [←he.integral_comp' (fun z ↦ finiteMaximum (fun p ↦ linearProcess (guerraCoeff n v) z p+d p.2))]have hlin (z : ((Fin n×Fin n) → ℝ)×((κ×κ) → ℝ)) :(fun p ↦ linearProcess (guerraCoeff n v)((MeasurableEquiv.sumPiEquivProdPi (fun _ : (Fin n×Fin n)⊕(κ×κ) ↦ ℝ)).symm z) p+d p.2) =(fun p ↦ linearProcess (hamCoeff n) z.1 p.1+(linearProcess (leafAuxCoeff n v) z.2 p.2+d p.2)) := byfunext psimp [linearProcess,guerraCoeff,Fintype.sum_sum_type,MeasurableEquiv.coe_sumPiEquivProdPi_symm,add_assoc]have hm (z : ((Fin n×Fin n) → ℝ)×((κ×κ) → ℝ)) :finiteMaximum (fun p : (Fin n → Bool)×Λ ↦ linearProcess (hamCoeff n) z.1 p.1+(linearProcess (leafAuxCoeff n v) z.2 p.2+d p.2)) =finiteMaximum (linearProcess (hamCoeff n) z.1)+finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n v) z.2 α+d α) :=finiteMaximum_prod_add (linearProcess (hamCoeff n) z.1)(fun α ↦ linearProcess (leafAuxCoeff n v) z.2 α+d α)simp only [hlin,hm]change (∫ z, finiteMaximum (linearProcess (hamCoeff n) z.1)+finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n v) z.2 α+d α)∂(gaussianProduct (Fin n×Fin n)).prod (gaussianProduct (κ×κ))) = _rw [integral_add ((finiteMaximum_integrable (hamCoeff n)).comp_fst _)((affineMaximum_integrable (leafAuxCoeff n v) d).comp_snd _),integral_fun_fst (fun z ↦ finiteMaximum (linearProcess (hamCoeff n) z)),integral_fun_snd (fun z ↦ finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n v) z α+d α))]simp [expectedMaximum]theorem finite_guerra_upper {Λ κ : Type*} [Fintype Λ] [Nonempty Λ] [Fintype κ]{n : ℕ} (hn : 0<n) (v : Λ → κ → ℝ)(hv : ∀ α, ∑ k, (v α k)^2=1) (d : Λ → ℝ) :expectedMaximum n+(∫ z, finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n v) z α+d α)∂gaussianProduct (κ×κ)) ≤∫ z, finiteMaximum (fun α ↦ (∑ i, |leafField v z α i|)+d α)∂gaussianProduct (Fin n×κ) := byhave h := expected_affine_max_le (guerraCoeff n v) (leafFieldCoeff n v)(fun p ↦ d p.2) (guerra_metric_le hn v hv)simpa only [expected_guerra_max,leafField_max] using hend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import Mathlibimport OAI.Probability.SKValue.Equations.LiteralNormalizerimport OAI.Probability.SKValue.Control.Regularityimport OAI.Probability.SKValue.GroundState.RoundingSpinnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuetheorem shiftedCoefficientSum_le_groundState (W : BrownianSpace) (γ : OrderParameter){T : ℝ} (hT : 0≤T) (hT1 : T<1) {N : ℕ} (hN : 0<N)(hpos : ∀ j<N,0<∫ z,(rawCoefficient W γ T N j z)^2 ∂gaussianProduct (Fin (N+1))) :shiftedCoefficientSum W γ T N≤groundStateValue := byobtain ⟨Kv,Lv,K,L,D,Lu,La,hV,hG,hD,hLu,hLa,hDb,hu,ha⟩ := sourceStripRegularity W γ T ⟨hT,hT1⟩rw [literal_shiftedCoefficientSum]exact normalized_shifted_sum_le_groundState(fun j : Fin N ↦ meshRaw T N γ.coeff (gradient W γ) j)(meshTerminal T N γ.coeff (gradient W γ))(fun j ↦ mesh_raw_measurable hT hG hN j.isLt.le)(fun j ↦ mesh_raw_depends T j.isLt.le γ.coeff (gradient W γ))(fun j ↦ mesh_raw_memLp hT hG hDb hN j.isLt.le)(fun j ↦ hpos j j.isLt)(mesh_terminal_measurable hT hG hN) (mesh_terminal_depends T N γ.coeff (gradient W γ))end SKValueendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma finiteMaximum_prod_add {ι Λ : Type*} [Fintype ι] [Nonempty ι][Fintype Λ] [Nonempty Λ] (f : ι → ℝ) (g : Λ → ℝ) :finiteMaximum (fun p : ι×Λ ↦ f p.1+g p.2)=finiteMaximum f+finiteMaximum g := byapply le_antisymm· obtain ⟨p,hp⟩ := exists_finiteMaximum (fun p : ι×Λ ↦ f p.1+g p.2)rw [←hp]exact add_le_add (le_finiteMaximum f p.1) (le_finiteMaximum g p.2)· obtain ⟨i,hi⟩ := exists_finiteMaximum fobtain ⟨a,ha⟩ := exists_finiteMaximum grw [←hi,←ha]exact le_finiteMaximum (fun p : ι×Λ ↦ f p.1+g p.2) (i,a)lemma finiteMaximum_prod_curry {ι Λ : Type*} [Fintype ι] [Nonempty ι][Fintype Λ] [Nonempty Λ] (f : ι×Λ → ℝ) :finiteMaximum f=finiteMaximum (fun a ↦ finiteMaximum (fun i ↦ f (i,a))) := byapply le_antisymm· obtain ⟨p,hp⟩ := exists_finiteMaximum frw [←hp]exact (le_finiteMaximum (fun i ↦ f (i,p.2)) p.1).trans(le_finiteMaximum (fun a ↦ finiteMaximum (fun i ↦ f (i,a))) p.2)· obtain ⟨a,ha⟩ := exists_finiteMaximum (fun a ↦ finiteMaximum (fun i ↦ f (i,a)))obtain ⟨i,hi⟩ := exists_finiteMaximum (fun i ↦ f (i,a))rw [←ha,←hi]exact le_finiteMaximum f (i,a)lemma spinMaximum_eq_sum_abs {ι : Type*} [Fintype ι] (x : ι → ℝ) :finiteMaximum (fun σ : ι → Bool ↦ ∑ i, spin (σ i)*x i)=∑ i, |x i| := byclassicalapply le_antisymm· obtain ⟨σ,hσ⟩ := exists_finiteMaximum (fun σ : ι → Bool ↦ ∑ i, spin (σ i)*x i)rw [←hσ]apply Finset.sum_le_sumintro i _calc_ ≤ |spin (σ i)*x i| := le_abs_self __ = _ := by rw [abs_mul,abs_spin,one_mul]· let σ : ι → Bool := fun i ↦ decide (0≤x i)have he (i : ι) : spin (σ i)*x i=|x i| := byby_cases h : 0≤x i· simp [σ,spin,h,abs_of_nonneg h]· simp [σ,spin,h,abs_of_neg (lt_of_not_ge h)]simpa only [he] using le_finiteMaximum (fun σ : ι → Bool ↦ ∑ i, spin (σ i)*x i) σnoncomputable def leafField {Λ κ : Type*} [Fintype κ] {n : ℕ}(v : Λ → κ → ℝ) (z : Fin n×κ → ℝ) (α : Λ) (i : Fin n) : ℝ :=∑ k, v α k*z (i,k)lemma linearProcess_leafField {Λ κ : Type*} [Fintype κ] (n : ℕ)(v : Λ → κ → ℝ) (z : Fin n×κ → ℝ) (p : (Fin n → Bool)×Λ) :linearProcess (leafFieldCoeff n v) z p=∑ i, spin (p.1 i)*leafField v z p.2 i := bysimp only [linearProcess,leafFieldCoeff,Fintype.sum_prod_type,leafField,Finset.mul_sum]apply Finset.sum_congr rflintro i _apply Finset.sum_congr rflintro k _ringlemma leafField_max {Λ κ : Type*} [Fintype Λ] [Nonempty Λ] [Fintype κ](n : ℕ) (v : Λ → κ → ℝ) (d : Λ → ℝ) (z : Fin n×κ → ℝ) :finiteMaximum (fun p ↦ linearProcess (leafFieldCoeff n v) z p+d p.2)=finiteMaximum (fun α ↦ (∑ i, |leafField v z α i|)+d α) := byrw [finiteMaximum_prod_curry]simp only [linearProcess_leafField,finiteMaximum_add_const,spinMaximum_eq_sum_abs]lemma expected_guerra_max {Λ κ : Type*} [Fintype Λ] [Nonempty Λ] [Fintype κ](n : ℕ) (v : Λ → κ → ℝ) (d : Λ → ℝ) :(∫ z, finiteMaximum (fun p ↦ linearProcess (guerraCoeff n v) z p+d p.2)∂gaussianProduct ((Fin n×Fin n)⊕(κ×κ))) = expectedMaximum n+∫ z, finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n v) z α+d α)∂gaussianProduct (κ×κ) := byhave he := measurePreserving_sumPiEquivProdPi_symm(fun _ : (Fin n×Fin n)⊕(κ×κ) ↦ standardGaussian)change (∫ z, finiteMaximum (fun p ↦ linearProcess (guerraCoeff n v) z p+d p.2)∂Measure.pi (fun _ : (Fin n×Fin n)⊕(κ×κ) ↦ standardGaussian)) = _rw [←he.integral_comp' (fun z ↦ finiteMaximum (fun p ↦ linearProcess (guerraCoeff n v) z p+d p.2))]have hlin (z : ((Fin n×Fin n) → ℝ)×((κ×κ) → ℝ)) :(fun p ↦ linearProcess (guerraCoeff n v)((MeasurableEquiv.sumPiEquivProdPi (fun _ : (Fin n×Fin n)⊕(κ×κ) ↦ ℝ)).symm z) p+d p.2) =(fun p ↦ linearProcess (hamCoeff n) z.1 p.1+(linearProcess (leafAuxCoeff n v) z.2 p.2+d p.2)) := byfunext psimp [linearProcess,guerraCoeff,Fintype.sum_sum_type,MeasurableEquiv.coe_sumPiEquivProdPi_symm,add_assoc]have hm (z : ((Fin n×Fin n) → ℝ)×((κ×κ) → ℝ)) :finiteMaximum (fun p : (Fin n → Bool)×Λ ↦ linearProcess (hamCoeff n) z.1 p.1+(linearProcess (leafAuxCoeff n v) z.2 p.2+d p.2)) =finiteMaximum (linearProcess (hamCoeff n) z.1)+finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n v) z.2 α+d α) :=finiteMaximum_prod_add (linearProcess (hamCoeff n) z.1)(fun α ↦ linearProcess (leafAuxCoeff n v) z.2 α+d α)simp only [hlin,hm]change (∫ z, finiteMaximum (linearProcess (hamCoeff n) z.1)+finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n v) z.2 α+d α)∂(gaussianProduct (Fin n×Fin n)).prod (gaussianProduct (κ×κ))) = _rw [integral_add ((finiteMaximum_integrable (hamCoeff n)).comp_fst _)((affineMaximum_integrable (leafAuxCoeff n v) d).comp_snd _),integral_fun_fst (fun z ↦ finiteMaximum (linearProcess (hamCoeff n) z)),integral_fun_snd (fun z ↦ finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n v) z α+d α))]simp [expectedMaximum]theorem finite_guerra_upper {Λ κ : Type*} [Fintype Λ] [Nonempty Λ] [Fintype κ]{n : ℕ} (hn : 0<n) (v : Λ → κ → ℝ)(hv : ∀ α, ∑ k, (v α k)^2=1) (d : Λ → ℝ) :expectedMaximum n+(∫ z, finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n v) z α+d α)∂gaussianProduct (κ×κ)) ≤∫ z, finiteMaximum (fun α ↦ (∑ i, |leafField v z α i|)+d α)∂gaussianProduct (Fin n×κ) := byhave h := expected_affine_max_le (guerraCoeff n v) (leafFieldCoeff n v)(fun p ↦ d p.2) (guerra_metric_le hn v hv)simpa only [expected_guerra_max,leafField_max] using hend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165import Mathlibimport OAI.Probability.SKValue.GroundState.RotatedCoefficientsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma expected_logPartition_reindex {ι κ ν : Type*} [Fintype ι] [Fintype κ][Fintype ν] (e : κ ≃ ν) (a : ι → κ → ℝ) :(∫ z, logPartition (linearProcess (fun i k ↦ a i (e.symm k)) z)∂gaussianProduct ν) = ∫ z, logPartition (linearProcess a z) ∂gaussianProduct κ := bysimpa only [linearProcess_reindex] using gaussian_integral_reindex e(fun z ↦ logPartition (linearProcess a z))lemma expected_logPartition_le_orthogonal {ι κ : Type*}[Fintype ι] [Nonempty ι] [Fintype κ] (a b : ι → κ → ℝ)(horth : ∀ i j, (∑ k, (a i k-a j k)*(b i k-b j k)) = 0)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, logPartition (linearProcess a z) ∂gaussianProduct κ) ≤∫ z, logPartition (linearProcess b z) ∂gaussianProduct κ := bylet e := Fintype.equivFin κhave h := expected_logPartition_le_of_pair_distances(fun i k ↦ a i (e.symm k)) (fun i k ↦ b i (e.symm k))(fun i j ↦ byrw [e.symm.sum_comp (fun k ↦ (a i k-a j k)*(b i k-b j k))]exact horth i j)(fun i j ↦ byrw [e.symm.sum_comp (fun k ↦ (a i k-a j k)^2),e.symm.sum_comp (fun k ↦ (b i k-b j k)^2)]exact hdist i j)simpa only [expected_logPartition_reindex] using hlemma expected_logPartition_embedLeft {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν](a : ι → κ → ℝ) :(∫ z, logPartition (linearProcess (embedLeft (ν := ν) a) z) ∂gaussianProduct (κ ⊕ ν)) =∫ z, logPartition (linearProcess a z) ∂gaussianProduct κ := byhave he := measurePreserving_sumPiEquivProdPi_symm (fun _ : κ ⊕ ν ↦ standardGaussian)change (∫ z, logPartition (linearProcess (embedLeft a) z)∂Measure.pi (fun _ : κ ⊕ ν ↦ standardGaussian)) = _rw [← he.integral_comp' (fun z ↦ logPartition (linearProcess (embedLeft a) z))]have hlin (p : (κ → ℝ) × (ν → ℝ)) :linearProcess (embedLeft a) ((MeasurableEquiv.sumPiEquivProdPi(fun _ : κ ⊕ ν ↦ ℝ)).symm p) = linearProcess a p.1 := byfunext isimp [linearProcess,embedLeft,Fintype.sum_sum_type,MeasurableEquiv.coe_sumPiEquivProdPi_symm]simp only [hlin]simpa [gaussianProduct] using integral_fun_fst (μ := gaussianProduct κ)(ν := gaussianProduct ν) (fun z ↦ logPartition (linearProcess a z))lemma expected_logPartition_embedRight {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν](b : ι → ν → ℝ) :(∫ z, logPartition (linearProcess (embedRight (κ := κ) b) z) ∂gaussianProduct (κ ⊕ ν)) =∫ z, logPartition (linearProcess b z) ∂gaussianProduct ν := byhave he := measurePreserving_sumPiEquivProdPi_symm (fun _ : κ ⊕ ν ↦ standardGaussian)change (∫ z, logPartition (linearProcess (embedRight b) z)∂Measure.pi (fun _ : κ ⊕ ν ↦ standardGaussian)) = _rw [← he.integral_comp' (fun z ↦ logPartition (linearProcess (embedRight b) z))]have hlin (p : (κ → ℝ) × (ν → ℝ)) :linearProcess (embedRight b) ((MeasurableEquiv.sumPiEquivProdPi(fun _ : κ ⊕ ν ↦ ℝ)).symm p) = linearProcess b p.2 := byfunext isimp [linearProcess,embedRight,Fintype.sum_sum_type,MeasurableEquiv.coe_sumPiEquivProdPi_symm]simp only [hlin]simpa [gaussianProduct] using integral_fun_snd (μ := gaussianProduct κ)(ν := gaussianProduct ν) (fun z ↦ logPartition (linearProcess b z))lemma expected_logPartition_le {ι κ ν : Type*}[Fintype ι] [Nonempty ι] [Fintype κ] [Fintype ν](a : ι → κ → ℝ) (b : ι → ν → ℝ)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, logPartition (linearProcess a z) ∂gaussianProduct κ) ≤∫ z, logPartition (linearProcess b z) ∂gaussianProduct ν := byhave h := expected_logPartition_le_orthogonal(embedLeft (ν := ν) a) (embedRight (κ := κ) b)(fun i j ↦ by simp [embedLeft,embedRight,Fintype.sum_sum_type])(fun i j ↦ by simpa only [Fintype.sum_sum_type,embedLeft,embedRight,Sum.elim_inl,Sum.elim_inr,sub_self,zero_pow (by decide : 2 ≠ 0),Finset.sum_const_zero,zero_add,add_zero] using hdist i j)simpa only [expected_logPartition_embedLeft,expected_logPartition_embedRight] using hend SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma finiteMaximum_mono {ι : Type*} [Fintype ι] [Nonempty ι] {x y : ι → ℝ}(h : ∀ i, x i ≤ y i) : finiteMaximum x ≤ finiteMaximum y := byobtain ⟨i,hi⟩ := exists_finiteMaximum xrw [← hi]exact (h i).trans (le_finiteMaximum y i)lemma finiteMaximum_add_const {ι : Type*} [Fintype ι] [Nonempty ι](x : ι → ℝ) (c : ℝ) : finiteMaximum (fun i ↦ x i+c)=finiteMaximum x+c := byobtain ⟨i,hi⟩ := exists_finiteMaximum xobtain ⟨j,hj⟩ := exists_finiteMaximum (fun i ↦ x i+c)apply le_antisymm· rw [← hj]linarith [le_finiteMaximum x j]· rw [← hi]exact le_finiteMaximum (fun i ↦ x i+c) ilemma affineMaximum_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](a : ι → κ → ℝ) (d : ι → ℝ) :Integrable (fun z ↦ finiteMaximum (fun i ↦ linearProcess a z i+d i)) (gaussianProduct κ) := byapply (integrable_finsetSum Finset.univ (fun i _ ↦((linearProcess_integrable a i).add (integrable_const (d i))).abs)).mono'· exact (continuous_finiteMaximum.comp ((continuous_linearProcess a).add continuous_const)).aestronglyMeasurable· exact Eventually.of_forall (fun z ↦ bysimpa only [Real.norm_eq_abs,Pi.add_apply] using abs_finiteMaximum_le(fun i ↦ linearProcess a z i + d i))lemma replicated_partition_bounds {ι : Type*} [Fintype ι] [Nonempty ι](x d : ι → ℝ) (β : ℝ) (hβ : 0≤β) (m : ι → ℕ)(hl : ∀ i, Real.exp (β*d i) ≤ (m i : ℝ))(hu : ∀ i, (m i : ℝ) ≤ 2*Real.exp (β*d i)) :β*finiteMaximum (fun i ↦ x i+d i) ≤logPartition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) ∧logPartition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) ≤β*finiteMaximum (fun i ↦ x i+d i)+Real.log (2*(Fintype.card ι : ℝ)) := byhave hp : partition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) =∑ i, (m i : ℝ)*Real.exp (β*x i) := bysimp [partition,Fintype.sum_sigma]have hlo : Real.exp (β*finiteMaximum (fun i ↦ x i+d i)) ≤partition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) := byobtain ⟨i,hi⟩ := exists_finiteMaximum (fun i ↦ x i+d i)rw [← hi,hp]calc_ = Real.exp (β*d i)*Real.exp (β*x i) := by rw [←Real.exp_add]; congr 1; ring_ ≤ (m i : ℝ)*Real.exp (β*x i) := mul_le_mul_of_nonneg_right (hl i) (Real.exp_pos _).le_ ≤ _ := Finset.single_le_sum (f := fun j ↦ (m j : ℝ)*Real.exp (β*x j)) (fun j _ ↦ by positivity) (Finset.mem_univ i)have hup : partition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) ≤2*(Fintype.card ι : ℝ)*Real.exp (β*finiteMaximum (fun i ↦ x i+d i)) := byrw [hp]calc_ ≤ ∑ i : ι, 2*Real.exp (β*finiteMaximum (fun i ↦ x i+d i)) := byapply Finset.sum_le_sumintro i _calc_ ≤ 2*Real.exp (β*d i)*Real.exp (β*x i) :=mul_le_mul_of_nonneg_right (hu i) (Real.exp_pos _).le_ = 2*Real.exp (β*(x i+d i)) := by rw [mul_assoc,←Real.exp_add]; congr 2; ring_ ≤ _ := mul_le_mul_of_nonneg_left(Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left (le_finiteMaximum (fun i ↦ x i+d i) i) hβ)) (by norm_num)_ = _ := by simp; ringrefine ⟨?_,?_⟩· simpa only [Real.log_exp,logPartition] using Real.log_le_log (Real.exp_pos _) hlo· have hc : 0<2*(Fintype.card ι : ℝ) := by positivityhave hh := Real.log_le_log ((Real.exp_pos _).trans_le hlo) hupsimpa only [logPartition,Real.log_mul hc.ne' (Real.exp_pos _).ne',Real.log_exp,add_comm] using hhend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165import Mathlibimport OAI.Probability.SKValue.GroundState.RotatedCoefficientsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma expected_logPartition_reindex {ι κ ν : Type*} [Fintype ι] [Fintype κ][Fintype ν] (e : κ ≃ ν) (a : ι → κ → ℝ) :(∫ z, logPartition (linearProcess (fun i k ↦ a i (e.symm k)) z)∂gaussianProduct ν) = ∫ z, logPartition (linearProcess a z) ∂gaussianProduct κ := bysimpa only [linearProcess_reindex] using gaussian_integral_reindex e(fun z ↦ logPartition (linearProcess a z))lemma expected_logPartition_le_orthogonal {ι κ : Type*}[Fintype ι] [Nonempty ι] [Fintype κ] (a b : ι → κ → ℝ)(horth : ∀ i j, (∑ k, (a i k-a j k)*(b i k-b j k)) = 0)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, logPartition (linearProcess a z) ∂gaussianProduct κ) ≤∫ z, logPartition (linearProcess b z) ∂gaussianProduct κ := bylet e := Fintype.equivFin κhave h := expected_logPartition_le_of_pair_distances(fun i k ↦ a i (e.symm k)) (fun i k ↦ b i (e.symm k))(fun i j ↦ byrw [e.symm.sum_comp (fun k ↦ (a i k-a j k)*(b i k-b j k))]exact horth i j)(fun i j ↦ byrw [e.symm.sum_comp (fun k ↦ (a i k-a j k)^2),e.symm.sum_comp (fun k ↦ (b i k-b j k)^2)]exact hdist i j)simpa only [expected_logPartition_reindex] using hlemma expected_logPartition_embedLeft {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν](a : ι → κ → ℝ) :(∫ z, logPartition (linearProcess (embedLeft (ν := ν) a) z) ∂gaussianProduct (κ ⊕ ν)) =∫ z, logPartition (linearProcess a z) ∂gaussianProduct κ := byhave he := measurePreserving_sumPiEquivProdPi_symm (fun _ : κ ⊕ ν ↦ standardGaussian)change (∫ z, logPartition (linearProcess (embedLeft a) z)∂Measure.pi (fun _ : κ ⊕ ν ↦ standardGaussian)) = _rw [← he.integral_comp' (fun z ↦ logPartition (linearProcess (embedLeft a) z))]have hlin (p : (κ → ℝ) × (ν → ℝ)) :linearProcess (embedLeft a) ((MeasurableEquiv.sumPiEquivProdPi(fun _ : κ ⊕ ν ↦ ℝ)).symm p) = linearProcess a p.1 := byfunext isimp [linearProcess,embedLeft,Fintype.sum_sum_type,MeasurableEquiv.coe_sumPiEquivProdPi_symm]simp only [hlin]simpa [gaussianProduct] using integral_fun_fst (μ := gaussianProduct κ)(ν := gaussianProduct ν) (fun z ↦ logPartition (linearProcess a z))lemma expected_logPartition_embedRight {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν](b : ι → ν → ℝ) :(∫ z, logPartition (linearProcess (embedRight (κ := κ) b) z) ∂gaussianProduct (κ ⊕ ν)) =∫ z, logPartition (linearProcess b z) ∂gaussianProduct ν := byhave he := measurePreserving_sumPiEquivProdPi_symm (fun _ : κ ⊕ ν ↦ standardGaussian)change (∫ z, logPartition (linearProcess (embedRight b) z)∂Measure.pi (fun _ : κ ⊕ ν ↦ standardGaussian)) = _rw [← he.integral_comp' (fun z ↦ logPartition (linearProcess (embedRight b) z))]have hlin (p : (κ → ℝ) × (ν → ℝ)) :linearProcess (embedRight b) ((MeasurableEquiv.sumPiEquivProdPi(fun _ : κ ⊕ ν ↦ ℝ)).symm p) = linearProcess b p.2 := byfunext isimp [linearProcess,embedRight,Fintype.sum_sum_type,MeasurableEquiv.coe_sumPiEquivProdPi_symm]simp only [hlin]simpa [gaussianProduct] using integral_fun_snd (μ := gaussianProduct κ)(ν := gaussianProduct ν) (fun z ↦ logPartition (linearProcess b z))lemma expected_logPartition_le {ι κ ν : Type*}[Fintype ι] [Nonempty ι] [Fintype κ] [Fintype ν](a : ι → κ → ℝ) (b : ι → ν → ℝ)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, logPartition (linearProcess a z) ∂gaussianProduct κ) ≤∫ z, logPartition (linearProcess b z) ∂gaussianProduct ν := byhave h := expected_logPartition_le_orthogonal(embedLeft (ν := ν) a) (embedRight (κ := κ) b)(fun i j ↦ by simp [embedLeft,embedRight,Fintype.sum_sum_type])(fun i j ↦ by simpa only [Fintype.sum_sum_type,embedLeft,embedRight,Sum.elim_inl,Sum.elim_inr,sub_self,zero_pow (by decide : 2 ≠ 0),Finset.sum_const_zero,zero_add,add_zero] using hdist i j)simpa only [expected_logPartition_embedLeft,expected_logPartition_embedRight] using hend SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma finiteMaximum_mono {ι : Type*} [Fintype ι] [Nonempty ι] {x y : ι → ℝ}(h : ∀ i, x i ≤ y i) : finiteMaximum x ≤ finiteMaximum y := byobtain ⟨i,hi⟩ := exists_finiteMaximum xrw [← hi]exact (h i).trans (le_finiteMaximum y i)lemma finiteMaximum_add_const {ι : Type*} [Fintype ι] [Nonempty ι](x : ι → ℝ) (c : ℝ) : finiteMaximum (fun i ↦ x i+c)=finiteMaximum x+c := byobtain ⟨i,hi⟩ := exists_finiteMaximum xobtain ⟨j,hj⟩ := exists_finiteMaximum (fun i ↦ x i+c)apply le_antisymm· rw [← hj]linarith [le_finiteMaximum x j]· rw [← hi]exact le_finiteMaximum (fun i ↦ x i+c) ilemma affineMaximum_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](a : ι → κ → ℝ) (d : ι → ℝ) :Integrable (fun z ↦ finiteMaximum (fun i ↦ linearProcess a z i+d i)) (gaussianProduct κ) := byapply (integrable_finsetSum Finset.univ (fun i _ ↦((linearProcess_integrable a i).add (integrable_const (d i))).abs)).mono'· exact (continuous_finiteMaximum.comp ((continuous_linearProcess a).add continuous_const)).aestronglyMeasurable· exact Eventually.of_forall (fun z ↦ bysimpa only [Real.norm_eq_abs,Pi.add_apply] using abs_finiteMaximum_le(fun i ↦ linearProcess a z i + d i))lemma replicated_partition_bounds {ι : Type*} [Fintype ι] [Nonempty ι](x d : ι → ℝ) (β : ℝ) (hβ : 0≤β) (m : ι → ℕ)(hl : ∀ i, Real.exp (β*d i) ≤ (m i : ℝ))(hu : ∀ i, (m i : ℝ) ≤ 2*Real.exp (β*d i)) :β*finiteMaximum (fun i ↦ x i+d i) ≤logPartition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) ∧logPartition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) ≤β*finiteMaximum (fun i ↦ x i+d i)+Real.log (2*(Fintype.card ι : ℝ)) := byhave hp : partition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) =∑ i, (m i : ℝ)*Real.exp (β*x i) := bysimp [partition,Fintype.sum_sigma]have hlo : Real.exp (β*finiteMaximum (fun i ↦ x i+d i)) ≤partition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) := byobtain ⟨i,hi⟩ := exists_finiteMaximum (fun i ↦ x i+d i)rw [← hi,hp]calc_ = Real.exp (β*d i)*Real.exp (β*x i) := by rw [←Real.exp_add]; congr 1; ring_ ≤ (m i : ℝ)*Real.exp (β*x i) := mul_le_mul_of_nonneg_right (hl i) (Real.exp_pos _).le_ ≤ _ := Finset.single_le_sum (f := fun j ↦ (m j : ℝ)*Real.exp (β*x j)) (fun j _ ↦ by positivity) (Finset.mem_univ i)have hup : partition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) ≤2*(Fintype.card ι : ℝ)*Real.exp (β*finiteMaximum (fun i ↦ x i+d i)) := byrw [hp]calc_ ≤ ∑ i : ι, 2*Real.exp (β*finiteMaximum (fun i ↦ x i+d i)) := byapply Finset.sum_le_sumintro i _calc_ ≤ 2*Real.exp (β*d i)*Real.exp (β*x i) :=mul_le_mul_of_nonneg_right (hu i) (Real.exp_pos _).le_ = 2*Real.exp (β*(x i+d i)) := by rw [mul_assoc,←Real.exp_add]; congr 2; ring_ ≤ _ := mul_le_mul_of_nonneg_left(Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left (le_finiteMaximum (fun i ↦ x i+d i) i) hβ)) (by norm_num)_ = _ := by simp; ringrefine ⟨?_,?_⟩· simpa only [Real.log_exp,logPartition] using Real.log_le_log (Real.exp_pos _) hlo· have hc : 0<2*(Fintype.card ι : ℝ) := by positivityhave hh := Real.log_le_log ((Real.exp_pos _).trans_le hlo) hupsimpa only [logPartition,Real.log_mul hc.ne' (Real.exp_pos _).ne',Real.log_exp,add_comm] using hhend SKValueGendend OAI
1234567891011121314151617181920212223242526272829303132import Mathlibimport OAI.Probability.SKValue.Variation.MinimizerContactimport OAI.Probability.SKValue.Variation.ContactAssemblyimport OAI.Probability.SKValue.Processes.DiffusionExistencenamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValuetheorem scalar_value_target (W:BrownianSpace) (γ:OrderParameter) (X:ℝ → W.Ω → ℝ)(hmin:IsMinimizer W γ) (hX:IsDiffusion W γ X):ScalarValueConclusion W γ X :=hX.scalar_value_of_contact (hmin.gradient_moment_contact hX)theorem finite_gaussian_target (W:BrownianSpace) (γ:OrderParameter) (X:ℝ → W.Ω → ℝ)(T:ℝ) (hT:0<T) (hT1:T<1) (hmin:IsMinimizer W γ) (hX:IsDiffusion W γ X):FiniteGaussianConclusion W γ X T :=hX.finite_gaussian_of_contact (hmin.gradient_moment_contact hX) hT hT1lemma IsMinimizer.ground_state_parisi_of_diffusion {W:BrownianSpace} {γ:OrderParameter} {X:ℝ → W.Ω → ℝ}(hmin:IsMinimizer W γ) (hX:IsDiffusion W γ X):groundStateValue=parisi W γ :=hX.groundState_eq_parisi_of_contact (hmin.gradient_moment_contact hX)theorem ground_state_parisi_target (W:BrownianSpace) (γ:OrderParameter)(hmin:IsMinimizer W γ):groundStateValue=parisi W γ :=hmin.ground_state_parisi_of_diffusion (diffusionProcess_isDiffusion W γ)end SKValueendend OAI1234567891011121314151617181920212223242526272829303132import Mathlibimport OAI.Probability.SKValue.Variation.MinimizerContactimport OAI.Probability.SKValue.Variation.ContactAssemblyimport OAI.Probability.SKValue.Processes.DiffusionExistencenamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValuetheorem scalar_value_target (W:BrownianSpace) (γ:OrderParameter) (X:ℝ → W.Ω → ℝ)(hmin:IsMinimizer W γ) (hX:IsDiffusion W γ X):ScalarValueConclusion W γ X :=hX.scalar_value_of_contact (hmin.gradient_moment_contact hX)theorem finite_gaussian_target (W:BrownianSpace) (γ:OrderParameter) (X:ℝ → W.Ω → ℝ)(T:ℝ) (hT:0<T) (hT1:T<1) (hmin:IsMinimizer W γ) (hX:IsDiffusion W γ X):FiniteGaussianConclusion W γ X T :=hX.finite_gaussian_of_contact (hmin.gradient_moment_contact hX) hT hT1lemma IsMinimizer.ground_state_parisi_of_diffusion {W:BrownianSpace} {γ:OrderParameter} {X:ℝ → W.Ω → ℝ}(hmin:IsMinimizer W γ) (hX:IsDiffusion W γ X):groundStateValue=parisi W γ :=hX.groundState_eq_parisi_of_contact (hmin.gradient_moment_contact hX)theorem ground_state_parisi_target (W:BrownianSpace) (γ:OrderParameter)(hmin:IsMinimizer W γ):groundStateValue=parisi W γ :=hmin.ground_state_parisi_of_diffusion (diffusionProcess_isDiffusion W γ)end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294import Mathlibimport OAI.Probability.SKValue.Modelnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsnamespace SKValuelemma independent_of_coordinate_not_in {ι β : Type*} [Fintype ι] [DecidableEq ι][MeasurableSpace β]{μ : ι → Measure ℝ} [∀ i, IsProbabilityMeasure (μ i)](S : Finset ι) {j : ι} (hj : j ∉ S) {F : (ι → ℝ) → β}(hF : Measurable F)(hdep : ∀ x y, (∀ i ∈ S, x i=y i) → F x=F y) :IndepFun F (fun x ↦ x j) (Measure.pi μ) := bylet fill : (S → ℝ) → ι → ℝ := fun x i ↦ if hi : i ∈ S then x ⟨i,hi⟩ else 0have hfill : Measurable fill := byapply Measurable.of_evalintro iby_cases hi : i ∈ S· simpa only [fill, dite_eq_left hi] using (measurable_pi_apply (⟨i,hi⟩ : S))· simp only [fill, dite_eq_right hi]exact measurable_consthave hid : ∀ x : ι → ℝ, F (fill (fun i : S ↦ x i)) = F x := byintro xapply hdepintro i hisimp [fill,hi]have hST : Disjoint S {j} := by simpa using hjhave hind : iIndepFun (fun i (x : ι → ℝ) ↦ x i) (Measure.pi μ) :=iIndepFun_pi (fun i ↦ (measurable_id : Measurable (id : ℝ → ℝ)).aemeasurable)have H := (hind.indepFun_finset S {j} hST (fun i ↦ measurable_pi_apply i)).comp(hF.comp hfill) (measurable_pi_apply (⟨j,by simp⟩ : ({j} : Finset ι)))simpa only [Function.comp_def, hid] using Hlemma measurable_coordinate (N j : ℕ) : Measurable (coordinate N j) :=measurable_pi_apply _lemma coordinate_eq_apply {N j : ℕ} (hj : j < N+1) (z : Fin (N+1) → ℝ) :coordinate N j z = z ⟨j,hj⟩ := bysimp [coordinate, Nat.mod_eq_of_lt hj]lemma euler_depends_on_past (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(j : ℕ) (z z' : Fin (N+1) → ℝ)(h : ∀ i < j, coordinate N i z=coordinate N i z') :euler T N γ u z j=euler T N γ u z' j := byinduction j with| zero => rfl| succ j ih =>have hp := ih (fun i hi ↦ h i (by omega))simp only [euler, hp,h j (by omega)]lemma measurable_euler (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(hU : ∀ k < N, Measurable (u (meshTime T N k))) :∀ j ≤ N, Measurable (fun z ↦ euler T N γ u z j) := byintro j hjinduction j with| zero => exact measurable_const| succ j ih =>have hjN : j < N := by omegahave hy := ih (by omega)have hz := measurable_coordinate N jhave hu := (hU j hjN).comp hysimp only [euler]fun_proplemma euler_coefficient_independent {T : ℝ} {N j : ℕ} {γ : ℝ → ℝ}{u a : ℝ → ℝ → ℝ} (hj : j < N+1)(hU : ∀ k < N, Measurable (u (meshTime T N k)))(hA : Measurable (a (meshTime T N j))) :IndepFun (fun z ↦ a (meshTime T N j) (euler T N γ u z j))(coordinate N j) (gaussianProduct (Fin (N+1))) := bylet S : Finset (Fin (N+1)) := Finset.univ.filter (fun i ↦ (i : ℕ)<j)have hjS : (⟨j,hj⟩ : Fin (N+1)) ∉ S := by simp [S]have hF : Measurable (fun z ↦ a (meshTime T N j) (euler T N γ u z j)) :=hA.comp (measurable_euler T N γ u hU j (by omega))have h := independent_of_coordinate_not_in (μ := fun _ : Fin (N+1) ↦ standardGaussian)S hjS hF(fun z z' heq ↦ byapply congrArg (a (meshTime T N j))apply euler_depends_on_past T N γ u j z z'intro i hihave hiN : i < N+1 := hi.trans hjrw [coordinate_eq_apply hiN,coordinate_eq_apply hiN]apply heqsimp [S,hi])have heq : coordinate N j = fun z : Fin (N+1) → ℝ ↦ z ⟨j,hj⟩ :=funext (coordinate_eq_apply hj)rw [heq]exact hvariable {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}lemma gaussian_mean {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ) :∫ ω, Z ω ∂μ = 0 := byrw [hZ.integral_eq, integral_id_gaussianReal]lemma gaussian_memLp {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ)(p : ℝ≥0∞) (hp : p ≠ ∞) : MemLp Z p μ := byhave H : MemLp (id : ℝ → ℝ) p (μ.map Z) := byrw [hZ.map_eq]exact memLp_id_gaussianReal' p hpsimpa using (memLp_map_measure_iff H.aestronglyMeasurable hZ.aemeasurable).1 Hlemma gaussian_second_moment {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ) :∫ ω, (Z ω)^2 ∂μ = 1 := byhave hvar := hZ.variance_eqrw [variance_eq_integral hZ.aemeasurable, gaussian_mean hZ] at hvarsimpa using hvarnoncomputable def predictableNormalizer (H : Ω → ℝ) (μ : Measure Ω) : ℝ :=(Real.sqrt (∫ ω, (H ω)^2 ∂μ))⁻¹noncomputable def normalizedIncrement (H Z : Ω → ℝ) (μ : Measure Ω) : Ω → ℝ :=fun ω ↦ predictableNormalizer H μ * H ω * Z ωlemma predictableNormalizer_pos {H : Ω → ℝ}(hHpos : 0 < ∫ ω, (H ω)^2 ∂μ) :0 < predictableNormalizer H μ := byexact inv_pos.mpr (Real.sqrt_pos.mpr hHpos)lemma normalizedIncrement_mean {H Z : Ω → ℝ}(hH : AEStronglyMeasurable H μ) (hZ : HasLaw Z (gaussianReal 0 1) μ)(hind : IndepFun H Z μ) :∫ ω, normalizedIncrement H Z μ ω ∂μ = 0 := bysimp only [normalizedIncrement, mul_assoc]rw [integral_const_mul]have hi := hind.integral_mul_eq_mul_integral hH hZ.aemeasurable.aestronglyMeasurablechange (∫ ω, H ω * Z ω ∂μ) = _ at hirw [hi, gaussian_mean hZ, mul_zero, mul_zero]lemma normalizedIncrement_second_moment {H Z : Ω → ℝ}(hH : AEStronglyMeasurable H μ) (hZ : HasLaw Z (gaussianReal 0 1) μ)(hind : IndepFun H Z μ) (hHpos : 0 < ∫ ω, (H ω)^2 ∂μ) :∫ ω, (normalizedIncrement H Z μ ω)^2 ∂μ = 1 := byhave hind2 : IndepFun (fun ω ↦ (H ω)^2) (fun ω ↦ (Z ω)^2) μ :=hind.comp (measurable_id.pow_const 2) (measurable_id.pow_const 2)have hi := hind2.integral_mul_eq_mul_integral(hH.fun_pow 2)(hZ.aemeasurable.aestronglyMeasurable.fun_pow 2)change (∫ ω, (H ω)^2 * (Z ω)^2 ∂μ) =(∫ ω, (H ω)^2 ∂μ) * (∫ ω, (Z ω)^2 ∂μ) at hisimp only [normalizedIncrement, mul_pow, mul_assoc]rw [integral_const_mul, hi, gaussian_second_moment hZ, mul_one]simp only [predictableNormalizer, inv_pow, Real.sq_sqrt (le_of_lt hHpos)]exact inv_mul_cancel₀ (ne_of_gt hHpos)lemma normalizedIncrement_memLp_two {H Z : Ω → ℝ}(hH : MemLp H 2 μ) (hZ : HasLaw Z (gaussianReal 0 1) μ)(hind : IndepFun H Z μ) :MemLp (normalizedIncrement H Z μ) 2 μ := byapply (memLp_two_iff_integrable_sq((hH.aestronglyMeasurable.const_mul _).mul hZ.aemeasurable.aestronglyMeasurable)).2have hi := (hind.comp (measurable_id.pow_const 2) (measurable_id.pow_const 2)).integrable_mulhH.integrable_sq (gaussian_memLp hZ 2 (by norm_num)).integrable_sqhave hj := hi.const_mul (predictableNormalizer H μ ^ 2)simpa only [normalizedIncrement, Pi.mul_apply, mul_pow, mul_assoc, Function.comp_def, id_eq] using hjlemma normalizedIncrement_gaussian_coefficient {H Z : Ω → ℝ}(hH : AEStronglyMeasurable H μ) (hZ : HasLaw Z (gaussianReal 0 1) μ)(hind : IndepFun H Z μ) :∫ ω, normalizedIncrement H Z μ ω * Z ω ∂μ =predictableNormalizer H μ * ∫ ω, H ω ∂μ := byhave hind2 : IndepFun H (fun ω ↦ (Z ω)^2) μ :=hind.comp measurable_id (measurable_id.pow_const 2)have hi := hind2.integral_mul_eq_mul_integral hH(hZ.aemeasurable.aestronglyMeasurable.fun_pow 2)change (∫ ω, H ω * (Z ω)^2 ∂μ) =(∫ ω, H ω ∂μ) * (∫ ω, (Z ω)^2 ∂μ) at hisimp only [normalizedIncrement, mul_assoc, ← pow_two]rw [integral_const_mul, hi, gaussian_second_moment hZ, mul_one]lemma predictable_product_mean_zero {H K Z : Ω → ℝ}(hH : AEStronglyMeasurable H μ) (hK : AEStronglyMeasurable K μ)(hZ : HasLaw Z (gaussianReal 0 1) μ)(hind : IndepFun (fun ω ↦ H ω * K ω) Z μ) :∫ ω, K ω * normalizedIncrement H Z μ ω ∂μ = 0 := byhave hi := hind.integral_mul_eq_mul_integral (hH.mul hK)hZ.aemeasurable.aestronglyMeasurablechange (∫ ω, (H ω * K ω) * Z ω ∂μ) = _ at hicalc_ = predictableNormalizer H μ * ∫ ω, (H ω * K ω) * Z ω ∂μ := byrw [← integral_const_mul]congr 1ext ωsimp only [normalizedIncrement]ring_ = 0 := by rw [hi, gaussian_mean hZ, mul_zero, mul_zero]lemma coordinate_hasLaw (N j : ℕ) :HasLaw (coordinate N j) (gaussianReal 0 1) (gaussianProduct (Fin (N+1))) :=(measurePreserving_eval (fun _ : Fin (N+1) ↦ standardGaussian)⟨j % (N+1), Nat.mod_lt _ (Nat.succ_pos _)⟩).hasLawdef DependsBefore {N : ℕ} {β : Type*} (j : ℕ) (F : (Fin (N+1) → ℝ) → β) : Prop :=∀ z z', (∀ i : Fin (N+1), (i : ℕ)<j → z i=z' i) → F z=F z'lemma DependsBefore.independent {N j : ℕ} {β : Type*} [MeasurableSpace β] (hj : j<N+1){F : (Fin (N+1) → ℝ) → β} (hF : DependsBefore j F) (hm : Measurable F) :IndepFun F (coordinate N j) (gaussianProduct (Fin (N+1))) := byhave H := independent_of_coordinate_not_in (μ := fun _ : Fin (N+1) ↦ standardGaussian)(Finset.univ.filter (fun i : Fin (N+1) ↦ (i : ℕ)<j))(j := ⟨j,hj⟩) (by simp) hm (fun z z' heq ↦ hF z z' (by simpa using heq))have heq : coordinate N j = fun z : Fin (N+1) → ℝ ↦ z ⟨j,hj⟩ :=funext (coordinate_eq_apply hj)rw [heq]exact Hlemma DependsBefore.mono {N i j : ℕ} {β : Type*} {F : (Fin (N+1) → ℝ) → β}(hF : DependsBefore i F) (hij : i≤j) : DependsBefore j F :=fun z z' h ↦ hF z z' (fun k hk ↦ h k (hk.trans_le hij))lemma DependsBefore.prodMk {N j : ℕ} {β β' : Type*}{F : (Fin (N+1) → ℝ) → β} {G : (Fin (N+1) → ℝ) → β'}(hF : DependsBefore j F) (hG : DependsBefore j G) :DependsBefore j (fun z ↦ (F z,G z)) := byintro z z' hexact Prod.ext (hF z z' h) (hG z z' h)lemma DependsBefore.mul {N j : ℕ} {F G : (Fin (N+1) → ℝ) → ℝ}(hF : DependsBefore j F) (hG : DependsBefore j G) :DependsBefore j (fun z ↦ F z * G z) := byintro z z' hdsimp onlyrw [hF z z' h, hG z z' h]lemma eulerCoefficient_dependsBefore (T : ℝ) {N j : ℕ} (hj : j≤N)(γ : ℝ → ℝ) (u a : ℝ → ℝ → ℝ) :DependsBefore j (fun z ↦ a (meshTime T N j) (euler T N γ u z j)) := byintro z z' happly congrArg (a (meshTime T N j))apply euler_depends_on_pastintro i hihave hiN : i<N+1 := by omegarw [coordinate_eq_apply hiN, coordinate_eq_apply hiN]exact h ⟨i,hiN⟩ hilemma normalizedIncrement_dependsBefore {N j : ℕ} (hj : j<N+1){H : (Fin (N+1) → ℝ) → ℝ} (hH : DependsBefore j H) :DependsBefore (j+1) (normalizedIncrement H (coordinate N j) (gaussianProduct (Fin (N+1)))) := byintro z z' hhave heq := hH.mono (Nat.le_succ j) z z' hhave hz : coordinate N j z=coordinate N j z' := byrw [coordinate_eq_apply hj, coordinate_eq_apply hj]exact h ⟨j,hj⟩ (Nat.lt_succ_self j)simp only [normalizedIncrement,heq,hz]lemma measurable_normalizedIncrement {N j : ℕ} {H : (Fin (N+1) → ℝ) → ℝ}(hH : Measurable H) :Measurable (normalizedIncrement H (coordinate N j) (gaussianProduct (Fin (N+1)))) :=(hH.const_mul _).mul (measurable_coordinate N j)lemma normalizedIncrements_orthogonal {N i j : ℕ} (hij : i<j) (hj : j<N+1){H K : (Fin (N+1) → ℝ) → ℝ} (hHm : Measurable H) (hKm : Measurable K)(hH : DependsBefore i H) (hK : DependsBefore j K) :∫ z, normalizedIncrement H (coordinate N i) (gaussianProduct (Fin (N+1))) z *normalizedIncrement K (coordinate N j) (gaussianProduct (Fin (N+1))) z∂gaussianProduct (Fin (N+1)) = 0 := byhave hi : i<N+1 := hij.trans hjhave hprev := (normalizedIncrement_dependsBefore hi hH).mono (by omega : i+1≤j)exact predictable_product_mean_zero hKm.aestronglyMeasurable(measurable_normalizedIncrement hHm).aestronglyMeasurable (coordinate_hasLaw N j)((hK.mul hprev).independent hj(hKm.mul (measurable_normalizedIncrement hHm)))lemma euler_normalized_increment_properties {T : ℝ} {N j : ℕ} {γ : ℝ → ℝ}{u a : ℝ → ℝ → ℝ} (hj : j<N+1)(hU : ∀ k<N, Measurable (u (meshTime T N k)))(hA : Measurable (a (meshTime T N j)))(hpos : 0 < ∫ z, (a (meshTime T N j) (euler T N γ u z j))^2∂gaussianProduct (Fin (N+1))) :let H := fun z ↦ a (meshTime T N j) (euler T N γ u z j)let μ := gaussianProduct (Fin (N+1))0 < predictableNormalizer H μ ∧(∫ z, normalizedIncrement H (coordinate N j) μ z ∂μ)=0 ∧(∫ z, (normalizedIncrement H (coordinate N j) μ z)^2 ∂μ)=1 := bydsimp onlyhave hm := hA.comp (measurable_euler T N γ u hU j (by omega))have hind := euler_coefficient_independent (γ := γ) hj hU hAexact ⟨predictableNormalizer_pos hpos,normalizedIncrement_mean hm.aestronglyMeasurable (coordinate_hasLaw N j) hind,normalizedIncrement_second_moment hm.aestronglyMeasurable (coordinate_hasLaw N j) hind hpos⟩end SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294import Mathlibimport OAI.Probability.SKValue.Modelnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsnamespace SKValuelemma independent_of_coordinate_not_in {ι β : Type*} [Fintype ι] [DecidableEq ι][MeasurableSpace β]{μ : ι → Measure ℝ} [∀ i, IsProbabilityMeasure (μ i)](S : Finset ι) {j : ι} (hj : j ∉ S) {F : (ι → ℝ) → β}(hF : Measurable F)(hdep : ∀ x y, (∀ i ∈ S, x i=y i) → F x=F y) :IndepFun F (fun x ↦ x j) (Measure.pi μ) := bylet fill : (S → ℝ) → ι → ℝ := fun x i ↦ if hi : i ∈ S then x ⟨i,hi⟩ else 0have hfill : Measurable fill := byapply Measurable.of_evalintro iby_cases hi : i ∈ S· simpa only [fill, dite_eq_left hi] using (measurable_pi_apply (⟨i,hi⟩ : S))· simp only [fill, dite_eq_right hi]exact measurable_consthave hid : ∀ x : ι → ℝ, F (fill (fun i : S ↦ x i)) = F x := byintro xapply hdepintro i hisimp [fill,hi]have hST : Disjoint S {j} := by simpa using hjhave hind : iIndepFun (fun i (x : ι → ℝ) ↦ x i) (Measure.pi μ) :=iIndepFun_pi (fun i ↦ (measurable_id : Measurable (id : ℝ → ℝ)).aemeasurable)have H := (hind.indepFun_finset S {j} hST (fun i ↦ measurable_pi_apply i)).comp(hF.comp hfill) (measurable_pi_apply (⟨j,by simp⟩ : ({j} : Finset ι)))simpa only [Function.comp_def, hid] using Hlemma measurable_coordinate (N j : ℕ) : Measurable (coordinate N j) :=measurable_pi_apply _lemma coordinate_eq_apply {N j : ℕ} (hj : j < N+1) (z : Fin (N+1) → ℝ) :coordinate N j z = z ⟨j,hj⟩ := bysimp [coordinate, Nat.mod_eq_of_lt hj]lemma euler_depends_on_past (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(j : ℕ) (z z' : Fin (N+1) → ℝ)(h : ∀ i < j, coordinate N i z=coordinate N i z') :euler T N γ u z j=euler T N γ u z' j := byinduction j with| zero => rfl| succ j ih =>have hp := ih (fun i hi ↦ h i (by omega))simp only [euler, hp,h j (by omega)]lemma measurable_euler (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(hU : ∀ k < N, Measurable (u (meshTime T N k))) :∀ j ≤ N, Measurable (fun z ↦ euler T N γ u z j) := byintro j hjinduction j with| zero => exact measurable_const| succ j ih =>have hjN : j < N := by omegahave hy := ih (by omega)have hz := measurable_coordinate N jhave hu := (hU j hjN).comp hysimp only [euler]fun_proplemma euler_coefficient_independent {T : ℝ} {N j : ℕ} {γ : ℝ → ℝ}{u a : ℝ → ℝ → ℝ} (hj : j < N+1)(hU : ∀ k < N, Measurable (u (meshTime T N k)))(hA : Measurable (a (meshTime T N j))) :IndepFun (fun z ↦ a (meshTime T N j) (euler T N γ u z j))(coordinate N j) (gaussianProduct (Fin (N+1))) := bylet S : Finset (Fin (N+1)) := Finset.univ.filter (fun i ↦ (i : ℕ)<j)have hjS : (⟨j,hj⟩ : Fin (N+1)) ∉ S := by simp [S]have hF : Measurable (fun z ↦ a (meshTime T N j) (euler T N γ u z j)) :=hA.comp (measurable_euler T N γ u hU j (by omega))have h := independent_of_coordinate_not_in (μ := fun _ : Fin (N+1) ↦ standardGaussian)S hjS hF(fun z z' heq ↦ byapply congrArg (a (meshTime T N j))apply euler_depends_on_past T N γ u j z z'intro i hihave hiN : i < N+1 := hi.trans hjrw [coordinate_eq_apply hiN,coordinate_eq_apply hiN]apply heqsimp [S,hi])have heq : coordinate N j = fun z : Fin (N+1) → ℝ ↦ z ⟨j,hj⟩ :=funext (coordinate_eq_apply hj)rw [heq]exact hvariable {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}lemma gaussian_mean {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ) :∫ ω, Z ω ∂μ = 0 := byrw [hZ.integral_eq, integral_id_gaussianReal]lemma gaussian_memLp {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ)(p : ℝ≥0∞) (hp : p ≠ ∞) : MemLp Z p μ := byhave H : MemLp (id : ℝ → ℝ) p (μ.map Z) := byrw [hZ.map_eq]exact memLp_id_gaussianReal' p hpsimpa using (memLp_map_measure_iff H.aestronglyMeasurable hZ.aemeasurable).1 Hlemma gaussian_second_moment {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ) :∫ ω, (Z ω)^2 ∂μ = 1 := byhave hvar := hZ.variance_eqrw [variance_eq_integral hZ.aemeasurable, gaussian_mean hZ] at hvarsimpa using hvarnoncomputable def predictableNormalizer (H : Ω → ℝ) (μ : Measure Ω) : ℝ :=(Real.sqrt (∫ ω, (H ω)^2 ∂μ))⁻¹noncomputable def normalizedIncrement (H Z : Ω → ℝ) (μ : Measure Ω) : Ω → ℝ :=fun ω ↦ predictableNormalizer H μ * H ω * Z ωlemma predictableNormalizer_pos {H : Ω → ℝ}(hHpos : 0 < ∫ ω, (H ω)^2 ∂μ) :0 < predictableNormalizer H μ := byexact inv_pos.mpr (Real.sqrt_pos.mpr hHpos)lemma normalizedIncrement_mean {H Z : Ω → ℝ}(hH : AEStronglyMeasurable H μ) (hZ : HasLaw Z (gaussianReal 0 1) μ)(hind : IndepFun H Z μ) :∫ ω, normalizedIncrement H Z μ ω ∂μ = 0 := bysimp only [normalizedIncrement, mul_assoc]rw [integral_const_mul]have hi := hind.integral_mul_eq_mul_integral hH hZ.aemeasurable.aestronglyMeasurablechange (∫ ω, H ω * Z ω ∂μ) = _ at hirw [hi, gaussian_mean hZ, mul_zero, mul_zero]lemma normalizedIncrement_second_moment {H Z : Ω → ℝ}(hH : AEStronglyMeasurable H μ) (hZ : HasLaw Z (gaussianReal 0 1) μ)(hind : IndepFun H Z μ) (hHpos : 0 < ∫ ω, (H ω)^2 ∂μ) :∫ ω, (normalizedIncrement H Z μ ω)^2 ∂μ = 1 := byhave hind2 : IndepFun (fun ω ↦ (H ω)^2) (fun ω ↦ (Z ω)^2) μ :=hind.comp (measurable_id.pow_const 2) (measurable_id.pow_const 2)have hi := hind2.integral_mul_eq_mul_integral(hH.fun_pow 2)(hZ.aemeasurable.aestronglyMeasurable.fun_pow 2)change (∫ ω, (H ω)^2 * (Z ω)^2 ∂μ) =(∫ ω, (H ω)^2 ∂μ) * (∫ ω, (Z ω)^2 ∂μ) at hisimp only [normalizedIncrement, mul_pow, mul_assoc]rw [integral_const_mul, hi, gaussian_second_moment hZ, mul_one]simp only [predictableNormalizer, inv_pow, Real.sq_sqrt (le_of_lt hHpos)]exact inv_mul_cancel₀ (ne_of_gt hHpos)lemma normalizedIncrement_memLp_two {H Z : Ω → ℝ}(hH : MemLp H 2 μ) (hZ : HasLaw Z (gaussianReal 0 1) μ)(hind : IndepFun H Z μ) :MemLp (normalizedIncrement H Z μ) 2 μ := byapply (memLp_two_iff_integrable_sq((hH.aestronglyMeasurable.const_mul _).mul hZ.aemeasurable.aestronglyMeasurable)).2have hi := (hind.comp (measurable_id.pow_const 2) (measurable_id.pow_const 2)).integrable_mulhH.integrable_sq (gaussian_memLp hZ 2 (by norm_num)).integrable_sqhave hj := hi.const_mul (predictableNormalizer H μ ^ 2)simpa only [normalizedIncrement, Pi.mul_apply, mul_pow, mul_assoc, Function.comp_def, id_eq] using hjlemma normalizedIncrement_gaussian_coefficient {H Z : Ω → ℝ}(hH : AEStronglyMeasurable H μ) (hZ : HasLaw Z (gaussianReal 0 1) μ)(hind : IndepFun H Z μ) :∫ ω, normalizedIncrement H Z μ ω * Z ω ∂μ =predictableNormalizer H μ * ∫ ω, H ω ∂μ := byhave hind2 : IndepFun H (fun ω ↦ (Z ω)^2) μ :=hind.comp measurable_id (measurable_id.pow_const 2)have hi := hind2.integral_mul_eq_mul_integral hH(hZ.aemeasurable.aestronglyMeasurable.fun_pow 2)change (∫ ω, H ω * (Z ω)^2 ∂μ) =(∫ ω, H ω ∂μ) * (∫ ω, (Z ω)^2 ∂μ) at hisimp only [normalizedIncrement, mul_assoc, ← pow_two]rw [integral_const_mul, hi, gaussian_second_moment hZ, mul_one]lemma predictable_product_mean_zero {H K Z : Ω → ℝ}(hH : AEStronglyMeasurable H μ) (hK : AEStronglyMeasurable K μ)(hZ : HasLaw Z (gaussianReal 0 1) μ)(hind : IndepFun (fun ω ↦ H ω * K ω) Z μ) :∫ ω, K ω * normalizedIncrement H Z μ ω ∂μ = 0 := byhave hi := hind.integral_mul_eq_mul_integral (hH.mul hK)hZ.aemeasurable.aestronglyMeasurablechange (∫ ω, (H ω * K ω) * Z ω ∂μ) = _ at hicalc_ = predictableNormalizer H μ * ∫ ω, (H ω * K ω) * Z ω ∂μ := byrw [← integral_const_mul]congr 1ext ωsimp only [normalizedIncrement]ring_ = 0 := by rw [hi, gaussian_mean hZ, mul_zero, mul_zero]lemma coordinate_hasLaw (N j : ℕ) :HasLaw (coordinate N j) (gaussianReal 0 1) (gaussianProduct (Fin (N+1))) :=(measurePreserving_eval (fun _ : Fin (N+1) ↦ standardGaussian)⟨j % (N+1), Nat.mod_lt _ (Nat.succ_pos _)⟩).hasLawdef DependsBefore {N : ℕ} {β : Type*} (j : ℕ) (F : (Fin (N+1) → ℝ) → β) : Prop :=∀ z z', (∀ i : Fin (N+1), (i : ℕ)<j → z i=z' i) → F z=F z'lemma DependsBefore.independent {N j : ℕ} {β : Type*} [MeasurableSpace β] (hj : j<N+1){F : (Fin (N+1) → ℝ) → β} (hF : DependsBefore j F) (hm : Measurable F) :IndepFun F (coordinate N j) (gaussianProduct (Fin (N+1))) := byhave H := independent_of_coordinate_not_in (μ := fun _ : Fin (N+1) ↦ standardGaussian)(Finset.univ.filter (fun i : Fin (N+1) ↦ (i : ℕ)<j))(j := ⟨j,hj⟩) (by simp) hm (fun z z' heq ↦ hF z z' (by simpa using heq))have heq : coordinate N j = fun z : Fin (N+1) → ℝ ↦ z ⟨j,hj⟩ :=funext (coordinate_eq_apply hj)rw [heq]exact Hlemma DependsBefore.mono {N i j : ℕ} {β : Type*} {F : (Fin (N+1) → ℝ) → β}(hF : DependsBefore i F) (hij : i≤j) : DependsBefore j F :=fun z z' h ↦ hF z z' (fun k hk ↦ h k (hk.trans_le hij))lemma DependsBefore.prodMk {N j : ℕ} {β β' : Type*}{F : (Fin (N+1) → ℝ) → β} {G : (Fin (N+1) → ℝ) → β'}(hF : DependsBefore j F) (hG : DependsBefore j G) :DependsBefore j (fun z ↦ (F z,G z)) := byintro z z' hexact Prod.ext (hF z z' h) (hG z z' h)lemma DependsBefore.mul {N j : ℕ} {F G : (Fin (N+1) → ℝ) → ℝ}(hF : DependsBefore j F) (hG : DependsBefore j G) :DependsBefore j (fun z ↦ F z * G z) := byintro z z' hdsimp onlyrw [hF z z' h, hG z z' h]lemma eulerCoefficient_dependsBefore (T : ℝ) {N j : ℕ} (hj : j≤N)(γ : ℝ → ℝ) (u a : ℝ → ℝ → ℝ) :DependsBefore j (fun z ↦ a (meshTime T N j) (euler T N γ u z j)) := byintro z z' happly congrArg (a (meshTime T N j))apply euler_depends_on_pastintro i hihave hiN : i<N+1 := by omegarw [coordinate_eq_apply hiN, coordinate_eq_apply hiN]exact h ⟨i,hiN⟩ hilemma normalizedIncrement_dependsBefore {N j : ℕ} (hj : j<N+1){H : (Fin (N+1) → ℝ) → ℝ} (hH : DependsBefore j H) :DependsBefore (j+1) (normalizedIncrement H (coordinate N j) (gaussianProduct (Fin (N+1)))) := byintro z z' hhave heq := hH.mono (Nat.le_succ j) z z' hhave hz : coordinate N j z=coordinate N j z' := byrw [coordinate_eq_apply hj, coordinate_eq_apply hj]exact h ⟨j,hj⟩ (Nat.lt_succ_self j)simp only [normalizedIncrement,heq,hz]lemma measurable_normalizedIncrement {N j : ℕ} {H : (Fin (N+1) → ℝ) → ℝ}(hH : Measurable H) :Measurable (normalizedIncrement H (coordinate N j) (gaussianProduct (Fin (N+1)))) :=(hH.const_mul _).mul (measurable_coordinate N j)lemma normalizedIncrements_orthogonal {N i j : ℕ} (hij : i<j) (hj : j<N+1){H K : (Fin (N+1) → ℝ) → ℝ} (hHm : Measurable H) (hKm : Measurable K)(hH : DependsBefore i H) (hK : DependsBefore j K) :∫ z, normalizedIncrement H (coordinate N i) (gaussianProduct (Fin (N+1))) z *normalizedIncrement K (coordinate N j) (gaussianProduct (Fin (N+1))) z∂gaussianProduct (Fin (N+1)) = 0 := byhave hi : i<N+1 := hij.trans hjhave hprev := (normalizedIncrement_dependsBefore hi hH).mono (by omega : i+1≤j)exact predictable_product_mean_zero hKm.aestronglyMeasurable(measurable_normalizedIncrement hHm).aestronglyMeasurable (coordinate_hasLaw N j)((hK.mul hprev).independent hj(hKm.mul (measurable_normalizedIncrement hHm)))lemma euler_normalized_increment_properties {T : ℝ} {N j : ℕ} {γ : ℝ → ℝ}{u a : ℝ → ℝ → ℝ} (hj : j<N+1)(hU : ∀ k<N, Measurable (u (meshTime T N k)))(hA : Measurable (a (meshTime T N j)))(hpos : 0 < ∫ z, (a (meshTime T N j) (euler T N γ u z j))^2∂gaussianProduct (Fin (N+1))) :let H := fun z ↦ a (meshTime T N j) (euler T N γ u z j)let μ := gaussianProduct (Fin (N+1))0 < predictableNormalizer H μ ∧(∫ z, normalizedIncrement H (coordinate N j) μ z ∂μ)=0 ∧(∫ z, (normalizedIncrement H (coordinate N j) μ z)^2 ∂μ)=1 := bydsimp onlyhave hm := hA.comp (measurable_euler T N γ u hU j (by omega))have hind := euler_coefficient_independent (γ := γ) hj hU hAexact ⟨predictableNormalizer_pos hpos,normalizedIncrement_mean hm.aestronglyMeasurable (coordinate_hasLaw N j) hind,normalizedIncrement_second_moment hm.aestronglyMeasurable (coordinate_hasLaw N j) hind hpos⟩end SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199import Mathlibimport OAI.Probability.SKValue.GroundState.AdaptiveColumnsimport OAI.Probability.SKValue.GroundState.GramSchmidtLimitimport OAI.Probability.SKValue.GroundState.EmpiricalVectorsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueGnoncomputable def spinVector (n : ℕ) (s : Fin n → Bool) : EuclideanSpace ℝ (Fin n) :=WithLp.toLp 2 (fun i ↦ spin (s i))lemma spinVector_inner (n : ℕ) (s t : Fin n → Bool) :⟪spinVector n s,spinVector n t⟫=∑ i,spin (s i)*spin (t i) := euclidean_inner_sum _ _lemma spinVector_sqNorm (n : ℕ) (s : Fin n → Bool) : ‖spinVector n s‖^2=(n : ℝ) := byrw [←real_inner_self_eq_norm_sq,spinVector_inner]simp only [←sq,spin_sq,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,mul_one]lemma spinVector_norm (n : ℕ) (s : Fin n → Bool) : ‖spinVector n s‖=Real.sqrt (n : ℝ) := byrw [←spinVector_sqNorm n s,Real.sqrt_sq (norm_nonneg _)]lemma finiteMaximum_mul_nonneg {ι : Type*} [Fintype ι] [Nonempty ι](f : ι → ℝ) {c : ℝ} (hc : 0≤c) :finiteMaximum (fun i ↦ c*f i)=c*finiteMaximum f := byobtain ⟨i,hi⟩ := exists_finiteMaximum fapply le_antisymm· obtain ⟨j,hj⟩ := exists_finiteMaximum (fun i ↦ c*f i)rw [←hj]exact mul_le_mul_of_nonneg_left (le_finiteMaximum f j) hc· rw [←hi]exact le_finiteMaximum (fun i ↦ c*f i) ilemma scaled_linearProcess {ι κ : Type*} [Fintype κ] (a : ι → κ → ℝ) (c : ℝ)(z : κ → ℝ) (i : ι) : linearProcess (fun i k ↦ c*a i k) z i=c*linearProcess a z i := bysimp only [linearProcess,Finset.mul_sum,mul_assoc]lemma quadratic_spin_distance {n : ℕ} (hn : 0<n) (s t : Fin n → Bool) :(∑ k,(quadraticCoeff (spinVector n s) k-quadraticCoeff (spinVector n t) k)^2)=∑ k,(Real.sqrt (n : ℝ)*hamCoeff n s k-Real.sqrt (n : ℝ)*hamCoeff n t k)^2 := byhave hs0 : (n : ℝ)≠0 := by exact_mod_cast hn.ne'have hq (s : Fin n → Bool) :(∑ k,(quadraticCoeff (spinVector n s) k)^2)=(n : ℝ)^2/2 := bysimp only [sq]rw [quadraticCoeff_inner,real_inner_self_eq_norm_sq,spinVector_sqNorm]ringrw [sq_distance_sum,hq,hq,quadraticCoeff_inner,spinVector_inner]have hs : (∑ k,(Real.sqrt (n : ℝ)*hamCoeff n s k-Real.sqrt (n : ℝ)*hamCoeff n t k)^2)=(n : ℝ)*(∑ k,(hamCoeff n s k-hamCoeff n t k)^2) := bysimp only [←mul_sub,mul_pow,Real.sq_sqrt (Nat.cast_nonneg n),Finset.mul_sum]rw [hs,hamCoeff_distance hn]field_simpringtheorem quadraticValue_spin {n : ℕ} (hn : 0<n) :quadraticValue (spinVector n) (fun _ ↦ 0)=Real.sqrt (n : ℝ)*expectedMaximum n := byhave he : (∫ z,finiteMaximum (fun s ↦ linearProcess (fun s ↦ quadraticCoeff (spinVector n s)) z s+0)∂gaussianProduct (Fin n×Fin n))=∫ z,finiteMaximum (fun s ↦ linearProcess (fun s k ↦ Real.sqrt (n : ℝ)*hamCoeff n s k) z s+0)∂gaussianProduct (Fin n×Fin n) := byapply le_antisymm· exact expected_affine_max_le _ _ (fun _ ↦ 0) (fun s t ↦ (quadratic_spin_distance hn s t).le)· exact expected_affine_max_le _ _ (fun _ ↦ 0) (fun s t ↦ (quadratic_spin_distance hn s t).ge)unfold quadraticValuerw [he]simp only [add_zero,scaled_linearProcess,finiteMaximum_mul_nonneg _ (Real.sqrt_nonneg _)]rw [integral_const_mul]rfltheorem finite_adaptive_SK_lower {n : ℕ} (hn : 0<n)(v : (j : ℕ) → ColumnHistory (Fin n) j → EuclideanSpace ℝ (Fin n))(hv : ∀ j,Measurable (v j)) (hu : ∀ j h,v j h=0 ∨ ⟪v j h,v j h⟫=1)(K : ℕ) (s : ColumnHistory (Fin n) K → (Fin n → Bool))(hs : Measurable (fun h ↦ adaptiveOffset (spinVector n) v K h (s h))) :(∫ h,adaptiveOffset (spinVector n) v K h (s h) ∂columnHistoryLaw (Fin n) K)/((n : ℝ)*Real.sqrt (n : ℝ))≤groundStateSequence n := byhave hh := adaptive_spin_lower (spinVector n) v hv hu (Real.sqrt (n : ℝ))(fun s ↦ (spinVector_norm n s).le) K s hsrw [quadraticValue_spin hn] at hhhave hn' : (0 : ℝ)<n := by exact_mod_cast hnhave pro : (0 : ℝ)<(n : ℝ)*Real.sqrt (n : ℝ) := mul_pos hn' (Real.sqrt_pos.mpr hn')apply (div_le_div_of_nonneg_right hh pro.le).trans_eqrw [groundStateSequence_eq]field_simpend SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueGlemma orthogonalRemainder_smul {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E](v : ℕ → E) (w : E) (j : ℕ) (c : ℝ) :orthogonalRemainder v (c • w) j=c • orthogonalRemainder v w j := bysimp only [orthogonalRemainder,smul_sub,Finset.smul_sum,real_inner_smul_right,smul_smul]lemma columnVector_smul {κ : Type*} [Fintype κ](v w : EuclideanSpace ℝ κ) (c : ℝ) : columnVector v (c • w)=c^2 • columnVector v w := bysimp only [columnVector,columnResidual,real_inner_smul_right,smul_sub,smul_add,smul_smul]modulelemma empiricalVector_scale {Ω : Type*} (f : Ω → ℝ) (x : ℕ → Ω) {n : ℕ} (hn : 0<n) :Real.sqrt (n : ℝ) • empiricalVector f x n=WithLp.toLp 2 (fun i : Fin n ↦ f (x i)) := byrw [empiricalVector,smul_smul,mul_inv_cancel₀,one_smul]exact Real.sqrt_ne_zero'.mpr (by exact_mod_cast hn)variable (K n : ℕ) (f : ℕ → (Fin (K+1) → ℝ) → ℝ)(ha : ∀ l x y,(∀ i : Fin (K+1),i.val≤l → x i=y i) → f l x=f l y)(x : ℕ → (Fin (K+1) → ℝ))include ha inlemma predictableResidual_rows {ι : Type*} [Fintype ι] [Nonempty ι](w : ι → EuclideanSpace ℝ (Fin n)) (j : ℕ) (s : ι) :adaptiveResidual w (predictableDirection K n f) (j+1)(rowHistory K n (fun i ↦ x i) (j+1)) s=orthogonalRemainder (gramSchmidtNormed ℝ (fun l ↦ empiricalVector (f l) x n)) (w s) j := byinduction j with| zero => simp [adaptiveResidual,predictableDirection,columnResidual,orthogonalRemainder]| succ j ih =>change columnResidual (predictableDirection K n f (j+1)(rowHistory K n (fun i ↦ x i) (j+1)))(adaptiveResidual w (predictableDirection K n f) (j+1)(rowHistory K n (fun i ↦ x i) (j+1)) s)=_rw [predictableDirection_rows K n f ha x j,ih]apply columnResidual_orthogonalRemainderintro i hiexact gramSchmidtNormed_pairwise_orthogonal _ (Ne.symm (Nat.ne_of_lt hi))include ha inlemma predictableOffset_rows {ι : Type*} [Fintype ι] [Nonempty ι](w : ι → EuclideanSpace ℝ (Fin n)) (J : ℕ) (s : ι) :adaptiveOffset w (predictableDirection K n f) (J+1)(rowHistory K n (fun i ↦ x i) (J+1)) s=∑ j∈Finset.range J,⟪columnVector (gramSchmidtNormed ℝ (fun l ↦ empiricalVector (f l) x n) j)(orthogonalRemainder (gramSchmidtNormed ℝ (fun l ↦ empiricalVector (f l) x n)) (w s) j),WithLp.toLp 2 (rowColumn K n (fun i ↦ x i) (j+1))⟫ := byinduction J with| zero => simp [adaptiveOffset,predictableDirection,columnVector,columnResidual,linearProcess]| succ J ih =>change adaptiveOffset w (predictableDirection K n f) (J+1)(rowHistory K n (fun i ↦ x i) (J+1)) s+linearProcess (fun i k ↦ columnVector(predictableDirection K n f (J+1) (rowHistory K n (fun i ↦ x i) (J+1)))(adaptiveResidual w (predictableDirection K n f) (J+1)(rowHistory K n (fun i ↦ x i) (J+1)) i) k)(rowColumn K n (fun i ↦ x i) (J+1)) s=_rw [ih,Finset.sum_range_succ,predictableDirection_rows K n f ha x J]congr 1unfold linearProcessdsimp onlyrw [predictableResidual_rows K n f ha x w J s]rw [euclidean_inner_sum]noncomputable def empiricalColumnEnergy (F : (Fin (K+1) → ℝ) → ℝ) (j : ℕ) : ℝ :=⟪columnVector (gramSchmidtNormed ℝ (fun l ↦ empiricalVector (f l) x n) j)(orthogonalRemainder (gramSchmidtNormed ℝ (fun l ↦ empiricalVector (f l) x n))(empiricalVector F x n) j),empiricalVector (fun y ↦ if hj : j+1<K+1 then y ⟨j+1,hj⟩ else 0) x n⟫include ha inlemma normalizedOffset_rows (hn : 0<n) (F : (Fin (K+1) → ℝ) → Bool) :adaptiveOffset (spinVector n) (predictableDirection K n f) (K+1)(rowHistory K n (fun i ↦ x i) (K+1)) (fun i ↦ F (x i))/((n : ℝ)*Real.sqrt (n : ℝ))=∑ j∈Finset.range K,empiricalColumnEnergy K n f x (fun y ↦ spin (F y)) j := byrw [predictableOffset_rows K n f ha x (spinVector n) K]rw [Finset.sum_div]apply Finset.sum_congr rflintro j hjhave hw : spinVector n (fun i ↦ F (x i))=Real.sqrt (n : ℝ) • empiricalVector (fun y ↦ spin (F y)) x n :=(empiricalVector_scale (fun y ↦ spin (F y)) x hn).symmhave hz : WithLp.toLp 2 (rowColumn K n (fun i ↦ x i) (j+1))=Real.sqrt (n : ℝ) • empiricalVector(fun y ↦ if hj : j+1<K+1 then y ⟨j+1,hj⟩ else 0) x n :=bychange (WithLp.toLp 2 (fun i : Fin n ↦ if hj : j+1<K+1 then x i ⟨j+1,hj⟩ else 0)) = _exact (empiricalVector_scale (fun y : Fin (K+1) → ℝ ↦ if hj : j+1<K+1 then y ⟨j+1,hj⟩ else 0) x hn).symmrw [hw,hz,orthogonalRemainder_smul,columnVector_smul,real_inner_smul_left,real_inner_smul_right,Real.sq_sqrt (Nat.cast_nonneg n)]unfold empiricalColumnEnergyhave hn' : (n : ℝ)≠0 := by exact_mod_cast hn.ne'have hs : Real.sqrt (n : ℝ)≠0 := Real.sqrt_ne_zero'.mpr (by exact_mod_cast hn)field_simpend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199import Mathlibimport OAI.Probability.SKValue.GroundState.AdaptiveColumnsimport OAI.Probability.SKValue.GroundState.GramSchmidtLimitimport OAI.Probability.SKValue.GroundState.EmpiricalVectorsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueGnoncomputable def spinVector (n : ℕ) (s : Fin n → Bool) : EuclideanSpace ℝ (Fin n) :=WithLp.toLp 2 (fun i ↦ spin (s i))lemma spinVector_inner (n : ℕ) (s t : Fin n → Bool) :⟪spinVector n s,spinVector n t⟫=∑ i,spin (s i)*spin (t i) := euclidean_inner_sum _ _lemma spinVector_sqNorm (n : ℕ) (s : Fin n → Bool) : ‖spinVector n s‖^2=(n : ℝ) := byrw [←real_inner_self_eq_norm_sq,spinVector_inner]simp only [←sq,spin_sq,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,mul_one]lemma spinVector_norm (n : ℕ) (s : Fin n → Bool) : ‖spinVector n s‖=Real.sqrt (n : ℝ) := byrw [←spinVector_sqNorm n s,Real.sqrt_sq (norm_nonneg _)]lemma finiteMaximum_mul_nonneg {ι : Type*} [Fintype ι] [Nonempty ι](f : ι → ℝ) {c : ℝ} (hc : 0≤c) :finiteMaximum (fun i ↦ c*f i)=c*finiteMaximum f := byobtain ⟨i,hi⟩ := exists_finiteMaximum fapply le_antisymm· obtain ⟨j,hj⟩ := exists_finiteMaximum (fun i ↦ c*f i)rw [←hj]exact mul_le_mul_of_nonneg_left (le_finiteMaximum f j) hc· rw [←hi]exact le_finiteMaximum (fun i ↦ c*f i) ilemma scaled_linearProcess {ι κ : Type*} [Fintype κ] (a : ι → κ → ℝ) (c : ℝ)(z : κ → ℝ) (i : ι) : linearProcess (fun i k ↦ c*a i k) z i=c*linearProcess a z i := bysimp only [linearProcess,Finset.mul_sum,mul_assoc]lemma quadratic_spin_distance {n : ℕ} (hn : 0<n) (s t : Fin n → Bool) :(∑ k,(quadraticCoeff (spinVector n s) k-quadraticCoeff (spinVector n t) k)^2)=∑ k,(Real.sqrt (n : ℝ)*hamCoeff n s k-Real.sqrt (n : ℝ)*hamCoeff n t k)^2 := byhave hs0 : (n : ℝ)≠0 := by exact_mod_cast hn.ne'have hq (s : Fin n → Bool) :(∑ k,(quadraticCoeff (spinVector n s) k)^2)=(n : ℝ)^2/2 := bysimp only [sq]rw [quadraticCoeff_inner,real_inner_self_eq_norm_sq,spinVector_sqNorm]ringrw [sq_distance_sum,hq,hq,quadraticCoeff_inner,spinVector_inner]have hs : (∑ k,(Real.sqrt (n : ℝ)*hamCoeff n s k-Real.sqrt (n : ℝ)*hamCoeff n t k)^2)=(n : ℝ)*(∑ k,(hamCoeff n s k-hamCoeff n t k)^2) := bysimp only [←mul_sub,mul_pow,Real.sq_sqrt (Nat.cast_nonneg n),Finset.mul_sum]rw [hs,hamCoeff_distance hn]field_simpringtheorem quadraticValue_spin {n : ℕ} (hn : 0<n) :quadraticValue (spinVector n) (fun _ ↦ 0)=Real.sqrt (n : ℝ)*expectedMaximum n := byhave he : (∫ z,finiteMaximum (fun s ↦ linearProcess (fun s ↦ quadraticCoeff (spinVector n s)) z s+0)∂gaussianProduct (Fin n×Fin n))=∫ z,finiteMaximum (fun s ↦ linearProcess (fun s k ↦ Real.sqrt (n : ℝ)*hamCoeff n s k) z s+0)∂gaussianProduct (Fin n×Fin n) := byapply le_antisymm· exact expected_affine_max_le _ _ (fun _ ↦ 0) (fun s t ↦ (quadratic_spin_distance hn s t).le)· exact expected_affine_max_le _ _ (fun _ ↦ 0) (fun s t ↦ (quadratic_spin_distance hn s t).ge)unfold quadraticValuerw [he]simp only [add_zero,scaled_linearProcess,finiteMaximum_mul_nonneg _ (Real.sqrt_nonneg _)]rw [integral_const_mul]rfltheorem finite_adaptive_SK_lower {n : ℕ} (hn : 0<n)(v : (j : ℕ) → ColumnHistory (Fin n) j → EuclideanSpace ℝ (Fin n))(hv : ∀ j,Measurable (v j)) (hu : ∀ j h,v j h=0 ∨ ⟪v j h,v j h⟫=1)(K : ℕ) (s : ColumnHistory (Fin n) K → (Fin n → Bool))(hs : Measurable (fun h ↦ adaptiveOffset (spinVector n) v K h (s h))) :(∫ h,adaptiveOffset (spinVector n) v K h (s h) ∂columnHistoryLaw (Fin n) K)/((n : ℝ)*Real.sqrt (n : ℝ))≤groundStateSequence n := byhave hh := adaptive_spin_lower (spinVector n) v hv hu (Real.sqrt (n : ℝ))(fun s ↦ (spinVector_norm n s).le) K s hsrw [quadraticValue_spin hn] at hhhave hn' : (0 : ℝ)<n := by exact_mod_cast hnhave pro : (0 : ℝ)<(n : ℝ)*Real.sqrt (n : ℝ) := mul_pos hn' (Real.sqrt_pos.mpr hn')apply (div_le_div_of_nonneg_right hh pro.le).trans_eqrw [groundStateSequence_eq]field_simpend SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueGlemma orthogonalRemainder_smul {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E](v : ℕ → E) (w : E) (j : ℕ) (c : ℝ) :orthogonalRemainder v (c • w) j=c • orthogonalRemainder v w j := bysimp only [orthogonalRemainder,smul_sub,Finset.smul_sum,real_inner_smul_right,smul_smul]lemma columnVector_smul {κ : Type*} [Fintype κ](v w : EuclideanSpace ℝ κ) (c : ℝ) : columnVector v (c • w)=c^2 • columnVector v w := bysimp only [columnVector,columnResidual,real_inner_smul_right,smul_sub,smul_add,smul_smul]modulelemma empiricalVector_scale {Ω : Type*} (f : Ω → ℝ) (x : ℕ → Ω) {n : ℕ} (hn : 0<n) :Real.sqrt (n : ℝ) • empiricalVector f x n=WithLp.toLp 2 (fun i : Fin n ↦ f (x i)) := byrw [empiricalVector,smul_smul,mul_inv_cancel₀,one_smul]exact Real.sqrt_ne_zero'.mpr (by exact_mod_cast hn)variable (K n : ℕ) (f : ℕ → (Fin (K+1) → ℝ) → ℝ)(ha : ∀ l x y,(∀ i : Fin (K+1),i.val≤l → x i=y i) → f l x=f l y)(x : ℕ → (Fin (K+1) → ℝ))include ha inlemma predictableResidual_rows {ι : Type*} [Fintype ι] [Nonempty ι](w : ι → EuclideanSpace ℝ (Fin n)) (j : ℕ) (s : ι) :adaptiveResidual w (predictableDirection K n f) (j+1)(rowHistory K n (fun i ↦ x i) (j+1)) s=orthogonalRemainder (gramSchmidtNormed ℝ (fun l ↦ empiricalVector (f l) x n)) (w s) j := byinduction j with| zero => simp [adaptiveResidual,predictableDirection,columnResidual,orthogonalRemainder]| succ j ih =>change columnResidual (predictableDirection K n f (j+1)(rowHistory K n (fun i ↦ x i) (j+1)))(adaptiveResidual w (predictableDirection K n f) (j+1)(rowHistory K n (fun i ↦ x i) (j+1)) s)=_rw [predictableDirection_rows K n f ha x j,ih]apply columnResidual_orthogonalRemainderintro i hiexact gramSchmidtNormed_pairwise_orthogonal _ (Ne.symm (Nat.ne_of_lt hi))include ha inlemma predictableOffset_rows {ι : Type*} [Fintype ι] [Nonempty ι](w : ι → EuclideanSpace ℝ (Fin n)) (J : ℕ) (s : ι) :adaptiveOffset w (predictableDirection K n f) (J+1)(rowHistory K n (fun i ↦ x i) (J+1)) s=∑ j∈Finset.range J,⟪columnVector (gramSchmidtNormed ℝ (fun l ↦ empiricalVector (f l) x n) j)(orthogonalRemainder (gramSchmidtNormed ℝ (fun l ↦ empiricalVector (f l) x n)) (w s) j),WithLp.toLp 2 (rowColumn K n (fun i ↦ x i) (j+1))⟫ := byinduction J with| zero => simp [adaptiveOffset,predictableDirection,columnVector,columnResidual,linearProcess]| succ J ih =>change adaptiveOffset w (predictableDirection K n f) (J+1)(rowHistory K n (fun i ↦ x i) (J+1)) s+linearProcess (fun i k ↦ columnVector(predictableDirection K n f (J+1) (rowHistory K n (fun i ↦ x i) (J+1)))(adaptiveResidual w (predictableDirection K n f) (J+1)(rowHistory K n (fun i ↦ x i) (J+1)) i) k)(rowColumn K n (fun i ↦ x i) (J+1)) s=_rw [ih,Finset.sum_range_succ,predictableDirection_rows K n f ha x J]congr 1unfold linearProcessdsimp onlyrw [predictableResidual_rows K n f ha x w J s]rw [euclidean_inner_sum]noncomputable def empiricalColumnEnergy (F : (Fin (K+1) → ℝ) → ℝ) (j : ℕ) : ℝ :=⟪columnVector (gramSchmidtNormed ℝ (fun l ↦ empiricalVector (f l) x n) j)(orthogonalRemainder (gramSchmidtNormed ℝ (fun l ↦ empiricalVector (f l) x n))(empiricalVector F x n) j),empiricalVector (fun y ↦ if hj : j+1<K+1 then y ⟨j+1,hj⟩ else 0) x n⟫include ha inlemma normalizedOffset_rows (hn : 0<n) (F : (Fin (K+1) → ℝ) → Bool) :adaptiveOffset (spinVector n) (predictableDirection K n f) (K+1)(rowHistory K n (fun i ↦ x i) (K+1)) (fun i ↦ F (x i))/((n : ℝ)*Real.sqrt (n : ℝ))=∑ j∈Finset.range K,empiricalColumnEnergy K n f x (fun y ↦ spin (F y)) j := byrw [predictableOffset_rows K n f ha x (spinVector n) K]rw [Finset.sum_div]apply Finset.sum_congr rflintro j hjhave hw : spinVector n (fun i ↦ F (x i))=Real.sqrt (n : ℝ) • empiricalVector (fun y ↦ spin (F y)) x n :=(empiricalVector_scale (fun y ↦ spin (F y)) x hn).symmhave hz : WithLp.toLp 2 (rowColumn K n (fun i ↦ x i) (j+1))=Real.sqrt (n : ℝ) • empiricalVector(fun y ↦ if hj : j+1<K+1 then y ⟨j+1,hj⟩ else 0) x n :=bychange (WithLp.toLp 2 (fun i : Fin n ↦ if hj : j+1<K+1 then x i ⟨j+1,hj⟩ else 0)) = _exact (empiricalVector_scale (fun y : Fin (K+1) → ℝ ↦ if hj : j+1<K+1 then y ⟨j+1,hj⟩ else 0) x hn).symmrw [hw,hz,orthogonalRemainder_smul,columnVector_smul,real_inner_smul_left,real_inner_smul_right,Real.sq_sqrt (Nat.cast_nonneg n)]unfold empiricalColumnEnergyhave hn' : (n : ℝ)≠0 := by exact_mod_cast hn.ne'have hs : Real.sqrt (n : ℝ)≠0 := Real.sqrt_ne_zero'.mpr (by exact_mod_cast hn)field_simpend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155import Mathlibimport OAI.Probability.SKValue.GroundState.ColumnBoundsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueGvariable {Ω ι κ ν : Type*} [MeasurableSpace Ω] [Fintype ι] [Nonempty ι][Fintype κ] [Fintype ν] {μ : Measure Ω} [IsProbabilityMeasure μ]lemma measurable_finiteMaximum {f : Ω → ι → ℝ} (hf : ∀ i,Measurable (fun ω ↦ f ω i)) :Measurable (fun ω ↦ finiteMaximum (f ω)) :=continuous_finiteMaximum.measurable.comp (Measurable.of_eval hf)omit [IsProbabilityMeasure μ] inlemma integrable_randomMaximum [IsProbabilityMeasure μ] {f : Ω → ι → ℝ}(hf : ∀ i,Integrable (fun ω ↦ f ω i) μ) :Integrable (fun ω ↦ finiteMaximum (f ω)) μ := byapply (integrable_finsetSum Finset.univ (fun i _ ↦ (hf i).abs)).mono'(continuous_finiteMaximum.comp_aestronglyMeasurable((integrable_pi_iff.mpr hf).aestronglyMeasurable))exact Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs] using abs_finiteMaximum_le (f ω))omit [Fintype ι] [Nonempty ι] inlemma random_linear_integrable [Fintype ι] [Nonempty ι] (a : Ω → ι → ν → ℝ)(ha : ∀ i k,Measurable (fun ω ↦ a ω i k)) (C : ℝ)(hC : ∀ ω i k,|a ω i k|≤C) (i : ι) :Integrable (fun p : Ω×(ν → ℝ) ↦ linearProcess (a p.1) p.2 i)(μ.prod (gaussianProduct ν)) := byunfold linearProcessapply integrable_finsetSumintro k _apply ((gaussian_coordinate_integrable k).abs.const_mul C |>.comp_snd μ).mono'(((ha i k).comp measurable_fst).mul ((measurable_pi_apply k).comp measurable_snd)).aestronglyMeasurableexact Eventually.of_forall (fun p ↦ bychange |a p.1 i k * p.2 k| ≤ C * |p.2 k|rw [abs_mul]exact mul_le_mul_of_nonneg_right (hC p.1 i k) (abs_nonneg _))lemma measurable_quadraticValue (w : Ω → ι → EuclideanSpace ℝ κ) (d : Ω → ι → ℝ)(hw : ∀ i,Measurable (fun ω ↦ w ω i)) (hd : ∀ i,Measurable (fun ω ↦ d ω i)) :Measurable (fun ω ↦ quadraticValue (w ω) (d ω)) := byhave hm : Measurable (fun p : Ω×((κ×κ) → ℝ) ↦finiteMaximum (fun i ↦ linearProcess (fun i ↦ quadraticCoeff (w p.1 i)) p.2 i+d p.1 i)) := byapply measurable_finiteMaximumintro iunfold linearProcess quadraticCoefffun_propexact hm.stronglyMeasurable.integral_prod_right.measurablelemma random_quadratic_integrable (w : Ω → ι → EuclideanSpace ℝ κ) (d : Ω → ι → ℝ)(hw : ∀ i,Measurable (fun ω ↦ w ω i)) (hd : ∀ i,Integrable (fun ω ↦ d ω i) μ)(R : ℝ) (hR : ∀ ω i,‖w ω i‖≤R) :Integrable (fun ω ↦ quadraticValue (w ω) (d ω)) μ := byhave hi : Integrable (fun p : Ω×((κ×κ) → ℝ) ↦finiteMaximum (fun i ↦ linearProcess (fun i ↦ quadraticCoeff (w p.1 i)) p.2 i+d p.1 i))(μ.prod (gaussianProduct (κ×κ))) := byapply integrable_randomMaximumintro iapply Integrable.add _ ((hd i).comp_fst _)apply random_linear_integrable (fun ω i ↦ quadraticCoeff (w ω i)) _ (R^2) _ i· intro i k; unfold quadraticCoeff; fun_prop· intro ω i kexact (quadraticCoeff_coord_bound _ _).trans (sq_le_sq₀ (norm_nonneg _) (le_trans (norm_nonneg _) (hR ω i)) |>.mpr (hR ω i))exact hi.integral_prod_leftlemma columnVector_coord_bound {v : EuclideanSpace ℝ κ} (hv : v=0 ∨ ⟪v,v⟫=1)(w : EuclideanSpace ℝ κ) (k : κ) : |columnVector v w k|≤‖w‖^2 :=(PiLp.norm_apply_le _ k).trans (columnVector_norm_le hv w)theorem random_column_identity (w : Ω → ι → EuclideanSpace ℝ κ) (d : Ω → ι → ℝ)(v : Ω → EuclideanSpace ℝ κ) (hw : ∀ i,Measurable (fun ω ↦ w ω i))(_hdm : ∀ i,Measurable (fun ω ↦ d ω i))(hd : ∀ i,Integrable (fun ω ↦ d ω i) μ) (hv : Measurable v)(hu : ∀ ω,v ω=0 ∨ ⟪v ω,v ω⟫=1) (R : ℝ) (hR : ∀ ω i,‖w ω i‖≤R) :(∫ ω,quadraticValue (w ω) (d ω) ∂μ)=∫ p : Ω×(κ → ℝ),quadraticValue (fun i ↦ columnResidual (v p.1) (w p.1 i))(fun i ↦ d p.1 i+linearProcess (fun i k ↦ columnVector (v p.1) (w p.1 i) k) p.2 i)∂μ.prod (gaussianProduct κ) := byhave hw' (i : ι) : Measurable (fun p : Ω×(κ → ℝ) ↦ columnResidual (v p.1) (w p.1 i)) :=measurable_columnResidual (hv.comp measurable_fst) ((hw i).comp measurable_fst)have hd' (i : ι) : Integrable (fun p : Ω×(κ → ℝ) ↦d p.1 i+linearProcess (fun i k ↦ columnVector (v p.1) (w p.1 i) k) p.2 i)(μ.prod (gaussianProduct κ)) := byapply ((hd i).comp_fst _).addapply random_linear_integrable (fun ω i k ↦ columnVector (v ω) (w ω i) k) _ (R^2) _ i· intro i kexact (PiLp.continuous_apply 2 (fun _ : κ ↦ ℝ) k).measurable.comp (measurable_columnVector hv (hw i))· intro ω i kexact (columnVector_coord_bound (hu ω) _ _).trans((sq_le_sq₀ (norm_nonneg _) ((norm_nonneg _).trans (hR ω i))).mpr (hR ω i))have hi := random_quadratic_integrable _ _ hw' hd' R(fun p i ↦ (columnResidual_norm_le (hu p.1) (w p.1 i)).trans (hR p.1 i))rw [integral_prod _ hi]apply integral_congr_aeexact Eventually.of_forall (fun ω ↦ quadraticValue_column (w ω) (d ω) (v ω) (hu ω))end SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueGvariable (κ : Type*) [Fintype κ]abbrev ColumnHistory (j : ℕ) := Fin j → κ → ℝnoncomputable def columnHistoryLaw (j : ℕ) : Measure (ColumnHistory κ j) :=Measure.pi (fun _ ↦ gaussianProduct κ)instance (j : ℕ) : IsProbabilityMeasure (columnHistoryLaw κ j) := byunfold columnHistoryLaw; infer_instancedef historyInit {j : ℕ} (h : ColumnHistory κ (j+1)) : ColumnHistory κ j := fun i ↦ h i.castSuccdef historySplit (j : ℕ) : ColumnHistory κ (j+1) ≃ᵐ ColumnHistory κ j × (κ → ℝ) :=(MeasurableEquiv.piFinSuccAbove (fun _ : Fin (j+1) ↦ κ → ℝ) (Fin.last j)).transMeasurableEquiv.prodCommomit [Fintype κ] inlemma historySplit_apply [Fintype κ] (j : ℕ) (h : ColumnHistory κ (j+1)) :historySplit κ j h=(historyInit κ h,h (Fin.last j)) := bysimp [historySplit,MeasurableEquiv.piFinSuccAbove,Fin.insertNthEquiv]rfllemma historySplit_preserving (j : ℕ) :MeasurePreserving (historySplit κ j) (columnHistoryLaw κ (j+1))((columnHistoryLaw κ j).prod (gaussianProduct κ)) := byexact (Measure.measurePreserving_swap).comp(measurePreserving_piFinSuccAbove (fun _ : Fin (j+1) ↦ gaussianProduct κ) (Fin.last j))omit [Fintype κ] inlemma historyInit_measurable [Fintype κ] (j : ℕ) : Measurable (historyInit κ (j:=j)) := byunfold historyInit; fun_proplemma history_integral_succ (j : ℕ) (f : ColumnHistory κ j × (κ → ℝ) → ℝ) :(∫ h,f (historyInit κ h,h (Fin.last j)) ∂columnHistoryLaw κ (j+1))=∫ p,f p ∂(columnHistoryLaw κ j).prod (gaussianProduct κ) := bysimpa only [historySplit_apply] using (historySplit_preserving κ j).integral_comp' flemma history_integrable_succ (j : ℕ) {f : ColumnHistory κ j × (κ → ℝ) → ℝ}(hf : Integrable f ((columnHistoryLaw κ j).prod (gaussianProduct κ))) :Integrable (fun h ↦ f (historyInit κ h,h (Fin.last j))) (columnHistoryLaw κ (j+1)) := bysimpa only [Function.comp_def,historySplit_apply] using (historySplit_preserving κ j).integrable_comphf.aestronglyMeasurable |>.mpr hfend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155import Mathlibimport OAI.Probability.SKValue.GroundState.ColumnBoundsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueGvariable {Ω ι κ ν : Type*} [MeasurableSpace Ω] [Fintype ι] [Nonempty ι][Fintype κ] [Fintype ν] {μ : Measure Ω} [IsProbabilityMeasure μ]lemma measurable_finiteMaximum {f : Ω → ι → ℝ} (hf : ∀ i,Measurable (fun ω ↦ f ω i)) :Measurable (fun ω ↦ finiteMaximum (f ω)) :=continuous_finiteMaximum.measurable.comp (Measurable.of_eval hf)omit [IsProbabilityMeasure μ] inlemma integrable_randomMaximum [IsProbabilityMeasure μ] {f : Ω → ι → ℝ}(hf : ∀ i,Integrable (fun ω ↦ f ω i) μ) :Integrable (fun ω ↦ finiteMaximum (f ω)) μ := byapply (integrable_finsetSum Finset.univ (fun i _ ↦ (hf i).abs)).mono'(continuous_finiteMaximum.comp_aestronglyMeasurable((integrable_pi_iff.mpr hf).aestronglyMeasurable))exact Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs] using abs_finiteMaximum_le (f ω))omit [Fintype ι] [Nonempty ι] inlemma random_linear_integrable [Fintype ι] [Nonempty ι] (a : Ω → ι → ν → ℝ)(ha : ∀ i k,Measurable (fun ω ↦ a ω i k)) (C : ℝ)(hC : ∀ ω i k,|a ω i k|≤C) (i : ι) :Integrable (fun p : Ω×(ν → ℝ) ↦ linearProcess (a p.1) p.2 i)(μ.prod (gaussianProduct ν)) := byunfold linearProcessapply integrable_finsetSumintro k _apply ((gaussian_coordinate_integrable k).abs.const_mul C |>.comp_snd μ).mono'(((ha i k).comp measurable_fst).mul ((measurable_pi_apply k).comp measurable_snd)).aestronglyMeasurableexact Eventually.of_forall (fun p ↦ bychange |a p.1 i k * p.2 k| ≤ C * |p.2 k|rw [abs_mul]exact mul_le_mul_of_nonneg_right (hC p.1 i k) (abs_nonneg _))lemma measurable_quadraticValue (w : Ω → ι → EuclideanSpace ℝ κ) (d : Ω → ι → ℝ)(hw : ∀ i,Measurable (fun ω ↦ w ω i)) (hd : ∀ i,Measurable (fun ω ↦ d ω i)) :Measurable (fun ω ↦ quadraticValue (w ω) (d ω)) := byhave hm : Measurable (fun p : Ω×((κ×κ) → ℝ) ↦finiteMaximum (fun i ↦ linearProcess (fun i ↦ quadraticCoeff (w p.1 i)) p.2 i+d p.1 i)) := byapply measurable_finiteMaximumintro iunfold linearProcess quadraticCoefffun_propexact hm.stronglyMeasurable.integral_prod_right.measurablelemma random_quadratic_integrable (w : Ω → ι → EuclideanSpace ℝ κ) (d : Ω → ι → ℝ)(hw : ∀ i,Measurable (fun ω ↦ w ω i)) (hd : ∀ i,Integrable (fun ω ↦ d ω i) μ)(R : ℝ) (hR : ∀ ω i,‖w ω i‖≤R) :Integrable (fun ω ↦ quadraticValue (w ω) (d ω)) μ := byhave hi : Integrable (fun p : Ω×((κ×κ) → ℝ) ↦finiteMaximum (fun i ↦ linearProcess (fun i ↦ quadraticCoeff (w p.1 i)) p.2 i+d p.1 i))(μ.prod (gaussianProduct (κ×κ))) := byapply integrable_randomMaximumintro iapply Integrable.add _ ((hd i).comp_fst _)apply random_linear_integrable (fun ω i ↦ quadraticCoeff (w ω i)) _ (R^2) _ i· intro i k; unfold quadraticCoeff; fun_prop· intro ω i kexact (quadraticCoeff_coord_bound _ _).trans (sq_le_sq₀ (norm_nonneg _) (le_trans (norm_nonneg _) (hR ω i)) |>.mpr (hR ω i))exact hi.integral_prod_leftlemma columnVector_coord_bound {v : EuclideanSpace ℝ κ} (hv : v=0 ∨ ⟪v,v⟫=1)(w : EuclideanSpace ℝ κ) (k : κ) : |columnVector v w k|≤‖w‖^2 :=(PiLp.norm_apply_le _ k).trans (columnVector_norm_le hv w)theorem random_column_identity (w : Ω → ι → EuclideanSpace ℝ κ) (d : Ω → ι → ℝ)(v : Ω → EuclideanSpace ℝ κ) (hw : ∀ i,Measurable (fun ω ↦ w ω i))(_hdm : ∀ i,Measurable (fun ω ↦ d ω i))(hd : ∀ i,Integrable (fun ω ↦ d ω i) μ) (hv : Measurable v)(hu : ∀ ω,v ω=0 ∨ ⟪v ω,v ω⟫=1) (R : ℝ) (hR : ∀ ω i,‖w ω i‖≤R) :(∫ ω,quadraticValue (w ω) (d ω) ∂μ)=∫ p : Ω×(κ → ℝ),quadraticValue (fun i ↦ columnResidual (v p.1) (w p.1 i))(fun i ↦ d p.1 i+linearProcess (fun i k ↦ columnVector (v p.1) (w p.1 i) k) p.2 i)∂μ.prod (gaussianProduct κ) := byhave hw' (i : ι) : Measurable (fun p : Ω×(κ → ℝ) ↦ columnResidual (v p.1) (w p.1 i)) :=measurable_columnResidual (hv.comp measurable_fst) ((hw i).comp measurable_fst)have hd' (i : ι) : Integrable (fun p : Ω×(κ → ℝ) ↦d p.1 i+linearProcess (fun i k ↦ columnVector (v p.1) (w p.1 i) k) p.2 i)(μ.prod (gaussianProduct κ)) := byapply ((hd i).comp_fst _).addapply random_linear_integrable (fun ω i k ↦ columnVector (v ω) (w ω i) k) _ (R^2) _ i· intro i kexact (PiLp.continuous_apply 2 (fun _ : κ ↦ ℝ) k).measurable.comp (measurable_columnVector hv (hw i))· intro ω i kexact (columnVector_coord_bound (hu ω) _ _).trans((sq_le_sq₀ (norm_nonneg _) ((norm_nonneg _).trans (hR ω i))).mpr (hR ω i))have hi := random_quadratic_integrable _ _ hw' hd' R(fun p i ↦ (columnResidual_norm_le (hu p.1) (w p.1 i)).trans (hR p.1 i))rw [integral_prod _ hi]apply integral_congr_aeexact Eventually.of_forall (fun ω ↦ quadraticValue_column (w ω) (d ω) (v ω) (hu ω))end SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueGvariable (κ : Type*) [Fintype κ]abbrev ColumnHistory (j : ℕ) := Fin j → κ → ℝnoncomputable def columnHistoryLaw (j : ℕ) : Measure (ColumnHistory κ j) :=Measure.pi (fun _ ↦ gaussianProduct κ)instance (j : ℕ) : IsProbabilityMeasure (columnHistoryLaw κ j) := byunfold columnHistoryLaw; infer_instancedef historyInit {j : ℕ} (h : ColumnHistory κ (j+1)) : ColumnHistory κ j := fun i ↦ h i.castSuccdef historySplit (j : ℕ) : ColumnHistory κ (j+1) ≃ᵐ ColumnHistory κ j × (κ → ℝ) :=(MeasurableEquiv.piFinSuccAbove (fun _ : Fin (j+1) ↦ κ → ℝ) (Fin.last j)).transMeasurableEquiv.prodCommomit [Fintype κ] inlemma historySplit_apply [Fintype κ] (j : ℕ) (h : ColumnHistory κ (j+1)) :historySplit κ j h=(historyInit κ h,h (Fin.last j)) := bysimp [historySplit,MeasurableEquiv.piFinSuccAbove,Fin.insertNthEquiv]rfllemma historySplit_preserving (j : ℕ) :MeasurePreserving (historySplit κ j) (columnHistoryLaw κ (j+1))((columnHistoryLaw κ j).prod (gaussianProduct κ)) := byexact (Measure.measurePreserving_swap).comp(measurePreserving_piFinSuccAbove (fun _ : Fin (j+1) ↦ gaussianProduct κ) (Fin.last j))omit [Fintype κ] inlemma historyInit_measurable [Fintype κ] (j : ℕ) : Measurable (historyInit κ (j:=j)) := byunfold historyInit; fun_proplemma history_integral_succ (j : ℕ) (f : ColumnHistory κ j × (κ → ℝ) → ℝ) :(∫ h,f (historyInit κ h,h (Fin.last j)) ∂columnHistoryLaw κ (j+1))=∫ p,f p ∂(columnHistoryLaw κ j).prod (gaussianProduct κ) := bysimpa only [historySplit_apply] using (historySplit_preserving κ j).integral_comp' flemma history_integrable_succ (j : ℕ) {f : ColumnHistory κ j × (κ → ℝ) → ℝ}(hf : Integrable f ((columnHistoryLaw κ j).prod (gaussianProduct κ))) :Integrable (fun h ↦ f (historyInit κ h,h (Fin.last j))) (columnHistoryLaw κ (j+1)) := bysimpa only [Function.comp_def,historySplit_apply] using (historySplit_preserving κ j).integrable_comphf.aestronglyMeasurable |>.mpr hfend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178import Mathlibimport OAI.Probability.SKValue.GroundState.FieldTreeLawnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma scalar_pairing_law (T : GaussianTree) :MeasurePreserving (fun p : (TreeEdges T → ℝ)×(TreeEdges T → ℝ) ↦ fun e ↦ (p.1 e,p.2 e))((gaussianProduct (TreeEdges T)).prod (Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw)))(Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw)) :=(measurePreserving_arrowProdEquivProdArrow ℝ ℝ (TreeEdges T)(fun _ ↦ standardGaussian) (fun _ ↦ gumbelLaw)).symmlemma field_pairing_law (n : ℕ) (T : GaussianTree) :MeasurePreserving (fun p : (Fin n×TreeEdges T → ℝ)×(TreeEdges T → ℝ) ↦ fun e ↦ ((fun i ↦ p.1 (i,e)),p.2 e))((gaussianProduct (Fin n×TreeEdges T)).prod (Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw)))(Measure.pi (fun _ : TreeEdges T ↦ fieldNoiseLaw n)) := byhave hs := measurePreserving_piCongrLeft (fun _ : TreeEdges T×Fin n ↦ standardGaussian)(Equiv.prodComm (Fin n) (TreeEdges T))have hc := (measurePreserving_finite_curry (I := TreeEdges T) (E := Fin n) standardGaussian).comp hshave hp := (measurePreserving_arrowProdEquivProdArrow (Fin n → ℝ) ℝ (TreeEdges T)(fun _ ↦ gaussianProduct (Fin n)) (fun _ ↦ gumbelLaw)).symmexact hp.comp (hc.prod (MeasurePreserving.id (Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw))))lemma scalarTreeEval_integrable (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :Integrable (scalarTreeEval c q T) (Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw)) :=(scalarTreeEval_law c q T).integrable_comp aestronglyMeasurable_id |>.mpr (scalarTreeLaw_integrable c q T)lemma scalarTreeValue_integrable_prod (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :Integrable (fun p : (TreeEdges T → ℝ)×(TreeEdges T → ℝ) ↦ scalarTreeValue c q T p.1 p.2)((gaussianProduct (TreeEdges T)).prod (Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw))) := byexact (scalar_pairing_law T).integrable_comp (continuous_scalarTreeEval c q T).aestronglyMeasurable|>.mpr (scalarTreeEval_integrable c q T)lemma fieldTreeValue_integrable_prod (n : ℕ) (q : ℝ) (T : GaussianTree) (x : Fin n → ℝ) :Integrable (fun p : (Fin n×TreeEdges T → ℝ)×(TreeEdges T → ℝ) ↦ fieldTreeValue n q T x p.1 p.2)((gaussianProduct (Fin n×TreeEdges T)).prod (Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw))) := byhave hc : Continuous (fieldTreeEval n q T x) :=(continuous_fieldTreeEval n q T).comp (continuous_const.prodMk continuous_id)exact (field_pairing_law n T).integrable_comp hc.aestronglyMeasurable|>.mpr (fieldTreeEval_integrable n q T x)lemma scalarTreeValue_mean (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :(∫ g,∫ z,scalarTreeValue c q T z g ∂gaussianProduct (TreeEdges T)∂Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw))=∫ y,y ∂scalarTreeLaw c q T := byrw [←integral_prod_symm _ (scalarTreeValue_integrable_prod c q T)]have hcomp := (scalarTreeEval_law c q T).comp (scalar_pairing_law T)have he := hcomp.hasLaw.integral_comp aestronglyMeasurable_idexact helemma fieldTreeValue_mean (n : ℕ) (q : ℝ) (T : GaussianTree) (x : Fin n → ℝ) :(∫ g,∫ z,fieldTreeValue n q T x z g ∂gaussianProduct (Fin n×TreeEdges T)∂Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw))=∫ w,fieldTreeEval n q T x w ∂Measure.pi (fun _ : TreeEdges T ↦ fieldNoiseLaw n) := byrw [←integral_prod_symm _ (fieldTreeValue_integrable_prod n q T x)]have hc : Continuous (fieldTreeEval n q T x) :=(continuous_fieldTreeEval n q T).comp (continuous_const.prodMk continuous_id)exact (field_pairing_law n T).hasLaw.integral_comp hc.aestronglyMeasurabletheorem randomized_tree_guerra_upper {n : ℕ} (hn : 0 < n) (T : GaussianTree) (hT : ValidTreeGrid 0 T) :expectedMaximum n+(∫ y,y ∂scalarTreeLaw (fun q l ↦ Real.sqrt ((n : ℝ)/2)*Real.sqrt (l.endpoint^2-q^2)) 0 T) ≤∫ w,fieldTreeEval n 0 T (fun _ ↦ 0) w ∂Measure.pi (fun _ : TreeEdges T ↦ fieldNoiseLaw n) := bylet c : ℝ → TreeLevel → ℝ := fun q l ↦ Real.sqrt ((n : ℝ)/2)*Real.sqrt (l.endpoint^2-q^2)have hiA := scalarTreeValue_integrable_prod c 0 Thave hiF := fieldTreeValue_integrable_prod n 0 T (fun _ ↦ 0)have hg : ∀ g : TreeEdges T → ℝ, expectedMaximum n+(∫ z,scalarTreeValue c 0 T z g ∂gaussianProduct (TreeEdges T)) ≤∫ z,fieldTreeValue n 0 T (fun _ ↦ 0) z g ∂gaussianProduct (Fin n×TreeEdges T) := byintro gsimpa only [scalarTreeValue,fieldTreeValue,zero_add,treeAuxVector,c] usingfinite_tree_guerra_upper hn T hT (treeOffset T g)have hu := integral_mono ((integrable_const (expectedMaximum n)).add hiA.integral_prod_right)hiF.integral_prod_right hgsimp only [Pi.add_apply] at hurw [integral_add (integrable_const _) hiA.integral_prod_right,integral_const,probReal_univ,one_smul,scalarTreeValue_mean,fieldTreeValue_mean] at huexact huend SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma coleHopf_one_sided {ψ : ℝ → ℝ} (hψ : LipschitzWith 1 ψ) {m : ℝ} (hm : 0 < m)(h x y : ℝ) : SKValue.coleHopf m h ψ x ≤ SKValue.coleHopf m h ψ y+|x-y| := byhave hiX := SKValue.lipschitz_exp_integrable hψ hm.le x (Real.sqrt h)have hiY := SKValue.lipschitz_exp_integrable hψ hm.le y (Real.sqrt h)have hpX := SKValue.lipschitz_exp_integral_pos hψ hm.le x (Real.sqrt h)have hpY := SKValue.lipschitz_exp_integral_pos hψ hm.le y (Real.sqrt h)have e : SKValue.standardGaussian=standardGaussian := rflrw [e] at hiX hiY hpX hpYhave hbound : (∫ z,Real.exp (m*ψ (x+Real.sqrt h*z)) ∂standardGaussian) ≤Real.exp (m*|x-y|)*(∫ z,Real.exp (m*ψ (y+Real.sqrt h*z)) ∂standardGaussian) := byrw [←integral_const_mul]apply integral_mono hiX (hiY.const_mul _)intro zhave hl := hψ.dist_le_mul (x+Real.sqrt h*z) (y+Real.sqrt h*z)simp only [Real.dist_eq,NNReal.coe_one,one_mul] at hlrw [show x+Real.sqrt h*z-(y+Real.sqrt h*z)=x-y by ring] at hldsimp onlyrw [←Real.exp_add]apply Real.exp_le_exp.mprhave hh := le_abs_self (ψ (x+Real.sqrt h*z)-ψ (y+Real.sqrt h*z))nlinarithhave hh := Real.log_le_log hpX hboundrw [Real.log_mul (Real.exp_pos _).ne' hpY.ne',Real.log_exp] at hhsimp only [SKValue.coleHopf,ite_eq_right hm.ne',SKValue.heat,e]apply (div_le_iff₀ hm).mprhave he : (Real.log (∫ z,Real.exp (m*ψ (y+Real.sqrt h*z)) ∂standardGaussian)/m+|x-y|)*m=m*|x-y|+Real.log (∫ z,Real.exp (m*ψ (y+Real.sqrt h*z)) ∂standardGaussian) := by field_simp; ringrw [he]exact hhlemma coleHopf_lipschitz {ψ : ℝ → ℝ} (hψ : LipschitzWith 1 ψ) {m : ℝ} (hm : 0 < m)(h : ℝ) : LipschitzWith 1 (SKValue.coleHopf m h ψ) := byapply LipschitzWith.of_dist_le_mulintro x ysimp only [NNReal.coe_one,one_mul,Real.dist_eq]have hxy := coleHopf_one_sided hψ hm h x yhave hyx := coleHopf_one_sided hψ hm h y xrw [abs_sub_comm y x] at hyxexact abs_le.mpr ⟨by linarith,by linarith⟩noncomputable def fieldProfile (q : ℝ) : GaussianTree → ℝ → ℝ| [] => abs| l::T => SKValue.coleHopf l.height (l.endpoint-q) (fieldProfile l.endpoint T)def TreeScale (a : ℝ) : GaussianTree → Prop| [] => 0 ≤ a| l::T => 0 ≤ a ∧ a < l.height ∧ TreeScale l.height Tlemma fieldProfile_lipschitz {T : GaussianTree} {a : ℝ} (h : TreeScale a T) (q : ℝ) :LipschitzWith 1 (fieldProfile q T) := byinduction T generalizing a q with| nil =>apply LipschitzWith.of_dist_le_mulintro x ysimpa only [fieldProfile,NNReal.coe_one,one_mul,Real.dist_eq] using abs_abs_sub_abs_le_abs_sub x y| cons l T ih =>obtain ⟨ha,ham,hT⟩ := hexact coleHopf_lipschitz (ih hT _) (ha.trans_lt ham) _lemma gaussian_exp_sum_profile_integrable {ψ : ℝ → ℝ} (hψ : LipschitzWith 1 ψ){m : ℝ} (hm : 0 ≤ m) (n : ℕ) (x : Fin n → ℝ) (s : ℝ) :Integrable (fun z : Fin n → ℝ ↦ Real.exp (m*∑ i,ψ (x i+s*z i))) (gaussianProduct (Fin n)) := byhave hi := Integrable.fintype_prod (fun i : Fin n ↦ SKValue.lipschitz_exp_integrable hψ hm (x i) s)convert hi using 1· funext zsimp only [Finset.mul_sum,Real.exp_sum]· rfllemma gaussian_exp_sum_coleHopf {ψ : ℝ → ℝ} (hψ : LipschitzWith 1 ψ){m : ℝ} (hm : 0 < m) (n : ℕ) (x : Fin n → ℝ) (h : ℝ) :(∫ z : Fin n → ℝ,Real.exp (m*∑ i,ψ (x i+Real.sqrt h*z i)) ∂gaussianProduct (Fin n))=Real.exp (m*∑ i,SKValue.coleHopf m h ψ (x i)) := bysimp only [Finset.mul_sum,Real.exp_sum]rw [gaussianProduct,integral_fintype_prod_eq_prod (fun i : Fin n ↦ fun z : ℝ ↦ Real.exp (m*ψ (x i+Real.sqrt h*z)))]apply Finset.prod_congr rflintro i _simp only [SKValue.coleHopf,ite_eq_right hm.ne',SKValue.heat]rw [mul_div_cancel₀ _ hm.ne',Real.exp_log (SKValue.lipschitz_exp_integral_pos hψ hm.le (x i) (Real.sqrt h))]rflend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178import Mathlibimport OAI.Probability.SKValue.GroundState.FieldTreeLawnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma scalar_pairing_law (T : GaussianTree) :MeasurePreserving (fun p : (TreeEdges T → ℝ)×(TreeEdges T → ℝ) ↦ fun e ↦ (p.1 e,p.2 e))((gaussianProduct (TreeEdges T)).prod (Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw)))(Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw)) :=(measurePreserving_arrowProdEquivProdArrow ℝ ℝ (TreeEdges T)(fun _ ↦ standardGaussian) (fun _ ↦ gumbelLaw)).symmlemma field_pairing_law (n : ℕ) (T : GaussianTree) :MeasurePreserving (fun p : (Fin n×TreeEdges T → ℝ)×(TreeEdges T → ℝ) ↦ fun e ↦ ((fun i ↦ p.1 (i,e)),p.2 e))((gaussianProduct (Fin n×TreeEdges T)).prod (Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw)))(Measure.pi (fun _ : TreeEdges T ↦ fieldNoiseLaw n)) := byhave hs := measurePreserving_piCongrLeft (fun _ : TreeEdges T×Fin n ↦ standardGaussian)(Equiv.prodComm (Fin n) (TreeEdges T))have hc := (measurePreserving_finite_curry (I := TreeEdges T) (E := Fin n) standardGaussian).comp hshave hp := (measurePreserving_arrowProdEquivProdArrow (Fin n → ℝ) ℝ (TreeEdges T)(fun _ ↦ gaussianProduct (Fin n)) (fun _ ↦ gumbelLaw)).symmexact hp.comp (hc.prod (MeasurePreserving.id (Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw))))lemma scalarTreeEval_integrable (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :Integrable (scalarTreeEval c q T) (Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw)) :=(scalarTreeEval_law c q T).integrable_comp aestronglyMeasurable_id |>.mpr (scalarTreeLaw_integrable c q T)lemma scalarTreeValue_integrable_prod (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :Integrable (fun p : (TreeEdges T → ℝ)×(TreeEdges T → ℝ) ↦ scalarTreeValue c q T p.1 p.2)((gaussianProduct (TreeEdges T)).prod (Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw))) := byexact (scalar_pairing_law T).integrable_comp (continuous_scalarTreeEval c q T).aestronglyMeasurable|>.mpr (scalarTreeEval_integrable c q T)lemma fieldTreeValue_integrable_prod (n : ℕ) (q : ℝ) (T : GaussianTree) (x : Fin n → ℝ) :Integrable (fun p : (Fin n×TreeEdges T → ℝ)×(TreeEdges T → ℝ) ↦ fieldTreeValue n q T x p.1 p.2)((gaussianProduct (Fin n×TreeEdges T)).prod (Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw))) := byhave hc : Continuous (fieldTreeEval n q T x) :=(continuous_fieldTreeEval n q T).comp (continuous_const.prodMk continuous_id)exact (field_pairing_law n T).integrable_comp hc.aestronglyMeasurable|>.mpr (fieldTreeEval_integrable n q T x)lemma scalarTreeValue_mean (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :(∫ g,∫ z,scalarTreeValue c q T z g ∂gaussianProduct (TreeEdges T)∂Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw))=∫ y,y ∂scalarTreeLaw c q T := byrw [←integral_prod_symm _ (scalarTreeValue_integrable_prod c q T)]have hcomp := (scalarTreeEval_law c q T).comp (scalar_pairing_law T)have he := hcomp.hasLaw.integral_comp aestronglyMeasurable_idexact helemma fieldTreeValue_mean (n : ℕ) (q : ℝ) (T : GaussianTree) (x : Fin n → ℝ) :(∫ g,∫ z,fieldTreeValue n q T x z g ∂gaussianProduct (Fin n×TreeEdges T)∂Measure.pi (fun _ : TreeEdges T ↦ gumbelLaw))=∫ w,fieldTreeEval n q T x w ∂Measure.pi (fun _ : TreeEdges T ↦ fieldNoiseLaw n) := byrw [←integral_prod_symm _ (fieldTreeValue_integrable_prod n q T x)]have hc : Continuous (fieldTreeEval n q T x) :=(continuous_fieldTreeEval n q T).comp (continuous_const.prodMk continuous_id)exact (field_pairing_law n T).hasLaw.integral_comp hc.aestronglyMeasurabletheorem randomized_tree_guerra_upper {n : ℕ} (hn : 0 < n) (T : GaussianTree) (hT : ValidTreeGrid 0 T) :expectedMaximum n+(∫ y,y ∂scalarTreeLaw (fun q l ↦ Real.sqrt ((n : ℝ)/2)*Real.sqrt (l.endpoint^2-q^2)) 0 T) ≤∫ w,fieldTreeEval n 0 T (fun _ ↦ 0) w ∂Measure.pi (fun _ : TreeEdges T ↦ fieldNoiseLaw n) := bylet c : ℝ → TreeLevel → ℝ := fun q l ↦ Real.sqrt ((n : ℝ)/2)*Real.sqrt (l.endpoint^2-q^2)have hiA := scalarTreeValue_integrable_prod c 0 Thave hiF := fieldTreeValue_integrable_prod n 0 T (fun _ ↦ 0)have hg : ∀ g : TreeEdges T → ℝ, expectedMaximum n+(∫ z,scalarTreeValue c 0 T z g ∂gaussianProduct (TreeEdges T)) ≤∫ z,fieldTreeValue n 0 T (fun _ ↦ 0) z g ∂gaussianProduct (Fin n×TreeEdges T) := byintro gsimpa only [scalarTreeValue,fieldTreeValue,zero_add,treeAuxVector,c] usingfinite_tree_guerra_upper hn T hT (treeOffset T g)have hu := integral_mono ((integrable_const (expectedMaximum n)).add hiA.integral_prod_right)hiF.integral_prod_right hgsimp only [Pi.add_apply] at hurw [integral_add (integrable_const _) hiA.integral_prod_right,integral_const,probReal_univ,one_smul,scalarTreeValue_mean,fieldTreeValue_mean] at huexact huend SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma coleHopf_one_sided {ψ : ℝ → ℝ} (hψ : LipschitzWith 1 ψ) {m : ℝ} (hm : 0 < m)(h x y : ℝ) : SKValue.coleHopf m h ψ x ≤ SKValue.coleHopf m h ψ y+|x-y| := byhave hiX := SKValue.lipschitz_exp_integrable hψ hm.le x (Real.sqrt h)have hiY := SKValue.lipschitz_exp_integrable hψ hm.le y (Real.sqrt h)have hpX := SKValue.lipschitz_exp_integral_pos hψ hm.le x (Real.sqrt h)have hpY := SKValue.lipschitz_exp_integral_pos hψ hm.le y (Real.sqrt h)have e : SKValue.standardGaussian=standardGaussian := rflrw [e] at hiX hiY hpX hpYhave hbound : (∫ z,Real.exp (m*ψ (x+Real.sqrt h*z)) ∂standardGaussian) ≤Real.exp (m*|x-y|)*(∫ z,Real.exp (m*ψ (y+Real.sqrt h*z)) ∂standardGaussian) := byrw [←integral_const_mul]apply integral_mono hiX (hiY.const_mul _)intro zhave hl := hψ.dist_le_mul (x+Real.sqrt h*z) (y+Real.sqrt h*z)simp only [Real.dist_eq,NNReal.coe_one,one_mul] at hlrw [show x+Real.sqrt h*z-(y+Real.sqrt h*z)=x-y by ring] at hldsimp onlyrw [←Real.exp_add]apply Real.exp_le_exp.mprhave hh := le_abs_self (ψ (x+Real.sqrt h*z)-ψ (y+Real.sqrt h*z))nlinarithhave hh := Real.log_le_log hpX hboundrw [Real.log_mul (Real.exp_pos _).ne' hpY.ne',Real.log_exp] at hhsimp only [SKValue.coleHopf,ite_eq_right hm.ne',SKValue.heat,e]apply (div_le_iff₀ hm).mprhave he : (Real.log (∫ z,Real.exp (m*ψ (y+Real.sqrt h*z)) ∂standardGaussian)/m+|x-y|)*m=m*|x-y|+Real.log (∫ z,Real.exp (m*ψ (y+Real.sqrt h*z)) ∂standardGaussian) := by field_simp; ringrw [he]exact hhlemma coleHopf_lipschitz {ψ : ℝ → ℝ} (hψ : LipschitzWith 1 ψ) {m : ℝ} (hm : 0 < m)(h : ℝ) : LipschitzWith 1 (SKValue.coleHopf m h ψ) := byapply LipschitzWith.of_dist_le_mulintro x ysimp only [NNReal.coe_one,one_mul,Real.dist_eq]have hxy := coleHopf_one_sided hψ hm h x yhave hyx := coleHopf_one_sided hψ hm h y xrw [abs_sub_comm y x] at hyxexact abs_le.mpr ⟨by linarith,by linarith⟩noncomputable def fieldProfile (q : ℝ) : GaussianTree → ℝ → ℝ| [] => abs| l::T => SKValue.coleHopf l.height (l.endpoint-q) (fieldProfile l.endpoint T)def TreeScale (a : ℝ) : GaussianTree → Prop| [] => 0 ≤ a| l::T => 0 ≤ a ∧ a < l.height ∧ TreeScale l.height Tlemma fieldProfile_lipschitz {T : GaussianTree} {a : ℝ} (h : TreeScale a T) (q : ℝ) :LipschitzWith 1 (fieldProfile q T) := byinduction T generalizing a q with| nil =>apply LipschitzWith.of_dist_le_mulintro x ysimpa only [fieldProfile,NNReal.coe_one,one_mul,Real.dist_eq] using abs_abs_sub_abs_le_abs_sub x y| cons l T ih =>obtain ⟨ha,ham,hT⟩ := hexact coleHopf_lipschitz (ih hT _) (ha.trans_lt ham) _lemma gaussian_exp_sum_profile_integrable {ψ : ℝ → ℝ} (hψ : LipschitzWith 1 ψ){m : ℝ} (hm : 0 ≤ m) (n : ℕ) (x : Fin n → ℝ) (s : ℝ) :Integrable (fun z : Fin n → ℝ ↦ Real.exp (m*∑ i,ψ (x i+s*z i))) (gaussianProduct (Fin n)) := byhave hi := Integrable.fintype_prod (fun i : Fin n ↦ SKValue.lipschitz_exp_integrable hψ hm (x i) s)convert hi using 1· funext zsimp only [Finset.mul_sum,Real.exp_sum]· rfllemma gaussian_exp_sum_coleHopf {ψ : ℝ → ℝ} (hψ : LipschitzWith 1 ψ){m : ℝ} (hm : 0 < m) (n : ℕ) (x : Fin n → ℝ) (h : ℝ) :(∫ z : Fin n → ℝ,Real.exp (m*∑ i,ψ (x i+Real.sqrt h*z i)) ∂gaussianProduct (Fin n))=Real.exp (m*∑ i,SKValue.coleHopf m h ψ (x i)) := bysimp only [Finset.mul_sum,Real.exp_sum]rw [gaussianProduct,integral_fintype_prod_eq_prod (fun i : Fin n ↦ fun z : ℝ ↦ Real.exp (m*ψ (x i+Real.sqrt h*z)))]apply Finset.prod_congr rflintro i _simp only [SKValue.coleHopf,ite_eq_right hm.ne',SKValue.heat]rw [mul_div_cancel₀ _ hm.ne',Real.exp_log (SKValue.lipschitz_exp_integral_pos hψ hm.le (x i) (Real.sqrt h))]rflend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396import Mathlibimport OAI.Probability.SKValue.GroundState.StandardGaussiannamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma gaussian_gibbs_derivative_nonneg {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (c d : ι → Fin n → ℝ)(h : ∀ i j, 0 ≤ ∑ k, (d i k-d j k)*(c i k-c j k)) :0 ≤ ∫ z, ∑ i, gibbsWeight (linearProcess c z) i*linearProcess d z i ∂gaussianProduct (Fin n) := byhave hi : ∀ i, Integrable (fun z ↦ gibbsWeight (linearProcess c z) i*linearProcess d z i)(gaussianProduct (Fin n)) := fun i ↦ gibbsWeight_mul_integrable c i (linearProcess_integrable d i)have hi' : ∀ i, Integrable (fun z ↦ gibbsWeight (linearProcess c z) i *((∑ k, d i k*c i k)-∑ j, gibbsWeight (linearProcess c z) j*(∑ k, d i k*c j k)))(gaussianProduct (Fin n)) := byintro iapply gibbsWeight_mul_integrableexact (integrable_const _).sub (integrable_finsetSum _ (fun j _ ↦ (integrable_linear_gibbsWeight c j).mul_const _))rw [integral_finsetSum _ (fun i _ ↦ hi i)]simp_rw [gaussian_linear_gibbsWeight]rw [← integral_finsetSum _ (fun i _ ↦ hi' i)]apply integral_nonnegintro zchange (0 : ℝ) ≤ ∑ i, gibbsWeight (linearProcess c z) i *((∑ k, d i k*c i k)-∑ j, gibbsWeight (linearProcess c z) j*(∑ k, d i k*c j k))rw [weighted_covariance_pairs _ (fun i j ↦ ∑ k, d i k*c j k) (sum_gibbsWeight (linearProcess c z))]apply mul_nonneg (by norm_num)apply Finset.sum_nonnegintro i _apply Finset.sum_nonnegintro j _apply mul_nonneg (mul_nonneg (gibbsWeight_nonneg _ _) (gibbsWeight_nonneg _ _))have he : (∑ k, d i k*c i k)+(∑ k, d j k*c j k)-(∑ k, d i k*c j k)-(∑ k, d j k*c i k) = ∑ k, (d i k-d j k)*(c i k-c j k) := byrw [← Finset.sum_add_distrib,← Finset.sum_sub_distrib,← Finset.sum_sub_distrib]apply Finset.sum_congr rfl; intro k _; ringrw [he]exact h i jnoncomputable def rotatedCoefficients {ι κ : Type*} (a b : ι → κ → ℝ) (t : ℝ) (i : ι) (k : κ) : ℝ :=Real.cos t*a i k + Real.sin t*b i knoncomputable def rotationVelocity {ι κ : Type*} (a b : ι → κ → ℝ) (t : ℝ) (i : ι) (k : κ) : ℝ :=-Real.sin t*a i k + Real.cos t*b i klemma hasDerivAt_rotatedProcess {ι κ : Type*} [Fintype κ] (a b : ι → κ → ℝ)(t : ℝ) (z : κ → ℝ) (i : ι) :HasDerivAt (fun s ↦ linearProcess (rotatedCoefficients a b s) z i)(linearProcess (rotationVelocity a b t) z i) t := byexact HasDerivAt.fun_sum (u := Finset.univ) (fun k _ ↦(((Real.hasDerivAt_cos t).mul_const (a i k)).add ((Real.hasDerivAt_sin t).mul_const (b i k))).mul_const (z k))lemma abs_rotationVelocity_le {ι κ : Type*} (a b : ι → κ → ℝ) (t : ℝ) (i : ι) (k : κ) :|rotationVelocity a b t i k| ≤ |a i k|+|b i k| := bycalc_ ≤ |-Real.sin t*a i k| + |Real.cos t*b i k| := abs_add_le _ __ = |Real.sin t| *|a i k| + |Real.cos t| *|b i k| := by rw [abs_mul,abs_neg,abs_mul]_ ≤ 1*|a i k| + 1*|b i k| := add_le_add(mul_le_mul_of_nonneg_right (Real.abs_sin_le_one t) (abs_nonneg _))(mul_le_mul_of_nonneg_right (Real.abs_cos_le_one t) (abs_nonneg _))_ = _ := by ringlemma rotation_derivative_bound {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](a b : ι → κ → ℝ) (t : ℝ) (z : κ → ℝ) :|∑ i, gibbsWeight (linearProcess (rotatedCoefficients a b t) z) i *linearProcess (rotationVelocity a b t) z i| ≤∑ i, ∑ k, (|a i k|+|b i k|)*|z k| := byapply abs_gibbsMean_leintro icalc_ ≤ ∑ k, |rotationVelocity a b t i k*z k| := Finset.abs_sum_le_sum_abs _ __ ≤ ∑ k, (|a i k|+|b i k|)*|z k| := byapply Finset.sum_le_sumintro k _rw [abs_mul]exact mul_le_mul_of_nonneg_right (abs_rotationVelocity_le _ _ _ _ _) (abs_nonneg _)_ ≤ _ := Finset.single_le_sum (f := fun j ↦ ∑ k, (|a j k|+|b j k|)*|z k|) (fun j _ ↦ Finset.sum_nonneg (fun k _ ↦ mul_nonneg (add_nonneg (abs_nonneg _) (abs_nonneg _)) (abs_nonneg _))) (Finset.mem_univ i)lemma hasDerivAt_expected_rotated_logPartition {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (a b : ι → Fin n → ℝ) (t : ℝ) :HasDerivAt (fun s ↦ ∫ z, logPartition (linearProcess (rotatedCoefficients a b s) z) ∂gaussianProduct (Fin n))(∫ z, ∑ i, gibbsWeight (linearProcess (rotatedCoefficients a b t) z) i *linearProcess (rotationVelocity a b t) z i ∂gaussianProduct (Fin n)) t := byhave hb : Integrable (fun z : Fin n → ℝ ↦ ∑ i, ∑ k, (|a i k|+|b i k|)*|z k|)(gaussianProduct (Fin n)) :=integrable_finsetSum _ (fun i _ ↦ integrable_finsetSum _ (fun k _ ↦(gaussian_coordinate_integrable k).abs.const_mul _))have hmc : Continuous (fun z : Fin n → ℝ ↦ ∑ i,gibbsWeight (linearProcess (rotatedCoefficients a b t) z) i *linearProcess (rotationVelocity a b t) z i) := byapply continuous_finsetSumintro i _apply (continuous_linear_gibbsWeight _ _).mulexact (continuous_apply i).comp (continuous_linearProcess _)exact (hasDerivAt_integral_of_dominated_loc_of_deriv_le (s := Set.univ) (μ := gaussianProduct (Fin n))(F := fun s z ↦ logPartition (linearProcess (rotatedCoefficients a b s) z))(F' := fun s z ↦ ∑ i, gibbsWeight (linearProcess (rotatedCoefficients a b s) z) i *linearProcess (rotationVelocity a b s) z i)(bound := fun z ↦ ∑ i, ∑ k, (|a i k|+|b i k|)*|z k|)(Filter.univ_mem)(Eventually.of_forall (fun s ↦ (continuous_logPartition.comp (continuous_linearProcess _)).aestronglyMeasurable))(logPartition_integrable _) hmc.aestronglyMeasurable(Eventually.of_forall (fun z s _ ↦ by simpa only [Real.norm_eq_abs] using rotation_derivative_bound a b s z)) hb(Eventually.of_forall (fun z s _ ↦ hasDerivAt_logPartition (hasDerivAt_rotatedProcess a b s z)))).2lemma rotation_pair_covariance {ι κ : Type*} [Fintype κ] (a b : ι → κ → ℝ) (t : ℝ) (i j : ι) :(∑ k, (rotationVelocity a b t i k-rotationVelocity a b t j k)*(rotatedCoefficients a b t i k-rotatedCoefficients a b t j k)) =Real.sin t*Real.cos t*((∑ k, (b i k-b j k)^2)-(∑ k, (a i k-a j k)^2)) +((Real.cos t)^2-(Real.sin t)^2)*∑ k, (a i k-a j k)*(b i k-b j k) := bysimp only [rotationVelocity,rotatedCoefficients,← Finset.sum_sub_distrib,Finset.mul_sum,← Finset.sum_add_distrib]apply Finset.sum_congr rflintro k _ringlemma expected_logPartition_le_of_pair_distances {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (a b : ι → Fin n → ℝ)(horth : ∀ i j, (∑ k, (a i k-a j k)*(b i k-b j k)) = 0)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, logPartition (linearProcess a z) ∂gaussianProduct (Fin n)) ≤∫ z, logPartition (linearProcess b z) ∂gaussianProduct (Fin n) := bylet F := fun t ↦ ∫ z, logPartition (linearProcess (rotatedCoefficients a b t) z) ∂gaussianProduct (Fin n)have hd : ∀ t, HasDerivAt F (∫ z, ∑ i, gibbsWeight (linearProcess (rotatedCoefficients a b t) z) i *linearProcess (rotationVelocity a b t) z i ∂gaussianProduct (Fin n)) t :=hasDerivAt_expected_rotated_logPartition a bhave hc : Continuous F := continuous_iff_continuousAt.mpr (fun t ↦ (hd t).continuousAt)have hm : MonotoneOn F (Icc (0 : ℝ) (Real.pi/2)) := byapply monotoneOn_of_deriv_nonneg (convex_Icc _ _) hc.continuousOn(fun t _ ↦ (hd t).differentiableAt.differentiableWithinAt)intro t hthave ht' : t ∈ Icc (0 : ℝ) (Real.pi/2) := interior_subset htrw [(hd t).deriv]apply gaussian_gibbs_derivative_nonnegintro i jrw [rotation_pair_covariance,horth,mul_zero,add_zero]exact mul_nonneg (mul_nonneg(Real.sin_nonneg_of_nonneg_of_le_pi ht'.1 (ht'.2.trans (by linarith [Real.pi_pos])))(Real.cos_nonneg_of_mem_Icc ⟨by linarith [Real.pi_pos, ht'.1],ht'.2⟩)) (sub_nonneg.mpr (hdist i j))have hπ : (0 : ℝ) ≤ Real.pi/2 := by positivityhave hh := hm ⟨le_rfl,hπ⟩ ⟨hπ,le_rfl⟩ hπhave ha0 : rotatedCoefficients a b 0 = a := by funext i k; simp [rotatedCoefficients]have hb0 : rotatedCoefficients a b (Real.pi/2) = b := by funext i k; simp [rotatedCoefficients]simpa only [F,ha0,hb0] using hhnoncomputable def finiteMaximum {ι : Type*} (x : ι → ℝ) : ℝ := sSup (Set.range x)lemma le_finiteMaximum {ι : Type*} [Fintype ι] (x : ι → ℝ) (i : ι) : x i ≤ finiteMaximum x :=le_csSup (Set.finite_range x).bddAbove (Set.mem_range_self i)lemma exists_finiteMaximum {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) :∃ i, x i = finiteMaximum x := (Set.range_nonempty x).csSup_mem (Set.finite_range x)lemma continuous_finiteMaximum {ι : Type*} [Fintype ι] [Nonempty ι] :Continuous (@finiteMaximum ι) := byhave he (x : ι → ℝ) : finiteMaximum x = Finset.univ.sup' Finset.univ_nonempty x := byrw [Finset.sup'_eq_csSup_image]simp only [Finset.coe_univ,Set.image_univ,finiteMaximum]simp_rw [funext he]exact Continuous.finset_sup'_apply Finset.univ_nonempty (fun i _ ↦ continuous_apply i)lemma abs_finiteMaximum_le {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) :|finiteMaximum x| ≤ ∑ i, |x i| := byobtain ⟨i,hi⟩ := exists_finiteMaximum xrw [← hi]exact Finset.single_le_sum (fun j _ ↦ abs_nonneg (x j)) (Finset.mem_univ i)lemma finiteMaximum_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) : Integrable (fun z ↦ finiteMaximum (linearProcess c z)) (gaussianProduct κ) := byapply (integrable_finsetSum Finset.univ (fun i _ ↦ (linearProcess_integrable c i).abs)).mono'((continuous_finiteMaximum.comp (continuous_linearProcess c)).aestronglyMeasurable)exact Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs,Function.comp_def] using abs_finiteMaximum_le (linearProcess c z))lemma scaled_max_le_logPartition {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ)(β : ℝ) : β*finiteMaximum x ≤ logPartition (fun i ↦ β*x i) := byobtain ⟨i,hi⟩ := exists_finiteMaximum xrw [← hi]exact le_logPartition (fun i ↦ β*x i) ilemma logPartition_le_scaled_max {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ){β : ℝ} (hβ : 0 ≤ β) : logPartition (fun i ↦ β*x i) ≤ β*finiteMaximum x+Real.log (Fintype.card ι) := byexact (logPartition_le _ (fun i ↦ mul_le_mul_of_nonneg_left (le_finiteMaximum x i) hβ)).trans_eq (add_comm _ _)lemma linearProcess_scaled {ι κ : Type*} [Fintype κ] (c : ι → κ → ℝ) (β : ℝ) (z : κ → ℝ) :linearProcess (fun i k ↦ β*c i k) z = fun i ↦ β*linearProcess c z i := byfunext isimp only [linearProcess,Finset.mul_sum,mul_assoc]lemma expected_max_le_of_pair_distances_orthogonal {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (a b : ι → Fin n → ℝ)(horth : ∀ i j, (∑ k, (a i k-a j k)*(b i k-b j k)) = 0)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n)) ≤∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct (Fin n) := byhave hb (β : ℝ) (hβ : 0 ≤ β) :β*(∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n)) ≤β*(∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct (Fin n)) + Real.log (Fintype.card ι) := byhave hiA := logPartition_integrable (fun i k ↦ β*a i k)have hiB := logPartition_integrable (fun i k ↦ β*b i k)have hcomp := expected_logPartition_le_of_pair_distances(fun i k ↦ β*a i k) (fun i k ↦ β*b i k)(fun i j ↦ bycalc(∑ k, (β*a i k-β*a j k)*(β*b i k-β*b j k)) =β^2*(∑ k, (a i k-a j k)*(b i k-b j k)) := byrw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro k _; ring_ = 0 := by rw [horth,mul_zero])(fun i j ↦ byhave he (c : ι → Fin n → ℝ) : (∑ k, (β*c i k-β*c j k)^2) = β^2*∑ k, (c i k-c j k)^2 := byrw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro k _; ringrw [he,he]exact mul_le_mul_of_nonneg_left (hdist i j) (sq_nonneg β))calc_ = ∫ z, β*finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n) := by rw [integral_const_mul]_ ≤ ∫ z, logPartition (linearProcess (fun i k ↦ β*a i k) z) ∂gaussianProduct (Fin n) := byapply integral_mono ((finiteMaximum_integrable a).const_mul _) hiAintro zchange β*finiteMaximum (linearProcess a z) ≤ logPartition (linearProcess (fun i k ↦ β*a i k) z)rw [linearProcess_scaled]exact scaled_max_le_logPartition _ __ ≤ _ := hcomp_ ≤ ∫ z, β*finiteMaximum (linearProcess b z)+Real.log (Fintype.card ι) ∂gaussianProduct (Fin n) := byapply integral_mono hiB (((finiteMaximum_integrable b).const_mul _).add (integrable_const _))intro zchange logPartition (linearProcess (fun i k ↦ β*b i k) z) ≤ β*finiteMaximum (linearProcess b z)+Real.log (Fintype.card ι)rw [linearProcess_scaled]exact logPartition_le_scaled_max _ hβ_ = _ := by rw [integral_add ((finiteMaximum_integrable b).const_mul _) (integrable_const _),integral_const_mul,integral_const]; simpby_contra hhhave hΔ : 0 < (∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n)) -(∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct (Fin n)) := sub_pos.mpr (lt_of_not_ge hh)let Δ := (∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n)) -(∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct (Fin n))let β := (|Real.log (Fintype.card ι)|+1)/Δhave hβ : 0 < β := div_pos (by positivity) hΔhave hh' := hb β hβ.lehave he : β*Δ = |Real.log (Fintype.card ι)|+1 := div_mul_cancel₀ _ hΔ.ne'have hlog := le_abs_self (Real.log (Fintype.card ι))dsimp [Δ] at henlinarithlemma gaussian_integral_reindex {κ ν : Type*} [Fintype κ] [Fintype ν] (e : κ ≃ ν)(f : (κ → ℝ) → ℝ) :(∫ z : ν → ℝ, f (fun k ↦ z (e k)) ∂gaussianProduct ν) = ∫ z, f z ∂gaussianProduct κ := byhave he := measurePreserving_piCongrLeft (α := fun _ : κ ↦ ℝ)(fun _ : κ ↦ standardGaussian) e.symmhave hf (z : ν → ℝ) : (MeasurableEquiv.piCongrLeft (π := fun _ : κ ↦ ℝ) e.symm) z = fun k ↦ z (e k) := byfunext ksimp [MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft_apply]simpa only [gaussianProduct,hf] using he.integral_comp' flemma linearProcess_reindex {ι κ ν : Type*} [Fintype κ] [Fintype ν](c : ι → κ → ℝ) (e : κ ≃ ν) (z : ν → ℝ) :linearProcess c (fun k ↦ z (e k)) = linearProcess (fun i l ↦ c i (e.symm l)) z := byfunext isimpa only [linearProcess, Equiv.symm_apply_apply] using e.sum_comp (fun l ↦ c i (e.symm l)*z l)lemma expected_max_reindex {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν](c : ι → κ → ℝ) (e : κ ≃ ν) :(∫ z, finiteMaximum (linearProcess (fun i l ↦ c i (e.symm l)) z) ∂gaussianProduct ν) =∫ z, finiteMaximum (linearProcess c z) ∂gaussianProduct κ := bysimpa only [linearProcess_reindex] using gaussian_integral_reindex e (fun z ↦ finiteMaximum (linearProcess c z))lemma expected_max_le_of_pair_distances_orthogonal_fintype {ι κ : Type*}[Fintype ι] [Nonempty ι] [Fintype κ] (a b : ι → κ → ℝ)(horth : ∀ i j, (∑ k, (a i k-a j k)*(b i k-b j k)) = 0)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct κ) ≤∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct κ := bylet e := Fintype.equivFin κhave hh := expected_max_le_of_pair_distances_orthogonal(fun i k ↦ a i (e.symm k)) (fun i k ↦ b i (e.symm k))(fun i j ↦ byrw [e.symm.sum_comp (fun k ↦ (a i k-a j k)*(b i k-b j k))]exact horth i j)(fun i j ↦ byrw [e.symm.sum_comp (fun k ↦ (a i k-a j k)^2), e.symm.sum_comp (fun k ↦ (b i k-b j k)^2)]exact hdist i j)simpa only [expected_max_reindex] using hhnoncomputable def embedLeft {ι κ ν : Type*} (a : ι → κ → ℝ) (i : ι) : κ ⊕ ν → ℝ :=Sum.elim (a i) (fun _ ↦ 0)noncomputable def embedRight {ι κ ν : Type*} (b : ι → ν → ℝ) (i : ι) : κ ⊕ ν → ℝ :=Sum.elim (fun _ ↦ 0) (b i)lemma expected_max_embedLeft {ι κ ν : Type*} [Fintype ι] [Nonempty ι] [Fintype κ] [Fintype ν](a : ι → κ → ℝ) :(∫ z, finiteMaximum (linearProcess (embedLeft (ν := ν) a) z) ∂gaussianProduct (κ ⊕ ν)) =∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct κ := byhave he := measurePreserving_sumPiEquivProdPi_symm (fun _ : κ ⊕ ν ↦ standardGaussian)change (∫ z, finiteMaximum (linearProcess (embedLeft a) z) ∂Measure.pi (fun _ : κ ⊕ ν ↦ standardGaussian)) = _rw [← he.integral_comp' (fun z ↦ finiteMaximum (linearProcess (embedLeft a) z))]have hlin (p : (κ → ℝ) × (ν → ℝ)) :linearProcess (embedLeft a) ((MeasurableEquiv.sumPiEquivProdPi (fun _ : κ ⊕ ν ↦ ℝ)).symm p) =linearProcess a p.1 := byfunext isimp [linearProcess,embedLeft,Fintype.sum_sum_type,MeasurableEquiv.coe_sumPiEquivProdPi_symm]simp only [hlin]simpa [gaussianProduct] using integral_fun_fst (μ := gaussianProduct κ) (ν := gaussianProduct ν) (fun z ↦ finiteMaximum (linearProcess a z))lemma expected_max_embedRight {ι κ ν : Type*} [Fintype ι] [Nonempty ι] [Fintype κ] [Fintype ν](b : ι → ν → ℝ) :(∫ z, finiteMaximum (linearProcess (embedRight (κ := κ) b) z) ∂gaussianProduct (κ ⊕ ν)) =∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct ν := byhave he := measurePreserving_sumPiEquivProdPi_symm (fun _ : κ ⊕ ν ↦ standardGaussian)change (∫ z, finiteMaximum (linearProcess (embedRight b) z) ∂Measure.pi (fun _ : κ ⊕ ν ↦ standardGaussian)) = _rw [← he.integral_comp' (fun z ↦ finiteMaximum (linearProcess (embedRight b) z))]have hlin (p : (κ → ℝ) × (ν → ℝ)) :linearProcess (embedRight b) ((MeasurableEquiv.sumPiEquivProdPi (fun _ : κ ⊕ ν ↦ ℝ)).symm p) =linearProcess b p.2 := byfunext isimp [linearProcess,embedRight,Fintype.sum_sum_type,MeasurableEquiv.coe_sumPiEquivProdPi_symm]simp only [hlin]simpa [gaussianProduct] using integral_fun_snd (μ := gaussianProduct κ) (ν := gaussianProduct ν) (fun z ↦ finiteMaximum (linearProcess b z))lemma expected_max_le_of_pair_distances {ι κ ν : Type*}[Fintype ι] [Nonempty ι] [Fintype κ] [Fintype ν](a : ι → κ → ℝ) (b : ι → ν → ℝ)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct κ) ≤∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct ν := byhave h := expected_max_le_of_pair_distances_orthogonal_fintype(embedLeft (ν := ν) a) (embedRight (κ := κ) b)(fun i j ↦ by simp [embedLeft,embedRight,Fintype.sum_sum_type])(fun i j ↦ by simpa only [Fintype.sum_sum_type,embedLeft,embedRight,Sum.elim_inl,Sum.elim_inr,sub_self,zero_pow (by decide : 2 ≠ 0),Finset.sum_const_zero,zero_add,add_zero] using hdist i j)simpa only [expected_max_embedLeft,expected_max_embedRight] using hnoncomputable def spin (b : Bool) : ℝ := if b then 1 else -1noncomputable def hamiltonian (n : ℕ) (J : (Fin n × Fin n) → ℝ)(σ : Fin n → Bool) : ℝ :=(Real.sqrt (n : ℝ))⁻¹ *∑ i : Fin n, ∑ j : Fin n, if i < j then J (i,j) * spin (σ i) * spin (σ j) else 0noncomputable def groundStateSequence (n : ℕ) : ℝ :=(n : ℝ)⁻¹ * ∫ J, sSup (range (hamiltonian n J)) ∂gaussianProduct (Fin n × Fin n)noncomputable def groundStateValue : ℝ := limUnder atTop groundStateSequencenoncomputable def hamCoeff (n : ℕ) (σ : Fin n → Bool) (k : Fin n × Fin n) : ℝ :=if k.1 < k.2 then (Real.sqrt (n : ℝ))⁻¹ * spin (σ k.1) * spin (σ k.2) else 0noncomputable def expectedMaximum (n : ℕ) : ℝ :=∫ J, finiteMaximum (linearProcess (hamCoeff n) J) ∂gaussianProduct (Fin n × Fin n)lemma spin_sq (b : Bool) : spin b ^ 2 = 1 := by cases b <;> norm_num [spin]lemma abs_spin (b : Bool) : |spin b| = 1 := by cases b <;> norm_num [spin]lemma linearProcess_hamCoeff (n : ℕ) (J : (Fin n × Fin n) → ℝ) :linearProcess (hamCoeff n) J = hamiltonian n J := byfunext σsimp only [linearProcess,hamCoeff,hamiltonian,Fintype.sum_prod_type,Finset.mul_sum]apply Finset.sum_congr rflintro i _apply Finset.sum_congr rflintro j _split_ifs <;> ringlemma groundStateSequence_eq (n : ℕ) : groundStateSequence n = (n : ℝ)⁻¹ * expectedMaximum n := bysimp only [groundStateSequence,expectedMaximum,linearProcess_hamCoeff,finiteMaximum]lemma twice_upper_sum {ι : Type*} [Fintype ι] [LinearOrder ι] (f : ι → ι → ℝ)(hsymm : ∀ i j, f i j = f j i) (hdiag : ∀ i, f i i = 0) :2*(∑ i, ∑ j, if i < j then f i j else 0) = ∑ i, ∑ j, f i j := byhave hs : (∑ i, ∑ j, if j < i then f i j else 0) = ∑ i, ∑ j, if i < j then f i j else 0 := byrw [Finset.sum_comm]apply Finset.sum_congr rflintro i _apply Finset.sum_congr rflintro j _rw [hsymm j i]have hsplit (i j : ι) : f i j = (if i < j then f i j else 0)+(if j < i then f i j else 0) := byrcases lt_trichotomy i j with h | h | h· simp [h,not_lt_of_ge h.le]· subst j; simp [hdiag]· simp [h,not_lt_of_ge h.le]conv_rhs => arg 2; ext i; arg 2; ext j; rw [hsplit i j]simp only [Finset.sum_add_distrib,hs]ringlemma spin_pair_difference {dimension : ℕ} (σ τ : Fin dimension → Bool) (i j : Fin dimension) :(spin (σ i)*spin (σ j)-spin (τ i)*spin (τ j))^2 =2-2*(spin (σ i)*spin (τ i))*(spin (σ j)*spin (τ j)) := byhave h1 := spin_sq (σ i)have h2 := spin_sq (σ j)have h3 := spin_sq (τ i)have h4 := spin_sq (τ j)calc_ = (spin (σ i))^2*(spin (σ j))^2+(spin (τ i))^2*(spin (τ j))^2 -2*(spin (σ i)*spin (τ i))*(spin (σ j)*spin (τ j)) := by ring_ = _ := by rw [h1,h2,h3,h4]; ringend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396import Mathlibimport OAI.Probability.SKValue.GroundState.StandardGaussiannamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma gaussian_gibbs_derivative_nonneg {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (c d : ι → Fin n → ℝ)(h : ∀ i j, 0 ≤ ∑ k, (d i k-d j k)*(c i k-c j k)) :0 ≤ ∫ z, ∑ i, gibbsWeight (linearProcess c z) i*linearProcess d z i ∂gaussianProduct (Fin n) := byhave hi : ∀ i, Integrable (fun z ↦ gibbsWeight (linearProcess c z) i*linearProcess d z i)(gaussianProduct (Fin n)) := fun i ↦ gibbsWeight_mul_integrable c i (linearProcess_integrable d i)have hi' : ∀ i, Integrable (fun z ↦ gibbsWeight (linearProcess c z) i *((∑ k, d i k*c i k)-∑ j, gibbsWeight (linearProcess c z) j*(∑ k, d i k*c j k)))(gaussianProduct (Fin n)) := byintro iapply gibbsWeight_mul_integrableexact (integrable_const _).sub (integrable_finsetSum _ (fun j _ ↦ (integrable_linear_gibbsWeight c j).mul_const _))rw [integral_finsetSum _ (fun i _ ↦ hi i)]simp_rw [gaussian_linear_gibbsWeight]rw [← integral_finsetSum _ (fun i _ ↦ hi' i)]apply integral_nonnegintro zchange (0 : ℝ) ≤ ∑ i, gibbsWeight (linearProcess c z) i *((∑ k, d i k*c i k)-∑ j, gibbsWeight (linearProcess c z) j*(∑ k, d i k*c j k))rw [weighted_covariance_pairs _ (fun i j ↦ ∑ k, d i k*c j k) (sum_gibbsWeight (linearProcess c z))]apply mul_nonneg (by norm_num)apply Finset.sum_nonnegintro i _apply Finset.sum_nonnegintro j _apply mul_nonneg (mul_nonneg (gibbsWeight_nonneg _ _) (gibbsWeight_nonneg _ _))have he : (∑ k, d i k*c i k)+(∑ k, d j k*c j k)-(∑ k, d i k*c j k)-(∑ k, d j k*c i k) = ∑ k, (d i k-d j k)*(c i k-c j k) := byrw [← Finset.sum_add_distrib,← Finset.sum_sub_distrib,← Finset.sum_sub_distrib]apply Finset.sum_congr rfl; intro k _; ringrw [he]exact h i jnoncomputable def rotatedCoefficients {ι κ : Type*} (a b : ι → κ → ℝ) (t : ℝ) (i : ι) (k : κ) : ℝ :=Real.cos t*a i k + Real.sin t*b i knoncomputable def rotationVelocity {ι κ : Type*} (a b : ι → κ → ℝ) (t : ℝ) (i : ι) (k : κ) : ℝ :=-Real.sin t*a i k + Real.cos t*b i klemma hasDerivAt_rotatedProcess {ι κ : Type*} [Fintype κ] (a b : ι → κ → ℝ)(t : ℝ) (z : κ → ℝ) (i : ι) :HasDerivAt (fun s ↦ linearProcess (rotatedCoefficients a b s) z i)(linearProcess (rotationVelocity a b t) z i) t := byexact HasDerivAt.fun_sum (u := Finset.univ) (fun k _ ↦(((Real.hasDerivAt_cos t).mul_const (a i k)).add ((Real.hasDerivAt_sin t).mul_const (b i k))).mul_const (z k))lemma abs_rotationVelocity_le {ι κ : Type*} (a b : ι → κ → ℝ) (t : ℝ) (i : ι) (k : κ) :|rotationVelocity a b t i k| ≤ |a i k|+|b i k| := bycalc_ ≤ |-Real.sin t*a i k| + |Real.cos t*b i k| := abs_add_le _ __ = |Real.sin t| *|a i k| + |Real.cos t| *|b i k| := by rw [abs_mul,abs_neg,abs_mul]_ ≤ 1*|a i k| + 1*|b i k| := add_le_add(mul_le_mul_of_nonneg_right (Real.abs_sin_le_one t) (abs_nonneg _))(mul_le_mul_of_nonneg_right (Real.abs_cos_le_one t) (abs_nonneg _))_ = _ := by ringlemma rotation_derivative_bound {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](a b : ι → κ → ℝ) (t : ℝ) (z : κ → ℝ) :|∑ i, gibbsWeight (linearProcess (rotatedCoefficients a b t) z) i *linearProcess (rotationVelocity a b t) z i| ≤∑ i, ∑ k, (|a i k|+|b i k|)*|z k| := byapply abs_gibbsMean_leintro icalc_ ≤ ∑ k, |rotationVelocity a b t i k*z k| := Finset.abs_sum_le_sum_abs _ __ ≤ ∑ k, (|a i k|+|b i k|)*|z k| := byapply Finset.sum_le_sumintro k _rw [abs_mul]exact mul_le_mul_of_nonneg_right (abs_rotationVelocity_le _ _ _ _ _) (abs_nonneg _)_ ≤ _ := Finset.single_le_sum (f := fun j ↦ ∑ k, (|a j k|+|b j k|)*|z k|) (fun j _ ↦ Finset.sum_nonneg (fun k _ ↦ mul_nonneg (add_nonneg (abs_nonneg _) (abs_nonneg _)) (abs_nonneg _))) (Finset.mem_univ i)lemma hasDerivAt_expected_rotated_logPartition {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (a b : ι → Fin n → ℝ) (t : ℝ) :HasDerivAt (fun s ↦ ∫ z, logPartition (linearProcess (rotatedCoefficients a b s) z) ∂gaussianProduct (Fin n))(∫ z, ∑ i, gibbsWeight (linearProcess (rotatedCoefficients a b t) z) i *linearProcess (rotationVelocity a b t) z i ∂gaussianProduct (Fin n)) t := byhave hb : Integrable (fun z : Fin n → ℝ ↦ ∑ i, ∑ k, (|a i k|+|b i k|)*|z k|)(gaussianProduct (Fin n)) :=integrable_finsetSum _ (fun i _ ↦ integrable_finsetSum _ (fun k _ ↦(gaussian_coordinate_integrable k).abs.const_mul _))have hmc : Continuous (fun z : Fin n → ℝ ↦ ∑ i,gibbsWeight (linearProcess (rotatedCoefficients a b t) z) i *linearProcess (rotationVelocity a b t) z i) := byapply continuous_finsetSumintro i _apply (continuous_linear_gibbsWeight _ _).mulexact (continuous_apply i).comp (continuous_linearProcess _)exact (hasDerivAt_integral_of_dominated_loc_of_deriv_le (s := Set.univ) (μ := gaussianProduct (Fin n))(F := fun s z ↦ logPartition (linearProcess (rotatedCoefficients a b s) z))(F' := fun s z ↦ ∑ i, gibbsWeight (linearProcess (rotatedCoefficients a b s) z) i *linearProcess (rotationVelocity a b s) z i)(bound := fun z ↦ ∑ i, ∑ k, (|a i k|+|b i k|)*|z k|)(Filter.univ_mem)(Eventually.of_forall (fun s ↦ (continuous_logPartition.comp (continuous_linearProcess _)).aestronglyMeasurable))(logPartition_integrable _) hmc.aestronglyMeasurable(Eventually.of_forall (fun z s _ ↦ by simpa only [Real.norm_eq_abs] using rotation_derivative_bound a b s z)) hb(Eventually.of_forall (fun z s _ ↦ hasDerivAt_logPartition (hasDerivAt_rotatedProcess a b s z)))).2lemma rotation_pair_covariance {ι κ : Type*} [Fintype κ] (a b : ι → κ → ℝ) (t : ℝ) (i j : ι) :(∑ k, (rotationVelocity a b t i k-rotationVelocity a b t j k)*(rotatedCoefficients a b t i k-rotatedCoefficients a b t j k)) =Real.sin t*Real.cos t*((∑ k, (b i k-b j k)^2)-(∑ k, (a i k-a j k)^2)) +((Real.cos t)^2-(Real.sin t)^2)*∑ k, (a i k-a j k)*(b i k-b j k) := bysimp only [rotationVelocity,rotatedCoefficients,← Finset.sum_sub_distrib,Finset.mul_sum,← Finset.sum_add_distrib]apply Finset.sum_congr rflintro k _ringlemma expected_logPartition_le_of_pair_distances {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (a b : ι → Fin n → ℝ)(horth : ∀ i j, (∑ k, (a i k-a j k)*(b i k-b j k)) = 0)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, logPartition (linearProcess a z) ∂gaussianProduct (Fin n)) ≤∫ z, logPartition (linearProcess b z) ∂gaussianProduct (Fin n) := bylet F := fun t ↦ ∫ z, logPartition (linearProcess (rotatedCoefficients a b t) z) ∂gaussianProduct (Fin n)have hd : ∀ t, HasDerivAt F (∫ z, ∑ i, gibbsWeight (linearProcess (rotatedCoefficients a b t) z) i *linearProcess (rotationVelocity a b t) z i ∂gaussianProduct (Fin n)) t :=hasDerivAt_expected_rotated_logPartition a bhave hc : Continuous F := continuous_iff_continuousAt.mpr (fun t ↦ (hd t).continuousAt)have hm : MonotoneOn F (Icc (0 : ℝ) (Real.pi/2)) := byapply monotoneOn_of_deriv_nonneg (convex_Icc _ _) hc.continuousOn(fun t _ ↦ (hd t).differentiableAt.differentiableWithinAt)intro t hthave ht' : t ∈ Icc (0 : ℝ) (Real.pi/2) := interior_subset htrw [(hd t).deriv]apply gaussian_gibbs_derivative_nonnegintro i jrw [rotation_pair_covariance,horth,mul_zero,add_zero]exact mul_nonneg (mul_nonneg(Real.sin_nonneg_of_nonneg_of_le_pi ht'.1 (ht'.2.trans (by linarith [Real.pi_pos])))(Real.cos_nonneg_of_mem_Icc ⟨by linarith [Real.pi_pos, ht'.1],ht'.2⟩)) (sub_nonneg.mpr (hdist i j))have hπ : (0 : ℝ) ≤ Real.pi/2 := by positivityhave hh := hm ⟨le_rfl,hπ⟩ ⟨hπ,le_rfl⟩ hπhave ha0 : rotatedCoefficients a b 0 = a := by funext i k; simp [rotatedCoefficients]have hb0 : rotatedCoefficients a b (Real.pi/2) = b := by funext i k; simp [rotatedCoefficients]simpa only [F,ha0,hb0] using hhnoncomputable def finiteMaximum {ι : Type*} (x : ι → ℝ) : ℝ := sSup (Set.range x)lemma le_finiteMaximum {ι : Type*} [Fintype ι] (x : ι → ℝ) (i : ι) : x i ≤ finiteMaximum x :=le_csSup (Set.finite_range x).bddAbove (Set.mem_range_self i)lemma exists_finiteMaximum {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) :∃ i, x i = finiteMaximum x := (Set.range_nonempty x).csSup_mem (Set.finite_range x)lemma continuous_finiteMaximum {ι : Type*} [Fintype ι] [Nonempty ι] :Continuous (@finiteMaximum ι) := byhave he (x : ι → ℝ) : finiteMaximum x = Finset.univ.sup' Finset.univ_nonempty x := byrw [Finset.sup'_eq_csSup_image]simp only [Finset.coe_univ,Set.image_univ,finiteMaximum]simp_rw [funext he]exact Continuous.finset_sup'_apply Finset.univ_nonempty (fun i _ ↦ continuous_apply i)lemma abs_finiteMaximum_le {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) :|finiteMaximum x| ≤ ∑ i, |x i| := byobtain ⟨i,hi⟩ := exists_finiteMaximum xrw [← hi]exact Finset.single_le_sum (fun j _ ↦ abs_nonneg (x j)) (Finset.mem_univ i)lemma finiteMaximum_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) : Integrable (fun z ↦ finiteMaximum (linearProcess c z)) (gaussianProduct κ) := byapply (integrable_finsetSum Finset.univ (fun i _ ↦ (linearProcess_integrable c i).abs)).mono'((continuous_finiteMaximum.comp (continuous_linearProcess c)).aestronglyMeasurable)exact Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs,Function.comp_def] using abs_finiteMaximum_le (linearProcess c z))lemma scaled_max_le_logPartition {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ)(β : ℝ) : β*finiteMaximum x ≤ logPartition (fun i ↦ β*x i) := byobtain ⟨i,hi⟩ := exists_finiteMaximum xrw [← hi]exact le_logPartition (fun i ↦ β*x i) ilemma logPartition_le_scaled_max {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ){β : ℝ} (hβ : 0 ≤ β) : logPartition (fun i ↦ β*x i) ≤ β*finiteMaximum x+Real.log (Fintype.card ι) := byexact (logPartition_le _ (fun i ↦ mul_le_mul_of_nonneg_left (le_finiteMaximum x i) hβ)).trans_eq (add_comm _ _)lemma linearProcess_scaled {ι κ : Type*} [Fintype κ] (c : ι → κ → ℝ) (β : ℝ) (z : κ → ℝ) :linearProcess (fun i k ↦ β*c i k) z = fun i ↦ β*linearProcess c z i := byfunext isimp only [linearProcess,Finset.mul_sum,mul_assoc]lemma expected_max_le_of_pair_distances_orthogonal {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (a b : ι → Fin n → ℝ)(horth : ∀ i j, (∑ k, (a i k-a j k)*(b i k-b j k)) = 0)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n)) ≤∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct (Fin n) := byhave hb (β : ℝ) (hβ : 0 ≤ β) :β*(∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n)) ≤β*(∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct (Fin n)) + Real.log (Fintype.card ι) := byhave hiA := logPartition_integrable (fun i k ↦ β*a i k)have hiB := logPartition_integrable (fun i k ↦ β*b i k)have hcomp := expected_logPartition_le_of_pair_distances(fun i k ↦ β*a i k) (fun i k ↦ β*b i k)(fun i j ↦ bycalc(∑ k, (β*a i k-β*a j k)*(β*b i k-β*b j k)) =β^2*(∑ k, (a i k-a j k)*(b i k-b j k)) := byrw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro k _; ring_ = 0 := by rw [horth,mul_zero])(fun i j ↦ byhave he (c : ι → Fin n → ℝ) : (∑ k, (β*c i k-β*c j k)^2) = β^2*∑ k, (c i k-c j k)^2 := byrw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro k _; ringrw [he,he]exact mul_le_mul_of_nonneg_left (hdist i j) (sq_nonneg β))calc_ = ∫ z, β*finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n) := by rw [integral_const_mul]_ ≤ ∫ z, logPartition (linearProcess (fun i k ↦ β*a i k) z) ∂gaussianProduct (Fin n) := byapply integral_mono ((finiteMaximum_integrable a).const_mul _) hiAintro zchange β*finiteMaximum (linearProcess a z) ≤ logPartition (linearProcess (fun i k ↦ β*a i k) z)rw [linearProcess_scaled]exact scaled_max_le_logPartition _ __ ≤ _ := hcomp_ ≤ ∫ z, β*finiteMaximum (linearProcess b z)+Real.log (Fintype.card ι) ∂gaussianProduct (Fin n) := byapply integral_mono hiB (((finiteMaximum_integrable b).const_mul _).add (integrable_const _))intro zchange logPartition (linearProcess (fun i k ↦ β*b i k) z) ≤ β*finiteMaximum (linearProcess b z)+Real.log (Fintype.card ι)rw [linearProcess_scaled]exact logPartition_le_scaled_max _ hβ_ = _ := by rw [integral_add ((finiteMaximum_integrable b).const_mul _) (integrable_const _),integral_const_mul,integral_const]; simpby_contra hhhave hΔ : 0 < (∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n)) -(∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct (Fin n)) := sub_pos.mpr (lt_of_not_ge hh)let Δ := (∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n)) -(∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct (Fin n))let β := (|Real.log (Fintype.card ι)|+1)/Δhave hβ : 0 < β := div_pos (by positivity) hΔhave hh' := hb β hβ.lehave he : β*Δ = |Real.log (Fintype.card ι)|+1 := div_mul_cancel₀ _ hΔ.ne'have hlog := le_abs_self (Real.log (Fintype.card ι))dsimp [Δ] at henlinarithlemma gaussian_integral_reindex {κ ν : Type*} [Fintype κ] [Fintype ν] (e : κ ≃ ν)(f : (κ → ℝ) → ℝ) :(∫ z : ν → ℝ, f (fun k ↦ z (e k)) ∂gaussianProduct ν) = ∫ z, f z ∂gaussianProduct κ := byhave he := measurePreserving_piCongrLeft (α := fun _ : κ ↦ ℝ)(fun _ : κ ↦ standardGaussian) e.symmhave hf (z : ν → ℝ) : (MeasurableEquiv.piCongrLeft (π := fun _ : κ ↦ ℝ) e.symm) z = fun k ↦ z (e k) := byfunext ksimp [MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft_apply]simpa only [gaussianProduct,hf] using he.integral_comp' flemma linearProcess_reindex {ι κ ν : Type*} [Fintype κ] [Fintype ν](c : ι → κ → ℝ) (e : κ ≃ ν) (z : ν → ℝ) :linearProcess c (fun k ↦ z (e k)) = linearProcess (fun i l ↦ c i (e.symm l)) z := byfunext isimpa only [linearProcess, Equiv.symm_apply_apply] using e.sum_comp (fun l ↦ c i (e.symm l)*z l)lemma expected_max_reindex {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν](c : ι → κ → ℝ) (e : κ ≃ ν) :(∫ z, finiteMaximum (linearProcess (fun i l ↦ c i (e.symm l)) z) ∂gaussianProduct ν) =∫ z, finiteMaximum (linearProcess c z) ∂gaussianProduct κ := bysimpa only [linearProcess_reindex] using gaussian_integral_reindex e (fun z ↦ finiteMaximum (linearProcess c z))lemma expected_max_le_of_pair_distances_orthogonal_fintype {ι κ : Type*}[Fintype ι] [Nonempty ι] [Fintype κ] (a b : ι → κ → ℝ)(horth : ∀ i j, (∑ k, (a i k-a j k)*(b i k-b j k)) = 0)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct κ) ≤∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct κ := bylet e := Fintype.equivFin κhave hh := expected_max_le_of_pair_distances_orthogonal(fun i k ↦ a i (e.symm k)) (fun i k ↦ b i (e.symm k))(fun i j ↦ byrw [e.symm.sum_comp (fun k ↦ (a i k-a j k)*(b i k-b j k))]exact horth i j)(fun i j ↦ byrw [e.symm.sum_comp (fun k ↦ (a i k-a j k)^2), e.symm.sum_comp (fun k ↦ (b i k-b j k)^2)]exact hdist i j)simpa only [expected_max_reindex] using hhnoncomputable def embedLeft {ι κ ν : Type*} (a : ι → κ → ℝ) (i : ι) : κ ⊕ ν → ℝ :=Sum.elim (a i) (fun _ ↦ 0)noncomputable def embedRight {ι κ ν : Type*} (b : ι → ν → ℝ) (i : ι) : κ ⊕ ν → ℝ :=Sum.elim (fun _ ↦ 0) (b i)lemma expected_max_embedLeft {ι κ ν : Type*} [Fintype ι] [Nonempty ι] [Fintype κ] [Fintype ν](a : ι → κ → ℝ) :(∫ z, finiteMaximum (linearProcess (embedLeft (ν := ν) a) z) ∂gaussianProduct (κ ⊕ ν)) =∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct κ := byhave he := measurePreserving_sumPiEquivProdPi_symm (fun _ : κ ��� ν ↦ standardGaussian)change (∫ z, finiteMaximum (linearProcess (embedLeft a) z) ∂Measure.pi (fun _ : κ ⊕ ν ↦ standardGaussian)) = _rw [← he.integral_comp' (fun z ↦ finiteMaximum (linearProcess (embedLeft a) z))]have hlin (p : (κ → ℝ) × (ν → ℝ)) :linearProcess (embedLeft a) ((MeasurableEquiv.sumPiEquivProdPi (fun _ : κ ⊕ ν ↦ ℝ)).symm p) =linearProcess a p.1 := byfunext isimp [linearProcess,embedLeft,Fintype.sum_sum_type,MeasurableEquiv.coe_sumPiEquivProdPi_symm]simp only [hlin]simpa [gaussianProduct] using integral_fun_fst (μ := gaussianProduct κ) (ν := gaussianProduct ν) (fun z ↦ finiteMaximum (linearProcess a z))lemma expected_max_embedRight {ι κ ν : Type*} [Fintype ι] [Nonempty ι] [Fintype κ] [Fintype ν](b : ι → ν → ℝ) :(∫ z, finiteMaximum (linearProcess (embedRight (κ := κ) b) z) ∂gaussianProduct (κ ⊕ ν)) =∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct ν := byhave he := measurePreserving_sumPiEquivProdPi_symm (fun _ : κ ⊕ ν ↦ standardGaussian)change (∫ z, finiteMaximum (linearProcess (embedRight b) z) ∂Measure.pi (fun _ : κ ⊕ ν ↦ standardGaussian)) = _rw [← he.integral_comp' (fun z ↦ finiteMaximum (linearProcess (embedRight b) z))]have hlin (p : (κ → ℝ) × (ν → ℝ)) :linearProcess (embedRight b) ((MeasurableEquiv.sumPiEquivProdPi (fun _ : κ ⊕ ν ↦ ℝ)).symm p) =linearProcess b p.2 := byfunext isimp [linearProcess,embedRight,Fintype.sum_sum_type,MeasurableEquiv.coe_sumPiEquivProdPi_symm]simp only [hlin]simpa [gaussianProduct] using integral_fun_snd (μ := gaussianProduct κ) (ν := gaussianProduct ν) (fun z ↦ finiteMaximum (linearProcess b z))lemma expected_max_le_of_pair_distances {ι κ ν : Type*}[Fintype ι] [Nonempty ι] [Fintype κ] [Fintype ν](a : ι → κ → ℝ) (b : ι → ν → ℝ)(hdist : ∀ i j, (∑ k, (a i k-a j k)^2) ≤ ∑ k, (b i k-b j k)^2) :(∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct κ) ≤∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct ν := byhave h := expected_max_le_of_pair_distances_orthogonal_fintype(embedLeft (ν := ν) a) (embedRight (κ := κ) b)(fun i j ↦ by simp [embedLeft,embedRight,Fintype.sum_sum_type])(fun i j ↦ by simpa only [Fintype.sum_sum_type,embedLeft,embedRight,Sum.elim_inl,Sum.elim_inr,sub_self,zero_pow (by decide : 2 ≠ 0),Finset.sum_const_zero,zero_add,add_zero] using hdist i j)simpa only [expected_max_embedLeft,expected_max_embedRight] using hnoncomputable def spin (b : Bool) : ℝ := if b then 1 else -1noncomputable def hamiltonian (n : ℕ) (J : (Fin n × Fin n) → ℝ)(σ : Fin n → Bool) : ℝ :=(Real.sqrt (n : ℝ))⁻¹ *∑ i : Fin n, ∑ j : Fin n, if i < j then J (i,j) * spin (σ i) * spin (σ j) else 0noncomputable def groundStateSequence (n : ℕ) : ℝ :=(n : ℝ)⁻¹ * ∫ J, sSup (range (hamiltonian n J)) ∂gaussianProduct (Fin n × Fin n)noncomputable def groundStateValue : ℝ := limUnder atTop groundStateSequencenoncomputable def hamCoeff (n : ℕ) (σ : Fin n → Bool) (k : Fin n × Fin n) : ℝ :=if k.1 < k.2 then (Real.sqrt (n : ℝ))⁻¹ * spin (σ k.1) * spin (σ k.2) else 0noncomputable def expectedMaximum (n : ℕ) : ℝ :=∫ J, finiteMaximum (linearProcess (hamCoeff n) J) ∂gaussianProduct (Fin n × Fin n)lemma spin_sq (b : Bool) : spin b ^ 2 = 1 := by cases b <;> norm_num [spin]lemma abs_spin (b : Bool) : |spin b| = 1 := by cases b <;> norm_num [spin]lemma linearProcess_hamCoeff (n : ℕ) (J : (Fin n × Fin n) → ℝ) :linearProcess (hamCoeff n) J = hamiltonian n J := byfunext σsimp only [linearProcess,hamCoeff,hamiltonian,Fintype.sum_prod_type,Finset.mul_sum]apply Finset.sum_congr rflintro i _apply Finset.sum_congr rflintro j _split_ifs <;> ringlemma groundStateSequence_eq (n : ℕ) : groundStateSequence n = (n : ℝ)⁻¹ * expectedMaximum n := bysimp only [groundStateSequence,expectedMaximum,linearProcess_hamCoeff,finiteMaximum]lemma twice_upper_sum {ι : Type*} [Fintype ι] [LinearOrder ι] (f : ι → ι → ℝ)(hsymm : ∀ i j, f i j = f j i) (hdiag : ∀ i, f i i = 0) :2*(∑ i, ∑ j, if i < j then f i j else 0) = ∑ i, ∑ j, f i j := byhave hs : (∑ i, ∑ j, if j < i then f i j else 0) = ∑ i, ∑ j, if i < j then f i j else 0 := byrw [Finset.sum_comm]apply Finset.sum_congr rflintro i _apply Finset.sum_congr rflintro j _rw [hsymm j i]have hsplit (i j : ι) : f i j = (if i < j then f i j else 0)+(if j < i then f i j else 0) := byrcases lt_trichotomy i j with h | h | h· simp [h,not_lt_of_ge h.le]· subst j; simp [hdiag]· simp [h,not_lt_of_ge h.le]conv_rhs => arg 2; ext i; arg 2; ext j; rw [hsplit i j]simp only [Finset.sum_add_distrib,hs]ringlemma spin_pair_difference {dimension : ℕ} (σ τ : Fin dimension → Bool) (i j : Fin dimension) :(spin (σ i)*spin (σ j)-spin (τ i)*spin (τ j))^2 =2-2*(spin (σ i)*spin (τ i))*(spin (σ j)*spin (τ j)) := byhave h1 := spin_sq (σ i)have h2 := spin_sq (σ j)have h3 := spin_sq (τ i)have h4 := spin_sq (τ j)calc_ = (spin (σ i))^2*(spin (σ j))^2+(spin (τ i))^2*(spin (τ j))^2 -2*(spin (σ i)*spin (τ i))*(spin (σ j)*spin (τ j)) := by ring_ = _ := by rw [h1,h2,h3,h4]; ringend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126import Mathlibimport OAI.Probability.SKValue.GroundState.ConstantFatounamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuenoncomputable def boolSign (x : ℝ) : Bool := if 0≤x then true else falselemma measurable_boolSign : Measurable boolSign :=Measurable.ite measurableSet_Ici measurable_const measurable_constlemma spin_boolSign_eq {x : ℝ} (hx : x≠0) : SKValueG.spin (boolSign x)=Real.sign x := byrcases lt_or_gt_of_ne hx with h | h· simp [boolSign,SKValueG.spin,not_le.mpr h,Real.sign_of_neg h]· simp [boolSign,SKValueG.spin,h.le,Real.sign_of_pos h]lemma gaussian_rounding_nonzero (a : ℝ) :∀ᵐ z ∂standardGaussian,a+2*cdf standardGaussian z-1≠0 := byhave hh : ∀ᵐ z ∂standardGaussian,cdf standardGaussian z≠(1-a)/2 :=(standardGaussian_cdf_hasLaw_uniform.ae_iff (measurableSet_setOfPred.mp ((measurableSet_eq_fun measurable_id measurable_const).compl))).mpr((volume.restrict (Ioc (0 : ℝ) 1)).ae_ne ((1-a)/2))filter_upwards [hh] with z hzintro happly hzlinarithlemma independent_rounding_nonzero {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}[IsProbabilityMeasure μ] {U Z : Ω → ℝ}(hU : Measurable U) (hZ : HasLaw Z standardGaussian μ) (hind : IndepFun U Z μ) :∀ᵐ ω ∂μ,U ω+2*cdf standardGaussian (Z ω)-1≠0 := byhave hLaw : HasLaw U (μ.map U) μ := ⟨hU.aemeasurable,rfl⟩have hJoint := hind.hasLaw_prod hLaw hZhave hm : Measurable (fun p : ℝ×ℝ ↦ p.1+2*cdf standardGaussian p.2-1) :=(measurable_fst.add (((monotone_cdf _).measurable.comp measurable_snd).const_mul 2)).sub_const 1apply (hJoint.ae_iff (measurableSet_setOfPred.mp ((measurableSet_eq_fun hm measurable_const).compl))).mprapply (Measure.ae_prod_iff_ae_ae ((measurableSet_eq_fun hm measurable_const).compl)).mprexact Eventually.of_forall gaussian_rounding_nonzerolemma finite_rounding_signed_spin {N : ℕ} {U : (Fin (N+1) → ℝ) → ℝ}(hU : Measurable U) (hUp : DependsBefore N U) :(fun z ↦ SKValueG.spin (boolSign (U z+2*cdf standardGaussian (coordinate N N z)-1)))=ᵐ[gaussianProduct (Fin (N+1))](fun z ↦ Real.sign (U z+2*cdf standardGaussian (coordinate N N z)-1)) := byhave := gaussianProduct_probability (Fin (N+1))exact (independent_rounding_nonzero hU (coordinate_hasLaw N N)(hUp.independent (by omega) hU)).mono (fun _ ↦ spin_boolSign_eq)end SKValueendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuetheorem normalized_shifted_sum_le_groundState {N : ℕ}(H : Fin N → (Fin (N+1) → ℝ) → ℝ) (U : (Fin (N+1) → ℝ) → ℝ)(hm : ∀ j,Measurable (H j)) (hp : ∀ j : Fin N,DependsBefore j (H j))(hL : ∀ j,MemLp (H j) 2 (gaussianProduct (Fin (N+1))))(hpos : ∀ j,0<∫ z,(H j z)^2 ∂gaussianProduct (Fin (N+1)))(hU : Measurable U) (hUp : DependsBefore N U) :(∑ j : Fin N,(∫ z,finiteRounded U z*normalizedIncrement (H j) (coordinate N j) (gaussianProduct (Fin (N+1))) z∂gaussianProduct (Fin (N+1)))*(∫ z,finiteRounded U z*coordinate N (j+1) z ∂gaussianProduct (Fin (N+1))))≤groundStateValue := bylet f := fun j : ℕ ↦ if hj : j<N thennormalizedIncrement (H ⟨j,hj⟩) (coordinate N j) (gaussianProduct (Fin (N+1))) else fun _ ↦ 0let F := fun z ↦ boolSign (U z+2*cdf standardGaussian (coordinate N N z)-1)have hfm (j : ℕ) : Measurable (f j) := bydsimp only [f]split_ifs with hj· exact measurable_normalizedIncrement (hm ⟨j,hj⟩)· exact measurable_consthave hfa (l : ℕ) (x y : Fin (N+1) → ℝ)(he : ∀ i : Fin (N+1),i.val≤l → x i=y i) : f l x=f l y := bydsimp only [f]split_ifs with hl· apply normalizedIncrement_dependsBefore (by omega) (hp ⟨l,hl⟩)intro i hichange i.val<l+1 at hiexact he i (by omega)· rflhave hfL (j : ℕ) (hj : j<N) : MemLp (f j) 2 (SKValueG.gaussianProduct (Fin (N+1))) := bysimp only [f,dite_eq_left hj]exact normalizedIncrement_memLp_two (hL ⟨j,hj⟩) (coordinate_hasLaw N j)((hp ⟨j,hj⟩).independent (by omega) (hm ⟨j,hj⟩))have hfu (j : ℕ) (hj : j<N) : (∫ z,(f j z)^2 ∂SKValueG.gaussianProduct (Fin (N+1)))=1 := bysimp only [f,dite_eq_left hj]exact normalizedIncrement_second_moment (hm ⟨j,hj⟩).aestronglyMeasurable (coordinate_hasLaw N j)((hp ⟨j,hj⟩).independent (by omega) (hm ⟨j,hj⟩)) (hpos ⟨j,hj⟩)have hfo (i j : ℕ) (hij : i<j) (hj : j<N) :(∫ z,f i z*f j z ∂SKValueG.gaussianProduct (Fin (N+1)))=0 := byhave hi : i<N := hij.trans hjsimp only [f,dite_eq_left hi,dite_eq_left hj]exact normalizedIncrements_orthogonal hij (by omega) (hm ��i,hi⟩) (hm ⟨j,hj⟩)(hp ⟨i,hi⟩) (hp ⟨j,hj⟩)have hFm : Measurable F := measurable_boolSign.comp((hU.add (((monotone_cdf _).measurable.comp (measurable_coordinate N N)).const_mul 2)).sub_const 1)have he : (fun z ↦ SKValueG.spin (F z))=ᵐ[gaussianProduct (Fin (N+1))] finiteRounded U :=finite_rounding_signed_spin hU hUphave hb := SKValueG.predictable_coefficients_le_groundState N f F hfm hfa hfL hfu hfo hFmchange _≤SKValueG.groundStateValueconvert hb using 1apply Finset.sum_congr rflintro j hjcongr 1· apply integral_congr_aefilter_upwards [he] with z hzsimp only [f,dite_eq_left j.isLt,hz]exact mul_comm _ _· apply integral_congr_aefilter_upwards [he] with z hzrw [hz,coordinate_eq_apply (by omega)]end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126import Mathlibimport OAI.Probability.SKValue.GroundState.ConstantFatounamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuenoncomputable def boolSign (x : ℝ) : Bool := if 0≤x then true else falselemma measurable_boolSign : Measurable boolSign :=Measurable.ite measurableSet_Ici measurable_const measurable_constlemma spin_boolSign_eq {x : ℝ} (hx : x≠0) : SKValueG.spin (boolSign x)=Real.sign x := byrcases lt_or_gt_of_ne hx with h | h· simp [boolSign,SKValueG.spin,not_le.mpr h,Real.sign_of_neg h]· simp [boolSign,SKValueG.spin,h.le,Real.sign_of_pos h]lemma gaussian_rounding_nonzero (a : ℝ) :∀ᵐ z ∂standardGaussian,a+2*cdf standardGaussian z-1≠0 := byhave hh : ∀ᵐ z ∂standardGaussian,cdf standardGaussian z≠(1-a)/2 :=(standardGaussian_cdf_hasLaw_uniform.ae_iff (measurableSet_setOfPred.mp ((measurableSet_eq_fun measurable_id measurable_const).compl))).mpr((volume.restrict (Ioc (0 : ℝ) 1)).ae_ne ((1-a)/2))filter_upwards [hh] with z hzintro happly hzlinarithlemma independent_rounding_nonzero {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}[IsProbabilityMeasure μ] {U Z : Ω → ℝ}(hU : Measurable U) (hZ : HasLaw Z standardGaussian μ) (hind : IndepFun U Z μ) :∀ᵐ ω ∂μ,U ω+2*cdf standardGaussian (Z ω)-1≠0 := byhave hLaw : HasLaw U (μ.map U) μ := ⟨hU.aemeasurable,rfl⟩have hJoint := hind.hasLaw_prod hLaw hZhave hm : Measurable (fun p : ℝ×ℝ ↦ p.1+2*cdf standardGaussian p.2-1) :=(measurable_fst.add (((monotone_cdf _).measurable.comp measurable_snd).const_mul 2)).sub_const 1apply (hJoint.ae_iff (measurableSet_setOfPred.mp ((measurableSet_eq_fun hm measurable_const).compl))).mprapply (Measure.ae_prod_iff_ae_ae ((measurableSet_eq_fun hm measurable_const).compl)).mprexact Eventually.of_forall gaussian_rounding_nonzerolemma finite_rounding_signed_spin {N : ℕ} {U : (Fin (N+1) → ℝ) → ℝ}(hU : Measurable U) (hUp : DependsBefore N U) :(fun z ↦ SKValueG.spin (boolSign (U z+2*cdf standardGaussian (coordinate N N z)-1)))=ᵐ[gaussianProduct (Fin (N+1))](fun z ↦ Real.sign (U z+2*cdf standardGaussian (coordinate N N z)-1)) := byhave := gaussianProduct_probability (Fin (N+1))exact (independent_rounding_nonzero hU (coordinate_hasLaw N N)(hUp.independent (by omega) hU)).mono (fun _ ↦ spin_boolSign_eq)end SKValueendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuetheorem normalized_shifted_sum_le_groundState {N : ℕ}(H : Fin N → (Fin (N+1) → ℝ) → ℝ) (U : (Fin (N+1) → ℝ) → ℝ)(hm : ∀ j,Measurable (H j)) (hp : ∀ j : Fin N,DependsBefore j (H j))(hL : ∀ j,MemLp (H j) 2 (gaussianProduct (Fin (N+1))))(hpos : ∀ j,0<∫ z,(H j z)^2 ∂gaussianProduct (Fin (N+1)))(hU : Measurable U) (hUp : DependsBefore N U) :(∑ j : Fin N,(∫ z,finiteRounded U z*normalizedIncrement (H j) (coordinate N j) (gaussianProduct (Fin (N+1))) z∂gaussianProduct (Fin (N+1)))*(∫ z,finiteRounded U z*coordinate N (j+1) z ∂gaussianProduct (Fin (N+1))))≤groundStateValue := bylet f := fun j : ℕ ↦ if hj : j<N thennormalizedIncrement (H ⟨j,hj⟩) (coordinate N j) (gaussianProduct (Fin (N+1))) else fun _ ↦ 0let F := fun z ↦ boolSign (U z+2*cdf standardGaussian (coordinate N N z)-1)have hfm (j : ℕ) : Measurable (f j) := bydsimp only [f]split_ifs with hj· exact measurable_normalizedIncrement (hm ⟨j,hj⟩)· exact measurable_consthave hfa (l : ℕ) (x y : Fin (N+1) → ℝ)(he : ∀ i : Fin (N+1),i.val≤l → x i=y i) : f l x=f l y := bydsimp only [f]split_ifs with hl· apply normalizedIncrement_dependsBefore (by omega) (hp ⟨l,hl⟩)intro i hichange i.val<l+1 at hiexact he i (by omega)· rflhave hfL (j : ℕ) (hj : j<N) : MemLp (f j) 2 (SKValueG.gaussianProduct (Fin (N+1))) := bysimp only [f,dite_eq_left hj]exact normalizedIncrement_memLp_two (hL ⟨j,hj⟩) (coordinate_hasLaw N j)((hp ⟨j,hj⟩).independent (by omega) (hm ⟨j,hj⟩))have hfu (j : ℕ) (hj : j<N) : (∫ z,(f j z)^2 ∂SKValueG.gaussianProduct (Fin (N+1)))=1 := bysimp only [f,dite_eq_left hj]exact normalizedIncrement_second_moment (hm ⟨j,hj⟩).aestronglyMeasurable (coordinate_hasLaw N j)((hp ⟨j,hj⟩).independent (by omega) (hm ⟨j,hj⟩)) (hpos ⟨j,hj⟩)have hfo (i j : ℕ) (hij : i<j) (hj : j<N) :(∫ z,f i z*f j z ∂SKValueG.gaussianProduct (Fin (N+1)))=0 := byhave hi : i<N := hij.trans hjsimp only [f,dite_eq_left hi,dite_eq_left hj]exact normalizedIncrements_orthogonal hij (by omega) (hm ⟨i,hi⟩) (hm ⟨j,hj⟩)(hp ⟨i,hi⟩) (hp ⟨j,hj⟩)have hFm : Measurable F := measurable_boolSign.comp((hU.add (((monotone_cdf _).measurable.comp (measurable_coordinate N N)).const_mul 2)).sub_const 1)have he : (fun z ↦ SKValueG.spin (F z))=ᵐ[gaussianProduct (Fin (N+1))] finiteRounded U :=finite_rounding_signed_spin hU hUphave hb := SKValueG.predictable_coefficients_le_groundState N f F hfm hfa hfL hfu hfo hFmchange _≤SKValueG.groundStateValueconvert hb using 1apply Finset.sum_congr rflintro j hjcongr 1· apply integral_congr_aefilter_upwards [he] with z hzsimp only [f,dite_eq_left j.isLt,hz]exact mul_comm _ _· apply integral_congr_aefilter_upwards [he] with z hzrw [hz,coordinate_eq_apply (by omega)]end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384import Mathlibimport OAI.Probability.SKValue.Evolution.BoundedSmoothnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGnoncomputable def standardGaussian : Measure ℝ := gaussianReal 0 1noncomputable def gaussianProduct (ι : Type*) [Fintype ι] : Measure (ι → ℝ) :=Measure.pi (fun _ : ι ↦ standardGaussian)instance : IsProbabilityMeasure standardGaussian := by unfold standardGaussian; infer_instanceinstance {ι : Type*} [Fintype ι] : IsProbabilityMeasure (gaussianProduct ι) := byunfold gaussianProduct; infer_instancelemma density_hasDerivAt (x : ℝ) :HasDerivAt (gaussianPDFReal 0 1) (-x*gaussianPDFReal 0 1 x) x := byhave h1 : HasDerivAt (fun y : ℝ ↦ -y^2/2) (-x) x := byhave hh := ((hasDerivAt_id x).pow 2).neg.div_const (2 : ℝ)simpa only [Pi.pow_def,Pi.neg_def,id_eq,pow_one,show (2 : ℕ)-1=1 from rfl,Nat.cast_ofNat,mul_one,neg_div,mul_div_cancel_left₀ _ (by norm_num : (2 : ℝ) ≠ 0)] using hhhave hd := h1.exp.const_mul ((Real.sqrt (2*Real.pi))⁻¹)convert hd using 1 <;> try rfl· funext ysimp only [gaussianPDFReal,NNReal.coe_one,mul_one,sub_zero]· simp only [gaussianPDFReal,NNReal.coe_one,mul_one,sub_zero]ringlemma density_mul_integrable {f : ℝ → ℝ} (hf : Integrable f standardGaussian) :Integrable (fun x ↦ gaussianPDFReal 0 1 x*f x) := byrw [standardGaussian,gaussianReal_of_var_ne_zero _ (by norm_num)] at hfhave hh := (integrable_withDensity_iff_integrable_smul'(measurable_gaussianPDF 0 1) (Eventually.of_forall (fun x ↦ gaussianPDF_lt_top (μ := 0) (v := 1) (x := x)))).mp hfsimpa only [toReal_gaussianPDF,smul_eq_mul] using hhlemma standardGaussian_integrable_id : Integrable (fun x : ℝ ↦ x) standardGaussian := byhave hh := (memLp_id_gaussianReal' (μ := (0 : ℝ)) (v := (1 : ℝ≥0)) (1 : ℝ≥0∞) (by norm_num))exact hh.integrable (by norm_num)lemma gaussian_stein_bounded {f f' : ℝ → ℝ} {C D : ℝ}(hf : ∀ x, HasDerivAt f (f' x) x) (hm : AEStronglyMeasurable f' standardGaussian)(hC : ∀ x, |f x|≤C) (hD : ∀ x, |f' x|≤D) :(∫ x, x*f x ∂standardGaussian) = ∫ x, f' x ∂standardGaussian := byhave hfm : Continuous f := continuous_iff_continuousAt.mpr (fun x ↦ (hf x).continuousAt)have hfi : Integrable f standardGaussian := Integrable.of_bound hfm.aestronglyMeasurable C(Eventually.of_forall (fun x ↦ (Real.norm_eq_abs _).trans_le (hC x)))have hf'i : Integrable f' standardGaussian := Integrable.of_bound hm D(Eventually.of_forall (fun x ↦ (Real.norm_eq_abs _).trans_le (hD x)))have hxfi : Integrable (fun x ↦ x*f x) standardGaussian :=standardGaussian_integrable_id.mul_bdd hfm.aestronglyMeasurable(Eventually.of_forall (fun x ↦ (Real.norm_eq_abs _).trans_le (hC x)))have hi1 : Integrable (fun x ↦ f x*(-x*gaussianPDFReal 0 1 x)) := byconvert (density_mul_integrable hxfi).neg using 1ext xsimp only [Pi.neg_apply]ringhave hi2 : Integrable (fun x ↦ f' x*gaussianPDFReal 0 1 x) := bysimpa only [mul_comm] using density_mul_integrable hf'ihave hi3 : Integrable (fun x ↦ f x*gaussianPDFReal 0 1 x) := bysimpa only [mul_comm] using density_mul_integrable hfihave hibp := integral_mul_deriv_eq_deriv_mul_of_integrable(u := f) (v := gaussianPDFReal 0 1) (u' := f') (v' := fun x ↦ -x*gaussianPDFReal 0 1 x)(fun x _ ↦ hf x) (fun x _ ↦ density_hasDerivAt x) hi1 hi2 hi3have hb : (∫ x, f x*(-x*gaussianPDFReal 0 1 x)) =-(∫ x, gaussianPDFReal 0 1 x*(x*f x)) := byrw [← integral_neg]apply integral_congr_aeexact Eventually.of_forall (fun x ↦ by ring)rw [hb] at hibphave he : (∫ x, gaussianPDFReal 0 1 x*(x*f x)) =∫ x, gaussianPDFReal 0 1 x*f' x := byexact neg_injective hibp |>.trans (by congr 1; funext x; ring)simpa only [standardGaussian,integral_gaussianReal_eq_integral_smul (by norm_num : (1 : ℝ≥0) ≠ 0),smul_eq_mul] using helemma gaussian_coordinate_integrable {ι : Type*} [Fintype ι] (i : ι) :Integrable (fun z : ι → ℝ ↦ z i) (gaussianProduct ι) := byexact ((measurePreserving_eval (fun _ : ι ↦ standardGaussian) i).integrable_compstandardGaussian_integrable_id.aestronglyMeasurable).mpr standardGaussian_integrable_idlemma gaussian_pi_stein_bounded {n : ℕ} (i : Fin n) {f f' : (Fin n → ℝ) → ℝ} {C D : ℝ}(hf : Continuous f) (hf' : Continuous f')(hd : ∀ z, HasDerivAt (fun x ↦ f (Function.update z i x)) (f' z) (z i))(hC : ∀ z, |f z| ≤ C) (hD : ∀ z, |f' z| ≤ D) :(∫ z, z i*f z ∂gaussianProduct (Fin n)) = ∫ z, f' z ∂gaussianProduct (Fin n) := bycases n with| zero => exact Fin.elim0 i| succ n =>let e := MeasurableEquiv.piFinSuccAbove (fun _ : Fin (n+1) ↦ ℝ) ihave he : MeasurePreserving e.symm (standardGaussian.prod (gaussianProduct (Fin n)))(gaussianProduct (Fin (n+1))) :=(measurePreserving_piFinSuccAbove (fun _ : Fin (n+1) ↦ standardGaussian) i).symmhave hi : Integrable (fun z : Fin (n+1) → ℝ ↦ z i*f z) (gaussianProduct (Fin (n+1))) :=(gaussian_coordinate_integrable i).mul_bdd hf.aestronglyMeasurable(Eventually.of_forall (fun z ↦ (Real.norm_eq_abs _).trans_le (hC z)))have hi' : Integrable f' (gaussianProduct (Fin (n+1))) :=Integrable.of_bound hf'.aestronglyMeasurable D(Eventually.of_forall (fun z ↦ (Real.norm_eq_abs _).trans_le (hD z)))have hip : Integrable (fun p ↦ e.symm p i * f (e.symm p))(standardGaussian.prod (gaussianProduct (Fin n))) := (he.integrable_comp hi.aestronglyMeasurable).mpr hihave hi'p : Integrable (fun p ↦ f' (e.symm p))(standardGaussian.prod (gaussianProduct (Fin n))) := (he.integrable_comp hi'.aestronglyMeasurable).mpr hi'rw [← he.integral_comp' (fun z ↦ z i*f z), ← he.integral_comp' f',integral_prod _ hip, integral_prod _ hi'p,integral_integral_swap (f := fun x y ↦ e.symm (x,y) i * f (e.symm (x,y))) hip,integral_integral_swap (f := fun x y ↦ f' (e.symm (x,y))) hi'p]apply integral_congr_aeapply Eventually.of_forallintro ysimp only [e, MeasurableEquiv.piFinSuccAbove_symm_apply,Fin.insertNthEquiv,Equiv.coe_fn_mk,Fin.insertNth_apply_same]change (∫ x, x*f (i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y) ∂standardGaussian) =∫ x, f' (i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y) ∂standardGaussianhave hmeas : Measurable (fun x : ℝ ↦ i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y) := byexact e.symm.measurable.comp (measurable_id.prodMk measurable_const)apply gaussian_stein_bounded (f' := fun x ↦ f' (i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y))· intro xsimpa only [Fin.update_insertNth,Fin.insertNth_apply_same] using hd (i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y)· exact (hf'.measurable.comp hmeas).aestronglyMeasurable· exact fun x ↦ hC _· exact fun x ↦ hD _noncomputable def partition {ι : Type*} [Fintype ι] (x : ι → ℝ) : ℝ :=∑ i, Real.exp (x i)noncomputable def gibbsWeight {ι : Type*} [Fintype ι] (x : ι → ℝ) (i : ι) : ℝ :=Real.exp (x i) / partition xnoncomputable def logPartition {ι : Type*} [Fintype ι] (x : ι → ℝ) : ℝ :=Real.log (partition x)lemma partition_pos {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) : 0 < partition x := byexact Finset.sum_pos (fun i _ ↦ Real.exp_pos _) Finset.univ_nonemptylemma gibbsWeight_nonneg {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (i : ι) :0 ≤ gibbsWeight x i := le_of_lt (div_pos (Real.exp_pos _) (partition_pos x))lemma sum_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) :∑ i, gibbsWeight x i = 1 := bysimp only [gibbsWeight,← Finset.sum_div]change partition x / partition x = 1exact div_self (ne_of_gt (partition_pos x))lemma gibbsWeight_le_one {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (i : ι) :gibbsWeight x i ≤ 1 := bycalc_ ≤ ∑ j, gibbsWeight x j := Finset.single_le_sum (fun j _ ↦ gibbsWeight_nonneg x j) (Finset.mem_univ i)_ = 1 := sum_gibbsWeight xlemma continuous_partition {ι : Type*} [Fintype ι] : Continuous (@partition ι _) := byunfold partitionfun_proplemma continuous_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι] (i : ι) :Continuous (fun x : ι → ℝ ↦ gibbsWeight x i) := byexact (Real.continuous_exp.comp (continuous_apply i)).div continuous_partition (fun x ↦ ne_of_gt (partition_pos x))lemma hasDerivAt_partition {ι : Type*} [Fintype ι] {x : ℝ → ι → ℝ} {v : ι → ℝ} {t : ℝ}(h : ∀ i, HasDerivAt (fun s ↦ x s i) (v i) t) :HasDerivAt (fun s ↦ partition (x s)) (∑ i, Real.exp (x t i)*v i) t := bysimpa only [partition,Finset.sum_apply] using (HasDerivAt.fun_sum (u := Finset.univ) (fun i _ ↦ (h i).exp))lemma hasDerivAt_logPartition {ι : Type*} [Fintype ι] [Nonempty ι]{x : ℝ → ι → ℝ} {v : ι → ℝ} {t : ℝ}(h : ∀ i, HasDerivAt (fun s ↦ x s i) (v i) t) :HasDerivAt (fun s ↦ logPartition (x s)) (∑ i, gibbsWeight (x t) i*v i) t := byconvert (hasDerivAt_partition h).log (ne_of_gt (partition_pos _)) using 1 <;> try rflsimp only [gibbsWeight,Finset.sum_div,mul_div_assoc]apply Finset.sum_congr rflintro i _ringlemma hasDerivAt_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι]{x : ℝ → ι → ℝ} {v : ι → ℝ} {t : ℝ}(h : ∀ i, HasDerivAt (fun s ↦ x s i) (v i) t) (i : ι) :HasDerivAt (fun s ↦ gibbsWeight (x s) i)(gibbsWeight (x t) i*(v i-∑ j, gibbsWeight (x t) j*v j)) t := byconvert (h i).exp.div (hasDerivAt_partition h) (ne_of_gt (partition_pos _)) using 1 <;> try rflsimp only [gibbsWeight]rw [show (∑ j, Real.exp (x t j)/partition (x t)*v j) =(∑ j, Real.exp (x t j)*v j)/partition (x t) byrw [Finset.sum_div]; apply Finset.sum_congr rfl; intro j _; ring]field_simp [ne_of_gt (partition_pos (x t))]lemma abs_gibbsMean_le {ι : Type*} [Fintype ι] [Nonempty ι] (x v : ι → ℝ) {C : ℝ}(hC : ∀ i, |v i| ≤ C) : |∑ i, gibbsWeight x i*v i| ≤ C := bycalc_ ≤ ∑ i, |gibbsWeight x i*v i| := Finset.abs_sum_le_sum_abs _ __ = ∑ i, gibbsWeight x i*|v i| := by simp only [abs_mul,abs_of_nonneg (gibbsWeight_nonneg _ _)]_ ≤ ∑ i, gibbsWeight x i*C := Finset.sum_le_sum (fun i _ ↦ mul_le_mul_of_nonneg_left (hC i) (gibbsWeight_nonneg _ _))_ = C := by rw [← Finset.sum_mul,sum_gibbsWeight,one_mul]noncomputable def linearProcess {ι κ : Type*} [Fintype κ] (c : ι → κ → ℝ) (z : κ → ℝ) (i : ι) : ℝ :=∑ k, c i k*z klemma continuous_linearProcess {ι κ : Type*} [Fintype κ] (c : ι → κ → ℝ) :Continuous (linearProcess c) := byunfold linearProcessfun_proplemma hasDerivAt_linearProcess_update {ι κ : Type*} [Fintype κ] [DecidableEq κ](c : ι → κ → ℝ) (z : κ → ℝ) (i : ι) (k : κ) :HasDerivAt (fun x ↦ linearProcess c (Function.update z k x) i) (c i k) (z k) := byhave h : ∀ j, HasDerivAt (fun x ↦ c i j * Function.update z k x j)(if j=k then c i k else 0) (z k) := byintro jby_cases hj : j=k· subst jsimpa only [Function.update_self,ite_true,mul_one,id_eq] using (hasDerivAt_id (z k)).const_mul (c i k)· simpa only [Function.update_of_ne hj,ite_eq_right hj] using hasDerivAt_const (z k) (c i j*z j)simpa only [linearProcess,Finset.sum_apply,Finset.sum_ite_eq',Finset.mem_univ,ite_true]using HasDerivAt.fun_sum (u := Finset.univ) (fun j _ ↦ h j)lemma continuous_linear_gibbsWeight {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) (i : ι) : Continuous (fun z ↦ gibbsWeight (linearProcess c z) i) :=(continuous_gibbsWeight i).comp (continuous_linearProcess c)lemma integrable_linear_gibbsWeight {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) (i : ι) : Integrable (fun z ↦ gibbsWeight (linearProcess c z) i) (gaussianProduct κ) := byapply Integrable.of_bound (continuous_linear_gibbsWeight c i).aestronglyMeasurable 1exact Eventually.of_forall (fun z ↦ by rw [Real.norm_eq_abs,abs_of_nonneg (gibbsWeight_nonneg _ _)]; exact gibbsWeight_le_one _ _)lemma coordinate_gibbsWeight_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) (i : ι) (k : κ) :Integrable (fun z ↦ z k*gibbsWeight (linearProcess c z) i) (gaussianProduct κ) := byapply (gaussian_coordinate_integrable k).mul_bdd (continuous_linear_gibbsWeight c i).aestronglyMeasurableexact Eventually.of_forall (fun z ↦ by rw [Real.norm_eq_abs,abs_of_nonneg (gibbsWeight_nonneg _ _)]; exact gibbsWeight_le_one _ _)lemma gaussian_coordinate_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (c : ι → Fin n → ℝ) (i : ι) (k : Fin n) :(∫ z, z k*gibbsWeight (linearProcess c z) i ∂gaussianProduct (Fin n)) =∫ z, gibbsWeight (linearProcess c z) i *(c i k - ∑ j, gibbsWeight (linearProcess c z) j*c j k) ∂gaussianProduct (Fin n) := byapply gaussian_pi_stein_bounded k (C := 1) (D := 2*∑ j, |c j k|)· exact continuous_linear_gibbsWeight c i· apply Continuous.mul (continuous_linear_gibbsWeight c i)apply continuous_const.subexact continuous_finsetSum _ (fun j _ ↦ (continuous_linear_gibbsWeight c j).mul continuous_const)· intro zsimpa only [Function.update_eq_self] usinghasDerivAt_gibbsWeight (fun j ↦ hasDerivAt_linearProcess_update c z j k) i· intro zrw [abs_of_nonneg (gibbsWeight_nonneg _ _)]exact gibbsWeight_le_one _ _· intro zhave hsum : ∀ j, |c j k| ≤ ∑ l, |c l k| := fun j ↦Finset.single_le_sum (f := fun l ↦ |c l k|) (fun l _ ↦ abs_nonneg _) (Finset.mem_univ j)calc_ = gibbsWeight (linearProcess c z) i * |c i k-∑ j, gibbsWeight (linearProcess c z) j*c j k| := byrw [abs_mul,abs_of_nonneg (gibbsWeight_nonneg _ _)]_ ≤ |c i k-∑ j, gibbsWeight (linearProcess c z) j*c j k| :=mul_le_of_le_one_left (abs_nonneg _) (gibbsWeight_le_one _ _)_ ≤ |c i k| + |∑ j, gibbsWeight (linearProcess c z) j*c j k| := abs_sub _ __ ≤ (∑ j, |c j k|) + (∑ j, |c j k|) := add_le_add (hsum i) (abs_gibbsMean_le _ _ hsum)_ = _ := by ringlemma le_logPartition {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (i : ι) :x i ≤ logPartition x := byapply (Real.le_log_iff_exp_le (partition_pos x)).mprexact Finset.single_le_sum (fun j _ ↦ (Real.exp_pos _).le) (Finset.mem_univ i)lemma logPartition_le {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) {C : ℝ}(h : ∀ i, x i ≤ C) : logPartition x ≤ Real.log (Fintype.card ι) + C := byhave hc : (0 : ℝ) < Fintype.card ι := Nat.cast_pos.mpr Fintype.card_poscalclogPartition x ≤ Real.log ((Fintype.card ι : ℝ)*Real.exp C) := byapply Real.log_le_log (partition_pos x)calcpartition x ≤ ∑ _ : ι, Real.exp C := Finset.sum_le_sum (fun i _ ↦ Real.exp_le_exp.mpr (h i))_ = _ := by simp_ = _ := by rw [Real.log_mul (ne_of_gt hc) (Real.exp_ne_zero _),Real.log_exp]lemma abs_logPartition_le {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) :|logPartition x| ≤ |Real.log (Fintype.card ι)| + ∑ i, |x i| := byhave hsum : ∀ i, |x i| ≤ ∑ j, |x j| := fun i ↦Finset.single_le_sum (f := fun j ↦ |x j|) (fun j _ ↦ abs_nonneg _) (Finset.mem_univ i)have hu := logPartition_le x (fun i ↦ (le_abs_self _).trans (hsum i))obtain ⟨i⟩ := ‹Nonempty ι›have hl := le_logPartition x ihave hx := neg_abs_le (x i)have hxi := hsum irw [abs_le]constructor <;> linarith [le_abs_self (Real.log (Fintype.card ι)),abs_nonneg (Real.log (Fintype.card ι))]lemma continuous_logPartition {ι : Type*} [Fintype ι] [Nonempty ι] :Continuous (@logPartition ι _) :=continuous_partition.log (fun x ↦ ne_of_gt (partition_pos x))lemma linearProcess_integrable {ι κ : Type*} [Fintype κ] (c : ι → κ → ℝ) (i : ι) :Integrable (fun z ↦ linearProcess c z i) (gaussianProduct κ) :=integrable_finsetSum _ (fun k _ ↦ (gaussian_coordinate_integrable k).const_mul (c i k))lemma logPartition_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) : Integrable (fun z ↦ logPartition (linearProcess c z)) (gaussianProduct κ) := byhave hb := (integrable_const (|Real.log (Fintype.card ι)| : ℝ)).add(integrable_finsetSum Finset.univ (fun i _ ↦ (linearProcess_integrable c i).abs))apply hb.mono' ((continuous_logPartition.comp (continuous_linearProcess c)).aestronglyMeasurable)exact Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs,Function.comp_def,Pi.add_apply] using abs_logPartition_le (linearProcess c z))lemma gibbsWeight_mul_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) (i : ι) {f : (κ → ℝ) → ℝ} (hi : Integrable f (gaussianProduct κ)) :Integrable (fun z ↦ gibbsWeight (linearProcess c z) i*f z) (gaussianProduct κ) := bysimpa only [mul_comm] using hi.mul_bdd (continuous_linear_gibbsWeight c i).aestronglyMeasurable(Eventually.of_forall (fun z ↦ by rw [Real.norm_eq_abs,abs_of_nonneg (gibbsWeight_nonneg _ _)]; exact gibbsWeight_le_one _ _))lemma gaussian_linear_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (c d : ι → Fin n → ℝ) (i : ι) :(∫ z, gibbsWeight (linearProcess c z) i * linearProcess d z i ∂gaussianProduct (Fin n)) =∫ z, gibbsWeight (linearProcess c z) i *((∑ k, d i k*c i k) - ∑ j, gibbsWeight (linearProcess c z) j*(∑ k, d i k*c j k))∂gaussianProduct (Fin n) := byhave hid : ∀ k, Integrable (fun z ↦ d i k * (z k*gibbsWeight (linearProcess c z) i))(gaussianProduct (Fin n)) := fun k ↦ (coordinate_gibbsWeight_integrable c i k).const_mul _have hic : ∀ k, Integrable (fun z ↦ d i k * (gibbsWeight (linearProcess c z) i *(c i k - ∑ j, gibbsWeight (linearProcess c z) j*c j k))) (gaussianProduct (Fin n)) := byintro kapply Integrable.const_mulapply gibbsWeight_mul_integrableexact (integrable_const _).sub (integrable_finsetSum Finset.univ(fun j _ ↦ (integrable_linear_gibbsWeight c j).mul_const _))calc_ = ∫ z, ∑ k, d i k*(z k*gibbsWeight (linearProcess c z) i) ∂gaussianProduct (Fin n) := byapply integral_congr_aeexact Eventually.of_forall (fun z ↦ by simp only [linearProcess,Finset.mul_sum]; apply Finset.sum_congr rfl; intro k _; ring)_ = ∑ k, d i k * (∫ z, z k*gibbsWeight (linearProcess c z) i ∂gaussianProduct (Fin n)) := byrw [integral_finsetSum Finset.univ (fun k _ ↦ hid k)]simp only [integral_const_mul]_ = ∑ k, d i k * (∫ z, gibbsWeight (linearProcess c z) i *(c i k-∑ j, gibbsWeight (linearProcess c z) j*c j k) ∂gaussianProduct (Fin n)) := bysimp only [gaussian_coordinate_gibbsWeight]_ = ∫ z, ∑ k, d i k * (gibbsWeight (linearProcess c z) i *(c i k-∑ j, gibbsWeight (linearProcess c z) j*c j k)) ∂gaussianProduct (Fin n) := byrw [integral_finsetSum Finset.univ (fun k _ ↦ hic k)]simp only [integral_const_mul]_ = _ := byapply integral_congr_aeapply Eventually.of_forallintro zsimp only [mul_sub,Finset.sum_sub_distrib,Finset.mul_sum]congr 1· apply Finset.sum_congr rfl; intro k _; ring· rw [Finset.sum_comm]apply Finset.sum_congr rfl; intro j _apply Finset.sum_congr rfl; intro k _; ringlemma weighted_covariance_pairs {ι : Type*} [Fintype ι] (p : ι → ℝ) (D : ι → ι → ℝ)(hp : ∑ i, p i = 1) :∑ i, p i*(D i i-∑ j, p j*D i j) =(1/2 : ℝ)*∑ i, ∑ j, p i*p j*(D i i+D j j-D i j-D j i) := byhave h1 : (∑ i, ∑ j, p i*p j*D i i) = ∑ i, p i*D i i := byapply Finset.sum_congr rflintro i _calc_ = p i*D i i*∑ j, p j := by rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro j _; ring_ = _ := by rw [hp,mul_one]have h2 : (∑ i, ∑ j, p i*p j*D j j) = ∑ j, p j*D j j := byrw [Finset.sum_comm]apply Finset.sum_congr rflintro j _calc_ = (∑ i, p i)*(p j*D j j) := by rw [Finset.sum_mul]; apply Finset.sum_congr rfl; intro i _; ring_ = _ := by rw [hp,one_mul]have h3 : (∑ i, ∑ j, p i*p j*D j i) = ∑ i, ∑ j, p i*p j*D i j := byrw [Finset.sum_comm]apply Finset.sum_congr rfl; intro i _apply Finset.sum_congr rfl; intro j _; ringhave hl : (∑ i, p i*(D i i-∑ j, p j*D i j)) =(∑ i, p i*D i i) - ∑ i, ∑ j, p i*p j*D i j := bysimp only [mul_sub,Finset.sum_sub_distrib,Finset.mul_sum,mul_assoc]have hr : (∑ i, ∑ j, p i*p j*(D i i+D j j-D i j-D j i)) =2*(∑ i, p i*D i i)-2*(∑ i, ∑ j, p i*p j*D i j) := bysimp only [mul_sub,mul_add,Finset.sum_sub_distrib,Finset.sum_add_distrib]rw [h1,h2,h3]ringrw [hl,hr]ringend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384import Mathlibimport OAI.Probability.SKValue.Evolution.BoundedSmoothnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGnoncomputable def standardGaussian : Measure ℝ := gaussianReal 0 1noncomputable def gaussianProduct (ι : Type*) [Fintype ι] : Measure (ι → ℝ) :=Measure.pi (fun _ : ι ↦ standardGaussian)instance : IsProbabilityMeasure standardGaussian := by unfold standardGaussian; infer_instanceinstance {ι : Type*} [Fintype ι] : IsProbabilityMeasure (gaussianProduct ι) := byunfold gaussianProduct; infer_instancelemma density_hasDerivAt (x : ℝ) :HasDerivAt (gaussianPDFReal 0 1) (-x*gaussianPDFReal 0 1 x) x := byhave h1 : HasDerivAt (fun y : ℝ ↦ -y^2/2) (-x) x := byhave hh := ((hasDerivAt_id x).pow 2).neg.div_const (2 : ℝ)simpa only [Pi.pow_def,Pi.neg_def,id_eq,pow_one,show (2 : ℕ)-1=1 from rfl,Nat.cast_ofNat,mul_one,neg_div,mul_div_cancel_left₀ _ (by norm_num : (2 : ℝ) ≠ 0)] using hhhave hd := h1.exp.const_mul ((Real.sqrt (2*Real.pi))⁻¹)convert hd using 1 <;> try rfl· funext ysimp only [gaussianPDFReal,NNReal.coe_one,mul_one,sub_zero]· simp only [gaussianPDFReal,NNReal.coe_one,mul_one,sub_zero]ringlemma density_mul_integrable {f : ℝ → ℝ} (hf : Integrable f standardGaussian) :Integrable (fun x ↦ gaussianPDFReal 0 1 x*f x) := byrw [standardGaussian,gaussianReal_of_var_ne_zero _ (by norm_num)] at hfhave hh := (integrable_withDensity_iff_integrable_smul'(measurable_gaussianPDF 0 1) (Eventually.of_forall (fun x ↦ gaussianPDF_lt_top (μ := 0) (v := 1) (x := x)))).mp hfsimpa only [toReal_gaussianPDF,smul_eq_mul] using hhlemma standardGaussian_integrable_id : Integrable (fun x : ℝ ↦ x) standardGaussian := byhave hh := (memLp_id_gaussianReal' (μ := (0 : ℝ)) (v := (1 : ℝ≥0)) (1 : ℝ≥0∞) (by norm_num))exact hh.integrable (by norm_num)lemma gaussian_stein_bounded {f f' : ℝ → ℝ} {C D : ℝ}(hf : ∀ x, HasDerivAt f (f' x) x) (hm : AEStronglyMeasurable f' standardGaussian)(hC : ∀ x, |f x|≤C) (hD : ∀ x, |f' x|≤D) :(∫ x, x*f x ∂standardGaussian) = ∫ x, f' x ∂standardGaussian := byhave hfm : Continuous f := continuous_iff_continuousAt.mpr (fun x ↦ (hf x).continuousAt)have hfi : Integrable f standardGaussian := Integrable.of_bound hfm.aestronglyMeasurable C(Eventually.of_forall (fun x ↦ (Real.norm_eq_abs _).trans_le (hC x)))have hf'i : Integrable f' standardGaussian := Integrable.of_bound hm D(Eventually.of_forall (fun x ↦ (Real.norm_eq_abs _).trans_le (hD x)))have hxfi : Integrable (fun x ↦ x*f x) standardGaussian :=standardGaussian_integrable_id.mul_bdd hfm.aestronglyMeasurable(Eventually.of_forall (fun x ↦ (Real.norm_eq_abs _).trans_le (hC x)))have hi1 : Integrable (fun x ↦ f x*(-x*gaussianPDFReal 0 1 x)) := byconvert (density_mul_integrable hxfi).neg using 1ext xsimp only [Pi.neg_apply]ringhave hi2 : Integrable (fun x ↦ f' x*gaussianPDFReal 0 1 x) := bysimpa only [mul_comm] using density_mul_integrable hf'ihave hi3 : Integrable (fun x ↦ f x*gaussianPDFReal 0 1 x) := bysimpa only [mul_comm] using density_mul_integrable hfihave hibp := integral_mul_deriv_eq_deriv_mul_of_integrable(u := f) (v := gaussianPDFReal 0 1) (u' := f') (v' := fun x ↦ -x*gaussianPDFReal 0 1 x)(fun x _ ↦ hf x) (fun x _ ↦ density_hasDerivAt x) hi1 hi2 hi3have hb : (∫ x, f x*(-x*gaussianPDFReal 0 1 x)) =-(∫ x, gaussianPDFReal 0 1 x*(x*f x)) := byrw [← integral_neg]apply integral_congr_aeexact Eventually.of_forall (fun x ↦ by ring)rw [hb] at hibphave he : (∫ x, gaussianPDFReal 0 1 x*(x*f x)) =∫ x, gaussianPDFReal 0 1 x*f' x := byexact neg_injective hibp |>.trans (by congr 1; funext x; ring)simpa only [standardGaussian,integral_gaussianReal_eq_integral_smul (by norm_num : (1 : ℝ≥0) ≠ 0),smul_eq_mul] using helemma gaussian_coordinate_integrable {ι : Type*} [Fintype ι] (i : ι) :Integrable (fun z : ι → ℝ ↦ z i) (gaussianProduct ι) := byexact ((measurePreserving_eval (fun _ : ι ↦ standardGaussian) i).integrable_compstandardGaussian_integrable_id.aestronglyMeasurable).mpr standardGaussian_integrable_idlemma gaussian_pi_stein_bounded {n : ℕ} (i : Fin n) {f f' : (Fin n → ℝ) → ℝ} {C D : ℝ}(hf : Continuous f) (hf' : Continuous f')(hd : ∀ z, HasDerivAt (fun x ↦ f (Function.update z i x)) (f' z) (z i))(hC : ∀ z, |f z| ≤ C) (hD : ∀ z, |f' z| ≤ D) :(∫ z, z i*f z ∂gaussianProduct (Fin n)) = ∫ z, f' z ∂gaussianProduct (Fin n) := bycases n with| zero => exact Fin.elim0 i| succ n =>let e := MeasurableEquiv.piFinSuccAbove (fun _ : Fin (n+1) ↦ ℝ) ihave he : MeasurePreserving e.symm (standardGaussian.prod (gaussianProduct (Fin n)))(gaussianProduct (Fin (n+1))) :=(measurePreserving_piFinSuccAbove (fun _ : Fin (n+1) ↦ standardGaussian) i).symmhave hi : Integrable (fun z : Fin (n+1) → ℝ ↦ z i*f z) (gaussianProduct (Fin (n+1))) :=(gaussian_coordinate_integrable i).mul_bdd hf.aestronglyMeasurable(Eventually.of_forall (fun z ↦ (Real.norm_eq_abs _).trans_le (hC z)))have hi' : Integrable f' (gaussianProduct (Fin (n+1))) :=Integrable.of_bound hf'.aestronglyMeasurable D(Eventually.of_forall (fun z ↦ (Real.norm_eq_abs _).trans_le (hD z)))have hip : Integrable (fun p ↦ e.symm p i * f (e.symm p))(standardGaussian.prod (gaussianProduct (Fin n))) := (he.integrable_comp hi.aestronglyMeasurable).mpr hihave hi'p : Integrable (fun p ↦ f' (e.symm p))(standardGaussian.prod (gaussianProduct (Fin n))) := (he.integrable_comp hi'.aestronglyMeasurable).mpr hi'rw [← he.integral_comp' (fun z ↦ z i*f z), ← he.integral_comp' f',integral_prod _ hip, integral_prod _ hi'p,integral_integral_swap (f := fun x y ↦ e.symm (x,y) i * f (e.symm (x,y))) hip,integral_integral_swap (f := fun x y ↦ f' (e.symm (x,y))) hi'p]apply integral_congr_aeapply Eventually.of_forallintro ysimp only [e, MeasurableEquiv.piFinSuccAbove_symm_apply,Fin.insertNthEquiv,Equiv.coe_fn_mk,Fin.insertNth_apply_same]change (∫ x, x*f (i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y) ∂standardGaussian) =∫ x, f' (i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y) ∂standardGaussianhave hmeas : Measurable (fun x : ℝ ↦ i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y) := byexact e.symm.measurable.comp (measurable_id.prodMk measurable_const)apply gaussian_stein_bounded (f' := fun x ↦ f' (i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y))· intro xsimpa only [Fin.update_insertNth,Fin.insertNth_apply_same] using hd (i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y)· exact (hf'.measurable.comp hmeas).aestronglyMeasurable· exact fun x ↦ hC _· exact fun x ↦ hD _noncomputable def partition {ι : Type*} [Fintype ι] (x : ι → ℝ) : ℝ :=∑ i, Real.exp (x i)noncomputable def gibbsWeight {ι : Type*} [Fintype ι] (x : ι → ℝ) (i : ι) : ℝ :=Real.exp (x i) / partition xnoncomputable def logPartition {ι : Type*} [Fintype ι] (x : ι → ℝ) : ℝ :=Real.log (partition x)lemma partition_pos {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) : 0 < partition x := byexact Finset.sum_pos (fun i _ ↦ Real.exp_pos _) Finset.univ_nonemptylemma gibbsWeight_nonneg {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (i : ι) :0 ≤ gibbsWeight x i := le_of_lt (div_pos (Real.exp_pos _) (partition_pos x))lemma sum_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) :∑ i, gibbsWeight x i = 1 := bysimp only [gibbsWeight,← Finset.sum_div]change partition x / partition x = 1exact div_self (ne_of_gt (partition_pos x))lemma gibbsWeight_le_one {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (i : ι) :gibbsWeight x i ≤ 1 := bycalc_ ≤ ∑ j, gibbsWeight x j := Finset.single_le_sum (fun j _ ↦ gibbsWeight_nonneg x j) (Finset.mem_univ i)_ = 1 := sum_gibbsWeight xlemma continuous_partition {ι : Type*} [Fintype ι] : Continuous (@partition ι _) := byunfold partitionfun_proplemma continuous_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι] (i : ι) :Continuous (fun x : ι → ℝ ↦ gibbsWeight x i) := byexact (Real.continuous_exp.comp (continuous_apply i)).div continuous_partition (fun x ↦ ne_of_gt (partition_pos x))lemma hasDerivAt_partition {ι : Type*} [Fintype ι] {x : ℝ → ι → ℝ} {v : ι → ℝ} {t : ℝ}(h : ∀ i, HasDerivAt (fun s ↦ x s i) (v i) t) :HasDerivAt (fun s ↦ partition (x s)) (∑ i, Real.exp (x t i)*v i) t := bysimpa only [partition,Finset.sum_apply] using (HasDerivAt.fun_sum (u := Finset.univ) (fun i _ ↦ (h i).exp))lemma hasDerivAt_logPartition {ι : Type*} [Fintype ι] [Nonempty ι]{x : ℝ → ι → ℝ} {v : ι → ℝ} {t : ℝ}(h : ∀ i, HasDerivAt (fun s ↦ x s i) (v i) t) :HasDerivAt (fun s ↦ logPartition (x s)) (∑ i, gibbsWeight (x t) i*v i) t := byconvert (hasDerivAt_partition h).log (ne_of_gt (partition_pos _)) using 1 <;> try rflsimp only [gibbsWeight,Finset.sum_div,mul_div_assoc]apply Finset.sum_congr rflintro i _ringlemma hasDerivAt_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι]{x : ℝ → ι → ℝ} {v : ι → ℝ} {t : ℝ}(h : ∀ i, HasDerivAt (fun s ↦ x s i) (v i) t) (i : ι) :HasDerivAt (fun s ↦ gibbsWeight (x s) i)(gibbsWeight (x t) i*(v i-∑ j, gibbsWeight (x t) j*v j)) t := byconvert (h i).exp.div (hasDerivAt_partition h) (ne_of_gt (partition_pos _)) using 1 <;> try rflsimp only [gibbsWeight]rw [show (∑ j, Real.exp (x t j)/partition (x t)*v j) =(∑ j, Real.exp (x t j)*v j)/partition (x t) byrw [Finset.sum_div]; apply Finset.sum_congr rfl; intro j _; ring]field_simp [ne_of_gt (partition_pos (x t))]lemma abs_gibbsMean_le {ι : Type*} [Fintype ι] [Nonempty ι] (x v : ι → ℝ) {C : ℝ}(hC : ∀ i, |v i| ≤ C) : |∑ i, gibbsWeight x i*v i| ≤ C := bycalc_ ≤ ∑ i, |gibbsWeight x i*v i| := Finset.abs_sum_le_sum_abs _ __ = ∑ i, gibbsWeight x i*|v i| := by simp only [abs_mul,abs_of_nonneg (gibbsWeight_nonneg _ _)]_ ≤ ∑ i, gibbsWeight x i*C := Finset.sum_le_sum (fun i _ ↦ mul_le_mul_of_nonneg_left (hC i) (gibbsWeight_nonneg _ _))_ = C := by rw [← Finset.sum_mul,sum_gibbsWeight,one_mul]noncomputable def linearProcess {ι κ : Type*} [Fintype κ] (c : ι → κ → ℝ) (z : κ → ℝ) (i : ι) : ℝ :=∑ k, c i k*z klemma continuous_linearProcess {ι κ : Type*} [Fintype κ] (c : ι → κ → ℝ) :Continuous (linearProcess c) := byunfold linearProcessfun_proplemma hasDerivAt_linearProcess_update {ι κ : Type*} [Fintype κ] [DecidableEq κ](c : ι → κ → ℝ) (z : κ → ℝ) (i : ι) (k : κ) :HasDerivAt (fun x ↦ linearProcess c (Function.update z k x) i) (c i k) (z k) := byhave h : ∀ j, HasDerivAt (fun x ↦ c i j * Function.update z k x j)(if j=k then c i k else 0) (z k) := byintro jby_cases hj : j=k· subst jsimpa only [Function.update_self,ite_true,mul_one,id_eq] using (hasDerivAt_id (z k)).const_mul (c i k)· simpa only [Function.update_of_ne hj,ite_eq_right hj] using hasDerivAt_const (z k) (c i j*z j)simpa only [linearProcess,Finset.sum_apply,Finset.sum_ite_eq',Finset.mem_univ,ite_true]using HasDerivAt.fun_sum (u := Finset.univ) (fun j _ ↦ h j)lemma continuous_linear_gibbsWeight {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) (i : ι) : Continuous (fun z ↦ gibbsWeight (linearProcess c z) i) :=(continuous_gibbsWeight i).comp (continuous_linearProcess c)lemma integrable_linear_gibbsWeight {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) (i : ι) : Integrable (fun z ↦ gibbsWeight (linearProcess c z) i) (gaussianProduct κ) := byapply Integrable.of_bound (continuous_linear_gibbsWeight c i).aestronglyMeasurable 1exact Eventually.of_forall (fun z ↦ by rw [Real.norm_eq_abs,abs_of_nonneg (gibbsWeight_nonneg _ _)]; exact gibbsWeight_le_one _ _)lemma coordinate_gibbsWeight_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) (i : ι) (k : κ) :Integrable (fun z ↦ z k*gibbsWeight (linearProcess c z) i) (gaussianProduct κ) := byapply (gaussian_coordinate_integrable k).mul_bdd (continuous_linear_gibbsWeight c i).aestronglyMeasurableexact Eventually.of_forall (fun z ↦ by rw [Real.norm_eq_abs,abs_of_nonneg (gibbsWeight_nonneg _ _)]; exact gibbsWeight_le_one _ _)lemma gaussian_coordinate_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (c : ι → Fin n → ℝ) (i : ι) (k : Fin n) :(∫ z, z k*gibbsWeight (linearProcess c z) i ∂gaussianProduct (Fin n)) =∫ z, gibbsWeight (linearProcess c z) i *(c i k - ∑ j, gibbsWeight (linearProcess c z) j*c j k) ∂gaussianProduct (Fin n) := byapply gaussian_pi_stein_bounded k (C := 1) (D := 2*∑ j, |c j k|)· exact continuous_linear_gibbsWeight c i· apply Continuous.mul (continuous_linear_gibbsWeight c i)apply continuous_const.subexact continuous_finsetSum _ (fun j _ ↦ (continuous_linear_gibbsWeight c j).mul continuous_const)· intro zsimpa only [Function.update_eq_self] usinghasDerivAt_gibbsWeight (fun j ↦ hasDerivAt_linearProcess_update c z j k) i· intro zrw [abs_of_nonneg (gibbsWeight_nonneg _ _)]exact gibbsWeight_le_one _ _· intro zhave hsum : ∀ j, |c j k| ≤ ∑ l, |c l k| := fun j ↦Finset.single_le_sum (f := fun l ↦ |c l k|) (fun l _ ↦ abs_nonneg _) (Finset.mem_univ j)calc_ = gibbsWeight (linearProcess c z) i * |c i k-∑ j, gibbsWeight (linearProcess c z) j*c j k| := byrw [abs_mul,abs_of_nonneg (gibbsWeight_nonneg _ _)]_ ≤ |c i k-∑ j, gibbsWeight (linearProcess c z) j*c j k| :=mul_le_of_le_one_left (abs_nonneg _) (gibbsWeight_le_one _ _)_ ≤ |c i k| + |∑ j, gibbsWeight (linearProcess c z) j*c j k| := abs_sub _ __ ≤ (∑ j, |c j k|) + (∑ j, |c j k|) := add_le_add (hsum i) (abs_gibbsMean_le _ _ hsum)_ = _ := by ringlemma le_logPartition {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (i : ι) :x i ≤ logPartition x := byapply (Real.le_log_iff_exp_le (partition_pos x)).mprexact Finset.single_le_sum (fun j _ ↦ (Real.exp_pos _).le) (Finset.mem_univ i)lemma logPartition_le {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) {C : ℝ}(h : ∀ i, x i ≤ C) : logPartition x ≤ Real.log (Fintype.card ι) + C := byhave hc : (0 : ℝ) < Fintype.card ι := Nat.cast_pos.mpr Fintype.card_poscalclogPartition x ≤ Real.log ((Fintype.card ι : ℝ)*Real.exp C) := byapply Real.log_le_log (partition_pos x)calcpartition x ≤ ∑ _ : ι, Real.exp C := Finset.sum_le_sum (fun i _ ↦ Real.exp_le_exp.mpr (h i))_ = _ := by simp_ = _ := by rw [Real.log_mul (ne_of_gt hc) (Real.exp_ne_zero _),Real.log_exp]lemma abs_logPartition_le {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) :|logPartition x| ≤ |Real.log (Fintype.card ι)| + ∑ i, |x i| := byhave hsum : ∀ i, |x i| ≤ ∑ j, |x j| := fun i ↦Finset.single_le_sum (f := fun j ↦ |x j|) (fun j _ ↦ abs_nonneg _) (Finset.mem_univ i)have hu := logPartition_le x (fun i ↦ (le_abs_self _).trans (hsum i))obtain ⟨i⟩ := ‹Nonempty ι›have hl := le_logPartition x ihave hx := neg_abs_le (x i)have hxi := hsum irw [abs_le]constructor <;> linarith [le_abs_self (Real.log (Fintype.card ι)),abs_nonneg (Real.log (Fintype.card ι))]lemma continuous_logPartition {ι : Type*} [Fintype ι] [Nonempty ι] :Continuous (@logPartition ι _) :=continuous_partition.log (fun x ↦ ne_of_gt (partition_pos x))lemma linearProcess_integrable {ι κ : Type*} [Fintype κ] (c : ι → κ → ℝ) (i : ι) :Integrable (fun z ↦ linearProcess c z i) (gaussianProduct κ) :=integrable_finsetSum _ (fun k _ ↦ (gaussian_coordinate_integrable k).const_mul (c i k))lemma logPartition_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) : Integrable (fun z ↦ logPartition (linearProcess c z)) (gaussianProduct κ) := byhave hb := (integrable_const (|Real.log (Fintype.card ι)| : ℝ)).add(integrable_finsetSum Finset.univ (fun i _ ↦ (linearProcess_integrable c i).abs))apply hb.mono' ((continuous_logPartition.comp (continuous_linearProcess c)).aestronglyMeasurable)exact Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs,Function.comp_def,Pi.add_apply] using abs_logPartition_le (linearProcess c z))lemma gibbsWeight_mul_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ](c : ι → κ → ℝ) (i : ι) {f : (κ → ℝ) → ℝ} (hi : Integrable f (gaussianProduct κ)) :Integrable (fun z ↦ gibbsWeight (linearProcess c z) i*f z) (gaussianProduct κ) := bysimpa only [mul_comm] using hi.mul_bdd (continuous_linear_gibbsWeight c i).aestronglyMeasurable(Eventually.of_forall (fun z ↦ by rw [Real.norm_eq_abs,abs_of_nonneg (gibbsWeight_nonneg _ _)]; exact gibbsWeight_le_one _ _))lemma gaussian_linear_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι]{n : ℕ} (c d : ι → Fin n → ℝ) (i : ι) :(∫ z, gibbsWeight (linearProcess c z) i * linearProcess d z i ∂gaussianProduct (Fin n)) =∫ z, gibbsWeight (linearProcess c z) i *((∑ k, d i k*c i k) - ∑ j, gibbsWeight (linearProcess c z) j*(∑ k, d i k*c j k))∂gaussianProduct (Fin n) := byhave hid : ∀ k, Integrable (fun z ↦ d i k * (z k*gibbsWeight (linearProcess c z) i))(gaussianProduct (Fin n)) := fun k ↦ (coordinate_gibbsWeight_integrable c i k).const_mul _have hic : ∀ k, Integrable (fun z ↦ d i k * (gibbsWeight (linearProcess c z) i *(c i k - ∑ j, gibbsWeight (linearProcess c z) j*c j k))) (gaussianProduct (Fin n)) := byintro kapply Integrable.const_mulapply gibbsWeight_mul_integrableexact (integrable_const _).sub (integrable_finsetSum Finset.univ(fun j _ ↦ (integrable_linear_gibbsWeight c j).mul_const _))calc_ = ∫ z, ∑ k, d i k*(z k*gibbsWeight (linearProcess c z) i) ∂gaussianProduct (Fin n) := byapply integral_congr_aeexact Eventually.of_forall (fun z ↦ by simp only [linearProcess,Finset.mul_sum]; apply Finset.sum_congr rfl; intro k _; ring)_ = ∑ k, d i k * (∫ z, z k*gibbsWeight (linearProcess c z) i ∂gaussianProduct (Fin n)) := byrw [integral_finsetSum Finset.univ (fun k _ ↦ hid k)]simp only [integral_const_mul]_ = ∑ k, d i k * (∫ z, gibbsWeight (linearProcess c z) i *(c i k-∑ j, gibbsWeight (linearProcess c z) j*c j k) ∂gaussianProduct (Fin n)) := bysimp only [gaussian_coordinate_gibbsWeight]_ = ∫ z, ∑ k, d i k * (gibbsWeight (linearProcess c z) i *(c i k-∑ j, gibbsWeight (linearProcess c z) j*c j k)) ∂gaussianProduct (Fin n) := byrw [integral_finsetSum Finset.univ (fun k _ ↦ hic k)]simp only [integral_const_mul]_ = _ := byapply integral_congr_aeapply Eventually.of_forallintro zsimp only [mul_sub,Finset.sum_sub_distrib,Finset.mul_sum]congr 1· apply Finset.sum_congr rfl; intro k _; ring· rw [Finset.sum_comm]apply Finset.sum_congr rfl; intro j _apply Finset.sum_congr rfl; intro k _; ringlemma weighted_covariance_pairs {ι : Type*} [Fintype ι] (p : ι → ℝ) (D : ι → ι → ℝ)(hp : ∑ i, p i = 1) :∑ i, p i*(D i i-∑ j, p j*D i j) =(1/2 : ℝ)*∑ i, ∑ j, p i*p j*(D i i+D j j-D i j-D j i) := byhave h1 : (∑ i, ∑ j, p i*p j*D i i) = ∑ i, p i*D i i := byapply Finset.sum_congr rflintro i _calc_ = p i*D i i*∑ j, p j := by rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro j _; ring_ = _ := by rw [hp,mul_one]have h2 : (∑ i, ∑ j, p i*p j*D j j) = ∑ j, p j*D j j := byrw [Finset.sum_comm]apply Finset.sum_congr rflintro j _calc_ = (∑ i, p i)*(p j*D j j) := by rw [Finset.sum_mul]; apply Finset.sum_congr rfl; intro i _; ring_ = _ := by rw [hp,one_mul]have h3 : (∑ i, ∑ j, p i*p j*D j i) = ∑ i, ∑ j, p i*p j*D i j := byrw [Finset.sum_comm]apply Finset.sum_congr rfl; intro i _apply Finset.sum_congr rfl; intro j _; ringhave hl : (∑ i, p i*(D i i-∑ j, p j*D i j)) =(∑ i, p i*D i i) - ∑ i, ∑ j, p i*p j*D i j := bysimp only [mul_sub,Finset.sum_sub_distrib,Finset.mul_sum,mul_assoc]have hr : (∑ i, ∑ j, p i*p j*(D i i+D j j-D i j-D j i)) =2*(∑ i, p i*D i i)-2*(∑ i, ∑ j, p i*p j*D i j) := bysimp only [mul_sub,mul_add,Finset.sum_sub_distrib,Finset.sum_add_distrib]rw [h1,h2,h3]ringrw [hl,hr]ringend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161import Mathlibimport OAI.Probability.SKValue.GroundState.LiteralLowerimport OAI.Probability.SKValue.GroundState.GaussianTreenamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma treeAux_tensor_distance (n : ℕ) (T : GaussianTree) (hT : ValidTreeGrid 0 T)(α β : TreeLeaves T) :(∑ e,(leafAuxCoeff n (treeFieldVector 0 T) α e-leafAuxCoeff n (treeFieldVector 0 T) β e)^2)=∑ e,(treeAuxVector n 0 T α e-treeAuxVector n 0 T β e)^2 := byrw [sq_distance_sum,leafAux_sq n _ (treeField_unit T hT),leafAux_sq n _ (treeField_unit T hT),leafAux_inner,treeField_inner 0 T hT,treeAux_distance n T hT]ringlemma expected_treeAux_eq_tensor (n : ℕ) (T : GaussianTree) (hT : ValidTreeGrid 0 T)(d : TreeLeaves T → ℝ) :(∫ z,finiteMaximum (fun α ↦ linearProcess (treeAuxVector n 0 T) z α+d α)∂gaussianProduct (TreeEdges T))=∫ z,finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n (treeFieldVector 0 T)) z α+d α)∂gaussianProduct (TreeEdges T × TreeEdges T) := byapply le_antisymm· exact expected_affine_max_le _ _ d (fun α β ↦ (treeAux_tensor_distance n T hT α β).symm.le)· exact expected_affine_max_le _ _ d (fun α β ↦ (treeAux_tensor_distance n T hT α β).le)theorem finite_tree_guerra_upper {n : ℕ} (hn : 0 < n)(T : GaussianTree) (hT : ValidTreeGrid 0 T) (d : TreeLeaves T → ℝ) :expectedMaximum n+(∫ z,finiteMaximum (fun α ↦ linearProcess (treeAuxVector n 0 T) z α+d α)∂gaussianProduct (TreeEdges T))≤∫ z,finiteMaximum (fun α ↦ (∑ i,|leafField (treeFieldVector 0 T) z α i|)+d α)∂gaussianProduct (Fin n × TreeEdges T) := byrw [expected_treeAux_eq_tensor n T hT d]exact finite_guerra_upper hn (treeFieldVector 0 T) (treeField_unit T hT) dend SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma finiteMaximum_prod_curry_left {ι κ : Type*} [Fintype ι] [Nonempty ι][Fintype κ] [Nonempty κ] (f : ι×κ → ℝ) :finiteMaximum f=finiteMaximum (fun i ↦ finiteMaximum (fun j ↦ f (i,j))) := byapply le_antisymm· obtain ⟨p,hp⟩ := exists_finiteMaximum frw [←hp]exact (le_finiteMaximum (fun j ↦ f (p.1,j)) p.2).trans(le_finiteMaximum (fun i ↦ finiteMaximum (fun j ↦ f (i,j))) p.1)· obtain ⟨i,hi⟩ := exists_finiteMaximum (fun i ↦ finiteMaximum (fun j ↦ f (i,j)))obtain ⟨j,hj⟩ := exists_finiteMaximum (fun j ↦ f (i,j))rw [←hi,←hj]exact le_finiteMaximum f (i,j)lemma treeLinear_step (c : ℝ → TreeLevel → ℝ) (q : ℝ) (l : TreeLevel) (T : GaussianTree)(z : TreeEdges (l::T) → ℝ) (α : TreeLeaves (l::T)) :linearProcess (treePathCoeff c q (l::T)) z α=c q l*z (Sum.inl α.1)+linearProcess (treePathCoeff c l.endpoint T)(fun e ↦ z (Sum.inr (α.1,e))) α.2 := byclassicalchange (∑ e : Fin (l.branchExcess+1) ⊕ (Fin (l.branchExcess+1) × TreeEdges T),_)=_rw [Fintype.sum_sum_type,Fintype.sum_prod_type]simp only [treePathCoeff,ite_mul,zero_mul]simp [linearProcess]noncomputable def treeCenter : GaussianTree → ℝ| [] => 0| l::T => Real.log (l.branchExcess+1 : ℝ)/l.height+treeCenter Tnoncomputable def treeOffset (T : GaussianTree) (g : TreeEdges T → ℝ) (α : TreeLeaves T) : ℝ :=linearProcess (treePathCoeff (fun _ l ↦ 1/l.height) 0 T) g α-treeCenter Tlemma treePathCoeff_const_q (c : TreeLevel → ℝ) (q r : ℝ) (T : GaussianTree) :treePathCoeff (fun _ l ↦ c l) q T=treePathCoeff (fun _ l ↦ c l) r T := byinduction T with| nil => rfl| cons l T ih => funext α e; cases e <;> rfllemma treeOffset_step (l : TreeLevel) (T : GaussianTree)(g : TreeEdges (l::T) → ℝ) (α : TreeLeaves (l::T)) :treeOffset (l::T) g α=(g (Sum.inl α.1)-Real.log (l.branchExcess+1 : ℝ))/l.height+treeOffset T (fun e ↦ g (Sum.inr (α.1,e))) α.2 := byrw [treeOffset,treeLinear_step,treeCenter]rw [treePathCoeff_const_q (fun l ↦ 1/l.height) l.endpoint 0 T]simp only [treeOffset]ringnoncomputable def scalarTreeValue (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree)(z g : TreeEdges T → ℝ) : ℝ :=finiteMaximum (fun α ↦ linearProcess (treePathCoeff c q T) z α+treeOffset T g α)lemma scalarTreeValue_step (c : ℝ → TreeLevel → ℝ) (q : ℝ) (l : TreeLevel) (T : GaussianTree)(z g : TreeEdges (l::T) → ℝ) :scalarTreeValue c q (l::T) z g=finiteMaximum (fun i : Fin (l.branchExcess+1) ↦c q l*z (Sum.inl i)+scalarTreeValue c l.endpoint T(fun e ↦ z (Sum.inr (i,e))) (fun e ↦ g (Sum.inr (i,e)))+(g (Sum.inl i)-Real.log (l.branchExcess+1 : ���))/l.height) := byunfold scalarTreeValuechange finiteMaximum (fun α : Fin (l.branchExcess+1) × TreeLeaves T ↦ _)=_rw [finiteMaximum_prod_curry_left]congr 1; funext iconv_lhs =>arg 1ext αrw [treeLinear_step c q l T z (i,α),treeOffset_step l T g (i,α)]have he (a b d e : ℝ) : a+b+(d+e)=(b+e)+(a+d) := by ringconv_lhs =>arg 1ext αrw [he]dsimp onlyrw [finiteMaximum_add_const]ringnoncomputable def fieldTreeValue (n : ℕ) (q : ℝ) (T : GaussianTree) (x : Fin n → ℝ)(z : Fin n × TreeEdges T → ℝ) (g : TreeEdges T → ℝ) : ℝ :=finiteMaximum (fun α ↦ (∑ i,|x i+leafField (treeFieldVector q T) z α i|)+treeOffset T g α)lemma fieldTreeValue_step (n : ℕ) (q : ℝ) (l : TreeLevel) (T : GaussianTree) (x : Fin n → ℝ)(z : Fin n × TreeEdges (l::T) → ℝ) (g : TreeEdges (l::T) → ℝ) :fieldTreeValue n q (l::T) x z g=finiteMaximum (fun j : Fin (l.branchExcess+1) ↦fieldTreeValue n l.endpoint T (fun i ↦ x i+Real.sqrt (l.endpoint-q)*z (i,Sum.inl j))(fun p ↦ z (p.1,Sum.inr (j,p.2))) (fun e ↦ g (Sum.inr (j,e)))+(g (Sum.inl j)-Real.log (l.branchExcess+1 : ℝ))/l.height) := byhave hh (α : TreeLeaves (l::T)) (i : Fin n) :leafField (treeFieldVector q (l::T)) z α i=Real.sqrt (l.endpoint-q)*z (i,Sum.inl α.1)+leafField (treeFieldVector l.endpoint T) (fun p ↦ z (p.1,Sum.inr (α.1,p.2))) α.2 i := byexact treeLinear_step (fun q l ↦ Real.sqrt (l.endpoint-q)) q l T (fun e ↦ z (i,e)) αunfold fieldTreeValuechange finiteMaximum (fun α : Fin (l.branchExcess+1) × TreeLeaves T ↦ _)=_rw [finiteMaximum_prod_curry_left]congr 1; funext jconv_lhs =>arg 1ext αrw [treeOffset_step l T g (j,α)]simp only [hh (j,α),←add_assoc]dsimp onlyhave he (a b d : ℝ) : a+b+d=(a+d)+b := by ringconv_lhs =>arg 1ext αrw [he]rw [finiteMaximum_add_const]end SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161import Mathlibimport OAI.Probability.SKValue.GroundState.LiteralLowerimport OAI.Probability.SKValue.GroundState.GaussianTreenamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma treeAux_tensor_distance (n : ℕ) (T : GaussianTree) (hT : ValidTreeGrid 0 T)(α β : TreeLeaves T) :(∑ e,(leafAuxCoeff n (treeFieldVector 0 T) α e-leafAuxCoeff n (treeFieldVector 0 T) β e)^2)=∑ e,(treeAuxVector n 0 T α e-treeAuxVector n 0 T β e)^2 := byrw [sq_distance_sum,leafAux_sq n _ (treeField_unit T hT),leafAux_sq n _ (treeField_unit T hT),leafAux_inner,treeField_inner 0 T hT,treeAux_distance n T hT]ringlemma expected_treeAux_eq_tensor (n : ℕ) (T : GaussianTree) (hT : ValidTreeGrid 0 T)(d : TreeLeaves T → ℝ) :(∫ z,finiteMaximum (fun α ↦ linearProcess (treeAuxVector n 0 T) z α+d α)∂gaussianProduct (TreeEdges T))=∫ z,finiteMaximum (fun α ↦ linearProcess (leafAuxCoeff n (treeFieldVector 0 T)) z α+d α)∂gaussianProduct (TreeEdges T × TreeEdges T) := byapply le_antisymm· exact expected_affine_max_le _ _ d (fun α β ↦ (treeAux_tensor_distance n T hT α β).symm.le)· exact expected_affine_max_le _ _ d (fun α β ↦ (treeAux_tensor_distance n T hT α β).le)theorem finite_tree_guerra_upper {n : ℕ} (hn : 0 < n)(T : GaussianTree) (hT : ValidTreeGrid 0 T) (d : TreeLeaves T → ℝ) :expectedMaximum n+(∫ z,finiteMaximum (fun α ↦ linearProcess (treeAuxVector n 0 T) z α+d α)∂gaussianProduct (TreeEdges T))≤∫ z,finiteMaximum (fun α ↦ (∑ i,|leafField (treeFieldVector 0 T) z α i|)+d α)∂gaussianProduct (Fin n × TreeEdges T) := byrw [expected_treeAux_eq_tensor n T hT d]exact finite_guerra_upper hn (treeFieldVector 0 T) (treeField_unit T hT) dend SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma finiteMaximum_prod_curry_left {ι κ : Type*} [Fintype ι] [Nonempty ι][Fintype κ] [Nonempty κ] (f : ι×κ → ℝ) :finiteMaximum f=finiteMaximum (fun i ↦ finiteMaximum (fun j ↦ f (i,j))) := byapply le_antisymm· obtain ⟨p,hp⟩ := exists_finiteMaximum frw [←hp]exact (le_finiteMaximum (fun j ↦ f (p.1,j)) p.2).trans(le_finiteMaximum (fun i ↦ finiteMaximum (fun j ↦ f (i,j))) p.1)· obtain ⟨i,hi⟩ := exists_finiteMaximum (fun i ↦ finiteMaximum (fun j ↦ f (i,j)))obtain ⟨j,hj⟩ := exists_finiteMaximum (fun j ↦ f (i,j))rw [←hi,←hj]exact le_finiteMaximum f (i,j)lemma treeLinear_step (c : ℝ → TreeLevel → ℝ) (q : ℝ) (l : TreeLevel) (T : GaussianTree)(z : TreeEdges (l::T) → ℝ) (α : TreeLeaves (l::T)) :linearProcess (treePathCoeff c q (l::T)) z α=c q l*z (Sum.inl α.1)+linearProcess (treePathCoeff c l.endpoint T)(fun e ↦ z (Sum.inr (α.1,e))) α.2 := byclassicalchange (∑ e : Fin (l.branchExcess+1) ⊕ (Fin (l.branchExcess+1) × TreeEdges T),_)=_rw [Fintype.sum_sum_type,Fintype.sum_prod_type]simp only [treePathCoeff,ite_mul,zero_mul]simp [linearProcess]noncomputable def treeCenter : GaussianTree → ℝ| [] => 0| l::T => Real.log (l.branchExcess+1 : ℝ)/l.height+treeCenter Tnoncomputable def treeOffset (T : GaussianTree) (g : TreeEdges T → ℝ) (α : TreeLeaves T) : ℝ :=linearProcess (treePathCoeff (fun _ l ↦ 1/l.height) 0 T) g α-treeCenter Tlemma treePathCoeff_const_q (c : TreeLevel → ℝ) (q r : ℝ) (T : GaussianTree) :treePathCoeff (fun _ l ↦ c l) q T=treePathCoeff (fun _ l ↦ c l) r T := byinduction T with| nil => rfl| cons l T ih => funext α e; cases e <;> rfllemma treeOffset_step (l : TreeLevel) (T : GaussianTree)(g : TreeEdges (l::T) → ℝ) (α : TreeLeaves (l::T)) :treeOffset (l::T) g α=(g (Sum.inl α.1)-Real.log (l.branchExcess+1 : ℝ))/l.height+treeOffset T (fun e ↦ g (Sum.inr (α.1,e))) α.2 := byrw [treeOffset,treeLinear_step,treeCenter]rw [treePathCoeff_const_q (fun l ↦ 1/l.height) l.endpoint 0 T]simp only [treeOffset]ringnoncomputable def scalarTreeValue (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree)(z g : TreeEdges T → ℝ) : ℝ :=finiteMaximum (fun α ↦ linearProcess (treePathCoeff c q T) z α+treeOffset T g α)lemma scalarTreeValue_step (c : ℝ → TreeLevel → ℝ) (q : ℝ) (l : TreeLevel) (T : GaussianTree)(z g : TreeEdges (l::T) → ℝ) :scalarTreeValue c q (l::T) z g=finiteMaximum (fun i : Fin (l.branchExcess+1) ↦c q l*z (Sum.inl i)+scalarTreeValue c l.endpoint T(fun e ↦ z (Sum.inr (i,e))) (fun e ↦ g (Sum.inr (i,e)))+(g (Sum.inl i)-Real.log (l.branchExcess+1 : ℝ))/l.height) := byunfold scalarTreeValuechange finiteMaximum (fun α : Fin (l.branchExcess+1) × TreeLeaves T ↦ _)=_rw [finiteMaximum_prod_curry_left]congr 1; funext iconv_lhs =>arg 1ext αrw [treeLinear_step c q l T z (i,α),treeOffset_step l T g (i,α)]have he (a b d e : ℝ) : a+b+(d+e)=(b+e)+(a+d) := by ringconv_lhs =>arg 1ext αrw [he]dsimp onlyrw [finiteMaximum_add_const]ringnoncomputable def fieldTreeValue (n : ℕ) (q : ℝ) (T : GaussianTree) (x : Fin n → ℝ)(z : Fin n × TreeEdges T → ℝ) (g : TreeEdges T → ℝ) : ℝ :=finiteMaximum (fun α ↦ (∑ i,|x i+leafField (treeFieldVector q T) z α i|)+treeOffset T g α)lemma fieldTreeValue_step (n : ℕ) (q : ℝ) (l : TreeLevel) (T : GaussianTree) (x : Fin n → ℝ)(z : Fin n × TreeEdges (l::T) → ℝ) (g : TreeEdges (l::T) → ℝ) :fieldTreeValue n q (l::T) x z g=finiteMaximum (fun j : Fin (l.branchExcess+1) ↦fieldTreeValue n l.endpoint T (fun i ↦ x i+Real.sqrt (l.endpoint-q)*z (i,Sum.inl j))(fun p ↦ z (p.1,Sum.inr (j,p.2))) (fun e ↦ g (Sum.inr (j,e)))+(g (Sum.inl j)-Real.log (l.branchExcess+1 : ℝ))/l.height) := byhave hh (α : TreeLeaves (l::T)) (i : Fin n) :leafField (treeFieldVector q (l::T)) z α i=Real.sqrt (l.endpoint-q)*z (i,Sum.inl α.1)+leafField (treeFieldVector l.endpoint T) (fun p ↦ z (p.1,Sum.inr (α.1,p.2))) α.2 i := byexact treeLinear_step (fun q l ↦ Real.sqrt (l.endpoint-q)) q l T (fun e ↦ z (i,e)) αunfold fieldTreeValuechange finiteMaximum (fun α : Fin (l.branchExcess+1) × TreeLeaves T ↦ _)=_rw [finiteMaximum_prod_curry_left]congr 1; funext jconv_lhs =>arg 1ext αrw [treeOffset_step l T g (j,α)]simp only [hh (j,α),←add_assoc]dsimp onlyhave he (a b d : ℝ) : a+b+d=(a+d)+b := by ringconv_lhs =>arg 1ext αrw [he]rw [finiteMaximum_add_const]end SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204import Mathlibimport OAI.Probability.SKValue.GroundState.TreeGuerraimport OAI.Probability.SKValue.GroundState.BranchLawnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma measurePreserving_finite_curry {I E A : Type*} [Fintype I] [Fintype E][MeasurableSpace A] (μ : Measure A) [IsProbabilityMeasure μ] :MeasurePreserving (fun z : I×E → A ↦ fun i e ↦ z (i,e))(Measure.pi (fun _ ↦ μ)) (Measure.pi (fun _ : I ↦ Measure.pi (fun _ : E ↦ μ))) := byrefine ⟨by fun_prop,?_⟩have h := Measure.infinitePi_map_curry (fun (_ : I) (_ : E) ↦ μ)simp only [Measure.infinitePi_eq_pi,MeasurableEquiv.coe_curry] at hconvert h using 1rfllemma measurePreserving_nodeBlocks {I E A : Type*} [Fintype I] [Fintype E][MeasurableSpace A] (μ : Measure A) [IsProbabilityMeasure μ] :MeasurePreserving (fun z : I⊕(I×E) → A ↦ fun i ↦ (z (Sum.inl i),fun e ↦ z (Sum.inr (i,e))))(Measure.pi (fun _ ↦ μ))(Measure.pi (fun _ : I ↦ μ.prod (Measure.pi (fun _ : E ↦ μ)))) := byhave hsum := measurePreserving_sumPiEquivProdPi (fun _ : I⊕(I×E) ↦ μ)have hc := (MeasurePreserving.id (Measure.pi (fun _ : I ↦ μ))).prod(measurePreserving_finite_curry (I := I) (E := E) μ)have hp := (measurePreserving_arrowProdEquivProdArrow A (E → A) I(fun _ ↦ μ) (fun _ ↦ Measure.pi (fun _ : E ↦ μ))).symmexact hp.comp (hc.comp hsum)lemma measurePreserving_midSwap {A B C : Type*} [MeasurableSpace A][MeasurableSpace B] [MeasurableSpace C] (μ : Measure A) (ν : Measure B) (σ : Measure C)[SFinite μ] [SFinite ν] [SFinite σ] :MeasurePreserving (fun p : (A×B)×C ↦ ((p.1.1,p.2),p.1.2))((μ.prod ν).prod σ) ((μ.prod σ).prod ν) := byhave h1 := measurePreserving_prodAssoc μ ν σhave h2 := (MeasurePreserving.id μ).prod (Measure.measurePreserving_swap (μ := ν) (ν := σ))have h3 := (measurePreserving_prodAssoc μ σ ν).symmexact h3.comp (h2.comp h1)noncomputable def gaussianAddLaw (c : ℝ) (μ : Measure ℝ) : Measure ℝ :=(standardGaussian.prod μ).map (fun p : ℝ×ℝ ↦ c*p.1+p.2)instance gaussianAddLaw_probability (c : ℝ) (μ : Measure ℝ) [IsProbabilityMeasure μ] :IsProbabilityMeasure (gaussianAddLaw c μ) := byunfold gaussianAddLawinfer_instancelemma gaussianAddLaw_integrable (c : ℝ) {μ : Measure ℝ} [IsProbabilityMeasure μ](hi : Integrable (fun x : ℝ ↦ x) μ) :Integrable (fun x : ℝ ↦ x) (gaussianAddLaw c μ) := byrw [gaussianAddLaw,integrable_map_measure (by fun_prop) (by fun_prop)]exact ((standardGaussian_integrable_id.const_mul c).comp_fst μ).add (hi.comp_snd _)lemma gaussianAddLaw_exp_integrable (c a : ℝ) {μ : Measure ℝ} [IsProbabilityMeasure μ](hi : Integrable (fun x : ℝ ↦ Real.exp (a*x)) μ) :Integrable (fun x : ℝ ↦ Real.exp (a*x)) (gaussianAddLaw c μ) := byrw [gaussianAddLaw,integrable_map_measure (by fun_prop) (by fun_prop)]have hg : Integrable (fun z : ℝ ↦ Real.exp ((a*c)*z)) standardGaussian :=integrable_exp_mul_gaussianReal (μ := 0) (v := 1) (a*c)convert hg.mul_prod hi using 1funext pdsimp only [Function.comp_def]rw [←Real.exp_add]congr 1ringlemma gaussianAddLaw_exp (c a : ℝ) {μ : Measure ℝ} [IsProbabilityMeasure μ] :(∫ x,Real.exp (a*x) ∂gaussianAddLaw c μ)=Real.exp ((a*c)^2/2)*(∫ x,Real.exp (a*x) ∂μ) := byrw [gaussianAddLaw,integral_map (by fun_prop) (by fun_prop)]have he (p : ℝ×ℝ) : Real.exp (a*(c*p.1+p.2))=Real.exp ((a*c)*p.1)*Real.exp (a*p.2) := byrw [←Real.exp_add]; congr 1; ringsimp_rw [he]rw [integral_prod_mul (fun z : ℝ ↦ Real.exp ((a*c)*z)) (fun x : ℝ ↦ Real.exp (a*x))]have heq := congrFun (mgf_fun_id_gaussianReal (μ := 0) (v := 1)) (a*c)simpa [mgf,standardGaussian] using congrArg (fun x ↦ x*(∫ x,Real.exp (a*x) ∂μ)) heqend SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGnoncomputable def edgeNoiseLaw : Measure (ℝ×ℝ) := standardGaussian.prod gumbelLawinstance edgeNoiseLaw_probability : IsProbabilityMeasure edgeNoiseLaw := byunfold edgeNoiseLaw; infer_instancenoncomputable def scalarTreeLaw (c : ℝ → TreeLevel → ℝ) (q : ℝ) : GaussianTree → Measure ℝ| [] => Measure.dirac 0| l::T => branchLaw (gaussianAddLaw (c q l) (scalarTreeLaw c l.endpoint T)) l.height l.branchExcessinstance scalarTreeLaw_probability (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :IsProbabilityMeasure (scalarTreeLaw c q T) := byinduction T generalizing q with| nil => exact inferInstanceAs (IsProbabilityMeasure (Measure.dirac (0 : ℝ)))| cons l T ih =>have := ih l.endpointexact inferInstanceAs (IsProbabilityMeasure(branchLaw (gaussianAddLaw (c q l) (scalarTreeLaw c l.endpoint T)) l.height l.branchExcess))noncomputable def scalarTreeEval (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree)(w : TreeEdges T → ℝ×ℝ) : ℝ :=scalarTreeValue c q T (fun e ↦ (w e).1) (fun e ↦ (w e).2)lemma finiteMaximum_const {I : Type*} [Fintype I] [Nonempty I] (a : ℝ) :finiteMaximum (fun _ : I ↦ a)=a := byobtain ⟨i,hi⟩ := exists_finiteMaximum (fun _ : I ↦ a)exact hi.symmlemma scalarTreeEval_nil (c : ℝ → TreeLevel → ℝ) (q : ℝ) (w : TreeEdges [] → ℝ×ℝ) :scalarTreeEval c q [] w=0 := bysimp only [scalarTreeEval,scalarTreeValue,treeOffset,treeCenter,linearProcess]simp only [show ∀ f : PEmpty → ℝ, (∑ e,f e)=0 from fun f ↦ Fintype.sum_empty f,sub_self,zero_add,finiteMaximum_const]lemma continuous_scalarTreeEval (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :Continuous (scalarTreeEval c q T) := byunfold scalarTreeEval scalarTreeValue treeOffsetapply continuous_finiteMaximum.compapply continuous_piintro αunfold linearProcessfun_proplemma marked_gaussianAddLaw {S : Type*} [MeasurableSpace S] (σ : Measure S) [IsProbabilityMeasure σ]{μ : Measure ℝ} [IsProbabilityMeasure μ] {f : S → ℝ}(hf : MeasurePreserving f σ μ) (c : ℝ) :MeasurePreserving (fun p : (ℝ×ℝ)×S ↦ (c*p.1.1+f p.2,p.1.2))(edgeNoiseLaw.prod σ) ((gaussianAddLaw c μ).prod gumbelLaw) := byhave hadd : MeasurePreserving (fun p : ℝ×ℝ ↦ c*p.1+p.2)(standardGaussian.prod μ) (gaussianAddLaw c μ) := ⟨by fun_prop,rfl⟩exact ((hadd.prod (MeasurePreserving.id gumbelLaw)).comp(((MeasurePreserving.id standardGaussian).prod hf).prod (MeasurePreserving.id gumbelLaw))).comp(measurePreserving_midSwap standardGaussian gumbelLaw σ)lemma scalarTreeEval_step (c : ℝ → TreeLevel → ℝ) (q : ℝ) (l : TreeLevel) (T : GaussianTree)(w : TreeEdges (l::T) → ℝ×ℝ) :scalarTreeEval c q (l::T) w=branchMax l.height l.branchExcess((fun i ↦ c q l*(w (Sum.inl i)).1+scalarTreeEval c l.endpoint T (fun e ↦ w (Sum.inr (i,e)))),fun i ↦ (w (Sum.inl i)).2) := byrw [scalarTreeEval,scalarTreeValue_step]unfold branchMaxhave he (i : Fin (l.branchExcess+1)) :c q l*(w (Sum.inl i)).1+scalarTreeEval c l.endpoint T (fun e ↦ w (Sum.inr (i,e)))+((w (Sum.inl i)).2-Real.log (l.branchExcess+1 : ℝ))/l.height=(c q l*(w (Sum.inl i)).1+scalarTreeEval c l.endpoint T (fun e ↦ w (Sum.inr (i,e)))+(w (Sum.inl i)).2/l.height)+(-Real.log (l.branchExcess+1 : ℝ)/l.height) := by ringchange finiteMaximum (fun i ↦ c q l*(w (Sum.inl i)).1+scalarTreeEval c l.endpoint T (fun e ↦ w (Sum.inr (i,e)))+((w (Sum.inl i)).2-Real.log (l.branchExcess+1 : ℝ))/l.height)=_conv_lhs => arg 1; ext i; rw [he i]rw [finiteMaximum_add_const]ringtheorem scalarTreeEval_law (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :MeasurePreserving (scalarTreeEval c q T) (Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw))(scalarTreeLaw c q T) := byinduction T generalizing q with| nil =>have he : scalarTreeEval c q []=fun _ ↦ (0 : ℝ) := funext (scalarTreeEval_nil c q)rw [he,scalarTreeLaw]exact ⟨measurable_const,by simp⟩| cons l T ih =>let ν := gaussianAddLaw (c q l) (scalarTreeLaw c l.endpoint T)have hblock := measurePreserving_nodeBlocks (I := Fin (l.branchExcess+1)) (E := TreeEdges T) edgeNoiseLawhave hchild := marked_gaussianAddLaw (Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw)) (ih l.endpoint) (c q l)have hchildren := measurePreserving_pi (fun _ : Fin (l.branchExcess+1) ↦edgeNoiseLaw.prod (Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw)))(fun _ ↦ ν.prod gumbelLaw) (fun _ ↦ hchild)have hpair := measurePreserving_arrowProdEquivProdArrow ℝ ℝ (Fin (l.branchExcess+1))(fun _ ↦ ν) (fun _ ↦ gumbelLaw)have hmax : MeasurePreserving (branchMax l.height l.branchExcess)((Measure.pi (fun _ : Fin (l.branchExcess+1) ↦ ν)).prod(Measure.pi (fun _ : Fin (l.branchExcess+1) ↦ gumbelLaw)))(scalarTreeLaw c q (l::T)) := ⟨(continuous_branchMax _ _).measurable,rfl⟩have hall := hmax.comp (hpair.comp (hchildren.comp hblock))convert hall using 1funext wexact scalarTreeEval_step c q l T wlemma scalarTreeLaw_integrable (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :Integrable (fun x : ℝ ↦ x) (scalarTreeLaw c q T) := byinduction T generalizing q with| nil =>change Integrable (fun x : ℝ ↦ x) (Measure.dirac (0 : ℝ))exact integrable_dirac (by simp)| cons l T ih => exact branchLaw_integrable (gaussianAddLaw_integrable _ (ih l.endpoint)) _ _end SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204import Mathlibimport OAI.Probability.SKValue.GroundState.TreeGuerraimport OAI.Probability.SKValue.GroundState.BranchLawnamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma measurePreserving_finite_curry {I E A : Type*} [Fintype I] [Fintype E][MeasurableSpace A] (μ : Measure A) [IsProbabilityMeasure μ] :MeasurePreserving (fun z : I×E → A ↦ fun i e ↦ z (i,e))(Measure.pi (fun _ ↦ μ)) (Measure.pi (fun _ : I ↦ Measure.pi (fun _ : E ↦ μ))) := byrefine ⟨by fun_prop,?_⟩have h := Measure.infinitePi_map_curry (fun (_ : I) (_ : E) ↦ μ)simp only [Measure.infinitePi_eq_pi,MeasurableEquiv.coe_curry] at hconvert h using 1rfllemma measurePreserving_nodeBlocks {I E A : Type*} [Fintype I] [Fintype E][MeasurableSpace A] (μ : Measure A) [IsProbabilityMeasure μ] :MeasurePreserving (fun z : I⊕(I×E) → A ↦ fun i ↦ (z (Sum.inl i),fun e ↦ z (Sum.inr (i,e))))(Measure.pi (fun _ ↦ μ))(Measure.pi (fun _ : I ↦ μ.prod (Measure.pi (fun _ : E ↦ μ)))) := byhave hsum := measurePreserving_sumPiEquivProdPi (fun _ : I⊕(I×E) ↦ μ)have hc := (MeasurePreserving.id (Measure.pi (fun _ : I ↦ μ))).prod(measurePreserving_finite_curry (I := I) (E := E) μ)have hp := (measurePreserving_arrowProdEquivProdArrow A (E → A) I(fun _ ↦ μ) (fun _ ↦ Measure.pi (fun _ : E ↦ μ))).symmexact hp.comp (hc.comp hsum)lemma measurePreserving_midSwap {A B C : Type*} [MeasurableSpace A][MeasurableSpace B] [MeasurableSpace C] (μ : Measure A) (ν : Measure B) (σ : Measure C)[SFinite μ] [SFinite ν] [SFinite σ] :MeasurePreserving (fun p : (A×B)×C ↦ ((p.1.1,p.2),p.1.2))((μ.prod ν).prod σ) ((μ.prod σ).prod ν) := byhave h1 := measurePreserving_prodAssoc μ ν σhave h2 := (MeasurePreserving.id μ).prod (Measure.measurePreserving_swap (μ := ν) (ν := σ))have h3 := (measurePreserving_prodAssoc μ σ ν).symmexact h3.comp (h2.comp h1)noncomputable def gaussianAddLaw (c : ℝ) (μ : Measure ℝ) : Measure ℝ :=(standardGaussian.prod μ).map (fun p : ℝ×ℝ ↦ c*p.1+p.2)instance gaussianAddLaw_probability (c : ℝ) (μ : Measure ℝ) [IsProbabilityMeasure μ] :IsProbabilityMeasure (gaussianAddLaw c μ) := byunfold gaussianAddLawinfer_instancelemma gaussianAddLaw_integrable (c : ℝ) {μ : Measure ℝ} [IsProbabilityMeasure μ](hi : Integrable (fun x : ℝ ↦ x) μ) :Integrable (fun x : ℝ ↦ x) (gaussianAddLaw c μ) := byrw [gaussianAddLaw,integrable_map_measure (by fun_prop) (by fun_prop)]exact ((standardGaussian_integrable_id.const_mul c).comp_fst μ).add (hi.comp_snd _)lemma gaussianAddLaw_exp_integrable (c a : ℝ) {μ : Measure ℝ} [IsProbabilityMeasure μ](hi : Integrable (fun x : ℝ ↦ Real.exp (a*x)) μ) :Integrable (fun x : ℝ ↦ Real.exp (a*x)) (gaussianAddLaw c μ) := byrw [gaussianAddLaw,integrable_map_measure (by fun_prop) (by fun_prop)]have hg : Integrable (fun z : ℝ ↦ Real.exp ((a*c)*z)) standardGaussian :=integrable_exp_mul_gaussianReal (μ := 0) (v := 1) (a*c)convert hg.mul_prod hi using 1funext pdsimp only [Function.comp_def]rw [←Real.exp_add]congr 1ringlemma gaussianAddLaw_exp (c a : ℝ) {μ : Measure ℝ} [IsProbabilityMeasure μ] :(∫ x,Real.exp (a*x) ∂gaussianAddLaw c μ)=Real.exp ((a*c)^2/2)*(∫ x,Real.exp (a*x) ∂μ) := byrw [gaussianAddLaw,integral_map (by fun_prop) (by fun_prop)]have he (p : ℝ×ℝ) : Real.exp (a*(c*p.1+p.2))=Real.exp ((a*c)*p.1)*Real.exp (a*p.2) := byrw [←Real.exp_add]; congr 1; ringsimp_rw [he]rw [integral_prod_mul (fun z : ℝ ↦ Real.exp ((a*c)*z)) (fun x : ℝ ↦ Real.exp (a*x))]have heq := congrFun (mgf_fun_id_gaussianReal (μ := 0) (v := 1)) (a*c)simpa [mgf,standardGaussian] using congrArg (fun x ↦ x*(∫ x,Real.exp (a*x) ∂μ)) heqend SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGnoncomputable def edgeNoiseLaw : Measure (ℝ×ℝ) := standardGaussian.prod gumbelLawinstance edgeNoiseLaw_probability : IsProbabilityMeasure edgeNoiseLaw := byunfold edgeNoiseLaw; infer_instancenoncomputable def scalarTreeLaw (c : ℝ → TreeLevel → ℝ) (q : ℝ) : GaussianTree → Measure ℝ| [] => Measure.dirac 0| l::T => branchLaw (gaussianAddLaw (c q l) (scalarTreeLaw c l.endpoint T)) l.height l.branchExcessinstance scalarTreeLaw_probability (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :IsProbabilityMeasure (scalarTreeLaw c q T) := byinduction T generalizing q with| nil => exact inferInstanceAs (IsProbabilityMeasure (Measure.dirac (0 : ℝ)))| cons l T ih =>have := ih l.endpointexact inferInstanceAs (IsProbabilityMeasure(branchLaw (gaussianAddLaw (c q l) (scalarTreeLaw c l.endpoint T)) l.height l.branchExcess))noncomputable def scalarTreeEval (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree)(w : TreeEdges T → ℝ×ℝ) : ℝ :=scalarTreeValue c q T (fun e ↦ (w e).1) (fun e ↦ (w e).2)lemma finiteMaximum_const {I : Type*} [Fintype I] [Nonempty I] (a : ℝ) :finiteMaximum (fun _ : I ↦ a)=a := byobtain ⟨i,hi⟩ := exists_finiteMaximum (fun _ : I ↦ a)exact hi.symmlemma scalarTreeEval_nil (c : ℝ → TreeLevel → ℝ) (q : ℝ) (w : TreeEdges [] → ℝ×ℝ) :scalarTreeEval c q [] w=0 := bysimp only [scalarTreeEval,scalarTreeValue,treeOffset,treeCenter,linearProcess]simp only [show ∀ f : PEmpty → ℝ, (∑ e,f e)=0 from fun f ↦ Fintype.sum_empty f,sub_self,zero_add,finiteMaximum_const]lemma continuous_scalarTreeEval (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :Continuous (scalarTreeEval c q T) := byunfold scalarTreeEval scalarTreeValue treeOffsetapply continuous_finiteMaximum.compapply continuous_piintro αunfold linearProcessfun_proplemma marked_gaussianAddLaw {S : Type*} [MeasurableSpace S] (σ : Measure S) [IsProbabilityMeasure σ]{μ : Measure ℝ} [IsProbabilityMeasure μ] {f : S → ℝ}(hf : MeasurePreserving f σ μ) (c : ℝ) :MeasurePreserving (fun p : (ℝ×ℝ)×S ↦ (c*p.1.1+f p.2,p.1.2))(edgeNoiseLaw.prod σ) ((gaussianAddLaw c μ).prod gumbelLaw) := byhave hadd : MeasurePreserving (fun p : ℝ×ℝ ↦ c*p.1+p.2)(standardGaussian.prod μ) (gaussianAddLaw c μ) := ⟨by fun_prop,rfl⟩exact ((hadd.prod (MeasurePreserving.id gumbelLaw)).comp(((MeasurePreserving.id standardGaussian).prod hf).prod (MeasurePreserving.id gumbelLaw))).comp(measurePreserving_midSwap standardGaussian gumbelLaw σ)lemma scalarTreeEval_step (c : ℝ → TreeLevel → ℝ) (q : ℝ) (l : TreeLevel) (T : GaussianTree)(w : TreeEdges (l::T) → ℝ×ℝ) :scalarTreeEval c q (l::T) w=branchMax l.height l.branchExcess((fun i ↦ c q l*(w (Sum.inl i)).1+scalarTreeEval c l.endpoint T (fun e ↦ w (Sum.inr (i,e)))),fun i ↦ (w (Sum.inl i)).2) := byrw [scalarTreeEval,scalarTreeValue_step]unfold branchMaxhave he (i : Fin (l.branchExcess+1)) :c q l*(w (Sum.inl i)).1+scalarTreeEval c l.endpoint T (fun e ↦ w (Sum.inr (i,e)))+((w (Sum.inl i)).2-Real.log (l.branchExcess+1 : ℝ))/l.height=(c q l*(w (Sum.inl i)).1+scalarTreeEval c l.endpoint T (fun e ↦ w (Sum.inr (i,e)))+(w (Sum.inl i)).2/l.height)+(-Real.log (l.branchExcess+1 : ℝ)/l.height) := by ringchange finiteMaximum (fun i ↦ c q l*(w (Sum.inl i)).1+scalarTreeEval c l.endpoint T (fun e ↦ w (Sum.inr (i,e)))+((w (Sum.inl i)).2-Real.log (l.branchExcess+1 : ℝ))/l.height)=_conv_lhs => arg 1; ext i; rw [he i]rw [finiteMaximum_add_const]ringtheorem scalarTreeEval_law (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :MeasurePreserving (scalarTreeEval c q T) (Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw))(scalarTreeLaw c q T) := byinduction T generalizing q with| nil =>have he : scalarTreeEval c q []=fun _ ↦ (0 : ℝ) := funext (scalarTreeEval_nil c q)rw [he,scalarTreeLaw]exact ⟨measurable_const,by simp⟩| cons l T ih =>let ν := gaussianAddLaw (c q l) (scalarTreeLaw c l.endpoint T)have hblock := measurePreserving_nodeBlocks (I := Fin (l.branchExcess+1)) (E := TreeEdges T) edgeNoiseLawhave hchild := marked_gaussianAddLaw (Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw)) (ih l.endpoint) (c q l)have hchildren := measurePreserving_pi (fun _ : Fin (l.branchExcess+1) ↦edgeNoiseLaw.prod (Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw)))(fun _ ↦ ν.prod gumbelLaw) (fun _ ↦ hchild)have hpair := measurePreserving_arrowProdEquivProdArrow ℝ ℝ (Fin (l.branchExcess+1))(fun _ ↦ ν) (fun _ ↦ gumbelLaw)have hmax : MeasurePreserving (branchMax l.height l.branchExcess)((Measure.pi (fun _ : Fin (l.branchExcess+1) ↦ ν)).prod(Measure.pi (fun _ : Fin (l.branchExcess+1) ↦ gumbelLaw)))(scalarTreeLaw c q (l::T)) := ⟨(continuous_branchMax _ _).measurable,rfl⟩have hall := hmax.comp (hpair.comp (hchildren.comp hblock))convert hall using 1funext wexact scalarTreeEval_step c q l T wlemma scalarTreeLaw_integrable (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :Integrable (fun x : ℝ ↦ x) (scalarTreeLaw c q T) := byinduction T generalizing q with| nil =>change Integrable (fun x : ℝ ↦ x) (Measure.dirac (0 : ℝ))exact integrable_dirac (by simp)| cons l T ih => exact branchLaw_integrable (gaussianAddLaw_integrable _ (ih l.endpoint)) _ _end SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119import Mathlibimport OAI.Probability.SKValue.GroundState.BranchMeanUppernamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGnoncomputable def auxAmplitude (n : ℕ) (q : ℝ) (l : TreeLevel) : ℝ :=Real.sqrt ((n : ℝ)/2)*Real.sqrt (l.endpoint^2-q^2)noncomputable def auxShape (n : ℕ) (q : ℝ) : GaussianTree → CascadeShape| [] => []| l::T => (auxAmplitude n q l,l.height)::auxShape n l.endpoint Tnoncomputable def resizeTree (n : ℕ) (q : ℝ) : (T : GaussianTree) → CascadeWidths (auxShape n q T) → GaussianTree| [],_ => []| l::T,w => {l with branchExcess := w.1}::resizeTree n l.endpoint T w.2lemma resizeTree_valid (n : ℕ) {q : ℝ} {T : GaussianTree} (h : ValidTreeGrid q T)(w : CascadeWidths (auxShape n q T)) : ValidTreeGrid q (resizeTree n q T w) := byinduction T generalizing q with| nil => exact h| cons l T ih => exact ⟨h.1,ih h.2 w.2⟩lemma resizeTree_scale (n : ℕ) (q : ℝ) {a : ℝ} {T : GaussianTree} (h : TreeScale a T)(w : CascadeWidths (auxShape n q T)) : TreeScale a (resizeTree n q T w) := byinduction T generalizing a q with| nil => exact h| cons l T ih => exact ⟨h.1,h.2.1,ih _ h.2.2 w.2⟩lemma auxShape_scale (n : ℕ) (q : ℝ) {a : ℝ} {T : GaussianTree} (h : TreeScale a T) :CascadeScale a (auxShape n q T) := byinduction T generalizing a q with| nil => exact h| cons l T ih => exact ⟨h.1,h.2.1,ih _ h.2.2⟩lemma resizeTree_profile (n : ℕ) (q : ℝ) (T : GaussianTree) (w : CascadeWidths (auxShape n q T)) :fieldProfile q (resizeTree n q T w)=fieldProfile q T := byinduction T generalizing q with| nil => rfl| cons l T ih => simp only [resizeTree,fieldProfile,ih]lemma resizeTree_gumbelMoment (n : ℕ) (q a : ℝ) (T : GaussianTree) (w : CascadeWidths (auxShape n q T)) :gumbelTreeMoment a (resizeTree n q T w)=gumbelTreeMoment a T := byinduction T generalizing q a with| nil => rfl| cons l T ih => simp only [resizeTree,gumbelTreeMoment,ih]lemma resizeTree_gumbelMean (n : ℕ) (q : ℝ) (T : GaussianTree) (w : CascadeWidths (auxShape n q T)) :gumbelTreeMean (resizeTree n q T w)=gumbelTreeMean T := bycases T with| nil => rfl| cons l T => simp only [resizeTree,gumbelTreeMean,resizeTree_gumbelMoment]lemma resizeTree_scalarLaw (n : ℕ) (q : ℝ) (T : GaussianTree) (w : CascadeWidths (auxShape n q T)) :scalarTreeLaw (auxAmplitude n) q (resizeTree n q T w)=cascadeLaw (auxShape n q T) w := byinduction T generalizing q with| nil => rfl| cons l T ih => simp only [resizeTree,scalarTreeLaw,auxShape,cascadeLaw,ih,auxAmplitude]noncomputable def treeCorrection (q : ℝ) : GaussianTree → ℝ| [] => 0| l::T => l.height*(l.endpoint^2-q^2)/4+treeCorrection l.endpoint Tlemma auxAmplitude_sq (n : ℕ) {q : ℝ} {l : TreeLevel} (hq : 0 ≤ q) (hql : q ≤ l.endpoint) :(auxAmplitude n q l)^2=(n : ℝ)/2*(l.endpoint^2-q^2) := byhave hl := hq.trans hqlhave hs : 0 ≤ l.endpoint^2-q^2 := by nlinarithrw [auxAmplitude,mul_pow,Real.sq_sqrt (by positivity),Real.sq_sqrt hs]lemma auxShape_moment (n : ℕ) {q a : ℝ} {T : GaussianTree} (hq : 0 ≤ q)(hgrid : ValidTreeGrid q T) (h : TreeScale a T) :cascadeMoment a (auxShape n q T)=gumbelTreeMoment a T*Real.exp (a*(n : ℝ)*treeCorrection q T) := byinduction T generalizing q a with| nil => simp [auxShape,cascadeMoment,gumbelTreeMoment,treeCorrection]| cons l T ih =>obtain ⟨ha,ham,hT⟩ := hhave hm : 0 < l.height := ha.trans_lt hamhave hs := auxAmplitude_sq n hq hgrid.1rw [auxShape,cascadeMoment,ih (hq.trans hgrid.1) hgrid.2 hT]rw [mul_pow,hs]have he : Real.exp (l.height^2*((n : ℝ)/2*(l.endpoint^2-q^2))/2)*(gumbelTreeMoment l.height T*Real.exp (l.height*(n : ℝ)*treeCorrection l.endpoint T))=gumbelTreeMoment l.height T*Real.exp (l.height*(n : ℝ)*treeCorrection q (l::T)) := byrw [mul_left_comm,←Real.exp_add]congr 2simp only [treeCorrection]ringrw [he,Real.mul_rpow (gumbelTreeMoment_pos hT).le (Real.exp_pos _).le,←Real.exp_mul]have he2 : l.height*(n : ℝ)*treeCorrection q (l::T)*(a/l.height)=a*(n : ℝ)*treeCorrection q (l::T) := byfield_simprw [he2]simp only [gumbelTreeMoment,mul_assoc]lemma auxShape_mean (n : ℕ) {q : ℝ} {T : GaussianTree} (hq : 0 ≤ q)(hgrid : ValidTreeGrid q T) (h : TreeScale 0 T) :cascadeMean (auxShape n q T)=gumbelTreeMean T+(n : ℝ)*treeCorrection q T := bycases T with| nil => simp [auxShape,cascadeMean,gumbelTreeMean,treeCorrection]| cons l T =>obtain ⟨_,hm,hT⟩ := hhave hs := auxAmplitude_sq n hq hgrid.1rw [auxShape,cascadeMean,auxShape_moment n (hq.trans hgrid.1) hgrid.2 hT]rw [Real.log_mul (Real.exp_pos _).ne' (mul_pos (gumbelTreeMoment_pos hT) (Real.exp_pos _)).ne',Real.log_exp,Real.log_mul (gumbelTreeMoment_pos hT).ne' (Real.exp_pos _).ne',Real.log_exp]rw [mul_pow,hs]simp only [gumbelTreeMean,treeCorrection]field_simpringend SKValueGendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119import Mathlibimport OAI.Probability.SKValue.GroundState.BranchMeanUppernamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGnoncomputable def auxAmplitude (n : ℕ) (q : ℝ) (l : TreeLevel) : ℝ :=Real.sqrt ((n : ℝ)/2)*Real.sqrt (l.endpoint^2-q^2)noncomputable def auxShape (n : ℕ) (q : ℝ) : GaussianTree → CascadeShape| [] => []| l::T => (auxAmplitude n q l,l.height)::auxShape n l.endpoint Tnoncomputable def resizeTree (n : ℕ) (q : ℝ) : (T : GaussianTree) → CascadeWidths (auxShape n q T) → GaussianTree| [],_ => []| l::T,w => {l with branchExcess := w.1}::resizeTree n l.endpoint T w.2lemma resizeTree_valid (n : ℕ) {q : ℝ} {T : GaussianTree} (h : ValidTreeGrid q T)(w : CascadeWidths (auxShape n q T)) : ValidTreeGrid q (resizeTree n q T w) := byinduction T generalizing q with| nil => exact h| cons l T ih => exact ⟨h.1,ih h.2 w.2⟩lemma resizeTree_scale (n : ℕ) (q : ℝ) {a : ℝ} {T : GaussianTree} (h : TreeScale a T)(w : CascadeWidths (auxShape n q T)) : TreeScale a (resizeTree n q T w) := byinduction T generalizing a q with| nil => exact h| cons l T ih => exact ⟨h.1,h.2.1,ih _ h.2.2 w.2⟩lemma auxShape_scale (n : ℕ) (q : ℝ) {a : ℝ} {T : GaussianTree} (h : TreeScale a T) :CascadeScale a (auxShape n q T) := byinduction T generalizing a q with| nil => exact h| cons l T ih => exact ⟨h.1,h.2.1,ih _ h.2.2⟩lemma resizeTree_profile (n : ℕ) (q : ℝ) (T : GaussianTree) (w : CascadeWidths (auxShape n q T)) :fieldProfile q (resizeTree n q T w)=fieldProfile q T := byinduction T generalizing q with| nil => rfl| cons l T ih => simp only [resizeTree,fieldProfile,ih]lemma resizeTree_gumbelMoment (n : ℕ) (q a : ℝ) (T : GaussianTree) (w : CascadeWidths (auxShape n q T)) :gumbelTreeMoment a (resizeTree n q T w)=gumbelTreeMoment a T := byinduction T generalizing q a with| nil => rfl| cons l T ih => simp only [resizeTree,gumbelTreeMoment,ih]lemma resizeTree_gumbelMean (n : ℕ) (q : ℝ) (T : GaussianTree) (w : CascadeWidths (auxShape n q T)) :gumbelTreeMean (resizeTree n q T w)=gumbelTreeMean T := bycases T with| nil => rfl| cons l T => simp only [resizeTree,gumbelTreeMean,resizeTree_gumbelMoment]lemma resizeTree_scalarLaw (n : ℕ) (q : ℝ) (T : GaussianTree) (w : CascadeWidths (auxShape n q T)) :scalarTreeLaw (auxAmplitude n) q (resizeTree n q T w)=cascadeLaw (auxShape n q T) w := byinduction T generalizing q with| nil => rfl| cons l T ih => simp only [resizeTree,scalarTreeLaw,auxShape,cascadeLaw,ih,auxAmplitude]noncomputable def treeCorrection (q : ℝ) : GaussianTree → ℝ| [] => 0| l::T => l.height*(l.endpoint^2-q^2)/4+treeCorrection l.endpoint Tlemma auxAmplitude_sq (n : ℕ) {q : ℝ} {l : TreeLevel} (hq : 0 ≤ q) (hql : q ≤ l.endpoint) :(auxAmplitude n q l)^2=(n : ℝ)/2*(l.endpoint^2-q^2) := byhave hl := hq.trans hqlhave hs : 0 ≤ l.endpoint^2-q^2 := by nlinarithrw [auxAmplitude,mul_pow,Real.sq_sqrt (by positivity),Real.sq_sqrt hs]lemma auxShape_moment (n : ℕ) {q a : ℝ} {T : GaussianTree} (hq : 0 ≤ q)(hgrid : ValidTreeGrid q T) (h : TreeScale a T) :cascadeMoment a (auxShape n q T)=gumbelTreeMoment a T*Real.exp (a*(n : ℝ)*treeCorrection q T) := byinduction T generalizing q a with| nil => simp [auxShape,cascadeMoment,gumbelTreeMoment,treeCorrection]| cons l T ih =>obtain ⟨ha,ham,hT⟩ := hhave hm : 0 < l.height := ha.trans_lt hamhave hs := auxAmplitude_sq n hq hgrid.1rw [auxShape,cascadeMoment,ih (hq.trans hgrid.1) hgrid.2 hT]rw [mul_pow,hs]have he : Real.exp (l.height^2*((n : ℝ)/2*(l.endpoint^2-q^2))/2)*(gumbelTreeMoment l.height T*Real.exp (l.height*(n : ℝ)*treeCorrection l.endpoint T))=gumbelTreeMoment l.height T*Real.exp (l.height*(n : ℝ)*treeCorrection q (l::T)) := byrw [mul_left_comm,←Real.exp_add]congr 2simp only [treeCorrection]ringrw [he,Real.mul_rpow (gumbelTreeMoment_pos hT).le (Real.exp_pos _).le,←Real.exp_mul]have he2 : l.height*(n : ℝ)*treeCorrection q (l::T)*(a/l.height)=a*(n : ℝ)*treeCorrection q (l::T) := byfield_simprw [he2]simp only [gumbelTreeMoment,mul_assoc]lemma auxShape_mean (n : ℕ) {q : ℝ} {T : GaussianTree} (hq : 0 ≤ q)(hgrid : ValidTreeGrid q T) (h : TreeScale 0 T) :cascadeMean (auxShape n q T)=gumbelTreeMean T+(n : ℝ)*treeCorrection q T := bycases T with| nil => simp [auxShape,cascadeMean,gumbelTreeMean,treeCorrection]| cons l T =>obtain ⟨_,hm,hT⟩ := hhave hs := auxAmplitude_sq n hq hgrid.1rw [auxShape,cascadeMean,auxShape_moment n (hq.trans hgrid.1) hgrid.2 hT]rw [Real.log_mul (Real.exp_pos _).ne' (mul_pos (gumbelTreeMoment_pos hT) (Real.exp_pos _)).ne',Real.log_exp,Real.log_mul (gumbelTreeMoment_pos hT).ne' (Real.exp_pos _).ne',Real.log_exp]rw [mul_pow,hs]simp only [gumbelTreeMean,treeCorrection]field_simpringend SKValueGendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import Mathlibimport OAI.Probability.SKValue.GroundState.CascadePassageimport OAI.Probability.SKValue.Equations.StrictProfilenamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma profile_penalty_mono (ε : ℝ≥0) (k : ℕ) {l : SKValue.HeatProfile}(hT : SKValue.profileTime l=1) :(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t) ≤∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff (SKValue.liftProfile ε k l) t := byhave h1 := profile_weighted_integrable 0 lhave h2 := profile_weighted_integrable 0 (SKValue.liftProfile ε k l)simp only [zero_add,SKValue.liftProfile_time,hT] at h1 h2apply intervalIntegral.integral_mono_on (by norm_num) h1 h2intro t htexact mul_le_mul_of_nonneg_left (SKValue.liftProfile_coeff_lower ε k l t) ht.1lemma weak_profile_guerra_upper (W : SKValue.BrownianSpace) {n : ℕ} (hn : 0<n){ψ : ℝ → ℝ} (hψ : SKValue.SmoothTerminal ψ) (hb : ∀ x,|x|≤ψ x){l : SKValue.HeatProfile} (hl : l.Pairwise (fun p r ↦ p.2≤r.2)) (hT : SKValue.profileTime l=1) :expectedMaximum n ≤ (n : ℝ)*(SKValue.profileValue ψ l 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t)) := byhave he : ∀ ε : ℝ,0<ε → expectedMaximum n ≤ (n : ℝ)*(SKValue.profileValue ψ l 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t)+(3/2 : ℝ)*ε*(1+l.length)) := byintro ε hεlet e : ℝ≥0 := ⟨ε,hε.le⟩have hepos : 0<e := hεhave hs := profileTree_scale (q := 0) (by norm_num : (0 : ℝ)≤0)(SKValue.liftProfile_strict hepos 1 hl) (SKValue.liftProfile_positive hepos (by norm_num : 0<1) l)have hg := profileTree_valid (q := 0) (l := SKValue.liftProfile e 1 l)(by rw [zero_add,SKValue.liftProfile_time,hT])have hu := finite_step_guerra_upper hn _ hg hshave hv := profileTree_le_smooth hψ hb hs 0have hvb := abs_le.mp (hψ.liftProfile_bound W hl hT hepos 1 0)have hc := profile_penalty_mono e 1 hTrw [profileTree_correction] at husimp only [SKValue.liftProfile_time,hT,zero_add] at huhave hnn : (0 : ℝ)≤n := by positivityhave hvb' : SKValue.profileValue ψ (SKValue.liftProfile e 1 l) 0 0-SKValue.profileValue ψ l 0 0 ≤(3/2 : ℝ)*ε*(1+l.length) := byhave h := hvb.2have hcoe : (e : ℝ)=ε := rflrw [Nat.cast_one,hcoe] at hexact happly hu.transapply mul_le_mul_of_nonneg_left _ hnnlinarithhave hh : Tendsto (fun j : ℕ ↦ (n : ℝ)*(SKValue.profileValue ψ l 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t)+(3/2 : ℝ)*(1/(j+1 : ℝ))*(1+l.length))) atTop(𝓝 ((n : ℝ)*(SKValue.profileValue ψ l 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t)))) := byhave hr : Tendsto (fun j : ℕ ↦ (3/2 : ℝ)*(1/(j+1 : ℝ))*(1+l.length)) atTop (𝓝 0) := bysimpa only [mul_zero,zero_mul] using(tendsto_one_div_add_atTop_nhds_zero_nat.const_mul (3/2 : ℝ)).mul_const (1+(l.length : ℝ))simpa only [add_zero] using (hr.const_add (SKValue.profileValue ψ l 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t))).const_mul (n : ℝ)exact ge_of_tendsto hh (Eventually.of_forall (fun (j : ℕ) ↦ he (1/(j+1 : ℝ)) (one_div_pos.mpr (by exact_mod_cast Nat.succ_pos j))))end SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuelemma logCoshTerminal_ge_abs {M : ℝ} (hM : 0<M) (x : ℝ) :|x|≤logCoshTerminal M x := byhave hh := (log_two_cosh_bounds (M*x)).1rw [abs_mul,abs_of_pos hM] at hhexact (le_div_iff₀ hM).mpr (by simpa only [mul_comm] using hh)lemma OrderParameter.weighted_cutoff_integral (γ : OrderParameter) :(∫ t in (0 : ℝ)..1,t*γ.cutoff t)=∫ t in (0 : ℝ)..1,t*γ.coeff t := byapply intervalIntegral.integral_congr_aefilter_upwards [Measure.ae_ne volume (1 : ℝ)] with t hne htrw [uIoc_of_le (by norm_num : (0 : ℝ)≤1)] at hthave ht' : t∈Ico (0 : ℝ) 1 := ⟨ht.1.le,lt_of_le_of_ne ht.2 hne⟩simp only [OrderParameter.cutoff,indicator_of_mem ht']lemma OrderParameter.weighted_grid_error (γ : OrderParameter) (j : ℕ) :|(∫ t in (0 : ℝ)..1,t*profileCoeff (γ.grid j) t)-(∫ t in (0 : ℝ)..1,t*γ.cutoff t)|≤γ.gridError j := byhave hi : IntervalIntegrable (profileCoeff (γ.grid j)) volume 0 1 :=γ.grid_time j ▸ profileCoeff_integrable (γ.grid j)have hj : IntervalIntegrable γ.cutoff volume 0 1 := γ.cutoff_integrable.intervalIntegrablehave hiw := hi.continuousOn_mul (continuous_id : Continuous (fun t : ℝ ↦ t)).continuousOnhave hjw := hj.continuousOn_mul (continuous_id : Continuous (fun t : ℝ ↦ t)).continuousOnsimp only [id_eq] at hiw hjwrw [←intervalIntegral.integral_sub hiw hjw]calc_ ≤ ∫ t in (0 : ℝ)..1,|t*profileCoeff (γ.grid j) t-t*γ.cutoff t| :=intervalIntegral.abs_integral_le_integral_abs (by norm_num)_ ≤ ∫ t in (0 : ℝ)..1,|profileCoeff (γ.grid j) t-γ.cutoff t| := byapply intervalIntegral.integral_mono_on (by norm_num) (hiw.sub hjw).abs (hi.sub hj).absintro t htrw [←mul_sub,abs_mul,abs_of_nonneg ht.1]exact mul_le_of_le_one_left (abs_nonneg _) ht.2_ = γ.gridError j := rfllemma OrderParameter.weighted_grid_tendsto (γ : OrderParameter) :Tendsto (fun j ↦ ∫ t in (0 : ℝ)..1,t*profileCoeff (γ.grid j) t) atTop(𝓝 (∫ t in (0 : ℝ)..1,t*γ.coeff t)) := byrw [←γ.weighted_cutoff_integral]apply (tendsto_iff_dist_tendsto_zero).mprsimp only [Real.dist_eq]exact squeeze_zero (fun _ ↦ abs_nonneg _) γ.weighted_grid_error γ.gridError_tendstotheorem expectedMaximum_le_parisi (W : BrownianSpace) (γ : OrderParameter) {n : ℕ} (hn : 0<n) :SKValueG.expectedMaximum n≤(n : ℝ)*parisi W γ := byhave ht := (smoothApprox_tendsto W γ).tendsto_at ((⟨0,by norm_num⟩ : Ico (0 : ℝ) 1),0)have hp := γ.weighted_grid_tendstohave hf : Tendsto (fun j ↦ (n : ℝ)*(smoothApprox γ j 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*profileCoeff (γ.grid j) t))) atTop (𝓝 ((n : ℝ)*parisi W γ)) := bysimpa only [parisi] using tendsto_const_nhds.mul (ht.sub (tendsto_const_nhds.mul hp))apply ge_of_tendsto hfexact Eventually.of_forall (fun j ↦ SKValueG.weak_profile_guerra_upper W hn(logCoshTerminal_smoothTerminal (by positivity : (0 : ℝ)<j+1))(logCoshTerminal_ge_abs (by positivity)) (γ.grid_mono j) (γ.grid_time j))theorem groundStateValue_le_parisi (W : BrownianSpace) (γ : OrderParameter) :groundStateValue≤parisi W γ := byhave he : SKValueG.groundStateSequence=groundStateSequence := rflhave hev : SKValueG.groundStateValue=groundStateValue := rflhave ht := SKValueG.groundStateSequence_tendstorw [he,hev] at htapply le_of_tendsto htfilter_upwards [eventually_gt_atTop (0 : ℕ)] with n hnchange SKValueG.groundStateSequence n≤_rw [SKValueG.groundStateSequence_eq]have hn' : (0 : ℝ)<n := by exact_mod_cast hnhave hh := mul_le_mul_of_nonneg_left (expectedMaximum_le_parisi W γ hn) (inv_nonneg.mpr hn'.le)simpa only [←mul_assoc,inv_mul_cancel₀ hn'.ne',one_mul] using hhend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import Mathlibimport OAI.Probability.SKValue.GroundState.CascadePassageimport OAI.Probability.SKValue.Equations.StrictProfilenamespace OAIsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueGlemma profile_penalty_mono (ε : ℝ≥0) (k : ℕ) {l : SKValue.HeatProfile}(hT : SKValue.profileTime l=1) :(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t) ≤∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff (SKValue.liftProfile ε k l) t := byhave h1 := profile_weighted_integrable 0 lhave h2 := profile_weighted_integrable 0 (SKValue.liftProfile ε k l)simp only [zero_add,SKValue.liftProfile_time,hT] at h1 h2apply intervalIntegral.integral_mono_on (by norm_num) h1 h2intro t htexact mul_le_mul_of_nonneg_left (SKValue.liftProfile_coeff_lower ε k l t) ht.1lemma weak_profile_guerra_upper (W : SKValue.BrownianSpace) {n : ℕ} (hn : 0<n){ψ : ℝ → ℝ} (hψ : SKValue.SmoothTerminal ψ) (hb : ∀ x,|x|≤ψ x){l : SKValue.HeatProfile} (hl : l.Pairwise (fun p r ↦ p.2≤r.2)) (hT : SKValue.profileTime l=1) :expectedMaximum n ≤ (n : ℝ)*(SKValue.profileValue ψ l 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t)) := byhave he : ∀ ε : ℝ,0<ε → expectedMaximum n ≤ (n : ℝ)*(SKValue.profileValue ψ l 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t)+(3/2 : ℝ)*ε*(1+l.length)) := byintro ε hεlet e : ℝ≥0 := ⟨ε,hε.le⟩have hepos : 0<e := hεhave hs := profileTree_scale (q := 0) (by norm_num : (0 : ℝ)≤0)(SKValue.liftProfile_strict hepos 1 hl) (SKValue.liftProfile_positive hepos (by norm_num : 0<1) l)have hg := profileTree_valid (q := 0) (l := SKValue.liftProfile e 1 l)(by rw [zero_add,SKValue.liftProfile_time,hT])have hu := finite_step_guerra_upper hn _ hg hshave hv := profileTree_le_smooth hψ hb hs 0have hvb := abs_le.mp (hψ.liftProfile_bound W hl hT hepos 1 0)have hc := profile_penalty_mono e 1 hTrw [profileTree_correction] at husimp only [SKValue.liftProfile_time,hT,zero_add] at huhave hnn : (0 : ℝ)≤n := by positivityhave hvb' : SKValue.profileValue ψ (SKValue.liftProfile e 1 l) 0 0-SKValue.profileValue ψ l 0 0 ≤(3/2 : ℝ)*ε*(1+l.length) := byhave h := hvb.2have hcoe : (e : ℝ)=ε := rflrw [Nat.cast_one,hcoe] at hexact happly hu.transapply mul_le_mul_of_nonneg_left _ hnnlinarithhave hh : Tendsto (fun j : ℕ ↦ (n : ℝ)*(SKValue.profileValue ψ l 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t)+(3/2 : ℝ)*(1/(j+1 : ℝ))*(1+l.length))) atTop(𝓝 ((n : ℝ)*(SKValue.profileValue ψ l 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t)))) := byhave hr : Tendsto (fun j : ℕ ↦ (3/2 : ℝ)*(1/(j+1 : ℝ))*(1+l.length)) atTop (𝓝 0) := bysimpa only [mul_zero,zero_mul] using(tendsto_one_div_add_atTop_nhds_zero_nat.const_mul (3/2 : ℝ)).mul_const (1+(l.length : ℝ))simpa only [add_zero] using (hr.const_add (SKValue.profileValue ψ l 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*SKValue.profileCoeff l t))).const_mul (n : ℝ)exact ge_of_tendsto hh (Eventually.of_forall (fun (j : ℕ) ↦ he (1/(j+1 : ℝ)) (one_div_pos.mpr (by exact_mod_cast Nat.succ_pos j))))end SKValueGendsectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuelemma logCoshTerminal_ge_abs {M : ℝ} (hM : 0<M) (x : ℝ) :|x|≤logCoshTerminal M x := byhave hh := (log_two_cosh_bounds (M*x)).1rw [abs_mul,abs_of_pos hM] at hhexact (le_div_iff₀ hM).mpr (by simpa only [mul_comm] using hh)lemma OrderParameter.weighted_cutoff_integral (γ : OrderParameter) :(∫ t in (0 : ℝ)..1,t*γ.cutoff t)=∫ t in (0 : ℝ)..1,t*γ.coeff t := byapply intervalIntegral.integral_congr_aefilter_upwards [Measure.ae_ne volume (1 : ℝ)] with t hne htrw [uIoc_of_le (by norm_num : (0 : ℝ)≤1)] at hthave ht' : t∈Ico (0 : ℝ) 1 := ⟨ht.1.le,lt_of_le_of_ne ht.2 hne⟩simp only [OrderParameter.cutoff,indicator_of_mem ht']lemma OrderParameter.weighted_grid_error (γ : OrderParameter) (j : ℕ) :|(∫ t in (0 : ℝ)..1,t*profileCoeff (γ.grid j) t)-(∫ t in (0 : ℝ)..1,t*γ.cutoff t)|≤γ.gridError j := byhave hi : IntervalIntegrable (profileCoeff (γ.grid j)) volume 0 1 :=γ.grid_time j ▸ profileCoeff_integrable (γ.grid j)have hj : IntervalIntegrable γ.cutoff volume 0 1 := γ.cutoff_integrable.intervalIntegrablehave hiw := hi.continuousOn_mul (continuous_id : Continuous (fun t : ℝ ↦ t)).continuousOnhave hjw := hj.continuousOn_mul (continuous_id : Continuous (fun t : ℝ ↦ t)).continuousOnsimp only [id_eq] at hiw hjwrw [←intervalIntegral.integral_sub hiw hjw]calc_ ≤ ∫ t in (0 : ℝ)..1,|t*profileCoeff (γ.grid j) t-t*γ.cutoff t| :=intervalIntegral.abs_integral_le_integral_abs (by norm_num)_ ≤ ∫ t in (0 : ℝ)..1,|profileCoeff (γ.grid j) t-γ.cutoff t| := byapply intervalIntegral.integral_mono_on (by norm_num) (hiw.sub hjw).abs (hi.sub hj).absintro t htrw [←mul_sub,abs_mul,abs_of_nonneg ht.1]exact mul_le_of_le_one_left (abs_nonneg _) ht.2_ = γ.gridError j := rfllemma OrderParameter.weighted_grid_tendsto (γ : OrderParameter) :Tendsto (fun j ↦ ∫ t in (0 : ℝ)..1,t*profileCoeff (γ.grid j) t) atTop(𝓝 (∫ t in (0 : ℝ)..1,t*γ.coeff t)) := byrw [←γ.weighted_cutoff_integral]apply (tendsto_iff_dist_tendsto_zero).mprsimp only [Real.dist_eq]exact squeeze_zero (fun _ ↦ abs_nonneg _) γ.weighted_grid_error γ.gridError_tendstotheorem expectedMaximum_le_parisi (W : BrownianSpace) (γ : OrderParameter) {n : ℕ} (hn : 0<n) :SKValueG.expectedMaximum n≤(n : ℝ)*parisi W γ := byhave ht := (smoothApprox_tendsto W γ).tendsto_at ((⟨0,by norm_num⟩ : Ico (0 : ℝ) 1),0)have hp := γ.weighted_grid_tendstohave hf : Tendsto (fun j ↦ (n : ℝ)*(smoothApprox γ j 0 0-(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*profileCoeff (γ.grid j) t))) atTop (𝓝 ((n : ℝ)*parisi W γ)) := bysimpa only [parisi] using tendsto_const_nhds.mul (ht.sub (tendsto_const_nhds.mul hp))apply ge_of_tendsto hfexact Eventually.of_forall (fun j ↦ SKValueG.weak_profile_guerra_upper W hn(logCoshTerminal_smoothTerminal (by positivity : (0 : ℝ)<j+1))(logCoshTerminal_ge_abs (by positivity)) (γ.grid_mono j) (γ.grid_time j))theorem groundStateValue_le_parisi (W : BrownianSpace) (γ : OrderParameter) :groundStateValue≤parisi W γ := byhave he : SKValueG.groundStateSequence=groundStateSequence := rflhave hev : SKValueG.groundStateValue=groundStateValue := rflhave ht := SKValueG.groundStateSequence_tendstorw [he,hev] at htapply le_of_tendsto htfilter_upwards [eventually_gt_atTop (0 : ℕ)] with n hnchange SKValueG.groundStateSequence n≤_rw [SKValueG.groundStateSequence_eq]have hn' : (0 : ℝ)<n := by exact_mod_cast hnhave hh := mul_le_mul_of_nonneg_left (expectedMaximum_le_parisi W γ hn) (inv_nonneg.mpr hn'.le)simpa only [←mul_assoc,inv_mul_cancel₀ hn'.ne',one_mul] using hhend SKValueendend OAI
12345678910111213141516171819202122232425262728import Mathlibimport OAI.Probability.SKValue.Gaussian.IntegralPositiveMulGaussianimport OAI.Probability.SKValue.Processes.TestExpectationimport OAI.Probability.SKValue.Processes.ForcedExpectationimport OAI.Probability.SKValue.Processes.ForcedDiffusionimport OAI.Probability.SKValue.Equations.PolynomialForcedimport OAI.Probability.SKValue.Evolution.HeatConvexityimport OAI.Probability.SKValue.Evolution.TerminalAlgebraimport OAI.Probability.SKValue.Evolution.TestStripimport OAI.Probability.SKValue.GroundState.MainConclusionsnamespace OAInamespace SKValuetheorem value_consequences :(∀ (W : BrownianSpace) (γ : OrderParameter) (X : ℝ → W.Ω → ℝ),IsMinimizer W γ → IsDiffusion W γ X → ScalarValueConclusion W γ X) ∧(∀ (W : BrownianSpace) (γ : OrderParameter) (X : ℝ → W.Ω → ℝ) (T : ℝ),0 < T → T < 1 → IsMinimizer W γ → IsDiffusion W γ X →FiniteGaussianConclusion W γ X T) ∧(∀ (W : BrownianSpace) (γ : OrderParameter),IsMinimizer W γ → groundStateValue = parisi W γ) := byexact ⟨scalar_value_target, finite_gaussian_target, ground_state_parisi_target⟩end SKValueend OAI12345678910111213141516171819202122232425262728import Mathlibimport OAI.Probability.SKValue.Gaussian.IntegralPositiveMulGaussianimport OAI.Probability.SKValue.Processes.TestExpectationimport OAI.Probability.SKValue.Processes.ForcedExpectationimport OAI.Probability.SKValue.Processes.ForcedDiffusionimport OAI.Probability.SKValue.Equations.PolynomialForcedimport OAI.Probability.SKValue.Evolution.HeatConvexityimport OAI.Probability.SKValue.Evolution.TerminalAlgebraimport OAI.Probability.SKValue.Evolution.TestStripimport OAI.Probability.SKValue.GroundState.MainConclusionsnamespace OAInamespace SKValuetheorem value_consequences :(∀ (W : BrownianSpace) (γ : OrderParameter) (X : ℝ → W.Ω → ℝ),IsMinimizer W γ → IsDiffusion W γ X → ScalarValueConclusion W γ X) ∧(∀ (W : BrownianSpace) (γ : OrderParameter) (X : ℝ → W.Ω → ℝ) (T : ℝ),0 < T → T < 1 → IsMinimizer W γ → IsDiffusion W γ X →FiniteGaussianConclusion W γ X T) ∧(∀ (W : BrownianSpace) (γ : OrderParameter),IsMinimizer W γ → groundStateValue = parisi W γ) := byexact ⟨scalar_value_target, finite_gaussian_target, ground_state_parisi_target⟩end SKValueend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165import Mathlibnamespace OAIopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology ENNReal NNReal BigOperatorsnamespace SKValuenoncomputable def standardGaussian : Measure ℝ := gaussianReal 0 1instance : IsProbabilityMeasure standardGaussian := by unfold standardGaussian; infer_instancenoncomputable def gaussianProduct (ι : Type) [Fintype ι] : Measure (ι → ℝ) :=Measure.pi (fun _ : ι ↦ standardGaussian)instance gaussianProduct_probability (ι : Type) [Fintype ι] :IsProbabilityMeasure (gaussianProduct ι) := byunfold gaussianProductinfer_instancedef coordinate (N : ℕ) (j : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=z ⟨j % (N+1), Nat.mod_lt _ (Nat.succ_pos _)⟩noncomputable def stepSize (T : ℝ) (N : ℕ) : ℝ := T / Nnoncomputable def meshTime (T : ℝ) (N j : ℕ) : ℝ := j * stepSize T Nnoncomputable def euler (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(z : Fin (N+1) → ℝ) : ℕ → ℝ| 0 => 0| j+1 => euler T N γ u z j + Real.sqrt (stepSize T N) * coordinate N j z +stepSize T N * γ (meshTime T N j) * u (meshTime T N j) (euler T N γ u z j)structure OrderParameter wherecoeff : ℝ → ℝnonneg : ∀ t ∈ Ico (0 : ℝ) 1, 0 ≤ coeff tmonotone : MonotoneOn coeff (Ico (0 : ℝ) 1)rightContinuous : ∀ t ∈ Ico (0 : ℝ) 1, ContinuousWithinAt coeff (Ici t) tintegrable : IntegrableOn coeff (Ioc (0 : ℝ) 1)structure BrownianSpace whereΩ : TypemeasurableSpace : MeasurableSpace Ωμ : @Measure Ω measurableSpaceprobability : @IsProbabilityMeasure Ω measurableSpace μB : ℝ≥0 → Ω → ℝmeasurable : ∀ t, @StronglyMeasurable Ω ℝ _ measurableSpace (B t)brownian : @IsBrownianReal Ω measurableSpace B μattribute [instance] BrownianSpace.measurableSpace BrownianSpace.probabilitynoncomputable def BrownianSpace.filtration (W : BrownianSpace) :Filtration ℝ≥0 W.measurableSpace := Filtration.natural W.B W.measurablenoncomputable def shiftedFiltration (W : BrownianSpace) (t : ℝ) :Filtration ℝ≥0 W.measurableSpace :=Filtration.natural (fun s ω ↦ W.B (Real.toNNReal t + s) ω - W.B (Real.toNNReal t) ω)(fun _ ↦ (W.measurable _).sub (W.measurable _))def Admissible (W : BrownianSpace) (t : ℝ) (α : ℝ≥0 → W.Ω → ℝ) : Prop :=IsProgressive (shiftedFiltration W t) α ∧ ∀ s ω, |α s ω| ≤ 1noncomputable def controlPayoff (W : BrownianSpace) (γ : OrderParameter)(t x : ℝ) (α : ℝ≥0 → W.Ω → ℝ) : ℝ :=∫ ω, (|x + W.B 1 ω - W.B (Real.toNNReal t) ω +∫ s in (0 : ℝ)..(1-t), γ.coeff (t+s) * α (Real.toNNReal s) ω| -(1/2 : ℝ) * ∫ s in (0 : ℝ)..(1-t), γ.coeff (t+s) * α (Real.toNNReal s) ω ^ 2) ∂W.μnoncomputable def phi (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ :=sSup {r | ∃ α, Admissible W t α ∧ r = controlPayoff W γ t x α}noncomputable def gradient (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ :=deriv (phi W γ t) xnoncomputable def curvature (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ :=deriv (gradient W γ t) xnoncomputable def parisi (W : BrownianSpace) (γ : OrderParameter) : ℝ :=phi W γ 0 0 - (1/2 : ℝ) * ∫ t in (0 : ℝ)..1, t * γ.coeff tdef IsMinimizer (W : BrownianSpace) (γ : OrderParameter) : Prop :=∀ η : OrderParameter, parisi W γ ≤ parisi W ηdef IsDiffusion (W : BrownianSpace) (γ : OrderParameter) (X : ℝ → W.Ω → ℝ) : Prop :=Adapted W.filtration (fun t ω ↦ X (min (t : ℝ) 1) ω) ∧(∀ᵐ ω ∂W.μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) 1) ∧∀ t ∈ Icc (0 : ℝ) 1,X t ω = W.B (Real.toNNReal t) ω +∫ s in (0 : ℝ)..t, γ.coeff s * gradient W γ s (X s ω))noncomputable def spin (b : Bool) : ℝ := if b then 1 else -1noncomputable def hamiltonian (n : ℕ) (J : (Fin n × Fin n) → ℝ)(σ : Fin n → Bool) : ℝ :=(Real.sqrt (n : ℝ))⁻¹ *∑ i : Fin n, ∑ j : Fin n, if i < j then J (i,j) * spin (σ i) * spin (σ j) else 0noncomputable def groundStateSequence (n : ℕ) : ℝ :=(n : ℝ)⁻¹ * ∫ J, sSup (range (hamiltonian n J)) ∂gaussianProduct (Fin n × Fin n)noncomputable def groundStateValue : ℝ := limUnder atTop groundStateSequencenoncomputable def gradientStopped (W : BrownianSpace) (γ : OrderParameter)(X : ℝ → W.Ω → ℝ) (U : W.Ω → ℝ) (t : ℝ≥0) (ω : W.Ω) : ℝ :=if (t : ℝ) < 1 then gradient W γ t (X t ω) else U ωdef ScalarValueConclusion (W : BrownianSpace) (γ : OrderParameter)(X : ℝ → W.Ω → ℝ) : Prop :=Tendsto groundStateSequence atTop (𝓝 groundStateValue) ∧∃ U : W.Ω → ℝ,Martingale (gradientStopped W γ X U) W.filtration W.μ ∧(∀ᵐ ω ∂W.μ, |U ω| ≤ 1 �� (U ω)^2 = 1 ∧Tendsto (fun t ↦ gradient W γ t (X t ω)) (𝓝[<] (1 : ℝ)) (𝓝 (U ω))) ∧Tendsto (fun t ↦ ∫ ω, (gradient W γ t (X t ω) - U ω)^2 ∂W.μ)(𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) ∧groundStateValue = (∫ ω, |X 1 ω| ∂W.μ) - ∫ t in (0 : ℝ)..1, t * γ.coeff t ∧groundStateValue = ∫ ω, U ω * W.B 1 ω ∂W.μ ∧groundStateValue = ∫ t in (0 : ℝ)..1, ∫ ω, curvature W γ t (X t ω) ∂W.μ ∧IntervalIntegrable (fun t ↦ ∫ ω, curvature W γ t (X t ω) ∂W.μ) volume 0 1noncomputable def eulerPath (W : BrownianSpace) (γ : OrderParameter) (T : ℝ) (N : ℕ)(z : Fin (N+1) → ℝ) (j : ℕ) : ℝ :=euler T N γ.coeff (gradient W γ) z jnoncomputable def rawCoefficient (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N j : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=curvature W γ (meshTime T N j) (eulerPath W γ T N z j)noncomputable def normalizer (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N j : ℕ) : ℝ :=(Real.sqrt (∫ z, (rawCoefficient W γ T N j z)^2 ∂gaussianProduct (Fin (N+1))))⁻¹noncomputable def gaussianIncrement (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N j : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=normalizer W γ T N j * rawCoefficient W γ T N j z * coordinate N j znoncomputable def roundedSign (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=Real.sign (gradient W γ T (eulerPath W γ T N z N) +2 * cdf standardGaussian (coordinate N N z) - 1)noncomputable def coefficientA (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N j : ℕ) : ℝ :=if j = 0 then 0 else∫ z, roundedSign W γ T N z * gaussianIncrement W γ T N (j-1) z∂gaussianProduct (Fin (N+1))noncomputable def coefficientB (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N i : ℕ) : ℝ :=∫ z, roundedSign W γ T N z * coordinate N (i-1) z ∂gaussianProduct (Fin (N+1))noncomputable def shiftedCoefficientSum (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N : ℕ) : ℝ :=∑ j ∈ Finset.range (N+1), coefficientA W γ T N j * coefficientB W γ T N (j+1)def FiniteGaussianConclusion (W : BrownianSpace) (γ : OrderParameter)(X : ℝ → W.Ω → ℝ) (T : ℝ) : Prop :=(∀ᶠ N in atTop, ∀ j < N, 0 < normalizer W γ T N j) ∧Tendsto (shiftedCoefficientSum W γ T) atTop(𝓝 (∫ t in (0 : ℝ)..T, ∫ ω, curvature W γ t (X t ω) ∂W.μ)) ∧Tendsto (fun S ↦ ∫ t in (0 : ℝ)..S, ∫ ω, curvature W γ t (X t ω) ∂W.μ)(𝓝[<] (1 : ℝ)) (𝓝 groundStateValue)end SKValueend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165import Mathlibnamespace OAIopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology ENNReal NNReal BigOperatorsnamespace SKValuenoncomputable def standardGaussian : Measure ℝ := gaussianReal 0 1instance : IsProbabilityMeasure standardGaussian := by unfold standardGaussian; infer_instancenoncomputable def gaussianProduct (ι : Type) [Fintype ι] : Measure (ι → ℝ) :=Measure.pi (fun _ : ι ↦ standardGaussian)instance gaussianProduct_probability (ι : Type) [Fintype ι] :IsProbabilityMeasure (gaussianProduct ι) := byunfold gaussianProductinfer_instancedef coordinate (N : ℕ) (j : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=z ⟨j % (N+1), Nat.mod_lt _ (Nat.succ_pos _)⟩noncomputable def stepSize (T : ℝ) (N : ℕ) : ℝ := T / Nnoncomputable def meshTime (T : ℝ) (N j : ℕ) : ℝ := j * stepSize T Nnoncomputable def euler (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(z : Fin (N+1) → ℝ) : ℕ → ℝ| 0 => 0| j+1 => euler T N γ u z j + Real.sqrt (stepSize T N) * coordinate N j z +stepSize T N * γ (meshTime T N j) * u (meshTime T N j) (euler T N γ u z j)structure OrderParameter wherecoeff : ℝ → ℝnonneg : ∀ t ∈ Ico (0 : ℝ) 1, 0 ≤ coeff tmonotone : MonotoneOn coeff (Ico (0 : ℝ) 1)rightContinuous : ∀ t ∈ Ico (0 : ℝ) 1, ContinuousWithinAt coeff (Ici t) tintegrable : IntegrableOn coeff (Ioc (0 : ℝ) 1)structure BrownianSpace whereΩ : TypemeasurableSpace : MeasurableSpace Ωμ : @Measure Ω measurableSpaceprobability : @IsProbabilityMeasure Ω measurableSpace μB : ℝ≥0 → Ω → ℝmeasurable : ∀ t, @StronglyMeasurable Ω ℝ _ measurableSpace (B t)brownian : @IsBrownianReal Ω measurableSpace B μattribute [instance] BrownianSpace.measurableSpace BrownianSpace.probabilitynoncomputable def BrownianSpace.filtration (W : BrownianSpace) :Filtration ℝ≥0 W.measurableSpace := Filtration.natural W.B W.measurablenoncomputable def shiftedFiltration (W : BrownianSpace) (t : ℝ) :Filtration ℝ≥0 W.measurableSpace :=Filtration.natural (fun s ω ↦ W.B (Real.toNNReal t + s) ω - W.B (Real.toNNReal t) ω)(fun _ ↦ (W.measurable _).sub (W.measurable _))def Admissible (W : BrownianSpace) (t : ℝ) (α : ℝ≥0 → W.Ω → ℝ) : Prop :=IsProgressive (shiftedFiltration W t) α ∧ ∀ s ω, |α s ω| ≤ 1noncomputable def controlPayoff (W : BrownianSpace) (γ : OrderParameter)(t x : ℝ) (α : ℝ≥0 → W.Ω → ℝ) : ℝ :=∫ ω, (|x + W.B 1 ω - W.B (Real.toNNReal t) ω +∫ s in (0 : ℝ)..(1-t), γ.coeff (t+s) * α (Real.toNNReal s) ω| -(1/2 : ℝ) * ∫ s in (0 : ℝ)..(1-t), γ.coeff (t+s) * α (Real.toNNReal s) ω ^ 2) ∂W.μnoncomputable def phi (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ :=sSup {r | ∃ α, Admissible W t α ∧ r = controlPayoff W γ t x α}noncomputable def gradient (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ :=deriv (phi W γ t) xnoncomputable def curvature (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ :=deriv (gradient W γ t) xnoncomputable def parisi (W : BrownianSpace) (γ : OrderParameter) : ℝ :=phi W γ 0 0 - (1/2 : ℝ) * ∫ t in (0 : ℝ)..1, t * γ.coeff tdef IsMinimizer (W : BrownianSpace) (γ : OrderParameter) : Prop :=∀ η : OrderParameter, parisi W γ ≤ parisi W ηdef IsDiffusion (W : BrownianSpace) (γ : OrderParameter) (X : ℝ → W.Ω → ℝ) : Prop :=Adapted W.filtration (fun t ω ↦ X (min (t : ℝ) 1) ω) ∧(∀ᵐ ω ∂W.μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) 1) ∧∀ t ∈ Icc (0 : ℝ) 1,X t ω = W.B (Real.toNNReal t) ω +∫ s in (0 : ℝ)..t, γ.coeff s * gradient W γ s (X s ω))noncomputable def spin (b : Bool) : ℝ := if b then 1 else -1noncomputable def hamiltonian (n : ℕ) (J : (Fin n × Fin n) → ℝ)(σ : Fin n → Bool) : ℝ :=(Real.sqrt (n : ℝ))⁻¹ *∑ i : Fin n, ∑ j : Fin n, if i < j then J (i,j) * spin (σ i) * spin (σ j) else 0noncomputable def groundStateSequence (n : ℕ) : ℝ :=(n : ℝ)⁻¹ * ∫ J, sSup (range (hamiltonian n J)) ∂gaussianProduct (Fin n × Fin n)noncomputable def groundStateValue : ℝ := limUnder atTop groundStateSequencenoncomputable def gradientStopped (W : BrownianSpace) (γ : OrderParameter)(X : ℝ → W.Ω → ℝ) (U : W.Ω → ℝ) (t : ℝ≥0) (ω : W.Ω) : ℝ :=if (t : ℝ) < 1 then gradient W γ t (X t ω) else U ωdef ScalarValueConclusion (W : BrownianSpace) (γ : OrderParameter)(X : ℝ → W.Ω → ℝ) : Prop :=Tendsto groundStateSequence atTop (𝓝 groundStateValue) ∧∃ U : W.Ω → ℝ,Martingale (gradientStopped W γ X U) W.filtration W.μ ∧(∀ᵐ ω ∂W.μ, |U ω| ≤ 1 ∧ (U ω)^2 = 1 ∧Tendsto (fun t ↦ gradient W γ t (X t ω)) (𝓝[<] (1 : ℝ)) (𝓝 (U ω))) ∧Tendsto (fun t ↦ ∫ ω, (gradient W γ t (X t ω) - U ω)^2 ∂W.μ)(𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) ∧groundStateValue = (∫ ω, |X 1 ω| ∂W.μ) - ∫ t in (0 : ℝ)..1, t * γ.coeff t ∧groundStateValue = ∫ ω, U ω * W.B 1 ω ∂W.μ ∧groundStateValue = ∫ t in (0 : ℝ)..1, ∫ ω, curvature W γ t (X t ω) ∂W.μ ∧IntervalIntegrable (fun t ↦ ∫ ω, curvature W γ t (X t ω) ∂W.μ) volume 0 1noncomputable def eulerPath (W : BrownianSpace) (γ : OrderParameter) (T : ℝ) (N : ℕ)(z : Fin (N+1) → ℝ) (j : ℕ) : ℝ :=euler T N γ.coeff (gradient W γ) z jnoncomputable def rawCoefficient (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N j : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=curvature W γ (meshTime T N j) (eulerPath W γ T N z j)noncomputable def normalizer (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N j : ℕ) : ℝ :=(Real.sqrt (∫ z, (rawCoefficient W γ T N j z)^2 ∂gaussianProduct (Fin (N+1))))⁻¹noncomputable def gaussianIncrement (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N j : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=normalizer W γ T N j * rawCoefficient W γ T N j z * coordinate N j znoncomputable def roundedSign (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=Real.sign (gradient W γ T (eulerPath W γ T N z N) +2 * cdf standardGaussian (coordinate N N z) - 1)noncomputable def coefficientA (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N j : ℕ) : ℝ :=if j = 0 then 0 else∫ z, roundedSign W γ T N z * gaussianIncrement W γ T N (j-1) z∂gaussianProduct (Fin (N+1))noncomputable def coefficientB (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N i : ℕ) : ℝ :=∫ z, roundedSign W γ T N z * coordinate N (i-1) z ∂gaussianProduct (Fin (N+1))noncomputable def shiftedCoefficientSum (W : BrownianSpace) (γ : OrderParameter)(T : ℝ) (N : ℕ) : ℝ :=∑ j ∈ Finset.range (N+1), coefficientA W γ T N j * coefficientB W γ T N (j+1)def FiniteGaussianConclusion (W : BrownianSpace) (γ : OrderParameter)(X : ℝ → W.Ω → ℝ) (T : ℝ) : Prop :=(∀ᶠ N in atTop, ∀ j < N, 0 < normalizer W γ T N j) ∧Tendsto (shiftedCoefficientSum W γ T) atTop(𝓝 (∫ t in (0 : ℝ)..T, ∫ ω, curvature W γ t (X t ω) ∂W.μ)) ∧Tendsto (fun S ↦ ∫ t in (0 : ℝ)..S, ∫ ω, curvature W γ t (X t ω) ∂W.μ)(𝓝[<] (1 : ℝ)) (𝓝 groundStateValue)end SKValueend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import Mathlibimport OAI.Probability.SKValue.GroundState.CrossExpectationnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuelemma abs_telescope_source {N : ℕ} {A b Γ Δ : ℕ → ℝ} {c d e : ℝ}(h : ∀ j<N,|A (j+1)-A j+b j|≤c+d*(Γ (j+1)-Γ j)+e*(Δ (j+1)-Δ j)) :|A N-A 0+∑ j∈Finset.range N,b j|≤(N : ℝ)*c+d*(Γ N-Γ 0)+e*(Δ N-Δ 0) := byhave hs := (Finset.abs_sum_le_sum_abs (fun j ↦ A (j+1)-A j+b j) (Finset.range N)).trans(Finset.sum_le_sum (fun j hj ↦ h j (Finset.mem_range.mp hj)))simpa only [Finset.sum_add_distrib,Finset.sum_range_sub,←Finset.mul_sum,Finset.sum_const,Finset.card_range,nsmul_eq_mul] using hsnoncomputable def crossMeshSource (T : ℝ) (N : ℕ) (γ β : ℝ → ℝ) (V U : ℝ → ℝ → ℝ) : ℝ :=∑ j∈Finset.range N,(stepSize T N/2)*(β (meshTime T N j)-γ (meshTime T N j))*(∫ z,(deriv (V (meshTime T N j)) (euler T N β (crossFeedback V U) z j))^2∂gaussianProduct (Fin (N+1)))lemma cross_value_mesh_expectation {T K L K' L' G : ℝ}{γ β : ℝ → ℝ} {V U : ℝ → ℝ → ℝ}(hV : ValueStrip T γ V K L) (hU : ValueStrip T β U K' L')(hT : 0<T) (hT1 : T≤1) (hG : γ T≤G) (hG' : β T≤G) {N : ℕ} (hN : 0<N) :|(∫ z,U T (euler T N β (crossFeedback V U) z N)-V T (euler T N β (crossFeedback V U) z N) ∂gaussianProduct (Fin (N+1)))-(U 0 0-V 0 0)+crossMeshSource T N γ β V U|≤T*Real.sqrt (stepSize T N)*(cubicEnvelopeMean G K ((1/2+G)*L)+cubicEnvelopeMean G K' ((1/2+G)*L'))+stepSize T N*K*(γ T-γ 0)+stepSize T N*K'*(β T-β 0) := bylet δ := stepSize T Nlet Y := euler T N β (crossFeedback V U)let A := fun j ↦ ∫ z,U (meshTime T N j) (Y z j)-V (meshTime T N j) (Y z j)∂gaussianProduct (Fin (N+1))let b := fun j ↦ (δ/2)*(β (meshTime T N j)-γ (meshTime T N j))*(∫ z,(deriv (V (meshTime T N j)) (Y z j))^2 ∂gaussianProduct (Fin (N+1)))have hNr : 0<(N : ℝ) := by exact_mod_cast hNhave hδ : 0≤δ := div_nonneg hT.le hNr.lehave hδ1 : δ≤1 := byapply (div_le_iff₀ hNr).mprhave hN1 : (1 : ℝ)≤N := by exact_mod_cast hNsimpa only [one_mul] using hT1.trans hN1have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hjhave hs (j : ℕ) : meshTime T N j+δ=meshTime T N (j+1) := bydsimp [meshTime]; push_cast; ringhave hlast : meshTime T N N=T := by dsimp [meshTime,stepSize]; field_simphave hzero : meshTime T N 0=0 := by simp [meshTime]have hfm (j : ℕ) (hj : j<N) : Measurable (crossFeedback V U (meshTime T N j)) :=(((hU.smooth _ (htime j hj.le)).continuous_deriv (by norm_num)).measurable.add((hV.smooth _ (htime j hj.le)).continuous_deriv (by norm_num)).measurable).div_const 2have hfb (j : ℕ) (hj : j<N) (x : ℝ) : |crossFeedback V U (meshTime T N j) x|≤1 :=crossFeedback_bound (hV.bounded _ (htime j hj.le) x) (hU.bounded _ (htime j hj.le) x)have hstep (j : ℕ) (hj : j<N) : |A (j+1)-A j+b j|≤δ*Real.sqrt δ*(cubicEnvelopeMean G K ((1/2+G)*L)+cubicEnvelopeMean G K' ((1/2+G)*L'))+δ*K*(γ (meshTime T N (j+1))-γ (meshTime T N j))+δ*K'*(β (meshTime T N (j+1))-β (meshTime T N j)) := byhave hYp : DependsBefore j (fun z ↦ Y z j) :=eulerCoefficient_dependsBefore T hj.le β (crossFeedback V U) (fun _ y ↦ y)have he := cross_value_expectation_step hV hU (htime j hj.le).1 hδ hδ1(by rw [hs]; exact (htime (j+1) (by omega)).2) hG hG' (by omega : j<N+1)(measurable_euler T N β (crossFeedback V U) hfm j hj.le) hYp(euler_memLp T N β (crossFeedback V U) hfm hfb j hj.le)dsimp only at herw [hs] at hesimpa only [A,b,Y,euler,δ,mul_assoc] using hehave hh := abs_telescope_source (A := A) (b := b)(Γ := fun j ↦ γ (meshTime T N j)) (Δ := fun j ↦ β (meshTime T N j)) hstephave hA0 : A 0=U 0 0-V 0 0 := by simp [A,Y,meshTime,euler]rw [hA0,show A N=(∫ z,U T (Y z N)-V T (Y z N) ∂gaussianProduct (Fin (N+1))) bydsimp only [A]; rw [hlast],hlast,hzero] at hhhave hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simpconvert hh using 1· rfl· dsimp only [δ] at hNd ⊢simp only [←mul_assoc,hNd]end SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuelemma euler_same_noise_bound {T G L d e : ℝ} {N : ℕ} {γ β : ℝ → ℝ}{u v : ℝ → ℝ → ℝ} (hT : 0≤T) (hN : 0<N)(hG : 0≤G) (hL : 0≤L) (hd : 0≤d) (he : 0≤e)(hg : ∀ j<N,|γ (meshTime T N j)|≤G)(hc : ∀ j<N,|β (meshTime T N j)-γ (meshTime T N j)|≤d)(hv : ∀ j<N,∀ x,|v (meshTime T N j) x|≤1)(hs : ∀ j<N,∀ x,|v (meshTime T N j) x-u (meshTime T N j) x|≤e)(hu : ∀ j<N,∀ x y,|u (meshTime T N j) x-u (meshTime T N j) y|≤L*|x-y|)(z : Fin (N+1) → ℝ) {j : ℕ} (hj : j≤N) :|euler T N β v z j-euler T N γ u z j|≤T*(d+G*e)*Real.exp (T*G*L) := bylet δ := stepSize T Nhave hδ : 0≤δ := div_nonneg hT (Nat.cast_nonneg _)have hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simphave hrec (k : ℕ) (hk : k<N) :|euler T N β v z (k+1)-euler T N γ u z (k+1)|≤(1+δ*G*L)*|euler T N β v z k-euler T N γ u z k|+δ*(d+G*e) := bylet y := euler T N β v z klet x := euler T N γ u z klet t := meshTime T N khave hb : |β t*v t y-γ t*u t x|≤d+G*e+G*L*|y-x| := bycalc|β t*v t y-γ t*u t x| = |(β t-γ t)*v t y+γ t*(v t y-u t y)+γ t*(u t y-u t x)| := by congr 1; ring_ ≤ |(β t-γ t)*v t y|+|γ t*(v t y-u t y)|+|γ t*(u t y-u t x)| := (abs_add_le _ _).trans (add_le_add (abs_add_le _ _) le_rfl)_ ≤ d*1+G*e+G*(L*|y-x|) := bysimp only [abs_mul]gcongr· exact hc k hk· exact hv k hk y· exact hg k hk· exact hs k hk y· exact hg k hk· exact hu k hk y x_ = _ := by ringchange |y+Real.sqrt δ*coordinate N k z+δ*β t*v t y-(x+Real.sqrt δ*coordinate N k z+δ*γ t*u t x)|≤_calc_ = |(y-x)+δ*(β t*v t y-γ t*u t x)| := by congr 1; ring_ ≤ |y-x|+δ*|β t*v t y-γ t*u t x| := by simpa only [abs_mul,abs_of_nonneg hδ] using abs_add_le (y-x) (δ*(β t*v t y-γ t*u t x))_ ≤ |y-x|+δ*(d+G*e+G*L*|y-x|) := add_le_add_right (mul_le_mul_of_nonneg_left hb hδ) __ = _ := by ringhave h := finite_discrete_gronwall (e := fun k ↦ |euler T N β v z k-euler T N γ u z k|) (mul_nonneg (mul_nonneg hδ hG) hL)(show |euler T N β v z 0-euler T N γ u z 0|=0 by simp [euler])(fun k hk ↦ mul_nonneg hδ (add_nonneg hd (mul_nonneg hG he))) hrec j hjhave hsum : (∑ k∈Finset.range j,δ*(d+G*e))≤T*(d+G*e) := bysimp only [Finset.sum_const,Finset.card_range,nsmul_eq_mul]rw [←hNd]have hjs : (j : ℝ)≤N := by exact_mod_cast hjnlinarith [mul_nonneg hG he,mul_nonneg hd hδ,mul_nonneg hδ (mul_nonneg hG he)]apply h.transapply mul_le_mul hsum· apply Real.exp_le_exp.mprcalc(j : ℝ)*(δ*G*L)≤(N : ℝ)*(δ*G*L) := mul_le_mul_of_nonneg_right (by exact_mod_cast hj) (mul_nonneg (mul_nonneg hδ hG) hL)_=T*G*L := by rw [←hNd]; ring· positivity· positivityend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import Mathlibimport OAI.Probability.SKValue.GroundState.CrossExpectationnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuelemma abs_telescope_source {N : ℕ} {A b Γ Δ : ℕ → ℝ} {c d e : ℝ}(h : ∀ j<N,|A (j+1)-A j+b j|≤c+d*(Γ (j+1)-Γ j)+e*(Δ (j+1)-Δ j)) :|A N-A 0+∑ j∈Finset.range N,b j|≤(N : ℝ)*c+d*(Γ N-Γ 0)+e*(Δ N-Δ 0) := byhave hs := (Finset.abs_sum_le_sum_abs (fun j ↦ A (j+1)-A j+b j) (Finset.range N)).trans(Finset.sum_le_sum (fun j hj ↦ h j (Finset.mem_range.mp hj)))simpa only [Finset.sum_add_distrib,Finset.sum_range_sub,←Finset.mul_sum,Finset.sum_const,Finset.card_range,nsmul_eq_mul] using hsnoncomputable def crossMeshSource (T : ℝ) (N : ℕ) (γ β : ℝ → ℝ) (V U : ℝ → ℝ → ℝ) : ℝ :=∑ j∈Finset.range N,(stepSize T N/2)*(β (meshTime T N j)-γ (meshTime T N j))*(∫ z,(deriv (V (meshTime T N j)) (euler T N β (crossFeedback V U) z j))^2∂gaussianProduct (Fin (N+1)))lemma cross_value_mesh_expectation {T K L K' L' G : ℝ}{γ β : ℝ → ℝ} {V U : ℝ → ℝ → ℝ}(hV : ValueStrip T γ V K L) (hU : ValueStrip T β U K' L')(hT : 0<T) (hT1 : T≤1) (hG : γ T≤G) (hG' : β T≤G) {N : ℕ} (hN : 0<N) :|(∫ z,U T (euler T N β (crossFeedback V U) z N)-V T (euler T N β (crossFeedback V U) z N) ∂gaussianProduct (Fin (N+1)))-(U 0 0-V 0 0)+crossMeshSource T N γ β V U|≤T*Real.sqrt (stepSize T N)*(cubicEnvelopeMean G K ((1/2+G)*L)+cubicEnvelopeMean G K' ((1/2+G)*L'))+stepSize T N*K*(γ T-γ 0)+stepSize T N*K'*(β T-β 0) := bylet δ := stepSize T Nlet Y := euler T N β (crossFeedback V U)let A := fun j ↦ ∫ z,U (meshTime T N j) (Y z j)-V (meshTime T N j) (Y z j)∂gaussianProduct (Fin (N+1))let b := fun j ↦ (δ/2)*(β (meshTime T N j)-γ (meshTime T N j))*(∫ z,(deriv (V (meshTime T N j)) (Y z j))^2 ∂gaussianProduct (Fin (N+1)))have hNr : 0<(N : ℝ) := by exact_mod_cast hNhave hδ : 0≤δ := div_nonneg hT.le hNr.lehave hδ1 : δ≤1 := byapply (div_le_iff₀ hNr).mprhave hN1 : (1 : ℝ)≤N := by exact_mod_cast hNsimpa only [one_mul] using hT1.trans hN1have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hjhave hs (j : ℕ) : meshTime T N j+δ=meshTime T N (j+1) := bydsimp [meshTime]; push_cast; ringhave hlast : meshTime T N N=T := by dsimp [meshTime,stepSize]; field_simphave hzero : meshTime T N 0=0 := by simp [meshTime]have hfm (j : ℕ) (hj : j<N) : Measurable (crossFeedback V U (meshTime T N j)) :=(((hU.smooth _ (htime j hj.le)).continuous_deriv (by norm_num)).measurable.add((hV.smooth _ (htime j hj.le)).continuous_deriv (by norm_num)).measurable).div_const 2have hfb (j : ℕ) (hj : j<N) (x : ℝ) : |crossFeedback V U (meshTime T N j) x|≤1 :=crossFeedback_bound (hV.bounded _ (htime j hj.le) x) (hU.bounded _ (htime j hj.le) x)have hstep (j : ℕ) (hj : j<N) : |A (j+1)-A j+b j|≤δ*Real.sqrt δ*(cubicEnvelopeMean G K ((1/2+G)*L)+cubicEnvelopeMean G K' ((1/2+G)*L'))+δ*K*(γ (meshTime T N (j+1))-γ (meshTime T N j))+δ*K'*(β (meshTime T N (j+1))-β (meshTime T N j)) := byhave hYp : DependsBefore j (fun z ↦ Y z j) :=eulerCoefficient_dependsBefore T hj.le β (crossFeedback V U) (fun _ y ↦ y)have he := cross_value_expectation_step hV hU (htime j hj.le).1 hδ hδ1(by rw [hs]; exact (htime (j+1) (by omega)).2) hG hG' (by omega : j<N+1)(measurable_euler T N β (crossFeedback V U) hfm j hj.le) hYp(euler_memLp T N β (crossFeedback V U) hfm hfb j hj.le)dsimp only at herw [hs] at hesimpa only [A,b,Y,euler,δ,mul_assoc] using hehave hh := abs_telescope_source (A := A) (b := b)(Γ := fun j ↦ γ (meshTime T N j)) (Δ := fun j ↦ β (meshTime T N j)) hstephave hA0 : A 0=U 0 0-V 0 0 := by simp [A,Y,meshTime,euler]rw [hA0,show A N=(∫ z,U T (Y z N)-V T (Y z N) ∂gaussianProduct (Fin (N+1))) bydsimp only [A]; rw [hlast],hlast,hzero] at hhhave hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simpconvert hh using 1· rfl· dsimp only [δ] at hNd ⊢simp only [←mul_assoc,hNd]end SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuelemma euler_same_noise_bound {T G L d e : ℝ} {N : ℕ} {γ β : ℝ → ℝ}{u v : ℝ → ℝ → ℝ} (hT : 0≤T) (hN : 0<N)(hG : 0≤G) (hL : 0≤L) (hd : 0≤d) (he : 0≤e)(hg : ∀ j<N,|γ (meshTime T N j)|≤G)(hc : ∀ j<N,|β (meshTime T N j)-γ (meshTime T N j)|≤d)(hv : ∀ j<N,∀ x,|v (meshTime T N j) x|≤1)(hs : ∀ j<N,∀ x,|v (meshTime T N j) x-u (meshTime T N j) x|≤e)(hu : ∀ j<N,∀ x y,|u (meshTime T N j) x-u (meshTime T N j) y|≤L*|x-y|)(z : Fin (N+1) → ℝ) {j : ℕ} (hj : j≤N) :|euler T N β v z j-euler T N γ u z j|≤T*(d+G*e)*Real.exp (T*G*L) := bylet δ := stepSize T Nhave hδ : 0≤δ := div_nonneg hT (Nat.cast_nonneg _)have hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simphave hrec (k : ℕ) (hk : k<N) :|euler T N β v z (k+1)-euler T N γ u z (k+1)|≤(1+δ*G*L)*|euler T N β v z k-euler T N γ u z k|+δ*(d+G*e) := bylet y := euler T N β v z klet x := euler T N γ u z klet t := meshTime T N khave hb : |β t*v t y-γ t*u t x|≤d+G*e+G*L*|y-x| := bycalc|β t*v t y-γ t*u t x| = |(β t-γ t)*v t y+γ t*(v t y-u t y)+γ t*(u t y-u t x)| := by congr 1; ring_ ≤ |(β t-γ t)*v t y|+|γ t*(v t y-u t y)|+|γ t*(u t y-u t x)| := (abs_add_le _ _).trans (add_le_add (abs_add_le _ _) le_rfl)_ ≤ d*1+G*e+G*(L*|y-x|) := bysimp only [abs_mul]gcongr· exact hc k hk· exact hv k hk y· exact hg k hk· exact hs k hk y· exact hg k hk· exact hu k hk y x_ = _ := by ringchange |y+Real.sqrt δ*coordinate N k z+δ*β t*v t y-(x+Real.sqrt δ*coordinate N k z+δ*γ t*u t x)|≤_calc_ = |(y-x)+δ*(β t*v t y-γ t*u t x)| := by congr 1; ring_ ≤ |y-x|+δ*|β t*v t y-γ t*u t x| := by simpa only [abs_mul,abs_of_nonneg hδ] using abs_add_le (y-x) (δ*(β t*v t y-γ t*u t x))_ ≤ |y-x|+δ*(d+G*e+G*L*|y-x|) := add_le_add_right (mul_le_mul_of_nonneg_left hb hδ) __ = _ := by ringhave h := finite_discrete_gronwall (e := fun k ↦ |euler T N β v z k-euler T N γ u z k|) (mul_nonneg (mul_nonneg hδ hG) hL)(show |euler T N β v z 0-euler T N γ u z 0|=0 by simp [euler])(fun k hk ↦ mul_nonneg hδ (add_nonneg hd (mul_nonneg hG he))) hrec j hjhave hsum : (∑ k∈Finset.range j,δ*(d+G*e))≤T*(d+G*e) := bysimp only [Finset.sum_const,Finset.card_range,nsmul_eq_mul]rw [←hNd]have hjs : (j : ℝ)≤N := by exact_mod_cast hjnlinarith [mul_nonneg hG he,mul_nonneg hd hδ,mul_nonneg hδ (mul_nonneg hG he)]apply h.transapply mul_le_mul hsum· apply Real.exp_le_exp.mprcalc(j : ℝ)*(δ*G*L)≤(N : ℝ)*(δ*G*L) := mul_le_mul_of_nonneg_right (by exact_mod_cast hj) (mul_nonneg (mul_nonneg hδ hG) hL)_=T*G*L := by rw [←hNd]; ring· positivity· positivityend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuenoncomputable def ordinaryMeshSource (T : ℝ) (N : ℕ) (γ β : ℝ → ℝ) (V : ℝ → ℝ → ℝ) : ℝ :=stepSize T N*∑ j : Fin N,(β (meshTime T N j)-γ (meshTime T N j))*(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j))(euler T N γ (fun t ↦ deriv (V t)) z j))^2 ∂gaussianProduct (Fin (N+1)))lemma crossMeshSource_half_form (T : ℝ) (N : ℕ) (γ β : ℝ → ℝ) (V U : ℝ → ℝ → ℝ) :crossMeshSource T N γ β V U=stepSize T N*∑ j : Fin N,(β (meshTime T N j)-γ (meshTime T N j))*(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j))(euler T N β (crossFeedback V U) z j))^2 ∂gaussianProduct (Fin (N+1))) := byunfold crossMeshSourcerw [Fin.sum_univ_eq_sum_range (fun j : ℕ ↦ (β (meshTime T N j)-γ (meshTime T N j))*(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j))(euler T N β (crossFeedback V U) z j))^2 ∂gaussianProduct (Fin (N+1))))]simp only [integral_const_mul,Finset.mul_sum]apply Finset.sum_congr rflintro j hjringlemma crossMeshSource_difference_bound {T K L K' L' d R : ℝ}{γ β : ℝ → ℝ} {V U : ℝ → ℝ → ℝ}(hV : ValueStrip T γ V K L) (hU : ValueStrip T β U K' L')(hT : 0≤T) {N : ℕ} (hN : 0<N) (hd : 0≤d) (hR : 0≤R)(hc : ∀ t∈Icc (0 : ℝ) T,|β t-γ t|≤d)(hY : ∀ z : Fin (N+1) → ℝ,∀ j≤N,|euler T N β (crossFeedback V U) z j-euler T N γ (fun t ↦ deriv (V t)) z j|≤R) :|crossMeshSource T N γ β V U-ordinaryMeshSource T N γ β V|≤T*d*L*R := byhave hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg _)have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT hN hjhave hfm (j : ℕ) (hj : j<N) : Measurable (crossFeedback V U (meshTime T N j)) :=(((hU.smooth _ (htime j hj.le)).continuous_deriv (by norm_num)).measurable.add((hV.smooth _ (htime j hj.le)).continuous_deriv (by norm_num)).measurable).div_const 2have hfb (j : ℕ) (hj : j<N) (x : ℝ) : |crossFeedback V U (meshTime T N j) x|≤1 :=crossFeedback_bound (hV.bounded _ (htime j hj.le) x) (hU.bounded _ (htime j hj.le) x)have hm (j : Fin N) :|(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N β (crossFeedback V U) z j))^2∂gaussianProduct (Fin (N+1)))-(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N γ (fun t ↦ deriv (V t)) z j))^2∂gaussianProduct (Fin (N+1)))|≤L*R := byhave hLip := hV.product_lipschitzWith (htime j j.isLt.le)have hM1 := lipschitz_comp_memLp_finite hLip (euler_memLp T N β (crossFeedback V U) hfm hfb j j.isLt.le)have hM2 := lipschitz_comp_memLp_finite hLip (euler_memLp T N γ (fun t ↦ deriv (V t))(fun k hk ↦ ((hV.smooth _ (htime k hk.le)).continuous_deriv (by norm_num)).measurable)(fun k hk x ↦ hV.bounded _ (htime k hk.le) x) j j.isLt.le)rw [←integral_sub (f := fun z ↦ (1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N β (crossFeedback V U) z j))^2)(g := fun z ↦ (1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N γ (fun t ↦ deriv (V t)) z j))^2)(hM1.integrable (by norm_num)) (hM2.integrable (by norm_num))]apply (abs_integral_le_integral_abs).transcalc_ ≤ ∫ _ : Fin (N+1) → ℝ,|L*R| ∂gaussianProduct (Fin (N+1)) := byapply integral_mono ((hM1.integrable (by norm_num)).sub (hM2.integrable (by norm_num))).norm (integrable_const _)intro zhave hh := hLip.dist_le_mul (euler T N β (crossFeedback V U) z j) (euler T N γ (fun t ↦ deriv (V t)) z j)rw [Real.dist_eq,Real.dist_eq,Real.coe_toNNReal _ hV.L_nonneg] at hhexact (hh.trans (mul_le_mul_of_nonneg_left (hY z j j.isLt.le) hV.L_nonneg)).trans(le_abs_self (L*R))_=L*R := by simp [abs_of_nonneg (mul_nonneg hV.L_nonneg hR)]rw [crossMeshSource_half_form,ordinaryMeshSource,←mul_sub,←Finset.sum_sub_distrib,abs_mul,abs_of_nonneg hδ]calc_ ≤ stepSize T N*∑ j : Fin N,|(β (meshTime T N j)-γ (meshTime T N j))*((∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N β (crossFeedback V U) z j))^2 ∂gaussianProduct (Fin (N+1)))-(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N γ (fun t ↦ deriv (V t)) z j))^2 ∂gaussianProduct (Fin (N+1))))| := bysimp_rw [←mul_sub]exact mul_le_mul_of_nonneg_left (Finset.abs_sum_le_sum_abs _ _) hδ_ ≤ stepSize T N*∑ _ : Fin N,d*(L*R) := byapply mul_le_mul_of_nonneg_left _ hδapply Finset.sum_le_sumintro j hjrw [abs_mul]exact mul_le_mul (hc _ (htime j j.isLt.le)) (hm j) (abs_nonneg _) hd_=T*d*L*R := bysimp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,stepSize]field_simpend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuenoncomputable def ordinaryMeshSource (T : ℝ) (N : ℕ) (γ β : ℝ → ℝ) (V : ℝ → ℝ → ℝ) : ℝ :=stepSize T N*∑ j : Fin N,(β (meshTime T N j)-γ (meshTime T N j))*(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j))(euler T N γ (fun t ↦ deriv (V t)) z j))^2 ∂gaussianProduct (Fin (N+1)))lemma crossMeshSource_half_form (T : ℝ) (N : ℕ) (γ β : ℝ → ℝ) (V U : ℝ → ℝ → ℝ) :crossMeshSource T N γ β V U=stepSize T N*∑ j : Fin N,(β (meshTime T N j)-γ (meshTime T N j))*(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j))(euler T N β (crossFeedback V U) z j))^2 ∂gaussianProduct (Fin (N+1))) := byunfold crossMeshSourcerw [Fin.sum_univ_eq_sum_range (fun j : ℕ ↦ (β (meshTime T N j)-γ (meshTime T N j))*(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j))(euler T N β (crossFeedback V U) z j))^2 ∂gaussianProduct (Fin (N+1))))]simp only [integral_const_mul,Finset.mul_sum]apply Finset.sum_congr rflintro j hjringlemma crossMeshSource_difference_bound {T K L K' L' d R : ℝ}{γ β : ℝ → ℝ} {V U : ℝ → ℝ → ℝ}(hV : ValueStrip T γ V K L) (hU : ValueStrip T β U K' L')(hT : 0≤T) {N : ℕ} (hN : 0<N) (hd : 0≤d) (hR : 0≤R)(hc : ∀ t∈Icc (0 : ℝ) T,|β t-γ t|≤d)(hY : ∀ z : Fin (N+1) → ℝ,∀ j≤N,|euler T N β (crossFeedback V U) z j-euler T N γ (fun t ↦ deriv (V t)) z j|≤R) :|crossMeshSource T N γ β V U-ordinaryMeshSource T N γ β V|≤T*d*L*R := byhave hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg _)have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT hN hjhave hfm (j : ℕ) (hj : j<N) : Measurable (crossFeedback V U (meshTime T N j)) :=(((hU.smooth _ (htime j hj.le)).continuous_deriv (by norm_num)).measurable.add((hV.smooth _ (htime j hj.le)).continuous_deriv (by norm_num)).measurable).div_const 2have hfb (j : ℕ) (hj : j<N) (x : ℝ) : |crossFeedback V U (meshTime T N j) x|≤1 :=crossFeedback_bound (hV.bounded _ (htime j hj.le) x) (hU.bounded _ (htime j hj.le) x)have hm (j : Fin N) :|(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N β (crossFeedback V U) z j))^2∂gaussianProduct (Fin (N+1)))-(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N γ (fun t ↦ deriv (V t)) z j))^2∂gaussianProduct (Fin (N+1)))|≤L*R := byhave hLip := hV.product_lipschitzWith (htime j j.isLt.le)have hM1 := lipschitz_comp_memLp_finite hLip (euler_memLp T N β (crossFeedback V U) hfm hfb j j.isLt.le)have hM2 := lipschitz_comp_memLp_finite hLip (euler_memLp T N γ (fun t ↦ deriv (V t))(fun k hk ↦ ((hV.smooth _ (htime k hk.le)).continuous_deriv (by norm_num)).measurable)(fun k hk x ↦ hV.bounded _ (htime k hk.le) x) j j.isLt.le)rw [←integral_sub (f := fun z ↦ (1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N β (crossFeedback V U) z j))^2)(g := fun z ↦ (1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N γ (fun t ↦ deriv (V t)) z j))^2)(hM1.integrable (by norm_num)) (hM2.integrable (by norm_num))]apply (abs_integral_le_integral_abs).transcalc_ ≤ ∫ _ : Fin (N+1) → ℝ,|L*R| ∂gaussianProduct (Fin (N+1)) := byapply integral_mono ((hM1.integrable (by norm_num)).sub (hM2.integrable (by norm_num))).norm (integrable_const _)intro zhave hh := hLip.dist_le_mul (euler T N β (crossFeedback V U) z j) (euler T N γ (fun t ↦ deriv (V t)) z j)rw [Real.dist_eq,Real.dist_eq,Real.coe_toNNReal _ hV.L_nonneg] at hhexact (hh.trans (mul_le_mul_of_nonneg_left (hY z j j.isLt.le) hV.L_nonneg)).trans(le_abs_self (L*R))_=L*R := by simp [abs_of_nonneg (mul_nonneg hV.L_nonneg hR)]rw [crossMeshSource_half_form,ordinaryMeshSource,←mul_sub,←Finset.sum_sub_distrib,abs_mul,abs_of_nonneg hδ]calc_ ≤ stepSize T N*∑ j : Fin N,|(β (meshTime T N j)-γ (meshTime T N j))*((∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N β (crossFeedback V U) z j))^2 ∂gaussianProduct (Fin (N+1)))-(∫ z,(1/2 : ℝ)*(deriv (V (meshTime T N j)) (euler T N γ (fun t ↦ deriv (V t)) z j))^2 ∂gaussianProduct (Fin (N+1))))| := bysimp_rw [←mul_sub]exact mul_le_mul_of_nonneg_left (Finset.abs_sum_le_sum_abs _ _) hδ_ ≤ stepSize T N*∑ _ : Fin N,d*(L*R) := byapply mul_le_mul_of_nonneg_left _ hδapply Finset.sum_le_sumintro j hjrw [abs_mul]exact mul_le_mul (hc _ (htime j j.isLt.le)) (hm j) (abs_nonneg _) hd_=T*d*L*R := bysimp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,stepSize]field_simpend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108import Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshComparisonimport OAI.Probability.SKValue.Variation.WeightedMomentsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuelemma ordinaryMeshSource_eq (W : BrownianSpace) (γ β : OrderParameter) (T : ℝ) (N : ℕ) :ordinaryMeshSource T N γ.coeff β.coeff (phi W γ)=weightedEulerMoment W γ β T N-weightedEulerMoment W γ γ T N := byhave he : gradient W γ=(fun t ↦ deriv (phi W γ t)) := rflsimp only [ordinaryMeshSource,weightedEulerMoment,he,←mul_sub,←Finset.sum_sub_distrib]congr 1apply Finset.sum_congr rflintro j hjringlemma IsDiffusion.cross_value_bound {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) (β : OrderParameter){T Kv Lv Lu d e : ℝ} (hT : 0<T) (hT1 : T<1)(hV : ValueStrip T γ.coeff (phi W γ) Kv Lv)(hLu : 0≤Lu) (hd : 0≤d) (he : 0≤e)(hc : ∀ t∈Icc (0 : ℝ) T,|(β.coeff t)-(γ.coeff t)|≤d)(hu : ∀ t∈Icc (0 : ℝ) T,∀ x y,|gradient W γ t x-gradient W γ t y|≤Lu*|x-y|)(hs : ∀ t∈Icc (0 : ℝ) T,∀ x,|gradient W β t x-gradient W γ t x|≤e) :phi W β 0 0-phi W γ 0 0≤(3/2 : ℝ)*(∫ t in T..1,|β.cutoff t-γ.cutoff t|)+((∫ t in (0 : ℝ)..T,β.coeff t*(∫ ω,(1/2 : ℝ)*(gradient W γ t (X t ω))^2 ∂W.μ))-(∫ t in (0 : ℝ)..T,γ.coeff t*(∫ ω,(1/2 : ℝ)*(gradient W γ t (X t ω))^2 ∂W.μ)))+T*d*Lv*(T*(d+γ.coeff T*e)*Real.exp (T*γ.coeff T*Lu)) := byobtain ⟨Kv',Lv',K',L',D',Lu',La',hU,rest⟩ := sourceStripRegularity W β T ⟨hT.le,hT1⟩let G := max (γ.coeff T) (β.coeff T)let R := T*(d+γ.coeff T*e)*Real.exp (T*γ.coeff T*Lu)let B := (3/2 : ℝ)*(∫ t in T..1,|β.cutoff t-γ.cutoff t|)let err (N : ℕ) :=T*Real.sqrt (stepSize T N)*(cubicEnvelopeMean G Kv ((1/2+G)*Lv)+cubicEnvelopeMean G Kv' ((1/2+G)*Lv'))+stepSize T N*Kv*(γ.coeff T-γ.coeff 0)+stepSize T N*Kv'*(β.coeff T-β.coeff 0)have hγT : 0≤γ.coeff T := γ.nonneg T ⟨hT.le,hT1⟩have hR : 0≤R := by dsimp [R]; positivityhave heN (N : ℕ) (hN : 0<N) : phi W β 0 0-phi W γ 0 0≤B+(weightedEulerMoment W γ β T N-weightedEulerMoment W γ γ T N)+T*d*Lv*R+err N := byhave htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hjhave hfb (t : ℝ) (ht : t∈Icc (0 : ℝ) T) (x : ℝ) :|crossFeedback (phi W γ) (phi W β) t x|≤1 :=crossFeedback_bound (hV.bounded t ht x) (hU.bounded t ht x)have hfs (t : ℝ) (ht : t∈Icc (0 : ℝ) T) (x : ℝ) :|crossFeedback (phi W γ) (phi W β) t x-gradient W γ t x|≤e := byhave hh := hs t ht xhave hh' : |crossFeedback (phi W γ) (phi W β) t x-gradient W γ t x|=|gradient W β t x-gradient W γ t x|/2 := bydsimp only [crossFeedback,gradient]rw [show (deriv (phi W β t) x+deriv (phi W γ t) x)/2-deriv (phi W γ t) x=(deriv (phi W β t) x-deriv (phi W γ t) x)/2 by ring,abs_div,abs_of_pos (by norm_num : (0 : ℝ)<2)]rw [hh']linarithhave hY (z : Fin (N+1) → ℝ) (j : ℕ) (hj : j≤N) :|euler T N β.coeff (crossFeedback (phi W γ) (phi W β)) z j-euler T N γ.coeff (gradient W γ) z j|≤R := byapply euler_same_noise_bound hT.le hN hγT hLu hd he· intro k hkrw [abs_of_nonneg (γ.nonneg _ ⟨(htime k hk.le).1,(htime k hk.le).2.trans_lt hT1⟩)]exact γ.monotone ⟨(htime k hk.le).1,(htime k hk.le).2.trans_lt hT1⟩ ⟨hT.le,hT1⟩ (htime k hk.le).2· intro k hk; exact hc _ (htime k hk.le)· intro k hk; exact hfb _ (htime k hk.le)· intro k hk; exact hfs _ (htime k hk.le)· intro k hk; exact hu _ (htime k hk.le)· exact hjhave htelescope := cross_value_mesh_expectation hV hU hT hT1.le(le_max_left _ _ : γ.coeff T≤G) (le_max_right _ _ : β.coeff T≤G) hNhave hcompare := crossMeshSource_difference_bound hV hU hT.le hN hd hR hc hYrw [ordinaryMeshSource_eq] at hcomparehave hterminal : (∫ z,phi W β T (euler T N β.coeff (crossFeedback (phi W γ) (phi W β)) z N)-phi W γ T (euler T N β.coeff (crossFeedback (phi W γ) (phi W β)) z N)∂gaussianProduct (Fin (N+1)))≤B := byapply (le_abs_self _).transsimpa only [Real.norm_eq_abs,probReal_univ,mul_one] using(norm_integral_le_of_norm_le_const (μ := gaussianProduct (Fin (N+1))) (C := B)(f := fun z ↦ phi W β T (euler T N β.coeff (crossFeedback (phi W γ) (phi W β)) z N)-phi W γ T (euler T N β.coeff (crossFeedback (phi W γ) (phi W β)) z N))(Eventually.of_forall (fun z ↦ phi_difference_bound W γ β ⟨hT.le,hT1.le⟩ _)))have htlow := (abs_le.mp htelescope).1have hcup := (abs_le.mp hcompare).2dsimp only [err]linarithhave hδ : Tendsto (fun N : ℕ ↦ stepSize T N) atTop (𝓝 (0 : ℝ)) := tendsto_const_div_atTop_nhds_zero_nat Thave hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδhave herr : Tendsto err atTop (𝓝 0) := bysimpa only [err,Function.comp_def,Real.sqrt_zero,mul_zero,zero_mul,zero_add] using(((hsqrt.const_mul T).mul_const (cubicEnvelopeMean G Kv ((1/2+G)*Lv)+cubicEnvelopeMean G Kv' ((1/2+G)*Lv'))).add((hδ.mul_const Kv).mul_const (γ.coeff T-γ.coeff 0))).add((hδ.mul_const Kv').mul_const (β.coeff T-β.coeff 0))have hlim := (((((hX.weightedEulerMoment_tendsto β hT hT1).sub(hX.weightedEulerMoment_tendsto γ hT hT1)).const_add B).add_const (T*d*Lv*R)).add herr)have hh := ge_of_tendsto hlim (by filter_upwards [eventually_gt_atTop 0] with N hN using heN N hN)simpa only [add_zero,B,R] using hhend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108import Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshComparisonimport OAI.Probability.SKValue.Variation.WeightedMomentsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuelemma ordinaryMeshSource_eq (W : BrownianSpace) (γ β : OrderParameter) (T : ℝ) (N : ℕ) :ordinaryMeshSource T N γ.coeff β.coeff (phi W γ)=weightedEulerMoment W γ β T N-weightedEulerMoment W γ γ T N := byhave he : gradient W γ=(fun t ↦ deriv (phi W γ t)) := rflsimp only [ordinaryMeshSource,weightedEulerMoment,he,←mul_sub,←Finset.sum_sub_distrib]congr 1apply Finset.sum_congr rflintro j hjringlemma IsDiffusion.cross_value_bound {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) (β : OrderParameter){T Kv Lv Lu d e : ℝ} (hT : 0<T) (hT1 : T<1)(hV : ValueStrip T γ.coeff (phi W γ) Kv Lv)(hLu : 0≤Lu) (hd : 0≤d) (he : 0≤e)(hc : ∀ t∈Icc (0 : ℝ) T,|(β.coeff t)-(γ.coeff t)|≤d)(hu : ∀ t∈Icc (0 : ℝ) T,∀ x y,|gradient W γ t x-gradient W γ t y|≤Lu*|x-y|)(hs : ∀ t∈Icc (0 : ℝ) T,∀ x,|gradient W β t x-gradient W γ t x|≤e) :phi W β 0 0-phi W γ 0 0≤(3/2 : ℝ)*(∫ t in T..1,|β.cutoff t-γ.cutoff t|)+((∫ t in (0 : ℝ)..T,β.coeff t*(∫ ω,(1/2 : ℝ)*(gradient W γ t (X t ω))^2 ∂W.μ))-(∫ t in (0 : ℝ)..T,γ.coeff t*(∫ ω,(1/2 : ℝ)*(gradient W γ t (X t ω))^2 ∂W.μ)))+T*d*Lv*(T*(d+γ.coeff T*e)*Real.exp (T*γ.coeff T*Lu)) := byobtain ⟨Kv',Lv',K',L',D',Lu',La',hU,rest⟩ := sourceStripRegularity W β T ⟨hT.le,hT1⟩let G := max (γ.coeff T) (β.coeff T)let R := T*(d+γ.coeff T*e)*Real.exp (T*γ.coeff T*Lu)let B := (3/2 : ℝ)*(∫ t in T..1,|β.cutoff t-γ.cutoff t|)let err (N : ℕ) :=T*Real.sqrt (stepSize T N)*(cubicEnvelopeMean G Kv ((1/2+G)*Lv)+cubicEnvelopeMean G Kv' ((1/2+G)*Lv'))+stepSize T N*Kv*(γ.coeff T-γ.coeff 0)+stepSize T N*Kv'*(β.coeff T-β.coeff 0)have hγT : 0≤γ.coeff T := γ.nonneg T ⟨hT.le,hT1⟩have hR : 0≤R := by dsimp [R]; positivityhave heN (N : ℕ) (hN : 0<N) : phi W β 0 0-phi W γ 0 0≤B+(weightedEulerMoment W γ β T N-weightedEulerMoment W γ γ T N)+T*d*Lv*R+err N := byhave htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hjhave hfb (t : ℝ) (ht : t∈Icc (0 : ℝ) T) (x : ℝ) :|crossFeedback (phi W γ) (phi W β) t x|≤1 :=crossFeedback_bound (hV.bounded t ht x) (hU.bounded t ht x)have hfs (t : ℝ) (ht : t∈Icc (0 : ℝ) T) (x : ℝ) :|crossFeedback (phi W γ) (phi W β) t x-gradient W γ t x|≤e := byhave hh := hs t ht xhave hh' : |crossFeedback (phi W γ) (phi W β) t x-gradient W γ t x|=|gradient W β t x-gradient W γ t x|/2 := bydsimp only [crossFeedback,gradient]rw [show (deriv (phi W β t) x+deriv (phi W γ t) x)/2-deriv (phi W γ t) x=(deriv (phi W β t) x-deriv (phi W γ t) x)/2 by ring,abs_div,abs_of_pos (by norm_num : (0 : ℝ)<2)]rw [hh']linarithhave hY (z : Fin (N+1) → ℝ) (j : ℕ) (hj : j≤N) :|euler T N β.coeff (crossFeedback (phi W γ) (phi W β)) z j-euler T N γ.coeff (gradient W γ) z j|≤R := byapply euler_same_noise_bound hT.le hN hγT hLu hd he· intro k hkrw [abs_of_nonneg (γ.nonneg _ ⟨(htime k hk.le).1,(htime k hk.le).2.trans_lt hT1⟩)]exact γ.monotone ⟨(htime k hk.le).1,(htime k hk.le).2.trans_lt hT1⟩ ⟨hT.le,hT1⟩ (htime k hk.le).2· intro k hk; exact hc _ (htime k hk.le)· intro k hk; exact hfb _ (htime k hk.le)· intro k hk; exact hfs _ (htime k hk.le)· intro k hk; exact hu _ (htime k hk.le)· exact hjhave htelescope := cross_value_mesh_expectation hV hU hT hT1.le(le_max_left _ _ : γ.coeff T≤G) (le_max_right _ _ : β.coeff T≤G) hNhave hcompare := crossMeshSource_difference_bound hV hU hT.le hN hd hR hc hYrw [ordinaryMeshSource_eq] at hcomparehave hterminal : (∫ z,phi W β T (euler T N β.coeff (crossFeedback (phi W γ) (phi W β)) z N)-phi W γ T (euler T N β.coeff (crossFeedback (phi W γ) (phi W β)) z N)∂gaussianProduct (Fin (N+1)))≤B := byapply (le_abs_self _).transsimpa only [Real.norm_eq_abs,probReal_univ,mul_one] using(norm_integral_le_of_norm_le_const (μ := gaussianProduct (Fin (N+1))) (C := B)(f := fun z ↦ phi W β T (euler T N β.coeff (crossFeedback (phi W γ) (phi W β)) z N)-phi W γ T (euler T N β.coeff (crossFeedback (phi W γ) (phi W β)) z N))(Eventually.of_forall (fun z ↦ phi_difference_bound W γ β ⟨hT.le,hT1.le⟩ _)))have htlow := (abs_le.mp htelescope).1have hcup := (abs_le.mp hcompare).2dsimp only [err]linarithhave hδ : Tendsto (fun N : ℕ ↦ stepSize T N) atTop (𝓝 (0 : ℝ)) := tendsto_const_div_atTop_nhds_zero_nat Thave hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδhave herr : Tendsto err atTop (𝓝 0) := bysimpa only [err,Function.comp_def,Real.sqrt_zero,mul_zero,zero_mul,zero_add] using(((hsqrt.const_mul T).mul_const (cubicEnvelopeMean G Kv ((1/2+G)*Lv)+cubicEnvelopeMean G Kv' ((1/2+G)*Lv'))).add((hδ.mul_const Kv).mul_const (γ.coeff T-γ.coeff 0))).add((hδ.mul_const Kv').mul_const (β.coeff T-β.coeff 0))have hlim := (((((hX.weightedEulerMoment_tendsto β hT hT1).sub(hX.weightedEulerMoment_tendsto γ hT hT1)).const_add B).add_const (T*d*Lv*R)).add herr)have hh := ge_of_tendsto hlim (by filter_upwards [eventually_gt_atTop 0] with N hN using heN N hN)simpa only [add_zero,B,R] using hhend SKValueendend OAI
12345678910111213141516171819202122232425262728293031323334353637383940414243import Mathlibimport OAI.Probability.SKValue.Coercivity.LiteralCoercivitynamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValuelemma IsDiffusion.curvature_generator_nonneg {W:BrownianSpace} {γ:OrderParameter} {X:ℝ → W.Ω → ℝ}(hX:IsDiffusion W γ X) {t:ℝ} (ht:t∈Ioo (0:ℝ) 1):0≤∫ z,(iteratedDeriv 3 (deriv (phi W γ t)) (X t z))^2-12*γ.coeff t*iteratedDeriv 1 (deriv (phi W γ t)) (X t z)*(iteratedDeriv 2 (deriv (phi W γ t)) (X t z))^2+6*(γ.coeff t)^2*(iteratedDeriv 1 (deriv (phi W γ t)) (X t z))^4 ∂W.μ := byhave hc:=γ.nonneg t ⟨ht.1.le,ht.2⟩rcases hc.eq_or_lt with hc|hc· rw [←hc]simp only [mul_zero,zero_mul,sub_zero,zero_pow (by norm_num: (2:ℕ)≠0),add_zero]exact integral_nonneg (fun z ↦ sq_nonneg _)· have h:=hX.literal_coercivity ⟨t,ht⟩have hn:0≤(1/1000:ℝ)*(∫ z,(spatialJet (γ.coeff t) (phi W γ t) 1 (X t z))^4 ∂W.μ) := byapply mul_nonneg (by norm_num)exact integral_nonneg (fun z ↦ by positivity)have hn:=hn.trans hhave he:(fun z ↦ (spatialJet (γ.coeff t) (phi W γ t) 3 (X t z))^2-12*spatialJet (γ.coeff t) (phi W γ t) 1 (X t z)*(spatialJet (γ.coeff t) (phi W γ t) 2 (X t z))^2+6*(spatialJet (γ.coeff t) (phi W γ t) 1 (X t z))^4)=(fun z ↦ (γ.coeff t)^2*((iteratedDeriv 3 (deriv (phi W γ t)) (X t z))^2-12*γ.coeff t*iteratedDeriv 1 (deriv (phi W γ t)) (X t z)*(iteratedDeriv 2 (deriv (phi W γ t)) (X t z))^2+6*(γ.coeff t)^2*(iteratedDeriv 1 (deriv (phi W γ t)) (X t z))^4)) := byfunext zsimp only [spatialJet]ringchange 0≤∫ z,(spatialJet (γ.coeff t) (phi W γ t) 3 (X t z))^2-12*spatialJet (γ.coeff t) (phi W γ t) 1 (X t z)*(spatialJet (γ.coeff t) (phi W γ t) 2 (X t z))^2+6*(spatialJet (γ.coeff t) (phi W γ t) 1 (X t z))^4 ∂W.μ at hnrw [he,integral_const_mul] at hnexact nonneg_of_mul_nonneg_right hn (sq_pos_of_pos hc)end SKValueendend OAI12345678910111213141516171819202122232425262728293031323334353637383940414243import Mathlibimport OAI.Probability.SKValue.Coercivity.LiteralCoercivitynamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValuelemma IsDiffusion.curvature_generator_nonneg {W:BrownianSpace} {γ:OrderParameter} {X:ℝ → W.Ω → ℝ}(hX:IsDiffusion W γ X) {t:ℝ} (ht:t∈Ioo (0:ℝ) 1):0≤∫ z,(iteratedDeriv 3 (deriv (phi W γ t)) (X t z))^2-12*γ.coeff t*iteratedDeriv 1 (deriv (phi W γ t)) (X t z)*(iteratedDeriv 2 (deriv (phi W γ t)) (X t z))^2+6*(γ.coeff t)^2*(iteratedDeriv 1 (deriv (phi W γ t)) (X t z))^4 ∂W.μ := byhave hc:=γ.nonneg t ⟨ht.1.le,ht.2⟩rcases hc.eq_or_lt with hc|hc· rw [←hc]simp only [mul_zero,zero_mul,sub_zero,zero_pow (by norm_num: (2:ℕ)≠0),add_zero]exact integral_nonneg (fun z ↦ sq_nonneg _)· have h:=hX.literal_coercivity ⟨t,ht⟩have hn:0≤(1/1000:ℝ)*(∫ z,(spatialJet (γ.coeff t) (phi W γ t) 1 (X t z))^4 ∂W.μ) := byapply mul_nonneg (by norm_num)exact integral_nonneg (fun z ↦ by positivity)have hn:=hn.trans hhave he:(fun z ↦ (spatialJet (γ.coeff t) (phi W γ t) 3 (X t z))^2-12*spatialJet (γ.coeff t) (phi W γ t) 1 (X t z)*(spatialJet (γ.coeff t) (phi W γ t) 2 (X t z))^2+6*(spatialJet (γ.coeff t) (phi W γ t) 1 (X t z))^4)=(fun z ↦ (γ.coeff t)^2*((iteratedDeriv 3 (deriv (phi W γ t)) (X t z))^2-12*γ.coeff t*iteratedDeriv 1 (deriv (phi W γ t)) (X t z)*(iteratedDeriv 2 (deriv (phi W γ t)) (X t z))^2+6*(γ.coeff t)^2*(iteratedDeriv 1 (deriv (phi W γ t)) (X t z))^4)) := byfunext zsimp only [spatialJet]ringchange 0≤∫ z,(spatialJet (γ.coeff t) (phi W γ t) 3 (X t z))^2-12*spatialJet (γ.coeff t) (phi W γ t) 1 (X t z)*(spatialJet (γ.coeff t) (phi W γ t) 2 (X t z))^2+6*(spatialJet (γ.coeff t) (phi W γ t) 1 (X t z))^4 ∂W.μ at hnrw [he,integral_const_mul] at hnexact nonneg_of_mul_nonneg_right hn (sq_pos_of_pos hc)end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384import Mathlibimport OAI.Probability.SKValue.Processes.EulerLimitProcessnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filter Functionopen scoped Topology NNRealnamespace SKValuenoncomputable def terminalEulerProcess (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω):ℝ :=limsup (fun n:ℕ ↦ eulerLimitProcess W γ (terminalTime n) z) atTopnoncomputable def diffusionProcess (W:BrownianSpace) (γ:OrderParameter) (t:ℝ) (z:W.Ω):ℝ :=if t<1 then eulerLimitProcess W γ t z else terminalEulerProcess W γ zlemma terminalEulerProcess_measurable (W:BrownianSpace) (γ:OrderParameter):StronglyMeasurable[W.filtration 1] (terminalEulerProcess W γ) :=byapply Measurable.stronglyMeasurableapply Measurable.limsupintro napply ((eulerLimitProcess_measurable W γ (terminalTime n)).mono ?_).measurableapply W.filtration.monoexact Real.toNNReal_le_iff_le_coe.mpr (terminalTime_mem n).2.lelemma diffusionProcess_measurable (W:BrownianSpace) (γ:OrderParameter) {t:ℝ}:StronglyMeasurable[W.filtration t.toNNReal] (diffusionProcess W γ t) :=bychange StronglyMeasurable[W.filtration t.toNNReal] (fun z ↦ if t<1 then eulerLimitProcess W γ t z else terminalEulerProcess W γ z)by_cases ht:t<1· simp only [ite_eq_left ht]exact eulerLimitProcess_measurable W γ t· simp only [ite_eq_right ht]apply (terminalEulerProcess_measurable W γ).mono (W.filtration.mono ?_)exact (Real.le_toNNReal_iff_coe_le (zero_le_one.trans (not_lt.mp ht))).mpr (not_lt.mp ht)lemma diffusionProcess_adapted (W:BrownianSpace) (γ:OrderParameter):Adapted W.filtration (fun t z ↦ diffusionProcess W γ (min (t:ℝ) 1) z) :=byintro tapply ((diffusionProcess_measurable W γ (t:=min (t:ℝ) 1)).mono ?_).measurableapply W.filtration.monoexact Real.toNNReal_le_iff_le_coe.mpr (min_le_left _ _)lemma diffusionProcess_path (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω)(hb:Continuous (fun t:ℝ ↦ W.B t.toNNReal z)) (h0:W.B 0 z=0):ContinuousOn (fun t ↦ diffusionProcess W γ t z) (Icc (0:ℝ) 1) ∧∀t∈Icc (0:ℝ) 1,diffusionProcess W γ t z=W.B t.toNNReal z+∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (diffusionProcess W γ s z) :=bylet f:=fun s ↦ γ.coeff s*gradient W γ s (eulerLimitProcess W γ s z)let F:=fun t ↦ W.B t.toNNReal z+∫s in (0:ℝ)..t,f shave hi:IntervalIntegrable f volume 0 1:=eulerLimitProcess_drift_integrable W γ z hb h0have hc:ContinuousOn F (Icc (0:ℝ) 1):=byapply hb.continuousOn.addsimpa only [uIcc_of_le (by norm_num:(0:ℝ)≤1)] usingintervalIntegral.continuousOn_primitive_interval' hi left_mem_uIcchave he:∀t∈Ico (0:ℝ) 1,eulerLimitProcess W γ t z=F t:=byintro t htexact (eulerLimitProcess_local_path W γ z hb h0 ht).2.2 t ⟨ht.1,le_rfl⟩have hl:Tendsto (fun n ↦ eulerLimitProcess W γ (terminalTime n) z) atTop (𝓝 (F 1)):=byhave htime:Tendsto terminalTime atTop (𝓝[Icc (0:ℝ) 1] (1:ℝ)):=tendsto_nhdsWithin_iff.mpr ⟨(tendsto_nhdsWithin_iff.mp terminalTime_tendsto).1,Eventually.of_forall (fun n ↦ ⟨(terminalTime_mem n).1,(terminalTime_mem n).2.le⟩)⟩apply ((hc 1 ⟨by norm_num,le_rfl⟩).tendsto.comp htime).congrintro nexact (he _ (terminalTime_mem n)).symmhave hU:terminalEulerProcess W γ z=F 1:=hl.limsup_eqhave hEq (t:ℝ) (ht:t∈Icc (0:ℝ) 1):diffusionProcess W γ t z=F t:=byby_cases ht1:t<1· simpa only [diffusionProcess,ite_eq_left ht1] using he t ⟨ht.1,ht1⟩· have ht':t=1:=le_antisymm ht.2 (not_lt.mp ht1)subst tsimpa only [diffusionProcess,lt_self_iff_false,ite_false] using hUrefine ⟨hc.congr hEq,?_⟩intro t htrw [hEq t ht]change W.B t.toNNReal z+(∫s in (0:ℝ)..t,f s)=_congr 1apply intervalIntegral.integral_congr_Ioo_of_le ht.1intro s hssimp only [f,diffusionProcess,ite_eq_left (hs.2.trans_le ht.2)]theorem diffusionProcess_isDiffusion (W:BrownianSpace) (γ:OrderParameter):IsDiffusion W γ (diffusionProcess W γ) :=byrefine ⟨diffusionProcess_adapted W γ,?_⟩filter_upwards [W.brownian.cont,W.brownian.toIsPreBrownianReal.eval_zero_ae_eq_zero] with z hz h0exact diffusionProcess_path W γ z (hz.comp (by fun_prop:Continuous (fun t:ℝ ↦ t.toNNReal))) h0lemma exists_diffusion (W:BrownianSpace) (γ:OrderParameter):∃X:ℝ → W.Ω → ℝ,IsDiffusion W γ X:=⟨diffusionProcess W γ,diffusionProcess_isDiffusion W γ⟩end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384import Mathlibimport OAI.Probability.SKValue.Processes.EulerLimitProcessnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filter Functionopen scoped Topology NNRealnamespace SKValuenoncomputable def terminalEulerProcess (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω):ℝ :=limsup (fun n:ℕ ↦ eulerLimitProcess W γ (terminalTime n) z) atTopnoncomputable def diffusionProcess (W:BrownianSpace) (γ:OrderParameter) (t:ℝ) (z:W.Ω):ℝ :=if t<1 then eulerLimitProcess W γ t z else terminalEulerProcess W γ zlemma terminalEulerProcess_measurable (W:BrownianSpace) (γ:OrderParameter):StronglyMeasurable[W.filtration 1] (terminalEulerProcess W γ) :=byapply Measurable.stronglyMeasurableapply Measurable.limsupintro napply ((eulerLimitProcess_measurable W γ (terminalTime n)).mono ?_).measurableapply W.filtration.monoexact Real.toNNReal_le_iff_le_coe.mpr (terminalTime_mem n).2.lelemma diffusionProcess_measurable (W:BrownianSpace) (γ:OrderParameter) {t:ℝ}:StronglyMeasurable[W.filtration t.toNNReal] (diffusionProcess W γ t) :=bychange StronglyMeasurable[W.filtration t.toNNReal] (fun z ↦ if t<1 then eulerLimitProcess W γ t z else terminalEulerProcess W γ z)by_cases ht:t<1· simp only [ite_eq_left ht]exact eulerLimitProcess_measurable W γ t· simp only [ite_eq_right ht]apply (terminalEulerProcess_measurable W γ).mono (W.filtration.mono ?_)exact (Real.le_toNNReal_iff_coe_le (zero_le_one.trans (not_lt.mp ht))).mpr (not_lt.mp ht)lemma diffusionProcess_adapted (W:BrownianSpace) (γ:OrderParameter):Adapted W.filtration (fun t z ↦ diffusionProcess W γ (min (t:ℝ) 1) z) :=byintro tapply ((diffusionProcess_measurable W γ (t:=min (t:ℝ) 1)).mono ?_).measurableapply W.filtration.monoexact Real.toNNReal_le_iff_le_coe.mpr (min_le_left _ _)lemma diffusionProcess_path (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω)(hb:Continuous (fun t:ℝ ↦ W.B t.toNNReal z)) (h0:W.B 0 z=0):ContinuousOn (fun t ↦ diffusionProcess W γ t z) (Icc (0:ℝ) 1) ∧∀t∈Icc (0:ℝ) 1,diffusionProcess W γ t z=W.B t.toNNReal z+∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (diffusionProcess W γ s z) :=bylet f:=fun s ↦ γ.coeff s*gradient W γ s (eulerLimitProcess W γ s z)let F:=fun t ↦ W.B t.toNNReal z+∫s in (0:ℝ)..t,f shave hi:IntervalIntegrable f volume 0 1:=eulerLimitProcess_drift_integrable W γ z hb h0have hc:ContinuousOn F (Icc (0:ℝ) 1):=byapply hb.continuousOn.addsimpa only [uIcc_of_le (by norm_num:(0:ℝ)≤1)] usingintervalIntegral.continuousOn_primitive_interval' hi left_mem_uIcchave he:∀t∈Ico (0:ℝ) 1,eulerLimitProcess W γ t z=F t:=byintro t htexact (eulerLimitProcess_local_path W γ z hb h0 ht).2.2 t ⟨ht.1,le_rfl⟩have hl:Tendsto (fun n ↦ eulerLimitProcess W γ (terminalTime n) z) atTop (𝓝 (F 1)):=byhave htime:Tendsto terminalTime atTop (𝓝[Icc (0:ℝ) 1] (1:ℝ)):=tendsto_nhdsWithin_iff.mpr ⟨(tendsto_nhdsWithin_iff.mp terminalTime_tendsto).1,Eventually.of_forall (fun n ↦ ⟨(terminalTime_mem n).1,(terminalTime_mem n).2.le⟩)⟩apply ((hc 1 ⟨by norm_num,le_rfl⟩).tendsto.comp htime).congrintro nexact (he _ (terminalTime_mem n)).symmhave hU:terminalEulerProcess W γ z=F 1:=hl.limsup_eqhave hEq (t:ℝ) (ht:t∈Icc (0:ℝ) 1):diffusionProcess W γ t z=F t:=byby_cases ht1:t<1· simpa only [diffusionProcess,ite_eq_left ht1] using he t ⟨ht.1,ht1⟩· have ht':t=1:=le_antisymm ht.2 (not_lt.mp ht1)subst tsimpa only [diffusionProcess,lt_self_iff_false,ite_false] using hUrefine ⟨hc.congr hEq,?_⟩intro t htrw [hEq t ht]change W.B t.toNNReal z+(∫s in (0:ℝ)..t,f s)=_congr 1apply intervalIntegral.integral_congr_Ioo_of_le ht.1intro s hssimp only [f,diffusionProcess,ite_eq_left (hs.2.trans_le ht.2)]theorem diffusionProcess_isDiffusion (W:BrownianSpace) (γ:OrderParameter):IsDiffusion W γ (diffusionProcess W γ) :=byrefine ⟨diffusionProcess_adapted W γ,?_⟩filter_upwards [W.brownian.cont,W.brownian.toIsPreBrownianReal.eval_zero_ae_eq_zero] with z hz h0exact diffusionProcess_path W γ z (hz.comp (by fun_prop:Continuous (fun t:ℝ ↦ t.toNNReal))) h0lemma exists_diffusion (W:BrownianSpace) (γ:OrderParameter):∃X:ℝ → W.Ω → ℝ,IsDiffusion W γ X:=⟨diffusionProcess W γ,diffusionProcess_isDiffusion W γ⟩end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import Mathlibimport OAI.Probability.SKValue.Equations.Shiftnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorslemma diffusion_gradient_condExp{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ)(hBm : ∀ t, StronglyMeasurable (B t)){T K L Lu : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ} {X : ℝ → Ω → ℝ}(hT1 : T≤1) (hLu : 0≤Lu) (h : GradientStripCore T γ u K L)(hLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(hXM : ∀ t∈Icc (0 : ℝ) T,StronglyMeasurable[Filtration.natural B hBm t.toNNReal] (X t))(hpaths : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧∀ t∈Icc (0 : ℝ) T, X t ω=B t.toNNReal ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)){a b : ℝ} (ha : a∈Icc (0 : ℝ) T) (hb : b∈Icc (0 : ℝ) T) (hab : a≤b) :μ[(fun ω ↦ u b (X b ω)) | Filtration.natural B hBm a.toNNReal]=ᵐ[μ](fun ω ↦ u a (X a ω)) := bylet ℱ := Filtration.natural B hBmby_cases heq : a=b· subst bhave hh := (h.smooth a ha).continuous.comp_stronglyMeasurable (hXM a ha)apply condExp_of_aestronglyMeasurable' (ℱ.le _) hh.aestronglyMeasurableexact Integrable.of_bound (hh.mono (ℱ.le _)).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ (Real.norm_eq_abs _).trans_le (h.bounded a ha _)))have hlt : a<b := lt_of_le_of_ne hab heqhave hba : 0<b-a := sub_pos.mpr hlthave hba1 : b-a≤1 := by linarith [hb.2,ha.1]let Y := fun t : ℝ ↦ X (a+t)let W := fun t : ℝ ↦ fun ω ↦ X a ω+B (a.toNNReal+t.toNNReal) ω-B a.toNNReal ωhave hmem (t : ℝ) (ht : t∈Icc (0 : ℝ) (b-a)) : a+t∈Icc (0 : ℝ) T := byconstructor <;> linarith [ha.1,hb.2,ht.1,ht.2]have hLip' : ∀ s∈Icc (0 : ℝ) (b-a), ∀ t∈Icc (0 : ℝ) (b-a), ∀ x y,|u (a+s) x-u (a+t) y|≤Lu*(|s-t|+|x-y|) := byintro s hs t ht x ysimpa only [add_sub_add_left_eq_sub] using hLip _ (hmem s hs) _ (hmem t ht) x yhave hYM (t : ℝ) (ht : t∈Icc (0 : ℝ) (b-a)) :StronglyMeasurable[ℱ (a.toNNReal+t.toNNReal)] (Y t) := byhave hh := hXM _ (hmem t ht)rw [Real.toNNReal_add ha.1 ht.1] at hhexact hhhave hWM (t : ℝ) (_ht : t∈Icc (0 : ℝ) (b-a)) : AEStronglyMeasurable (W t) μ :=((((hXM a ha).mono (ℱ.le _)).add (hBm _)).sub (hBm _)).aestronglyMeasurablehave hW : ∀ s∈Icc (0 : ℝ) (b-a), ∀ t∈Icc (0 : ℝ) (b-a), ∀ ω,W t ω-W s ω=B (a.toNNReal+t.toNNReal) ω-B (a.toNNReal+s.toNNReal) ω := byintro s _ t _ ωdsimp [W]ringhave hpaths' : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ Y t ω) (Icc (0 : ℝ) (b-a)) ∧IntervalIntegrable (fun s ↦ γ (a+s)*u (a+s) (Y s ω)) volume 0 (b-a) ∧∀ t∈Icc (0 : ℝ) (b-a), Y t ω=W t ω+∫ s in (0 : ℝ)..t, γ (a+s)*u (a+s) (Y s ω) := byfilter_upwards [hpaths] with ω hωhave hT : 0≤T := ha.1.trans ha.2have hi := intervalIntegrable_substrip hT hω.2.1 ha hbrefine ⟨hω.1.comp (continuous_const.add continuous_id).continuousOn hmem,?_,?_⟩· simpa only [sub_self,Y] using hi.comp_add_left a· intro t hthave hhalf := intervalIntegrable_substrip hT hω.2.1 ha (hmem t ht)have hleft := intervalIntegrable_substrip hT hω.2.1 ⟨le_rfl,hT⟩ hahave hsum := intervalIntegral.integral_add_adjacent_intervals hleft hhalfdsimp only [Y,W]rw [intervalIntegral.integral_comp_add_left (fun s ↦ γ s*u s (X s ω)) a,add_zero]rw [hω.2.2 _ (hmem t ht),hω.2.2 _ ha,Real.toNNReal_add ha.1 ht.1]linarithhave hh := diffusion_gradient_condExp_local hB hBm a.toNNReal hba hba1 hLu(h.shift ha.1 hab hb.2) hLip' hYM hWM hW hpaths'simpa only [Y,add_sub_cancel,add_zero] using hhend SKValuenamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorslemma diffusion_gradient_stopped_martingale{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{B : ℝ≥0 → Ω �� ℝ} (hB : IsPreBrownianReal B μ)(hBm : ∀ t, StronglyMeasurable (B t)){T K L Lu : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ} {X : ℝ → Ω → ℝ}(hT : 0≤T) (hT1 : T≤1) (hLu : 0≤Lu) (h : GradientStripCore T γ u K L)(hLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(hXM : ∀ t∈Icc (0 : ℝ) T,StronglyMeasurable[Filtration.natural B hBm t.toNNReal] (X t))(hpaths : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧∀ t∈Icc (0 : ℝ) T, X t ω=B t.toNNReal ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) :Martingale (fun t : ℝ≥0 ↦ fun ω ↦ u (min (t : ℝ) T) (X (min (t : ℝ) T) ω))(Filtration.natural B hBm) μ := bylet ℱ := Filtration.natural B hBmhave hmem (t : ℝ≥0) : min (t : ℝ) T∈Icc (0 : ℝ) T :=⟨le_min t.coe_nonneg hT,min_le_right _ _⟩have htime (t : ℝ≥0) : (min (t : ℝ) T).toNNReal≤t := byhave hh := Real.toNNReal_mono (min_le_left (t : ℝ) T)rw [Real.toNNReal_coe] at hhexact hhhave hm (t : ℝ≥0) : StronglyMeasurable[ℱ t](fun ω ↦ u (min (t : ℝ) T) (X (min (t : ℝ) T) ω)) :=((h.smooth _ (hmem t)).continuous.comp_stronglyMeasurable (hXM _ (hmem t))).mono (ℱ.mono (htime t))have hi (t : ℝ≥0) : Integrable (fun ω ↦ u (min (t : ℝ) T) (X (min (t : ℝ) T) ω)) μ :=Integrable.of_bound ((hm t).mono (ℱ.le _)).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ (Real.norm_eq_abs _).trans_le (h.bounded _ (hmem t) _)))refine ⟨hm,?_⟩intro s t hstby_cases hs : (s : ℝ)≤T· have ha : (s : ℝ)∈Icc (0 : ℝ) T := ⟨s.coe_nonneg,hs⟩have hh := diffusion_gradient_condExp hB hBm hT1 hLu h hLip hXM hpaths ha (hmem t)(le_min (by exact_mod_cast hst) hs)rw [Real.toNNReal_coe] at hhsimpa only [min_eq_left hs] using hh· have hs' : T≤(s : ℝ) := (lt_of_not_ge hs).lehave ht : T≤(t : ℝ) := hs'.trans (by exact_mod_cast hst)have hh := condExp_of_aestronglyMeasurable' (ℱ.le s) (hm s).aestronglyMeasurable (hi s)simpa only [min_eq_right hs',min_eq_right ht] using hhend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import Mathlibimport OAI.Probability.SKValue.Equations.Shiftnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorslemma diffusion_gradient_condExp{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ)(hBm : ∀ t, StronglyMeasurable (B t)){T K L Lu : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ} {X : ℝ → Ω → ℝ}(hT1 : T≤1) (hLu : 0≤Lu) (h : GradientStripCore T γ u K L)(hLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(hXM : ∀ t∈Icc (0 : ℝ) T,StronglyMeasurable[Filtration.natural B hBm t.toNNReal] (X t))(hpaths : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧∀ t∈Icc (0 : ℝ) T, X t ω=B t.toNNReal ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)){a b : ℝ} (ha : a∈Icc (0 : ℝ) T) (hb : b∈Icc (0 : ℝ) T) (hab : a≤b) :μ[(fun ω ↦ u b (X b ω)) | Filtration.natural B hBm a.toNNReal]=ᵐ[μ](fun ω ↦ u a (X a ω)) := bylet ℱ := Filtration.natural B hBmby_cases heq : a=b· subst bhave hh := (h.smooth a ha).continuous.comp_stronglyMeasurable (hXM a ha)apply condExp_of_aestronglyMeasurable' (ℱ.le _) hh.aestronglyMeasurableexact Integrable.of_bound (hh.mono (ℱ.le _)).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ (Real.norm_eq_abs _).trans_le (h.bounded a ha _)))have hlt : a<b := lt_of_le_of_ne hab heqhave hba : 0<b-a := sub_pos.mpr hlthave hba1 : b-a≤1 := by linarith [hb.2,ha.1]let Y := fun t : ℝ ↦ X (a+t)let W := fun t : ℝ ↦ fun ω ↦ X a ω+B (a.toNNReal+t.toNNReal) ω-B a.toNNReal ωhave hmem (t : ℝ) (ht : t∈Icc (0 : ℝ) (b-a)) : a+t∈Icc (0 : ℝ) T := byconstructor <;> linarith [ha.1,hb.2,ht.1,ht.2]have hLip' : ∀ s∈Icc (0 : ℝ) (b-a), ∀ t∈Icc (0 : ℝ) (b-a), ∀ x y,|u (a+s) x-u (a+t) y|≤Lu*(|s-t|+|x-y|) := byintro s hs t ht x ysimpa only [add_sub_add_left_eq_sub] using hLip _ (hmem s hs) _ (hmem t ht) x yhave hYM (t : ℝ) (ht : t∈Icc (0 : ℝ) (b-a)) :StronglyMeasurable[ℱ (a.toNNReal+t.toNNReal)] (Y t) := byhave hh := hXM _ (hmem t ht)rw [Real.toNNReal_add ha.1 ht.1] at hhexact hhhave hWM (t : ℝ) (_ht : t∈Icc (0 : ℝ) (b-a)) : AEStronglyMeasurable (W t) μ :=((((hXM a ha).mono (ℱ.le _)).add (hBm _)).sub (hBm _)).aestronglyMeasurablehave hW : ∀ s∈Icc (0 : ℝ) (b-a), ∀ t∈Icc (0 : ℝ) (b-a), ∀ ω,W t ω-W s ω=B (a.toNNReal+t.toNNReal) ω-B (a.toNNReal+s.toNNReal) ω := byintro s _ t _ ωdsimp [W]ringhave hpaths' : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ Y t ω) (Icc (0 : ℝ) (b-a)) ∧IntervalIntegrable (fun s ↦ γ (a+s)*u (a+s) (Y s ω)) volume 0 (b-a) ∧∀ t∈Icc (0 : ℝ) (b-a), Y t ω=W t ω+∫ s in (0 : ℝ)..t, γ (a+s)*u (a+s) (Y s ω) := byfilter_upwards [hpaths] with ω hωhave hT : 0≤T := ha.1.trans ha.2have hi := intervalIntegrable_substrip hT hω.2.1 ha hbrefine ⟨hω.1.comp (continuous_const.add continuous_id).continuousOn hmem,?_,?_⟩· simpa only [sub_self,Y] using hi.comp_add_left a· intro t hthave hhalf := intervalIntegrable_substrip hT hω.2.1 ha (hmem t ht)have hleft := intervalIntegrable_substrip hT hω.2.1 ⟨le_rfl,hT⟩ hahave hsum := intervalIntegral.integral_add_adjacent_intervals hleft hhalfdsimp only [Y,W]rw [intervalIntegral.integral_comp_add_left (fun s ↦ γ s*u s (X s ω)) a,add_zero]rw [hω.2.2 _ (hmem t ht),hω.2.2 _ ha,Real.toNNReal_add ha.1 ht.1]linarithhave hh := diffusion_gradient_condExp_local hB hBm a.toNNReal hba hba1 hLu(h.shift ha.1 hab hb.2) hLip' hYM hWM hW hpaths'simpa only [Y,add_sub_cancel,add_zero] using hhend SKValuenamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorslemma diffusion_gradient_stopped_martingale{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ)(hBm : ∀ t, StronglyMeasurable (B t)){T K L Lu : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ} {X : ℝ → Ω → ℝ}(hT : 0≤T) (hT1 : T≤1) (hLu : 0≤Lu) (h : GradientStripCore T γ u K L)(hLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(hXM : ∀ t∈Icc (0 : ℝ) T,StronglyMeasurable[Filtration.natural B hBm t.toNNReal] (X t))(hpaths : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧∀ t∈Icc (0 : ℝ) T, X t ω=B t.toNNReal ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) :Martingale (fun t : ℝ≥0 ↦ fun ω ↦ u (min (t : ℝ) T) (X (min (t : ℝ) T) ω))(Filtration.natural B hBm) μ := bylet ℱ := Filtration.natural B hBmhave hmem (t : ℝ≥0) : min (t : ℝ) T∈Icc (0 : ℝ) T :=⟨le_min t.coe_nonneg hT,min_le_right _ _⟩have htime (t : ℝ≥0) : (min (t : ℝ) T).toNNReal≤t := byhave hh := Real.toNNReal_mono (min_le_left (t : ℝ) T)rw [Real.toNNReal_coe] at hhexact hhhave hm (t : ℝ≥0) : StronglyMeasurable[ℱ t](fun ω ↦ u (min (t : ℝ) T) (X (min (t : ℝ) T) ω)) :=((h.smooth _ (hmem t)).continuous.comp_stronglyMeasurable (hXM _ (hmem t))).mono (ℱ.mono (htime t))have hi (t : ℝ≥0) : Integrable (fun ω ↦ u (min (t : ℝ) T) (X (min (t : ℝ) T) ω)) μ :=Integrable.of_bound ((hm t).mono (ℱ.le _)).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ (Real.norm_eq_abs _).trans_le (h.bounded _ (hmem t) _)))refine ⟨hm,?_⟩intro s t hstby_cases hs : (s : ℝ)≤T· have ha : (s : ℝ)∈Icc (0 : ℝ) T := ⟨s.coe_nonneg,hs⟩have hh := diffusion_gradient_condExp hB hBm hT1 hLu h hLip hXM hpaths ha (hmem t)(le_min (by exact_mod_cast hst) hs)rw [Real.toNNReal_coe] at hhsimpa only [min_eq_left hs] using hh· have hs' : T≤(s : ℝ) := (lt_of_not_ge hs).lehave ht : T≤(t : ℝ) := hs'.trans (by exact_mod_cast hst)have hh := condExp_of_aestronglyMeasurable' (ℱ.le s) (hm s).aestronglyMeasurable (hi s)simpa only [min_eq_right hs',min_eq_right ht] using hhend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131import Mathlibimport OAI.Probability.SKValue.Equations.CubicEnvelopeMeanimport OAI.Probability.SKValue.Gaussian.ShiftedBrownianCoordinatesnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorslemma diffusion_gradient_weak_martingale_local{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ)(hBm : ∀ t, StronglyMeasurable (B t)) (a : ℝ≥0){T K L Lu H : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ} {X W : ℝ → Ω → ℝ}{F : Ω → ℝ} (hT : 0<T) (hT1 : T≤1) (hLu : 0≤Lu) (hH : 0≤H)(h : GradientStripCore T γ u K L)(hLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(hXM : ∀ t∈Icc (0 : ℝ) T,StronglyMeasurable[Filtration.natural B hBm (a+t.toNNReal)] (X t))(hWM : ∀ t∈Icc (0 : ℝ) T, AEStronglyMeasurable (W t) μ)(hW : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ ω,W t ω-W s ω=B (a+t.toNNReal) ω-B (a+s.toNNReal) ω)(hpaths : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧∀ t∈Icc (0 : ℝ) T, X t ω=W t ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω))(hFm : StronglyMeasurable[Filtration.natural B hBm a] F) (hFb : ∀ ω, |F ω|≤H) :(∫ ω, F ω*u T (X T ω) ∂μ)=(∫ ω, F ω*u 0 (X 0 ω) ∂μ) := bylet ℱ := Filtration.natural B hBmhave hFM : AEStronglyMeasurable F μ := (hFm.mono (ℱ.le a)).aestronglyMeasurablehave hXM' (t : ℝ) (ht : t∈Icc (0 : ℝ) T) : AEStronglyMeasurable (X t) μ :=((hXM t ht).mono (ℱ.le _)).aestronglyMeasurablehave hsp (t : ℝ) (ht : t∈Icc (0 : ℝ) T) (x y : ℝ) :|u t x-u t y|≤Lu*|x-y| := bysimpa only [sub_self,abs_zero,zero_add] using hLip t ht t ht x yhave hVi (t : ℝ) (ht : t∈Icc (0 : ℝ) T) : Integrable (fun ω ↦ F ω*u t (X t ω)) μ := byapply Integrable.of_bound (hFM.mul ((h.smooth t ht).continuous.comp_aestronglyMeasurable (hXM' t ht))) Hfilter_upwards [] with ωsimp only [Pi.mul_apply, Real.norm_eq_abs, abs_mul]exact (mul_le_mul (hFb ω) (h.bounded t ht _) (abs_nonneg _) hH).trans_eq (mul_one H)have hlim := weighted_pathGradientResidual_tendsto (Z:=shiftedBrownianCoordinates B a T)hT hT1 hLu hH h hLip hXM' hWM(fun N hN i ↦ shiftedBrownianCoordinates_hasLaw hB a hT hN i)(fun N hN i ω ↦ shiftedBrownianCoordinates_exact hT hN hW i ω) hpaths hFM hFbhave hmean (N : ℕ) : (∫ ω, F ω*pathGradientResidual T N u (fun t ↦ X t ω)(fun t ↦ W t ω) ∂μ)=(∫ ω, F ω*u T (X T ω) ∂μ)-(∫ ω, F ω*u 0 (X 0 ω) ∂μ) := byhave hδ : 0≤ stepSize T N := div_nonneg hT.le (Nat.cast_nonneg N)have htime (j : ℕ) (hj : j≤N) := mesh_time_mem_total hT.le hjlet τ := fun j : ℕ ↦ a+(meshTime T N j).toNNRealhave hτ (i : Fin N) : τ i≤τ (i+1) := bydsimp [τ]apply add_le_add le_rflapply Real.toNNReal_monodsimp [meshTime]push_castnlinarithhave hτdiff (i : Fin N) : (τ (i+1) : ℝ)-(τ i : ℝ)=stepSize T N := bydsimp only [τ]rw [NNReal.coe_add,NNReal.coe_add,Real.coe_toNNReal _ (htime (i+1) i.isLt).1,Real.coe_toNNReal _ (htime i i.isLt.le).1]dsimp [meshTime]push_castringhave hWeq (i : Fin N) (ω : Ω) :W (meshTime T N (i+1)) ω-W (meshTime T N i) ω=B (τ (i+1)) ω-B (τ i) ω :=hW _ (htime i i.isLt.le) _ (htime (i+1) i.isLt) ωhave hFm' (i : Fin N) : StronglyMeasurable[ℱ (τ i)] F :=hFm.mono (ℱ.mono (le_add_of_nonneg_right (by positivity)))have hDm (i : Fin N) : StronglyMeasurable[ℱ (τ i)](fun ω ↦ F ω*deriv (u (meshTime T N i)) (X (meshTime T N i) ω)) :=(hFm' i).mul ((h.continuous_deriv (htime i i.isLt.le)).comp_stronglyMeasurable(hXM _ (htime i i.isLt.le)))have hD2m (i : Fin N) : StronglyMeasurable[ℱ (τ i)](fun ω ↦ F ω*deriv (deriv (u (meshTime T N i))) (X (meshTime T N i) ω)) :=(hFm' i).mul ((h.continuous_second (htime i i.isLt.le)).comp_stronglyMeasurable(hXM _ (htime i i.isLt.le)))have hDi (i : Fin N) : Integrable(fun ω ↦ F ω*deriv (u (meshTime T N i)) (X (meshTime T N i) ω)) μ := byapply Integrable.of_bound ((hDm i).mono (ℱ.le _)).aestronglyMeasurable (H*Lu)filter_upwards [] with ωrw [Real.norm_eq_abs,abs_mul]exact mul_le_mul (hFb ω) (GradientStripCore.deriv_bound hLu hsp (htime i i.isLt.le) _)(abs_nonneg _) hHhave hD2i (i : Fin N) : Integrable(fun ω ↦ F ω*deriv (deriv (u (meshTime T N i))) (X (meshTime T N i) ω)) μ := byapply Integrable.of_bound ((hD2m i).mono (ℱ.le _)).aestronglyMeasurable (H*K)filter_upwards [] with ωrw [Real.norm_eq_abs,abs_mul]exact mul_le_mul (hFb ω) (h.second_bound _ (htime i i.isLt.le) _) (abs_nonneg _) hHapply weighted_pathGradientResidual_integral (hVi T ⟨hT.le,le_rfl⟩) (hVi 0 ⟨le_rfl,hT.le⟩)· intro isimpa only [hWeq,mul_assoc] usingbrownian_predictable_increment_integrable hB hBm (hτ i) (hDm i) (hDi i)· intro isimpa only [hWeq,hτdiff,mul_assoc] usingbrownian_predictable_quadratic_integrable hB hBm (hτ i) (hD2m i) (hD2i i)· intro isimpa only [hWeq,mul_assoc] using brownian_predictable_increment_mean hB hBm (hτ i) (hDm i)· intro isimpa only [hWeq,hτdiff,mul_assoc] usingbrownian_predictable_quadratic_mean hB hBm (hτ i) (hD2m i)have hh : (∫ ω, F ω*u T (X T ω) ∂μ)-(∫ ω, F ω*u 0 (X 0 ω) ∂μ)=0 := byhave hc : Tendsto (fun _ : ℕ ↦ (∫ ω, F ω*u T (X T ω) ∂μ)-(∫ ω, F ω*u 0 (X 0 ω) ∂μ)) atTop (𝓝 (0 : ℝ)) := bysimpa only [hmean] using hlimexact tendsto_nhds_unique tendsto_const_nhds hcexact sub_eq_zero.mp hhend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131import Mathlibimport OAI.Probability.SKValue.Equations.CubicEnvelopeMeanimport OAI.Probability.SKValue.Gaussian.ShiftedBrownianCoordinatesnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorslemma diffusion_gradient_weak_martingale_local{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ)(hBm : ∀ t, StronglyMeasurable (B t)) (a : ℝ≥0){T K L Lu H : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ} {X W : ℝ → Ω → ℝ}{F : Ω → ℝ} (hT : 0<T) (hT1 : T≤1) (hLu : 0≤Lu) (hH : 0≤H)(h : GradientStripCore T γ u K L)(hLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(hXM : ∀ t∈Icc (0 : ℝ) T,StronglyMeasurable[Filtration.natural B hBm (a+t.toNNReal)] (X t))(hWM : ∀ t∈Icc (0 : ℝ) T, AEStronglyMeasurable (W t) μ)(hW : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ ω,W t ω-W s ω=B (a+t.toNNReal) ω-B (a+s.toNNReal) ω)(hpaths : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧∀ t∈Icc (0 : ℝ) T, X t ω=W t ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω))(hFm : StronglyMeasurable[Filtration.natural B hBm a] F) (hFb : ∀ ω, |F ω|≤H) :(∫ ω, F ω*u T (X T ω) ∂μ)=(∫ ω, F ω*u 0 (X 0 ω) ∂μ) := bylet ℱ := Filtration.natural B hBmhave hFM : AEStronglyMeasurable F μ := (hFm.mono (ℱ.le a)).aestronglyMeasurablehave hXM' (t : ℝ) (ht : t∈Icc (0 : ℝ) T) : AEStronglyMeasurable (X t) μ :=((hXM t ht).mono (ℱ.le _)).aestronglyMeasurablehave hsp (t : ℝ) (ht : t∈Icc (0 : ℝ) T) (x y : ℝ) :|u t x-u t y|≤Lu*|x-y| := bysimpa only [sub_self,abs_zero,zero_add] using hLip t ht t ht x yhave hVi (t : ℝ) (ht : t∈Icc (0 : ℝ) T) : Integrable (fun ω ↦ F ω*u t (X t ω)) μ := byapply Integrable.of_bound (hFM.mul ((h.smooth t ht).continuous.comp_aestronglyMeasurable (hXM' t ht))) Hfilter_upwards [] with ωsimp only [Pi.mul_apply, Real.norm_eq_abs, abs_mul]exact (mul_le_mul (hFb ω) (h.bounded t ht _) (abs_nonneg _) hH).trans_eq (mul_one H)have hlim := weighted_pathGradientResidual_tendsto (Z:=shiftedBrownianCoordinates B a T)hT hT1 hLu hH h hLip hXM' hWM(fun N hN i ↦ shiftedBrownianCoordinates_hasLaw hB a hT hN i)(fun N hN i ω ↦ shiftedBrownianCoordinates_exact hT hN hW i ω) hpaths hFM hFbhave hmean (N : ℕ) : (∫ ω, F ω*pathGradientResidual T N u (fun t ↦ X t ω)(fun t ↦ W t ω) ∂μ)=(∫ ω, F ω*u T (X T ω) ∂μ)-(∫ ω, F ω*u 0 (X 0 ω) ∂μ) := byhave hδ : 0≤ stepSize T N := div_nonneg hT.le (Nat.cast_nonneg N)have htime (j : ℕ) (hj : j≤N) := mesh_time_mem_total hT.le hjlet τ := fun j : ℕ ↦ a+(meshTime T N j).toNNRealhave hτ (i : Fin N) : τ i≤τ (i+1) := bydsimp [τ]apply add_le_add le_rflapply Real.toNNReal_monodsimp [meshTime]push_castnlinarithhave hτdiff (i : Fin N) : (τ (i+1) : ℝ)-(τ i : ℝ)=stepSize T N := bydsimp only [τ]rw [NNReal.coe_add,NNReal.coe_add,Real.coe_toNNReal _ (htime (i+1) i.isLt).1,Real.coe_toNNReal _ (htime i i.isLt.le).1]dsimp [meshTime]push_castringhave hWeq (i : Fin N) (ω : Ω) :W (meshTime T N (i+1)) ω-W (meshTime T N i) ω=B (τ (i+1)) ω-B (τ i) ω :=hW _ (htime i i.isLt.le) _ (htime (i+1) i.isLt) ωhave hFm' (i : Fin N) : StronglyMeasurable[ℱ (τ i)] F :=hFm.mono (ℱ.mono (le_add_of_nonneg_right (by positivity)))have hDm (i : Fin N) : StronglyMeasurable[ℱ (τ i)](fun ω ↦ F ω*deriv (u (meshTime T N i)) (X (meshTime T N i) ω)) :=(hFm' i).mul ((h.continuous_deriv (htime i i.isLt.le)).comp_stronglyMeasurable(hXM _ (htime i i.isLt.le)))have hD2m (i : Fin N) : StronglyMeasurable[ℱ (τ i)](fun ω ↦ F ω*deriv (deriv (u (meshTime T N i))) (X (meshTime T N i) ω)) :=(hFm' i).mul ((h.continuous_second (htime i i.isLt.le)).comp_stronglyMeasurable(hXM _ (htime i i.isLt.le)))have hDi (i : Fin N) : Integrable(fun ω ↦ F ω*deriv (u (meshTime T N i)) (X (meshTime T N i) ω)) μ := byapply Integrable.of_bound ((hDm i).mono (ℱ.le _)).aestronglyMeasurable (H*Lu)filter_upwards [] with ωrw [Real.norm_eq_abs,abs_mul]exact mul_le_mul (hFb ω) (GradientStripCore.deriv_bound hLu hsp (htime i i.isLt.le) _)(abs_nonneg _) hHhave hD2i (i : Fin N) : Integrable(fun ω ↦ F ω*deriv (deriv (u (meshTime T N i))) (X (meshTime T N i) ω)) μ := byapply Integrable.of_bound ((hD2m i).mono (ℱ.le _)).aestronglyMeasurable (H*K)filter_upwards [] with ωrw [Real.norm_eq_abs,abs_mul]exact mul_le_mul (hFb ω) (h.second_bound _ (htime i i.isLt.le) _) (abs_nonneg _) hHapply weighted_pathGradientResidual_integral (hVi T ⟨hT.le,le_rfl⟩) (hVi 0 ⟨le_rfl,hT.le⟩)· intro isimpa only [hWeq,mul_assoc] usingbrownian_predictable_increment_integrable hB hBm (hτ i) (hDm i) (hDi i)· intro isimpa only [hWeq,hτdiff,mul_assoc] usingbrownian_predictable_quadratic_integrable hB hBm (hτ i) (hD2m i) (hD2i i)· intro isimpa only [hWeq,mul_assoc] using brownian_predictable_increment_mean hB hBm (hτ i) (hDm i)· intro isimpa only [hWeq,hτdiff,mul_assoc] usingbrownian_predictable_quadratic_mean hB hBm (hτ i) (hD2m i)have hh : (∫ ω, F ω*u T (X T ω) ∂μ)-(∫ ω, F ω*u 0 (X 0 ω) ∂μ)=0 := byhave hc : Tendsto (fun _ : ℕ ↦ (∫ ω, F ω*u T (X T ω) ∂μ)-(∫ ω, F ω*u 0 (X 0 ω) ∂μ)) atTop (𝓝 (0 : ℝ)) := bysimpa only [hmean] using hlimexact tendsto_nhds_unique tendsto_const_nhds hcexact sub_eq_zero.mp hhend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202import Mathlibimport OAI.Probability.SKValue.Equations.LipschitzCompMemLpFiniteimport OAI.Probability.SKValue.Evolution.BoundedSmoothimport OAI.Probability.SKValue.Equations.TestGeneratorimport OAI.Probability.SKValue.Processes.TestExpectationnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorsnamespace SKValuelemma euler_same_noise_sum_bound {T G L e : ℝ} {d : ℕ → ℝ} {N : ℕ} {γ β : ℝ → ℝ}{u v : ℝ → ℝ → ℝ} (hT : 0≤T) (hN : 0<N)(hG : 0≤G) (hL : 0≤L) (hd : ∀ k<N,0≤d k) (he : 0≤e)(hg : ∀ j<N,|γ (meshTime T N j)|≤G)(hc : ∀ j<N,|β (meshTime T N j)-γ (meshTime T N j)|≤d j)(hv : ∀ j<N,∀ x,|v (meshTime T N j) x|≤1)(hs : ∀ j<N,∀ x,|v (meshTime T N j) x-u (meshTime T N j) x|≤e)(hu : ∀ j<N,∀ x y,|u (meshTime T N j) x-u (meshTime T N j) y|≤L*|x-y|)(z : Fin (N+1) → ℝ) {j : ℕ} (hj : j≤N) :|euler T N β v z j-euler T N γ u z j|≤(∑ k∈Finset.range j,stepSize T N*(d k+G*e))*Real.exp (T*G*L) := bylet δ := stepSize T Nhave hδ : 0≤δ := div_nonneg hT (Nat.cast_nonneg _)have hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simphave hrec (k : ℕ) (hk : k<N) :|euler T N β v z (k+1)-euler T N γ u z (k+1)|≤(1+δ*G*L)*|euler T N β v z k-euler T N γ u z k|+δ*(d k+G*e) := bylet y := euler T N β v z klet x := euler T N γ u z klet t := meshTime T N khave hb : |β t*v t y-γ t*u t x|≤d k+G*e+G*L*|y-x| := bycalc|β t*v t y-γ t*u t x| = |(β t-γ t)*v t y+γ t*(v t y-u t y)+γ t*(u t y-u t x)| := by congr 1; ring_ ≤ |(β t-γ t)*v t y|+|γ t*(v t y-u t y)|+|γ t*(u t y-u t x)| := (abs_add_le _ _).trans (add_le_add (abs_add_le _ _) le_rfl)_ ≤ d k*1+G*e+G*(L*|y-x|) := bysimp only [abs_mul]gcongr· exact hd k hk· exact hc k hk· exact hv k hk y· exact hg k hk· exact hs k hk y· exact hg k hk· exact hu k hk y x_ = _ := by ringchange |y+Real.sqrt δ*coordinate N k z+δ*β t*v t y-(x+Real.sqrt δ*coordinate N k z+δ*γ t*u t x)|≤_calc_ = |(y-x)+δ*(β t*v t y-γ t*u t x)| := by congr 1; ring_ ≤ |y-x|+δ*|β t*v t y-γ t*u t x| := by simpa only [abs_mul,abs_of_nonneg hδ] using abs_add_le (y-x) (δ*(β t*v t y-γ t*u t x))_ ≤ |y-x|+δ*(d k+G*e+G*L*|y-x|) := add_le_add_right (mul_le_mul_of_nonneg_left hb hδ) __ = _ := by ringhave h := finite_discrete_gronwall (e := fun k ↦ |euler T N β v z k-euler T N γ u z k|) (mul_nonneg (mul_nonneg hδ hG) hL)(show |euler T N β v z 0-euler T N γ u z 0|=0 by simp [euler])(fun k hk ↦ mul_nonneg hδ (add_nonneg (hd k hk) (mul_nonneg hG he))) hrec j hjapply h.transapply mul_le_mul le_rfl· apply Real.exp_le_exp.mprcalc(j : ℝ)*(δ*G*L)≤(N : ℝ)*(δ*G*L) := mul_le_mul_of_nonneg_right (by exact_mod_cast hj) (mul_nonneg (mul_nonneg hδ hG) hL)_=T*G*L := by rw [←hNd]; ring· positivity· exact Finset.sum_nonneg (fun k hk ↦ mul_nonneg hδ (add_nonneg (hd k ((Finset.mem_range.mp hk).trans_le hj)) (mul_nonneg hG he)))end SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorsnamespace SKValuelemma monotone_grid_sum_tendsto {γ:ℝ → ℝ} {T:ℝ} (hT:0<T)(hm:MonotoneOn γ (Icc (0:ℝ) T)) (h0:0≤γ 0) :Tendsto (fun N:ℕ ↦ stepSize T N*∑ j∈Finset.range N,γ (meshTime T N j)) atTop(𝓝 (∫ t in (0:ℝ)..T,γ t)) := bysimpa only [mul_one,stepSize,meshTime] usingmonotone_weighted_grid_tendsto (γ:=γ) (f:=fun _ ↦ (1:ℝ)) (K:=1) hT (by norm_num) hm h0continuousOn_const (fun _ _ ↦ by norm_num)lemma euler_ordered_coeff_bound {T G L a b:ℝ} {β γ:ℝ → ℝ} {u v:ℝ → ℝ → ℝ}{N:ℕ} (hT:0≤T) (hN:0<N) (hG:0≤G) (hL:0≤L) (ha:0≤a) (hb:0≤b)(hg:∀ j<N,|γ (meshTime T N j)|≤G)(hc:∀ j<N,β (meshTime T N j)≤γ (meshTime T N j)+a)(hv:∀ j<N,∀ x,|v (meshTime T N j) x|≤1)(hs:∀ j<N,∀ x,|v (meshTime T N j) x-u (meshTime T N j) x|≤b)(hu:∀ j<N,∀ x y,|u (meshTime T N j) x-u (meshTime T N j) y|≤L*|x-y|)(z:Fin (N+1) → ℝ) :|euler T N β v z N-euler T N γ u z N|≤(stepSize T N*(∑ j∈Finset.range N,γ (meshTime T N j))-stepSize T N*(∑ j∈Finset.range N,β (meshTime T N j))+T*(2*a+G*b))*Real.exp (T*G*L) := byhave hd (j:ℕ) (hj:j<N) : 0≤γ (meshTime T N j)-β (meshTime T N j)+2*a := by linarith [hc j hj]have h:=euler_same_noise_sum_bound (β:=β) (γ:=γ) (u:=u) (v:=v) hT hN hG hL hd hb hg(fun j hj ↦ by apply abs_le.mpr;constructor <;> linarith [hc j hj]) hv hs hu z le_rflhave he:(∑ j∈Finset.range N,stepSize T N*(γ (meshTime T N j)-β (meshTime T N j)+2*a+G*b))=stepSize T N*(∑ j∈Finset.range N,γ (meshTime T N j))-stepSize T N*(∑ j∈Finset.range N,β (meshTime T N j))+T*(2*a+G*b) := bysimp only [mul_add,mul_sub,Finset.sum_add_distrib,Finset.sum_sub_distrib,←Finset.mul_sum,Finset.sum_const,Finset.card_range,nsmul_eq_mul]have hNd:(N:ℝ)*stepSize T N=T := by dsimp [stepSize];field_simpnlinarith only [congrArg (fun x:ℝ ↦ x*(2*a+G*b)) hNd]rwa [he] at hend SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorsnamespace SKValuelemma BackwardTest.diffusion_comparison {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {T K L K' L' Lu a b H:ℝ} {γ β:ℝ → ℝ} {u v V:ℝ → ℝ → ℝ}(hT:0<T) (hT1:T≤1) (hu:GradientStrip T γ u K L) (h:BackwardTest T β v V K' L')(hLu:0≤Lu) (hLip:∀ s∈Icc (0:ℝ) T,∀ t∈Icc (0:ℝ) T,∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(ha:0≤a) (hb:0≤b) (hH:0≤H)(hc:∀ t∈Icc (0:ℝ) T,β t≤γ t+a)(hs:∀ t∈Icc (0:ℝ) T,∀ x,|v t x-u t x|≤b)(hf:∀ x y,|V T x-V T y|≤H*|x-y|)(hXM:∀ t∈Icc (0:ℝ) T,MemLp (X t) 2 μ)(hpaths:∀ᵐ ω ∂μ,ContinuousOn (fun t ↦ X t ω) (Icc (0:ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t∈Icc (0:ℝ) T,X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,γ s*u s (X s ω)) ∧ X 0 ω=0) :|(∫ ω,V T (X T ω) ∂μ)-V 0 0|≤H*((∫ t in (0:ℝ)..T,γ t)-(∫ t in (0:ℝ)..T,β t)+T*(2*a+γ T*b))*Real.exp (T*γ T*Lu) := bylet D:=fun N:ℕ ↦ stepSize T N*(∑ j∈Finset.range N,γ (meshTime T N j))-stepSize T N*(∑ j∈Finset.range N,β (meshTime T N j))+T*(2*a+γ T*b)let E:=fun N:ℕ ↦ T*Real.sqrt (stepSize T N)*cubicEnvelopeMean (β T) K' ((1/2+β T)*L')+stepSize T N*K'*(β T-β 0)let F:=fun N:ℕ ↦ H*Real.sqrt (∫ ω,(meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ)have hG:0≤γ T := hu.gamma_nonneg T ⟨hT.le,le_rfl⟩have hD:Tendsto D atTop (𝓝 ((∫ t in (0:ℝ)..T,γ t)-(∫ t in (0:ℝ)..T,β t)+T*(2*a+γ T*b))) :=((monotone_grid_sum_tendsto hT hu.gamma_mono (hu.gamma_nonneg 0 ⟨le_rfl,hT.le⟩)).sub(monotone_grid_sum_tendsto hT h.gamma_mono (h.gamma_nonneg 0 ⟨le_rfl,hT.le⟩))).add_const _have hδ:Tendsto (fun N:ℕ ↦ stepSize T N) atTop (𝓝 (0:ℝ)) := tendsto_const_div_atTop_nhds_zero_nat Thave hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδhave hE:Tendsto E atTop (𝓝 0) := bysimpa only [E,Function.comp_def,Real.sqrt_zero,mul_zero,zero_mul,add_zero] using(((hsqrt.const_mul T).mul_const (cubicEnvelopeMean (β T) K' ((1/2+β T)*L'))).add((hδ.mul_const K').mul_const (β T-β 0)))have hF:Tendsto F atTop (𝓝 0) := bysimpa only [F,Function.comp_def,Real.sqrt_zero,mul_zero] using(((Real.continuous_sqrt.tendsto 0).comp(coupled_euler_L2_convergence hB hT hu hLu hLip (fun t ht ↦ (hXM t ht).aestronglyMeasurable) hpaths)).const_mul H)have hlip:LipschitzWith ⟨H,hH⟩ (V T) := byapply LipschitzWith.of_dist_le_mulintro x yexact hf x yhave hbound:∀ᶠ N in atTop,|(∫ ω,V T (X T ω) ∂μ)-V 0 0|≤E N+H*D N*Real.exp (T*γ T*Lu)+F N := byfilter_upwards [eventually_gt_atTop 0] with N hNlet P:=fun z:Fin (N+1) → ℝ ↦ V T (euler T N β v z N)let Q:=fun z:Fin (N+1) → ℝ ↦ V T (euler T N γ u z N)have htime (j:ℕ) (hj:j≤N):meshTime T N j∈Icc (0:ℝ) T := mesh_time_mem hT.le hN hjhave hp:Integrable P (gaussianProduct (Fin (N+1))) := byapply Integrable.of_bound ((hlip.continuous.measurable.comp(measurable_euler T N β v (fun j hj ↦ h.drift_measurable _ (htime j hj.le)) N le_rfl)).aestronglyMeasurable) K'exact Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs,Function.comp_apply] using h.bound T ⟨hT.le,le_rfl⟩ _)have hq:Integrable Q (gaussianProduct (Fin (N+1))) := byapply Integrable.of_bound ((hlip.continuous.measurable.comp(measurable_euler T N γ u (fun j hj ↦ (hu.smooth _ (htime j hj.le)).continuous.measurable) N le_rfl)).aestronglyMeasurable) K'exact Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs,Function.comp_apply] using h.bound T ⟨hT.le,le_rfl⟩ _)have hpq:|(∫ z,P z ∂gaussianProduct (Fin (N+1)))-(∫ z,Q z ∂gaussianProduct (Fin (N+1)))|≤H*D N*Real.exp (T*γ T*Lu) := byrw [←integral_sub hp hq]apply (show |∫ z,P z-Q z ∂gaussianProduct (Fin (N+1))|≤H*D N*Real.exp (T*γ T*Lu) from ?_)have hnorm:=norm_integral_le_of_norm_le_const (μ:=gaussianProduct (Fin (N+1)))(C:=H*D N*Real.exp (T*γ T*Lu)) (f:=fun z ↦ P z-Q z) (Eventually.of_forall (fun z ↦ byrw [Real.norm_eq_abs]apply (hf _ _).transhave he:=euler_ordered_coeff_bound (β:=β) (γ:=γ) (u:=u) (v:=v) hT.le hN hG hLu ha hb(fun j hj ↦ by rw [abs_of_nonneg (hu.gamma_nonneg _ (htime j hj.le))]; exact hu.gamma_mono (htime j hj.le) ⟨hT.le,le_rfl⟩ (htime j hj.le).2)(fun j hj ↦ hc _ (htime j hj.le)) (fun j hj ↦ h.drift_bound _ (htime j hj.le))(fun j hj ↦ hs _ (htime j hj.le))(fun j hj x y ↦ by simpa only [sub_self,abs_zero,zero_add] using hLip _ (htime j hj.le) _ (htime j hj.le) x y) zsimpa only [D,mul_assoc] using mul_le_mul_of_nonneg_left he hH))simpa only [Real.norm_eq_abs,probReal_univ,mul_one] using hnormhave he:=h.mesh_expectation hT hT1 hNhave hqX:=coupled_lipschitz_expectation_bound hB hT hu hXM(hpaths.mono (fun _ hω ↦ hω.2.2)) hN le_rfl hliphave hend:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simprw [hend] at hqXchange |(∫ z,Q z ∂gaussianProduct (Fin (N+1)))-(∫ ω,V T (X T ω) ∂μ)|≤F N at hqXchange |(∫ z,P z ∂gaussianProduct (Fin (N+1)))-V 0 0|≤E N at hecalc|(∫ ω,V T (X T ω) ∂μ)-V 0 0| ≤|(∫ ω,V T (X T ω) ∂μ)-(∫ z,Q z ∂gaussianProduct (Fin (N+1)))|+|(∫ z,Q z ∂gaussianProduct (Fin (N+1)))-V 0 0| := abs_sub_le _ _ __ ≤ F N+(H*D N*Real.exp (T*γ T*Lu)+E N) := byapply add_le_add· rw [abs_sub_comm]; exact hqX· exact (abs_sub_le _ (∫ z,P z ∂gaussianProduct (Fin (N+1))) _).trans(add_le_add (by rw [abs_sub_comm]; exact hpq) he)_ = E N+H*D N*Real.exp (T*γ T*Lu)+F N := by ringhave he:=le_of_tendsto_of_tendsto tendsto_const_nhds((hE.add ((hD.const_mul H).mul_const (Real.exp (T*γ T*Lu)))).add hF) hboundsimpa only [zero_add,add_zero] using heend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202import Mathlibimport OAI.Probability.SKValue.Equations.LipschitzCompMemLpFiniteimport OAI.Probability.SKValue.Evolution.BoundedSmoothimport OAI.Probability.SKValue.Equations.TestGeneratorimport OAI.Probability.SKValue.Processes.TestExpectationnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorsnamespace SKValuelemma euler_same_noise_sum_bound {T G L e : ℝ} {d : ℕ → ℝ} {N : ℕ} {γ β : ℝ → ℝ}{u v : ℝ → ℝ → ℝ} (hT : 0≤T) (hN : 0<N)(hG : 0≤G) (hL : 0≤L) (hd : ∀ k<N,0≤d k) (he : 0≤e)(hg : ∀ j<N,|γ (meshTime T N j)|≤G)(hc : ∀ j<N,|β (meshTime T N j)-γ (meshTime T N j)|≤d j)(hv : ∀ j<N,∀ x,|v (meshTime T N j) x|≤1)(hs : ∀ j<N,∀ x,|v (meshTime T N j) x-u (meshTime T N j) x|≤e)(hu : ∀ j<N,∀ x y,|u (meshTime T N j) x-u (meshTime T N j) y|≤L*|x-y|)(z : Fin (N+1) → ℝ) {j : ℕ} (hj : j≤N) :|euler T N β v z j-euler T N γ u z j|≤(∑ k∈Finset.range j,stepSize T N*(d k+G*e))*Real.exp (T*G*L) := bylet δ := stepSize T Nhave hδ : 0≤δ := div_nonneg hT (Nat.cast_nonneg _)have hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simphave hrec (k : ℕ) (hk : k<N) :|euler T N β v z (k+1)-euler T N γ u z (k+1)|≤(1+δ*G*L)*|euler T N β v z k-euler T N γ u z k|+δ*(d k+G*e) := bylet y := euler T N β v z klet x := euler T N γ u z klet t := meshTime T N khave hb : |β t*v t y-γ t*u t x|≤d k+G*e+G*L*|y-x| := bycalc|β t*v t y-γ t*u t x| = |(β t-γ t)*v t y+γ t*(v t y-u t y)+γ t*(u t y-u t x)| := by congr 1; ring_ ≤ |(β t-γ t)*v t y|+|γ t*(v t y-u t y)|+|γ t*(u t y-u t x)| := (abs_add_le _ _).trans (add_le_add (abs_add_le _ _) le_rfl)_ ≤ d k*1+G*e+G*(L*|y-x|) := bysimp only [abs_mul]gcongr· exact hd k hk· exact hc k hk· exact hv k hk y· exact hg k hk· exact hs k hk y· exact hg k hk· exact hu k hk y x_ = _ := by ringchange |y+Real.sqrt δ*coordinate N k z+δ*β t*v t y-(x+Real.sqrt δ*coordinate N k z+δ*γ t*u t x)|≤_calc_ = |(y-x)+δ*(β t*v t y-γ t*u t x)| := by congr 1; ring_ ≤ |y-x|+δ*|β t*v t y-γ t*u t x| := by simpa only [abs_mul,abs_of_nonneg hδ] using abs_add_le (y-x) (δ*(β t*v t y-γ t*u t x))_ ≤ |y-x|+δ*(d k+G*e+G*L*|y-x|) := add_le_add_right (mul_le_mul_of_nonneg_left hb hδ) __ = _ := by ringhave h := finite_discrete_gronwall (e := fun k ↦ |euler T N β v z k-euler T N γ u z k|) (mul_nonneg (mul_nonneg hδ hG) hL)(show |euler T N β v z 0-euler T N γ u z 0|=0 by simp [euler])(fun k hk ↦ mul_nonneg hδ (add_nonneg (hd k hk) (mul_nonneg hG he))) hrec j hjapply h.transapply mul_le_mul le_rfl· apply Real.exp_le_exp.mprcalc(j : ℝ)*(δ*G*L)≤(N : ℝ)*(δ*G*L) := mul_le_mul_of_nonneg_right (by exact_mod_cast hj) (mul_nonneg (mul_nonneg hδ hG) hL)_=T*G*L := by rw [←hNd]; ring· positivity· exact Finset.sum_nonneg (fun k hk ↦ mul_nonneg hδ (add_nonneg (hd k ((Finset.mem_range.mp hk).trans_le hj)) (mul_nonneg hG he)))end SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorsnamespace SKValuelemma monotone_grid_sum_tendsto {γ:ℝ → ℝ} {T:ℝ} (hT:0<T)(hm:MonotoneOn γ (Icc (0:ℝ) T)) (h0:0≤γ 0) :Tendsto (fun N:ℕ ↦ stepSize T N*∑ j∈Finset.range N,γ (meshTime T N j)) atTop(𝓝 (∫ t in (0:ℝ)..T,γ t)) := bysimpa only [mul_one,stepSize,meshTime] usingmonotone_weighted_grid_tendsto (γ:=γ) (f:=fun _ ↦ (1:ℝ)) (K:=1) hT (by norm_num) hm h0continuousOn_const (fun _ _ ↦ by norm_num)lemma euler_ordered_coeff_bound {T G L a b:ℝ} {β γ:ℝ → ℝ} {u v:ℝ → ℝ → ℝ}{N:ℕ} (hT:0≤T) (hN:0<N) (hG:0≤G) (hL:0≤L) (ha:0≤a) (hb:0≤b)(hg:∀ j<N,|γ (meshTime T N j)|≤G)(hc:∀ j<N,β (meshTime T N j)≤γ (meshTime T N j)+a)(hv:∀ j<N,∀ x,|v (meshTime T N j) x|≤1)(hs:∀ j<N,∀ x,|v (meshTime T N j) x-u (meshTime T N j) x|≤b)(hu:∀ j<N,∀ x y,|u (meshTime T N j) x-u (meshTime T N j) y|≤L*|x-y|)(z:Fin (N+1) → ℝ) :|euler T N β v z N-euler T N γ u z N|≤(stepSize T N*(∑ j∈Finset.range N,γ (meshTime T N j))-stepSize T N*(∑ j∈Finset.range N,β (meshTime T N j))+T*(2*a+G*b))*Real.exp (T*G*L) := byhave hd (j:ℕ) (hj:j<N) : 0≤γ (meshTime T N j)-β (meshTime T N j)+2*a := by linarith [hc j hj]have h:=euler_same_noise_sum_bound (β:=β) (γ:=γ) (u:=u) (v:=v) hT hN hG hL hd hb hg(fun j hj ↦ by apply abs_le.mpr;constructor <;> linarith [hc j hj]) hv hs hu z le_rflhave he:(∑ j∈Finset.range N,stepSize T N*(γ (meshTime T N j)-β (meshTime T N j)+2*a+G*b))=stepSize T N*(∑ j∈Finset.range N,γ (meshTime T N j))-stepSize T N*(∑ j∈Finset.range N,β (meshTime T N j))+T*(2*a+G*b) := bysimp only [mul_add,mul_sub,Finset.sum_add_distrib,Finset.sum_sub_distrib,←Finset.mul_sum,Finset.sum_const,Finset.card_range,nsmul_eq_mul]have hNd:(N:ℝ)*stepSize T N=T := by dsimp [stepSize];field_simpnlinarith only [congrArg (fun x:ℝ ↦ x*(2*a+G*b)) hNd]rwa [he] at hend SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorsnamespace SKValuelemma BackwardTest.diffusion_comparison {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {T K L K' L' Lu a b H:ℝ} {γ β:ℝ → ℝ} {u v V:ℝ → ℝ → ℝ}(hT:0<T) (hT1:T≤1) (hu:GradientStrip T γ u K L) (h:BackwardTest T β v V K' L')(hLu:0≤Lu) (hLip:∀ s∈Icc (0:ℝ) T,∀ t∈Icc (0:ℝ) T,∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(ha:0≤a) (hb:0≤b) (hH:0≤H)(hc:∀ t∈Icc (0:ℝ) T,β t≤γ t+a)(hs:∀ t∈Icc (0:ℝ) T,∀ x,|v t x-u t x|≤b)(hf:∀ x y,|V T x-V T y|≤H*|x-y|)(hXM:∀ t∈Icc (0:ℝ) T,MemLp (X t) 2 μ)(hpaths:∀ᵐ ω ∂μ,ContinuousOn (fun t ↦ X t ω) (Icc (0:ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t∈Icc (0:ℝ) T,X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,γ s*u s (X s ω)) ∧ X 0 ω=0) :|(∫ ω,V T (X T ω) ∂μ)-V 0 0|≤H*((∫ t in (0:ℝ)..T,γ t)-(∫ t in (0:ℝ)..T,β t)+T*(2*a+γ T*b))*Real.exp (T*γ T*Lu) := bylet D:=fun N:ℕ ↦ stepSize T N*(∑ j∈Finset.range N,γ (meshTime T N j))-stepSize T N*(∑ j∈Finset.range N,β (meshTime T N j))+T*(2*a+γ T*b)let E:=fun N:ℕ ↦ T*Real.sqrt (stepSize T N)*cubicEnvelopeMean (β T) K' ((1/2+β T)*L')+stepSize T N*K'*(β T-β 0)let F:=fun N:ℕ ↦ H*Real.sqrt (∫ ω,(meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ)have hG:0≤γ T := hu.gamma_nonneg T ⟨hT.le,le_rfl⟩have hD:Tendsto D atTop (𝓝 ((∫ t in (0:ℝ)..T,γ t)-(∫ t in (0:ℝ)..T,β t)+T*(2*a+γ T*b))) :=((monotone_grid_sum_tendsto hT hu.gamma_mono (hu.gamma_nonneg 0 ⟨le_rfl,hT.le⟩)).sub(monotone_grid_sum_tendsto hT h.gamma_mono (h.gamma_nonneg 0 ⟨le_rfl,hT.le⟩))).add_const _have hδ:Tendsto (fun N:ℕ ↦ stepSize T N) atTop (𝓝 (0:ℝ)) := tendsto_const_div_atTop_nhds_zero_nat Thave hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδhave hE:Tendsto E atTop (𝓝 0) := bysimpa only [E,Function.comp_def,Real.sqrt_zero,mul_zero,zero_mul,add_zero] using(((hsqrt.const_mul T).mul_const (cubicEnvelopeMean (β T) K' ((1/2+β T)*L'))).add((hδ.mul_const K').mul_const (β T-β 0)))have hF:Tendsto F atTop (𝓝 0) := bysimpa only [F,Function.comp_def,Real.sqrt_zero,mul_zero] using(((Real.continuous_sqrt.tendsto 0).comp(coupled_euler_L2_convergence hB hT hu hLu hLip (fun t ht ↦ (hXM t ht).aestronglyMeasurable) hpaths)).const_mul H)have hlip:LipschitzWith ⟨H,hH⟩ (V T) := byapply LipschitzWith.of_dist_le_mulintro x yexact hf x yhave hbound:∀ᶠ N in atTop,|(∫ ω,V T (X T ω) ∂μ)-V 0 0|≤E N+H*D N*Real.exp (T*γ T*Lu)+F N := byfilter_upwards [eventually_gt_atTop 0] with N hNlet P:=fun z:Fin (N+1) → ℝ ↦ V T (euler T N β v z N)let Q:=fun z:Fin (N+1) → ℝ ↦ V T (euler T N γ u z N)have htime (j:ℕ) (hj:j≤N):meshTime T N j∈Icc (0:ℝ) T := mesh_time_mem hT.le hN hjhave hp:Integrable P (gaussianProduct (Fin (N+1))) := byapply Integrable.of_bound ((hlip.continuous.measurable.comp(measurable_euler T N β v (fun j hj ↦ h.drift_measurable _ (htime j hj.le)) N le_rfl)).aestronglyMeasurable) K'exact Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs,Function.comp_apply] using h.bound T ⟨hT.le,le_rfl⟩ _)have hq:Integrable Q (gaussianProduct (Fin (N+1))) := byapply Integrable.of_bound ((hlip.continuous.measurable.comp(measurable_euler T N γ u (fun j hj ↦ (hu.smooth _ (htime j hj.le)).continuous.measurable) N le_rfl)).aestronglyMeasurable) K'exact Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs,Function.comp_apply] using h.bound T ⟨hT.le,le_rfl⟩ _)have hpq:|(∫ z,P z ∂gaussianProduct (Fin (N+1)))-(∫ z,Q z ∂gaussianProduct (Fin (N+1)))|≤H*D N*Real.exp (T*γ T*Lu) := byrw [←integral_sub hp hq]apply (show |∫ z,P z-Q z ∂gaussianProduct (Fin (N+1))|≤H*D N*Real.exp (T*γ T*Lu) from ?_)have hnorm:=norm_integral_le_of_norm_le_const (μ:=gaussianProduct (Fin (N+1)))(C:=H*D N*Real.exp (T*γ T*Lu)) (f:=fun z ↦ P z-Q z) (Eventually.of_forall (fun z ↦ byrw [Real.norm_eq_abs]apply (hf _ _).transhave he:=euler_ordered_coeff_bound (β:=β) (γ:=γ) (u:=u) (v:=v) hT.le hN hG hLu ha hb(fun j hj ↦ by rw [abs_of_nonneg (hu.gamma_nonneg _ (htime j hj.le))]; exact hu.gamma_mono (htime j hj.le) ⟨hT.le,le_rfl⟩ (htime j hj.le).2)(fun j hj ↦ hc _ (htime j hj.le)) (fun j hj ↦ h.drift_bound _ (htime j hj.le))(fun j hj ↦ hs _ (htime j hj.le))(fun j hj x y ↦ by simpa only [sub_self,abs_zero,zero_add] using hLip _ (htime j hj.le) _ (htime j hj.le) x y) zsimpa only [D,mul_assoc] using mul_le_mul_of_nonneg_left he hH))simpa only [Real.norm_eq_abs,probReal_univ,mul_one] using hnormhave he:=h.mesh_expectation hT hT1 hNhave hqX:=coupled_lipschitz_expectation_bound hB hT hu hXM(hpaths.mono (fun _ hω ↦ hω.2.2)) hN le_rfl hliphave hend:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simprw [hend] at hqXchange |(∫ z,Q z ∂gaussianProduct (Fin (N+1)))-(∫ ω,V T (X T ω) ∂μ)|≤F N at hqXchange |(∫ z,P z ∂gaussianProduct (Fin (N+1)))-V 0 0|≤E N at hecalc|(∫ ω,V T (X T ω) ∂μ)-V 0 0| ≤|(∫ ω,V T (X T ω) ∂μ)-(∫ z,Q z ∂gaussianProduct (Fin (N+1)))|+|(∫ z,Q z ∂gaussianProduct (Fin (N+1)))-V 0 0| := abs_sub_le _ _ __ ≤ F N+(H*D N*Real.exp (T*γ T*Lu)+E N) := byapply add_le_add· rw [abs_sub_comm]; exact hqX· exact (abs_sub_le _ (∫ z,P z ∂gaussianProduct (Fin (N+1))) _).trans(add_le_add (by rw [abs_sub_comm]; exact hpq) he)_ = E N+H*D N*Real.exp (T*γ T*Lu)+F N := by ringhave he:=le_of_tendsto_of_tendsto tendsto_const_nhds((hE.add ((hD.const_mul H).mul_const (Real.exp (T*γ T*Lu)))).add hF) hboundsimpa only [zero_add,add_zero] using heend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128import Mathlibimport OAI.Probability.SKValue.Processes.Volterranamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filter Functionopen scoped Topology NNRealnamespace SKValuenoncomputable def eulerLimitProcess (W:BrownianSpace) (γ:OrderParameter) (t:ℝ) (z:W.Ω):ℝ :=if 0<t ∧ t<1 then limsup (fun N:ℕ ↦ coupledEuler t γ.coeff (gradient W γ) W.B N N z) atTop else 0lemma eulerLimitProcess_zero (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω):eulerLimitProcess W γ 0 z=0 :=bysimp [eulerLimitProcess]lemma eulerLimitProcess_measurable (W:BrownianSpace) (γ:OrderParameter) (t:ℝ):StronglyMeasurable[W.filtration t.toNNReal] (eulerLimitProcess W γ t) := byby_cases ht:0<t ∧ t<1· change StronglyMeasurable[W.filtration t.toNNReal] (fun z ↦ if 0<t ∧ t<1 then limsup (fun N:ℕ ↦ coupledEuler t γ.coeff (gradient W γ) W.B N N z) atTop else 0)simp only [ite_eq_left ht]apply Measurable.stronglyMeasurableapply Measurable.limsupintro Nby_cases hN:N=0· subst Nexact measurable_consthave hN':0<N:=Nat.pos_of_ne_zero hNhave hh:=coupled_euler_past_measurable W.measurable ht.1 hN' γ.coeff (gradient W γ)(fun j hj ↦ ((phi_evolution W γ ⟨ht.1.le,ht.2⟩).slices _ (mesh_time_mem ht.1.le hN' hj.le)).jets.smooth.continuous.measurable) N le_rflhave he:meshTime t N N=t:=by dsimp [meshTime,stepSize];field_simprw [he] at hhexact hh.measurable· change StronglyMeasurable[W.filtration t.toNNReal] (fun z ↦ if 0<t ∧ t<1 then limsup (fun N:ℕ ↦ coupledEuler t γ.coeff (gradient W γ) W.B N N z) atTop else 0)simp only [ite_eq_right ht]exact stronglyMeasurable_constlemma eulerLimitProcess_eq_path (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω){T:ℝ} (hT:T∈Ico (0:ℝ) 1) {X:ℝ → ℝ}(hc:ContinuousOn X (Icc (0:ℝ) T))(hi:IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (X s)) volume 0 T)(he:∀t∈Icc (0:ℝ) T,X t=W.B t.toNNReal z+∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (X s))(h0:X 0=0) {t:ℝ} (ht:t∈Icc (0:ℝ) T):eulerLimitProcess W γ t z=X t := byrcases ht.1.eq_or_lt with htz|htz· subst trw [eulerLimitProcess_zero,h0]have ht1:t<1:=ht.2.trans_lt hT.2obtain ⟨K,L,Lu,hLu,hG,hu⟩:=(sourceStripRegularity W γ).core t ⟨htz.le,ht1⟩have hsub:Icc (0:ℝ) t⊆Icc (0:ℝ) T:=Icc_subset_Icc le_rfl ht.2have hi':IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (X s)) volume 0 t:=hi.mono_set (byrw [uIcc_of_le htz.le,uIcc_of_le hT.1];exact hsub)have hv:=driven_euler_uniform_convergence(Y:=fun N j ↦ coupledEuler t γ.coeff (gradient W γ) W.B N j z) htz.le hLu(γ.monotone.mono (fun s hs ↦ ⟨hs.1,hs.2.trans_lt ht1⟩))(γ.nonneg 0 (by norm_num)) (fun s hs x ↦ gradient_bound W γ ⟨hs.1,hs.2.trans ht1.le⟩ x)hu (hc.mono hsub) hi' (fun s hs ↦ he s (hsub hs)) h0(fun N ↦ coupled_euler_zero t γ.coeff (gradient W γ) W.B N z)(fun N hN j hj ↦ coupled_euler_step W.B htz γ.coeff (gradient W γ) hN hj z)have hl:Tendsto (fun N:ℕ ↦ coupledEuler t γ.coeff (gradient W γ) W.B N N z) atTop (𝓝 (X t)) :=byapply Metric.tendsto_atTop.mprintro ε hεobtain ⟨N,hN⟩:=eventually_atTop.mp (hv ε hε)refine ⟨max N 1,?_⟩intro n hnhave hnpos:0<n:= lt_of_lt_of_le (by norm_num:(0:ℕ)<1) ((le_max_right N 1).trans hn)have hh:=hN n ((le_max_left N 1).trans hn) n le_rflhave hnt:(n:ℝ)*(t/n)=t:=by field_simpsimpa only [hnt,Real.dist_eq] using hhsimpa only [eulerLimitProcess,ite_eq_left (show 0<t ∧ t<1 from ⟨htz,ht1⟩)] using hl.limsup_eqend SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filter Functionopen scoped Topology NNRealnamespace SKValuelemma eulerLimitProcess_local_path (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω)(hb:Continuous (fun t:ℝ ↦ W.B t.toNNReal z)) (h0:W.B 0 z=0){T:ℝ} (hT:T∈Ico (0:ℝ) 1):ContinuousOn (fun t ↦ eulerLimitProcess W γ t z) (Icc (0:ℝ) T) ∧IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (eulerLimitProcess W γ s z)) volume 0 T ∧∀t∈Icc (0:ℝ) T,eulerLimitProcess W γ t z=W.B t.toNNReal z+∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (eulerLimitProcess W γ s z) :=byobtain ⟨X,hc,hi,he⟩:=exists_local_diffusion_path W γ hT _ hb.continuousOnhave hz:X 0=0:=by simpa only [Real.toNNReal_zero,h0,intervalIntegral.integral_same,add_zero] using he 0 ⟨le_rfl,hT.1⟩have heq (t:ℝ) (ht:t∈Icc (0:ℝ) T):eulerLimitProcess W γ t z=X t:=eulerLimitProcess_eq_path W γ z hT hc hi he hz htrefine ⟨hc.congr heq,hi.congr (fun s hs ↦ ?_),?_⟩· rw [uIoc_of_le hT.1] at hsrw [heq s ⟨hs.1.le,hs.2⟩]intro t htrw [heq t ht,he t ht]congr 1apply intervalIntegral.integral_congrintro s hsrw [uIcc_of_le ht.1] at hsdsimp onlyrw [heq s ⟨hs.1,hs.2.trans ht.2⟩]lemma continuousOn_preterminal_of_strips {f:ℝ → ℝ}(h:∀T∈Ico (0:ℝ) 1,ContinuousOn f (Icc (0:ℝ) T)):ContinuousOn f (Ico (0:ℝ) 1) :=byintro t htobtain ⟨T,htT,hT⟩:=exists_between ht.2apply (h T ⟨ht.1.trans htT.le,hT⟩ t ⟨ht.1,htT.le⟩).mono_of_mem_nhdsWithinfilter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds htT)] with s hs hsTexact ⟨hs.1,hsT.le⟩lemma eulerLimitProcess_drift_integrable (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω)(hb:Continuous (fun t:ℝ ↦ W.B t.toNNReal z)) (h0:W.B 0 z=0):IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (eulerLimitProcess W γ s z)) volume 0 1 :=byhave hu:ContinuousOn (fun s ↦ gradient W γ s (eulerLimitProcess W γ s z)) (Ico (0:ℝ) 1):=byapply continuousOn_preterminal_of_stripsintro T hTobtain ⟨K,L,Lu,hLu,hG,hLip⟩:=(sourceStripRegularity W γ).core T hThave hj:ContinuousOn (fun p:ℝ×ℝ ↦ gradient W γ p.1 p.2) {p | p.1∈Icc (0:ℝ) T}:=derivative_joint_continuous hLu hLiphave hp:ContinuousOn (fun s ↦ (s,eulerLimitProcess W γ s z)) (Icc (0:ℝ) T):=continuousOn_id.prodMk (eulerLimitProcess_local_path W γ z hb h0 hT).1exact ContinuousOn.comp (g:=fun p:ℝ×ℝ ↦ gradient W γ p.1 p.2)(f:=fun s ↦ (s,eulerLimitProcess W γ s z)) hj hp (fun s hs ↦ hs)apply (intervalIntegrable_iff_integrableOn_Ioc_of_le (by norm_num:(0:ℝ)≤1)).mprhave hm:AEStronglyMeasurable (fun s ↦ gradient W γ s (eulerLimitProcess W γ s z)) (volume.restrict (Ioc (0:ℝ) 1)) :=byrw [←Measure.restrict_congr_set Ioo_ae_eq_Ioc]exact (hu.mono Ioo_subset_Ico_self).aestronglyMeasurable measurableSet_Iooapply γ.integrable.mul_bdd hm (c:=(1:ℝ))filter_upwards [ae_restrict_mem measurableSet_Ioc] with s hssimpa only [Real.norm_eq_abs] using gradient_bound W γ ⟨hs.1.le,hs.2⟩ (eulerLimitProcess W γ s z)end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128import Mathlibimport OAI.Probability.SKValue.Processes.Volterranamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filter Functionopen scoped Topology NNRealnamespace SKValuenoncomputable def eulerLimitProcess (W:BrownianSpace) (γ:OrderParameter) (t:ℝ) (z:W.Ω):ℝ :=if 0<t ∧ t<1 then limsup (fun N:ℕ ↦ coupledEuler t γ.coeff (gradient W γ) W.B N N z) atTop else 0lemma eulerLimitProcess_zero (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω):eulerLimitProcess W γ 0 z=0 :=bysimp [eulerLimitProcess]lemma eulerLimitProcess_measurable (W:BrownianSpace) (γ:OrderParameter) (t:ℝ):StronglyMeasurable[W.filtration t.toNNReal] (eulerLimitProcess W γ t) := byby_cases ht:0<t ∧ t<1· change StronglyMeasurable[W.filtration t.toNNReal] (fun z ↦ if 0<t ∧ t<1 then limsup (fun N:ℕ ↦ coupledEuler t γ.coeff (gradient W γ) W.B N N z) atTop else 0)simp only [ite_eq_left ht]apply Measurable.stronglyMeasurableapply Measurable.limsupintro Nby_cases hN:N=0· subst Nexact measurable_consthave hN':0<N:=Nat.pos_of_ne_zero hNhave hh:=coupled_euler_past_measurable W.measurable ht.1 hN' γ.coeff (gradient W γ)(fun j hj ↦ ((phi_evolution W γ ⟨ht.1.le,ht.2⟩).slices _ (mesh_time_mem ht.1.le hN' hj.le)).jets.smooth.continuous.measurable) N le_rflhave he:meshTime t N N=t:=by dsimp [meshTime,stepSize];field_simprw [he] at hhexact hh.measurable· change StronglyMeasurable[W.filtration t.toNNReal] (fun z ↦ if 0<t ∧ t<1 then limsup (fun N:ℕ ↦ coupledEuler t γ.coeff (gradient W γ) W.B N N z) atTop else 0)simp only [ite_eq_right ht]exact stronglyMeasurable_constlemma eulerLimitProcess_eq_path (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω){T:ℝ} (hT:T∈Ico (0:ℝ) 1) {X:ℝ → ℝ}(hc:ContinuousOn X (Icc (0:ℝ) T))(hi:IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (X s)) volume 0 T)(he:∀t∈Icc (0:ℝ) T,X t=W.B t.toNNReal z+∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (X s))(h0:X 0=0) {t:ℝ} (ht:t∈Icc (0:ℝ) T):eulerLimitProcess W γ t z=X t := byrcases ht.1.eq_or_lt with htz|htz· subst trw [eulerLimitProcess_zero,h0]have ht1:t<1:=ht.2.trans_lt hT.2obtain ⟨K,L,Lu,hLu,hG,hu⟩:=(sourceStripRegularity W γ).core t ⟨htz.le,ht1⟩have hsub:Icc (0:ℝ) t⊆Icc (0:ℝ) T:=Icc_subset_Icc le_rfl ht.2have hi':IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (X s)) volume 0 t:=hi.mono_set (byrw [uIcc_of_le htz.le,uIcc_of_le hT.1];exact hsub)have hv:=driven_euler_uniform_convergence(Y:=fun N j ↦ coupledEuler t γ.coeff (gradient W γ) W.B N j z) htz.le hLu(γ.monotone.mono (fun s hs ↦ ⟨hs.1,hs.2.trans_lt ht1⟩))(γ.nonneg 0 (by norm_num)) (fun s hs x ↦ gradient_bound W γ ⟨hs.1,hs.2.trans ht1.le⟩ x)hu (hc.mono hsub) hi' (fun s hs ↦ he s (hsub hs)) h0(fun N ↦ coupled_euler_zero t γ.coeff (gradient W γ) W.B N z)(fun N hN j hj ↦ coupled_euler_step W.B htz γ.coeff (gradient W γ) hN hj z)have hl:Tendsto (fun N:ℕ ↦ coupledEuler t γ.coeff (gradient W γ) W.B N N z) atTop (𝓝 (X t)) :=byapply Metric.tendsto_atTop.mprintro ε hεobtain ⟨N,hN⟩:=eventually_atTop.mp (hv ε hε)refine ⟨max N 1,?_⟩intro n hnhave hnpos:0<n:= lt_of_lt_of_le (by norm_num:(0:ℕ)<1) ((le_max_right N 1).trans hn)have hh:=hN n ((le_max_left N 1).trans hn) n le_rflhave hnt:(n:ℝ)*(t/n)=t:=by field_simpsimpa only [hnt,Real.dist_eq] using hhsimpa only [eulerLimitProcess,ite_eq_left (show 0<t ∧ t<1 from ⟨htz,ht1⟩)] using hl.limsup_eqend SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filter Functionopen scoped Topology NNRealnamespace SKValuelemma eulerLimitProcess_local_path (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω)(hb:Continuous (fun t:ℝ ↦ W.B t.toNNReal z)) (h0:W.B 0 z=0){T:ℝ} (hT:T∈Ico (0:ℝ) 1):ContinuousOn (fun t ↦ eulerLimitProcess W γ t z) (Icc (0:ℝ) T) ∧IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (eulerLimitProcess W γ s z)) volume 0 T ∧∀t∈Icc (0:ℝ) T,eulerLimitProcess W γ t z=W.B t.toNNReal z+∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (eulerLimitProcess W γ s z) :=byobtain ⟨X,hc,hi,he⟩:=exists_local_diffusion_path W γ hT _ hb.continuousOnhave hz:X 0=0:=by simpa only [Real.toNNReal_zero,h0,intervalIntegral.integral_same,add_zero] using he 0 ⟨le_rfl,hT.1⟩have heq (t:ℝ) (ht:t∈Icc (0:ℝ) T):eulerLimitProcess W γ t z=X t:=eulerLimitProcess_eq_path W γ z hT hc hi he hz htrefine ⟨hc.congr heq,hi.congr (fun s hs ↦ ?_),?_⟩· rw [uIoc_of_le hT.1] at hsrw [heq s ⟨hs.1.le,hs.2⟩]intro t htrw [heq t ht,he t ht]congr 1apply intervalIntegral.integral_congrintro s hsrw [uIcc_of_le ht.1] at hsdsimp onlyrw [heq s ⟨hs.1,hs.2.trans ht.2⟩]lemma continuousOn_preterminal_of_strips {f:ℝ → ℝ}(h:∀T∈Ico (0:ℝ) 1,ContinuousOn f (Icc (0:ℝ) T)):ContinuousOn f (Ico (0:ℝ) 1) :=byintro t htobtain ⟨T,htT,hT⟩:=exists_between ht.2apply (h T ⟨ht.1.trans htT.le,hT⟩ t ⟨ht.1,htT.le⟩).mono_of_mem_nhdsWithinfilter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds htT)] with s hs hsTexact ⟨hs.1,hsT.le⟩lemma eulerLimitProcess_drift_integrable (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω)(hb:Continuous (fun t:ℝ ↦ W.B t.toNNReal z)) (h0:W.B 0 z=0):IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (eulerLimitProcess W γ s z)) volume 0 1 :=byhave hu:ContinuousOn (fun s ↦ gradient W γ s (eulerLimitProcess W γ s z)) (Ico (0:ℝ) 1):=byapply continuousOn_preterminal_of_stripsintro T hTobtain ⟨K,L,Lu,hLu,hG,hLip⟩:=(sourceStripRegularity W γ).core T hThave hj:ContinuousOn (fun p:ℝ×ℝ ↦ gradient W γ p.1 p.2) {p | p.1∈Icc (0:ℝ) T}:=derivative_joint_continuous hLu hLiphave hp:ContinuousOn (fun s ↦ (s,eulerLimitProcess W γ s z)) (Icc (0:ℝ) T):=continuousOn_id.prodMk (eulerLimitProcess_local_path W γ z hb h0 hT).1exact ContinuousOn.comp (g:=fun p:ℝ×ℝ ↦ gradient W γ p.1 p.2)(f:=fun s ↦ (s,eulerLimitProcess W γ s z)) hj hp (fun s hs ↦ hs)apply (intervalIntegrable_iff_integrableOn_Ioc_of_le (by norm_num:(0:ℝ)≤1)).mprhave hm:AEStronglyMeasurable (fun s ↦ gradient W γ s (eulerLimitProcess W γ s z)) (volume.restrict (Ioc (0:ℝ) 1)) :=byrw [←Measure.restrict_congr_set Ioo_ae_eq_Ioc]exact (hu.mono Ioo_subset_Ico_self).aestronglyMeasurable measurableSet_Iooapply γ.integrable.mul_bdd hm (c:=(1:ℝ))filter_upwards [ae_restrict_mem measurableSet_Ioc] with s hssimpa only [Real.norm_eq_abs] using gradient_bound W γ ⟨hs.1.le,hs.2⟩ (eulerLimitProcess W γ s z)end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151import Mathlibimport OAI.Probability.SKValue.Equations.RawIncrementimport OAI.Probability.SKValue.Equations.ValueStripnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorslemma euler_memLp (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(huM : ∀ j<N, Measurable (u (meshTime T N j)))(huB : ∀ j<N, ∀ x, |u (meshTime T N j) x|≤1) :∀ j≤N, MemLp (fun z ↦ euler T N γ u z j) 2 (gaussianProduct (Fin (N+1))) := byintro jinduction j with| zero => intro _; exact memLp_const (0 : ℝ)| succ j ih =>intro hjhave hlt : j<N := by omegahave hU : MemLp (fun z ↦ u (meshTime T N j) (euler T N γ u z j)) 2(gaussianProduct (Fin (N+1))) :=MemLp.of_bound ((huM j hlt).comp (measurable_euler T N γ u huM j hlt.le)).aestronglyMeasurable 1(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using huB j hlt _))exact ((ih hlt.le).add ((gaussian_memLp (coordinate_hasLaw N j) 2 (by norm_num)).const_mul _)).add(hU.const_mul (stepSize T N*γ (meshTime T N j)))lemma ValueStrip.value_lipschitz {T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(h : ValueStrip T γ V K L) {t : ℝ} (ht : t∈Icc (0 : ℝ) T) :LipschitzWith 1 (V t) := byapply lipschitzWith_of_nnnorm_deriv_le ((h.smooth t ht).differentiable (by norm_num))intro xexact_mod_cast (show ‖deriv (V t) x‖≤(1 : ℝ) by simpa only [Real.norm_eq_abs] using h.bounded t ht x)lemma ValueStrip.value_memLp {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsFiniteMeasure μ]{T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ} (h : ValueStrip T γ V K L){t : ℝ} (ht : t∈Icc (0 : ℝ) T) {Y : Ω → ℝ} (hY : MemLp Y 2 μ) :MemLp (fun ω ↦ V t (Y ω)) 2 μ := byhave hl : LipschitzWith 1 (fun x ↦ V t x - V t 0) := byrw [lipschitzWith_iff_dist_le_mul]intro x ysimpa only [dist_sub_right] using (h.value_lipschitz ht).dist_le_mul x yhave hh := hl.comp_memLp (by simp) hYconvert hh.add (memLp_const (V t 0)) using 1funext ωsimplemma value_mesh_expectation_error {T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0<T) (h : ValueStrip T γ V K L) {N : ℕ} (hN : 0<N) :|(∫ z, V T (euler T N γ (fun t ↦ deriv (V t)) z N) ∂gaussianProduct (Fin (N+1)))-V 0 0-(∫ z, valueMeshEnergy T N γ V N z ∂gaussianProduct (Fin (N+1)))| ≤Real.sqrt (valueMeshError T N γ V) := bylet u := fun t ↦ deriv (V t)let Y := euler T N γ ulet μ := gaussianProduct (Fin (N+1))let A (i : Fin N) (z : Fin (N+1) → ℝ) := u (meshTime T N i) (Y z i)let M (z : Fin (N+1) → ℝ) := ∑ i : Fin N, Real.sqrt (stepSize T N)*A i z*coordinate N i zlet R (z : Fin (N+1) → ℝ) := valueMeshCompensated T N γ V N z-V 0 0-M zhave htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hjhave huc (j : ℕ) (hj : j≤N) : Continuous (u (meshTime T N j)) :=(h.smooth _ (htime j hj)).continuous_deriv (by norm_num)have hY (j : ℕ) (hj : j≤N) : Measurable (fun z ↦ Y z j) :=measurable_euler T N γ u (fun i hi ↦ (huc i hi.le).measurable) j hjhave hAm (i : Fin N) : Measurable (A i) := (huc i i.isLt.le).measurable.comp (hY i i.isLt.le)have hAb (i : Fin N) z : |A i z|≤1 := h.bounded _ (htime i i.isLt.le) _have hAp (i : Fin N) : DependsBefore i (A i) := eulerCoefficient_dependsBefore T i.isLt.le γ u uhave hAM (i : Fin N) : MemLp (A i) 2 μ :=MemLp.of_bound (hAm i).aestronglyMeasurable 1(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using hAb i z))have hMm : MemLp M 2 μ := finiteRaw_memLp hAm hAp hAMhave hMv : (∫ z, M z ∂μ)=0 := byhave hMi (i : Fin N) : Integrable (fun z ↦ Real.sqrt (stepSize T N)*A i z*coordinate N i z) μ :=((rawIncrement_memLp (by omega : (i : ℕ)<N+1) (hAm i) (hAp i) (hAM i)).const_mul(Real.sqrt (stepSize T N))).integrable (by norm_num) |>.congr (byfilter_upwards [] with z; simp only [rawIncrement]; ring)rw [show (∫ z, M z ∂μ)=∑ i : Fin N, ∫ z, Real.sqrt (stepSize T N)*A i z*coordinate N i z ∂μ fromintegral_finsetSum _ (fun i _ ↦ hMi i)]have he (i : Fin N) : (∫ z, Real.sqrt (stepSize T N)*A i z*coordinate N i z ∂μ)=0 := bysimp only [mul_assoc]rw [integral_const_mul]change Real.sqrt (stepSize T N)*(∫ z, rawIncrement (A i) i z ∂μ)=0rw [rawIncrement_mean (by omega) (hAm i) (hAp i),mul_zero]simp only [he, Finset.sum_const_zero]have hEm : MemLp (valueMeshEnergy T N γ V N) 2 μ := byapply memLp_finsetSumintro j hjhave hjN : j<N := Finset.mem_range.mp hjapply MemLp.const_mulapply MemLp.of_bound (((huc j hjN.le).measurable.comp (hY j hjN.le)).pow_const 2).aestronglyMeasurable 1filter_upwards [] with zrw [Real.norm_eq_abs, abs_pow, sq_le_one_iff_abs_le_one]simpa only [abs_abs, u, Function.comp_apply] using h.bounded _ (htime j hjN.le) (Y z j)have hYM : MemLp (fun z ↦ Y z N) 2 μ :=euler_memLp T N γ u (fun i hi ↦ (huc i hi.le).measurable)(fun i hi x ↦ h.bounded _ (htime i hi.le) x) N le_rflhave hVM := h.value_memLp (t := T) ⟨hT.le,le_rfl⟩ hYMhave hlast : meshTime T N N=T := bydsimp only [meshTime, stepSize]have hn : (N : ℝ)≠0 := by exact_mod_cast Nat.ne_of_gt hNfield_simphave hRM : MemLp R 2 μ := bydsimp only [R,valueMeshCompensated]rw [hlast]exact ((hVM.sub hEm).sub (memLp_const (V 0 0))).sub hMmhave hRint : (∫ z, R z ∂μ)=(∫ z, V T (Y z N) ∂μ)-V 0 0-(∫ z, valueMeshEnergy T N γ V N z ∂μ) := bydsimp only [R,valueMeshCompensated]rw [hlast]have hi₁ := integral_sub (((hVM.sub hEm).sub (memLp_const (V 0 0))).integrable (by norm_num)) (hMm.integrable (by norm_num))have hi₂ := integral_sub ((hVM.sub hEm).integrable (by norm_num)) (integrable_const (V 0 0))simp only [Pi.sub_apply] at hi₁ hi₂change (∫ z, V T (Y z N)-valueMeshEnergy T N γ V N z-V 0 0-M z ∂μ)=_rw [hi₁, hi₂]rw [integral_sub (hVM.integrable (by norm_num)) (hEm.integrable (by norm_num)),hMv,integral_const]simp only [probReal_univ, smul_eq_mul, sub_zero]ringrw [←hRint]exact abs_integral_le_integral_abs.trans (integral_abs_le_sqrt_integral_sq hRM)lemma value_mesh_expectation_error_tendsto {T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0<T) (hT1 : T≤1) (h : ValueStrip T γ V K L) :Tendsto (fun N ↦ (∫ z, V T (euler T N γ (fun t ↦ deriv (V t)) z N)∂gaussianProduct (Fin (N+1)))-V 0 0-(∫ z, valueMeshEnergy T N γ V N z ∂gaussianProduct (Fin (N+1)))) atTop (𝓝 0) := byapply squeeze_zero_norm' (a := fun N ↦ Real.sqrt (valueMeshError T N γ V))· filter_upwards [eventually_gt_atTop 0] with N hNsimpa only [Real.norm_eq_abs] using value_mesh_expectation_error hT h hN· simpa only [Real.sqrt_zero, Function.comp_def] using (Real.continuous_sqrt.tendsto 0).comp (valueMeshError_tendsto_zero hT hT1 h)end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151import Mathlibimport OAI.Probability.SKValue.Equations.RawIncrementimport OAI.Probability.SKValue.Equations.ValueStripnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorslemma euler_memLp (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(huM : ∀ j<N, Measurable (u (meshTime T N j)))(huB : ∀ j<N, ∀ x, |u (meshTime T N j) x|≤1) :∀ j≤N, MemLp (fun z ↦ euler T N γ u z j) 2 (gaussianProduct (Fin (N+1))) := byintro jinduction j with| zero => intro _; exact memLp_const (0 : ℝ)| succ j ih =>intro hjhave hlt : j<N := by omegahave hU : MemLp (fun z ↦ u (meshTime T N j) (euler T N γ u z j)) 2(gaussianProduct (Fin (N+1))) :=MemLp.of_bound ((huM j hlt).comp (measurable_euler T N γ u huM j hlt.le)).aestronglyMeasurable 1(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using huB j hlt _))exact ((ih hlt.le).add ((gaussian_memLp (coordinate_hasLaw N j) 2 (by norm_num)).const_mul _)).add(hU.const_mul (stepSize T N*γ (meshTime T N j)))lemma ValueStrip.value_lipschitz {T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(h : ValueStrip T γ V K L) {t : ℝ} (ht : t∈Icc (0 : ℝ) T) :LipschitzWith 1 (V t) := byapply lipschitzWith_of_nnnorm_deriv_le ((h.smooth t ht).differentiable (by norm_num))intro xexact_mod_cast (show ‖deriv (V t) x‖≤(1 : ℝ) by simpa only [Real.norm_eq_abs] using h.bounded t ht x)lemma ValueStrip.value_memLp {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsFiniteMeasure μ]{T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ} (h : ValueStrip T γ V K L){t : ℝ} (ht : t∈Icc (0 : ℝ) T) {Y : Ω → ℝ} (hY : MemLp Y 2 μ) :MemLp (fun ω ↦ V t (Y ω)) 2 μ := byhave hl : LipschitzWith 1 (fun x ↦ V t x - V t 0) := byrw [lipschitzWith_iff_dist_le_mul]intro x ysimpa only [dist_sub_right] using (h.value_lipschitz ht).dist_le_mul x yhave hh := hl.comp_memLp (by simp) hYconvert hh.add (memLp_const (V t 0)) using 1funext ωsimplemma value_mesh_expectation_error {T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0<T) (h : ValueStrip T γ V K L) {N : ℕ} (hN : 0<N) :|(∫ z, V T (euler T N γ (fun t ↦ deriv (V t)) z N) ∂gaussianProduct (Fin (N+1)))-V 0 0-(∫ z, valueMeshEnergy T N γ V N z ∂gaussianProduct (Fin (N+1)))| ≤Real.sqrt (valueMeshError T N γ V) := bylet u := fun t ↦ deriv (V t)let Y := euler T N γ ulet μ := gaussianProduct (Fin (N+1))let A (i : Fin N) (z : Fin (N+1) → ℝ) := u (meshTime T N i) (Y z i)let M (z : Fin (N+1) → ℝ) := ∑ i : Fin N, Real.sqrt (stepSize T N)*A i z*coordinate N i zlet R (z : Fin (N+1) → ℝ) := valueMeshCompensated T N γ V N z-V 0 0-M zhave htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hjhave huc (j : ℕ) (hj : j≤N) : Continuous (u (meshTime T N j)) :=(h.smooth _ (htime j hj)).continuous_deriv (by norm_num)have hY (j : ℕ) (hj : j≤N) : Measurable (fun z ↦ Y z j) :=measurable_euler T N γ u (fun i hi ↦ (huc i hi.le).measurable) j hjhave hAm (i : Fin N) : Measurable (A i) := (huc i i.isLt.le).measurable.comp (hY i i.isLt.le)have hAb (i : Fin N) z : |A i z|≤1 := h.bounded _ (htime i i.isLt.le) _have hAp (i : Fin N) : DependsBefore i (A i) := eulerCoefficient_dependsBefore T i.isLt.le γ u uhave hAM (i : Fin N) : MemLp (A i) 2 μ :=MemLp.of_bound (hAm i).aestronglyMeasurable 1(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using hAb i z))have hMm : MemLp M 2 μ := finiteRaw_memLp hAm hAp hAMhave hMv : (∫ z, M z ∂μ)=0 := byhave hMi (i : Fin N) : Integrable (fun z ↦ Real.sqrt (stepSize T N)*A i z*coordinate N i z) μ :=((rawIncrement_memLp (by omega : (i : ℕ)<N+1) (hAm i) (hAp i) (hAM i)).const_mul(Real.sqrt (stepSize T N))).integrable (by norm_num) |>.congr (byfilter_upwards [] with z; simp only [rawIncrement]; ring)rw [show (∫ z, M z ∂μ)=∑ i : Fin N, ∫ z, Real.sqrt (stepSize T N)*A i z*coordinate N i z ∂μ fromintegral_finsetSum _ (fun i _ ↦ hMi i)]have he (i : Fin N) : (∫ z, Real.sqrt (stepSize T N)*A i z*coordinate N i z ∂μ)=0 := bysimp only [mul_assoc]rw [integral_const_mul]change Real.sqrt (stepSize T N)*(∫ z, rawIncrement (A i) i z ∂μ)=0rw [rawIncrement_mean (by omega) (hAm i) (hAp i),mul_zero]simp only [he, Finset.sum_const_zero]have hEm : MemLp (valueMeshEnergy T N γ V N) 2 μ := byapply memLp_finsetSumintro j hjhave hjN : j<N := Finset.mem_range.mp hjapply MemLp.const_mulapply MemLp.of_bound (((huc j hjN.le).measurable.comp (hY j hjN.le)).pow_const 2).aestronglyMeasurable 1filter_upwards [] with zrw [Real.norm_eq_abs, abs_pow, sq_le_one_iff_abs_le_one]simpa only [abs_abs, u, Function.comp_apply] using h.bounded _ (htime j hjN.le) (Y z j)have hYM : MemLp (fun z ↦ Y z N) 2 μ :=euler_memLp T N γ u (fun i hi ↦ (huc i hi.le).measurable)(fun i hi x ↦ h.bounded _ (htime i hi.le) x) N le_rflhave hVM := h.value_memLp (t := T) ⟨hT.le,le_rfl⟩ hYMhave hlast : meshTime T N N=T := bydsimp only [meshTime, stepSize]have hn : (N : ℝ)≠0 := by exact_mod_cast Nat.ne_of_gt hNfield_simphave hRM : MemLp R 2 μ := bydsimp only [R,valueMeshCompensated]rw [hlast]exact ((hVM.sub hEm).sub (memLp_const (V 0 0))).sub hMmhave hRint : (∫ z, R z ∂μ)=(∫ z, V T (Y z N) ∂μ)-V 0 0-(∫ z, valueMeshEnergy T N γ V N z ∂μ) := bydsimp only [R,valueMeshCompensated]rw [hlast]have hi₁ := integral_sub (((hVM.sub hEm).sub (memLp_const (V 0 0))).integrable (by norm_num)) (hMm.integrable (by norm_num))have hi₂ := integral_sub ((hVM.sub hEm).integrable (by norm_num)) (integrable_const (V 0 0))simp only [Pi.sub_apply] at hi₁ hi₂change (∫ z, V T (Y z N)-valueMeshEnergy T N γ V N z-V 0 0-M z ∂μ)=_rw [hi₁, hi₂]rw [integral_sub (hVM.integrable (by norm_num)) (hEm.integrable (by norm_num)),hMv,integral_const]simp only [probReal_univ, smul_eq_mul, sub_zero]ringrw [←hRint]exact abs_integral_le_integral_abs.trans (integral_abs_le_sqrt_integral_sq hRM)lemma value_mesh_expectation_error_tendsto {T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0<T) (hT1 : T≤1) (h : ValueStrip T γ V K L) :Tendsto (fun N ↦ (∫ z, V T (euler T N γ (fun t ↦ deriv (V t)) z N)∂gaussianProduct (Fin (N+1)))-V 0 0-(∫ z, valueMeshEnergy T N γ V N z ∂gaussianProduct (Fin (N+1)))) atTop (𝓝 0) := byapply squeeze_zero_norm' (a := fun N ↦ Real.sqrt (valueMeshError T N γ V))· filter_upwards [eventually_gt_atTop 0] with N hNsimpa only [Real.norm_eq_abs] using value_mesh_expectation_error hT h hN· simpa only [Real.sqrt_zero, Function.comp_def] using (Real.continuous_sqrt.tendsto 0).comp (valueMeshError_tendsto_zero hT hT1 h)end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299import Mathlibimport OAI.Probability.SKValue.Gaussian.CoupledCoordinatesimport OAI.Probability.SKValue.Equations.ValueStripimport OAI.Probability.SKValue.Equations.CubicEnvelopeMeanimport OAI.Probability.SKValue.Control.Controlsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuenoncomputable def meshControl {Ω : Type*} (T : ℝ) (N : ℕ) (H : Fin N → Ω → ℝ)(t : ℝ≥0) (ω : Ω) : ℝ :=∑ j : Fin N, if meshTime T N j < t ∧ (t : ℝ) ≤ meshTime T N (j+1) then H j ω else 0lemma progressive_interval {Ω : Type*} [m : MeasurableSpace Ω]{f : Filtration ℝ≥0 m} {a b : ℝ} {H : Ω → ℝ} (_ : 0 ≤ a)(hH : Measurable[f (Real.toNNReal a)] H) :IsProgressive f (fun t ω ↦ if a < (t : ℝ) ∧ (t : ℝ) ≤ b then H ω else 0) := byintro tby_cases hat : Real.toNNReal a ≤ t· let : MeasurableSpace Ω := f thave hHm : Measurable H := hH.mono (f.mono hat) le_rflexact (hHm.comp measurable_snd).ite((measurableSet_lt measurable_const (measurable_coe_nnreal_real.comp(measurable_subtype_coe.comp measurable_fst))).inter(measurableSet_le (measurable_coe_nnreal_real.comp(measurable_subtype_coe.comp measurable_fst)) measurable_const)) measurable_const· have he : (fun p : Iic t × Ω ↦ if a < (p.1 : ℝ≥0) ∧ ((p.1 : ℝ≥0) : ℝ) ≤ b then H p.2 else 0) =fun _ ↦ (0 : ℝ) := byfunext papply ite_eq_rightintro hpexact hat ((Real.toNNReal_le_iff_le_coe).2 (hp.1.le.trans (by exact_mod_cast p.1.2)))rw [he]exact measurable_constlemma meshControl_progressive {Ω : Type*} [m : MeasurableSpace Ω]{f : Filtration ℝ≥0 m} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} {H : Fin N → Ω → ℝ}(hH : ∀ j : Fin N, Measurable[f (Real.toNNReal (meshTime T N j))] (H j)) :IsProgressive f (meshControl T N H) := byapply IsProgressive.finsetSumintro j _exact progressive_interval (mesh_time_mem_total hT j.isLt.le).1 (hH j)lemma mesh_intervals_disjoint {T : ℝ} (hT : 0 ≤ T) {N : ℕ} {i j : Fin N} {t : ℝ}(hi : meshTime T N i < t ∧ t ≤ meshTime T N (i+1))(hj : meshTime T N j < t ∧ t ≤ meshTime T N (j+1)) : i=j := byhave hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg N)have hlt : ∀ a b : ℕ, a+1 ≤ b → meshTime T N (a+1) ≤ meshTime T N b := byintro a b habexact mul_le_mul_of_nonneg_right (by exact_mod_cast hab) hδapply Fin.extby_contra hercases lt_or_gt_of_ne he with hij | hji· have hh := hlt i j hijlinarith [hi.2,hj.1]· have hh := hlt j i hjilinarith [hi.1,hj.2]lemma meshControl_eq {Ω : Type*} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} (H : Fin N → Ω → ℝ){j : Fin N} {t : ℝ≥0} (ht : meshTime T N j < t ∧ (t : ℝ) ≤ meshTime T N (j+1)) (ω : Ω) :meshControl T N H t ω=H j ω := byunfold meshControlrw [Finset.sum_eq_single j]· simp only [ite_eq_left ht]· intro i _ hijexact ite_eq_right (fun hi ↦ hij (mesh_intervals_disjoint hT hi ht))· simplemma meshControl_bound {Ω : Type*} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} (H : Fin N → Ω → ℝ)(hH : ∀ j ω, |H j ω| ≤ 1) (t : ℝ≥0) (ω : Ω) : |meshControl T N H t ω| ≤ 1 := byby_cases he : ∃ j : Fin N, meshTime T N j < t ∧ (t : ℝ) ≤ meshTime T N (j+1)· obtain ⟨j,hj⟩ := herw [meshControl_eq hT H hj]exact hH j ω· have hh : meshControl T N H t ω=0 := byunfold meshControlapply Finset.sum_eq_zerointro j _exact ite_eq_right (fun hj ↦ he ⟨j,hj⟩)rw [hh]norm_numlemma meshControl_momentIntegral {Ω : Type*} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} (hN : 0<N)(H : Fin N → Ω → ℝ) {γ : ℝ → ℝ} (hγ : IntervalIntegrable γ volume 0 T)(k : ℕ) (ω : Ω) :controlAccum γ (meshControl T N H) k T ω =∑ j : Fin N, (∫ s in meshTime T N j..meshTime T N (j+1), γ s)*(H j ω)^k := byhave hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg N)have htime (j : ℕ) (hj : j ≤ N) := mesh_time_mem_total hT hjhave horder (j : ℕ) : meshTime T N j ≤ meshTime T N (j+1) := bydsimp [meshTime]exact mul_le_mul_of_nonneg_right (by exact_mod_cast Nat.le_succ j) hδhave hlast : meshTime T N N=T := bydsimp [meshTime,stepSize]field_simphave he (j : Fin N) :(fun s ↦ γ s*(meshControl T N H (Real.toNNReal s) ω)^k) =ᵐ[volume.restrict (uIoc (meshTime T N j) (meshTime T N (j+1)))](fun s ↦ γ s*(H j ω)^k) := byfilter_upwards [ae_restrict_mem measurableSet_uIoc] with s hsrw [uIoc_of_le (horder j)] at hshave hs0 : 0 ≤ s := (htime j j.isLt.le).1.trans hs.1.lerw [meshControl_eq hT H (by simpa only [Real.coe_toNNReal _ hs0,Set.mem_Ioc] using hs)]have hi (j : ℕ) (hj : j<N) : IntervalIntegrable(fun s ↦ γ s*(meshControl T N H (Real.toNNReal s) ω)^k) volume(meshTime T N j) (meshTime T N (j+1)) := byapply ((intervalIntegrable_substrip hT hγ (htime j hj.le)(htime (j+1) hj)).mul_const ((H ⟨j,hj⟩ ω)^k)).congr_aeexact (he ⟨j,hj⟩).symmhave hs := intervalIntegral.sum_integral_adjacent_intervals hirw [hlast,show meshTime T N 0=0 by simp [meshTime]] at hsrw [controlAccum,←hs,←Fin.sum_univ_eq_sum_range]apply Finset.sum_congr rflintro j _rw [intervalIntegral.integral_congr_ae_restrict (he j),intervalIntegral.integral_mul_const]lemma monotone_interval_quadrature {γ : ℝ → ℝ} {a b : ℝ} (hab : a ≤ b)(hγ : MonotoneOn γ (Icc a b)) :|(∫ s in a..b, γ s)-(b-a)*γ a| ≤ (b-a)*(γ b-γ a) := byhave hi : IntervalIntegrable γ volume a b := byapply MonotoneOn.intervalIntegrablesimpa only [uIcc_of_le hab] using hγhave hdiff : (∫ s in a..b, γ s)-(b-a)*γ a =∫ s in a..b, γ s-γ a := byrw [intervalIntegral.integral_sub hi intervalIntegrable_const]simp only [intervalIntegral.integral_const,smul_eq_mul]rw [hdiff]have hh := intervalIntegral.norm_integral_le_of_norm_le_const(a := a) (b := b) (f := fun s ↦ γ s-γ a) (C := γ b-γ a) (fun s hs ↦ byrw [uIoc_of_le hab] at hshave hs' : s∈Icc a b := ⟨hs.1.le,hs.2⟩rw [Real.norm_eq_abs,abs_of_nonneg (sub_nonneg.mpr (hγ ⟨le_rfl,hab⟩ hs' hs.1.le))]exact sub_le_sub_right (hγ hs' ⟨hab,le_rfl⟩ hs.2) _)simpa only [Real.norm_eq_abs,abs_of_nonneg (sub_nonneg.mpr hab),mul_comm] using hhlemma meshControl_quadrature {Ω : Type*} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} (hN : 0<N)(H : Fin N → Ω → ℝ) (hH : ∀ j ω, |H j ω| ≤ 1){γ : ℝ → ℝ} (hγ : MonotoneOn γ (Icc (0 : ℝ) T)) (k : ℕ) (ω : Ω) :|controlAccum γ (meshControl T N H) k T ω-∑ j : Fin N, stepSize T N*γ (meshTime T N j)*(H j ω)^k| ≤stepSize T N*(γ T-γ 0) := byhave hi : IntervalIntegrable γ volume 0 T := byapply MonotoneOn.intervalIntegrablesimpa only [uIcc_of_le hT] using hγrw [meshControl_momentIntegral hT hN H hi, ←Finset.sum_sub_distrib]have hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg N)have htime (j : ℕ) (hj : j ≤ N) := mesh_time_mem_total hT hjhave hgap (j : ℕ) : meshTime T N (j+1)-meshTime T N j=stepSize T N := bydsimp [meshTime]push_castringhave horder (j : ℕ) : meshTime T N j ≤ meshTime T N (j+1) := bylinarith [hgap j]have hloc (j : Fin N) :|(∫ s in meshTime T N j..meshTime T N (j+1), γ s)*(H j ω)^k-stepSize T N*γ (meshTime T N j)*(H j ω)^k| ≤stepSize T N*(γ (meshTime T N (j+1))-γ (meshTime T N j)) := byrw [←sub_mul,abs_mul]have hh := monotone_interval_quadrature (horder j)(hγ.mono (Icc_subset_Icc (htime j j.isLt.le).1 (htime (j+1) j.isLt).2))rw [hgap] at hhhave hp : |(H j ω)^k| ≤ 1 := byrw [abs_pow]exact pow_le_one₀ (abs_nonneg _) (hH j ω)exact (mul_le_mul_of_nonneg_left hp (abs_nonneg _)).trans (by simpa only [mul_one] using hh)calc_ ≤ ∑ j : Fin N, |(∫ s in meshTime T N j..meshTime T N (j+1), γ s)*(H j ω)^k-stepSize T N*γ (meshTime T N j)*(H j ω)^k| := Finset.abs_sum_le_sum_abs _ __ ≤ ∑ j : Fin N, stepSize T N*(γ (meshTime T N (j+1))-γ (meshTime T N j)) :=Finset.sum_le_sum (fun j _ ↦ hloc j)_ = _ := byrw [←Finset.mul_sum, sum_steps_sub (fun j ↦ γ (meshTime T N j))]have hlast : meshTime T N N=T := bydsimp [meshTime,stepSize]field_simpchange stepSize T N*(γ (meshTime T N N)-γ (meshTime T N 0)) = _rw [hlast]simp only [meshTime,Nat.cast_zero,zero_mul]lemma coupled_euler_past_measurable {Ω : Type*} [m : MeasurableSpace Ω]{B : ℝ≥0 → Ω → ℝ} (hBm : ∀ t, StronglyMeasurable (B t)){T : ℝ} (hT : 0<T) {N : ℕ} (hN : 0<N) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(hu : ∀ j<N, Measurable (u (meshTime T N j))) :∀ j ≤ N, StronglyMeasurable[Filtration.natural B hBm (Real.toNNReal (meshTime T N j))](coupledEuler T γ u B N j) := bylet f := Filtration.natural B hBmintro jinduction j with| zero =>intro _convert (stronglyMeasurable_const : StronglyMeasurable[f (Real.toNNReal (meshTime T N 0))] (fun _ : Ω ↦ (0 : ℝ))) using 1funext ωexact coupled_euler_zero T γ u B N ω| succ j ih =>intro hjNhave hj : j<N := hjNhave hδ : 0 ≤ stepSize T N := div_nonneg hT.le (Nat.cast_nonneg N)have ht : Real.toNNReal (meshTime T N j) ≤ Real.toNNReal (meshTime T N (j+1)) := byapply Real.toNNReal_monoapply mul_le_mul_of_nonneg_right _ hδexact_mod_cast Nat.le_succ jhave hY := (ih hj.le).mono (f.mono ht)have hB0 := (Filtration.stronglyAdapted_natural hBm (Real.toNNReal (meshTime T N j))).mono (f.mono ht)have hB1 := Filtration.stronglyAdapted_natural hBm (Real.toNNReal (meshTime T N (j+1)))have hU := ((hu j hj).comp hY.measurable).stronglyMeasurable.const_mul(stepSize T N*γ (meshTime T N j))convert ((hY.add hB1).sub hB0).add hU using 1funext ωrw [coupled_euler_step B hT γ u hN hj ω]rfllemma coupled_euler_drift_sum {Ω : Type*} (B : ℝ≥0 → Ω → ℝ){T : ℝ} (hT : 0<T) {N : ℕ} (hN : 0<N) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ) (ω : Ω) :coupledEuler T γ u B N N ω = B (Real.toNNReal T) ω-B 0 ω+∑ j : Fin N, stepSize T N*γ (meshTime T N j)*u (meshTime T N j) (coupledEuler T γ u B N j ω) := byhave he (j : Fin N) :coupledEuler T γ u B N (j+1) ω-coupledEuler T γ u B N j ω =(B (Real.toNNReal (meshTime T N (j+1))) ω-B (Real.toNNReal (meshTime T N j)) ω)+stepSize T N*γ (meshTime T N j)*u (meshTime T N j) (coupledEuler T γ u B N j ω) := byrw [coupled_euler_step B hT γ u hN j.isLt ω]dsimp [meshTime,stepSize]ringhave hh := Finset.sum_congr (rfl : (Finset.univ : Finset (Fin N))=Finset.univ) (fun j _ ↦ he j)rw [sum_steps_sub (fun j ↦ coupledEuler T γ u B N j ω),Finset.sum_add_distrib,sum_steps_sub (fun j ↦ B (Real.toNNReal (meshTime T N j)) ω),coupled_euler_zero] at hhhave hlast : meshTime T N N=T := by dsimp [meshTime,stepSize]; field_simpsimpa only [sub_zero,hlast,show meshTime T N 0=0 by simp [meshTime],Real.toNNReal_zero] using hhnoncomputable def feedbackControl {Ω : Type*} (B : ℝ≥0 → Ω → ℝ) (γ : ℝ → ℝ)(V : ℝ → ℝ → ℝ) (T : ℝ) (N : ℕ) : ℝ≥0 → Ω → ℝ :=meshControl T N (fun j ω ↦ deriv (V (meshTime T N j))(coupledEuler T γ (fun t ↦ deriv (V t)) B N j ω))lemma ValueStrip.feedback_progressive {Ω : Type*} [m : MeasurableSpace Ω]{B : ℝ≥0 → Ω → ℝ} (hBm : ∀ t, StronglyMeasurable (B t)){T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0<T) (h : ValueStrip T γ V K L) {N : ℕ} (hN : 0<N) :IsProgressive (Filtration.natural B hBm) (feedbackControl B γ V T N) := byapply meshControl_progressive hT.leintro jhave hu (i : ℕ) (hi : i ≤ N) : Continuous (deriv (V (meshTime T N i))) :=(h.smooth _ (mesh_time_mem_total hT.le hi)).continuous_deriv (by norm_num)exact (hu j j.isLt.le).measurable.comp(coupled_euler_past_measurable hBm hT hN γ (fun t ↦ deriv (V t))(fun i hi ↦ (hu i hi.le).measurable) j j.isLt.le).measurablelemma ValueStrip.feedback_bound {Ω : Type*} (B : ℝ≥0 → Ω → ℝ){T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0 ≤ T) (h : ValueStrip T γ V K L) (N : ℕ) (s : ℝ≥0) (ω : Ω) :|feedbackControl B γ V T N s ω| ≤ 1 :=meshControl_bound hT _ (fun j _ ↦ h.bounded _ (mesh_time_mem_total hT j.isLt.le) _) s ωlemma ValueStrip.feedback_state_error {Ω : Type*} (B : ℝ≥0 → Ω → ℝ){T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0<T) (h : ValueStrip T γ V K L) {N : ℕ} (hN : 0<N)(ω : Ω) (hB0 : B 0 ω=0) :|controlState B γ (feedbackControl B γ V T N) 0 T ω-coupledEuler T γ (fun t ↦ deriv (V t)) B N N ω| ≤ stepSize T N*(γ T-γ 0) := byhave hh := meshControl_quadrature hT.le hN(fun (j : Fin N) ω ↦ deriv (V (meshTime T N j))(coupledEuler T γ (fun t ↦ deriv (V t)) B N j ω))(fun j ω ↦ h.bounded _ (mesh_time_mem_total hT.le j.isLt.le) _)h.gamma_mono 1 ωrw [controlState,coupled_euler_drift_sum B hT hN,hB0]simpa only [pow_one,zero_add,sub_zero,add_sub_add_left_eq_sub,feedbackControl] using hhlemma ValueStrip.feedback_energy_error {Ω : Type*} (B : ℝ≥0 → Ω → ℝ){T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0<T) (h : ValueStrip T γ V K L) {N : ℕ} (hN : 0<N) (ω : Ω) :|(1/2 : ℝ)*controlAccum γ (feedbackControl B γ V T N) 2 T ω-valueMeshEnergy T N γ V N (coupledCoordinates T N B ω)| ≤(1/2 : ℝ)*stepSize T N*(γ T-γ 0) := byhave hh := meshControl_quadrature hT.le hN(fun (j : Fin N) ω ↦ deriv (V (meshTime T N j))(coupledEuler T γ (fun t ↦ deriv (V t)) B N j ω))(fun j ω ↦ h.bounded _ (mesh_time_mem_total hT.le j.isLt.le) _)h.gamma_mono 2 ωhave he : valueMeshEnergy T N γ V N (coupledCoordinates T N B ω) = (1/2 : ℝ)*∑ j : Fin N, stepSize T N*γ (meshTime T N j)*(deriv (V (meshTime T N j)) (coupledEuler T γ (fun t ↦ deriv (V t)) B N j ω))^2 := byrw [Fin.sum_univ_eq_sum_range (fun j ↦ stepSize T N*γ (meshTime T N j)*(deriv (V (meshTime T N j)) (coupledEuler T γ (fun t ↦ deriv (V t)) B N j ω))^2)]dsimp only [valueMeshEnergy,coupledEuler]simp only [ite_eq_right hN.ne',Finset.mul_sum]apply Finset.sum_congr rflintro j _ringrw [he,←mul_sub,abs_mul,abs_of_nonneg (by norm_num : 0 ≤ (1/2 : ℝ))]exact (mul_le_mul_of_nonneg_left hh (by norm_num)).trans_eq (by ring)end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299import Mathlibimport OAI.Probability.SKValue.Gaussian.CoupledCoordinatesimport OAI.Probability.SKValue.Equations.ValueStripimport OAI.Probability.SKValue.Equations.CubicEnvelopeMeanimport OAI.Probability.SKValue.Control.Controlsnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValuenoncomputable def meshControl {Ω : Type*} (T : ℝ) (N : ℕ) (H : Fin N → Ω → ℝ)(t : ℝ≥0) (ω : Ω) : ℝ :=∑ j : Fin N, if meshTime T N j < t ∧ (t : ℝ) ≤ meshTime T N (j+1) then H j ω else 0lemma progressive_interval {Ω : Type*} [m : MeasurableSpace Ω]{f : Filtration ℝ≥0 m} {a b : ℝ} {H : Ω → ℝ} (_ : 0 ≤ a)(hH : Measurable[f (Real.toNNReal a)] H) :IsProgressive f (fun t ω ↦ if a < (t : ℝ) ∧ (t : ℝ) ≤ b then H ω else 0) := byintro tby_cases hat : Real.toNNReal a ≤ t· let : MeasurableSpace Ω := f thave hHm : Measurable H := hH.mono (f.mono hat) le_rflexact (hHm.comp measurable_snd).ite((measurableSet_lt measurable_const (measurable_coe_nnreal_real.comp(measurable_subtype_coe.comp measurable_fst))).inter(measurableSet_le (measurable_coe_nnreal_real.comp(measurable_subtype_coe.comp measurable_fst)) measurable_const)) measurable_const· have he : (fun p : Iic t × Ω ↦ if a < (p.1 : ℝ≥0) ∧ ((p.1 : ℝ≥0) : ℝ) ≤ b then H p.2 else 0) =fun _ ↦ (0 : ℝ) := byfunext papply ite_eq_rightintro hpexact hat ((Real.toNNReal_le_iff_le_coe).2 (hp.1.le.trans (by exact_mod_cast p.1.2)))rw [he]exact measurable_constlemma meshControl_progressive {Ω : Type*} [m : MeasurableSpace Ω]{f : Filtration ℝ≥0 m} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} {H : Fin N → Ω → ℝ}(hH : ∀ j : Fin N, Measurable[f (Real.toNNReal (meshTime T N j))] (H j)) :IsProgressive f (meshControl T N H) := byapply IsProgressive.finsetSumintro j _exact progressive_interval (mesh_time_mem_total hT j.isLt.le).1 (hH j)lemma mesh_intervals_disjoint {T : ℝ} (hT : 0 ≤ T) {N : ℕ} {i j : Fin N} {t : ℝ}(hi : meshTime T N i < t ∧ t ≤ meshTime T N (i+1))(hj : meshTime T N j < t ∧ t ≤ meshTime T N (j+1)) : i=j := byhave hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg N)have hlt : ∀ a b : ℕ, a+1 ≤ b → meshTime T N (a+1) ≤ meshTime T N b := byintro a b habexact mul_le_mul_of_nonneg_right (by exact_mod_cast hab) hδapply Fin.extby_contra hercases lt_or_gt_of_ne he with hij | hji· have hh := hlt i j hijlinarith [hi.2,hj.1]· have hh := hlt j i hjilinarith [hi.1,hj.2]lemma meshControl_eq {Ω : Type*} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} (H : Fin N → Ω → ℝ){j : Fin N} {t : ℝ≥0} (ht : meshTime T N j < t ∧ (t : ℝ) ≤ meshTime T N (j+1)) (ω : Ω) :meshControl T N H t ω=H j ω := byunfold meshControlrw [Finset.sum_eq_single j]· simp only [ite_eq_left ht]· intro i _ hijexact ite_eq_right (fun hi ↦ hij (mesh_intervals_disjoint hT hi ht))· simplemma meshControl_bound {Ω : Type*} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} (H : Fin N → Ω → ℝ)(hH : ∀ j ω, |H j ω| ≤ 1) (t : ℝ≥0) (ω : Ω) : |meshControl T N H t ω| ≤ 1 := byby_cases he : ∃ j : Fin N, meshTime T N j < t ∧ (t : ℝ) ≤ meshTime T N (j+1)· obtain ⟨j,hj⟩ := herw [meshControl_eq hT H hj]exact hH j ω· have hh : meshControl T N H t ω=0 := byunfold meshControlapply Finset.sum_eq_zerointro j _exact ite_eq_right (fun hj ↦ he ⟨j,hj⟩)rw [hh]norm_numlemma meshControl_momentIntegral {Ω : Type*} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} (hN : 0<N)(H : Fin N → Ω → ℝ) {γ : ℝ → ℝ} (hγ : IntervalIntegrable γ volume 0 T)(k : ℕ) (ω : Ω) :controlAccum γ (meshControl T N H) k T ω =∑ j : Fin N, (∫ s in meshTime T N j..meshTime T N (j+1), γ s)*(H j ω)^k := byhave hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg N)have htime (j : ℕ) (hj : j ≤ N) := mesh_time_mem_total hT hjhave horder (j : ℕ) : meshTime T N j ≤ meshTime T N (j+1) := bydsimp [meshTime]exact mul_le_mul_of_nonneg_right (by exact_mod_cast Nat.le_succ j) hδhave hlast : meshTime T N N=T := bydsimp [meshTime,stepSize]field_simphave he (j : Fin N) :(fun s ↦ γ s*(meshControl T N H (Real.toNNReal s) ω)^k) =ᵐ[volume.restrict (uIoc (meshTime T N j) (meshTime T N (j+1)))](fun s ↦ γ s*(H j ω)^k) := byfilter_upwards [ae_restrict_mem measurableSet_uIoc] with s hsrw [uIoc_of_le (horder j)] at hshave hs0 : 0 ≤ s := (htime j j.isLt.le).1.trans hs.1.lerw [meshControl_eq hT H (by simpa only [Real.coe_toNNReal _ hs0,Set.mem_Ioc] using hs)]have hi (j : ℕ) (hj : j<N) : IntervalIntegrable(fun s ↦ γ s*(meshControl T N H (Real.toNNReal s) ω)^k) volume(meshTime T N j) (meshTime T N (j+1)) := byapply ((intervalIntegrable_substrip hT hγ (htime j hj.le)(htime (j+1) hj)).mul_const ((H ⟨j,hj⟩ ω)^k)).congr_aeexact (he ⟨j,hj⟩).symmhave hs := intervalIntegral.sum_integral_adjacent_intervals hirw [hlast,show meshTime T N 0=0 by simp [meshTime]] at hsrw [controlAccum,←hs,←Fin.sum_univ_eq_sum_range]apply Finset.sum_congr rflintro j _rw [intervalIntegral.integral_congr_ae_restrict (he j),intervalIntegral.integral_mul_const]lemma monotone_interval_quadrature {γ : ℝ → ℝ} {a b : ℝ} (hab : a ≤ b)(hγ : MonotoneOn γ (Icc a b)) :|(∫ s in a..b, γ s)-(b-a)*γ a| ≤ (b-a)*(γ b-γ a) := byhave hi : IntervalIntegrable γ volume a b := byapply MonotoneOn.intervalIntegrablesimpa only [uIcc_of_le hab] using hγhave hdiff : (∫ s in a..b, γ s)-(b-a)*γ a =∫ s in a..b, γ s-γ a := byrw [intervalIntegral.integral_sub hi intervalIntegrable_const]simp only [intervalIntegral.integral_const,smul_eq_mul]rw [hdiff]have hh := intervalIntegral.norm_integral_le_of_norm_le_const(a := a) (b := b) (f := fun s ↦ γ s-γ a) (C := γ b-γ a) (fun s hs ↦ byrw [uIoc_of_le hab] at hshave hs' : s∈Icc a b := ⟨hs.1.le,hs.2⟩rw [Real.norm_eq_abs,abs_of_nonneg (sub_nonneg.mpr (hγ ⟨le_rfl,hab⟩ hs' hs.1.le))]exact sub_le_sub_right (hγ hs' ⟨hab,le_rfl⟩ hs.2) _)simpa only [Real.norm_eq_abs,abs_of_nonneg (sub_nonneg.mpr hab),mul_comm] using hhlemma meshControl_quadrature {Ω : Type*} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} (hN : 0<N)(H : Fin N → Ω → ℝ) (hH : ∀ j ω, |H j ω| ≤ 1){γ : ℝ → ℝ} (hγ : MonotoneOn γ (Icc (0 : ℝ) T)) (k : ℕ) (ω : Ω) :|controlAccum γ (meshControl T N H) k T ω-∑ j : Fin N, stepSize T N*γ (meshTime T N j)*(H j ω)^k| ≤stepSize T N*(γ T-γ 0) := byhave hi : IntervalIntegrable γ volume 0 T := byapply MonotoneOn.intervalIntegrablesimpa only [uIcc_of_le hT] using hγrw [meshControl_momentIntegral hT hN H hi, ←Finset.sum_sub_distrib]have hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg N)have htime (j : ℕ) (hj : j ≤ N) := mesh_time_mem_total hT hjhave hgap (j : ℕ) : meshTime T N (j+1)-meshTime T N j=stepSize T N := bydsimp [meshTime]push_castringhave horder (j : ℕ) : meshTime T N j ≤ meshTime T N (j+1) := bylinarith [hgap j]have hloc (j : Fin N) :|(∫ s in meshTime T N j..meshTime T N (j+1), γ s)*(H j ω)^k-stepSize T N*γ (meshTime T N j)*(H j ω)^k| ≤stepSize T N*(γ (meshTime T N (j+1))-γ (meshTime T N j)) := byrw [←sub_mul,abs_mul]have hh := monotone_interval_quadrature (horder j)(hγ.mono (Icc_subset_Icc (htime j j.isLt.le).1 (htime (j+1) j.isLt).2))rw [hgap] at hhhave hp : |(H j ω)^k| ≤ 1 := byrw [abs_pow]exact pow_le_one₀ (abs_nonneg _) (hH j ω)exact (mul_le_mul_of_nonneg_left hp (abs_nonneg _)).trans (by simpa only [mul_one] using hh)calc_ ≤ ∑ j : Fin N, |(∫ s in meshTime T N j..meshTime T N (j+1), γ s)*(H j ω)^k-stepSize T N*γ (meshTime T N j)*(H j ω)^k| := Finset.abs_sum_le_sum_abs _ __ ≤ ∑ j : Fin N, stepSize T N*(γ (meshTime T N (j+1))-γ (meshTime T N j)) :=Finset.sum_le_sum (fun j _ ↦ hloc j)_ = _ := byrw [←Finset.mul_sum, sum_steps_sub (fun j ↦ γ (meshTime T N j))]have hlast : meshTime T N N=T := bydsimp [meshTime,stepSize]field_simpchange stepSize T N*(γ (meshTime T N N)-γ (meshTime T N 0)) = _rw [hlast]simp only [meshTime,Nat.cast_zero,zero_mul]lemma coupled_euler_past_measurable {Ω : Type*} [m : MeasurableSpace Ω]{B : ℝ≥0 → Ω → ℝ} (hBm : ∀ t, StronglyMeasurable (B t)){T : ℝ} (hT : 0<T) {N : ℕ} (hN : 0<N) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(hu : ∀ j<N, Measurable (u (meshTime T N j))) :∀ j ≤ N, StronglyMeasurable[Filtration.natural B hBm (Real.toNNReal (meshTime T N j))](coupledEuler T γ u B N j) := bylet f := Filtration.natural B hBmintro jinduction j with| zero =>intro _convert (stronglyMeasurable_const : StronglyMeasurable[f (Real.toNNReal (meshTime T N 0))] (fun _ : Ω ↦ (0 : ℝ))) using 1funext ωexact coupled_euler_zero T γ u B N ω| succ j ih =>intro hjNhave hj : j<N := hjNhave hδ : 0 ≤ stepSize T N := div_nonneg hT.le (Nat.cast_nonneg N)have ht : Real.toNNReal (meshTime T N j) ≤ Real.toNNReal (meshTime T N (j+1)) := byapply Real.toNNReal_monoapply mul_le_mul_of_nonneg_right _ hδexact_mod_cast Nat.le_succ jhave hY := (ih hj.le).mono (f.mono ht)have hB0 := (Filtration.stronglyAdapted_natural hBm (Real.toNNReal (meshTime T N j))).mono (f.mono ht)have hB1 := Filtration.stronglyAdapted_natural hBm (Real.toNNReal (meshTime T N (j+1)))have hU := ((hu j hj).comp hY.measurable).stronglyMeasurable.const_mul(stepSize T N*γ (meshTime T N j))convert ((hY.add hB1).sub hB0).add hU using 1funext ωrw [coupled_euler_step B hT γ u hN hj ω]rfllemma coupled_euler_drift_sum {Ω : Type*} (B : ℝ≥0 → Ω → ℝ){T : ℝ} (hT : 0<T) {N : ℕ} (hN : 0<N) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ) (ω : Ω) :coupledEuler T γ u B N N ω = B (Real.toNNReal T) ω-B 0 ω+∑ j : Fin N, stepSize T N*γ (meshTime T N j)*u (meshTime T N j) (coupledEuler T γ u B N j ω) := byhave he (j : Fin N) :coupledEuler T γ u B N (j+1) ω-coupledEuler T γ u B N j ω =(B (Real.toNNReal (meshTime T N (j+1))) ω-B (Real.toNNReal (meshTime T N j)) ω)+stepSize T N*γ (meshTime T N j)*u (meshTime T N j) (coupledEuler T γ u B N j ω) := byrw [coupled_euler_step B hT γ u hN j.isLt ω]dsimp [meshTime,stepSize]ringhave hh := Finset.sum_congr (rfl : (Finset.univ : Finset (Fin N))=Finset.univ) (fun j _ ↦ he j)rw [sum_steps_sub (fun j ↦ coupledEuler T γ u B N j ω),Finset.sum_add_distrib,sum_steps_sub (fun j ↦ B (Real.toNNReal (meshTime T N j)) ω),coupled_euler_zero] at hhhave hlast : meshTime T N N=T := by dsimp [meshTime,stepSize]; field_simpsimpa only [sub_zero,hlast,show meshTime T N 0=0 by simp [meshTime],Real.toNNReal_zero] using hhnoncomputable def feedbackControl {Ω : Type*} (B : ℝ≥0 → Ω → ℝ) (γ : ℝ → ℝ)(V : ℝ → ℝ → ℝ) (T : ℝ) (N : ℕ) : ℝ≥0 → Ω → ℝ :=meshControl T N (fun j ω ↦ deriv (V (meshTime T N j))(coupledEuler T γ (fun t ↦ deriv (V t)) B N j ω))lemma ValueStrip.feedback_progressive {Ω : Type*} [m : MeasurableSpace Ω]{B : ℝ≥0 → Ω → ℝ} (hBm : ∀ t, StronglyMeasurable (B t)){T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0<T) (h : ValueStrip T γ V K L) {N : ℕ} (hN : 0<N) :IsProgressive (Filtration.natural B hBm) (feedbackControl B γ V T N) := byapply meshControl_progressive hT.leintro jhave hu (i : ℕ) (hi : i ≤ N) : Continuous (deriv (V (meshTime T N i))) :=(h.smooth _ (mesh_time_mem_total hT.le hi)).continuous_deriv (by norm_num)exact (hu j j.isLt.le).measurable.comp(coupled_euler_past_measurable hBm hT hN γ (fun t ↦ deriv (V t))(fun i hi ↦ (hu i hi.le).measurable) j j.isLt.le).measurablelemma ValueStrip.feedback_bound {Ω : Type*} (B : ℝ≥0 → Ω → ℝ){T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0 ≤ T) (h : ValueStrip T γ V K L) (N : ℕ) (s : ℝ≥0) (ω : Ω) :|feedbackControl B γ V T N s ω| ≤ 1 :=meshControl_bound hT _ (fun j _ ↦ h.bounded _ (mesh_time_mem_total hT j.isLt.le) _) s ωlemma ValueStrip.feedback_state_error {Ω : Type*} (B : ℝ≥0 → Ω → ℝ){T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0<T) (h : ValueStrip T γ V K L) {N : ℕ} (hN : 0<N)(ω : Ω) (hB0 : B 0 ω=0) :|controlState B γ (feedbackControl B γ V T N) 0 T ω-coupledEuler T γ (fun t ↦ deriv (V t)) B N N ω| ≤ stepSize T N*(γ T-γ 0) := byhave hh := meshControl_quadrature hT.le hN(fun (j : Fin N) ω ↦ deriv (V (meshTime T N j))(coupledEuler T γ (fun t ↦ deriv (V t)) B N j ω))(fun j ω ↦ h.bounded _ (mesh_time_mem_total hT.le j.isLt.le) _)h.gamma_mono 1 ωrw [controlState,coupled_euler_drift_sum B hT hN,hB0]simpa only [pow_one,zero_add,sub_zero,add_sub_add_left_eq_sub,feedbackControl] using hhlemma ValueStrip.feedback_energy_error {Ω : Type*} (B : ℝ≥0 → Ω → ℝ){T K L : ℝ} {γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ}(hT : 0<T) (h : ValueStrip T γ V K L) {N : ℕ} (hN : 0<N) (ω : Ω) :|(1/2 : ℝ)*controlAccum γ (feedbackControl B γ V T N) 2 T ω-valueMeshEnergy T N γ V N (coupledCoordinates T N B ω)| ≤(1/2 : ℝ)*stepSize T N*(γ T-γ 0) := byhave hh := meshControl_quadrature hT.le hN(fun (j : Fin N) ω ↦ deriv (V (meshTime T N j))(coupledEuler T γ (fun t ↦ deriv (V t)) B N j ω))(fun j ω ↦ h.bounded _ (mesh_time_mem_total hT.le j.isLt.le) _)h.gamma_mono 2 ωhave he : valueMeshEnergy T N γ V N (coupledCoordinates T N B ω) = (1/2 : ℝ)*∑ j : Fin N, stepSize T N*γ (meshTime T N j)*(deriv (V (meshTime T N j)) (coupledEuler T γ (fun t ↦ deriv (V t)) B N j ω))^2 := byrw [Fin.sum_univ_eq_sum_range (fun j ↦ stepSize T N*γ (meshTime T N j)*(deriv (V (meshTime T N j)) (coupledEuler T γ (fun t ↦ deriv (V t)) B N j ω))^2)]dsimp only [valueMeshEnergy,coupledEuler]simp only [ite_eq_right hN.ne',Finset.mul_sum]apply Finset.sum_congr rflintro j _ringrw [he,←mul_sub,abs_mul,abs_of_nonneg (by norm_num : 0 ≤ (1/2 : ℝ))]exact (mul_le_mul_of_nonneg_left hh (by norm_num)).trans_eq (by ring)end SKValueendend OAI
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import Mathlibimport OAI.Probability.SKValue.Evolution.MeanDerivativeContinuousimport OAI.Probability.SKValue.Processes.StripPathsimport OAI.Probability.SKValue.Equations.LiteralNormalizernamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologylemma IsDiffusion.finite_gaussian_fixed_strip {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {T K L D Lu La : ℝ}(hT : 0<T) (hT1 : T<1) (hg : GradientStrip T γ.coeff (gradient W γ) K L)(hD : 0≤D) (hLu : 0≤Lu) (hLa : 0≤La)(ha : ∀ t∈Icc (0 : ℝ) T, ∀ x, |curvature W γ t x|≤D)(huLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|gradient W γ s x-gradient W γ t y|≤Lu*(|s-t|+|x-y|))(haLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|curvature W γ s x-curvature W γ t y|≤La*(|s-t|+|x-y|))(hmom : ∀ t∈Icc (0 : ℝ) T, (∫ ω, (curvature W γ t (X t ω))^2 ∂W.μ)=1) :(∀ᶠ N in atTop, ∀ j<N, 0<normalizer W γ T N j) ∧Tendsto (shiftedCoefficientSum W γ T) atTop(𝓝 (∫ t in (0 : ℝ)..T, ∫ ω, curvature W γ t (X t ω) ∂W.μ)) := byhave hh := finiteGaussian_from_diffusion W.brownian.toIsPreBrownianReal hT hT1.le hghD hLu hLa ha huLip haLip(fun t ht ↦ (hX.measurable ⟨ht.1,ht.2.trans hT1.le⟩).aestronglyMeasurable)(hX.strip_paths hT.le hT1 hLu (fun t ht s hs x y ↦ huLip s hs t ht y x)) hmomconstructor· simpa only [literal_normalizer] using hh.1· apply hh.2.congr'exact Eventually.of_forall (fun N ↦ (literal_shiftedCoefficientSum W γ T N).symm)end SKValueendend OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import Mathlibimport OAI.Probability.SKValue.Evolution.MeanDerivativeContinuousimport OAI.Probability.SKValue.Processes.StripPathsimport OAI.Probability.SKValue.Equations.LiteralNormalizernamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologylemma IsDiffusion.finite_gaussian_fixed_strip {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {T K L D Lu La : ℝ}(hT : 0<T) (hT1 : T<1) (hg : GradientStrip T γ.coeff (gradient W γ) K L)(hD : 0≤D) (hLu : 0≤Lu) (hLa : 0≤La)(ha : ∀ t∈Icc (0 : ℝ) T, ∀ x, |curvature W γ t x|≤D)(huLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|gradient W γ s x-gradient W γ t y|≤Lu*(|s-t|+|x-y|))(haLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|curvature W γ s x-curvature W γ t y|≤La*(|s-t|+|x-y|))(hmom : ∀ t∈Icc (0 : ℝ) T, (∫ ω, (curvature W γ t (X t ω))^2 ∂W.μ)=1) :(∀ᶠ N in atTop, ∀ j<N, 0<normalizer W γ T N j) ∧Tendsto (shiftedCoefficientSum W γ T) atTop(𝓝 (∫ t in (0 : ℝ)..T, ∫ ω, curvature W γ t (X t ω) ∂W.μ)) := byhave hh := finiteGaussian_from_diffusion W.brownian.toIsPreBrownianReal hT hT1.le hghD hLu hLa ha huLip haLip(fun t ht ↦ (hX.measurable ⟨ht.1,ht.2.trans hT1.le⟩).aestronglyMeasurable)(hX.strip_paths hT.le hT1 hLu (fun t ht s hs x y ↦ huLip s hs t ht y x)) hmomconstructor· simpa only [literal_normalizer] using hh.1· apply hh.2.congr'exact Eventually.of_forall (fun N ↦ (literal_shiftedCoefficientSum W γ T N).symm)end SKValueendend OAI
12345678910111213141516171819202122232425262728293031323334353637383940import Mathlibimport OAI.Probability.SKValue.Processes.TestDiffusionimport OAI.Probability.SKValue.Equations.TestPatchimport OAI.Probability.SKValue.Evolution.TestStripnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValuelemma SmoothTerminal.profile_diffusion_test {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {ψ f:ℝ → ℝ} (hψ:SmoothTerminal ψ) (heven:∀ x,ψ (-x)=ψ x)(hf:BoundedSmooth f) {l:HeatProfile} (hl:l.Pairwise (fun p q ↦ p.2≤q.2))(hT:0<profileTime l) (hT1:profileTime l≤1)(hXM:∀ t∈Icc (0:ℝ) (profileTime l),AEStronglyMeasurable (X t) μ)(hpaths:∀ᵐ ω ∂μ,ContinuousOn (fun t ↦ X t ω) (Icc (0:ℝ) (profileTime l)) ∧IntervalIntegrable (fun s ↦ profileCoeff l s*deriv (profileValue ψ l s) (X s ω)) volume 0 (profileTime l) ∧(∀ t∈Icc (0:ℝ) (profileTime l),X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,profileCoeff l s*deriv (profileValue ψ l s) (X s ω)) ∧ X 0 ω=0) :(∫ ω,f (X (profileTime l) ω) ∂μ)=profileResponse ψ f l 0 0 := byhave hA := hψ.profile_evolution lhave hV := hψ.linear_profile hf lobtain ⟨K,L,hu⟩ := hψ.profile_gradient_strip heven hlobtain ⟨K',L',hv⟩ := hV.toBackwardTest (profileTime_nonneg l) hA(fun t _ ↦ profileCoeff_nonneg l t) (profileCoeff_mono hl)obtain ⟨Lu,hLu,hLip⟩ := hA.jet_joint 0have hLip' : ∀ s∈Icc (0:ℝ) (profileTime l),∀ t∈Icc (0:ℝ) (profileTime l),∀ x y,|deriv (profileValue ψ l s) x-deriv (profileValue ψ l t) y|≤Lu*(|s-t|+|x-y|) := byintro s hs t ht x ysimpa only [iteratedDeriv_zero] using hLip s hs t ht y xhave he := hv.diffusion_expectation hB hT hT1 hu hLu hLip' hXM hpathsrwa [profileResponse_terminal] at heend SKValueendend OAI12345678910111213141516171819202122232425262728293031323334353637383940import Mathlibimport OAI.Probability.SKValue.Processes.TestDiffusionimport OAI.Probability.SKValue.Equations.TestPatchimport OAI.Probability.SKValue.Evolution.TestStripnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValuelemma SmoothTerminal.profile_diffusion_test {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {ψ f:ℝ → ℝ} (hψ:SmoothTerminal ψ) (heven:∀ x,ψ (-x)=ψ x)(hf:BoundedSmooth f) {l:HeatProfile} (hl:l.Pairwise (fun p q ↦ p.2≤q.2))(hT:0<profileTime l) (hT1:profileTime l≤1)(hXM:∀ t∈Icc (0:ℝ) (profileTime l),AEStronglyMeasurable (X t) μ)(hpaths:∀ᵐ ω ∂μ,ContinuousOn (fun t ↦ X t ω) (Icc (0:ℝ) (profileTime l)) ∧IntervalIntegrable (fun s ↦ profileCoeff l s*deriv (profileValue ψ l s) (X s ω)) volume 0 (profileTime l) ∧(∀ t∈Icc (0:ℝ) (profileTime l),X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,profileCoeff l s*deriv (profileValue ψ l s) (X s ω)) ∧ X 0 ω=0) :(∫ ω,f (X (profileTime l) ω) ∂μ)=profileResponse ψ f l 0 0 := byhave hA := hψ.profile_evolution lhave hV := hψ.linear_profile hf lobtain ⟨K,L,hu⟩ := hψ.profile_gradient_strip heven hlobtain ⟨K',L',hv⟩ := hV.toBackwardTest (profileTime_nonneg l) hA(fun t _ ↦ profileCoeff_nonneg l t) (profileCoeff_mono hl)obtain ⟨Lu,hLu,hLip⟩ := hA.jet_joint 0have hLip' : ∀ s∈Icc (0:ℝ) (profileTime l),∀ t∈Icc (0:ℝ) (profileTime l),∀ x y,|deriv (profileValue ψ l s) x-deriv (profileValue ψ l t) y|≤Lu*(|s-t|+|x-y|) := byintro s hs t ht x ysimpa only [iteratedDeriv_zero] using hLip s hs t ht y xhave he := hv.diffusion_expectation hB hT hT1 hu hLu hLip' hXM hpathsrwa [profileResponse_terminal] at heend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import Mathlibimport OAI.Probability.SKValue.Equations.ForcedGeneratorimport OAI.Probability.SKValue.Processes.ForcedExpectationnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorsnamespace SKValuelemma ForcedTest.diffusion_generator_of_source_limit {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {T K L K' L' Lu:ℝ} {γ:ℝ → ℝ} {u V b p:ℝ → ℝ → ℝ}(hT:0<T) (hT1:T≤1) (hu:GradientStrip T γ u K L) (h:ForcedTest T γ u V b p K' L')(hLu:0≤Lu) (hLip:∀ s∈Icc (0:ℝ) T,∀ t∈Icc (0:ℝ) T,∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(hXM:∀ t∈Icc (0:ℝ) T,AEStronglyMeasurable (X t) μ)(hpaths:∀ᵐ ω ∂μ,ContinuousOn (fun t ↦ X t ω) (Icc (0:ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t∈Icc (0:ℝ) T,X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,γ s*u s (X s ω)) ∧ X 0 ω=0){I:ℝ} (hsource:Tendsto (fun N ↦ stepSize T N*∑ j∈Finset.range N,(∫ z,forcedSource γ u V b p (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1))))atTop (𝓝 I)) :(∫ ω,V T (X T ω) ∂μ)=V 0 0+I := bylet S := fun N ↦ stepSize T N*∑ j∈Finset.range N,(∫ z,forcedSource γ u V b p (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1)))let A := fun N ↦ ∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1))let E := fun N ↦ T*Real.sqrt (stepSize T N)*cubicEnvelopeMean (γ T) K' ((1/2+γ T)*L')+stepSize T N*K'*(γ T-γ 0)let F := fun N ↦ K'*Real.sqrt (∫ ω,(meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ)have hδ:Tendsto (fun N:ℕ ↦ stepSize T N) atTop (𝓝 (0:ℝ)) := tendsto_const_div_atTop_nhds_zero_nat Thave hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδhave hE:Tendsto E atTop (𝓝 0) := bysimpa only [E,Function.comp_def,Real.sqrt_zero,mul_zero,zero_mul,add_zero] using(((hsqrt.const_mul T).mul_const (cubicEnvelopeMean (γ T) K' ((1/2+γ T)*L'))).add((hδ.mul_const K').mul_const (γ T-γ 0)))have hF:Tendsto F atTop (𝓝 0) := bysimpa only [F,Function.comp_def,Real.sqrt_zero,mul_zero] using(((Real.continuous_sqrt.tendsto 0).comp(coupled_euler_L2_convergence hB hT hu hLu hLip hXM hpaths)).const_mul K')have hbound:∀ᶠ N in atTop,|(∫ ω,V T (X T ω) ∂μ)-V 0 0-S N|≤E N+F N := byfilter_upwards [eventually_gt_atTop 0] with N hNhave he := h.mesh_expectation hT hT1 hNhave hf := h.coupled_terminal_error hB hT hu hXM(by filter_upwards [hpaths] with ω hω using hω.2.2) hNhave ht := abs_sub_le ((∫ ω,V T (X T ω) ∂μ)-V 0 0-S N) (A N-V 0 0-S N) 0change |A N-V 0 0-S N|≤E N at hechange |A N-(∫ ω,V T (X T ω) ∂μ)|≤F N at hfhave hf' : |(∫ ω,V T (X T ω) ∂μ)-A N|≤F N := byrw [abs_sub_comm];exact hfhave hid:((∫ ω,V T (X T ω) ∂μ)-V 0 0-S N)-(A N-V 0 0-S N)=(∫ ω,V T (X T ω) ∂μ)-A N := by ringrw [hid,sub_zero,sub_zero] at htlinarithhave hleft:Tendsto (fun N ↦ |(∫ ω,V T (X T ω) ∂μ)-V 0 0-S N|) atTop(𝓝 |(∫ ω,V T (X T ω) ∂μ)-V 0 0-I|) := (tendsto_const_nhds.sub hsource).abshave hz := le_of_tendsto_of_tendsto hleft (hE.add hF) hboundhave habs:|(∫ ω,V T (X T ω) ∂μ)-V 0 0-I|=0 := le_antisymm (by simpa using hz) (abs_nonneg _)have he := abs_eq_zero.mp habslinarithend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import Mathlibimport OAI.Probability.SKValue.Equations.ForcedGeneratorimport OAI.Probability.SKValue.Processes.ForcedExpectationnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperatorsnamespace SKValuelemma ForcedTest.diffusion_generator_of_source_limit {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {T K L K' L' Lu:ℝ} {γ:ℝ → ℝ} {u V b p:ℝ → ℝ → ℝ}(hT:0<T) (hT1:T≤1) (hu:GradientStrip T γ u K L) (h:ForcedTest T γ u V b p K' L')(hLu:0≤Lu) (hLip:∀ s∈Icc (0:ℝ) T,∀ t∈Icc (0:ℝ) T,∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(hXM:∀ t∈Icc (0:ℝ) T,AEStronglyMeasurable (X t) μ)(hpaths:∀ᵐ ω ∂μ,ContinuousOn (fun t ↦ X t ω) (Icc (0:ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t∈Icc (0:ℝ) T,X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,γ s*u s (X s ω)) ∧ X 0 ω=0){I:ℝ} (hsource:Tendsto (fun N ↦ stepSize T N*∑ j∈Finset.range N,(∫ z,forcedSource γ u V b p (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1))))atTop (𝓝 I)) :(∫ ω,V T (X T ω) ∂μ)=V 0 0+I := bylet S := fun N ↦ stepSize T N*∑ j∈Finset.range N,(∫ z,forcedSource γ u V b p (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1)))let A := fun N ↦ ∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1))let E := fun N ↦ T*Real.sqrt (stepSize T N)*cubicEnvelopeMean (γ T) K' ((1/2+γ T)*L')+stepSize T N*K'*(γ T-γ 0)let F := fun N ↦ K'*Real.sqrt (∫ ω,(meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ)have hδ:Tendsto (fun N:ℕ ↦ stepSize T N) atTop (𝓝 (0:ℝ)) := tendsto_const_div_atTop_nhds_zero_nat Thave hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδhave hE:Tendsto E atTop (𝓝 0) := bysimpa only [E,Function.comp_def,Real.sqrt_zero,mul_zero,zero_mul,add_zero] using(((hsqrt.const_mul T).mul_const (cubicEnvelopeMean (γ T) K' ((1/2+γ T)*L'))).add((hδ.mul_const K').mul_const (γ T-γ 0)))have hF:Tendsto F atTop (𝓝 0) := bysimpa only [F,Function.comp_def,Real.sqrt_zero,mul_zero] using(((Real.continuous_sqrt.tendsto 0).comp(coupled_euler_L2_convergence hB hT hu hLu hLip hXM hpaths)).const_mul K')have hbound:∀ᶠ N in atTop,|(∫ ω,V T (X T ω) ∂μ)-V 0 0-S N|≤E N+F N := byfilter_upwards [eventually_gt_atTop 0] with N hNhave he := h.mesh_expectation hT hT1 hNhave hf := h.coupled_terminal_error hB hT hu hXM(by filter_upwards [hpaths] with ω hω using hω.2.2) hNhave ht := abs_sub_le ((∫ ω,V T (X T ω) ∂μ)-V 0 0-S N) (A N-V 0 0-S N) 0change |A N-V 0 0-S N|≤E N at hechange |A N-(∫ ω,V T (X T ω) ∂μ)|≤F N at hfhave hf' : |(∫ ω,V T (X T ω) ∂μ)-A N|≤F N := byrw [abs_sub_comm];exact hfhave hid:((∫ ω,V T (X T ω) ∂μ)-V 0 0-S N)-(A N-V 0 0-S N)=(∫ ω,V T (X T ω) ∂μ)-A N := by ringrw [hid,sub_zero,sub_zero] at htlinarithhave hleft:Tendsto (fun N ↦ |(∫ ω,V T (X T ω) ∂μ)-V 0 0-S N|) atTop(𝓝 |(∫ ω,V T (X T ω) ∂μ)-V 0 0-I|) := (tendsto_const_nhds.sub hsource).abshave hz := le_of_tendsto_of_tendsto hleft (hE.add hF) hboundhave habs:|(∫ ω,V T (X T ω) ∂μ)-V 0 0-I|=0 := le_antisymm (by simpa using hz) (abs_nonneg _)have he := abs_eq_zero.mp habslinarithend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202import Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshimport OAI.Probability.SKValue.Control.Forcednamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperators NNRealnamespace SKValuelemma ForcedTest.expectation_step {T K L t δ:ℝ} {γ:ℝ → ℝ} {u V b₀ p₀:ℝ → ℝ → ℝ}(h:ForcedTest T γ u V b₀ p₀ K L) (ht:0≤t) (hδ:0≤δ) (hδ1:δ≤1) (htδ:t+δ≤T){N j:ℕ} (hj:j<N+1) {Y:(Fin (N+1) → ℝ) → ℝ}(hYm:Measurable Y) (hYp:DependsBefore j Y) :let μ := gaussianProduct (Fin (N+1))let Y' := fun z ↦ Y z+Real.sqrt δ*coordinate N j z+δ*γ t*u t (Y z)|(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)-δ*(∫ z,forcedSource γ u V b₀ p₀ t (Y z) ∂μ)|≤δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (t+δ)-γ t) := bylet μ := gaussianProduct (Fin (N+1))let p := fun z ↦ deriv (V t) (Y z)let a := fun z ↦ deriv (deriv (V t)) (Y z)let Y' := fun z ↦ Y z+Real.sqrt δ*coordinate N j z+δ*γ t*u t (Y z)let P := fun z ↦ Real.sqrt δ*rawIncrement p j zlet Q := fun z ↦ (δ/2)*(a z*((coordinate N j z)^2-1))let S := fun z ↦ forcedSource γ u V b₀ p₀ t (Y z)let D := fun z ↦ V (t+δ) (Y' z)-V t (Y z)-δ*S zlet R := fun z ↦ D z-P z-Q zlet E := fun z ↦ δ*Real.sqrt δ*cubicEnvelope (γ T) K ((1/2+γ T)*L) (coordinate N j z)+δ*K*(γ (t+δ)-γ t)have htT:t≤T := (le_add_of_nonneg_right hδ).trans htδhave htm:t∈Icc (0:ℝ) T := ⟨ht,htT⟩have hem:t+δ∈Icc (0:ℝ) T := ⟨by linarith,htδ⟩have hpm:Measurable p := ((h.smooth t htm).continuous_deriv (by norm_num)).measurable.comp hYmhave ham:Measurable a := byhave hh := (h.smooth t htm).continuous_iteratedDeriv 2 (by norm_num)simp only [show (2:ℕ)=1+1 from rfl,iteratedDeriv_succ] at hhexact hh.measurable.comp hYmhave hpM:MemLp p 2 μ := MemLp.of_bound hpm.aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.first_bound t htm (Y z)))have haM:MemLp a 2 μ := MemLp.of_bound ham.aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.second_bound t htm (Y z)))have hpp:DependsBefore j p := fun z z' hz ↦ by dsimp only [p];rw [hYp z z' hz]have hap:DependsBefore j a := fun z z' hz ↦ by dsimp only [a];rw [hYp z z' hz]have hPi:Integrable P μ := (((rawIncrement_memLp hj hpm hpp hpM).const_mul _).integrable (by norm_num))have hQi:Integrable Q μ := (((predictableCenteredSquare_memLp ham (fun z ↦ h.second_bound t htm (Y z))).const_mul _).integrable (by norm_num))have hP0:(∫ z,P z ∂μ)=0 := bydsimp only [P]rw [integral_const_mul,rawIncrement_mean hj hpm hpp,mul_zero]have hQ0:(∫ z,Q z ∂μ)=0 := bydsimp only [Q]rw [integral_const_mul,predictableCenteredSquare_mean hj ham hap,mul_zero]have hY'm:Measurable Y' := (hYm.add ((measurable_coordinate N j).const_mul _)).add(((h.drift_measurable t htm).comp hYm).const_mul _)have hcur:Integrable (fun z ↦ V t (Y z)) μ :=(MemLp.of_bound ((h.smooth t htm).continuous.measurable.comp hYm).aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.bound t htm (Y z))) :MemLp (fun z ↦ V t (Y z)) 2 μ).integrable (by norm_num)have hnext:Integrable (fun z ↦ V (t+δ) (Y' z)) μ :=(MemLp.of_bound ((h.smooth (t+δ) hem).continuous.measurable.comp hY'm).aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.bound (t+δ) hem (Y' z))) :MemLp (fun z ↦ V (t+δ) (Y' z)) 2 μ).integrable (by norm_num)have hSi:Integrable S μ :=(MemLp.of_bound ((h.source_measurable htm).comp hYm).aestronglyMeasurable ((1+2*γ T)*K)(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.source_bound htm (Y z))) :MemLp S 2 μ).integrable (by norm_num)have hDi:Integrable D μ := (hnext.sub hcur).sub (hSi.const_mul δ)have hRi:Integrable R μ := (hDi.sub hPi).sub hQihave hEi0 := (cubicEnvelope_memLp_two (coordinate_hasLaw N j)(h.gamma_nonneg T ⟨ht.trans htT,le_rfl⟩) K ((1/2+γ T)*L)).integrable (by norm_num)have hEi:Integrable E μ := (hEi0.const_mul _).add (integrable_const _)have hRE (z) : |R z|≤E z := byhave hh := h.euler_one_step ht hδ hδ1 htδ (x:=Y z) (z:=coordinate N j z)convert! hh using 1dsimp only [R,D,P,Q,p,a,Y',S,E,rawIncrement]congr 1ring_nfhave hRmean:(∫ z,R z ∂μ)=(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)-δ*(∫ z,S z ∂μ) := byhave hs := integral_sub (hDi.sub hPi) hQichange (∫ z,D z-P z-Q z ∂μ)=(∫ z,D z-P z ∂μ)-(∫ z,Q z ∂μ) at hshave hs1 := integral_sub hDi hPichange (∫ z,D z-P z ∂μ)=(∫ z,D z ∂μ)-(∫ z,P z ∂μ) at hs1change (∫ z,D z-P z-Q z ∂μ)=_rw [hs,hs1,hP0,hQ0,sub_zero,sub_zero]have hs2 := integral_sub (hnext.sub hcur) (hSi.const_mul δ)change (∫ z,V (t+δ) (Y' z)-V t (Y z)-δ*S z ∂μ)=(∫ z,V (t+δ) (Y' z)-V t (Y z) ∂μ)-(∫ z,δ*S z ∂μ) at hs2dsimp only [D]rw [hs2,integral_sub hnext hcur,integral_const_mul]have hEmean:(∫ z,E z ∂μ)=δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (t+δ)-γ t) := bydsimp only [E]rw [integral_add (hEi0.const_mul _) (integrable_const _),integral_const_mul]simp only [integral_const,probReal_univ,smul_eq_mul,one_mul]have he:(∫ z,cubicEnvelope (γ T) K ((1/2+γ T)*L) (coordinate N j z) ∂μ)=cubicEnvelopeMean (γ T) K ((1/2+γ T)*L) := bysimpa only [Function.comp_def,cubicEnvelopeMean,standardGaussian] using(coordinate_hasLaw N j).integral_comp (measurable_cubicEnvelope (γ T) K ((1/2+γ T)*L)).aestronglyMeasurablerw [he]change |(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)-δ*(∫ z,forcedSource γ u V b₀ p₀ t (Y z) ∂μ)|≤_rw [←hRmean,←hEmean]exact abs_integral_le_integral_abs.trans (integral_mono hRi.norm hEi hRE)end SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperators NNRealnamespace SKValuelemma ForcedTest.mesh_expectation {T K L:ℝ} {γ:ℝ → ℝ} {u V b p:ℝ → ℝ → ℝ}(h:ForcedTest T γ u V b p K L) (hT:0<T) (hT1:T≤1) {N:ℕ} (hN:0<N) :|(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))-V 0 0-stepSize T N*∑ j∈Finset.range N,(∫ z,forcedSource γ u V b p (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1)))|≤T*Real.sqrt (stepSize T N)*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+stepSize T N*K*(γ T-γ 0) := bylet δ := stepSize T Nlet A := fun j ↦ ∫ z,V (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1))let S := fun j ↦ ∫ z,forcedSource γ u V b p (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1))have hNr:0<(N:ℝ) := by exact_mod_cast hNhave hδ:0≤δ := div_nonneg hT.le hNr.lehave hδ1:δ≤1 := byapply (div_le_iff₀ hNr).mprhave hn:(1:ℝ)≤N := by exact_mod_cast hNsimpa only [one_mul] using hT1.trans hnhave htime (j:ℕ) (hj:j≤N) := mesh_time_mem hT.le hN hjhave hs (j:ℕ) : meshTime T N j+δ=meshTime T N (j+1) := by dsimp [meshTime];push_cast;ringhave hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simphave hzero:meshTime T N 0=0 := by simp [meshTime]have hum (j:ℕ) (hj:j<N) : Measurable (u (meshTime T N j)) := h.drift_measurable _ (htime j hj.le)have hstep (j:ℕ) (hj:j<N) : |A (j+1)-A j+(-δ*S j)|≤δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (meshTime T N (j+1))-γ (meshTime T N j))+0*((0:ℝ)-0) := byhave hYp:DependsBefore j (fun z ↦ euler T N γ u z j) :=eulerCoefficient_dependsBefore T hj.le γ u (fun _ y ↦ y)have he := h.expectation_step (htime j hj.le).1 hδ hδ1(by rw [hs];exact (htime (j+1) (by omega)).2) (by omega:j<N+1)(measurable_euler T N γ u hum j hj.le) hYpdsimp only at herw [hs] at hesimpa only [A,S,euler,δ,mul_assoc,add_zero,sub_self,mul_zero,sub_eq_add_neg,neg_mul] using hehave hh := abs_telescope_source (A:=A) (b:=fun j ↦ -δ*S j) (Γ:=fun j ↦ γ (meshTime T N j))(Δ:=fun _ ↦ 0) (e:=0) hstephave hA0:A 0=V 0 0 := by simp [A,meshTime,euler]rw [hA0,show A N=(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1))) bydsimp only [A];rw [hlast],hlast,hzero] at hhhave hNd:(N:ℝ)*δ=T := by dsimp [δ,stepSize];field_simpsimpa only [neg_mul,Finset.sum_neg_distrib,←Finset.mul_sum,sub_self,mul_zero,add_zero,←mul_assoc,hNd,←sub_eq_add_neg,S] using hhlemma ForcedTest.terminal_lipschitz {T K L:ℝ} {γ:ℝ → ℝ} {u V b p:ℝ → ℝ → ℝ}(h:ForcedTest T γ u V b p K L) (hT:0≤T) (x y:ℝ) : |V T x-V T y|≤K*|x-y| := byhave hd := (h.smooth T ⟨hT,le_rfl⟩).differentiable (by norm_num)have hb:∀ z,‖deriv (V T) z‖≤K := fun z ↦ by simpa only [Real.norm_eq_abs] using h.first_bound T ⟨hT,le_rfl⟩ zhave hl : LipschitzWith ⟨K,h.K_nonneg⟩ (V T) := byapply lipschitzWith_of_nnnorm_deriv_le hdintro zexact_mod_cast hb zhave hh := hl.dist_le_mul x ychange |V T x-V T y|≤K*|x-y| at hhexact hhlemma ForcedTest.coupled_terminal_error {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {T K L K' L':ℝ} {γ:ℝ → ℝ} {u V b p:ℝ → ℝ → ℝ}(hT:0<T) (hu:GradientStrip T γ u K L) (h:ForcedTest T γ u V b p K' L')(hXM:∀ t∈Icc (0:ℝ) T,AEStronglyMeasurable (X t) μ)(hpaths:∀ᵐ ω ∂μ,(∀ t∈Icc (0:ℝ) T,X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,γ s*u s (X s ω)) ∧ X 0 ω=0) {N:ℕ} (hN:0<N) :|(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))-(∫ ω,V T (X T ω) ∂μ)|≤K'*Real.sqrt (∫ ω,(meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ) := bylet F := fun ω ↦ V T (coupledEuler T γ u B N N ω)let G := fun ω ↦ V T (X T ω)let E := meshMaxError T X (coupledEuler T γ u B) Nhave ht:T∈Icc (0:ℝ) T := ⟨hT.le,le_rfl⟩have hm:Continuous (V T) := (h.smooth T ht).continuoushave hFM:MemLp F 2 μ := MemLp.of_bound(hm.measurable.comp_aemeasurable (coupled_euler_measurable hB hT hu N N le_rfl).aemeasurable).aestronglyMeasurable K'(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs,F] using h.bound T ht _))have hGM:MemLp G 2 μ := MemLp.of_bound(hm.measurable.comp_aemeasurable (hXM T ht).aemeasurable).aestronglyMeasurable K'(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs,G] using h.bound T ht _))have hEM:MemLp E 2 μ := coupled_mesh_error_memLp hB hT hu hXM hpaths hNhave hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simphave hFG (ω:Ω) : |F ω-G ω|≤K'*|E ω| := byhave he:|coupledEuler T γ u B N N ω-X T ω|≤E ω := byhave hh := le_initialMax (f:=fun k ↦|coupledEuler T γ u B N k ω-X (meshTime T N k) ω|) (le_refl N)change |coupledEuler T γ u B N N ω-X (meshTime T N N) ω|≤E ω at hhrwa [hlast] at hhexact (h.terminal_lipschitz hT.le _ _).trans(mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) h.K_nonneg)have heq:(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))=(∫ ω,F ω ∂μ) := byhave heum := measurable_euler T N γ u (fun j hj ↦ (hu.smooth _ (mesh_time_mem hT.le hN hj.le)).continuous.measurable) N le_rflhave hh := (coupledCoordinates_hasLaw hB hT hN).integral_comp (hm.measurable.comp heum).aestronglyMeasurablesimpa only [Function.comp_apply,F,coupledEuler,ite_eq_right (Nat.ne_of_gt hN)] using hh.symmrw [heq]exact first_moment_perturbation hFM hGM hEM h.K_nonneg (Eventually.of_forall hFG)end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202import Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshimport OAI.Probability.SKValue.Control.Forcednamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperators NNRealnamespace SKValuelemma ForcedTest.expectation_step {T K L t δ:ℝ} {γ:ℝ → ℝ} {u V b₀ p₀:ℝ → ℝ → ℝ}(h:ForcedTest T γ u V b₀ p₀ K L) (ht:0≤t) (hδ:0≤δ) (hδ1:δ≤1) (htδ:t+δ≤T){N j:ℕ} (hj:j<N+1) {Y:(Fin (N+1) → ℝ) → ℝ}(hYm:Measurable Y) (hYp:DependsBefore j Y) :let μ := gaussianProduct (Fin (N+1))let Y' := fun z ↦ Y z+Real.sqrt δ*coordinate N j z+δ*γ t*u t (Y z)|(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)-δ*(∫ z,forcedSource γ u V b₀ p₀ t (Y z) ∂μ)|≤δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (t+δ)-γ t) := bylet μ := gaussianProduct (Fin (N+1))let p := fun z ↦ deriv (V t) (Y z)let a := fun z ↦ deriv (deriv (V t)) (Y z)let Y' := fun z ↦ Y z+Real.sqrt δ*coordinate N j z+δ*γ t*u t (Y z)let P := fun z ↦ Real.sqrt δ*rawIncrement p j zlet Q := fun z ↦ (δ/2)*(a z*((coordinate N j z)^2-1))let S := fun z ↦ forcedSource γ u V b₀ p₀ t (Y z)let D := fun z ↦ V (t+δ) (Y' z)-V t (Y z)-δ*S zlet R := fun z ↦ D z-P z-Q zlet E := fun z ↦ δ*Real.sqrt δ*cubicEnvelope (γ T) K ((1/2+γ T)*L) (coordinate N j z)+δ*K*(γ (t+δ)-γ t)have htT:t≤T := (le_add_of_nonneg_right hδ).trans htδhave htm:t∈Icc (0:ℝ) T := ⟨ht,htT⟩have hem:t+δ∈Icc (0:ℝ) T := ⟨by linarith,htδ⟩have hpm:Measurable p := ((h.smooth t htm).continuous_deriv (by norm_num)).measurable.comp hYmhave ham:Measurable a := byhave hh := (h.smooth t htm).continuous_iteratedDeriv 2 (by norm_num)simp only [show (2:ℕ)=1+1 from rfl,iteratedDeriv_succ] at hhexact hh.measurable.comp hYmhave hpM:MemLp p 2 μ := MemLp.of_bound hpm.aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.first_bound t htm (Y z)))have haM:MemLp a 2 μ := MemLp.of_bound ham.aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.second_bound t htm (Y z)))have hpp:DependsBefore j p := fun z z' hz ↦ by dsimp only [p];rw [hYp z z' hz]have hap:DependsBefore j a := fun z z' hz ↦ by dsimp only [a];rw [hYp z z' hz]have hPi:Integrable P μ := (((rawIncrement_memLp hj hpm hpp hpM).const_mul _).integrable (by norm_num))have hQi:Integrable Q μ := (((predictableCenteredSquare_memLp ham (fun z ↦ h.second_bound t htm (Y z))).const_mul _).integrable (by norm_num))have hP0:(∫ z,P z ∂μ)=0 := bydsimp only [P]rw [integral_const_mul,rawIncrement_mean hj hpm hpp,mul_zero]have hQ0:(∫ z,Q z ∂μ)=0 := bydsimp only [Q]rw [integral_const_mul,predictableCenteredSquare_mean hj ham hap,mul_zero]have hY'm:Measurable Y' := (hYm.add ((measurable_coordinate N j).const_mul _)).add(((h.drift_measurable t htm).comp hYm).const_mul _)have hcur:Integrable (fun z ↦ V t (Y z)) μ :=(MemLp.of_bound ((h.smooth t htm).continuous.measurable.comp hYm).aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.bound t htm (Y z))) :MemLp (fun z ↦ V t (Y z)) 2 μ).integrable (by norm_num)have hnext:Integrable (fun z ↦ V (t+δ) (Y' z)) μ :=(MemLp.of_bound ((h.smooth (t+δ) hem).continuous.measurable.comp hY'm).aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.bound (t+δ) hem (Y' z))) :MemLp (fun z ↦ V (t+δ) (Y' z)) 2 μ).integrable (by norm_num)have hSi:Integrable S μ :=(MemLp.of_bound ((h.source_measurable htm).comp hYm).aestronglyMeasurable ((1+2*γ T)*K)(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.source_bound htm (Y z))) :MemLp S 2 μ).integrable (by norm_num)have hDi:Integrable D μ := (hnext.sub hcur).sub (hSi.const_mul δ)have hRi:Integrable R μ := (hDi.sub hPi).sub hQihave hEi0 := (cubicEnvelope_memLp_two (coordinate_hasLaw N j)(h.gamma_nonneg T ⟨ht.trans htT,le_rfl⟩) K ((1/2+γ T)*L)).integrable (by norm_num)have hEi:Integrable E μ := (hEi0.const_mul _).add (integrable_const _)have hRE (z) : |R z|≤E z := byhave hh := h.euler_one_step ht hδ hδ1 htδ (x:=Y z) (z:=coordinate N j z)convert! hh using 1dsimp only [R,D,P,Q,p,a,Y',S,E,rawIncrement]congr 1ring_nfhave hRmean:(∫ z,R z ∂μ)=(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)-δ*(∫ z,S z ∂μ) := byhave hs := integral_sub (hDi.sub hPi) hQichange (∫ z,D z-P z-Q z ∂μ)=(∫ z,D z-P z ∂μ)-(∫ z,Q z ∂μ) at hshave hs1 := integral_sub hDi hPichange (∫ z,D z-P z ∂μ)=(∫ z,D z ∂μ)-(∫ z,P z ∂μ) at hs1change (∫ z,D z-P z-Q z ∂μ)=_rw [hs,hs1,hP0,hQ0,sub_zero,sub_zero]have hs2 := integral_sub (hnext.sub hcur) (hSi.const_mul δ)change (∫ z,V (t+δ) (Y' z)-V t (Y z)-δ*S z ∂μ)=(∫ z,V (t+δ) (Y' z)-V t (Y z) ∂μ)-(∫ z,δ*S z ∂μ) at hs2dsimp only [D]rw [hs2,integral_sub hnext hcur,integral_const_mul]have hEmean:(∫ z,E z ∂μ)=δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (t+δ)-γ t) := bydsimp only [E]rw [integral_add (hEi0.const_mul _) (integrable_const _),integral_const_mul]simp only [integral_const,probReal_univ,smul_eq_mul,one_mul]have he:(∫ z,cubicEnvelope (γ T) K ((1/2+γ T)*L) (coordinate N j z) ∂μ)=cubicEnvelopeMean (γ T) K ((1/2+γ T)*L) := bysimpa only [Function.comp_def,cubicEnvelopeMean,standardGaussian] using(coordinate_hasLaw N j).integral_comp (measurable_cubicEnvelope (γ T) K ((1/2+γ T)*L)).aestronglyMeasurablerw [he]change |(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)-δ*(∫ z,forcedSource γ u V b₀ p₀ t (Y z) ∂μ)|≤_rw [←hRmean,←hEmean]exact abs_integral_le_integral_abs.trans (integral_mono hRi.norm hEi hRE)end SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperators NNRealnamespace SKValuelemma ForcedTest.mesh_expectation {T K L:ℝ} {γ:ℝ → ℝ} {u V b p:ℝ → ℝ → ℝ}(h:ForcedTest T γ u V b p K L) (hT:0<T) (hT1:T≤1) {N:ℕ} (hN:0<N) :|(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))-V 0 0-stepSize T N*∑ j∈Finset.range N,(∫ z,forcedSource γ u V b p (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1)))|≤T*Real.sqrt (stepSize T N)*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+stepSize T N*K*(γ T-γ 0) := bylet δ := stepSize T Nlet A := fun j ↦ ∫ z,V (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1))let S := fun j ↦ ∫ z,forcedSource γ u V b p (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1))have hNr:0<(N:ℝ) := by exact_mod_cast hNhave hδ:0≤δ := div_nonneg hT.le hNr.lehave hδ1:δ≤1 := byapply (div_le_iff₀ hNr).mprhave hn:(1:ℝ)≤N := by exact_mod_cast hNsimpa only [one_mul] using hT1.trans hnhave htime (j:ℕ) (hj:j≤N) := mesh_time_mem hT.le hN hjhave hs (j:ℕ) : meshTime T N j+δ=meshTime T N (j+1) := by dsimp [meshTime];push_cast;ringhave hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simphave hzero:meshTime T N 0=0 := by simp [meshTime]have hum (j:ℕ) (hj:j<N) : Measurable (u (meshTime T N j)) := h.drift_measurable _ (htime j hj.le)have hstep (j:ℕ) (hj:j<N) : |A (j+1)-A j+(-δ*S j)|≤δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (meshTime T N (j+1))-γ (meshTime T N j))+0*((0:ℝ)-0) := byhave hYp:DependsBefore j (fun z ↦ euler T N γ u z j) :=eulerCoefficient_dependsBefore T hj.le γ u (fun _ y ↦ y)have he := h.expectation_step (htime j hj.le).1 hδ hδ1(by rw [hs];exact (htime (j+1) (by omega)).2) (by omega:j<N+1)(measurable_euler T N γ u hum j hj.le) hYpdsimp only at herw [hs] at hesimpa only [A,S,euler,δ,mul_assoc,add_zero,sub_self,mul_zero,sub_eq_add_neg,neg_mul] using hehave hh := abs_telescope_source (A:=A) (b:=fun j ↦ -δ*S j) (Γ:=fun j ↦ γ (meshTime T N j))(Δ:=fun _ ↦ 0) (e:=0) hstephave hA0:A 0=V 0 0 := by simp [A,meshTime,euler]rw [hA0,show A N=(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1))) bydsimp only [A];rw [hlast],hlast,hzero] at hhhave hNd:(N:ℝ)*δ=T := by dsimp [δ,stepSize];field_simpsimpa only [neg_mul,Finset.sum_neg_distrib,←Finset.mul_sum,sub_self,mul_zero,add_zero,←mul_assoc,hNd,←sub_eq_add_neg,S] using hhlemma ForcedTest.terminal_lipschitz {T K L:ℝ} {γ:ℝ → ℝ} {u V b p:ℝ → ℝ → ℝ}(h:ForcedTest T γ u V b p K L) (hT:0≤T) (x y:ℝ) : |V T x-V T y|≤K*|x-y| := byhave hd := (h.smooth T ⟨hT,le_rfl⟩).differentiable (by norm_num)have hb:∀ z,‖deriv (V T) z‖≤K := fun z ↦ by simpa only [Real.norm_eq_abs] using h.first_bound T ⟨hT,le_rfl⟩ zhave hl : LipschitzWith ⟨K,h.K_nonneg⟩ (V T) := byapply lipschitzWith_of_nnnorm_deriv_le hdintro zexact_mod_cast hb zhave hh := hl.dist_le_mul x ychange |V T x-V T y|≤K*|x-y| at hhexact hhlemma ForcedTest.coupled_terminal_error {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {T K L K' L':ℝ} {γ:ℝ → ℝ} {u V b p:ℝ → ℝ → ℝ}(hT:0<T) (hu:GradientStrip T γ u K L) (h:ForcedTest T γ u V b p K' L')(hXM:∀ t∈Icc (0:ℝ) T,AEStronglyMeasurable (X t) μ)(hpaths:∀ᵐ ω ∂μ,(∀ t∈Icc (0:ℝ) T,X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,γ s*u s (X s ω)) ∧ X 0 ω=0) {N:ℕ} (hN:0<N) :|(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))-(∫ ω,V T (X T ω) ∂μ)|≤K'*Real.sqrt (∫ ω,(meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ) := bylet F := fun ω ↦ V T (coupledEuler T γ u B N N ω)let G := fun ω ↦ V T (X T ω)let E := meshMaxError T X (coupledEuler T γ u B) Nhave ht:T∈Icc (0:ℝ) T := ⟨hT.le,le_rfl⟩have hm:Continuous (V T) := (h.smooth T ht).continuoushave hFM:MemLp F 2 μ := MemLp.of_bound(hm.measurable.comp_aemeasurable (coupled_euler_measurable hB hT hu N N le_rfl).aemeasurable).aestronglyMeasurable K'(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs,F] using h.bound T ht _))have hGM:MemLp G 2 μ := MemLp.of_bound(hm.measurable.comp_aemeasurable (hXM T ht).aemeasurable).aestronglyMeasurable K'(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs,G] using h.bound T ht _))have hEM:MemLp E 2 μ := coupled_mesh_error_memLp hB hT hu hXM hpaths hNhave hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simphave hFG (ω:Ω) : |F ω-G ω|≤K'*|E ω| := byhave he:|coupledEuler T γ u B N N ω-X T ω|≤E ω := byhave hh := le_initialMax (f:=fun k ↦|coupledEuler T γ u B N k ω-X (meshTime T N k) ω|) (le_refl N)change |coupledEuler T γ u B N N ω-X (meshTime T N N) ω|≤E ω at hhrwa [hlast] at hhexact (h.terminal_lipschitz hT.le _ _).trans(mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) h.K_nonneg)have heq:(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))=(∫ ω,F ω ∂μ) := byhave heum := measurable_euler T N γ u (fun j hj ↦ (hu.smooth _ (mesh_time_mem hT.le hN hj.le)).continuous.measurable) N le_rflhave hh := (coupledCoordinates_hasLaw hB hT hN).integral_comp (hm.measurable.comp heum).aestronglyMeasurablesimpa only [Function.comp_apply,F,coupledEuler,ite_eq_right (Nat.ne_of_gt hN)] using hh.symmrw [heq]exact first_moment_perturbation hFM hGM hEM h.K_nonneg (Eventually.of_forall hFG)end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596import Mathlibimport OAI.Probability.SKValue.Control.StripRegularitynamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReallemma IsDiffusion.gradient_square_integral {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) (hreg : SourceStripRegularity W γ){T : ℝ} (hT : 0<T) (hT1 : T<1) :(∫ ω, (gradient W γ T (X T ω))^2 ∂W.μ)=∫ t in (0 : ℝ)..T, ∫ ω, (curvature W γ t (X t ω))^2 ∂W.μ := byobtain ⟨Kv,Lv,K,L,D,Lu,La,hV,hG,hD,hLu,hLa,hDb,hu,ha⟩ := hreg T ⟨hT.le,hT1⟩exact diffusion_gradient_isometry W.brownian.toIsPreBrownianReal hT hT1.le hGhD hLu hLa hDb hu ha(fun t ht ↦ (hX.measurable ⟨ht.1,ht.2.trans hT1.le⟩).aestronglyMeasurable)(hX.strip_paths hT.le hT1 hLu (fun t ht s hs x y ↦ hu s hs t ht y x))lemma IsDiffusion.curvature_square_mean_continuous {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) (hreg : SourceStripRegularity W γ) :ContinuousOn (fun t ↦ ∫ ω, (curvature W γ t (X t ω))^2 ∂W.μ) (Ico (0 : ℝ) 1) := byintro t htobtain ⟨T,htT,hT1⟩ := exists_between ht.2obtain ⟨Kv,Lv,K,L,D,Lu,La,hV,hG,hD,hLu,hLa,hDb,hu,ha⟩ := hreg T ⟨ht.1.trans htT.le,hT1⟩have hc := mean_derivative_square_continuous hD hLa(fun s hs ↦ (hG.smooth s hs).continuous_deriv (by norm_num)) hDb ha(fun s hs ↦ (hX.measurable ⟨hs.1,hs.2.trans hT1.le⟩).aestronglyMeasurable)(hX.2.mono (fun _ hω ↦ hω.1.mono (Icc_subset_Icc le_rfl hT1.le)))apply (hc t ⟨ht.1,htT.le⟩).mono_of_mem_nhdsWithinfilter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds htT)] with s hs hsTexact ⟨hs.1,hsT.le⟩lemma continuous_eq_one_of_primitive {f : ℝ → ℝ}(hc : ContinuousOn f (Ico (0 : ℝ) 1))(hi : ∀ t∈Ioo (0 : ℝ) 1, (∫ s in (0 : ℝ)..t, f s)=t) :∀ t∈Ico (0 : ℝ) 1, f t=1 := byhave hint (t : ℝ) (ht : t∈Ioo (0 : ℝ) 1) : f t=1 := byhave hf : IntervalIntegrable f volume 0 t := byapply ContinuousOn.intervalIntegrablerw [uIcc_of_le ht.1.le]exact hc.mono (fun s hs ↦ ⟨hs.1,hs.2.trans_lt ht.2⟩)have hs : Ico (0 : ℝ) 1∈𝓝 t := Ico_mem_nhds ht.1 ht.2have hd := intervalIntegral.integral_hasDerivAt_right hf⟨Ico (0 : ℝ) 1,hs,hc.aestronglyMeasurable measurableSet_Ico⟩((hc t ⟨ht.1.le,ht.2⟩).continuousAt hs)have he : (fun t ↦ ∫ s in (0 : ℝ)..t, f s)=ᶠ[𝓝 t] (id : ℝ → ℝ) := byfilter_upwards [Ioo_mem_nhds ht.1 ht.2] with s hsexact hi s hsexact hd.unique ((hasDerivAt_id t).congr_of_eventuallyEq he)intro t htobtain h0|h0 := ht.1.eq_or_lt· subst thave hlim : Tendsto f (𝓝[>] (0 : ℝ)) (𝓝 (f 0)) := byapply (hc 0 (by norm_num)).mono_leftapply le_inf nhdsWithin_le_nhdsapply le_principal_iff.mprfilter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds (by norm_num : (0 : ℝ)<1))] with s hs hs1exact ⟨hs.le,hs1⟩apply tendsto_nhds_unique hlimapply tendsto_const_nhds.congr'filter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds (by norm_num : (0 : ℝ)<1))] with s hs hs1exact (hint s ⟨hs,hs1⟩).symm· exact hint t ⟨h0,ht.2⟩lemma IsDiffusion.curvature_unit_moment_of_contact {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) (hreg : SourceStripRegularity W γ)(hmom : ∀ t∈Ico (0 : ℝ) 1, (∫ ω, (gradient W γ t (X t ω))^2 ∂W.μ)=t) :∀ t∈Ico (0 : ℝ) 1, (∫ ω, (curvature W γ t (X t ω))^2 ∂W.μ)=1 := byapply continuous_eq_one_of_primitive (hX.curvature_square_mean_continuous hreg)intro t htrw [←hX.gradient_square_integral hreg ht.1 ht.2,hmom t ⟨ht.1.le,ht.2⟩]end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596import Mathlibimport OAI.Probability.SKValue.Control.StripRegularitynamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReallemma IsDiffusion.gradient_square_integral {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) (hreg : SourceStripRegularity W γ){T : ℝ} (hT : 0<T) (hT1 : T<1) :(∫ ω, (gradient W γ T (X T ω))^2 ∂W.μ)=∫ t in (0 : ℝ)..T, ∫ ω, (curvature W γ t (X t ω))^2 ∂W.μ := byobtain ⟨Kv,Lv,K,L,D,Lu,La,hV,hG,hD,hLu,hLa,hDb,hu,ha⟩ := hreg T ⟨hT.le,hT1⟩exact diffusion_gradient_isometry W.brownian.toIsPreBrownianReal hT hT1.le hGhD hLu hLa hDb hu ha(fun t ht ↦ (hX.measurable ⟨ht.1,ht.2.trans hT1.le⟩).aestronglyMeasurable)(hX.strip_paths hT.le hT1 hLu (fun t ht s hs x y ↦ hu s hs t ht y x))lemma IsDiffusion.curvature_square_mean_continuous {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) (hreg : SourceStripRegularity W γ) :ContinuousOn (fun t ↦ ∫ ω, (curvature W γ t (X t ω))^2 ∂W.μ) (Ico (0 : ℝ) 1) := byintro t htobtain ⟨T,htT,hT1⟩ := exists_between ht.2obtain ⟨Kv,Lv,K,L,D,Lu,La,hV,hG,hD,hLu,hLa,hDb,hu,ha⟩ := hreg T ⟨ht.1.trans htT.le,hT1⟩have hc := mean_derivative_square_continuous hD hLa(fun s hs ↦ (hG.smooth s hs).continuous_deriv (by norm_num)) hDb ha(fun s hs ↦ (hX.measurable ⟨hs.1,hs.2.trans hT1.le⟩).aestronglyMeasurable)(hX.2.mono (fun _ hω ↦ hω.1.mono (Icc_subset_Icc le_rfl hT1.le)))apply (hc t ⟨ht.1,htT.le⟩).mono_of_mem_nhdsWithinfilter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds htT)] with s hs hsTexact ⟨hs.1,hsT.le⟩lemma continuous_eq_one_of_primitive {f : ℝ → ℝ}(hc : ContinuousOn f (Ico (0 : ℝ) 1))(hi : ∀ t∈Ioo (0 : ℝ) 1, (∫ s in (0 : ℝ)..t, f s)=t) :∀ t∈Ico (0 : ℝ) 1, f t=1 := byhave hint (t : ℝ) (ht : t∈Ioo (0 : ℝ) 1) : f t=1 := byhave hf : IntervalIntegrable f volume 0 t := byapply ContinuousOn.intervalIntegrablerw [uIcc_of_le ht.1.le]exact hc.mono (fun s hs ↦ ⟨hs.1,hs.2.trans_lt ht.2⟩)have hs : Ico (0 : ℝ) 1∈𝓝 t := Ico_mem_nhds ht.1 ht.2have hd := intervalIntegral.integral_hasDerivAt_right hf⟨Ico (0 : ℝ) 1,hs,hc.aestronglyMeasurable measurableSet_Ico⟩((hc t ⟨ht.1.le,ht.2⟩).continuousAt hs)have he : (fun t ↦ ∫ s in (0 : ℝ)..t, f s)=ᶠ[𝓝 t] (id : ℝ → ℝ) := byfilter_upwards [Ioo_mem_nhds ht.1 ht.2] with s hsexact hi s hsexact hd.unique ((hasDerivAt_id t).congr_of_eventuallyEq he)intro t htobtain h0|h0 := ht.1.eq_or_lt· subst thave hlim : Tendsto f (𝓝[>] (0 : ℝ)) (𝓝 (f 0)) := byapply (hc 0 (by norm_num)).mono_leftapply le_inf nhdsWithin_le_nhdsapply le_principal_iff.mprfilter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds (by norm_num : (0 : ℝ)<1))] with s hs hs1exact ⟨hs.le,hs1⟩apply tendsto_nhds_unique hlimapply tendsto_const_nhds.congr'filter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds (by norm_num : (0 : ℝ)<1))] with s hs hs1exact (hint s ⟨hs,hs1⟩).symm· exact hint t ⟨h0,ht.2⟩lemma IsDiffusion.curvature_unit_moment_of_contact {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) (hreg : SourceStripRegularity W γ)(hmom : ∀ t∈Ico (0 : ℝ) 1, (∫ ω, (gradient W γ t (X t ω))^2 ∂W.μ)=t) :∀ t∈Ico (0 : ℝ) 1, (∫ ω, (curvature W γ t (X t ω))^2 ∂W.μ)=1 := byapply continuous_eq_one_of_primitive (hX.curvature_square_mean_continuous hreg)intro t htrw [←hX.gradient_square_integral hreg ht.1 ht.2,hmom t ⟨ht.1.le,ht.2⟩]end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import Mathlibimport OAI.Probability.SKValue.Evolution.TerminalErrornamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorslemma IsDiffusion.measurable {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {t : ℝ} (ht : t∈Icc (0 : ℝ) 1) :Measurable (X t) := bysimpa only [Real.coe_toNNReal t ht.1, min_eq_left ht.2] using(hX.1 t.toNNReal).mono (W.filtration.le t.toNNReal) le_rfllemma drift_integral_bound (W : BrownianSpace) (γ : OrderParameter) {t : ℝ}(ht : t∈Icc (0 : ℝ) 1) (x : ℝ → ℝ) :|∫ s in (0 : ℝ)..t, γ.coeff s*gradient W γ s (x s)|≤∫ s in (0 : ℝ)..1, γ.cutoff s := byhave he : (∫ s in (0 : ℝ)..t, γ.coeff s*gradient W γ s (x s)) =∫ s in (0 : ℝ)..t, γ.cutoff s*gradient W γ s (x s) := byapply intervalIntegral.integral_congr_Ioo_of_le ht.1intro s hschange γ.coeff s*gradient W γ s (x s)=γ.cutoff s*gradient W γ s (x s)have hs' : s∈Ico (0 : ℝ) 1 := ⟨hs.1.le,hs.2.trans_le ht.2⟩rw [OrderParameter.cutoff, Set.indicator_of_mem hs']rw [he]have hb := intervalIntegral.norm_integral_le_of_norm_le ht.1(f := fun s ↦ γ.cutoff s*gradient W γ s (x s))(Eventually.of_forall (fun s hs ↦ byrw [Real.norm_eq_abs,abs_mul,abs_of_nonneg (γ.cutoff_nonneg s)]exact (mul_le_mul_of_nonneg_left (gradient_bound W γ ⟨hs.1.le,hs.2.trans ht.2⟩ (x s))(γ.cutoff_nonneg s)).trans_eq (mul_one _)))(γ.cutoff_integrable.intervalIntegrable (a := 0) (b := t))have hm := intervalIntegral.integral_mono_interval (c := (0 : ℝ)) (d := 1) le_rfl ht.1 ht.2(Eventually.of_forall (fun s ↦ γ.cutoff_nonneg s)) γ.cutoff_integrable.intervalIntegrablerw [Real.norm_eq_abs] at hbexact hb.trans hmlemma IsDiffusion.drift_bound {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) :∀ᵐ ω ∂W.μ, ∀ t∈Icc (0 : ℝ) 1,|X t ω-W.B t.toNNReal ω|≤∫ s in (0 : ℝ)..1, γ.cutoff s := byfilter_upwards [hX.2] with ω hω t htrw [hω.2 t ht, add_sub_cancel_left]exact drift_integral_bound W γ ht (fun s ↦ X s ω)lemma IsDiffusion.memLp {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {t : ℝ} (ht : t∈Icc (0 : ℝ) 1){p : ℝ≥0∞} (hp : p≠∞) : MemLp (X t) p W.μ := byhave hd : MemLp (fun ω ↦ X t ω-W.B t.toNNReal ω) p W.μ :=MemLp.of_bound ((hX.measurable ht).sub (W.measurable _).measurable).aestronglyMeasurable(∫ s in (0 : ℝ)..1, γ.cutoff s) (hX.drift_bound.mono (fun ω hω ↦ bysimpa only [Real.norm_eq_abs] using hω t ht))have hb := (W.brownian.hasLaw_eval t.toNNReal).hasGaussianLaw.memLp hpconvert hd.add hb using 1funext ωsimp only [Pi.add_apply, sub_add_cancel]lemma eventually_time_mem : ∀ᶠ t : ℝ in 𝓝[<] 1, t∈Icc (0 : ℝ) 1 := byfilter_upwards [Ico_mem_nhdsLT (by norm_num : (0 : ℝ)<1)] with t htexact ⟨ht.1,ht.2.le⟩lemma IsDiffusion.ae_tendsto {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) :∀ᵐ ω ∂W.μ, Tendsto (fun t ↦ X t ω) (𝓝[<] (1 : ℝ)) (𝓝 (X 1 ω)) := byhave ht : Tendsto (id : ℝ → ℝ) (𝓝[<] 1) (𝓝[Icc (0 : ℝ) 1] 1) :=tendsto_nhdsWithin_iff.mpr ⟨nhdsWithin_le_nhds,eventually_time_mem⟩filter_upwards [hX.2] with ω hωexact Tendsto.comp (hω.1 1 (by norm_num : (1 : ℝ)∈Icc (0 : ℝ) 1)) htlemma IsDiffusion.L2_terminal {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) :Tendsto (fun t ↦ ∫ ω, (X t ω-X 1 ω)^2 ∂W.μ) (𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) := bylet D (t : ℝ) (ω : W.Ω) := X t ω-W.B t.toNNReal ωlet G := ∫ s in (0 : ℝ)..1, γ.cutoff shave hG : 0≤G := intervalIntegral.integral_nonneg_of_forall (by norm_num)(fun s ↦ γ.cutoff_nonneg s)have hD (t : ℝ) (ht : t∈Icc (0 : ℝ) 1) : MemLp (D t) 2 W.μ :=(hX.memLp ht (by norm_num)).sub ((W.brownian.hasLaw_eval t.toNNReal).hasGaussianLaw.memLp_two)have hD1 := hD 1 (by norm_num)have hDb : ∀ᵐ ω ∂W.μ, ∀ t���Icc (0 : ℝ) 1, |D t ω|≤G := hX.drift_boundhave hDC : ∀ᵐ ω ∂W.μ, Tendsto (fun t ↦ D t ω) (𝓝[<] (1 : ℝ)) (𝓝 (D 1 ω)) := byfilter_upwards [hX.ae_tendsto,W.brownian.cont] with ω hω hBωexact hω.sub ((hBω.comp continuous_real_toNNReal).continuousAt.tendsto.mono_left nhdsWithin_le_nhds)have hDL : Tendsto (fun t ↦ ∫ ω, (D t ω-D 1 ω)^2 ∂W.μ)(𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) := byhave h := tendsto_integral_filter_of_dominated_convergence(μ := W.μ) (l := 𝓝[<] (1 : ℝ)) (F := fun t ω ↦ (D t ω-D 1 ω)^2) (f := fun _ ↦ (0 : ℝ))(fun _ ↦ 4*G^2) ?_ ?_ (integrable_const (4*G^2)) ?_· simpa only [integral_zero] using h· filter_upwards [eventually_time_mem] with t htexact ((hD t ht).sub hD1).aestronglyMeasurable.aemeasurable.pow_const 2 |>.aestronglyMeasurable· filter_upwards [eventually_time_mem] with t htfilter_upwards [hDb] with ω hωrw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)]have h0 := abs_le.mp (hω t ht)have h1 := abs_le.mp (hω 1 (by norm_num))nlinarith [sq_nonneg (D t ω-D 1 ω), sq_nonneg (G-(D t ω-D 1 ω)/2),sq_nonneg (G+(D t ω-D 1 ω)/2), mul_nonneg (show 0≤2*G-(D t ω-D 1 ω) by linarith)(show 0≤2*G+(D t ω-D 1 ω) by linarith)]· filter_upwards [hDC] with ω hωsimpa only [sub_self, zero_pow (by norm_num : (2 : ℕ)≠0)] using (hω.sub (tendsto_const_nhds (x := D 1 ω))).pow 2have hb : ∀ t∈Icc (0 : ℝ) 1,(∫ ω, (X t ω-X 1 ω)^2 ∂W.μ) ≤2*(∫ ω, (D t ω-D 1 ω)^2 ∂W.μ)+2*(1-t) := byintro t hthave hxint := ((hX.memLp ht (by norm_num : (2 : ℝ≥0∞)≠∞)).sub(hX.memLp (by norm_num : (1 : ℝ)∈Icc (0 : ℝ) 1) (by norm_num))).integrable_sqhave hdint : Integrable (fun ω ↦ (D t ω-D 1 ω)^2) W.μ := ((hD t ht).sub hD1).integrable_sqhave hbint := (brownian_increment_memLp W t).integrable_sqcalc_ ≤ ∫ ω, 2*(D t ω-D 1 ω)^2+2*(W.B 1 ω-W.B t.toNNReal ω)^2 ∂W.μ := byapply integral_mono hxint ((hdint.const_mul 2).add (hbint.const_mul 2))intro ωdsimp only [D,Pi.add_apply,Pi.sub_apply]simp only [Real.toNNReal_one]nlinarith [sq_nonneg (X t ω-W.B t.toNNReal ω-(X 1 ω-W.B 1 ω)+(W.B 1 ω-W.B t.toNNReal ω))]_ = _ := byrw [integral_add (hdint.const_mul 2) (hbint.const_mul 2), integral_const_mul,integral_const_mul, brownian_increment_second W ht]apply squeeze_zero' (Eventually.of_forall (fun t ↦ integral_nonneg (fun ω ↦ sq_nonneg _)))(eventually_time_mem.mono (fun t ht ↦ hb t ht))simpa only [sub_self, mul_zero, add_zero,id_eq] using(hDL.const_mul 2).add (((tendsto_const_nhds (x := (1 : ℝ))).sub (tendsto_id.mono_left nhdsWithin_le_nhds : Tendsto (id : ℝ → ℝ) (𝓝[<] 1) (𝓝 1))).const_mul 2)end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import Mathlibimport OAI.Probability.SKValue.Evolution.TerminalErrornamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorslemma IsDiffusion.measurable {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {t : ℝ} (ht : t∈Icc (0 : ℝ) 1) :Measurable (X t) := bysimpa only [Real.coe_toNNReal t ht.1, min_eq_left ht.2] using(hX.1 t.toNNReal).mono (W.filtration.le t.toNNReal) le_rfllemma drift_integral_bound (W : BrownianSpace) (γ : OrderParameter) {t : ℝ}(ht : t∈Icc (0 : ℝ) 1) (x : ℝ → ℝ) :|∫ s in (0 : ℝ)..t, γ.coeff s*gradient W γ s (x s)|≤∫ s in (0 : ℝ)..1, γ.cutoff s := byhave he : (∫ s in (0 : ℝ)..t, γ.coeff s*gradient W γ s (x s)) =∫ s in (0 : ℝ)..t, γ.cutoff s*gradient W γ s (x s) := byapply intervalIntegral.integral_congr_Ioo_of_le ht.1intro s hschange γ.coeff s*gradient W γ s (x s)=γ.cutoff s*gradient W γ s (x s)have hs' : s∈Ico (0 : ℝ) 1 := ⟨hs.1.le,hs.2.trans_le ht.2⟩rw [OrderParameter.cutoff, Set.indicator_of_mem hs']rw [he]have hb := intervalIntegral.norm_integral_le_of_norm_le ht.1(f := fun s ↦ γ.cutoff s*gradient W γ s (x s))(Eventually.of_forall (fun s hs ↦ byrw [Real.norm_eq_abs,abs_mul,abs_of_nonneg (γ.cutoff_nonneg s)]exact (mul_le_mul_of_nonneg_left (gradient_bound W γ ⟨hs.1.le,hs.2.trans ht.2⟩ (x s))(γ.cutoff_nonneg s)).trans_eq (mul_one _)))(γ.cutoff_integrable.intervalIntegrable (a := 0) (b := t))have hm := intervalIntegral.integral_mono_interval (c := (0 : ℝ)) (d := 1) le_rfl ht.1 ht.2(Eventually.of_forall (fun s ↦ γ.cutoff_nonneg s)) γ.cutoff_integrable.intervalIntegrablerw [Real.norm_eq_abs] at hbexact hb.trans hmlemma IsDiffusion.drift_bound {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) :∀ᵐ ω ∂W.μ, ∀ t∈Icc (0 : ℝ) 1,|X t ω-W.B t.toNNReal ω|≤∫ s in (0 : ℝ)..1, γ.cutoff s := byfilter_upwards [hX.2] with ω hω t htrw [hω.2 t ht, add_sub_cancel_left]exact drift_integral_bound W γ ht (fun s ↦ X s ω)lemma IsDiffusion.memLp {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {t : ℝ} (ht : t∈Icc (0 : ℝ) 1){p : ℝ≥0∞} (hp : p≠∞) : MemLp (X t) p W.μ := byhave hd : MemLp (fun ω ↦ X t ω-W.B t.toNNReal ω) p W.μ :=MemLp.of_bound ((hX.measurable ht).sub (W.measurable _).measurable).aestronglyMeasurable(∫ s in (0 : ℝ)..1, γ.cutoff s) (hX.drift_bound.mono (fun ω hω ↦ bysimpa only [Real.norm_eq_abs] using hω t ht))have hb := (W.brownian.hasLaw_eval t.toNNReal).hasGaussianLaw.memLp hpconvert hd.add hb using 1funext ωsimp only [Pi.add_apply, sub_add_cancel]lemma eventually_time_mem : ∀ᶠ t : ℝ in 𝓝[<] 1, t∈Icc (0 : ℝ) 1 := byfilter_upwards [Ico_mem_nhdsLT (by norm_num : (0 : ℝ)<1)] with t htexact ⟨ht.1,ht.2.le⟩lemma IsDiffusion.ae_tendsto {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) :∀ᵐ ω ∂W.μ, Tendsto (fun t ↦ X t ω) (𝓝[<] (1 : ℝ)) (𝓝 (X 1 ω)) := byhave ht : Tendsto (id : ℝ → ℝ) (𝓝[<] 1) (𝓝[Icc (0 : ℝ) 1] 1) :=tendsto_nhdsWithin_iff.mpr ⟨nhdsWithin_le_nhds,eventually_time_mem⟩filter_upwards [hX.2] with ω hωexact Tendsto.comp (hω.1 1 (by norm_num : (1 : ℝ)∈Icc (0 : ℝ) 1)) htlemma IsDiffusion.L2_terminal {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) :Tendsto (fun t ↦ ∫ ω, (X t ω-X 1 ω)^2 ∂W.μ) (𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) := bylet D (t : ℝ) (ω : W.Ω) := X t ω-W.B t.toNNReal ωlet G := ∫ s in (0 : ℝ)..1, γ.cutoff shave hG : 0≤G := intervalIntegral.integral_nonneg_of_forall (by norm_num)(fun s ↦ γ.cutoff_nonneg s)have hD (t : ℝ) (ht : t∈Icc (0 : ℝ) 1) : MemLp (D t) 2 W.μ :=(hX.memLp ht (by norm_num)).sub ((W.brownian.hasLaw_eval t.toNNReal).hasGaussianLaw.memLp_two)have hD1 := hD 1 (by norm_num)have hDb : ∀ᵐ ω ∂W.μ, ∀ t∈Icc (0 : ℝ) 1, |D t ω|≤G := hX.drift_boundhave hDC : ∀ᵐ ω ∂W.μ, Tendsto (fun t ↦ D t ω) (𝓝[<] (1 : ℝ)) (𝓝 (D 1 ω)) := byfilter_upwards [hX.ae_tendsto,W.brownian.cont] with ω hω hBωexact hω.sub ((hBω.comp continuous_real_toNNReal).continuousAt.tendsto.mono_left nhdsWithin_le_nhds)have hDL : Tendsto (fun t ↦ ∫ ω, (D t ω-D 1 ω)^2 ∂W.μ)(𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) := byhave h := tendsto_integral_filter_of_dominated_convergence(μ := W.μ) (l := 𝓝[<] (1 : ℝ)) (F := fun t ω ↦ (D t ω-D 1 ω)^2) (f := fun _ ↦ (0 : ℝ))(fun _ ↦ 4*G^2) ?_ ?_ (integrable_const (4*G^2)) ?_· simpa only [integral_zero] using h· filter_upwards [eventually_time_mem] with t htexact ((hD t ht).sub hD1).aestronglyMeasurable.aemeasurable.pow_const 2 |>.aestronglyMeasurable· filter_upwards [eventually_time_mem] with t htfilter_upwards [hDb] with ω hωrw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)]have h0 := abs_le.mp (hω t ht)have h1 := abs_le.mp (hω 1 (by norm_num))nlinarith [sq_nonneg (D t ω-D 1 ω), sq_nonneg (G-(D t ω-D 1 ω)/2),sq_nonneg (G+(D t ω-D 1 ω)/2), mul_nonneg (show 0≤2*G-(D t ω-D 1 ω) by linarith)(show 0≤2*G+(D t ω-D 1 ω) by linarith)]· filter_upwards [hDC] with ω hωsimpa only [sub_self, zero_pow (by norm_num : (2 : ℕ)≠0)] using (hω.sub (tendsto_const_nhds (x := D 1 ω))).pow 2have hb : ∀ t∈Icc (0 : ℝ) 1,(∫ ω, (X t ω-X 1 ω)^2 ∂W.μ) ≤2*(∫ ω, (D t ω-D 1 ω)^2 ∂W.μ)+2*(1-t) := byintro t hthave hxint := ((hX.memLp ht (by norm_num : (2 : ℝ≥0∞)≠∞)).sub(hX.memLp (by norm_num : (1 : ℝ)∈Icc (0 : ℝ) 1) (by norm_num))).integrable_sqhave hdint : Integrable (fun ω ↦ (D t ω-D 1 ω)^2) W.μ := ((hD t ht).sub hD1).integrable_sqhave hbint := (brownian_increment_memLp W t).integrable_sqcalc_ ≤ ∫ ω, 2*(D t ω-D 1 ω)^2+2*(W.B 1 ω-W.B t.toNNReal ω)^2 ∂W.μ := byapply integral_mono hxint ((hdint.const_mul 2).add (hbint.const_mul 2))intro ωdsimp only [D,Pi.add_apply,Pi.sub_apply]simp only [Real.toNNReal_one]nlinarith [sq_nonneg (X t ω-W.B t.toNNReal ω-(X 1 ω-W.B 1 ω)+(W.B 1 ω-W.B t.toNNReal ω))]_ = _ := byrw [integral_add (hdint.const_mul 2) (hbint.const_mul 2), integral_const_mul,integral_const_mul, brownian_increment_second W ht]apply squeeze_zero' (Eventually.of_forall (fun t ↦ integral_nonneg (fun ω ↦ sq_nonneg _)))(eventually_time_mem.mono (fun t ht ↦ hb t ht))simpa only [sub_self, mul_zero, add_zero,id_eq] using(hDL.const_mul 2).add (((tendsto_const_nhds (x := (1 : ℝ))).sub (tendsto_id.mono_left nhdsWithin_le_nhds : Tendsto (id : ℝ → ℝ) (𝓝[<] 1) (𝓝 1))).const_mul 2)end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343import Mathlibimport OAI.Probability.SKValue.Evolution.MeanDerivativeContinuousimport OAI.Probability.SKValue.Equations.RawIncrementnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology BigOperatorslemma coupled_terminal_second_moment_bound {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}[IsProbabilityMeasure μ] {B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ){X : ℝ → Ω → ℝ} {T K L Lu : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0<T) (h : GradientStrip T γ u K L) (hLu : 0≤Lu)(huLip : ∀ x y, |u T x-u T y|≤Lu*|x-y|)(hXM : ∀ t∈Icc (0 : ℝ) T, AEStronglyMeasurable (X t) μ)(hpaths : ∀ᵐ ω ∂μ,(∀ t∈Icc (0 : ℝ) T, X t ω=B (Real.toNNReal t) ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) ∧ X 0 ω=0){N : ℕ} (hN : 0<N) :|(∫ z, (meshTerminal T N γ u z)^2 ∂gaussianProduct (Fin (N+1)))-(∫ ω, (u T (X T ω))^2 ∂μ)| ≤(2*Lu)*Real.sqrt (∫ ω, (meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ) := bylet F (ω : Ω) := u T (coupledEuler T γ u B N N ω)let G (ω : Ω) := u T (X T ω)let E := meshMaxError T X (coupledEuler T γ u B) Nhave ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩have hd := (h.smooth T ht).continuoushave hFM : MemLp F 2 μ := MemLp.of_bound(hd.measurable.comp_aemeasurable (coupled_euler_measurable hB hT h N N le_rfl).aemeasurable).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs, F] using h.bounded T ht _))have hGM : MemLp G 2 μ := MemLp.of_bound(hd.measurable.comp_aemeasurable (hXM T ht).aemeasurable).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs, G] using h.bounded T ht _))have hEM : MemLp E 2 μ := coupled_mesh_error_memLp hB hT h hXM hpaths hNhave hlast : meshTime T N N = T := by dsimp [meshTime, stepSize]; field_simphave hFG (ω : Ω) : |F ω-G ω|≤Lu*|E ω| := byhave he : |coupledEuler T γ u B N N ω-X T ω|≤E ω := bychange |coupledEuler T γ u B N N ω-X T ω| ≤ initialMax _ Nhave hm := le_initialMax (f := fun k ↦ |coupledEuler T γ u B N k ω-X (meshTime T N k) ω|) (le_refl N)change |coupledEuler T γ u B N N ω-X (meshTime T N N) ω| ≤ initialMax _ N at hmrw [hlast] at hmexact hmexact (huLip _ _).trans (mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) hLu)have hlaw := coupledCoordinates_hasLaw hB hT hNhave heq : (∫ z, (meshTerminal T N γ u z)^2 ∂gaussianProduct (Fin (N+1)))=∫ ω, (F ω)^2 ∂μ := byrw [←hlaw.integral_comp ((mesh_terminal_measurable hT.le h hN).pow_const 2).aestronglyMeasurable]simp only [Function.comp_apply, F, meshTerminal, coupledEuler, ite_eq_right (Nat.ne_of_gt hN)]rw [heq]simpa only [mul_one] using second_moment_perturbation hFM hGM hEM (by norm_num : (0 : ℝ)≤1) hLu(Eventually.of_forall (fun ω ↦ ⟨h.bounded T ht _, h.bounded T ht _, hFG ω⟩))theorem diffusion_gradient_isometry{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ){X : ℝ → Ω → ℝ} {T K L D Lu La : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0<T) (hT1 : T≤1) (h : GradientStrip T γ u K L)(hD0 : 0≤D) (hLu : 0≤Lu) (hLa : 0≤La)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D)(huLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(haLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|deriv (u s) x-deriv (u t) y|≤La*(|s-t|+|x-y|))(hXM : ∀ t∈Icc (0 : ℝ) T, AEStronglyMeasurable (X t) μ)(hpaths : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t∈Icc (0 : ℝ) T, X t ω = B (Real.toNNReal t) ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) ∧ X 0 ω=0) :(∫ ω, (u T (X T ω))^2 ∂μ) =∫ t in (0 : ℝ)..T, ∫ ω, (deriv (u t) (X t ω))^2 ∂μ := bylet E (N : ℕ) := ∫ ω, (meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μhave hE : Tendsto E atTop (𝓝 0) := coupled_euler_L2_convergence hB hT h hLu huLip hXM hpathshave hEs : Tendsto (fun N ↦ Real.sqrt (E N)) atTop (𝓝 0) := bysimpa only [Real.sqrt_zero, Function.comp_def] using (Real.continuous_sqrt.tendsto 0).comp hEhave ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩have hmoment : Tendsto (fun N ↦ ∫ z, (meshTerminal T N γ u z)^2 ∂gaussianProduct (Fin (N+1)))atTop (𝓝 (∫ ω, (u T (X T ω))^2 ∂μ)) := byapply tendsto_iff_norm_sub_tendsto_zero.mprapply squeeze_zero' (Eventually.of_forall (fun _ ↦ norm_nonneg _)) ?_(by simpa only [mul_zero] using hEs.const_mul (2*Lu))filter_upwards [eventually_gt_atTop 0] with N hNrw [Real.norm_eq_abs]exact coupled_terminal_second_moment_bound hB hT h hLu(fun x y ↦ by simpa only [sub_self, abs_zero, zero_add] using huLip T ht T ht x y)hXM (hpaths.mono (fun _ hω ↦ hω.2.2)) hNhave hmean := mean_derivative_square_continuous hD0 hLa(fun t ht ↦ (h.smooth t ht).continuous_deriv (by norm_num)) hD haLip hXM(hpaths.mono (fun _ hω ↦ hω.1))have hquadrature : Tendsto (fun N ↦ stepSize T N * ∑ i : Fin N,∫ z, (meshRaw T N γ u i z)^2 ∂gaussianProduct (Fin (N+1))) atTop(𝓝 (∫ t in (0 : ℝ)..T, ∫ ω, (deriv (u t) (X t ω))^2 ∂μ)) := byapply perturbed_grid_riemann_tendsto (r := fun N ↦ (2*D*La)*Real.sqrt (E N)) hT hmean(by simpa only [mul_zero] using hEs.const_mul (2*D*La))filter_upwards [eventually_gt_atTop 0] with N hN iexact (coupled_mesh_general_moment_bounds hB hT h hD0 hLa hD(fun t ht x y ↦ by simpa only [sub_self, abs_zero, zero_add] using haLip t ht t ht x y)hXM (hpaths.mono (fun _ hω ↦ hω.2.2)) hN i).1have herror : Tendsto (fun N ↦(∫ z, (meshTerminal T N γ u z)^2 ∂gaussianProduct (Fin (N+1)))-stepSize T N * ∑ i : Fin N, ∫ z, (meshRaw T N γ u i z)^2 ∂gaussianProduct (Fin (N+1)))atTop (𝓝 0) := byapply squeeze_zero_norm' (a := fun N ↦Real.sqrt (gradientMeshError T N γ u) * Real.sqrt (2*(1+T*D^2)))· filter_upwards [eventually_gt_atTop 0] with N hNrw [Real.norm_eq_abs]exact mesh_terminal_stochastic_second_moment_error hT h hD0 hD hN· simpa only [Real.sqrt_zero, zero_mul, Function.comp_def] using((Real.continuous_sqrt.tendsto 0).comp (gradientMeshError_tendsto_zero hT hT1 h)).mul_const(Real.sqrt (2*(1+T*D^2)))have hlimit := herror.add hquadraturesimp only [sub_add_cancel, zero_add] at hlimitexact tendsto_nhds_unique hmoment hlimitlemma weighted_first_moment_perturbation {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}{f g e b : Ω → ℝ} {L : ℝ} (hf : MemLp f 2 μ) (hg : MemLp g 2 μ)(he : MemLp e 2 μ) (hb : MemLp b 2 μ) (hL : 0≤L)(hfg : ∀ᵐ ω ∂μ, |f ω-g ω|≤L*|e ω|) :|(∫ ω, f ω*b ω ∂μ)-(∫ ω, g ω*b ω ∂μ)| ≤L*Real.sqrt (∫ ω, (e ω)^2 ∂μ)*Real.sqrt (∫ ω, (b ω)^2 ∂μ) := byrw [←integral_sub (f := fun ω ↦ f ω*b ω) (g := fun ω ↦ g ω*b ω) (hf.integrable_mul hb) (hg.integrable_mul hb)]have heq : (fun ω ↦ f ω*b ω-g ω*b ω)=(fun ω ↦ (f ω-g ω)*b ω) := by funext ω; ringrw [heq]calc_ ≤ ∫ ω, |(f ω-g ω)*b ω| ∂μ := abs_integral_le_integral_abs_ ≤ ∫ ω, L*(|e ω| * |b ω|) ∂μ := byapply integral_mono_ae ((hf.sub hg).integrable_mul hb).abs ((he.abs.integrable_mul hb.abs).const_mul L)filter_upwards [hfg] with ω hωchange |(f ω-g ω)*b ω| ≤ L*(|e ω| * |b ω|)rw [abs_mul]exact (mul_le_mul_of_nonneg_right hω (abs_nonneg _)).trans_eq (mul_assoc _ _ _)_ = L*(∫ ω, |e ω| * |b ω| ∂μ) := integral_const_mul _ __ ≤ L*(Real.sqrt (∫ ω, (e ω)^2 ∂μ)*Real.sqrt (∫ ω, (b ω)^2 ∂μ)) := byhave hcs := integral_product_CS he.abs hb.abschange |∫ ω, |e ω| * |b ω| ∂μ|≤Real.sqrt (∫ ω, |e ω|^2 ∂μ)*Real.sqrt (∫ ω, |b ω|^2 ∂μ) at hcssimp only [sq_abs] at hcsexact mul_le_mul_of_nonneg_left ((le_abs_self _).trans hcs) hL_ = _ := by ringlemma brownian_eval_second_moment {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ) (t : ℝ≥0) :(∫ ω, (B t ω)^2 ∂μ)=(t : ℝ) := byhave hv := (hB.hasLaw_eval t).variance_eqrw [variance_eq_integral (hB.aemeasurable t), hB.integral_eval t] at hvsimpa using hvnoncomputable def meshBrownian (T : ℝ) (N : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=∑ j : Fin N, Real.sqrt (stepSize T N)*coordinate N j zlemma meshBrownian_measurable (T : ℝ) (N : ℕ) : Measurable (meshBrownian T N) := byapply Finset.measurable_sumintro i _exact measurable_const.mul (measurable_coordinate N i)lemma meshBrownian_memLp (T : ℝ) (N : ℕ) :MemLp (meshBrownian T N) 2 (gaussianProduct (Fin (N+1))) := byconvert memLp_finsetSum' Finset.univ (fun i : Fin N ↦ fun _ ↦(gaussian_memLp (coordinate_hasLaw N i) 2 (by norm_num)).const_mul (Real.sqrt (stepSize T N))) using 1funext zsimp only [meshBrownian, Finset.sum_apply]lemma coupled_meshBrownian {Ω : Type*} (B : ℝ≥0 → Ω → ℝ) {T : ℝ} (hT : 0<T){N : ℕ} (hN : 0<N) (ω : Ω) :meshBrownian T N (coupledCoordinates T N B ω)=B (Real.toNNReal T) ω-B 0 ω := byhave hlast : (N : ℝ)*(T/N)=T := by field_simpunfold meshBrownianhave heq (j : Fin N) := coupled_coordinate_exact B hT hN (show (j : ℕ)<N+1 by omega) ωsimp_rw [stepSize, heq]rw [Fin.sum_univ_eq_sum_range (fun j ↦ B (Real.toNNReal (((j+1 : ℕ) : ℝ)*(T/N))) ω-B (Real.toNNReal ((j : ℝ)*(T/N))) ω), Finset.sum_range_sub (fun j : ℕ ↦ B (Real.toNNReal ((j : ℝ)*(T/N))) ω) N]simp only [Nat.cast_zero, zero_mul, Real.toNNReal_zero, hlast]lemma meshBrownian_second_moment {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ) {T : ℝ} (hT : 0<T){N : ℕ} (hN : 0<N) :(∫ z, (meshBrownian T N z)^2 ∂gaussianProduct (Fin (N+1)))=T := byrw [←(coupledCoordinates_hasLaw hB hT hN).integral_comp((meshBrownian_measurable T N).pow_const 2).aestronglyMeasurable]have heq : (fun ω ↦ (meshBrownian T N (coupledCoordinates T N B ω))^2)=ᵐ[μ](fun ω ↦ (B (Real.toNNReal T) ω)^2) := byfilter_upwards [hB.eval_zero_ae_eq_zero] with ω hωsimp only [coupled_meshBrownian B hT hN ω, hω, sub_zero]exact (integral_congr_ae heq).trans ((brownian_eval_second_moment hB _).trans(Real.coe_toNNReal _ hT.le))lemma mesh_terminal_brownian_error {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ){T K L D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0<T) (h : GradientStrip T γ u K L)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D) {N : ℕ} (hN : 0<N) :|(∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))-stepSize T N * ∑ i : Fin N, ∫ z, meshRaw T N γ u i z ∂gaussianProduct (Fin (N+1))| ≤Real.sqrt (gradientMeshError T N γ u)*Real.sqrt T := byhave hm (i : Fin N) := mesh_raw_measurable hT.le h hN i.isLt.lehave hp (i : Fin N) := mesh_raw_depends T i.isLt.le γ uhave hH (i : Fin N) := mesh_raw_memLp hT.le h hD hN i.isLt.lehave hu := mesh_terminal_memLp hT.le h hNhave hr := finiteRaw_memLp (δ := stepSize T N) hm hp hHhave hb := meshBrownian_memLp T Nrw [←finiteRaw_brownian_covariance (δ := stepSize T N) (div_nonneg hT.le (Nat.cast_nonneg N)) hm hp hH]change |(∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))-(∫ z, finiteRawMartingale (stepSize T N) (fun i : Fin N ↦ meshRaw T N γ u i) z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))|≤_rw [←integral_sub (f := fun z ↦ meshTerminal T N γ u z * meshBrownian T N z)(g := fun z ↦ finiteRawMartingale (stepSize T N) (fun i : Fin N ↦ meshRaw T N γ u i) z * meshBrownian T N z)(hu.integrable_mul hb) (hr.integrable_mul hb)]simp_rw [←sub_mul]have hcs := integral_product_CS (hu.sub hr) hbrw [meshBrownian_second_moment hB hT hN] at hcsexact hcslemma coupled_terminal_brownian_error {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}[IsProbabilityMeasure μ] {B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ){X : ℝ → Ω → ℝ} {T K L Lu : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0<T) (h : GradientStrip T γ u K L) (hLu : 0≤Lu)(huLip : ∀ x y, |u T x-u T y|≤Lu*|x-y|)(hXM : ∀ t∈Icc (0 : ℝ) T, AEStronglyMeasurable (X t) μ)(hpaths : ∀ᵐ ω ∂μ,(∀ t∈Icc (0 : ℝ) T, X t ω=B (Real.toNNReal t) ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) ∧ X 0 ω=0){N : ℕ} (hN : 0<N) :|(∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))-(∫ ω, u T (X T ω)*B (Real.toNNReal T) ω ∂μ)| ≤Lu*Real.sqrt (∫ ω, (meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ)*Real.sqrt T := bylet F (ω : Ω) := u T (coupledEuler T γ u B N N ω)let G (ω : Ω) := u T (X T ω)let E := meshMaxError T X (coupledEuler T γ u B) Nhave ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩have hd := (h.smooth T ht).continuoushave hFM : MemLp F 2 μ := MemLp.of_bound(hd.measurable.comp_aemeasurable (coupled_euler_measurable hB hT h N N le_rfl).aemeasurable).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs, F] using h.bounded T ht _))have hGM : MemLp G 2 μ := MemLp.of_bound(hd.measurable.comp_aemeasurable (hXM T ht).aemeasurable).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs, G] using h.bounded T ht _))have hEM : MemLp E 2 μ := coupled_mesh_error_memLp hB hT h hXM hpaths hNhave hlast : meshTime T N N = T := by dsimp [meshTime, stepSize]; field_simphave hFG (ω : Ω) : |F ω-G ω|≤Lu*|E ω| := byhave he : |coupledEuler T γ u B N N ω-X T ω|≤E ω := bychange |coupledEuler T γ u B N N ω-X T ω| ≤ initialMax _ Nhave hm := le_initialMax (f := fun k ↦ |coupledEuler T γ u B N k ω-X (meshTime T N k) ω|) (le_refl N)rw [hlast] at hmexact hmexact (huLip _ _).trans (mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) hLu)have hlaw := coupledCoordinates_hasLaw hB hT hNhave heq : (∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))=∫ ω, F ω*B (Real.toNNReal T) ω ∂μ := byhave hm : AEStronglyMeasurable (fun z ↦ meshTerminal T N γ u z * meshBrownian T N z) (gaussianProduct (Fin (N+1))) :=((mesh_terminal_measurable hT.le h hN).mul (meshBrownian_measurable T N)).aestronglyMeasurablerw [←hlaw.integral_comp hm]apply integral_congr_aefilter_upwards [hB.eval_zero_ae_eq_zero] with ω hωsimp only [Function.comp_apply, F, meshTerminal, coupledEuler, ite_eq_right (Nat.ne_of_gt hN),coupled_meshBrownian B hT hN ω, hω, sub_zero]rw [heq]have hh := weighted_first_moment_perturbation hFM hGM hEM (hB.hasLaw_eval T.toNNReal).hasGaussianLaw.memLp_two hLu(Eventually.of_forall hFG)rw [brownian_eval_second_moment hB,Real.coe_toNNReal _ hT.le] at hhexact hhtheorem diffusion_gradient_brownian_covariance{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ){X : ℝ → Ω → ℝ} {T K L D Lu La : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0<T) (hT1 : T≤1) (h : GradientStrip T γ u K L)(hD0 : 0≤D) (hLu : 0≤Lu) (hLa : 0≤La)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D)(huLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(haLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|deriv (u s) x-deriv (u t) y|≤La*(|s-t|+|x-y|))(hXM : ∀ t∈Icc (0 : ℝ) T, AEStronglyMeasurable (X t) μ)(hpaths : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t∈Icc (0 : ℝ) T, X t ω = B (Real.toNNReal t) ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) ∧ X 0 ω=0) :(∫ ω, u T (X T ω)*B (Real.toNNReal T) ω ∂μ) =∫ t in (0 : ℝ)..T, ∫ ω, deriv (u t) (X t ω) ∂μ := bylet E (N : ℕ) := ∫ ω, (meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μhave hE : Tendsto E atTop (𝓝 0) := coupled_euler_L2_convergence hB hT h hLu huLip hXM hpathshave hEs : Tendsto (fun N ↦ Real.sqrt (E N)) atTop (𝓝 0) := bysimpa only [Real.sqrt_zero, Function.comp_def] using (Real.continuous_sqrt.tendsto 0).comp hEhave ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩have hcovariance : Tendsto (fun N ↦ ∫ z, meshTerminal T N γ u z * meshBrownian T N z∂gaussianProduct (Fin (N+1))) atTop(𝓝 (∫ ω, u T (X T ω)*B T.toNNReal ω ∂μ)) := byapply tendsto_iff_norm_sub_tendsto_zero.mprapply squeeze_zero' (Eventually.of_forall (fun _ ↦ norm_nonneg _)) ?_(by simpa only [mul_zero, zero_mul] using (hEs.const_mul Lu).mul_const (Real.sqrt T))filter_upwards [eventually_gt_atTop 0] with N hNrw [Real.norm_eq_abs]exact coupled_terminal_brownian_error hB hT h hLu(fun x y ↦ by simpa only [sub_self, abs_zero, zero_add] using huLip T ht T ht x y)hXM (hpaths.mono (fun _ hω ↦ hω.2.2)) hNhave hmean := mean_derivative_continuous hLa(fun t ht ↦ (h.smooth t ht).continuous_deriv (by norm_num)) hD haLip hXM(hpaths.mono (fun _ hω ↦ hω.1))have hquadrature : Tendsto (fun N ↦ stepSize T N * ∑ i : Fin N,∫ z, meshRaw T N γ u i z ∂gaussianProduct (Fin (N+1))) atTop(𝓝 (∫ t in (0 : ℝ)..T, ∫ ω, deriv (u t) (X t ω) ∂μ)) := byapply perturbed_grid_riemann_tendsto (r := fun N ↦ La*Real.sqrt (E N)) hT hmean(by simpa only [mul_zero] using hEs.const_mul La)filter_upwards [eventually_gt_atTop 0] with N hN iexact (coupled_mesh_general_moment_bounds hB hT h hD0 hLa hD(fun t ht x y ↦ by simpa only [sub_self, abs_zero, zero_add] using haLip t ht t ht x y)hXM (hpaths.mono (fun _ hω ↦ hω.2.2)) hN i).2have herror : Tendsto (fun N ↦(∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))-stepSize T N * ∑ i : Fin N, ∫ z, meshRaw T N γ u i z ∂gaussianProduct (Fin (N+1)))atTop (𝓝 0) := byapply squeeze_zero_norm' (a := fun N ↦Real.sqrt (gradientMeshError T N γ u) * Real.sqrt T)· filter_upwards [eventually_gt_atTop 0] with N hNrw [Real.norm_eq_abs]exact mesh_terminal_brownian_error hB hT h hD hN· simpa only [Real.sqrt_zero, zero_mul, Function.comp_def] using((Real.continuous_sqrt.tendsto 0).comp (gradientMeshError_tendsto_zero hT hT1 h)).mul_const(Real.sqrt T)have hlimit := herror.add hquadraturesimp only [sub_add_cancel, zero_add] at hlimitexact tendsto_nhds_unique hcovariance hlimitend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343import Mathlibimport OAI.Probability.SKValue.Evolution.MeanDerivativeContinuousimport OAI.Probability.SKValue.Equations.RawIncrementnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology BigOperatorslemma coupled_terminal_second_moment_bound {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}[IsProbabilityMeasure μ] {B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ){X : ℝ → Ω → ℝ} {T K L Lu : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0<T) (h : GradientStrip T γ u K L) (hLu : 0≤Lu)(huLip : ∀ x y, |u T x-u T y|≤Lu*|x-y|)(hXM : ∀ t∈Icc (0 : ℝ) T, AEStronglyMeasurable (X t) μ)(hpaths : ∀ᵐ ω ∂μ,(∀ t∈Icc (0 : ℝ) T, X t ω=B (Real.toNNReal t) ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) ∧ X 0 ω=0){N : ℕ} (hN : 0<N) :|(∫ z, (meshTerminal T N γ u z)^2 ∂gaussianProduct (Fin (N+1)))-(∫ ω, (u T (X T ω))^2 ∂μ)| ≤(2*Lu)*Real.sqrt (∫ ω, (meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ) := bylet F (ω : Ω) := u T (coupledEuler T γ u B N N ω)let G (ω : Ω) := u T (X T ω)let E := meshMaxError T X (coupledEuler T γ u B) Nhave ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩have hd := (h.smooth T ht).continuoushave hFM : MemLp F 2 μ := MemLp.of_bound(hd.measurable.comp_aemeasurable (coupled_euler_measurable hB hT h N N le_rfl).aemeasurable).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs, F] using h.bounded T ht _))have hGM : MemLp G 2 μ := MemLp.of_bound(hd.measurable.comp_aemeasurable (hXM T ht).aemeasurable).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs, G] using h.bounded T ht _))have hEM : MemLp E 2 μ := coupled_mesh_error_memLp hB hT h hXM hpaths hNhave hlast : meshTime T N N = T := by dsimp [meshTime, stepSize]; field_simphave hFG (ω : Ω) : |F ω-G ω|≤Lu*|E ω| := byhave he : |coupledEuler T γ u B N N ω-X T ω|≤E ω := bychange |coupledEuler T γ u B N N ω-X T ω| ≤ initialMax _ Nhave hm := le_initialMax (f := fun k ↦ |coupledEuler T γ u B N k ω-X (meshTime T N k) ω|) (le_refl N)change |coupledEuler T γ u B N N ω-X (meshTime T N N) ω| ≤ initialMax _ N at hmrw [hlast] at hmexact hmexact (huLip _ _).trans (mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) hLu)have hlaw := coupledCoordinates_hasLaw hB hT hNhave heq : (∫ z, (meshTerminal T N γ u z)^2 ∂gaussianProduct (Fin (N+1)))=∫ ω, (F ω)^2 ∂μ := byrw [←hlaw.integral_comp ((mesh_terminal_measurable hT.le h hN).pow_const 2).aestronglyMeasurable]simp only [Function.comp_apply, F, meshTerminal, coupledEuler, ite_eq_right (Nat.ne_of_gt hN)]rw [heq]simpa only [mul_one] using second_moment_perturbation hFM hGM hEM (by norm_num : (0 : ℝ)≤1) hLu(Eventually.of_forall (fun ω ↦ ⟨h.bounded T ht _, h.bounded T ht _, hFG ω⟩))theorem diffusion_gradient_isometry{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ){X : ℝ → Ω → ℝ} {T K L D Lu La : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0<T) (hT1 : T≤1) (h : GradientStrip T γ u K L)(hD0 : 0≤D) (hLu : 0≤Lu) (hLa : 0≤La)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D)(huLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(haLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|deriv (u s) x-deriv (u t) y|≤La*(|s-t|+|x-y|))(hXM : ∀ t∈Icc (0 : ℝ) T, AEStronglyMeasurable (X t) μ)(hpaths : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ��) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t∈Icc (0 : ℝ) T, X t ω = B (Real.toNNReal t) ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) ∧ X 0 ω=0) :(∫ ω, (u T (X T ω))^2 ∂μ) =∫ t in (0 : ℝ)..T, ∫ ω, (deriv (u t) (X t ω))^2 ∂μ := bylet E (N : ℕ) := ∫ ω, (meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μhave hE : Tendsto E atTop (𝓝 0) := coupled_euler_L2_convergence hB hT h hLu huLip hXM hpathshave hEs : Tendsto (fun N ↦ Real.sqrt (E N)) atTop (𝓝 0) := bysimpa only [Real.sqrt_zero, Function.comp_def] using (Real.continuous_sqrt.tendsto 0).comp hEhave ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩have hmoment : Tendsto (fun N ↦ ∫ z, (meshTerminal T N γ u z)^2 ∂gaussianProduct (Fin (N+1)))atTop (𝓝 (∫ ω, (u T (X T ω))^2 ∂μ)) := byapply tendsto_iff_norm_sub_tendsto_zero.mprapply squeeze_zero' (Eventually.of_forall (fun _ ↦ norm_nonneg _)) ?_(by simpa only [mul_zero] using hEs.const_mul (2*Lu))filter_upwards [eventually_gt_atTop 0] with N hNrw [Real.norm_eq_abs]exact coupled_terminal_second_moment_bound hB hT h hLu(fun x y ↦ by simpa only [sub_self, abs_zero, zero_add] using huLip T ht T ht x y)hXM (hpaths.mono (fun _ hω ↦ hω.2.2)) hNhave hmean := mean_derivative_square_continuous hD0 hLa(fun t ht ↦ (h.smooth t ht).continuous_deriv (by norm_num)) hD haLip hXM(hpaths.mono (fun _ hω ↦ hω.1))have hquadrature : Tendsto (fun N ↦ stepSize T N * ∑ i : Fin N,∫ z, (meshRaw T N γ u i z)^2 ∂gaussianProduct (Fin (N+1))) atTop(𝓝 (∫ t in (0 : ℝ)..T, ∫ ω, (deriv (u t) (X t ω))^2 ∂μ)) := byapply perturbed_grid_riemann_tendsto (r := fun N ↦ (2*D*La)*Real.sqrt (E N)) hT hmean(by simpa only [mul_zero] using hEs.const_mul (2*D*La))filter_upwards [eventually_gt_atTop 0] with N hN iexact (coupled_mesh_general_moment_bounds hB hT h hD0 hLa hD(fun t ht x y ↦ by simpa only [sub_self, abs_zero, zero_add] using haLip t ht t ht x y)hXM (hpaths.mono (fun _ hω ↦ hω.2.2)) hN i).1have herror : Tendsto (fun N ↦(∫ z, (meshTerminal T N γ u z)^2 ∂gaussianProduct (Fin (N+1)))-stepSize T N * ∑ i : Fin N, ∫ z, (meshRaw T N γ u i z)^2 ∂gaussianProduct (Fin (N+1)))atTop (𝓝 0) := byapply squeeze_zero_norm' (a := fun N ↦Real.sqrt (gradientMeshError T N γ u) * Real.sqrt (2*(1+T*D^2)))· filter_upwards [eventually_gt_atTop 0] with N hNrw [Real.norm_eq_abs]exact mesh_terminal_stochastic_second_moment_error hT h hD0 hD hN· simpa only [Real.sqrt_zero, zero_mul, Function.comp_def] using((Real.continuous_sqrt.tendsto 0).comp (gradientMeshError_tendsto_zero hT hT1 h)).mul_const(Real.sqrt (2*(1+T*D^2)))have hlimit := herror.add hquadraturesimp only [sub_add_cancel, zero_add] at hlimitexact tendsto_nhds_unique hmoment hlimitlemma weighted_first_moment_perturbation {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}{f g e b : Ω → ℝ} {L : ℝ} (hf : MemLp f 2 μ) (hg : MemLp g 2 μ)(he : MemLp e 2 μ) (hb : MemLp b 2 μ) (hL : 0≤L)(hfg : ∀ᵐ ω ∂μ, |f ω-g ω|≤L*|e ω|) :|(∫ ω, f ω*b ω ∂μ)-(∫ ω, g ω*b ω ∂μ)| ≤L*Real.sqrt (∫ ω, (e ω)^2 ∂μ)*Real.sqrt (∫ ω, (b ω)^2 ∂μ) := byrw [←integral_sub (f := fun ω ↦ f ω*b ω) (g := fun ω ↦ g ω*b ω) (hf.integrable_mul hb) (hg.integrable_mul hb)]have heq : (fun ω ↦ f ω*b ω-g ω*b ω)=(fun ω ↦ (f ω-g ω)*b ω) := by funext ω; ringrw [heq]calc_ ≤ ∫ ω, |(f ω-g ω)*b ω| ∂μ := abs_integral_le_integral_abs_ ≤ ∫ ω, L*(|e ω| * |b ω|) ∂μ := byapply integral_mono_ae ((hf.sub hg).integrable_mul hb).abs ((he.abs.integrable_mul hb.abs).const_mul L)filter_upwards [hfg] with ω hωchange |(f ω-g ω)*b ω| ≤ L*(|e ω| * |b ω|)rw [abs_mul]exact (mul_le_mul_of_nonneg_right hω (abs_nonneg _)).trans_eq (mul_assoc _ _ _)_ = L*(∫ ω, |e ω| * |b ω| ∂μ) := integral_const_mul _ __ ≤ L*(Real.sqrt (∫ ω, (e ω)^2 ∂μ)*Real.sqrt (∫ ω, (b ω)^2 ∂μ)) := byhave hcs := integral_product_CS he.abs hb.abschange |∫ ω, |e ω| * |b ω| ∂μ|≤Real.sqrt (∫ ω, |e ω|^2 ∂μ)*Real.sqrt (∫ ω, |b ω|^2 ∂μ) at hcssimp only [sq_abs] at hcsexact mul_le_mul_of_nonneg_left ((le_abs_self _).trans hcs) hL_ = _ := by ringlemma brownian_eval_second_moment {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ) (t : ℝ≥0) :(∫ ω, (B t ω)^2 ∂μ)=(t : ℝ) := byhave hv := (hB.hasLaw_eval t).variance_eqrw [variance_eq_integral (hB.aemeasurable t), hB.integral_eval t] at hvsimpa using hvnoncomputable def meshBrownian (T : ℝ) (N : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=∑ j : Fin N, Real.sqrt (stepSize T N)*coordinate N j zlemma meshBrownian_measurable (T : ℝ) (N : ℕ) : Measurable (meshBrownian T N) := byapply Finset.measurable_sumintro i _exact measurable_const.mul (measurable_coordinate N i)lemma meshBrownian_memLp (T : ℝ) (N : ℕ) :MemLp (meshBrownian T N) 2 (gaussianProduct (Fin (N+1))) := byconvert memLp_finsetSum' Finset.univ (fun i : Fin N ↦ fun _ ↦(gaussian_memLp (coordinate_hasLaw N i) 2 (by norm_num)).const_mul (Real.sqrt (stepSize T N))) using 1funext zsimp only [meshBrownian, Finset.sum_apply]lemma coupled_meshBrownian {Ω : Type*} (B : ℝ≥0 → Ω → ℝ) {T : ℝ} (hT : 0<T){N : ℕ} (hN : 0<N) (ω : Ω) :meshBrownian T N (coupledCoordinates T N B ω)=B (Real.toNNReal T) ω-B 0 ω := byhave hlast : (N : ℝ)*(T/N)=T := by field_simpunfold meshBrownianhave heq (j : Fin N) := coupled_coordinate_exact B hT hN (show (j : ℕ)<N+1 by omega) ωsimp_rw [stepSize, heq]rw [Fin.sum_univ_eq_sum_range (fun j ↦ B (Real.toNNReal (((j+1 : ℕ) : ℝ)*(T/N))) ω-B (Real.toNNReal ((j : ℝ)*(T/N))) ω), Finset.sum_range_sub (fun j : ℕ ↦ B (Real.toNNReal ((j : ℝ)*(T/N))) ω) N]simp only [Nat.cast_zero, zero_mul, Real.toNNReal_zero, hlast]lemma meshBrownian_second_moment {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ) {T : ℝ} (hT : 0<T){N : ℕ} (hN : 0<N) :(∫ z, (meshBrownian T N z)^2 ∂gaussianProduct (Fin (N+1)))=T := byrw [←(coupledCoordinates_hasLaw hB hT hN).integral_comp((meshBrownian_measurable T N).pow_const 2).aestronglyMeasurable]have heq : (fun ω ↦ (meshBrownian T N (coupledCoordinates T N B ω))^2)=ᵐ[μ](fun ω ↦ (B (Real.toNNReal T) ω)^2) := byfilter_upwards [hB.eval_zero_ae_eq_zero] with ω hωsimp only [coupled_meshBrownian B hT hN ω, hω, sub_zero]exact (integral_congr_ae heq).trans ((brownian_eval_second_moment hB _).trans(Real.coe_toNNReal _ hT.le))lemma mesh_terminal_brownian_error {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ){T K L D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0<T) (h : GradientStrip T γ u K L)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D) {N : ℕ} (hN : 0<N) :|(∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))-stepSize T N * ∑ i : Fin N, ∫ z, meshRaw T N γ u i z ∂gaussianProduct (Fin (N+1))| ≤Real.sqrt (gradientMeshError T N γ u)*Real.sqrt T := byhave hm (i : Fin N) := mesh_raw_measurable hT.le h hN i.isLt.lehave hp (i : Fin N) := mesh_raw_depends T i.isLt.le γ uhave hH (i : Fin N) := mesh_raw_memLp hT.le h hD hN i.isLt.lehave hu := mesh_terminal_memLp hT.le h hNhave hr := finiteRaw_memLp (δ := stepSize T N) hm hp hHhave hb := meshBrownian_memLp T Nrw [←finiteRaw_brownian_covariance (δ := stepSize T N) (div_nonneg hT.le (Nat.cast_nonneg N)) hm hp hH]change |(∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))-(∫ z, finiteRawMartingale (stepSize T N) (fun i : Fin N ↦ meshRaw T N γ u i) z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))|≤_rw [←integral_sub (f := fun z ↦ meshTerminal T N γ u z * meshBrownian T N z)(g := fun z ↦ finiteRawMartingale (stepSize T N) (fun i : Fin N ↦ meshRaw T N γ u i) z * meshBrownian T N z)(hu.integrable_mul hb) (hr.integrable_mul hb)]simp_rw [←sub_mul]have hcs := integral_product_CS (hu.sub hr) hbrw [meshBrownian_second_moment hB hT hN] at hcsexact hcslemma coupled_terminal_brownian_error {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}[IsProbabilityMeasure μ] {B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ){X : ℝ → Ω → ℝ} {T K L Lu : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0<T) (h : GradientStrip T γ u K L) (hLu : 0≤Lu)(huLip : ∀ x y, |u T x-u T y|≤Lu*|x-y|)(hXM : ∀ t∈Icc (0 : ℝ) T, AEStronglyMeasurable (X t) μ)(hpaths : ∀ᵐ ω ∂μ,(∀ t∈Icc (0 : ℝ) T, X t ω=B (Real.toNNReal t) ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) ∧ X 0 ω=0){N : ℕ} (hN : 0<N) :|(∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))-(∫ ω, u T (X T ω)*B (Real.toNNReal T) ω ∂μ)| ≤Lu*Real.sqrt (∫ ω, (meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ)*Real.sqrt T := bylet F (ω : Ω) := u T (coupledEuler T γ u B N N ω)let G (ω : Ω) := u T (X T ω)let E := meshMaxError T X (coupledEuler T γ u B) Nhave ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩have hd := (h.smooth T ht).continuoushave hFM : MemLp F 2 μ := MemLp.of_bound(hd.measurable.comp_aemeasurable (coupled_euler_measurable hB hT h N N le_rfl).aemeasurable).aestronglyMeasurable 1(Eventually.of_forall (fun �� ↦ by simpa only [Real.norm_eq_abs, F] using h.bounded T ht _))have hGM : MemLp G 2 μ := MemLp.of_bound(hd.measurable.comp_aemeasurable (hXM T ht).aemeasurable).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs, G] using h.bounded T ht _))have hEM : MemLp E 2 μ := coupled_mesh_error_memLp hB hT h hXM hpaths hNhave hlast : meshTime T N N = T := by dsimp [meshTime, stepSize]; field_simphave hFG (ω : Ω) : |F ω-G ω|≤Lu*|E ω| := byhave he : |coupledEuler T γ u B N N ω-X T ω|≤E ω := bychange |coupledEuler T γ u B N N ω-X T ω| ≤ initialMax _ Nhave hm := le_initialMax (f := fun k ↦ |coupledEuler T γ u B N k ω-X (meshTime T N k) ω|) (le_refl N)rw [hlast] at hmexact hmexact (huLip _ _).trans (mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) hLu)have hlaw := coupledCoordinates_hasLaw hB hT hNhave heq : (∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))=∫ ω, F ω*B (Real.toNNReal T) ω ∂μ := byhave hm : AEStronglyMeasurable (fun z ↦ meshTerminal T N γ u z * meshBrownian T N z) (gaussianProduct (Fin (N+1))) :=((mesh_terminal_measurable hT.le h hN).mul (meshBrownian_measurable T N)).aestronglyMeasurablerw [←hlaw.integral_comp hm]apply integral_congr_aefilter_upwards [hB.eval_zero_ae_eq_zero] with ω hωsimp only [Function.comp_apply, F, meshTerminal, coupledEuler, ite_eq_right (Nat.ne_of_gt hN),coupled_meshBrownian B hT hN ω, hω, sub_zero]rw [heq]have hh := weighted_first_moment_perturbation hFM hGM hEM (hB.hasLaw_eval T.toNNReal).hasGaussianLaw.memLp_two hLu(Eventually.of_forall hFG)rw [brownian_eval_second_moment hB,Real.coe_toNNReal _ hT.le] at hhexact hhtheorem diffusion_gradient_brownian_covariance{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ){X : ℝ → Ω → ℝ} {T K L D Lu La : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0<T) (hT1 : T≤1) (h : GradientStrip T γ u K L)(hD0 : 0≤D) (hLu : 0≤Lu) (hLa : 0≤La)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D)(huLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(haLip : ∀ s∈Icc (0 : ℝ) T, ∀ t∈Icc (0 : ℝ) T, ∀ x y,|deriv (u s) x-deriv (u t) y|≤La*(|s-t|+|x-y|))(hXM : ∀ t∈Icc (0 : ℝ) T, AEStronglyMeasurable (X t) μ)(hpaths : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t∈Icc (0 : ℝ) T, X t ω = B (Real.toNNReal t) ω+∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) ∧ X 0 ω=0) :(∫ ω, u T (X T ω)*B (Real.toNNReal T) ω ∂μ) =∫ t in (0 : ℝ)..T, ∫ ω, deriv (u t) (X t ω) ∂μ := bylet E (N : ℕ) := ∫ ω, (meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μhave hE : Tendsto E atTop (𝓝 0) := coupled_euler_L2_convergence hB hT h hLu huLip hXM hpathshave hEs : Tendsto (fun N ↦ Real.sqrt (E N)) atTop (𝓝 0) := bysimpa only [Real.sqrt_zero, Function.comp_def] using (Real.continuous_sqrt.tendsto 0).comp hEhave ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩have hcovariance : Tendsto (fun N ↦ ∫ z, meshTerminal T N γ u z * meshBrownian T N z∂gaussianProduct (Fin (N+1))) atTop(𝓝 (∫ ω, u T (X T ω)*B T.toNNReal ω ∂μ)) := byapply tendsto_iff_norm_sub_tendsto_zero.mprapply squeeze_zero' (Eventually.of_forall (fun _ ↦ norm_nonneg _)) ?_(by simpa only [mul_zero, zero_mul] using (hEs.const_mul Lu).mul_const (Real.sqrt T))filter_upwards [eventually_gt_atTop 0] with N hNrw [Real.norm_eq_abs]exact coupled_terminal_brownian_error hB hT h hLu(fun x y ↦ by simpa only [sub_self, abs_zero, zero_add] using huLip T ht T ht x y)hXM (hpaths.mono (fun _ hω ↦ hω.2.2)) hNhave hmean := mean_derivative_continuous hLa(fun t ht ↦ (h.smooth t ht).continuous_deriv (by norm_num)) hD haLip hXM(hpaths.mono (fun _ hω ↦ hω.1))have hquadrature : Tendsto (fun N ↦ stepSize T N * ∑ i : Fin N,∫ z, meshRaw T N γ u i z ∂gaussianProduct (Fin (N+1))) atTop(𝓝 (∫ t in (0 : ℝ)..T, ∫ ω, deriv (u t) (X t ω) ∂μ)) := byapply perturbed_grid_riemann_tendsto (r := fun N ↦ La*Real.sqrt (E N)) hT hmean(by simpa only [mul_zero] using hEs.const_mul La)filter_upwards [eventually_gt_atTop 0] with N hN iexact (coupled_mesh_general_moment_bounds hB hT h hD0 hLa hD(fun t ht x y ↦ by simpa only [sub_self, abs_zero, zero_add] using haLip t ht t ht x y)hXM (hpaths.mono (fun _ hω ↦ hω.2.2)) hN i).2have herror : Tendsto (fun N ↦(∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))-stepSize T N * ∑ i : Fin N, ∫ z, meshRaw T N γ u i z ∂gaussianProduct (Fin (N+1)))atTop (𝓝 0) := byapply squeeze_zero_norm' (a := fun N ↦Real.sqrt (gradientMeshError T N γ u) * Real.sqrt T)· filter_upwards [eventually_gt_atTop 0] with N hNrw [Real.norm_eq_abs]exact mesh_terminal_brownian_error hB hT h hD hN· simpa only [Real.sqrt_zero, zero_mul, Function.comp_def] using((Real.continuous_sqrt.tendsto 0).comp (gradientMeshError_tendsto_zero hT hT1 h)).mul_const(Real.sqrt T)have hlimit := herror.add hquadraturesimp only [sub_add_cancel, zero_add] at hlimitexact tendsto_nhds_unique hcovariance hlimitend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687import Mathlibimport OAI.Probability.SKValue.Equations.InitialMaxnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValuenoncomputable def meshMaxError {Ω : Type*} (T : ℝ) (X : ℝ → Ω → ℝ)(Y : ℕ → ℕ → Ω → ℝ) (N : ℕ) (ω : Ω) : ℝ :=initialMax (fun j ↦ |Y N j ω-X ((j : ℝ)*(T/N)) ω|) Nlemma meshMaxError_nonneg {Ω : Type*} (T : ℝ) (X : ℝ → Ω → ℝ)(Y : ℕ → ℕ → Ω → ℝ) (N : ℕ) (ω : Ω) : 0 ≤ meshMaxError T X Y N ω :=(abs_nonneg _).trans (le_initialMax(f := fun j ↦ |Y N j ω-X ((j : ℝ)*(T/N)) ω|) (Nat.zero_le N))lemma driven_euler_L2_convergence {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}[IsFiniteMeasure μ] {T L : ℝ} {u : ℝ → ℝ → ℝ} {γ : ℝ → ℝ}{W X : ℝ → Ω → ℝ} {Y : ℕ → ℕ → Ω → ℝ}(hT : 0 ≤ T) (hL : 0 ≤ L)(hγ : MonotoneOn γ (Icc (0 : ℝ) T)) (hγ0 : 0 ≤ γ 0)(hu : ∀ t ∈ Icc (0 : ℝ) T, ∀ x, |u t x| ≤ 1)(hLip : ∀ s ∈ Icc (0 : ℝ) T, ∀ t ∈ Icc (0 : ℝ) T, ∀ x y,|u s x-u t y| ≤ L*(|s-t|+|x-y|))(hXM : ∀ t, AEStronglyMeasurable (X t) μ)(hYM : ∀ N j, AEStronglyMeasurable (Y N j) μ)(hpaths : ∀ᵐ ω ∂μ,ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t ∈ Icc (0 : ℝ) T,X t ω = W t ω + ∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) ∧ X 0 ω = 0)(hY0 : ∀ N ω, Y N 0 ω = 0)(hY : ∀ N > 0, ∀ j < N, ∀ ω,Y N (j+1) ω = Y N j ω + W (((j+1 : ℕ) : ℝ)*(T/N)) ω-W ((j : ℝ)*(T/N)) ω +(T/N)*γ ((j : ℝ)*(T/N))*u ((j : ℝ)*(T/N)) (Y N j ω)) :Tendsto (fun N ↦ ∫ ω, (meshMaxError T X Y N ω)^2 ∂μ) atTop (𝓝 (0 : ℝ)) := byhave hmeas : ∀ N, AEStronglyMeasurable (fun ω ↦ (meshMaxError T X Y N ω)^2) μ := byintro Nexact (aestronglyMeasurable_initialMax (fun j ↦ ((hYM N j).sub (hXM _)).norm) N).fun_pow 2have hbound : ∀ᶠ N in atTop, ∀ᵐ ω ∂μ,‖(meshMaxError T X Y N ω)^2‖ ≤ (2*T*γ T)^2 := byfilter_upwards [eventually_gt_atTop 0] with N hNfilter_upwards [hpaths] with ω hωhave hδ : 0 ≤ T/(N : ℝ) := div_nonneg hT (Nat.cast_nonneg _)have horizon : (N : ℝ)*(T/N) = T := by field_simphave H := driven_euler_uniform_bound (Y := fun j ↦ Y N j ω) hδ hT horizon hγ hγ0 hu hω.2.2.1 hω.2.2.2(hY0 N ω) (fun j hj ↦ hY N hN j hj ω)have he : meshMaxError T X Y N ω ≤ 2*T*γ T := initialMax_le_iff.mpr Hrw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)]exact pow_le_pow_left₀ (meshMaxError_nonneg T X Y N ω) he 2have hlim : ∀ᵐ ω ∂μ, Tendsto (fun N ↦ (meshMaxError T X Y N ω)^2) atTop (𝓝 (0 : ℝ)) := byfilter_upwards [hpaths] with ω hωhave H := driven_euler_uniform_convergence (Y := fun N j ↦ Y N j ω) hT hL hγ hγ0 hu hLip hω.1 hω.2.1 hω.2.2.1hω.2.2.2 (fun N ↦ hY0 N ω) (fun N hN j hj ↦ hY N hN j hj ω)have hzero : Tendsto (fun N ↦ meshMaxError T X Y N ω) atTop (𝓝 (0 : ℝ)) := byrw [Metric.tendsto_nhds]intro ε hεfilter_upwards [H ε hε] with N hNrw [Real.dist_eq,sub_zero,abs_of_nonneg (meshMaxError_nonneg T X Y N ω)]exact initialMax_lt_iff.mpr hNsimpa using hzero.pow 2have H := tendsto_integral_filter_of_dominated_convergence (fun _ : Ω ↦ (2*T*γ T)^2)(Eventually.of_forall hmeas) hbound (integrable_const _) hlimsimpa using Hend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687import Mathlibimport OAI.Probability.SKValue.Equations.InitialMaxnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValuenoncomputable def meshMaxError {Ω : Type*} (T : ���) (X : ℝ → Ω → ℝ)(Y : ℕ → ℕ → Ω → ℝ) (N : ℕ) (ω : Ω) : ℝ :=initialMax (fun j ↦ |Y N j ω-X ((j : ℝ)*(T/N)) ω|) Nlemma meshMaxError_nonneg {Ω : Type*} (T : ℝ) (X : ℝ → Ω → ℝ)(Y : ℕ → ℕ → Ω → ℝ) (N : ℕ) (ω : Ω) : 0 ≤ meshMaxError T X Y N ω :=(abs_nonneg _).trans (le_initialMax(f := fun j ↦ |Y N j ω-X ((j : ℝ)*(T/N)) ω|) (Nat.zero_le N))lemma driven_euler_L2_convergence {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}[IsFiniteMeasure μ] {T L : ℝ} {u : ℝ → ℝ → ℝ} {γ : ℝ → ℝ}{W X : ℝ → Ω → ℝ} {Y : ℕ → ℕ → Ω → ℝ}(hT : 0 ≤ T) (hL : 0 ≤ L)(hγ : MonotoneOn γ (Icc (0 : ℝ) T)) (hγ0 : 0 ≤ γ 0)(hu : ∀ t ∈ Icc (0 : ℝ) T, ∀ x, |u t x| ≤ 1)(hLip : ∀ s ∈ Icc (0 : ℝ) T, ∀ t ∈ Icc (0 : ℝ) T, ∀ x y,|u s x-u t y| ≤ L*(|s-t|+|x-y|))(hXM : ∀ t, AEStronglyMeasurable (X t) μ)(hYM : ∀ N j, AEStronglyMeasurable (Y N j) μ)(hpaths : ∀ᵐ ω ∂μ,ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t ∈ Icc (0 : ℝ) T,X t ω = W t ω + ∫ s in (0 : ℝ)..t, γ s*u s (X s ω)) ∧ X 0 ω = 0)(hY0 : ∀ N ω, Y N 0 ω = 0)(hY : ∀ N > 0, ∀ j < N, ∀ ω,Y N (j+1) ω = Y N j ω + W (((j+1 : ℕ) : ℝ)*(T/N)) ω-W ((j : ℝ)*(T/N)) ω +(T/N)*γ ((j : ℝ)*(T/N))*u ((j : ℝ)*(T/N)) (Y N j ω)) :Tendsto (fun N ↦ ∫ ω, (meshMaxError T X Y N ω)^2 ∂μ) atTop (𝓝 (0 : ℝ)) := byhave hmeas : ∀ N, AEStronglyMeasurable (fun ω ↦ (meshMaxError T X Y N ω)^2) μ := byintro Nexact (aestronglyMeasurable_initialMax (fun j ↦ ((hYM N j).sub (hXM _)).norm) N).fun_pow 2have hbound : ∀ᶠ N in atTop, ∀ᵐ ω ∂μ,‖(meshMaxError T X Y N ω)^2‖ ≤ (2*T*γ T)^2 := byfilter_upwards [eventually_gt_atTop 0] with N hNfilter_upwards [hpaths] with ω hωhave hδ : 0 ≤ T/(N : ℝ) := div_nonneg hT (Nat.cast_nonneg _)have horizon : (N : ℝ)*(T/N) = T := by field_simphave H := driven_euler_uniform_bound (Y := fun j ↦ Y N j ω) hδ hT horizon hγ hγ0 hu hω.2.2.1 hω.2.2.2(hY0 N ω) (fun j hj ↦ hY N hN j hj ω)have he : meshMaxError T X Y N ω ≤ 2*T*γ T := initialMax_le_iff.mpr Hrw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)]exact pow_le_pow_left₀ (meshMaxError_nonneg T X Y N ω) he 2have hlim : ∀ᵐ ω ∂μ, Tendsto (fun N ↦ (meshMaxError T X Y N ω)^2) atTop (𝓝 (0 : ℝ)) := byfilter_upwards [hpaths] with ω hωhave H := driven_euler_uniform_convergence (Y := fun N j ↦ Y N j ω) hT hL hγ hγ0 hu hLip hω.1 hω.2.1 hω.2.2.1hω.2.2.2 (fun N ↦ hY0 N ω) (fun N hN j hj ↦ hY N hN j hj ω)have hzero : Tendsto (fun N ↦ meshMaxError T X Y N ω) atTop (𝓝 (0 : ℝ)) := byrw [Metric.tendsto_nhds]intro ε hεfilter_upwards [H ε hε] with N hNrw [Real.dist_eq,sub_zero,abs_of_nonneg (meshMaxError_nonneg T X Y N ω)]exact initialMax_lt_iff.mpr hNsimpa using hzero.pow 2have H := tendsto_integral_filter_of_dominated_convergence (fun _ : Ω ↦ (2*T*γ T)^2)(Eventually.of_forall hmeas) hbound (integrable_const _) hlimsimpa using Hend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145import Mathlibimport OAI.Probability.SKValue.Equations.ShiftedPairingimport OAI.Probability.SKValue.Evolution.UniformGridRiemannBoundimport OAI.Probability.SKValue.Processes.MeshRawnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorslemma mesh_mean_bound {T D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D){N : ℕ} (hN : 0<N) {j : ℕ} (hj : j≤N) :|∫ z, meshRaw T N γ u j z ∂gaussianProduct (Fin (N+1))|≤D := byhave := gaussianProduct_probability (Fin (N+1))simpa [Real.norm_eq_abs] using(norm_integral_le_of_norm_le_const (μ := gaussianProduct (Fin (N+1)))(Eventually.of_forall (fun z ↦ show ‖meshRaw T N γ u j z‖≤D from bysimpa only [Real.norm_eq_abs, meshRaw] using hD _ (mesh_time_mem hT hN hj) _)))lemma product_perturbation_bound {a b f D r : ℝ} (hD : 0≤D) (_ : 0≤r)(ha : |a|≤D) (hb : |b-1|≤r) (hf : |a-f|≤r) : |a*b-f|≤(D+1)*r := bycalc|a*b-f| = |a*(b-1)+(a-f)| := by congr 1; ring_ ≤ |a*(b-1)|+|a-f| := abs_add_le _ __ ≤ D*r+r := byrw [abs_mul]exact add_le_add (mul_le_mul ha hb (abs_nonneg _) hD) hf_ = _ := by ringtheorem finiteGaussian_from_strip_and_moments{T K L D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ} {f : ℝ → ℝ} {r : ℕ → ℝ}(hT : 0<T) (hT1 : T≤1) (h : GradientStrip T γ u K L) (hD0 : 0≤D)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D)(hf : ContinuousOn f (Icc (0 : ℝ) T)) (hr : ∀ N, 0≤r N)(hr0 : Tendsto r atTop (𝓝 0))(hq : ∀ N, 0<N → ∀ j : Fin N,|(∫ z, (meshRaw T N γ u j z)^2 ∂gaussianProduct (Fin (N+1)))-1|≤r N)(hm : ∀ N, 0<N → ∀ j : Fin N,|(∫ z, meshRaw T N γ u j z ∂gaussianProduct (Fin (N+1)))-f (meshTime T N j)|≤r N) :(∀ᶠ N in atTop, ∀ j<N, 0<predictableNormalizer (meshRaw T N γ u j)(gaussianProduct (Fin (N+1)))) ∧Tendsto (fun N ↦ finiteShiftedValue T N γ u) atTop (𝓝 (∫ t in (0 : ℝ)..T, f t)) := bylet q (N j : ℕ) := ∫ z, (meshRaw T N γ u j z)^2 ∂gaussianProduct (Fin (N+1))have hqpos : ∀ᶠ N in atTop, ∀ j<N, 0<q N j :=uniform_moment_positive hr0 (fun N j hj ↦ hq N (by omega) ⟨j,hj⟩)constructor· filter_upwards [hqpos] with N hN j hjexact predictableNormalizer_pos (hN j hj)· let A (N : ℕ) (i : Fin (N+1)) := meshA T (N+1) γ u ilet B (N : ℕ) (i : Fin (N+1)) := meshB T (N+1) γ u ilet α (N : ℕ) (i : Fin (N+1)) := Real.sqrt (stepSize T (N+1))/predictableNormalizer (meshRaw T (N+1) γ u i) (gaussianProduct (Fin ((N+1)+1)))let β (N : ℕ) (i : Fin (N+1)) := Real.sqrt (stepSize T (N+1))*∫ z, meshRaw T (N+1) γ u i z ∂gaussianProduct (Fin ((N+1)+1))let bstar (N : ℕ) := meshB T (N+1) γ u (N+1)let e (N : ℕ) := gradientMeshError T (N+1) γ ulet rend (N : ℕ) := Real.sqrt (stepSize T (N+1))*Dhave hproj : ∀ᶠ N in atTop,(∑ i, (A N i-α N i)^2)≤e N ∧ (∑ i, (B N i-β N i)^2)≤e N := byfilter_upwards [(tendsto_add_atTop_nat 1).eventually hqpos] with N hNexact mesh_coefficient_errors hT.le h hD (Nat.succ_pos N) (fun i ↦ hN i i.isLt)have hnorm (N : ℕ) : (∑ i, (B N i)^2)≤1 ∧ |bstar N|≤1 :=mesh_coefficients_norms hT.le h (Nat.succ_pos N)have hαnorm (N : ℕ) : (∑ i, (α N i)^2)≤(Real.sqrt T*D)^2 :=mesh_leading_norm hT.le h hD0 hD (Nat.succ_pos N)have hend (N : ℕ) : |α N (Fin.last N)|≤rend N := byhave := gaussianProduct_probability (Fin ((N+1)+1))exact sqrt_div_normalizer_bound(mesh_raw_memLp hT.le h hD (Nat.succ_pos N) (Nat.le_succ N)) hD0(Eventually.of_forall (fun z ↦ hD _ (mesh_time_mem hT.le (Nat.succ_pos N) (Nat.le_succ N)) _))have he0 : Tendsto e atTop (𝓝 0) :=(gradientMeshError_tendsto_zero hT hT1 h).comp (tendsto_add_atTop_nat 1)have hδ0 : Tendsto (fun N : ℕ ↦ stepSize T (N+1)) atTop (𝓝 0) :=(tendsto_const_div_atTop_nhds_zero_nat T).comp (tendsto_add_atTop_nat 1)have hrend0 : Tendsto rend atTop (𝓝 0) := bysimpa only [rend, Function.comp_def, Real.sqrt_zero, zero_mul] using((Real.continuous_sqrt.tendsto 0).comp hδ0).mul_const Dhave herr := shiftedPairing_tendsto_error_zero(fun N ↦ gradientMeshError_nonneg T (N+1) γ u) (mul_nonneg (Real.sqrt_nonneg T) hD0)(hproj.mono (fun _ hN ↦ hN.1)) (hproj.mono (fun _ hN ↦ hN.2))(Eventually.of_forall (fun N ↦ (hnorm N).1)) (Eventually.of_forall hαnorm)(Eventually.of_forall (fun N ↦ (hnorm N).2)) (Eventually.of_forall hend) he0 hrend0let v (N : ℕ) (i : Fin N) :=(∫ z, meshRaw T (N+1) γ u (i+1) z ∂gaussianProduct (Fin ((N+1)+1)))*Real.sqrt (q (N+1) i)have hv (N : ℕ) (i : Fin N) :|v N i-f ((i+1 : ℕ)*(T/(N+1)))|≤(D+1)*r (N+1) := byapply product_perturbation_bound hD0 (hr (N+1))· exact mesh_mean_bound hT.le hD (Nat.succ_pos N) (by omega)· exact (abs_sqrt_sub_one_le (integral_nonneg (fun z ↦ sq_nonneg _))).trans(hq (N+1) (Nat.succ_pos N) i.castSucc)· simpa only [meshTime, stepSize, Fin.val_succ, Nat.cast_add, Nat.cast_one] usinghm (N+1) (Nat.succ_pos N) i.succhave hv0 : Tendsto (fun N ↦ (D+1)*r (N+1)) atTop (𝓝 0) := bysimpa only [mul_zero, Function.comp_def] using (hr0.comp (tendsto_add_atTop_nat 1)).const_mul (D+1)have hvlim := perturbed_shifted_grid_tendsto hT hf(fun N ↦ mul_nonneg (by positivity : 0≤D+1) (hr (N+1))) hv0 (Eventually.of_forall hv)have hsum (N : ℕ) : (∑ i : Fin N, α N i.castSucc*β N i.succ)=(T/(N+1))*∑ i : Fin N, v N i := byrw [Finset.mul_sum]apply Finset.sum_congr rflintro i _have hδ : 0 ≤ stepSize T (N+1) := div_nonneg hT.le (Nat.cast_nonneg _)dsimp only [α, β, v, q, predictableNormalizer]rw [div_inv_eq_mul]calc_ = (Real.sqrt (stepSize T (N+1)))^2 *((∫ z, meshRaw T (N+1) γ u (i+1) z ∂gaussianProduct (Fin ((N+1)+1)))*Real.sqrt (∫ z, (meshRaw T (N+1) γ u i z)^2 ∂gaussianProduct (Fin ((N+1)+1)))) := bysimp only [Fin.val_castSucc, Fin.val_succ]ring_ = _ := by rw [Real.sq_sqrt hδ]; simp only [stepSize, Nat.cast_add, Nat.cast_one]have hp (N : ℕ) : shiftedPairing (A N) (B N) (bstar N)=finiteShiftedValue T (N+1) γ u := bysimp only [shiftedPairing, finiteShiftedValue, A, B, bstar]rw [Fin.sum_univ_castSucc]simp only [Fin.val_castSucc, Fin.val_succ, Fin.val_last]simp_rw [hp, hsum] at herrhave hlim := herr.add hvlimsimp only [sub_add_cancel, zero_add] at hlimexact (tendsto_add_atTop_iff_nat 1).mp hlimend SKValueopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145import Mathlibimport OAI.Probability.SKValue.Equations.ShiftedPairingimport OAI.Probability.SKValue.Evolution.UniformGridRiemannBoundimport OAI.Probability.SKValue.Processes.MeshRawnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorslemma mesh_mean_bound {T D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D){N : ℕ} (hN : 0<N) {j : ℕ} (hj : j≤N) :|∫ z, meshRaw T N γ u j z ∂gaussianProduct (Fin (N+1))|≤D := byhave := gaussianProduct_probability (Fin (N+1))simpa [Real.norm_eq_abs] using(norm_integral_le_of_norm_le_const (μ := gaussianProduct (Fin (N+1)))(Eventually.of_forall (fun z ↦ show ‖meshRaw T N γ u j z‖≤D from bysimpa only [Real.norm_eq_abs, meshRaw] using hD _ (mesh_time_mem hT hN hj) _)))lemma product_perturbation_bound {a b f D r : ℝ} (hD : 0≤D) (_ : 0≤r)(ha : |a|≤D) (hb : |b-1|≤r) (hf : |a-f|≤r) : |a*b-f|≤(D+1)*r := bycalc|a*b-f| = |a*(b-1)+(a-f)| := by congr 1; ring_ ≤ |a*(b-1)|+|a-f| := abs_add_le _ __ ≤ D*r+r := byrw [abs_mul]exact add_le_add (mul_le_mul ha hb (abs_nonneg _) hD) hf_ = _ := by ringtheorem finiteGaussian_from_strip_and_moments{T K L D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ} {f : ℝ → ℝ} {r : ℕ → ℝ}(hT : 0<T) (hT1 : T≤1) (h : GradientStrip T γ u K L) (hD0 : 0≤D)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D)(hf : ContinuousOn f (Icc (0 : ℝ) T)) (hr : ∀ N, 0≤r N)(hr0 : Tendsto r atTop (𝓝 0))(hq : ∀ N, 0<N → ∀ j : Fin N,|(∫ z, (meshRaw T N γ u j z)^2 ∂gaussianProduct (Fin (N+1)))-1|≤r N)(hm : ∀ N, 0<N → ∀ j : Fin N,|(∫ z, meshRaw T N γ u j z ∂gaussianProduct (Fin (N+1)))-f (meshTime T N j)|≤r N) :(∀ᶠ N in atTop, ∀ j<N, 0<predictableNormalizer (meshRaw T N γ u j)(gaussianProduct (Fin (N+1)))) ∧Tendsto (fun N ↦ finiteShiftedValue T N γ u) atTop (𝓝 (∫ t in (0 : ℝ)..T, f t)) := bylet q (N j : ℕ) := ∫ z, (meshRaw T N γ u j z)^2 ∂gaussianProduct (Fin (N+1))have hqpos : ∀ᶠ N in atTop, ∀ j<N, 0<q N j :=uniform_moment_positive hr0 (fun N j hj ↦ hq N (by omega) ⟨j,hj⟩)constructor· filter_upwards [hqpos] with N hN j hjexact predictableNormalizer_pos (hN j hj)· let A (N : ℕ) (i : Fin (N+1)) := meshA T (N+1) γ u ilet B (N : ℕ) (i : Fin (N+1)) := meshB T (N+1) γ u ilet α (N : ℕ) (i : Fin (N+1)) := Real.sqrt (stepSize T (N+1))/predictableNormalizer (meshRaw T (N+1) γ u i) (gaussianProduct (Fin ((N+1)+1)))let β (N : ℕ) (i : Fin (N+1)) := Real.sqrt (stepSize T (N+1))*∫ z, meshRaw T (N+1) γ u i z ∂gaussianProduct (Fin ((N+1)+1))let bstar (N : ℕ) := meshB T (N+1) γ u (N+1)let e (N : ℕ) := gradientMeshError T (N+1) γ ulet rend (N : ℕ) := Real.sqrt (stepSize T (N+1))*Dhave hproj : ∀ᶠ N in atTop,(∑ i, (A N i-α N i)^2)≤e N ∧ (∑ i, (B N i-β N i)^2)≤e N := byfilter_upwards [(tendsto_add_atTop_nat 1).eventually hqpos] with N hNexact mesh_coefficient_errors hT.le h hD (Nat.succ_pos N) (fun i ↦ hN i i.isLt)have hnorm (N : ℕ) : (∑ i, (B N i)^2)≤1 ∧ |bstar N|≤1 :=mesh_coefficients_norms hT.le h (Nat.succ_pos N)have hαnorm (N : ℕ) : (∑ i, (α N i)^2)≤(Real.sqrt T*D)^2 :=mesh_leading_norm hT.le h hD0 hD (Nat.succ_pos N)have hend (N : ℕ) : |α N (Fin.last N)|≤rend N := byhave := gaussianProduct_probability (Fin ((N+1)+1))exact sqrt_div_normalizer_bound(mesh_raw_memLp hT.le h hD (Nat.succ_pos N) (Nat.le_succ N)) hD0(Eventually.of_forall (fun z ↦ hD _ (mesh_time_mem hT.le (Nat.succ_pos N) (Nat.le_succ N)) _))have he0 : Tendsto e atTop (𝓝 0) :=(gradientMeshError_tendsto_zero hT hT1 h).comp (tendsto_add_atTop_nat 1)have hδ0 : Tendsto (fun N : ℕ ↦ stepSize T (N+1)) atTop (𝓝 0) :=(tendsto_const_div_atTop_nhds_zero_nat T).comp (tendsto_add_atTop_nat 1)have hrend0 : Tendsto rend atTop (𝓝 0) := bysimpa only [rend, Function.comp_def, Real.sqrt_zero, zero_mul] using((Real.continuous_sqrt.tendsto 0).comp hδ0).mul_const Dhave herr := shiftedPairing_tendsto_error_zero(fun N ↦ gradientMeshError_nonneg T (N+1) γ u) (mul_nonneg (Real.sqrt_nonneg T) hD0)(hproj.mono (fun _ hN ↦ hN.1)) (hproj.mono (fun _ hN ↦ hN.2))(Eventually.of_forall (fun N ↦ (hnorm N).1)) (Eventually.of_forall hαnorm)(Eventually.of_forall (fun N ↦ (hnorm N).2)) (Eventually.of_forall hend) he0 hrend0let v (N : ℕ) (i : Fin N) :=(∫ z, meshRaw T (N+1) γ u (i+1) z ∂gaussianProduct (Fin ((N+1)+1)))*Real.sqrt (q (N+1) i)have hv (N : ℕ) (i : Fin N) :|v N i-f ((i+1 : ℕ)*(T/(N+1)))|≤(D+1)*r (N+1) := byapply product_perturbation_bound hD0 (hr (N+1))· exact mesh_mean_bound hT.le hD (Nat.succ_pos N) (by omega)· exact (abs_sqrt_sub_one_le (integral_nonneg (fun z ↦ sq_nonneg _))).trans(hq (N+1) (Nat.succ_pos N) i.castSucc)· simpa only [meshTime, stepSize, Fin.val_succ, Nat.cast_add, Nat.cast_one] usinghm (N+1) (Nat.succ_pos N) i.succhave hv0 : Tendsto (fun N ↦ (D+1)*r (N+1)) atTop (𝓝 0) := bysimpa only [mul_zero, Function.comp_def] using (hr0.comp (tendsto_add_atTop_nat 1)).const_mul (D+1)have hvlim := perturbed_shifted_grid_tendsto hT hf(fun N ↦ mul_nonneg (by positivity : 0≤D+1) (hr (N+1))) hv0 (Eventually.of_forall hv)have hsum (N : ℕ) : (∑ i : Fin N, α N i.castSucc*β N i.succ)=(T/(N+1))*∑ i : Fin N, v N i := byrw [Finset.mul_sum]apply Finset.sum_congr rflintro i _have hδ : 0 ≤ stepSize T (N+1) := div_nonneg hT.le (Nat.cast_nonneg _)dsimp only [α, β, v, q, predictableNormalizer]rw [div_inv_eq_mul]calc_ = (Real.sqrt (stepSize T (N+1)))^2 *((∫ z, meshRaw T (N+1) γ u (i+1) z ∂gaussianProduct (Fin ((N+1)+1)))*Real.sqrt (∫ z, (meshRaw T (N+1) γ u i z)^2 ∂gaussianProduct (Fin ((N+1)+1)))) := bysimp only [Fin.val_castSucc, Fin.val_succ]ring_ = _ := by rw [Real.sq_sqrt hδ]; simp only [stepSize, Nat.cast_add, Nat.cast_one]have hp (N : ℕ) : shiftedPairing (A N) (B N) (bstar N)=finiteShiftedValue T (N+1) γ u := bysimp only [shiftedPairing, finiteShiftedValue, A, B, bstar]rw [Fin.sum_univ_castSucc]simp only [Fin.val_castSucc, Fin.val_succ, Fin.val_last]simp_rw [hp, hsum] at herrhave hlim := herr.add hvlimsimp only [sub_add_cancel, zero_add] at hlimexact (tendsto_add_atTop_iff_nat 1).mp hlimend SKValueopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import Mathlibimport OAI.Probability.SKValue.Equations.FiniteRoundednamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsnoncomputable def meshRaw (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(j : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=deriv (u (meshTime T N j)) (euler T N γ u z j)noncomputable def meshTerminal (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(z : Fin (N+1) → ℝ) : ℝ := u T (euler T N γ u z N)noncomputable def meshA (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(j : ℕ) : ℝ :=∫ z, finiteRounded (meshTerminal T N γ u) z *normalizedIncrement (meshRaw T N γ u j) (coordinate N j) (gaussianProduct (Fin (N+1))) z∂gaussianProduct (Fin (N+1))noncomputable def meshB (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(j : ℕ) : ℝ :=∫ z, finiteRounded (meshTerminal T N γ u) z * coordinate N j z ∂gaussianProduct (Fin (N+1))noncomputable def finiteShiftedValue (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ) : ℝ :=∑ i : Fin N, meshA T N γ u i * meshB T N γ u (i+1)lemma mesh_time_mem {T : ℝ} (hT : 0≤T) {N j : ℕ} (hN : 0<N) (hj : j≤N) :meshTime T N j∈Icc (0 : ℝ) T := byapply mesh_mem_strip_ito (δ := stepSize T N) (div_nonneg hT (Nat.cast_nonneg N)) _ hjhave hNr : (N : ℝ)≠0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hN)unfold stepSizefield_simplemma mesh_terminal_measurable {T K L : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L) {N : ℕ} (hN : 0<N) :Measurable (meshTerminal T N γ u) :=(h.smooth T ⟨hT,le_rfl⟩).continuous.measurable.comp(measurable_euler T N γ u (fun _ hj ↦(h.smooth _ (mesh_time_mem hT hN hj.le)).continuous.measurable) N le_rfl)lemma mesh_raw_measurable {T K L : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L) {N : ℕ} (hN : 0<N) {j : ℕ} (hj : j≤N) :Measurable (meshRaw T N γ u j) :=((h.smooth _ (mesh_time_mem hT hN hj)).continuous_deriv (by norm_num)).measurable.comp(measurable_euler T N γ u (fun k hk ↦(h.smooth _ (mesh_time_mem hT hN hk.le)).continuous.measurable) j hj)lemma mesh_raw_depends (T : ℝ) {N j : ℕ} (hj : j≤N) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ) :DependsBefore j (meshRaw T N γ u j) :=eulerCoefficient_dependsBefore T hj γ u (fun t ↦ deriv (u t))lemma mesh_terminal_depends (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ) :DependsBefore N (meshTerminal T N γ u) :=eulerCoefficient_dependsBefore T le_rfl γ u (fun _ ↦ u T)lemma mesh_raw_memLp {T K L D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D){N : ℕ} (hN : 0<N) {j : ℕ} (hj : j≤N) :MemLp (meshRaw T N γ u j) 2 (gaussianProduct (Fin (N+1))) := byhave := gaussianProduct_probability (Fin (N+1))apply MemLp.of_bound (mesh_raw_measurable hT h hN hj).aestronglyMeasurable Dexact Eventually.of_forall (fun z ↦ bysimpa only [meshRaw, Real.norm_eq_abs] using hD _ (mesh_time_mem hT hN hj) (euler T N γ u z j))lemma mesh_coefficient_errors {T K L D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D){N : ℕ} (hN : 0<N)(hpos : ∀ j : Fin N, 0<∫ z, (meshRaw T N γ u j z)^2 ∂gaussianProduct (Fin (N+1))) :(∑ j : Fin N, (meshA T N γ u j-Real.sqrt (stepSize T N)/predictableNormalizer (meshRaw T N γ u j) (gaussianProduct (Fin (N+1))))^2)≤gradientMeshError T N γ u ∧(∑ j : Fin N, (meshB T N γ u j-Real.sqrt (stepSize T N)*∫ z, meshRaw T N γ u j z ∂gaussianProduct (Fin (N+1)))^2)≤gradientMeshError T N γ u := byexact finite_coefficient_L2_errors(fun j ↦ mesh_raw_measurable hT h hN j.isLt.le)(fun j ↦ mesh_raw_depends T j.isLt.le γ u)(fun j ↦ mesh_raw_memLp hT h hD hN j.isLt.le) hpos(mesh_terminal_measurable hT h hN) (mesh_terminal_depends T N γ u)(fun z ↦ h.bounded T ⟨hT,le_rfl⟩ _)lemma mesh_coefficients_norms {T K L : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L) {N : ℕ} (hN : 0<N) :(∑ j : Fin N, (meshB T N γ u j)^2)≤1 ∧ |meshB T N γ u N|≤1 :=finiteRounded_coordinate_norms (mesh_terminal_measurable hT h hN)lemma mesh_leading_norm {T K L D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L) (hD0 : 0≤D)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D){N : ℕ} (hN : 0<N) :(∑ j : Fin N, (Real.sqrt (stepSize T N)/predictableNormalizer (meshRaw T N γ u j) (gaussianProduct (Fin (N+1))))^2)≤(Real.sqrt T*D)^2 := byhave := gaussianProduct_probability (Fin (N+1))have hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg N)calc_ ≤ ∑ j : Fin N, (Real.sqrt (stepSize T N)*D)^2 := byapply Finset.sum_le_sumintro j _rw [←sq_abs (Real.sqrt _ / _)]apply (sq_le_sq₀ (abs_nonneg _) (mul_nonneg (Real.sqrt_nonneg _) hD0)).2exact sqrt_div_normalizer_bound (mesh_raw_memLp hT h hD hN j.isLt.le) hD0(Eventually.of_forall (fun z ↦ hD _ (mesh_time_mem hT hN j.isLt.le) _))_ = (Real.sqrt T*D)^2 := bysimp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_pow]rw [Real.sq_sqrt hδ, Real.sq_sqrt hT]unfold stepSizehave hNr : (N : ℝ)≠0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hN)field_simplemma abs_sqrt_sub_one_le {q : ℝ} (hq : 0≤q) : |Real.sqrt q-1|≤|q-1| := byhave heq : |q-1|=|Real.sqrt q-1| * (Real.sqrt q+1) := byrw [←abs_of_nonneg (by positivity : 0≤Real.sqrt q+1), ←abs_mul]congr 1nlinarith [Real.sq_sqrt hq]rw [heq]nlinarith [Real.sqrt_nonneg q, abs_nonneg (Real.sqrt q-1)]end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import Mathlibimport OAI.Probability.SKValue.Equations.FiniteRoundednamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsnoncomputable def meshRaw (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(j : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=deriv (u (meshTime T N j)) (euler T N γ u z j)noncomputable def meshTerminal (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(z : Fin (N+1) → ℝ) : ℝ := u T (euler T N γ u z N)noncomputable def meshA (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(j : ℕ) : ℝ :=∫ z, finiteRounded (meshTerminal T N γ u) z *normalizedIncrement (meshRaw T N γ u j) (coordinate N j) (gaussianProduct (Fin (N+1))) z∂gaussianProduct (Fin (N+1))noncomputable def meshB (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ)(j : ℕ) : ℝ :=∫ z, finiteRounded (meshTerminal T N γ u) z * coordinate N j z ∂gaussianProduct (Fin (N+1))noncomputable def finiteShiftedValue (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ) : ℝ :=∑ i : Fin N, meshA T N γ u i * meshB T N γ u (i+1)lemma mesh_time_mem {T : ℝ} (hT : 0≤T) {N j : ℕ} (hN : 0<N) (hj : j≤N) :meshTime T N j∈Icc (0 : ℝ) T := byapply mesh_mem_strip_ito (δ := stepSize T N) (div_nonneg hT (Nat.cast_nonneg N)) _ hjhave hNr : (N : ℝ)≠0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hN)unfold stepSizefield_simplemma mesh_terminal_measurable {T K L : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L) {N : ℕ} (hN : 0<N) :Measurable (meshTerminal T N γ u) :=(h.smooth T ⟨hT,le_rfl⟩).continuous.measurable.comp(measurable_euler T N γ u (fun _ hj ↦(h.smooth _ (mesh_time_mem hT hN hj.le)).continuous.measurable) N le_rfl)lemma mesh_raw_measurable {T K L : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L) {N : ℕ} (hN : 0<N) {j : ℕ} (hj : j≤N) :Measurable (meshRaw T N γ u j) :=((h.smooth _ (mesh_time_mem hT hN hj)).continuous_deriv (by norm_num)).measurable.comp(measurable_euler T N γ u (fun k hk ↦(h.smooth _ (mesh_time_mem hT hN hk.le)).continuous.measurable) j hj)lemma mesh_raw_depends (T : ℝ) {N j : ℕ} (hj : j≤N) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ) :DependsBefore j (meshRaw T N γ u j) :=eulerCoefficient_dependsBefore T hj γ u (fun t ↦ deriv (u t))lemma mesh_terminal_depends (T : ℝ) (N : ℕ) (γ : ℝ → ℝ) (u : ℝ → ℝ → ℝ) :DependsBefore N (meshTerminal T N γ u) :=eulerCoefficient_dependsBefore T le_rfl γ u (fun _ ↦ u T)lemma mesh_raw_memLp {T K L D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D){N : ℕ} (hN : 0<N) {j : ℕ} (hj : j≤N) :MemLp (meshRaw T N γ u j) 2 (gaussianProduct (Fin (N+1))) := byhave := gaussianProduct_probability (Fin (N+1))apply MemLp.of_bound (mesh_raw_measurable hT h hN hj).aestronglyMeasurable Dexact Eventually.of_forall (fun z ↦ bysimpa only [meshRaw, Real.norm_eq_abs] using hD _ (mesh_time_mem hT hN hj) (euler T N γ u z j))lemma mesh_coefficient_errors {T K L D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D){N : ℕ} (hN : 0<N)(hpos : ∀ j : Fin N, 0<∫ z, (meshRaw T N γ u j z)^2 ∂gaussianProduct (Fin (N+1))) :(∑ j : Fin N, (meshA T N γ u j-Real.sqrt (stepSize T N)/predictableNormalizer (meshRaw T N γ u j) (gaussianProduct (Fin (N+1))))^2)≤gradientMeshError T N γ u ∧(∑ j : Fin N, (meshB T N γ u j-Real.sqrt (stepSize T N)*∫ z, meshRaw T N γ u j z ∂gaussianProduct (Fin (N+1)))^2)≤gradientMeshError T N γ u := byexact finite_coefficient_L2_errors(fun j ↦ mesh_raw_measurable hT h hN j.isLt.le)(fun j ↦ mesh_raw_depends T j.isLt.le γ u)(fun j ↦ mesh_raw_memLp hT h hD hN j.isLt.le) hpos(mesh_terminal_measurable hT h hN) (mesh_terminal_depends T N γ u)(fun z ↦ h.bounded T ⟨hT,le_rfl⟩ _)lemma mesh_coefficients_norms {T K L : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L) {N : ℕ} (hN : 0<N) :(∑ j : Fin N, (meshB T N γ u j)^2)≤1 ∧ |meshB T N γ u N|≤1 :=finiteRounded_coordinate_norms (mesh_terminal_measurable hT h hN)lemma mesh_leading_norm {T K L D : ℝ} {γ : ℝ → ℝ} {u : ℝ → ℝ → ℝ}(hT : 0≤T) (h : GradientStrip T γ u K L) (hD0 : 0≤D)(hD : ∀ t∈Icc (0 : ℝ) T, ∀ x, |deriv (u t) x|≤D){N : ℕ} (hN : 0<N) :(∑ j : Fin N, (Real.sqrt (stepSize T N)/predictableNormalizer (meshRaw T N γ u j) (gaussianProduct (Fin (N+1))))^2)≤(Real.sqrt T*D)^2 := byhave := gaussianProduct_probability (Fin (N+1))have hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg N)calc_ ≤ ∑ j : Fin N, (Real.sqrt (stepSize T N)*D)^2 := byapply Finset.sum_le_sumintro j _rw [←sq_abs (Real.sqrt _ / _)]apply (sq_le_sq₀ (abs_nonneg _) (mul_nonneg (Real.sqrt_nonneg _) hD0)).2exact sqrt_div_normalizer_bound (mesh_raw_memLp hT h hD hN j.isLt.le) hD0(Eventually.of_forall (fun z ↦ hD _ (mesh_time_mem hT hN j.isLt.le) _))_ = (Real.sqrt T*D)^2 := bysimp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_pow]rw [Real.sq_sqrt hδ, Real.sq_sqrt hT]unfold stepSizehave hNr : (N : ℝ)≠0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hN)field_simplemma abs_sqrt_sub_one_le {q : ℝ} (hq : 0≤q) : |Real.sqrt q-1|≤|q-1| := byhave heq : |q-1|=|Real.sqrt q-1| * (Real.sqrt q+1) := byrw [←abs_of_nonneg (by positivity : 0≤Real.sqrt q+1), ←abs_mul]congr 1nlinarith [Real.sq_sqrt hq]rw [heq]nlinarith [Real.sqrt_nonneg q, abs_nonneg (Real.sqrt q-1)]end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778import Mathlibimport OAI.Probability.SKValue.Equations.Cutoffimport OAI.Probability.SKValue.Equations.LipschitzCompMemLpFiniteimport OAI.Probability.SKValue.Processes.Measurablenamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology BigOperatorslemma IsDiffusion.strip_paths {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {T Lu : ℝ}(hT : 0≤T) (hT1 : T<1) (hLu : 0≤Lu)(huLip : ∀ t∈Icc (0 : ℝ) T, ∀ s∈Icc (0 : ℝ) T, ∀ x y,|gradient W γ s y-gradient W γ t x|≤Lu*(|s-t|+|y-x|)) :∀ᵐ ω ∂W.μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (X s ω)) volume 0 T ∧(∀ t∈Icc (0 : ℝ) T, X t ω = W.B (Real.toNNReal t) ω+∫ s in (0 : ℝ)..t, γ.coeff s*gradient W γ s (X s ω)) ∧ X 0 ω=0 := byfilter_upwards [hX.2, W.brownian.toIsPreBrownianReal.eval_zero_ae_eq_zero] with ω hω h0have hsub : Icc (0 : ℝ) T ⊆ Icc (0 : ℝ) 1 := Icc_subset_Icc le_rfl hT1.lerefine ⟨hω.1.mono hsub, ?_, fun t ht ↦ hω.2 t (hsub ht), ?_⟩· have hj : ContinuousOn (fun p : ℝ×ℝ ↦ gradient W γ p.1 p.2){p | p.1∈Icc (0 : ℝ) T} :=derivative_joint_continuous hLu (fun s hs t ht x y ↦ huLip t ht s hs y x)have hp : ContinuousOn (fun t : ℝ ↦ (t, X t ω)) (Icc (0 : ℝ) T) :=continuousOn_id.prodMk (hω.1.mono hsub)have hc : ContinuousOn (fun t ↦ gradient W γ t (X t ω)) (Icc (0 : ℝ) T) := byexact ContinuousOn.comp (g := fun p : ℝ×ℝ ↦ gradient W γ p.1 p.2)(f := fun t : ℝ ↦ (t, X t ω)) hj hp (fun t ht ↦ ht)have hgi : IntervalIntegrable γ.coeff volume 0 T :=γ.intervalIntegrable.mono_set (bysimpa only [uIcc_of_le hT, uIcc_of_le (by norm_num : (0 : ℝ)≤1)] using(Icc_subset_Icc le_rfl hT1.le))exact hgi.mul_continuousOn (by simpa only [uIcc_of_le hT] using hc)· simpa only [intervalIntegral.integral_same, add_zero, Real.toNNReal_zero, h0]using hω.2 0 (by norm_num)lemma IsDiffusion.value_expectation {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {T K L Kg Lg Lu : ℝ}(hT : 0<T) (hT1 : T<1)(h : ValueStrip T γ.coeff (phi W γ) K L)(hg : GradientStrip T γ.coeff (gradient W γ) Kg Lg)(hLu : 0≤Lu)(huLip : ∀ t∈Icc (0 : ℝ) T, ∀ s∈Icc (0 : ℝ) T, ∀ x y,|gradient W γ s y-gradient W γ t x|≤Lu*(|s-t|+|y-x|)) :(∫ ω, phi W γ T (X T ω) ∂W.μ) = phi W γ 0 0+(1/2 : ℝ)*(∫ t in (0 : ℝ)..T, γ.coeff t*(∫ ω, (gradient W γ t (X t ω))^2 ∂W.μ)) := byapply diffusion_value_expectation (μ := W.μ) (B := W.B) (X := X)W.brownian.toIsPreBrownianReal hT hT1.le h hg hLu(fun s hs t ht x y ↦ huLip t ht s hs y x)· intro t htexact hX.memLp ⟨ht.1,ht.2.trans hT1.le⟩ (by norm_num)· exact hX.strip_paths hT.le hT1 hLu huLipend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778import Mathlibimport OAI.Probability.SKValue.Equations.Cutoffimport OAI.Probability.SKValue.Equations.LipschitzCompMemLpFiniteimport OAI.Probability.SKValue.Processes.Measurablenamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology BigOperatorslemma IsDiffusion.strip_paths {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {T Lu : ℝ}(hT : 0≤T) (hT1 : T<1) (hLu : 0≤Lu)(huLip : ∀ t∈Icc (0 : ℝ) T, ∀ s∈Icc (0 : ℝ) T, ∀ x y,|gradient W γ s y-gradient W γ t x|≤Lu*(|s-t|+|y-x|)) :∀ᵐ ω ∂W.μ, ContinuousOn (fun t ↦ X t ω) (Icc (0 : ℝ) T) ∧IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (X s ω)) volume 0 T ∧(∀ t∈Icc (0 : ℝ) T, X t ω = W.B (Real.toNNReal t) ω+∫ s in (0 : ℝ)..t, γ.coeff s*gradient W γ s (X s ω)) ∧ X 0 ω=0 := byfilter_upwards [hX.2, W.brownian.toIsPreBrownianReal.eval_zero_ae_eq_zero] with ω hω h0have hsub : Icc (0 : ℝ) T ⊆ Icc (0 : ℝ) 1 := Icc_subset_Icc le_rfl hT1.lerefine ⟨hω.1.mono hsub, ?_, fun t ht ↦ hω.2 t (hsub ht), ?_⟩· have hj : ContinuousOn (fun p : ℝ×ℝ ↦ gradient W γ p.1 p.2){p | p.1∈Icc (0 : ℝ) T} :=derivative_joint_continuous hLu (fun s hs t ht x y ↦ huLip t ht s hs y x)have hp : ContinuousOn (fun t : ℝ ↦ (t, X t ω)) (Icc (0 : ℝ) T) :=continuousOn_id.prodMk (hω.1.mono hsub)have hc : ContinuousOn (fun t ↦ gradient W γ t (X t ω)) (Icc (0 : ℝ) T) := byexact ContinuousOn.comp (g := fun p : ℝ×ℝ ↦ gradient W γ p.1 p.2)(f := fun t : ℝ ↦ (t, X t ω)) hj hp (fun t ht ↦ ht)have hgi : IntervalIntegrable γ.coeff volume 0 T :=γ.intervalIntegrable.mono_set (bysimpa only [uIcc_of_le hT, uIcc_of_le (by norm_num : (0 : ℝ)≤1)] using(Icc_subset_Icc le_rfl hT1.le))exact hgi.mul_continuousOn (by simpa only [uIcc_of_le hT] using hc)· simpa only [intervalIntegral.integral_same, add_zero, Real.toNNReal_zero, h0]using hω.2 0 (by norm_num)lemma IsDiffusion.value_expectation {W : BrownianSpace} {γ : OrderParameter}{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {T K L Kg Lg Lu : ℝ}(hT : 0<T) (hT1 : T<1)(h : ValueStrip T γ.coeff (phi W γ) K L)(hg : GradientStrip T γ.coeff (gradient W γ) Kg Lg)(hLu : 0≤Lu)(huLip : ∀ t∈Icc (0 : ℝ) T, ∀ s∈Icc (0 : ℝ) T, ∀ x y,|gradient W γ s y-gradient W γ t x|≤Lu*(|s-t|+|y-x|)) :(∫ ω, phi W γ T (X T ω) ∂W.μ) = phi W γ 0 0+(1/2 : ℝ)*(∫ t in (0 : ℝ)..T, γ.coeff t*(∫ ω, (gradient W γ t (X t ω))^2 ∂W.μ)) := byapply diffusion_value_expectation (μ := W.μ) (B := W.B) (X := X)W.brownian.toIsPreBrownianReal hT hT1.le h hg hLu(fun s hs t ht x y ↦ huLip t ht s hs y x)· intro t htexact hX.memLp ⟨ht.1,ht.2.trans hT1.le⟩ (by norm_num)· exact hX.strip_paths hT.le hT1 hLu huLipend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import Mathlibimport OAI.Probability.SKValue.Processes.UnitMomentMartingalenamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValuevariable {Ω : Type*} {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]variable {ℱ : Filtration ℝ m} {f : ℝ → Ω → ℝ}lemma UnitMomentMartingale.terminal_condExp(h : UnitMomentMartingale (μ := μ) ℱ f) {U : Ω → ℝ}(hUm : StronglyMeasurable[ℱ 1] U)(hU : ∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))){s : ℝ} (hs : s ∈ Ico (0 : ℝ) 1) : μ[U | ℱ s] =ᵐ[μ] f s := byhave hUi : Integrable U μ := Integrable.of_bound (hUm.mono (ℱ.le _)).aestronglyMeasurable 1(hU.mono (fun ω hω ↦ (Real.norm_eq_abs _).trans_le hω.1))apply Filter.EventuallyEq.symmapply ae_eq_condExp_of_forall_setIntegral_eq (ℱ.le s) hUi(fun S _ _ ↦ (h.integrable hs).integrableOn) _ (h.measurable s hs).aestronglyMeasurableintro S hS _have hlim : Tendsto (fun n ↦ ∫ ω in S, f (terminalTime n) ω ∂μ) atTop (𝓝 (∫ ω in S, U ω ∂μ)) :=tendsto_integral_of_dominated_convergence (fun _ : Ω ↦ (1 : ℝ))(fun n ↦ ((h.measurable _ (terminalTime_mem n)).mono (ℱ.le _)).aestronglyMeasurable.restrict)(integrable_const 1)(fun n ↦ Eventually.of_forall (fun ω ↦ (Real.norm_eq_abs _).trans_le(h.bounded _ (terminalTime_mem n) ω)))(ae_restrict_of_ae (hU.mono (fun _ hω ↦ hω.2)))have he : ∀ᶠ n in atTop, (∫ ω in S, f (terminalTime n) ω ∂μ) = ∫ ω in S, f s ω ∂μ := byhave hsn : ∀ᶠ n in atTop, s ≤ terminalTime n :=((tendsto_nhdsWithin_iff.mp terminalTime_tendsto).1.eventually (Ioi_mem_nhds hs.2)).mono(fun _ hn ↦ hn.le)filter_upwards [hsn] with n hncalc_ = ∫ ω in S, μ[f (terminalTime n) | ℱ s] ω ∂μ :=(setIntegral_condExp (ℱ.le s) (h.integrable (terminalTime_mem n)) hS).symm_ = _ := integral_congr_ae (ae_restrict_of_ae (h.condExp s hs _ (terminalTime_mem n) hn))exact tendsto_nhds_unique (tendsto_const_nhds.congr' (Filter.EventuallyEq.symm he)) hlimlemma UnitMomentMartingale.terminal_stopped_martingale(h : UnitMomentMartingale (μ := μ) ℱ f) {U : Ω → ℝ}(hUm : StronglyMeasurable[ℱ 1] U)(hU : ∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))) :Martingale (fun t : ℝ≥0 ↦ fun ω ↦ if (t : ℝ)<1 then f t ω else U ω)(⟨fun t : ℝ≥0 ↦ ℱ t,fun _ _ hij ↦ ℱ.mono hij,fun t ↦ ℱ.le t⟩ :Filtration ℝ≥0 m) μ := byhave hUi : Integrable U μ := Integrable.of_bound (hUm.mono (ℱ.le _)).aestronglyMeasurable 1(hU.mono (fun ω hω ↦ (Real.norm_eq_abs _).trans_le hω.1))constructor· intro tby_cases ht : (t : ℝ)<1· simpa only [ht,ite_true,ite_false] using h.measurable t ⟨t.coe_nonneg,ht⟩· simpa only [ht,ite_true,ite_false] using hUm.mono (ℱ.mono (not_lt.mp ht))· intro s t hstby_cases hs : (s : ℝ)<1· by_cases ht : (t : ℝ)<1· simpa only [hs,ht,ite_true,ite_false] usingh.condExp s ⟨s.coe_nonneg,hs⟩ t ⟨t.coe_nonneg,ht⟩ hst· simpa only [hs,ht,ite_true,ite_false] using h.terminal_condExp hUm hU ⟨s.coe_nonneg,hs⟩· have ht : ¬(t : ℝ)<1 := not_lt.mpr ((not_lt.mp hs).trans hst)have he := condExp_of_stronglyMeasurable (ℱ.le s)(hUm.mono (ℱ.mono (not_lt.mp hs))) hUisimpa only [hs,ht,ite_true,ite_false] using Filter.EventuallyEq.of_eq helemma UnitMomentMartingale.exists_terminal(h : UnitMomentMartingale (μ := μ) ℱ f)(hc : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ f t ω) (Ico (0 : ℝ) 1)) :∃ U : Ω → ℝ, StronglyMeasurable[ℱ 1] U ∧Martingale (fun t : ℝ≥0 ↦ fun ω ↦ if (t : ℝ)<1 then f t ω else U ω)(⟨fun t : ℝ≥0 ↦ ℱ t,fun _ _ hij ↦ ℱ.mono hij,fun t ↦ ℱ.le t⟩ :Filtration ℝ≥0 m) μ ∧(∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧ (U ω)^2=1 ∧Tendsto (fun t ↦ f t ω) (𝓝[<] (1 : ℝ)) (𝓝 (U ω))) ∧Tendsto (fun t ↦ ∫ ω, (f t ω-U ω)^2 ∂μ) (𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) := byobtain ⟨U,hUm,hU⟩ := h.exists_continuous_terminal hchave hseq : ∀ᵐ ω ∂μ, |U ω|≤1 ∧Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω)) :=hU.mono (fun ω hω ↦ ⟨hω.1,hω.2.comp terminalTime_tendsto⟩)refine ⟨U,hUm,h.terminal_stopped_martingale hUm hseq,?_,h.terminal_mean_square hUm hU⟩filter_upwards [hU,h.terminal_square hUm hseq] with ω hω hsqexact ⟨hω.1,hsq,hω.2⟩end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import Mathlibimport OAI.Probability.SKValue.Processes.UnitMomentMartingalenamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValuevariable {Ω : Type*} {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]variable {ℱ : Filtration ℝ m} {f : ℝ → Ω → ℝ}lemma UnitMomentMartingale.terminal_condExp(h : UnitMomentMartingale (μ := μ) ℱ f) {U : Ω → ℝ}(hUm : StronglyMeasurable[ℱ 1] U)(hU : ∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))){s : ℝ} (hs : s ∈ Ico (0 : ℝ) 1) : μ[U | ℱ s] =ᵐ[μ] f s := byhave hUi : Integrable U μ := Integrable.of_bound (hUm.mono (ℱ.le _)).aestronglyMeasurable 1(hU.mono (fun ω hω ↦ (Real.norm_eq_abs _).trans_le hω.1))apply Filter.EventuallyEq.symmapply ae_eq_condExp_of_forall_setIntegral_eq (ℱ.le s) hUi(fun S _ _ ↦ (h.integrable hs).integrableOn) _ (h.measurable s hs).aestronglyMeasurableintro S hS _have hlim : Tendsto (fun n ↦ ∫ ω in S, f (terminalTime n) ω ∂μ) atTop (𝓝 (∫ ω in S, U ω ∂μ)) :=tendsto_integral_of_dominated_convergence (fun _ : Ω ↦ (1 : ℝ))(fun n ↦ ((h.measurable _ (terminalTime_mem n)).mono (ℱ.le _)).aestronglyMeasurable.restrict)(integrable_const 1)(fun n ↦ Eventually.of_forall (fun ω ↦ (Real.norm_eq_abs _).trans_le(h.bounded _ (terminalTime_mem n) ω)))(ae_restrict_of_ae (hU.mono (fun _ hω ↦ hω.2)))have he : ∀ᶠ n in atTop, (∫ ω in S, f (terminalTime n) ω ∂μ) = ∫ ω in S, f s ω ∂μ := byhave hsn : ∀ᶠ n in atTop, s ≤ terminalTime n :=((tendsto_nhdsWithin_iff.mp terminalTime_tendsto).1.eventually (Ioi_mem_nhds hs.2)).mono(fun _ hn ↦ hn.le)filter_upwards [hsn] with n hncalc_ = ∫ ω in S, μ[f (terminalTime n) | ℱ s] ω ∂μ :=(setIntegral_condExp (ℱ.le s) (h.integrable (terminalTime_mem n)) hS).symm_ = _ := integral_congr_ae (ae_restrict_of_ae (h.condExp s hs _ (terminalTime_mem n) hn))exact tendsto_nhds_unique (tendsto_const_nhds.congr' (Filter.EventuallyEq.symm he)) hlimlemma UnitMomentMartingale.terminal_stopped_martingale(h : UnitMomentMartingale (μ := μ) ℱ f) {U : Ω → ℝ}(hUm : StronglyMeasurable[ℱ 1] U)(hU : ∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))) :Martingale (fun t : ℝ≥0 ↦ fun ω ↦ if (t : ℝ)<1 then f t ω else U ω)(⟨fun t : ℝ≥0 ↦ ℱ t,fun _ _ hij ↦ ℱ.mono hij,fun t ↦ ℱ.le t⟩ :Filtration ℝ≥0 m) μ := byhave hUi : Integrable U μ := Integrable.of_bound (hUm.mono (ℱ.le _)).aestronglyMeasurable 1(hU.mono (fun ω hω ↦ (Real.norm_eq_abs _).trans_le hω.1))constructor· intro tby_cases ht : (t : ℝ)<1· simpa only [ht,ite_true,ite_false] using h.measurable t ⟨t.coe_nonneg,ht⟩· simpa only [ht,ite_true,ite_false] using hUm.mono (ℱ.mono (not_lt.mp ht))· intro s t hstby_cases hs : (s : ℝ)<1· by_cases ht : (t : ℝ)<1· simpa only [hs,ht,ite_true,ite_false] usingh.condExp s ⟨s.coe_nonneg,hs⟩ t ⟨t.coe_nonneg,ht⟩ hst· simpa only [hs,ht,ite_true,ite_false] using h.terminal_condExp hUm hU ⟨s.coe_nonneg,hs⟩· have ht : ¬(t : ℝ)<1 := not_lt.mpr ((not_lt.mp hs).trans hst)have he := condExp_of_stronglyMeasurable (ℱ.le s)(hUm.mono (ℱ.mono (not_lt.mp hs))) hUisimpa only [hs,ht,ite_true,ite_false] using Filter.EventuallyEq.of_eq helemma UnitMomentMartingale.exists_terminal(h : UnitMomentMartingale (μ := μ) ℱ f)(hc : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ f t ω) (Ico (0 : ℝ) 1)) :∃ U : Ω → ℝ, StronglyMeasurable[ℱ 1] U ∧Martingale (fun t : ℝ≥0 ↦ fun ω ↦ if (t : ℝ)<1 then f t ω else U ω)(⟨fun t : ℝ≥0 ↦ ℱ t,fun _ _ hij ↦ ℱ.mono hij,fun t ↦ ℱ.le t⟩ :Filtration ℝ≥0 m) μ ∧(∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧ (U ω)^2=1 ∧Tendsto (fun t ↦ f t ω) (𝓝[<] (1 : ℝ)) (𝓝 (U ω))) ∧Tendsto (fun t ↦ ∫ ω, (f t ω-U ω)^2 ∂μ) (𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) := byobtain ⟨U,hUm,hU⟩ := h.exists_continuous_terminal hchave hseq : ∀ᵐ ω ∂μ, |U ω|≤1 ∧Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω)) :=hU.mono (fun ω hω ↦ ⟨hω.1,hω.2.comp terminalTime_tendsto⟩)refine ⟨U,hUm,h.terminal_stopped_martingale hUm hseq,?_,h.terminal_mean_square hUm hU⟩filter_upwards [hU,h.terminal_square hUm hseq] with ω hω hsqexact ⟨hω.1,hsq,hω.2⟩end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import Mathlibimport OAI.Probability.SKValue.Gaussian.CoupledCoordinatesimport OAI.Probability.SKValue.Evolution.BoundedSmoothimport OAI.Probability.SKValue.Equations.TestGeneratorimport OAI.Probability.SKValue.Processes.TestExpectationnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValuelemma BackwardTest.diffusion_expectation {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {T K L K' L' Lu:ℝ} {γ:ℝ → ℝ} {u V:ℝ → ℝ → ℝ}(hT:0<T) (hT1:T≤1) (hu:GradientStrip T γ u K L) (h:BackwardTest T γ u V K' L')(hLu:0≤Lu) (hLip:∀ s∈Icc (0:ℝ) T,∀ t∈Icc (0:ℝ) T,∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(hXM:∀ t∈Icc (0:ℝ) T,AEStronglyMeasurable (X t) μ)(hpaths:∀ᵐ ω ∂μ,ContinuousOn (fun t ↦ X t ω) (Icc (0:ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t∈Icc (0:ℝ) T,X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,γ s*u s (X s ω)) ∧ X 0 ω=0) :(∫ ω,V T (X T ω) ∂μ)=V 0 0 := bylet A := fun N ↦ ∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1))let E := fun N ↦ T*Real.sqrt (stepSize T N)*cubicEnvelopeMean (γ T) K' ((1/2+γ T)*L')+stepSize T N*K'*(γ T-γ 0)let F := fun N ↦ K'*Real.sqrt (∫ ω,(meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ)have hδ:Tendsto (fun N:ℕ ↦ stepSize T N) atTop (𝓝 (0:ℝ)) := tendsto_const_div_atTop_nhds_zero_nat Thave hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδhave hE:Tendsto E atTop (𝓝 0) := bysimpa only [E,Function.comp_def,Real.sqrt_zero,mul_zero,zero_mul,add_zero] using(((hsqrt.const_mul T).mul_const (cubicEnvelopeMean (γ T) K' ((1/2+γ T)*L'))).add((hδ.mul_const K').mul_const (γ T-γ 0)))have hF:Tendsto F atTop (𝓝 0) := bysimpa only [F,Function.comp_def,Real.sqrt_zero,mul_zero] using(((Real.continuous_sqrt.tendsto 0).comp(coupled_euler_L2_convergence hB hT hu hLu hLip hXM hpaths)).const_mul K')have hbound:∀ᶠ N in atTop,|(∫ ω,V T (X T ω) ∂μ)-V 0 0|≤E N+F N := byfilter_upwards [eventually_gt_atTop 0] with N hNhave he := h.mesh_expectation hT hT1 hNhave hf := h.coupled_terminal_error hB hT hu hXM(by filter_upwards [hpaths] with ω hω using hω.2.2) hNhave ht := abs_sub_le (∫ ω,V T (X T ω) ∂μ) (A N) (V 0 0)change |A N-V 0 0|≤E N at hechange |A N-(∫ ω,V T (X T ω) ∂μ)|≤F N at hfhave hf' : |(∫ ω,V T (X T ω) ∂μ)-A N|≤F N := byrw [abs_sub_comm];exact hflinarithhave hz := le_of_tendsto_of_tendsto tendsto_const_nhds (hE.add hF) hboundhave habs:|(∫ ω,V T (X T ω) ∂μ)-V 0 0|=0 := le_antisymm (by simpa using hz) (abs_nonneg _)exact sub_eq_zero.mp (abs_eq_zero.mp habs)end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import Mathlibimport OAI.Probability.SKValue.Gaussian.CoupledCoordinatesimport OAI.Probability.SKValue.Evolution.BoundedSmoothimport OAI.Probability.SKValue.Equations.TestGeneratorimport OAI.Probability.SKValue.Processes.TestExpectationnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValuelemma BackwardTest.diffusion_expectation {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {T K L K' L' Lu:ℝ} {γ:ℝ → ℝ} {u V:ℝ → ℝ → ℝ}(hT:0<T) (hT1:T≤1) (hu:GradientStrip T γ u K L) (h:BackwardTest T γ u V K' L')(hLu:0≤Lu) (hLip:∀ s∈Icc (0:ℝ) T,∀ t∈Icc (0:ℝ) T,∀ x y,|u s x-u t y|≤Lu*(|s-t|+|x-y|))(hXM:∀ t∈Icc (0:ℝ) T,AEStronglyMeasurable (X t) μ)(hpaths:∀ᵐ ω ∂μ,ContinuousOn (fun t ↦ X t ω) (Icc (0:ℝ) T) ∧IntervalIntegrable (fun s ↦ γ s*u s (X s ω)) volume 0 T ∧(∀ t∈Icc (0:ℝ) T,X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,γ s*u s (X s ω)) ∧ X 0 ω=0) :(∫ ω,V T (X T ω) ∂μ)=V 0 0 := bylet A := fun N ↦ ∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1))let E := fun N ↦ T*Real.sqrt (stepSize T N)*cubicEnvelopeMean (γ T) K' ((1/2+γ T)*L')+stepSize T N*K'*(γ T-γ 0)let F := fun N ↦ K'*Real.sqrt (∫ ω,(meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ)have hδ:Tendsto (fun N:ℕ ↦ stepSize T N) atTop (𝓝 (0:ℝ)) := tendsto_const_div_atTop_nhds_zero_nat Thave hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδhave hE:Tendsto E atTop (𝓝 0) := bysimpa only [E,Function.comp_def,Real.sqrt_zero,mul_zero,zero_mul,add_zero] using(((hsqrt.const_mul T).mul_const (cubicEnvelopeMean (γ T) K' ((1/2+γ T)*L'))).add((hδ.mul_const K').mul_const (γ T-γ 0)))have hF:Tendsto F atTop (𝓝 0) := bysimpa only [F,Function.comp_def,Real.sqrt_zero,mul_zero] using(((Real.continuous_sqrt.tendsto 0).comp(coupled_euler_L2_convergence hB hT hu hLu hLip hXM hpaths)).const_mul K')have hbound:∀ᶠ N in atTop,|(∫ ω,V T (X T ω) ∂μ)-V 0 0|≤E N+F N := byfilter_upwards [eventually_gt_atTop 0] with N hNhave he := h.mesh_expectation hT hT1 hNhave hf := h.coupled_terminal_error hB hT hu hXM(by filter_upwards [hpaths] with ω hω using hω.2.2) hNhave ht := abs_sub_le (∫ ω,V T (X T ω) ∂μ) (A N) (V 0 0)change |A N-V 0 0|≤E N at hechange |A N-(∫ ω,V T (X T ω) ∂μ)|≤F N at hfhave hf' : |(∫ ω,V T (X T ω) ∂μ)-A N|≤F N := byrw [abs_sub_comm];exact hflinarithhave hz := le_of_tendsto_of_tendsto tendsto_const_nhds (hE.add hF) hboundhave habs:|(∫ ω,V T (X T ω) ∂μ)-V 0 0|=0 := le_antisymm (by simpa using hz) (abs_nonneg _)exact sub_eq_zero.mp (abs_eq_zero.mp habs)end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191import Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshimport OAI.Probability.SKValue.Equations.TestGeneratornamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperators NNRealnamespace SKValuelemma BackwardTest.expectation_step {T K L t δ:ℝ} {γ:ℝ → ℝ} {u V:ℝ → ℝ → ℝ}(h:BackwardTest T γ u V K L) (ht:0≤t) (hδ:0≤δ) (hδ1:δ≤1) (htδ:t+δ≤T){N j:ℕ} (hj:j<N+1) {Y:(Fin (N+1) → ℝ) → ℝ}(hYm:Measurable Y) (hYp:DependsBefore j Y) :let μ := gaussianProduct (Fin (N+1))let Y' := fun z ↦ Y z+Real.sqrt δ*coordinate N j z+δ*γ t*u t (Y z)|(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)|≤δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (t+δ)-γ t) := bylet μ := gaussianProduct (Fin (N+1))let p := fun z ↦ deriv (V t) (Y z)let a := fun z ↦ deriv (deriv (V t)) (Y z)let Y' := fun z ↦ Y z+Real.sqrt δ*coordinate N j z+δ*γ t*u t (Y z)let P := fun z ↦ Real.sqrt δ*rawIncrement p j zlet Q := fun z ↦ (δ/2)*(a z*((coordinate N j z)^2-1))let D := fun z ↦ V (t+δ) (Y' z)-V t (Y z)let R := fun z ↦ D z-P z-Q zlet E := fun z ↦ δ*Real.sqrt δ*cubicEnvelope (γ T) K ((1/2+γ T)*L) (coordinate N j z)+δ*K*(γ (t+δ)-γ t)have htT:t≤T := (le_add_of_nonneg_right hδ).trans htδhave htm:t∈Icc (0:ℝ) T := ⟨ht,htT⟩have hem:t+δ∈Icc (0:ℝ) T := ⟨by linarith,htδ⟩have hpm:Measurable p := ((h.smooth t htm).continuous_deriv (by norm_num)).measurable.comp hYmhave ham:Measurable a := byhave hh := (h.smooth t htm).continuous_iteratedDeriv 2 (by norm_num)simp only [show (2:ℕ)=1+1 from rfl,iteratedDeriv_succ] at hhexact hh.measurable.comp hYmhave hpM:MemLp p 2 μ := MemLp.of_bound hpm.aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.first_bound t htm (Y z)))have haM:MemLp a 2 μ := MemLp.of_bound ham.aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.second_bound t htm (Y z)))have hpp:DependsBefore j p := fun z z' hz ↦ by dsimp only [p];rw [hYp z z' hz]have hap:DependsBefore j a := fun z z' hz ↦ by dsimp only [a];rw [hYp z z' hz]have hPi:Integrable P μ := (((rawIncrement_memLp hj hpm hpp hpM).const_mul _).integrable (by norm_num))have hQi:Integrable Q μ := (((predictableCenteredSquare_memLp ham (fun z ↦ h.second_bound t htm (Y z))).const_mul _).integrable (by norm_num))have hP0:(∫ z,P z ∂μ)=0 := bydsimp only [P]rw [integral_const_mul,rawIncrement_mean hj hpm hpp,mul_zero]have hQ0:(∫ z,Q z ∂μ)=0 := bydsimp only [Q]rw [integral_const_mul,predictableCenteredSquare_mean hj ham hap,mul_zero]have hY'm:Measurable Y' := (hYm.add ((measurable_coordinate N j).const_mul _)).add(((h.drift_measurable t htm).comp hYm).const_mul _)have hcur:Integrable (fun z ↦ V t (Y z)) μ :=(MemLp.of_bound ((h.smooth t htm).continuous.measurable.comp hYm).aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.bound t htm (Y z))) :MemLp (fun z ↦ V t (Y z)) 2 μ).integrable (by norm_num)have hnext:Integrable (fun z ↦ V (t+δ) (Y' z)) μ :=(MemLp.of_bound ((h.smooth (t+δ) hem).continuous.measurable.comp hY'm).aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.bound (t+δ) hem (Y' z))) :MemLp (fun z ↦ V (t+δ) (Y' z)) 2 μ).integrable (by norm_num)have hDi:Integrable D μ := hnext.sub hcurhave hRi:Integrable R μ := (hDi.sub hPi).sub hQihave hEi0 := (cubicEnvelope_memLp_two (coordinate_hasLaw N j)(h.gamma_nonneg T ⟨ht.trans htT,le_rfl⟩) K ((1/2+γ T)*L)).integrable (by norm_num)have hEi:Integrable E μ := (hEi0.const_mul _).add (integrable_const _)have hRE (z) : |R z|≤E z := byhave hh := h.euler_one_step ht hδ hδ1 htδ (x:=Y z) (z:=coordinate N j z)convert! hh using 1dsimp only [R,D,P,Q,p,a,Y',E,rawIncrement]congr 1ring_nfhave hRmean:(∫ z,R z ∂μ)=(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ) := byhave hs := integral_sub (hDi.sub hPi) hQichange (∫ z,D z-P z-Q z ∂μ)=(∫ z,D z-P z ∂μ)-(∫ z,Q z ∂μ) at hshave hs1 := integral_sub hDi hPichange (∫ z,D z-P z ∂μ)=(∫ z,D z ∂μ)-(∫ z,P z ∂μ) at hs1change (∫ z,D z-P z-Q z ∂μ)=_rw [hs,hs1,hP0,hQ0,sub_zero,sub_zero]exact integral_sub hnext hcurhave hEmean:(∫ z,E z ∂μ)=δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (t+δ)-γ t) := bydsimp only [E]rw [integral_add (hEi0.const_mul _) (integrable_const _),integral_const_mul]simp only [integral_const,probReal_univ,smul_eq_mul,one_mul]have he:(∫ z,cubicEnvelope (γ T) K ((1/2+γ T)*L) (coordinate N j z) ∂μ)=cubicEnvelopeMean (γ T) K ((1/2+γ T)*L) := bysimpa only [Function.comp_def,cubicEnvelopeMean,standardGaussian] using(coordinate_hasLaw N j).integral_comp (measurable_cubicEnvelope (γ T) K ((1/2+γ T)*L)).aestronglyMeasurablerw [he]change |(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)|≤_rw [←hRmean,←hEmean]exact abs_integral_le_integral_abs.trans (integral_mono hRi.norm hEi hRE)end SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperators NNRealnamespace SKValuelemma BackwardTest.mesh_expectation {T K L:ℝ} {γ:ℝ → ℝ} {u V:ℝ → ℝ → ℝ}(h:BackwardTest T γ u V K L) (hT:0<T) (hT1:T≤1) {N:ℕ} (hN:0<N) :|(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))-V 0 0|≤T*Real.sqrt (stepSize T N)*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+stepSize T N*K*(γ T-γ 0) := bylet δ := stepSize T Nlet A := fun j ↦ ∫ z,V (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1))have hNr:0<(N:ℝ) := by exact_mod_cast hNhave hδ:0≤δ := div_nonneg hT.le hNr.lehave hδ1:δ≤1 := byapply (div_le_iff₀ hNr).mprhave hn:(1:ℝ)≤N := by exact_mod_cast hNsimpa only [one_mul] using hT1.trans hnhave htime (j:ℕ) (hj:j≤N) := mesh_time_mem hT.le hN hjhave hs (j:ℕ) : meshTime T N j+δ=meshTime T N (j+1) := by dsimp [meshTime];push_cast;ringhave hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simphave hzero:meshTime T N 0=0 := by simp [meshTime]have hum (j:ℕ) (hj:j<N) : Measurable (u (meshTime T N j)) := h.drift_measurable _ (htime j hj.le)have hstep (j:ℕ) (hj:j<N) : |A (j+1)-A j+0|≤δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (meshTime T N (j+1))-γ (meshTime T N j))+0*((0:ℝ)-0) := byhave hYp:DependsBefore j (fun z ↦ euler T N γ u z j) :=eulerCoefficient_dependsBefore T hj.le γ u (fun _ y ↦ y)have he := h.expectation_step (htime j hj.le).1 hδ hδ1(by rw [hs];exact (htime (j+1) (by omega)).2) (by omega:j<N+1)(measurable_euler T N γ u hum j hj.le) hYpdsimp only at herw [hs] at hesimpa only [A,euler,δ,mul_assoc,add_zero,sub_self,mul_zero] using hehave hh := abs_telescope_source (A:=A) (b:=fun _ ↦ 0) (Γ:=fun j ↦ γ (meshTime T N j))(Δ:=fun _ ↦ 0) (e:=0) hstephave hA0:A 0=V 0 0 := by simp [A,meshTime,euler]rw [hA0,show A N=(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1))) bydsimp only [A];rw [hlast],hlast,hzero] at hhhave hNd:(N:ℝ)*δ=T := by dsimp [δ,stepSize];field_simpsimpa only [Finset.sum_const_zero,add_zero,sub_self,mul_zero,←mul_assoc,hNd] using hhlemma BackwardTest.terminal_lipschitz {T K L:ℝ} {γ:ℝ → ℝ} {u V:ℝ → ℝ → ℝ}(h:BackwardTest T γ u V K L) (hT:0≤T) (x y:ℝ) : |V T x-V T y|≤K*|x-y| := byhave hd := (h.smooth T ⟨hT,le_rfl⟩).differentiable (by norm_num)have hb:∀ z,‖deriv (V T) z‖≤K := fun z ↦ by simpa only [Real.norm_eq_abs] using h.first_bound T ⟨hT,le_rfl⟩ zhave hl : LipschitzWith ⟨K,h.K_nonneg⟩ (V T) := byapply lipschitzWith_of_nnnorm_deriv_le hdintro zexact_mod_cast hb zhave hh := hl.dist_le_mul x ychange |V T x-V T y|≤K*|x-y| at hhexact hhlemma BackwardTest.coupled_terminal_error {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {T K L K' L':ℝ} {γ:ℝ → ℝ} {u V:ℝ → ℝ → ℝ}(hT:0<T) (hu:GradientStrip T γ u K L) (h:BackwardTest T γ u V K' L')(hXM:∀ t∈Icc (0:ℝ) T,AEStronglyMeasurable (X t) μ)(hpaths:∀ᵐ ω ∂μ,(∀ t∈Icc (0:ℝ) T,X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,γ s*u s (X s ω)) ∧ X 0 ω=0) {N:ℕ} (hN:0<N) :|(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))-(∫ ω,V T (X T ω) ∂μ)|≤K'*Real.sqrt (∫ ω,(meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ) := bylet F := fun ω ↦ V T (coupledEuler T γ u B N N ω)let G := fun ω ↦ V T (X T ω)let E := meshMaxError T X (coupledEuler T γ u B) Nhave ht:T∈Icc (0:ℝ) T := ⟨hT.le,le_rfl⟩have hm:Continuous (V T) := (h.smooth T ht).continuoushave hFM:MemLp F 2 μ := MemLp.of_bound(hm.measurable.comp_aemeasurable (coupled_euler_measurable hB hT hu N N le_rfl).aemeasurable).aestronglyMeasurable K'(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs,F] using h.bound T ht _))have hGM:MemLp G 2 μ := MemLp.of_bound(hm.measurable.comp_aemeasurable (hXM T ht).aemeasurable).aestronglyMeasurable K'(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs,G] using h.bound T ht _))have hEM:MemLp E 2 μ := coupled_mesh_error_memLp hB hT hu hXM hpaths hNhave hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simphave hFG (ω:Ω) : |F ω-G ω|≤K'*|E ω| := byhave he:|coupledEuler T γ u B N N ω-X T ω|≤E ω := byhave hh := le_initialMax (f:=fun k ↦|coupledEuler T γ u B N k ω-X (meshTime T N k) ω|) (le_refl N)change |coupledEuler T γ u B N N ω-X (meshTime T N N) ω|≤E ω at hhrwa [hlast] at hhexact (h.terminal_lipschitz hT.le _ _).trans(mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) h.K_nonneg)have heq:(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))=(∫ ω,F ω ∂μ) := byhave heum := measurable_euler T N γ u (fun j hj ↦ (hu.smooth _ (mesh_time_mem hT.le hN hj.le)).continuous.measurable) N le_rflhave hh := (coupledCoordinates_hasLaw hB hT hN).integral_comp (hm.measurable.comp heum).aestronglyMeasurablesimpa only [Function.comp_apply,F,coupledEuler,ite_eq_right (Nat.ne_of_gt hN)] using hh.symmrw [heq]exact first_moment_perturbation hFM hGM hEM h.K_nonneg (Eventually.of_forall hFG)end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191import Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshimport OAI.Probability.SKValue.Equations.TestGeneratornamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperators NNRealnamespace SKValuelemma BackwardTest.expectation_step {T K L t δ:ℝ} {γ:ℝ → ℝ} {u V:ℝ → ℝ → ℝ}(h:BackwardTest T γ u V K L) (ht:0≤t) (hδ:0≤δ) (hδ1:δ≤1) (htδ:t+δ≤T){N j:ℕ} (hj:j<N+1) {Y:(Fin (N+1) → ℝ) → ℝ}(hYm:Measurable Y) (hYp:DependsBefore j Y) :let μ := gaussianProduct (Fin (N+1))let Y' := fun z ↦ Y z+Real.sqrt δ*coordinate N j z+δ*γ t*u t (Y z)|(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)|≤δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (t+δ)-γ t) := bylet μ := gaussianProduct (Fin (N+1))let p := fun z ↦ deriv (V t) (Y z)let a := fun z ↦ deriv (deriv (V t)) (Y z)let Y' := fun z ↦ Y z+Real.sqrt δ*coordinate N j z+δ*γ t*u t (Y z)let P := fun z ↦ Real.sqrt δ*rawIncrement p j zlet Q := fun z ↦ (δ/2)*(a z*((coordinate N j z)^2-1))let D := fun z ↦ V (t+δ) (Y' z)-V t (Y z)let R := fun z ↦ D z-P z-Q zlet E := fun z ↦ δ*Real.sqrt δ*cubicEnvelope (γ T) K ((1/2+γ T)*L) (coordinate N j z)+δ*K*(γ (t+δ)-γ t)have htT:t≤T := (le_add_of_nonneg_right hδ).trans htδhave htm:t∈Icc (0:ℝ) T := ⟨ht,htT⟩have hem:t+δ∈Icc (0:ℝ) T := ⟨by linarith,htδ⟩have hpm:Measurable p := ((h.smooth t htm).continuous_deriv (by norm_num)).measurable.comp hYmhave ham:Measurable a := byhave hh := (h.smooth t htm).continuous_iteratedDeriv 2 (by norm_num)simp only [show (2:ℕ)=1+1 from rfl,iteratedDeriv_succ] at hhexact hh.measurable.comp hYmhave hpM:MemLp p 2 μ := MemLp.of_bound hpm.aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.first_bound t htm (Y z)))have haM:MemLp a 2 μ := MemLp.of_bound ham.aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.second_bound t htm (Y z)))have hpp:DependsBefore j p := fun z z' hz ↦ by dsimp only [p];rw [hYp z z' hz]have hap:DependsBefore j a := fun z z' hz ↦ by dsimp only [a];rw [hYp z z' hz]have hPi:Integrable P μ := (((rawIncrement_memLp hj hpm hpp hpM).const_mul _).integrable (by norm_num))have hQi:Integrable Q μ := (((predictableCenteredSquare_memLp ham (fun z ↦ h.second_bound t htm (Y z))).const_mul _).integrable (by norm_num))have hP0:(∫ z,P z ∂μ)=0 := bydsimp only [P]rw [integral_const_mul,rawIncrement_mean hj hpm hpp,mul_zero]have hQ0:(∫ z,Q z ∂μ)=0 := bydsimp only [Q]rw [integral_const_mul,predictableCenteredSquare_mean hj ham hap,mul_zero]have hY'm:Measurable Y' := (hYm.add ((measurable_coordinate N j).const_mul _)).add(((h.drift_measurable t htm).comp hYm).const_mul _)have hcur:Integrable (fun z ↦ V t (Y z)) μ :=(MemLp.of_bound ((h.smooth t htm).continuous.measurable.comp hYm).aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.bound t htm (Y z))) :MemLp (fun z ↦ V t (Y z)) 2 μ).integrable (by norm_num)have hnext:Integrable (fun z ↦ V (t+δ) (Y' z)) μ :=(MemLp.of_bound ((h.smooth (t+δ) hem).continuous.measurable.comp hY'm).aestronglyMeasurable K(Eventually.of_forall (fun z ↦ by simpa only [Real.norm_eq_abs] using h.bound (t+δ) hem (Y' z))) :MemLp (fun z ↦ V (t+δ) (Y' z)) 2 μ).integrable (by norm_num)have hDi:Integrable D μ := hnext.sub hcurhave hRi:Integrable R μ := (hDi.sub hPi).sub hQihave hEi0 := (cubicEnvelope_memLp_two (coordinate_hasLaw N j)(h.gamma_nonneg T ⟨ht.trans htT,le_rfl⟩) K ((1/2+γ T)*L)).integrable (by norm_num)have hEi:Integrable E μ := (hEi0.const_mul _).add (integrable_const _)have hRE (z) : |R z|≤E z := byhave hh := h.euler_one_step ht hδ hδ1 htδ (x:=Y z) (z:=coordinate N j z)convert! hh using 1dsimp only [R,D,P,Q,p,a,Y',E,rawIncrement]congr 1ring_nfhave hRmean:(∫ z,R z ∂μ)=(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ) := byhave hs := integral_sub (hDi.sub hPi) hQichange (∫ z,D z-P z-Q z ∂μ)=(∫ z,D z-P z ∂μ)-(∫ z,Q z ∂μ) at hshave hs1 := integral_sub hDi hPichange (∫ z,D z-P z ∂μ)=(∫ z,D z ∂μ)-(∫ z,P z ∂μ) at hs1change (∫ z,D z-P z-Q z ∂μ)=_rw [hs,hs1,hP0,hQ0,sub_zero,sub_zero]exact integral_sub hnext hcurhave hEmean:(∫ z,E z ∂μ)=δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (t+δ)-γ t) := bydsimp only [E]rw [integral_add (hEi0.const_mul _) (integrable_const _),integral_const_mul]simp only [integral_const,probReal_univ,smul_eq_mul,one_mul]have he:(∫ z,cubicEnvelope (γ T) K ((1/2+γ T)*L) (coordinate N j z) ∂μ)=cubicEnvelopeMean (γ T) K ((1/2+γ T)*L) := bysimpa only [Function.comp_def,cubicEnvelopeMean,standardGaussian] using(coordinate_hasLaw N j).integral_comp (measurable_cubicEnvelope (γ T) K ((1/2+γ T)*L)).aestronglyMeasurablerw [he]change |(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)|≤_rw [←hRmean,←hEmean]exact abs_integral_le_integral_abs.trans (integral_mono hRi.norm hEi hRE)end SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperators NNRealnamespace SKValuelemma BackwardTest.mesh_expectation {T K L:ℝ} {γ:ℝ → ℝ} {u V:ℝ → ℝ → ℝ}(h:BackwardTest T γ u V K L) (hT:0<T) (hT1:T≤1) {N:ℕ} (hN:0<N) :|(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))-V 0 0|≤T*Real.sqrt (stepSize T N)*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+stepSize T N*K*(γ T-γ 0) := bylet δ := stepSize T Nlet A := fun j ↦ ∫ z,V (meshTime T N j) (euler T N γ u z j) ∂gaussianProduct (Fin (N+1))have hNr:0<(N:ℝ) := by exact_mod_cast hNhave hδ:0≤δ := div_nonneg hT.le hNr.lehave hδ1:δ≤1 := byapply (div_le_iff₀ hNr).mprhave hn:(1:ℝ)≤N := by exact_mod_cast hNsimpa only [one_mul] using hT1.trans hnhave htime (j:ℕ) (hj:j≤N) := mesh_time_mem hT.le hN hjhave hs (j:ℕ) : meshTime T N j+δ=meshTime T N (j+1) := by dsimp [meshTime];push_cast;ringhave hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simphave hzero:meshTime T N 0=0 := by simp [meshTime]have hum (j:ℕ) (hj:j<N) : Measurable (u (meshTime T N j)) := h.drift_measurable _ (htime j hj.le)have hstep (j:ℕ) (hj:j<N) : |A (j+1)-A j+0|≤δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (meshTime T N (j+1))-γ (meshTime T N j))+0*((0:ℝ)-0) := byhave hYp:DependsBefore j (fun z ↦ euler T N γ u z j) :=eulerCoefficient_dependsBefore T hj.le γ u (fun _ y ↦ y)have he := h.expectation_step (htime j hj.le).1 hδ hδ1(by rw [hs];exact (htime (j+1) (by omega)).2) (by omega:j<N+1)(measurable_euler T N γ u hum j hj.le) hYpdsimp only at herw [hs] at hesimpa only [A,euler,δ,mul_assoc,add_zero,sub_self,mul_zero] using hehave hh := abs_telescope_source (A:=A) (b:=fun _ ↦ 0) (Γ:=fun j ↦ γ (meshTime T N j))(Δ:=fun _ ↦ 0) (e:=0) hstephave hA0:A 0=V 0 0 := by simp [A,meshTime,euler]rw [hA0,show A N=(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1))) bydsimp only [A];rw [hlast],hlast,hzero] at hhhave hNd:(N:ℝ)*δ=T := by dsimp [δ,stepSize];field_simpsimpa only [Finset.sum_const_zero,add_zero,sub_self,mul_zero,←mul_assoc,hNd] using hhlemma BackwardTest.terminal_lipschitz {T K L:ℝ} {γ:ℝ → ℝ} {u V:ℝ → ℝ → ℝ}(h:BackwardTest T γ u V K L) (hT:0≤T) (x y:ℝ) : |V T x-V T y|≤K*|x-y| := byhave hd := (h.smooth T ⟨hT,le_rfl⟩).differentiable (by norm_num)have hb:∀ z,‖deriv (V T) z‖≤K := fun z ↦ by simpa only [Real.norm_eq_abs] using h.first_bound T ⟨hT,le_rfl⟩ zhave hl : LipschitzWith ⟨K,h.K_nonneg⟩ (V T) := byapply lipschitzWith_of_nnnorm_deriv_le hdintro zexact_mod_cast hb zhave hh := hl.dist_le_mul x ychange |V T x-V T y|≤K*|x-y| at hhexact hhlemma BackwardTest.coupled_terminal_error {Ω:Type*} [MeasurableSpace Ω] {μ:Measure Ω}[IsProbabilityMeasure μ] {B:ℝ≥0 → Ω → ℝ} (hB:IsPreBrownianReal B μ){X:ℝ → Ω → ℝ} {T K L K' L':ℝ} {γ:ℝ → ℝ} {u V:ℝ → ℝ → ℝ}(hT:0<T) (hu:GradientStrip T γ u K L) (h:BackwardTest T γ u V K' L')(hXM:∀ t∈Icc (0:ℝ) T,AEStronglyMeasurable (X t) μ)(hpaths:∀ᵐ ω ∂μ,(∀ t∈Icc (0:ℝ) T,X t ω=B t.toNNReal ω+∫ s in (0:ℝ)..t,γ s*u s (X s ω)) ∧ X 0 ω=0) {N:ℕ} (hN:0<N) :|(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))-(∫ ω,V T (X T ω) ∂μ)|≤K'*Real.sqrt (∫ ω,(meshMaxError T X (coupledEuler T γ u B) N ω)^2 ∂μ) := bylet F := fun ω ↦ V T (coupledEuler T γ u B N N ω)let G := fun ω ↦ V T (X T ω)let E := meshMaxError T X (coupledEuler T γ u B) Nhave ht:T∈Icc (0:ℝ) T := ⟨hT.le,le_rfl⟩have hm:Continuous (V T) := (h.smooth T ht).continuoushave hFM:MemLp F 2 μ := MemLp.of_bound(hm.measurable.comp_aemeasurable (coupled_euler_measurable hB hT hu N N le_rfl).aemeasurable).aestronglyMeasurable K'(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs,F] using h.bound T ht _))have hGM:MemLp G 2 μ := MemLp.of_bound(hm.measurable.comp_aemeasurable (hXM T ht).aemeasurable).aestronglyMeasurable K'(Eventually.of_forall (fun ω ↦ by simpa only [Real.norm_eq_abs,G] using h.bound T ht _))have hEM:MemLp E 2 μ := coupled_mesh_error_memLp hB hT hu hXM hpaths hNhave hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simphave hFG (ω:Ω) : |F ω-G ω|≤K'*|E ω| := byhave he:|coupledEuler T γ u B N N ω-X T ω|≤E ω := byhave hh := le_initialMax (f:=fun k ↦|coupledEuler T γ u B N k ω-X (meshTime T N k) ω|) (le_refl N)change |coupledEuler T γ u B N N ω-X (meshTime T N N) ω|≤E ω at hhrwa [hlast] at hhexact (h.terminal_lipschitz hT.le _ _).trans(mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) h.K_nonneg)have heq:(∫ z,V T (euler T N γ u z N) ∂gaussianProduct (Fin (N+1)))=(∫ ω,F ω ∂μ) := byhave heum := measurable_euler T N γ u (fun j hj ↦ (hu.smooth _ (mesh_time_mem hT.le hN hj.le)).continuous.measurable) N le_rflhave hh := (coupledCoordinates_hasLaw hB hT hN).integral_comp (hm.measurable.comp heum).aestronglyMeasurablesimpa only [Function.comp_apply,F,coupledEuler,ite_eq_right (Nat.ne_of_gt hN)] using hh.symmrw [heq]exact first_moment_perturbation hFM hGM hEM h.K_nonneg (Eventually.of_forall hFG)end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396import Mathlibnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValuevariable {Ω : Type*} {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]structure UnitMomentMartingale (ℱ : Filtration ℝ m) (f : ℝ → Ω → ℝ) : Prop wheremeasurable : ∀ t ∈ Ico (0 : ℝ) 1, StronglyMeasurable[ℱ t] (f t)bounded : ∀ t ∈ Ico (0 : ℝ) 1, ∀ ω, |f t ω| ≤ 1condExp : ∀ s ∈ Ico (0 : ℝ) 1, ∀ t ∈ Ico (0 : ℝ) 1, s ≤ t →μ[f t | ℱ s] =ᵐ[μ] f ssecondMoment : ∀ t ∈ Ico (0 : ℝ) 1, ∫ ω, (f t ω)^2 ∂μ = tvariable {ℱ : Filtration ℝ m} {f : ℝ → Ω → ℝ}lemma UnitMomentMartingale.integrable (h : UnitMomentMartingale (μ := μ) ℱ f){t : ℝ} (ht : t ∈ Ico (0 : ℝ) 1) : Integrable (f t) μ :=Integrable.of_bound ((h.measurable t ht).mono (ℱ.le t)).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ (Real.norm_eq_abs _).trans_le (h.bounded t ht ω)))lemma UnitMomentMartingale.integrable_mul (h : UnitMomentMartingale (μ := μ) ℱ f){s t : ℝ} (hs : s ∈ Ico (0 : ℝ) 1) (ht : t ∈ Ico (0 : ℝ) 1) :Integrable (fun ω ↦ f s ω * f t ω) μ :=Integrable.of_bound (((h.measurable s hs).mono (ℱ.le s)).mul((h.measurable t ht).mono (ℱ.le t))).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ byrw [Real.norm_eq_abs,abs_mul]nlinarith [h.bounded s hs ω,h.bounded t ht ω,abs_nonneg (f s ω),abs_nonneg (f t ω)]))lemma UnitMomentMartingale.integral_past_mul (h : UnitMomentMartingale (μ := μ) ℱ f){s t : ℝ} (hs : s ∈ Ico (0 : ℝ) 1) (ht : t ∈ Ico (0 : ℝ) 1) (hst : s ≤ t) :∫ ω, f s ω * f t ω ∂μ = s := byhave hc := condExp_mul_of_stronglyMeasurable_left (h.measurable s hs)(h.integrable_mul hs ht) (h.integrable ht)have he : μ[(f s) * (f t) | ℱ s] =ᵐ[μ] fun ω ↦ (f s ω)^2 := byfilter_upwards [hc,h.condExp s hs t ht hst] with ω hω hω'simpa only [Pi.mul_apply,hω',pow_two] using hωcalc_ = ∫ ω, μ[(f s) * (f t) | ℱ s] ω ∂μ := (integral_condExp (ℱ.le s)).symm_ = ∫ ω, (f s ω)^2 ∂μ := integral_congr_ae he_ = s := h.secondMoment s hslemma UnitMomentMartingale.sampled_gap_martingale(h : UnitMomentMartingale (μ := μ) ℱ f) {s : ℝ}(hs : s ∈ Ico (0 : ℝ) 1) (r : ℕ → ℝ) (hr : Monotone r)(hrmem : ∀ n, r n ∈ Ico s 1) :Martingale (fun n ω ↦ 1-f s ω*f (r n) ω)(⟨fun n ↦ ℱ (r n),fun _ _ hij ↦ ℱ.mono (hr hij),fun n ↦ ℱ.le (r n)⟩ :Filtration ℕ m) μ := byhave ht (n : ℕ) : r n ∈ Ico (0 : ℝ) 1 := ⟨hs.1.trans (hrmem n).1,(hrmem n).2⟩refine ⟨fun n ↦ stronglyMeasurable_const.sub(((h.measurable s hs).mono (ℱ.mono (hrmem n).1)).mul (h.measurable (r n) (ht n))),?_⟩intro i j hijhave hc := condExp_mul_of_stronglyMeasurable_left((h.measurable s hs).mono (ℱ.mono (hrmem i).1))(h.integrable_mul hs (ht j)) (h.integrable (ht j))have hc1 := condExp_of_stronglyMeasurable (ℱ.le (r i))(stronglyMeasurable_const (b := (1 : ℝ))) (integrable_const (μ := μ) 1)filter_upwards [condExp_sub (integrable_const (1 : ℝ))(h.integrable_mul hs (ht j)) (ℱ (r i)),hc,h.condExp (r i) (ht i) (r j) (ht j) (hr hij)] with ω hsub hmul hesimp only [Pi.sub_apply] at hsubchange μ[(fun ω ↦ f s ω*f (r j) ω) | ℱ (r i)] ω =f s ω*μ[f (r j) | ℱ (r i)] ω at hmulrw [hc1,hmul] at hsubsimpa only [Pi.sub_def,Pi.mul_def,Pi.mul_apply,he] using hsubomit [IsProbabilityMeasure μ] inlemma UnitMomentMartingale.sampled_gap_nonneg(h : UnitMomentMartingale (μ := μ) ℱ f) {s t : ℝ}(hs : s ∈ Ico (0 : ℝ) 1) (ht : t ∈ Ico (0 : ℝ) 1) (ω : Ω) :0 ≤ 1-f s ω*f t ω := byhave hh : f s ω*f t ω ≤ 1 := calc_ ≤ |f s ω*f t ω| := le_abs_self __ = |f s ω| * |f t ω| := abs_mul _ __ ≤ 1 := by nlinarith [h.bounded s hs ω,h.bounded t ht ω,abs_nonneg (f s ω),abs_nonneg (f t ω)]linarithlemma UnitMomentMartingale.sampled_gap_integral(h : UnitMomentMartingale (μ := μ) ℱ f) {s t : ℝ}(hs : s ∈ Ico (0 : ℝ) 1) (ht : t ∈ Ico (0 : ℝ) 1) (hst : s ≤ t) :∫ ω, 1-f s ω*f t ω ∂μ = 1-s := byrw [integral_sub (integrable_const 1) (h.integrable_mul hs ht),h.integral_past_mul hs ht hst]simplemma UnitMomentMartingale.finite_gap_maximal(h : UnitMomentMartingale (μ := μ) ℱ f) {s : ℝ}(hs : s ∈ Ico (0 : ℝ) 1) (S : Finset ℝ)(hS : ∀ t ∈ S, t ∈ Ico s 1) (ε : ℝ≥0) :(ε : ℝ≥0∞) * μ {ω | ∃ t ∈ S, (ε : ℝ) ≤ 1-f s ω*f t ω} ≤ENNReal.ofReal (1-s) := byclassicalby_cases hne : S.Nonempty· have hcard : 0 < S.card := Finset.card_pos.mpr hnelet e := S.orderEmbOfFin rfllet r : ℕ → ℝ := fun n ↦ e ⟨min n (S.card-1),by omega⟩have hr : Monotone r := byintro i j hijexact e.monotone (show min i (S.card-1) ≤ min j (S.card-1) from min_le_min_right _ hij)have hrmem (n : ℕ) : r n ∈ Ico s 1 := hS _ (S.orderEmbOfFin_mem rfl _)have hm := h.sampled_gap_martingale hs r hr hrmemhave hn : 0 ≤ (fun n ω ↦ 1-f s ω*f (r n) ω) :=fun n ω ↦ h.sampled_gap_nonneg hs ⟨hs.1.trans (hrmem n).1,(hrmem n).2⟩ ωhave hb := maximal_ineq hm.submartingale hn (ε := ε) (S.card-1)have hset : {ω | ∃ t ∈ S, (ε : ℝ) ≤ 1-f s ω*f t ω} ⊆{ω | (ε : ℝ) ≤ (Finset.range ((S.card-1)+1)).sup' Finset.nonempty_range_add_one(fun k ↦ 1-f s ω*f (r k) ω)} := byrintro ω ⟨t,ht,heps⟩let i := (S.orderIsoOfFin rfl).symm ⟨t,ht⟩have her : r i.val = t := bydsimp only [r]have hh : (⟨min i.val (S.card-1),by omega⟩ : Fin S.card) = i :=Fin.ext (min_eq_left (by omega))rw [hh]change ((S.orderIsoOfFin rfl) i).val = tsimp [i]refine heps.trans ?_rw [← her]exact Finset.le_sup' (f := fun k ↦ 1-f s ω*f (r k) ω)(Finset.mem_range.mpr (by omega : i.val < (S.card-1)+1))calc_ ≤ (ε : ℝ≥0∞) * μ {ω | (ε : ℝ) ≤(Finset.range ((S.card-1)+1)).sup' Finset.nonempty_range_add_one(fun k ↦ 1-f s ω*f (r k) ω)} := by gcongr_ ≤ _ := hb_ ≤ ENNReal.ofReal (∫ ω, 1-f s ω*f (r (S.card-1)) ω ∂μ) := byapply ENNReal.ofReal_le_ofRealexact setIntegral_le_integral (integrable_const 1 |>.sub(h.integrable_mul hs ⟨hs.1.trans (hrmem _).1,(hrmem _).2⟩))(Eventually.of_forall (hn (S.card-1)))_ = _ := congrArg ENNReal.ofReal (h.sampled_gap_integral hs⟨hs.1.trans (hrmem _).1,(hrmem _).2⟩ (hrmem _).1)· simp [Finset.not_nonempty_iff_eq_empty.mp hne]lemma UnitMomentMartingale.rational_gap_maximal(h : UnitMomentMartingale (μ := μ) ℱ f) {s : ℝ}(hs : s ∈ Ico (0 : ℝ) 1) (ε : ℝ≥0) :(ε : ℝ≥0∞) * μ {ω | ∃ q : ℚ, (q : ℝ) ∈ Ico s 1 ∧(ε : ℝ) ≤ 1-f s ω*f q ω} ≤ ENNReal.ofReal (1-s) := byclassicallet E : Finset ℚ → Set Ω := fun S ↦ {ω | ∃ q ∈ S, (q : ℝ) ∈ Ico s 1 ∧(ε : ℝ) ≤ 1-f s ω*f q ω}have hd : Directed (· ⊆ ·) E := byintro S Trefine ⟨S∪T, ?_, ?_⟩· rintro ω ⟨q,hq,hmem,he⟩exact ⟨q,Finset.mem_union_left _ hq,hmem,he⟩· rintro ω ⟨q,hq,hmem,he⟩exact ⟨q,Finset.mem_union_right _ hq,hmem,he⟩have heq : {ω | ∃ q : ℚ, (q : ℝ) ∈ Ico s 1 ∧ (ε : ℝ) ≤ 1-f s ω*f q ω} =⋃ S : Finset ℚ, E S := byext ωconstructor· rintro ⟨q,hmem,he⟩exact mem_iUnion.mpr ⟨{q},q,Finset.mem_singleton_self _,hmem,he⟩· intro hωobtain ⟨S,q,hq,hmem,he⟩ := mem_iUnion.mp hωexact ⟨q,hmem,he⟩rw [heq,hd.measure_iUnion,ENNReal.mul_iSup]refine iSup_le fun S ↦ ?_let R : Finset ℝ := (S.filter (fun q : ℚ ↦ (q : ℝ) ∈ Ico s 1)).image (fun q : ℚ ↦ (q : ℝ))have hR : ∀ t ∈ R, t ∈ Ico s 1 := byintro t htobtain ⟨q,hq,rfl⟩ := Finset.mem_image.mp htexact (Finset.mem_filter.mp hq).2have hE : E S ⊆ {ω | ∃ t ∈ R, (ε : ℝ) ≤ 1-f s ω*f t ω} := byrintro ω ⟨q,hq,hmem,he⟩exact ⟨(q : ℝ),Finset.mem_image.mpr ⟨q,Finset.mem_filter.mpr ⟨hq,hmem⟩,rfl⟩,he⟩calc_ ≤ (ε : ℝ≥0∞) * μ {ω | ∃ t ∈ R, (ε : ℝ) ≤ 1-f s ω*f t ω} := by gcongr_ ≤ _ := h.finite_gap_maximal hs R hR εnoncomputable def terminalTime (n : ℕ) : ℝ := 1-1/(n+1)lemma terminalTime_mem (n : ℕ) : terminalTime n ∈ Ico (0 : ℝ) 1 := byhave hn : (1 : ℝ) ≤ n+1 := by linarith [Nat.cast_nonneg (α := ℝ) n]have hp : (0 : ℝ) < n+1 := by positivitysimp only [terminalTime]constructor· have hh : (1 : ℝ)/(n+1) ≤ 1 := (div_le_one hp).mpr hnlinarith· have hh : (0 : ℝ) < 1/(n+1) := by positivitylinarithlemma terminalTime_monotone : Monotone terminalTime := byintro i j hijsimp only [terminalTime]have hh : (1 : ℝ)/(j+1) ≤ 1/(i+1) := one_div_le_one_div_of_le(by positivity) (by exact_mod_cast Nat.add_le_add_right hij 1)linarithlemma terminalTime_tendsto : Tendsto terminalTime atTop (𝓝[<] (1 : ℝ)) := byrefine tendsto_nhdsWithin_iff.mpr ⟨?_,Eventually.of_forall (fun n ↦ (terminalTime_mem n).2)⟩change Tendsto (fun n : ℕ ↦ (1 : ℝ)-1/((n : ℝ)+1)) atTop (𝓝 (1 : ℝ))simpa only [sub_zero] using (tendsto_const_nhds (x := (1 : ℝ))).sub(tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ))lemma UnitMomentMartingale.ae_exists_rational_gap_bound(h : UnitMomentMartingale (μ := μ) ℱ f) {ε : ℝ} (hε : 0 < ε) :∀ᵐ ω ∂μ, ∃ n, ∀ q : ℚ, (q : ℝ) ∈ Ico (terminalTime n) 1 →1-f (terminalTime n) ω*f q ω < ε := bylet E : ℕ → Set Ω := fun n ↦ {ω | ∃ q : ℚ, (q : ℝ) ∈ Ico (terminalTime n) 1 ∧ε ≤ 1-f (terminalTime n) ω*f q ω}have hbound (n : ℕ) : ENNReal.ofReal ε * μ (⋂ n, E n) ≤ENNReal.ofReal (1-terminalTime n) := calc_ ≤ ENNReal.ofReal ε * μ (E n) := by gcongr; exact iInter_subset E n_ ≤ _ := byhave hh := h.rational_gap_maximal (terminalTime_mem n) (NNReal.mk ε hε.le)simpa only [E,NNReal.coe_mk,ENNReal.coe_nnreal_eq] using hhhave hzero : ENNReal.ofReal ε * μ (⋂ n, E n) = 0 := byapply le_antisymm _ bot_lehave hlim : Tendsto (fun n ↦ ENNReal.ofReal (1-terminalTime n)) atTop (𝓝 0) := byhave hh : Tendsto (fun n ↦ 1-terminalTime n) atTop (𝓝 (0 : ℝ)) := bysimpa only [sub_self] using ((tendsto_const_nhds (x := (1 : ℝ))).sub(tendsto_nhdsWithin_iff.mp terminalTime_tendsto).1)simpa only [ENNReal.ofReal_zero,Function.comp_def] usingENNReal.continuous_ofReal.continuousAt.tendsto.comp hhexact ge_of_tendsto' hlim hboundhave hn : μ (⋂ n, E n) = 0 := (mul_eq_zero.mp hzero).resolve_left(ne_of_gt (ENNReal.ofReal_pos.mpr hε))have ha : ∀ᵐ ω ∂μ, ω ∉ ⋂ n, E n := byrw [ae_iff]convert hn using 1simp only [not_not,Set.ofPred_mem_eq]filter_upwards [ha] with ω hωsimp only [mem_iInter,E,mem_ofPred_eq,not_forall,not_exists,not_and,not_le] at hωexact hωlemma continuous_gap_bound_of_rat {v : ℝ → ℝ}(hv : ContinuousOn v (Ico (0 : ℝ) 1)) {s ε : ℝ}(hs : s ∈ Ico (0 : ℝ) 1)(hq : ∀ q : ℚ, (q : ℝ) ∈ Ico s 1 → 1-v s*v q < ε) :∀ t ∈ Ioo s 1, 1-v s*v t ≤ ε := byintro t htby_contra! hehave hvt : ContinuousAt v t := (hv t ⟨hs.1.trans ht.1.le,ht.2⟩).continuousAt(Ico_mem_nhds_iff.mpr ⟨hs.1.trans_lt ht.1,ht.2⟩)have hgt : ContinuousAt (fun r ↦ 1-v s*v r) t := continuousAt_const.sub(continuousAt_const.mul hvt)have hevent : {r | ε < 1-v s*v r} ∈ 𝓝 t := hgt (Ioi_mem_nhds he)obtain ⟨q,hq'⟩ := Rat.denseRange_cast.mem_nhds (inter_mem hevent (Ioo_mem_nhds ht.1 ht.2))exact (hq q ⟨hq'.2.1.le,hq'.2.2⟩).not_gt hq'.1lemma UnitMomentMartingale.exists_sequence_terminal(h : UnitMomentMartingale (μ := μ) ℱ f) :∃ U : Ω → ℝ, StronglyMeasurable[ℱ 1] U ∧(∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))) := bylet 𝒢 : Filtration ℕ m := ⟨fun n ↦ ℱ (terminalTime n),fun _ _ hij ↦ ℱ.mono (terminalTime_monotone hij),fun n ↦ ℱ.le _⟩have hm : Martingale (fun n ↦ f (terminalTime n)) 𝒢 μ :=⟨fun n ↦ h.measurable _ (terminalTime_mem n),fun i j hij ↦h.condExp _ (terminalTime_mem i) _ (terminalTime_mem j) (terminalTime_monotone hij)⟩have hb (n : ℕ) : eLpNorm (f (terminalTime n)) 1 μ ≤ (1 : ℝ≥0) := byhave hh := eLpNorm_le_of_ae_bound (μ := μ) (p := (1 : ℝ≥0∞))(h.integrable (terminalTime_mem n)).aestronglyMeasurable(Eventually.of_forall (fun ω ↦ (Real.norm_eq_abs _).trans_le(h.bounded _ (terminalTime_mem n) ω)))simpa using hhlet U := 𝒢.limitProcess (fun n ↦ f (terminalTime n)) μhave hU : StronglyMeasurable[ℱ 1] U :=Filtration.stronglyMeasurable_limitProcess.mono (iSup_le fun n ↦ ℱ.mono (terminalTime_mem n).2.le)refine ⟨U,hU,?_⟩filter_upwards [hm.submartingale.ae_tendsto_limitProcess hb] with ω hωexact ⟨le_of_tendsto' hω.abs (fun n ↦ h.bounded _ (terminalTime_mem n) ω),hω⟩lemma UnitMomentMartingale.exists_continuous_terminal(h : UnitMomentMartingale (μ := μ) ℱ f)(hc : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ f t ω) (Ico (0 : ℝ) 1)) :∃ U : Ω → ℝ, StronglyMeasurable[ℱ 1] U ∧(∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun t ↦ f t ω) (𝓝[<] (1 : ℝ)) (𝓝 (U ω))) := byobtain ⟨U,hU,hseq⟩ := h.exists_sequence_terminalhave hg : ∀ᵐ ω ∂μ, ∀ k : ℕ, ∃ n, ∀ q : ℚ,(q : ℝ) ∈ Ico (terminalTime n) 1 →1-f (terminalTime n) ω*f q ω < 1/(k+1) := byapply ae_all_iff.mprintro kexact h.ae_exists_rational_gap_bound (by positivity)refine ⟨U,hU,?_⟩filter_upwards [hc,hseq,hg] with ω hcont hseqω hgaprefine ⟨hseqω.1,Metric.tendsto_nhds.mpr (fun δ hδ ↦ ?_)⟩obtain ⟨k,hk⟩ : ∃ k : ℕ, (1 : ℝ)/(k+1) < δ^2/32 := byhave hh := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).eventually(Iio_mem_nhds (show (0 : ℝ) < δ^2/32 by positivity))exact hh.existsobtain ⟨n,hn⟩ := hgap khave hreal := continuous_gap_bound_of_rat hcont (terminalTime_mem n) hnhave hbound (t : ℝ) (ht : t ∈ Ioo (terminalTime n) 1) :|f t ω-f (terminalTime n) ω| ≤ δ/4 := byhave hbt := h.bounded t ⟨(terminalTime_mem n).1.trans ht.1.le,ht.2⟩ ωhave hbs := h.bounded _ (terminalTime_mem n) ωhave he := hreal t hthave hsq1 : (f t ω)^2 ≤ 1 := by nlinarith [abs_le.mp hbt]have hsq2 : (f (terminalTime n) ω)^2 ≤ 1 := by nlinarith [abs_le.mp hbs]have habs : |f t ω-f (terminalTime n) ω|^2 < (δ/4)^2 := byrw [sq_abs]nlinarithnlinarith [abs_nonneg (f t ω-f (terminalTime n) ω)]have hUb : |U ω-f (terminalTime n) ω| ≤ δ/4 := byapply le_of_tendsto ((hseqω.2.sub_const _).abs)have hev : ∀ᶠ k in atTop, terminalTime k ∈ Ioo (terminalTime n) 1 :=terminalTime_tendsto.eventually (Ioo_mem_nhdsLT (terminalTime_mem n).2)exact hev.mono (fun k hk ↦ hbound _ hk)filter_upwards [Ioo_mem_nhdsLT (terminalTime_mem n).2] with t htrw [Real.dist_eq]have hh := abs_add_le (f t ω-f (terminalTime n) ω) (f (terminalTime n) ω-U ω)have hh' := hbound t hthave hUb' : |f (terminalTime n) ω-U ω| ≤ δ/4 := by simpa only [abs_sub_comm] using hUbhave heq : f t ω-U ω = (f t ω-f (terminalTime n) ω)+(f (terminalTime n) ω-U ω) := by ringrw [heq]linarithlemma UnitMomentMartingale.terminal_square(h : UnitMomentMartingale (μ := μ) ℱ f) {U : Ω → ℝ}(hUm : StronglyMeasurable[ℱ 1] U)(hU : ∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))) :∀ᵐ ω ∂μ, (U ω)^2 = 1 := byhave hU2i : Integrable (fun ω ↦ (U ω)^2) μ :=Integrable.of_bound ((hUm.mono (ℱ.le 1)).pow 2).aestronglyMeasurable 1(hU.mono (fun ω hω ↦ byrw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)]nlinarith [abs_le.mp hω.1]))have ht := tendsto_integral_of_dominated_convergence (μ := μ)(F := fun n ω ↦ (f (terminalTime n) ω)^2) (fun _ : Ω ↦ (1 : ℝ))(fun n ↦ (((h.measurable _ (terminalTime_mem n)).mono (ℱ.le _)).pow 2).aestronglyMeasurable)(integrable_const 1)(fun n ↦ Eventually.of_forall (fun ω ↦ byrw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)]nlinarith [abs_le.mp (h.bounded _ (terminalTime_mem n) ω)]))(hU.mono (fun ω hω ↦ hω.2.pow 2))have hi : ∫ ω, (U ω)^2 ∂μ = 1 := byhave hh : (fun n ↦ ∫ ω, (f (terminalTime n) ω)^2 ∂μ) = terminalTime :=funext (fun n ↦ h.secondMoment _ (terminalTime_mem n))rw [hh] at htexact tendsto_nhds_unique ht (tendsto_nhdsWithin_iff.mp terminalTime_tendsto).1have hnonneg : 0 ≤ᵐ[μ] (fun ω ↦ 1-(U ω)^2) := hU.mono (fun ω hω ↦ bydsimpnlinarith [abs_le.mp hω.1])have hzero : ∫ ω, 1-(U ω)^2 ∂μ = 0 := byrw [integral_sub (integrable_const 1) hU2i,hi]simphave he := (integral_eq_zero_iff_of_nonneg_ae hnonneg ((integrable_const 1).sub hU2i)).mp hzerofilter_upwards [he] with ω hωchange 1-(U ω)^2=0 at hωlinarithlemma UnitMomentMartingale.terminal_mean_square(h : UnitMomentMartingale (μ := μ) ℱ f) {U : Ω → ℝ}(hUm : StronglyMeasurable[ℱ 1] U)(hU : ∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun t ↦ f t ω) (𝓝[<] (1 : ℝ)) (𝓝 (U ω))) :Tendsto (fun t ↦ ∫ ω, (f t ω-U ω)^2 ∂μ) (𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) := byhave hev : ∀ᶠ t in 𝓝[<] (1 : ℝ), t ∈ Ico (0 : ℝ) 1 := byfilter_upwards [Ioo_mem_nhdsLT (show (0 : ℝ)<1 by norm_num)] with t htexact ⟨ht.1.le,ht.2⟩have ht := tendsto_integral_filter_of_dominated_convergence (μ := μ)(F := fun t ω ↦ (f t ω-U ω)^2) (f := fun _ ↦ (0 : ℝ)) (fun _ : Ω ↦ (4 : ℝ))(hev.mono (fun t ht ↦ ((((h.measurable t ht).mono (ℱ.le t)).sub(hUm.mono (ℱ.le 1))).pow 2).aestronglyMeasurable))(hev.mono (fun t ht ↦ hU.mono (fun ω hω ↦ byrw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)]have hb := h.bounded t ht ωhave hd : |f t ω-U ω| ≤ 2 := (abs_sub _ _).trans (by linarith [hω.1])nlinarith [sq_abs (f t ω-U ω),abs_nonneg (f t ω-U ω)])))(integrable_const 4)(hU.mono (fun ω hω ↦ bysimpa only [sub_self,zero_pow (by decide : (2 : ℕ) ≠ 0)] using (hω.2.sub_const (U ω)).pow 2))simpa only [integral_zero] using htend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396import Mathlibnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValuevariable {Ω : Type*} {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]structure UnitMomentMartingale (ℱ : Filtration ℝ m) (f : ℝ → Ω → ℝ) : Prop wheremeasurable : ∀ t ∈ Ico (0 : ℝ) 1, StronglyMeasurable[ℱ t] (f t)bounded : ∀ t ∈ Ico (0 : ℝ) 1, ∀ ω, |f t ω| ≤ 1condExp : ∀ s ∈ Ico (0 : ℝ) 1, ∀ t ∈ Ico (0 : ℝ) 1, s ≤ t →μ[f t | ℱ s] =ᵐ[μ] f ssecondMoment : ∀ t ∈ Ico (0 : ℝ) 1, ∫ ω, (f t ω)^2 ∂μ = tvariable {ℱ : Filtration ℝ m} {f : ℝ → Ω → ℝ}lemma UnitMomentMartingale.integrable (h : UnitMomentMartingale (μ := μ) ℱ f){t : ℝ} (ht : t ∈ Ico (0 : ℝ) 1) : Integrable (f t) μ :=Integrable.of_bound ((h.measurable t ht).mono (ℱ.le t)).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ (Real.norm_eq_abs _).trans_le (h.bounded t ht ω)))lemma UnitMomentMartingale.integrable_mul (h : UnitMomentMartingale (μ := μ) ℱ f){s t : ℝ} (hs : s ∈ Ico (0 : ℝ) 1) (ht : t ∈ Ico (0 : ℝ) 1) :Integrable (fun ω ↦ f s ω * f t ω) μ :=Integrable.of_bound (((h.measurable s hs).mono (ℱ.le s)).mul((h.measurable t ht).mono (ℱ.le t))).aestronglyMeasurable 1(Eventually.of_forall (fun ω ↦ byrw [Real.norm_eq_abs,abs_mul]nlinarith [h.bounded s hs ω,h.bounded t ht ω,abs_nonneg (f s ω),abs_nonneg (f t ω)]))lemma UnitMomentMartingale.integral_past_mul (h : UnitMomentMartingale (μ := μ) ℱ f){s t : ℝ} (hs : s ∈ Ico (0 : ℝ) 1) (ht : t ∈ Ico (0 : ℝ) 1) (hst : s ≤ t) :∫ ω, f s ω * f t ω ∂μ = s := byhave hc := condExp_mul_of_stronglyMeasurable_left (h.measurable s hs)(h.integrable_mul hs ht) (h.integrable ht)have he : μ[(f s) * (f t) | ℱ s] =ᵐ[μ] fun ω ↦ (f s ω)^2 := byfilter_upwards [hc,h.condExp s hs t ht hst] with ω hω hω'simpa only [Pi.mul_apply,hω',pow_two] using hωcalc_ = ∫ ω, μ[(f s) * (f t) | ℱ s] ω ∂μ := (integral_condExp (ℱ.le s)).symm_ = ∫ ω, (f s ω)^2 ∂μ := integral_congr_ae he_ = s := h.secondMoment s hslemma UnitMomentMartingale.sampled_gap_martingale(h : UnitMomentMartingale (μ := μ) ℱ f) {s : ℝ}(hs : s ∈ Ico (0 : ℝ) 1) (r : ℕ → ℝ) (hr : Monotone r)(hrmem : ∀ n, r n ∈ Ico s 1) :Martingale (fun n ω ↦ 1-f s ω*f (r n) ω)(⟨fun n ↦ ℱ (r n),fun _ _ hij ↦ ℱ.mono (hr hij),fun n ↦ ℱ.le (r n)⟩ :Filtration ℕ m) μ := byhave ht (n : ℕ) : r n ∈ Ico (0 : ℝ) 1 := ⟨hs.1.trans (hrmem n).1,(hrmem n).2⟩refine ⟨fun n ↦ stronglyMeasurable_const.sub(((h.measurable s hs).mono (ℱ.mono (hrmem n).1)).mul (h.measurable (r n) (ht n))),?_⟩intro i j hijhave hc := condExp_mul_of_stronglyMeasurable_left((h.measurable s hs).mono (ℱ.mono (hrmem i).1))(h.integrable_mul hs (ht j)) (h.integrable (ht j))have hc1 := condExp_of_stronglyMeasurable (ℱ.le (r i))(stronglyMeasurable_const (b := (1 : ℝ))) (integrable_const (μ := μ) 1)filter_upwards [condExp_sub (integrable_const (1 : ℝ))(h.integrable_mul hs (ht j)) (ℱ (r i)),hc,h.condExp (r i) (ht i) (r j) (ht j) (hr hij)] with ω hsub hmul hesimp only [Pi.sub_apply] at hsubchange μ[(fun ω ↦ f s ω*f (r j) ω) | ℱ (r i)] ω =f s ω*μ[f (r j) | ℱ (r i)] ω at hmulrw [hc1,hmul] at hsubsimpa only [Pi.sub_def,Pi.mul_def,Pi.mul_apply,he] using hsubomit [IsProbabilityMeasure μ] inlemma UnitMomentMartingale.sampled_gap_nonneg(h : UnitMomentMartingale (μ := μ) ℱ f) {s t : ℝ}(hs : s ∈ Ico (0 : ℝ) 1) (ht : t ∈ Ico (0 : ℝ) 1) (ω : Ω) :0 ≤ 1-f s ω*f t ω := byhave hh : f s ω*f t ω ≤ 1 := calc_ ≤ |f s ω*f t ω| := le_abs_self __ = |f s ω| * |f t ω| := abs_mul _ __ ≤ 1 := by nlinarith [h.bounded s hs ω,h.bounded t ht ω,abs_nonneg (f s ω),abs_nonneg (f t ω)]linarithlemma UnitMomentMartingale.sampled_gap_integral(h : UnitMomentMartingale (μ := μ) ℱ f) {s t : ℝ}(hs : s ∈ Ico (0 : ℝ) 1) (ht : t ∈ Ico (0 : ℝ) 1) (hst : s ≤ t) :∫ ω, 1-f s ω*f t ω ∂μ = 1-s := byrw [integral_sub (integrable_const 1) (h.integrable_mul hs ht),h.integral_past_mul hs ht hst]simplemma UnitMomentMartingale.finite_gap_maximal(h : UnitMomentMartingale (μ := μ) ℱ f) {s : ℝ}(hs : s ∈ Ico (0 : ℝ) 1) (S : Finset ℝ)(hS : ∀ t ∈ S, t ∈ Ico s 1) (ε : ℝ≥0) :(ε : ℝ≥0∞) * μ {ω | ∃ t ∈ S, (ε : ℝ) ≤ 1-f s ω*f t ω} ≤ENNReal.ofReal (1-s) := byclassicalby_cases hne : S.Nonempty· have hcard : 0 < S.card := Finset.card_pos.mpr hnelet e := S.orderEmbOfFin rfllet r : ℕ → ℝ := fun n ↦ e ⟨min n (S.card-1),by omega⟩have hr : Monotone r := byintro i j hijexact e.monotone (show min i (S.card-1) ≤ min j (S.card-1) from min_le_min_right _ hij)have hrmem (n : ℕ) : r n ∈ Ico s 1 := hS _ (S.orderEmbOfFin_mem rfl _)have hm := h.sampled_gap_martingale hs r hr hrmemhave hn : 0 ≤ (fun n ω ↦ 1-f s ω*f (r n) ω) :=fun n ω ↦ h.sampled_gap_nonneg hs ⟨hs.1.trans (hrmem n).1,(hrmem n).2⟩ ωhave hb := maximal_ineq hm.submartingale hn (ε := ε) (S.card-1)have hset : {ω | ∃ t ∈ S, (ε : ℝ) ≤ 1-f s ω*f t ω} ⊆{ω | (ε : ℝ) ≤ (Finset.range ((S.card-1)+1)).sup' Finset.nonempty_range_add_one(fun k ↦ 1-f s ω*f (r k) ω)} := byrintro ω ⟨t,ht,heps⟩let i := (S.orderIsoOfFin rfl).symm ⟨t,ht⟩have her : r i.val = t := bydsimp only [r]have hh : (⟨min i.val (S.card-1),by omega⟩ : Fin S.card) = i :=Fin.ext (min_eq_left (by omega))rw [hh]change ((S.orderIsoOfFin rfl) i).val = tsimp [i]refine heps.trans ?_rw [← her]exact Finset.le_sup' (f := fun k ↦ 1-f s ω*f (r k) ω)(Finset.mem_range.mpr (by omega : i.val < (S.card-1)+1))calc_ ≤ (ε : ℝ≥0∞) * μ {ω | (ε : ℝ) ≤(Finset.range ((S.card-1)+1)).sup' Finset.nonempty_range_add_one(fun k ↦ 1-f s ω*f (r k) ω)} := by gcongr_ ≤ _ := hb_ ≤ ENNReal.ofReal (∫ ω, 1-f s ω*f (r (S.card-1)) ω ∂μ) := byapply ENNReal.ofReal_le_ofRealexact setIntegral_le_integral (integrable_const 1 |>.sub(h.integrable_mul hs ⟨hs.1.trans (hrmem _).1,(hrmem _).2⟩))(Eventually.of_forall (hn (S.card-1)))_ = _ := congrArg ENNReal.ofReal (h.sampled_gap_integral hs⟨hs.1.trans (hrmem _).1,(hrmem _).2⟩ (hrmem _).1)· simp [Finset.not_nonempty_iff_eq_empty.mp hne]lemma UnitMomentMartingale.rational_gap_maximal(h : UnitMomentMartingale (μ := μ) ℱ f) {s : ℝ}(hs : s ∈ Ico (0 : ℝ) 1) (ε : ℝ≥0) :(ε : ℝ≥0∞) * μ {ω | ∃ q : ℚ, (q : ℝ) ∈ Ico s 1 ∧(ε : ℝ) ≤ 1-f s ω*f q ω} ≤ ENNReal.ofReal (1-s) := byclassicallet E : Finset ℚ → Set Ω := fun S ↦ {ω | ∃ q ∈ S, (q : ℝ) ∈ Ico s 1 ∧(ε : ℝ) ≤ 1-f s ω*f q ω}have hd : Directed (· ⊆ ·) E := byintro S Trefine ⟨S∪T, ?_, ?_⟩· rintro ω ⟨q,hq,hmem,he⟩exact ⟨q,Finset.mem_union_left _ hq,hmem,he⟩· rintro ω ⟨q,hq,hmem,he⟩exact ⟨q,Finset.mem_union_right _ hq,hmem,he⟩have heq : {ω | ∃ q : ℚ, (q : ℝ) ∈ Ico s 1 ∧ (ε : ℝ) ≤ 1-f s ω*f q ω} =⋃ S : Finset ℚ, E S := byext ωconstructor· rintro ⟨q,hmem,he⟩exact mem_iUnion.mpr ⟨{q},q,Finset.mem_singleton_self _,hmem,he⟩· intro hωobtain ⟨S,q,hq,hmem,he⟩ := mem_iUnion.mp hωexact ⟨q,hmem,he⟩rw [heq,hd.measure_iUnion,ENNReal.mul_iSup]refine iSup_le fun S ↦ ?_let R : Finset ℝ := (S.filter (fun q : ℚ ↦ (q : ℝ) ∈ Ico s 1)).image (fun q : ℚ ↦ (q : ℝ))have hR : ∀ t ∈ R, t ∈ Ico s 1 := byintro t htobtain ⟨q,hq,rfl⟩ := Finset.mem_image.mp htexact (Finset.mem_filter.mp hq).2have hE : E S ⊆ {ω | ∃ t ∈ R, (ε : ℝ) ≤ 1-f s ω*f t ω} := byrintro ω ⟨q,hq,hmem,he⟩exact ⟨(q : ℝ),Finset.mem_image.mpr ⟨q,Finset.mem_filter.mpr ⟨hq,hmem⟩,rfl⟩,he⟩calc_ ≤ (ε : ℝ≥0∞) * μ {ω | ∃ t ∈ R, (ε : ℝ) ≤ 1-f s ω*f t ω} := by gcongr_ ≤ _ := h.finite_gap_maximal hs R hR εnoncomputable def terminalTime (n : ℕ) : ℝ := 1-1/(n+1)lemma terminalTime_mem (n : ℕ) : terminalTime n ∈ Ico (0 : ℝ) 1 := byhave hn : (1 : ℝ) ≤ n+1 := by linarith [Nat.cast_nonneg (α := ℝ) n]have hp : (0 : ℝ) < n+1 := by positivitysimp only [terminalTime]constructor· have hh : (1 : ℝ)/(n+1) ≤ 1 := (div_le_one hp).mpr hnlinarith· have hh : (0 : ℝ) < 1/(n+1) := by positivitylinarithlemma terminalTime_monotone : Monotone terminalTime := byintro i j hijsimp only [terminalTime]have hh : (1 : ℝ)/(j+1) ≤ 1/(i+1) := one_div_le_one_div_of_le(by positivity) (by exact_mod_cast Nat.add_le_add_right hij 1)linarithlemma terminalTime_tendsto : Tendsto terminalTime atTop (𝓝[<] (1 : ℝ)) := byrefine tendsto_nhdsWithin_iff.mpr ⟨?_,Eventually.of_forall (fun n ↦ (terminalTime_mem n).2)⟩change Tendsto (fun n : ℕ ↦ (1 : ℝ)-1/((n : ℝ)+1)) atTop (𝓝 (1 : ℝ))simpa only [sub_zero] using (tendsto_const_nhds (x := (1 : ℝ))).sub(tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ))lemma UnitMomentMartingale.ae_exists_rational_gap_bound(h : UnitMomentMartingale (μ := μ) ℱ f) {ε : ℝ} (hε : 0 < ε) :∀ᵐ ω ∂μ, ∃ n, ∀ q : ℚ, (q : ℝ) ∈ Ico (terminalTime n) 1 →1-f (terminalTime n) ω*f q ω < ε := bylet E : ℕ → Set Ω := fun n ↦ {ω | ∃ q : ℚ, (q : ℝ) ∈ Ico (terminalTime n) 1 ∧ε ≤ 1-f (terminalTime n) ω*f q ω}have hbound (n : ℕ) : ENNReal.ofReal ε * μ (⋂ n, E n) ≤ENNReal.ofReal (1-terminalTime n) := calc_ ≤ ENNReal.ofReal ε * μ (E n) := by gcongr; exact iInter_subset E n_ ≤ _ := byhave hh := h.rational_gap_maximal (terminalTime_mem n) (NNReal.mk ε hε.le)simpa only [E,NNReal.coe_mk,ENNReal.coe_nnreal_eq] using hhhave hzero : ENNReal.ofReal ε * μ (⋂ n, E n) = 0 := byapply le_antisymm _ bot_lehave hlim : Tendsto (fun n ↦ ENNReal.ofReal (1-terminalTime n)) atTop (𝓝 0) := byhave hh : Tendsto (fun n ↦ 1-terminalTime n) atTop (𝓝 (0 : ℝ)) := bysimpa only [sub_self] using ((tendsto_const_nhds (x := (1 : ℝ))).sub(tendsto_nhdsWithin_iff.mp terminalTime_tendsto).1)simpa only [ENNReal.ofReal_zero,Function.comp_def] usingENNReal.continuous_ofReal.continuousAt.tendsto.comp hhexact ge_of_tendsto' hlim hboundhave hn : μ (⋂ n, E n) = 0 := (mul_eq_zero.mp hzero).resolve_left(ne_of_gt (ENNReal.ofReal_pos.mpr hε))have ha : ∀ᵐ ω ∂μ, ω ∉ ⋂ n, E n := byrw [ae_iff]convert hn using 1simp only [not_not,Set.ofPred_mem_eq]filter_upwards [ha] with ω hωsimp only [mem_iInter,E,mem_ofPred_eq,not_forall,not_exists,not_and,not_le] at hωexact hωlemma continuous_gap_bound_of_rat {v : ℝ → ℝ}(hv : ContinuousOn v (Ico (0 : ℝ) 1)) {s ε : ℝ}(hs : s ∈ Ico (0 : ℝ) 1)(hq : ∀ q : ℚ, (q : ℝ) ∈ Ico s 1 → 1-v s*v q < ε) :∀ t ∈ Ioo s 1, 1-v s*v t ≤ ε := byintro t htby_contra! hehave hvt : ContinuousAt v t := (hv t ⟨hs.1.trans ht.1.le,ht.2⟩).continuousAt(Ico_mem_nhds_iff.mpr ⟨hs.1.trans_lt ht.1,ht.2⟩)have hgt : ContinuousAt (fun r ↦ 1-v s*v r) t := continuousAt_const.sub(continuousAt_const.mul hvt)have hevent : {r | ε < 1-v s*v r} ∈ 𝓝 t := hgt (Ioi_mem_nhds he)obtain ⟨q,hq'⟩ := Rat.denseRange_cast.mem_nhds (inter_mem hevent (Ioo_mem_nhds ht.1 ht.2))exact (hq q ⟨hq'.2.1.le,hq'.2.2⟩).not_gt hq'.1lemma UnitMomentMartingale.exists_sequence_terminal(h : UnitMomentMartingale (μ := μ) ℱ f) :∃ U : Ω → ℝ, StronglyMeasurable[ℱ 1] U ∧(∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))) := bylet 𝒢 : Filtration ℕ m := ⟨fun n ↦ ℱ (terminalTime n),fun _ _ hij ↦ ℱ.mono (terminalTime_monotone hij),fun n ↦ ℱ.le _⟩have hm : Martingale (fun n ↦ f (terminalTime n)) 𝒢 μ :=⟨fun n ↦ h.measurable _ (terminalTime_mem n),fun i j hij ↦h.condExp _ (terminalTime_mem i) _ (terminalTime_mem j) (terminalTime_monotone hij)⟩have hb (n : ℕ) : eLpNorm (f (terminalTime n)) 1 μ ≤ (1 : ℝ≥0) := byhave hh := eLpNorm_le_of_ae_bound (μ := μ) (p := (1 : ℝ≥0∞))(h.integrable (terminalTime_mem n)).aestronglyMeasurable(Eventually.of_forall (fun ω ↦ (Real.norm_eq_abs _).trans_le(h.bounded _ (terminalTime_mem n) ω)))simpa using hhlet U := 𝒢.limitProcess (fun n ↦ f (terminalTime n)) μhave hU : StronglyMeasurable[ℱ 1] U :=Filtration.stronglyMeasurable_limitProcess.mono (iSup_le fun n ↦ ℱ.mono (terminalTime_mem n).2.le)refine ⟨U,hU,?_⟩filter_upwards [hm.submartingale.ae_tendsto_limitProcess hb] with ω hωexact ⟨le_of_tendsto' hω.abs (fun n ↦ h.bounded _ (terminalTime_mem n) ω),hω⟩lemma UnitMomentMartingale.exists_continuous_terminal(h : UnitMomentMartingale (μ := μ) ℱ f)(hc : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ f t ω) (Ico (0 : ℝ) 1)) :∃ U : Ω → ℝ, StronglyMeasurable[ℱ 1] U ∧(∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun t ↦ f t ω) (𝓝[<] (1 : ℝ)) (𝓝 (U ω))) := byobtain ⟨U,hU,hseq⟩ := h.exists_sequence_terminalhave hg : ∀ᵐ ω ∂μ, ∀ k : ℕ, ∃ n, ∀ q : ℚ,(q : ℝ) ∈ Ico (terminalTime n) 1 →1-f (terminalTime n) ω*f q ω < 1/(k+1) := byapply ae_all_iff.mprintro kexact h.ae_exists_rational_gap_bound (by positivity)refine ⟨U,hU,?_⟩filter_upwards [hc,hseq,hg] with ω hcont hseqω hgaprefine ⟨hseqω.1,Metric.tendsto_nhds.mpr (fun δ hδ ↦ ?_)⟩obtain ⟨k,hk⟩ : ∃ k : ℕ, (1 : ℝ)/(k+1) < δ^2/32 := byhave hh := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).eventually(Iio_mem_nhds (show (0 : ℝ) < δ^2/32 by positivity))exact hh.existsobtain ⟨n,hn⟩ := hgap khave hreal := continuous_gap_bound_of_rat hcont (terminalTime_mem n) hnhave hbound (t : ℝ) (ht : t ∈ Ioo (terminalTime n) 1) :|f t ω-f (terminalTime n) ω| ≤ δ/4 := byhave hbt := h.bounded t ⟨(terminalTime_mem n).1.trans ht.1.le,ht.2⟩ ωhave hbs := h.bounded _ (terminalTime_mem n) ωhave he := hreal t hthave hsq1 : (f t ω)^2 ≤ 1 := by nlinarith [abs_le.mp hbt]have hsq2 : (f (terminalTime n) ω)^2 ≤ 1 := by nlinarith [abs_le.mp hbs]have habs : |f t ω-f (terminalTime n) ω|^2 < (δ/4)^2 := byrw [sq_abs]nlinarithnlinarith [abs_nonneg (f t ω-f (terminalTime n) ω)]have hUb : |U ω-f (terminalTime n) ω| ≤ δ/4 := byapply le_of_tendsto ((hseqω.2.sub_const _).abs)have hev : ∀ᶠ k in atTop, terminalTime k ∈ Ioo (terminalTime n) 1 :=terminalTime_tendsto.eventually (Ioo_mem_nhdsLT (terminalTime_mem n).2)exact hev.mono (fun k hk ↦ hbound _ hk)filter_upwards [Ioo_mem_nhdsLT (terminalTime_mem n).2] with t htrw [Real.dist_eq]have hh := abs_add_le (f t ω-f (terminalTime n) ω) (f (terminalTime n) ω-U ω)have hh' := hbound t hthave hUb' : |f (terminalTime n) ω-U ω| ≤ δ/4 := by simpa only [abs_sub_comm] using hUbhave heq : f t ω-U ω = (f t ω-f (terminalTime n) ω)+(f (terminalTime n) ω-U ω) := by ringrw [heq]linarithlemma UnitMomentMartingale.terminal_square(h : UnitMomentMartingale (μ := μ) ℱ f) {U : Ω → ℝ}(hUm : StronglyMeasurable[ℱ 1] U)(hU : ∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))) :∀ᵐ ω ∂μ, (U ω)^2 = 1 := byhave hU2i : Integrable (fun ω ↦ (U ω)^2) μ :=Integrable.of_bound ((hUm.mono (ℱ.le 1)).pow 2).aestronglyMeasurable 1(hU.mono (fun ω hω ↦ byrw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)]nlinarith [abs_le.mp hω.1]))have ht := tendsto_integral_of_dominated_convergence (μ := μ)(F := fun n ω ↦ (f (terminalTime n) ω)^2) (fun _ : Ω ↦ (1 : ℝ))(fun n ↦ (((h.measurable _ (terminalTime_mem n)).mono (ℱ.le _)).pow 2).aestronglyMeasurable)(integrable_const 1)(fun n ↦ Eventually.of_forall (fun ω ↦ byrw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)]nlinarith [abs_le.mp (h.bounded _ (terminalTime_mem n) ω)]))(hU.mono (fun ω hω ↦ hω.2.pow 2))have hi : ∫ ω, (U ω)^2 ∂μ = 1 := byhave hh : (fun n ↦ ∫ ω, (f (terminalTime n) ω)^2 ∂μ) = terminalTime :=funext (fun n ↦ h.secondMoment _ (terminalTime_mem n))rw [hh] at htexact tendsto_nhds_unique ht (tendsto_nhdsWithin_iff.mp terminalTime_tendsto).1have hnonneg : 0 ≤ᵐ[μ] (fun ω ↦ 1-(U ω)^2) := hU.mono (fun ω hω ↦ bydsimpnlinarith [abs_le.mp hω.1])have hzero : ∫ ω, 1-(U ω)^2 ∂μ = 0 := byrw [integral_sub (integrable_const 1) hU2i,hi]simphave he := (integral_eq_zero_iff_of_nonneg_ae hnonneg ((integrable_const 1).sub hU2i)).mp hzerofilter_upwards [he] with ω hωchange 1-(U ω)^2=0 at hωlinarithlemma UnitMomentMartingale.terminal_mean_square(h : UnitMomentMartingale (μ := μ) ℱ f) {U : Ω → ℝ}(hUm : StronglyMeasurable[ℱ 1] U)(hU : ∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧Tendsto (fun t ↦ f t ω) (𝓝[<] (1 : ℝ)) (𝓝 (U ω))) :Tendsto (fun t ↦ ∫ ω, (f t ω-U ω)^2 ∂μ) (𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) := byhave hev : ∀ᶠ t in 𝓝[<] (1 : ℝ), t ∈ Ico (0 : ℝ) 1 := byfilter_upwards [Ioo_mem_nhdsLT (show (0 : ℝ)<1 by norm_num)] with t htexact ⟨ht.1.le,ht.2⟩have ht := tendsto_integral_filter_of_dominated_convergence (μ := μ)(F := fun t ω ↦ (f t ω-U ω)^2) (f := fun _ ↦ (0 : ℝ)) (fun _ : Ω ↦ (4 : ℝ))(hev.mono (fun t ht ↦ ((((h.measurable t ht).mono (ℱ.le t)).sub(hUm.mono (ℱ.le 1))).pow 2).aestronglyMeasurable))(hev.mono (fun t ht ↦ hU.mono (fun ω hω ↦ byrw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)]have hb := h.bounded t ht ωhave hd : |f t ω-U ω| ≤ 2 := (abs_sub _ _).trans (by linarith [hω.1])nlinarith [sq_abs (f t ω-U ω),abs_nonneg (f t ω-U ω)])))(integrable_const 4)(hU.mono (fun ω hω ↦ bysimpa only [sub_self,zero_pow (by decide : (2 : ℕ) ≠ 0)] using (hω.2.sub_const (U ω)).pow 2))simpa only [integral_zero] using htend SKValueendend OAI
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091import Mathlibimport OAI.Probability.SKValue.Equations.ThirdOrderRemainderBoundnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorslemma value_euler_one_step {V : ℝ → ℝ → ℝ} {γ : ℝ → ℝ}{t δ x z G K L : ℝ} (hδ : 0≤δ) (hδ1 : δ≤1)(hG : 0≤G) (hK : 0≤K) (hL : 0≤L)(hγ : MonotoneOn γ (Icc t (t+δ))) (hγ0 : 0≤γ t) (hγG : γ t≤G)(hu : |deriv (V t) x|≤1) (hsmooth : ContDiff ℝ 3 (V t))(ha : |deriv (deriv (V t)) x|≤K)(hthird : ∀ y, |iteratedDeriv 3 (V t) y|≤K)(hp : ∀ s ∈ Icc t (t+δ), ∀ y, |(1/2 : ℝ)*(deriv (V s) y)^2|≤K)(haLip : ∀ s ∈ Icc t (t+δ), ∀ y,|deriv (deriv (V s)) y-deriv (deriv (V t)) x|≤L*(|s-t|+|y-x|))(hpLip : ∀ s ∈ Icc t (t+δ), ∀ y,|(1/2 : ℝ)*(deriv (V s) y)^2-(1/2 : ℝ)*(deriv (V t) x)^2|≤L*(|s-t|+|y-x|))(haint : ∀ y, IntervalIntegrable (fun s ↦ deriv (deriv (V s)) y) volume t (t+δ))(hpint : ∀ y, IntervalIntegrable (fun s ↦ γ s*((1/2 : ℝ)*(deriv (V s) y)^2)) volume t (t+δ))(hPDE : ∀ y, V (t+δ) y-V t y =-(∫ s in t..(t+δ), (1/2 : ℝ)*deriv (deriv (V s)) y+γ s*((1/2 : ℝ)*(deriv (V s) y)^2))) :let d := Real.sqrt δ*z+δ*γ t*deriv (V t) x|V (t+δ) (x+d)-V t x-deriv (V t) x*Real.sqrt δ*z-(1/2 : ℝ)*δ*deriv (deriv (V t)) x*(z^2-1)-(1/2 : ℝ)*δ*γ t*(deriv (V t) x)^2| ≤δ*Real.sqrt δ*(K*(|z|+G)^3+(1/2+G)*L*(1+|z|+G)+K*G*(|z|+G/2))+δ*K*(γ (t+δ)-γ t) := bydsimp onlylet d := Real.sqrt δ*z+δ*γ t*deriv (V t) xhave htm := gradient_generator_quadrature(b := fun s y ↦ deriv (deriv (V s)) y)(p := fun s y ↦ (1/2 : ℝ)*(deriv (V s) y)^2) (y := x+d)hδ hG hK hL hγ hγ0 hγG(fun s hs ↦ hp s hs _) (fun s hs ↦ haLip s hs _) (fun s hs ↦ hpLip s hs _)(haint _) (hpint _)have ht : |(V (t+δ) (x+d)-V t x+deriv (V t) x-(1/2 : ℝ)*δ*γ t*(deriv (V t) x)^2)-(V t (x+d)-V t x+deriv (V t) x)+δ*((1/2 : ℝ)*deriv (deriv (V t)) x+γ t*deriv (V t) x*deriv (V t) x)| ≤δ*(((1/2 : ℝ)+G)*L*(δ+|d|)+K*(γ (t+δ)-γ t)) := byhave heq : (V (t+δ) (x+d)-V t x+deriv (V t) x-(1/2 : ℝ)*δ*γ t*(deriv (V t) x)^2)-(V t (x+d)-V t x+deriv (V t) x)+δ*((1/2 : ℝ)*deriv (deriv (V t)) x+γ t*deriv (V t) x*deriv (V t) x) =(V (t+δ) (x+d)-V t (x+d))+δ*((1/2 : ℝ)*deriv (deriv (V t)) x+γ t*((1/2 : ℝ)*(deriv (V t) x)^2)) := by ringrw [heq,hPDE]rw [show -(∫ s in t..(t+δ), (1/2 : ℝ)*deriv (deriv (V s)) (x+d)+γ s*((1/2 : ℝ)*(deriv (V s) (x+d))^2))+δ*((1/2 : ℝ)*deriv (deriv (V t)) x+γ t*((1/2 : ℝ)*(deriv (V t) x)^2)) =-((∫ s in t..(t+δ), (1/2 : ℝ)*deriv (deriv (V s)) (x+d)+γ s*((1/2 : ℝ)*(deriv (V s) (x+d))^2))-δ*((1/2 : ℝ)*deriv (deriv (V t)) x+γ t*((1/2 : ℝ)*(deriv (V t) x)^2))) by ring,abs_neg]simpa only [add_sub_cancel_left] using htmhave hs : |(V t (x+d)-V t x+deriv (V t) x)-deriv (V t) x-deriv (V t) x*d-(1/2 : ℝ)*deriv (deriv (V t)) x*d^2| ≤ K*|d|^3 := bysimpa only [add_sub_cancel_right] using third_order_remainder_bound hsmooth hK hthird x dhave hh := euler_cubic_remainder hδ hδ1 hG hK (by positivity : 0≤(1/2+G)*L)(by rwa [abs_of_nonneg hγ0]) hu ha hs htconvert hh using 1congr 1dsimp only [d]ringend SKValueendend OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091import Mathlibimport OAI.Probability.SKValue.Equations.ThirdOrderRemainderBoundnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorslemma value_euler_one_step {V : ℝ → ℝ → ℝ} {γ : ℝ → ℝ}{t δ x z G K L : ℝ} (hδ : 0≤δ) (hδ1 : δ≤1)(hG : 0≤G) (hK : 0≤K) (hL : 0≤L)(hγ : MonotoneOn γ (Icc t (t+δ))) (hγ0 : 0≤γ t) (hγG : γ t≤G)(hu : |deriv (V t) x|≤1) (hsmooth : ContDiff ℝ 3 (V t))(ha : |deriv (deriv (V t)) x|≤K)(hthird : ∀ y, |iteratedDeriv 3 (V t) y|≤K)(hp : ∀ s ∈ Icc t (t+δ), ∀ y, |(1/2 : ℝ)*(deriv (V s) y)^2|≤K)(haLip : ∀ s ∈ Icc t (t+δ), ∀ y,|deriv (deriv (V s)) y-deriv (deriv (V t)) x|≤L*(|s-t|+|y-x|))(hpLip : ∀ s ∈ Icc t (t+δ), ∀ y,|(1/2 : ℝ)*(deriv (V s) y)^2-(1/2 : ℝ)*(deriv (V t) x)^2|≤L*(|s-t|+|y-x|))(haint : ∀ y, IntervalIntegrable (fun s ↦ deriv (deriv (V s)) y) volume t (t+δ))(hpint : ∀ y, IntervalIntegrable (fun s ↦ γ s*((1/2 : ℝ)*(deriv (V s) y)^2)) volume t (t+δ))(hPDE : ∀ y, V (t+δ) y-V t y =-(∫ s in t..(t+δ), (1/2 : ℝ)*deriv (deriv (V s)) y+γ s*((1/2 : ℝ)*(deriv (V s) y)^2))) :let d := Real.sqrt δ*z+δ*γ t*deriv (V t) x|V (t+δ) (x+d)-V t x-deriv (V t) x*Real.sqrt δ*z-(1/2 : ℝ)*δ*deriv (deriv (V t)) x*(z^2-1)-(1/2 : ℝ)*δ*γ t*(deriv (V t) x)^2| ≤δ*Real.sqrt δ*(K*(|z|+G)^3+(1/2+G)*L*(1+|z|+G)+K*G*(|z|+G/2))+δ*K*(γ (t+δ)-γ t) := bydsimp onlylet d := Real.sqrt δ*z+δ*γ t*deriv (V t) xhave htm := gradient_generator_quadrature(b := fun s y ↦ deriv (deriv (V s)) y)(p := fun s y ↦ (1/2 : ℝ)*(deriv (V s) y)^2) (y := x+d)hδ hG hK hL hγ hγ0 hγG(fun s hs ↦ hp s hs _) (fun s hs ↦ haLip s hs _) (fun s hs ↦ hpLip s hs _)(haint _) (hpint _)have ht : |(V (t+δ) (x+d)-V t x+deriv (V t) x-(1/2 : ℝ)*δ*γ t*(deriv (V t) x)^2)-(V t (x+d)-V t x+deriv (V t) x)+δ*((1/2 : ℝ)*deriv (deriv (V t)) x+γ t*deriv (V t) x*deriv (V t) x)| ≤δ*(((1/2 : ℝ)+G)*L*(δ+|d|)+K*(γ (t+δ)-γ t)) := byhave heq : (V (t+δ) (x+d)-V t x+deriv (V t) x-(1/2 : ℝ)*δ*γ t*(deriv (V t) x)^2)-(V t (x+d)-V t x+deriv (V t) x)+δ*((1/2 : ℝ)*deriv (deriv (V t)) x+γ t*deriv (V t) x*deriv (V t) x) =(V (t+δ) (x+d)-V t (x+d))+δ*((1/2 : ℝ)*deriv (deriv (V t)) x+γ t*((1/2 : ℝ)*(deriv (V t) x)^2)) := by ringrw [heq,hPDE]rw [show -(∫ s in t..(t+δ), (1/2 : ℝ)*deriv (deriv (V s)) (x+d)+γ s*((1/2 : ℝ)*(deriv (V s) (x+d))^2))+δ*((1/2 : ℝ)*deriv (deriv (V t)) x+γ t*((1/2 : ℝ)*(deriv (V t) x)^2)) =-((∫ s in t..(t+δ), (1/2 : ℝ)*deriv (deriv (V s)) (x+d)+γ s*((1/2 : ℝ)*(deriv (V s) (x+d))^2))-δ*((1/2 : ℝ)*deriv (deriv (V t)) x+γ t*((1/2 : ℝ)*(deriv (V t) x)^2))) by ring,abs_neg]simpa only [add_sub_cancel_left] using htmhave hs : |(V t (x+d)-V t x+deriv (V t) x)-deriv (V t) x-deriv (V t) x*d-(1/2 : ℝ)*deriv (deriv (V t)) x*d^2| ≤ K*|d|^3 := bysimpa only [add_sub_cancel_right] using third_order_remainder_bound hsmooth hK hthird x dhave hh := euler_cubic_remainder hδ hδ1 hG hK (by positivity : 0≤(1/2+G)*L)(by rwa [abs_of_nonneg hγ0]) hu ha hs htconvert hh using 1congr 1dsimp only [d]ringend SKValueendend OAI
1234567891011121314151617181920212223242526272829303132import Mathlibimport OAI.Probability.SKValue.Equations.ResponseContractionimport OAI.Probability.SKValue.Gaussian.UniformErrorimport OAI.Probability.SKValue.Equations.UniformPolynomialnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValuelemma IsDiffusion.splitResponse_varying {W:BrownianSpace} {γ:OrderParameter} {X:ℝ → W.Ω → ℝ}(hX:IsDiffusion W γ X) (t:Ioo (0:ℝ) 1) {F:ℕ → ℝ → ℝ} {f:ℝ → ℝ}(hF:∀ n,BoundedSmooth (F n)) (hf:BoundedSmooth f) (hl:BoundedUniformLimit F f) :Tendsto (fun n ↦ profileResponse (splitTerminal γ t n) (F n) (γ.splitSegment 0 t t.property.1.le n) 0 0)atTop (𝓝 (∫ z, f (X t z) ∂W.μ)) := byobtain ⟨C,hC,hb,hfb⟩:=hl.boundhave he:∀ n,∃ D:ℝ,∀ x,|F n x-f x| ≤ D :=fun n ↦ ⟨C+C,fun x ↦ (abs_sub _ _).trans (add_le_add (hb n x) (hfb x))⟩have hel:=uniformDistance_tendsto hl.tendsto hehave hd:Tendsto (fun n ↦ profileResponse (splitTerminal γ t n) (F n) (γ.splitSegment 0 t t.property.1.le n) 0 0-profileResponse (splitTerminal γ t n) f (γ.splitSegment 0 t t.property.1.le n) 0 0) atTop (𝓝 0) := byapply squeeze_zero_norm (fun n ↦ ?_) helrw [Real.norm_eq_abs]exact (splitTerminal_smooth γ t n).profile_response_contraction (hF n) hf (le_uniformDistance (he n)) _ _ _have ht:=hd.add (hX.splitResponse_tendsto t hf)simpa only [sub_add_cancel,zero_add] using htend SKValueendend OAI1234567891011121314151617181920212223242526272829303132import Mathlibimport OAI.Probability.SKValue.Equations.ResponseContractionimport OAI.Probability.SKValue.Gaussian.UniformErrorimport OAI.Probability.SKValue.Equations.UniformPolynomialnamespace OAIsectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValuelemma IsDiffusion.splitResponse_varying {W:BrownianSpace} {γ:OrderParameter} {X:ℝ → W.Ω → ℝ}(hX:IsDiffusion W γ X) (t:Ioo (0:ℝ) 1) {F:ℕ → ℝ → ℝ} {f:ℝ → ℝ}(hF:∀ n,BoundedSmooth (F n)) (hf:BoundedSmooth f) (hl:BoundedUniformLimit F f) :Tendsto (fun n ↦ profileResponse (splitTerminal γ t n) (F n) (γ.splitSegment 0 t t.property.1.le n) 0 0)atTop (𝓝 (∫ z, f (X t z) ∂W.μ)) := byobtain ⟨C,hC,hb,hfb⟩:=hl.boundhave he:∀ n,∃ D:ℝ,∀ x,|F n x-f x| ≤ D :=fun n ↦ ⟨C+C,fun x ↦ (abs_sub _ _).trans (add_le_add (hb n x) (hfb x))⟩have hel:=uniformDistance_tendsto hl.tendsto hehave hd:Tendsto (fun n ↦ profileResponse (splitTerminal γ t n) (F n) (γ.splitSegment 0 t t.property.1.le n) 0 0-profileResponse (splitTerminal γ t n) f (γ.splitSegment 0 t t.property.1.le n) 0 0) atTop (𝓝 0) := byapply squeeze_zero_norm (fun n ↦ ?_) helrw [Real.norm_eq_abs]exact (splitTerminal_smooth γ t n).profile_response_contraction (hF n) hf (le_uniformDistance (he n)) _ _ _have ht:=hd.add (hX.splitResponse_tendsto t hf)simpa only [sub_add_cancel,zero_add] using htend SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131import Mathlibimport OAI.Probability.SKValue.Control.Regularitynamespace OAIsectionopen MeasureTheory Set Filter Functionopen scoped Topology NNReal Natnamespace SKValuestructure VolterraData (T:ℝ) (hT:0≤T) wherefield:ℝ → ℝ → ℝlip:ℝ≥0bound:∀t∈Icc (0:ℝ) T,∀x y,dist (field t x) (field t y)≤lip*dist x yinteg:∀Y:C(Icc (0:ℝ) T,ℝ),IntervalIntegrable (fun s ↦ field s (Y (projIcc 0 T hT s))) volume 0 Tnamespace VolterraDatavariable {T:ℝ} {hT:0≤T} (D:VolterraData T hT)noncomputable def next (Y:C(Icc (0:ℝ) T,ℝ)):C(Icc (0:ℝ) T,ℝ) wheretoFun t:=∫s in (0:ℝ)..(t:ℝ),D.field s (Y (projIcc 0 T hT s))continuous_toFun:=byhave hc:=intervalIntegral.continuousOn_primitive_interval' (D.integ Y) left_mem_uIccrw [uIcc_of_le hT] at hcexact hc.domRestrictlemma next_apply (Y:C(Icc (0:ℝ) T,ℝ)) (t:Icc (0:ℝ) T):D.next Y t=∫s in (0:ℝ)..(t:ℝ),D.field s (Y (projIcc 0 T hT s)) :=rfllemma integ_to (Y:C(Icc (0:ℝ) T,ℝ)) (t:Icc (0:ℝ) T):IntervalIntegrable (fun s ↦ D.field s (Y (projIcc 0 T hT s))) volume 0 t := byapply (D.integ Y).mono_setrw [uIcc_of_le t.2.1,uIcc_of_le hT]exact Icc_subset_Icc le_rfl t.2.2lemma iterate_bound (Y Z:C(Icc (0:ℝ) T,ℝ)) (n:ℕ) (t:Icc (0:ℝ) T):dist ((D.next)^[n] Y t) ((D.next)^[n] Z t)≤(D.lip*|((t:ℝ)-0)|)^n/n.factorial*dist Y Z := byinduction n generalizing t with| zero=>simpa using ContinuousMap.dist_apply_le_dist (f:=Y) (g:=Z) t| succ n hn=>rw [iterate_succ_apply',iterate_succ_apply',dist_eq_norm,next_apply,next_apply,←intervalIntegral.integral_sub (D.integ_to _ t) (D.integ_to _ t)]calc_≤∫s in uIoc (0:ℝ) (t:ℝ),(D.lip:ℝ)^(n+1)*|s-0|^n/n.factorial*dist Y Z := byrw [intervalIntegral.norm_intervalIntegral_eq]apply norm_integral_le_of_norm_le ((by fun_prop:Continuous (fun s:ℝ ↦(D.lip:ℝ)^(n+1)*|s-0|^n/n.factorial*dist Y Z)).integrableOn_uIoc)filter_upwards [ae_restrict_mem measurableSet_uIoc] with s hsrw [uIoc_of_le t.2.1] at hshave hsT:s∈Icc (0:ℝ) T:=⟨hs.1.le,hs.2.trans t.2.2⟩rw [←dist_eq_norm]have hp:=D.bound s hsT ((D.next)^[n] Y (projIcc 0 T hT s)) ((D.next)^[n] Z (projIcc 0 T hT s))have hh:=hn (⟨s,hsT⟩:Icc (0:ℝ) T)have he:projIcc 0 T hT s=(⟨s,hsT⟩:Icc (0:ℝ) T):=projIcc_of_mem hT hsTrw [he] at hp ⊢apply hp.transcalc_≤(D.lip:ℝ)*((D.lip*|s-0|)^n/n.factorial*dist Y Z):=mul_le_mul_of_nonneg_left hh D.lip.coe_nonneg_=_:=by rw [mul_pow,pow_succ];ring_≤_:=byapply le_of_abs_lerw [←intervalIntegral.abs_intervalIntegral_eq,intervalIntegral.integral_mul_const,intervalIntegral.integral_div,intervalIntegral.integral_const_mul,abs_mul,abs_div,abs_mul,intervalIntegral.abs_intervalIntegral_eq,integral_pow_abs_sub_uIoc,abs_div,abs_pow,abs_pow,abs_dist,NNReal.abs_eq,abs_abs,mul_div,div_div,←abs_mul,←Nat.cast_succ,←Nat.cast_mul,←Nat.factorial_succ,Nat.abs_cast,←mul_pow]lemma exists_fixedPoint:∃Y:C(Icc (0:ℝ) T,ℝ),D.next Y=Y := byobtain ⟨n,hn⟩:= (FloorSemiring.tendsto_pow_div_factorial_atTop ((D.lip:ℝ)*T)).eventually(gt_mem_nhds zero_lt_one) |>.existshave hn0:0≤((D.lip:ℝ)*T)^n/n.factorial:=by positivityhave hc:ContractingWith ⟨((D.lip:ℝ)*T)^n/n.factorial,hn0⟩ (D.next)^[n] := byrefine ⟨hn,LipschitzWith.of_dist_le_mul (fun Y Z ↦ ?_)⟩rw [ContinuousMap.dist_le]· intro tapply (D.iterate_bound Y Z n t).transsimp only [sub_zero,abs_of_nonneg t.2.1]change (D.lip*↑t)^n/n.factorial*dist Y Z ≤ ((D.lip:ℝ)*T)^n/n.factorial*dist Y Zgcongr· exact mul_nonneg D.lip.coe_nonneg t.2.1· exact t.2.2· positivityexact ⟨_,hc.isFixedPt_fixedPoint_iterate⟩end VolterraDataend SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filter Functionopen scoped Topology NNRealnamespace SKValuelemma exists_local_diffusion_path (W:BrownianSpace) (γ:OrderParameter) {T:ℝ}(hT:T∈Ico (0:ℝ) 1) (b:ℝ → ℝ) (hb:ContinuousOn b (Icc (0:ℝ) T)):∃X:ℝ → ℝ,ContinuousOn X (Icc (0:ℝ) T) ∧IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (X s)) volume 0 T ∧∀t∈Icc (0:ℝ) T,X t=b t+∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (X s) := byobtain ⟨K,L,Lu,hLu,hG,hu⟩:=(sourceStripRegularity W γ).core T hThave hg0:0≤γ.coeff T:=γ.nonneg T hThave hi:IntervalIntegrable γ.coeff volume 0 T:=γ.intervalIntegrable.mono_set (byrw [uIcc_of_le hT.1,uIcc_of_le (by norm_num:(0:ℝ)≤1)];exact Icc_subset_Icc le_rfl hT.2.le)have hj:=derivative_joint_continuous hLu hulet D:VolterraData T hT.1:={field:=fun t y ↦ γ.coeff t*gradient W γ t (b t+y)lip:=⟨γ.coeff T*Lu,mul_nonneg hg0 hLu⟩bound:=byintro t ht x yhave hg:0≤γ.coeff t:=γ.nonneg t ⟨ht.1,ht.2.trans_lt hT.2⟩have hgt:γ.coeff t≤γ.coeff T:=γ.monotone ⟨ht.1,ht.2.trans_lt hT.2⟩ hT ht.2simp only [Real.dist_eq,←mul_sub,abs_mul,abs_of_nonneg hg]have hh:=hu t ht t ht (b t+x) (b t+y)simp only [sub_self,abs_zero,zero_add,add_sub_add_left_eq_sub] at hhchange _≤(γ.coeff T*Lu)*|x-y|calc_≤γ.coeff t*(Lu*|x-y|):=mul_le_mul_of_nonneg_left hh hg_≤γ.coeff T*(Lu*|x-y|):=mul_le_mul_of_nonneg_right hgt (by positivity)_=_:=by ringinteg:=byintro Yapply hi.mul_continuousOnrw [uIcc_of_le hT.1]apply hj.comp (continuousOn_id.prodMk (hb.add ((Y.continuous.comp continuous_projIcc).continuousOn)))exact fun t ht ↦ ht }obtain ⟨Y,hY⟩:=D.exists_fixedPointlet X:=fun t ↦ b t+Y (projIcc 0 T hT.1 t)have hXcont:ContinuousOn X (Icc (0:ℝ) T):=hb.add ((Y.continuous.comp continuous_projIcc).continuousOn)refine ⟨X,hXcont,D.integ Y,?_⟩intro t hthave he:=congrArg (fun f:C(Icc (0:ℝ) T,ℝ) ↦ f ⟨t,ht⟩) hYchange (∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (X s))=Y ⟨t,ht⟩ at hedsimp only [X]rw [projIcc_of_mem hT.1 ht,he]end SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131import Mathlibimport OAI.Probability.SKValue.Control.Regularitynamespace OAIsectionopen MeasureTheory Set Filter Functionopen scoped Topology NNReal Natnamespace SKValuestructure VolterraData (T:ℝ) (hT:0≤T) wherefield:ℝ → ℝ → ℝlip:ℝ≥0bound:∀t∈Icc (0:ℝ) T,∀x y,dist (field t x) (field t y)≤lip*dist x yinteg:∀Y:C(Icc (0:ℝ) T,ℝ),IntervalIntegrable (fun s ↦ field s (Y (projIcc 0 T hT s))) volume 0 Tnamespace VolterraDatavariable {T:ℝ} {hT:0≤T} (D:VolterraData T hT)noncomputable def next (Y:C(Icc (0:ℝ) T,ℝ)):C(Icc (0:ℝ) T,ℝ) wheretoFun t:=∫s in (0:ℝ)..(t:ℝ),D.field s (Y (projIcc 0 T hT s))continuous_toFun:=byhave hc:=intervalIntegral.continuousOn_primitive_interval' (D.integ Y) left_mem_uIccrw [uIcc_of_le hT] at hcexact hc.domRestrictlemma next_apply (Y:C(Icc (0:ℝ) T,ℝ)) (t:Icc (0:ℝ) T):D.next Y t=∫s in (0:ℝ)..(t:ℝ),D.field s (Y (projIcc 0 T hT s)) :=rfllemma integ_to (Y:C(Icc (0:ℝ) T,ℝ)) (t:Icc (0:ℝ) T):IntervalIntegrable (fun s ↦ D.field s (Y (projIcc 0 T hT s))) volume 0 t := byapply (D.integ Y).mono_setrw [uIcc_of_le t.2.1,uIcc_of_le hT]exact Icc_subset_Icc le_rfl t.2.2lemma iterate_bound (Y Z:C(Icc (0:ℝ) T,ℝ)) (n:ℕ) (t:Icc (0:ℝ) T):dist ((D.next)^[n] Y t) ((D.next)^[n] Z t)≤(D.lip*|((t:ℝ)-0)|)^n/n.factorial*dist Y Z := byinduction n generalizing t with| zero=>simpa using ContinuousMap.dist_apply_le_dist (f:=Y) (g:=Z) t| succ n hn=>rw [iterate_succ_apply',iterate_succ_apply',dist_eq_norm,next_apply,next_apply,←intervalIntegral.integral_sub (D.integ_to _ t) (D.integ_to _ t)]calc_≤∫s in uIoc (0:ℝ) (t:ℝ),(D.lip:ℝ)^(n+1)*|s-0|^n/n.factorial*dist Y Z := byrw [intervalIntegral.norm_intervalIntegral_eq]apply norm_integral_le_of_norm_le ((by fun_prop:Continuous (fun s:ℝ ↦(D.lip:ℝ)^(n+1)*|s-0|^n/n.factorial*dist Y Z)).integrableOn_uIoc)filter_upwards [ae_restrict_mem measurableSet_uIoc] with s hsrw [uIoc_of_le t.2.1] at hshave hsT:s∈Icc (0:ℝ) T:=⟨hs.1.le,hs.2.trans t.2.2⟩rw [←dist_eq_norm]have hp:=D.bound s hsT ((D.next)^[n] Y (projIcc 0 T hT s)) ((D.next)^[n] Z (projIcc 0 T hT s))have hh:=hn (⟨s,hsT⟩:Icc (0:ℝ) T)have he:projIcc 0 T hT s=(⟨s,hsT⟩:Icc (0:ℝ) T):=projIcc_of_mem hT hsTrw [he] at hp ⊢apply hp.transcalc_≤(D.lip:ℝ)*((D.lip*|s-0|)^n/n.factorial*dist Y Z):=mul_le_mul_of_nonneg_left hh D.lip.coe_nonneg_=_:=by rw [mul_pow,pow_succ];ring_≤_:=byapply le_of_abs_lerw [←intervalIntegral.abs_intervalIntegral_eq,intervalIntegral.integral_mul_const,intervalIntegral.integral_div,intervalIntegral.integral_const_mul,abs_mul,abs_div,abs_mul,intervalIntegral.abs_intervalIntegral_eq,integral_pow_abs_sub_uIoc,abs_div,abs_pow,abs_pow,abs_dist,NNReal.abs_eq,abs_abs,mul_div,div_div,←abs_mul,←Nat.cast_succ,←Nat.cast_mul,←Nat.factorial_succ,Nat.abs_cast,←mul_pow]lemma exists_fixedPoint:∃Y:C(Icc (0:ℝ) T,ℝ),D.next Y=Y := byobtain ⟨n,hn⟩:= (FloorSemiring.tendsto_pow_div_factorial_atTop ((D.lip:ℝ)*T)).eventually(gt_mem_nhds zero_lt_one) |>.existshave hn0:0≤((D.lip:ℝ)*T)^n/n.factorial:=by positivityhave hc:ContractingWith ⟨((D.lip:ℝ)*T)^n/n.factorial,hn0⟩ (D.next)^[n] := byrefine ⟨hn,LipschitzWith.of_dist_le_mul (fun Y Z ↦ ?_)⟩rw [ContinuousMap.dist_le]· intro tapply (D.iterate_bound Y Z n t).transsimp only [sub_zero,abs_of_nonneg t.2.1]change (D.lip*↑t)^n/n.factorial*dist Y Z ≤ ((D.lip:ℝ)*T)^n/n.factorial*dist Y Zgcongr· exact mul_nonneg D.lip.coe_nonneg t.2.1· exact t.2.2· positivityexact ⟨_,hc.isFixedPt_fixedPoint_iterate⟩end VolterraDataend SKValueendsectionopen MeasureTheory ProbabilityTheory Set Filter Functionopen scoped Topology NNRealnamespace SKValuelemma exists_local_diffusion_path (W:BrownianSpace) (γ:OrderParameter) {T:ℝ}(hT:T∈Ico (0:ℝ) 1) (b:ℝ → ℝ) (hb:ContinuousOn b (Icc (0:ℝ) T)):∃X:ℝ → ℝ,ContinuousOn X (Icc (0:ℝ) T) ∧IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (X s)) volume 0 T ∧∀t∈Icc (0:ℝ) T,X t=b t+∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (X s) := byobtain ⟨K,L,Lu,hLu,hG,hu⟩:=(sourceStripRegularity W γ).core T hThave hg0:0≤γ.coeff T:=γ.nonneg T hThave hi:IntervalIntegrable γ.coeff volume 0 T:=γ.intervalIntegrable.mono_set (byrw [uIcc_of_le hT.1,uIcc_of_le (by norm_num:(0:ℝ)≤1)];exact Icc_subset_Icc le_rfl hT.2.le)have hj:=derivative_joint_continuous hLu hulet D:VolterraData T hT.1:={field:=fun t y ↦ γ.coeff t*gradient W γ t (b t+y)lip:=⟨γ.coeff T*Lu,mul_nonneg hg0 hLu⟩bound:=byintro t ht x yhave hg:0≤γ.coeff t:=γ.nonneg t ⟨ht.1,ht.2.trans_lt hT.2⟩have hgt:γ.coeff t≤γ.coeff T:=γ.monotone ⟨ht.1,ht.2.trans_lt hT.2⟩ hT ht.2simp only [Real.dist_eq,←mul_sub,abs_mul,abs_of_nonneg hg]have hh:=hu t ht t ht (b t+x) (b t+y)simp only [sub_self,abs_zero,zero_add,add_sub_add_left_eq_sub] at hhchange _≤(γ.coeff T*Lu)*|x-y|calc_≤γ.coeff t*(Lu*|x-y|):=mul_le_mul_of_nonneg_left hh hg_≤γ.coeff T*(Lu*|x-y|):=mul_le_mul_of_nonneg_right hgt (by positivity)_=_:=by ringinteg:=byintro Yapply hi.mul_continuousOnrw [uIcc_of_le hT.1]apply hj.comp (continuousOn_id.prodMk (hb.add ((Y.continuous.comp continuous_projIcc).continuousOn)))exact fun t ht ↦ ht }obtain ⟨Y,hY⟩:=D.exists_fixedPointlet X:=fun t ↦ b t+Y (projIcc 0 T hT.1 t)have hXcont:ContinuousOn X (Icc (0:ℝ) T):=hb.add ((Y.continuous.comp continuous_projIcc).continuousOn)refine ⟨X,hXcont,D.integ Y,?_⟩intro t hthave he:=congrArg (fun f:C(Icc (0:ℝ) T,ℝ) ↦ f ⟨t,ht⟩) hYchange (∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (X s))=Y ⟨t,ht⟩ at hedsimp only [X]rw [projIcc_of_mem hT.1 ht,he]end SKValueendend OAI
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778import Mathlibimport OAI.Probability.SKValue.Equations.RealFiltrationnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologylemma UnitMomentMartingale.weighted_terminal_expectation{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{ℱ : Filtration ℝ ‹MeasurableSpace Ω›} {f : ℝ → Ω → ℝ}(h : UnitMomentMartingale (μ := μ) ℱ f) {U : Ω → ℝ}(hUm : StronglyMeasurable[ℱ 1] U)(hU : ∀ᵐ ω ∂μ, |U ω|≤1 ∧ Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))){γ : ℝ → ℝ} {T : ℝ} (hT : 0≤T) (hT1 : T<1)(hc : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ f t ω) (Icc (0 : ℝ) T))(hγ : IntervalIntegrable γ volume 0 T) :(∫ ω, U ω*(∫ t in (0 : ℝ)..T, γ t*f t ω) ∂μ)=∫ t in (0 : ℝ)..T, t*γ t := byhave hm (t : ℝ) (ht : t∈Icc (0 : ℝ) T) : t∈Ico (0 : ℝ) 1 := ⟨ht.1,ht.2.trans_lt hT1⟩rw [compact_weighted_fubini hT (fun t ht ↦ (h.measurable t (hm t ht)).mono (ℱ.le t))hc (fun t ht ↦ h.bounded t (hm t ht)) (hUm.mono (ℱ.le 1)).aestronglyMeasurable(hU.mono (fun _ hω ↦ hω.1)) hγ]apply intervalIntegral.integral_congrintro t htrw [uIcc_of_le hT] at htchange γ t * (∫ ω, U ω * f t ω ∂μ) = t * γ trw [h.terminal_past_product hUm hU (hm t ht),mul_comm]lemma bounded_multiplier_integral_difference {Ω : Type*} [MeasurableSpace Ω]{μ : Measure Ω} {U X Y : Ω → ℝ}(hU : AEStronglyMeasurable U μ) (hb : ∀ᵐ ω ∂μ, |U ω|≤1)(hX : Integrable X μ) (hY : Integrable Y μ) :|(∫ ω, U ω*X ω ∂μ)-(∫ ω, U ω*Y ω ∂μ)|≤∫ ω, |X ω-Y ω| ∂μ := byhave hUb : ∀ᵐ ω ∂μ, ‖U ω‖≤1 := hb.mono (fun ω hω ↦ by simpa only [Real.norm_eq_abs] using hω)have hUX := hX.bdd_mul hU hUbhave hUY := hY.bdd_mul hU hUbrw [←integral_sub hUX hUY]apply abs_integral_le_integral_abs.transapply integral_mono_ae (hUX.sub hUY).abs (hX.sub hY).absfilter_upwards [hb] with ω hωdsimp only [Pi.sub_apply]rw [←mul_sub,abs_mul]exact (mul_le_mul_of_nonneg_right hω (abs_nonneg _)).trans_eq (one_mul _)lemma bounded_multiplier_integral_tendsto {Ω I : Type*} [MeasurableSpace Ω]{μ : Measure Ω} {l : Filter I} {U : Ω → ℝ} {X : I → Ω → ℝ} {Y : Ω → ℝ}(hU : AEStronglyMeasurable U μ) (hb : ∀ᵐ ω ∂μ, |U ω|≤1)(hX : ∀ᶠ t in l, Integrable (X t) μ) (hY : Integrable Y μ)(hL1 : Tendsto (fun t ↦ ∫ ω, |X t ω-Y ω| ∂μ) l (𝓝 (0 : ℝ))) :Tendsto (fun t ↦ ∫ ω, U ω*X t ω ∂μ) l (𝓝 (∫ ω, U ω*Y ω ∂μ)) := byapply tendsto_iff_norm_sub_tendsto_zero.mprapply squeeze_zero' (Eventually.of_forall (fun _ ↦ norm_nonneg _)) ?_ hL1filter_upwards [hX] with t htsimpa only [Real.norm_eq_abs] using bounded_multiplier_integral_difference hU hb ht hYend SKValueendend OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778import Mathlibimport OAI.Probability.SKValue.Equations.RealFiltrationnamespace OAIsectionopen MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topologyopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology ENNReal NNRealopen Filter Setopen scoped Topology BigOperatorsopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologyopen MeasureTheory Set Filteropen scoped Topology BigOperatorsopen MeasureTheory Set Filter Finsetopen scoped Topology BigOperatorsnamespace SKValueopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topologylemma UnitMomentMartingale.weighted_terminal_expectation{Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsProbabilityMeasure μ]{ℱ : Filtration ℝ ‹MeasurableSpace Ω›} {f : ℝ → Ω → ℝ}(h : UnitMomentMartingale (μ := μ) ℱ f) {U : Ω → ℝ}(hUm : StronglyMeasurable[ℱ 1] U)(hU : ∀ᵐ ω ∂μ, |U ω|≤1 ∧ Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))){γ : ℝ → ℝ} {T : ℝ} (hT : 0≤T) (hT1 : T<1)(hc : ∀ᵐ ω ∂μ, ContinuousOn (fun t ↦ f t ω) (Icc (0 : ℝ) T))(hγ : IntervalIntegrable γ volume 0 T) :(∫ ω, U ω*(∫ t in (0 : ℝ)..T, γ t*f t ω) ∂μ)=∫ t in (0 : ℝ)..T, t*γ t := byhave hm (t : ℝ) (ht : t∈Icc (0 : ℝ) T) : t∈Ico (0 : ℝ) 1 := ⟨ht.1,ht.2.trans_lt hT1⟩rw [compact_weighted_fubini hT (fun t ht ↦ (h.measurable t (hm t ht)).mono (ℱ.le t))hc (fun t ht ↦ h.bounded t (hm t ht)) (hUm.mono (ℱ.le 1)).aestronglyMeasurable(hU.mono (fun _ hω ↦ hω.1)) hγ]apply intervalIntegral.integral_congrintro t htrw [uIcc_of_le hT] at htchange γ t * (∫ ω, U ω * f t ω ∂μ) = t * γ trw [h.terminal_past_product hUm hU (hm t ht),mul_comm]lemma bounded_multiplier_integral_difference {Ω : Type*} [MeasurableSpace Ω]{μ : Measure Ω} {U X Y : Ω → ℝ}(hU : AEStronglyMeasurable U μ) (hb : ∀ᵐ ω ∂μ, |U ω|≤1)(hX : Integrable X μ) (hY : Integrable Y μ) :|(∫ ω, U ω*X ω ∂μ)-(∫ ω, U ω*Y ω ∂μ)|≤∫ ω, |X ω-Y ω| ∂μ := byhave hUb : ∀ᵐ ω ∂μ, ‖U ω‖≤1 := hb.mono (fun ω hω ↦ by simpa only [Real.norm_eq_abs] using hω)have hUX := hX.bdd_mul hU hUbhave hUY := hY.bdd_mul hU hUbrw [←integral_sub hUX hUY]apply abs_integral_le_integral_abs.transapply integral_mono_ae (hUX.sub hUY).abs (hX.sub hY).absfilter_upwards [hb] with ω hωdsimp only [Pi.sub_apply]rw [←mul_sub,abs_mul]exact (mul_le_mul_of_nonneg_right hω (abs_nonneg _)).trans_eq (one_mul _)lemma bounded_multiplier_integral_tendsto {Ω I : Type*} [MeasurableSpace Ω]{μ : Measure Ω} {l : Filter I} {U : Ω → ℝ} {X : I → Ω → ℝ} {Y : Ω → ℝ}(hU : AEStronglyMeasurable U μ) (hb : ∀ᵐ ω ∂μ, |U ω|≤1)(hX : ∀ᶠ t in l, Integrable (X t) μ) (hY : Integrable Y μ)(hL1 : Tendsto (fun t ↦ ∫ ω, |X t ω-Y ω| ∂μ) l (𝓝 (0 : ℝ))) :Tendsto (fun t ↦ ∫ ω, U ω*X t ω ∂μ) l (𝓝 (∫ ω, U ω*Y ω ∂μ)) := byapply tendsto_iff_norm_sub_tendsto_zero.mprapply squeeze_zero' (Eventually.of_forall (fun _ ↦ norm_nonneg _)) ?_ hL1filter_upwards [hX] with t htsimpa only [Real.norm_eq_abs] using bounded_multiplier_integral_difference hU hb ht hYend SKValueendend OAI
lean/OAI/Probability/SKValue/GroundState/GaussianTree.lean+149-149
lean/OAI/Probability/SKValue/GroundState/GramSchmidtLimit.lean+182-182
lean/OAI/Probability/SKValue/GroundState/GumbelMax.lean+152-152
lean/OAI/Probability/SKValue/GroundState/GumbelReplacement.lean+132-132
lean/OAI/Probability/SKValue/GroundState/LiteralLower.lean+153-153
lean/OAI/Probability/SKValue/GroundState/LogComparison.lean+165-165
lean/OAI/Probability/SKValue/GroundState/MainConclusions.lean+32-32
lean/OAI/Probability/SKValue/GroundState/PredictableNormalizer.lean+294-294
lean/OAI/Probability/SKValue/GroundState/QuadraticSK.lean+199-199
lean/OAI/Probability/SKValue/GroundState/RandomColumn.lean+155-155
lean/OAI/Probability/SKValue/GroundState/RandomGuerra.lean+178-178
lean/OAI/Probability/SKValue/GroundState/RotatedCoefficients.lean+396-396
lean/OAI/Probability/SKValue/GroundState/RoundingSpin.lean+126-126
lean/OAI/Probability/SKValue/GroundState/StandardGaussian.lean+384-384
lean/OAI/Probability/SKValue/GroundState/TreeGuerra.lean+161-161
lean/OAI/Probability/SKValue/GroundState/TreeProductLaw.lean+204-204
lean/OAI/Probability/SKValue/GroundState/TreeWidths.lean+119-119
lean/OAI/Probability/SKValue/GroundState/WeakGuerra.lean+147-147
lean/OAI/Probability/SKValue/Main.lean+28-28
lean/OAI/Probability/SKValue/Model.lean+165-165
lean/OAI/Probability/SKValue/Processes/CrossMesh.lean+153-153
lean/OAI/Probability/SKValue/Processes/CrossMeshComparison.lean+90-90
lean/OAI/Probability/SKValue/Processes/CrossValueBound.lean+108-108
lean/OAI/Probability/SKValue/Processes/CurvatureNonneg.lean+43-43
lean/OAI/Probability/SKValue/Processes/DiffusionExistence.lean+84-84
lean/OAI/Probability/SKValue/Processes/DiffusionGradientCondExp.lean+143-143
lean/OAI/Probability/SKValue/Processes/DiffusionGradientWeakMartingaleLocal.lean+131-131
lean/OAI/Probability/SKValue/Processes/EulerL1.lean+202-202
lean/OAI/Probability/SKValue/Processes/EulerLimitProcess.lean+128-128
lean/OAI/Probability/SKValue/Processes/EulerMemLp.lean+151-151
lean/OAI/Probability/SKValue/Processes/Feedback.lean+299-299
lean/OAI/Probability/SKValue/Processes/FiniteGaussianFixedStrip.lean+55-55
lean/OAI/Probability/SKValue/Processes/FiniteProfileLaw.lean+40-40
lean/OAI/Probability/SKValue/Processes/ForcedDiffusion.lean+66-66
lean/OAI/Probability/SKValue/Processes/ForcedExpectation.lean+202-202
lean/OAI/Probability/SKValue/Processes/GradientSquareIntegral.lean+96-96
lean/OAI/Probability/SKValue/Processes/Measurable.lean+147-147
lean/OAI/Probability/SKValue/Processes/MeshBrownian.lean+343-343
lean/OAI/Probability/SKValue/Processes/MeshMaxError.lean+87-87
lean/OAI/Probability/SKValue/Processes/MeshMeanBound.lean+145-145
lean/OAI/Probability/SKValue/Processes/MeshRaw.lean+143-143
lean/OAI/Probability/SKValue/Processes/StripPaths.lean+78-78
lean/OAI/Probability/SKValue/Processes/TerminalCondExp.lean+105-105
lean/OAI/Probability/SKValue/Processes/TestDiffusion.lean+57-57
lean/OAI/Probability/SKValue/Processes/TestExpectation.lean+191-191
lean/OAI/Probability/SKValue/Processes/UnitMomentMartingale.lean+396-396
lean/OAI/Probability/SKValue/Processes/ValueEulerOneStep.lean+91-91
lean/OAI/Probability/SKValue/Processes/VariableTestLaw.lean+32-32
lean/OAI/Probability/SKValue/Processes/Volterra.lean+131-131
lean/OAI/Probability/SKValue/Processes/WeightedTerminalExpectation.lean+78-78