cfahlgren1/math / lean /OAI /Probability /SKValue /Evolution /EvolutionPatch.lean
cfahlgren1's picture
download
raw
8.55 kB
import Mathlib
import OAI.Probability.SKValue.Evolution.SmoothEvolution
import OAI.Probability.SKValue.Evolution.TimePatch
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal ENNReal BigOperators ContDiff
namespace SKValue
lemma patchTime_apply {a t x : ℝ} (V W : ℝ → ℝ → ℝ) :
patchTime a V W t x=patchTime a (fun t ↦ V t x) (fun t ↦ W t x) t := by
by_cases ht : t≤a <;> simp [patchTime,ht]
lemma patchTime_gradient {a t : ℝ} (V W : ℝ → ℝ → ℝ) :
deriv (patchTime a V W t)=patchTime a (fun t ↦ deriv (V t)) (fun t ↦ deriv (W t)) t := by
by_cases ht : t≤a <;> simp [patchTime,ht]
lemma patchTime_jet {a t x : ℝ} (V W : ℝ → ℝ → ℝ) (n : ℕ) :
iteratedDeriv n (deriv (patchTime a V W t)) x=
patchTime a (fun t ↦ iteratedDeriv n (deriv (V t)) x) (fun t ↦ iteratedDeriv n (deriv (W t)) x) t := by
by_cases ht : t≤a <;> simp [patchTime,ht]
lemma SmoothEvolution.value_rhs_integrable {T : ℝ} (hT : 0≤T)
{γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ} (h : SmoothEvolution T γ V)
(hg : IntervalIntegrable γ volume 0 T) (x : ℝ) :
IntervalIntegrable (fun r ↦ -((1/2 : ℝ)*deriv (deriv (V r)) x+
γ r*((1/2 : ℝ)*(deriv (V r) x)^2))) volume 0 T := by
have hc1 : ContinuousOn (fun t ↦ deriv (deriv (V t)) x) (uIcc (0 : ℝ) T) := by
simpa only [uIcc_of_le hT,iteratedDeriv_one] using h.continuous_jet 1 x
have hc0 : ContinuousOn (fun t ↦ deriv (V t) x) (uIcc (0 : ℝ) T) := by
simpa only [uIcc_of_le hT,iteratedDeriv_zero] using h.continuous_jet 0 x
apply IntervalIntegrable.neg
apply IntervalIntegrable.add (hc1.intervalIntegrable.const_mul _)
apply hg.mul_continuousOn
convert! continuousOn_const.mul (hc0.pow 2) using 1
lemma SmoothEvolution.gradient_rhs_integrable {T : ℝ} (hT : 0≤T)
{γ : ℝ → ℝ} {V : ℝ → ℝ → ℝ} (h : SmoothEvolution T γ V)
(hg : IntervalIntegrable γ volume 0 T) (x : ℝ) :
IntervalIntegrable (fun r ↦ -((1/2 : ℝ)*deriv (deriv (deriv (V r))) x+
γ r*(deriv (V r) x*deriv (deriv (V r)) x))) volume 0 T := by
have hc2 : ContinuousOn (fun t ↦ deriv (deriv (deriv (V t))) x) (uIcc (0 : ℝ) T) := by
simpa only [uIcc_of_le hT,show (2:ℕ)=1+1 from rfl,iteratedDeriv_succ,iteratedDeriv_zero]
using h.continuous_jet 2 x
have hc1 : ContinuousOn (fun t ↦ deriv (deriv (V t)) x) (uIcc (0 : ℝ) T) := by
simpa only [uIcc_of_le hT,iteratedDeriv_one] using h.continuous_jet 1 x
have hc0 : ContinuousOn (fun t ↦ deriv (V t) x) (uIcc (0 : ℝ) T) := by
simpa only [uIcc_of_le hT,iteratedDeriv_zero] using h.continuous_jet 0 x
apply IntervalIntegrable.neg
apply IntervalIntegrable.add (hc2.intervalIntegrable.const_mul _)
apply hg.mul_continuousOn
convert! hc0.mul hc1 using 1
lemma primitive_to_integral {T : ℝ} (hT : 0≤T) {f p : ℝ → ℝ}
(hp : IntervalIntegrable p volume 0 T)
(hf : ∀ t∈Icc (0 : ℝ) T, f t-f 0=∫ r in (0 : ℝ)..t, p r)
{s t : ℝ} (hs : s∈Icc (0 : ℝ) T) (ht : t∈Icc (0 : ℝ) T) :
f s-f t=∫ r in t..s, p r := by
have hi {a b : ℝ} (ha : a∈Icc (0 : ℝ) T) (hb : b∈Icc (0 : ℝ) T) :
IntervalIntegrable p volume a b := hp.mono_set (by
rw [uIcc_of_le hT]
exact uIcc_subset_Icc ha hb)
have hh := intervalIntegral.integral_add_adjacent_intervals (hi ⟨le_rfl,hT⟩ ht) (hi ht hs)
rw [←hf s hs,←hf t ht] at hh
linarith
lemma SmoothEvolution.patch_value_pde {a b : ℝ} (ha : 0≤a) (hb : 0≤b)
{γ η : ℝ → ℝ} {V W : ℝ → ℝ → ℝ}
(hV : SmoothEvolution a γ V) (hW : SmoothEvolution b η W)
(hγ : IntervalIntegrable γ volume 0 a) (hη : IntervalIntegrable η volume 0 b)
(hjoin : V a=W 0) {s t : ℝ} (hs : s∈Icc (0 : ℝ) (a+b)) (ht : t∈Icc (0 : ℝ) (a+b)) (x : ℝ) :
patchTime a V W s x-patchTime a V W t x =
-(∫ r in t..s, (1/2 : ℝ)*deriv (deriv (patchTime a V W r)) x+
patchTime a γ η r*((1/2 : ℝ)*(deriv (patchTime a V W r) x)^2)) := by
let p := fun r ↦ -((1/2 : ℝ)*deriv (deriv (V r)) x+γ r*((1/2 : ℝ)*(deriv (V r) x)^2))
let q := fun r ↦ -((1/2 : ℝ)*deriv (deriv (W r)) x+η r*((1/2 : ℝ)*(deriv (W r) x)^2))
have hp := hV.value_rhs_integrable ha hγ x
have hq := hW.value_rhs_integrable hb hη x
have hv : ∀ t∈Icc (0 : ℝ) a, V t x-V 0 x=∫ r in (0 : ℝ)..t, p r := by
intro t ht
simpa only [p,intervalIntegral.integral_neg] using hV.value_pde 0 ⟨le_rfl,ha⟩ t ht x
have hw : ∀ t∈Icc (0 : ℝ) b, W t x-W 0 x=∫ r in (0 : ℝ)..t, q r := by
intro t ht
simpa only [q,intervalIntegral.integral_neg] using hW.value_pde 0 ⟨le_rfl,hb⟩ t ht x
have he := primitive_to_integral (add_nonneg ha hb) (patchTime_intervalIntegrable ha hb hp hq)
(patchTime_primitive ha hb hp hq hv hw (congrFun hjoin x)) hs ht
rw [←patchTime_apply V W,←patchTime_apply V W] at he
rw [he,←intervalIntegral.integral_neg]
apply intervalIntegral.integral_congr
intro r _
by_cases hr : r≤a <;> simp [patchTime,hr]
lemma SmoothEvolution.patch_gradient_pde {a b : ℝ} (ha : 0≤a) (hb : 0≤b)
{γ η : ℝ → ℝ} {V W : ℝ → ℝ → ℝ}
(hV : SmoothEvolution a γ V) (hW : SmoothEvolution b η W)
(hγ : IntervalIntegrable γ volume 0 a) (hη : IntervalIntegrable η volume 0 b)
(hjoin : V a=W 0) {s t : ℝ} (hs : s∈Icc (0 : ℝ) (a+b)) (ht : t∈Icc (0 : ℝ) (a+b)) (x : ℝ) :
deriv (patchTime a V W s) x-deriv (patchTime a V W t) x =
-(∫ r in t..s, (1/2 : ℝ)*deriv (deriv (deriv (patchTime a V W r))) x+
patchTime a γ η r*(deriv (patchTime a V W r) x*deriv (deriv (patchTime a V W r)) x)) := by
let p := fun r ↦ -((1/2 : ℝ)*deriv (deriv (deriv (V r))) x+γ r*(deriv (V r) x*deriv (deriv (V r)) x))
let q := fun r ↦ -((1/2 : ℝ)*deriv (deriv (deriv (W r))) x+η r*(deriv (W r) x*deriv (deriv (W r)) x))
have hp := hV.gradient_rhs_integrable ha hγ x
have hq := hW.gradient_rhs_integrable hb hη x
have hv : ∀ t∈Icc (0 : ℝ) a, deriv (V t) x-deriv (V 0) x=∫ r in (0 : ℝ)..t, p r := by
intro t ht
simpa only [p,intervalIntegral.integral_neg] using hV.gradient_pde 0 ⟨le_rfl,ha⟩ t ht x
have hw : ∀ t∈Icc (0 : ℝ) b, deriv (W t) x-deriv (W 0) x=∫ r in (0 : ℝ)..t, q r := by
intro t ht
simpa only [q,intervalIntegral.integral_neg] using hW.gradient_pde 0 ⟨le_rfl,hb⟩ t ht x
have hj : deriv (V a) x=deriv (W 0) x := by rw [hjoin]
have he := primitive_to_integral (add_nonneg ha hb) (patchTime_intervalIntegrable ha hb hp hq)
(patchTime_primitive ha hb hp hq hv hw hj) hs ht
simp_rw [patchTime_gradient,patchTime_apply]
rw [he,←intervalIntegral.integral_neg]
apply intervalIntegral.integral_congr
intro r _
by_cases hr : r≤a <;> simp [patchTime,hr]
lemma SmoothEvolution.patch {a b : ℝ} (ha : 0≤a) (hb : 0≤b)
{γ η : ℝ → ℝ} {V W : ℝ → ℝ → ℝ}
(hV : SmoothEvolution a γ V) (hW : SmoothEvolution b η W)
(hγ : IntervalIntegrable γ volume 0 a) (hη : IntervalIntegrable η volume 0 b)
(hjoin : V a=W 0) :
SmoothEvolution (a+b) (patchTime a γ η) (patchTime a V W) := by
refine ⟨?_,?_,?_,?_,?_,?_,?_⟩
· intro t ht
by_cases hta : t≤a
· rw [patchTime_left V W hta]
exact hV.slices t ⟨ht.1,hta⟩
· rw [patchTime_right V W (lt_of_not_ge hta)]
exact hW.slices (t-a) ⟨by linarith,by linarith [ht.2]⟩
· intro x
simp_rw [patchTime_apply]
exact patchTime_continuous (hV.continuous_value x) (hW.continuous_value x) (congrFun hjoin x)
· intro n x
simp_rw [patchTime_jet]
apply patchTime_continuous (hV.continuous_jet n x) (hW.continuous_jet n x)
rw [hjoin]
· intro n
obtain ⟨C,hC,hv⟩ := hV.bound n
obtain ⟨D,hD,hw⟩ := hW.bound n
refine ⟨C+D,add_nonneg hC hD,?_⟩
intro t ht x
rw [patchTime_jet]
exact patchTime_bound hC hD (fun t ht ↦ hv t ht x) (fun t ht ↦ hw t ht x) t ht
· intro n
obtain ⟨C,hC,hv⟩ := hV.temporal n
obtain ⟨D,hD,hw⟩ := hW.temporal n
refine ⟨C+D,add_nonneg hC hD,?_⟩
intro s hs t ht x
rw [patchTime_jet,patchTime_jet]
apply patchTime_lipschitz ha hb hC hD (fun s hs t ht ↦ hv s hs t ht x)
(fun s hs t ht ↦ hw s hs t ht x) _ s hs t ht
rw [hjoin]
· intro t ht s hs x
exact hV.patch_value_pde ha hb hW hγ hη hjoin hs ht x
· intro t ht s hs x
exact hV.patch_gradient_pde ha hb hW hγ hη hjoin hs ht x
end SKValue
end
end OAI

Xet Storage Details

Size:
8.55 kB
·
Xet hash:
fddc5ee3467061fff1574ec2d9a891fcfb2450f73f7177e8bea6387e918887fe

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.