Download lean/OAI/Analysis/HardSphere/Bridges/PrefixMap.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 9.05 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Analysis/HardSphere/Bridges/PrefixMap.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Analysis/HardSphere/Bridges/PrefixMap.lean
-
curl -L -o PrefixMap.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Analysis/HardSphere/Bridges/PrefixMap.lean
9.05 kB
Lean 4 · 13
declarations statementsfull
def prefixMap (u : Time) : C(Time,ℝ) →L[ℝ] C(Time,ℝ) := body · 1 line
ContinuousMap.compCLM ℝ ℝ (prefixTime u)def suffixMap (u : Time) : C(Time,ℝ) →L[ℝ] C(Time,ℝ) := body · 2 lines
ContinuousMap.compCLM ℝ ℝ (suffixTime u) -
(ContinuousLinearMap.const ℝ Time).comp (ContinuousMap.evalCLM ℝ u)@[simp] lemma prefixMap_apply (u : Time) (f : C(Time,ℝ)) (t : Time) :
prefixMap u f t = f (prefixTime u t) := rfl @[simp] lemma suffixMap_apply (u : Time) (f : C(Time,ℝ)) (t : Time) :
suffixMap u f t = f (suffixTime u t) - f u := rfl lemma prefixTime_le (u t : Time) : (prefixTime u t:ℝ) ≤ u := by proof · 2 lines
change (u:ℝ)*(t:ℝ) ≤ u
nlinarith [u.property.1,t.property.2]lemma le_suffixTime (u t : Time) : (u:ℝ) ≤ suffixTime u t := by proof · 2 lines
change (u:ℝ) ≤ (u:ℝ)+(1-(u:ℝ))*(t:ℝ)
nlinarith [u.property.2,t.property.1]lemma split_gaussian (u : Time) :
IsGaussianProcess (Sum.elim (fun t ω ↦ prefixMap u (path ω) t)
(fun t ω ↦ suffixMap u (path ω) t)) law := by proof · 13 lines
classical
constructor
intro I
let loc : Option I → Time := fun i ↦ i.elim u
(fun j ↦ j.val.elim (prefixTime u) (suffixTime u))
let ev (i : Option I) : (Option I → ℝ) →L[ℝ] ℝ := ContinuousLinearMap.proj i
let L : (Option I → ℝ) →L[ℝ] (I → ℝ) :=
ContinuousLinearMap.pi (fun i ↦ match i.val with
| .inl _ => ev (some i)
| .inr _ => ev (some i) - ev none)
convert! (finite_path_gaussian loc).map_fun L using 1
funext ω i
cases hi : i.val <;> simp [L,loc,hi,ev]lemma independent_split (u : Time) :
IndepFun (fun ω ↦ prefixMap u (path ω)) (fun ω ↦ suffixMap u (path ω)) law := by proof · 21 lines
have hc (s t : Time) :
cov[fun ω ↦ prefixMap u (path ω) s, fun ω ↦ suffixMap u (path ω) t; law] = 0 := by
simp only [prefixMap_apply,suffixMap_apply]
rw [covariance_fun_sub_right
(path_eval_law _).hasGaussianLaw.memLp_two
(path_eval_law _).hasGaussianLaw.memLp_two
(path_eval_law _).hasGaussianLaw.memLp_two,
path_covariance,path_covariance,
min_eq_left ((prefixTime_le u s).trans (le_suffixTime u t)),
min_eq_left (prefixTime_le u s),sub_self]
have hi := (split_gaussian u).indepFun_of_covariance_eq_zero
(fun t ↦ ((continuous_eval_const t).measurable.comp
((prefixMap u).continuous.measurable.comp measurable_path)).aemeasurable)
(fun t ↦ ((continuous_eval_const t).measurable.comp
((suffixMap u).continuous.measurable.comp measurable_path)).aemeasurable) hc
have hid := hi.comp
(Measurable.of_eval fun index ↦ measurable_pi_apply (TopologicalSpace.denseSeq Time index))
(Measurable.of_eval fun index ↦ measurable_pi_apply (TopologicalSpace.denseSeq Time index))
have hh := hid.comp denseEval_embedding.measurable_invFun denseEval_embedding.measurable_invFun
convert hh using 1 <;> funext ω <;>
exact (denseEval_embedding.leftInverse_invFun _).symmlemma scaled_path_projection_law {ι : Type*} [Fintype ι]
(r : ℝ) (hr : 0 ≤ r) (c : ι → ℝ) (t : ι → Time) :
HasLaw (fun ω ↦ ∑ i, c i * (Real.sqrt r • path ω) (t i))
(gaussianReal 0 (Real.toNNReal (r * ∑ i, ∑ j,
c i*c j*min (t i:ℝ) (t j:ℝ)))) law := by proof · 19 lines
have hh := path_projection_law (fun i ↦ c i * Real.sqrt r) t
convert hh using 1
· funext ω
apply Finset.sum_congr rfl
intro i _
simp only [ContinuousMap.smul_apply,smul_eq_mul]
ring
· congr 1
congr 1
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro i _
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro j _
calc
r * (c i*c j*min (t i:ℝ) (t j:ℝ)) =
Real.sqrt r ^ 2 * (c i*c j*min (t i:ℝ) (t j:ℝ)) := by rw [Real.sq_sqrt hr]
_ = _ := by ringlemma prefix_law (u : Time) :
law.map (fun ω ↦ prefixMap u (path ω)) =
law.map (fun ω ↦ Real.sqrt (u:ℝ) • path ω) := by proof · 20 lines
apply continuous_path_law_ext (X := fun ω ↦ prefixMap u (path ω))
(Y := fun ω ↦ Real.sqrt (u:ℝ) • path ω)
((prefixMap u).continuous.measurable.comp measurable_path)
((show Measurable (fun f : C(Time,ℝ) ↦ Real.sqrt (u:ℝ) • f) from
(by fun_prop)).comp measurable_path)
intro ι _ c t
have h := path_projection_law c (fun i ↦ prefixTime u (t i))
have hvar : (∑ i, ∑ j, c i*c j*min (prefixTime u (t i):ℝ) (prefixTime u (t j):ℝ)) =
(u:ℝ)*∑ i, ∑ j, c i*c j*min (t i:ℝ) (t j:ℝ) := by
simp only [prefixTime,ContinuousMap.coe_mk]
simp_rw [← mul_min_of_nonneg _ _ u.property.1]
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro i _
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro j _
ring
rw [hvar] at h
exact h.map_eq.trans (scaled_path_projection_law _ u.property.1 c t).map_eq.symmlemma suffix_projection_algebra {ι : Type*} [Fintype ι]
(u : Time) (c : ι → ℝ) (t : ι → Time) :
let a : Option ι → ℝ := fun i ↦ i.elim (-∑ i, c i) c proof · 37 lines
let v : Option ι → Time := fun i ↦ i.elim u (fun j ↦ suffixTime u (t j))
(∑ i, ∑ j, a i*a j*min (v i:ℝ) (v j:ℝ)) =
(1-(u:ℝ))*∑ i, ∑ j, c i*c j*min (t i:ℝ) (t j:ℝ) := by
let A : ℝ := ∑ i, c i
have hh : (∑ i, ∑ j, c i*c j*(u:ℝ)) = A*A*(u:ℝ) := by
dsimp only [A]
rw [Finset.sum_mul_sum, Finset.sum_mul]
apply Finset.sum_congr rfl
intro i _
rw [Finset.sum_mul]
have h1 : (∑ i, (-A)*c i*(u:ℝ)) = -A*A*(u:ℝ) := by
rw [← Finset.sum_mul, ← Finset.mul_sum]
have h2 : (∑ i, c i*(-A)*(u:ℝ)) = -A*A*(u:ℝ) := by
rw [← Finset.sum_mul, ← Finset.sum_mul]
dsimp only [A]
ring
have h3 : (∑ i, ∑ j, c i*c j*((1-(u:ℝ))*min (t i:ℝ) (t j:ℝ))) =
(1-(u:ℝ))*∑ i, ∑ j, c i*c j*min (t i:ℝ) (t j:ℝ) := by
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro i _
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro j _
ring
dsimp only
simp only [Fintype.sum_option,Option.elim_none,Option.elim_some,
min_self,min_eq_left (le_suffixTime u (t _)),min_eq_right (le_suffixTime u (t _))]
have ht i j : min (suffixTime u (t i):ℝ) (suffixTime u (t j):ℝ) =
(u:ℝ)+(1-(u:ℝ))*min (t i:ℝ) (t j:ℝ) := by
change min ((u:ℝ)+(1-(u:ℝ))*(t i:ℝ)) ((u:ℝ)+(1-(u:ℝ))*(t j:ℝ)) = _
rw [min_add_add_left,← mul_min_of_nonneg _ _ (sub_nonneg.mpr u.property.2)]
simp_rw [ht,mul_add,Finset.sum_add_distrib]
change (-A)*(-A)*(u:ℝ)+(∑ i,(-A)*c i*(u:ℝ))+
((∑ i,c i*(-A)*(u:ℝ))+((∑ i,∑ j,c i*c j*(u:ℝ))+_)) = _
rw [hh,h1,h2,h3]
ringlemma suffix_law (u : Time) :
law.map (fun ω ↦ suffixMap u (path ω)) =
law.map (fun ω ↦ Real.sqrt (1-(u:ℝ)) • path ω) := by proof · 18 lines
apply continuous_path_law_ext (X := fun ω ↦ suffixMap u (path ω))
(Y := fun ω ↦ Real.sqrt (1-(u:ℝ)) • path ω)
((suffixMap u).continuous.measurable.comp measurable_path)
((show Measurable (fun f : C(Time,ℝ) ↦ Real.sqrt (1-(u:ℝ)) • f) from
(by fun_prop)).comp measurable_path)
intro ι _ c t
have hh := path_projection_law (fun i : Option ι ↦ i.elim (-∑ i,c i) c)
(fun i ↦ i.elim u (fun j ↦ suffixTime u (t j)))
rw [suffix_projection_algebra] at hh
have heq : (fun ω ↦ ∑ i, c i*suffixMap u (path ω) (t i)) =
(fun ω ↦ ∑ i : Option ι, i.elim (-∑ i,c i) c *
path ω (i.elim u (fun j ↦ suffixTime u (t j)))) := by
funext ω
simp only [Fintype.sum_option,Option.elim_none,Option.elim_some,suffixMap_apply,
mul_sub,Finset.sum_sub_distrib,neg_mul,Finset.sum_mul]
ring
rw [heq, hh.map_eq,
(scaled_path_projection_law _ (sub_nonneg.mpr u.property.2) c t).map_eq]lemma split_path_law (u : Time) :
law.map (fun ω ↦ (prefixMap u (path ω),suffixMap u (path ω))) =
(wiener.map (fun f ↦ Real.sqrt (u:ℝ) • f)).prod
(wiener.map (fun f ↦ Real.sqrt (1-(u:ℝ)) • f)) := by proof · 12 lines
calc
_ = (law.map (fun ω ↦ prefixMap u (path ω))).prod
(law.map (fun ω ↦ suffixMap u (path ω))) := by
simpa only [Function.comp_def] using (independent_split u).map_prod_eq_prod_map_map
((prefixMap u).continuous.measurable.comp measurable_path).aemeasurable
((suffixMap u).continuous.measurable.comp measurable_path).aemeasurable
_ = _ := by
rw [prefix_law,suffix_law]
unfold wiener
rw [Measure.map_map (show Measurable (fun f : C(Time,ℝ) ↦ Real.sqrt (u:ℝ) • f) from by fun_prop) measurable_path,
Measure.map_map (show Measurable (fun f : C(Time,ℝ) ↦ Real.sqrt (1-(u:ℝ)) • f) from by fun_prop) measurable_path]
rflOutline