import Euler.InitialTimePrimitive import Mathlib.Analysis.SpecialFunctions.Integrals.Basic import Euler.TimeH1PointwiseBounds import Euler.TimeH1OperatorProduct /-! An explicit terminal-layer H¹ trial obtained by multiplying a differentiable projection path by the smooth exponential ramp. Both energy estimates concern the actual Bochner L² derivative and primitive. -/ /-! ## From `Euler/TerminalLayerRamp.lean` The text of `Euler/TerminalLayerRamp.lean`, folded into this file, which was its only importer. -/ section /-! An explicit smooth terminal-layer trial profile. Its endpoint values are zero and one, and its squared value/derivative integrals are at most `2/L` and `2*L` when `L*T ≥ 1`. These are the same energy bounds needed for the piecewise linear terminal ramp in the activation argument. -/ noncomputable section namespace EulerTerminalLayerRamp open Set MeasureTheory def ramp (T L t : ℝ) : ℝ := (Real.exp (L * (t - T)) - Real.exp (-L * T)) / (1 - Real.exp (-L * T)) def rampDerivative (T L t : ℝ) : ℝ := L * Real.exp (L * (t - T)) / (1 - Real.exp (-L * T)) theorem denominator_lower {T L : ℝ} (hLT : 1 ≤ L * T) : (1 / 2 : ℝ) ≤ 1 - Real.exp (-L * T) := by have he : 2 ≤ Real.exp (L * T) := by linarith only [Real.add_one_le_exp (L * T), hLT] have hp : Real.exp (L * T) * Real.exp (-L * T) = 1 := by rw [← Real.exp_add] rw [show L * T + -L * T = 0 by ring, Real.exp_zero] have hm := mul_le_mul_of_nonneg_right he (Real.exp_nonneg (-L * T)) linarith only [hp, hm] theorem denominator_pos {T L : ℝ} (hLT : 1 ≤ L * T) : 0 < 1 - Real.exp (-L * T) := lt_of_lt_of_le (by norm_num) (denominator_lower hLT) @[simp] theorem ramp_initial (T L : ℝ) : ramp T L 0 = 0 := by simp [ramp, mul_neg] theorem ramp_terminal {T L : ℝ} (hLT : 1 ≤ L * T) : ramp T L T = 1 := by simp only [ramp, sub_self, mul_zero, Real.exp_zero] exact div_self (denominator_pos hLT).ne' theorem ramp_hasDerivAt (T L t : ℝ) : HasDerivAt (ramp T L) (rampDerivative T L t) t := by change HasDerivAt (fun s => (Real.exp (L * (s - T)) - Real.exp (-L * T)) / (1 - Real.exp (-L * T))) (L * Real.exp (L * (t - T)) / (1 - Real.exp (-L * T))) t simpa only [id_eq, mul_one, mul_comm] using (((((hasDerivAt_id t).sub_const T).const_mul L).exp).sub_const (Real.exp (-L * T))).div_const (1 - Real.exp (-L * T)) theorem ramp_continuous (T L : ℝ) : Continuous (ramp T L) := continuous_iff_continuousAt.2 fun t => (ramp_hasDerivAt T L t).continuousAt theorem rampDerivative_continuous (T L : ℝ) : Continuous (rampDerivative T L) := by unfold rampDerivative fun_prop theorem ramp_nonneg {T L t : ℝ} (hL : 0 ≤ L) (hLT : 1 ≤ L * T) (ht : 0 ≤ t) : 0 ≤ ramp T L t := by apply div_nonneg _ (denominator_pos hLT).le apply sub_nonneg.mpr (Real.exp_le_exp.mpr _) linarith only [mul_nonneg hL ht] theorem ramp_le_exp {T L t : ℝ} (hLT : 1 ≤ L * T) : ramp T L t ≤ 2 * Real.exp (L * (t - T)) := by apply (div_le_iff₀ (denominator_pos hLT)).2 have hm := mul_le_mul_of_nonneg_right (denominator_lower hLT) (Real.exp_nonneg (L * (t - T))) linarith only [hm, Real.exp_nonneg (-L * T)] theorem rampDerivative_nonneg {T L t : ℝ} (hL : 0 ≤ L) (hLT : 1 ≤ L * T) : 0 ≤ rampDerivative T L t := div_nonneg (mul_nonneg hL (Real.exp_nonneg _)) (denominator_pos hLT).le theorem rampDerivative_le_exp {T L t : ℝ} (hL : 0 ≤ L) (hLT : 1 ≤ L * T) : rampDerivative T L t ≤ 2 * L * Real.exp (L * (t - T)) := by apply (div_le_iff₀ (denominator_pos hLT)).2 have hm := mul_le_mul_of_nonneg_right (denominator_lower hLT) (mul_nonneg hL (Real.exp_nonneg (L * (t - T)))) linarith only [hm] theorem ramp_sq_le {T L t : ℝ} (hL : 0 ≤ L) (hLT : 1 ≤ L * T) (ht : 0 ≤ t) : ramp T L t ^ 2 ≤ 4 * Real.exp (2 * L * (t - T)) := by have hp := pow_le_pow_left₀ (ramp_nonneg hL hLT ht) (ramp_le_exp (t := t) hLT) 2 have he : Real.exp (L * (t - T)) ^ 2 = Real.exp (2 * L * (t - T)) := by rw [pow_two, ← Real.exp_add] congr 1 ring simpa only [mul_pow, he, show (2 : ℝ) ^ 2 = 4 by norm_num] using hp theorem rampDerivative_sq_le {T L t : ℝ} (hL : 0 ≤ L) (hLT : 1 ≤ L * T) : rampDerivative T L t ^ 2 ≤ (4 * L ^ 2) * Real.exp (2 * L * (t - T)) := by have hp := pow_le_pow_left₀ (rampDerivative_nonneg (t := t) hL hLT) (rampDerivative_le_exp (t := t) hL hLT) 2 have he : Real.exp (L * (t - T)) ^ 2 = Real.exp (2 * L * (t - T)) := by rw [pow_two, ← Real.exp_add] congr 1 ring simpa only [mul_pow, he, show (2 : ℝ) ^ 2 = 4 by norm_num] using hp theorem exp_kernel_integral_le {T L : ℝ} (hL : 0 < L) : (∫ t in 0..T, Real.exp (2 * L * (t - T))) ≤ 1 / (2 * L) := by have hd (t : ℝ) : HasDerivAt (fun s => Real.exp (2 * L * (s - T)) / (2 * L)) (Real.exp (2 * L * (t - T))) t := by simpa only [id_eq, mul_one, mul_div_cancel_right₀ _ (show 2 * L ≠ 0 by positivity)] using (((((hasDerivAt_id t).sub_const T).const_mul (2 * L)).exp).div_const (2 * L)) have hi := intervalIntegral.integral_eq_sub_of_hasDerivAt (fun t _ => hd t) ((Real.continuous_exp.comp (continuous_const.mul (continuous_id.sub continuous_const))).intervalIntegrable 0 T) calc (∫ t in 0..T, Real.exp (2 * L * (t - T))) = (1 - Real.exp (2 * L * (0 - T))) / (2 * L) := by rw [hi, sub_self, mul_zero, Real.exp_zero, sub_div] _ ≤ 1 / (2 * L) := div_le_div_of_nonneg_right (sub_le_self _ (Real.exp_nonneg _)) (by positivity) theorem ramp_energy {T L : ℝ} (hT : 0 ≤ T) (hL : 0 < L) (hLT : 1 ≤ L * T) : (∫ t in 0..T, ramp T L t ^ 2) ≤ 2 / L := by have hc : Continuous (fun t : ℝ => Real.exp (2 * L * (t - T))) := by fun_prop have hi := intervalIntegral.integral_mono_on (μ := volume) hT (((ramp_continuous T L).pow 2).intervalIntegrable 0 T) ((continuous_const.mul hc).intervalIntegrable (a := 0) (b := T)) (fun t ht => ramp_sq_le hL.le hLT ht.1) change (∫ t in 0..T, ramp T L t ^ 2) ≤ ∫ t in 0..T, 4 * Real.exp (2 * L * (t - T)) at hi rw [intervalIntegral.integral_const_mul] at hi calc (∫ t in 0..T, ramp T L t ^ 2) ≤ 4 * (∫ t in 0..T, Real.exp (2 * L * (t - T))) := hi _ ≤ 4 * (1 / (2 * L)) := mul_le_mul_of_nonneg_left (exp_kernel_integral_le hL) (by norm_num) _ = 2 / L := by ring theorem rampDerivative_energy {T L : ℝ} (hT : 0 ≤ T) (hL : 0 < L) (hLT : 1 ≤ L * T) : (∫ t in 0..T, rampDerivative T L t ^ 2) ≤ 2 * L := by have hc : Continuous (fun t : ℝ => Real.exp (2 * L * (t - T))) := by fun_prop have hi := intervalIntegral.integral_mono_on (μ := volume) hT (((rampDerivative_continuous T L).pow 2).intervalIntegrable 0 T) ((continuous_const.mul hc).intervalIntegrable (a := 0) (b := T)) (fun t _ => rampDerivative_sq_le (t := t) hL.le hLT) change (∫ t in 0..T, rampDerivative T L t ^ 2) ≤ ∫ t in 0..T, (4 * L ^ 2) * Real.exp (2 * L * (t - T)) at hi rw [intervalIntegral.integral_const_mul] at hi calc (∫ t in 0..T, rampDerivative T L t ^ 2) ≤ (4 * L ^ 2) * (∫ t in 0..T, Real.exp (2 * L * (t - T))) := hi _ ≤ (4 * L ^ 2) * (1 / (2 * L)) := mul_le_mul_of_nonneg_left (exp_kernel_integral_le hL) (by positivity) _ = 2 * L := by field_simp; ring end EulerTerminalLayerRamp end end noncomputable section namespace EulerTerminalProjectionTrial open MeasureTheory Set InnerProductSpace ContinuousLinearMap EulerTimeLp EulerTerminalTimePrimitive EulerInitialTimePrimitive EulerTimeH1OperatorProduct EulerTimeH1PointwiseBounds EulerVolterraConvolution EulerTerminalLayerRamp variable {E U : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E] [NormedAddCommGroup U] [NormedSpace ℝ U] private local instance : NormedAddCommGroup (U →L[ℝ] E) := inferInstance private local instance : NormedSpace ℝ (U →L[ℝ] E) := inferInstance private local instance : AddCommGroup (U →L[ℝ] E) := (inferInstance : NormedAddCommGroup (U →L[ℝ] E)).toAddCommGroup private local instance : Module ℝ (U →L[ℝ] E) := (inferInstance : NormedSpace ℝ (U →L[ℝ] E)).toModule private local instance : TopologicalSpace (U →L[ℝ] E) := (inferInstance : PseudoMetricSpace (U →L[ℝ] E)).toUniformSpace.toTopologicalSpace variable (T : ℝ) (hT : 0 ≤ T) (L : ℝ) (P P₁ : C(Icc (0 : ℝ) T, U →L[ℝ] E)) /-- Evaluation of an actual continuous operator path as a bounded map into paths. -/ def operatorEvaluation (A : C(Icc (0 : ℝ) T, U →L[ℝ] E)) : U →L[ℝ] C(Icc (0 : ℝ) T, E) := ({ toFun := fun Y => ⟨fun t => A t Y, A.continuous.clm_apply continuous_const⟩ map_add' := by intros; ext; simp map_smul' := by intros; ext; simp } : U →ₗ[ℝ] C(Icc (0 : ℝ) T, E)).mkContinuous ‖A‖ (by intro Y change ‖(⟨fun t => A t Y, A.continuous.clm_apply continuous_const⟩ : C(Icc (0 : ℝ) T, E))‖ ≤ ‖A‖ * ‖Y‖ apply (ContinuousMap.norm_le _ (mul_nonneg (norm_nonneg A) (norm_nonneg Y))).2 intro t exact (A t).le_opNorm Y |>.trans (mul_le_mul_of_nonneg_right (A.norm_coe_le_norm t) (norm_nonneg Y))) omit [CompleteSpace E] in @[simp] theorem operatorEvaluation_apply (A : C(Icc (0 : ℝ) T, U →L[ℝ] E)) (Y : U) (t : Icc (0 : ℝ) T) : operatorEvaluation T A Y t = A t Y := rfl def trialFrame : C(Icc (0 : ℝ) T, U →L[ℝ] E) := ⟨fun t => ramp T L t • P t, ((ramp_continuous T L).comp continuous_subtype_val).smul P.continuous⟩ def trialFrameDerivative : C(Icc (0 : ℝ) T, U →L[ℝ] E) := ⟨fun t => rampDerivative T L t • P t + ramp T L t • P₁ t, (((rampDerivative_continuous T L).comp continuous_subtype_val).smul P.continuous).add (((ramp_continuous T L).comp continuous_subtype_val).smul P₁.continuous)⟩ def trialDerivative : U →L[ℝ] TimeLp T E := (pathLpOperator T hT).comp (operatorEvaluation T (trialFrameDerivative T L P P₁)) variable (hd : ∀ t : Icc (0 : ℝ) T, HasDerivWithinAt (extendPath T hT P) (P₁ t) (Icc (0 : ℝ) T) t) include hd in omit [CompleteSpace E] in theorem trialFrame_hasDerivWithinAt (t : Icc (0 : ℝ) T) : HasDerivWithinAt (extendPath T hT (trialFrame T L P)) (trialFrameDerivative T L P P₁ t) (Icc (0 : ℝ) T) t := by have hs := (ramp_hasDerivAt T L t).hasDerivWithinAt.smul (hd t) have hs' : HasDerivWithinAt (fun s => ramp T L s • extendPath T hT P s) (trialFrameDerivative T L P P₁ t) (Icc (0 : ℝ) T) t := by convert! hs using 1 simp only [trialFrameDerivative, ContinuousMap.coe_mk, extendPath, projIcc_of_mem hT t.property, add_comm] apply hs'.congr_of_mem _ t.property intro s hs simp only [extendPath, projIcc_of_mem hT hs, trialFrame, ContinuousMap.coe_mk] include hd in omit [CompleteSpace E] in /-- The trial derivative is the actual derivative of its explicit ramp-times-projection path. -/ theorem trialDerivative_realizes (Y : U) : ∀ᵐ t ∂timeMeasure T, HasDerivAt (fun s => extendPath T hT (trialFrame T L P) s Y) (trialDerivative T hT L P P₁ Y t) t := by have hmem : ∀ᵐ t ∂timeMeasure T, t ∈ Ioo (0 : ℝ) T := by change ∀ᵐ t ∂volume.restrict (Icc (0 : ℝ) T), t ∈ Ioo (0 : ℝ) T rw [← restrict_Ioo_eq_restrict_Icc] exact ae_restrict_mem measurableSet_Ioo filter_upwards [hmem, pathLp_ae T hT (operatorEvaluation T (trialFrameDerivative T L P P₁) Y)] with t ht hu change trialDerivative T hT L P P₁ Y t = extendPath T hT (operatorEvaluation T (trialFrameDerivative T L P P₁) Y) t at hu rw [hu] have hg := (trialFrame_hasDerivWithinAt T hT L P P₁ hd ⟨t, ht.1.le, ht.2.le⟩).hasDerivAt (Icc_mem_nhds ht.1 ht.2) simpa only [extendPath, projIcc_of_mem hT ⟨ht.1.le, ht.2.le⟩, operatorEvaluation_apply, map_zero, add_zero] using hg.clm_apply (hasDerivAt_const t Y) include hd in /-- Integrating the constructed L² derivative gives the prescribed trial at every time. -/ theorem initialPrimitive_trialDerivative (Y : U) (t : Icc (0 : ℝ) T) : initialPrimitive T hT (trialDerivative T hT L P P₁ Y) t = ramp T L t • P t Y := by let η : ℝ → E := fun s => extendPath T hT (trialFrame T L P) s Y have hη : AbsolutelyContinuousOnInterval η 0 T := clm_apply_absolutelyContinuous (operatorPath_absolutelyContinuous T hT (trialFrame T L P) (trialFrameDerivative T L P P₁) (trialFrame_hasDerivWithinAt T hT L P P₁ hd)) ((LipschitzWith.const Y).lipschitzOnWith.absolutelyContinuousOnInterval) have hηd := trialDerivative_realizes T hT L P P₁ hd Y have he := eq_primitive_add_terminal T hT (trialDerivative T hT L P P₁ Y) η hη hηd t t.property have he0 := eq_primitive_add_terminal T hT (trialDerivative T hT L P P₁ Y) η hη hηd 0 ⟨le_rfl, hT⟩ have hz : η 0 = 0 := by simp only [η, extendPath, projIcc_of_mem hT ⟨le_rfl, hT⟩, trialFrame, ContinuousMap.coe_mk, ramp_initial, zero_smul, zero_apply] change realPrimitive T (trialDerivative T hT L P P₁ Y) t - realPrimitive T (trialDerivative T hT L P P₁ Y) 0 = _ rw [(eq_sub_iff_add_eq.mpr he.symm), (eq_sub_iff_add_eq.mpr he0.symm), hz] simp only [zero_sub, sub_neg_eq_add, sub_add_cancel] simp only [η, extendPath, projIcc_of_mem hT t.property, trialFrame, ContinuousMap.coe_mk, smul_apply] include hd in theorem initialPrimitiveTimeLp_trialDerivative (Y : U) : initialPrimitiveTimeLp T hT (trialDerivative T hT L P P₁ Y) = pathLp T hT (operatorEvaluation T (trialFrame T L P) Y) := by change pathLp T hT (initialPrimitive T hT (trialDerivative T hT L P P₁ Y)) = _ apply congrArg (pathLp T hT) ext t exact initialPrimitive_trialDerivative T hT L P P₁ hd Y t omit [CompleteSpace E] [InnerProductSpace ℝ E] in theorem norm_add_sq_le (a b : E) : ‖a + b‖ ^ 2 ≤ 2 * ‖a‖ ^ 2 + 2 * ‖b‖ ^ 2 := by have hs := pow_le_pow_left₀ (norm_nonneg (a + b)) (norm_add_le a b) 2 linarith only [hs, sq_nonneg (‖a‖ - ‖b‖)] omit [CompleteSpace E] in theorem trialFrameDerivative_apply_sq_le (M : ℝ) (_hM : 0 ≤ M) (hP : ∀ t, ‖P t‖ ≤ 1) (hP₁ : ∀ t, ‖P₁ t‖ ≤ M) (Y : U) (t : Icc (0 : ℝ) T) : ‖trialFrameDerivative T L P P₁ t Y‖ ^ 2 ≤ (2 * rampDerivative T L t ^ 2 + 2 * ramp T L t ^ 2 * M ^ 2) * ‖Y‖ ^ 2 := by have hp : ‖P t Y‖ ≤ ‖Y‖ := by simpa only [one_mul] using (P t).le_opNorm Y |>.trans (mul_le_mul_of_nonneg_right (hP t) (norm_nonneg Y)) have hp₁ : ‖P₁ t Y‖ ≤ M * ‖Y‖ := (P₁ t).le_opNorm Y |>.trans (mul_le_mul_of_nonneg_right (hP₁ t) (norm_nonneg Y)) change ‖rampDerivative T L t • P t Y + ramp T L t • P₁ t Y‖ ^ 2 ≤ _ calc _ ≤ 2 * ‖rampDerivative T L t • P t Y‖ ^ 2 + 2 * ‖ramp T L t • P₁ t Y‖ ^ 2 := norm_add_sq_le _ _ _ = 2 * rampDerivative T L t ^ 2 * ‖P t Y‖ ^ 2 + 2 * ramp T L t ^ 2 * ‖P₁ t Y‖ ^ 2 := by simp only [norm_smul, Real.norm_eq_abs, mul_pow, sq_abs] ring _ ≤ 2 * rampDerivative T L t ^ 2 * ‖Y‖ ^ 2 + 2 * ramp T L t ^ 2 * (M * ‖Y‖) ^ 2 := by gcongr _ = _ := by ring omit [CompleteSpace E] in /-- The actual L² derivative cost of the explicit terminal-layer trial. -/ theorem trialDerivative_norm_sq_le (hL : 0 < L) (hLT : 1 ≤ L * T) (M : ℝ) (hM : 0 ≤ M) (hP : ∀ t, ‖P t‖ ≤ 1) (hP₁ : ∀ t, ‖P₁ t‖ ≤ M) (Y : U) : ‖trialDerivative T hT L P P₁ Y‖ ^ 2 ≤ (4 * L + 4 * M ^ 2 / L) * ‖Y‖ ^ 2 := by change ‖pathLp T hT (operatorEvaluation T (trialFrameDerivative T L P P₁) Y)‖ ^ 2 ≤ _ rw [pathLp_norm_sq] have hi := intervalIntegral.integral_mono_on (μ := volume) hT (((extendPath_continuous T hT (operatorEvaluation T (trialFrameDerivative T L P P₁) Y)).norm.pow 2).intervalIntegrable 0 T) ((((((rampDerivative_continuous T L).pow 2).const_mul 2).add ((((ramp_continuous T L).pow 2).const_mul 2).mul_const (M ^ 2))).mul_const (‖Y‖ ^ 2)).intervalIntegrable 0 T) (fun s hs => by change ‖extendPath T hT (operatorEvaluation T (trialFrameDerivative T L P P₁) Y) s‖ ^ 2 ≤ (2 * rampDerivative T L s ^ 2 + 2 * ramp T L s ^ 2 * M ^ 2) * ‖Y‖ ^ 2 simpa only [extendPath, projIcc_of_mem hT hs, operatorEvaluation_apply] using trialFrameDerivative_apply_sq_le T L P P₁ M hM hP hP₁ Y ⟨s, hs⟩) change (∫ s in 0..T, ‖extendPath T hT (operatorEvaluation T (trialFrameDerivative T L P P₁) Y) s‖ ^ 2) ≤ ∫ s in 0..T, (2 * rampDerivative T L s ^ 2 + 2 * ramp T L s ^ 2 * M ^ 2) * ‖Y‖ ^ 2 at hi have hv : IntervalIntegrable (fun s => ramp T L s ^ 2) volume 0 T := ((ramp_continuous T L).pow 2).intervalIntegrable 0 T have hdv : IntervalIntegrable (fun s => rampDerivative T L s ^ 2) volume 0 T := ((rampDerivative_continuous T L).pow 2).intervalIntegrable 0 T rw [intervalIntegral.integral_mul_const, intervalIntegral.integral_add (hdv.const_mul 2) ((hv.const_mul 2).mul_const (M ^ 2)), intervalIntegral.integral_const_mul, intervalIntegral.integral_mul_const, intervalIntegral.integral_const_mul] at hi apply hi.trans calc (2 * (∫ s in 0..T, rampDerivative T L s ^ 2) + 2 * (∫ s in 0..T, ramp T L s ^ 2) * M ^ 2) * ‖Y‖ ^ 2 ≤ (2 * (2 * L) + 2 * (2 / L) * M ^ 2) * ‖Y‖ ^ 2 := by gcongr · exact rampDerivative_energy hT hL hLT · exact ramp_energy hT hL hLT _ = _ := by ring include hd in /-- The corresponding physical displacement cost retains the inverse layer width. -/ theorem trialDisplacement_norm_sq_le (hL : 0 < L) (hLT : 1 ≤ L * T) (hP : ∀ t, ‖P t‖ ≤ 1) (Y : U) : ‖initialPrimitiveTimeLp T hT (trialDerivative T hT L P P₁ Y)‖ ^ 2 ≤ (2 / L) * ‖Y‖ ^ 2 := by rw [initialPrimitiveTimeLp_trialDerivative T hT L P P₁ hd, pathLp_norm_sq] have hv := ((ramp_continuous T L).pow 2).intervalIntegrable (μ := volume) 0 T have hi := intervalIntegral.integral_mono_on (μ := volume) hT (((extendPath_continuous T hT (operatorEvaluation T (trialFrame T L P) Y)).norm.pow 2).intervalIntegrable 0 T) (hv.mul_const (‖Y‖ ^ 2)) (fun s hs => by change ‖extendPath T hT (operatorEvaluation T (trialFrame T L P) Y) s‖ ^ 2 ≤ ramp T L s ^ 2 * ‖Y‖ ^ 2 simp only [extendPath, projIcc_of_mem hT hs, operatorEvaluation_apply, trialFrame, ContinuousMap.coe_mk, smul_apply, norm_smul, Real.norm_eq_abs, mul_pow, sq_abs] have hp : ‖P ⟨s, hs⟩ Y‖ ≤ ‖Y‖ := by simpa only [one_mul] using (P ⟨s, hs⟩).le_opNorm Y |>.trans (mul_le_mul_of_nonneg_right (hP ⟨s, hs⟩) (norm_nonneg Y)) exact mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (norm_nonneg _) hp 2) (sq_nonneg _)) change (∫ s in 0..T, ‖extendPath T hT (operatorEvaluation T (trialFrame T L P) Y) s‖ ^ 2) ≤ ∫ s in 0..T, ramp T L s ^ 2 * ‖Y‖ ^ 2 at hi rw [intervalIntegral.integral_mul_const] at hi exact hi.trans (mul_le_mul_of_nonneg_right (ramp_energy hT hL hLT) (sq_nonneg _)) end EulerTerminalProjectionTrial