import Euler.TransverseEndpointVelocity import Euler.MovingNormalProjection import Euler.TerminalProjectionTrial /-! Source (26) for the actual stationary transverse solution. The endpoint matrix is the constructed Dirichlet-to-Neumann operator and its norm is derived from the explicit moving-projection trial. The selected velocity is the genuine derivative η_t minus Mη, not a separately prescribed matrix output. -/ /-! ## From `Euler/TransverseActivationTrial.lean` The text of `Euler/TransverseActivationTrial.lean`, folded into this file, which was its only importer. -/ section /-! The explicit activation trial and its endpoint-energy bound. The trial uses the actual moving normal, not a deformation-frame condition number. A layer of width `1/h` gives `‖Λ‖ ≤ (4 + 64 CM² + 2 CH) h` under the source's low history bounds. -/ noncomputable section namespace EulerTransverseActivationTrial open MeasureTheory Set InnerProductSpace ContinuousLinearMap EulerTimeLp EulerInitialTimePrimitive EulerVolterraConvolution EulerTerminalProjectionTrial EulerTerminalLayerRamp EulerMovingNormalProjection EulerTransverseEndpointEnergy variable {E U : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup U] [InnerProductSpace ℝ U] private local instance : NormedAddCommGroup (E →L[ℝ] E) := inferInstance private local instance : NormedSpace ℝ (E →L[ℝ] E) := inferInstance private local instance : AddCommGroup (E →L[ℝ] E) := (inferInstance : NormedAddCommGroup (E →L[ℝ] E)).toAddCommGroup private local instance : Module ℝ (E →L[ℝ] E) := (inferInstance : NormedSpace ℝ (E →L[ℝ] E)).toModule private local instance : TopologicalSpace (E →L[ℝ] E) := (inferInstance : PseudoMetricSpace (E →L[ℝ] E)).toUniformSpace.toTopologicalSpace 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) (m m₁ : C(Icc (0 : ℝ) T, E)) (hne : ∀ t, m t ≠ 0) (R : U →L[ℝ] E) def projectionPath : C(Icc (0 : ℝ) T, U →L[ℝ] E) := ⟨fun t => (normalProjection (m t)).comp R, (normalProjection_continuous m.continuous hne).clm_comp continuous_const⟩ def projectionDerivativePath : C(Icc (0 : ℝ) T, U →L[ℝ] E) := ⟨fun t => (normalProjectionDerivative (m t) (m₁ t)).comp R, (normalProjectionDerivative_continuous m.continuous m₁.continuous hne).clm_comp continuous_const⟩ variable (hd : ∀ t : Icc (0 : ℝ) T, HasDerivWithinAt (extendPath T hT m) (m₁ t) (Icc (0 : ℝ) T) t) include hd in theorem projectionPath_hasDerivWithinAt (t : Icc (0 : ℝ) T) : HasDerivWithinAt (extendPath T hT (projectionPath T m hne R)) (projectionDerivativePath T m m₁ hne R t) (Icc (0 : ℝ) T) t := by have hm : extendPath T hT m t ≠ 0 := by simpa only [extendPath, projIcc_of_mem hT t.property] using hne t have hp := normalProjection_hasDerivWithinAt (hd t) hm have hc := hp.clm_comp (hasDerivWithinAt_const (t : ℝ) (Icc (0 : ℝ) T) R) convert! hc using 1 simp only [projectionDerivativePath, ContinuousMap.coe_mk, extendPath, projIcc_of_mem hT t.property, comp_zero, add_zero] theorem projectionPath_norm_le (hR : ‖R‖ ≤ 1) (t : Icc (0 : ℝ) T) : ‖projectionPath T m hne R t‖ ≤ 1 := by calc ‖projectionPath T m hne R t‖ ≤ ‖normalProjection (m t)‖ * ‖R‖ := opNorm_comp_le _ _ _ ≤ 1 * 1 := mul_le_mul (normalProjection_norm_le (m t) (hne t)) hR (norm_nonneg R) (by norm_num) _ = 1 := one_mul 1 variable [CompleteSpace E] theorem projectionDerivativePath_norm_le (hR : ‖R‖ ≤ 1) (M : Icc (0 : ℝ) T → E →L[ℝ] E) (hRay : ∀ t, m₁ t = -(M t).adjoint (m t)) (B : ℝ) (_hB : 0 ≤ B) (hM : ∀ t, ‖M t‖ ≤ B) (t : Icc (0 : ℝ) T) : ‖projectionDerivativePath T m m₁ hne R t‖ ≤ 4 * B := by calc ‖projectionDerivativePath T m m₁ hne R t‖ ≤ ‖normalProjectionDerivative (m t) (m₁ t)‖ * ‖R‖ := opNorm_comp_le _ _ _ ≤ (4 * ‖M t‖) * 1 := by apply mul_le_mul _ hR (norm_nonneg R) (by positivity) rw [hRay] exact normalProjectionDerivative_ray_bound (m t) (hne t) (M t) _ ≤ 4 * B := by nlinarith only [hM t] /-- The actual derivative of the explicit terminal-layer displacement. -/ def activationTrial (h : ℝ) : U →L[ℝ] TimeLp T E := trialDerivative T hT h (projectionPath T m hne R) (projectionDerivativePath T m m₁ hne R) include hd in theorem activationTrial_primitive (h : ℝ) (Y : U) (t : Icc (0 : ℝ) T) : initialPrimitive T hT (activationTrial T hT m m₁ hne R h Y) t = ramp T h t • normalProjection (m t) (R Y) := initialPrimitive_trialDerivative T hT h (projectionPath T m hne R) (projectionDerivativePath T m m₁ hne R) (projectionPath_hasDerivWithinAt T hT m m₁ hne R hd) Y t include hd in theorem activationTrial_tangent (h : ℝ) (Y : U) (t : Icc (0 : ℝ) T) : ⟪m t, initialPrimitive T hT (activationTrial T hT m m₁ hne R h Y) t⟫_ℝ = 0 := by rw [activationTrial_primitive T hT m m₁ hne R hd, real_inner_smul_right, normalProjection_tangent (m t) (hne t), mul_zero] include hd in theorem activationTrial_terminal (h : ℝ) (hLayer : 1 ≤ h * T) (hR : ∀ Y, ⟪m ⟨T, hT, le_rfl⟩, R Y⟫_ℝ = 0) (Y : U) : initialPrimitive T hT (activationTrial T hT m m₁ hne R h Y) ⟨T, hT, le_rfl⟩ = R Y := by rw [activationTrial_primitive T hT m m₁ hne R hd, ramp_terminal hLayer, one_smul, normalProjection_fixed _ _ (hR Y)] omit [CompleteSpace E] in theorem potential_abs_bound (H : C(Icc (0 : ℝ) T, E →L[ℝ] E)) (u : TimeLp T E) : |⟪timeMultiplier T hT H u, u⟫_ℝ| ≤ ‖H‖ * ‖u‖ ^ 2 := by calc |⟪timeMultiplier T hT H u, u⟫_ℝ| ≤ ‖timeMultiplier T hT H u‖ * ‖u‖ := abs_real_inner_le_norm _ _ _ ≤ (‖H‖ * ‖u‖) * ‖u‖ := mul_le_mul_of_nonneg_right (timeApply_bound T hT H u) (norm_nonneg u) _ = _ := by ring variable [CompleteSpace U] include hd in /-- All input bounds concern the parent coefficients and the actual ray. The endpoint operator and its `O(h)` norm are constructed conclusions. -/ theorem activation_endpoint_norm (h : ℝ) (hh : 0 < h) (hLayer : 1 ≤ h * T) (hR : ‖R‖ ≤ 1) (CM CH : ℝ) (hCM : 0 ≤ CM) (hCH : 0 ≤ CH) (M : Icc (0 : ℝ) T → E →L[ℝ] E) (hRay : ∀ t, m₁ t = -(M t).adjoint (m t)) (hM : ∀ t, ‖M t‖ ≤ CM * h) (H : C(Icc (0 : ℝ) T, E →L[ℝ] E)) (hHs : ∀ t, (H t).IsSymmetric) (hHnorm : ‖H‖ ≤ CH * h ^ 2) (K : ℝ) (hK : 0 ≤ K) (hH : ∀ t x, ⟪H t x, x⟫_ℝ ≤ K * ‖x‖ ^ 2) (hsmall : K * (T ^ 2 / 2) ≤ 1 / 2) : ‖dirichletToNeumann T hT (fun t => m t) H K hK hH hsmall (activationTrial T hT m m₁ hne R h)‖ ≤ (4 + 64 * CM ^ 2 + 2 * CH) * h := by apply dirichletToNeumann_norm_le T hT (fun t => m t) H K hK hH hsmall hHs (activationTrial T hT m m₁ hne R h) ((4 + 64 * CM ^ 2 + 2 * CH) * h) (by positivity) intro Y have hproj := projectionPath_norm_le T m hne R hR have hproj₁ := projectionDerivativePath_norm_le T m m₁ hne R hR M hRay (CM * h) (by positivity) hM have hD := trialDerivative_norm_sq_le T hT h (projectionPath T m hne R) (projectionDerivativePath T m m₁ hne R) hh hLayer (4 * (CM * h)) (by positivity) hproj hproj₁ Y have hη := trialDisplacement_norm_sq_le T hT h (projectionPath T m hne R) (projectionDerivativePath T m m₁ hne R) (projectionPath_hasDerivWithinAt T hT m m₁ hne R hd) hh hLayer hproj Y change ‖activationTrial T hT m m₁ hne R h Y‖ ^ 2 ≤ (4 * h + 4 * (4 * (CM * h)) ^ 2 / h) * ‖Y‖ ^ 2 at hD change ‖initialPrimitiveTimeLp T hT (activationTrial T hT m m₁ hne R h Y)‖ ^ 2 ≤ (2 / h) * ‖Y‖ ^ 2 at hη let u := activationTrial T hT m m₁ hne R h Y let η := initialPrimitiveTimeLp T hT u have hp : -⟪timeMultiplier T hT H η, η⟫_ℝ ≤ CH * h ^ 2 * ‖η‖ ^ 2 := by exact (neg_le_abs _).trans ((potential_abs_bound T hT H η).trans (mul_le_mul_of_nonneg_right hHnorm (sq_nonneg _))) change ‖u‖ ^ 2 - ⟪timeMultiplier T hT H η, η⟫_ℝ ≤ _ calc ‖u‖ ^ 2 - ⟪timeMultiplier T hT H η, η⟫_ℝ ≤ ‖u‖ ^ 2 + CH * h ^ 2 * ‖η‖ ^ 2 := by linarith only [hp] _ ≤ (4 * h + 4 * (4 * (CM * h)) ^ 2 / h) * ‖Y‖ ^ 2 + CH * h ^ 2 * ((2 / h) * ‖Y‖ ^ 2) := add_le_add hD (mul_le_mul_of_nonneg_left hη (by positivity)) _ = (4 + 64 * CM ^ 2 + 2 * CH) * h * ‖Y‖ ^ 2 := by field_simp; ring end EulerTransverseActivationTrial end end noncomputable section namespace EulerTransverseActivationSelection open MeasureTheory Set InnerProductSpace ContinuousLinearMap EulerTimeLp EulerInitialTimePrimitive EulerVolterraConvolution EulerTransverseEndpointEnergy EulerTransverseEndpointVelocity EulerTransverseActivationTrial EulerDNSelection variable {U E V : Type*} [NormedAddCommGroup U] [InnerProductSpace ℝ U] [CompleteSpace U] [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E] [NormedAddCommGroup V] [InnerProductSpace ℝ V] [CompleteSpace V] def activationConstant (CM CH : ℝ) : ℝ := 4 + 64 * CM ^ 2 + 2 * CH /-- The actual terminal matrix after subtracting the prescribed shear. -/ def terminalPerturbation (T : ℝ) (hT : 0 ≤ T) (R : V →ₗᵢ[ℝ] E) (M : C(Icc (0 : ℝ) T, E →L[ℝ] E)) (p q : V) (h : ℝ) : V →L[ℝ] V := R.toContinuousLinearMap.adjoint.comp ((M ⟨T, hT, le_rfl⟩).comp R.toContinuousLinearMap) - h • rankOne ℝ q p /-- Differentiating the actual moving tangency constraint makes η_t−Mη tangent. -/ theorem corrected_velocity_tangent (T : ℝ) (hT : 0 < T) (m m₁ : C(Icc (0 : ℝ) T, E)) (M : C(Icc (0 : ℝ) T, E →L[ℝ] E)) (hdm : ∀ t : Icc (0 : ℝ) T, HasDerivWithinAt (extendPath T hT.le m) (m₁ t) (Icc (0 : ℝ) T) t) (hRay : ∀ t, m₁ t = -(M t).adjoint (m t)) (η v : ℝ → E) (hdη : ∀ t : Icc (0 : ℝ) T, HasDerivWithinAt η (v t) (Icc (0 : ℝ) T) t) (htan : ∀ t : Icc (0 : ℝ) T, ⟪m t, η t⟫_ℝ = 0) (t : Icc (0 : ℝ) T) : ⟪m t, v t - M t (η t)⟫_ℝ = 0 := by have hd := (hdm t).inner ℝ (hdη t) have hz : HasDerivWithinAt (fun s => ⟪extendPath T hT.le m s, η s⟫_ℝ) (0 : ℝ) (Icc (0 : ℝ) T) t := by apply (hasDerivWithinAt_const (t : ℝ) (Icc (0 : ℝ) T) (0 : ℝ)).congr_of_mem _ t.property intro s hs simpa only [extendPath, projIcc_of_mem hT.le hs] using htan ⟨s, hs⟩ have he := (hd.derivWithin ((uniqueDiffOn_Icc hT) t t.property)).symm.trans (hz.derivWithin ((uniqueDiffOn_Icc hT) t t.property)) simp only [extendPath, projIcc_of_mem hT.le t.property, hRay, inner_neg_left, adjoint_inner_left, inner_sub_right] at he ⊢ linarith only [he] /-- The activation choice is attached to the actual weak inverse, its continuous physical derivative, and the derived endpoint energy bound. -/ theorem select_actual_activation (T : ℝ) (hT : 0 < T) (Q Q₁ : C(Icc (0 : ℝ) T, U →L[ℝ] E)) (c : ℝ) (hc : 0 < c) (hQ : ∀ t x, c * ‖x‖ ^ 2 ≤ ‖Q t x‖ ^ 2) (hdQ : ∀ t : Icc (0 : ℝ) T, HasDerivWithinAt (extendPath T hT.le Q) (Q₁ t) (Icc (0 : ℝ) T) t) (m m₁ : C(Icc (0 : ℝ) T, E)) (hne : ∀ t, m t ≠ 0) (hdm : ∀ t : Icc (0 : ℝ) T, HasDerivWithinAt (extendPath T hT.le m) (m₁ t) (Icc (0 : ℝ) T) t) (hm : ∀ t x, ⟪m t, Q t x⟫_ℝ = 0) (hRange : ∀ t η, ⟪m t, η⟫_ℝ = 0 → ∃ x : U, Q t x = η) (R : V →ₗᵢ[ℝ] E) (hR : ∀ Y, ⟪m ⟨T, hT.le, le_rfl⟩, R Y⟫_ℝ = 0) (H : C(Icc (0 : ℝ) T, E →L[ℝ] E)) (hHs : ∀ t, (H t).IsSymmetric) (K : ℝ) (hK : 0 ≤ K) (hH : ∀ t x, ⟪H t x, x⟫_ℝ ≤ K * ‖x‖ ^ 2) (hsmall : K * (T ^ 2 / 2) ≤ 1 / 2) (M : C(Icc (0 : ℝ) T, E →L[ℝ] E)) (hRay : ∀ t, m₁ t = -(M t).adjoint (m t)) (h CM CH ε : ℝ) (hh : 0 < h) (hLayer : 1 ≤ h * T) (hCM : 0 ≤ CM) (hCH : 0 ≤ CH) (hε : 0 ≤ ε) (hM : ∀ t, ‖M t‖ ≤ CM * h) (hHnorm : ‖H‖ ≤ CH * h ^ 2) (p q : V) (hp : ‖p‖ = 1) (hq : ‖q‖ = 1) (hpq : ⟪p, q⟫_ℝ = 0) (hεsmall : 16 * (activationConstant CM CH + 1) * ε ≤ 1) (hB : ‖terminalPerturbation T hT.le R M p q h‖ ≤ ε * h) (hBpp : ⟪terminalPerturbation T hT.le R M p q h p, p⟫_ℝ < 0) : ∃ Y : V, let L := activationTrial T hT.le m m₁ hne R.toContinuousLinearMap h let u := endpointDerivative T hT.le (fun t => m t) H K hK hH hsmall L Y let η := initialRealPrimitive T u let v := physicalVelocityPath T hT.le Q Q₁ c hc hQ H u let w := fun t => v t - extendPath T hT.le M t (η t) η 0 = 0 ∧ η T = R Y ∧ Continuous v ∧ (∀ t : Icc (0 : ℝ) T, HasDerivWithinAt η (v t) (Icc (0 : ℝ) T) t) ∧ (∀ t : Icc (0 : ℝ) T, ⟪m t, w t⟫_ℝ = 0) ∧ ⟪w T, R q⟫_ℝ = 1 ∧ -8 * (activationConstant CM CH + 1) ≤ ⟪w T, R p⟫_ℝ ∧ ⟪w T, R p⟫_ℝ ≤ 0 ∧ ‖Y‖ ≤ 8 * (activationConstant CM CH + 1) / h := by let L := activationTrial T hT.le m m₁ hne R.toContinuousLinearMap h let Λ := dirichletToNeumann T hT.le (fun t => m t) H K hK hH hsmall L let B := terminalPerturbation T hT.le R M p q h have hΛ : Λ.IsPositive := dirichletToNeumann_positive T hT.le (fun t => m t) H K hK hH hsmall hHs L have hΛnorm : ‖Λ‖ ≤ activationConstant CM CH * h := activation_endpoint_norm T hT.le m m₁ hne R.toContinuousLinearMap hdm h hh hLayer R.norm_toContinuousLinearMap_le CM CH hCM hCH M hRay hM H hHs hHnorm K hK hH hsmall have hC : 1 ≤ activationConstant CM CH := by unfold activationConstant linarith only [sq_nonneg CM, hCH] obtain ⟨yp, yq, hwq, hwpl, hwpu, hY⟩ := select_endpoint_hilbert Λ B p q (activationConstant CM CH) ε h hΛ hp hq hpq hC hε hh hεsmall hΛnorm hB hBpp let Y := yp • p + yq • q let u := endpointDerivative T hT.le (fun t => m t) H K hK hH hsmall L Y let η := initialRealPrimitive T u let v := physicalVelocityPath T hT.le Q Q₁ c hc hQ H u let w := fun t => v t - extendPath T hT.le M t (η t) have hLt : ∀ Z t, ⟪m t, initialPrimitive T hT.le (L Z) t⟫_ℝ = 0 := activationTrial_tangent T hT.le m m₁ hne R.toContinuousLinearMap hdm h have hLT : ∀ Z, initialPrimitive T hT.le (L Z) ⟨T, hT.le, le_rfl⟩ = R Z := activationTrial_terminal T hT.le m m₁ hne R.toContinuousLinearMap hdm h hLayer hR have hηT : η T = R Y := (endpointDisplacement_terminal T hT.le (fun t => m t) H K hK hH hsmall L Y).trans (hLT Y) have hdη : ∀ t : Icc (0 : ℝ) T, HasDerivWithinAt η (v t) (Icc (0 : ℝ) T) t := endpointDisplacement_hasDerivWithinAt T hT.le Q Q₁ c hc hQ H hdQ hT (fun t => m t) hm hRange K hK hH hsmall L hLt Y have hηtan : ∀ t : Icc (0 : ℝ) T, ⟪m t, η t⟫_ℝ = 0 := endpointDisplacement_tangent T hT.le (fun t => m t) H K hK hH hsmall L hLt Y have hvt : R.toContinuousLinearMap.adjoint (v T) = Λ Y := (dirichletToNeumann_eq_terminal_velocity T hT.le Q Q₁ c hc hQ H hdQ hT (fun t => m t) hm hRange K hK hH hsmall L R.toContinuousLinearMap hLt hLT Y).symm have hwt : R.toContinuousLinearMap.adjoint (w T) = Λ Y - B Y - (h * ⟪p, Y⟫_ℝ) • q := by dsimp only [w] rw [map_sub, hvt, hηT] simp only [B, terminalPerturbation, sub_apply, smul_apply, rankOne_apply, smul_smul, extendPath, projIcc_of_mem hT.le (show T ∈ Icc (0 : ℝ) T from ⟨hT.le, le_rfl⟩)] abel have hwcoord (z : V) : ⟪w T, R z⟫_ℝ = ⟪Λ Y - B Y - (h * ⟪p, Y⟫_ℝ) • q, z⟫_ℝ := by change ⟪w T, R.toContinuousLinearMap z⟫_ℝ = _ rw [← R.toContinuousLinearMap.adjoint_inner_left, hwt] refine ⟨Y, initialRealPrimitive_initial T u, hηT, physicalVelocityPath_continuous T hT.le Q Q₁ c hc hQ H u, hdη, ?_, ?_, ?_, ?_, hY⟩ · intro t simpa only [extendPath, projIcc_of_mem hT.le t.property] using corrected_velocity_tangent T hT m m₁ M hdm hRay η v hdη hηtan t · exact (hwcoord q).trans hwq · exact (hwcoord p).symm ▸ hwpl · exact (hwcoord p).symm ▸ hwpu end EulerTransverseActivationSelection