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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149import Mathlib
import OAI.Probability.SKValue.GroundState.AffineComparison
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
structure TreeLevel where
branchExcess : ℕ
endpoint : ℝ
height : ℝ
abbrev GaussianTree := List TreeLevel
abbrev TreeLeaves : GaussianTree → Type
| [] => PUnit
| l::T => Fin (l.branchExcess+1) × TreeLeaves T
abbrev TreeEdges : GaussianTree → Type
| [] => PEmpty
| l::T => Fin (l.branchExcess+1) ⊕ (Fin (l.branchExcess+1) × TreeEdges T)
instance treeLeavesFintype (T : GaussianTree) : Fintype (TreeLeaves T) := by
induction 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) := by
induction 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) := by
induction 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 0
noncomputable def treeOverlap (q : ℝ) : (T : GaussianTree) → TreeLeaves T → TreeLeaves T → ℝ
| [],_,_ => q
| l::T,α,β => if α.1=β.1 then treeOverlap l.endpoint T α.2 β.2 else q
def ValidTreeGrid (q : ℝ) : GaussianTree → Prop
| [] => q=1
| l::T => q≤l.endpoint ∧ ValidTreeGrid l.endpoint T
lemma 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 := by
classical
change (∑ 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) := by
rintro ⟨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 := by
split_ifs with ha hb <;> try rfl
exact (he i ⟨ha,hb⟩).elim
simp 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 T
noncomputable 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 T
lemma treeField_inner (q : ℝ) (T : GaussianTree) (hT : ValidTreeGrid q T)
(α β : TreeLeaves T) :
(∑ e,treeFieldVector q T α e*treeFieldVector q T β e)=treeOverlap q T α β-q := by
induction 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 hT
rw [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 β.2
change (l.endpoint-q)+(∑ e,treeFieldVector l.endpoint T α.2 e*treeFieldVector l.endpoint T β.2 e)=_
rw [hh]; ring
· ring
lemma 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) := by
induction 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 hT
rw [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 β.2
change ((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
· ring
lemma treeOverlap_self (q : ℝ) (T : GaussianTree) (hT : ValidTreeGrid q T) (α : TreeLeaves T) :
treeOverlap q T α α=1 := by
induction T generalizing q with
| nil => exact hT
| cons l T ih => simp only [treeOverlap,ite_true]; exact ih l.endpoint hT.2 α.2
lemma treeField_unit (T : GaussianTree) (hT : ValidTreeGrid 0 T) (α : TreeLeaves T) :
(∑ e,(treeFieldVector 0 T α e)^2)=1 := by
simp only [sq]
rw [treeField_inner 0 T hT,treeOverlap_self 0 T hT]
norm_num
lemma 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) := by
rw [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]
ring
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.AffineComparison
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
structure TreeLevel where branchExcess : ℕ endpoint : ℝ height : ℝ
abbrev GaussianTree := List TreeLevel
abbrev TreeLeaves : GaussianTree → Type | [] => PUnit | l::T => Fin (l.branchExcess+1) × TreeLeaves T
abbrev TreeEdges : GaussianTree → Type | [] => PEmpty | l::T => Fin (l.branchExcess+1) ⊕ (Fin (l.branchExcess+1) × TreeEdges T)
instance treeLeavesFintype (T : GaussianTree) : Fintype (TreeLeaves T) := by induction 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) := by induction 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) := by induction 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 0
noncomputable def treeOverlap (q : ℝ) : (T : GaussianTree) → TreeLeaves T → TreeLeaves T → ℝ | [],_,_ => q | l::T,α,β => if α.1=β.1 then treeOverlap l.endpoint T α.2 β.2 else q
def ValidTreeGrid (q : ℝ) : GaussianTree → Prop | [] => q=1 | l::T => q≤l.endpoint ∧ ValidTreeGrid l.endpoint T
lemma 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 := by classical change (∑ 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) := by rintro ⟨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 := by split_ifs with ha hb <;> try rfl exact (he i ⟨ha,hb⟩).elim simp 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 T
noncomputable 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 T
lemma treeField_inner (q : ℝ) (T : GaussianTree) (hT : ValidTreeGrid q T) (α β : TreeLeaves T) : (∑ e,treeFieldVector q T α e*treeFieldVector q T β e)=treeOverlap q T α β-q := by induction 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 hT rw [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 β.2 change (l.endpoint-q)+(∑ e,treeFieldVector l.endpoint T α.2 e*treeFieldVector l.endpoint T β.2 e)=_ rw [hh]; ring · ring
lemma 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) := by induction 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 hT rw [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 β.2 change ((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 · ring
lemma treeOverlap_self (q : ℝ) (T : GaussianTree) (hT : ValidTreeGrid q T) (α : TreeLeaves T) : treeOverlap q T α α=1 := by induction T generalizing q with | nil => exact hT | cons l T ih => simp only [treeOverlap,ite_true]; exact ih l.endpoint hT.2 α.2
lemma treeField_unit (T : GaussianTree) (hT : ValidTreeGrid 0 T) (α : TreeLeaves T) : (∑ e,(treeFieldVector 0 T α e)^2)=1 := by simp only [sq] rw [treeField_inner 0 T hT,treeOverlap_self 0 T hT] norm_num
lemma 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) := by rw [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] ring
end SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182import Mathlib
import OAI.Probability.SKValue.GroundState.GaussianColumn
namespace OAI
section
open Filter Set InnerProductSpace
open scoped Topology BigOperators RealInnerProductSpace
namespace SKValueG
variable {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) := by
have hdiff : Tendsto (fun n ↦ ⟪x n,y n⟫-⟪x' n,y n⟫) atTop (𝓝 0) := by
apply 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 hxy
omit [∀ n, InnerProductSpace ℝ (E n)] in
lemma 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) := by
have hd : Tendsto (fun n ↦ ‖x n‖-‖x' n‖) atTop (𝓝 0) := by
exact squeeze_zero_norm (fun n ↦ by simpa only [Real.norm_eq_abs] using abs_norm_sub_norm_le (x n) (x' n)) hx
simpa 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) := by
induction 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) := by
simp 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 h
have 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) := by
simpa 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 ↦ ?_) hs
have he := gramSchmidt_def'' ℝ (a n) j
have 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) := by
simp only [Nat.Iio_eq_range] at he
calc
_ = gramSchmidt ℝ (a n) j-(gramSchmidt ℝ (a n) j+_) := congrArg (fun x ↦ gramSchmidt ℝ (a n) j-x) he
_ = _ := by abel
rw [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) := by
have hg := gramSchmidt_approx a K hn hi j hj
have hgn := norm_approx_tendsto hg (hn j hj)
have hscale : Tendsto (fun n ↦ |‖gramSchmidt ℝ (a n) j‖⁻¹-1| *
‖gramSchmidt ℝ (a n) j‖) atTop (𝓝 0) := by
simpa using ((hgn.inv₀ (by norm_num)).sub_const 1).abs.mul hgn
apply 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‖ := by
calc
_ = ‖(gramSchmidtNormed ℝ (a n) j-gramSchmidt ℝ (a n) j)+(gramSchmidt ℝ (a n) j-a n j)‖ := by congr 1; abel
_ ≤ _ := norm_add_le _ _
_ = _ := by
congr 1
change ‖‖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 SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Set InnerProductSpace
open scoped Topology NNReal ENNReal BigOperators RealInnerProductSpace
namespace SKValueG
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
noncomputable def orthogonalRemainder (v : ℕ → E) (w : E) (j : ℕ) : E :=
w-∑ i∈Finset.range j,(⟪v i,w⟫ : ℝ) • v i
lemma inner_orthogonalRemainder (v : ℕ → E) (w : E) (j : ℕ)
(ho : ∀ i<j,⟪v j,v i⟫=0) :
⟪v j,orthogonalRemainder v w j⟫=⟪v j,w⟫ := by
simp 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 := by
apply Finset.sum_eq_zero
intro i hi
simp [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 := by
simp only [orthogonalRemainder,Finset.sum_range_succ]
abel
lemma 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) := by
rw [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⟫ := by
simp only [columnVector,inner_add_left,real_inner_smul_left]
rw [inner_orthogonalRemainder v w j ho,columnResidual_orthogonalRemainder v w j ho]
section Limit
variable {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) := by
have hs : Tendsto (fun n ↦ ∑ j∈Finset.range K,⟪v n j,w n⟫*⟪v n j,z n⟫) atTop (𝓝 0) := by
have 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 hh
have ht := hwz.sub hs
simpa only [orthogonalRemainder,inner_sub_left,sum_inner,real_inner_smul_left,sub_zero] using ht
theorem 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)) := by
have 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_rfl
have 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)) hb
simpa 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 Limit
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.GaussianColumn
namespace OAI
section
open 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) := by have hdiff : Tendsto (fun n ↦ ⟪x n,y n⟫-⟪x' n,y n⟫) atTop (𝓝 0) := by apply 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 hxy
omit [∀ 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) := by have hd : Tendsto (fun n ↦ ‖x n‖-‖x' n‖) atTop (𝓝 0) := by exact squeeze_zero_norm (fun n ↦ by simpa only [Real.norm_eq_abs] using abs_norm_sub_norm_le (x n) (x' n)) hx simpa 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) := by induction 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) := by simp 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 h have 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) := by simpa 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 ↦ ?_) hs have he := gramSchmidt_def'' ℝ (a n) j have 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) := by simp only [Nat.Iio_eq_range] at he calc _ = gramSchmidt ℝ (a n) j-(gramSchmidt ℝ (a n) j+_) := congrArg (fun x ↦ gramSchmidt ℝ (a n) j-x) he _ = _ := by abel rw [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) := by have hg := gramSchmidt_approx a K hn hi j hj have hgn := norm_approx_tendsto hg (hn j hj) have hscale : Tendsto (fun n ↦ |‖gramSchmidt ℝ (a n) j‖⁻¹-1| * ‖gramSchmidt ℝ (a n) j‖) atTop (𝓝 0) := by simpa using ((hgn.inv₀ (by norm_num)).sub_const 1).abs.mul hgn apply 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‖ := by calc _ = ‖(gramSchmidtNormed ℝ (a n) j-gramSchmidt ℝ (a n) j)+(gramSchmidt ℝ (a n) j-a n j)‖ := by congr 1; abel _ ≤ _ := norm_add_le _ _ _ = _ := by congr 1 change ‖‖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 SKValueG
end
section
open 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 i
lemma inner_orthogonalRemainder (v : ℕ → E) (w : E) (j : ℕ) (ho : ∀ i<j,⟪v j,v i⟫=0) : ⟪v j,orthogonalRemainder v w j⟫=⟪v j,w⟫ := by simp 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 := by apply Finset.sum_eq_zero intro i hi simp [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 := by simp only [orthogonalRemainder,Finset.sum_range_succ] abel
lemma 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) := by rw [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⟫ := by simp 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) := by have hs : Tendsto (fun n ↦ ∑ j∈Finset.range K,⟪v n j,w n⟫*⟪v n j,z n⟫) atTop (𝓝 0) := by have 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 hh have ht := hwz.sub hs simpa only [orthogonalRemainder,inner_sub_left,sum_inner,real_inner_smul_left,sub_zero] using ht
theorem 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)) := by have 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_rfl have 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)) hb simpa 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 SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152import Mathlib
import OAI.Probability.SKValue.GroundState.RotatedCoefficients
import OAI.Probability.SKValue.GroundState.ExponentialMoments
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology ENNReal NNReal BigOperators
namespace SKValueG
lemma finiteMaximum_le_iff {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (t : ℝ) :
finiteMaximum x ≤ t ↔ ∀ i, x i≤t := by
constructor
· intro h i; exact (le_finiteMaximum x i).trans h
· intro h; obtain ⟨i,hi⟩ := exists_finiteMaximum x; simpa only [←hi] using h i
noncomputable 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_nonempty
lemma gumbel_shift_cdf (d t : ℝ) :
cdf (gumbelLaw.map (fun x ↦ x+d)) t=Real.exp (-Real.exp (-(t-d))) := by
have : IsProbabilityMeasure (gumbelLaw.map (fun x ↦ x+d)) := inferInstance
rw [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 <;> linarith
rw [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))) := by
have hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=
(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurable
have : IsProbabilityMeasure ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map
(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := inferInstance
rw [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)) := by
ext z
simp 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 1
simp 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) := by
have hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=
(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurable
have : IsProbabilityMeasure ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map
(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := inferInstance
have : IsProbabilityMeasure (gumbelLaw.map (fun x ↦ x+logSumExp d)) := inferInstance
apply prob_measure_eq_of_cdf
intro t
rw [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)) := by
have hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=
(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurable
have h : Integrable (fun x : ℝ ↦ x) ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map
(fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := by
rw [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 h
lemma integral_gumbel_max {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) :
(∫ z, finiteMaximum (fun i ↦ d i+z i) ∂Measure.pi (fun _ : ι ↦ gumbelLaw))=
gumbelMean+logSumExp d := by
have hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) :=
(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurable
have 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 h
rw [h,integral_add gumbel_integrable (integrable_const _)]
simp only [integral_const,probReal_univ,smul_eq_mul,one_mul,gumbelMean]
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology BigOperators ENNReal NNReal
namespace SKValueG
lemma log_tangent_bound {x m : ℝ} (hx : 0<x) (hm : 0 < m) :
Real.log x ≤ x/m-1+Real.log m := by
have h := Real.log_le_sub_one_of_pos (div_pos hx hm)
rw [Real.log_div hx.ne' hm.ne'] at h
linarith
lemma 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 ι : ℝ)) := by
let c : ℝ := Fintype.card ι
have hc : 0<c := by dsimp [c]; positivity
let m : ℝ := (∑ i, x i)/c
have hm : 0 < m := div_pos (Finset.sum_pos (fun i _ ↦ hx i) Finset.univ_nonempty) hc
have 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 := by
rw [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]
ring
rw [he] at h
exact (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 ω ∂μ) := by
have hm : 0<∫ ω, f ω ∂μ := integral_pos_iff_support_of_nonneg_ae (hp.mono (fun _ h ↦ h.le)) hf |>.mpr (by
have 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 ω ∂μ) := by
rw [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 he
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.RotatedCoefficientsimport OAI.Probability.SKValue.GroundState.ExponentialMoments
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology ENNReal NNReal BigOperatorsnamespace SKValueG
lemma finiteMaximum_le_iff {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (t : ℝ) : finiteMaximum x ≤ t ↔ ∀ i, x i≤t := by constructor · intro h i; exact (le_finiteMaximum x i).trans h · intro h; obtain ⟨i,hi⟩ := exists_finiteMaximum x; simpa only [←hi] using h i
noncomputable 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_nonempty
lemma gumbel_shift_cdf (d t : ℝ) : cdf (gumbelLaw.map (fun x ↦ x+d)) t=Real.exp (-Real.exp (-(t-d))) := by have : IsProbabilityMeasure (gumbelLaw.map (fun x ↦ x+d)) := inferInstance rw [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 <;> linarith rw [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))) := by have hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) := (continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurable have : IsProbabilityMeasure ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map (fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := inferInstance rw [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)) := by ext z simp 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 1 simp 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) := by have hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) := (continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurable have : IsProbabilityMeasure ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map (fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := inferInstance have : IsProbabilityMeasure (gumbelLaw.map (fun x ↦ x+logSumExp d)) := inferInstance apply prob_measure_eq_of_cdf intro t rw [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)) := by have hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) := (continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurable have h : Integrable (fun x : ℝ ↦ x) ((Measure.pi (fun _ : ι ↦ gumbelLaw)).map (fun z ↦ finiteMaximum (fun i ↦ d i+z i))) := by rw [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 h
lemma integral_gumbel_max {ι : Type*} [Fintype ι] [Nonempty ι] (d : ι → ℝ) : (∫ z, finiteMaximum (fun i ↦ d i+z i) ∂Measure.pi (fun _ : ι ↦ gumbelLaw))= gumbelMean+logSumExp d := by have hm : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ d i+z i)) := (continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurable have 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 h rw [h,integral_add gumbel_integrable (integrable_const _)] simp only [integral_const,probReal_univ,smul_eq_mul,one_mul,gumbelMean]
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology BigOperators ENNReal NNRealnamespace SKValueG
lemma log_tangent_bound {x m : ℝ} (hx : 0<x) (hm : 0 < m) : Real.log x ≤ x/m-1+Real.log m := by have h := Real.log_le_sub_one_of_pos (div_pos hx hm) rw [Real.log_div hx.ne' hm.ne'] at h linarith
lemma 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 ι : ℝ)) := by let c : ℝ := Fintype.card ι have hc : 0<c := by dsimp [c]; positivity let m : ℝ := (∑ i, x i)/c have hm : 0 < m := div_pos (Finset.sum_pos (fun i _ ↦ hx i) Finset.univ_nonempty) hc have 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 := by rw [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] ring rw [he] at h exact (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 ω ∂μ) := by have hm : 0<∫ ω, f ω ∂μ := integral_pos_iff_support_of_nonneg_ae (hp.mono (fun _ h ↦ h.le)) hf |>.mpr (by have 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 ω ∂μ) := by rw [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 he
end SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132import Mathlib
import OAI.Probability.SKValue.GroundState.FiniteBranching
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology ENNReal NNReal BigOperators
namespace SKValueG
lemma lipschitz_integrable_comp {Ω : Type*} [MeasurableSpace Ω]
{μ : Measure Ω} [IsFiniteMeasure μ] {f : Ω → ℝ} (hi : Integrable f μ)
{ψ : ℝ → ℝ} {L : ℝ≥0} (hψ : LipschitzWith L ψ) : Integrable (fun ω ↦ ψ (f ω)) μ := by
apply ((hi.norm.const_mul (L : ℝ)).add (integrable_const ‖ψ 0‖)).mono'
(hψ.continuous.comp_aestronglyMeasurable hi.aestronglyMeasurable)
exact Eventually.of_forall (fun ω ↦ by
have h : ‖ψ (f ω)-ψ 0‖ ≤ (L : ℝ)*‖f ω‖ := by simpa only [sub_zero] using hψ.norm_sub_le (f ω) 0
have htri := norm_add_le (ψ (f ω)-ψ 0) (ψ 0)
simp only [sub_add_cancel] at htri
change ‖ψ (f ω)‖ ≤ (L : ℝ)*‖f ω‖+‖ψ 0‖
linarith)
noncomputable def gumbelSmooth (m : ℝ) (ψ : ℝ → ℝ) (s : ℝ) : ℝ :=
∫ g, ψ (g/m+s) ∂gumbelLaw
lemma gumbelSmooth_lipschitz {m : ℝ} {ψ : ℝ → ℝ} {L : ℝ≥0}
(hψ : LipschitzWith L ψ) : LipschitzWith L (gumbelSmooth m ψ) := by
rw [lipschitzWith_iff_dist_le_mul]
intro x y
have 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| := by
simpa 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| ∂μ) := by
have his := lipschitz_integrable_comp hi hψ
have hie : Integrable (fun ω ↦ |s ω-c|) μ := (hi.sub (integrable_const c)).abs
calc
_ = |∫ ω,ψ (s ω)-ψ c ∂μ| := by rw [integral_sub his (integrable_const _)]; simp
_ ≤ ∫ ω,|ψ (s ω)-ψ c| ∂μ := by simpa only [Real.norm_eq_abs] using
norm_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) := by
have hmmax : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ m*d i+z i)) :=
(continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurable
have ht : Measurable (fun y : ℝ ↦ ψ (y/m-Real.log (Fintype.card ι : ℝ)/m)) := by fun_prop
have 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 h
have he (z : ι → ℝ) : finiteMaximum (fun i ↦ d i+z i/m)=
finiteMaximum (fun i ↦ m*d i+z i)/m := by
rw [←finiteMaximum_div_pos _ hm]
congr 1; ext i; field_simp
simp_rw [he]
rw [h]
apply integral_congr_ae
exact Eventually.of_forall (fun g ↦ by
apply 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))) := by
let Y := fun i ω ↦ Real.exp (m*X i ω)
have hf : Measurable (fun x : ℝ ↦ Real.exp (m*x)) := by fun_prop
have hl : Integrable (fun ω ↦ Real.log (Y 0 ω)) μ := by
simpa only [Y,Real.log_exp] using hi.const_mul m
have hiY (i) : Integrable (Y i) μ := ((hid i).comp hf).integrable_iff.mpr he
have hilogY (i) : Integrable (fun ω ↦ Real.log (Y i ω)) μ :=
(((hid i).comp hf).comp Real.measurable_log).integrable_iff.mpr hl
have 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 ω ∂μ)/m
let s := fun n ω ↦ Real.log (empiricalMean Y n ω)/m
have his (n) : Integrable (s n) μ :=
(empiricalMean_log_integrable Y hiY hilogY hpY n).div_const m
have herr (n) : (∫ ω,|s n ω-c| ∂μ)=
(∫ ω,|Real.log (empiricalMean Y n ω)-Real.log (∫ ω,Y 0 ω ∂μ)| ∂μ)/m := by
rw [←integral_div]
apply integral_congr_ae
exact 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) := by
simpa only [herr,zero_div] using hlim.div_const m
have hg := gumbelSmooth_lipschitz (m := m) hψ
have hb (n) := integral_comp_diff_le (his n) hg c
have 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 (by
simpa 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 ω) ∂μ := by
apply integral_congr_ae
exact Eventually.of_forall (fun ω ↦ by
have hh := scaled_gumbel_test_integral (fun i : Fin (n+1) ↦ X i ω) hm ψ hψ.continuous.measurable
rw [Fin.sum_univ_eq_sum_range (fun i ↦ Real.exp (m*X i ω))] at hh
simpa only [Fintype.card_fin,Nat.cast_add,Nat.cast_one,empiricalMean,Y,s] using hh)
simpa only [heq,c,Y] using hconv
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.FiniteBranching
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology ENNReal NNReal BigOperatorsnamespace SKValueG
lemma lipschitz_integrable_comp {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} [IsFiniteMeasure μ] {f : Ω → ℝ} (hi : Integrable f μ) {ψ : ℝ → ℝ} {L : ℝ≥0} (hψ : LipschitzWith L ψ) : Integrable (fun ω ↦ ψ (f ω)) μ := by apply ((hi.norm.const_mul (L : ℝ)).add (integrable_const ‖ψ 0‖)).mono' (hψ.continuous.comp_aestronglyMeasurable hi.aestronglyMeasurable) exact Eventually.of_forall (fun ω ↦ by have h : ‖ψ (f ω)-ψ 0‖ ≤ (L : ℝ)*‖f ω‖ := by simpa only [sub_zero] using hψ.norm_sub_le (f ω) 0 have htri := norm_add_le (ψ (f ω)-ψ 0) (ψ 0) simp only [sub_add_cancel] at htri change ‖ψ (f ω)‖ ≤ (L : ℝ)*‖f ω‖+‖ψ 0‖ linarith)
noncomputable def gumbelSmooth (m : ℝ) (ψ : ℝ → ℝ) (s : ℝ) : ℝ := ∫ g, ψ (g/m+s) ∂gumbelLaw
lemma gumbelSmooth_lipschitz {m : ℝ} {ψ : ℝ → ℝ} {L : ℝ≥0} (hψ : LipschitzWith L ψ) : LipschitzWith L (gumbelSmooth m ψ) := by rw [lipschitzWith_iff_dist_le_mul] intro x y have 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| := by simpa 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| ∂μ) := by have his := lipschitz_integrable_comp hi hψ have hie : Integrable (fun ω ↦ |s ω-c|) μ := (hi.sub (integrable_const c)).abs calc _ = |∫ ω,ψ (s ω)-ψ c ∂μ| := by rw [integral_sub his (integrable_const _)]; simp _ ≤ ∫ ω,|ψ (s ω)-ψ c| ∂μ := by simpa only [Real.norm_eq_abs] using norm_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) := by have hmmax : Measurable (fun z : ι → ℝ ↦ finiteMaximum (fun i ↦ m*d i+z i)) := (continuous_finiteMaximum.comp (continuous_const.add continuous_id)).measurable have ht : Measurable (fun y : ℝ ↦ ψ (y/m-Real.log (Fintype.card ι : ℝ)/m)) := by fun_prop have 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 h have he (z : ι → ℝ) : finiteMaximum (fun i ↦ d i+z i/m)= finiteMaximum (fun i ↦ m*d i+z i)/m := by rw [←finiteMaximum_div_pos _ hm] congr 1; ext i; field_simp simp_rw [he] rw [h] apply integral_congr_ae exact Eventually.of_forall (fun g ↦ by apply 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))) := by let Y := fun i ω ↦ Real.exp (m*X i ω) have hf : Measurable (fun x : ℝ ↦ Real.exp (m*x)) := by fun_prop have hl : Integrable (fun ω ↦ Real.log (Y 0 ω)) μ := by simpa only [Y,Real.log_exp] using hi.const_mul m have hiY (i) : Integrable (Y i) μ := ((hid i).comp hf).integrable_iff.mpr he have hilogY (i) : Integrable (fun ω ↦ Real.log (Y i ω)) μ := (((hid i).comp hf).comp Real.measurable_log).integrable_iff.mpr hl have 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 ω ∂μ)/m let s := fun n ω ↦ Real.log (empiricalMean Y n ω)/m have his (n) : Integrable (s n) μ := (empiricalMean_log_integrable Y hiY hilogY hpY n).div_const m have herr (n) : (∫ ω,|s n ω-c| ∂μ)= (∫ ω,|Real.log (empiricalMean Y n ω)-Real.log (∫ ω,Y 0 ω ∂μ)| ∂μ)/m := by rw [←integral_div] apply integral_congr_ae exact 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) := by simpa only [herr,zero_div] using hlim.div_const m have hg := gumbelSmooth_lipschitz (m := m) hψ have hb (n) := integral_comp_diff_le (his n) hg c have 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 (by simpa 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 ω) ∂μ := by apply integral_congr_ae exact Eventually.of_forall (fun ω ↦ by have hh := scaled_gumbel_test_integral (fun i : Fin (n+1) ↦ X i ω) hm ψ hψ.continuous.measurable rw [Fin.sum_univ_eq_sum_range (fun i ↦ Real.exp (m*X i ω))] at hh simpa only [Fintype.card_fin,Nat.cast_add,Nat.cast_one,empiricalMean,Y,s] using hh) simpa only [heq,c,Y] using hconv
end SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import Mathlib
import OAI.Probability.SKValue.Equations.LiteralNormalizer
import OAI.Probability.SKValue.Control.Regularity
import OAI.Probability.SKValue.GroundState.RoundingSpin
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValue
theorem 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 := by
obtain ⟨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 SKValue
end
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
lemma finiteMaximum_prod_add {ι Λ : Type*} [Fintype ι] [Nonempty ι]
[Fintype Λ] [Nonempty Λ] (f : ι → ℝ) (g : Λ → ℝ) :
finiteMaximum (fun p : ι×Λ ↦ f p.1+g p.2)=finiteMaximum f+finiteMaximum g := by
apply 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 f
obtain ⟨a,ha⟩ := exists_finiteMaximum g
rw [←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))) := by
apply le_antisymm
· obtain ⟨p,hp⟩ := exists_finiteMaximum f
rw [←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| := by
classical
apply le_antisymm
· obtain ⟨σ,hσ⟩ := exists_finiteMaximum (fun σ : ι → Bool ↦ ∑ i, spin (σ i)*x i)
rw [←hσ]
apply Finset.sum_le_sum
intro 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| := by
by_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 := by
simp only [linearProcess,leafFieldCoeff,Fintype.sum_prod_type,leafField,Finset.mul_sum]
apply Finset.sum_congr rfl
intro i _
apply Finset.sum_congr rfl
intro k _
ring
lemma 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 α) := by
rw [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 (κ×κ) := by
have 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)) := by
funext p
simp [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×κ) := by
have 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 h
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.LiteralNormalizerimport OAI.Probability.SKValue.Control.Regularityimport OAI.Probability.SKValue.GroundState.RoundingSpin
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValue
theorem 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 := by obtain ⟨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 SKValue
end
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
lemma finiteMaximum_prod_add {ι Λ : Type*} [Fintype ι] [Nonempty ι] [Fintype Λ] [Nonempty Λ] (f : ι → ℝ) (g : Λ → ℝ) : finiteMaximum (fun p : ι×Λ ↦ f p.1+g p.2)=finiteMaximum f+finiteMaximum g := by apply 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 f obtain ⟨a,ha⟩ := exists_finiteMaximum g rw [←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))) := by apply le_antisymm · obtain ⟨p,hp⟩ := exists_finiteMaximum f rw [←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| := by classical apply le_antisymm · obtain ⟨σ,hσ⟩ := exists_finiteMaximum (fun σ : ι → Bool ↦ ∑ i, spin (σ i)*x i) rw [←hσ] apply Finset.sum_le_sum intro 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| := by by_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 := by simp only [linearProcess,leafFieldCoeff,Fintype.sum_prod_type,leafField,Finset.mul_sum] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro k _ ring
lemma 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 α) := by rw [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 (κ×κ) := by have 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)) := by funext p simp [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×κ) := by have 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 h
end SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165import Mathlib
import OAI.Probability.SKValue.GroundState.RotatedCoefficients
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
lemma 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 κ := by
simpa 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 κ := by
let 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 ↦ by
rw [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 ↦ by
rw [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 h
lemma expected_logPartition_embedLeft {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν]
(a : ι → κ → ℝ) :
(∫ z, logPartition (linearProcess (embedLeft (ν := ν) a) z) ∂gaussianProduct (κ ⊕ ν)) =
∫ z, logPartition (linearProcess a z) ∂gaussianProduct κ := by
have 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 := by
funext i
simp [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 ν := by
have 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 := by
funext i
simp [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 ν := by
have 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 h
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
lemma finiteMaximum_mono {ι : Type*} [Fintype ι] [Nonempty ι] {x y : ι → ℝ}
(h : ∀ i, x i ≤ y i) : finiteMaximum x ≤ finiteMaximum y := by
obtain ⟨i,hi⟩ := exists_finiteMaximum x
rw [← 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 := by
obtain ⟨i,hi⟩ := exists_finiteMaximum x
obtain ⟨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) i
lemma affineMaximum_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ]
(a : ι → κ → ℝ) (d : ι → ℝ) :
Integrable (fun z ↦ finiteMaximum (fun i ↦ linearProcess a z i+d i)) (gaussianProduct κ) := by
apply (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 ↦ by
simpa 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 ι : ℝ)) := by
have hp : partition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) =
∑ i, (m i : ℝ)*Real.exp (β*x i) := by
simp [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) := by
obtain ⟨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)) := by
rw [hp]
calc
_ ≤ ∑ i : ι, 2*Real.exp (β*finiteMaximum (fun i ↦ x i+d i)) := by
apply Finset.sum_le_sum
intro 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; ring
refine ⟨?_,?_⟩
· simpa only [Real.log_exp,logPartition] using Real.log_le_log (Real.exp_pos _) hlo
· have hc : 0<2*(Fintype.card ι : ℝ) := by positivity
have hh := Real.log_le_log ((Real.exp_pos _).trans_le hlo) hup
simpa only [logPartition,Real.log_mul hc.ne' (Real.exp_pos _).ne',
Real.log_exp,add_comm] using hh
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.RotatedCoefficients
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
lemma 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 κ := by simpa 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 κ := by let 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 ↦ by rw [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 ↦ by rw [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 h
lemma expected_logPartition_embedLeft {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν] (a : ι → κ → ℝ) : (∫ z, logPartition (linearProcess (embedLeft (ν := ν) a) z) ∂gaussianProduct (κ ⊕ ν)) = ∫ z, logPartition (linearProcess a z) ∂gaussianProduct κ := by have 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 := by funext i simp [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 ν := by have 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 := by funext i simp [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 ν := by have 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 h
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
lemma finiteMaximum_mono {ι : Type*} [Fintype ι] [Nonempty ι] {x y : ι → ℝ} (h : ∀ i, x i ≤ y i) : finiteMaximum x ≤ finiteMaximum y := by obtain ⟨i,hi⟩ := exists_finiteMaximum x rw [← 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 := by obtain ⟨i,hi⟩ := exists_finiteMaximum x obtain ⟨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) i
lemma affineMaximum_integrable {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ] (a : ι → κ → ℝ) (d : ι → ℝ) : Integrable (fun z ↦ finiteMaximum (fun i ↦ linearProcess a z i+d i)) (gaussianProduct κ) := by apply (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 ↦ by simpa 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 ι : ℝ)) := by have hp : partition (fun i : (Σ i, Fin (m i)) ↦ β*x i.1) = ∑ i, (m i : ℝ)*Real.exp (β*x i) := by simp [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) := by obtain ⟨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)) := by rw [hp] calc _ ≤ ∑ i : ι, 2*Real.exp (β*finiteMaximum (fun i ↦ x i+d i)) := by apply Finset.sum_le_sum intro 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; ring refine ⟨?_,?_⟩ · simpa only [Real.log_exp,logPartition] using Real.log_le_log (Real.exp_pos _) hlo · have hc : 0<2*(Fintype.card ι : ℝ) := by positivity have hh := Real.log_le_log ((Real.exp_pos _).trans_le hlo) hup simpa only [logPartition,Real.log_mul hc.ne' (Real.exp_pos _).ne', Real.log_exp,add_comm] using hh
end SKValueG
end
end OAI12345678910111213141516171819202122232425262728293031321234567891011121314151617181920212223242526272829303132import Mathlib
import OAI.Probability.SKValue.Variation.MinimizerContact
import OAI.Probability.SKValue.Variation.ContactAssembly
import OAI.Probability.SKValue.Processes.DiffusionExistence
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal
namespace SKValue
theorem 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 hT1
lemma 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 SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Variation.MinimizerContactimport OAI.Probability.SKValue.Variation.ContactAssemblyimport OAI.Probability.SKValue.Processes.DiffusionExistence
namespace OAI
sectionopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNRealnamespace SKValue
theorem 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 SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294import Mathlib
import OAI.Probability.SKValue.Model
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
namespace SKValue
lemma 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 μ) := by
let fill : (S → ℝ) → ι → ℝ := fun x i ↦ if hi : i ∈ S then x ⟨i,hi⟩ else 0
have hfill : Measurable fill := by
apply Measurable.of_eval
intro i
by_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_const
have hid : ∀ x : ι → ℝ, F (fill (fun i : S ↦ x i)) = F x := by
intro x
apply hdep
intro i hi
simp [fill,hi]
have hST : Disjoint S {j} := by simpa using hj
have 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 H
lemma 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⟩ := by
simp [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 := by
induction 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) := by
intro j hj
induction j with
| zero => exact measurable_const
| succ j ih =>
have hjN : j < N := by omega
have hy := ih (by omega)
have hz := measurable_coordinate N j
have hu := (hU j hjN).comp hy
simp only [euler]
fun_prop
lemma 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))) := by
let 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 ↦ by
apply congrArg (a (meshTime T N j))
apply euler_depends_on_past T N γ u j z z'
intro i hi
have hiN : i < N+1 := hi.trans hj
rw [coordinate_eq_apply hiN,coordinate_eq_apply hiN]
apply heq
simp [S,hi])
have heq : coordinate N j = fun z : Fin (N+1) → ℝ ↦ z ⟨j,hj⟩ :=
funext (coordinate_eq_apply hj)
rw [heq]
exact h
variable {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}
lemma gaussian_mean {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ) :
∫ ω, Z ω ∂μ = 0 := by
rw [hZ.integral_eq, integral_id_gaussianReal]
lemma gaussian_memLp {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ)
(p : ℝ≥0∞) (hp : p ≠ ∞) : MemLp Z p μ := by
have H : MemLp (id : ℝ → ℝ) p (μ.map Z) := by
rw [hZ.map_eq]
exact memLp_id_gaussianReal' p hp
simpa using (memLp_map_measure_iff H.aestronglyMeasurable hZ.aemeasurable).1 H
lemma gaussian_second_moment {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ) :
∫ ω, (Z ω)^2 ∂μ = 1 := by
have hvar := hZ.variance_eq
rw [variance_eq_integral hZ.aemeasurable, gaussian_mean hZ] at hvar
simpa using hvar
noncomputable 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 μ := by
exact 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 := by
simp only [normalizedIncrement, mul_assoc]
rw [integral_const_mul]
have hi := hind.integral_mul_eq_mul_integral hH hZ.aemeasurable.aestronglyMeasurable
change (∫ ω, H ω * Z ω ∂μ) = _ at hi
rw [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 := by
have 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 hi
simp 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 μ := by
apply (memLp_two_iff_integrable_sq
((hH.aestronglyMeasurable.const_mul _).mul hZ.aemeasurable.aestronglyMeasurable)).2
have hi := (hind.comp (measurable_id.pow_const 2) (measurable_id.pow_const 2)).integrable_mul
hH.integrable_sq (gaussian_memLp hZ 2 (by norm_num)).integrable_sq
have hj := hi.const_mul (predictableNormalizer H μ ^ 2)
simpa only [normalizedIncrement, Pi.mul_apply, mul_pow, mul_assoc, Function.comp_def, id_eq] using hj
lemma 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 ω ∂μ := by
have 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 hi
simp 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 := by
have hi := hind.integral_mul_eq_mul_integral (hH.mul hK)
hZ.aemeasurable.aestronglyMeasurable
change (∫ ω, (H ω * K ω) * Z ω ∂μ) = _ at hi
calc
_ = predictableNormalizer H μ * ∫ ω, (H ω * K ω) * Z ω ∂μ := by
rw [← integral_const_mul]
congr 1
ext ω
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 _)⟩).hasLaw
def 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))) := by
have 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 H
lemma 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)) := by
intro z z' h
exact 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) := by
intro z z' h
dsimp only
rw [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)) := by
intro z z' h
apply congrArg (a (meshTime T N j))
apply euler_depends_on_past
intro i hi
have hiN : i<N+1 := by omega
rw [coordinate_eq_apply hiN, coordinate_eq_apply hiN]
exact h ⟨i,hiN⟩ hi
lemma 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)))) := by
intro z z' h
have heq := hH.mono (Nat.le_succ j) z z' h
have hz : coordinate N j z=coordinate N j z' := by
rw [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 := by
have hi : i<N+1 := hij.trans hj
have 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 := by
dsimp only
have hm := hA.comp (measurable_euler T N γ u hU j (by omega))
have hind := euler_coefficient_independent (γ := γ) hj hU hA
exact ⟨predictableNormalizer_pos hpos,
normalizedIncrement_mean hm.aestronglyMeasurable (coordinate_hasLaw N j) hind,
normalizedIncrement_second_moment hm.aestronglyMeasurable (coordinate_hasLaw N j) hind hpos⟩
end SKValue
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Model
namespace OAI
section
open MeasureTheory ProbabilityTheory Setopen scoped ENNReal NNReal BigOperatorsnamespace SKValue
lemma 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 μ) := by let fill : (S → ℝ) → ι → ℝ := fun x i ↦ if hi : i ∈ S then x ⟨i,hi⟩ else 0 have hfill : Measurable fill := by apply Measurable.of_eval intro i by_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_const have hid : ∀ x : ι → ℝ, F (fill (fun i : S ↦ x i)) = F x := by intro x apply hdep intro i hi simp [fill,hi] have hST : Disjoint S {j} := by simpa using hj have 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 H
lemma 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⟩ := by simp [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 := by induction 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) := by intro j hj induction j with | zero => exact measurable_const | succ j ih => have hjN : j < N := by omega have hy := ih (by omega) have hz := measurable_coordinate N j have hu := (hU j hjN).comp hy simp only [euler] fun_prop
lemma 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))) := by let 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 ↦ by apply congrArg (a (meshTime T N j)) apply euler_depends_on_past T N γ u j z z' intro i hi have hiN : i < N+1 := hi.trans hj rw [coordinate_eq_apply hiN,coordinate_eq_apply hiN] apply heq simp [S,hi]) have heq : coordinate N j = fun z : Fin (N+1) → ℝ ↦ z ⟨j,hj⟩ := funext (coordinate_eq_apply hj) rw [heq] exact h
variable {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}
lemma gaussian_mean {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ) : ∫ ω, Z ω ∂μ = 0 := by rw [hZ.integral_eq, integral_id_gaussianReal]
lemma gaussian_memLp {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ) (p : ℝ≥0∞) (hp : p ≠ ∞) : MemLp Z p μ := by have H : MemLp (id : ℝ → ℝ) p (μ.map Z) := by rw [hZ.map_eq] exact memLp_id_gaussianReal' p hp simpa using (memLp_map_measure_iff H.aestronglyMeasurable hZ.aemeasurable).1 H
lemma gaussian_second_moment {Z : Ω → ℝ} (hZ : HasLaw Z (gaussianReal 0 1) μ) : ∫ ω, (Z ω)^2 ∂μ = 1 := by have hvar := hZ.variance_eq rw [variance_eq_integral hZ.aemeasurable, gaussian_mean hZ] at hvar simpa using hvar
noncomputable 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 μ := by exact 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 := by simp only [normalizedIncrement, mul_assoc] rw [integral_const_mul] have hi := hind.integral_mul_eq_mul_integral hH hZ.aemeasurable.aestronglyMeasurable change (∫ ω, H ω * Z ω ∂μ) = _ at hi rw [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 := by have 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 hi simp 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 μ := by apply (memLp_two_iff_integrable_sq ((hH.aestronglyMeasurable.const_mul _).mul hZ.aemeasurable.aestronglyMeasurable)).2 have hi := (hind.comp (measurable_id.pow_const 2) (measurable_id.pow_const 2)).integrable_mul hH.integrable_sq (gaussian_memLp hZ 2 (by norm_num)).integrable_sq have hj := hi.const_mul (predictableNormalizer H μ ^ 2) simpa only [normalizedIncrement, Pi.mul_apply, mul_pow, mul_assoc, Function.comp_def, id_eq] using hj
lemma 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 ω ∂μ := by have 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 hi simp 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 := by have hi := hind.integral_mul_eq_mul_integral (hH.mul hK) hZ.aemeasurable.aestronglyMeasurable change (∫ ω, (H ω * K ω) * Z ω ∂μ) = _ at hi calc _ = predictableNormalizer H μ * ∫ ω, (H ω * K ω) * Z ω ∂μ := by rw [← integral_const_mul] congr 1 ext ω 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 _)⟩).hasLaw
def 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))) := by have 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 H
lemma 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)) := by intro z z' h exact 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) := by intro z z' h dsimp only rw [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)) := by intro z z' h apply congrArg (a (meshTime T N j)) apply euler_depends_on_past intro i hi have hiN : i<N+1 := by omega rw [coordinate_eq_apply hiN, coordinate_eq_apply hiN] exact h ⟨i,hiN⟩ hi
lemma 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)))) := by intro z z' h have heq := hH.mono (Nat.le_succ j) z z' h have hz : coordinate N j z=coordinate N j z' := by rw [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 := by have hi : i<N+1 := hij.trans hj have 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 := by dsimp only have hm := hA.comp (measurable_euler T N γ u hU j (by omega)) have hind := euler_coefficient_independent (γ := γ) hj hU hA exact ⟨predictableNormalizer_pos hpos, normalizedIncrement_mean hm.aestronglyMeasurable (coordinate_hasLaw N j) hind, normalizedIncrement_second_moment hm.aestronglyMeasurable (coordinate_hasLaw N j) hind hpos⟩
end SKValue
open MeasureTheory ProbabilityTheory Filter Setopen scoped BigOperators Topology
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199import Mathlib
import OAI.Probability.SKValue.GroundState.AdaptiveColumns
import OAI.Probability.SKValue.GroundState.GramSchmidtLimit
import OAI.Probability.SKValue.GroundState.EmpiricalVectors
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set InnerProductSpace
open scoped Topology NNReal ENNReal BigOperators RealInnerProductSpace
namespace SKValueG
noncomputable 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 : ℝ) := by
rw [←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 : ℝ) := by
rw [←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 := by
obtain ⟨i,hi⟩ := exists_finiteMaximum f
apply 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) i
lemma scaled_linearProcess {ι κ : Type*} [Fintype κ] (a : ι → κ → ℝ) (c : ℝ)
(z : κ → ℝ) (i : ι) : linearProcess (fun i k ↦ c*a i k) z i=c*linearProcess a z i := by
simp 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 := by
have 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 := by
simp only [sq]
rw [quadraticCoeff_inner,real_inner_self_eq_norm_sq,spinVector_sqNorm]
ring
rw [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) := by
simp only [←mul_sub,mul_pow,Real.sq_sqrt (Nat.cast_nonneg n),Finset.mul_sum]
rw [hs,hamCoeff_distance hn]
field_simp
ring
theorem quadraticValue_spin {n : ℕ} (hn : 0<n) :
quadraticValue (spinVector n) (fun _ ↦ 0)=Real.sqrt (n : ℝ)*expectedMaximum n := by
have 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) := by
apply 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 quadraticValue
rw [he]
simp only [add_zero,scaled_linearProcess,finiteMaximum_mul_nonneg _ (Real.sqrt_nonneg _)]
rw [integral_const_mul]
rfl
theorem 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 := by
have hh := adaptive_spin_lower (spinVector n) v hv hu (Real.sqrt (n : ℝ))
(fun s ↦ (spinVector_norm n s).le) K s hs
rw [quadraticValue_spin hn] at hh
have hn' : (0 : ℝ)<n := by exact_mod_cast hn
have 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_eq
rw [groundStateSequence_eq]
field_simp
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Set InnerProductSpace
open scoped Topology NNReal ENNReal BigOperators RealInnerProductSpace
namespace SKValueG
lemma orthogonalRemainder_smul {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
(v : ℕ → E) (w : E) (j : ℕ) (c : ℝ) :
orthogonalRemainder v (c • w) j=c • orthogonalRemainder v w j := by
simp 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 := by
simp only [columnVector,columnResidual,real_inner_smul_right,smul_sub,smul_add,smul_smul]
module
lemma 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)) := by
rw [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 in
lemma 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 := by
induction 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_orthogonalRemainder
intro i hi
exact gramSchmidtNormed_pairwise_orthogonal _ (Ne.symm (Nat.ne_of_lt hi))
include ha in
lemma 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))⟫ := by
induction 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 1
unfold linearProcess
dsimp only
rw [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 in
lemma 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 := by
rw [predictableOffset_rows K n f ha x (spinVector n) K]
rw [Finset.sum_div]
apply Finset.sum_congr rfl
intro j hj
have 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).symm
have 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 :=
by
change (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).symm
rw [hw,hz,orthogonalRemainder_smul,columnVector_smul,real_inner_smul_left,real_inner_smul_right,
Real.sq_sqrt (Nat.cast_nonneg n)]
unfold empiricalColumnEnergy
have 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_simp
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.AdaptiveColumnsimport OAI.Probability.SKValue.GroundState.GramSchmidtLimitimport OAI.Probability.SKValue.GroundState.EmpiricalVectors
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueG
noncomputable 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 : ℝ) := by rw [←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 : ℝ) := by rw [←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 := by obtain ⟨i,hi⟩ := exists_finiteMaximum f apply 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) i
lemma scaled_linearProcess {ι κ : Type*} [Fintype κ] (a : ι → κ → ℝ) (c : ℝ) (z : κ → ℝ) (i : ι) : linearProcess (fun i k ↦ c*a i k) z i=c*linearProcess a z i := by simp 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 := by have 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 := by simp only [sq] rw [quadraticCoeff_inner,real_inner_self_eq_norm_sq,spinVector_sqNorm] ring rw [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) := by simp only [←mul_sub,mul_pow,Real.sq_sqrt (Nat.cast_nonneg n),Finset.mul_sum] rw [hs,hamCoeff_distance hn] field_simp ring
theorem quadraticValue_spin {n : ℕ} (hn : 0<n) : quadraticValue (spinVector n) (fun _ ↦ 0)=Real.sqrt (n : ℝ)*expectedMaximum n := by have 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) := by apply 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 quadraticValue rw [he] simp only [add_zero,scaled_linearProcess,finiteMaximum_mul_nonneg _ (Real.sqrt_nonneg _)] rw [integral_const_mul] rfl
theorem 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 := by have hh := adaptive_spin_lower (spinVector n) v hv hu (Real.sqrt (n : ℝ)) (fun s ↦ (spinVector_norm n s).le) K s hs rw [quadraticValue_spin hn] at hh have hn' : (0 : ℝ)<n := by exact_mod_cast hn have 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_eq rw [groundStateSequence_eq] field_simp
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Set InnerProductSpaceopen scoped Topology NNReal ENNReal BigOperators RealInnerProductSpacenamespace SKValueG
lemma orthogonalRemainder_smul {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (v : ℕ → E) (w : E) (j : ℕ) (c : ℝ) : orthogonalRemainder v (c • w) j=c • orthogonalRemainder v w j := by simp 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 := by simp only [columnVector,columnResidual,real_inner_smul_right,smul_sub,smul_add,smul_smul] module
lemma 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)) := by rw [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 := by induction 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_orthogonalRemainder intro i hi exact 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))⟫ := by induction 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 1 unfold linearProcess dsimp only rw [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 := by rw [predictableOffset_rows K n f ha x (spinVector n) K] rw [Finset.sum_div] apply Finset.sum_congr rfl intro j hj have 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).symm have 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 := by change (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).symm rw [hw,hz,orthogonalRemainder_smul,columnVector_smul,real_inner_smul_left,real_inner_smul_right, Real.sq_sqrt (Nat.cast_nonneg n)] unfold empiricalColumnEnergy have 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_simp
end SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155import Mathlib
import OAI.Probability.SKValue.GroundState.ColumnBounds
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set InnerProductSpace
open scoped Topology NNReal ENNReal BigOperators RealInnerProductSpace
namespace SKValueG
variable {Ω ι κ ν : 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 μ] in
lemma integrable_randomMaximum [IsProbabilityMeasure μ] {f : Ω → ι → ℝ}
(hf : ∀ i,Integrable (fun ω ↦ f ω i) μ) :
Integrable (fun ω ↦ finiteMaximum (f ω)) μ := by
apply (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 ι] in
lemma 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 ν)) := by
unfold linearProcess
apply integrable_finsetSum
intro 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)).aestronglyMeasurable
exact Eventually.of_forall (fun p ↦ by
change |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 ω)) := by
have hm : Measurable (fun p : Ω×((κ×κ) → ℝ) ↦
finiteMaximum (fun i ↦ linearProcess (fun i ↦ quadraticCoeff (w p.1 i)) p.2 i+d p.1 i)) := by
apply measurable_finiteMaximum
intro i
unfold linearProcess quadraticCoeff
fun_prop
exact hm.stronglyMeasurable.integral_prod_right.measurable
lemma 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 ω)) μ := by
have hi : Integrable (fun p : Ω×((κ×κ) → ℝ) ↦
finiteMaximum (fun i ↦ linearProcess (fun i ↦ quadraticCoeff (w p.1 i)) p.2 i+d p.1 i))
(μ.prod (gaussianProduct (κ×κ))) := by
apply integrable_randomMaximum
intro i
apply 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 k
exact (quadraticCoeff_coord_bound _ _).trans (sq_le_sq₀ (norm_nonneg _) (le_trans (norm_nonneg _) (hR ω i)) |>.mpr (hR ω i))
exact hi.integral_prod_left
lemma 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 κ) := by
have 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 κ)) := by
apply ((hd i).comp_fst _).add
apply random_linear_integrable (fun ω i k ↦ columnVector (v ω) (w ω i) k) _ (R^2) _ i
· intro i k
exact (PiLp.continuous_apply 2 (fun _ : κ ↦ ℝ) k).measurable.comp (measurable_columnVector hv (hw i))
· intro ω i k
exact (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_ae
exact Eventually.of_forall (fun ω ↦ quadraticValue_column (w ω) (d ω) (v ω) (hu ω))
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Set InnerProductSpace
open scoped Topology NNReal ENNReal BigOperators RealInnerProductSpace
namespace SKValueG
variable (κ : Type*) [Fintype κ]
abbrev ColumnHistory (j : ℕ) := Fin j → κ → ℝ
noncomputable def columnHistoryLaw (j : ℕ) : Measure (ColumnHistory κ j) :=
Measure.pi (fun _ ↦ gaussianProduct κ)
instance (j : ℕ) : IsProbabilityMeasure (columnHistoryLaw κ j) := by
unfold columnHistoryLaw; infer_instance
def historyInit {j : ℕ} (h : ColumnHistory κ (j+1)) : ColumnHistory κ j := fun i ↦ h i.castSucc
def historySplit (j : ℕ) : ColumnHistory κ (j+1) ≃ᵐ ColumnHistory κ j × (κ → ℝ) :=
(MeasurableEquiv.piFinSuccAbove (fun _ : Fin (j+1) ↦ κ → ℝ) (Fin.last j)).trans
MeasurableEquiv.prodComm
omit [Fintype κ] in
lemma historySplit_apply [Fintype κ] (j : ℕ) (h : ColumnHistory κ (j+1)) :
historySplit κ j h=(historyInit κ h,h (Fin.last j)) := by
simp [historySplit,MeasurableEquiv.piFinSuccAbove,Fin.insertNthEquiv]
rfl
lemma historySplit_preserving (j : ℕ) :
MeasurePreserving (historySplit κ j) (columnHistoryLaw κ (j+1))
((columnHistoryLaw κ j).prod (gaussianProduct κ)) := by
exact (Measure.measurePreserving_swap).comp
(measurePreserving_piFinSuccAbove (fun _ : Fin (j+1) ↦ gaussianProduct κ) (Fin.last j))
omit [Fintype κ] in
lemma historyInit_measurable [Fintype κ] (j : ℕ) : Measurable (historyInit κ (j:=j)) := by
unfold historyInit; fun_prop
lemma 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 κ) := by
simpa only [historySplit_apply] using (historySplit_preserving κ j).integral_comp' f
lemma 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)) := by
simpa only [Function.comp_def,historySplit_apply] using (historySplit_preserving κ j).integrable_comp
hf.aestronglyMeasurable |>.mpr hf
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.ColumnBounds
namespace OAI
section
open 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 ω)) μ := by apply (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 ν)) := by unfold linearProcess apply integrable_finsetSum intro 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)).aestronglyMeasurable exact Eventually.of_forall (fun p ↦ by change |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 ω)) := by have hm : Measurable (fun p : Ω×((κ×κ) → ℝ) ↦ finiteMaximum (fun i ↦ linearProcess (fun i ↦ quadraticCoeff (w p.1 i)) p.2 i+d p.1 i)) := by apply measurable_finiteMaximum intro i unfold linearProcess quadraticCoeff fun_prop exact hm.stronglyMeasurable.integral_prod_right.measurable
lemma 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 ω)) μ := by have hi : Integrable (fun p : Ω×((κ×κ) → ℝ) ↦ finiteMaximum (fun i ↦ linearProcess (fun i ↦ quadraticCoeff (w p.1 i)) p.2 i+d p.1 i)) (μ.prod (gaussianProduct (κ×κ))) := by apply integrable_randomMaximum intro i apply 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 k exact (quadraticCoeff_coord_bound _ _).trans (sq_le_sq₀ (norm_nonneg _) (le_trans (norm_nonneg _) (hR ω i)) |>.mpr (hR ω i)) exact hi.integral_prod_left
lemma 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 κ) := by have 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 κ)) := by apply ((hd i).comp_fst _).add apply random_linear_integrable (fun ω i k ↦ columnVector (v ω) (w ω i) k) _ (R^2) _ i · intro i k exact (PiLp.continuous_apply 2 (fun _ : κ ↦ ℝ) k).measurable.comp (measurable_columnVector hv (hw i)) · intro ω i k exact (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_ae exact Eventually.of_forall (fun ω ↦ quadraticValue_column (w ω) (d ω) (v ω) (hu ω))
end SKValueG
end
section
open 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) := by unfold columnHistoryLaw; infer_instance
def historyInit {j : ℕ} (h : ColumnHistory κ (j+1)) : ColumnHistory κ j := fun i ↦ h i.castSucc
def historySplit (j : ℕ) : ColumnHistory κ (j+1) ≃ᵐ ColumnHistory κ j × (κ → ℝ) := (MeasurableEquiv.piFinSuccAbove (fun _ : Fin (j+1) ↦ κ → ℝ) (Fin.last j)).trans MeasurableEquiv.prodComm
omit [Fintype κ] inlemma historySplit_apply [Fintype κ] (j : ℕ) (h : ColumnHistory κ (j+1)) : historySplit κ j h=(historyInit κ h,h (Fin.last j)) := by simp [historySplit,MeasurableEquiv.piFinSuccAbove,Fin.insertNthEquiv] rfl
lemma historySplit_preserving (j : ℕ) : MeasurePreserving (historySplit κ j) (columnHistoryLaw κ (j+1)) ((columnHistoryLaw κ j).prod (gaussianProduct κ)) := by exact (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)) := by unfold historyInit; fun_prop
lemma 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 κ) := by simpa only [historySplit_apply] using (historySplit_preserving κ j).integral_comp' f
lemma 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)) := by simpa only [Function.comp_def,historySplit_apply] using (historySplit_preserving κ j).integrable_comp hf.aestronglyMeasurable |>.mpr hf
end SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178import Mathlib
import OAI.Probability.SKValue.GroundState.FieldTreeLaw
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
lemma 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)).symm
lemma 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)) := by
have 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 hs
have hp := (measurePreserving_arrowProdEquivProdArrow (Fin n → ℝ) ℝ (TreeEdges T)
(fun _ ↦ gaussianProduct (Fin n)) (fun _ ↦ gumbelLaw)).symm
exact 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))) := by
exact (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))) := by
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).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 := by
rw [←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_id
exact he
lemma 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) := by
rw [←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.aestronglyMeasurable
theorem 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) := by
let c : ℝ → TreeLevel → ℝ := fun q l ↦ Real.sqrt ((n : ℝ)/2)*Real.sqrt (l.endpoint^2-q^2)
have hiA := scalarTreeValue_integrable_prod c 0 T
have 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) := by
intro g
simpa only [scalarTreeValue,fieldTreeValue,zero_add,treeAuxVector,c] using
finite_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 hg
simp only [Pi.add_apply] at hu
rw [integral_add (integrable_const _) hiA.integral_prod_right,integral_const,probReal_univ,one_smul,
scalarTreeValue_mean,fieldTreeValue_mean] at hu
exact hu
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
lemma 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| := by
have 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 := rfl
rw [e] at hiX hiY hpX hpY
have 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) := by
rw [←integral_const_mul]
apply integral_mono hiX (hiY.const_mul _)
intro z
have 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 hl
rw [show x+Real.sqrt h*z-(y+Real.sqrt h*z)=x-y by ring] at hl
dsimp only
rw [←Real.exp_add]
apply Real.exp_le_exp.mpr
have hh := le_abs_self (ψ (x+Real.sqrt h*z)-ψ (y+Real.sqrt h*z))
nlinarith
have hh := Real.log_le_log hpX hbound
rw [Real.log_mul (Real.exp_pos _).ne' hpY.ne',Real.log_exp] at hh
simp only [SKValue.coleHopf,ite_eq_right hm.ne',SKValue.heat,e]
apply (div_le_iff₀ hm).mpr
have 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; ring
rw [he]
exact hh
lemma coleHopf_lipschitz {ψ : ℝ → ℝ} (hψ : LipschitzWith 1 ψ) {m : ℝ} (hm : 0 < m)
(h : ℝ) : LipschitzWith 1 (SKValue.coleHopf m h ψ) := by
apply LipschitzWith.of_dist_le_mul
intro x y
simp only [NNReal.coe_one,one_mul,Real.dist_eq]
have hxy := coleHopf_one_sided hψ hm h x y
have hyx := coleHopf_one_sided hψ hm h y x
rw [abs_sub_comm y x] at hyx
exact 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 T
lemma fieldProfile_lipschitz {T : GaussianTree} {a : ℝ} (h : TreeScale a T) (q : ℝ) :
LipschitzWith 1 (fieldProfile q T) := by
induction T generalizing a q with
| nil =>
apply LipschitzWith.of_dist_le_mul
intro x y
simpa 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⟩ := h
exact 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)) := by
have hi := Integrable.fintype_prod (fun i : Fin n ↦ SKValue.lipschitz_exp_integrable hψ hm (x i) s)
convert hi using 1
· funext z
simp only [Finset.mul_sum,Real.exp_sum]
· rfl
lemma 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)) := by
simp 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 rfl
intro 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))]
rfl
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.FieldTreeLaw
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
lemma 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)).symm
lemma 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)) := by have 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 hs have hp := (measurePreserving_arrowProdEquivProdArrow (Fin n → ℝ) ℝ (TreeEdges T) (fun _ ↦ gaussianProduct (Fin n)) (fun _ ↦ gumbelLaw)).symm exact 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))) := by exact (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))) := by 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).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 := by rw [←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_id exact he
lemma 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) := by rw [←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.aestronglyMeasurable
theorem 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) := by let c : ℝ → TreeLevel → ℝ := fun q l ↦ Real.sqrt ((n : ℝ)/2)*Real.sqrt (l.endpoint^2-q^2) have hiA := scalarTreeValue_integrable_prod c 0 T have 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) := by intro g simpa only [scalarTreeValue,fieldTreeValue,zero_add,treeAuxVector,c] using finite_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 hg simp only [Pi.add_apply] at hu rw [integral_add (integrable_const _) hiA.integral_prod_right,integral_const,probReal_univ,one_smul, scalarTreeValue_mean,fieldTreeValue_mean] at hu exact hu
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
lemma 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| := by have 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 := rfl rw [e] at hiX hiY hpX hpY have 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) := by rw [←integral_const_mul] apply integral_mono hiX (hiY.const_mul _) intro z have 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 hl rw [show x+Real.sqrt h*z-(y+Real.sqrt h*z)=x-y by ring] at hl dsimp only rw [←Real.exp_add] apply Real.exp_le_exp.mpr have hh := le_abs_self (ψ (x+Real.sqrt h*z)-ψ (y+Real.sqrt h*z)) nlinarith have hh := Real.log_le_log hpX hbound rw [Real.log_mul (Real.exp_pos _).ne' hpY.ne',Real.log_exp] at hh simp only [SKValue.coleHopf,ite_eq_right hm.ne',SKValue.heat,e] apply (div_le_iff₀ hm).mpr have 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; ring rw [he] exact hh
lemma coleHopf_lipschitz {ψ : ℝ → ℝ} (hψ : LipschitzWith 1 ψ) {m : ℝ} (hm : 0 < m) (h : ℝ) : LipschitzWith 1 (SKValue.coleHopf m h ψ) := by apply LipschitzWith.of_dist_le_mul intro x y simp only [NNReal.coe_one,one_mul,Real.dist_eq] have hxy := coleHopf_one_sided hψ hm h x y have hyx := coleHopf_one_sided hψ hm h y x rw [abs_sub_comm y x] at hyx exact 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 T
lemma fieldProfile_lipschitz {T : GaussianTree} {a : ℝ} (h : TreeScale a T) (q : ℝ) : LipschitzWith 1 (fieldProfile q T) := by induction T generalizing a q with | nil => apply LipschitzWith.of_dist_le_mul intro x y simpa 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⟩ := h exact 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)) := by have hi := Integrable.fintype_prod (fun i : Fin n ↦ SKValue.lipschitz_exp_integrable hψ hm (x i) s) convert hi using 1 · funext z simp only [Finset.mul_sum,Real.exp_sum] · rfl
lemma 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)) := by simp 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 rfl intro 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))] rfl
end SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396import Mathlib
import OAI.Probability.SKValue.GroundState.StandardGaussian
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
lemma 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) := by
have 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)) := by
intro i
apply gibbsWeight_mul_integrable
exact (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_nonneg
intro z
change (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_nonneg
intro i _
apply Finset.sum_nonneg
intro 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) := by
rw [← Finset.sum_add_distrib,← Finset.sum_sub_distrib,← Finset.sum_sub_distrib]
apply Finset.sum_congr rfl; intro k _; ring
rw [he]
exact h i j
noncomputable def rotatedCoefficients {ι κ : Type*} (a b : ι → κ → ℝ) (t : ℝ) (i : ι) (k : κ) : ℝ :=
Real.cos t*a i k + Real.sin t*b i k
noncomputable def rotationVelocity {ι κ : Type*} (a b : ι → κ → ℝ) (t : ℝ) (i : ι) (k : κ) : ℝ :=
-Real.sin t*a i k + Real.cos t*b i k
lemma 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 := by
exact 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| := by
calc
_ ≤ |-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 ring
lemma 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| := by
apply abs_gibbsMean_le
intro i
calc
_ ≤ ∑ k, |rotationVelocity a b t i k*z k| := Finset.abs_sum_le_sum_abs _ _
_ ≤ ∑ k, (|a i k|+|b i k|)*|z k| := by
apply Finset.sum_le_sum
intro 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 := by
have 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) := by
apply continuous_finsetSum
intro i _
apply (continuous_linear_gibbsWeight _ _).mul
exact (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)))).2
lemma 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) := by
simp only [rotationVelocity,rotatedCoefficients,← Finset.sum_sub_distrib,Finset.mul_sum,← Finset.sum_add_distrib]
apply Finset.sum_congr rfl
intro k _
ring
lemma 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) := by
let 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 b
have hc : Continuous F := continuous_iff_continuousAt.mpr (fun t ↦ (hd t).continuousAt)
have hm : MonotoneOn F (Icc (0 : ℝ) (Real.pi/2)) := by
apply monotoneOn_of_deriv_nonneg (convex_Icc _ _) hc.continuousOn
(fun t _ ↦ (hd t).differentiableAt.differentiableWithinAt)
intro t ht
have ht' : t ∈ Icc (0 : ℝ) (Real.pi/2) := interior_subset ht
rw [(hd t).deriv]
apply gaussian_gibbs_derivative_nonneg
intro i j
rw [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 positivity
have 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 hh
noncomputable 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 ι) := by
have he (x : ι → ℝ) : finiteMaximum x = Finset.univ.sup' Finset.univ_nonempty x := by
rw [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| := by
obtain ⟨i,hi⟩ := exists_finiteMaximum x
rw [← 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 κ) := by
apply (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) := by
obtain ⟨i,hi⟩ := exists_finiteMaximum x
rw [← hi]
exact le_logPartition (fun i ↦ β*x i) i
lemma logPartition_le_scaled_max {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ)
{β : ℝ} (hβ : 0 ≤ β) : logPartition (fun i ↦ β*x i) ≤ β*finiteMaximum x+Real.log (Fintype.card ι) := by
exact (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 := by
funext i
simp 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) := by
have hb (β : ℝ) (hβ : 0 ≤ β) :
β*(∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n)) ≤
β*(∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct (Fin n)) + Real.log (Fintype.card ι) := by
have 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 ↦ by
calc
(∑ 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)) := by
rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro k _; ring
_ = 0 := by rw [horth,mul_zero])
(fun i j ↦ by
have he (c : ι → Fin n → ℝ) : (∑ k, (β*c i k-β*c j k)^2) = β^2*∑ k, (c i k-c j k)^2 := by
rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro k _; ring
rw [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) := by
apply integral_mono ((finiteMaximum_integrable a).const_mul _) hiA
intro z
change β*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) := by
apply integral_mono hiB (((finiteMaximum_integrable b).const_mul _).add (integrable_const _))
intro z
change 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]; simp
by_contra hh
have 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β.le
have he : β*Δ = |Real.log (Fintype.card ι)|+1 := div_mul_cancel₀ _ hΔ.ne'
have hlog := le_abs_self (Real.log (Fintype.card ι))
dsimp [Δ] at he
nlinarith
lemma gaussian_integral_reindex {κ ν : Type*} [Fintype κ] [Fintype ν] (e : κ ≃ ν)
(f : (κ → ℝ) → ℝ) :
(∫ z : ν → ℝ, f (fun k ↦ z (e k)) ∂gaussianProduct ν) = ∫ z, f z ∂gaussianProduct κ := by
have he := measurePreserving_piCongrLeft (α := fun _ : κ ↦ ℝ)
(fun _ : κ ↦ standardGaussian) e.symm
have hf (z : ν → ℝ) : (MeasurableEquiv.piCongrLeft (π := fun _ : κ ↦ ℝ) e.symm) z = fun k ↦ z (e k) := by
funext k
simp [MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft_apply]
simpa only [gaussianProduct,hf] using he.integral_comp' f
lemma 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 := by
funext i
simpa 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 κ := by
simpa 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 κ := by
let 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 ↦ by
rw [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 ↦ by
rw [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 hh
noncomputable 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 κ := by
have 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 := by
funext i
simp [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 ν := by
have 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 := by
funext i
simp [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 ν := by
have 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 h
noncomputable def spin (b : Bool) : ℝ := if b then 1 else -1
noncomputable 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 0
noncomputable def groundStateSequence (n : ℕ) : ℝ :=
(n : ℝ)⁻¹ * ∫ J, sSup (range (hamiltonian n J)) ∂gaussianProduct (Fin n × Fin n)
noncomputable def groundStateValue : ℝ := limUnder atTop groundStateSequence
noncomputable 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 0
noncomputable 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 := by
funext σ
simp only [linearProcess,hamCoeff,hamiltonian,Fintype.sum_prod_type,Finset.mul_sum]
apply Finset.sum_congr rfl
intro i _
apply Finset.sum_congr rfl
intro j _
split_ifs <;> ring
lemma groundStateSequence_eq (n : ℕ) : groundStateSequence n = (n : ℝ)⁻¹ * expectedMaximum n := by
simp 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 := by
have hs : (∑ i, ∑ j, if j < i then f i j else 0) = ∑ i, ∑ j, if i < j then f i j else 0 := by
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro i _
apply Finset.sum_congr rfl
intro 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) := by
rcases 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]
ring
lemma 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)) := by
have 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]; ring
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.StandardGaussian
namespace OAI
sectionopen MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
lemma 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) := by have 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)) := by intro i apply gibbsWeight_mul_integrable exact (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_nonneg intro z change (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_nonneg intro i _ apply Finset.sum_nonneg intro 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) := by rw [← Finset.sum_add_distrib,← Finset.sum_sub_distrib,← Finset.sum_sub_distrib] apply Finset.sum_congr rfl; intro k _; ring rw [he] exact h i j
noncomputable def rotatedCoefficients {ι κ : Type*} (a b : ι → κ → ℝ) (t : ℝ) (i : ι) (k : κ) : ℝ := Real.cos t*a i k + Real.sin t*b i k
noncomputable def rotationVelocity {ι κ : Type*} (a b : ι → κ → ℝ) (t : ℝ) (i : ι) (k : κ) : ℝ := -Real.sin t*a i k + Real.cos t*b i k
lemma 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 := by exact 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| := by calc _ ≤ |-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 ring
lemma 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| := by apply abs_gibbsMean_le intro i calc _ ≤ ∑ k, |rotationVelocity a b t i k*z k| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ k, (|a i k|+|b i k|)*|z k| := by apply Finset.sum_le_sum intro 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 := by have 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) := by apply continuous_finsetSum intro i _ apply (continuous_linear_gibbsWeight _ _).mul exact (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)))).2
lemma 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) := by simp only [rotationVelocity,rotatedCoefficients,← Finset.sum_sub_distrib,Finset.mul_sum,← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro k _ ring
lemma 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) := by let 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 b have hc : Continuous F := continuous_iff_continuousAt.mpr (fun t ↦ (hd t).continuousAt) have hm : MonotoneOn F (Icc (0 : ℝ) (Real.pi/2)) := by apply monotoneOn_of_deriv_nonneg (convex_Icc _ _) hc.continuousOn (fun t _ ↦ (hd t).differentiableAt.differentiableWithinAt) intro t ht have ht' : t ∈ Icc (0 : ℝ) (Real.pi/2) := interior_subset ht rw [(hd t).deriv] apply gaussian_gibbs_derivative_nonneg intro i j rw [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 positivity have 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 hh
noncomputable 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 ι) := by have he (x : ι → ℝ) : finiteMaximum x = Finset.univ.sup' Finset.univ_nonempty x := by rw [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| := by obtain ⟨i,hi⟩ := exists_finiteMaximum x rw [← 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 κ) := by apply (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) := by obtain ⟨i,hi⟩ := exists_finiteMaximum x rw [← hi] exact le_logPartition (fun i ↦ β*x i) i
lemma logPartition_le_scaled_max {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) {β : ℝ} (hβ : 0 ≤ β) : logPartition (fun i ↦ β*x i) ≤ β*finiteMaximum x+Real.log (Fintype.card ι) := by exact (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 := by funext i simp 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) := by have hb (β : ℝ) (hβ : 0 ≤ β) : β*(∫ z, finiteMaximum (linearProcess a z) ∂gaussianProduct (Fin n)) ≤ β*(∫ z, finiteMaximum (linearProcess b z) ∂gaussianProduct (Fin n)) + Real.log (Fintype.card ι) := by have 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 ↦ by calc (∑ 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)) := by rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro k _; ring _ = 0 := by rw [horth,mul_zero]) (fun i j ↦ by have he (c : ι → Fin n → ℝ) : (∑ k, (β*c i k-β*c j k)^2) = β^2*∑ k, (c i k-c j k)^2 := by rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro k _; ring rw [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) := by apply integral_mono ((finiteMaximum_integrable a).const_mul _) hiA intro z change β*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) := by apply integral_mono hiB (((finiteMaximum_integrable b).const_mul _).add (integrable_const _)) intro z change 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]; simp by_contra hh have 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β.le have he : β*Δ = |Real.log (Fintype.card ι)|+1 := div_mul_cancel₀ _ hΔ.ne' have hlog := le_abs_self (Real.log (Fintype.card ι)) dsimp [Δ] at he nlinarith
lemma gaussian_integral_reindex {κ ν : Type*} [Fintype κ] [Fintype ν] (e : κ ≃ ν) (f : (κ → ℝ) → ℝ) : (∫ z : ν → ℝ, f (fun k ↦ z (e k)) ∂gaussianProduct ν) = ∫ z, f z ∂gaussianProduct κ := by have he := measurePreserving_piCongrLeft (α := fun _ : κ ↦ ℝ) (fun _ : κ ↦ standardGaussian) e.symm have hf (z : ν → ℝ) : (MeasurableEquiv.piCongrLeft (π := fun _ : κ ↦ ℝ) e.symm) z = fun k ↦ z (e k) := by funext k simp [MeasurableEquiv.coe_piCongrLeft, Equiv.piCongrLeft_apply] simpa only [gaussianProduct,hf] using he.integral_comp' f
lemma 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 := by funext i simpa 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 κ := by simpa 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 κ := by let 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 ↦ by rw [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 ↦ by rw [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 hh
noncomputable 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 κ := by have 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 := by funext i simp [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 ν := by have 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 := by funext i simp [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 ν := by have 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 h
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 groundStateSequence
noncomputable 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 := by funext σ simp only [linearProcess,hamCoeff,hamiltonian,Fintype.sum_prod_type,Finset.mul_sum] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ split_ifs <;> ring
lemma groundStateSequence_eq (n : ℕ) : groundStateSequence n = (n : ℝ)⁻¹ * expectedMaximum n := by simp 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 := by have hs : (∑ i, ∑ j, if j < i then f i j else 0) = ∑ i, ∑ j, if i < j then f i j else 0 := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro 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) := by rcases 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] ring
lemma 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)) := by have 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]; ring
end SKValueGend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126import Mathlib
import OAI.Probability.SKValue.GroundState.ConstantFatou
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValue
noncomputable def boolSign (x : ℝ) : Bool := if 0≤x then true else false
lemma measurable_boolSign : Measurable boolSign :=
Measurable.ite measurableSet_Ici measurable_const measurable_const
lemma spin_boolSign_eq {x : ℝ} (hx : x≠0) : SKValueG.spin (boolSign x)=Real.sign x := by
rcases 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 := by
have 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 hz
intro h
apply hz
linarith
lemma 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 := by
have hLaw : HasLaw U (μ.map U) μ := ⟨hU.aemeasurable,rfl⟩
have hJoint := hind.hasLaw_prod hLaw hZ
have 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 1
apply (hJoint.ae_iff (measurableSet_setOfPred.mp ((measurableSet_eq_fun hm measurable_const).compl))).mpr
apply (Measure.ae_prod_iff_ae_ae ((measurableSet_eq_fun hm measurable_const).compl)).mpr
exact Eventually.of_forall gaussian_rounding_nonzero
lemma 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)) := by
have := 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 SKValue
end
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValue
theorem 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 := by
let f := fun j : ℕ ↦ if hj : j<N then
normalizedIncrement (H ⟨j,hj⟩) (coordinate N j) (gaussianProduct (Fin (N+1))) else fun _ ↦ 0
let F := fun z ↦ boolSign (U z+2*cdf standardGaussian (coordinate N N z)-1)
have hfm (j : ℕ) : Measurable (f j) := by
dsimp only [f]
split_ifs with hj
· exact measurable_normalizedIncrement (hm ⟨j,hj⟩)
· exact measurable_const
have 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 := by
dsimp only [f]
split_ifs with hl
· apply normalizedIncrement_dependsBefore (by omega) (hp ⟨l,hl⟩)
intro i hi
change i.val<l+1 at hi
exact he i (by omega)
· rfl
have hfL (j : ℕ) (hj : j<N) : MemLp (f j) 2 (SKValueG.gaussianProduct (Fin (N+1))) := by
simp 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 := by
simp 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 := by
have hi : i<N := hij.trans hj
simp 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 hUp
have hb := SKValueG.predictable_coefficients_le_groundState N f F hfm hfa hfL hfu hfo hFm
change _≤SKValueG.groundStateValue
convert hb using 1
apply Finset.sum_congr rfl
intro j hj
congr 1
· apply integral_congr_ae
filter_upwards [he] with z hz
simp only [f,dite_eq_left j.isLt,hz]
exact mul_comm _ _
· apply integral_congr_ae
filter_upwards [he] with z hz
rw [hz,coordinate_eq_apply (by omega)]
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.ConstantFatou
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValue
noncomputable def boolSign (x : ℝ) : Bool := if 0≤x then true else false
lemma measurable_boolSign : Measurable boolSign := Measurable.ite measurableSet_Ici measurable_const measurable_const
lemma spin_boolSign_eq {x : ℝ} (hx : x≠0) : SKValueG.spin (boolSign x)=Real.sign x := by rcases 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 := by have 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 hz intro h apply hz linarith
lemma 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 := by have hLaw : HasLaw U (μ.map U) μ := ⟨hU.aemeasurable,rfl⟩ have hJoint := hind.hasLaw_prod hLaw hZ have 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 1 apply (hJoint.ae_iff (measurableSet_setOfPred.mp ((measurableSet_eq_fun hm measurable_const).compl))).mpr apply (Measure.ae_prod_iff_ae_ae ((measurableSet_eq_fun hm measurable_const).compl)).mpr exact Eventually.of_forall gaussian_rounding_nonzero
lemma 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)) := by have := 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 SKValue
end
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValue
theorem 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 := by let f := fun j : ℕ ↦ if hj : j<N then normalizedIncrement (H ⟨j,hj⟩) (coordinate N j) (gaussianProduct (Fin (N+1))) else fun _ ↦ 0 let F := fun z ↦ boolSign (U z+2*cdf standardGaussian (coordinate N N z)-1) have hfm (j : ℕ) : Measurable (f j) := by dsimp only [f] split_ifs with hj · exact measurable_normalizedIncrement (hm ⟨j,hj⟩) · exact measurable_const have 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 := by dsimp only [f] split_ifs with hl · apply normalizedIncrement_dependsBefore (by omega) (hp ⟨l,hl⟩) intro i hi change i.val<l+1 at hi exact he i (by omega) · rfl have hfL (j : ℕ) (hj : j<N) : MemLp (f j) 2 (SKValueG.gaussianProduct (Fin (N+1))) := by simp 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 := by simp 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 := by have hi : i<N := hij.trans hj simp 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 hUp have hb := SKValueG.predictable_coefficients_le_groundState N f F hfm hfa hfL hfu hfo hFm change _≤SKValueG.groundStateValue convert hb using 1 apply Finset.sum_congr rfl intro j hj congr 1 · apply integral_congr_ae filter_upwards [he] with z hz simp only [f,dite_eq_left j.isLt,hz] exact mul_comm _ _ · apply integral_congr_ae filter_upwards [he] with z hz rw [hz,coordinate_eq_apply (by omega)]
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384import Mathlib
import OAI.Probability.SKValue.Evolution.BoundedSmooth
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
noncomputable def standardGaussian : Measure ℝ := gaussianReal 0 1
noncomputable def gaussianProduct (ι : Type*) [Fintype ι] : Measure (ι → ℝ) :=
Measure.pi (fun _ : ι ↦ standardGaussian)
instance : IsProbabilityMeasure standardGaussian := by unfold standardGaussian; infer_instance
instance {ι : Type*} [Fintype ι] : IsProbabilityMeasure (gaussianProduct ι) := by
unfold gaussianProduct; infer_instance
lemma density_hasDerivAt (x : ℝ) :
HasDerivAt (gaussianPDFReal 0 1) (-x*gaussianPDFReal 0 1 x) x := by
have h1 : HasDerivAt (fun y : ℝ ↦ -y^2/2) (-x) x := by
have 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 hh
have hd := h1.exp.const_mul ((Real.sqrt (2*Real.pi))⁻¹)
convert hd using 1 <;> try rfl
· funext y
simp only [gaussianPDFReal,NNReal.coe_one,mul_one,sub_zero]
· simp only [gaussianPDFReal,NNReal.coe_one,mul_one,sub_zero]
ring
lemma density_mul_integrable {f : ℝ → ℝ} (hf : Integrable f standardGaussian) :
Integrable (fun x ↦ gaussianPDFReal 0 1 x*f x) := by
rw [standardGaussian,gaussianReal_of_var_ne_zero _ (by norm_num)] at hf
have hh := (integrable_withDensity_iff_integrable_smul'
(measurable_gaussianPDF 0 1) (Eventually.of_forall (fun x ↦ gaussianPDF_lt_top (μ := 0) (v := 1) (x := x)))).mp hf
simpa only [toReal_gaussianPDF,smul_eq_mul] using hh
lemma standardGaussian_integrable_id : Integrable (fun x : ℝ ↦ x) standardGaussian := by
have 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 := by
have 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)) := by
convert (density_mul_integrable hxfi).neg using 1
ext x
simp only [Pi.neg_apply]
ring
have hi2 : Integrable (fun x ↦ f' x*gaussianPDFReal 0 1 x) := by
simpa only [mul_comm] using density_mul_integrable hf'i
have hi3 : Integrable (fun x ↦ f x*gaussianPDFReal 0 1 x) := by
simpa only [mul_comm] using density_mul_integrable hfi
have 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 hi3
have hb : (∫ x, f x*(-x*gaussianPDFReal 0 1 x)) =
-(∫ x, gaussianPDFReal 0 1 x*(x*f x)) := by
rw [← integral_neg]
apply integral_congr_ae
exact Eventually.of_forall (fun x ↦ by ring)
rw [hb] at hibp
have he : (∫ x, gaussianPDFReal 0 1 x*(x*f x)) =
∫ x, gaussianPDFReal 0 1 x*f' x := by
exact 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 he
lemma gaussian_coordinate_integrable {ι : Type*} [Fintype ι] (i : ι) :
Integrable (fun z : ι → ℝ ↦ z i) (gaussianProduct ι) := by
exact ((measurePreserving_eval (fun _ : ι ↦ standardGaussian) i).integrable_comp
standardGaussian_integrable_id.aestronglyMeasurable).mpr standardGaussian_integrable_id
lemma 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) := by
cases n with
| zero => exact Fin.elim0 i
| succ n =>
let e := MeasurableEquiv.piFinSuccAbove (fun _ : Fin (n+1) ↦ ℝ) i
have he : MeasurePreserving e.symm (standardGaussian.prod (gaussianProduct (Fin n)))
(gaussianProduct (Fin (n+1))) :=
(measurePreserving_piFinSuccAbove (fun _ : Fin (n+1) ↦ standardGaussian) i).symm
have 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 hi
have 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_ae
apply Eventually.of_forall
intro y
simp 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) ∂standardGaussian
have hmeas : Measurable (fun x : ℝ ↦ i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y) := by
exact 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 x
simpa 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 x
noncomputable def logPartition {ι : Type*} [Fintype ι] (x : ι → ℝ) : ℝ :=
Real.log (partition x)
lemma partition_pos {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) : 0 < partition x := by
exact Finset.sum_pos (fun i _ ↦ Real.exp_pos _) Finset.univ_nonempty
lemma 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 := by
simp only [gibbsWeight,← Finset.sum_div]
change partition x / partition x = 1
exact div_self (ne_of_gt (partition_pos x))
lemma gibbsWeight_le_one {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (i : ι) :
gibbsWeight x i ≤ 1 := by
calc
_ ≤ ∑ j, gibbsWeight x j := Finset.single_le_sum (fun j _ ↦ gibbsWeight_nonneg x j) (Finset.mem_univ i)
_ = 1 := sum_gibbsWeight x
lemma continuous_partition {ι : Type*} [Fintype ι] : Continuous (@partition ι _) := by
unfold partition
fun_prop
lemma continuous_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι] (i : ι) :
Continuous (fun x : ι → ℝ ↦ gibbsWeight x i) := by
exact (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 := by
simpa 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 := by
convert (hasDerivAt_partition h).log (ne_of_gt (partition_pos _)) using 1 <;> try rfl
simp only [gibbsWeight,Finset.sum_div,mul_div_assoc]
apply Finset.sum_congr rfl
intro i _
ring
lemma 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 := by
convert (h i).exp.div (hasDerivAt_partition h) (ne_of_gt (partition_pos _)) using 1 <;> try rfl
simp 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) by
rw [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 := by
calc
_ ≤ ∑ 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 k
lemma continuous_linearProcess {ι κ : Type*} [Fintype κ] (c : ι → κ → ℝ) :
Continuous (linearProcess c) := by
unfold linearProcess
fun_prop
lemma 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) := by
have 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) := by
intro j
by_cases hj : j=k
· subst j
simpa 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 κ) := by
apply Integrable.of_bound (continuous_linear_gibbsWeight c i).aestronglyMeasurable 1
exact 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 κ) := by
apply (gaussian_coordinate_integrable k).mul_bdd (continuous_linear_gibbsWeight c i).aestronglyMeasurable
exact 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) := by
apply 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.sub
exact continuous_finsetSum _ (fun j _ ↦ (continuous_linear_gibbsWeight c j).mul continuous_const)
· intro z
simpa only [Function.update_eq_self] using
hasDerivAt_gibbsWeight (fun j ↦ hasDerivAt_linearProcess_update c z j k) i
· intro z
rw [abs_of_nonneg (gibbsWeight_nonneg _ _)]
exact gibbsWeight_le_one _ _
· intro z
have 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| := by
rw [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 ring
lemma le_logPartition {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (i : ι) :
x i ≤ logPartition x := by
apply (Real.le_log_iff_exp_le (partition_pos x)).mpr
exact 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 := by
have hc : (0 : ℝ) < Fintype.card ι := Nat.cast_pos.mpr Fintype.card_pos
calc
logPartition x ≤ Real.log ((Fintype.card ι : ℝ)*Real.exp C) := by
apply Real.log_le_log (partition_pos x)
calc
partition 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| := by
have 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 i
have hx := neg_abs_le (x i)
have hxi := hsum i
rw [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 κ) := by
have 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 κ) := by
simpa 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) := by
have 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)) := by
intro k
apply Integrable.const_mul
apply gibbsWeight_mul_integrable
exact (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) := by
apply integral_congr_ae
exact 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)) := by
rw [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)) := by
simp 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) := by
rw [integral_finsetSum Finset.univ (fun k _ ↦ hic k)]
simp only [integral_const_mul]
_ = _ := by
apply integral_congr_ae
apply Eventually.of_forall
intro z
simp 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 _; ring
lemma 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) := by
have h1 : (∑ i, ∑ j, p i*p j*D i i) = ∑ i, p i*D i i := by
apply Finset.sum_congr rfl
intro 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 := by
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro 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 := by
rw [Finset.sum_comm]
apply Finset.sum_congr rfl; intro i _
apply Finset.sum_congr rfl; intro j _; ring
have 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 := by
simp 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) := by
simp only [mul_sub,mul_add,Finset.sum_sub_distrib,Finset.sum_add_distrib]
rw [h1,h2,h3]
ring
rw [hl,hr]
ring
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Evolution.BoundedSmooth
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
noncomputable 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 ι) := by unfold gaussianProduct; infer_instance
lemma density_hasDerivAt (x : ℝ) : HasDerivAt (gaussianPDFReal 0 1) (-x*gaussianPDFReal 0 1 x) x := by have h1 : HasDerivAt (fun y : ℝ ↦ -y^2/2) (-x) x := by have 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 hh have hd := h1.exp.const_mul ((Real.sqrt (2*Real.pi))⁻¹) convert hd using 1 <;> try rfl · funext y simp only [gaussianPDFReal,NNReal.coe_one,mul_one,sub_zero] · simp only [gaussianPDFReal,NNReal.coe_one,mul_one,sub_zero] ring
lemma density_mul_integrable {f : ℝ → ℝ} (hf : Integrable f standardGaussian) : Integrable (fun x ↦ gaussianPDFReal 0 1 x*f x) := by rw [standardGaussian,gaussianReal_of_var_ne_zero _ (by norm_num)] at hf have hh := (integrable_withDensity_iff_integrable_smul' (measurable_gaussianPDF 0 1) (Eventually.of_forall (fun x ↦ gaussianPDF_lt_top (μ := 0) (v := 1) (x := x)))).mp hf simpa only [toReal_gaussianPDF,smul_eq_mul] using hh
lemma standardGaussian_integrable_id : Integrable (fun x : ℝ ↦ x) standardGaussian := by have 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 := by have 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)) := by convert (density_mul_integrable hxfi).neg using 1 ext x simp only [Pi.neg_apply] ring have hi2 : Integrable (fun x ↦ f' x*gaussianPDFReal 0 1 x) := by simpa only [mul_comm] using density_mul_integrable hf'i have hi3 : Integrable (fun x ↦ f x*gaussianPDFReal 0 1 x) := by simpa only [mul_comm] using density_mul_integrable hfi have 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 hi3 have hb : (∫ x, f x*(-x*gaussianPDFReal 0 1 x)) = -(∫ x, gaussianPDFReal 0 1 x*(x*f x)) := by rw [← integral_neg] apply integral_congr_ae exact Eventually.of_forall (fun x ↦ by ring) rw [hb] at hibp have he : (∫ x, gaussianPDFReal 0 1 x*(x*f x)) = ∫ x, gaussianPDFReal 0 1 x*f' x := by exact 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 he
lemma gaussian_coordinate_integrable {ι : Type*} [Fintype ι] (i : ι) : Integrable (fun z : ι → ℝ ↦ z i) (gaussianProduct ι) := by exact ((measurePreserving_eval (fun _ : ι ↦ standardGaussian) i).integrable_comp standardGaussian_integrable_id.aestronglyMeasurable).mpr standardGaussian_integrable_id
lemma 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) := by cases n with | zero => exact Fin.elim0 i | succ n => let e := MeasurableEquiv.piFinSuccAbove (fun _ : Fin (n+1) ↦ ℝ) i have he : MeasurePreserving e.symm (standardGaussian.prod (gaussianProduct (Fin n))) (gaussianProduct (Fin (n+1))) := (measurePreserving_piFinSuccAbove (fun _ : Fin (n+1) ↦ standardGaussian) i).symm have 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 hi have 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_ae apply Eventually.of_forall intro y simp 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) ∂standardGaussian have hmeas : Measurable (fun x : ℝ ↦ i.insertNth (α := fun _ : Fin (n+1) ↦ ℝ) x y) := by exact 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 x simpa 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 x
noncomputable def logPartition {ι : Type*} [Fintype ι] (x : ι → ℝ) : ℝ := Real.log (partition x)
lemma partition_pos {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) : 0 < partition x := by exact Finset.sum_pos (fun i _ ↦ Real.exp_pos _) Finset.univ_nonempty
lemma 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 := by simp only [gibbsWeight,← Finset.sum_div] change partition x / partition x = 1 exact div_self (ne_of_gt (partition_pos x))
lemma gibbsWeight_le_one {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (i : ι) : gibbsWeight x i ≤ 1 := by calc _ ≤ ∑ j, gibbsWeight x j := Finset.single_le_sum (fun j _ ↦ gibbsWeight_nonneg x j) (Finset.mem_univ i) _ = 1 := sum_gibbsWeight x
lemma continuous_partition {ι : Type*} [Fintype ι] : Continuous (@partition ι _) := by unfold partition fun_prop
lemma continuous_gibbsWeight {ι : Type*} [Fintype ι] [Nonempty ι] (i : ι) : Continuous (fun x : ι → ℝ ↦ gibbsWeight x i) := by exact (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 := by simpa 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 := by convert (hasDerivAt_partition h).log (ne_of_gt (partition_pos _)) using 1 <;> try rfl simp only [gibbsWeight,Finset.sum_div,mul_div_assoc] apply Finset.sum_congr rfl intro i _ ring
lemma 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 := by convert (h i).exp.div (hasDerivAt_partition h) (ne_of_gt (partition_pos _)) using 1 <;> try rfl simp 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) by rw [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 := by calc _ ≤ ∑ 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 k
lemma continuous_linearProcess {ι κ : Type*} [Fintype κ] (c : ι → κ → ℝ) : Continuous (linearProcess c) := by unfold linearProcess fun_prop
lemma 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) := by have 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) := by intro j by_cases hj : j=k · subst j simpa 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 κ) := by apply Integrable.of_bound (continuous_linear_gibbsWeight c i).aestronglyMeasurable 1 exact 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 κ) := by apply (gaussian_coordinate_integrable k).mul_bdd (continuous_linear_gibbsWeight c i).aestronglyMeasurable exact 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) := by apply 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.sub exact continuous_finsetSum _ (fun j _ ↦ (continuous_linear_gibbsWeight c j).mul continuous_const) · intro z simpa only [Function.update_eq_self] using hasDerivAt_gibbsWeight (fun j ↦ hasDerivAt_linearProcess_update c z j k) i · intro z rw [abs_of_nonneg (gibbsWeight_nonneg _ _)] exact gibbsWeight_le_one _ _ · intro z have 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| := by rw [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 ring
lemma le_logPartition {ι : Type*} [Fintype ι] [Nonempty ι] (x : ι → ℝ) (i : ι) : x i ≤ logPartition x := by apply (Real.le_log_iff_exp_le (partition_pos x)).mpr exact 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 := by have hc : (0 : ℝ) < Fintype.card ι := Nat.cast_pos.mpr Fintype.card_pos calc logPartition x ≤ Real.log ((Fintype.card ι : ℝ)*Real.exp C) := by apply Real.log_le_log (partition_pos x) calc partition 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| := by have 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 i have hx := neg_abs_le (x i) have hxi := hsum i rw [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 κ) := by have 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 κ) := by simpa 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) := by have 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)) := by intro k apply Integrable.const_mul apply gibbsWeight_mul_integrable exact (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) := by apply integral_congr_ae exact 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)) := by rw [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)) := by simp 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) := by rw [integral_finsetSum Finset.univ (fun k _ ↦ hic k)] simp only [integral_const_mul] _ = _ := by apply integral_congr_ae apply Eventually.of_forall intro z simp 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 _; ring
lemma 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) := by have h1 : (∑ i, ∑ j, p i*p j*D i i) = ∑ i, p i*D i i := by apply Finset.sum_congr rfl intro 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 := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro 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 := by rw [Finset.sum_comm] apply Finset.sum_congr rfl; intro i _ apply Finset.sum_congr rfl; intro j _; ring have 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 := by simp 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) := by simp only [mul_sub,mul_add,Finset.sum_sub_distrib,Finset.sum_add_distrib] rw [h1,h2,h3] ring rw [hl,hr] ring
end SKValueGend
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161import Mathlib
import OAI.Probability.SKValue.GroundState.LiteralLower
import OAI.Probability.SKValue.GroundState.GaussianTree
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
lemma 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 := by
rw [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]
ring
lemma 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) := by
apply 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) := by
rw [expected_treeAux_eq_tensor n T hT d]
exact finite_guerra_upper hn (treeFieldVector 0 T) (treeField_unit T hT) d
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
lemma finiteMaximum_prod_curry_left {ι κ : Type*} [Fintype ι] [Nonempty ι]
[Fintype κ] [Nonempty κ] (f : ι×κ → ℝ) :
finiteMaximum f=finiteMaximum (fun i ↦ finiteMaximum (fun j ↦ f (i,j))) := by
apply le_antisymm
· obtain ⟨p,hp⟩ := exists_finiteMaximum f
rw [←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 := by
classical
change (∑ 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 T
noncomputable def treeOffset (T : GaussianTree) (g : TreeEdges T → ℝ) (α : TreeLeaves T) : ℝ :=
linearProcess (treePathCoeff (fun _ l ↦ 1/l.height) 0 T) g α-treeCenter T
lemma treePathCoeff_const_q (c : TreeLevel → ℝ) (q r : ℝ) (T : GaussianTree) :
treePathCoeff (fun _ l ↦ c l) q T=treePathCoeff (fun _ l ↦ c l) r T := by
induction T with
| nil => rfl
| cons l T ih => funext α e; cases e <;> rfl
lemma 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 := by
rw [treeOffset,treeLinear_step,treeCenter]
rw [treePathCoeff_const_q (fun l ↦ 1/l.height) l.endpoint 0 T]
simp only [treeOffset]
ring
noncomputable 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) := by
unfold scalarTreeValue
change finiteMaximum (fun α : Fin (l.branchExcess+1) × TreeLeaves T ↦ _)=_
rw [finiteMaximum_prod_curry_left]
congr 1; funext i
conv_lhs =>
arg 1
ext α
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 ring
conv_lhs =>
arg 1
ext α
rw [he]
dsimp only
rw [finiteMaximum_add_const]
ring
noncomputable 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) := by
have 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 := by
exact treeLinear_step (fun q l ↦ Real.sqrt (l.endpoint-q)) q l T (fun e ↦ z (i,e)) α
unfold fieldTreeValue
change finiteMaximum (fun α : Fin (l.branchExcess+1) × TreeLeaves T ↦ _)=_
rw [finiteMaximum_prod_curry_left]
congr 1; funext j
conv_lhs =>
arg 1
ext α
rw [treeOffset_step l T g (j,α)]
simp only [hh (j,α),←add_assoc]
dsimp only
have he (a b d : ℝ) : a+b+d=(a+d)+b := by ring
conv_lhs =>
arg 1
ext α
rw [he]
rw [finiteMaximum_add_const]
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.LiteralLowerimport OAI.Probability.SKValue.GroundState.GaussianTree
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
lemma 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 := by rw [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] ring
lemma 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) := by apply 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) := by rw [expected_treeAux_eq_tensor n T hT d] exact finite_guerra_upper hn (treeFieldVector 0 T) (treeField_unit T hT) d
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
lemma finiteMaximum_prod_curry_left {ι κ : Type*} [Fintype ι] [Nonempty ι] [Fintype κ] [Nonempty κ] (f : ι×κ → ℝ) : finiteMaximum f=finiteMaximum (fun i ↦ finiteMaximum (fun j ↦ f (i,j))) := by apply le_antisymm · obtain ⟨p,hp⟩ := exists_finiteMaximum f rw [←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 := by classical change (∑ 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 T
noncomputable def treeOffset (T : GaussianTree) (g : TreeEdges T → ℝ) (α : TreeLeaves T) : ℝ := linearProcess (treePathCoeff (fun _ l ↦ 1/l.height) 0 T) g α-treeCenter T
lemma treePathCoeff_const_q (c : TreeLevel → ℝ) (q r : ℝ) (T : GaussianTree) : treePathCoeff (fun _ l ↦ c l) q T=treePathCoeff (fun _ l ↦ c l) r T := by induction T with | nil => rfl | cons l T ih => funext α e; cases e <;> rfl
lemma 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 := by rw [treeOffset,treeLinear_step,treeCenter] rw [treePathCoeff_const_q (fun l ↦ 1/l.height) l.endpoint 0 T] simp only [treeOffset] ring
noncomputable 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) := by unfold scalarTreeValue change finiteMaximum (fun α : Fin (l.branchExcess+1) × TreeLeaves T ↦ _)=_ rw [finiteMaximum_prod_curry_left] congr 1; funext i conv_lhs => arg 1 ext α 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 ring conv_lhs => arg 1 ext α rw [he] dsimp only rw [finiteMaximum_add_const] ring
noncomputable 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) := by have 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 := by exact treeLinear_step (fun q l ↦ Real.sqrt (l.endpoint-q)) q l T (fun e ↦ z (i,e)) α unfold fieldTreeValue change finiteMaximum (fun α : Fin (l.branchExcess+1) × TreeLeaves T ↦ _)=_ rw [finiteMaximum_prod_curry_left] congr 1; funext j conv_lhs => arg 1 ext α rw [treeOffset_step l T g (j,α)] simp only [hh (j,α),←add_assoc] dsimp only have he (a b d : ℝ) : a+b+d=(a+d)+b := by ring conv_lhs => arg 1 ext α rw [he] rw [finiteMaximum_add_const]
end SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204import Mathlib
import OAI.Probability.SKValue.GroundState.TreeGuerra
import OAI.Probability.SKValue.GroundState.BranchLaw
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
lemma 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 ↦ μ))) := by
refine ⟨by fun_prop,?_⟩
have h := Measure.infinitePi_map_curry (fun (_ : I) (_ : E) ↦ μ)
simp only [Measure.infinitePi_eq_pi,MeasurableEquiv.coe_curry] at h
convert h using 1
rfl
lemma 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 ↦ μ)))) := by
have 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 ↦ μ))).symm
exact 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 ν) := by
have h1 := measurePreserving_prodAssoc μ ν σ
have h2 := (MeasurePreserving.id μ).prod (Measure.measurePreserving_swap (μ := ν) (ν := σ))
have h3 := (measurePreserving_prodAssoc μ σ ν).symm
exact 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 μ) := by
unfold gaussianAddLaw
infer_instance
lemma gaussianAddLaw_integrable (c : ℝ) {μ : Measure ℝ} [IsProbabilityMeasure μ]
(hi : Integrable (fun x : ℝ ↦ x) μ) :
Integrable (fun x : ℝ ↦ x) (gaussianAddLaw c μ) := by
rw [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 μ) := by
rw [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 1
funext p
dsimp only [Function.comp_def]
rw [←Real.exp_add]
congr 1
ring
lemma gaussianAddLaw_exp (c a : ℝ) {μ : Measure ℝ} [IsProbabilityMeasure μ] :
(∫ x,Real.exp (a*x) ∂gaussianAddLaw c μ)=
Real.exp ((a*c)^2/2)*(∫ x,Real.exp (a*x) ∂μ) := by
rw [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) := by
rw [←Real.exp_add]; congr 1; ring
simp_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) ∂μ)) heq
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
noncomputable def edgeNoiseLaw : Measure (ℝ×ℝ) := standardGaussian.prod gumbelLaw
instance edgeNoiseLaw_probability : IsProbabilityMeasure edgeNoiseLaw := by
unfold edgeNoiseLaw; infer_instance
noncomputable 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.branchExcess
instance scalarTreeLaw_probability (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :
IsProbabilityMeasure (scalarTreeLaw c q T) := by
induction T generalizing q with
| nil => exact inferInstanceAs (IsProbabilityMeasure (Measure.dirac (0 : ℝ)))
| cons l T ih =>
have := ih l.endpoint
exact 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 := by
obtain ⟨i,hi⟩ := exists_finiteMaximum (fun _ : I ↦ a)
exact hi.symm
lemma scalarTreeEval_nil (c : ℝ → TreeLevel → ℝ) (q : ℝ) (w : TreeEdges [] → ℝ×ℝ) :
scalarTreeEval c q [] w=0 := by
simp 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) := by
unfold scalarTreeEval scalarTreeValue treeOffset
apply continuous_finiteMaximum.comp
apply continuous_pi
intro α
unfold linearProcess
fun_prop
lemma 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) := by
have 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) := by
rw [scalarTreeEval,scalarTreeValue_step]
unfold branchMax
have 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 ring
change 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]
ring
theorem scalarTreeEval_law (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :
MeasurePreserving (scalarTreeEval c q T) (Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw))
(scalarTreeLaw c q T) := by
induction 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) edgeNoiseLaw
have 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 1
funext w
exact scalarTreeEval_step c q l T w
lemma scalarTreeLaw_integrable (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) :
Integrable (fun x : ℝ ↦ x) (scalarTreeLaw c q T) := by
induction 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 SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.TreeGuerraimport OAI.Probability.SKValue.GroundState.BranchLaw
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
lemma 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 ↦ μ))) := by refine ⟨by fun_prop,?_⟩ have h := Measure.infinitePi_map_curry (fun (_ : I) (_ : E) ↦ μ) simp only [Measure.infinitePi_eq_pi,MeasurableEquiv.coe_curry] at h convert h using 1 rfl
lemma 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 ↦ μ)))) := by have 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 ↦ μ))).symm exact 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 ν) := by have h1 := measurePreserving_prodAssoc μ ν σ have h2 := (MeasurePreserving.id μ).prod (Measure.measurePreserving_swap (μ := ν) (ν := σ)) have h3 := (measurePreserving_prodAssoc μ σ ν).symm exact 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 μ) := by unfold gaussianAddLaw infer_instance
lemma gaussianAddLaw_integrable (c : ℝ) {μ : Measure ℝ} [IsProbabilityMeasure μ] (hi : Integrable (fun x : ℝ ↦ x) μ) : Integrable (fun x : ℝ ↦ x) (gaussianAddLaw c μ) := by rw [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 μ) := by rw [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 1 funext p dsimp only [Function.comp_def] rw [←Real.exp_add] congr 1 ring
lemma gaussianAddLaw_exp (c a : ℝ) {μ : Measure ℝ} [IsProbabilityMeasure μ] : (∫ x,Real.exp (a*x) ∂gaussianAddLaw c μ)= Real.exp ((a*c)^2/2)*(∫ x,Real.exp (a*x) ∂μ) := by rw [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) := by rw [←Real.exp_add]; congr 1; ring simp_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) ∂μ)) heq
end SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
noncomputable def edgeNoiseLaw : Measure (ℝ×ℝ) := standardGaussian.prod gumbelLawinstance edgeNoiseLaw_probability : IsProbabilityMeasure edgeNoiseLaw := by unfold edgeNoiseLaw; infer_instance
noncomputable 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.branchExcess
instance scalarTreeLaw_probability (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) : IsProbabilityMeasure (scalarTreeLaw c q T) := by induction T generalizing q with | nil => exact inferInstanceAs (IsProbabilityMeasure (Measure.dirac (0 : ℝ))) | cons l T ih => have := ih l.endpoint exact 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 := by obtain ⟨i,hi⟩ := exists_finiteMaximum (fun _ : I ↦ a) exact hi.symm
lemma scalarTreeEval_nil (c : ℝ → TreeLevel → ℝ) (q : ℝ) (w : TreeEdges [] → ℝ×ℝ) : scalarTreeEval c q [] w=0 := by simp 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) := by unfold scalarTreeEval scalarTreeValue treeOffset apply continuous_finiteMaximum.comp apply continuous_pi intro α unfold linearProcess fun_prop
lemma 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) := by have 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) := by rw [scalarTreeEval,scalarTreeValue_step] unfold branchMax have 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 ring change 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] ring
theorem scalarTreeEval_law (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) : MeasurePreserving (scalarTreeEval c q T) (Measure.pi (fun _ : TreeEdges T ↦ edgeNoiseLaw)) (scalarTreeLaw c q T) := by induction 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) edgeNoiseLaw have 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 1 funext w exact scalarTreeEval_step c q l T w
lemma scalarTreeLaw_integrable (c : ℝ → TreeLevel → ℝ) (q : ℝ) (T : GaussianTree) : Integrable (fun x : ℝ ↦ x) (scalarTreeLaw c q T) := by induction 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 SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119import Mathlib
import OAI.Probability.SKValue.GroundState.BranchMeanUpper
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
noncomputable 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 T
noncomputable 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.2
lemma resizeTree_valid (n : ℕ) {q : ℝ} {T : GaussianTree} (h : ValidTreeGrid q T)
(w : CascadeWidths (auxShape n q T)) : ValidTreeGrid q (resizeTree n q T w) := by
induction 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) := by
induction 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) := by
induction 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 := by
induction 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 := by
induction 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 := by
cases 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 := by
induction 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 T
lemma 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) := by
have hl := hq.trans hql
have hs : 0 ≤ l.endpoint^2-q^2 := by nlinarith
rw [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) := by
induction T generalizing q a with
| nil => simp [auxShape,cascadeMoment,gumbelTreeMoment,treeCorrection]
| cons l T ih =>
obtain ⟨ha,ham,hT⟩ := h
have hm : 0 < l.height := ha.trans_lt ham
have hs := auxAmplitude_sq n hq hgrid.1
rw [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)) := by
rw [mul_left_comm,←Real.exp_add]
congr 2
simp only [treeCorrection]
ring
rw [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) := by
field_simp
rw [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 := by
cases T with
| nil => simp [auxShape,cascadeMean,gumbelTreeMean,treeCorrection]
| cons l T =>
obtain ⟨_,hm,hT⟩ := h
have hs := auxAmplitude_sq n hq hgrid.1
rw [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_simp
ring
end SKValueG
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.BranchMeanUpper
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
noncomputable 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 T
noncomputable 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.2
lemma resizeTree_valid (n : ℕ) {q : ℝ} {T : GaussianTree} (h : ValidTreeGrid q T) (w : CascadeWidths (auxShape n q T)) : ValidTreeGrid q (resizeTree n q T w) := by induction 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) := by induction 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) := by induction 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 := by induction 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 := by induction 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 := by cases 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 := by induction 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 T
lemma 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) := by have hl := hq.trans hql have hs : 0 ≤ l.endpoint^2-q^2 := by nlinarith rw [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) := by induction T generalizing q a with | nil => simp [auxShape,cascadeMoment,gumbelTreeMoment,treeCorrection] | cons l T ih => obtain ⟨ha,ham,hT⟩ := h have hm : 0 < l.height := ha.trans_lt ham have hs := auxAmplitude_sq n hq hgrid.1 rw [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)) := by rw [mul_left_comm,←Real.exp_add] congr 2 simp only [treeCorrection] ring rw [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) := by field_simp rw [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 := by cases T with | nil => simp [auxShape,cascadeMean,gumbelTreeMean,treeCorrection] | cons l T => obtain ⟨_,hm,hT⟩ := h have hs := auxAmplitude_sq n hq hgrid.1 rw [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_simp ring
end SKValueG
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import Mathlib
import OAI.Probability.SKValue.GroundState.CascadePassage
import OAI.Probability.SKValue.Equations.StrictProfile
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValueG
lemma 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 := by
have h1 := profile_weighted_integrable 0 l
have h2 := profile_weighted_integrable 0 (SKValue.liftProfile ε k l)
simp only [zero_add,SKValue.liftProfile_time,hT] at h1 h2
apply intervalIntegral.integral_mono_on (by norm_num) h1 h2
intro t ht
exact mul_le_mul_of_nonneg_left (SKValue.liftProfile_coeff_lower ε k l t) ht.1
lemma 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)) := by
have 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)) := by
intro ε 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 hs
have hv := profileTree_le_smooth hψ hb hs 0
have hvb := abs_le.mp (hψ.liftProfile_bound W hl hT hepos 1 0)
have hc := profile_penalty_mono e 1 hT
rw [profileTree_correction] at hu
simp only [SKValue.liftProfile_time,hT,zero_add] at hu
have hnn : (0 : ℝ)≤n := by positivity
have hvb' : SKValue.profileValue ψ (SKValue.liftProfile e 1 l) 0 0-SKValue.profileValue ψ l 0 0 ≤
(3/2 : ℝ)*ε*(1+l.length) := by
have h := hvb.2
have hcoe : (e : ℝ)=ε := rfl
rw [Nat.cast_one,hcoe] at h
exact h
apply hu.trans
apply mul_le_mul_of_nonneg_left _ hnn
linarith
have 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)))) := by
have hr : Tendsto (fun j : ℕ ↦ (3/2 : ℝ)*(1/(j+1 : ℝ))*(1+l.length)) atTop (𝓝 0) := by
simpa 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 SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
namespace SKValue
lemma logCoshTerminal_ge_abs {M : ℝ} (hM : 0<M) (x : ℝ) :
|x|≤logCoshTerminal M x := by
have hh := (log_two_cosh_bounds (M*x)).1
rw [abs_mul,abs_of_pos hM] at hh
exact (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 := by
apply intervalIntegral.integral_congr_ae
filter_upwards [Measure.ae_ne volume (1 : ℝ)] with t hne ht
rw [uIoc_of_le (by norm_num : (0 : ℝ)≤1)] at ht
have 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 := by
have hi : IntervalIntegrable (profileCoeff (γ.grid j)) volume 0 1 :=
γ.grid_time j ▸ profileCoeff_integrable (γ.grid j)
have hj : IntervalIntegrable γ.cutoff volume 0 1 := γ.cutoff_integrable.intervalIntegrable
have hiw := hi.continuousOn_mul (continuous_id : Continuous (fun t : ℝ ↦ t)).continuousOn
have hjw := hj.continuousOn_mul (continuous_id : Continuous (fun t : ℝ ↦ t)).continuousOn
simp only [id_eq] at hiw hjw
rw [←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| := by
apply intervalIntegral.integral_mono_on (by norm_num) (hiw.sub hjw).abs (hi.sub hj).abs
intro t ht
rw [←mul_sub,abs_mul,abs_of_nonneg ht.1]
exact mul_le_of_le_one_left (abs_nonneg _) ht.2
_ = γ.gridError j := rfl
lemma 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)) := by
rw [←γ.weighted_cutoff_integral]
apply (tendsto_iff_dist_tendsto_zero).mpr
simp only [Real.dist_eq]
exact squeeze_zero (fun _ ↦ abs_nonneg _) γ.weighted_grid_error γ.gridError_tendsto
theorem expectedMaximum_le_parisi (W : BrownianSpace) (γ : OrderParameter) {n : ℕ} (hn : 0<n) :
SKValueG.expectedMaximum n≤(n : ℝ)*parisi W γ := by
have ht := (smoothApprox_tendsto W γ).tendsto_at ((⟨0,by norm_num⟩ : Ico (0 : ℝ) 1),0)
have hp := γ.weighted_grid_tendsto
have hf : Tendsto (fun j ↦ (n : ℝ)*(smoothApprox γ j 0 0-
(1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*profileCoeff (γ.grid j) t))) atTop (𝓝 ((n : ℝ)*parisi W γ)) := by
simpa only [parisi] using tendsto_const_nhds.mul (ht.sub (tendsto_const_nhds.mul hp))
apply ge_of_tendsto hf
exact 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 γ := by
have he : SKValueG.groundStateSequence=groundStateSequence := rfl
have hev : SKValueG.groundStateValue=groundStateValue := rfl
have ht := SKValueG.groundStateSequence_tendsto
rw [he,hev] at ht
apply le_of_tendsto ht
filter_upwards [eventually_gt_atTop (0 : ℕ)] with n hn
change SKValueG.groundStateSequence n≤_
rw [SKValueG.groundStateSequence_eq]
have hn' : (0 : ℝ)<n := by exact_mod_cast hn
have 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 hh
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.CascadePassageimport OAI.Probability.SKValue.Equations.StrictProfile
namespace OAI
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValueG
lemma 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 := by have h1 := profile_weighted_integrable 0 l have h2 := profile_weighted_integrable 0 (SKValue.liftProfile ε k l) simp only [zero_add,SKValue.liftProfile_time,hT] at h1 h2 apply intervalIntegral.integral_mono_on (by norm_num) h1 h2 intro t ht exact mul_le_mul_of_nonneg_left (SKValue.liftProfile_coeff_lower ε k l t) ht.1
lemma 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)) := by have 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)) := by intro ε 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 hs have hv := profileTree_le_smooth hψ hb hs 0 have hvb := abs_le.mp (hψ.liftProfile_bound W hl hT hepos 1 0) have hc := profile_penalty_mono e 1 hT rw [profileTree_correction] at hu simp only [SKValue.liftProfile_time,hT,zero_add] at hu have hnn : (0 : ℝ)≤n := by positivity have hvb' : SKValue.profileValue ψ (SKValue.liftProfile e 1 l) 0 0-SKValue.profileValue ψ l 0 0 ≤ (3/2 : ℝ)*ε*(1+l.length) := by have h := hvb.2 have hcoe : (e : ℝ)=ε := rfl rw [Nat.cast_one,hcoe] at h exact h apply hu.trans apply mul_le_mul_of_nonneg_left _ hnn linarith have 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)))) := by have hr : Tendsto (fun j : ℕ ↦ (3/2 : ℝ)*(1/(j+1 : ℝ))*(1+l.length)) atTop (𝓝 0) := by simpa 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 SKValueG
end
section
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValue
lemma logCoshTerminal_ge_abs {M : ℝ} (hM : 0<M) (x : ℝ) : |x|≤logCoshTerminal M x := by have hh := (log_two_cosh_bounds (M*x)).1 rw [abs_mul,abs_of_pos hM] at hh exact (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 := by apply intervalIntegral.integral_congr_ae filter_upwards [Measure.ae_ne volume (1 : ℝ)] with t hne ht rw [uIoc_of_le (by norm_num : (0 : ℝ)≤1)] at ht have 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 := by have hi : IntervalIntegrable (profileCoeff (γ.grid j)) volume 0 1 := γ.grid_time j ▸ profileCoeff_integrable (γ.grid j) have hj : IntervalIntegrable γ.cutoff volume 0 1 := γ.cutoff_integrable.intervalIntegrable have hiw := hi.continuousOn_mul (continuous_id : Continuous (fun t : ℝ ↦ t)).continuousOn have hjw := hj.continuousOn_mul (continuous_id : Continuous (fun t : ℝ ↦ t)).continuousOn simp only [id_eq] at hiw hjw rw [←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| := by apply intervalIntegral.integral_mono_on (by norm_num) (hiw.sub hjw).abs (hi.sub hj).abs intro t ht rw [←mul_sub,abs_mul,abs_of_nonneg ht.1] exact mul_le_of_le_one_left (abs_nonneg _) ht.2 _ = γ.gridError j := rfl
lemma 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)) := by rw [←γ.weighted_cutoff_integral] apply (tendsto_iff_dist_tendsto_zero).mpr simp only [Real.dist_eq] exact squeeze_zero (fun _ ↦ abs_nonneg _) γ.weighted_grid_error γ.gridError_tendsto
theorem expectedMaximum_le_parisi (W : BrownianSpace) (γ : OrderParameter) {n : ℕ} (hn : 0<n) : SKValueG.expectedMaximum n≤(n : ℝ)*parisi W γ := by have ht := (smoothApprox_tendsto W γ).tendsto_at ((⟨0,by norm_num⟩ : Ico (0 : ℝ) 1),0) have hp := γ.weighted_grid_tendsto have hf : Tendsto (fun j ↦ (n : ℝ)*(smoothApprox γ j 0 0- (1/2 : ℝ)*(∫ t in (0 : ℝ)..1,t*profileCoeff (γ.grid j) t))) atTop (𝓝 ((n : ℝ)*parisi W γ)) := by simpa only [parisi] using tendsto_const_nhds.mul (ht.sub (tendsto_const_nhds.mul hp)) apply ge_of_tendsto hf exact 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 γ := by have he : SKValueG.groundStateSequence=groundStateSequence := rfl have hev : SKValueG.groundStateValue=groundStateValue := rfl have ht := SKValueG.groundStateSequence_tendsto rw [he,hev] at ht apply le_of_tendsto ht filter_upwards [eventually_gt_atTop (0 : ℕ)] with n hn change SKValueG.groundStateSequence n≤_ rw [SKValueG.groundStateSequence_eq] have hn' : (0 : ℝ)<n := by exact_mod_cast hn have 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 hh
end SKValue
end
end OAI1234567891011121314151617181920212223242526272812345678910111213141516171819202122232425262728import Mathlib
import OAI.Probability.SKValue.Gaussian.IntegralPositiveMulGaussian
import OAI.Probability.SKValue.Processes.TestExpectation
import OAI.Probability.SKValue.Processes.ForcedExpectation
import OAI.Probability.SKValue.Processes.ForcedDiffusion
import OAI.Probability.SKValue.Equations.PolynomialForced
import OAI.Probability.SKValue.Evolution.HeatConvexity
import OAI.Probability.SKValue.Evolution.TerminalAlgebra
import OAI.Probability.SKValue.Evolution.TestStrip
import OAI.Probability.SKValue.GroundState.MainConclusions
namespace OAI
namespace SKValue
theorem 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 γ) := by
exact ⟨scalar_value_target, finite_gaussian_target, ground_state_parisi_target⟩
end SKValue
end OAIimport 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.MainConclusions
namespace OAI
namespace SKValue
theorem 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 γ) := by exact ⟨scalar_value_target, finite_gaussian_target, ground_state_parisi_target⟩
end SKValue
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165import Mathlib
namespace OAI
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology ENNReal NNReal BigOperators
namespace SKValue
noncomputable def standardGaussian : Measure ℝ := gaussianReal 0 1
instance : IsProbabilityMeasure standardGaussian := by unfold standardGaussian; infer_instance
noncomputable def gaussianProduct (ι : Type) [Fintype ι] : Measure (ι → ℝ) :=
Measure.pi (fun _ : ι ↦ standardGaussian)
instance gaussianProduct_probability (ι : Type) [Fintype ι] :
IsProbabilityMeasure (gaussianProduct ι) := by
unfold gaussianProduct
infer_instance
def coordinate (N : ℕ) (j : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=
z ⟨j % (N+1), Nat.mod_lt _ (Nat.succ_pos _)⟩
noncomputable def stepSize (T : ℝ) (N : ℕ) : ℝ := T / N
noncomputable def meshTime (T : ℝ) (N j : ℕ) : ℝ := j * stepSize T N
noncomputable 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 where
coeff : ℝ → ℝ
nonneg : ∀ t ∈ Ico (0 : ℝ) 1, 0 ≤ coeff t
monotone : MonotoneOn coeff (Ico (0 : ℝ) 1)
rightContinuous : ∀ t ∈ Ico (0 : ℝ) 1, ContinuousWithinAt coeff (Ici t) t
integrable : IntegrableOn coeff (Ioc (0 : ℝ) 1)
structure BrownianSpace where
Ω : Type
measurableSpace : MeasurableSpace Ω
μ : @Measure Ω measurableSpace
probability : @IsProbabilityMeasure Ω measurableSpace μ
B : ℝ≥0 → Ω → ℝ
measurable : ∀ t, @StronglyMeasurable Ω ℝ _ measurableSpace (B t)
brownian : @IsBrownianReal Ω measurableSpace B μ
attribute [instance] BrownianSpace.measurableSpace BrownianSpace.probability
noncomputable def BrownianSpace.filtration (W : BrownianSpace) :
Filtration ℝ≥0 W.measurableSpace := Filtration.natural W.B W.measurable
noncomputable 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 ω| ≤ 1
noncomputable 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) x
noncomputable def curvature (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ :=
deriv (gradient W γ t) x
noncomputable def parisi (W : BrownianSpace) (γ : OrderParameter) : ℝ :=
phi W γ 0 0 - (1/2 : ℝ) * ∫ t in (0 : ℝ)..1, t * γ.coeff t
def 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 -1
noncomputable 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 0
noncomputable def groundStateSequence (n : ℕ) : ℝ :=
(n : ℝ)⁻¹ * ∫ J, sSup (range (hamiltonian n J)) ∂gaussianProduct (Fin n × Fin n)
noncomputable def groundStateValue : ℝ := limUnder atTop groundStateSequence
noncomputable 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 1
noncomputable def eulerPath (W : BrownianSpace) (γ : OrderParameter) (T : ℝ) (N : ℕ)
(z : Fin (N+1) → ℝ) (j : ℕ) : ℝ :=
euler T N γ.coeff (gradient W γ) z j
noncomputable 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 z
noncomputable 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 SKValue
end OAIimport Mathlib
namespace OAI
open MeasureTheory ProbabilityTheory Filter Setopen scoped Topology ENNReal NNReal BigOperators
namespace SKValue
noncomputable def standardGaussian : Measure ℝ := gaussianReal 0 1
instance : IsProbabilityMeasure standardGaussian := by unfold standardGaussian; infer_instance
noncomputable def gaussianProduct (ι : Type) [Fintype ι] : Measure (ι → ℝ) := Measure.pi (fun _ : ι ↦ standardGaussian)instance gaussianProduct_probability (ι : Type) [Fintype ι] : IsProbabilityMeasure (gaussianProduct ι) := by unfold gaussianProduct infer_instance
def 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 N
noncomputable 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 where coeff : ℝ → ℝ nonneg : ∀ t ∈ Ico (0 : ℝ) 1, 0 ≤ coeff t monotone : MonotoneOn coeff (Ico (0 : ℝ) 1) rightContinuous : ∀ t ∈ Ico (0 : ℝ) 1, ContinuousWithinAt coeff (Ici t) t integrable : IntegrableOn coeff (Ioc (0 : ℝ) 1)
structure BrownianSpace where Ω : Type measurableSpace : MeasurableSpace Ω μ : @Measure Ω measurableSpace probability : @IsProbabilityMeasure Ω measurableSpace μ B : ℝ≥0 → Ω → ℝ measurable : ∀ t, @StronglyMeasurable Ω ℝ _ measurableSpace (B t) brownian : @IsBrownianReal Ω measurableSpace B μ
attribute [instance] BrownianSpace.measurableSpace BrownianSpace.probability
noncomputable def BrownianSpace.filtration (W : BrownianSpace) : Filtration ℝ≥0 W.measurableSpace := Filtration.natural W.B W.measurable
noncomputable 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 ω| ≤ 1
noncomputable 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) x
noncomputable def curvature (W : BrownianSpace) (γ : OrderParameter) (t x : ℝ) : ℝ := deriv (gradient W γ t) x
noncomputable def parisi (W : BrownianSpace) (γ : OrderParameter) : ℝ := phi W γ 0 0 - (1/2 : ℝ) * ∫ t in (0 : ℝ)..1, t * γ.coeff t
def 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 -1
noncomputable 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 0
noncomputable def groundStateSequence (n : ℕ) : ℝ := (n : ℝ)⁻¹ * ∫ J, sSup (range (hamiltonian n J)) ∂gaussianProduct (Fin n × Fin n)
noncomputable def groundStateValue : ℝ := limUnder atTop groundStateSequence
noncomputable 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 1
noncomputable def eulerPath (W : BrownianSpace) (γ : OrderParameter) (T : ℝ) (N : ℕ) (z : Fin (N+1) → ℝ) (j : ℕ) : ℝ := euler T N γ.coeff (gradient W γ) z j
noncomputable 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 z
noncomputable 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 SKValue
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import Mathlib
import OAI.Probability.SKValue.GroundState.CrossExpectation
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal ENNReal BigOperators
namespace SKValue
lemma 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) := by
have 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 hs
noncomputable 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) := by
let δ := stepSize T N
let 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 hN
have hδ : 0≤δ := div_nonneg hT.le hNr.le
have hδ1 : δ≤1 := by
apply (div_le_iff₀ hNr).mpr
have hN1 : (1 : ℝ)≤N := by exact_mod_cast hN
simpa only [one_mul] using hT1.trans hN1
have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hj
have hs (j : ℕ) : meshTime T N j+δ=meshTime T N (j+1) := by
dsimp [meshTime]; push_cast; ring
have hlast : meshTime T N N=T := by dsimp [meshTime,stepSize]; field_simp
have 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 2
have 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)) := by
have 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 he
rw [hs] at he
simpa only [A,b,Y,euler,δ,mul_assoc] using he
have hh := abs_telescope_source (A := A) (b := b)
(Γ := fun j ↦ γ (meshTime T N j)) (Δ := fun j ↦ β (meshTime T N j)) hstep
have 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))) by
dsimp only [A]; rw [hlast],hlast,hzero] at hh
have hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simp
convert hh using 1
· rfl
· dsimp only [δ] at hNd ⊢
simp only [←mul_assoc,hNd]
end SKValue
end
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal ENNReal BigOperators
namespace SKValue
lemma 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) := by
let δ := stepSize T N
have hδ : 0≤δ := div_nonneg hT (Nat.cast_nonneg _)
have hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simp
have 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) := by
let y := euler T N β v z k
let x := euler T N γ u z k
let t := meshTime T N k
have hb : |β t*v t y-γ t*u t x|≤d+G*e+G*L*|y-x| := by
calc
|β 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|) := by
simp 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 ring
change |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 ring
have 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 hj
have hsum : (∑ k∈Finset.range j,δ*(d+G*e))≤T*(d+G*e) := by
simp only [Finset.sum_const,Finset.card_range,nsmul_eq_mul]
rw [←hNd]
have hjs : (j : ℝ)≤N := by exact_mod_cast hj
nlinarith [mul_nonneg hG he,mul_nonneg hd hδ,mul_nonneg hδ (mul_nonneg hG he)]
apply h.trans
apply mul_le_mul hsum
· apply Real.exp_le_exp.mpr
calc
(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
· positivity
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.GroundState.CrossExpectation
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValue
lemma 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) := by have 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 hs
noncomputable 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) := by let δ := stepSize T N let 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 hN have hδ : 0≤δ := div_nonneg hT.le hNr.le have hδ1 : δ≤1 := by apply (div_le_iff₀ hNr).mpr have hN1 : (1 : ℝ)≤N := by exact_mod_cast hN simpa only [one_mul] using hT1.trans hN1 have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hj have hs (j : ℕ) : meshTime T N j+δ=meshTime T N (j+1) := by dsimp [meshTime]; push_cast; ring have hlast : meshTime T N N=T := by dsimp [meshTime,stepSize]; field_simp have 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 2 have 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)) := by have 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 he rw [hs] at he simpa only [A,b,Y,euler,δ,mul_assoc] using he have hh := abs_telescope_source (A := A) (b := b) (Γ := fun j ↦ γ (meshTime T N j)) (Δ := fun j ↦ β (meshTime T N j)) hstep have 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))) by dsimp only [A]; rw [hlast],hlast,hzero] at hh have hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simp convert hh using 1 · rfl · dsimp only [δ] at hNd ⊢ simp only [←mul_assoc,hNd]
end SKValue
end
section
open MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValue
lemma 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) := by let δ := stepSize T N have hδ : 0≤δ := div_nonneg hT (Nat.cast_nonneg _) have hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simp have 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) := by let y := euler T N β v z k let x := euler T N γ u z k let t := meshTime T N k have hb : |β t*v t y-γ t*u t x|≤d+G*e+G*L*|y-x| := by calc |β 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|) := by simp 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 ring change |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 ring have 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 hj have hsum : (∑ k∈Finset.range j,δ*(d+G*e))≤T*(d+G*e) := by simp only [Finset.sum_const,Finset.card_range,nsmul_eq_mul] rw [←hNd] have hjs : (j : ℝ)≤N := by exact_mod_cast hj nlinarith [mul_nonneg hG he,mul_nonneg hd hδ,mul_nonneg hδ (mul_nonneg hG he)] apply h.trans apply mul_le_mul hsum · apply Real.exp_le_exp.mpr calc (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 · positivity
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import Mathlib
import OAI.Probability.SKValue.Processes.CrossMesh
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal ENNReal BigOperators
namespace SKValue
noncomputable 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))) := by
unfold crossMeshSource
rw [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 rfl
intro j hj
ring
lemma 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 := by
have hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg _)
have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT hN hj
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 2
have 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 := by
have 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).trans
calc
_ ≤ ∫ _ : Fin (N+1) → ℝ,|L*R| ∂gaussianProduct (Fin (N+1)) := by
apply integral_mono ((hM1.integrable (by norm_num)).sub (hM2.integrable (by norm_num))).norm (integrable_const _)
intro z
have 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 hh
exact (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))))| := by
simp_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) := by
apply mul_le_mul_of_nonneg_left _ hδ
apply Finset.sum_le_sum
intro j hj
rw [abs_mul]
exact mul_le_mul (hc _ (htime j j.isLt.le)) (hm j) (abs_nonneg _) hd
_=T*d*L*R := by
simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,stepSize]
field_simp
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Processes.CrossMesh
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValue
noncomputable 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))) := by unfold crossMeshSource rw [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 rfl intro j hj ring
lemma 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 := by have hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg _) have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT hN hj 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 2 have 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 := by have 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).trans calc _ ≤ ∫ _ : Fin (N+1) → ℝ,|L*R| ∂gaussianProduct (Fin (N+1)) := by apply integral_mono ((hM1.integrable (by norm_num)).sub (hM2.integrable (by norm_num))).norm (integrable_const _) intro z have 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 hh exact (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))))| := by simp_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) := by apply mul_le_mul_of_nonneg_left _ hδ apply Finset.sum_le_sum intro j hj rw [abs_mul] exact mul_le_mul (hc _ (htime j j.isLt.le)) (hm j) (abs_nonneg _) hd _=T*d*L*R := by simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,stepSize] field_simp
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108import Mathlib
import OAI.Probability.SKValue.Processes.CrossMeshComparison
import OAI.Probability.SKValue.Variation.WeightedMoments
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal ENNReal BigOperators
namespace SKValue
lemma ordinaryMeshSource_eq (W : BrownianSpace) (γ β : OrderParameter) (T : ℝ) (N : ℕ) :
ordinaryMeshSource T N γ.coeff β.coeff (phi W γ)=
weightedEulerMoment W γ β T N-weightedEulerMoment W γ γ T N := by
have he : gradient W γ=(fun t ↦ deriv (phi W γ t)) := rfl
simp only [ordinaryMeshSource,weightedEulerMoment,he,←mul_sub,←Finset.sum_sub_distrib]
congr 1
apply Finset.sum_congr rfl
intro j hj
ring
lemma 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)) := by
obtain ⟨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]; positivity
have 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 := by
have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hj
have 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 := by
have hh := hs t ht x
have hh' : |crossFeedback (phi W γ) (phi W β) t x-gradient W γ t x|=
|gradient W β t x-gradient W γ t x|/2 := by
dsimp 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']
linarith
have 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 := by
apply euler_same_noise_bound hT.le hN hγT hLu hd he
· intro k hk
rw [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 hj
have htelescope := cross_value_mesh_expectation hV hU hT hT1.le
(le_max_left _ _ : γ.coeff T≤G) (le_max_right _ _ : β.coeff T≤G) hN
have hcompare := crossMeshSource_difference_bound hV hU hT.le hN hd hR hc hY
rw [ordinaryMeshSource_eq] at hcompare
have 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 := by
apply (le_abs_self _).trans
simpa 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).1
have hcup := (abs_le.mp hcompare).2
dsimp only [err]
linarith
have hδ : Tendsto (fun N : ℕ ↦ stepSize T N) atTop (𝓝 (0 : ℝ)) := tendsto_const_div_atTop_nhds_zero_nat T
have hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδ
have herr : Tendsto err atTop (𝓝 0) := by
simpa 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 hh
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshComparisonimport OAI.Probability.SKValue.Variation.WeightedMoments
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValue
lemma ordinaryMeshSource_eq (W : BrownianSpace) (γ β : OrderParameter) (T : ℝ) (N : ℕ) : ordinaryMeshSource T N γ.coeff β.coeff (phi W γ)= weightedEulerMoment W γ β T N-weightedEulerMoment W γ γ T N := by have he : gradient W γ=(fun t ↦ deriv (phi W γ t)) := rfl simp only [ordinaryMeshSource,weightedEulerMoment,he,←mul_sub,←Finset.sum_sub_distrib] congr 1 apply Finset.sum_congr rfl intro j hj ring
lemma 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)) := by obtain ⟨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]; positivity have 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 := by have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hj have 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 := by have hh := hs t ht x have hh' : |crossFeedback (phi W γ) (phi W β) t x-gradient W γ t x|= |gradient W β t x-gradient W γ t x|/2 := by dsimp 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'] linarith have 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 := by apply euler_same_noise_bound hT.le hN hγT hLu hd he · intro k hk rw [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 hj have htelescope := cross_value_mesh_expectation hV hU hT hT1.le (le_max_left _ _ : γ.coeff T≤G) (le_max_right _ _ : β.coeff T≤G) hN have hcompare := crossMeshSource_difference_bound hV hU hT.le hN hd hR hc hY rw [ordinaryMeshSource_eq] at hcompare have 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 := by apply (le_abs_self _).trans simpa 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).1 have hcup := (abs_le.mp hcompare).2 dsimp only [err] linarith have hδ : Tendsto (fun N : ℕ ↦ stepSize T N) atTop (𝓝 (0 : ℝ)) := tendsto_const_div_atTop_nhds_zero_nat T have hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδ have herr : Tendsto err atTop (𝓝 0) := by simpa 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 hh
end SKValue
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424312345678910111213141516171819202122232425262728293031323334353637383940414243import Mathlib
import OAI.Probability.SKValue.Coercivity.LiteralCoercivity
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal
namespace SKValue
lemma 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.μ := by
have 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.μ) := by
apply mul_nonneg (by norm_num)
exact integral_nonneg (fun z ↦ by positivity)
have hn:=hn.trans h
have 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)) := by
funext z
simp only [spatialJet]
ring
change 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 hn
rw [he,integral_const_mul] at hn
exact nonneg_of_mul_nonneg_right hn (sq_pos_of_pos hc)
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Coercivity.LiteralCoercivity
namespace OAI
sectionopen 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.μ := by have 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.μ) := by apply mul_nonneg (by norm_num) exact integral_nonneg (fun z ↦ by positivity) have hn:=hn.trans h have 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)) := by funext z simp only [spatialJet] ring change 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 hn rw [he,integral_const_mul] at hn exact nonneg_of_mul_nonneg_right hn (sq_pos_of_pos hc)end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384import Mathlib
import OAI.Probability.SKValue.Processes.EulerLimitProcess
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter Function
open scoped Topology NNReal
namespace SKValue
noncomputable def terminalEulerProcess (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω):ℝ :=
limsup (fun n:ℕ ↦ eulerLimitProcess W γ (terminalTime n) z) atTop
noncomputable def diffusionProcess (W:BrownianSpace) (γ:OrderParameter) (t:ℝ) (z:W.Ω):ℝ :=
if t<1 then eulerLimitProcess W γ t z else terminalEulerProcess W γ z
lemma terminalEulerProcess_measurable (W:BrownianSpace) (γ:OrderParameter):
StronglyMeasurable[W.filtration 1] (terminalEulerProcess W γ) :=by
apply Measurable.stronglyMeasurable
apply Measurable.limsup
intro n
apply ((eulerLimitProcess_measurable W γ (terminalTime n)).mono ?_).measurable
apply W.filtration.mono
exact Real.toNNReal_le_iff_le_coe.mpr (terminalTime_mem n).2.le
lemma diffusionProcess_measurable (W:BrownianSpace) (γ:OrderParameter) {t:ℝ}:
StronglyMeasurable[W.filtration t.toNNReal] (diffusionProcess W γ t) :=by
change 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) :=by
intro t
apply ((diffusionProcess_measurable W γ (t:=min (t:ℝ) 1)).mono ?_).measurable
apply W.filtration.mono
exact 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) :=by
let 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 s
have hi:IntervalIntegrable f volume 0 1:=eulerLimitProcess_drift_integrable W γ z hb h0
have hc:ContinuousOn F (Icc (0:ℝ) 1):=by
apply hb.continuousOn.add
simpa only [uIcc_of_le (by norm_num:(0:ℝ)≤1)] using
intervalIntegral.continuousOn_primitive_interval' hi left_mem_uIcc
have he:∀t∈Ico (0:ℝ) 1,eulerLimitProcess W γ t z=F t:=by
intro t ht
exact (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)):=by
have 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).congr
intro n
exact (he _ (terminalTime_mem n)).symm
have hU:terminalEulerProcess W γ z=F 1:=hl.limsup_eq
have hEq (t:ℝ) (ht:t∈Icc (0:ℝ) 1):diffusionProcess W γ t z=F t:=by
by_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 t
simpa only [diffusionProcess,lt_self_iff_false,ite_false] using hU
refine ⟨hc.congr hEq,?_⟩
intro t ht
rw [hEq t ht]
change W.B t.toNNReal z+(∫s in (0:ℝ)..t,f s)=_
congr 1
apply intervalIntegral.integral_congr_Ioo_of_le ht.1
intro s hs
simp only [f,diffusionProcess,ite_eq_left (hs.2.trans_le ht.2)]
theorem diffusionProcess_isDiffusion (W:BrownianSpace) (γ:OrderParameter):IsDiffusion W γ (diffusionProcess W γ) :=by
refine ⟨diffusionProcess_adapted W γ,?_⟩
filter_upwards [W.brownian.cont,W.brownian.toIsPreBrownianReal.eval_zero_ae_eq_zero] with z hz h0
exact diffusionProcess_path W γ z (hz.comp (by fun_prop:Continuous (fun t:ℝ ↦ t.toNNReal))) h0
lemma exists_diffusion (W:BrownianSpace) (γ:OrderParameter):∃X:ℝ → W.Ω → ℝ,IsDiffusion W γ X:=
⟨diffusionProcess W γ,diffusionProcess_isDiffusion W γ⟩
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Processes.EulerLimitProcess
namespace OAI
sectionopen 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 γ) :=by apply Measurable.stronglyMeasurable apply Measurable.limsup intro n apply ((eulerLimitProcess_measurable W γ (terminalTime n)).mono ?_).measurable apply W.filtration.mono exact 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) :=by change 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) :=by intro t apply ((diffusionProcess_measurable W γ (t:=min (t:ℝ) 1)).mono ?_).measurable apply W.filtration.mono exact 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) :=by let 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 s have hi:IntervalIntegrable f volume 0 1:=eulerLimitProcess_drift_integrable W γ z hb h0 have hc:ContinuousOn F (Icc (0:ℝ) 1):=by apply hb.continuousOn.add simpa only [uIcc_of_le (by norm_num:(0:ℝ)≤1)] using intervalIntegral.continuousOn_primitive_interval' hi left_mem_uIcc have he:∀t∈Ico (0:ℝ) 1,eulerLimitProcess W γ t z=F t:=by intro t ht exact (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)):=by have 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).congr intro n exact (he _ (terminalTime_mem n)).symm have hU:terminalEulerProcess W γ z=F 1:=hl.limsup_eq have hEq (t:ℝ) (ht:t∈Icc (0:ℝ) 1):diffusionProcess W γ t z=F t:=by by_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 t simpa only [diffusionProcess,lt_self_iff_false,ite_false] using hU refine ⟨hc.congr hEq,?_⟩ intro t ht rw [hEq t ht] change W.B t.toNNReal z+(∫s in (0:ℝ)..t,f s)=_ congr 1 apply intervalIntegral.integral_congr_Ioo_of_le ht.1 intro s hs simp only [f,diffusionProcess,ite_eq_left (hs.2.trans_le ht.2)]theorem diffusionProcess_isDiffusion (W:BrownianSpace) (γ:OrderParameter):IsDiffusion W γ (diffusionProcess W γ) :=by refine ⟨diffusionProcess_adapted W γ,?_⟩ filter_upwards [W.brownian.cont,W.brownian.toIsPreBrownianReal.eval_zero_ae_eq_zero] with z hz h0 exact 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 SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import Mathlib
import OAI.Probability.SKValue.Equations.Shift
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal BigOperators
lemma 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 ω)) := by
let ℱ := Filtration.natural B hBm
by_cases heq : a=b
· subst b
have hh := (h.smooth a ha).continuous.comp_stronglyMeasurable (hXM a ha)
apply condExp_of_aestronglyMeasurable' (ℱ.le _) hh.aestronglyMeasurable
exact 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 heq
have hba : 0<b-a := sub_pos.mpr hlt
have 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 := by
constructor <;> 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|) := by
intro s hs t ht x y
simpa only [add_sub_add_left_eq_sub] using hLip _ (hmem s hs) _ (hmem t ht) x y
have hYM (t : ℝ) (ht : t∈Icc (0 : ℝ) (b-a)) :
StronglyMeasurable[ℱ (a.toNNReal+t.toNNReal)] (Y t) := by
have hh := hXM _ (hmem t ht)
rw [Real.toNNReal_add ha.1 ht.1] at hh
exact hh
have hWM (t : ℝ) (_ht : t∈Icc (0 : ℝ) (b-a)) : AEStronglyMeasurable (W t) μ :=
((((hXM a ha).mono (ℱ.le _)).add (hBm _)).sub (hBm _)).aestronglyMeasurable
have 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) ω := by
intro s _ t _ ω
dsimp [W]
ring
have 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 ω) := by
filter_upwards [hpaths] with ω hω
have hT : 0≤T := ha.1.trans ha.2
have hi := intervalIntegrable_substrip hT hω.2.1 ha hb
refine ⟨hω.1.comp (continuous_const.add continuous_id).continuousOn hmem,?_,?_⟩
· simpa only [sub_self,Y] using hi.comp_add_left a
· intro t ht
have hhalf := intervalIntegrable_substrip hT hω.2.1 ha (hmem t ht)
have hleft := intervalIntegrable_substrip hT hω.2.1 ⟨le_rfl,hT⟩ ha
have hsum := intervalIntegral.integral_add_adjacent_intervals hleft hhalf
dsimp 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]
linarith
have 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 hh
end SKValue
namespace SKValue
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal BigOperators
lemma 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) μ := by
let ℱ := Filtration.natural B hBm
have 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 := by
have hh := Real.toNNReal_mono (min_le_left (t : ℝ) T)
rw [Real.toNNReal_coe] at hh
exact hh
have 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 hst
by_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 hh
simpa only [min_eq_left hs] using hh
· have hs' : T≤(s : ℝ) := (lt_of_not_ge hs).le
have 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 hh
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.Shift
namespace OAI
sectionopen 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 BigOperators
lemma 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 ω)) := by let ℱ := Filtration.natural B hBm by_cases heq : a=b · subst b have hh := (h.smooth a ha).continuous.comp_stronglyMeasurable (hXM a ha) apply condExp_of_aestronglyMeasurable' (ℱ.le _) hh.aestronglyMeasurable exact 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 heq have hba : 0<b-a := sub_pos.mpr hlt have 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 := by constructor <;> 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|) := by intro s hs t ht x y simpa only [add_sub_add_left_eq_sub] using hLip _ (hmem s hs) _ (hmem t ht) x y have hYM (t : ℝ) (ht : t∈Icc (0 : ℝ) (b-a)) : StronglyMeasurable[ℱ (a.toNNReal+t.toNNReal)] (Y t) := by have hh := hXM _ (hmem t ht) rw [Real.toNNReal_add ha.1 ht.1] at hh exact hh have hWM (t : ℝ) (_ht : t∈Icc (0 : ℝ) (b-a)) : AEStronglyMeasurable (W t) μ := ((((hXM a ha).mono (ℱ.le _)).add (hBm _)).sub (hBm _)).aestronglyMeasurable have 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) ω := by intro s _ t _ ω dsimp [W] ring have 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 ω) := by filter_upwards [hpaths] with ω hω have hT : 0≤T := ha.1.trans ha.2 have hi := intervalIntegrable_substrip hT hω.2.1 ha hb refine ⟨hω.1.comp (continuous_const.add continuous_id).continuousOn hmem,?_,?_⟩ · simpa only [sub_self,Y] using hi.comp_add_left a · intro t ht have hhalf := intervalIntegrable_substrip hT hω.2.1 ha (hmem t ht) have hleft := intervalIntegrable_substrip hT hω.2.1 ⟨le_rfl,hT⟩ ha have hsum := intervalIntegral.integral_add_adjacent_intervals hleft hhalf dsimp 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] linarith have 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 hh
end SKValue
namespace SKValueopen MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal BigOperators
lemma 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) μ := by let ℱ := Filtration.natural B hBm have 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 := by have hh := Real.toNNReal_mono (min_le_left (t : ℝ) T) rw [Real.toNNReal_coe] at hh exact hh have 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 hst by_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 hh simpa only [min_eq_left hs] using hh · have hs' : T≤(s : ℝ) := (lt_of_not_ge hs).le have 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 hh
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131import Mathlib
import OAI.Probability.SKValue.Equations.CubicEnvelopeMean
import OAI.Probability.SKValue.Gaussian.ShiftedBrownianCoordinates
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal BigOperators
lemma 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 ω) ∂μ) := by
let ℱ := Filtration.natural B hBm
have hFM : AEStronglyMeasurable F μ := (hFm.mono (ℱ.le a)).aestronglyMeasurable
have hXM' (t : ℝ) (ht : t∈Icc (0 : ℝ) T) : AEStronglyMeasurable (X t) μ :=
((hXM t ht).mono (ℱ.le _)).aestronglyMeasurable
have hsp (t : ℝ) (ht : t∈Icc (0 : ℝ) T) (x y : ℝ) :
|u t x-u t y|≤Lu*|x-y| := by
simpa only [sub_self,abs_zero,zero_add] using hLip t ht t ht x y
have hVi (t : ℝ) (ht : t∈Icc (0 : ℝ) T) : Integrable (fun ω ↦ F ω*u t (X t ω)) μ := by
apply Integrable.of_bound (hFM.mul ((h.smooth t ht).continuous.comp_aestronglyMeasurable (hXM' t ht))) H
filter_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 hFb
have 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 ω) ∂μ) := by
have 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 hj
let τ := fun j : ℕ ↦ a+(meshTime T N j).toNNReal
have hτ (i : Fin N) : τ i≤τ (i+1) := by
dsimp [τ]
apply add_le_add le_rfl
apply Real.toNNReal_mono
dsimp [meshTime]
push_cast
nlinarith
have hτdiff (i : Fin N) : (τ (i+1) : ℝ)-(τ i : ℝ)=stepSize T N := by
dsimp 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_cast
ring
have 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) ω)) μ := by
apply 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 _) hH
have hD2i (i : Fin N) : Integrable
(fun ω ↦ F ω*deriv (deriv (u (meshTime T N i))) (X (meshTime T N i) ω)) μ := by
apply 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 _) hH
apply weighted_pathGradientResidual_integral (hVi T ⟨hT.le,le_rfl⟩) (hVi 0 ⟨le_rfl,hT.le⟩)
· intro i
simpa only [hWeq,mul_assoc] using
brownian_predictable_increment_integrable hB hBm (hτ i) (hDm i) (hDi i)
· intro i
simpa only [hWeq,hτdiff,mul_assoc] using
brownian_predictable_quadratic_integrable hB hBm (hτ i) (hD2m i) (hD2i i)
· intro i
simpa only [hWeq,mul_assoc] using brownian_predictable_increment_mean hB hBm (hτ i) (hDm i)
· intro i
simpa only [hWeq,hτdiff,mul_assoc] using
brownian_predictable_quadratic_mean hB hBm (hτ i) (hD2m i)
have hh : (∫ ω, F ω*u T (X T ω) ∂μ)-(∫ ω, F ω*u 0 (X 0 ω) ∂μ)=0 := by
have hc : Tendsto (fun _ : ℕ ↦ (∫ ω, F ω*u T (X T ω) ∂μ)-
(∫ ω, F ω*u 0 (X 0 ω) ∂μ)) atTop (𝓝 (0 : ℝ)) := by
simpa only [hmean] using hlim
exact tendsto_nhds_unique tendsto_const_nhds hc
exact sub_eq_zero.mp hh
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.CubicEnvelopeMeanimport OAI.Probability.SKValue.Gaussian.ShiftedBrownianCoordinates
namespace OAI
sectionopen 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 BigOperators
lemma 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 ω) ∂μ) := by let ℱ := Filtration.natural B hBm have hFM : AEStronglyMeasurable F μ := (hFm.mono (ℱ.le a)).aestronglyMeasurable have hXM' (t : ℝ) (ht : t∈Icc (0 : ℝ) T) : AEStronglyMeasurable (X t) μ := ((hXM t ht).mono (ℱ.le _)).aestronglyMeasurable have hsp (t : ℝ) (ht : t∈Icc (0 : ℝ) T) (x y : ℝ) : |u t x-u t y|≤Lu*|x-y| := by simpa only [sub_self,abs_zero,zero_add] using hLip t ht t ht x y have hVi (t : ℝ) (ht : t∈Icc (0 : ℝ) T) : Integrable (fun ω ↦ F ω*u t (X t ω)) μ := by apply Integrable.of_bound (hFM.mul ((h.smooth t ht).continuous.comp_aestronglyMeasurable (hXM' t ht))) H filter_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 hFb have 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 ω) ∂μ) := by have 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 hj let τ := fun j : ℕ ↦ a+(meshTime T N j).toNNReal have hτ (i : Fin N) : τ i≤τ (i+1) := by dsimp [τ] apply add_le_add le_rfl apply Real.toNNReal_mono dsimp [meshTime] push_cast nlinarith have hτdiff (i : Fin N) : (τ (i+1) : ℝ)-(τ i : ℝ)=stepSize T N := by dsimp 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_cast ring have 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) ω)) μ := by apply 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 _) hH have hD2i (i : Fin N) : Integrable (fun ω ↦ F ω*deriv (deriv (u (meshTime T N i))) (X (meshTime T N i) ω)) μ := by apply 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 _) hH apply weighted_pathGradientResidual_integral (hVi T ⟨hT.le,le_rfl⟩) (hVi 0 ⟨le_rfl,hT.le⟩) · intro i simpa only [hWeq,mul_assoc] using brownian_predictable_increment_integrable hB hBm (hτ i) (hDm i) (hDi i) · intro i simpa only [hWeq,hτdiff,mul_assoc] using brownian_predictable_quadratic_integrable hB hBm (hτ i) (hD2m i) (hD2i i) · intro i simpa only [hWeq,mul_assoc] using brownian_predictable_increment_mean hB hBm (hτ i) (hDm i) · intro i simpa only [hWeq,hτdiff,mul_assoc] using brownian_predictable_quadratic_mean hB hBm (hτ i) (hD2m i) have hh : (∫ ω, F ω*u T (X T ω) ∂μ)-(∫ ω, F ω*u 0 (X 0 ω) ∂μ)=0 := by have hc : Tendsto (fun _ : ℕ ↦ (∫ ω, F ω*u T (X T ω) ∂μ)- (∫ ω, F ω*u 0 (X 0 ω) ∂μ)) atTop (𝓝 (0 : ℝ)) := by simpa only [hmean] using hlim exact tendsto_nhds_unique tendsto_const_nhds hc exact sub_eq_zero.mp hh
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202import Mathlib
import OAI.Probability.SKValue.Equations.LipschitzCompMemLpFinite
import OAI.Probability.SKValue.Evolution.BoundedSmooth
import OAI.Probability.SKValue.Equations.TestGenerator
import OAI.Probability.SKValue.Processes.TestExpectation
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal BigOperators
namespace SKValue
lemma 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) := by
let δ := stepSize T N
have hδ : 0≤δ := div_nonneg hT (Nat.cast_nonneg _)
have hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simp
have 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) := by
let y := euler T N β v z k
let x := euler T N γ u z k
let t := meshTime T N k
have hb : |β t*v t y-γ t*u t x|≤d k+G*e+G*L*|y-x| := by
calc
|β 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|) := by
simp 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 ring
change |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 ring
have 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 hj
apply h.trans
apply mul_le_mul le_rfl
· apply Real.exp_le_exp.mpr
calc
(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 SKValue
end
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal BigOperators
namespace SKValue
lemma 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)) := by
simpa only [mul_one,stepSize,meshTime] using
monotone_weighted_grid_tendsto (γ:=γ) (f:=fun _ ↦ (1:ℝ)) (K:=1) hT (by norm_num) hm h0
continuousOn_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) := by
have 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_rfl
have 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) := by
simp 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_simp
nlinarith only [congrArg (fun x:ℝ ↦ x*(2*a+G*b)) hNd]
rwa [he] at h
end SKValue
end
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal BigOperators
namespace SKValue
lemma 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) := by
let 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 T
have hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδ
have hE:Tendsto E atTop (𝓝 0) := by
simpa 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) := by
simpa 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) := by
apply LipschitzWith.of_dist_le_mul
intro x y
exact hf x y
have hbound:∀ᶠ N in atTop,|(∫ ω,V T (X T ω) ∂μ)-V 0 0|≤E N+H*D N*Real.exp (T*γ T*Lu)+F N := by
filter_upwards [eventually_gt_atTop 0] with N hN
let 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 hj
have hp:Integrable P (gaussianProduct (Fin (N+1))) := by
apply 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))) := by
apply 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) := by
rw [←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 ↦ by
rw [Real.norm_eq_abs]
apply (hf _ _).trans
have 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) z
simpa only [D,mul_assoc] using mul_le_mul_of_nonneg_left he hH))
simpa only [Real.norm_eq_abs,probReal_univ,mul_one] using hnorm
have he:=h.mesh_expectation hT hT1 hN
have hqX:=coupled_lipschitz_expectation_bound hB hT hu hXM
(hpaths.mono (fun _ hω ↦ hω.2.2)) hN le_rfl hlip
have hend:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simp
rw [hend] at hqX
change |(∫ z,Q z ∂gaussianProduct (Fin (N+1)))-(∫ ω,V T (X T ω) ∂μ)|≤F N at hqX
change |(∫ z,P z ∂gaussianProduct (Fin (N+1)))-V 0 0|≤E N at he
calc
|(∫ ω,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) := by
apply 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 ring
have he:=le_of_tendsto_of_tendsto tendsto_const_nhds
((hE.add ((hD.const_mul H).mul_const (Real.exp (T*γ T*Lu)))).add hF) hbound
simpa only [zero_add,add_zero] using he
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.LipschitzCompMemLpFiniteimport OAI.Probability.SKValue.Evolution.BoundedSmoothimport OAI.Probability.SKValue.Equations.TestGeneratorimport OAI.Probability.SKValue.Processes.TestExpectation
namespace OAI
sectionopen 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) := by let δ := stepSize T N have hδ : 0≤δ := div_nonneg hT (Nat.cast_nonneg _) have hNd : (N : ℝ)*δ=T := by dsimp [δ,stepSize]; field_simp have 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) := by let y := euler T N β v z k let x := euler T N γ u z k let t := meshTime T N k have hb : |β t*v t y-γ t*u t x|≤d k+G*e+G*L*|y-x| := by calc |β 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|) := by simp 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 ring change |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 ring have 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 hj apply h.trans apply mul_le_mul le_rfl · apply Real.exp_le_exp.mpr calc (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 SKValue
end
sectionopen 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)) := by simpa only [mul_one,stepSize,meshTime] using monotone_weighted_grid_tendsto (γ:=γ) (f:=fun _ ↦ (1:ℝ)) (K:=1) hT (by norm_num) hm h0 continuousOn_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) := by have 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_rfl have 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) := by simp 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_simp nlinarith only [congrArg (fun x:ℝ ↦ x*(2*a+G*b)) hNd] rwa [he] at hend SKValue
end
section
open 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) := by let 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 T have hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδ have hE:Tendsto E atTop (𝓝 0) := by simpa 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) := by simpa 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) := by apply LipschitzWith.of_dist_le_mul intro x y exact hf x y have hbound:∀ᶠ N in atTop,|(∫ ω,V T (X T ω) ∂μ)-V 0 0|≤E N+H*D N*Real.exp (T*γ T*Lu)+F N := by filter_upwards [eventually_gt_atTop 0] with N hN let 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 hj have hp:Integrable P (gaussianProduct (Fin (N+1))) := by apply 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))) := by apply 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) := by rw [←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 ↦ by rw [Real.norm_eq_abs] apply (hf _ _).trans have 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) z simpa only [D,mul_assoc] using mul_le_mul_of_nonneg_left he hH)) simpa only [Real.norm_eq_abs,probReal_univ,mul_one] using hnorm have he:=h.mesh_expectation hT hT1 hN have hqX:=coupled_lipschitz_expectation_bound hB hT hu hXM (hpaths.mono (fun _ hω ↦ hω.2.2)) hN le_rfl hlip have hend:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simp rw [hend] at hqX change |(∫ z,Q z ∂gaussianProduct (Fin (N+1)))-(∫ ω,V T (X T ω) ∂μ)|≤F N at hqX change |(∫ z,P z ∂gaussianProduct (Fin (N+1)))-V 0 0|≤E N at he calc |(∫ ω,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) := by apply 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 ring have he:=le_of_tendsto_of_tendsto tendsto_const_nhds ((hE.add ((hD.const_mul H).mul_const (Real.exp (T*γ T*Lu)))).add hF) hbound simpa only [zero_add,add_zero] using heend SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128import Mathlib
import OAI.Probability.SKValue.Processes.Volterra
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter Function
open scoped Topology NNReal
namespace SKValue
noncomputable 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 0
lemma eulerLimitProcess_zero (W:BrownianSpace) (γ:OrderParameter) (z:W.Ω):eulerLimitProcess W γ 0 z=0 :=by
simp [eulerLimitProcess]
lemma eulerLimitProcess_measurable (W:BrownianSpace) (γ:OrderParameter) (t:ℝ):
StronglyMeasurable[W.filtration t.toNNReal] (eulerLimitProcess W γ t) := by
by_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.stronglyMeasurable
apply Measurable.limsup
intro N
by_cases hN:N=0
· subst N
exact measurable_const
have hN':0<N:=Nat.pos_of_ne_zero hN
have 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_rfl
have he:meshTime t N N=t:=by dsimp [meshTime,stepSize];field_simp
rw [he] at hh
exact 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_const
lemma 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 := by
rcases ht.1.eq_or_lt with htz|htz
· subst t
rw [eulerLimitProcess_zero,h0]
have ht1:t<1:=ht.2.trans_lt hT.2
obtain ⟨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.2
have hi':IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (X s)) volume 0 t:=hi.mono_set (by
rw [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)) :=by
apply Metric.tendsto_atTop.mpr
intro ε hε
obtain ⟨N,hN⟩:=eventually_atTop.mp (hv ε hε)
refine ⟨max N 1,?_⟩
intro n hn
have 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_rfl
have hnt:(n:ℝ)*(t/n)=t:=by field_simp
simpa only [hnt,Real.dist_eq] using hh
simpa only [eulerLimitProcess,ite_eq_left (show 0<t ∧ t<1 from ⟨htz,ht1⟩)] using hl.limsup_eq
end SKValue
end
section
open MeasureTheory ProbabilityTheory Set Filter Function
open scoped Topology NNReal
namespace SKValue
lemma 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) :=by
obtain ⟨X,hc,hi,he⟩:=exists_local_diffusion_path W γ hT _ hb.continuousOn
have 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 ht
refine ⟨hc.congr heq,hi.congr (fun s hs ↦ ?_),?_⟩
· rw [uIoc_of_le hT.1] at hs
rw [heq s ⟨hs.1.le,hs.2⟩]
intro t ht
rw [heq t ht,he t ht]
congr 1
apply intervalIntegral.integral_congr
intro s hs
rw [uIcc_of_le ht.1] at hs
dsimp only
rw [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) :=by
intro t ht
obtain ⟨T,htT,hT⟩:=exists_between ht.2
apply (h T ⟨ht.1.trans htT.le,hT⟩ t ⟨ht.1,htT.le⟩).mono_of_mem_nhdsWithin
filter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds htT)] with s hs hsT
exact ⟨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 :=by
have hu:ContinuousOn (fun s ↦ gradient W γ s (eulerLimitProcess W γ s z)) (Ico (0:ℝ) 1):=by
apply continuousOn_preterminal_of_strips
intro T hT
obtain ⟨K,L,Lu,hLu,hG,hLip⟩:=(sourceStripRegularity W γ).core T hT
have hj:ContinuousOn (fun p:ℝ×ℝ ↦ gradient W γ p.1 p.2) {p | p.1∈Icc (0:ℝ) T}:=
derivative_joint_continuous hLu hLip
have hp:ContinuousOn (fun s ↦ (s,eulerLimitProcess W γ s z)) (Icc (0:ℝ) T):=
continuousOn_id.prodMk (eulerLimitProcess_local_path W γ z hb h0 hT).1
exact 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)).mpr
have hm:AEStronglyMeasurable (fun s ↦ gradient W γ s (eulerLimitProcess W γ s z)) (volume.restrict (Ioc (0:ℝ) 1)) :=by
rw [←Measure.restrict_congr_set Ioo_ae_eq_Ioc]
exact (hu.mono Ioo_subset_Ico_self).aestronglyMeasurable measurableSet_Ioo
apply γ.integrable.mul_bdd hm (c:=(1:ℝ))
filter_upwards [ae_restrict_mem measurableSet_Ioc] with s hs
simpa only [Real.norm_eq_abs] using gradient_bound W γ ⟨hs.1.le,hs.2⟩ (eulerLimitProcess W γ s z)
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Processes.Volterra
namespace OAI
sectionopen 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 :=by simp [eulerLimitProcess]lemma eulerLimitProcess_measurable (W:BrownianSpace) (γ:OrderParameter) (t:ℝ): StronglyMeasurable[W.filtration t.toNNReal] (eulerLimitProcess W γ t) := by by_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.stronglyMeasurable apply Measurable.limsup intro N by_cases hN:N=0 · subst N exact measurable_const have hN':0<N:=Nat.pos_of_ne_zero hN have 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_rfl have he:meshTime t N N=t:=by dsimp [meshTime,stepSize];field_simp rw [he] at hh exact 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 := by rcases ht.1.eq_or_lt with htz|htz · subst t rw [eulerLimitProcess_zero,h0] have ht1:t<1:=ht.2.trans_lt hT.2 obtain ⟨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.2 have hi':IntervalIntegrable (fun s ↦ γ.coeff s*gradient W γ s (X s)) volume 0 t:=hi.mono_set (by rw [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)) :=by apply Metric.tendsto_atTop.mpr intro ε hε obtain ⟨N,hN⟩:=eventually_atTop.mp (hv ε hε) refine ⟨max N 1,?_⟩ intro n hn have 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_rfl have hnt:(n:ℝ)*(t/n)=t:=by field_simp simpa only [hnt,Real.dist_eq] using hh simpa only [eulerLimitProcess,ite_eq_left (show 0<t ∧ t<1 from ⟨htz,ht1⟩)] using hl.limsup_eqend SKValue
end
sectionopen 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) :=by obtain ⟨X,hc,hi,he⟩:=exists_local_diffusion_path W γ hT _ hb.continuousOn have 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 ht refine ⟨hc.congr heq,hi.congr (fun s hs ↦ ?_),?_⟩ · rw [uIoc_of_le hT.1] at hs rw [heq s ⟨hs.1.le,hs.2⟩] intro t ht rw [heq t ht,he t ht] congr 1 apply intervalIntegral.integral_congr intro s hs rw [uIcc_of_le ht.1] at hs dsimp only rw [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) :=by intro t ht obtain ⟨T,htT,hT⟩:=exists_between ht.2 apply (h T ⟨ht.1.trans htT.le,hT⟩ t ⟨ht.1,htT.le⟩).mono_of_mem_nhdsWithin filter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds htT)] with s hs hsT exact ⟨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 :=by have hu:ContinuousOn (fun s ↦ gradient W γ s (eulerLimitProcess W γ s z)) (Ico (0:ℝ) 1):=by apply continuousOn_preterminal_of_strips intro T hT obtain ⟨K,L,Lu,hLu,hG,hLip⟩:=(sourceStripRegularity W γ).core T hT have hj:ContinuousOn (fun p:ℝ×ℝ ↦ gradient W γ p.1 p.2) {p | p.1∈Icc (0:ℝ) T}:= derivative_joint_continuous hLu hLip have hp:ContinuousOn (fun s ↦ (s,eulerLimitProcess W γ s z)) (Icc (0:ℝ) T):= continuousOn_id.prodMk (eulerLimitProcess_local_path W γ z hb h0 hT).1 exact 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)).mpr have hm:AEStronglyMeasurable (fun s ↦ gradient W γ s (eulerLimitProcess W γ s z)) (volume.restrict (Ioc (0:ℝ) 1)) :=by rw [←Measure.restrict_congr_set Ioo_ae_eq_Ioc] exact (hu.mono Ioo_subset_Ico_self).aestronglyMeasurable measurableSet_Ioo apply γ.integrable.mul_bdd hm (c:=(1:ℝ)) filter_upwards [ae_restrict_mem measurableSet_Ioc] with s hs simpa only [Real.norm_eq_abs] using gradient_bound W γ ⟨hs.1.le,hs.2⟩ (eulerLimitProcess W γ s z)end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151import Mathlib
import OAI.Probability.SKValue.Equations.RawIncrement
import OAI.Probability.SKValue.Equations.ValueStrip
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
lemma 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))) := by
intro j
induction j with
| zero => intro _; exact memLp_const (0 : ℝ)
| succ j ih =>
intro hj
have hlt : j<N := by omega
have 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) := by
apply lipschitzWith_of_nnnorm_deriv_le ((h.smooth t ht).differentiable (by norm_num))
intro x
exact_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 μ := by
have hl : LipschitzWith 1 (fun x ↦ V t x - V t 0) := by
rw [lipschitzWith_iff_dist_le_mul]
intro x y
simpa only [dist_sub_right] using (h.value_lipschitz ht).dist_le_mul x y
have hh := hl.comp_memLp (by simp) hY
convert hh.add (memLp_const (V t 0)) using 1
funext ω
simp
lemma 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) := by
let u := fun t ↦ deriv (V t)
let Y := euler T N γ u
let μ := 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 z
let R (z : Fin (N+1) → ℝ) := valueMeshCompensated T N γ V N z-V 0 0-M z
have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hj
have 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 hj
have 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 u
have 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 hAM
have hMv : (∫ z, M z ∂μ)=0 := by
have 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 (by
filter_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 ∂μ from
integral_finsetSum _ (fun i _ ↦ hMi i)]
have he (i : Fin N) : (∫ z, Real.sqrt (stepSize T N)*A i z*coordinate N i z ∂μ)=0 := by
simp only [mul_assoc]
rw [integral_const_mul]
change Real.sqrt (stepSize T N)*(∫ z, rawIncrement (A i) i z ∂μ)=0
rw [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 μ := by
apply memLp_finsetSum
intro j hj
have hjN : j<N := Finset.mem_range.mp hj
apply MemLp.const_mul
apply MemLp.of_bound (((huc j hjN.le).measurable.comp (hY j hjN.le)).pow_const 2).aestronglyMeasurable 1
filter_upwards [] with z
rw [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_rfl
have hVM := h.value_memLp (t := T) ⟨hT.le,le_rfl⟩ hYM
have hlast : meshTime T N N=T := by
dsimp only [meshTime, stepSize]
have hn : (N : ℝ)≠0 := by exact_mod_cast Nat.ne_of_gt hN
field_simp
have hRM : MemLp R 2 μ := by
dsimp only [R,valueMeshCompensated]
rw [hlast]
exact ((hVM.sub hEm).sub (memLp_const (V 0 0))).sub hMm
have hRint : (∫ z, R z ∂μ)=
(∫ z, V T (Y z N) ∂μ)-V 0 0-(∫ z, valueMeshEnergy T N γ V N z ∂μ) := by
dsimp 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]
ring
rw [←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) := by
apply squeeze_zero_norm' (a := fun N ↦ Real.sqrt (valueMeshError T N γ V))
· filter_upwards [eventually_gt_atTop 0] with N hN
simpa 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 SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.RawIncrementimport OAI.Probability.SKValue.Equations.ValueStrip
namespace OAI
sectionopen 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 BigOperators
lemma 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))) := by intro j induction j with | zero => intro _; exact memLp_const (0 : ℝ) | succ j ih => intro hj have hlt : j<N := by omega have 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) := by apply lipschitzWith_of_nnnorm_deriv_le ((h.smooth t ht).differentiable (by norm_num)) intro x exact_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 μ := by have hl : LipschitzWith 1 (fun x ↦ V t x - V t 0) := by rw [lipschitzWith_iff_dist_le_mul] intro x y simpa only [dist_sub_right] using (h.value_lipschitz ht).dist_le_mul x y have hh := hl.comp_memLp (by simp) hY convert hh.add (memLp_const (V t 0)) using 1 funext ω simp
lemma 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) := by let u := fun t ↦ deriv (V t) let Y := euler T N γ u let μ := 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 z let R (z : Fin (N+1) → ℝ) := valueMeshCompensated T N γ V N z-V 0 0-M z have htime (j : ℕ) (hj : j≤N) := mesh_time_mem hT.le hN hj have 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 hj have 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 u have 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 hAM have hMv : (∫ z, M z ∂μ)=0 := by have 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 (by filter_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 ∂μ from integral_finsetSum _ (fun i _ ↦ hMi i)] have he (i : Fin N) : (∫ z, Real.sqrt (stepSize T N)*A i z*coordinate N i z ∂μ)=0 := by simp only [mul_assoc] rw [integral_const_mul] change Real.sqrt (stepSize T N)*(∫ z, rawIncrement (A i) i z ∂μ)=0 rw [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 μ := by apply memLp_finsetSum intro j hj have hjN : j<N := Finset.mem_range.mp hj apply MemLp.const_mul apply MemLp.of_bound (((huc j hjN.le).measurable.comp (hY j hjN.le)).pow_const 2).aestronglyMeasurable 1 filter_upwards [] with z rw [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_rfl have hVM := h.value_memLp (t := T) ⟨hT.le,le_rfl⟩ hYM have hlast : meshTime T N N=T := by dsimp only [meshTime, stepSize] have hn : (N : ℝ)≠0 := by exact_mod_cast Nat.ne_of_gt hN field_simp have hRM : MemLp R 2 μ := by dsimp only [R,valueMeshCompensated] rw [hlast] exact ((hVM.sub hEm).sub (memLp_const (V 0 0))).sub hMm have hRint : (∫ z, R z ∂μ)= (∫ z, V T (Y z N) ∂μ)-V 0 0-(∫ z, valueMeshEnergy T N γ V N z ∂μ) := by dsimp 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] ring rw [←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) := by apply squeeze_zero_norm' (a := fun N ↦ Real.sqrt (valueMeshError T N γ V)) · filter_upwards [eventually_gt_atTop 0] with N hN simpa 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 SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299import Mathlib
import OAI.Probability.SKValue.Gaussian.CoupledCoordinates
import OAI.Probability.SKValue.Equations.ValueStrip
import OAI.Probability.SKValue.Equations.CubicEnvelopeMean
import OAI.Probability.SKValue.Control.Controls
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal ENNReal BigOperators
namespace SKValue
noncomputable 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 0
lemma 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) := by
intro t
by_cases hat : Real.toNNReal a ≤ t
· let : MeasurableSpace Ω := f t
have hHm : Measurable H := hH.mono (f.mono hat) le_rfl
exact (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 : ℝ) := by
funext p
apply ite_eq_right
intro hp
exact hat ((Real.toNNReal_le_iff_le_coe).2 (hp.1.le.trans (by exact_mod_cast p.1.2)))
rw [he]
exact measurable_const
lemma 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) := by
apply IsProgressive.finsetSum
intro 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 := by
have 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 := by
intro a b hab
exact mul_le_mul_of_nonneg_right (by exact_mod_cast hab) hδ
apply Fin.ext
by_contra he
rcases lt_or_gt_of_ne he with hij | hji
· have hh := hlt i j hij
linarith [hi.2,hj.1]
· have hh := hlt j i hji
linarith [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 ω := by
unfold meshControl
rw [Finset.sum_eq_single j]
· simp only [ite_eq_left ht]
· intro i _ hij
exact ite_eq_right (fun hi ↦ hij (mesh_intervals_disjoint hT hi ht))
· simp
lemma meshControl_bound {Ω : Type*} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} (H : Fin N → Ω → ℝ)
(hH : ∀ j ω, |H j ω| ≤ 1) (t : ℝ≥0) (ω : Ω) : |meshControl T N H t ω| ≤ 1 := by
by_cases he : ∃ j : Fin N, meshTime T N j < t ∧ (t : ℝ) ≤ meshTime T N (j+1)
· obtain ⟨j,hj⟩ := he
rw [meshControl_eq hT H hj]
exact hH j ω
· have hh : meshControl T N H t ω=0 := by
unfold meshControl
apply Finset.sum_eq_zero
intro j _
exact ite_eq_right (fun hj ↦ he ⟨j,hj⟩)
rw [hh]
norm_num
lemma 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 := by
have hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg N)
have htime (j : ℕ) (hj : j ≤ N) := mesh_time_mem_total hT hj
have horder (j : ℕ) : meshTime T N j ≤ meshTime T N (j+1) := by
dsimp [meshTime]
exact mul_le_mul_of_nonneg_right (by exact_mod_cast Nat.le_succ j) hδ
have hlast : meshTime T N N=T := by
dsimp [meshTime,stepSize]
field_simp
have 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) := by
filter_upwards [ae_restrict_mem measurableSet_uIoc] with s hs
rw [uIoc_of_le (horder j)] at hs
have hs0 : 0 ≤ s := (htime j j.isLt.le).1.trans hs.1.le
rw [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)) := by
apply ((intervalIntegrable_substrip hT hγ (htime j hj.le)
(htime (j+1) hj)).mul_const ((H ⟨j,hj⟩ ω)^k)).congr_ae
exact (he ⟨j,hj⟩).symm
have hs := intervalIntegral.sum_integral_adjacent_intervals hi
rw [hlast,show meshTime T N 0=0 by simp [meshTime]] at hs
rw [controlAccum,←hs,←Fin.sum_univ_eq_sum_range]
apply Finset.sum_congr rfl
intro 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) := by
have hi : IntervalIntegrable γ volume a b := by
apply MonotoneOn.intervalIntegrable
simpa only [uIcc_of_le hab] using hγ
have hdiff : (∫ s in a..b, γ s)-(b-a)*γ a =∫ s in a..b, γ s-γ a := by
rw [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 ↦ by
rw [uIoc_of_le hab] at hs
have 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 hh
lemma 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) := by
have hi : IntervalIntegrable γ volume 0 T := by
apply MonotoneOn.intervalIntegrable
simpa 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 hj
have hgap (j : ℕ) : meshTime T N (j+1)-meshTime T N j=stepSize T N := by
dsimp [meshTime]
push_cast
ring
have horder (j : ℕ) : meshTime T N j ≤ meshTime T N (j+1) := by
linarith [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)) := by
rw [←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 hh
have hp : |(H j ω)^k| ≤ 1 := by
rw [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)
_ = _ := by
rw [←Finset.mul_sum, sum_steps_sub (fun j ↦ γ (meshTime T N j))]
have hlast : meshTime T N N=T := by
dsimp [meshTime,stepSize]
field_simp
change 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) := by
let f := Filtration.natural B hBm
intro j
induction j with
| zero =>
intro _
convert (stronglyMeasurable_const : StronglyMeasurable[f (Real.toNNReal (meshTime T N 0))] (fun _ : Ω ↦ (0 : ℝ))) using 1
funext ω
exact coupled_euler_zero T γ u B N ω
| succ j ih =>
intro hjN
have hj : j<N := hjN
have 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)) := by
apply Real.toNNReal_mono
apply mul_le_mul_of_nonneg_right _ hδ
exact_mod_cast Nat.le_succ j
have 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 1
funext ω
rw [coupled_euler_step B hT γ u hN hj ω]
rfl
lemma 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 ω) := by
have 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 ω) := by
rw [coupled_euler_step B hT γ u hN j.isLt ω]
dsimp [meshTime,stepSize]
ring
have 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 hh
have hlast : meshTime T N N=T := by dsimp [meshTime,stepSize]; field_simp
simpa only [sub_zero,hlast,show meshTime T N 0=0 by simp [meshTime],Real.toNNReal_zero] using hh
noncomputable 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) := by
apply meshControl_progressive hT.le
intro j
have 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).measurable
lemma 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) := by
have 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 hh
lemma 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) := by
have 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 := by
rw [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 rfl
intro j _
ring
rw [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 SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Gaussian.CoupledCoordinatesimport OAI.Probability.SKValue.Equations.ValueStripimport OAI.Probability.SKValue.Equations.CubicEnvelopeMeanimport OAI.Probability.SKValue.Control.Controls
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filteropen scoped Topology NNReal ENNReal BigOperatorsnamespace SKValue
noncomputable 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 0
lemma 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) := by intro t by_cases hat : Real.toNNReal a ≤ t · let : MeasurableSpace Ω := f t have hHm : Measurable H := hH.mono (f.mono hat) le_rfl exact (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 : ℝ) := by funext p apply ite_eq_right intro hp exact hat ((Real.toNNReal_le_iff_le_coe).2 (hp.1.le.trans (by exact_mod_cast p.1.2))) rw [he] exact measurable_const
lemma 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) := by apply IsProgressive.finsetSum intro 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 := by have 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 := by intro a b hab exact mul_le_mul_of_nonneg_right (by exact_mod_cast hab) hδ apply Fin.ext by_contra he rcases lt_or_gt_of_ne he with hij | hji · have hh := hlt i j hij linarith [hi.2,hj.1] · have hh := hlt j i hji linarith [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 ω := by unfold meshControl rw [Finset.sum_eq_single j] · simp only [ite_eq_left ht] · intro i _ hij exact ite_eq_right (fun hi ↦ hij (mesh_intervals_disjoint hT hi ht)) · simp
lemma meshControl_bound {Ω : Type*} {T : ℝ} (hT : 0 ≤ T) {N : ℕ} (H : Fin N → Ω → ℝ) (hH : ∀ j ω, |H j ω| ≤ 1) (t : ℝ≥0) (ω : Ω) : |meshControl T N H t ω| ≤ 1 := by by_cases he : ∃ j : Fin N, meshTime T N j < t ∧ (t : ℝ) ≤ meshTime T N (j+1) · obtain ⟨j,hj⟩ := he rw [meshControl_eq hT H hj] exact hH j ω · have hh : meshControl T N H t ω=0 := by unfold meshControl apply Finset.sum_eq_zero intro j _ exact ite_eq_right (fun hj ↦ he ⟨j,hj⟩) rw [hh] norm_num
lemma 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 := by have hδ : 0 ≤ stepSize T N := div_nonneg hT (Nat.cast_nonneg N) have htime (j : ℕ) (hj : j ≤ N) := mesh_time_mem_total hT hj have horder (j : ℕ) : meshTime T N j ≤ meshTime T N (j+1) := by dsimp [meshTime] exact mul_le_mul_of_nonneg_right (by exact_mod_cast Nat.le_succ j) hδ have hlast : meshTime T N N=T := by dsimp [meshTime,stepSize] field_simp have 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) := by filter_upwards [ae_restrict_mem measurableSet_uIoc] with s hs rw [uIoc_of_le (horder j)] at hs have hs0 : 0 ≤ s := (htime j j.isLt.le).1.trans hs.1.le rw [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)) := by apply ((intervalIntegrable_substrip hT hγ (htime j hj.le) (htime (j+1) hj)).mul_const ((H ⟨j,hj⟩ ω)^k)).congr_ae exact (he ⟨j,hj⟩).symm have hs := intervalIntegral.sum_integral_adjacent_intervals hi rw [hlast,show meshTime T N 0=0 by simp [meshTime]] at hs rw [controlAccum,←hs,←Fin.sum_univ_eq_sum_range] apply Finset.sum_congr rfl intro 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) := by have hi : IntervalIntegrable γ volume a b := by apply MonotoneOn.intervalIntegrable simpa only [uIcc_of_le hab] using hγ have hdiff : (∫ s in a..b, γ s)-(b-a)*γ a =∫ s in a..b, γ s-γ a := by rw [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 ↦ by rw [uIoc_of_le hab] at hs have 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 hh
lemma 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) := by have hi : IntervalIntegrable γ volume 0 T := by apply MonotoneOn.intervalIntegrable simpa 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 hj have hgap (j : ℕ) : meshTime T N (j+1)-meshTime T N j=stepSize T N := by dsimp [meshTime] push_cast ring have horder (j : ℕ) : meshTime T N j ≤ meshTime T N (j+1) := by linarith [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)) := by rw [←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 hh have hp : |(H j ω)^k| ≤ 1 := by rw [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) _ = _ := by rw [←Finset.mul_sum, sum_steps_sub (fun j ↦ γ (meshTime T N j))] have hlast : meshTime T N N=T := by dsimp [meshTime,stepSize] field_simp change 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) := by let f := Filtration.natural B hBm intro j induction j with | zero => intro _ convert (stronglyMeasurable_const : StronglyMeasurable[f (Real.toNNReal (meshTime T N 0))] (fun _ : Ω ↦ (0 : ℝ))) using 1 funext ω exact coupled_euler_zero T γ u B N ω | succ j ih => intro hjN have hj : j<N := hjN have 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)) := by apply Real.toNNReal_mono apply mul_le_mul_of_nonneg_right _ hδ exact_mod_cast Nat.le_succ j have 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 1 funext ω rw [coupled_euler_step B hT γ u hN hj ω] rfl
lemma 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 ω) := by have 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 ω) := by rw [coupled_euler_step B hT γ u hN j.isLt ω] dsimp [meshTime,stepSize] ring have 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 hh have hlast : meshTime T N N=T := by dsimp [meshTime,stepSize]; field_simp simpa only [sub_zero,hlast,show meshTime T N 0=0 by simp [meshTime],Real.toNNReal_zero] using hh
noncomputable 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) := by apply meshControl_progressive hT.le intro j have 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).measurable
lemma 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) := by have 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 hh
lemma 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) := by have 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 := by rw [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 rfl intro j _ ring rw [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 SKValue
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545512345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import Mathlib
import OAI.Probability.SKValue.Evolution.MeanDerivativeContinuous
import OAI.Probability.SKValue.Processes.StripPaths
import OAI.Probability.SKValue.Equations.LiteralNormalizer
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
lemma 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.μ)) := by
have hh := finiteGaussian_from_diffusion W.brownian.toIsPreBrownianReal hT hT1.le hg
hD 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)) hmom
constructor
· simpa only [literal_normalizer] using hh.1
· apply hh.2.congr'
exact Eventually.of_forall (fun N ↦ (literal_shiftedCoefficientSum W γ T N).symm)
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Evolution.MeanDerivativeContinuousimport OAI.Probability.SKValue.Processes.StripPathsimport OAI.Probability.SKValue.Equations.LiteralNormalizer
namespace OAI
sectionopen 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
lemma 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.μ)) := by have hh := finiteGaussian_from_diffusion W.brownian.toIsPreBrownianReal hT hT1.le hg hD 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)) hmom constructor · simpa only [literal_normalizer] using hh.1 · apply hh.2.congr' exact Eventually.of_forall (fun N ↦ (literal_shiftedCoefficientSum W γ T N).symm)
end SKValue
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394012345678910111213141516171819202122232425262728293031323334353637383940import Mathlib
import OAI.Probability.SKValue.Processes.TestDiffusion
import OAI.Probability.SKValue.Equations.TestPatch
import OAI.Probability.SKValue.Evolution.TestStrip
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal
namespace SKValue
lemma 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 := by
have hA := hψ.profile_evolution l
have hV := hψ.linear_profile hf l
obtain ⟨K,L,hu⟩ := hψ.profile_gradient_strip heven hl
obtain ⟨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 0
have 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|) := by
intro s hs t ht x y
simpa only [iteratedDeriv_zero] using hLip s hs t ht y x
have he := hv.diffusion_expectation hB hT hT1 hu hLu hLip' hXM hpaths
rwa [profileResponse_terminal] at he
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Processes.TestDiffusionimport OAI.Probability.SKValue.Equations.TestPatchimport OAI.Probability.SKValue.Evolution.TestStrip
namespace OAI
section
open 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 := by have hA := hψ.profile_evolution l have hV := hψ.linear_profile hf l obtain ⟨K,L,hu⟩ := hψ.profile_gradient_strip heven hl obtain ⟨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 0 have 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|) := by intro s hs t ht x y simpa only [iteratedDeriv_zero] using hLip s hs t ht y x have he := hv.diffusion_expectation hB hT hT1 hu hLu hLip' hXM hpaths rwa [profileResponse_terminal] at heend SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import Mathlib
import OAI.Probability.SKValue.Equations.ForcedGenerator
import OAI.Probability.SKValue.Processes.ForcedExpectation
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal BigOperators
namespace SKValue
lemma 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 := by
let 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 T
have hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδ
have hE:Tendsto E atTop (𝓝 0) := by
simpa 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) := by
simpa 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 := by
filter_upwards [eventually_gt_atTop 0] with N hN
have he := h.mesh_expectation hT hT1 hN
have hf := h.coupled_terminal_error hB hT hu hXM
(by filter_upwards [hpaths] with ω hω using hω.2.2) hN
have ht := abs_sub_le ((∫ ω,V T (X T ω) ∂μ)-V 0 0-S N) (A N-V 0 0-S N) 0
change |A N-V 0 0-S N|≤E N at he
change |A N-(∫ ω,V T (X T ω) ∂μ)|≤F N at hf
have hf' : |(∫ ω,V T (X T ω) ∂μ)-A N|≤F N := by
rw [abs_sub_comm];exact hf
have hid:((∫ ω,V T (X T ω) ∂μ)-V 0 0-S N)-(A N-V 0 0-S N)=
(∫ ω,V T (X T ω) ∂μ)-A N := by ring
rw [hid,sub_zero,sub_zero] at ht
linarith
have 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).abs
have hz := le_of_tendsto_of_tendsto hleft (hE.add hF) hbound
have habs:|(∫ ω,V T (X T ω) ∂μ)-V 0 0-I|=0 := le_antisymm (by simpa using hz) (abs_nonneg _)
have he := abs_eq_zero.mp habs
linarith
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.ForcedGeneratorimport OAI.Probability.SKValue.Processes.ForcedExpectation
namespace OAI
section
open 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 := by let 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 T have hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδ have hE:Tendsto E atTop (𝓝 0) := by simpa 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) := by simpa 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 := by filter_upwards [eventually_gt_atTop 0] with N hN have he := h.mesh_expectation hT hT1 hN have hf := h.coupled_terminal_error hB hT hu hXM (by filter_upwards [hpaths] with ω hω using hω.2.2) hN have ht := abs_sub_le ((∫ ω,V T (X T ω) ∂μ)-V 0 0-S N) (A N-V 0 0-S N) 0 change |A N-V 0 0-S N|≤E N at he change |A N-(∫ ω,V T (X T ω) ∂μ)|≤F N at hf have hf' : |(∫ ω,V T (X T ω) ∂μ)-A N|≤F N := by rw [abs_sub_comm];exact hf have hid:((∫ ω,V T (X T ω) ∂μ)-V 0 0-S N)-(A N-V 0 0-S N)= (∫ ω,V T (X T ω) ∂μ)-A N := by ring rw [hid,sub_zero,sub_zero] at ht linarith have 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).abs have hz := le_of_tendsto_of_tendsto hleft (hE.add hF) hbound have habs:|(∫ ω,V T (X T ω) ∂μ)-V 0 0-I|=0 := le_antisymm (by simpa using hz) (abs_nonneg _) have he := abs_eq_zero.mp habs linarithend SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202import Mathlib
import OAI.Probability.SKValue.Processes.CrossMesh
import OAI.Probability.SKValue.Control.Forced
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators NNReal
namespace SKValue
lemma 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) := by
let μ := 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 z
let 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 z
let R := fun z ↦ D z-P z-Q z
let 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 hYm
have ham:Measurable a := by
have hh := (h.smooth t htm).continuous_iteratedDeriv 2 (by norm_num)
simp only [show (2:ℕ)=1+1 from rfl,iteratedDeriv_succ] at hh
exact hh.measurable.comp hYm
have 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 := by
dsimp only [P]
rw [integral_const_mul,rawIncrement_mean hj hpm hpp,mul_zero]
have hQ0:(∫ z,Q z ∂μ)=0 := by
dsimp 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 hQi
have 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 := by
have hh := h.euler_one_step ht hδ hδ1 htδ (x:=Y z) (z:=coordinate N j z)
convert! hh using 1
dsimp only [R,D,P,Q,p,a,Y',S,E,rawIncrement]
congr 1
ring_nf
have hRmean:(∫ z,R z ∂μ)=(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)-δ*(∫ z,S z ∂μ) := by
have hs := integral_sub (hDi.sub hPi) hQi
change (∫ z,D z-P z-Q z ∂μ)=(∫ z,D z-P z ∂μ)-(∫ z,Q z ∂μ) at hs
have hs1 := integral_sub hDi hPi
change (∫ z,D z-P z ∂μ)=(∫ z,D z ∂μ)-(∫ z,P z ∂μ) at hs1
change (∫ 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 hs2
dsimp 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) := by
dsimp 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) := by
simpa only [Function.comp_def,cubicEnvelopeMean,standardGaussian] using
(coordinate_hasLaw N j).integral_comp (measurable_cubicEnvelope (γ T) K ((1/2+γ T)*L)).aestronglyMeasurable
rw [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 SKValue
end
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators NNReal
namespace SKValue
lemma 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) := by
let δ := stepSize T N
let 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 hN
have hδ:0≤δ := div_nonneg hT.le hNr.le
have hδ1:δ≤1 := by
apply (div_le_iff₀ hNr).mpr
have hn:(1:ℝ)≤N := by exact_mod_cast hN
simpa only [one_mul] using hT1.trans hn
have htime (j:ℕ) (hj:j≤N) := mesh_time_mem hT.le hN hj
have hs (j:ℕ) : meshTime T N j+δ=meshTime T N (j+1) := by dsimp [meshTime];push_cast;ring
have hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simp
have 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) := by
have 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) hYp
dsimp only at he
rw [hs] at he
simpa only [A,S,euler,δ,mul_assoc,add_zero,sub_self,mul_zero,sub_eq_add_neg,neg_mul] using he
have hh := abs_telescope_source (A:=A) (b:=fun j ↦ -δ*S j) (Γ:=fun j ↦ γ (meshTime T N j))
(Δ:=fun _ ↦ 0) (e:=0) hstep
have 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))) by
dsimp only [A];rw [hlast],hlast,hzero] at hh
have hNd:(N:ℝ)*δ=T := by dsimp [δ,stepSize];field_simp
simpa 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 hh
lemma 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| := by
have 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⟩ z
have hl : LipschitzWith ⟨K,h.K_nonneg⟩ (V T) := by
apply lipschitzWith_of_nnnorm_deriv_le hd
intro z
exact_mod_cast hb z
have hh := hl.dist_le_mul x y
change |V T x-V T y|≤K*|x-y| at hh
exact hh
lemma 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 ∂μ) := by
let 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) N
have ht:T∈Icc (0:ℝ) T := ⟨hT.le,le_rfl⟩
have hm:Continuous (V T) := (h.smooth T ht).continuous
have 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 hN
have hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simp
have hFG (ω:Ω) : |F ω-G ω|≤K'*|E ω| := by
have he:|coupledEuler T γ u B N N ω-X T ω|≤E ω := by
have 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 hh
rwa [hlast] at hh
exact (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 ω ∂μ) := by
have heum := measurable_euler T N γ u (fun j hj ↦ (hu.smooth _ (mesh_time_mem hT.le hN hj.le)).continuous.measurable) N le_rfl
have hh := (coupledCoordinates_hasLaw hB hT hN).integral_comp (hm.measurable.comp heum).aestronglyMeasurable
simpa only [Function.comp_apply,F,coupledEuler,ite_eq_right (Nat.ne_of_gt hN)] using hh.symm
rw [heq]
exact first_moment_perturbation hFM hGM hEM h.K_nonneg (Eventually.of_forall hFG)
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshimport OAI.Probability.SKValue.Control.Forced
namespace OAI
section
open 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) := by let μ := 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 z let 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 z let R := fun z ↦ D z-P z-Q z let 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 hYm have ham:Measurable a := by have hh := (h.smooth t htm).continuous_iteratedDeriv 2 (by norm_num) simp only [show (2:ℕ)=1+1 from rfl,iteratedDeriv_succ] at hh exact hh.measurable.comp hYm have 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 := by dsimp only [P] rw [integral_const_mul,rawIncrement_mean hj hpm hpp,mul_zero] have hQ0:(∫ z,Q z ∂μ)=0 := by dsimp 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 hQi have 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 := by have hh := h.euler_one_step ht hδ hδ1 htδ (x:=Y z) (z:=coordinate N j z) convert! hh using 1 dsimp only [R,D,P,Q,p,a,Y',S,E,rawIncrement] congr 1 ring_nf have hRmean:(∫ z,R z ∂μ)=(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ)-δ*(∫ z,S z ∂μ) := by have hs := integral_sub (hDi.sub hPi) hQi change (∫ z,D z-P z-Q z ∂μ)=(∫ z,D z-P z ∂μ)-(∫ z,Q z ∂μ) at hs have hs1 := integral_sub hDi hPi change (∫ z,D z-P z ∂μ)=(∫ z,D z ∂μ)-(∫ z,P z ∂μ) at hs1 change (∫ 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 hs2 dsimp 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) := by dsimp 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) := by simpa only [Function.comp_def,cubicEnvelopeMean,standardGaussian] using (coordinate_hasLaw N j).integral_comp (measurable_cubicEnvelope (γ T) K ((1/2+γ T)*L)).aestronglyMeasurable rw [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 SKValue
end
section
open 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) := by let δ := stepSize T N let 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 hN have hδ:0≤δ := div_nonneg hT.le hNr.le have hδ1:δ≤1 := by apply (div_le_iff₀ hNr).mpr have hn:(1:ℝ)≤N := by exact_mod_cast hN simpa only [one_mul] using hT1.trans hn have htime (j:ℕ) (hj:j≤N) := mesh_time_mem hT.le hN hj have hs (j:ℕ) : meshTime T N j+δ=meshTime T N (j+1) := by dsimp [meshTime];push_cast;ring have hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simp have 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) := by have 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) hYp dsimp only at he rw [hs] at he simpa only [A,S,euler,δ,mul_assoc,add_zero,sub_self,mul_zero,sub_eq_add_neg,neg_mul] using he have hh := abs_telescope_source (A:=A) (b:=fun j ↦ -δ*S j) (Γ:=fun j ↦ γ (meshTime T N j)) (Δ:=fun _ ↦ 0) (e:=0) hstep have 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))) by dsimp only [A];rw [hlast],hlast,hzero] at hh have hNd:(N:ℝ)*δ=T := by dsimp [δ,stepSize];field_simp simpa 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 hh
lemma 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| := by have 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⟩ z have hl : LipschitzWith ⟨K,h.K_nonneg⟩ (V T) := by apply lipschitzWith_of_nnnorm_deriv_le hd intro z exact_mod_cast hb z have hh := hl.dist_le_mul x y change |V T x-V T y|≤K*|x-y| at hh exact hh
lemma 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 ∂μ) := by let 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) N have ht:T∈Icc (0:ℝ) T := ⟨hT.le,le_rfl⟩ have hm:Continuous (V T) := (h.smooth T ht).continuous have 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 hN have hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simp have hFG (ω:Ω) : |F ω-G ω|≤K'*|E ω| := by have he:|coupledEuler T γ u B N N ω-X T ω|≤E ω := by have 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 hh rwa [hlast] at hh exact (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 ω ∂μ) := by have heum := measurable_euler T N γ u (fun j hj ↦ (hu.smooth _ (mesh_time_mem hT.le hN hj.le)).continuous.measurable) N le_rfl have hh := (coupledCoordinates_hasLaw hB hT hN).integral_comp (hm.measurable.comp heum).aestronglyMeasurable simpa only [Function.comp_apply,F,coupledEuler,ite_eq_right (Nat.ne_of_gt hN)] using hh.symm rw [heq] exact first_moment_perturbation hFM hGM hEM h.K_nonneg (Eventually.of_forall hFG)end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596import Mathlib
import OAI.Probability.SKValue.Control.StripRegularity
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal
lemma 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.μ := by
obtain ⟨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 hG
hD 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) := by
intro t ht
obtain ⟨T,htT,hT1⟩ := exists_between ht.2
obtain ⟨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_nhdsWithin
filter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds htT)] with s hs hsT
exact ⟨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 := by
have hint (t : ℝ) (ht : t∈Ioo (0 : ℝ) 1) : f t=1 := by
have hf : IntervalIntegrable f volume 0 t := by
apply ContinuousOn.intervalIntegrable
rw [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.2
have 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 : ℝ → ℝ) := by
filter_upwards [Ioo_mem_nhds ht.1 ht.2] with s hs
exact hi s hs
exact hd.unique ((hasDerivAt_id t).congr_of_eventuallyEq he)
intro t ht
obtain h0|h0 := ht.1.eq_or_lt
· subst t
have hlim : Tendsto f (𝓝[>] (0 : ℝ)) (𝓝 (f 0)) := by
apply (hc 0 (by norm_num)).mono_left
apply le_inf nhdsWithin_le_nhds
apply le_principal_iff.mpr
filter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds (by norm_num : (0 : ℝ)<1))] with s hs hs1
exact ⟨hs.le,hs1⟩
apply tendsto_nhds_unique hlim
apply 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 hs1
exact (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 := by
apply continuous_eq_one_of_primitive (hX.curvature_square_mean_continuous hreg)
intro t ht
rw [←hX.gradient_square_integral hreg ht.1 ht.2,hmom t ⟨ht.1.le,ht.2⟩]
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Control.StripRegularity
namespace OAI
sectionopen 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
lemma 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.μ := by obtain ⟨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 hG hD 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) := by intro t ht obtain ⟨T,htT,hT1⟩ := exists_between ht.2 obtain ⟨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_nhdsWithin filter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds htT)] with s hs hsT exact ⟨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 := by have hint (t : ℝ) (ht : t∈Ioo (0 : ℝ) 1) : f t=1 := by have hf : IntervalIntegrable f volume 0 t := by apply ContinuousOn.intervalIntegrable rw [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.2 have 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 : ℝ → ℝ) := by filter_upwards [Ioo_mem_nhds ht.1 ht.2] with s hs exact hi s hs exact hd.unique ((hasDerivAt_id t).congr_of_eventuallyEq he) intro t ht obtain h0|h0 := ht.1.eq_or_lt · subst t have hlim : Tendsto f (𝓝[>] (0 : ℝ)) (𝓝 (f 0)) := by apply (hc 0 (by norm_num)).mono_left apply le_inf nhdsWithin_le_nhds apply le_principal_iff.mpr filter_upwards [self_mem_nhdsWithin,mem_nhdsWithin_of_mem_nhds (Iio_mem_nhds (by norm_num : (0 : ℝ)<1))] with s hs hs1 exact ⟨hs.le,hs1⟩ apply tendsto_nhds_unique hlim apply 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 hs1 exact (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 := by apply continuous_eq_one_of_primitive (hX.curvature_square_mean_continuous hreg) intro t ht rw [←hX.gradient_square_integral hreg ht.1 ht.2,hmom t ⟨ht.1.le,ht.2⟩]
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import Mathlib
import OAI.Probability.SKValue.Evolution.TerminalError
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators
lemma IsDiffusion.measurable {W : BrownianSpace} {γ : OrderParameter}
{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {t : ℝ} (ht : t∈Icc (0 : ℝ) 1) :
Measurable (X t) := by
simpa only [Real.coe_toNNReal t ht.1, min_eq_left ht.2] using
(hX.1 t.toNNReal).mono (W.filtration.le t.toNNReal) le_rfl
lemma 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 := by
have he : (∫ s in (0 : ℝ)..t, γ.coeff s*gradient W γ s (x s)) =
∫ s in (0 : ℝ)..t, γ.cutoff s*gradient W γ s (x s) := by
apply intervalIntegral.integral_congr_Ioo_of_le ht.1
intro s hs
change γ.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 ↦ by
rw [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.intervalIntegrable
rw [Real.norm_eq_abs] at hb
exact hb.trans hm
lemma 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 := by
filter_upwards [hX.2] with ω hω t ht
rw [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.μ := by
have 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ω ↦ by
simpa only [Real.norm_eq_abs] using hω t ht))
have hb := (W.brownian.hasLaw_eval t.toNNReal).hasGaussianLaw.memLp hp
convert hd.add hb using 1
funext ω
simp only [Pi.add_apply, sub_add_cancel]
lemma eventually_time_mem : ∀ᶠ t : ℝ in 𝓝[<] 1, t∈Icc (0 : ℝ) 1 := by
filter_upwards [Ico_mem_nhdsLT (by norm_num : (0 : ℝ)<1)] with t ht
exact ⟨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 ω)) := by
have 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)) ht
lemma IsDiffusion.L2_terminal {W : BrownianSpace} {γ : OrderParameter}
{X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) :
Tendsto (fun t ↦ ∫ ω, (X t ω-X 1 ω)^2 ∂W.μ) (𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) := by
let D (t : ℝ) (ω : W.Ω) := X t ω-W.B t.toNNReal ω
let G := ∫ s in (0 : ℝ)..1, γ.cutoff s
have 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_bound
have hDC : ∀ᵐ ω ∂W.μ, Tendsto (fun t ↦ D t ω) (𝓝[<] (1 : ℝ)) (𝓝 (D 1 ω)) := by
filter_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 : ℝ)) := by
have 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 ht
exact ((hD t ht).sub hD1).aestronglyMeasurable.aemeasurable.pow_const 2 |>.aestronglyMeasurable
· filter_upwards [eventually_time_mem] with t ht
filter_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 2
have hb : ∀ t∈Icc (0 : ℝ) 1,
(∫ ω, (X t ω-X 1 ω)^2 ∂W.μ) ≤
2*(∫ ω, (D t ω-D 1 ω)^2 ∂W.μ)+2*(1-t) := by
intro t ht
have hxint := ((hX.memLp ht (by norm_num : (2 : ℝ≥0∞)≠∞)).sub
(hX.memLp (by norm_num : (1 : ℝ)∈Icc (0 : ℝ) 1) (by norm_num))).integrable_sq
have hdint : Integrable (fun ω ↦ (D t ω-D 1 ω)^2) W.μ := ((hD t ht).sub hD1).integrable_sq
have hbint := (brownian_increment_memLp W t).integrable_sq
calc
_ ≤ ∫ ω, 2*(D t ω-D 1 ω)^2+2*(W.B 1 ω-W.B t.toNNReal ω)^2 ∂W.μ := by
apply 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 ω))]
_ = _ := by
rw [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 SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Evolution.TerminalError
namespace OAI
sectionopen 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 BigOperators
lemma IsDiffusion.measurable {W : BrownianSpace} {γ : OrderParameter} {X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) {t : ℝ} (ht : t∈Icc (0 : ℝ) 1) : Measurable (X t) := by simpa only [Real.coe_toNNReal t ht.1, min_eq_left ht.2] using (hX.1 t.toNNReal).mono (W.filtration.le t.toNNReal) le_rfl
lemma 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 := by have he : (∫ s in (0 : ℝ)..t, γ.coeff s*gradient W γ s (x s)) = ∫ s in (0 : ℝ)..t, γ.cutoff s*gradient W γ s (x s) := by apply intervalIntegral.integral_congr_Ioo_of_le ht.1 intro s hs change γ.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 ↦ by rw [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.intervalIntegrable rw [Real.norm_eq_abs] at hb exact hb.trans hm
lemma 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 := by filter_upwards [hX.2] with ω hω t ht rw [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.μ := by have 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ω ↦ by simpa only [Real.norm_eq_abs] using hω t ht)) have hb := (W.brownian.hasLaw_eval t.toNNReal).hasGaussianLaw.memLp hp convert hd.add hb using 1 funext ω simp only [Pi.add_apply, sub_add_cancel]
lemma eventually_time_mem : ∀ᶠ t : ℝ in 𝓝[<] 1, t∈Icc (0 : ℝ) 1 := by filter_upwards [Ico_mem_nhdsLT (by norm_num : (0 : ℝ)<1)] with t ht exact ⟨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 ω)) := by have 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)) ht
lemma IsDiffusion.L2_terminal {W : BrownianSpace} {γ : OrderParameter} {X : ℝ → W.Ω → ℝ} (hX : IsDiffusion W γ X) : Tendsto (fun t ↦ ∫ ω, (X t ω-X 1 ω)^2 ∂W.μ) (𝓝[<] (1 : ℝ)) (𝓝 (0 : ℝ)) := by let D (t : ℝ) (ω : W.Ω) := X t ω-W.B t.toNNReal ω let G := ∫ s in (0 : ℝ)..1, γ.cutoff s have 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_bound have hDC : ∀ᵐ ω ∂W.μ, Tendsto (fun t ↦ D t ω) (𝓝[<] (1 : ℝ)) (𝓝 (D 1 ω)) := by filter_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 : ℝ)) := by have 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 ht exact ((hD t ht).sub hD1).aestronglyMeasurable.aemeasurable.pow_const 2 |>.aestronglyMeasurable · filter_upwards [eventually_time_mem] with t ht filter_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 2 have hb : ∀ t∈Icc (0 : ℝ) 1, (∫ ω, (X t ω-X 1 ω)^2 ∂W.μ) ≤ 2*(∫ ω, (D t ω-D 1 ω)^2 ∂W.μ)+2*(1-t) := by intro t ht have hxint := ((hX.memLp ht (by norm_num : (2 : ℝ≥0∞)≠∞)).sub (hX.memLp (by norm_num : (1 : ℝ)∈Icc (0 : ℝ) 1) (by norm_num))).integrable_sq have hdint : Integrable (fun ω ↦ (D t ω-D 1 ω)^2) W.μ := ((hD t ht).sub hD1).integrable_sq have hbint := (brownian_increment_memLp W t).integrable_sq calc _ ≤ ∫ ω, 2*(D t ω-D 1 ω)^2+2*(W.B 1 ω-W.B t.toNNReal ω)^2 ∂W.μ := by apply 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 ω))] _ = _ := by rw [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 SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343import Mathlib
import OAI.Probability.SKValue.Evolution.MeanDerivativeContinuous
import OAI.Probability.SKValue.Equations.RawIncrement
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology BigOperators
lemma 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 ∂μ) := by
let F (ω : Ω) := u T (coupledEuler T γ u B N N ω)
let G (ω : Ω) := u T (X T ω)
let E := meshMaxError T X (coupledEuler T γ u B) N
have ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩
have hd := (h.smooth T ht).continuous
have 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 hN
have hlast : meshTime T N N = T := by dsimp [meshTime, stepSize]; field_simp
have hFG (ω : Ω) : |F ω-G ω|≤Lu*|E ω| := by
have he : |coupledEuler T γ u B N N ω-X T ω|≤E ω := by
change |coupledEuler T γ u B N N ω-X T ω| ≤ initialMax _ N
have 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 hm
rw [hlast] at hm
exact hm
exact (huLip _ _).trans (mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) hLu)
have hlaw := coupledCoordinates_hasLaw hB hT hN
have heq : (∫ z, (meshTerminal T N γ u z)^2 ∂gaussianProduct (Fin (N+1)))=∫ ω, (F ω)^2 ∂μ := by
rw [←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 ∂μ := by
let 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 hpaths
have hEs : Tendsto (fun N ↦ Real.sqrt (E N)) atTop (𝓝 0) := by
simpa only [Real.sqrt_zero, Function.comp_def] using (Real.continuous_sqrt.tendsto 0).comp hE
have 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 ∂μ)) := by
apply tendsto_iff_norm_sub_tendsto_zero.mpr
apply 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 hN
rw [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)) hN
have 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 ∂μ)) := by
apply 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 i
exact (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).1
have 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) := by
apply 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 hN
rw [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 hquadrature
simp only [sub_add_cancel, zero_add] at hlimit
exact tendsto_nhds_unique hmoment hlimit
lemma 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 ∂μ) := by
rw [←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 ω; ring
rw [heq]
calc
_ ≤ ∫ ω, |(f ω-g ω)*b ω| ∂μ := abs_integral_le_integral_abs
_ ≤ ∫ ω, L*(|e ω| * |b ω|) ∂μ := by
apply 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 ∂μ)) := by
have hcs := integral_product_CS he.abs hb.abs
change |∫ ω, |e ω| * |b ω| ∂μ|≤Real.sqrt (∫ ω, |e ω|^2 ∂μ)*Real.sqrt (∫ ω, |b ω|^2 ∂μ) at hcs
simp only [sq_abs] at hcs
exact mul_le_mul_of_nonneg_left ((le_abs_self _).trans hcs) hL
_ = _ := by ring
lemma brownian_eval_second_moment {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}
{B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ) (t : ℝ≥0) :
(∫ ω, (B t ω)^2 ∂μ)=(t : ℝ) := by
have hv := (hB.hasLaw_eval t).variance_eq
rw [variance_eq_integral (hB.aemeasurable t), hB.integral_eval t] at hv
simpa using hv
noncomputable def meshBrownian (T : ℝ) (N : ℕ) (z : Fin (N+1) → ℝ) : ℝ :=
∑ j : Fin N, Real.sqrt (stepSize T N)*coordinate N j z
lemma meshBrownian_measurable (T : ℝ) (N : ℕ) : Measurable (meshBrownian T N) := by
apply Finset.measurable_sum
intro i _
exact measurable_const.mul (measurable_coordinate N i)
lemma meshBrownian_memLp (T : ℝ) (N : ℕ) :
MemLp (meshBrownian T N) 2 (gaussianProduct (Fin (N+1))) := by
convert 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 1
funext z
simp 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 ω := by
have hlast : (N : ℝ)*(T/N)=T := by field_simp
unfold meshBrownian
have 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 := by
rw [←(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) := by
filter_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 := by
have hm (i : Fin N) := mesh_raw_measurable hT.le h hN i.isLt.le
have hp (i : Fin N) := mesh_raw_depends T i.isLt.le γ u
have hH (i : Fin N) := mesh_raw_memLp hT.le h hD hN i.isLt.le
have hu := mesh_terminal_memLp hT.le h hN
have hr := finiteRaw_memLp (δ := stepSize T N) hm hp hH
have hb := meshBrownian_memLp T N
rw [←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) hb
rw [meshBrownian_second_moment hB hT hN] at hcs
exact hcs
lemma 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 := by
let F (ω : Ω) := u T (coupledEuler T γ u B N N ω)
let G (ω : Ω) := u T (X T ω)
let E := meshMaxError T X (coupledEuler T γ u B) N
have ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩
have hd := (h.smooth T ht).continuous
have 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 hN
have hlast : meshTime T N N = T := by dsimp [meshTime, stepSize]; field_simp
have hFG (ω : Ω) : |F ω-G ω|≤Lu*|E ω| := by
have he : |coupledEuler T γ u B N N ω-X T ω|≤E ω := by
change |coupledEuler T γ u B N N ω-X T ω| ≤ initialMax _ N
have hm := le_initialMax (f := fun k ↦ |coupledEuler T γ u B N k ω-X (meshTime T N k) ω|) (le_refl N)
rw [hlast] at hm
exact hm
exact (huLip _ _).trans (mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) hLu)
have hlaw := coupledCoordinates_hasLaw hB hT hN
have heq : (∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))=
∫ ω, F ω*B (Real.toNNReal T) ω ∂μ := by
have 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)).aestronglyMeasurable
rw [←hlaw.integral_comp hm]
apply integral_congr_ae
filter_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 hh
exact hh
theorem 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 ω) ∂μ := by
let 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 hpaths
have hEs : Tendsto (fun N ↦ Real.sqrt (E N)) atTop (𝓝 0) := by
simpa only [Real.sqrt_zero, Function.comp_def] using (Real.continuous_sqrt.tendsto 0).comp hE
have 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 ω ∂μ)) := by
apply tendsto_iff_norm_sub_tendsto_zero.mpr
apply 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 hN
rw [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)) hN
have 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 ω) ∂μ)) := by
apply 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 i
exact (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).2
have 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) := by
apply squeeze_zero_norm' (a := fun N ↦
Real.sqrt (gradientMeshError T N γ u) * Real.sqrt T)
· filter_upwards [eventually_gt_atTop 0] with N hN
rw [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 hquadrature
simp only [sub_add_cancel, zero_add] at hlimit
exact tendsto_nhds_unique hcovariance hlimit
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Evolution.MeanDerivativeContinuousimport OAI.Probability.SKValue.Equations.RawIncrement
namespace OAI
sectionopen 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 BigOperators
lemma 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 ∂μ) := by let F (ω : Ω) := u T (coupledEuler T γ u B N N ω) let G (ω : Ω) := u T (X T ω) let E := meshMaxError T X (coupledEuler T γ u B) N have ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩ have hd := (h.smooth T ht).continuous have 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 hN have hlast : meshTime T N N = T := by dsimp [meshTime, stepSize]; field_simp have hFG (ω : Ω) : |F ω-G ω|≤Lu*|E ω| := by have he : |coupledEuler T γ u B N N ω-X T ω|≤E ω := by change |coupledEuler T γ u B N N ω-X T ω| ≤ initialMax _ N have 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 hm rw [hlast] at hm exact hm
exact (huLip _ _).trans (mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) hLu) have hlaw := coupledCoordinates_hasLaw hB hT hN have heq : (∫ z, (meshTerminal T N γ u z)^2 ∂gaussianProduct (Fin (N+1)))=∫ ω, (F ω)^2 ∂μ := by rw [←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 ∂μ := by let 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 hpaths have hEs : Tendsto (fun N ↦ Real.sqrt (E N)) atTop (𝓝 0) := by simpa only [Real.sqrt_zero, Function.comp_def] using (Real.continuous_sqrt.tendsto 0).comp hE have 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 ∂μ)) := by apply tendsto_iff_norm_sub_tendsto_zero.mpr apply 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 hN rw [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)) hN have 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 ∂μ)) := by apply 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 i exact (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).1 have 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) := by apply 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 hN rw [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 hquadrature simp only [sub_add_cancel, zero_add] at hlimit exact tendsto_nhds_unique hmoment hlimit
lemma 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 ∂μ) := by rw [←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 ω; ring rw [heq] calc _ ≤ ∫ ω, |(f ω-g ω)*b ω| ∂μ := abs_integral_le_integral_abs _ ≤ ∫ ω, L*(|e ω| * |b ω|) ∂μ := by apply 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 ∂μ)) := by have hcs := integral_product_CS he.abs hb.abs change |∫ ω, |e ω| * |b ω| ∂μ|≤Real.sqrt (∫ ω, |e ω|^2 ∂μ)*Real.sqrt (∫ ω, |b ω|^2 ∂μ) at hcs simp only [sq_abs] at hcs exact mul_le_mul_of_nonneg_left ((le_abs_self _).trans hcs) hL _ = _ := by ring
lemma brownian_eval_second_moment {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω} {B : ℝ≥0 → Ω → ℝ} (hB : IsPreBrownianReal B μ) (t : ℝ≥0) : (∫ ω, (B t ω)^2 ∂μ)=(t : ℝ) := by have hv := (hB.hasLaw_eval t).variance_eq rw [variance_eq_integral (hB.aemeasurable t), hB.integral_eval t] at hv simpa using hv
noncomputable def meshBrownian (T : ℝ) (N : ℕ) (z : Fin (N+1) → ℝ) : ℝ := ∑ j : Fin N, Real.sqrt (stepSize T N)*coordinate N j z
lemma meshBrownian_measurable (T : ℝ) (N : ℕ) : Measurable (meshBrownian T N) := by apply Finset.measurable_sum intro i _ exact measurable_const.mul (measurable_coordinate N i)
lemma meshBrownian_memLp (T : ℝ) (N : ℕ) : MemLp (meshBrownian T N) 2 (gaussianProduct (Fin (N+1))) := by convert 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 1 funext z simp 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 ω := by have hlast : (N : ℝ)*(T/N)=T := by field_simp unfold meshBrownian have 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 := by rw [←(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) := by filter_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 := by have hm (i : Fin N) := mesh_raw_measurable hT.le h hN i.isLt.le have hp (i : Fin N) := mesh_raw_depends T i.isLt.le γ u have hH (i : Fin N) := mesh_raw_memLp hT.le h hD hN i.isLt.le have hu := mesh_terminal_memLp hT.le h hN have hr := finiteRaw_memLp (δ := stepSize T N) hm hp hH have hb := meshBrownian_memLp T N rw [←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) hb rw [meshBrownian_second_moment hB hT hN] at hcs exact hcs
lemma 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 := by let F (ω : Ω) := u T (coupledEuler T γ u B N N ω) let G (ω : Ω) := u T (X T ω) let E := meshMaxError T X (coupledEuler T γ u B) N have ht : T∈Icc (0 : ℝ) T := ⟨hT.le,le_rfl⟩ have hd := (h.smooth T ht).continuous have 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 hN have hlast : meshTime T N N = T := by dsimp [meshTime, stepSize]; field_simp have hFG (ω : Ω) : |F ω-G ω|≤Lu*|E ω| := by have he : |coupledEuler T γ u B N N ω-X T ω|≤E ω := by change |coupledEuler T γ u B N N ω-X T ω| ≤ initialMax _ N have hm := le_initialMax (f := fun k ↦ |coupledEuler T γ u B N k ω-X (meshTime T N k) ω|) (le_refl N) rw [hlast] at hm exact hm exact (huLip _ _).trans (mul_le_mul_of_nonneg_left (he.trans (le_abs_self _)) hLu) have hlaw := coupledCoordinates_hasLaw hB hT hN have heq : (∫ z, meshTerminal T N γ u z * meshBrownian T N z ∂gaussianProduct (Fin (N+1)))= ∫ ω, F ω*B (Real.toNNReal T) ω ∂μ := by have 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)).aestronglyMeasurable rw [←hlaw.integral_comp hm] apply integral_congr_ae filter_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 hh exact hh
theorem 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 ω) ∂μ := by let 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 hpaths have hEs : Tendsto (fun N ↦ Real.sqrt (E N)) atTop (𝓝 0) := by simpa only [Real.sqrt_zero, Function.comp_def] using (Real.continuous_sqrt.tendsto 0).comp hE have 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 ω ∂μ)) := by apply tendsto_iff_norm_sub_tendsto_zero.mpr apply 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 hN rw [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)) hN have 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 ω) ∂μ)) := by apply 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 i exact (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).2 have 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) := by apply squeeze_zero_norm' (a := fun N ↦ Real.sqrt (gradientMeshError T N γ u) * Real.sqrt T) · filter_upwards [eventually_gt_atTop 0] with N hN rw [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 hquadrature simp only [sub_add_cancel, zero_add] at hlimit exact tendsto_nhds_unique hcovariance hlimit
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687import Mathlib
import OAI.Probability.SKValue.Equations.InitialMax
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
noncomputable def meshMaxError {Ω : Type*} (T : ℝ) (X : ℝ → Ω → ℝ)
(Y : ℕ → ℕ → Ω → ℝ) (N : ℕ) (ω : Ω) : ℝ :=
initialMax (fun j ↦ |Y N j ω-X ((j : ℝ)*(T/N)) ω|) N
lemma 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 : ℝ)) := by
have hmeas : ∀ N, AEStronglyMeasurable (fun ω ↦ (meshMaxError T X Y N ω)^2) μ := by
intro N
exact (aestronglyMeasurable_initialMax (fun j ↦ ((hYM N j).sub (hXM _)).norm) N).fun_pow 2
have hbound : ∀ᶠ N in atTop, ∀ᵐ ω ∂μ,
‖(meshMaxError T X Y N ω)^2‖ ≤ (2*T*γ T)^2 := by
filter_upwards [eventually_gt_atTop 0] with N hN
filter_upwards [hpaths] with ω hω
have hδ : 0 ≤ T/(N : ℝ) := div_nonneg hT (Nat.cast_nonneg _)
have horizon : (N : ℝ)*(T/N) = T := by field_simp
have 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 H
rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)]
exact pow_le_pow_left₀ (meshMaxError_nonneg T X Y N ω) he 2
have hlim : ∀ᵐ ω ∂μ, Tendsto (fun N ↦ (meshMaxError T X Y N ω)^2) atTop (𝓝 (0 : ℝ)) := by
filter_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.1
hω.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 : ℝ)) := by
rw [Metric.tendsto_nhds]
intro ε hε
filter_upwards [H ε hε] with N hN
rw [Real.dist_eq,sub_zero,abs_of_nonneg (meshMaxError_nonneg T X Y N ω)]
exact initialMax_lt_iff.mpr hN
simpa using hzero.pow 2
have H := tendsto_integral_filter_of_dominated_convergence (fun _ : Ω ↦ (2*T*γ T)^2)
(Eventually.of_forall hmeas) hbound (integrable_const _) hlim
simpa using H
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.InitialMax
namespace OAI
sectionopen 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 SKValue
noncomputable def meshMaxError {Ω : Type*} (T : ���) (X : ℝ → Ω → ℝ) (Y : ℕ → ℕ → Ω → ℝ) (N : ℕ) (ω : Ω) : ℝ := initialMax (fun j ↦ |Y N j ω-X ((j : ℝ)*(T/N)) ω|) N
lemma 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 : ℝ)) := by have hmeas : ∀ N, AEStronglyMeasurable (fun ω ↦ (meshMaxError T X Y N ω)^2) μ := by intro N exact (aestronglyMeasurable_initialMax (fun j ↦ ((hYM N j).sub (hXM _)).norm) N).fun_pow 2 have hbound : ∀ᶠ N in atTop, ∀ᵐ ω ∂μ, ‖(meshMaxError T X Y N ω)^2‖ ≤ (2*T*γ T)^2 := by filter_upwards [eventually_gt_atTop 0] with N hN filter_upwards [hpaths] with ω hω have hδ : 0 ≤ T/(N : ℝ) := div_nonneg hT (Nat.cast_nonneg _) have horizon : (N : ℝ)*(T/N) = T := by field_simp have 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 H rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] exact pow_le_pow_left₀ (meshMaxError_nonneg T X Y N ω) he 2 have hlim : ∀ᵐ ω ∂μ, Tendsto (fun N ↦ (meshMaxError T X Y N ω)^2) atTop (𝓝 (0 : ℝ)) := by filter_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.1 hω.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 : ℝ)) := by rw [Metric.tendsto_nhds] intro ε hε filter_upwards [H ε hε] with N hN rw [Real.dist_eq,sub_zero,abs_of_nonneg (meshMaxError_nonneg T X Y N ω)] exact initialMax_lt_iff.mpr hN simpa using hzero.pow 2 have H := tendsto_integral_filter_of_dominated_convergence (fun _ : Ω ↦ (2*T*γ T)^2) (Eventually.of_forall hmeas) hbound (integrable_const _) hlim simpa using H
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145import Mathlib
import OAI.Probability.SKValue.Equations.ShiftedPairing
import OAI.Probability.SKValue.Evolution.UniformGridRiemannBound
import OAI.Probability.SKValue.Processes.MeshRaw
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
lemma 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 := by
have := 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 by
simpa 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 := by
calc
|a*b-f| = |a*(b-1)+(a-f)| := by congr 1; ring
_ ≤ |a*(b-1)|+|a-f| := abs_add_le _ _
_ ≤ D*r+r := by
rw [abs_mul]
exact add_le_add (mul_le_mul ha hb (abs_nonneg _) hD) hf
_ = _ := by ring
theorem 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)) := by
let 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 hj
exact predictableNormalizer_pos (hN j hj)
· let A (N : ℕ) (i : Fin (N+1)) := meshA T (N+1) γ u i
let B (N : ℕ) (i : Fin (N+1)) := meshB T (N+1) γ u i
let α (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) γ u
let rend (N : ℕ) := Real.sqrt (stepSize T (N+1))*D
have hproj : ∀ᶠ N in atTop,
(∑ i, (A N i-α N i)^2)≤e N ∧ (∑ i, (B N i-β N i)^2)≤e N := by
filter_upwards [(tendsto_add_atTop_nat 1).eventually hqpos] with N hN
exact 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 := by
have := 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) := by
simpa only [rend, Function.comp_def, Real.sqrt_zero, zero_mul] using
((Real.continuous_sqrt.tendsto 0).comp hδ0).mul_const D
have 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 hrend0
let 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) := by
apply 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] using
hm (N+1) (Nat.succ_pos N) i.succ
have hv0 : Tendsto (fun N ↦ (D+1)*r (N+1)) atTop (𝓝 0) := by
simpa 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 := by
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro 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)))) := by
simp 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 := by
simp 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 herr
have hlim := herr.add hvlim
simp only [sub_add_cancel, zero_add] at hlim
exact (tendsto_add_atTop_iff_nat 1).mp hlim
end SKValue
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.ShiftedPairingimport OAI.Probability.SKValue.Evolution.UniformGridRiemannBoundimport OAI.Probability.SKValue.Processes.MeshRaw
namespace OAI
sectionopen 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 BigOperators
lemma 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 := by have := 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 by simpa 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 := by calc |a*b-f| = |a*(b-1)+(a-f)| := by congr 1; ring _ ≤ |a*(b-1)|+|a-f| := abs_add_le _ _ _ ≤ D*r+r := by rw [abs_mul] exact add_le_add (mul_le_mul ha hb (abs_nonneg _) hD) hf _ = _ := by ring
theorem 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)) := by let 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 hj exact predictableNormalizer_pos (hN j hj) · let A (N : ℕ) (i : Fin (N+1)) := meshA T (N+1) γ u i let B (N : ℕ) (i : Fin (N+1)) := meshB T (N+1) γ u i let α (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) γ u let rend (N : ℕ) := Real.sqrt (stepSize T (N+1))*D have hproj : ∀ᶠ N in atTop, (∑ i, (A N i-α N i)^2)≤e N ∧ (∑ i, (B N i-β N i)^2)≤e N := by filter_upwards [(tendsto_add_atTop_nat 1).eventually hqpos] with N hN exact 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 := by have := 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) := by simpa only [rend, Function.comp_def, Real.sqrt_zero, zero_mul] using ((Real.continuous_sqrt.tendsto 0).comp hδ0).mul_const D have 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 hrend0 let 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) := by apply 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] using hm (N+1) (Nat.succ_pos N) i.succ have hv0 : Tendsto (fun N ↦ (D+1)*r (N+1)) atTop (𝓝 0) := by simpa 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 := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro 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)))) := by simp 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 := by simp 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 herr have hlim := herr.add hvlim simp only [sub_add_cancel, zero_add] at hlim exact (tendsto_add_atTop_iff_nat 1).mp hlim
end SKValue
open MeasureTheory Set Filter Finsetopen scoped Topology BigOperators
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143import Mathlib
import OAI.Probability.SKValue.Equations.FiniteRounded
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
noncomputable 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 := by
apply mesh_mem_strip_ito (δ := stepSize T N) (div_nonneg hT (Nat.cast_nonneg N)) _ hj
have hNr : (N : ℝ)≠0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hN)
unfold stepSize
field_simp
lemma 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))) := by
have := gaussianProduct_probability (Fin (N+1))
apply MemLp.of_bound (mesh_raw_measurable hT h hN hj).aestronglyMeasurable D
exact Eventually.of_forall (fun z ↦ by
simpa 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 := by
exact 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 := by
have := 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 := by
apply Finset.sum_le_sum
intro j _
rw [←sq_abs (Real.sqrt _ / _)]
apply (sq_le_sq₀ (abs_nonneg _) (mul_nonneg (Real.sqrt_nonneg _) hD0)).2
exact 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 := by
simp 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 stepSize
have hNr : (N : ℝ)≠0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hN)
field_simp
lemma abs_sqrt_sub_one_le {q : ℝ} (hq : 0≤q) : |Real.sqrt q-1|≤|q-1| := by
have heq : |q-1|=|Real.sqrt q-1| * (Real.sqrt q+1) := by
rw [←abs_of_nonneg (by positivity : 0≤Real.sqrt q+1), ←abs_mul]
congr 1
nlinarith [Real.sq_sqrt hq]
rw [heq]
nlinarith [Real.sqrt_nonneg q, abs_nonneg (Real.sqrt q-1)]
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.FiniteRounded
namespace OAI
sectionopen 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 BigOperators
noncomputable 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 := by apply mesh_mem_strip_ito (δ := stepSize T N) (div_nonneg hT (Nat.cast_nonneg N)) _ hj have hNr : (N : ℝ)≠0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hN) unfold stepSize field_simp
lemma 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))) := by have := gaussianProduct_probability (Fin (N+1)) apply MemLp.of_bound (mesh_raw_measurable hT h hN hj).aestronglyMeasurable D exact Eventually.of_forall (fun z ↦ by simpa 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 := by exact 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 := by have := 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 := by apply Finset.sum_le_sum intro j _ rw [←sq_abs (Real.sqrt _ / _)] apply (sq_le_sq₀ (abs_nonneg _) (mul_nonneg (Real.sqrt_nonneg _) hD0)).2 exact 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 := by simp 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 stepSize have hNr : (N : ℝ)≠0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hN) field_simp
lemma abs_sqrt_sub_one_le {q : ℝ} (hq : 0≤q) : |Real.sqrt q-1|≤|q-1| := by have heq : |q-1|=|Real.sqrt q-1| * (Real.sqrt q+1) := by rw [←abs_of_nonneg (by positivity : 0≤Real.sqrt q+1), ←abs_mul] congr 1 nlinarith [Real.sq_sqrt hq] rw [heq] nlinarith [Real.sqrt_nonneg q, abs_nonneg (Real.sqrt q-1)]
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778import Mathlib
import OAI.Probability.SKValue.Equations.Cutoff
import OAI.Probability.SKValue.Equations.LipschitzCompMemLpFinite
import OAI.Probability.SKValue.Processes.Measurable
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology BigOperators
lemma 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 := by
filter_upwards [hX.2, W.brownian.toIsPreBrownianReal.eval_zero_ae_eq_zero] with ω hω h0
have hsub : Icc (0 : ℝ) T ⊆ Icc (0 : ℝ) 1 := Icc_subset_Icc le_rfl hT1.le
refine ⟨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) := by
exact 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 (by
simpa 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.μ)) := by
apply 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 ht
exact hX.memLp ⟨ht.1,ht.2.trans hT1.le⟩ (by norm_num)
· exact hX.strip_paths hT.le hT1 hLu huLip
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.Cutoffimport OAI.Probability.SKValue.Equations.LipschitzCompMemLpFiniteimport OAI.Probability.SKValue.Processes.Measurable
namespace OAI
sectionopen 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 BigOperators
lemma 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 := by filter_upwards [hX.2, W.brownian.toIsPreBrownianReal.eval_zero_ae_eq_zero] with ω hω h0 have hsub : Icc (0 : ℝ) T ⊆ Icc (0 : ℝ) 1 := Icc_subset_Icc le_rfl hT1.le refine ⟨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) := by exact 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 (by simpa 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.μ)) := by apply 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 ht exact hX.memLp ⟨ht.1,ht.2.trans hT1.le⟩ (by norm_num) · exact hX.strip_paths hT.le hT1 hLu huLip
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import Mathlib
import OAI.Probability.SKValue.Processes.UnitMomentMartingale
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
variable {Ω : 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 := by
have 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.symm
apply ae_eq_condExp_of_forall_setIntegral_eq (ℱ.le s) hUi
(fun S _ _ ↦ (h.integrable hs).integrableOn) _ (h.measurable s hs).aestronglyMeasurable
intro 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 ω ∂μ := by
have 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 hn
calc
_ = ∫ ω 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)) hlim
lemma 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) μ := by
have 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 t
by_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 hst
by_cases hs : (s : ℝ)<1
· by_cases ht : (t : ℝ)<1
· simpa only [hs,ht,ite_true,ite_false] using
h.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))) hUi
simpa only [hs,ht,ite_true,ite_false] using Filter.EventuallyEq.of_eq he
lemma 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 : ℝ)) := by
obtain ⟨U,hUm,hU⟩ := h.exists_continuous_terminal hc
have 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ω hsq
exact ⟨hω.1,hsq,hω.2⟩
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Processes.UnitMomentMartingale
namespace OAI
sectionopen 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 := by have 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.symm apply ae_eq_condExp_of_forall_setIntegral_eq (ℱ.le s) hUi (fun S _ _ ↦ (h.integrable hs).integrableOn) _ (h.measurable s hs).aestronglyMeasurable intro 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 ω ∂μ := by have 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 hn calc _ = ∫ ω 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)) hlim
lemma 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) μ := by have 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 t by_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 hst by_cases hs : (s : ℝ)<1 · by_cases ht : (t : ℝ)<1 · simpa only [hs,ht,ite_true,ite_false] using h.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))) hUi simpa only [hs,ht,ite_true,ite_false] using Filter.EventuallyEq.of_eq he
lemma 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 : ℝ)) := by obtain ⟨U,hUm,hU⟩ := h.exists_continuous_terminal hc have 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ω hsq exact ⟨hω.1,hsq,hω.2⟩
end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import Mathlib
import OAI.Probability.SKValue.Gaussian.CoupledCoordinates
import OAI.Probability.SKValue.Evolution.BoundedSmooth
import OAI.Probability.SKValue.Equations.TestGenerator
import OAI.Probability.SKValue.Processes.TestExpectation
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal
namespace SKValue
lemma 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 := by
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 T
have hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδ
have hE:Tendsto E atTop (𝓝 0) := by
simpa 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) := by
simpa 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 := by
filter_upwards [eventually_gt_atTop 0] with N hN
have he := h.mesh_expectation hT hT1 hN
have hf := h.coupled_terminal_error hB hT hu hXM
(by filter_upwards [hpaths] with ω hω using hω.2.2) hN
have ht := abs_sub_le (∫ ω,V T (X T ω) ∂μ) (A N) (V 0 0)
change |A N-V 0 0|≤E N at he
change |A N-(∫ ω,V T (X T ω) ∂μ)|≤F N at hf
have hf' : |(∫ ω,V T (X T ω) ∂μ)-A N|≤F N := by
rw [abs_sub_comm];exact hf
linarith
have hz := le_of_tendsto_of_tendsto tendsto_const_nhds (hE.add hF) hbound
have 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 SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Gaussian.CoupledCoordinatesimport OAI.Probability.SKValue.Evolution.BoundedSmoothimport OAI.Probability.SKValue.Equations.TestGeneratorimport OAI.Probability.SKValue.Processes.TestExpectation
namespace OAI
section
open 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 := by 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 T have hsqrt := (Real.continuous_sqrt.tendsto 0).comp hδ have hE:Tendsto E atTop (𝓝 0) := by simpa 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) := by simpa 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 := by filter_upwards [eventually_gt_atTop 0] with N hN have he := h.mesh_expectation hT hT1 hN have hf := h.coupled_terminal_error hB hT hu hXM (by filter_upwards [hpaths] with ω hω using hω.2.2) hN have ht := abs_sub_le (∫ ω,V T (X T ω) ∂μ) (A N) (V 0 0) change |A N-V 0 0|≤E N at he change |A N-(∫ ω,V T (X T ω) ∂μ)|≤F N at hf have hf' : |(∫ ω,V T (X T ω) ∂μ)-A N|≤F N := by rw [abs_sub_comm];exact hf linarith have hz := le_of_tendsto_of_tendsto tendsto_const_nhds (hE.add hF) hbound have 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 SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191import Mathlib
import OAI.Probability.SKValue.Processes.CrossMesh
import OAI.Probability.SKValue.Equations.TestGenerator
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators NNReal
namespace SKValue
lemma 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) := by
let μ := 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 z
let 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 z
let 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 hYm
have ham:Measurable a := by
have hh := (h.smooth t htm).continuous_iteratedDeriv 2 (by norm_num)
simp only [show (2:ℕ)=1+1 from rfl,iteratedDeriv_succ] at hh
exact hh.measurable.comp hYm
have 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 := by
dsimp only [P]
rw [integral_const_mul,rawIncrement_mean hj hpm hpp,mul_zero]
have hQ0:(∫ z,Q z ∂μ)=0 := by
dsimp 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 hcur
have hRi:Integrable R μ := (hDi.sub hPi).sub hQi
have 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 := by
have hh := h.euler_one_step ht hδ hδ1 htδ (x:=Y z) (z:=coordinate N j z)
convert! hh using 1
dsimp only [R,D,P,Q,p,a,Y',E,rawIncrement]
congr 1
ring_nf
have hRmean:(∫ z,R z ∂μ)=(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ) := by
have hs := integral_sub (hDi.sub hPi) hQi
change (∫ z,D z-P z-Q z ∂μ)=(∫ z,D z-P z ∂μ)-(∫ z,Q z ∂μ) at hs
have hs1 := integral_sub hDi hPi
change (∫ z,D z-P z ∂μ)=(∫ z,D z ∂μ)-(∫ z,P z ∂μ) at hs1
change (∫ z,D z-P z-Q z ∂μ)=_
rw [hs,hs1,hP0,hQ0,sub_zero,sub_zero]
exact integral_sub hnext hcur
have hEmean:(∫ z,E z ∂μ)=
δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (t+δ)-γ t) := by
dsimp 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) := by
simpa only [Function.comp_def,cubicEnvelopeMean,standardGaussian] using
(coordinate_hasLaw N j).integral_comp (measurable_cubicEnvelope (γ T) K ((1/2+γ T)*L)).aestronglyMeasurable
rw [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 SKValue
end
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators NNReal
namespace SKValue
lemma 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) := by
let δ := stepSize T N
let 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 hN
have hδ:0≤δ := div_nonneg hT.le hNr.le
have hδ1:δ≤1 := by
apply (div_le_iff₀ hNr).mpr
have hn:(1:ℝ)≤N := by exact_mod_cast hN
simpa only [one_mul] using hT1.trans hn
have htime (j:ℕ) (hj:j≤N) := mesh_time_mem hT.le hN hj
have hs (j:ℕ) : meshTime T N j+δ=meshTime T N (j+1) := by dsimp [meshTime];push_cast;ring
have hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simp
have 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) := by
have 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) hYp
dsimp only at he
rw [hs] at he
simpa only [A,euler,δ,mul_assoc,add_zero,sub_self,mul_zero] using he
have hh := abs_telescope_source (A:=A) (b:=fun _ ↦ 0) (Γ:=fun j ↦ γ (meshTime T N j))
(Δ:=fun _ ↦ 0) (e:=0) hstep
have 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))) by
dsimp only [A];rw [hlast],hlast,hzero] at hh
have hNd:(N:ℝ)*δ=T := by dsimp [δ,stepSize];field_simp
simpa only [Finset.sum_const_zero,add_zero,sub_self,mul_zero,←mul_assoc,hNd] using hh
lemma 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| := by
have 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⟩ z
have hl : LipschitzWith ⟨K,h.K_nonneg⟩ (V T) := by
apply lipschitzWith_of_nnnorm_deriv_le hd
intro z
exact_mod_cast hb z
have hh := hl.dist_le_mul x y
change |V T x-V T y|≤K*|x-y| at hh
exact hh
lemma 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 ∂μ) := by
let 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) N
have ht:T∈Icc (0:ℝ) T := ⟨hT.le,le_rfl⟩
have hm:Continuous (V T) := (h.smooth T ht).continuous
have 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 hN
have hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simp
have hFG (ω:Ω) : |F ω-G ω|≤K'*|E ω| := by
have he:|coupledEuler T γ u B N N ω-X T ω|≤E ω := by
have 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 hh
rwa [hlast] at hh
exact (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 ω ∂μ) := by
have heum := measurable_euler T N γ u (fun j hj ↦ (hu.smooth _ (mesh_time_mem hT.le hN hj.le)).continuous.measurable) N le_rfl
have hh := (coupledCoordinates_hasLaw hB hT hN).integral_comp (hm.measurable.comp heum).aestronglyMeasurable
simpa only [Function.comp_apply,F,coupledEuler,ite_eq_right (Nat.ne_of_gt hN)] using hh.symm
rw [heq]
exact first_moment_perturbation hFM hGM hEM h.K_nonneg (Eventually.of_forall hFG)
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Processes.CrossMeshimport OAI.Probability.SKValue.Equations.TestGenerator
namespace OAI
section
open 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) := by let μ := 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 z let 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 z let 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 hYm have ham:Measurable a := by have hh := (h.smooth t htm).continuous_iteratedDeriv 2 (by norm_num) simp only [show (2:ℕ)=1+1 from rfl,iteratedDeriv_succ] at hh exact hh.measurable.comp hYm have 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 := by dsimp only [P] rw [integral_const_mul,rawIncrement_mean hj hpm hpp,mul_zero] have hQ0:(∫ z,Q z ∂μ)=0 := by dsimp 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 hcur have hRi:Integrable R μ := (hDi.sub hPi).sub hQi have 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 := by have hh := h.euler_one_step ht hδ hδ1 htδ (x:=Y z) (z:=coordinate N j z) convert! hh using 1 dsimp only [R,D,P,Q,p,a,Y',E,rawIncrement] congr 1 ring_nf have hRmean:(∫ z,R z ∂μ)=(∫ z,V (t+δ) (Y' z) ∂μ)-(∫ z,V t (Y z) ∂μ) := by have hs := integral_sub (hDi.sub hPi) hQi change (∫ z,D z-P z-Q z ∂μ)=(∫ z,D z-P z ∂μ)-(∫ z,Q z ∂μ) at hs have hs1 := integral_sub hDi hPi change (∫ z,D z-P z ∂μ)=(∫ z,D z ∂μ)-(∫ z,P z ∂μ) at hs1 change (∫ z,D z-P z-Q z ∂μ)=_ rw [hs,hs1,hP0,hQ0,sub_zero,sub_zero] exact integral_sub hnext hcur have hEmean:(∫ z,E z ∂μ)= δ*Real.sqrt δ*cubicEnvelopeMean (γ T) K ((1/2+γ T)*L)+δ*K*(γ (t+δ)-γ t) := by dsimp 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) := by simpa only [Function.comp_def,cubicEnvelopeMean,standardGaussian] using (coordinate_hasLaw N j).integral_comp (measurable_cubicEnvelope (γ T) K ((1/2+γ T)*L)).aestronglyMeasurable rw [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 SKValue
end
section
open 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) := by let δ := stepSize T N let 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 hN have hδ:0≤δ := div_nonneg hT.le hNr.le have hδ1:δ≤1 := by apply (div_le_iff₀ hNr).mpr have hn:(1:ℝ)≤N := by exact_mod_cast hN simpa only [one_mul] using hT1.trans hn have htime (j:ℕ) (hj:j≤N) := mesh_time_mem hT.le hN hj have hs (j:ℕ) : meshTime T N j+δ=meshTime T N (j+1) := by dsimp [meshTime];push_cast;ring have hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simp have 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) := by have 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) hYp dsimp only at he rw [hs] at he simpa only [A,euler,δ,mul_assoc,add_zero,sub_self,mul_zero] using he have hh := abs_telescope_source (A:=A) (b:=fun _ ↦ 0) (Γ:=fun j ↦ γ (meshTime T N j)) (Δ:=fun _ ↦ 0) (e:=0) hstep have 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))) by dsimp only [A];rw [hlast],hlast,hzero] at hh have hNd:(N:ℝ)*δ=T := by dsimp [δ,stepSize];field_simp simpa only [Finset.sum_const_zero,add_zero,sub_self,mul_zero,←mul_assoc,hNd] using hh
lemma 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| := by have 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⟩ z have hl : LipschitzWith ⟨K,h.K_nonneg⟩ (V T) := by apply lipschitzWith_of_nnnorm_deriv_le hd intro z exact_mod_cast hb z have hh := hl.dist_le_mul x y change |V T x-V T y|≤K*|x-y| at hh exact hh
lemma 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 ∂μ) := by let 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) N have ht:T∈Icc (0:ℝ) T := ⟨hT.le,le_rfl⟩ have hm:Continuous (V T) := (h.smooth T ht).continuous have 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 hN have hlast:meshTime T N N=T := by dsimp [meshTime,stepSize];field_simp have hFG (ω:Ω) : |F ω-G ω|≤K'*|E ω| := by have he:|coupledEuler T γ u B N N ω-X T ω|≤E ω := by have 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 hh rwa [hlast] at hh exact (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 ω ∂μ) := by have heum := measurable_euler T N γ u (fun j hj ↦ (hu.smooth _ (mesh_time_mem hT.le hN hj.le)).continuous.measurable) N le_rfl have hh := (coupledCoordinates_hasLaw hB hT hN).integral_comp (hm.measurable.comp heum).aestronglyMeasurable simpa only [Function.comp_apply,F,coupledEuler,ite_eq_right (Nat.ne_of_gt hN)] using hh.symm rw [heq] exact first_moment_perturbation hFM hGM hEM h.K_nonneg (Eventually.of_forall hFG)end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396import Mathlib
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
variable {Ω : Type*} {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
structure UnitMomentMartingale (ℱ : Filtration ℝ m) (f : ℝ → Ω → ℝ) : Prop where
measurable : ∀ t ∈ Ico (0 : ℝ) 1, StronglyMeasurable[ℱ t] (f t)
bounded : ∀ t ∈ Ico (0 : ℝ) 1, ∀ ω, |f t ω| ≤ 1
condExp : ∀ s ∈ Ico (0 : ℝ) 1, ∀ t ∈ Ico (0 : ℝ) 1, s ≤ t →
μ[f t | ℱ s] =ᵐ[μ] f s
secondMoment : ∀ t ∈ Ico (0 : ℝ) 1, ∫ ω, (f t ω)^2 ∂μ = t
variable {ℱ : 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 ω ↦ by
rw [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 := by
have 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 := by
filter_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 hs
lemma 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) μ := by
have 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 hij
have 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 he
simp only [Pi.sub_apply] at hsub
change μ[(fun ω ↦ f s ω*f (r j) ω) | ℱ (r i)] ω =
f s ω*μ[f (r j) | ℱ (r i)] ω at hmul
rw [hc1,hmul] at hsub
simpa only [Pi.sub_def,Pi.mul_def,Pi.mul_apply,he] using hsub
omit [IsProbabilityMeasure μ] in
lemma 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 ω := by
have 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 ω)]
linarith
lemma 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 := by
rw [integral_sub (integrable_const 1) (h.integrable_mul hs ht),
h.integral_past_mul hs ht hst]
simp
lemma 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) := by
classical
by_cases hne : S.Nonempty
· have hcard : 0 < S.card := Finset.card_pos.mpr hne
let e := S.orderEmbOfFin rfl
let r : ℕ → ℝ := fun n ↦ e ⟨min n (S.card-1),by omega⟩
have hr : Monotone r := by
intro i j hij
exact 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 hrmem
have 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) ω)} := by
rintro ω ⟨t,ht,heps⟩
let i := (S.orderIsoOfFin rfl).symm ⟨t,ht⟩
have her : r i.val = t := by
dsimp 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 = t
simp [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)) ω ∂μ) := by
apply ENNReal.ofReal_le_ofReal
exact 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) := by
classical
let E : Finset ℚ → Set Ω := fun S ↦ {ω | ∃ q ∈ S, (q : ℝ) ∈ Ico s 1 ∧
(ε : ℝ) ≤ 1-f s ω*f q ω}
have hd : Directed (· ⊆ ·) E := by
intro S T
refine ⟨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 := by
ext ω
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 := by
intro t ht
obtain ⟨q,hq,rfl⟩ := Finset.mem_image.mp ht
exact (Finset.mem_filter.mp hq).2
have hE : E S ⊆ {ω | ∃ t ∈ R, (ε : ℝ) ≤ 1-f s ω*f t ω} := by
rintro ω ⟨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 := by
have hn : (1 : ℝ) ≤ n+1 := by linarith [Nat.cast_nonneg (α := ℝ) n]
have hp : (0 : ℝ) < n+1 := by positivity
simp only [terminalTime]
constructor
· have hh : (1 : ℝ)/(n+1) ≤ 1 := (div_le_one hp).mpr hn
linarith
· have hh : (0 : ℝ) < 1/(n+1) := by positivity
linarith
lemma terminalTime_monotone : Monotone terminalTime := by
intro i j hij
simp 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)
linarith
lemma terminalTime_tendsto : Tendsto terminalTime atTop (𝓝[<] (1 : ℝ)) := by
refine 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 ω < ε := by
let 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
_ ≤ _ := by
have hh := h.rational_gap_maximal (terminalTime_mem n) (NNReal.mk ε hε.le)
simpa only [E,NNReal.coe_mk,ENNReal.coe_nnreal_eq] using hh
have hzero : ENNReal.ofReal ε * μ (⋂ n, E n) = 0 := by
apply le_antisymm _ bot_le
have hlim : Tendsto (fun n ↦ ENNReal.ofReal (1-terminalTime n)) atTop (𝓝 0) := by
have hh : Tendsto (fun n ↦ 1-terminalTime n) atTop (𝓝 (0 : ℝ)) := by
simpa 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] using
ENNReal.continuous_ofReal.continuousAt.tendsto.comp hh
exact ge_of_tendsto' hlim hbound
have 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 := by
rw [ae_iff]
convert hn using 1
simp 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 ≤ ε := by
intro t ht
by_contra! he
have 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'.1
lemma UnitMomentMartingale.exists_sequence_terminal
(h : UnitMomentMartingale (μ := μ) ℱ f) :
∃ U : Ω → ℝ, StronglyMeasurable[ℱ 1] U ∧
(∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧
Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))) := by
let 𝒢 : 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) := by
have 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 hh
let 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 ω))) := by
obtain ⟨U,hU,hseq⟩ := h.exists_sequence_terminal
have hg : ∀ᵐ ω ∂μ, ∀ k : ℕ, ∃ n, ∀ q : ℚ,
(q : ℝ) ∈ Ico (terminalTime n) 1 →
1-f (terminalTime n) ω*f q ω < 1/(k+1) := by
apply ae_all_iff.mpr
intro k
exact h.ae_exists_rational_gap_bound (by positivity)
refine ⟨U,hU,?_⟩
filter_upwards [hc,hseq,hg] with ω hcont hseqω hgap
refine ⟨hseqω.1,Metric.tendsto_nhds.mpr (fun δ hδ ↦ ?_)⟩
obtain ⟨k,hk⟩ : ∃ k : ℕ, (1 : ℝ)/(k+1) < δ^2/32 := by
have hh := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).eventually
(Iio_mem_nhds (show (0 : ℝ) < δ^2/32 by positivity))
exact hh.exists
obtain ⟨n,hn⟩ := hgap k
have hreal := continuous_gap_bound_of_rat hcont (terminalTime_mem n) hn
have hbound (t : ℝ) (ht : t ∈ Ioo (terminalTime n) 1) :
|f t ω-f (terminalTime n) ω| ≤ δ/4 := by
have 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 ht
have 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 := by
rw [sq_abs]
nlinarith
nlinarith [abs_nonneg (f t ω-f (terminalTime n) ω)]
have hUb : |U ω-f (terminalTime n) ω| ≤ δ/4 := by
apply 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 ht
rw [Real.dist_eq]
have hh := abs_add_le (f t ω-f (terminalTime n) ω) (f (terminalTime n) ω-U ω)
have hh' := hbound t ht
have hUb' : |f (terminalTime n) ω-U ω| ≤ δ/4 := by simpa only [abs_sub_comm] using hUb
have heq : f t ω-U ω = (f t ω-f (terminalTime n) ω)+(f (terminalTime n) ω-U ω) := by ring
rw [heq]
linarith
lemma 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 := by
have hU2i : Integrable (fun ω ↦ (U ω)^2) μ :=
Integrable.of_bound ((hUm.mono (ℱ.le 1)).pow 2).aestronglyMeasurable 1
(hU.mono (fun ω hω ↦ by
rw [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 ω ↦ by
rw [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 := by
have hh : (fun n ↦ ∫ ω, (f (terminalTime n) ω)^2 ∂μ) = terminalTime :=
funext (fun n ↦ h.secondMoment _ (terminalTime_mem n))
rw [hh] at ht
exact tendsto_nhds_unique ht (tendsto_nhdsWithin_iff.mp terminalTime_tendsto).1
have hnonneg : 0 ≤ᵐ[μ] (fun ω ↦ 1-(U ω)^2) := hU.mono (fun ω hω ↦ by
dsimp
nlinarith [abs_le.mp hω.1])
have hzero : ∫ ω, 1-(U ω)^2 ∂μ = 0 := by
rw [integral_sub (integrable_const 1) hU2i,hi]
simp
have he := (integral_eq_zero_iff_of_nonneg_ae hnonneg ((integrable_const 1).sub hU2i)).mp hzero
filter_upwards [he] with ω hω
change 1-(U ω)^2=0 at hω
linarith
lemma 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 : ℝ)) := by
have hev : ∀ᶠ t in 𝓝[<] (1 : ℝ), t ∈ Ico (0 : ℝ) 1 := by
filter_upwards [Ioo_mem_nhdsLT (show (0 : ℝ)<1 by norm_num)] with t ht
exact ⟨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ω ↦ by
rw [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ω ↦ by
simpa only [sub_self,zero_pow (by decide : (2 : ℕ) ≠ 0)] using (hω.2.sub_const (U ω)).pow 2))
simpa only [integral_zero] using ht
end SKValue
end
end OAIimport Mathlib
namespace OAI
sectionopen 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 SKValue
variable {Ω : Type*} {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ]
structure UnitMomentMartingale (ℱ : Filtration ℝ m) (f : ℝ → Ω → ℝ) : Prop where measurable : ∀ t ∈ Ico (0 : ℝ) 1, StronglyMeasurable[ℱ t] (f t) bounded : ∀ t ∈ Ico (0 : ℝ) 1, ∀ ω, |f t ω| ≤ 1 condExp : ∀ s ∈ Ico (0 : ℝ) 1, ∀ t ∈ Ico (0 : ℝ) 1, s ≤ t → μ[f t | ℱ s] =ᵐ[μ] f s secondMoment : ∀ t ∈ Ico (0 : ℝ) 1, ∫ ω, (f t ω)^2 ∂μ = t
variable {ℱ : 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 ω ↦ by rw [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 := by have 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 := by filter_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 hs
lemma 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) μ := by have 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 hij have 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 he simp only [Pi.sub_apply] at hsub change μ[(fun ω ↦ f s ω*f (r j) ω) | ℱ (r i)] ω = f s ω*μ[f (r j) | ℱ (r i)] ω at hmul rw [hc1,hmul] at hsub simpa only [Pi.sub_def,Pi.mul_def,Pi.mul_apply,he] using hsub
omit [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 ω := by have 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 ω)] linarith
lemma 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 := by rw [integral_sub (integrable_const 1) (h.integrable_mul hs ht), h.integral_past_mul hs ht hst] simp
lemma 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) := by classical by_cases hne : S.Nonempty · have hcard : 0 < S.card := Finset.card_pos.mpr hne let e := S.orderEmbOfFin rfl let r : ℕ → ℝ := fun n ↦ e ⟨min n (S.card-1),by omega⟩ have hr : Monotone r := by intro i j hij exact 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 hrmem have 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) ω)} := by rintro ω ⟨t,ht,heps⟩ let i := (S.orderIsoOfFin rfl).symm ⟨t,ht⟩ have her : r i.val = t := by dsimp 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 = t simp [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)) ω ∂μ) := by apply ENNReal.ofReal_le_ofReal exact 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) := by classical let E : Finset ℚ → Set Ω := fun S ↦ {ω | ∃ q ∈ S, (q : ℝ) ∈ Ico s 1 ∧ (ε : ℝ) ≤ 1-f s ω*f q ω} have hd : Directed (· ⊆ ·) E := by intro S T refine ⟨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 := by ext ω 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 := by intro t ht obtain ⟨q,hq,rfl⟩ := Finset.mem_image.mp ht exact (Finset.mem_filter.mp hq).2 have hE : E S ⊆ {ω | ∃ t ∈ R, (ε : ℝ) ≤ 1-f s ω*f t ω} := by rintro ω ⟨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 := by have hn : (1 : ℝ) ≤ n+1 := by linarith [Nat.cast_nonneg (α := ℝ) n] have hp : (0 : ℝ) < n+1 := by positivity simp only [terminalTime] constructor · have hh : (1 : ℝ)/(n+1) ≤ 1 := (div_le_one hp).mpr hn linarith · have hh : (0 : ℝ) < 1/(n+1) := by positivity linarith
lemma terminalTime_monotone : Monotone terminalTime := by intro i j hij simp 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) linarith
lemma terminalTime_tendsto : Tendsto terminalTime atTop (𝓝[<] (1 : ℝ)) := by refine 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 ω < ε := by let 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 _ ≤ _ := by have hh := h.rational_gap_maximal (terminalTime_mem n) (NNReal.mk ε hε.le) simpa only [E,NNReal.coe_mk,ENNReal.coe_nnreal_eq] using hh have hzero : ENNReal.ofReal ε * μ (⋂ n, E n) = 0 := by apply le_antisymm _ bot_le have hlim : Tendsto (fun n ↦ ENNReal.ofReal (1-terminalTime n)) atTop (𝓝 0) := by have hh : Tendsto (fun n ↦ 1-terminalTime n) atTop (𝓝 (0 : ℝ)) := by simpa 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] using ENNReal.continuous_ofReal.continuousAt.tendsto.comp hh exact ge_of_tendsto' hlim hbound have 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 := by rw [ae_iff] convert hn using 1 simp 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 ≤ ε := by intro t ht by_contra! he have 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'.1
lemma UnitMomentMartingale.exists_sequence_terminal (h : UnitMomentMartingale (μ := μ) ℱ f) : ∃ U : Ω → ℝ, StronglyMeasurable[ℱ 1] U ∧ (∀ᵐ ω ∂μ, |U ω| ≤ 1 ∧ Tendsto (fun n ↦ f (terminalTime n) ω) atTop (𝓝 (U ω))) := by let 𝒢 : 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) := by have 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 hh let 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 ω))) := by obtain ⟨U,hU,hseq⟩ := h.exists_sequence_terminal have hg : ∀ᵐ ω ∂μ, ∀ k : ℕ, ∃ n, ∀ q : ℚ, (q : ℝ) ∈ Ico (terminalTime n) 1 → 1-f (terminalTime n) ω*f q ω < 1/(k+1) := by apply ae_all_iff.mpr intro k exact h.ae_exists_rational_gap_bound (by positivity) refine ⟨U,hU,?_⟩ filter_upwards [hc,hseq,hg] with ω hcont hseqω hgap refine ⟨hseqω.1,Metric.tendsto_nhds.mpr (fun δ hδ ↦ ?_)⟩ obtain ⟨k,hk⟩ : ∃ k : ℕ, (1 : ℝ)/(k+1) < δ^2/32 := by have hh := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).eventually (Iio_mem_nhds (show (0 : ℝ) < δ^2/32 by positivity)) exact hh.exists obtain ⟨n,hn⟩ := hgap k have hreal := continuous_gap_bound_of_rat hcont (terminalTime_mem n) hn have hbound (t : ℝ) (ht : t ∈ Ioo (terminalTime n) 1) : |f t ω-f (terminalTime n) ω| ≤ δ/4 := by have 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 ht have 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 := by rw [sq_abs] nlinarith nlinarith [abs_nonneg (f t ω-f (terminalTime n) ω)] have hUb : |U ω-f (terminalTime n) ω| ≤ δ/4 := by apply 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 ht rw [Real.dist_eq] have hh := abs_add_le (f t ω-f (terminalTime n) ω) (f (terminalTime n) ω-U ω) have hh' := hbound t ht have hUb' : |f (terminalTime n) ω-U ω| ≤ δ/4 := by simpa only [abs_sub_comm] using hUb have heq : f t ω-U ω = (f t ω-f (terminalTime n) ω)+(f (terminalTime n) ω-U ω) := by ring rw [heq] linarith
lemma 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 := by have hU2i : Integrable (fun ω ↦ (U ω)^2) μ := Integrable.of_bound ((hUm.mono (ℱ.le 1)).pow 2).aestronglyMeasurable 1 (hU.mono (fun ω hω ↦ by rw [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 ω ↦ by rw [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 := by have hh : (fun n ↦ ∫ ω, (f (terminalTime n) ω)^2 ∂μ) = terminalTime := funext (fun n ↦ h.secondMoment _ (terminalTime_mem n)) rw [hh] at ht exact tendsto_nhds_unique ht (tendsto_nhdsWithin_iff.mp terminalTime_tendsto).1 have hnonneg : 0 ≤ᵐ[μ] (fun ω ↦ 1-(U ω)^2) := hU.mono (fun ω hω ↦ by dsimp nlinarith [abs_le.mp hω.1]) have hzero : ∫ ω, 1-(U ω)^2 ∂μ = 0 := by rw [integral_sub (integrable_const 1) hU2i,hi] simp have he := (integral_eq_zero_iff_of_nonneg_ae hnonneg ((integrable_const 1).sub hU2i)).mp hzero filter_upwards [he] with ω hω change 1-(U ω)^2=0 at hω linarith
lemma 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 : ℝ)) := by have hev : ∀ᶠ t in 𝓝[<] (1 : ℝ), t ∈ Ico (0 : ℝ) 1 := by filter_upwards [Ioo_mem_nhdsLT (show (0 : ℝ)<1 by norm_num)] with t ht exact ⟨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ω ↦ by rw [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ω ↦ by simpa only [sub_self,zero_pow (by decide : (2 : ℕ) ≠ 0)] using (hω.2.sub_const (U ω)).pow 2)) simpa only [integral_zero] using ht
end SKValueend
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909112345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091import Mathlib
import OAI.Probability.SKValue.Equations.ThirdOrderRemainderBound
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
lemma 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) := by
dsimp only
let d := Real.sqrt δ*z+δ*γ t*deriv (V t) x
have 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)) := by
have 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 ring
rw [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 htm
have 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 := by
simpa only [add_sub_cancel_right] using third_order_remainder_bound hsmooth hK hthird x d
have 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 ht
convert hh using 1
congr 1
dsimp only [d]
ring
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.ThirdOrderRemainderBound
namespace OAI
sectionopen 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 BigOperators
lemma 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) := by dsimp only let d := Real.sqrt δ*z+δ*γ t*deriv (V t) x have 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)) := by have 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 ring rw [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 htm have 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 := by simpa only [add_sub_cancel_right] using third_order_remainder_bound hsmooth hK hthird x d have 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 ht convert hh using 1 congr 1 dsimp only [d] ring
end SKValue
end
end OAI12345678910111213141516171819202122232425262728293031321234567891011121314151617181920212223242526272829303132import Mathlib
import OAI.Probability.SKValue.Equations.ResponseContraction
import OAI.Probability.SKValue.Gaussian.UniformError
import OAI.Probability.SKValue.Equations.UniformPolynomial
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal
namespace SKValue
lemma 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.μ)) := by
obtain ⟨C,hC,hb,hfb⟩:=hl.bound
have 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 he
have 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) := by
apply squeeze_zero_norm (fun n ↦ ?_) hel
rw [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 ht
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.ResponseContractionimport OAI.Probability.SKValue.Gaussian.UniformErrorimport OAI.Probability.SKValue.Equations.UniformPolynomial
namespace OAI
sectionopen 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.μ)) := by obtain ⟨C,hC,hb,hfb⟩:=hl.bound have 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 he have 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) := by apply squeeze_zero_norm (fun n ↦ ?_) hel rw [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 SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131import Mathlib
import OAI.Probability.SKValue.Control.Regularity
namespace OAI
section
open MeasureTheory Set Filter Function
open scoped Topology NNReal Nat
namespace SKValue
structure VolterraData (T:ℝ) (hT:0≤T) where
field:ℝ → ℝ → ℝ
lip:ℝ≥0
bound:∀t∈Icc (0:ℝ) T,∀x y,dist (field t x) (field t y)≤lip*dist x y
integ:∀Y:C(Icc (0:ℝ) T,ℝ),IntervalIntegrable (fun s ↦ field s (Y (projIcc 0 T hT s))) volume 0 T
namespace VolterraData
variable {T:ℝ} {hT:0≤T} (D:VolterraData T hT)
noncomputable def next (Y:C(Icc (0:ℝ) T,ℝ)):C(Icc (0:ℝ) T,ℝ) where
toFun t:=∫s in (0:ℝ)..(t:ℝ),D.field s (Y (projIcc 0 T hT s))
continuous_toFun:=by
have hc:=intervalIntegral.continuousOn_primitive_interval' (D.integ Y) left_mem_uIcc
rw [uIcc_of_le hT] at hc
exact hc.domRestrict
lemma 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)) :=rfl
lemma 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 := by
apply (D.integ Y).mono_set
rw [uIcc_of_le t.2.1,uIcc_of_le hT]
exact Icc_subset_Icc le_rfl t.2.2
lemma 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 := by
induction 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 := by
rw [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 hs
rw [uIoc_of_le t.2.1] at hs
have 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 hsT
rw [he] at hp ⊢
apply hp.trans
calc
_≤(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
_≤_:=by
apply le_of_abs_le
rw [←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 := by
obtain ⟨n,hn⟩:= (FloorSemiring.tendsto_pow_div_factorial_atTop ((D.lip:ℝ)*T)).eventually
(gt_mem_nhds zero_lt_one) |>.exists
have hn0:0≤((D.lip:ℝ)*T)^n/n.factorial:=by positivity
have hc:ContractingWith ⟨((D.lip:ℝ)*T)^n/n.factorial,hn0⟩ (D.next)^[n] := by
refine ⟨hn,LipschitzWith.of_dist_le_mul (fun Y Z ↦ ?_)⟩
rw [ContinuousMap.dist_le]
· intro t
apply (D.iterate_bound Y Z n t).trans
simp 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 Z
gcongr
· exact mul_nonneg D.lip.coe_nonneg t.2.1
· exact t.2.2
· positivity
exact ⟨_,hc.isFixedPt_fixedPoint_iterate⟩
end VolterraData
end SKValue
end
section
open MeasureTheory ProbabilityTheory Set Filter Function
open scoped Topology NNReal
namespace SKValue
lemma 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) := by
obtain ⟨K,L,Lu,hLu,hG,hu⟩:=(sourceStripRegularity W γ).core T hT
have hg0:0≤γ.coeff T:=γ.nonneg T hT
have hi:IntervalIntegrable γ.coeff volume 0 T:=γ.intervalIntegrable.mono_set (by
rw [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 hu
let 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:=by
intro t ht x y
have 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.2
simp 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 hh
change _≤(γ.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 ring
integ:=by
intro Y
apply hi.mul_continuousOn
rw [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_fixedPoint
let 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 ht
have he:=congrArg (fun f:C(Icc (0:ℝ) T,ℝ) ↦ f ⟨t,ht⟩) hY
change (∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (X s))=Y ⟨t,ht⟩ at he
dsimp only [X]
rw [projIcc_of_mem hT.1 ht,he]
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Control.Regularity
namespace OAI
sectionopen MeasureTheory Set Filter Functionopen scoped Topology NNReal Natnamespace SKValuestructure VolterraData (T:ℝ) (hT:0≤T) where field:ℝ → ℝ → ℝ lip:ℝ≥0 bound:∀t∈Icc (0:ℝ) T,∀x y,dist (field t x) (field t y)≤lip*dist x y integ:∀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,ℝ) where toFun t:=∫s in (0:ℝ)..(t:ℝ),D.field s (Y (projIcc 0 T hT s)) continuous_toFun:=by have hc:=intervalIntegral.continuousOn_primitive_interval' (D.integ Y) left_mem_uIcc rw [uIcc_of_le hT] at hc exact 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 := by apply (D.integ Y).mono_set rw [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 := by induction 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 := by rw [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 hs rw [uIoc_of_le t.2.1] at hs have 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 hsT rw [he] at hp ⊢ apply hp.trans calc _≤(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 _≤_:=by apply le_of_abs_le rw [←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 := by obtain ⟨n,hn⟩:= (FloorSemiring.tendsto_pow_div_factorial_atTop ((D.lip:ℝ)*T)).eventually (gt_mem_nhds zero_lt_one) |>.exists have hn0:0≤((D.lip:ℝ)*T)^n/n.factorial:=by positivity have hc:ContractingWith ⟨((D.lip:ℝ)*T)^n/n.factorial,hn0⟩ (D.next)^[n] := by refine ⟨hn,LipschitzWith.of_dist_le_mul (fun Y Z ↦ ?_)⟩ rw [ContinuousMap.dist_le] · intro t apply (D.iterate_bound Y Z n t).trans simp 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 Z gcongr · exact mul_nonneg D.lip.coe_nonneg t.2.1 · exact t.2.2 · positivity exact ⟨_,hc.isFixedPt_fixedPoint_iterate⟩end VolterraDataend SKValue
end
sectionopen 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) := by obtain ⟨K,L,Lu,hLu,hG,hu⟩:=(sourceStripRegularity W γ).core T hT have hg0:0≤γ.coeff T:=γ.nonneg T hT have hi:IntervalIntegrable γ.coeff volume 0 T:=γ.intervalIntegrable.mono_set (by rw [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 hu let 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:=by intro t ht x y have 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.2 simp 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 hh change _≤(γ.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 ring integ:=by intro Y apply hi.mul_continuousOn rw [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_fixedPoint let 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 ht have he:=congrArg (fun f:C(Icc (0:ℝ) T,ℝ) ↦ f ⟨t,ht⟩) hY change (∫s in (0:ℝ)..t,γ.coeff s*gradient W γ s (X s))=Y ⟨t,ht⟩ at he dsimp only [X] rw [projIcc_of_mem hT.1 ht,he]end SKValue
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778import Mathlib
import OAI.Probability.SKValue.Equations.RealFiltration
namespace OAI
section
open MeasureTheory ProbabilityTheory Set
open scoped ENNReal NNReal BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology ENNReal NNReal
open Filter Set
open scoped Topology BigOperators
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
open MeasureTheory Set Filter
open scoped Topology BigOperators
open MeasureTheory Set Filter Finset
open scoped Topology BigOperators
namespace SKValue
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology
lemma 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 := by
have 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_congr
intro t ht
rw [uIcc_of_le hT] at ht
change γ t * (∫ ω, U ω * f t ω ∂μ) = t * γ t
rw [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 ω| ∂μ := by
have hUb : ∀ᵐ ω ∂μ, ‖U ω‖≤1 := hb.mono (fun ω hω ↦ by simpa only [Real.norm_eq_abs] using hω)
have hUX := hX.bdd_mul hU hUb
have hUY := hY.bdd_mul hU hUb
rw [←integral_sub hUX hUY]
apply abs_integral_le_integral_abs.trans
apply integral_mono_ae (hUX.sub hUY).abs (hX.sub hY).abs
filter_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 ω ∂μ)) := by
apply tendsto_iff_norm_sub_tendsto_zero.mpr
apply squeeze_zero' (Eventually.of_forall (fun _ ↦ norm_nonneg _)) ?_ hL1
filter_upwards [hX] with t ht
simpa only [Real.norm_eq_abs] using bounded_multiplier_integral_difference hU hb ht hY
end SKValue
end
end OAIimport Mathlibimport OAI.Probability.SKValue.Equations.RealFiltration
namespace OAI
sectionopen 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
lemma 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 := by have 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_congr intro t ht rw [uIcc_of_le hT] at ht change γ t * (∫ ω, U ω * f t ω ∂μ) = t * γ t rw [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 ω| ∂μ := by have hUb : ∀ᵐ ω ∂μ, ‖U ω‖≤1 := hb.mono (fun ω hω ↦ by simpa only [Real.norm_eq_abs] using hω) have hUX := hX.bdd_mul hU hUb have hUY := hY.bdd_mul hU hUb rw [←integral_sub hUX hUY] apply abs_integral_le_integral_abs.trans apply integral_mono_ae (hUX.sub hUY).abs (hX.sub hY).abs filter_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 ω ∂μ)) := by apply tendsto_iff_norm_sub_tendsto_zero.mpr apply squeeze_zero' (Eventually.of_forall (fun _ ↦ norm_nonneg _)) ?_ hL1 filter_upwards [hX] with t ht simpa only [Real.norm_eq_abs] using bounded_multiplier_integral_difference hU hb ht hY
end SKValue
end
end OAIlean/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