import OAI.Geometry.IsometricImmersion.Flows.FlowJointSmooth import Mathlib.Analysis.Calculus.Deriv.MeanValue namespace OAI noncomputable section open Set Filter MeasureTheory Function open scoped ContDiff Topology Interval namespace SmoothLocal.Flow open SmoothLocal.Geometry SmoothLocal.ODE SmoothLocal.Weighted theorem exists_cap_vertical_derivative_bound {q : Coord → ℝ} {U : Set Coord} (hq : ContDiffOn ℝ ∞ q U) (hU : IsOpen U) (hSU : modelSquare ⊆ U) : ∃ M : ℝ, 0 ≤ M ∧ ∀ p ∈ modelSquare, |coordPartial 1 q p| ≤ M := by obtain ⟨M, hM⟩ := modelSquare_isCompact.exists_bound_of_continuousOn ((partial_contDiffOn hq hU 1).continuousOn.mono hSU) refine ⟨max M 0, le_max_right _ _, ?_⟩ intro p hp have hh : |coordPartial 1 q p| ≤ M := by simpa only [Real.norm_eq_abs] using hM p hp exact hh.trans (le_max_left _ _) variable {q : Coord → ℝ} {U : Set Coord} {Y : ℝ → ℝ → ℝ} theorem flow_initial_integral_bound (hq : ContDiffOn ℝ ∞ q U) (hU : IsOpen U) (hSU : modelSquare ⊆ U) (hY : ContinuousOn (uncurry Y) (Icc (-2 : ℝ) 2 ×ˢ Icc (-2 : ℝ) 2)) (hrange : ∀ s ∈ Icc (-2 : ℝ) 2, ∀ t ∈ Icc (-2 : ℝ) 2, Y s t ∈ Icc (-3 : ℝ) 3) {M : ℝ} (hM : 0 ≤ M) (hMq : ∀ p ∈ modelSquare, |coordPartial 1 q p| ≤ M) {s t : ℝ} (hs : s ∈ Icc (-2 : ℝ) 2) (ht : t ∈ Icc (-2 : ℝ) 2) : IntervalIntegrable (fun r => coordPartial 1 q (coordinatePoint r (Y s r))) volume 0 t ∧ |∫ r in 0..t, coordPartial 1 q (coordinatePoint r (Y s r))| ≤ 2 * M := by have hmem (u : ℝ) (hu : u ∈ Icc (-2 : ℝ) 2) : coordinatePoint u (Y s u) ∈ modelSquare := coordinatePoint_mem_modelSquare ⟨by linarith [hu.1], by linarith [hu.2]⟩ (hrange s hs u hu) have hy : ContinuousOn (Y s) (Icc (-2 : ℝ) 2) := hY.comp (f := fun u : ℝ => (s, u)) (by fun_prop) (fun u hu => ⟨hs, hu⟩) have hmap : ContinuousOn (fun u => coordinatePoint u (Y s u)) (Icc (-2 : ℝ) 2) := (continuousOn_id.smul continuousOn_const).add (hy.smul continuousOn_const) have hc : ContinuousOn (fun u => coordPartial 1 q (coordinatePoint u (Y s u))) (Icc (-2 : ℝ) 2) := (partial_contDiffOn hq hU 1).continuousOn.comp hmap (fun u hu => hSU (hmem u hu)) have hseg : uIcc (0 : ℝ) t ⊆ Icc (-2 : ℝ) 2 := uIcc_subset_Icc ⟨by norm_num, by norm_num⟩ ht refine ⟨(hc.mono hseg).intervalIntegrable, ?_⟩ have hh := intervalIntegral.norm_integral_le_of_norm_le_const (a := 0) (b := t) (C := M) (f := fun u => coordPartial 1 q (coordinatePoint u (Y s u))) (fun u hu => by rw [Real.norm_eq_abs] exact hMq _ (hmem u (hseg (uIoc_subset_uIcc hu)))) have ht2 : |t| ≤ 2 := abs_le.mpr ht calc _ ≤ M * |t| := by simpa only [Real.norm_eq_abs, sub_zero] using hh _ ≤ M * 2 := mul_le_mul_of_nonneg_left ht2 hM _ = 2 * M := mul_comm _ _ theorem cap_flow_initial_deriv_bounds (hq : ContDiffOn ℝ ∞ q U) (hU : IsOpen U) (hSU : modelSquare ⊆ U) (hY : ContinuousOn (uncurry Y) (Icc (-2 : ℝ) 2 ×ˢ Icc (-2 : ℝ) 2)) (hrange : ∀ s ∈ Icc (-2 : ℝ) 2, ∀ t ∈ Icc (-2 : ℝ) 2, Y s t ∈ Icc (-3 : ℝ) 3) (hstart : ∀ s ∈ Icc (-2 : ℝ) 2, Y s 0 = s) (hode : ∀ s ∈ Icc (-2 : ℝ) 2, ∀ t ∈ Icc (-2 : ℝ) 2, HasDerivWithinAt (Y s) (-q (coordinatePoint t (Y s t))) (Icc (-2 : ℝ) 2) t) {M : ℝ} (hM : 0 ≤ M) (hMq : ∀ p ∈ modelSquare, |coordPartial 1 q p| ≤ M) {s t : ℝ} (hs : s ∈ Ioo (-2 : ℝ) 2) (ht : t ∈ Ioo (-2 : ℝ) 2) : Real.exp (-2 * M) ≤ deriv (fun u => Y u t) s ∧ deriv (fun u => Y u t) s ≤ Real.exp (2 * M) := by have hI := (flow_initial_integral_bound hq hU hSU hY hrange hM hMq ⟨hs.1.le, hs.2.le⟩ ⟨ht.1.le, ht.2.le⟩).2 rw [(cap_flow_hasDerivAt_initial hq hU hSU hY hrange hstart hode hs ht).deriv] constructor · apply Real.exp_monotone linarith [(abs_le.mp hI).2] · apply Real.exp_monotone linarith [(abs_le.mp hI).1] def triangularFlow (Y : ℝ → ℝ → ℝ) (p : ℝ × ℝ) : ℝ × ℝ := (p.1, Y p.2 p.1) theorem cap_flow_strictMonoOn_initial (hq : ContDiffOn ℝ ∞ q U) (hU : IsOpen U) (hSU : modelSquare ⊆ U) (hY : ContinuousOn (uncurry Y) (Icc (-2 : ℝ) 2 ×ˢ Icc (-2 : ℝ) 2)) (hrange : ∀ s ∈ Icc (-2 : ℝ) 2, ∀ t ∈ Icc (-2 : ℝ) 2, Y s t ∈ Icc (-3 : ℝ) 3) (hstart : ∀ s ∈ Icc (-2 : ℝ) 2, Y s 0 = s) (hode : ∀ s ∈ Icc (-2 : ℝ) 2, ∀ t ∈ Icc (-2 : ℝ) 2, HasDerivWithinAt (Y s) (-q (coordinatePoint t (Y s t))) (Icc (-2 : ℝ) 2) t) {t : ℝ} (ht : t ∈ Ioo (-2 : ℝ) 2) : StrictMonoOn (fun s => Y s t) (Ioo (-2 : ℝ) 2) := by have hc : ContinuousOn (fun s => Y s t) (Ioo (-2 : ℝ) 2) := HasDerivAt.continuousOn (fun s hs => cap_flow_hasDerivAt_initial hq hU hSU hY hrange hstart hode hs ht) apply strictMonoOn_of_deriv_pos (convex_Ioo (-2 : ℝ) 2) hc intro s hs apply cap_flow_initial_deriv_pos hq hU hSU hY hrange hstart hode _ ht simpa only [interior_Ioo] using hs theorem triangularFlow_injOn (hq : ContDiffOn ℝ ∞ q U) (hU : IsOpen U) (hSU : modelSquare ⊆ U) (hY : ContinuousOn (uncurry Y) (Icc (-2 : ℝ) 2 ×ˢ Icc (-2 : ℝ) 2)) (hrange : ∀ s ∈ Icc (-2 : ℝ) 2, ∀ t ∈ Icc (-2 : ℝ) 2, Y s t ∈ Icc (-3 : ℝ) 3) (hstart : ∀ s ∈ Icc (-2 : ℝ) 2, Y s 0 = s) (hode : ∀ s ∈ Icc (-2 : ℝ) 2, ∀ t ∈ Icc (-2 : ℝ) 2, HasDerivWithinAt (Y s) (-q (coordinatePoint t (Y s t))) (Icc (-2 : ℝ) 2) t) : InjOn (triangularFlow Y) (pairRectangle 2 (-2) 2) := by intro p hp z hz he have ht : p.1 = z.1 := by simpa only [triangularFlow] using congrArg (fun v : ℝ × ℝ => v.1) he have hy : Y p.2 p.1 = Y z.2 z.1 := by simpa only [triangularFlow] using congrArg (fun v : ℝ × ℝ => v.2) he rw [ht] at hy exact Prod.ext ht ((cap_flow_strictMonoOn_initial hq hU hSU hY hrange hstart hode hz.1).injOn hp.2 hz.2 hy) end SmoothLocal.Flow end end OAI