cfahlgren1's picture
download
raw
6.69 kB
import Mathlib
namespace OAI
section
open MeasureTheory ProbabilityTheory Set Filter
open scoped Topology NNReal ENNReal BigOperators ContDiff
namespace SKValue
noncomputable def patchTime {E : Type*} (a : ℝ) (f g : ℝ → E) (t : ℝ) : E :=
if t≤a then f t else g (t-a)
lemma patchTime_left {E : Type*} {a t : ℝ} (f g : ℝ → E) (ht : t≤a) :
patchTime a f g t=f t := ite_eq_left ht
lemma patchTime_right {E : Type*} {a t : ℝ} (f g : ℝ → E) (ht : a<t) :
patchTime a f g t=g (t-a) := ite_eq_right (not_le.mpr ht)
lemma patchTime_continuous {a b : ℝ} {f g : ℝ → ℝ}
(hf : ContinuousOn f (Icc (0 : ℝ) a)) (hg : ContinuousOn g (Icc (0 : ℝ) b))
(hfg : f a=g 0) : ContinuousOn (patchTime a f g) (Icc (0 : ℝ) (a+b)) := by
have hf' : ContinuousOn f (Icc (0 : ℝ) (a+b)∩closure (Iic a)) := by
apply hf.mono
simp only [closure_Iic]
exact fun _ hx ↦ ⟨hx.1.1,hx.2⟩
have hg' : ContinuousOn (fun t ↦ g (t-a)) (Icc (0 : ℝ) (a+b)∩closure (Iic a)ᶜ) := by
apply hg.comp (continuous_id.sub continuous_const).continuousOn
simp only [compl_Iic,closure_Ioi]
intro t ht
change 0≤t-a ∧ t-a≤b
exact ⟨sub_nonneg.mpr ht.2,by linarith [ht.1.2]⟩
have he : ∀ t∈Icc (0 : ℝ) (a+b)∩frontier (Iic a), f t=g (t-a) := by
intro t ht
have ht' : t=a := by simpa only [frontier_Iic,mem_singleton_iff] using ht.2
subst t
simpa only [sub_self] using hfg
have hh := ContinuousOn.piecewise he hf' hg'
convert hh using 1
funext t
simp only [patchTime,Set.piecewise,mem_Iic]
lemma patchTime_bound {a b C D : ℝ} (hC : 0≤C) (hD : 0≤D) {f g : ℝ → ℝ}
(hf : ∀ t∈Icc (0 : ℝ) a, |f t|≤C) (hg : ∀ t∈Icc (0 : ℝ) b, |g t|≤D) :
∀ t∈Icc (0 : ℝ) (a+b), |patchTime a f g t|≤C+D := by
intro t ht
by_cases hta : t≤a
· rw [patchTime_left f g hta]
exact (hf t ⟨ht.1,hta⟩).trans (le_add_of_nonneg_right hD)
· rw [patchTime_right f g (lt_of_not_ge hta)]
exact (hg (t-a) ⟨by linarith,by linarith [ht.2]⟩).trans (le_add_of_nonneg_left hC)
lemma patchTime_lipschitz {a b C D : ℝ} (ha : 0≤a) (hb : 0≤b)
(hC : 0≤C) (hD : 0≤D) {f g : ℝ → ℝ}
(hf : ∀ s∈Icc (0 : ℝ) a, ∀ t∈Icc (0 : ℝ) a, |f s-f t|≤C*|s-t|)
(hg : ∀ s∈Icc (0 : ℝ) b, ∀ t∈Icc (0 : ℝ) b, |g s-g t|≤D*|s-t|)
(hfg : f a=g 0) :
∀ s∈Icc (0 : ℝ) (a+b), ∀ t∈Icc (0 : ℝ) (a+b),
|patchTime a f g s-patchTime a f g t|≤(C+D)*|s-t| := by
have hcross {s t : ℝ} (hs : s∈Icc (0 : ℝ) a) (ht : t∈Icc a (a+b)) :
|f s-g (t-a)|≤(C+D)*|s-t| := by
have h1 := hf s hs a ⟨ha,le_rfl⟩
have h2 := hg 0 ⟨le_rfl,hb⟩ (t-a) ⟨sub_nonneg.mpr ht.1,by linarith [ht.2]⟩
have hh := abs_sub_le (f s) (f a) (g (t-a))
rw [hfg] at hh h1
rw [abs_of_nonpos (sub_nonpos.mpr hs.2)] at h1
rw [zero_sub,abs_neg,abs_of_nonneg (sub_nonneg.mpr ht.1)] at h2
rw [abs_of_nonpos (sub_nonpos.mpr (hs.2.trans ht.1))]
nlinarith [mul_nonneg hC (sub_nonneg.mpr ht.1),mul_nonneg hD (sub_nonneg.mpr hs.2)]
intro s hs t ht
by_cases hsa : s≤a <;> by_cases hta : t≤a
· rw [patchTime_left f g hsa,patchTime_left f g hta]
have hh := hf s ⟨hs.1,hsa⟩ t ⟨ht.1,hta⟩
nlinarith [mul_nonneg hD (abs_nonneg (s-t))]
· rw [patchTime_left f g hsa,patchTime_right f g (lt_of_not_ge hta)]
exact hcross ⟨hs.1,hsa⟩ ⟨le_of_lt (lt_of_not_ge hta),ht.2⟩
· rw [patchTime_right f g (lt_of_not_ge hsa),patchTime_left f g hta,abs_sub_comm,abs_sub_comm s t]
exact hcross ⟨ht.1,hta⟩ ⟨le_of_lt (lt_of_not_ge hsa),hs.2⟩
· rw [patchTime_right f g (lt_of_not_ge hsa),patchTime_right f g (lt_of_not_ge hta)]
have hh := hg (s-a) ⟨by linarith,by linarith [hs.2]⟩ (t-a) ⟨by linarith,by linarith [ht.2]⟩
rw [sub_sub_sub_cancel_right] at hh
nlinarith [mul_nonneg hC (abs_nonneg (s-t))]
lemma patchTime_intervalIntegrable {a b : ℝ} (ha : 0≤a) (hb : 0≤b) {f g : ℝ → ℝ}
(hf : IntervalIntegrable f volume 0 a) (hg : IntervalIntegrable g volume 0 b) :
IntervalIntegrable (patchTime a f g) volume 0 (a+b) := by
have hl : IntervalIntegrable (patchTime a f g) volume 0 a := by
apply hf.congr_uIoo
rw [uIoo_of_le ha]
intro t ht
exact (patchTime_left f g ht.2.le).symm
have hr : IntervalIntegrable (fun t ↦ g (t-a)) volume a (a+b) := by
simpa only [zero_add,add_comm b a] using hg.comp_sub_right a
apply hl.trans
apply hr.congr_uIoo
rw [uIoo_of_le (le_add_of_nonneg_right hb)]
intro t ht
exact (patchTime_right f g ht.1).symm
lemma patchTime_integral_left {a s : ℝ} (hs : s∈Icc (0 : ℝ) a) (f g : ℝ → ℝ) :
(∫ r in (0 : ℝ)..s, patchTime a f g r)=∫ r in (0 : ℝ)..s, f r := by
apply intervalIntegral.integral_congr
rw [uIcc_of_le hs.1]
exact fun r hr ↦ patchTime_left f g (hr.2.trans hs.2)
lemma patchTime_integral_right {a s : ℝ} (hs : a ≤ s) (f g : ℝ → ℝ) :
(∫ r in a..s, patchTime a f g r)=∫ r in (0 : ℝ)..(s-a), g r := by
calc
_ = ∫ r in a..s, g (r-a) := by
apply intervalIntegral.integral_congr_Ioo_of_le hs
exact fun r hr ↦ patchTime_right f g hr.1
_ = _ := by rw [intervalIntegral.integral_comp_sub_right,sub_self]
lemma patchTime_primitive {a b : ℝ} (ha : 0≤a) (hb : 0≤b)
{f g p q : ℝ → ℝ} (hp : IntervalIntegrable p volume 0 a)
(hq : IntervalIntegrable q volume 0 b)
(hf : ∀ t∈Icc (0 : ℝ) a, f t-f 0=∫ r in (0 : ℝ)..t, p r)
(hg : ∀ t∈Icc (0 : ℝ) b, g t-g 0=∫ r in (0 : ℝ)..t, q r)
(hfg : f a=g 0) : ∀ t∈Icc (0 : ℝ) (a+b),
patchTime a f g t-patchTime a f g 0=∫ r in (0 : ℝ)..t, patchTime a p q r := by
intro t ht
rw [patchTime_left f g ha]
by_cases hta : t≤a
· rw [patchTime_left f g hta,patchTime_integral_left ⟨ht.1,hta⟩]
exact hf t ⟨ht.1,hta⟩
· rw [patchTime_right f g (lt_of_not_ge hta)]
have hi := patchTime_intervalIntegrable ha hb hp hq
have hsub {s t : ℝ} (hs : s∈Icc (0 : ℝ) (a+b)) (ht : t∈Icc (0 : ℝ) (a+b)) :
uIcc s t⊆uIcc (0 : ℝ) (a+b) := by
rw [uIcc_of_le (add_nonneg ha hb)]
exact uIcc_subset_Icc hs ht
have hh := intervalIntegral.integral_add_adjacent_intervals
(hi.mono_set (hsub ⟨le_rfl,add_nonneg ha hb⟩ ⟨ha,le_add_of_nonneg_right hb⟩))
(hi.mono_set (hsub ⟨ha,le_add_of_nonneg_right hb⟩ ht))
rw [patchTime_integral_left ⟨ha,le_rfl⟩,patchTime_integral_right (le_of_lt (lt_of_not_ge hta))] at hh
have h1 := hf a ⟨ha,le_rfl⟩
have h2 := hg (t-a) ⟨by linarith,by linarith [ht.2]⟩
linarith
end SKValue
end
end OAI

Xet Storage Details

Size:
6.69 kB
·
Xet hash:
6f41bd1422b1736e30e263a00c5ca67182d8eefe3c0f26406be884ee13630875

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