diff --git a/LeanPool/C145.lean b/LeanPool/C145.lean new file mode 100644 index 0000000000..d3300cabe2 --- /dev/null +++ b/LeanPool/C145.lean @@ -0,0 +1,93 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8CommonUnit +public import LeanPool.C145.C145DRE8Frobenius +public import LeanPool.C145.C145DRE8HilbertStability +public import LeanPool.C145.C145DRE8ProjectionResiduals +public import LeanPool.C145.C145N6LiteralRows +public import LeanPool.C145.C145N6Squarefree +public import LeanPool.C145.C145PhysicalFrame +public import LeanPool.C145.C145ThreePlaneFactor +public import LeanPool.C145.C145WeightedGraph +public import LeanPool.C145.C145CyclicSpectral +public import LeanPool.C145.C145DRE8PhysicalTensor +public import LeanPool.C145.C145H2NumeratorData +public import LeanPool.C145.C145N6LineExclusion +public import LeanPool.C145.C145DRE8SliceRigidity +public import LeanPool.C145.C145DRE8TensorSpace +public import LeanPool.C145.C145H1ModalCalibration +public import LeanPool.C145.C145H2GridResidueInverse +public import LeanPool.C145.C145H2PositiveGrid +public import LeanPool.C145.C145CompleteOrdinaryH2Kernel +public import LeanPool.C145.C145SignedGroundPulseCalibration +public import LeanPool.C145.C145ReceivingLagrangeMoments +public import LeanPool.C145.C145SixFixedProducts +public import LeanPool.C145.C145DRE8WeightedKernel +public import LeanPool.C145.C145EightAffineFamilies +public import LeanPool.C145.C145DRE8CubicCancellation +public import LeanPool.C145.C145DRE8PositiveGridKernel +public import LeanPool.C145.C145PhysicalTraceResidue +public import LeanPool.C145.C145DRE8SpectralContraction +public import LeanPool.C145.C145N6TraceLine +public import LeanPool.C145.C145SmallPhysicalTraceSeparation +public import LeanPool.C145.C145CoordinatePermutation +public import LeanPool.C145.C145DRE8OptimalContraction +public import LeanPool.C145.C145DRE8OrthogonalTransport +public import LeanPool.C145.C145N6ResponseLine +public import LeanPool.C145.C145DRE8CalibratedUniqueness +public import LeanPool.C145.C145N6HelmertFrame +public import LeanPool.C145.C145OrientedEigenframe +public import LeanPool.C145.C145UncalibratedSmallH2 +public import LeanPool.C145.C145DelayKernelTransfer +public import LeanPool.C145.C145N6PhysicalWitness +public import LeanPool.C145.C145ActualResponseC2 +public import LeanPool.C145.C145N6CalibratedTransport +public import LeanPool.C145.C145TimeKernelContinuation +public import LeanPool.C145.C145ActualTimeConvolution +public import LeanPool.C145.C145N6PositiveGraph +public import LeanPool.C145.C145N6Uncalibrated +public import LeanPool.C145.C145ObservedKernelRecovery +public import LeanPool.C145.C145FixedHorizonSmallInverse +public import LeanPool.C145.C145N6TimeKernels +public import LeanPool.C145.C145GraphSpectralRealization +public import LeanPool.C145.C145N6OrdinaryJets +public import LeanPool.C145.C145DRE8ActualFrame +public import LeanPool.C145.C145N6GraphResponse +public import LeanPool.C145.C145PaperDomainChecks +public import LeanPool.C145.C145PaperRealizationInvariance +public import LeanPool.C145.C145DRE8ActualCalibratedInverse +public import LeanPool.C145.C145DRE8KrylovSlices +public import LeanPool.C145.C145DRE8PhysicalStability +public import LeanPool.C145.C145DRE8SignedGroundResidue +public import LeanPool.C145.C145N6OriginalGraph +public import LeanPool.C145.C145DRE8JointSignatureInverse +public import LeanPool.C145.C145DRE8TransferInverse +public import LeanPool.C145.C145PaperStability +public import LeanPool.C145.C145DRE8JointTransferInverse +public import LeanPool.C145.C145DRE8OriginalGraphInverse +public import LeanPool.C145.C145PaperResidualInvariance +public import LeanPool.C145.C145DRE8JointOriginalGraph +public import LeanPool.C145.C145PaperActualResponse +public import LeanPool.C145.C145PaperPositiveWitness +public import LeanPool.C145.C145PaperApplication +public import LeanPool.C145.C145PaperTheoremC + +/-! +# Exact single-port graph identification from two response derivatives + +Source: url:https://github.com/VanGogh7777/c145-lean/blob/75d25568c084c8aab4faee30bd94905a6d20c3ad/paper/C145_v0.6.pdf +Authors: Mark Gladden +Status: verified +Main declarations: `C145.PaperActualResponse.selected_response_theoremA_graph`, + `C145N6Frame.literal_N6_original_graph_identification` +Tags: graph identification, inverse problems, reaction diffusion +MSC: 93B30, 05C50 +-/ diff --git a/LeanPool/C145/C145ActualResponseC2.lean b/LeanPool/C145/C145ActualResponseC2.lean new file mode 100644 index 0000000000..4126580028 --- /dev/null +++ b/LeanPool/C145/C145ActualResponseC2.lean @@ -0,0 +1,1312 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DelayKernelTransfer +public import Mathlib.Topology.ContinuousMap.Compact +public import Mathlib.Topology.ContinuousMap.Algebra +public import Mathlib.Topology.Order.ProjIcc +public import Mathlib.Analysis.Calculus.InverseFunctionTheorem.ContDiff +public import Mathlib.Analysis.Calculus.FDeriv.Bilinear +public import Mathlib.Analysis.Calculus.FDeriv.CompCLM +public import Mathlib.Analysis.Calculus.ContDiff.Defs +public import Mathlib.Analysis.Calculus.Deriv.Prod +public import Mathlib.Analysis.Calculus.FDeriv.Symmetric +public import Mathlib.Analysis.SpecialFunctions.ExpDeriv +public import Mathlib.MeasureTheory.Integral.IntervalIntegral.FundThmCalculus +public import Mathlib.MeasureTheory.Integral.DominatedConvergence +public import Mathlib.Analysis.Normed.Operator.Bilinear +public import Mathlib.Analysis.Normed.Operator.Basic +public import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap + +/-! +# The local response and its first two derivatives + +The nonlinear solution is constructed by a local inverse and linked to the ODE +by FTC in both directions; the ordinary second derivative is derived explicitly. +-/ + +@[expose] public section + +noncomputable section +namespace C145.ActualResponse +open MeasureTheory Set Filter +open scoped BigOperators Topology ContDiff + +/-- A real state indexed by the graph's vertices. -/ +abbrev State (n : ℕ) := Fin (n + 1) → ℝ +/-- A real change of coordinates from modal indices to vertex indices. -/ +abbrev Frame (n : ℕ) := Fin (n + 1) → Fin (n + 1) → ℝ +/-- The closed observation interval from zero to the horizon. -/ +abbrev Time (T : ℝ) := Icc (0 : ℝ) T +/-- A continuous scalar forcing on the observation interval. -/ +abbrev Input (T : ℝ) := C(Time T, ℝ) +/-- A continuous vertex-state trajectory on the observation interval. -/ +abbrev Path (n : ℕ) (T : ℝ) := C(Time T, State n) +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +/-- The right endpoint as a point of the observation interval. -/ +def endTime (T : ℝ) (hT : 0 < T) : Time T := + ⟨T, hT.le, le_rfl⟩ + +/-- Extend a forcing to all real times by clipping to the observation interval. -/ +def extendInput {T : ℝ} (hT : 0 < T) (f : Input T) (s : ℝ) : ℝ := + f (projIcc 0 T hT.le s) + +/-- Extend a trajectory to all real times by clipping to the observation interval. -/ +def extendPath {n : ℕ} {T : ℝ} (hT : 0 < T) + (u : Path n T) (s : ℝ) : State n := + u (projIcc 0 T hT.le s) + +/-- Restrict a continuous real forcing to the observation interval. -/ +def restrictInput (T : ℝ) (g : ℝ → ℝ) (hg : Continuous g) : Input T := + ⟨fun t => g t, hg.comp continuous_subtype_val⟩ + +/-- Pair the vertex state with the signed measurement port. -/ +def observe {n : ℕ} (b x : State n) : ℝ := ∑ v, b v * x v + +/-- The spectral linear dynamics, coordinatewise square, and scalar forcing through the port. -/ +def vectorField {n : ℕ} (Q : Frame n) (rates b : State n) + (f : ℝ → ℝ) (t : ℝ) (x : State n) : State n := + fun v => (∑ w, C145CoordinatePermutation.spectralGenerator rates Q v w * x w) + + x v ^ 2 + b v * f t + +/-- A bound built from the frame entries and the exponential factors on the time horizon. -/ +def heatBound {n : ℕ} (Q : Frame n) (rates : State n) (T : ℝ) : ℝ := + 1 + ∑ i, ∑ v, ∑ w, + |Q v i| * |Q w i| * Real.exp (|rates i| * T) + +/-- Integrate the forced heat response in interaction-picture coordinates. -/ +def ipLinear {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (f : Input T) (t : ℝ) : State n := + ∫ s in (0 : ℝ)..t, + extendInput hT f s • C145.Pulse.heatAction Q rates (-s) b + +/-- Integrate the product of two trajectories after converting to and from the heat frame. -/ +def ipQuadratic {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v w : Path n T) (t : ℝ) : State n := + ∫ s in (0 : ℝ)..t, C145.Pulse.heatAction Q rates (-s) + (fun x => + C145.Pulse.heatAction Q rates s (extendPath hT v s) x * + C145.Pulse.heatAction Q rates s (extendPath hT w s) x) + +/-- The interaction-picture fixed-point residual obtained by subtracting the quadratic term. -/ +def ipResidual {n : ℕ} {T : ℝ} + (B : Path n T →L[ℝ] Path n T →L[ℝ] Path n T) (v : Path n T) : Path n T := + v - B v v + +/-- The first state variation as a heat convolution with the forcing direction. -/ +def firstState {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (g : Input T) (t : ℝ) : State n := + ∫ s in (0 : ℝ)..t, + extendInput hT g s • C145.Pulse.heatAction Q rates (t - s) b + +/-- The bilinear second-order coefficient from the product of the first state variations. -/ +def secondState {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (g h : Input T) (t : ℝ) : State n := + ∫ s in (0 : ℝ)..t, C145.Pulse.heatAction Q rates (t - s) + (fun v => firstState hT Q rates b g s v * firstState hT Q rates b h s v) + +/-- A response germ that maps zero to zero and solves the forced initial-value problem near zero. -/ +def IsActualResponse {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (R : Input T → Path n T) : Prop := + R 0 = 0 ∧ ∀ᶠ f in 𝓝 (0 : Input T), + extendPath hT (R f) 0 = 0 ∧ + ∀ t ∈ Icc (0 : ℝ) T, + HasDerivWithinAt (extendPath hT (R f)) + (vectorField Q rates b (extendInput hT f) t (extendPath hT (R f) t)) + (Icc (0 : ℝ) T) t + +/-- The derivative at zero of the observed response along one forcing direction. -/ +def rawFirst {n : ℕ} {T : ℝ} (b : State n) + (R : Input T → Path n T) (g : Input T) (t : Time T) : ℝ := + deriv (fun ε : ℝ => observe b (R (ε • g) t)) 0 + +/-- Half the second derivative at zero along one forcing direction. -/ +def rawQuadratic {n : ℕ} {T : ℝ} (b : State n) + (R : Input T → Path n T) (g : Input T) (t : Time T) : ℝ := + (1 / 2 : ℝ) * deriv (deriv (fun ε : ℝ => observe b (R (ε • g) t))) 0 + +/-- Half the mixed derivative of the observed response in two forcing directions. -/ +def rawMixed {n : ℕ} {T : ℝ} (b : State n) + (R : Input T → Path n T) (g h : Input T) (t : Time T) : ℝ := + (1 / 2 : ℝ) * deriv + (fun ε : ℝ => deriv (fun δ : ℝ => observe b (R (ε • g + δ • h) t)) 0) 0 + +/-! Finite heat algebra. No positivity of rates or entries is used. -/ + +private theorem heatAction_vec_add {n : ℕ} (Q : Frame n) (rates x y : State n) + (t : ℝ) : + C145.Pulse.heatAction Q rates t (x + y) = + C145.Pulse.heatAction Q rates t x + C145.Pulse.heatAction Q rates t y := by + classical + funext v + simp only [C145.Pulse.heatAction, Pi.add_apply, mul_add, Finset.sum_add_distrib] + +private theorem heatAction_vec_smul {n : ℕ} (Q : Frame n) (rates x : State n) + (t c : ℝ) : + C145.Pulse.heatAction Q rates t (c • x) = + c • C145.Pulse.heatAction Q rates t x := by + classical + funext v + simp only [C145.Pulse.heatAction, Pi.smul_apply, smul_eq_mul] + calc + (∑ i, Q v i * Real.exp (-rates i * t) * (∑ u, Q u i * (c * x u))) = + ∑ i, c * (Q v i * Real.exp (-rates i * t) * (∑ u, Q u i * x u)) := by + apply Finset.sum_congr rfl + intro i hi + have hinner : (∑ u, Q u i * (c * x u)) = c * (∑ u, Q u i * x u) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro u hu + ring + rw [hinner] + ring + _ = _ := (Finset.mul_sum _ _ _).symm + +private theorem heatAction_mode {n : ℕ} (Q : Frame n) (rates x : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) (t : ℝ) (i : Fin (n + 1)) : + (∑ v, Q v i * C145.Pulse.heatAction Q rates t x v) = + Real.exp (-rates i * t) * (∑ u, Q u i * x u) := by + classical + unfold C145.Pulse.heatAction + calc + (∑ v, Q v i * (∑ j, Q v j * Real.exp (-rates j * t) * (∑ u, Q u j * x u))) = + ∑ v, ∑ j, Q v i * (Q v j * Real.exp (-rates j * t) * (∑ u, Q u j * x u)) := by + apply Finset.sum_congr rfl + intro v hv + exact Finset.mul_sum _ _ _ + _ = ∑ j, ∑ v, Q v i * (Q v j * Real.exp (-rates j * t) * (∑ u, Q u j * x u)) := + Finset.sum_comm + _ = ∑ j, (∑ v, Q v i * Q v j) * + (Real.exp (-rates j * t) * (∑ u, Q u j * x u)) := by + apply Finset.sum_congr rfl + intro j hj + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro v hv + ring + _ = Real.exp (-rates i * t) * (∑ u, Q u i * x u) := by + simp_rw [hQ i] + simp only [ite_mul, one_mul, zero_mul, Finset.sum_ite_eq, + Finset.mem_univ, ite_true] + +theorem heatAction_zero {n : ℕ} (Q : Frame n) (rates x : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) : + C145.Pulse.heatAction Q rates 0 x = x := by + funext v + simpa only [C145.Pulse.heatAction, mul_zero, Real.exp_zero, mul_one, mul_comm] + using C145CoordinatePermutation.frame_reconstruction Q hQ x v + +theorem heatAction_add {n : ℕ} (Q : Frame n) (rates x : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) (s t : ℝ) : + C145.Pulse.heatAction Q rates (s + t) x = + C145.Pulse.heatAction Q rates s (C145.Pulse.heatAction Q rates t x) := by + classical + funext v + unfold C145.Pulse.heatAction + apply Finset.sum_congr rfl + intro i hi + have hmode := heatAction_mode Q rates x hQ t i + unfold C145.Pulse.heatAction at hmode + rw [hmode] + rw [mul_add, Real.exp_add] + ring + +private theorem generator_heat_mode {n : ℕ} (Q : Frame n) (rates x : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) (t : ℝ) (v : Fin (n + 1)) : + (∑ w, C145CoordinatePermutation.spectralGenerator rates Q v w * + C145.Pulse.heatAction Q rates t x w) = + ∑ i, Q v i * (Real.exp (-rates i * t) * (-rates i)) * + (∑ u, Q u i * x u) := by + classical + unfold C145CoordinatePermutation.spectralGenerator + simp_rw [← Finset.sum_neg_distrib, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i hi + calc + (∑ w, -(rates i * Q v i * Q w i) * + C145.Pulse.heatAction Q rates t x w) = + (-rates i * Q v i) * + (∑ w, Q w i * C145.Pulse.heatAction Q rates t x w) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro w hw + ring + _ = _ := by rw [heatAction_mode Q rates x hQ]; ring + +theorem heatAction_hasDerivAt {n : ℕ} (Q : Frame n) (rates x : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) (t : ℝ) : + HasDerivAt (fun s : ℝ => C145.Pulse.heatAction Q rates s x) + (fun v => ∑ w, C145CoordinatePermutation.spectralGenerator rates Q v w * + C145.Pulse.heatAction Q rates t x w) t := by + classical + apply hasDerivAt_pi.mpr + intro v + rw [generator_heat_mode Q rates x hQ t v] + unfold C145.Pulse.heatAction + apply HasDerivAt.fun_sum + intro i hi + simpa only [id_def, mul_one] using + (((hasDerivAt_id t).const_mul (-rates i)).exp.const_mul (Q v i)).mul_const + (∑ u, Q u i * x u) + +private theorem heatBound_pos {n : ℕ} (Q : Frame n) (rates : State n) (T : ℝ) : + 0 < heatBound Q rates T := by + unfold heatBound + positivity + +private theorem heat_bound_coordinate {n : ℕ} (Q : Frame n) (rates x : State n) + (T s : ℝ) (_hT : 0 ≤ T) (hs : |s| ≤ T) (v : Fin (n + 1)) : + |C145.Pulse.heatAction Q rates s x v| ≤ heatBound Q rates T * ‖x‖ := by + classical + have hexp (i : Fin (n + 1)) : + Real.exp (-rates i * s) ≤ Real.exp (|rates i| * T) := by + apply Real.exp_le_exp.mpr + calc + -rates i * s ≤ |-rates i * s| := le_abs_self _ + _ = |rates i| * |s| := by rw [abs_mul, abs_neg] + _ ≤ |rates i| * T := mul_le_mul_of_nonneg_left hs (abs_nonneg _) + have hcoord (w : Fin (n + 1)) : |x w| ≤ ‖x‖ := by + simpa only [Real.norm_eq_abs] using norm_le_pi_norm x w + calc + |C145.Pulse.heatAction Q rates s x v| ≤ + ∑ i, ∑ w, |Q v i| * |Q w i| * Real.exp (|rates i| * T) * ‖x‖ := by + unfold C145.Pulse.heatAction + calc + |∑ i, Q v i * Real.exp (-rates i * s) * (∑ w, Q w i * x w)| ≤ + ∑ i, |Q v i * Real.exp (-rates i * s) * (∑ w, Q w i * x w)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ i, ∑ w, |Q v i| * |Q w i| * Real.exp (|rates i| * T) * ‖x‖ := by + apply Finset.sum_le_sum + intro i hi + rw [abs_mul, abs_mul, abs_of_pos (Real.exp_pos _)] + calc + |Q v i| * Real.exp (-rates i * s) * |∑ w, Q w i * x w| ≤ + |Q v i| * Real.exp (|rates i| * T) * ∑ w, |Q w i| * ‖x‖ := by + apply mul_le_mul + · exact mul_le_mul_of_nonneg_left (hexp i) (abs_nonneg _) + · exact (Finset.abs_sum_le_sum_abs _ _).trans <| + Finset.sum_le_sum fun w hw => by + rw [abs_mul] + exact mul_le_mul_of_nonneg_left (hcoord w) (abs_nonneg _) + · positivity + · positivity + _ = _ := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro w hw + ring + _ = (∑ i, ∑ w, |Q v i| * |Q w i| * Real.exp (|rates i| * T)) * ‖x‖ := by + simp only [Finset.sum_mul] + _ ≤ (∑ i, ∑ v', ∑ w, + |Q v' i| * |Q w i| * Real.exp (|rates i| * T)) * ‖x‖ := by + apply mul_le_mul_of_nonneg_right _ (norm_nonneg x) + apply Finset.sum_le_sum + intro i hi + exact Finset.single_le_sum + (f := fun v' : Fin (n + 1) => + ∑ w, |Q v' i| * |Q w i| * Real.exp (|rates i| * T)) + (s := Finset.univ) + (fun v' hv' => Finset.sum_nonneg fun w hw => + mul_nonneg (mul_nonneg (abs_nonneg _) (abs_nonneg _)) (Real.exp_pos _).le) + (Finset.mem_univ v) + _ ≤ heatBound Q rates T * ‖x‖ := by + apply mul_le_mul_of_nonneg_right _ (norm_nonneg x) + unfold heatBound + linarith + +theorem finite_heat_bound {n : ℕ} (Q : Frame n) (rates x : State n) + (T s : ℝ) (hT : 0 ≤ T) (hs : |s| ≤ T) : + 0 < heatBound Q rates T ∧ + ‖C145.Pulse.heatAction Q rates s x‖ ≤ heatBound Q rates T * ‖x‖ := by + refine ⟨heatBound_pos Q rates T, ?_⟩ + apply (pi_norm_le_iff_of_nonneg + (mul_nonneg (heatBound_pos Q rates T).le (norm_nonneg x))).mpr + intro v + simpa only [Real.norm_eq_abs] using heat_bound_coordinate Q rates x T s hT hs v + +/-! Actual compact-path integrands and operator constructions. -/ + +private theorem continuous_extendInput {T : ℝ} (hT : 0 < T) (f : Input T) : + Continuous (extendInput hT f) := + f.continuous.comp continuous_projIcc + +private theorem continuous_extendPath {n : ℕ} {T : ℝ} (hT : 0 < T) (v : Path n T) : + Continuous (extendPath hT v) := + v.continuous.comp continuous_projIcc + +private theorem extendPath_at {n : ℕ} {T : ℝ} (hT : 0 < T) + (v : Path n T) (t : Time T) : extendPath hT v (t : ℝ) = v t := by + unfold extendPath + congr 1 + apply Subtype.ext + change max 0 (min T (t : ℝ)) = (t : ℝ) + rw [min_eq_right t.property.2, max_eq_right t.property.1] + +private theorem continuous_heat {n : ℕ} (Q : Frame n) (rates : State n) : + Continuous (fun p : ℝ × State n => C145.Pulse.heatAction Q rates p.1 p.2) := by + unfold C145.Pulse.heatAction + fun_prop + +private def linearIntegrand {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (f : Input T) (s : ℝ) : State n := + extendInput hT f s • C145.Pulse.heatAction Q rates (-s) b + +private def quadraticIntegrand {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v w : Path n T) (s : ℝ) : State n := + C145.Pulse.heatAction Q rates (-s) + (fun x => C145.Pulse.heatAction Q rates s (extendPath hT v s) x * + C145.Pulse.heatAction Q rates s (extendPath hT w s) x) + +private theorem continuous_linearIntegrand {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (f : Input T) : + Continuous (linearIntegrand hT Q rates b f) := by + exact (continuous_extendInput hT f).smul + ((continuous_heat Q rates).comp (continuous_neg.prodMk continuous_const)) + +private theorem continuous_quadraticIntegrand {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v w : Path n T) : + Continuous (quadraticIntegrand hT Q rates v w) := by + have hv := (continuous_heat Q rates).comp (continuous_id.prodMk (continuous_extendPath hT v)) + have hw := (continuous_heat Q rates).comp (continuous_id.prodMk (continuous_extendPath hT w)) + exact (continuous_heat Q rates).comp (continuous_neg.prodMk (hv.mul hw)) + +private def linearPath {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (f : Input T) : Path n T := + ⟨fun t => ipLinear hT Q rates b f t, + (intervalIntegral.continuous_primitive + (fun a c => (continuous_linearIntegrand hT Q rates b f).intervalIntegrable a c) 0).comp + continuous_subtype_val⟩ + +private def quadraticPath {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v w : Path n T) : Path n T := + ⟨fun t => ipQuadratic hT Q rates v w t, + (intervalIntegral.continuous_primitive + (fun a b => (continuous_quadraticIntegrand hT Q rates v w).intervalIntegrable a b) 0).comp + continuous_subtype_val⟩ + +private def heatPath {n : ℕ} {T : ℝ} (Q : Frame n) (rates : State n) + (σ : ℝ) (v : Path n T) : Path n T := + ⟨fun t => C145.Pulse.heatAction Q rates (σ * (t : ℝ)) (v t), + (continuous_heat Q rates).comp + ((continuous_const.mul continuous_subtype_val).prodMk v.continuous)⟩ + +private theorem linearPath_norm {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (f : Input T) : + ‖linearPath hT Q rates b f‖ ≤ (T * heatBound Q rates T * ‖b‖) * ‖f‖ := by + have hM := (heatBound_pos Q rates T).le + apply (ContinuousMap.norm_le _ (by positivity)).mpr + intro t + change ‖ipLinear hT Q rates b f (t : ℝ)‖ ≤ _ + have hint : ‖ipLinear hT Q rates b f (t : ℝ)‖ ≤ + (‖f‖ * (heatBound Q rates T * ‖b‖)) * |(t : ℝ) - 0| := by + apply intervalIntegral.norm_integral_le_of_norm_le_const + intro s hs + rw [uIoc_of_le t.property.1] at hs + have hs0 : 0 ≤ s := hs.1.le + have hsT : s ≤ T := hs.2.trans t.property.2 + have hheat := (finite_heat_bound Q rates b T (-s) hT.le + (by simpa only [abs_neg, abs_of_nonneg hs0] using hsT)).2 + rw [norm_smul] + exact mul_le_mul (f.norm_coe_le_norm _) hheat (norm_nonneg _) (norm_nonneg _) + calc + ‖ipLinear hT Q rates b f (t : ℝ)‖ ≤ + (‖f‖ * (heatBound Q rates T * ‖b‖)) * (t : ℝ) := by + simpa only [sub_zero, abs_of_nonneg t.property.1] using hint + _ ≤ (‖f‖ * (heatBound Q rates T * ‖b‖)) * T := + mul_le_mul_of_nonneg_left t.property.2 (by positivity) + _ = _ := by ring + +private theorem quadraticPath_norm {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v w : Path n T) : + ‖quadraticPath hT Q rates v w‖ ≤ (T * heatBound Q rates T ^ 3) * ‖v‖ * ‖w‖ := by + have hM := (heatBound_pos Q rates T).le + apply (ContinuousMap.norm_le _ (by positivity)).mpr + intro t + change ‖ipQuadratic hT Q rates v w (t : ℝ)‖ ≤ _ + have hint : ‖ipQuadratic hT Q rates v w (t : ℝ)‖ ≤ + (heatBound Q rates T ^ 3 * ‖v‖ * ‖w‖) * |(t : ℝ) - 0| := by + apply intervalIntegral.norm_integral_le_of_norm_le_const + intro s hs + rw [uIoc_of_le t.property.1] at hs + have hs0 : 0 ≤ s := hs.1.le + have hsT : s ≤ T := hs.2.trans t.property.2 + have hsabs : |s| ≤ T := by simpa only [abs_of_nonneg hs0] using hsT + have hsa : |-s| ≤ T := by simpa only [abs_neg] using hsabs + have hv : ‖C145.Pulse.heatAction Q rates s (extendPath hT v s)‖ ≤ + heatBound Q rates T * ‖v‖ := + ((finite_heat_bound Q rates _ T s hT.le hsabs).2).trans + (mul_le_mul_of_nonneg_left (v.norm_coe_le_norm _) hM) + have hw : ‖C145.Pulse.heatAction Q rates s (extendPath hT w s)‖ ≤ + heatBound Q rates T * ‖w‖ := + ((finite_heat_bound Q rates _ T s hT.le hsabs).2).trans + (mul_le_mul_of_nonneg_left (w.norm_coe_le_norm _) hM) + calc + ‖C145.Pulse.heatAction Q rates (-s) + (fun x => C145.Pulse.heatAction Q rates s (extendPath hT v s) x * + C145.Pulse.heatAction Q rates s (extendPath hT w s) x)‖ ≤ + heatBound Q rates T * + ‖C145.Pulse.heatAction Q rates s (extendPath hT v s) * + C145.Pulse.heatAction Q rates s (extendPath hT w s)‖ := + (finite_heat_bound Q rates _ T (-s) hT.le hsa).2 + _ ≤ heatBound Q rates T * + (‖C145.Pulse.heatAction Q rates s (extendPath hT v s)‖ * + ‖C145.Pulse.heatAction Q rates s (extendPath hT w s)‖) := + mul_le_mul_of_nonneg_left (norm_mul_le _ _) hM + _ ≤ heatBound Q rates T * ((heatBound Q rates T * ‖v‖) * + (heatBound Q rates T * ‖w‖)) := + mul_le_mul_of_nonneg_left + (mul_le_mul hv hw (norm_nonneg _) (by positivity)) hM + _ = _ := by ring + calc + ‖ipQuadratic hT Q rates v w (t : ℝ)‖ ≤ + (heatBound Q rates T ^ 3 * ‖v‖ * ‖w‖) * (t : ℝ) := by + simpa only [sub_zero, abs_of_nonneg t.property.1] using hint + _ ≤ (heatBound Q rates T ^ 3 * ‖v‖ * ‖w‖) * T := + mul_le_mul_of_nonneg_left t.property.2 (by positivity) + _ = _ := by ring + +private theorem heatPath_norm {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (σ : ℝ) (hσ : |σ| ≤ 1) (v : Path n T) : + ‖heatPath Q rates σ v‖ ≤ heatBound Q rates T * ‖v‖ := by + have hM := (heatBound_pos Q rates T).le + apply (ContinuousMap.norm_le _ (by positivity)).mpr + intro t + have hst : |σ * (t : ℝ)| ≤ T := by + rw [abs_mul, abs_of_nonneg t.property.1] + calc + |σ| * (t : ℝ) ≤ 1 * (t : ℝ) := + mul_le_mul_of_nonneg_right hσ t.property.1 + _ ≤ T := by simpa only [one_mul] using t.property.2 + exact ((finite_heat_bound Q rates _ T _ hT.le hst).2).trans + (mul_le_mul_of_nonneg_left (v.norm_coe_le_norm t) hM) + +private theorem linearPath_add {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (f g : Input T) : + linearPath hT Q rates b (f + g) = + linearPath hT Q rates b f + linearPath hT Q rates b g := by + apply ContinuousMap.ext + intro t + change ipLinear hT Q rates b (f + g) (t : ℝ) = + ipLinear hT Q rates b f (t : ℝ) + ipLinear hT Q rates b g (t : ℝ) + unfold ipLinear + simp only [extendInput, ContinuousMap.add_apply, add_smul] + exact intervalIntegral.integral_add + ((continuous_linearIntegrand hT Q rates b f).intervalIntegrable _ _) + ((continuous_linearIntegrand hT Q rates b g).intervalIntegrable _ _) + +private theorem linearPath_smul {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (c : ℝ) (f : Input T) : + linearPath hT Q rates b (c • f) = c • linearPath hT Q rates b f := by + apply ContinuousMap.ext + intro t + change ipLinear hT Q rates b (c • f) (t : ℝ) = c • ipLinear hT Q rates b f (t : ℝ) + unfold ipLinear + simp only [extendInput, ContinuousMap.smul_apply, smul_eq_mul, mul_smul] + exact intervalIntegral.integral_smul c _ + +private theorem quadraticIntegrand_add_left {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v v' w : Path n T) (s : ℝ) : + quadraticIntegrand hT Q rates (v + v') w s = + quadraticIntegrand hT Q rates v w s + quadraticIntegrand hT Q rates v' w s := by + have hext : extendPath hT (v + v') s = extendPath hT v s + extendPath hT v' s := rfl + unfold quadraticIntegrand + simp_rw [hext, heatAction_vec_add, Pi.add_apply] + have hprod : + (fun x => + (C145.Pulse.heatAction Q rates s (extendPath hT v s) x + + C145.Pulse.heatAction Q rates s (extendPath hT v' s) x) * + C145.Pulse.heatAction Q rates s (extendPath hT w s) x) = + (fun x => C145.Pulse.heatAction Q rates s (extendPath hT v s) x * + C145.Pulse.heatAction Q rates s (extendPath hT w s) x) + + (fun x => C145.Pulse.heatAction Q rates s (extendPath hT v' s) x * + C145.Pulse.heatAction Q rates s (extendPath hT w s) x) := by + funext x + exact add_mul _ _ _ + rw [hprod] + exact heatAction_vec_add Q rates _ _ (-s) + +private theorem quadraticIntegrand_smul_left {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (c : ℝ) (v w : Path n T) (s : ℝ) : + quadraticIntegrand hT Q rates (c • v) w s = + c • quadraticIntegrand hT Q rates v w s := by + have hext : extendPath hT (c • v) s = c • extendPath hT v s := rfl + unfold quadraticIntegrand + simp_rw [hext, heatAction_vec_smul, Pi.smul_apply, smul_eq_mul] + have hprod : + (fun x => (c * C145.Pulse.heatAction Q rates s (extendPath hT v s) x) * + C145.Pulse.heatAction Q rates s (extendPath hT w s) x) = + c • (fun x => C145.Pulse.heatAction Q rates s (extendPath hT v s) x * + C145.Pulse.heatAction Q rates s (extendPath hT w s) x) := by + funext x + simp only [Pi.smul_apply, smul_eq_mul] + ring + rw [hprod] + exact heatAction_vec_smul Q rates _ (-s) c + +private theorem quadraticIntegrand_symm {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v w : Path n T) (s : ℝ) : + quadraticIntegrand hT Q rates v w s = quadraticIntegrand hT Q rates w v s := by + unfold quadraticIntegrand + congr 1 + funext x + exact mul_comm _ _ + +private theorem quadraticPath_add_left {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v v' w : Path n T) : + quadraticPath hT Q rates (v + v') w = + quadraticPath hT Q rates v w + quadraticPath hT Q rates v' w := by + apply ContinuousMap.ext + intro t + change (∫ s in (0 : ℝ)..(t : ℝ), quadraticIntegrand hT Q rates (v + v') w s) = _ + simp_rw [quadraticIntegrand_add_left] + exact intervalIntegral.integral_add + ((continuous_quadraticIntegrand hT Q rates v w).intervalIntegrable _ _) + ((continuous_quadraticIntegrand hT Q rates v' w).intervalIntegrable _ _) + +private theorem quadraticPath_smul_left {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (c : ℝ) (v w : Path n T) : + quadraticPath hT Q rates (c • v) w = c • quadraticPath hT Q rates v w := by + apply ContinuousMap.ext + intro t + change (∫ s in (0 : ℝ)..(t : ℝ), quadraticIntegrand hT Q rates (c • v) w s) = _ + simp_rw [quadraticIntegrand_smul_left] + exact intervalIntegral.integral_smul c _ + +private theorem quadraticPath_symm {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v w : Path n T) : + quadraticPath hT Q rates v w = quadraticPath hT Q rates w v := by + apply ContinuousMap.ext + intro t + change (∫ s in (0 : ℝ)..(t : ℝ), quadraticIntegrand hT Q rates v w s) = _ + simp_rw [quadraticIntegrand_symm hT Q rates v w] + rfl + +private def linearOperator {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) : Input T →L[ℝ] Path n T := + LinearMap.mkContinuous + { toFun := linearPath hT Q rates b + map_add' := linearPath_add hT Q rates b + map_smul' := linearPath_smul hT Q rates b } + (T * heatBound Q rates T * ‖b‖) (linearPath_norm hT Q rates b) + +private def quadraticLinearMap {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) : Path n T →ₗ[ℝ] Path n T →ₗ[ℝ] Path n T := + LinearMap.mk₂ ℝ (quadraticPath hT Q rates) + (quadraticPath_add_left hT Q rates) + (quadraticPath_smul_left hT Q rates) + (fun v w w' => by + rw [quadraticPath_symm hT Q rates v (w + w'), quadraticPath_add_left, + quadraticPath_symm hT Q rates w v, quadraticPath_symm hT Q rates w' v]) + (fun c v w => by + rw [quadraticPath_symm hT Q rates v (c • w), quadraticPath_smul_left, + quadraticPath_symm hT Q rates w v]) + +private def quadraticOperator {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) : Path n T →L[ℝ] Path n T →L[ℝ] Path n T := + (quadraticLinearMap hT Q rates).mkContinuous₂ (T * heatBound Q rates T ^ 3) + (quadraticPath_norm hT Q rates) + +private def heatLinearMap {n : ℕ} {T : ℝ} (Q : Frame n) (rates : State n) + (σ : ℝ) : Path n T →ₗ[ℝ] Path n T where + toFun := heatPath Q rates σ + map_add' v w := by + apply ContinuousMap.ext + intro t + exact heatAction_vec_add Q rates (v t) (w t) _ + map_smul' c v := by + apply ContinuousMap.ext + intro t + exact heatAction_vec_smul Q rates (v t) _ c + +private def heatOperator {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (σ : ℝ) (hσ : |σ| ≤ 1) : + Path n T →L[ℝ] Path n T := + (heatLinearMap Q rates σ).mkContinuous (heatBound Q rates T) + (heatPath_norm hT Q rates σ hσ) + +theorem interaction_operators {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) : + ∃ (L : Input T →L[ℝ] Path n T) + (B : Path n T →L[ℝ] Path n T →L[ℝ] Path n T) + (Pplus Pminus : Path n T →L[ℝ] Path n T), + (∀ (f : Input T) (t : Time T), L f t = ipLinear hT Q rates b f t) ∧ + (∀ (v w : Path n T) (t : Time T), B v w t = ipQuadratic hT Q rates v w t) ∧ + (∀ (v : Path n T) (t : Time T), + Pplus v t = C145.Pulse.heatAction Q rates t (v t)) ∧ + (∀ (v : Path n T) (t : Time T), + Pminus v t = C145.Pulse.heatAction Q rates (-(t : ℝ)) (v t)) ∧ + (∀ v w : Path n T, B v w = B w v) ∧ + ‖L‖ ≤ T * heatBound Q rates T * ‖b‖ ∧ + ContinuousLinearMap.opNorm (𝕜 := ℝ) (𝕜₂ := ℝ) + (E := Path n T) (F := Path n T →L[ℝ] Path n T) + (σ₁₂ := RingHom.id ℝ) B ≤ T * heatBound Q rates T ^ 3 ∧ + ‖Pplus‖ ≤ heatBound Q rates T ∧ ‖Pminus‖ ≤ heatBound Q rates T := by + have hM := (heatBound_pos Q rates T).le + refine ⟨linearOperator hT Q rates b, quadraticOperator hT Q rates, + heatOperator hT Q rates 1 (by norm_num), heatOperator hT Q rates (-1) (by norm_num), + ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · intro f t + rfl + · intro v w t + rfl + · intro v t + change C145.Pulse.heatAction Q rates (1 * (t : ℝ)) (v t) = _ + rw [one_mul] + · intro v t + change C145.Pulse.heatAction Q rates (-1 * (t : ℝ)) (v t) = _ + rw [neg_one_mul] + · exact quadraticPath_symm hT Q rates + · exact LinearMap.mkContinuous_norm_le _ (by positivity) _ + · simpa only [quadraticOperator, ContinuousLinearMap.norm_def, ContinuousLinearMap.opNorm] using + (LinearMap.mkContinuous₂_norm_le (quadraticLinearMap hT Q rates) (by positivity) + (quadraticPath_norm hT Q rates)) + · exact LinearMap.mkContinuous_norm_le _ hM _ + · exact LinearMap.mkContinuous_norm_le _ hM _ + +/-! The residual inverse is genuinely nonlinear; its derivatives are not supplied. -/ + +private theorem residual_zero {n : ℕ} {T : ℝ} + (B : Path n T →L[ℝ] Path n T →L[ℝ] Path n T) : + ipResidual B 0 = 0 := by simp [ipResidual] + +private theorem residual_contDiff {n : ℕ} {T : ℝ} + (B : Path n T →L[ℝ] Path n T →L[ℝ] Path n T) : + ContDiff ℝ 2 (ipResidual B) := by + exact contDiff_id.sub + (B.isBoundedBilinearMap.contDiff.comp (contDiff_id.prodMk contDiff_id)) + +private theorem residual_hasFDerivAt_zero {n : ℕ} {T : ℝ} + (B : Path n T →L[ℝ] Path n T →L[ℝ] Path n T) : + HasFDerivAt (ipResidual B) (ContinuousLinearMap.id ℝ (Path n T)) 0 := by + have h := (hasFDerivAt_id (0 : Path n T)).sub + (B.hasFDerivAt_of_bilinear (hasFDerivAt_id (0 : Path n T)) + (hasFDerivAt_id (0 : Path n T))) + convert h using 1 + · rfl + · simp only [id_def, ContinuousLinearMap.map_zero, zero_apply, + add_zero, sub_zero] + +private theorem residual_local_inverse {n : ℕ} {T : ℝ} + (B : Path n T →L[ℝ] Path n T →L[ℝ] Path n T) : + ∃ W : Path n T → Path n T, + W 0 = 0 ∧ ContDiffAt ℝ 2 W 0 ∧ + HasFDerivAt W (ContinuousLinearMap.id ℝ (Path n T)) 0 ∧ + (∀ᶠ v in 𝓝 (0 : Path n T), W (ipResidual B v) = v) ∧ + (∀ᶠ z in 𝓝 (0 : Path n T), ipResidual B (W z) = z) := by + let e : Path n T ≃L[ℝ] Path n T := ContinuousLinearEquiv.refl ℝ _ + have hc : ContDiffAt ℝ 2 (ipResidual B) 0 := (residual_contDiff B).contDiffAt + have hd : HasFDerivAt (ipResidual B) (e : Path n T →L[ℝ] Path n T) 0 := by + simpa [e] using residual_hasFDerivAt_zero B + have hn : (2 : ℕ∞ω) ≠ 0 := by norm_num + let W := hc.localInverse hd hn + have hs := hc.hasStrictFDerivAt hd hn + refine ⟨W, ?_, ?_, ?_, ?_, ?_⟩ + · simpa only [residual_zero] using hc.localInverse_apply_image hd hn + · simpa only [residual_zero] using hc.to_localInverse hd hn + · simpa [W, ContDiffAt.localInverse, residual_zero, e] using hs.to_localInverse.hasFDerivAt + · exact hs.eventually_left_inverse + · simpa only [W, ContDiffAt.localInverse, residual_zero] using hs.eventually_right_inverse + +private theorem exists_interaction_C2_germ {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) : + ∃ V : Input T → Path n T, + V 0 = 0 ∧ ContDiffAt ℝ 2 V 0 ∧ + HasFDerivAt V (linearOperator hT Q rates b) 0 ∧ + ∀ᶠ f in 𝓝 (0 : Input T), + V f = linearPath hT Q rates b f + quadraticPath hT Q rates (V f) (V f) := by + let L := linearOperator hT Q rates b + let B := quadraticOperator hT Q rates + obtain ⟨W, hW0, hcW, hdW, hleft, hright⟩ := residual_local_inverse B + let V : Input T → Path n T := fun f => W (L f) + have hL0 : L 0 = 0 := L.map_zero + refine ⟨V, ?_, ?_, ?_, ?_⟩ + · simp only [V, hL0, hW0] + · have hcW' : ContDiffAt ℝ 2 W (L 0) := by simpa only [hL0] using hcW + exact hcW'.comp 0 (L.contDiff.contDiffAt) + · have hdW' : HasFDerivAt W (ContinuousLinearMap.id ℝ (Path n T)) (L 0) := by + simpa only [hL0] using hdW + simpa only [V, L, Function.comp_def, ContinuousLinearMap.id_comp] using hdW'.comp 0 + L.hasFDerivAt + · have hpre := L.continuous.continuousAt.tendsto.eventually + (show ∀ᶠ z in 𝓝 (L 0), ipResidual B (W z) = z by simpa only [hL0] using hright) + filter_upwards [hpre] with f hf + change V f = L f + B (V f) (V f) + change V f - B (V f) (V f) = L f at hf + exact sub_eq_iff_eq_add.mp hf + +private theorem heat_paths_inverse {n : ℕ} {T : ℝ} (_hT : 0 < T) + (Q : Frame n) (rates : State n) (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (v : Path n T) : + heatPath Q rates 1 (heatPath Q rates (-1) v) = v ∧ + heatPath Q rates (-1) (heatPath Q rates 1 v) = v := by + constructor + · apply ContinuousMap.ext + intro t + change C145.Pulse.heatAction Q rates (1 * (t : ℝ)) + (C145.Pulse.heatAction Q rates (-1 * (t : ℝ)) (v t)) = v t + rw [← heatAction_add Q rates (v t) hQ] + simpa only [one_mul, neg_one_mul, add_neg_cancel] using heatAction_zero Q rates (v t) hQ + · apply ContinuousMap.ext + intro t + change C145.Pulse.heatAction Q rates (-1 * (t : ℝ)) + (C145.Pulse.heatAction Q rates (1 * (t : ℝ)) (v t)) = v t + rw [← heatAction_add Q rates (v t) hQ] + simpa only [one_mul, neg_one_mul, neg_add_cancel] using heatAction_zero Q rates (v t) hQ + +private theorem ipLinear_hasDerivAt {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (f : Input T) (t : ℝ) : + HasDerivAt (ipLinear hT Q rates b f) (linearIntegrand hT Q rates b f t) t := + ((continuous_linearIntegrand hT Q rates b f).integral_hasStrictDerivAt 0 t).hasDerivAt + +private theorem ipQuadratic_hasDerivAt {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v w : Path n T) (t : ℝ) : + HasDerivAt (ipQuadratic hT Q rates v w) (quadraticIntegrand hT Q rates v w t) t := + ((continuous_quadraticIntegrand hT Q rates v w).integral_hasStrictDerivAt 0 t).hasDerivAt + +private theorem heatAction_along_hasDerivWithinAt {n : ℕ} (Q : Frame n) + (rates : State n) (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (v : ℝ → State n) (v' : State n) (S : Set ℝ) (t : ℝ) + (hv : HasDerivWithinAt v v' S t) : + HasDerivWithinAt (fun s => C145.Pulse.heatAction Q rates s (v s)) + (fun x => (∑ w, C145CoordinatePermutation.spectralGenerator rates Q x w * + C145.Pulse.heatAction Q rates t (v t) w) + + C145.Pulse.heatAction Q rates t v' x) S t := by + classical + apply hasDerivWithinAt_pi.mpr + intro x + have hmode (i : Fin (n + 1)) : + HasDerivWithinAt (fun s => ∑ u, Q u i * v s u) (∑ u, Q u i * v' u) S t := by + apply HasDerivWithinAt.fun_sum + intro u hu + exact (hasDerivWithinAt_pi.mp hv u).const_mul (Q u i) + have hexp (i : Fin (n + 1)) : + HasDerivWithinAt (fun s => Real.exp (-rates i * s)) + (Real.exp (-rates i * t) * (-rates i)) S t := by + simpa only [id_def, mul_one] using + (((hasDerivAt_id t).const_mul (-rates i)).exp).hasDerivWithinAt + have hd : HasDerivWithinAt + (fun s => ∑ i, Q x i * Real.exp (-rates i * s) * (∑ u, Q u i * v s u)) + (∑ i, ((Q x i * (Real.exp (-rates i * t) * (-rates i))) * (∑ u, Q u i * v t u) + + (Q x i * Real.exp (-rates i * t)) * (∑ u, Q u i * v' u))) S t := by + apply HasDerivWithinAt.fun_sum + intro i hi + exact ((hexp i).const_mul (Q x i)).mul (hmode i) + convert hd using 1 + · rfl + · rw [Finset.sum_add_distrib, ← generator_heat_mode Q rates (v t) hQ t x] + rfl + +private theorem heatPath_extend_at {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (v : Path n T) (s : ℝ) + (hs : s ∈ Icc (0 : ℝ) T) : + extendPath hT (heatPath Q rates 1 v) s = + C145.Pulse.heatAction Q rates s (extendPath hT v s) := by + let ts : Time T := ⟨s, hs⟩ + change extendPath hT (heatPath Q rates 1 v) (ts : ℝ) = + C145.Pulse.heatAction Q rates (ts : ℝ) (extendPath hT v (ts : ℝ)) + rw [extendPath_at, extendPath_at] + change C145.Pulse.heatAction Q rates (1 * s) (v ts) = _ + rw [one_mul] + +private theorem interaction_path_is_ode {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (f : Input T) (v : Path n T) + (hv : v = linearPath hT Q rates b f + quadraticPath hT Q rates v v) : + extendPath hT (heatPath Q rates 1 v) 0 = 0 ∧ + ∀ t ∈ Icc (0 : ℝ) T, + HasDerivWithinAt (extendPath hT (heatPath Q rates 1 v)) + (vectorField Q rates b (extendInput hT f) t + (extendPath hT (heatPath Q rates 1 v) t)) (Icc (0 : ℝ) T) t := by + have hveq : ∀ s ∈ Icc (0 : ℝ) T, + extendPath hT v s = ipLinear hT Q rates b f s + ipQuadratic hT Q rates v v s := by + intro s hs + let ts : Time T := ⟨s, hs⟩ + change extendPath hT v (ts : ℝ) = _ + rw [extendPath_at] + exact congrArg (fun p : Path n T => p ts) hv + have hzero : (0 : ℝ) ∈ Icc (0 : ℝ) T := ⟨le_rfl, hT.le⟩ + constructor + · rw [heatPath_extend_at hT Q rates v 0 hzero] + have hv0 : extendPath hT v 0 = 0 := by + simpa only [ipLinear, ipQuadratic, intervalIntegral.integral_same, add_zero] using hveq 0 + hzero + rw [hv0] + exact heatAction_zero Q rates 0 hQ + · intro t ht + have hvder : HasDerivWithinAt (extendPath hT v) + (linearIntegrand hT Q rates b f t + quadraticIntegrand hT Q rates v v t) + (Icc (0 : ℝ) T) t := + ((ipLinear_hasDerivAt hT Q rates b f t).add + (ipQuadratic_hasDerivAt hT Q rates v v t)).hasDerivWithinAt.congr_of_mem hveq ht + have huder := (heatAction_along_hasDerivWithinAt Q rates hQ _ _ _ t hvder).congr_of_mem + (heatPath_extend_at hT Q rates v) ht + have hinverse (z : State n) : + C145.Pulse.heatAction Q rates t (C145.Pulse.heatAction Q rates (-t) z) = z := by + rw [← heatAction_add Q rates z hQ, add_neg_cancel] + exact heatAction_zero Q rates z hQ + have hforcing : + C145.Pulse.heatAction Q rates t + (linearIntegrand hT Q rates b f t + quadraticIntegrand hT Q rates v v t) = + extendInput hT f t • b + + (fun x => C145.Pulse.heatAction Q rates t (extendPath hT v t) x ^ 2) := by + unfold linearIntegrand quadraticIntegrand + rw [heatAction_vec_add, heatAction_vec_smul, hinverse, hinverse] + congr 1 + funext x + rw [pow_two] + convert huder using 1 + funext x + rw [hforcing, heatPath_extend_at hT Q rates v t ht] + simp only [vectorField, Pi.add_apply, Pi.smul_apply, smul_eq_mul] + ring + +theorem exists_actual_C2_response {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) : + ∃ R : Input T → Path n T, + IsActualResponse hT Q rates b R ∧ ContDiffAt ℝ 2 R 0 := by + obtain ⟨V, hV0, hcV, hdV, hVeq⟩ := exists_interaction_C2_germ hT Q rates b + let P := heatOperator hT Q rates 1 (by norm_num : |(1 : ℝ)| ≤ 1) + let R : Input T → Path n T := fun f => P (V f) + refine ⟨R, ⟨?_, ?_⟩, ?_⟩ + · simp only [R, hV0, map_zero] + · filter_upwards [hVeq] with f hf + exact interaction_path_is_ode hT Q rates b hQ f (V f) hf + · exact P.contDiff.contDiffAt.comp 0 hcV + +private theorem generator_mode {n : ℕ} (Q : Frame n) (rates x : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) (i : Fin (n + 1)) : + (∑ v, Q v i * (∑ w, C145CoordinatePermutation.spectralGenerator rates Q v w * x w)) = + -rates i * (∑ w, Q w i * x w) := by + classical + have hleft : HasDerivAt (fun t : ℝ => ∑ v, Q v i * C145.Pulse.heatAction Q rates t x v) + (∑ v, Q v i * (∑ w, C145CoordinatePermutation.spectralGenerator rates Q v w * x w)) 0 := by + apply HasDerivAt.fun_sum + intro v hv + simpa only [heatAction_zero Q rates x hQ] using + ((hasDerivAt_pi.mp (heatAction_hasDerivAt Q rates x hQ 0)) v).const_mul (Q v i) + have hright : HasDerivAt (fun t : ℝ => ∑ v, Q v i * C145.Pulse.heatAction Q rates t x v) + (-rates i * (∑ w, Q w i * x w)) 0 := by + have heq : (fun t : ℝ => ∑ v, Q v i * C145.Pulse.heatAction Q rates t x v) = + (fun t : ℝ => Real.exp (-rates i * t) * (∑ w, Q w i * x w)) := + funext fun t => heatAction_mode Q rates x hQ t i + rw [heq] + simpa only [id_def, mul_one, mul_zero, Real.exp_zero, one_mul] using + (((hasDerivAt_id (0 : ℝ)).const_mul (-rates i)).exp).mul_const (∑ w, Q w i * x w) + exact hleft.unique hright + +private theorem heatAction_generator_commutes {n : ℕ} (Q : Frame n) + (rates x : State n) (hQ : C145PhysicalFrame.ColumnOrthonormal Q) (t : ℝ) : + C145.Pulse.heatAction Q rates t + (fun v => ∑ w, C145CoordinatePermutation.spectralGenerator rates Q v w * x w) = + (fun v => ∑ w, C145CoordinatePermutation.spectralGenerator rates Q v w * + C145.Pulse.heatAction Q rates t x w) := by + classical + funext v + change (∑ i, Q v i * Real.exp (-rates i * t) * + (∑ u, Q u i * (∑ w, C145CoordinatePermutation.spectralGenerator rates Q u w * x w))) = _ + simp_rw [generator_mode Q rates x hQ] + rw [generator_heat_mode Q rates x hQ t v] + apply Finset.sum_congr rfl + intro i hi + ring + +private theorem heatAction_neg_along_hasDerivWithinAt {n : ℕ} (Q : Frame n) + (rates : State n) (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (u : ℝ → State n) (u' : State n) (S : Set ℝ) (t : ℝ) + (hu : HasDerivWithinAt u u' S t) : + HasDerivWithinAt (fun s => C145.Pulse.heatAction Q rates (-s) (u s)) + (fun x => -(∑ w, C145CoordinatePermutation.spectralGenerator rates Q x w * + C145.Pulse.heatAction Q rates (-t) (u t) w) + + C145.Pulse.heatAction Q rates (-t) u' x) S t := by + classical + apply hasDerivWithinAt_pi.mpr + intro x + have hmode (i : Fin (n + 1)) : + HasDerivWithinAt (fun s => ∑ v, Q v i * u s v) (∑ v, Q v i * u' v) S t := by + apply HasDerivWithinAt.fun_sum + intro v hv + exact (hasDerivWithinAt_pi.mp hu v).const_mul (Q v i) + have hd : HasDerivWithinAt + (fun s => ∑ i, Q x i * Real.exp (rates i * s) * (∑ v, Q v i * u s v)) + (∑ i, ((Q x i * (Real.exp (rates i * t) * rates i)) * (∑ v, Q v i * u t v) + + (Q x i * Real.exp (rates i * t)) * (∑ v, Q v i * u' v))) S t := by + apply HasDerivWithinAt.fun_sum + intro i hi + with_reducible_and_instances + simpa only [id_def, mul_one] using + (((((hasDerivAt_id t).const_mul (rates i)).exp).hasDerivWithinAt).const_mul (Q x + i)).fun_mul (hmode i) + convert hd using 1 + · funext s + simp only [C145.Pulse.heatAction, neg_mul_neg] + · rw [Finset.sum_add_distrib, generator_heat_mode Q rates (u t) hQ (-t) x] + simp only [C145.Pulse.heatAction, neg_mul_neg] + rw [← Finset.sum_neg_distrib] + congr 1 + apply Finset.sum_congr rfl + intro i hi + ring + +private theorem heatPath_extend_scaled_at {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates : State n) (σ : ℝ) (v : Path n T) (s : ℝ) + (hs : s ∈ Icc (0 : ℝ) T) : + extendPath hT (heatPath Q rates σ v) s = + C145.Pulse.heatAction Q rates (σ * s) (extendPath hT v s) := by + let ts : Time T := ⟨s, hs⟩ + change extendPath hT (heatPath Q rates σ v) (ts : ℝ) = + C145.Pulse.heatAction Q rates (σ * (ts : ℝ)) (extendPath hT v (ts : ℝ)) + rw [extendPath_at, extendPath_at] + rfl + +private theorem actual_path_interaction {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (f : Input T) (u : Path n T) (hinit : extendPath hT u 0 = 0) + (hode : ∀ t ∈ Icc (0 : ℝ) T, + HasDerivWithinAt (extendPath hT u) + (vectorField Q rates b (extendInput hT f) t (extendPath hT u t)) (Icc (0 : ℝ) T) t) : + heatPath Q rates (-1) u = linearPath hT Q rates b f + + quadraticPath hT Q rates (heatPath Q rates (-1) u) (heatPath Q rates (-1) u) := by + let v := heatPath Q rates (-1) u + have hplus : ∀ s ∈ Icc (0 : ℝ) T, + C145.Pulse.heatAction Q rates s (extendPath hT v s) = extendPath hT u s := by + intro s hs + rw [heatPath_extend_scaled_at hT Q rates (-1) u s hs, neg_one_mul, + ← heatAction_add Q rates _ hQ, add_neg_cancel, heatAction_zero Q rates _ hQ] + have hv0 : extendPath hT v 0 = 0 := by + rw [heatPath_extend_scaled_at hT Q rates (-1) u 0 ⟨le_rfl, hT.le⟩, hinit] + simpa only [mul_zero] using heatAction_zero Q rates 0 hQ + have hvder : ∀ s ∈ Icc (0 : ℝ) T, + HasDerivWithinAt (extendPath hT v) + (linearIntegrand hT Q rates b f s + quadraticIntegrand hT Q rates v v s) + (Icc (0 : ℝ) T) s := by + intro s hs + have hd := (heatAction_neg_along_hasDerivWithinAt Q rates hQ _ _ _ s (hode s hs)).congr_of_mem + (fun r hr => by + simpa only [neg_one_mul] using heatPath_extend_scaled_at hT Q rates (-1) u r hr) hs + convert hd using 1 + have hgen := heatAction_generator_commutes Q rates (extendPath hT u s) hQ (-s) + have hsplit : vectorField Q rates b (extendInput hT f) s (extendPath hT u s) = + (fun x => ∑ w, C145CoordinatePermutation.spectralGenerator rates Q x w * extendPath hT u s + w) + + (fun x => extendPath hT u s x ^ 2) + extendInput hT f s • b := by + funext x + simp only [vectorField, Pi.add_apply, Pi.smul_apply, smul_eq_mul] + ring + rw [hsplit, heatAction_vec_add, heatAction_vec_add, heatAction_vec_smul, hgen] + unfold linearIntegrand quadraticIntegrand + simp_rw [hplus s hs] + funext x + simp only [Pi.add_apply, Pi.smul_apply, smul_eq_mul] + simp_rw [pow_two] + ring + apply ContinuousMap.ext + intro t + have hint : IntervalIntegrable + (fun s => linearIntegrand hT Q rates b f s + quadraticIntegrand hT Q rates v v s) + volume 0 (t : ℝ) := + ((continuous_linearIntegrand hT Q rates b f).add + (continuous_quadraticIntegrand hT Q rates v v)).intervalIntegrable _ _ + have hFTC := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le t.property.1 + (continuous_extendPath hT v).continuousOn + (fun s hs => (hvder s ⟨hs.1.le, hs.2.le.trans t.property.2⟩).hasDerivAt + (Icc_mem_nhds hs.1 (hs.2.trans_le t.property.2))) hint + rw [intervalIntegral.integral_add + ((continuous_linearIntegrand hT Q rates b f).intervalIntegrable _ _) + ((continuous_quadraticIntegrand hT Q rates v v).intervalIntegrable _ _), + hv0, sub_zero, extendPath_at hT v t] at hFTC + exact hFTC.symm + +theorem actual_response_germ_unique {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (R S : Input T → Path n T) + (hR : IsActualResponse hT Q rates b R) + (hS : IsActualResponse hT Q rates b S) + (hcR : ContinuousAt R 0) (hcS : ContinuousAt S 0) : + R =ᶠ[𝓝 (0 : Input T)] S := by + let L := linearOperator hT Q rates b + let B := quadraticOperator hT Q rates + let P := heatOperator hT Q rates (-1) (by norm_num : |(-1 : ℝ)| ≤ 1) + obtain ⟨W, hW0, hcW, hdW, hleft, hright⟩ := residual_local_inverse B + have hPR : Tendsto (fun f => P (R f)) (𝓝 (0 : Input T)) (𝓝 (0 : Path n T)) := by + have hc := P.continuous.continuousAt.comp hcR + simpa only [Function.comp_apply, Function.comp_def, hR.1, + ContinuousLinearMap.map_zero] using hc.tendsto + have hPS : Tendsto (fun f => P (S f)) (𝓝 (0 : Input T)) (𝓝 (0 : Path n T)) := by + have hc := P.continuous.continuousAt.comp hcS + simpa only [Function.comp_apply, Function.comp_def, hS.1, + ContinuousLinearMap.map_zero] using hc.tendsto + filter_upwards [hR.2, hS.2, hPR.eventually hleft, hPS.eventually hleft] with f hfR hfS hiR hiS + have hresR : ipResidual B (P (R f)) = L f := by + change P (R f) - B (P (R f)) (P (R f)) = L f + apply sub_eq_iff_eq_add.mpr + exact actual_path_interaction hT Q rates b hQ f (R f) hfR.1 hfR.2 + have hresS : ipResidual B (P (S f)) = L f := by + change P (S f) - B (P (S f)) (P (S f)) = L f + apply sub_eq_iff_eq_add.mpr + exact actual_path_interaction hT Q rates b hQ f (S f) hfS.1 hfS.2 + rw [hresR] at hiR + rw [hresS] at hiS + have heq : heatPath Q rates (-1) (R f) = heatPath Q rates (-1) (S f) := hiR.symm.trans hiS + calc + R f = heatPath Q rates 1 (heatPath Q rates (-1) (R f)) := + (heat_paths_inverse hT Q rates hQ (R f)).1.symm + _ = heatPath Q rates 1 (heatPath Q rates (-1) (S f)) := congrArg (heatPath Q rates 1) heq + _ = S f := (heat_paths_inverse hT Q rates hQ (S f)).1 + +/-! Differentiate the derived nonlinear integral identity twice. -/ + +private theorem interaction_fderiv_two {n : ℕ} {T : ℝ} + (L : Input T →L[ℝ] Path n T) + (B : Path n T →L[ℝ] Path n T →L[ℝ] Path n T) + (hB : ∀ v w, B v w = B w v) + (V : Input T → Path n T) (hV0 : V 0 = 0) (hcV : ContDiffAt ℝ 2 V 0) + (heq : V =ᶠ[𝓝 (0 : Input T)] fun f => L f + B (V f) (V f)) : + fderiv ℝ V 0 = L ∧ + ∀ g h : Input T, fderiv ℝ (fderiv ℝ V) 0 g h = 2 • B (L g) (L h) := by + let D := fderiv ℝ V + have hdiff : ∀ᶠ f in 𝓝 (0 : Input T), DifferentiableAt ℝ V f := + (hcV.eventually (by norm_num)).mono fun f hf => hf.differentiableAt (by norm_num) + have hDeq : D =ᶠ[𝓝 (0 : Input T)] fun f => + L + B.precompR (Input T) (V f) (D f) + B.precompL (Input T) (D f) (V f) := by + filter_upwards [heq.eventuallyEq_nhds, hdiff] with f hf hdf + have hd := (L.hasFDerivAt.add + (B.hasFDerivAt_of_bilinear hdf.hasFDerivAt hdf.hasFDerivAt)).congr_of_eventuallyEq hf + simpa only [add_assoc] using hd.fderiv + have hD0 : D 0 = L := by + have hz := hDeq.self_of_nhds + simpa only [hV0, ContinuousLinearMap.map_zero, zero_apply, zero_add, add_zero] using hz + refine ⟨hD0, ?_⟩ + intro g h + have hcD : ContDiffAt ℝ 1 D 0 := hcV.fderiv_right (by norm_num) + let DD := fderiv ℝ D 0 + have hdD : HasFDerivAt D DD 0 := hcD.differentiableAt_one.hasFDerivAt + have hdV : HasFDerivAt V L 0 := by + simpa only [D, hD0] using (hcV.differentiableAt (by norm_num)).hasFDerivAt + have hdDh : HasFDerivAt (fun f => D f h) (DD.flip h) 0 := by + simpa using hdD.clm_apply (hasFDerivAt_const h (0 : Input T)) + have hDhEq : (fun f => D f h) =ᶠ[𝓝 (0 : Input T)] + (fun f => L h + B (V f) (D f h) + B (D f h) (V f)) := by + filter_upwards [hDeq] with f hf + exact congrArg (fun K : Input T →L[ℝ] Path n T => K h) hf + have hright := ((hasFDerivAt_const (L h) (0 : Input T)).add + (B.hasFDerivAt_of_bilinear hdV hdDh)).add + (B.hasFDerivAt_of_bilinear hdDh hdV) + have hsecond := hdDh.unique (hright.congr_of_eventuallyEq hDhEq) + have hsecondg := congrArg (fun K : Input T →L[ℝ] Path n T => K g) hsecond + simp only [ContinuousLinearMap.flip_apply, add_apply, + zero_apply, ContinuousLinearMap.precompR_apply, + ContinuousLinearMap.precompL_apply, ContinuousLinearMap.compL_apply, + ContinuousLinearMap.comp_apply, hV0, hD0, map_zero, zero_add, add_zero] at hsecondg + change DD g h = 2 • B (L g) (L h) + rw [hsecondg, hB (L h) (L g), two_smul] + +private def heatAtOperator {n : ℕ} (Q : Frame n) (rates : State n) (t : ℝ) : + State n →L[ℝ] State n where + toFun := C145.Pulse.heatAction Q rates t + map_add' x y := heatAction_vec_add Q rates x y t + map_smul' c x := heatAction_vec_smul Q rates x t c + cont := (continuous_heat Q rates).comp (continuous_const.prodMk continuous_id) + +private theorem heat_plus_linear_at {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (g : Input T) (t : Time T) : + heatPath Q rates 1 (linearOperator hT Q rates b g) t = firstState hT Q rates b g t := by + change C145.Pulse.heatAction Q rates (1 * (t : ℝ)) (ipLinear hT Q rates b g t) = _ + rw [one_mul] + change (heatAtOperator Q rates t) (∫ s in (0 : ℝ)..(t : ℝ), linearIntegrand hT Q rates b g s) = _ + rw [← (heatAtOperator Q rates t).intervalIntegral_comp_comm + ((continuous_linearIntegrand hT Q rates b g).intervalIntegrable _ _)] + apply intervalIntegral.integral_congr + intro s hs + change C145.Pulse.heatAction Q rates (t : ℝ) + (extendInput hT g s • C145.Pulse.heatAction Q rates (-s) b) = + extendInput hT g s • C145.Pulse.heatAction Q rates ((t : ℝ) - s) b + rw [heatAction_vec_smul, ← heatAction_add Q rates b hQ, sub_eq_add_neg] + +private theorem heat_plus_quadratic_at {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (g h : Input T) (t : Time T) : + heatPath Q rates 1 + (quadraticOperator hT Q rates (linearOperator hT Q rates b g) (linearOperator hT Q rates b + h)) t = + secondState hT Q rates b g h t := by + let L := linearOperator hT Q rates b + change C145.Pulse.heatAction Q rates (1 * (t : ℝ)) (ipQuadratic hT Q rates (L g) (L h) t) = _ + rw [one_mul] + change (heatAtOperator Q rates t) + (∫ s in (0 : ℝ)..(t : ℝ), quadraticIntegrand hT Q rates (L g) (L h) s) = _ + rw [← (heatAtOperator Q rates t).intervalIntegral_comp_comm + ((continuous_quadraticIntegrand hT Q rates (L g) (L h)).intervalIntegrable _ _)] + apply intervalIntegral.integral_congr + intro s hs + have hsIcc : s ∈ Icc (0 : ℝ) T := by + rw [uIcc_of_le t.property.1] at hs + exact ⟨hs.1, hs.2.trans t.property.2⟩ + let ts : Time T := ⟨s, hsIcc⟩ + have hfirst (k : Input T) : + C145.Pulse.heatAction Q rates s (extendPath hT (L k) s) = firstState hT Q rates b k s := by + rw [extendPath_at hT (L k) ts] + have hk := heat_plus_linear_at hT Q rates b hQ k ts + change C145.Pulse.heatAction Q rates (1 * (ts : ℝ)) (L k ts) = + firstState hT Q rates b k (ts : ℝ) at hk + simpa only [one_mul] using hk + change C145.Pulse.heatAction Q rates (t : ℝ) + (C145.Pulse.heatAction Q rates (-s) + (fun x => C145.Pulse.heatAction Q rates s (extendPath hT (L g) s) x * + C145.Pulse.heatAction Q rates s (extendPath hT (L h) s) x)) = + C145.Pulse.heatAction Q rates ((t : ℝ) - s) + (fun x => firstState hT Q rates b g s x * firstState hT Q rates b h s x) + rw [← heatAction_add Q rates _ hQ, hfirst g, hfirst h, sub_eq_add_neg] + +private def observationOperator {n : ℕ} {T : ℝ} (b : State n) (t : Time T) : + Path n T →L[ℝ] ℝ := + ∑ v, b v • ((ContinuousLinearMap.proj v : State n →L[ℝ] ℝ).comp (ContinuousMap.evalCLM ℝ t)) + +private theorem observationOperator_apply {n : ℕ} {T : ℝ} (b : State n) (t : Time T) + (u : Path n T) : observationOperator b t u = observe b (u t) := by + simp only [observationOperator, sum_apply, smul_apply, + ContinuousLinearMap.comp_apply, ContinuousLinearMap.proj_apply, ContinuousMap.evalCLM_apply, + smul_eq_mul, observe] + +private theorem ordinary_derivatives_of_germ {n : ℕ} {T : ℝ} + (L : Input T →L[ℝ] Path n T) + (B : Path n T →L[ℝ] Path n T →L[ℝ] Path n T) + (hB : ∀ v w, B v w = B w v) + (V : Input T → Path n T) (hV0 : V 0 = 0) (hcV : ContDiffAt ℝ 2 V 0) + (heq : V =ᶠ[𝓝 (0 : Input T)] fun f => L f + B (V f) (V f)) + (J : Path n T →L[ℝ] ℝ) (g h : Input T) : + deriv (fun ε : ℝ => J (V (ε • g))) 0 = J (L g) ∧ + deriv (fun ε : ℝ => deriv (fun δ : ℝ => J (V (ε • g + δ • h))) 0) 0 = + 2 * J (B (L g) (L h)) ∧ + deriv (deriv (fun ε : ℝ => J (V (ε • g)))) 0 = 2 * J (B (L g) (L g)) := by + let D := fderiv ℝ V + obtain ⟨hD0, hDD⟩ := interaction_fderiv_two L B hB V hV0 hcV heq + have hDD' (k l : Input T) : fderiv ℝ D 0 k l = 2 • B (L k) (L l) := hDD k l + have hdV : HasFDerivAt V L 0 := by + simpa only [D, hD0] using (hcV.differentiableAt (by norm_num)).hasFDerivAt + have hline (k : Input T) (x : ℝ) : HasDerivAt (fun ε : ℝ => ε • k) k x := by + simpa only [id_def, one_smul] using (hasDerivAt_id x).smul_const k + have hfirst : HasDerivAt (fun ε : ℝ => J (V (ε • g))) (J (L g)) 0 := by + have hd : HasDerivAt (fun ε : ℝ => V (ε • g)) (L g) 0 := by + simpa only [Function.comp_def, zero_smul] using + hdV.comp_hasDerivAt_of_eq 0 (hline g 0) (by simp) + exact J.hasFDerivAt.comp_hasDerivAt 0 hd + refine ⟨hfirst.deriv, ?_, ?_⟩ + · have hcD : ContDiffAt ℝ 1 D 0 := hcV.fderiv_right (by norm_num) + have hdDh : HasFDerivAt (fun f => D f h) ((fderiv ℝ D 0).flip h) 0 := by + simpa using hcD.differentiableAt_one.hasFDerivAt.clm_apply + (hasFDerivAt_const h (0 : Input T)) + have hdOuter : HasDerivAt (fun ε : ℝ => J (D (ε • g) h)) (2 * J (B (L g) (L h))) 0 := by + have hd := J.hasFDerivAt.comp_hasDerivAt 0 + (show HasDerivAt (fun ε : ℝ => D (ε • g) h) + (fderiv ℝ D 0 g h) 0 by + simpa only [Function.comp_def, zero_smul, ContinuousLinearMap.flip_apply] using + hdDh.comp_hasDerivAt_of_eq 0 (hline g 0) (by simp)) + simpa only [Function.comp_def, hDD' g h, two_smul, J.map_add, two_mul] using hd + have hdiff : ∀ᶠ f in 𝓝 (0 : Input T), DifferentiableAt ℝ V f := + (hcV.eventually (by norm_num)).mono fun f hf => hf.differentiableAt (by norm_num) + have hlineT : Tendsto (fun ε : ℝ => ε • g) (𝓝 (0 : ℝ)) (𝓝 (0 : Input T)) := by + simpa only [zero_smul] using (hline g 0).continuousAt.tendsto + have hdiffLine : ∀ᶠ ε in 𝓝 (0 : ℝ), DifferentiableAt ℝ V (ε • g) := hlineT.eventually hdiff + have heqOuter : (fun ε : ℝ => deriv (fun δ : ℝ => J (V (ε • g + δ • h))) 0) =ᶠ[𝓝 (0 : ℝ)] + (fun ε : ℝ => J (D (ε • g) h)) := by + filter_upwards [hdiffLine] with ε hε + have hdline : HasDerivAt (fun δ : ℝ => ε • g + δ • h) h 0 := by + exact (hline h 0).const_add (ε • g) + have hdx : HasDerivAt (fun δ : ℝ => V (ε • g + δ • h)) (D (ε • g) h) 0 := by + simpa only [D, Function.comp_def, zero_smul, add_zero] using + hε.hasFDerivAt.comp_hasDerivAt_of_eq 0 hdline (by simp) + exact (J.hasFDerivAt.comp_hasDerivAt 0 hdx).deriv + exact (hdOuter.congr_of_eventuallyEq heqOuter).deriv + · have hcD : ContDiffAt ℝ 1 D 0 := hcV.fderiv_right (by norm_num) + have hdDg : HasFDerivAt (fun f => D f g) ((fderiv ℝ D 0).flip g) 0 := by + simpa using hcD.differentiableAt_one.hasFDerivAt.clm_apply + (hasFDerivAt_const g (0 : Input T)) + have hdOuter : HasDerivAt (fun ε : ℝ => J (D (ε • g) g)) (2 * J (B (L g) (L g))) 0 := by + have hd := J.hasFDerivAt.comp_hasDerivAt 0 + (show HasDerivAt (fun ε : ℝ => D (ε • g) g) + (fderiv ℝ D 0 g g) 0 by + simpa only [Function.comp_def, zero_smul, ContinuousLinearMap.flip_apply] using + hdDg.comp_hasDerivAt_of_eq 0 (hline g 0) (by simp)) + simpa only [Function.comp_def, hDD' g g, two_smul, J.map_add, two_mul] using hd + have hdiff : ∀ᶠ f in 𝓝 (0 : Input T), DifferentiableAt ℝ V f := + (hcV.eventually (by norm_num)).mono fun f hf => hf.differentiableAt (by norm_num) + have hlineT : Tendsto (fun ε : ℝ => ε • g) (𝓝 (0 : ℝ)) (𝓝 (0 : Input T)) := by + simpa only [zero_smul] using (hline g 0).continuousAt.tendsto + have hdiffLine : ∀ᶠ ε in 𝓝 (0 : ℝ), DifferentiableAt ℝ V (ε • g) := hlineT.eventually hdiff + have heqOuter : deriv (fun ε : ℝ => J (V (ε • g))) =ᶠ[𝓝 (0 : ℝ)] + (fun ε : ℝ => J (D (ε • g) g)) := by + filter_upwards [hdiffLine] with ε hε + exact (J.hasFDerivAt.comp_hasDerivAt ε (hε.hasFDerivAt.comp_hasDerivAt ε (hline g ε))).deriv + exact (hdOuter.congr_of_eventuallyEq heqOuter).deriv + +theorem actual_response_variations {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (R : Input T → Path n T) + (hR : IsActualResponse hT Q rates b R) (hcR : ContDiffAt ℝ 2 R 0) + (g h : Input T) (t : Time T) : + rawFirst b R g t = observe b (firstState hT Q rates b g t) ∧ + rawMixed b R g h t = observe b (secondState hT Q rates b g h t) ∧ + rawQuadratic b R g t = observe b (secondState hT Q rates b g g t) := by + let L := linearOperator hT Q rates b + let B := quadraticOperator hT Q rates + let Pminus := heatOperator hT Q rates (-1) (by norm_num : |(-1 : ℝ)| ≤ 1) + let Pplus := heatOperator hT Q rates 1 (by norm_num : |(1 : ℝ)| ≤ 1) + let V : Input T → Path n T := fun f => Pminus (R f) + let J := (observationOperator b t).comp Pplus + have hV0 : V 0 = 0 := by simp only [V, hR.1, map_zero] + have hcV : ContDiffAt ℝ 2 V 0 := Pminus.contDiff.contDiffAt.comp 0 hcR + have heq : V =ᶠ[𝓝 (0 : Input T)] fun f => L f + B (V f) (V f) := by + filter_upwards [hR.2] with f hf + exact actual_path_interaction hT Q rates b hQ f (R f) hf.1 hf.2 + have hB : ∀ v w, B v w = B w v := quadraticPath_symm hT Q rates + have hscalar (f : Input T) : observe b (R f t) = J (V f) := by + rw [show J (V f) = observe b (heatPath Q rates 1 (heatPath Q rates (-1) (R f)) t) by + exact observationOperator_apply b t _] + rw [(heat_paths_inverse hT Q rates hQ (R f)).1] + obtain ⟨hfirst, hmixed, hquad⟩ := ordinary_derivatives_of_germ L B hB V hV0 hcV heq J g h + have hJfirst : J (L g) = observe b (firstState hT Q rates b g t) := by + rw [show J (L g) = observe b (heatPath Q rates 1 (L g) t) by + exact observationOperator_apply b t _] + rw [heat_plus_linear_at hT Q rates b hQ g t] + have hJsecond (k : Input T) : J (B (L g) (L k)) = observe b (secondState hT Q rates b g k t) := by + rw [show J (B (L g) (L k)) = observe b (heatPath Q rates 1 (B (L g) (L k)) t) by + exact observationOperator_apply b t _] + rw [heat_plus_quadratic_at hT Q rates b hQ g k t] + constructor + · unfold rawFirst + simp_rw [hscalar] + exact hfirst.trans hJfirst + · constructor + · unfold rawMixed + simp_rw [hscalar] + rw [hmixed, hJsecond h] + ring + · unfold rawQuadratic + simp_rw [hscalar] + rw [hquad, hJsecond g] + ring + +-- Inert audit requests: no axiom printer has run in this workspace. + +end C145.ActualResponse +end + +end diff --git a/LeanPool/C145/C145ActualTimeConvolution.lean b/LeanPool/C145/C145ActualTimeConvolution.lean new file mode 100644 index 0000000000..c5389a4c0d --- /dev/null +++ b/LeanPool/C145/C145ActualTimeConvolution.lean @@ -0,0 +1,643 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145ActualResponseC2 +public import Mathlib.MeasureTheory.Integral.Prod +public import Mathlib.MeasureTheory.Integral.Bochner.Set +public import Mathlib.MeasureTheory.Integral.DominatedConvergence +public import Mathlib.MeasureTheory.Function.LocallyIntegrable +public import Mathlib.Topology.Algebra.Module.ContinuousLinearMap.PiProd +public import Mathlib.Tactic.FunProp +public import Mathlib.Tactic.Ring +public import Mathlib.Tactic.Linarith + +/-! +# Time-domain convolution formulas for the first and second response variations. +-/ + +@[expose] public section + +noncomputable section +namespace C145.ActualTimeConvolution +open MeasureTheory Set +open C145.ActualResponse +open scoped BigOperators Topology ContDiff +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +private theorem u2_continuous_extendInput {T : ℝ} + (hT : 0 < T) (g : Input T) : + Continuous (extendInput hT g) := by + exact g.continuous.comp continuous_projIcc + +private theorem u2_continuous_heat {n : ℕ} + (Q : Frame n) (rates : State n) : + Continuous (fun p : ℝ × State n => + C145.Pulse.heatAction Q rates p.1 p.2) := by + unfold C145.Pulse.heatAction + fun_prop + +private theorem u2_continuous_firstState {n : ℕ} {T : ℝ} + (hT : 0 < T) (Q : Frame n) (rates b : State n) (g : Input T) : + Continuous (firstState hT Q rates b g) := by + unfold firstState + apply intervalIntegral.continuous_parametric_intervalIntegral_of_continuous + · exact ((u2_continuous_extendInput hT g).comp continuous_snd).smul + ((u2_continuous_heat Q rates).comp + ((continuous_fst.sub continuous_snd).prodMk continuous_const)) + · exact continuous_id + +private theorem u2_continuous_delayIntegrand {n : ℕ} + (Q : Frame n) (rates b : State n) : + Continuous (fun p : (ℝ × ℝ) × ℝ => + C145.DelayKernel.delayIntegrand Q rates b p.1.1 p.1.2 p.2) := by + unfold C145.DelayKernel.delayIntegrand C145.Pulse.heatAction + fun_prop + +private theorem u2_continuous_delayKernel {n : ℕ} + (Q : Frame n) (rates b : State n) : + Continuous (fun p : ℝ × ℝ => + C145.DelayKernel.delayKernel Q rates b p.1 p.2) := by + unfold C145.DelayKernel.delayKernel + apply intervalIntegral.continuous_parametric_intervalIntegral_of_continuous + · exact u2_continuous_delayIntegrand Q rates b + · exact continuous_fst.min continuous_snd + +private theorem u2_state_integral_apply {n : ℕ} {a c : ℝ} + (f : ℝ → State n) (hf : Continuous f) (v : Fin (n + 1)) : + (∫ s in a..c, f s) v = ∫ s in a..c, f s v := by + simpa only [ContinuousLinearMap.proj_apply] using + ((ContinuousLinearMap.proj v : State n →L[ℝ] ℝ).intervalIntegral_comp_comm + (hf.intervalIntegrable a c)).symm + +private theorem u2_observe_integral {n : ℕ} {a c : ℝ} + (b : State n) (f : ℝ → State n) (hf : Continuous f) : + observe b (∫ s in a..c, f s) = + ∫ s in a..c, observe b (f s) := by + classical + have hterm (v : Fin (n + 1)) : + IntervalIntegrable (fun s : ℝ => b v * f s v) volume a c := by + have hcontinuous : Continuous (fun s : ℝ => b v * f s v) := + continuous_const.mul ((continuous_apply v).comp hf) + exact hcontinuous.intervalIntegrable a c + have hsum : + (∫ s in a..c, ∑ v : Fin (n + 1), b v * f s v) = + ∑ v : Fin (n + 1), ∫ s in a..c, b v * f s v := + intervalIntegral.integral_finsetSum + (a := a) (b := c) (μ := volume) + (s := Finset.univ) (f := fun v s => b v * f s v) + (fun v _ => hterm v) + change (∑ v : Fin (n + 1), b v * (∫ s in a..c, f s) v) = + ∫ s in a..c, ∑ v : Fin (n + 1), b v * f s v + calc + (∑ v : Fin (n + 1), b v * (∫ s in a..c, f s) v) = + ∑ v : Fin (n + 1), b v * (∫ s in a..c, f s v) := by + apply Finset.sum_congr rfl + intro v hv + exact congrArg (fun z : ℝ => b v * z) + (u2_state_integral_apply (a := a) (c := c) f hf v) + _ = ∑ v : Fin (n + 1), ∫ s in a..c, b v * f s v := by + apply Finset.sum_congr rfl + intro v hv + exact (intervalIntegral.integral_const_mul + (a := a) (b := c) (μ := volume) (b v) (fun s : ℝ => f s v)).symm + _ = ∫ s in a..c, ∑ v : Fin (n + 1), b v * f s v := hsum.symm + +private theorem u2_observe_heat_expansion {n : ℕ} + (Q : Frame n) (rates b x : State n) (a : ℝ) : + observe b (C145.Pulse.heatAction Q rates a x) = + ∑ w, (∑ v, ∑ i, + b v * Q v i * Real.exp (-rates i * a) * Q w i) * x w := by + classical + calc + observe b (C145.Pulse.heatAction Q rates a x) = + ∑ v, ∑ i, ∑ w, + b v * (Q v i * Real.exp (-rates i * a) * (Q w i * x w)) := by + simp only [observe, C145.Pulse.heatAction, Finset.mul_sum] + _ = ∑ v, ∑ w, ∑ i, + b v * (Q v i * Real.exp (-rates i * a) * (Q w i * x w)) := by + apply Finset.sum_congr rfl + intro v hv + exact Finset.sum_comm + _ = ∑ w, ∑ v, ∑ i, + b v * (Q v i * Real.exp (-rates i * a) * (Q w i * x w)) := + Finset.sum_comm + _ = ∑ w, (∑ v, ∑ i, + b v * Q v i * Real.exp (-rates i * a) * Q w i) * x w := by + simp only [Finset.sum_mul] + apply Finset.sum_congr rfl + intro w hw + apply Finset.sum_congr rfl + intro v hv + apply Finset.sum_congr rfl + intro i hi + ring + +private theorem u2_observe_heat_firstState_product {n : ℕ} {T : ℝ} + (hT : 0 < T) (Q : Frame n) (rates b : State n) + (g h : Input T) (t s : ℝ) : + observe b (C145.Pulse.heatAction Q rates (t - s) + (fun w => firstState hT Q rates b g s w * + firstState hT Q rates b h s w)) = + ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, + extendInput hT g u * extendInput hT h v * + C145.DelayKernel.delayIntegrand Q rates b + (t - u) (t - v) (t - s) := by + classical + let L : Fin (n + 1) → ℝ := fun w => + ∑ v, ∑ i, b v * Q v i * Real.exp (-rates i * (t - s)) * Q w i + let p : Fin (n + 1) → ℝ → ℝ := fun w u => + extendInput hT g u * C145.Pulse.heatAction Q rates (s - u) b w + let q : Fin (n + 1) → ℝ → ℝ := fun w v => + extendInput hT h v * C145.Pulse.heatAction Q rates (s - v) b w + have hp (w : Fin (n + 1)) : Continuous (p w) := by + exact (u2_continuous_extendInput hT g).mul + ((continuous_apply w).comp ((u2_continuous_heat Q rates).comp + ((continuous_const.sub continuous_id).prodMk continuous_const))) + have hq (w : Fin (n + 1)) : Continuous (q w) := by + exact (u2_continuous_extendInput hT h).mul + ((continuous_apply w).comp ((u2_continuous_heat Q rates).comp + ((continuous_const.sub continuous_id).prodMk continuous_const))) + have hfirst (k : Input T) (w : Fin (n + 1)) : + firstState hT Q rates b k s w = + ∫ u in (0 : ℝ)..s, + extendInput hT k u * C145.Pulse.heatAction Q rates (s - u) b w := by + simpa only [firstState, Pi.smul_apply, smul_eq_mul] using + (u2_state_integral_apply + (fun u => extendInput hT k u • C145.Pulse.heatAction Q rates (s - u) b) + ((u2_continuous_extendInput hT k).smul + ((u2_continuous_heat Q rates).comp + ((continuous_const.sub continuous_id).prodMk continuous_const))) w) + have hpoint (u v : ℝ) : + extendInput hT g u * extendInput hT h v * + C145.DelayKernel.delayIntegrand Q rates b (t - u) (t - v) (t - s) = + ∑ w, L w * p w u * q w v := by + change extendInput hT g u * extendInput hT h v * + observe b (C145.Pulse.heatAction Q rates (t - s) + (fun w => C145.Pulse.heatAction Q rates ((t - u) - (t - s)) b w * + C145.Pulse.heatAction Q rates ((t - v) - (t - s)) b w)) = _ + rw [show (t - u) - (t - s) = s - u by ring, + show (t - v) - (t - s) = s - v by ring, + u2_observe_heat_expansion, Finset.mul_sum] + apply Finset.sum_congr rfl + intro w hw + dsimp only [L, p, q] + ring + have hterm (w : Fin (n + 1)) : + L w * (∫ u in (0 : ℝ)..s, p w u) * (∫ v in (0 : ℝ)..s, q w v) = + ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, L w * p w u * q w v := by + simp only [intervalIntegral.integral_const_mul, intervalIntegral.integral_mul_const] + have hinner (u : ℝ) : + (∫ v in (0 : ℝ)..s, ∑ w, L w * p w u * q w v) = + ∑ w, ∫ v in (0 : ℝ)..s, L w * p w u * q w v := by + exact intervalIntegral.integral_finsetSum + (fun w _ => (continuous_const.mul (hq w)).intervalIntegrable 0 s) + have houter (w : Fin (n + 1)) : + IntervalIntegrable + (fun u => ∫ v in (0 : ℝ)..s, L w * p w u * q w v) volume 0 s := by + simp only [intervalIntegral.integral_const_mul] + exact ((continuous_const.mul (hp w)).mul continuous_const).intervalIntegrable 0 s + calc + observe b (C145.Pulse.heatAction Q rates (t - s) + (fun w => firstState hT Q rates b g s w * + firstState hT Q rates b h s w)) = + ∑ w, L w * (∫ u in (0 : ℝ)..s, p w u) * + (∫ v in (0 : ℝ)..s, q w v) := by + rw [u2_observe_heat_expansion] + apply Finset.sum_congr rfl + intro w hw + rw [hfirst g w, hfirst h w] + dsimp only [L, p, q] + ring + _ = ∑ w, ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, + L w * p w u * q w v := by + apply Finset.sum_congr rfl + intro w hw + exact hterm w + _ = ∫ u in (0 : ℝ)..s, ∑ w, ∫ v in (0 : ℝ)..s, + L w * p w u * q w v := + (intervalIntegral.integral_finsetSum (fun w _ => houter w)).symm + _ = ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, + ∑ w, L w * p w u * q w v := by + apply intervalIntegral.integral_congr + intro u hu + exact (hinner u).symm + _ = ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, + extendInput hT g u * extendInput hT h v * + C145.DelayKernel.delayIntegrand Q rates b + (t - u) (t - v) (t - s) := by + apply intervalIntegral.integral_congr + intro u hu + apply intervalIntegral.integral_congr + intro v hv + exact (hpoint u v).symm + +private theorem u2_secondState_triple_integral {n : ℕ} {T : ℝ} + (hT : 0 < T) (Q : Frame n) (rates b : State n) + (g h : Input T) (t : ℝ) : + observe b (secondState hT Q rates b g h t) = + ∫ s in (0 : ℝ)..t, ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, + extendInput hT g u * extendInput hT h v * + C145.DelayKernel.delayIntegrand Q rates b + (t - u) (t - v) (t - s) := by + let X : ℝ → State n := fun s => + firstState hT Q rates b g s * firstState hT Q rates b h s + have hX : Continuous X := + (u2_continuous_firstState hT Q rates b g).mul + (u2_continuous_firstState hT Q rates b h) + let H : ℝ → State n := fun s => + C145.Pulse.heatAction Q rates (t - s) (X s) + have htime : Continuous (fun s : ℝ => t - s) := + continuous_const.sub continuous_id + have hpair : Continuous (fun s : ℝ => (t - s, X s)) := + htime.prodMk hX + have hH : Continuous H := + (u2_continuous_heat Q rates).comp hpair + have hobserve : + observe b (∫ s in (0 : ℝ)..t, H s) = + ∫ s in (0 : ℝ)..t, observe b (H s) := + u2_observe_integral (a := (0 : ℝ)) (c := t) b H hH + calc + observe b (secondState hT Q rates b g h t) = + observe b (∫ s in (0 : ℝ)..t, H s) := rfl + _ = ∫ s in (0 : ℝ)..t, observe b (H s) := hobserve + _ = ∫ s in (0 : ℝ)..t, ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, + extendInput hT g u * extendInput hT h v * + C145.DelayKernel.delayIntegrand Q rates b + (t - u) (t - v) (t - s) := by + apply intervalIntegral.integral_congr + intro s hs + change observe b (C145.Pulse.heatAction Q rates (t - s) + (fun w => firstState hT Q rates b g s w * + firstState hT Q rates b h s w)) = _ + exact u2_observe_heat_firstState_product hT Q rates b g h t s + +private theorem u2_interval_eq_Icc {a c : ℝ} + (hac : a ≤ c) (f : ℝ → ℝ) : + (∫ s in a..c, f s) = ∫ s in Icc a c, f s := by + rw [intervalIntegral.integral_of_le hac, integral_Icc_eq_integral_Ioc] + +private theorem u2_compact_cube_integrable + (t : ℝ) (_ht : 0 ≤ t) (F : ℝ → ℝ → ℝ → ℝ) + (hF : Continuous (fun p : ℝ × (ℝ × ℝ) => F p.1 p.2.1 p.2.2)) : + let ρ : Measure ℝ := volume.restrict (Icc (0 : ℝ) t) + Integrable + (({p : ℝ × (ℝ × ℝ) | p.2.1 ≤ p.1 ∧ p.2.2 ≤ p.1}).indicator + (fun p => F p.1 p.2.1 p.2.2)) + (ρ.prod (ρ.prod ρ)) := by + let C : Set ℝ := Icc (0 : ℝ) t + have hcube : IsCompact (C ×ˢ (C ×ˢ C)) := + isCompact_Icc.prod (isCompact_Icc.prod isCompact_Icc) + have hbase : IntegrableOn + (fun p : ℝ × (ℝ × ℝ) => F p.1 p.2.1 p.2.2) + (C ×ˢ (C ×ˢ C)) + ((volume : Measure ℝ).prod ((volume : Measure ℝ).prod volume)) := + hF.continuousOn.integrableOn_compact hcube + have hrestricted : Integrable + (fun p : ℝ × (ℝ × ℝ) => F p.1 p.2.1 p.2.2) + ((volume.restrict C).prod ((volume.restrict C).prod (volume.restrict C))) := by + rw [Measure.prod_restrict C C, Measure.prod_restrict C (C ×ˢ C)] + exact hbase + have hclosed : IsClosed + {p : ℝ × (ℝ × ℝ) | p.2.1 ≤ p.1 ∧ p.2.2 ≤ p.1} := + (isClosed_le (continuous_fst.comp continuous_snd) continuous_fst).inter + (isClosed_le (continuous_snd.comp continuous_snd) continuous_fst) + exact hrestricted.indicator hclosed.measurableSet + +private theorem u2_lower_square_section + (t s : ℝ) (hs : s ∈ Icc (0 : ℝ) t) + (F : ℝ → ℝ → ℝ → ℝ) + (hF : Continuous (fun p : ℝ × (ℝ × ℝ) => F p.1 p.2.1 p.2.2)) : + (∫ q in Icc (0 : ℝ) t ×ˢ Icc (0 : ℝ) t, + (({z : ℝ × ℝ | z.1 ≤ s ∧ z.2 ≤ s}).indicator + (fun z => F s z.1 z.2)) q) = + ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, F s u v := by + have hmask : MeasurableSet {z : ℝ × ℝ | z.1 ≤ s ∧ z.2 ≤ s} := + ((isClosed_le continuous_fst continuous_const).inter + (isClosed_le continuous_snd continuous_const)).measurableSet + have hset : + (Icc (0 : ℝ) t ×ˢ Icc (0 : ℝ) t) ∩ + {z : ℝ × ℝ | z.1 ≤ s ∧ z.2 ≤ s} = + Icc (0 : ℝ) s ×ˢ Icc (0 : ℝ) s := by + ext z + constructor + · rintro ⟨⟨hu, hv⟩, hz⟩ + exact ⟨⟨hu.1, hz.1⟩, ⟨hv.1, hz.2⟩⟩ + · rintro ⟨hu, hv⟩ + exact ⟨⟨⟨hu.1, hu.2.trans hs.2⟩, ⟨hv.1, hv.2.trans hs.2⟩⟩, + ⟨hu.2, hv.2⟩⟩ + have hsection : Continuous (fun z : ℝ × ℝ => F s z.1 z.2) := + hF.comp (continuous_const.prodMk continuous_id) + have hint : IntegrableOn (fun z : ℝ × ℝ => F s z.1 z.2) + (Icc (0 : ℝ) s ×ˢ Icc (0 : ℝ) s) + ((volume : Measure ℝ).prod volume) := + hsection.continuousOn.integrableOn_compact (isCompact_Icc.prod isCompact_Icc) + rw [setIntegral_indicator hmask, hset] + change (∫ z in Icc (0 : ℝ) s ×ˢ Icc (0 : ℝ) s, + F s z.1 z.2 ∂((volume : Measure ℝ).prod volume)) = _ + rw [setIntegral_prod _ hint, u2_interval_eq_Icc hs.1] + apply setIntegral_congr_fun measurableSet_Icc + intro u hu + exact (u2_interval_eq_Icc hs.1 (F s u)).symm + +private theorem u2_upper_time_section + (t u v : ℝ) (hu : u ∈ Icc (0 : ℝ) t) + (hv : v ∈ Icc (0 : ℝ) t) (F : ℝ → ℝ → ℝ → ℝ) : + (∫ s in Icc (0 : ℝ) t, + (({s : ℝ | u ≤ s ∧ v ≤ s}).indicator + (fun s => F s u v)) s) = + ∫ s in max u v..t, F s u v := by + have hmask : MeasurableSet {s : ℝ | u ≤ s ∧ v ≤ s} := + ((isClosed_le continuous_const continuous_id).inter + (isClosed_le continuous_const continuous_id)).measurableSet + have hset : Icc (0 : ℝ) t ∩ {s : ℝ | u ≤ s ∧ v ≤ s} = + Icc (max u v) t := by + ext s + constructor + · rintro ⟨hs, hm⟩ + exact ⟨max_le hm.1 hm.2, hs.2⟩ + · intro hs + have hus : u ≤ s := (le_max_left u v).trans hs.1 + have hvs : v ≤ s := (le_max_right u v).trans hs.1 + exact ⟨⟨hu.1.trans hus, hs.2⟩, ⟨hus, hvs⟩⟩ + rw [setIntegral_indicator hmask, hset] + exact (u2_interval_eq_Icc (max_le hu.2 hv.2) (fun s => F s u v)).symm + +private theorem u2_compact_square_fubini + (t : ℝ) (ht : 0 ≤ t) (F : ℝ → ℝ → ℝ → ℝ) + (hF : Continuous (fun p : ℝ × (ℝ × ℝ) => F p.1 p.2.1 p.2.2)) : + (∫ s in (0 : ℝ)..t, ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, + F s u v) = + ∫ u in (0 : ℝ)..t, ∫ v in (0 : ℝ)..t, + ∫ s in max u v..t, F s u v := by + let C : Set ℝ := Icc (0 : ℝ) t + let ρ : Measure ℝ := volume.restrict C + let : IsFiniteMeasure ρ := ⟨by + change (volume.restrict C) Set.univ < ⊤ + rw [Measure.restrict_apply_univ] + exact isCompact_Icc.measure_lt_top⟩ + let J : ℝ → (ℝ × ℝ) → ℝ := fun s q => + ({p : ℝ × (ℝ × ℝ) | p.2.1 ≤ p.1 ∧ p.2.2 ≤ p.1}).indicator + (fun p => F p.1 p.2.1 p.2.2) (s, q) + have hJ : Integrable (Function.uncurry J) (ρ.prod (ρ.prod ρ)) := + u2_compact_cube_integrable t ht F hF + have hlower (s : ℝ) (hs : s ∈ C) : + (∫ q, J s q ∂(ρ.prod ρ)) = + ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, F s u v := by + change (∫ q, J s q ∂((volume.restrict C).prod (volume.restrict C))) = _ + rw [Measure.prod_restrict C C] + exact u2_lower_square_section t s hs F hF + have hupper (u v : ℝ) (hu : u ∈ C) (hv : v ∈ C) : + (∫ s, J s (u, v) ∂ρ) = ∫ s in max u v..t, F s u v := by + exact u2_upper_time_section t u v hu hv F + have hmarginal : Integrable (fun q => ∫ s, J s q ∂ρ) (ρ.prod ρ) := + hJ.integral_prod_right + have hrow (u : ℝ) (hu : u ∈ C) : + (∫ v, ∫ s, J s (u, v) ∂ρ ∂ρ) = + ∫ v in (0 : ℝ)..t, ∫ s in max u v..t, F s u v := by + calc + (∫ v, ∫ s, J s (u, v) ∂ρ ∂ρ) = + ∫ v in C, ∫ s, J s (u, v) ∂ρ := rfl + _ = ∫ v in C, ∫ s in max u v..t, F s u v := by + apply setIntegral_congr_fun (s := C) measurableSet_Icc + intro v hv + change (∫ s, J s (u, v) ∂ρ) = ∫ s in max u v..t, F s u v + exact hupper u v hu hv + _ = ∫ v in (0 : ℝ)..t, ∫ s in max u v..t, F s u v := + (u2_interval_eq_Icc ht (fun v => ∫ s in max u v..t, F s u v)).symm + calc + (∫ s in (0 : ℝ)..t, ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, + F s u v) = + ∫ s in C, ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, F s u v := + u2_interval_eq_Icc ht + (fun s => ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, F s u v) + _ = ∫ s in C, ∫ q, J s q ∂(ρ.prod ρ) := by + apply setIntegral_congr_fun (s := C) measurableSet_Icc + intro s hs + change (∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, F s u v) = + ∫ q, J s q ∂(ρ.prod ρ) + exact (hlower s hs).symm + _ = ∫ s, ∫ q, J s q ∂(ρ.prod ρ) ∂ρ := rfl + _ = ∫ q, ∫ s, J s q ∂ρ ∂(ρ.prod ρ) := integral_integral_swap hJ + _ = ∫ u, ∫ v, ∫ s, J s (u, v) ∂ρ ∂ρ ∂ρ := + integral_prod (fun q : ℝ × ℝ => ∫ s, J s q ∂ρ) hmarginal + _ = ∫ u in C, ∫ v in (0 : ℝ)..t, ∫ s in max u v..t, F s u v := by + change (∫ u in C, ∫ v, ∫ s, J s (u, v) ∂ρ ∂ρ) = _ + apply setIntegral_congr_fun (s := C) measurableSet_Icc + intro u hu + change (∫ v, ∫ s, J s (u, v) ∂ρ ∂ρ) = + ∫ v in (0 : ℝ)..t, ∫ s in max u v..t, F s u v + exact hrow u hu + _ = ∫ u in (0 : ℝ)..t, ∫ v in (0 : ℝ)..t, + ∫ s in max u v..t, F s u v := + (u2_interval_eq_Icc ht + (fun u => ∫ v in (0 : ℝ)..t, ∫ s in max u v..t, F s u v)).symm + +private theorem u2_backward_delay_inner {n : ℕ} {T : ℝ} + (hT : 0 < T) (Q : Frame n) (rates b : State n) + (g h : Input T) (t u v : ℝ) : + (∫ s in max u v..t, + extendInput hT g u * extendInput hT h v * + C145.DelayKernel.delayIntegrand Q rates b + (t - u) (t - v) (t - s)) = + C145.DelayKernel.delayKernel Q rates b (t - u) (t - v) * + extendInput hT g u * extendInput hT h v := by + have hendpoint : t - max u v = min (t - u) (t - v) := by + rcases le_total u v with huv | hvu + · rw [max_eq_right huv, min_eq_right (by linarith : t - v ≤ t - u)] + · rw [max_eq_left hvu, min_eq_left (by linarith : t - u ≤ t - v)] + have hreflect := intervalIntegral.integral_comp_sub_left + (fun a : ℝ => C145.DelayKernel.delayIntegrand Q rates b (t - u) (t - v) a) + (a := max u v) (b := t) t + calc + (∫ s in max u v..t, + extendInput hT g u * extendInput hT h v * + C145.DelayKernel.delayIntegrand Q rates b (t - u) (t - v) (t - s)) = + (extendInput hT g u * extendInput hT h v) * + (∫ s in max u v..t, + C145.DelayKernel.delayIntegrand Q rates b (t - u) (t - v) (t - s)) := + intervalIntegral.integral_const_mul _ _ + _ = (extendInput hT g u * extendInput hT h v) * + C145.DelayKernel.delayKernel Q rates b (t - u) (t - v) := by + congr 1 + simpa only [C145.DelayKernel.delayKernel, sub_self, hendpoint] using hreflect + _ = C145.DelayKernel.delayKernel Q rates b (t - u) (t - v) * + extendInput hT g u * extendInput hT h v := by ring + +theorem firstState_time_kernel {n : ℕ} {T : ℝ} + (hT : 0 < T) (Q : Frame n) (rates b : State n) + (g : Input T) (t : Time T) : + observe b (firstState hT Q rates b g (t : ℝ)) = + ∫ r in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.firstKernel Q rates b r * + extendInput hT g ((t : ℝ) - r) := by + have hcontinuous : Continuous + (fun u : ℝ => extendInput hT g u • + C145.Pulse.heatAction Q rates ((t : ℝ) - u) b) := + (u2_continuous_extendInput hT g).smul + ((u2_continuous_heat Q rates).comp + ((continuous_const.sub continuous_id).prodMk continuous_const)) + have hinverse (u : ℝ) : (t : ℝ) - ((t : ℝ) - u) = u := by ring + unfold firstState + rw [u2_observe_integral b _ hcontinuous] + calc + (∫ u in (0 : ℝ)..(t : ℝ), + observe b (extendInput hT g u • + C145.Pulse.heatAction Q rates ((t : ℝ) - u) b)) = + ∫ u in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.firstKernel Q rates b ((t : ℝ) - u) * extendInput hT g u := by + apply intervalIntegral.integral_congr + intro u hu + simp only [observe, C145.DelayKernel.firstKernel, Pi.smul_apply, + smul_eq_mul, Finset.sum_mul] + apply Finset.sum_congr rfl + intro v hv + ring + _ = ∫ r in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.firstKernel Q rates b r * + extendInput hT g ((t : ℝ) - r) := by + have hreflect := intervalIntegral.integral_comp_sub_left + (fun r : ℝ => C145.DelayKernel.firstKernel Q rates b r * + extendInput hT g ((t : ℝ) - r)) + (a := (0 : ℝ)) (b := (t : ℝ)) (t : ℝ) + simpa only [sub_self, sub_zero, hinverse] using hreflect + +theorem secondState_time_kernel {n : ℕ} {T : ℝ} + (hT : 0 < T) (Q : Frame n) (rates b : State n) + (g h : Input T) (t : Time T) : + observe b (secondState hT Q rates b g h (t : ℝ)) = + ∫ r₁ in (0 : ℝ)..(t : ℝ), ∫ r₂ in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.delayKernel Q rates b r₁ r₂ * + extendInput hT g ((t : ℝ) - r₁) * + extendInput hT h ((t : ℝ) - r₂) := by + let D : (ℝ × ℝ) × ℝ → ℝ := fun z => + C145.DelayKernel.delayIntegrand Q rates b z.1.1 z.1.2 z.2 + have hD : Continuous D := u2_continuous_delayIntegrand Q rates b + let U : ℝ × (ℝ × ℝ) → ℝ := fun p => p.2.1 + let V : ℝ × (ℝ × ℝ) → ℝ := fun p => p.2.2 + let S : ℝ × (ℝ × ℝ) → ℝ := fun p => p.1 + have hU : Continuous U := continuous_fst.comp continuous_snd + have hV : Continuous V := continuous_snd.comp continuous_snd + have hS : Continuous S := continuous_fst + let R₁ : ℝ × (ℝ × ℝ) → ℝ := fun p => (t : ℝ) - U p + let R₂ : ℝ × (ℝ × ℝ) → ℝ := fun p => (t : ℝ) - V p + let A : ℝ × (ℝ × ℝ) → ℝ := fun p => (t : ℝ) - S p + have hR₁ : Continuous R₁ := continuous_const.sub hU + have hR₂ : Continuous R₂ := continuous_const.sub hV + have hA : Continuous A := continuous_const.sub hS + let P : ℝ × (ℝ × ℝ) → (ℝ × ℝ) × ℝ := fun p => ((R₁ p, R₂ p), A p) + have hP : Continuous P := (hR₁.prodMk hR₂).prodMk hA + let G : ℝ × (ℝ × ℝ) → ℝ := fun p => extendInput hT g (U p) + let H : ℝ × (ℝ × ℝ) → ℝ := fun p => extendInput hT h (V p) + have hG : Continuous G := (u2_continuous_extendInput hT g).comp hU + have hH : Continuous H := (u2_continuous_extendInput hT h).comp hV + have hDP : Continuous (fun p : ℝ × (ℝ × ℝ) => D (P p)) := hD.comp hP + have hproduct : Continuous + (fun p : ℝ × (ℝ × ℝ) => (G p * H p) * D (P p)) := + (hG.mul hH).mul hDP + let F : ℝ → ℝ → ℝ → ℝ := fun s u v => + extendInput hT g u * extendInput hT h v * + C145.DelayKernel.delayIntegrand Q rates b + ((t : ℝ) - u) ((t : ℝ) - v) ((t : ℝ) - s) + have hFdef : + (fun p : ℝ × (ℝ × ℝ) => (G p * H p) * D (P p)) = + (fun p : ℝ × (ℝ × ℝ) => F p.1 p.2.1 p.2.2) := rfl + have hF : Continuous (fun p : ℝ × (ℝ × ℝ) => F p.1 p.2.1 p.2.2) := + Eq.mp (congrArg (fun k : ℝ × (ℝ × ℝ) → ℝ => Continuous k) hFdef) hproduct + have hinverse (u : ℝ) : (t : ℝ) - ((t : ℝ) - u) = u := by ring + have hinner (u : ℝ) : + (∫ v in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.delayKernel Q rates b ((t : ℝ) - u) ((t : ℝ) - v) * + extendInput hT g u * extendInput hT h v) = + ∫ r₂ in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.delayKernel Q rates b ((t : ℝ) - u) r₂ * + extendInput hT g u * extendInput hT h ((t : ℝ) - r₂) := by + have hreflect := intervalIntegral.integral_comp_sub_left + (fun r₂ : ℝ => C145.DelayKernel.delayKernel Q rates b ((t : ℝ) - u) r₂ * + extendInput hT g u * extendInput hT h ((t : ℝ) - r₂)) + (a := (0 : ℝ)) (b := (t : ℝ)) (t : ℝ) + simpa only [sub_self, sub_zero, hinverse] using hreflect + calc + observe b (secondState hT Q rates b g h (t : ℝ)) = + ∫ s in (0 : ℝ)..(t : ℝ), ∫ u in (0 : ℝ)..s, ∫ v in (0 : ℝ)..s, + F s u v := + u2_secondState_triple_integral hT Q rates b g h (t : ℝ) + _ = ∫ u in (0 : ℝ)..(t : ℝ), ∫ v in (0 : ℝ)..(t : ℝ), + ∫ s in max u v..(t : ℝ), F s u v := + u2_compact_square_fubini (t : ℝ) t.property.1 F hF + _ = ∫ u in (0 : ℝ)..(t : ℝ), ∫ v in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.delayKernel Q rates b ((t : ℝ) - u) ((t : ℝ) - v) * + extendInput hT g u * extendInput hT h v := by + apply intervalIntegral.integral_congr + intro u hu + apply intervalIntegral.integral_congr + intro v hv + change (∫ s in max u v..(t : ℝ), + extendInput hT g u * extendInput hT h v * + C145.DelayKernel.delayIntegrand Q rates b + ((t : ℝ) - u) ((t : ℝ) - v) ((t : ℝ) - s)) = _ + exact u2_backward_delay_inner hT Q rates b g h (t : ℝ) u v + _ = ∫ u in (0 : ℝ)..(t : ℝ), ∫ r₂ in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.delayKernel Q rates b ((t : ℝ) - u) r₂ * + extendInput hT g u * extendInput hT h ((t : ℝ) - r₂) := by + apply intervalIntegral.integral_congr + intro u hu + change (∫ v in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.delayKernel Q rates b ((t : ℝ) - u) ((t : ℝ) - v) * + extendInput hT g u * extendInput hT h v) = _ + exact hinner u + _ = ∫ r₁ in (0 : ℝ)..(t : ℝ), ∫ r₂ in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.delayKernel Q rates b r₁ r₂ * + extendInput hT g ((t : ℝ) - r₁) * + extendInput hT h ((t : ℝ) - r₂) := by + have hreflect := intervalIntegral.integral_comp_sub_left + (fun r₁ : ℝ => ∫ r₂ in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.delayKernel Q rates b r₁ r₂ * + extendInput hT g ((t : ℝ) - r₁) * + extendInput hT h ((t : ℝ) - r₂)) + (a := (0 : ℝ)) (b := (t : ℝ)) (t : ℝ) + simpa only [sub_self, sub_zero, hinverse] using hreflect + +theorem actual_response_time_kernel {n : ℕ} {T : ℝ} + (hT : 0 < T) (Q : Frame n) (rates b : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (R : Input T → Path n T) + (hR : IsActualResponse hT Q rates b R) + (hcR : ContDiffAt ℝ 2 R 0) + (g h : Input T) (t : Time T) : + rawFirst b R g t = + (∫ r in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.firstKernel Q rates b r * + extendInput hT g ((t : ℝ) - r)) ∧ + rawMixed b R g h t = + (∫ r₁ in (0 : ℝ)..(t : ℝ), ∫ r₂ in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.delayKernel Q rates b r₁ r₂ * + extendInput hT g ((t : ℝ) - r₁) * + extendInput hT h ((t : ℝ) - r₂)) ∧ + rawQuadratic b R g t = + (∫ r₁ in (0 : ℝ)..(t : ℝ), ∫ r₂ in (0 : ℝ)..(t : ℝ), + C145.DelayKernel.delayKernel Q rates b r₁ r₂ * + extendInput hT g ((t : ℝ) - r₁) * + extendInput hT g ((t : ℝ) - r₂)) := by + obtain ⟨hfirst, hmixed, hquadratic⟩ := + actual_response_variations hT Q rates b hQ R hR hcR g h t + exact ⟨hfirst.trans (firstState_time_kernel hT Q rates b g t), + hmixed.trans (secondState_time_kernel hT Q rates b g h t), + hquadratic.trans (secondState_time_kernel hT Q rates b g g t)⟩ + + +end C145.ActualTimeConvolution +end + +end diff --git a/LeanPool/C145/C145CompleteOrdinaryH2Kernel.lean b/LeanPool/C145/C145CompleteOrdinaryH2Kernel.lean new file mode 100644 index 0000000000..4fddcaa626 --- /dev/null +++ b/LeanPool/C145/C145CompleteOrdinaryH2Kernel.lean @@ -0,0 +1,272 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145H2GridResidueInverse + +/-! +C145: complete ordinary, unshifted, fully symmetric residual H2 kernel. + +The imported actual numerator, Box, regular response, grid inverse and +three-plane factorization are used unchanged. Coordinates are z=X 0, +x=X 1, y=X 2. Individual real rates need only be injective. Positivity is +assumed only in the named all-positive-data corollaries. No additive +nonresonance, supplied divisibility/reconstruction or rank premise occurs. +-/ + +@[expose] public section + +noncomputable section + +namespace C145.H2 + +open MvPolynomial C145.ThreePlane + +variable {n : ℕ} + +/-- Literal source coordinate bound, retaining negative-bound meaning at n<4. -/ +def QAdmissible (n : ℕ) (R : P3) : Prop := + R = 0 ∨ (4 ≤ n ∧ ∀ r : Fin 3, degreeOf r R ≤ n - 4) + +/-- Actual XiR negative-node residues, with x-input/y-input/z-output order. +Only individual oriented gap products occur in the denominator. -/ +def Res (rates : Fin n → ℝ) (R : P3) : Tensor n := + fun i j k => MvPolynomial.eval ![-rates k, -rates i, -rates j] (Xi * R) / + (di rates i * di rates j * di rates k) + +theorem res_eq_gridResidue (rates : Fin n → ℝ) (R : P3) : + Res rates R = gridResidue rates (Xi * R) := rfl + +/-- The literal quotient formula with the product evaluation split explicitly. -/ +theorem res_entry (rates : Fin n → ℝ) (R : P3) (i j k : Fin n) : + Res rates R i j k = + (MvPolynomial.eval ![-rates k, -rates i, -rates j] Xi * + MvPolynomial.eval ![-rates k, -rates i, -rates j] R) / + (di rates i * di rates j * di rates k) := by + simp only [Res, map_mul] + +/-- Source signs at negative rates; the three factors introduce one minus sign. -/ +theorem xi_negative_node_factors (a b c : ℝ) : + MvPolynomial.eval ![-c, -a, -b] Xi = + -((a + b - c) * (a + c - b) * (b + c - a)) := by + simp [Xi, Lz, Ly, Lx, x, y, z]; ring + +/-- Exactly the XiMinus cubic used by DRE6's receiving moment calculation. -/ +theorem xi_negative_node_expansion (a b c : ℝ) : + MvPolynomial.eval ![-c, -a, -b] Xi = + a ^ 3 + b ^ 3 + c ^ 3 - a ^ 2 * b - a ^ 2 * c - b ^ 2 * a - + b ^ 2 * c - c ^ 2 * a - c ^ 2 * b + 2 * a * b * c := by + rw [xi_negative_node_factors] + ring + +/-- In particular, the repeated-node sign matches CRITIC1's trace boundary. -/ +theorem xi_negative_diagonal (a b : ℝ) : + MvPolynomial.eval ![-b, -a, -b] Xi = a ^ 2 * (a - 2 * b) := by + rw [xi_negative_node_factors] + ring + +/-- Exact nonzero product degrees and the actual support Box derive the +quotient bound. Symmetry and plane vanishing are not additional premises here. -/ +theorem quotient_admissible {F R : P3} (hBox : Box n F) (hF : F = Xi * R) : + QAdmissible n R := by + by_cases hR : R = 0 + · exact Or.inl hR + · have hFne : F ≠ 0 := by + rw [hF] + exact mul_ne_zero xi_ne hR + have hn : 0 < n := by + by_contra hn + have hn0 : n = 0 := by omega + subst n + exact hFne ((box_zero_iff F).mp hBox) + have hdegree : ∀ r : Fin 3, 3 + degreeOf r R < n := by + intro r + have hd := factor_degree hF hFne r + have hb := (box_iff_degree_lt hn F).mp hBox r + omega + have hn4 : 4 ≤ n := by + have hd := hdegree 0 + omega + refine Or.inr ⟨hn4, fun r => ?_⟩ + have hd := hdegree r + omega + +/-- Upper degree bounds suffice in the converse, even when R is zero. -/ +theorem box_xi_mul_of_admissible {R : P3} (hR : QAdmissible n R) : + Box n (Xi * R) := by + rcases hR with rfl | ⟨hn4, hdegree⟩ + · simp [Box] + · apply (box_iff_degree_lt (by omega) (Xi * R)).mpr + intro r + have hd : degreeOf r (Xi * R) ≤ 3 + degreeOf r R := by + simpa only [xi_degree] using (degreeOf_mul_le r Xi R) + have hbound := hdegree r + omega + +/-- The actual support condition on XiR is exactly the literal admissibility. -/ +theorem box_xi_mul_iff_admissible (R : P3) : + Box n (Xi * R) ↔ QAdmissible n R := + ⟨fun h => quotient_admissible h rfl, box_xi_mul_of_admissible⟩ + +theorem xi_mul_symmetric {R : P3} (hR : SymPoly R) : SymPoly (Xi * R) := by + intro e + rw [map_mul, xi_symmetric e, hR e] + +theorem rhoZ_xi_mul (R : P3) : rhoZ (Xi * R) = 0 := by + simp only [Xi, map_mul, rhoZ_Lz, zero_mul] + +/-- Full polynomial kernel: the unique symmetric admissible quotient is +obtained from symmetry and the actual plane identity, not assumed. -/ +theorem complete_polynomial_kernel (F : P3) (hSym : SymPoly F) (hBox : Box n F) : + rhoZ F = 0 ↔ + ∃! R : P3, SymPoly R ∧ QAdmissible n R ∧ F = Xi * R := by + constructor + · intro hz + obtain ⟨R, hR, _⟩ := symmetric_three_plane_factor hSym hz + refine ⟨R, ⟨hR.2.1, quotient_admissible hBox hR.1, hR.1⟩, ?_⟩ + intro S hS + exact quotient_unique hS.2.2 hR.1 + · rintro ⟨R, hR, _⟩ + rw [hR.2.2] + exact rhoZ_xi_mul R + +/-- The accepted actual grid inverse identifies the quotient with its literal +residues. Admissibility derives the required Box; reconstruction is a conclusion. -/ +theorem numerator_eq_xi_iff_res (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (E : Tensor n) (R : P3) + (hR : QAdmissible n R) : + numerator rates E = Xi * R ↔ E = Res rates R := by + rw [res_eq_gridResidue] + exact numerator_eq_iff_gridResidue rates hRates E (Xi * R) + (box_xi_mul_of_admissible hR) + +theorem numerator_res (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (R : P3) (hR : QAdmissible n R) : + numerator rates (Res rates R) = Xi * R := + (numerator_eq_xi_iff_res rates hRates (Res rates R) R hR).mpr rfl + +/-- Every symmetric admissible quotient really gives a fully symmetric tensor. -/ +theorem res_symmetric (rates : Fin n → ℝ) (R : P3) (hR : SymPoly R) : + FullSymTensor (Res rates R) := by + rw [res_eq_gridResidue] + exact gridResidue_symmetric rates (Xi * R) (xi_mul_symmetric hR) + +/-- Every admissible quotient really gives zero actual ordinary response on +regular positive points; the converse does not require quotient symmetry. -/ +theorem res_nullRegular (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (R : P3) (hR : QAdmissible n R) : NullRegular rates (Res rates R) := by + apply (ordinary_data_iff_plane rates (Res rates R)).mpr + rw [numerator_res rates hRates R hR] + exact rhoZ_xi_mul R + +/-- Admissible parameters have distinct actual residues, including n=0. -/ +theorem res_injective_on_admissible (rates : Fin n → ℝ) + (hRates : Function.Injective rates) {R S : P3} + (hR : QAdmissible n R) (hS : QAdmissible n S) + (h : Res rates R = Res rates S) : R = S := by + apply mul_left_cancel₀ xi_ne + calc + Xi * R = numerator rates (Res rates R) := (numerator_res rates hRates R hR).symm + _ = numerator rates (Res rates S) := congrArg (numerator rates) h + _ = Xi * S := numerator_res rates hRates S hS + +/-- Complete all-n ordinary H2 kernel from the literal response. Only individual +rate injectivity is assumed. All three tensor slots are symmetric. -/ +theorem complete_ordinary_H2_kernel (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (E : Tensor n) (hSym : FullSymTensor E) : + NullRegular rates E ↔ + ∃! R : P3, SymPoly R ∧ QAdmissible n R ∧ E = Res rates R := by + constructor + · intro hdata + obtain ⟨R, hR, hUnique⟩ := + (complete_polynomial_kernel (numerator rates E) + (numerator_symmetric rates E hSym) (numerator_box rates E)).mp + ((ordinary_data_iff_plane rates E).mp hdata) + refine ⟨R, ⟨hR.1, hR.2.1, + (numerator_eq_xi_iff_res rates hRates E R hR.2.1).mp hR.2.2⟩, ?_⟩ + intro S hS + exact hUnique S ⟨hS.1, hS.2.1, + (numerator_eq_xi_iff_res rates hRates E S hS.2.1).mpr hS.2.2⟩ + · rintro ⟨R, hR, _⟩ + rw [hR.2.2] + exact res_nullRegular rates hRates R hR.2.1 + +/-- Exact physical positive-rate corollary, with all positive data points. -/ +theorem complete_positive_H2_kernel (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (E : Tensor n) (hSym : FullSymTensor E) : + NullPositive rates E ↔ + ∃! R : P3, SymPoly R ∧ QAdmissible n R ∧ E = Res rates R := by + rw [nullPositive_iff_nullRegular rates hPos E] + exact complete_ordinary_H2_kernel rates hRates E hSym + +/-- Equality of two ordinary positive H2 responses is exactly the unique +admissible residue difference S2-S1, with the source direction explicit. -/ +theorem equal_positive_H2_iff_residue_difference (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (S1 S2 : Tensor n) (hS1 : FullSymTensor S1) (hS2 : FullSymTensor S2) : + SamePositive rates S1 S2 ↔ + ∃! R : P3, SymPoly R ∧ QAdmissible n R ∧ S2 - S1 = Res rates R := by + have hd : SamePositive rates S1 S2 ↔ NullPositive rates (S2 - S1) := by + constructor + · intro h s t hs ht + rw [H_sub, h s t hs ht, sub_self] + · intro h s t hs ht + have hh := h s t hs ht + rw [H_sub] at hh + exact (sub_eq_zero.mp hh).symm + rw [hd] + exact complete_positive_H2_kernel rates hRates hPos (S2 - S1) + (fullSymTensor_sub S2 S1 hS2 hS1) + +/-- At n<=3 admissibility forces the zero polynomial, avoiding saturated +natural-degree bounds that would incorrectly allow constants at small n. -/ +theorem admissible_small_iff_zero (hn : n ≤ 3) (R : P3) : + QAdmissible n R ↔ R = 0 := by + constructor + · rintro (h | ⟨hn4, _⟩) + · exact h + · omega + · exact Or.inl + +theorem res_zero (rates : Fin n → ℝ) : Res rates (0 : P3) = 0 := by + funext i j k + simp [Res] + +/-- The complete characterization retains the accepted small-n injectivity. -/ +theorem small_n_kernel_iff_zero (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hn : n ≤ 3) + (E : Tensor n) (hSym : FullSymTensor E) : + NullRegular rates E ↔ E = 0 := by + constructor + · intro h + obtain ⟨R, hR, _⟩ := (complete_ordinary_H2_kernel rates hRates E hSym).mp h + rw [(admissible_small_iff_zero hn R).mp hR.2.1, res_zero] at hR + exact hR.2.2 + · rintro rfl + intro s t hs ht hreg + simp [H] + +theorem small_n_positive_kernel_iff_zero (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) (hn : n ≤ 3) + (E : Tensor n) (hSym : FullSymTensor E) : + NullPositive rates E ↔ E = 0 := by + rw [nullPositive_iff_nullRegular rates hPos E] + exact small_n_kernel_iff_zero rates hRates hn E hSym + +/-- Empty residual index set: the actual ordinary sum vanishes with no chosen +node, rate, or denominator, independently of the quotient presentation. -/ +theorem n0_nullRegular (rates : Fin 0 → ℝ) (E : Tensor 0) : NullRegular rates E := by + intro s t hs ht hreg + simp [H] + + +end C145.H2 + +end diff --git a/LeanPool/C145/C145CoordinatePermutation.lean b/LeanPool/C145/C145CoordinatePermutation.lean new file mode 100644 index 0000000000..fa3c12f182 --- /dev/null +++ b/LeanPool/C145/C145CoordinatePermutation.lean @@ -0,0 +1,473 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145SmallPhysicalTraceSeparation +public import Mathlib.Algebra.BigOperators.Ring.Finset +public import Mathlib.Algebra.BigOperators.Group.Finset.Sigma +public import Mathlib.Data.Finset.Card +public import Mathlib.Data.Finset.Filter +public import Mathlib.Data.Fintype.Card +public import Mathlib.Algebra.CharZero.Defs +public import Mathlib.Logic.Equiv.Defs +public import Mathlib.Tactic.Ring + +/-! +C145: actual finite-coordinate multiplication and one derived vertex permutation. + +All sums retain every vertex/mode in Fin (n+1), including the ground and n=0. +Column orthonormality derives row completeness. Literal cubic equality derives +full pointwise multiplicativity; real coordinate idempotents and column norms +derive a bijection. No multiplicativity, unit, rank, injection or permutation +is supplied as a scientific premise. The calibrated H2 join is only n <= 4. +Raw temporal jets, unknown N, calibration, spectral representation and graph +positivity remain upstream of these finite sums. +-/ + +@[expose] public section + +noncomputable section +namespace C145CoordinatePermutation +open scoped BigOperators + +/-- The change of vertex coordinates obtained by multiplying the second frame by the first +transpose. -/ +def transport {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) : + Fin (n + 1) → Fin (n + 1) → ℝ := + fun w v => ∑ i, Q1 w i * Q0 v i + +/-- Apply the modal transport matrix to a vertex vector. -/ +def applyTransport {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (f : Fin (n + 1) → ℝ) : Fin (n + 1) → ℝ := + fun w => ∑ v, transport Q0 Q1 w v * f v + +/-- The vertex coordinate vector supported at one index with value one. -/ +def coordinateVector {n : ℕ} (v : Fin (n + 1)) : + Fin (n + 1) → ℝ := + fun u => if u = v then 1 else 0 + +/-- Reconstruct the generator from the frame and the negatives of its modal decay rates. -/ +def spectralGenerator {n : ℕ} + (lam : Fin (n + 1) → ℝ) + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) : + Fin (n + 1) → Fin (n + 1) → ℝ := + fun v u => -(∑ i, lam i * Q v i * Q u i) + +/-- Reconstruct the signed port by weighting the modal columns with their overlaps. -/ +def spectralPort {n : ℕ} + (a : Fin (n + 1) → ℝ) + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) : + Fin (n + 1) → ℝ := + fun v => ∑ i, a i * Q v i + +/-- Recover the Laplacian by removing the common decay from the negative generator. -/ +def decayLaplacian {n : ℕ} + (μ : ℝ) (lam : Fin (n + 1) → ℝ) + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) : + Fin (n + 1) → Fin (n + 1) → ℝ := + fun v u => -spectralGenerator lam Q v u - + μ * (if v = u then 1 else 0) + +theorem transport_eq_matrix_mul_transpose {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) : + Matrix.of (transport Q0 Q1) = + Matrix.of Q1 * (Matrix.of Q0).transpose := by + ext w v + simp only [Matrix.mul_apply, Matrix.of_apply, Matrix.transpose_apply, transport] + +/-- A literal sum rearrangement; no frame hypothesis is needed. -/ +private theorem applyTransport_mode_expansion {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (f : Fin (n + 1) → ℝ) (w : Fin (n + 1)) : + applyTransport Q0 Q1 f w = + ∑ i, (∑ u, Q0 u i * f u) * Q1 w i := by + classical + calc + applyTransport Q0 Q1 f w = + ∑ v, ∑ i, Q0 v i * f v * Q1 w i := by + simp only [applyTransport, transport, Finset.sum_mul] + apply Finset.sum_congr rfl + intro v hv + apply Finset.sum_congr rfl + intro i hi + ring + _ = ∑ i, ∑ v, Q0 v i * f v * Q1 w i := Finset.sum_comm + _ = ∑ i, (∑ u, Q0 u i * f u) * Q1 w i := by + simp only [Finset.sum_mul] + +theorem frame_reconstruction {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (f : Fin (n + 1) → ℝ) (v : Fin (n + 1)) : + (∑ i, (∑ u, Q u i * f u) * Q v i) = f v := by + classical + have hRows := C145PhysicalFrame.columnOrthonormal_rowComplete Q hQ + calc + (∑ i, (∑ u, Q u i * f u) * Q v i) = + ∑ u, f u * (∑ i, Q u i * Q v i) := by + simp only [Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro u hu + apply Finset.sum_congr rfl + intro i hi + ring + _ = ∑ u, f u * (if u = v then 1 else 0) := by + apply Finset.sum_congr rfl + intro u hu + rw [hRows u v] + _ = f v := by + simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq', + Finset.mem_univ, ite_true] + +theorem transport_frame_column {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (w i : Fin (n + 1)) : + (∑ v, transport Q0 Q1 w v * Q0 v i) = Q1 w i := by + classical + change applyTransport Q0 Q1 (fun v => Q0 v i) w = Q1 w i + rw [applyTransport_mode_expansion] + calc + _ = ∑ j, (if j = i then 1 else 0) * Q1 w j := by + apply Finset.sum_congr rfl + intro j hj + rw [hQ0 j i] + _ = Q1 w i := by + simp only [ite_mul, one_mul, zero_mul, Finset.sum_ite_eq', + Finset.mem_univ, ite_true] + +theorem transport_transpose_frame_column {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (v i : Fin (n + 1)) : + (∑ w, transport Q0 Q1 w v * Q1 w i) = Q0 v i := by + classical + calc + (∑ w, transport Q0 Q1 w v * Q1 w i) = + ∑ j, Q0 v j * (∑ w, Q1 w j * Q1 w i) := by + simp only [transport, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro w hw + ring + _ = ∑ j, Q0 v j * (if j = i then 1 else 0) := by + apply Finset.sum_congr rfl + intro j hj + rw [hQ1 j i] + _ = Q0 v i := by + simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq', + Finset.mem_univ, ite_true] + +theorem transport_columnOrthonormal {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) : + C145PhysicalFrame.ColumnOrthonormal (transport Q0 Q1) := by + classical + intro v u + have hRows := C145PhysicalFrame.columnOrthonormal_rowComplete Q0 hQ0 + calc + (∑ w, transport Q0 Q1 w v * transport Q0 Q1 w u) = + ∑ w, (∑ i, Q1 w i * Q0 v i) * transport Q0 Q1 w u := rfl + _ = ∑ i, Q0 v i * (∑ w, transport Q0 Q1 w u * Q1 w i) := by + simp only [Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro w hw + ring + _ = ∑ i, Q0 v i * Q0 u i := by + simp_rw [transport_transpose_frame_column Q0 Q1 hQ1] + _ = if v = u then 1 else 0 := hRows v u + +theorem transport_frame_product {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hC : C145PhysicalFrame.C Q0 = C145PhysicalFrame.C Q1) + (w i j : Fin (n + 1)) : + (∑ v, transport Q0 Q1 w v * Q0 v i * Q0 v j) = + Q1 w i * Q1 w j := by + classical + have hRows := C145PhysicalFrame.columnOrthonormal_rowComplete Q1 hQ1 + calc + (∑ v, transport Q0 Q1 w v * Q0 v i * Q0 v j) = + ∑ k, Q1 w k * C145PhysicalFrame.C Q0 i j k := by + simp only [transport, C145PhysicalFrame.C, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro k hk + apply Finset.sum_congr rfl + intro v hv + ring + _ = ∑ k, Q1 w k * C145PhysicalFrame.C Q1 i j k := by rw [hC] + _ = ∑ z, (Q1 z i * Q1 z j) * (∑ k, Q1 w k * Q1 z k) := by + simp only [C145PhysicalFrame.C, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro z hz + apply Finset.sum_congr rfl + intro k hk + ring + _ = ∑ z, (Q1 z i * Q1 z j) * (if w = z then 1 else 0) := by + apply Finset.sum_congr rfl + intro z hz + rw [hRows w z] + _ = Q1 w i * Q1 w j := by + simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq, + Finset.mem_univ, ite_true] + +/-- Cubic equality determines products of all actual coordinate vectors. -/ +theorem transport_multiplicative {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hC : C145PhysicalFrame.C Q0 = C145PhysicalFrame.C Q1) + (f g : Fin (n + 1) → ℝ) (w : Fin (n + 1)) : + applyTransport Q0 Q1 (fun v => f v * g v) w = + applyTransport Q0 Q1 f w * applyTransport Q0 Q1 g w := by + classical + let α : Fin (n + 1) → ℝ := fun i => ∑ u, Q0 u i * f u + let β : Fin (n + 1) → ℝ := fun j => ∑ u, Q0 u j * g u + have hf (v : Fin (n + 1)) : (∑ i, α i * Q0 v i) = f v := + frame_reconstruction Q0 hQ0 f v + have hg (v : Fin (n + 1)) : (∑ j, β j * Q0 v j) = g v := + frame_reconstruction Q0 hQ0 g v + calc + applyTransport Q0 Q1 (fun v => f v * g v) w = + ∑ v, transport Q0 Q1 w v * + ((∑ i, α i * Q0 v i) * (∑ j, β j * Q0 v j)) := by + unfold applyTransport + apply Finset.sum_congr rfl + intro v hv + rw [hf v, hg v] + _ = ∑ v, ∑ i, ∑ j, + (α i * β j) * (transport Q0 Q1 w v * Q0 v i * Q0 v j) := by + apply Finset.sum_congr rfl + intro v hv + rw [Finset.sum_mul_sum] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j hj + ring + _ = ∑ i, ∑ j, (α i * β j) * + (∑ v, transport Q0 Q1 w v * Q0 v i * Q0 v j) := by + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i hi + rw [Finset.sum_comm] + _ = ∑ i, ∑ j, (α i * β j) * (Q1 w i * Q1 w j) := by + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + rw [transport_frame_product Q0 Q1 hQ1 hC w i j] + _ = (∑ i, α i * Q1 w i) * (∑ j, β j * Q1 w j) := by + rw [Finset.sum_mul_sum] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + ring + _ = applyTransport Q0 Q1 f w * applyTransport Q0 Q1 g w := by + rw [applyTransport_mode_expansion Q0 Q1 f w, + applyTransport_mode_expansion Q0 Q1 g w] + +theorem applyTransport_coordinateVector {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (v w : Fin (n + 1)) : + applyTransport Q0 Q1 (coordinateVector v) w = transport Q0 Q1 w v := by + classical + simp only [applyTransport, coordinateVector, mul_ite, mul_one, mul_zero, + Finset.sum_ite_eq', Finset.mem_univ, ite_true] + +theorem transport_entry_idempotent {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hC : C145PhysicalFrame.C Q0 = C145PhysicalFrame.C Q1) + (w v : Fin (n + 1)) : + transport Q0 Q1 w v * transport Q0 Q1 w v = transport Q0 Q1 w v := by + classical + have he : (fun u => coordinateVector v u * coordinateVector v u) = + coordinateVector v := by + funext u + by_cases hu : u = v <;> simp [coordinateVector, hu] + have h := transport_multiplicative Q0 Q1 hQ0 hQ1 hC + (coordinateVector v) (coordinateVector v) w + simpa only [he, applyTransport_coordinateVector] using h.symm + +theorem transport_entry_zero_or_one {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hC : C145PhysicalFrame.C Q0 = C145PhysicalFrame.C Q1) + (w v : Fin (n + 1)) : + transport Q0 Q1 w v = 0 ∨ transport Q0 Q1 w v = 1 := by + have hzero : transport Q0 Q1 w v * (transport Q0 Q1 w v - 1) = 0 := by + calc + _ = transport Q0 Q1 w v * transport Q0 Q1 w v - transport Q0 Q1 w v := by ring + _ = 0 := by rw [transport_entry_idempotent Q0 Q1 hQ0 hQ1 hC w v, sub_self] + rcases mul_eq_zero.mp hzero with h | h + · exact Or.inl h + · exact Or.inr (sub_eq_zero.mp h) + +theorem transport_column_singleton {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hC : C145PhysicalFrame.C Q0 = C145PhysicalFrame.C Q1) + (v : Fin (n + 1)) : + ∃! w : Fin (n + 1), transport Q0 Q1 w v = 1 := by + classical + let S : Finset (Fin (n + 1)) := + Finset.univ.filter (fun w => transport Q0 Q1 w v = 1) + have hU := transport_columnOrthonormal Q0 Q1 hQ0 hQ1 + have hcount : (S.card : ℝ) = 1 := by + calc + (S.card : ℝ) = (∑ w, if transport Q0 Q1 w v = 1 then (1 : ℝ) else 0) := by + exact (Finset.sum_boole (fun w : Fin (n + 1) => + transport Q0 Q1 w v = 1) Finset.univ).symm + _ = ∑ w, transport Q0 Q1 w v * transport Q0 Q1 w v := by + apply Finset.sum_congr rfl + intro w hw + rcases transport_entry_zero_or_one Q0 Q1 hQ0 hQ1 hC w v with h | h + · simp [h] + · simp [h] + _ = 1 := by simpa only [ite_true] using hU v v + have hcard : S.card = 1 := Nat.cast_eq_one.mp hcount + have hUnique := Finset.card_eq_one_iff_existsUnique.mp hcard + simpa only [S, Finset.mem_filter, Finset.mem_univ, true_and] using hUnique + +/-- The vertex bijection and its orientation are derived from actual U columns. -/ +theorem cubic_equality_vertex_permutation {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hC : C145PhysicalFrame.C Q0 = C145PhysicalFrame.C Q1) : + ∃ π : Equiv.Perm (Fin (n + 1)), + (∀ w v, transport Q0 Q1 w v = if w = π v then 1 else 0) ∧ + (∀ v i, Q1 (π v) i = Q0 v i) := by + classical + have hSingleton (v : Fin (n + 1)) := transport_column_singleton Q0 Q1 hQ0 hQ1 hC v + have hExists (v : Fin (n + 1)) : ∃ w, transport Q0 Q1 w v = 1 := by + obtain ⟨w, hw, _⟩ := hSingleton v + exact ⟨w, hw⟩ + let p : Fin (n + 1) → Fin (n + 1) := fun v => Classical.choose (hExists v) + have hp (v : Fin (n + 1)) : transport Q0 Q1 (p v) v = 1 := + Classical.choose_spec (hExists v) + have hDelta (w v : Fin (n + 1)) : + transport Q0 Q1 w v = if w = p v then 1 else 0 := by + by_cases hw : w = p v + · rw [ite_eq_left hw, hw] + exact hp v + · have hNotOne : transport Q0 Q1 w v ≠ 1 := by + intro h + obtain ⟨z, hz, hUnique⟩ := hSingleton v + exact hw ((hUnique w h).trans (hUnique (p v) (hp v)).symm) + have hZero := (transport_entry_zero_or_one Q0 Q1 hQ0 hQ1 hC w v).resolve_right hNotOne + simpa only [ite_eq_right hw] using hZero + have hU := transport_columnOrthonormal Q0 Q1 hQ0 hQ1 + have hInjective : Function.Injective p := by + intro v u hpu + by_cases hvu : v = u + · exact hvu + · have hColumns (w : Fin (n + 1)) : + transport Q0 Q1 w v = transport Q0 Q1 w u := by + rw [hDelta w v, hDelta w u, hpu] + have hNorm : (∑ w, transport Q0 Q1 w v * transport Q0 Q1 w u) = 1 := by + calc + _ = ∑ w, transport Q0 Q1 w v * transport Q0 Q1 w v := by + apply Finset.sum_congr rfl + intro w hw + rw [← hColumns w] + _ = 1 := by simpa only [ite_true] using hU v v + have hOrth : (∑ w, transport Q0 Q1 w v * transport Q0 Q1 w u) = 0 := by + simpa only [ite_eq_right hvu] using hU v u + exact False.elim ((zero_ne_one : (0 : ℝ) ≠ 1) (hOrth.symm.trans hNorm)) + let π : Equiv.Perm (Fin (n + 1)) := + Equiv.ofBijective p ⟨hInjective, Finite.surjective_of_injective hInjective⟩ + have hPerm (w v : Fin (n + 1)) : + transport Q0 Q1 w v = if w = π v then 1 else 0 := by + change transport Q0 Q1 w v = if w = p v then 1 else 0 + exact hDelta w v + refine ⟨π, hPerm, ?_⟩ + intro v i + calc + Q1 (π v) i = (∑ w, transport Q0 Q1 w v * Q1 w i) := by + simp only [hPerm, ite_mul, one_mul, zero_mul, Finset.sum_ite_eq', + Finset.mem_univ, ite_true] + _ = Q0 v i := transport_transpose_frame_column Q0 Q1 hQ1 v i + +/-- One and the same derived vertex permutation transports all literal formulas. -/ +theorem cubic_equality_spectral_transport {n : ℕ} + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hC : C145PhysicalFrame.C Q0 = C145PhysicalFrame.C Q1) + (lam a : Fin (n + 1) → ℝ) (μ : ℝ) : + ∃ π : Equiv.Perm (Fin (n + 1)), + (∀ w v, transport Q0 Q1 w v = if w = π v then 1 else 0) ∧ + (∀ v i, Q1 (π v) i = Q0 v i) ∧ + (∀ v u, spectralGenerator lam Q1 (π v) (π u) = + spectralGenerator lam Q0 v u) ∧ + (∀ v, spectralPort a Q1 (π v) = spectralPort a Q0 v) ∧ + (∀ v u, decayLaplacian μ lam Q1 (π v) (π u) = + decayLaplacian μ lam Q0 v u) := by + classical + obtain ⟨π, hPerm, hRows⟩ := cubic_equality_vertex_permutation Q0 Q1 hQ0 hQ1 hC + have hGenerator (v u : Fin (n + 1)) : + spectralGenerator lam Q1 (π v) (π u) = spectralGenerator lam Q0 v u := by + simp only [spectralGenerator, hRows] + refine ⟨π, hPerm, hRows, hGenerator, ?_, ?_⟩ + · intro v + simp only [spectralPort, hRows] + · intro v u + simp only [decayLaplacian, hGenerator, π.injective.eq_iff] + +/-- Accepted calibrated ordinary H2 separation through total size N=n+1 <= 5. -/ +theorem calibrated_small_H2_vertex_identification {n : ℕ} + (μ : ℝ) (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (ha : ∀ r, a r ≠ 0) + (hG0 : ∀ v, Q0 v 0 = c) (hG1 : ∀ v, Q1 v 0 = c) + (hn : n ≤ 4) + (hH : C145.H2.SamePositive (C145.H2.fullRates μ rates) + (C145PhysicalFrame.T Q0 a) (C145PhysicalFrame.T Q1 a)) : + ∃ π : Equiv.Perm (Fin (n + 1)), + (∀ w v, transport Q0 Q1 w v = if w = π v then 1 else 0) ∧ + (∀ v i, Q1 (π v) i = Q0 v i) ∧ + (∀ v u, spectralGenerator (C145.H2.fullRates μ rates) Q1 (π v) (π u) = + spectralGenerator (C145.H2.fullRates μ rates) Q0 v u) ∧ + (∀ v, spectralPort a Q1 (π v) = spectralPort a Q0 v) ∧ + (∀ v u, decayLaplacian μ (C145.H2.fullRates μ rates) Q1 (π v) (π u) = + decayLaplacian μ (C145.H2.fullRates μ rates) Q0 v u) := by + have hC := C145.H2.physical_small_H2_multiplication_equality μ rates hRates hPos + Q0 Q1 a c hQ0 hQ1 ha hG0 hG1 hn hH + exact cubic_equality_spectral_transport Q0 Q1 hQ0 hQ1 hC + (C145.H2.fullRates μ rates) a μ + + +end C145CoordinatePermutation +end + +end diff --git a/LeanPool/C145/C145CyclicSpectral.lean b/LeanPool/C145/C145CyclicSpectral.lean new file mode 100644 index 0000000000..e923ca270b --- /dev/null +++ b/LeanPool/C145/C145CyclicSpectral.lean @@ -0,0 +1,103 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145PhysicalFrame +public import Mathlib.Analysis.Matrix.Spectrum +public import Mathlib.LinearAlgebra.Matrix.DotProduct + +/-! Actual real Krylov spanning forces every spectral overlap to be nonzero and +every eigenvalue to be simple. No such conclusions are scientific premises. -/ + +@[expose] public section + +noncomputable section +namespace C145.CyclicSpectral +open scoped BigOperators +open Matrix +variable {V : Type*} [Fintype V] [DecidableEq V] + +/-- The iterates of the generator on the port span the whole vertex space. -/ +def KrylovCyclic (A : Matrix V V ℝ) (b : V → ℝ) : Prop := + Submodule.span ℝ (Set.range (fun k : ℕ => A ^ k *ᵥ b)) = ⊤ + +theorem cyclic_annihilator (A : Matrix V V ℝ) (b x : V → ℝ) + (hc : KrylovCyclic A b) + (hx : ∀ k : ℕ, x ⬝ᵥ (A ^ k *ᵥ b) = 0) : x = 0 := by + have hall : ∀ y ∈ Submodule.span ℝ (Set.range (fun k : ℕ => A ^ k *ᵥ b)), + x ⬝ᵥ y = 0 := by + intro y hy + induction hy using Submodule.span_induction with + | mem y hy => obtain ⟨k, rfl⟩ := hy; exact hx k + | zero => simp + | add y z _ _ hy hz => simp [dotProduct_add, hy, hz] + | smul a y _ hy => simp [dotProduct_smul, hy] + apply dotProduct_self_eq_zero.mp + exact hall x (by rw [hc]; trivial) + +theorem eigenvector_overlap_ne_zero (A : Matrix V V ℝ) (hs : A.IsSymm) + (b x : V → ℝ) (hc : KrylovCyclic A b) (lam : ℝ) + (he : A *ᵥ x = lam • x) (hx : x ≠ 0) : x ⬝ᵥ b ≠ 0 := by + intro hz + apply hx + apply cyclic_annihilator A b x hc + intro k + induction k with + | zero => simpa using hz + | succ k ih => + rw [pow_succ', ← Matrix.mulVec_mulVec, hs.dotProduct_mulVec_comm, + he, dotProduct_smul, dotProduct_comm (A ^ k *ᵥ b) x, ih, smul_zero] + +theorem eigenvalues_injective_of_cyclic {n : ℕ} + (A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) (hs : A.IsSymm) + (b : Fin (n + 1) → ℝ) (hc : KrylovCyclic A b) + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) (lam : Fin (n + 1) → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (he : ∀ i, A *ᵥ (fun v => Q v i) = lam i • (fun v => Q v i)) : + Function.Injective lam := by + intro i j hij + by_contra hne + let ai := (fun v => Q v i) ⬝ᵥ b + let aj := (fun v => Q v j) ⬝ᵥ b + have haj : aj ≠ 0 := eigenvector_overlap_ne_zero A hs b _ hc (lam j) (he j) (by + intro hz + have hh := hQ j j + simp only at hh + have hz' : ∀ v, Q v j = 0 := congrFun hz + simp [hz'] at hh) + let x : Fin (n + 1) → ℝ := aj • (fun v => Q v i) - ai • (fun v => Q v j) + have hex : A *ᵥ x = lam i • x := by + simp only [x, Matrix.mulVec_sub, Matrix.mulVec_smul, he, ← hij] + module + have hxb : x ⬝ᵥ b = 0 := by + simp only [x, sub_dotProduct, smul_dotProduct] + dsimp [ai, aj]; ring + have hxz : x = 0 := by + by_contra hx + exact eigenvector_overlap_ne_zero A hs b x hc (lam i) hex hx hxb + have hdot := congrArg (fun z => (fun v => Q v i) ⬝ᵥ z) hxz + have hii : (fun v => Q v i) ⬝ᵥ (fun v => Q v i) = 1 := by + simpa [dotProduct] using hQ i i + have hij' : (fun v => Q v i) ⬝ᵥ (fun v => Q v j) = 0 := by + simpa [dotProduct, hne] using hQ i j + simp only [dotProduct_sub, dotProduct_smul, hii, smul_eq_mul, mul_one, hij', mul_zero, + sub_zero, dotProduct_zero, x] at hdot + exact haj hdot + +theorem hermitian_frame {n : ℕ} + (A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) (hA : A.IsHermitian) : + C145PhysicalFrame.ColumnOrthonormal + (fun v i => (hA.eigenvectorBasis i) v) := by + intro i j + have hh := (orthonormal_iff_ite.mp hA.eigenvectorBasis.orthonormal) i j + simpa [EuclideanSpace.inner_eq_star_dotProduct, dotProduct, mul_comm] using hh + +end C145.CyclicSpectral + +end diff --git a/LeanPool/C145/C145DRE8ActualCalibratedInverse.lean b/LeanPool/C145/C145DRE8ActualCalibratedInverse.lean new file mode 100644 index 0000000000..7630799885 --- /dev/null +++ b/LeanPool/C145/C145DRE8ActualCalibratedInverse.lean @@ -0,0 +1,139 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8ActualFrame + +/-! Source Theorem A for actual calibrated full frames. All structural +identities are derived from the supplied physical frames and actual port. +Only the source spectral interval, source port separation and source q_Ch +criterion remain as scientific restrictions. The competitor has none of them. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 +variable {n : ℕ} + +/-- Exact square of the source q_Ch, expressed in original vertex coordinates. -/ +def sourceQChebyshevSq (b : Fin (n + 1) → ℝ) (ell u delta : ℝ) : ℝ := + (((n + 1 : ℕ) + 2 : ℝ) * (∑ v, centeredPort b v ^ 2) / (1024 * delta ^ 2))* + ((u-ell) / (2 * ell-u)) ^ 6 + +theorem sourceQ_eq_modal + (U : Fin (n + 1) → Fin (n + 1) → ℝ) (b : Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) (hG : ∀ v, U v 0 = c) + (ell u delta : ℝ) : + sourceQChebyshevSq b ell u delta = + qChebyshevSq (fun i : Fin n => C145.Pulse.modalOverlap U b i.succ) ell u delta := by + unfold sourceQChebyshevSq qChebyshevSq + rw [actual_residual_energy U b c hU hG] + +/-- Actual common calibration plus actual full H2 determine the full cubic +under the source scalar-signature condition, in arbitrary dimension. -/ +theorem actual_calibrated_H2_cubic_equality + (μ : ℝ) (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (b : Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (ha : ∀ i, C145.Pulse.modalOverlap U b i ≠ 0) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) + (hH : SamePositive (fullRates μ rates) + (C145PhysicalFrame.T U (C145.Pulse.modalOverlap U b)) + (C145PhysicalFrame.T V (C145.Pulse.modalOverlap U b))) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ (b j - b k) ^ 2) + (hq : sourceQChebyshevSq b ell u delta < 1) : + C145PhysicalFrame.C U = C145PhysicalFrame.C V := by + let a : Fin (n + 1) → ℝ := C145.Pulse.modalOverlap U b + let ar : Fin n → ℝ := fun i => a i.succ + let C0 : Tensor n := residual (C145PhysicalFrame.C U) + let C1 : Tensor n := residual (C145PhysicalFrame.C V) + let Q : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ := Matrix.of U * (Matrix.of V).transpose + have hCG := actual_cubic_common_ground U V c hU hV hGU hGV + have hDiff : C145PhysicalFrame.C V-C145PhysicalFrame.C U = groundZero (C1-C0) := + commonGround_difference _ _ hCG + have hPhys : physicalDifference Q = rotateTensor (Matrix.of U) (groundZero (C1-C0)) := by + rw [← hDiff] + exact actual_frame_physical_difference U V hU + have hQ : Q.transpose * Q = 1 := by + have h := columnOrthonormal_matrix (C145CoordinatePermutation.transport V U) + (C145CoordinatePermutation.transport_columnOrthonormal V U hV hU) + rw [C145CoordinatePermutation.transport_eq_matrix_mul_transpose] at h + exact h + have hunit : ∀ i, ∑ v, Q i v = 1 := actual_frame_common_unit U V c hU hV hGU hGV + have hData := actual_weighted_residual_data μ rates U V a c hU hV hGU hGV hH + have hSig := actual_residual_signature U b c hU hGU + have hSep : ∀ j k, j ≠ k → delta ^ 2≤ + (((Matrix.of U).mulVec (residualVector ar)) j- + ((Matrix.of U).mulVec (residualVector ar)) k) ^ 2 := by + intro j k hjk + change delta ^ 2≤ + (((Matrix.of U).mulVec (residualVector (fun i : Fin n => C145.Pulse.modalOverlap U b + i.succ))) j- + ((Matrix.of U).mulVec (residualVector (fun i : Fin n => C145.Pulse.modalOverlap U b + i.succ))) k) ^ 2 + rw [hSig] + simpa only [centeredPort, sub_sub_sub_cancel_right] using hsep j k hjk + have hqM : qChebyshevSq ar ell u delta < 1 := by + rw [sourceQ_eq_modal U b c hU hGU ell u delta] at hq + exact hq + have hPos : ∀ i, 0 < rates i := by + intro i + have hell : 0 < ell := by linarith + exact hell.trans_le (hlo i) + have hz : C1-C0 = 0 := calibrated_H2_kernel_zero ar rates (fun i => ha i.succ) hRates + (C1-C0) (fullSymTensor_sub C1 C0 + (residual_fullSym _ (actual_cubic_fullSym V)) + (residual_fullSym _ (actual_cubic_fullSym U))) + (samePositive_weighted_difference ar rates hPos C0 C1 hData) + ell u hw hband hlo hhi (Matrix.of U) Q (columnOrthonormal_matrix U hU) + hQ hunit hPhys delta hSep + ((qChebyshevSq_lt_one_iff ar ell u delta hband (ne_of_gt hd)).mp hqM) + have hzero : groundZero (0 : Tensor n) = 0 := by + funext i j k + refine Fin.cases ?_ (fun x => ?_) i + · rfl + · refine Fin.cases ?_ (fun y => ?_) j + · rfl + · refine Fin.cases ?_ (fun z => ?_) k <;> rfl + rw [hz,hzero] at hDiff + exact (sub_eq_zero.mp hDiff).symm + +/-- The vertex bijection is derived by the existing primitive coordinate +idempotent theorem; it is not a supplied reconstruction certificate. -/ +theorem actual_calibrated_H2_vertex_identification + (μ : ℝ) (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (b : Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (ha : ∀ i, C145.Pulse.modalOverlap U b i ≠ 0) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) + (hH : SamePositive (fullRates μ rates) + (C145PhysicalFrame.T U (C145.Pulse.modalOverlap U b)) + (C145PhysicalFrame.T V (C145.Pulse.modalOverlap U b))) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ (b j - b k) ^ 2) + (hq : sourceQChebyshevSq b ell u delta < 1) : + ∃ π : Equiv.Perm (Fin (n + 1)), + (∀ w v, C145CoordinatePermutation.transport U V w v = if w = π v then 1 else 0) ∧ + (∀ v i, V (π v) i = U v i) := by + exact C145CoordinatePermutation.cubic_equality_vertex_permutation U V hU hV + (actual_calibrated_H2_cubic_equality μ rates hRates U V b c hU hV ha hGU hGV hH + ell u hw hband hlo hhi delta hd hsep hq) + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8ActualFrame.lean b/LeanPool/C145/C145DRE8ActualFrame.lean new file mode 100644 index 0000000000..1f8e4db463 --- /dev/null +++ b/LeanPool/C145/C145DRE8ActualFrame.lean @@ -0,0 +1,214 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8CalibratedUniqueness +public import LeanPool.C145.C145GraphSpectralRealization + +/-! Derive the physical common-unit secant from two actual calibrated frames. +No tensor-frame certificate, common-unit certificate, or residual-H2 premise +is supplied to the eventual calibrated frame inverse. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 +variable {n : ℕ} + +theorem columnOrthonormal_matrix (U : Fin (n + 1) → Fin (n + 1) → ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) : + (Matrix.of U).transpose * Matrix.of U = 1 := by + ext i j + exact hU i j + +theorem rotateTensor_sub {ι : Type*} [Fintype ι] + (U : Matrix ι ι ℝ) (A B : ι → ι → ι → ℝ) : + rotateTensor U (A-B) = rotateTensor U A - rotateTensor U B := by + funext i j k + simp only [rotateTensor, rotateFirst, rotateSecond, rotateThird, + Pi.sub_apply, mul_sub, Finset.sum_sub_distrib] + +private theorem sum_cubic_factor (f g : Fin (n + 1) → ℝ) (x y : ℝ) : + (∑ r, f r * (g r * x * y)) = (∑ r, f r * g r) * x * y := by + simp only [Finset.sum_mul] + apply Finset.sum_congr rfl; intro r hr; ring + +theorem rotateTensor_cubic (U V : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) : + rotateTensor U (C145PhysicalFrame.C V) = competitorTensor (U * V.transpose) := by + have h3 (i j k : Fin (n + 1)) : + rotateThird U (C145PhysicalFrame.C V) i j k = + ∑ v, (∑ r, U k r * V v r) * V v i * V v j := by + simp only [rotateThird, C145PhysicalFrame.C, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro v hv + simpa only [mul_comm, mul_left_comm, mul_assoc] using + sum_cubic_factor (fun r => U k r) (fun r => V v r) (V v i) (V v j) + have h2 (i j k : Fin (n + 1)) : + rotateSecond U (rotateThird U (C145PhysicalFrame.C V)) i j k = + ∑ v, (∑ r, U j r * V v r) * V v i * (∑ r, U k r * V v r) := by + unfold rotateSecond + simp_rw [h3] + calc + _ = ∑ r, ∑ v, U j r * ((∑ s, U k s * V v s) * V v i * V v r) := by + apply Finset.sum_congr rfl; intro r hr; rw [Finset.mul_sum] + _ = ∑ v, ∑ r, U j r * ((∑ s, U k s * V v s) * V v i * V v r) := Finset.sum_comm + _ = _ := ?_ + apply Finset.sum_congr rfl; intro v hv + simpa only [mul_comm, mul_left_comm, mul_assoc] using + sum_cubic_factor (fun r => U j r) (fun r => V v r) (V v i) + (∑ r, U k r * V v r) + funext i j k + change (∑ r, U i r * rotateSecond U (rotateThird U (C145PhysicalFrame.C V)) r j k) = _ + simp_rw [h2] + calc + _ = ∑ r, ∑ v, U i r * ((∑ s, U j s * V v s) * V v r * + (∑ s, U k s * V v s)) := by + apply Finset.sum_congr rfl; intro r hr; rw [Finset.mul_sum] + _ = ∑ v, ∑ r, U i r * ((∑ s, U j s * V v s) * V v r * + (∑ s, U k s * V v s)) := Finset.sum_comm + _ = _ := ?_ + apply Finset.sum_congr rfl; intro v hv + simpa only [Matrix.mul_apply, Matrix.transpose_apply, mul_comm, mul_left_comm, mul_assoc] using + sum_cubic_factor (fun r => U i r) (fun r => V v r) + (∑ r, U j r * V v r) (∑ r, U k r * V v r) + +theorem competitorTensor_one : + competitorTensor (1 : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) = coordinateTensor := by + funext i j k + classical + simp only [competitorTensor, Matrix.one_apply, coordinateTensor] + by_cases hij : i = j + · subst j + simp [mul_ite] + · simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ↓reduceIte] + by_cases hjk : j = k + · have hik : i ≠ k := fun hik => hij (hik.trans hjk.symm) + simp [hjk, hik] + · simp [hij, hjk] + +theorem actual_frame_physical_difference + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) : + physicalDifference (Matrix.of U * (Matrix.of V).transpose) = + rotateTensor (Matrix.of U) (C145PhysicalFrame.C V-C145PhysicalFrame.C U) := by + change physicalDifference (Matrix.of U * (Matrix.of V).transpose) = + rotateTensor (Matrix.of U) (C145PhysicalFrame.C (Matrix.of V)-C145PhysicalFrame.C (Matrix.of U)) + rw [rotateTensor_sub, rotateTensor_cubic, rotateTensor_cubic, + orthogonal_rows (Matrix.of U) (columnOrthonormal_matrix U hU), competitorTensor_one] + rfl + +theorem actual_frame_common_unit + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) : + ∀ i, ∑ v, (Matrix.of U * (Matrix.of V).transpose) i v = 1 := by + intro i + have hc := C145PhysicalFrame.ground_ne_zero U c hU hGU + apply mul_right_cancel₀ hc + have h := C145CoordinatePermutation.transport_frame_column V U hV i 0 + change (∑ v, C145CoordinatePermutation.transport V U i v * V v 0) = U i 0 at h + simp_rw [hGV, hGU] at h + rw [← Finset.sum_mul] at h + simpa only [mul_one, one_mul, C145CoordinatePermutation.transport, + Matrix.mul_apply, Matrix.of_apply, Matrix.transpose_apply] using h + +theorem actual_cubic_common_ground + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) : + CommonGround (C145PhysicalFrame.C U) (C145PhysicalFrame.C V) := by + intro i j k hg + have h := physical_commonGround U V (fun _ => 1) c hU hV hGU hGV i j k hg + simpa only [C145PhysicalFrame.T, one_mul] using h + +private theorem residual_physical_weightedTensor + (U : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) : + residual (C145PhysicalFrame.T U a) = + weightedTensor (fun i : Fin n => a i.succ) (residual (C145PhysicalFrame.C U)) := rfl + +/-- Restrict calibrated positive H2 equality to the weighted non-ground tensors. -/ +theorem actual_weighted_residual_data + (μ : ℝ) (rates : Fin n → ℝ) + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) + (hH : SamePositive (fullRates μ rates) (C145PhysicalFrame.T U a) + (C145PhysicalFrame.T V a)) : + SamePositive rates + (weightedTensor (fun i : Fin n => a i.succ) (residual (C145PhysicalFrame.C U))) + (weightedTensor (fun i : Fin n => a i.succ) (residual (C145PhysicalFrame.C V))) := by + have hGround := physical_commonGround U V a c hU hV hGU hGV + have hData := samePositive_residual_of_commonGround μ rates + (C145PhysicalFrame.T U a) (C145PhysicalFrame.T V a) hGround hH + rw [residual_physical_weightedTensor U a, residual_physical_weightedTensor V a] at hData + exact hData + +theorem actual_cubic_fullSym (U : Fin (n + 1) → Fin (n + 1) → ℝ) : + FullSymTensor (C145PhysicalFrame.C U) := by + intro e v + have h := physical_fullSym U (fun _ => 1) e v + change C145PhysicalFrame.T U (fun _ => 1) (v (e 1)) (v (e 2)) (v (e 0)) = + C145PhysicalFrame.T U (fun _ => 1) (v 1) (v 2) (v 0) at h + change C145PhysicalFrame.C U (v (e 1)) (v (e 2)) (v (e 0)) = + C145PhysicalFrame.C U (v 1) (v 2) (v 0) + simpa only [C145PhysicalFrame.T, one_mul] using h + +/-- The actual port with its constant component removed. -/ +def centeredPort (b : Fin (n + 1) → ℝ) (v : Fin (n + 1)) : ℝ := + b v - (∑ w, b w) / (n + 1 : ℝ) + +theorem actual_residual_signature + (U : Fin (n + 1) → Fin (n + 1) → ℝ) (b : Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) (hG : ∀ v, U v 0 = c) : + (Matrix.of U).mulVec (residualVector (fun i : Fin n => C145.Pulse.modalOverlap U b i.succ)) = + centeredPort b := by + have hnorm := C145PhysicalFrame.ground_normalization U c hU hG + have hN : (n + 1 : ℝ) ≠ 0 := by positivity + have ha : C145.Pulse.modalOverlap U b 0 = c * (∑ v, b v) := by + simp only [C145.Pulse.modalOverlap, hG, Finset.mul_sum] + apply Finset.sum_congr rfl; intro v hv; ring + have hmean : C145.Pulse.modalOverlap U b 0 * c = (∑ v,b v) / (n + 1 : ℝ) := by + apply (eq_div_iff hN).mpr + rw [ha] + calc + _ = ((n + 1 : ℝ) * c ^ 2) * (∑ v,b v) := by ring + _ = _ := by rw [hnorm, one_mul] + funext v + have hr := congrFun (C145.UncalibratedSmallH2.spectralPort_modalOverlap U b hU) v + change (∑ i, C145.Pulse.modalOverlap U b i * U v i) = b v at hr + rw [Fin.sum_univ_succ, hG, hmean] at hr + change (∑ i, U v i * residualVector (fun i : Fin n => C145.Pulse.modalOverlap U b i.succ) i) = _ + simp only [Fin.sum_univ_succ, residualVector, Fin.cases_zero, Fin.cases_succ, mul_zero, zero_add] + dsimp [centeredPort] + have hs : (∑ i : Fin n, U v i.succ * C145.Pulse.modalOverlap U b i.succ) = + ∑ i : Fin n, C145.Pulse.modalOverlap U b i.succ * U v i.succ := by + apply Finset.sum_congr rfl; intro i hi; ring + rw [hs] + linarith + +theorem actual_residual_energy + (U : Fin (n + 1) → Fin (n + 1) → ℝ) (b : Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) (hG : ∀ v, U v 0 = c) : + (∑ i : Fin n, (C145.Pulse.modalOverlap U b i.succ) ^ 2) = ∑ v, centeredPort b v ^ 2 := by + have h := orthogonal_energy (Matrix.of U) (columnOrthonormal_matrix U hU) + (residualVector (fun i : Fin n => C145.Pulse.modalOverlap U b i.succ)) + change (∑ i, ((Matrix.of U).mulVec (residualVector (fun i : Fin n => C145.Pulse.modalOverlap U b + i.succ)) i) ^ 2) = _ at h + rw [actual_residual_signature U b c hU hG] at h + simpa only [Fin.sum_univ_succ, residualVector, Fin.cases_zero, Fin.cases_succ, + zero_pow (by omega : 2 ≠ 0), zero_add] using h.symm + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8CalibratedUniqueness.lean b/LeanPool/C145/C145DRE8CalibratedUniqueness.lean new file mode 100644 index 0000000000..018e10d4c8 --- /dev/null +++ b/LeanPool/C145/C145DRE8CalibratedUniqueness.lean @@ -0,0 +1,196 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8OrthogonalTransport +public import LeanPool.C145.C145DRE8SliceRigidity + +/-! The source's quantitative calibrated-tensor endpoint: actual response +contraction joined to physical Lemma B through an explicit shared orthogonal +modal-to-vertex map. This does not claim the original graph/ODE reconstruction +or infer H1 calibration. Q,U,common unit and the actual tensor-frame identity +are named structural assumptions, not supplied moment/norm certificates. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 +variable {n : ℕ} + +/-- Zero literal tensor energy is entrywise zero. -/ +theorem tensorSq_zero (E : Tensor n) (h : tensorSq E = 0) : E = 0 := by + classical + funext i j k + have hi : (∑ j, ∑ k, E i j k ^ 2) = 0 := + (Finset.sum_eq_zero_iff_of_nonneg (fun i hi => by positivity)).mp h i (Finset.mem_univ i) + have hj : (∑ k, E i j k ^ 2) = 0 := + (Finset.sum_eq_zero_iff_of_nonneg (fun j hj => by positivity)).mp hi j (Finset.mem_univ j) + exact (Finset.sum_sq_eq_zero_iff (Finset.univ : Finset (Fin n)) + (fun k => E i j k)).mp hj k (Finset.mem_univ k) + +/-- The accepted global Lemma B specialized to one actual separating signature. -/ +theorem physical_single_slice_rigidity + (Q : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) (hQ : Q.transpose * Q = 1) + (hunit : ∀ i, ∑ v, Q i v = 1) (h : Fin (n + 1) → ℝ) (delta : ℝ) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ (h j - h k) ^ 2) : + delta ^ 2 * tensorSq (physicalDifference Q) ≤ + ((n + 1 : ℕ) + 2 : ℝ) * matrixSq (tensorSlice (physicalDifference Q) h) := by + have hh := physical_slice_rigidity Q hQ hunit (fun _ : Unit => h) delta + (by intro j k hjk; simpa [signatureSq] using hsep j k hjk) + simpa [sliceSq] using hh + +/-- Exact modal rigidity bound. Tensor and signature both use the same U. +The hPhysical identity is a source-frame identity, not a target norm estimate. -/ +theorem calibrated_modal_rigidity + (U Q : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hU : U.transpose * U = 1) (hQ : Q.transpose * Q = 1) + (hunit : ∀ i, ∑ v, Q i v = 1) (E : Tensor n) (a : Fin n → ℝ) + (hPhysical : physicalDifference Q = rotateTensor U (groundZero E)) + (delta : ℝ) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ + ((U.mulVec (residualVector a)) j - (U.mulVec (residualVector a)) k) ^ 2) : + delta ^ 2 * tensorSq E ≤ ((n + 1 : ℕ) + 2 : ℝ) * matrixSq (tensorSlice E a) := by + have hh := physical_single_slice_rigidity Q hQ hunit + (U.mulVec (residualVector a)) delta hsep + rw [hPhysical, tensorSq_rotateTensor U hU, tensorSq_groundZero, + matrixSq_slice_rotateTensor U hU, matrixSq_slice_groundZero] at hh + exact hh + +/-- Source q_Ch<1 in exact squared form forces a calibrated physical secant +with actual zero weighted H2 to vanish. No unrestricted all-size inverse. -/ +theorem calibrated_H2_kernel_zero + (a rates : Fin n → ℝ) (ha : ∀ i, a i ≠ 0) (hRates : Function.Injective rates) + (E : Tensor n) (hSym : FullSymTensor E) + (hData : NullRegular rates (weightedTensor a E)) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) + (U Q : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hU : U.transpose * U = 1) (hQ : Q.transpose * Q = 1) + (hunit : ∀ i, ∑ v, Q i v = 1) + (hPhysical : physicalDifference Q = rotateTensor U (groundZero E)) + (delta : ℝ) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ + ((U.mulVec (residualVector a)) j - (U.mulVec (residualVector a)) k) ^ 2) + (hq : ((n + 1 : ℕ) + 2 : ℝ) * (u - ell) ^ 6 * (∑ i, a i ^ 2) < + 1024 * delta ^ 2 * (2 * ell - u) ^ 6) : E = 0 := by + have hc := actual_H2_chebyshev_contraction a rates ha hRates E hSym hData + ell u hw hband hlo hhi + have hr := calibrated_modal_rigidity U Q hU hQ hunit E a hPhysical delta hsep + have hg : 0 ≤ 1024 * (2 * ell-u) ^ 6 := by positivity + have hN : 0 ≤ ((n + 1 : ℕ) + 2 : ℝ) := by positivity + have h1 := mul_le_mul_of_nonneg_left hr hg + have h2 := mul_le_mul_of_nonneg_left hc hN + have hcombined : (1024 * delta ^ 2 * (2 * ell-u) ^ 6) * tensorSq E ≤ + (((n + 1 : ℕ) + 2 : ℝ) * (u-ell) ^ 6 * (∑ i, a i ^ 2)) * tensorSq E := by + calc + _ = (1024 * (2 * ell-u) ^ 6) * (delta ^ 2 * tensorSq E) := by ring + _ ≤ (1024 * (2 * ell-u) ^ 6) * + (((n + 1 : ℕ) + 2 : ℝ) * matrixSq (tensorSlice E a)) := h1 + _ = ((n + 1 : ℕ) + 2 : ℝ) * + (1024 * (2 * ell-u) ^ 6 * matrixSq (tensorSlice E a)) := by ring + _ ≤ ((n + 1 : ℕ) + 2 : ℝ) * + ((u-ell) ^ 6 * (∑ i, a i ^ 2) * tensorSq E) := h2 + _ = _ := by ring + apply tensorSq_zero E + apply le_antisymm _ (tensorSq_nonneg E) + by_contra h + have hp : 0 < tensorSq E := lt_of_not_ge h + exact (not_lt_of_ge hcombined) (mul_lt_mul_of_pos_right hq hp) + +/-- The criterion really is q_Ch<1: squared exact arithmetic, no square-root +choice or denominator ambiguity. The spectral band supplies a positive gap. -/ +def qChebyshevSq (a : Fin n → ℝ) (ell u delta : ℝ) : ℝ := + (((n + 1 : ℕ) + 2 : ℝ) * (∑ i, a i ^ 2) / (1024 * delta ^ 2)) * + ((u-ell) / (2 * ell-u)) ^ 6 + +theorem qChebyshevSq_lt_one_iff (a : Fin n → ℝ) (ell u delta : ℝ) + (hband : u < 2 * ell) (hd : delta ≠ 0) : + qChebyshevSq a ell u delta < 1 ↔ + ((n + 1 : ℕ) + 2 : ℝ) * (u-ell) ^ 6 * (∑ i, a i ^ 2) < + 1024 * delta ^ 2 * (2 * ell-u) ^ 6 := by + have hg : 0 < 2 * ell-u := by linarith + have hden : 0 < 1024 * delta ^ 2 * (2 * ell-u) ^ 6 := by positivity + have heq : qChebyshevSq a ell u delta = + (((n + 1 : ℕ) + 2 : ℝ) * (u-ell) ^ 6 * (∑ i, a i ^ 2)) / + (1024 * delta ^ 2 * (2 * ell-u) ^ 6) := by + dsimp [qChebyshevSq] + field_simp + rw [heq, div_lt_one hden] + +/-- Actual equality of positive weighted H2 data gives the null response used +above. This linearly normalizes the observed coefficients, preserving direction. -/ +theorem samePositive_weighted_difference (a rates : Fin n → ℝ) + (hPos : ∀ i, 0 < rates i) (C1 C2 : Tensor n) + (hData : SamePositive rates (weightedTensor a C1) (weightedTensor a C2)) : + NullRegular rates (weightedTensor a (C2-C1)) := by + apply (nullPositive_iff_nullRegular rates hPos _).mp + intro s t hs ht + have hh := hData s t hs ht + have hW : weightedTensor a (C2-C1) = weightedTensor a C2 - weightedTensor a C1 := by + funext i j k; simp only [weightedTensor, Pi.sub_apply]; ring + rw [hW, H_sub, hh, sub_self] + +/-- Calibrated modal tensor uniqueness from actual equal positive H2 under +source q_Ch<1. Calibration/H1 and graph idempotent reconstruction stay outside +this theorem's exact boundary; no physical norm or moment is supplied. -/ +theorem calibrated_tensors_unique + (a rates : Fin n → ℝ) (ha : ∀ i, a i ≠ 0) (hRates : Function.Injective rates) + (C1 C2 : Tensor n) (hC1 : FullSymTensor C1) (hC2 : FullSymTensor C2) + (hData : SamePositive rates (weightedTensor a C1) (weightedTensor a C2)) + (_hn : 2 ≤ n) (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) + (U Q : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hU : U.transpose * U = 1) (hQ : Q.transpose * Q = 1) + (hunit : ∀ i, ∑ v, Q i v = 1) + (hPhysical : physicalDifference Q = rotateTensor U (groundZero (C2 - C1))) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ + ((U.mulVec (residualVector a)) j - (U.mulVec (residualVector a)) k) ^ 2) + (hq : qChebyshevSq a ell u delta < 1) : C2 = C1 := by + have hPos : ∀ i, 0 < rates i := by + intro i + have hell : 0 < ell := by linarith + exact hell.trans_le (hlo i) + have hz := calibrated_H2_kernel_zero a rates ha hRates (C2-C1) + (fullSymTensor_sub C2 C1 hC2 hC1) + (samePositive_weighted_difference a rates hPos C1 C2 hData) + ell u hw hband hlo hhi U Q hU hQ hunit hPhysical delta hsep + ((qChebyshevSq_lt_one_iff a ell u delta hband (ne_of_gt hd)).mp hq) + exact sub_eq_zero.mp hz + +/-- Inherited n<=3 ordinary response injectivity after nonzero calibration. +No spectral width, band, separation, Q, or selected index is required, so +this retains n=0 and the source N=2/w=0 branch. -/ +theorem small_actual_H2_kernel_zero (a rates : Fin n → ℝ) + (ha : ∀ i, a i ≠ 0) (hRates : Function.Injective rates) (hn : n ≤ 3) + (E : Tensor n) (hSym : FullSymTensor E) + (hData : NullRegular rates (weightedTensor a E)) : E = 0 := by + have hz := (small_n_kernel_iff_zero rates hRates hn (weightedTensor a E) + (weightedTensor_symmetric a E hSym)).mp hData + calc + E = unweightedTensor a (weightedTensor a E) := (unweighted_weighted a ha E).symm + _ = 0 := by rw [hz]; funext i j k; simp [unweightedTensor] + +/-- The positive-H2 small-size uniqueness theorem is independent of w and +therefore remains available at w=0, including the inherited N=2 case. -/ +theorem small_calibrated_tensors_unique (a rates : Fin n → ℝ) + (ha : ∀ i, a i ≠ 0) (hRates : Function.Injective rates) + (hPos : ∀ i, 0 < rates i) (hn : n ≤ 3) + (C1 C2 : Tensor n) (hC1 : FullSymTensor C1) (hC2 : FullSymTensor C2) + (hData : SamePositive rates (weightedTensor a C1) (weightedTensor a C2)) : + C2 = C1 := by + exact sub_eq_zero.mp (small_actual_H2_kernel_zero a rates ha hRates hn (C2-C1) + (fullSymTensor_sub C2 C1 hC2 hC1) + (samePositive_weighted_difference a rates hPos C1 C2 hData)) + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8CommonUnit.lean b/LeanPool/C145/C145DRE8CommonUnit.lean new file mode 100644 index 0000000000..c7b680c001 --- /dev/null +++ b/LeanPool/C145/C145DRE8CommonUnit.lean @@ -0,0 +1,162 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Mathlib.Algebra.Order.BigOperators.Ring.Finset +public import Mathlib.Data.Fintype.BigOperators +public import Mathlib.Basic.Real.Basic +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.Positivity +public import Mathlib.Tactic.Ring +public import Mathlib.Tactic.SplitIfs + +/-! Finite-coordinate common-unit tensor bound for C145 DRE8 Lemma B. +All energies are explicit coordinate sums. No matrix/Pi default norm occurs. -/ + +@[expose] public section + +namespace C145DRE8 +open scoped BigOperators +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +/-- Sum of squares of all entries of a cubic tensor. -/ +noncomputable def tensorSq (E : ι → ι → ι → ℝ) : ℝ := ∑ i, ∑ j, ∑ k, E i j k ^ 2 +/-- Sum of squares of tensor entries whose second and third indices differ. -/ +noncomputable def offSq (E : ι → ι → ι → ℝ) : ℝ := + ∑ i, ∑ j, ∑ k, if j = k then 0 else E i j k ^ 2 +/-- Sum of squares of entries with equal last two indices and a distinct first index. -/ +noncomputable def repeatSq (E : ι → ι → ι → ℝ) : ℝ := + ∑ i, ∑ j, if i = j then 0 else E i j j ^ 2 +/-- Sum of squares of entries with all three indices equal. -/ +noncomputable def diagSq (E : ι → ι → ι → ℝ) : ℝ := ∑ j, E j j j ^ 2 + +theorem repeatSq_nonneg (E : ι → ι → ι → ℝ) : 0 ≤ repeatSq E := by + unfold repeatSq + positivity + +theorem tensorSq_decompose (E : ι → ι → ι → ℝ) : + tensorSq E = offSq E + repeatSq E + diagSq E := by + have hpoint (i j k : ι) : E i j k ^ 2 = + (if j = k then 0 else E i j k ^ 2) + (if j = k then E i j k ^ 2 else 0) := by + split_ifs <;> ring + have hsum : tensorSq E = offSq E + ∑ i, ∑ j, E i j j ^ 2 := by + unfold tensorSq offSq + calc + _ = ∑ i, ∑ j, ∑ k, ((if j = k then 0 else E i j k ^ 2) + + (if j = k then E i j k ^ 2 else 0)) := by + apply Finset.sum_congr rfl; intro i hi + apply Finset.sum_congr rfl; intro j hj + apply Finset.sum_congr rfl; intro k hk + exact hpoint i j k + _ = _ := by simp [Finset.sum_add_distrib] + rw [hsum, add_assoc] + congr 1 + unfold repeatSq diagSq + calc + _ = ∑ i, ∑ j, ((if i = j then 0 else E i j j ^ 2) + + (if i = j then E i j j ^ 2 else 0)) := by + apply Finset.sum_congr rfl; intro i hi + apply Finset.sum_congr rfl; intro j hj + split_ifs <;> ring + _ = _ := by simp [Finset.sum_add_distrib] + +theorem repeat_le_half_off (E : ι → ι → ι → ℝ) + (h13 : ∀ i j k, E i j k = E k j i) + (h12 : ∀ i j k, E i j k = E j i k) : + 2 * repeatSq E ≤ offSq E := by + let A : ι → ι → ι → ℝ := fun i j k => if i = j then + (if j = k then 0 else E i j k ^ 2) else 0 + let B : ι → ι → ι → ℝ := fun i j k => if i = k then + (if j = k then 0 else E i j k ^ 2) else 0 + have hp (i j k : ι) : A i j k + B i j k ≤ + if j = k then 0 else E i j k ^ 2 := by + dsimp [A, B] + split_ifs with hij hjk hik <;> subst_vars <;> simp_all [sq_nonneg] + have hA : (∑ i, ∑ j, ∑ k, A i j k) = repeatSq E := by + rw [Finset.sum_comm] + unfold repeatSq + conv_rhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro j hj + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro k hk + simp only [A, Fintype.sum_ite_eq'] + by_cases hjk : j = k + · simp [hjk] + · simp only [hjk, Ne.symm hjk, ↓reduceIte] + rw [h13] + have hB : (∑ i, ∑ j, ∑ k, B i j k) = repeatSq E := by + unfold repeatSq + conv_rhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro i hi + apply Finset.sum_congr rfl; intro j hj + simp only [B, Fintype.sum_ite_eq] + by_cases hij : i = j + · simp [hij] + · simp only [Ne.symm hij, ↓reduceIte] + rw [h12] + have hh := Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => + Finset.sum_le_sum (fun j (_ : j ∈ Finset.univ) => + Finset.sum_le_sum (fun k (_ : k ∈ Finset.univ) => hp i j k))) + simp only [Finset.sum_add_distrib] at hh + rw [hA, hB] at hh + unfold offSq + linarith + +theorem common_unit_diag_bound (E : ι → ι → ι → ℝ) + (hunit : ∀ j, ∑ i, E i j j = 0) : + diagSq E ≤ ((Fintype.card ι : ℝ) - 1) * repeatSq E := by + have hj (j : ι) : E j j j ^ 2 ≤ ((Fintype.card ι : ℝ) - 1) * + ∑ i, if i = j then 0 else E i j j ^ 2 := by + let s := Finset.univ.erase j + have hsum : ∑ i ∈ s, E i j j = - E j j j := by + have hh := Finset.sum_erase_add Finset.univ (fun i => E i j j) (Finset.mem_univ j) + rw [hunit j] at hh + dsimp [s] + linarith + have hc : (s.card : ℝ) = (Fintype.card ι : ℝ) - 1 := by + dsimp [s] + rw [Finset.card_erase_of_mem (Finset.mem_univ j)] + simp only [Finset.card_univ] + rw [Nat.cast_sub (Fintype.card_pos_iff.mpr ⟨j⟩)] + simp + have hcs := Finset.sum_mul_sq_le_sq_mul_sq s (fun _ => (1 : ℝ)) (fun i => E i j j) + simp only [one_mul, one_pow, Finset.sum_const, nsmul_eq_mul, mul_one] at hcs + rw [hsum, neg_sq, hc] at hcs + have he : (∑ i ∈ s, E i j j ^ 2) = ∑ i, if i = j then 0 else E i j j ^ 2 := by + dsimp [s] + symm + rw [← Finset.sum_erase_add Finset.univ + (fun i => if i = j then 0 else E i j j ^ 2) (Finset.mem_univ j)] + simp only [↓reduceIte, add_zero] + apply Finset.sum_congr rfl + intro i hi + simp [(Finset.mem_erase.mp hi).1] + rwa [he] at hcs + have hh := Finset.sum_le_sum (fun j (_ : j ∈ Finset.univ) => hj j) + rw [← Finset.mul_sum] at hh + rw [Finset.sum_comm] at hh + exact hh + +/-- DRE8's common-unit/symmetry contribution, valid also for empty and singleton index sets. -/ +theorem common_unit_tensor_bound (E : ι → ι → ι → ℝ) + (h13 : ∀ i j k, E i j k = E k j i) + (h12 : ∀ i j k, E i j k = E j i k) + (hunit : ∀ j, ∑ i, E i j j = 0) : + 2 * tensorSq E ≤ ((Fintype.card ι : ℝ) + 2) * offSq E := by + have hd := common_unit_diag_bound E hunit + have hu := repeat_le_half_off E h13 h12 + have hc : (0 : ℝ) ≤ Fintype.card ι := Nat.cast_nonneg _ + have hm := mul_le_mul_of_nonneg_left hu hc + rw [tensorSq_decompose] + nlinarith + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8CubicCancellation.lean b/LeanPool/C145/C145DRE8CubicCancellation.lean new file mode 100644 index 0000000000..489fe54958 --- /dev/null +++ b/LeanPool/C145/C145DRE8CubicCancellation.lean @@ -0,0 +1,143 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8WeightedKernel +public import LeanPool.C145.C145DRE8PhysicalTensor + +/-! Literal cubic cancellation in the orthonormal modal tensor variables, +DRE8 (6.2)-(6.3). No moment of E is assumed: V's moments come from the +actual weighted response bridge in C145DRE8WeightedKernel. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 C145.ThreePlane +variable {n : ℕ} + +/-- Contract the first tensor index against overlaps times a power of the modal rates. -/ +def weightedPower (a rates : Fin n → ℝ) (V : Tensor n) (p : ℕ) (j k : Fin n) : ℝ := + ∑ i, (a i * rates i ^ p) * V i j k + +/-- Expansion of the literal source Xi cubic in its contracted modal index. -/ +theorem xi_cubic_first (x y z : ℝ) : + MvPolynomial.eval ![-z, -x, -y] Xi = + x ^ 3 - (y + z) * x ^ 2 - (y-z) ^ 2 * x + + (y ^ 3 + z ^ 3-y ^ 2 * z-z ^ 2 * y) := by + rw [xi_negative_node_expansion] + ring + +/-- The source's scaled expansion (6.2), with its constant explicitly retained. -/ +theorem xi_scaled_cubic_first (theta x y z : ℝ) : + MvPolynomial.eval ![-(theta + z), -(theta + x), -(theta + y)] Xi = + x ^ 3 + (theta-y-z) * x ^ 2 - + (theta ^ 2 + 2 * theta * (y + z) + (y-z) ^ 2) * x + + (theta + z) ^ 3 + (theta + y) ^ 3-(theta + z) ^ 2 * (theta + y)- + (theta + y) ^ 2 * (theta + z) + theta ^ 3 - + ((theta + y) + (theta + z)) * theta ^ 2 - ((theta + y)-(theta + z)) ^ 2 * theta := by + rw [xi_cubic_first] + ring + +/-- Three derived annihilations leave only the leading rate cubic. -/ +theorem cubic_cancellation_rates (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (j k : Fin n) : + tensorSlice (xiWeighted rates V) a j k = weightedPower a rates V 3 j k := by + classical + have h0 := hm.1 0 (by omega) j k + have h1 := hm.1 1 (by omega) j k + have h2 := hm.1 2 (by omega) j k + calc + _ = weightedPower a rates V 3 j k - + (rates j + rates k) * weightedPower a rates V 2 j k - + (rates j - rates k) ^ 2 * weightedPower a rates V 1 j k + + (rates j ^ 3 + rates k ^ 3-rates j ^ 2 * rates k-rates k ^ 2 * rates j) * + weightedPower a rates V 0 j k := by + simp only [tensorSlice, xiWeighted, weightedPower, Finset.mul_sum, + ← Finset.sum_sub_distrib, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl; intro i hi + rw [xi_cubic_first] + ring + _ = _ := by + change weightedPower a rates V 3 j k - _ * + (∑ i, (a i * rates i ^ 2) * V i j k) - _ * + (∑ i, (a i * rates i ^ 1) * V i j k) + _ * + (∑ i, (a i * rates i ^ 0) * V i j k) = _ + rw [h2, h1, h0]; ring + +/-- The lower terms also disappear after shifting and scaling the modal band. -/ +theorem cubic_shift (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (ell w : ℝ) (hw : w ≠ 0) (j k : Fin n) : + weightedPower a rates V 3 j k = + w ^ 3 * weightedPower a (fun i => (rates i-ell) / w) V 3 j k := by + classical + have h0 := hm.1 0 (by omega) j k + have h1 := hm.1 1 (by omega) j k + have h2 := hm.1 2 (by omega) j k + calc + _ = w ^ 3 * weightedPower a (fun i => (rates i-ell) / w) V 3 j k + + 3 * ell * weightedPower a rates V 2 j k - + 3 * ell ^ 2 * weightedPower a rates V 1 j k + + ell ^ 3 * weightedPower a rates V 0 j k := by + simp only [weightedPower, Finset.mul_sum, ← Finset.sum_sub_distrib, + ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl; intro i hi + field_simp [hw] + ring + _ = _ := by + change _ + 3 * ell * (∑ i, (a i * rates i ^ 2) * V i j k) - + 3 * ell ^ 2 * (∑ i, (a i * rates i ^ 1) * V i j k) + + ell ^ 3 * (∑ i, (a i * rates i ^ 0) * V i j k) = _ + rw [h2,h1,h0]; ring + +/-- Exact source (6.3) in actual orthonormal modal coordinates. -/ +theorem cubic_cancellation (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (ell w : ℝ) (hw : w ≠ 0) : + tensorSlice (xiWeighted rates V) a = + fun j k => w ^ 3 * tensorSlice V (fun i => a i * ((rates i-ell) / w) ^ 3) j k := by + funext j k + rw [cubic_cancellation_rates a rates V hm, cubic_shift a rates V hm ell w hw] + rfl + +/-- Any explicit weighted quadratic may be subtracted from the cubic signature. +This includes the source projection's residual and the Chebyshev residual. -/ +theorem cubic_residual_slice (a t : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a t V) (c0 c1 c2 : ℝ) : + tensorSlice V (fun i => a i * t i ^ 3) = + tensorSlice V (fun i => a i * (t i ^ 3-(c0 + c1 * t i + c2 * t i ^ 2))) := by + classical + funext j k + have h0 := hm.1 0 (by omega) j k + have h1 := hm.1 1 (by omega) j k + have h2 := hm.1 2 (by omega) j k + calc + _ = tensorSlice V (fun i => a i * t i ^ 3) j k - + c0 * (∑ i, (a i * t i ^ 0) * V i j k) - + c1 * (∑ i, (a i * t i ^ 1) * V i j k) - + c2 * (∑ i, (a i * t i ^ 2) * V i j k) := by rw [h0,h1,h2]; ring + _ = _ := by + simp only [tensorSlice, Finset.mul_sum, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl; intro i hi; ring + +/-- Actual data yields the cubic matrix identity; no auxiliary moment certificate. -/ +theorem actual_H2_cubic_cancellation (a rates : Fin n → ℝ) + (ha : ∀ i, a i ≠ 0) (hRates : Function.Injective rates) + (E : Tensor n) (hSym : FullSymTensor E) + (hData : NullRegular rates (weightedTensor a E)) (ell w : ℝ) (hw : w ≠ 0) : + ∃ R : P3, SymPoly R ∧ QAdmissible n R ∧ + E = xiWeighted rates (physicalV a rates R) ∧ + tensorSlice E a = fun j k => w ^ 3 * + tensorSlice (physicalV a rates R) (fun i => a i * ((rates i-ell) / w) ^ 3) j k := by + obtain ⟨R,hR,hAdm,hE,hm,_⟩ := actual_H2_physical_kernel a rates ha hRates E hSym hData ell w + exact ⟨R,hR,hAdm,hE,by rw [hE]; exact cubic_cancellation a rates _ hm ell w hw⟩ + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8Frobenius.lean b/LeanPool/C145/C145DRE8Frobenius.lean new file mode 100644 index 0000000000..afcfb671d3 --- /dev/null +++ b/LeanPool/C145/C145DRE8Frobenius.lean @@ -0,0 +1,165 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Mathlib.Basic.Real.Basic +public import Mathlib.LinearAlgebra.Matrix.NonsingularInverse +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.Positivity +public import Mathlib.Tactic.Ring +public import Mathlib.Tactic.SplitIfs + +/-! Explicit squared Frobenius energy and its orthogonal invariance. -/ + +@[expose] public section + +namespace C145DRE8 +open scoped BigOperators +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +/-- The squared Frobenius norm written as a sum of squares of matrix entries. -/ +noncomputable def matrixSq (R : Matrix ι ι ℝ) : ℝ := ∑ i, ∑ j, R i j ^ 2 +/-- The squared Euclidean norm of the matrix diagonal. -/ +noncomputable def diagonalSq (R : Matrix ι ι ℝ) : ℝ := ∑ i, R i i ^ 2 + +omit [DecidableEq ι] in +theorem matrixSq_nonneg (R : Matrix ι ι ℝ) : 0 ≤ matrixSq R := by + unfold matrixSq; positivity + +omit [DecidableEq ι] in +theorem diagonalSq_nonneg (R : Matrix ι ι ℝ) : 0 ≤ diagonalSq R := by + unfold diagonalSq; positivity + +theorem orthogonal_rows (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) : + Q * Q.transpose = 1 := mul_eq_one_comm.mp hQ + +theorem orthogonal_columns_entry (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (a b : ι) : (∑ i, Q i a * Q i b) = if a = b then 1 else 0 := by + have h := congrArg (fun R : Matrix ι ι ℝ => R a b) hQ + simpa [Matrix.mul_apply, Matrix.transpose_apply, Matrix.one_apply] using h + +theorem orthogonal_energy (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (x : ι → ℝ) : ∑ i, (∑ j, Q i j * x j) ^ 2 = ∑ j, x j ^ 2 := by + have hexp (i : ι) : (∑ j, Q i j * x j) ^ 2 = + ∑ a, ∑ b, Q i a * Q i b * x a * x b := by + rw [pow_two, Finset.sum_mul] + apply Finset.sum_congr rfl; intro a ha + rw [Finset.mul_sum] + apply Finset.sum_congr rfl; intro b hb + ring + simp_rw [hexp] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro a ha + rw [Finset.sum_comm] + calc + _ = ∑ b, (∑ i, Q i a * Q i b) * x a * x b := by + apply Finset.sum_congr rfl; intro b hb + simp_rw [Finset.sum_mul] + _ = x a ^ 2 := by + simp_rw [orthogonal_columns_entry Q hQ] + simp [pow_two] + +omit [DecidableEq ι] in +theorem matrixSq_transpose (R : Matrix ι ι ℝ) : matrixSq R.transpose = matrixSq R := by + unfold matrixSq + exact Finset.sum_comm + +theorem matrixSq_left (Q R : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) : + matrixSq (Q * R) = matrixSq R := by + unfold matrixSq + rw [Finset.sum_comm] + conv_rhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro j hj + exact orthogonal_energy Q hQ (fun k => R k j) + +theorem matrixSq_right (Q R : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) : + matrixSq (R * Q) = matrixSq R := by + rw [← matrixSq_transpose (R * Q), Matrix.transpose_mul] + rw [matrixSq_left Q.transpose R.transpose] + · exact matrixSq_transpose R + · simpa using orthogonal_rows Q hQ + +theorem matrixSq_conjugate (Q R : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) : + matrixSq (Q.transpose * R * Q) = matrixSq R := by + rw [matrixSq_right Q (Q.transpose * R) hQ, matrixSq_left Q.transpose R] + simpa using orthogonal_rows Q hQ + +/-- The difference between the products in the two possible orders. -/ +noncomputable def commutator (R S : Matrix ι ι ℝ) : Matrix ι ι ℝ := R * S - S * R + +/-- Conjugate the diagonal formed from a row of the transport matrix by that matrix. -/ +noncomputable def physicalMatrix (Q : Matrix ι ι ℝ) (i : ι) : Matrix ι ι ℝ := + Q * Matrix.diagonal (Q i) * Q.transpose + +theorem conjugate_commutator (Q R : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) (i : ι) : + Q.transpose * commutator R (physicalMatrix Q i) * Q = + commutator (Q.transpose * R * Q) (Matrix.diagonal (Q i)) := by + have hcancel (X : Matrix ι ι ℝ) : Q.transpose * (Q * X) = X := by + rw [← Matrix.mul_assoc, hQ, Matrix.one_mul] + unfold commutator physicalMatrix + simp only [Matrix.mul_sub, Matrix.sub_mul] + simp only [Matrix.mul_assoc, hQ, Matrix.mul_one, hcancel] + +theorem commutator_diagonal_entry (R : Matrix ι ι ℝ) (d : ι → ℝ) (a b : ι) : + commutator R (Matrix.diagonal d) a b = R a b * (d b - d a) := by + simp only [commutator, Matrix.sub_apply, Matrix.mul_diagonal, Matrix.diagonal_mul] + ring + +/-- Orthogonal columns have squared pairwise distance two (zero on the diagonal). -/ +theorem orthogonal_column_distance (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (a b : ι) : ∑ i, (Q i b - Q i a) ^ 2 = if a = b then 0 else 2 := by + have hh (i : ι) : (Q i b - Q i a) ^ 2 = + Q i b * Q i b + Q i a * Q i a - 2 * (Q i a * Q i b) := by ring + simp_rw [hh, Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum] + rw [orthogonal_columns_entry Q hQ b b, orthogonal_columns_entry Q hQ a a, + orthogonal_columns_entry Q hQ a b] + simp only [ite_true] + split_ifs <;> norm_num + +/-- Exact DRE8 equation (5.3); symmetry of R is unnecessary for this real-coordinate identity. -/ +theorem physical_commutator_energy (Q R : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) : + (∑ i, matrixSq (commutator R (physicalMatrix Q i))) = + 2 * (matrixSq R - diagonalSq (Q.transpose * R * Q)) := by + let A := Q.transpose * R * Q + have he (i : ι) : matrixSq (commutator R (physicalMatrix Q i)) = + ∑ a, ∑ b, A a b ^ 2 * (Q i b - Q i a) ^ 2 := by + rw [← matrixSq_conjugate Q _ hQ, conjugate_commutator Q R hQ] + unfold matrixSq + apply Finset.sum_congr rfl; intro a ha + apply Finset.sum_congr rfl; intro b hb + rw [commutator_diagonal_entry, mul_pow] + simp_rw [he] + rw [Finset.sum_comm] + have hz : (∑ a, ∑ i, ∑ b, A a b ^ 2 * (Q i b - Q i a) ^ 2) = + ∑ a, ∑ b, A a b ^ 2 * (if a = b then 0 else 2) := by + apply Finset.sum_congr rfl; intro a ha + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro b hb + rw [← Finset.mul_sum, orthogonal_column_distance Q hQ a b] + rw [hz] + have hp (a b : ι) : A a b ^ 2 * (if a = b then 0 else 2) = + 2 * A a b ^ 2 - (if a = b then 2 * A a b ^ 2 else 0) := by + split_ifs <;> ring + simp_rw [hp, Finset.sum_sub_distrib, ← Finset.mul_sum] + simp only [Fintype.sum_ite_eq] + rw [← Finset.mul_sum] + change 2 * matrixSq A - 2 * diagonalSq A = _ + rw [show matrixSq A = matrixSq R from matrixSq_conjugate Q R hQ] + ring + +theorem physical_commutator_bound (Q R : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) : + (∑ i, matrixSq (commutator R (physicalMatrix Q i))) ≤ 2 * matrixSq R := by + rw [physical_commutator_energy Q R hQ] + have h := diagonalSq_nonneg (Q.transpose * R * Q) + linarith + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8HilbertStability.lean b/LeanPool/C145/C145DRE8HilbertStability.lean new file mode 100644 index 0000000000..eadf1920b6 --- /dev/null +++ b/LeanPool/C145/C145DRE8HilbertStability.lean @@ -0,0 +1,192 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import Mathlib.Analysis.InnerProductSpace.Projection.FiniteDimensional +public import Mathlib.Analysis.Normed.Module.FiniteDimension +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.NormNum +public import Mathlib.Tactic.Ring + +/-! +Finite-dimensional Hilbert mechanism for C145, Theorem E. +The domain norm is an inner-product norm; final tensor/grid instantiation must +use the source Frobenius/Euclidean norms, not default function sup norms. +-/ + +@[expose] public section + +namespace C145DRE8HilbertStability + +open scoped InnerProductSpace + +variable {E Y Z : Type*} +variable [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] +variable [NormedAddCommGroup Y] [NormedSpace ℝ Y] +variable [NormedAddCommGroup Z] [NormedSpace ℝ Z] + +/-- The actual orthogonal decomposition, including projection norm contraction. -/ +theorem orthogonal_decomposition (K : Submodule ℝ E) (x : E) : + ∃ k r : E, k ∈ K ∧ r ∈ Kᗮ ∧ x = k + r ∧ + inner ℝ k r = 0 ∧ ‖k‖ ≤ ‖x‖ := by + refine ⟨K.starProjection x, x - K.starProjection x, + K.starProjection_apply_mem x, K.sub_starProjection_mem_orthogonal x, + ?_, ?_, K.norm_starProjection_apply_le x⟩ + · abel + · exact Submodule.inner_right_of_mem_orthogonal + (K.starProjection_apply_mem x) (K.sub_starProjection_mem_orthogonal x) + +omit [FiniteDimensional ℝ E] in +/-- Kernel equality proves injectivity on the orthogonal complement. -/ +theorem complement_injective (M : E →ₗ[ℝ] Y) (K : Submodule ℝ E) + (hker : LinearMap.ker M = K) : + Function.Injective (M.domRestrict Kᗮ) := by + apply LinearMap.ker_eq_bot.mp + apply le_antisymm _ bot_le + intro u hu + have hMu : M (u : E) = 0 := hu + have hKu : (u : E) ∈ K := by + simpa only [hker] using (show (u : E) ∈ LinearMap.ker M from hMu) + have hu0 : (u : E) = 0 := by + apply (Submodule.mem_bot ℝ).mp + rw [← K.inf_orthogonal_eq_bot] + exact ⟨hKu, u.property⟩ + exact (Submodule.mem_bot ℝ).mpr (Subtype.ext hu0) + +/-- On a nonzero complement the genuine least unit-vector gain is attained +and strictly positive. The concluding bound is valid for every residual. -/ +theorem exists_attained_positive_complement_gain + (M : E →ₗ[ℝ] Y) (K : Submodule ℝ E) + (hker : LinearMap.ker M = K) [Nontrivial Kᗮ] : + ∃ (σ : ℝ) (u : Kᗮ), 0 < σ ∧ ‖u‖ = 1 ∧ ‖M (u : E)‖ = σ ∧ + (∀ v : Kᗮ, ‖v‖ = 1 → σ ≤ ‖M (v : E)‖) ∧ + (∀ r : E, r ∈ Kᗮ → σ * ‖r‖ ≤ ‖M r‖) := by + have hne : (Metric.sphere (0 : Kᗮ) 1).Nonempty := + NormedSpace.sphere_nonempty.mpr (by norm_num) + have hcont : Continuous (fun u : Kᗮ => ‖M (u : E)‖) := + (M.continuous_of_finiteDimensional.comp continuous_subtype_val).norm + obtain ⟨u, hu, hmin⟩ := (isCompact_sphere (0 : Kᗮ) 1).exists_isMinOn hne + hcont.continuousOn + have hun : ‖u‖ = 1 := by simpa only [Metric.mem_sphere, dist_zero_right] using hu + have hMu : M (u : E) ≠ 0 := by + intro heq + have hu0 : u = 0 := (complement_injective M K hker) (by simpa using heq) + simp [hu0] at hun + refine ⟨‖M (u : E)‖, u, norm_pos_iff.mpr hMu, hun, rfl, ?_, ?_⟩ + · intro v hv + exact hmin (by simpa only [Metric.mem_sphere, dist_zero_right] using hv) + · intro r hr + by_cases hr0 : r = 0 + · simp [hr0] + have hn : 0 < ‖r‖ := norm_pos_iff.mpr hr0 + let v : Kᗮ := ⟨‖r‖⁻¹ • r, Kᗮ.smul_mem _ hr⟩ + have hv : ‖v‖ = 1 := by + change ‖‖r‖⁻¹ • r‖ = 1 + rw [norm_smul, Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hn), + inv_mul_cancel₀ hn.ne'] + have hm := hmin (show v ∈ Metric.sphere (0 : Kᗮ) 1 by + simpa only [Metric.mem_sphere, dist_zero_right] using hv) + change ‖M (u : E)‖ ≤ ‖M (‖r‖⁻¹ • r)‖ at hm + rw [map_smul, norm_smul, Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hn)] at hm + have hs := mul_le_mul_of_nonneg_left hm hn.le + calc + ‖M (u : E)‖ * ‖r‖ = ‖r‖ * ‖M (u : E)‖ := mul_comm _ _ + _ ≤ ‖r‖ * (‖r‖⁻¹ * ‖M r‖) := hs + _ = ‖M r‖ := by rw [← mul_assoc, mul_inv_cancel₀ hn.ne', one_mul] + +omit [FiniteDimensional ℝ E] in +/-- If the complement is zero, σ=1 is a valid positive bound. This is a +vacuous lower-gain convention, not a minimum over an empty unit sphere. -/ +theorem zero_complement_gain (M : E →ₗ[ℝ] Y) (K : Submodule ℝ E) + [Subsingleton Kᗮ] : + 0 < (1 : ℝ) ∧ ∀ r : E, r ∈ Kᗮ → 1 * ‖r‖ ≤ ‖M r‖ := by + refine ⟨zero_lt_one, ?_⟩ + intro r hr + have hr0 : r = 0 := congrArg Subtype.val (Subsingleton.elim (⟨r, hr⟩ : Kᗮ) 0) + simp [hr0] + +/-- Every finite-dimensional operator has a positive lower gain off its kernel, +with the preceding σ=1 convention when that complement is zero. -/ +theorem exists_positive_complement_gain + (M : E →ₗ[ℝ] Y) (K : Submodule ℝ E) + (hker : LinearMap.ker M = K) : + ∃ σ : ℝ, 0 < σ ∧ ∀ r : E, r ∈ Kᗮ → σ * ‖r‖ ≤ ‖M r‖ := by + cases subsingleton_or_nontrivial Kᗮ with + | inl h => + let := h + exact ⟨1, zero_complement_gain M K⟩ + | inr h => + let := h + obtain ⟨σ, u, hσ, -, -, -, hbound⟩ := + exists_attained_positive_complement_gain M K hker + exact ⟨σ, hσ, hbound⟩ + +/-- Exact calibration stability. Physical rigidity is required only for x; +neither orthogonal component is assumed to be physical. σ may be the genuine +least gain above or any independently established positive lower gain. -/ +theorem fixed_calibration_stability + (M : E →ₗ[ℝ] Y) (K : Submodule ℝ E) (S : E →ₗ[ℝ] Z) + (hker : LinearMap.ker M = K) (x : E) + (a β B σ : ℝ) (ha : 0 ≤ a) (hβ : 0 ≤ β) (hB : 0 ≤ B) + (hσ : 0 < σ) (hq : a * β < 1) + (hgain : ∀ r : E, r ∈ Kᗮ → σ * ‖r‖ ≤ ‖M r‖) + (hphysical : ‖x‖ ≤ a * ‖S x‖) + (hkernel : ∀ k : E, k ∈ K → ‖S k‖ ≤ β * ‖k‖) + (hslices : ∀ r : E, ‖S r‖ ≤ B * ‖r‖) : + ‖x‖ ≤ (a * B / ((1 - a * β) * σ)) * ‖M x‖ := by + obtain ⟨k, r, hk, hr, hxr, -, hkn⟩ := orthogonal_decomposition K x + have hMk : M k = 0 := by + have : k ∈ LinearMap.ker M := by rwa [hker] + exact this + have hMr : M r = M x := by rw [hxr, map_add, hMk, zero_add] + have hS : ‖S x‖ ≤ β * ‖x‖ + B * ‖r‖ := by + calc + ‖S x‖ = ‖S k + S r‖ := by rw [hxr, map_add] + _ ≤ ‖S k‖ + ‖S r‖ := norm_add_le _ _ + _ ≤ β * ‖k‖ + B * ‖r‖ := add_le_add (hkernel k hk) (hslices r) + _ ≤ β * ‖x‖ + B * ‖r‖ := + add_le_add (mul_le_mul_of_nonneg_left hkn hβ) le_rfl + have habs : (1 - a * β) * ‖x‖ ≤ a * B * ‖r‖ := by + have := hphysical.trans (mul_le_mul_of_nonneg_left hS ha) + nlinarith only [this] + have hgr : σ * ‖r‖ ≤ ‖M x‖ := by simpa only [hMr] using hgain r hr + have hfinal : ((1 - a * β) * σ) * ‖x‖ ≤ (a * B) * ‖M x‖ := by + calc + ((1 - a * β) * σ) * ‖x‖ = σ * ((1 - a * β) * ‖x‖) := by ring + _ ≤ σ * (a * B * ‖r‖) := mul_le_mul_of_nonneg_left habs hσ.le + _ = (a * B) * (σ * ‖r‖) := by ring + _ ≤ (a * B) * ‖M x‖ := mul_le_mul_of_nonneg_left hgr (mul_nonneg ha hB) + rw [div_mul_eq_mul_div] + apply (le_div_iff₀ (mul_pos (sub_pos.mpr hq) hσ)).mpr + nlinarith only [hfinal] + +/-- Literal source normalization a=√(N+2)/δ and q=√(N+2)β/δ. -/ +theorem fixed_calibration_tensor_stability + (M : E →ₗ[ℝ] Y) (K : Submodule ℝ E) (S : E →ₗ[ℝ] Z) + (hker : LinearMap.ker M = K) (x : E) + (N : ℕ) (δ β B σ : ℝ) (hδ : 0 < δ) (hβ : 0 ≤ β) (hB : 0 ≤ B) + (hσ : 0 < σ) (hq : Real.sqrt (N + 2) * β / δ < 1) + (hgain : ∀ r : E, r ∈ Kᗮ → σ * ‖r‖ ≤ ‖M r‖) + (hphysical : ‖x‖ ≤ (Real.sqrt (N + 2) / δ) * ‖S x‖) + (hkernel : ∀ k : E, k ∈ K → ‖S k‖ ≤ β * ‖k‖) + (hslices : ∀ r : E, ‖S r‖ ≤ B * ‖r‖) : + ‖x‖ ≤ (Real.sqrt (N + 2) * B / + (δ * (1 - Real.sqrt (N + 2) * β / δ) * σ)) * ‖M x‖ := by + have hq' : (Real.sqrt (N + 2) / δ) * β < 1 := by + simpa only [div_mul_eq_mul_div] using hq + have h := fixed_calibration_stability M K S hker x + (Real.sqrt (N + 2) / δ) β B σ + (div_nonneg (Real.sqrt_nonneg _) hδ.le) hβ hB hσ hq' + hgain hphysical hkernel hslices + convert h using 1; field_simp + + +end C145DRE8HilbertStability + +end diff --git a/LeanPool/C145/C145DRE8JointOriginalGraph.lean b/LeanPool/C145/C145DRE8JointOriginalGraph.lean new file mode 100644 index 0000000000..d72a9d7dbb --- /dev/null +++ b/LeanPool/C145/C145DRE8JointOriginalGraph.lean @@ -0,0 +1,298 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8JointTransferInverse +public import LeanPool.C145.C145DRE8OriginalGraphInverse + +/-! The original fixed-horizon graph/port inverse under the DRE8 literal joint quadratic-Krylov +signature sufficient condition, with unrestricted-size admissible competitors. +Caller actual response and local C2 regularity are retained exactly as in the +accepted small-graph endpoint. The graph result identifies L, generator and +signed b; it does not identify unobservable self-loop weights. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators Topology ContDiff +open MeasureTheory Set C145.DelayKernel +open C145.ActualResponse C145.ObservedKernelRecovery +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +private theorem rates_pos_of_ground {n : ℕ} (μ : ℝ) (hμ : 0 < μ) + (rates : Fin (n + 1) → ℝ) (hGround : rates 0 = μ) + (hAbove : ∀ i : Fin n, μ < rates i.succ) : ∀ i, 0 < rates i := by + intro i + rcases Fin.eq_zero_or_eq_succ i with hi | ⟨j, hj⟩ + · rw [hi, hGround] + exact hμ + · rw [hj] + exact lt_trans hμ (hAbove j) + +theorem actual_time_kernel_theoremC_vertex_identification {m n : ℕ} + (μ c0 c1 : ℝ) (hμ : 0 < μ) + (Q0 : Fin (m + 1) → Fin (m + 1) → ℝ) + (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates0 b0 : Fin (m + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround0 : ∀ v, Q0 v 0 = c0) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hRateGround0 : rates0 0 = μ) + (hRateGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < C145.Pulse.modalOverlap Q0 b0 i) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (A : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (hEig : ∀ i, A.mulVec (fun v => Q0 v i) = + (-rates0 i) • (fun v => Q0 v i)) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i : Fin m, ell ≤ rates0 i.succ) (hhi : ∀ i : Fin m, rates0 i.succ ≤ u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → + delta ^ 2 ≤ signatureSq (physicalKrylov A b0 ell (u-ell)) j k) + (hq : ((m + 1 : ℕ) + 2 : ℝ) * + jointBetaSq (fun i : Fin m => C145.Pulse.modalOverlap Q0 b0 i.succ) + (fun i => (rates0 i.succ-ell) / (u-ell)) (ell / (u-ell)) < delta ^ 2) + (hK1 : ∀ r : ℝ, 0 ≤ r → + firstKernel Q0 rates0 b0 r = firstKernel Q1 rates1 b1 r) + (hK2 : ∀ r₁ r₂ : ℝ, 0 ≤ r₁ → 0 ≤ r₂ → + delayKernel Q0 rates0 b0 r₁ r₂ = + delayKernel Q1 rates1 b1 r₁ r₂) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap Q0 b0 i) ∧ + c0 = c1 ∧ (∑ v, b0 v) = (∑ w, b1 w) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u) ∧ + (∀ v : Fin (m + 1), b1 (π v) = b0 v) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u) := by + have hPos0 := rates_pos_of_ground μ hμ rates0 hRateGround0 hAbove0 + have hPos1 := rates_pos_of_ground μ hμ rates1 hRateGround1 hAbove1 + have hH1 : ∀ s : ℝ, 0 < s → + C145.H1.firstTransfer rates0 (C145.Pulse.modalOverlap Q0 b0) s = + C145.H1.firstTransfer rates1 (C145.Pulse.modalOverlap Q1 b1) s := by + intro s hs + rw [← (firstKernel_transform Q0 rates0 b0 hPos0 s hs).2, + ← (firstKernel_transform Q1 rates1 b1 hPos1 s hs).2] + unfold laplace + apply setIntegral_congr_fun measurableSet_Ioi + intro r hr + change Real.exp (-s * r) * firstKernel Q0 rates0 b0 r = + Real.exp (-s * r) * firstKernel Q1 rates1 b1 r + rw [hK1 r hr.le] + have hH2 : ∀ s t : ℝ, 0 < s → 0 < t → + C145.H2.H rates0 (C145PhysicalFrame.T Q0 (C145.Pulse.modalOverlap Q0 b0)) s t = + C145.H2.H rates1 (C145PhysicalFrame.T Q1 (C145.Pulse.modalOverlap Q1 b1)) s t := by + intro s t hs ht + rw [← (delayKernel_transform Q0 rates0 b0 hPos0 s t hs ht).2, + ← (delayKernel_transform Q1 rates1 b1 hPos1 s t hs ht).2] + unfold doubleLaplace + apply setIntegral_congr_fun measurableSet_Ioi + intro r₁ hr₁ + apply setIntegral_congr_fun measurableSet_Ioi + intro r₂ hr₂ + change Real.exp (-s * r₁) * Real.exp (-t * r₂) * delayKernel Q0 rates0 b0 r₁ r₂ = + Real.exp (-s * r₁) * Real.exp (-t * r₂) * delayKernel Q1 rates1 b1 r₁ r₂ + rw [hK2 r₁ r₂ hr₁.le hr₂.le] + exact actual_H1_H2_theoremC_vertex_identification + μ c0 c1 hμ Q0 Q1 rates0 b0 rates1 b1 hQ0 hQ1 hGround0 hGround1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 ha0 ha1 + A hEig ell u hw hband hlo hhi delta hd hsep hq + hH1 hH2 + +theorem ordinary_C2_jets_determine_theoremC_spectral_model {m n : ℕ} {T : ℝ} + (hT : 0 < T) + (μ c0 c1 : ℝ) (hμ : 0 < μ) + (Q0 : Fin (m + 1) → Fin (m + 1) → ℝ) + (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates0 b0 : Fin (m + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround0 : ∀ v, Q0 v 0 = c0) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hRateGround0 : rates0 0 = μ) + (hRateGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < C145.Pulse.modalOverlap Q0 b0 i) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (A : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (hEig : ∀ i, A.mulVec (fun v => Q0 v i) = + (-rates0 i) • (fun v => Q0 v i)) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i : Fin m, ell ≤ rates0 i.succ) (hhi : ∀ i : Fin m, rates0 i.succ ≤ u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → + delta ^ 2 ≤ signatureSq (physicalKrylov A b0 ell (u-ell)) j k) + (hq : ((m + 1 : ℕ) + 2 : ℝ) * + jointBetaSq (fun i : Fin m => C145.Pulse.modalOverlap Q0 b0 i.succ) + (fun i => (rates0 i.succ-ell) / (u-ell)) (ell / (u-ell)) < delta ^ 2) + (R0 : Input T → Path m T) (R1 : Input T → Path n T) + (hR0 : IsActualResponse hT Q0 rates0 b0 R0) + (hR1 : IsActualResponse hT Q1 rates1 b1 R1) + (hcR0 : ContDiffAt ℝ 2 R0 0) (hcR1 : ContDiffAt ℝ 2 R1 0) + (hFirst : ∀ (g : ℝ → ℝ) (hg : SmoothTemporalTest T g), + rawFirst b0 R0 (restrictInput T g hg.1.continuous) (endTime T hT) = + rawFirst b1 R1 (restrictInput T g hg.1.continuous) (endTime T hT)) + (hMixed : ∀ (g h : ℝ → ℝ) (hg : SmoothTemporalTest T g) (hh : SmoothTemporalTest T h), + rawMixed b0 R0 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT) = + rawMixed b1 R1 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT)) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap Q0 b0 i) ∧ + c0 = c1 ∧ (∑ v, b0 v) = (∑ w, b1 w) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u) ∧ + (∀ v : Fin (m + 1), b1 (π v) = b0 v) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u) := by + have hObserved := ordinary_C2_jets_recover_observed_time_kernels hT + Q0 rates0 b0 Q1 rates1 b1 hQ0 hQ1 R0 R1 hR0 hR1 hcR0 hcR1 hFirst hMixed + have hAll := C145.TimeKernelContinuation.observed_time_kernels_determine_all_nonnegative_delays + hT Q0 rates0 b0 Q1 rates1 b1 hObserved.1 hObserved.2 + exact actual_time_kernel_theoremC_vertex_identification + μ c0 c1 hμ Q0 Q1 rates0 b0 rates1 b1 hQ0 hQ1 hGround0 hGround1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 ha0 ha1 + A hEig ell u hw hband hlo hhi delta hd hsep hq hAll.1 hAll.2 + +open Matrix C145.WeightedGraph C145.CyclicSpectral C145.GraphSpectralRealization + +/-- One fixed actual source realization, derived from the original connected +cyclic graph. Its choice only selects an ordering of the genuine nonground +spectrum; no desired transport, tensor equality or reconstruction is supplied. -/ +def sourceOrientedRealization {m : ℕ} + (μ : ℝ) (hμ : 0 < μ) + (W : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (hs : W.IsSymm) (hn : ∀ v u, 0 ≤ W v u) + (hc : (supportGraph W hs).Connected) + (b : State m) (hcyc : KrylovCyclic (generator μ W) b) : + OrientedRealization μ W b := + Classical.choice (connected_cyclic_graph_has_oriented_spectral_realization + μ hμ W hs hn hc b hcyc) + +/-- Literal beta_0²+beta_1²+beta_2² from the actual source's nonground +rates and positive modal overlaps. The kappa_p inside jointBetaSq are true +weighted orthogonal projection residuals, for p=3,4,5. This is source spectral +data, not a hypothesis quantified over arbitrary realizations. -/ +def originalSourceJointBetaSq {m : ℕ} + (μ : ℝ) (hμ : 0 < μ) + (W : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (hs : W.IsSymm) (hn : ∀ v u, 0 ≤ W v u) + (hc : (supportGraph W hs).Connected) + (b : State m) (hcyc : KrylovCyclic (generator μ W) b) + (ell u : ℝ) : ℝ := + let S := sourceOrientedRealization μ hμ W hs hn hc b hcyc + jointBetaSq (fun i : Fin m => C145.Pulse.modalOverlap S.Q b i.succ) + (fun i => (S.rates i.succ-ell) / (u-ell)) (ell / (u-ell)) + +/-- DRE8 Theorem C for the actual original graph and signed port from fixed +positive-horizon ordinary response jets. Source q_H is expressed by its literal exact square; the + joint separation +uses h0=b_perp, h1=S b_perp, h2=S² b_perp and permits repeated b entries. Modal +calibration, common signed ground, physical transport, residual H2 equality, +size equality and the simultaneous vertex bijection are all derived. -/ +theorem ordinary_C2_jets_determine_theoremC_graph {m n : ℕ} {T : ℝ} + (hT : 0 < T) (μ : ℝ) (hμ : 0 < μ) + (W0 : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (W1 : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hs0 : W0.IsSymm) (hs1 : W1.IsSymm) + (hn0 : ∀ v u, 0 ≤ W0 v u) (hn1 : ∀ v u, 0 ≤ W1 v u) + (hc0 : (supportGraph W0 hs0).Connected) (hc1 : (supportGraph W1 hs1).Connected) + (b0 : State m) (b1 : State n) + (hcyc0 : KrylovCyclic (generator μ W0) b0) + (hcyc1 : KrylovCyclic (generator μ W1) b1) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hSpectrum : NonGroundDecayBand μ W0 ell u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ + signatureSq (physicalKrylov (generator μ W0) b0 ell (u - ell)) j k) + (hq : ((m + 1 : ℕ) + 2 : ℝ) * + originalSourceJointBetaSq μ hμ W0 hs0 hn0 hc0 b0 hcyc0 ell u < delta ^ 2) + (R0 : Input T → Path m T) (R1 : Input T → Path n T) + (hR0 : IsGraphResponse hT μ W0 b0 R0) (hR1 : IsGraphResponse hT μ W1 b1 R1) + (hC0 : ContDiffAt ℝ 2 R0 0) (hC1 : ContDiffAt ℝ 2 R1 0) + (hFirst : ∀ (g : ℝ → ℝ) (hg : SmoothTemporalTest T g), + rawFirst b0 R0 (restrictInput T g hg.1.continuous) (endTime T hT) = + rawFirst b1 R1 (restrictInput T g hg.1.continuous) (endTime T hT)) + (hMixed : ∀ (g h : ℝ → ℝ) (hg : SmoothTemporalTest T g) (hh : SmoothTemporalTest T h), + rawMixed b0 R0 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT) = + rawMixed b1 R1 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT)) : + ∃ (S0 : OrientedRealization μ W0 b0) (S1 : OrientedRealization μ W1 b1) + (e : Fin (m + 1) ≃ Fin (n + 1)), + m = n ∧ e 0 = 0 ∧ (∀ i, S1.rates (e i) = S0.rates i) ∧ + (∀ i, C145.Pulse.modalOverlap S1.Q b1 (e i) = + C145.Pulse.modalOverlap S0.Q b0 i) ∧ + S0.c = S1.c ∧ (∑ v, b0 v) = (∑ v, b1 v) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ v i, S1.Q (π v) (e i) = S0.Q v i) ∧ + (∀ v u, generator μ W1 (π v) (π u) = generator μ W0 v u) ∧ + (∀ v, b1 (π v) = b0 v) ∧ + (∀ v u, laplacian W1 (π v) (π u) = laplacian W0 v u) := by + let S0 := sourceOrientedRealization μ hμ W0 hs0 hn0 hc0 b0 hcyc0 + have hq0 : ((m + 1 : ℕ) + 2 : ℝ) * + jointBetaSq (fun i : Fin m => C145.Pulse.modalOverlap S0.Q b0 i.succ) + (fun i => (S0.rates i.succ-ell) / (u-ell)) (ell / (u-ell)) < delta ^ 2 := hq + obtain ⟨S1⟩ := connected_cyclic_graph_has_oriented_spectral_realization + μ hμ W1 hs1 hn1 hc1 b1 hcyc1 + have hBounds := orientedRealization_decayBand S0 ell u hSpectrum + obtain ⟨e, hmn, he0, hr, ha, hc, hb, π, _, hQ, hA, hport, hL⟩ := + ordinary_C2_jets_determine_theoremC_spectral_model + hT μ S0.c S1.c hμ S0.Q S1.Q S0.rates b0 S1.rates b1 + S0.orthonormal S1.orthonormal S0.ground S1.ground S0.simple S1.simple + S0.ground_rate S1.ground_rate S0.higher S1.higher + S0.positive_overlap S1.positive_overlap + (generator μ W0) S0.eigenvectors + ell u hw hband (fun i => (hBounds i).1) (fun i => (hBounds i).2) + delta hd hsep hq0 R0 R1 + (S0.actualResponse hT R0 hR0) (S1.actualResponse hT R1 hR1) + hC0 hC1 hFirst hMixed + refine ⟨S0, S1, e, hmn, he0, hr, ha, hc, hb, π, hQ, ?_, hport, ?_⟩ + · simpa only [S0.original_generator, S1.original_generator] using hA + · simpa only [S0.original_laplacian, S1.original_laplacian] using hL + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8JointSignatureInverse.lean b/LeanPool/C145/C145DRE8JointSignatureInverse.lean new file mode 100644 index 0000000000..0fff3bdd94 --- /dev/null +++ b/LeanPool/C145/C145DRE8JointSignatureInverse.lean @@ -0,0 +1,427 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8KrylovSlices +public import LeanPool.C145.C145DRE8OptimalContraction + +/-! +# The joint signature criterion for calibrated graph identification. +-/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 +variable {n : ℕ} + +/-- View a matrix as a vector indexed by ordered pairs with the Euclidean norm. -/ +def matrixVector (M : Matrix (Fin n) (Fin n) ℝ) : EuclideanSpace ℝ (Fin n × Fin n) := + WithLp.toLp 2 (fun p => M p.1 p.2) + +theorem matrixVector_energy (M : Matrix (Fin n) (Fin n) ℝ) : + ‖matrixVector M‖ ^ 2 = matrixSq M := by + rw [EuclideanSpace.norm_sq_eq] + simp [matrixVector, matrixSq, Fintype.sum_prod_type] + +theorem matrixVector_add (M N : Matrix (Fin n) (Fin n) ℝ) : + matrixVector (M + N) = matrixVector M + matrixVector N := rfl + +theorem matrixVector_sub (M N : Matrix (Fin n) (Fin n) ℝ) : + matrixVector (M-N) = matrixVector M-matrixVector N := rfl + +theorem matrixVector_scale (M : Matrix (Fin n) (Fin n) ℝ) (c : ℝ) : + matrixVector (fun j k => c * M j k) = c • matrixVector M := rfl + +theorem matrixVector_coeff_bound (M : Matrix (Fin n) (Fin n) ℝ) + (f : Fin n → Fin n → ℝ) (c : ℝ) (hc : 0 ≤ c) (hf : ∀ j k, |f j k| ≤ c) : + ‖matrixVector (fun j k => f j k * M j k)‖ ≤ c * ‖matrixVector M‖ := by + have hh : matrixSq (fun j k => f j k * M j k) ≤ c ^ 2 * matrixSq M := by + simp only [matrixSq, Finset.mul_sum] + apply Finset.sum_le_sum; intro j hj + apply Finset.sum_le_sum; intro k hk + have hf2 : (f j k) ^ 2 ≤ c ^ 2 := by + simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg (f j k)) hc).mpr (hf j k) + have h := mul_le_mul_of_nonneg_right hf2 (sq_nonneg (M j k)) + simpa only [mul_pow] using h + rw [← matrixVector_energy M, ← matrixVector_energy (fun j k => f j k * M j k), ← mul_pow] at hh + exact (sq_le_sq₀ (norm_nonneg _) (mul_nonneg hc (norm_nonneg _))).mp hh + +theorem krylov_coefficient_bounds (theta y z : ℝ) (ht : 1 < theta) + (hy0 : 0 ≤ y) (hy1 : y ≤ 1) (hz0 : 0 ≤ z) (hz1 : z ≤ 1) : + |theta-y-z|≤theta ∧ + |theta ^ 2 + 2 * theta * (y + z) + (y-z) ^ 2|≤theta ^ 2 + 4 * theta + 1 := by + have ht0 : 0 ≤ theta := by linarith + have hs : (y-z) ^ 2 ≤ 1 := by + have h : |y-z|≤1 := abs_le.mpr ⟨by linarith,by linarith⟩ + simpa only [sq_abs, one_pow] using + (sq_le_sq₀ (abs_nonneg (y - z)) (by norm_num : (0 : ℝ) ≤ 1)).mpr h + constructor + · exact abs_le.mpr ⟨by linarith,by linarith⟩ + · rw [abs_of_nonneg (by positivity)] + nlinarith + + + +/-- The three numerator bounds formed from residual powers three, four, and five. -/ +def jointNumerator (a t : Fin n → ℝ) (theta : ℝ) : Fin 3 → ℝ := + ![kappa a t 3, kappa a t 4 + theta * kappa a t 3, + kappa a t 5 + theta * kappa a t 4 + (theta ^ 2 + 4 * theta + 1) * kappa a t 3] + +/-- Literal source beta_r, retaining the three distinct projection norms. -/ +def jointBeta (a t : Fin n → ℝ) (theta : ℝ) (r : Fin 3) : ℝ := + jointNumerator a t theta r / (theta-1) ^ 3 + +/-- Sum of the squares of the three separate contraction coefficients. -/ +def jointBetaSq (a t : Fin n → ℝ) (theta : ℝ) : ℝ := + ∑ r : Fin 3, jointBeta a t theta r ^ 2 + +/-- The Euclidean norm of the three contraction coefficients. -/ +def jointBetaNorm (a t : Fin n → ℝ) (theta : ℝ) : ℝ := + Real.sqrt (jointBetaSq a t theta) + +theorem power_slice_norm_bound (a t : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a t V) (p : ℕ) : + ‖matrixVector (tensorSlice V (fun i => a i * t i ^ p))‖ ≤ + kappa a t p * Real.sqrt (tensorSq V) := by + have h := power_slice_kappa_bound a t V hm p + rw [← matrixVector_energy] at h + have hs : (Real.sqrt (tensorSq V)) ^ 2 = tensorSq V := Real.sq_sqrt (tensorSq_nonneg V) + apply (sq_le_sq₀ (norm_nonneg _) (mul_nonneg (kappa_nonneg a t p) (Real.sqrt_nonneg _))).mp + simpa only [mul_pow, hs] using h + +/-- Exact Minkowski estimate for the two surviving terms in source (7.2). -/ +theorem joint_one_norm_bound (a t : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a t V) (theta : ℝ) (ht : 1 < theta) + (hlo : ∀ i, 0 ≤ t i) (hhi : ∀ i, t i ≤ 1) : + ‖matrixVector (fun j k => tensorSlice V (fun i => a i * t i ^ 4) j k + + (theta-t j-t k) * tensorSlice V (fun i => a i * t i ^ 3) j k)‖ ≤ + (kappa a t 4 + theta * kappa a t 3) * Real.sqrt (tensorSq V) := by + have htheta : 0 ≤ theta := by linarith + have hc := matrixVector_coeff_bound (tensorSlice V (fun i => a i * t i ^ 3)) + (fun j k => theta-t j-t k) theta htheta + (fun j k => (krylov_coefficient_bounds theta (t j) (t k) ht + (hlo j) (hhi j) (hlo k) (hhi k)).1) + have h3 := power_slice_norm_bound a t V hm 3 + have h4 := power_slice_norm_bound a t V hm 4 + calc + _ ≤ ‖matrixVector (tensorSlice V (fun i => a i * t i ^ 4))‖+ + ‖matrixVector (fun j k => (theta-t j-t k) * tensorSlice V (fun i => a i * t i ^ 3) j k)‖ := + norm_add_le _ _ + _ ≤ kappa a t 4 * Real.sqrt (tensorSq V) + theta * (kappa a t 3 * Real.sqrt (tensorSq V)) := + add_le_add h4 (hc.trans (mul_le_mul_of_nonneg_left h3 htheta)) + _ = _ := by ring + +/-- Exact three-term estimate for source (7.3), with its stated coefficient. -/ +theorem joint_two_norm_bound (a t : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a t V) (theta : ℝ) (ht : 1 < theta) + (hlo : ∀ i, 0 ≤ t i) (hhi : ∀ i, t i ≤ 1) : + ‖matrixVector (fun j k => tensorSlice V (fun i => a i * t i ^ 5) j k + + (theta-t j-t k) * tensorSlice V (fun i => a i * t i ^ 4) j k - + (theta ^ 2 + 2 * theta * (t j + t k) + (t j-t k) ^ 2)* + tensorSlice V (fun i => a i * t i ^ 3) j k)‖ ≤ + (kappa a t 5 + theta * kappa a t 4 + (theta ^ 2 + 4 * theta + 1) * kappa a t 3)* + Real.sqrt (tensorSq V) := by + have htheta : 0 ≤ theta := by linarith + have hC : 0 ≤ theta ^ 2 + 4 * theta + 1 := by positivity + have hc4 := matrixVector_coeff_bound (tensorSlice V (fun i => a i * t i ^ 4)) + (fun j k => theta-t j-t k) theta htheta + (fun j k => (krylov_coefficient_bounds theta (t j) (t k) ht + (hlo j) (hhi j) (hlo k) (hhi k)).1) + have hc3 := matrixVector_coeff_bound (tensorSlice V (fun i => a i * t i ^ 3)) + (fun j k => theta ^ 2 + 2 * theta * (t j + t k) + (t j-t k) ^ 2) (theta ^ 2 + 4 * theta + 1) hC + (fun j k => (krylov_coefficient_bounds theta (t j) (t k) ht + (hlo j) (hhi j) (hlo k) (hhi k)).2) + have h3 := power_slice_norm_bound a t V hm 3 + have h4 := power_slice_norm_bound a t V hm 4 + have h5 := power_slice_norm_bound a t V hm 5 + calc + _ ≤ (‖matrixVector (tensorSlice V (fun i => a i * t i ^ 5))‖+ + ‖matrixVector (fun j k => (theta-t j-t k) * tensorSlice V (fun i => a i * t i ^ 4) j k)‖)+ + ‖matrixVector (fun j k => (theta ^ 2 + 2 * theta * (t j + t k) + (t j-t k) ^ 2)* + tensorSlice V (fun i => a i * t i ^ 3) j k)‖ := + (norm_sub_le + (matrixVector (tensorSlice V (fun i => a i * t i ^ 5)) + + matrixVector (fun j k => (theta-t j-t k) * tensorSlice V (fun i => a i * t i ^ 4) j k)) + (matrixVector (fun j k => (theta ^ 2 + 2 * theta * (t j + t k) + (t j-t k) ^ 2)* + tensorSlice V (fun i => a i * t i ^ 3) j k))).trans + (add_le_add (norm_add_le _ _) le_rfl) + _ ≤ (kappa a t 5 * Real.sqrt (tensorSq V) + theta * (kappa a t 4 * Real.sqrt (tensorSq V)))+ + (theta ^ 2 + 4 * theta + 1) * (kappa a t 3 * Real.sqrt (tensorSq V)) := + add_le_add (add_le_add h5 (hc4.trans (mul_le_mul_of_nonneg_left h4 htheta))) + (hc3.trans (mul_le_mul_of_nonneg_left h3 hC)) + _ = _ := by ring + + + +/-- The three tensor-slice matrices used in the modal joint-signature bound. -/ +def krylovCore (a t : Fin n → ℝ) (V : Tensor n) (theta : ℝ) : + Fin 3 → Matrix (Fin n) (Fin n) ℝ := + ![tensorSlice V (fun i => a i * t i ^ 3), + (fun j k => tensorSlice V (fun i => a i * t i ^ 4) j k + + (theta-t j-t k) * tensorSlice V (fun i => a i * t i ^ 3) j k), + (fun j k => tensorSlice V (fun i => a i * t i ^ 5) j k + + (theta-t j-t k) * tensorSlice V (fun i => a i * t i ^ 4) j k - + (theta ^ 2 + 2 * theta * (t j + t k) + (t j-t k) ^ 2)* + tensorSlice V (fun i => a i * t i ^ 3) j k)] + +theorem krylov_core_norm_bound (a t : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a t V) (theta : ℝ) (ht : 1 < theta) + (hlo : ∀ i, 0 ≤ t i) (hhi : ∀ i, t i ≤ 1) (r : Fin 3) : + ‖matrixVector (krylovCore a t V theta r)‖ ≤ + jointNumerator a t theta r * Real.sqrt (tensorSq V) := by + fin_cases r + · exact power_slice_norm_bound a t V hm 3 + · exact joint_one_norm_bound a t V hm theta ht hlo hhi + · exact joint_two_norm_bound a t V hm theta ht hlo hhi + +theorem jointNumerator_nonneg (a t : Fin n → ℝ) (theta : ℝ) (ht : 0 ≤ theta) (r : Fin 3) : + 0 ≤ jointNumerator a t theta r := by + have h3 := kappa_nonneg a t 3 + have h4 := kappa_nonneg a t 4 + have h5 := kappa_nonneg a t 5 + fin_cases r + · exact h3 + · exact add_nonneg h4 (mul_nonneg ht h3) + · exact add_nonneg (add_nonneg h5 (mul_nonneg ht h4)) + (mul_nonneg (by positivity) h3) + +theorem krylov_slice_core (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (ell w : ℝ) (hw : w ≠ 0) (r : Fin 3) : + tensorSlice (xiWeighted rates V) (krylovModal a rates ell w r.val) = + fun j k => w ^ 3 * krylovCore a (fun i => (rates i-ell) / w) V (ell / w) r j k := by + fin_cases r + · have ha : krylovModal a rates ell w 0 = a := by funext i; simp [krylovModal] + rw [ha, cubic_cancellation a rates V hm ell w hw] + rfl + · exact krylov_slice_one a rates V hm ell w hw + · exact krylov_slice_two a rates V hm ell w hw + +theorem krylov_slice_scaled_bound (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (ell u : ℝ) (hw : ell < u) + (hband : u < 2 * ell) (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) (r : Fin 3) : + matrixSq (tensorSlice (xiWeighted rates V) (krylovModal a rates ell (u-ell) r.val)) ≤ + (u-ell) ^ 6 * jointNumerator a (fun i => (rates i-ell) / (u-ell)) (ell / (u-ell)) r ^ 2 * + tensorSq V := by + have ht : 1 < ell / (u-ell) := (one_lt_div (sub_pos.mpr hw)).mpr (by linarith) + have hnorm := krylov_core_norm_bound a (fun i => (rates i-ell) / (u-ell)) V + (shifted_weighted_moments a rates V hm ell (u-ell)) (ell / (u-ell)) ht + (fun i => (band_coordinate rates ell u hw hlo hhi i).1) + (fun i => (band_coordinate rates ell u hw hlo hhi i).2) r + have hn := jointNumerator_nonneg a (fun i => (rates i - ell) / (u - ell)) + (ell / (u - ell)) (by linarith) r + have hs := (sq_le_sq₀ (norm_nonneg _) (mul_nonneg hn (Real.sqrt_nonneg _))).mpr hnorm + rw [matrixVector_energy, mul_pow, Real.sq_sqrt (tensorSq_nonneg V)] at hs + rw [krylov_slice_core a rates V hm ell (u-ell) (ne_of_gt (sub_pos.mpr hw)), matrixSq_scale] + calc + _ ≤ ((u-ell) ^ 3) ^ 2 * + (jointNumerator a (fun i => (rates i-ell) / (u-ell)) (ell / (u-ell)) r ^ 2 * tensorSq V) := + mul_le_mul_of_nonneg_left hs (sq_nonneg _) + _ = _ := by ring + +/-- Cancel the positive spectral width without strengthening the source beta. -/ +theorem scaled_gap_transfer (w d c ev ee m : ℝ) (_hw : 0 < w) (hd : 0 < d) + (hm : m ≤ w ^ 6 * c ^ 2 * ev) (he : (w * d) ^ 6 * ev ≤ ee) : + m ≤ (c / d ^ 3) ^ 2 * ee := by + have h1 := mul_le_mul_of_nonneg_left hm (le_of_lt (pow_pos hd 6)) + have h2 := mul_le_mul_of_nonneg_left he (sq_nonneg c) + have hh : d ^ 6 * m ≤ c ^ 2 * ee := by + calc + _ ≤ d ^ 6 * (w ^ 6 * c ^ 2 * ev) := h1 + _ = c ^ 2 * ((w * d) ^ 6 * ev) := by ring + _ ≤ _ := h2 + have hh' : m ≤ c ^ 2 * ee / d ^ 6 := (le_div_iff₀ (pow_pos hd 6)).mpr (by nlinarith only [hh]) + convert hh' using 1; field_simp [ne_of_gt hd] + +/-- Each literal beta_r controls its own actual quadratic-Krylov slice. -/ +theorem krylov_slice_beta_bound (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (ell u : ℝ) (hw : ell < u) + (hband : u < 2 * ell) (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) (r : Fin 3) : + matrixSq (tensorSlice (xiWeighted rates V) (krylovModal a rates ell (u-ell) r.val)) ≤ + jointBeta a (fun i => (rates i-ell) / (u-ell)) (ell / (u-ell)) r ^ 2 * + tensorSq (xiWeighted rates V) := by + have ht : 1 < ell / (u-ell) := (one_lt_div (sub_pos.mpr hw)).mpr (by linarith) + have hg : (u-ell) * (ell / (u-ell)-1) = 2 * ell-u := by + field_simp [ne_of_gt (sub_pos.mpr hw)]; ring + have he := spectral_tensor_bound rates V ell u hband hlo hhi + rw [← hg] at he + exact scaled_gap_transfer (u-ell) (ell / (u-ell)-1) _ _ _ _ + (sub_pos.mpr hw) (sub_pos.mpr ht) + (krylov_slice_scaled_bound a rates V hm ell u hw hband hlo hhi r) he + + + +/-- Joint physical rigidity transported through the very same actual frame. -/ +theorem calibrated_modal_joint_rigidity + (U Q : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hU : U.transpose * U = 1) (hQ : Q.transpose * Q = 1) + (hunit : ∀ i, ∑ v, Q i v = 1) (E : Tensor n) (a rates : Fin n → ℝ) + (ell w : ℝ) (hPhysical : physicalDifference Q = rotateTensor U (groundZero E)) + (delta : ℝ) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ signatureSq + (fun r : Fin 3 => U.mulVec (residualVector (krylovModal a rates ell w r.val))) j k) : + delta ^ 2 * tensorSq E ≤ ((n + 1 : ℕ) + 2 : ℝ)* + ∑ r : Fin 3, matrixSq (tensorSlice E (krylovModal a rates ell w r.val)) := by + have hh := physical_slice_rigidity Q hQ hunit + (fun r : Fin 3 => U.mulVec (residualVector (krylovModal a rates ell w r.val))) delta hsep + rw [hPhysical, tensorSq_rotateTensor U hU, tensorSq_groundZero] at hh + simp only [sliceSq, matrixSq_slice_rotateTensor U hU, matrixSq_slice_groundZero, + Fintype.card_fin] at hh + exact hh + +/-- Actual H2 null data provides all three literal source beta bounds. -/ +theorem actual_H2_joint_contraction (a rates : Fin n → ℝ) + (ha : ∀ i, a i ≠ 0) (hRates : Function.Injective rates) + (E : Tensor n) (hSym : FullSymTensor E) + (hData : NullRegular rates (weightedTensor a E)) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) : + (∑ r : Fin 3, matrixSq (tensorSlice E (krylovModal a rates ell (u-ell) r.val))) ≤ + jointBetaSq a (fun i => (rates i-ell) / (u-ell)) (ell / (u-ell)) * tensorSq E := by + obtain ⟨R,hR,hAdm,hE,hm,_⟩ := + actual_H2_physical_kernel a rates ha hRates E hSym hData ell (u-ell) + rw [hE] + unfold jointBetaSq + rw [Finset.sum_mul] + apply Finset.sum_le_sum + intro r hr + exact krylov_slice_beta_bound a rates _ hm ell u hw hband hlo hhi r + +/-- Source squared q_H<1 kills the actual calibrated physical secant. -/ +theorem calibrated_joint_H2_kernel_zero + (a rates : Fin n → ℝ) (ha : ∀ i, a i ≠ 0) (hRates : Function.Injective rates) + (E : Tensor n) (hSym : FullSymTensor E) + (hData : NullRegular rates (weightedTensor a E)) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) + (U Q : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hU : U.transpose * U = 1) (hQ : Q.transpose * Q = 1) + (hunit : ∀ i, ∑ v, Q i v = 1) + (hPhysical : physicalDifference Q = rotateTensor U (groundZero E)) + (delta : ℝ) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ signatureSq + (fun r : Fin 3 => U.mulVec (residualVector (krylovModal a rates ell (u-ell) r.val))) j k) + (hq : ((n + 1 : ℕ) + 2 : ℝ) * jointBetaSq a + (fun i => (rates i-ell) / (u-ell)) (ell / (u-ell)) < delta ^ 2) : E = 0 := by + have hc := actual_H2_joint_contraction a rates ha hRates E hSym hData ell u hw hband hlo hhi + have hr := calibrated_modal_joint_rigidity U Q hU hQ hunit E a rates ell (u-ell) hPhysical delta + hsep + have hN : (0 : ℝ) ≤ ((n + 1 : ℕ) + 2 : ℝ) := by positivity + have hh := hr.trans (mul_le_mul_of_nonneg_left hc hN) + have hcombined : delta ^ 2 * tensorSq E ≤ (((n + 1 : ℕ) + 2 : ℝ) * jointBetaSq a + (fun i => (rates i-ell) / (u-ell)) (ell / (u-ell))) * tensorSq E := by + simpa only [mul_assoc] using hh + apply tensorSq_zero E + apply le_antisymm _ (tensorSq_nonneg E) + by_contra h + have hp : 0 < tensorSq E := lt_of_not_ge h + exact (not_lt_of_ge hcombined) (mul_lt_mul_of_pos_right hq hp) + +theorem actual_calibrated_H2_joint_cubic_equality + (μ : ℝ) (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (b : Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (ha : ∀ i, C145.Pulse.modalOverlap U b i ≠ 0) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) + (hH : SamePositive (fullRates μ rates) + (C145PhysicalFrame.T U (C145.Pulse.modalOverlap U b)) + (C145PhysicalFrame.T V (C145.Pulse.modalOverlap U b))) + (A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hEig : ∀ i, A.mulVec (fun v => U v i) = (-fullRates μ rates i) • (fun v => U v i)) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) + (delta : ℝ) (_hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ signatureSq (physicalKrylov A b ell (u - ell)) j k) + (hq : ((n + 1 : ℕ) + 2 : ℝ) * jointBetaSq + (fun i : Fin n => C145.Pulse.modalOverlap U b i.succ) + (fun i => (rates i-ell) / (u-ell)) (ell / (u-ell)) < delta ^ 2) : + C145PhysicalFrame.C U = C145PhysicalFrame.C V := by + let a : Fin (n + 1) → ℝ := C145.Pulse.modalOverlap U b + let ar : Fin n → ℝ := fun i => a i.succ + let C0 : Tensor n := residual (C145PhysicalFrame.C U) + let C1 : Tensor n := residual (C145PhysicalFrame.C V) + let Q : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ := Matrix.of U * (Matrix.of V).transpose + have hCG := actual_cubic_common_ground U V c hU hV hGU hGV + have hDiff : C145PhysicalFrame.C V-C145PhysicalFrame.C U = groundZero (C1-C0) := + commonGround_difference _ _ hCG + have hPhys : physicalDifference Q = rotateTensor (Matrix.of U) (groundZero (C1-C0)) := by + rw [← hDiff] + exact actual_frame_physical_difference U V hU + have hQ : Q.transpose * Q = 1 := by + have h := columnOrthonormal_matrix (C145CoordinatePermutation.transport V U) + (C145CoordinatePermutation.transport_columnOrthonormal V U hV hU) + rw [C145CoordinatePermutation.transport_eq_matrix_mul_transpose] at h + exact h + have hunit : ∀ i, ∑ v, Q i v = 1 := actual_frame_common_unit U V c hU hV hGU hGV + have hData := actual_weighted_residual_data μ rates U V a c hU hV hGU hGV hH + have hSig (r : Fin 3) : physicalKrylov A b ell (u-ell) r = + (Matrix.of U).mulVec (residualVector (krylovModal ar rates ell (u-ell) r.val)) := + physicalKrylov_modal A U (fullRates μ rates) b c hU hGU hEig ell (u-ell) r + have hSep : ∀ j k, j ≠ k → delta ^ 2 ≤ signatureSq + (fun r : Fin 3 => (Matrix.of U).mulVec + (residualVector (krylovModal ar rates ell (u-ell) r.val))) j k := by + intro j k hjk + simpa only [signatureSq, hSig] using hsep j k hjk + have hPos : ∀ i, 0 < rates i := by + intro i + have hell : 0 < ell := by linarith + exact hell.trans_le (hlo i) + have hz : C1-C0 = 0 := calibrated_joint_H2_kernel_zero ar rates (fun i => ha i.succ) hRates + (C1-C0) (fullSymTensor_sub C1 C0 + (residual_fullSym _ (actual_cubic_fullSym V)) + (residual_fullSym _ (actual_cubic_fullSym U))) + (samePositive_weighted_difference ar rates hPos C0 C1 hData) + ell u hw hband hlo hhi (Matrix.of U) Q (columnOrthonormal_matrix U hU) + hQ hunit hPhys delta hSep + hq + have hzero : groundZero (0 : Tensor n) = 0 := by + funext i j k + refine Fin.cases ?_ (fun x => ?_) i + · rfl + · refine Fin.cases ?_ (fun y => ?_) j + · rfl + · refine Fin.cases ?_ (fun z => ?_) k <;> rfl + rw [hz,hzero] at hDiff + exact (sub_eq_zero.mp hDiff).symm + +/-- The vertex bijection is derived by the existing primitive coordinate +idempotent theorem; it is not a supplied reconstruction certificate. -/ +theorem actual_calibrated_H2_joint_vertex_identification + (μ : ℝ) (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (b : Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (ha : ∀ i, C145.Pulse.modalOverlap U b i ≠ 0) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) + (hH : SamePositive (fullRates μ rates) + (C145PhysicalFrame.T U (C145.Pulse.modalOverlap U b)) + (C145PhysicalFrame.T V (C145.Pulse.modalOverlap U b))) + (A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hEig : ∀ i, A.mulVec (fun v => U v i) = (-fullRates μ rates i) • (fun v => U v i)) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ signatureSq (physicalKrylov A b ell (u - ell)) j k) + (hq : ((n + 1 : ℕ) + 2 : ℝ) * jointBetaSq + (fun i : Fin n => C145.Pulse.modalOverlap U b i.succ) + (fun i => (rates i-ell) / (u-ell)) (ell / (u-ell)) < delta ^ 2) : + ∃ π : Equiv.Perm (Fin (n + 1)), + (∀ w v, C145CoordinatePermutation.transport U V w v = if w = π v then 1 else 0) ∧ + (∀ v i, V (π v) i = U v i) := by + exact C145CoordinatePermutation.cubic_equality_vertex_permutation U V hU hV + (actual_calibrated_H2_joint_cubic_equality μ rates hRates U V b c hU hV ha hGU hGV hH + A hEig ell u hw hband hlo hhi delta hd hsep hq) + + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8JointTransferInverse.lean b/LeanPool/C145/C145DRE8JointTransferInverse.lean new file mode 100644 index 0000000000..3afa1b88d8 --- /dev/null +++ b/LeanPool/C145/C145DRE8JointTransferInverse.lean @@ -0,0 +1,217 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8JointSignatureInverse +public import LeanPool.C145.C145DRE8SignedGroundResidue + +/-! Source Theorem C from own H1/H2 alone and the literal three-signature criterion. H1 derives +the unknown size, +mode matching and positive overlaps; the fixed-positive-variable cleared +numerator argument derives the signed common ground from H2. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.UncalibratedSmallH2 + +/-- The displayed source q_H<1 and the exact squared strict inequality used +by the inverse theorem are equivalent; beta is the literal joint norm. -/ +theorem joint_qH_lt_one_iff_sq {k : ℕ} (N : ℕ) + (a t : Fin k → ℝ) (theta delta : ℝ) (hd : 0 < delta) : + Real.sqrt ((N:ℝ) + 2) * jointBetaNorm a t theta / delta < 1 ↔ + ((N:ℝ) + 2) * jointBetaSq a t theta < delta ^ 2 := by + have hBeta : 0 ≤ jointBetaSq a t theta := + Finset.sum_nonneg (fun r _ => sq_nonneg (jointBeta a t theta r)) + have hN : 0 ≤ (N:ℝ) + 2 := by positivity + have hprod : 0 ≤ Real.sqrt ((N:ℝ) + 2) * jointBetaNorm a t theta := + mul_nonneg (Real.sqrt_nonneg _) (Real.sqrt_nonneg _) + rw [div_lt_iff₀ hd, one_mul] + have hs : (Real.sqrt ((N:ℝ) + 2) * jointBetaNorm a t theta) ^ 2 = + ((N:ℝ) + 2) * jointBetaSq a t theta := by + rw [mul_pow, Real.sq_sqrt hN, jointBetaNorm, Real.sq_sqrt hBeta] + rw [← hs] + exact (sq_lt_sq₀ hprod hd.le).symm + + +theorem actual_H1_H2_theoremC_vertex_identification {m n : ℕ} + (μ c0 c1 : ℝ) (hμ : 0 < μ) + (Q0 : Fin (m + 1) → Fin (m + 1) → ℝ) + (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates0 b0 : Fin (m + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround0 : ∀ v, Q0 v 0 = c0) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hRateGround0 : rates0 0 = μ) + (hRateGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < C145.Pulse.modalOverlap Q0 b0 i) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (A : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (hEig : ∀ i, A.mulVec (fun v => Q0 v i) = + (-rates0 i) • (fun v => Q0 v i)) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i : Fin m, ell ≤ rates0 i.succ) (hhi : ∀ i : Fin m, rates0 i.succ ≤ u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → + delta ^ 2 ≤ signatureSq (physicalKrylov A b0 ell (u-ell)) j k) + (hq : ((m + 1 : ℕ) + 2 : ℝ) * + jointBetaSq (fun i : Fin m => C145.Pulse.modalOverlap Q0 b0 i.succ) + (fun i => (rates0 i.succ-ell) / (u-ell)) (ell / (u-ell)) < delta ^ 2) + (hH1 : ∀ s : ℝ, 0 < s → + C145.H1.firstTransfer rates0 (C145.Pulse.modalOverlap Q0 b0) s = + C145.H1.firstTransfer rates1 (C145.Pulse.modalOverlap Q1 b1) s) + (hH2 : ∀ s t : ℝ, 0 < s → 0 < t → + C145.H2.H rates0 + (C145PhysicalFrame.T Q0 (C145.Pulse.modalOverlap Q0 b0)) s t = + C145.H2.H rates1 + (C145PhysicalFrame.T Q1 (C145.Pulse.modalOverlap Q1 b1)) s t) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap Q0 b0 i) ∧ + c0 = c1 ∧ (∑ v, b0 v) = (∑ w, b1 w) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u) ∧ + (∀ v : Fin (m + 1), b1 (π v) = b0 v) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u) := by + classical + let a0 : Fin (m + 1) → ℝ := C145.Pulse.modalOverlap Q0 b0 + let a1 : Fin (n + 1) → ℝ := C145.Pulse.modalOverlap Q1 b1 + obtain ⟨e, hSize, heGround, heRates, heOverlaps⟩ := + C145.H1.known_ground_positive_modal_identification μ hμ rates0 a0 rates1 a1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 ha0 ha1 hH1 + -- Size equality is a data-derived fact; the modal map is retained. + subst n + let Q1e : Fin (m + 1) → Fin (m + 1) → ℝ := columnReindex Q1 e + let r0 : Fin m → ℝ := fun i => rates0 i.succ + have hQ1e : C145PhysicalFrame.ColumnOrthonormal Q1e := + columnReindex_columnOrthonormal Q1 e hQ1 + have hG1ePre : ∀ v, Q1e v 0 = c1 := by + intro v + change Q1 v (e 0) = c1 + rw [heGround,hGround1] + have hResidualRates : Function.Injective r0 := by + intro i j hij + apply Fin.succ_inj.mp + apply hRates0 + exact hij + have hResidualPos : ∀ i : Fin m, 0 < r0 i := by + intro i + exact lt_trans hμ (hAbove0 i) + have hFull : C145.H2.fullRates μ r0 = rates0 := + fullRates_eq_own μ rates0 hRateGround0 + have hA : (fun i => a1 (e i)) = a0 := funext heOverlaps + have hLam : (fun i => rates1 (e i)) = rates0 := funext heRates + have hT : C145PhysicalFrame.T Q1e a0 = + (fun i j k => C145PhysicalFrame.T Q1 a1 (e i) (e j) (e k)) := by + funext i j k + simpa only [Q1e, hA] using tensor_columnReindex Q1 a1 e i j k + have hAlignedResponse : ∀ s t : ℝ, + C145.H2.H rates0 (C145PhysicalFrame.T Q1e a0) s t = + C145.H2.H rates1 (C145PhysicalFrame.T Q1 a1) s t := by + intro s t + have h := H_modal_reindex rates1 (C145PhysicalFrame.T Q1 a1) e s t + rw [hLam, ← hT] at h + exact h + have hHAligned : C145.H2.SamePositive (C145.H2.fullRates μ r0) + (C145PhysicalFrame.T Q0 a0) (C145PhysicalFrame.T Q1e a0) := by + intro s t hs ht + rw [hFull] + exact (hH2 s t hs ht).trans (hAlignedResponse s t).symm + have hPos0 : ∀ i, 0 < rates0 i := by + intro i + rcases Fin.eq_zero_or_eq_succ i with hi | ⟨j,hj⟩ + · rw [hi,hRateGround0]; exact hμ + · rw [hj]; exact hμ.trans (hAbove0 j) + have hHOwn : C145.H2.SamePositive rates0 + (C145PhysicalFrame.T Q0 a0) (C145PhysicalFrame.T Q1e a0) := by + rw [← hFull] + exact hHAligned + have hConstant : c0 = c1 := signed_ground_from_actual_H2 μ hμ rates0 hRates0 hPos0 + hRateGround0 Q0 Q1e a0 c0 c1 hQ0 hQ1e hGround0 hG1ePre ha0 hHOwn + have hG1e : ∀ v, Q1e v 0 = c0 := by + intro v + rw [hG1ePre,← hConstant] + -- This derives the arbitrary-dimension vertex map from actual full H2. + obtain ⟨π, hDeltaRaw, hRowsRaw⟩ := + actual_calibrated_H2_joint_vertex_identification μ r0 hResidualRates Q0 Q1e b0 c0 + hQ0 hQ1e (fun i => ne_of_gt (ha0 i)) hGround0 hG1e hHAligned + A (fun i => by simpa only [hFull] using hEig i) + ell u hw hband hlo hhi delta hd hsep hq + have hDelta : ∀ (w v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0 := by + intro w v + exact hDeltaRaw w v + have hRows : ∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i := by + intro v i + exact hRowsRaw v i + have hGenerator : ∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u := by + intro v u + unfold C145CoordinatePermutation.spectralGenerator + congr 1 + calc + (∑ j, rates1 j * Q1 (π v) j * Q1 (π u) j) = + ∑ i, rates1 (e i) * Q1 (π v) (e i) * Q1 (π u) (e i) := + (e.sum_comp (fun j => rates1 j * Q1 (π v) j * Q1 (π u) j)).symm + _ = ∑ i, rates0 i * Q0 v i * Q0 u i := by + apply Finset.sum_congr rfl + intro i hi + rw [heRates i, hRows v i, hRows u i] + have hPort : ∀ v : Fin (m + 1), b1 (π v) = b0 v := by + intro v + have hReconstruct1 := congrFun (spectralPort_modalOverlap Q1 b1 hQ1) (π v) + have hReconstruct0 := congrFun (spectralPort_modalOverlap Q0 b0 hQ0) v + change (∑ j, a1 j * Q1 (π v) j) = b1 (π v) at hReconstruct1 + change (∑ i, a0 i * Q0 v i) = b0 v at hReconstruct0 + calc + b1 (π v) = ∑ j, a1 j * Q1 (π v) j := hReconstruct1.symm + _ = ∑ i, a1 (e i) * Q1 (π v) (e i) := + (e.sum_comp (fun j => a1 j * Q1 (π v) j)).symm + _ = ∑ i, a0 i * Q0 v i := by + apply Finset.sum_congr rfl + intro i hi + rw [heOverlaps i, hRows v i] + _ = b0 v := hReconstruct0 + have hMeans : (∑ v,b0 v) = (∑ v,b1 v) := by + calc + _ = ∑ v,b1 (π v) := by + apply Finset.sum_congr rfl; intro v hv; exact (hPort v).symm + _ = _ := Equiv.sum_comp π b1 + have hL : ∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u := by + intro v u + simp only [C145CoordinatePermutation.decayLaplacian, hGenerator, + π.apply_eq_iff_eq] + exact ⟨e, rfl, heGround, heRates, heOverlaps, hConstant, hMeans, + π, hDelta, hRows, hGenerator, hPort, hL⟩ + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8KrylovSlices.lean b/LeanPool/C145/C145DRE8KrylovSlices.lean new file mode 100644 index 0000000000..2ee58e7dd6 --- /dev/null +++ b/LeanPool/C145/C145DRE8KrylovSlices.lean @@ -0,0 +1,195 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8ActualFrame + +/-! Actual quadratic-Krylov slice identities for source Theorem C. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 C145.ThreePlane +variable {n : ℕ} + +/-- The overlap vector weighted by a normalized spectral power. -/ +def krylovModal (a rates : Fin n → ℝ) (ell w : ℝ) (r : ℕ) : Fin n → ℝ := + fun i => a i * ((rates i-ell) / w) ^ r + +/-- The index-dependent constant term in the cubic cancellation polynomial. -/ +def xiConstant (theta y z : ℝ) : ℝ := + theta ^ 3-((theta + y) + (theta + z)) * theta ^ 2-(y-z) ^ 2 * theta + + (theta + y) ^ 3 + (theta + z) ^ 3-(theta + y) ^ 2 * (theta + z)-(theta + z) ^ 2 * (theta + y) + +theorem xi_band_expansion (x y z ell w : ℝ) (hw : w ≠ 0) : + MvPolynomial.eval ![-z,-x,-y] Xi = w ^ 3 * + (((x-ell) / w) ^ 3 + (ell / w-(y-ell) / w-(z-ell) / w) * ((x-ell) / w) ^ 2 - + ((ell / w) ^ 2 + 2 * (ell / w) * ((y-ell) / w + (z-ell) / w)+ + ((y-ell) / w-(z-ell) / w) ^ 2) * ((x-ell) / w) + + xiConstant (ell / w) ((y-ell) / w) ((z-ell) / w)) := by + rw [xi_cubic_first] + unfold xiConstant + field_simp; ring + +/-- The h1 slice is the literal fourth moment plus its variable cubic coefficient. -/ +theorem krylov_slice_one (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (ell w : ℝ) (hw : w ≠ 0) : + tensorSlice (xiWeighted rates V) (krylovModal a rates ell w 1) = + fun j k => w ^ 3 * (tensorSlice V (krylovModal a rates ell w 4) j k + + (ell / w-(rates j-ell) / w-(rates k-ell) / w)* + tensorSlice V (krylovModal a rates ell w 3) j k) := by + classical + funext j k + have ht := shifted_weighted_moments a rates V hm ell w + have h1 := ht.1 1 (by omega) j k + have h2 := ht.1 2 (by omega) j k + calc + _ = w ^ 3 * (tensorSlice V (krylovModal a rates ell w 4) j k + + (ell / w-(rates j-ell) / w-(rates k-ell) / w)* + tensorSlice V (krylovModal a rates ell w 3) j k - + ((ell / w) ^ 2 + 2 * (ell / w) * ((rates j-ell) / w + (rates k-ell) / w)+ + ((rates j-ell) / w-(rates k-ell) / w) ^ 2)* + (∑ i, (a i * ((rates i-ell) / w) ^ 2) * V i j k) + + xiConstant (ell / w) ((rates j-ell) / w) ((rates k-ell) / w)* + (∑ i, (a i * ((rates i-ell) / w) ^ 1) * V i j k)) := by + simp only [tensorSlice, xiWeighted, krylovModal, Finset.mul_sum, + ← Finset.sum_add_distrib, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro i hi + rw [xi_band_expansion _ _ _ ell w hw] + ring + _ = _ := by rw [h1,h2]; ring + +/-- The h2 slice retains the exact fifth, fourth and cubic moment terms. -/ +theorem krylov_slice_two (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (ell w : ℝ) (hw : w ≠ 0) : + tensorSlice (xiWeighted rates V) (krylovModal a rates ell w 2) = + fun j k => w ^ 3 * (tensorSlice V (krylovModal a rates ell w 5) j k + + (ell / w-(rates j-ell) / w-(rates k-ell) / w)* + tensorSlice V (krylovModal a rates ell w 4) j k - + ((ell / w) ^ 2 + 2 * (ell / w) * ((rates j-ell) / w + (rates k-ell) / w)+ + ((rates j-ell) / w-(rates k-ell) / w) ^ 2)* + tensorSlice V (krylovModal a rates ell w 3) j k) := by + classical + funext j k + have ht := shifted_weighted_moments a rates V hm ell w + have h2 := ht.1 2 (by omega) j k + calc + _ = w ^ 3 * (tensorSlice V (krylovModal a rates ell w 5) j k + + (ell / w-(rates j-ell) / w-(rates k-ell) / w)* + tensorSlice V (krylovModal a rates ell w 4) j k - + ((ell / w) ^ 2 + 2 * (ell / w) * ((rates j-ell) / w + (rates k-ell) / w)+ + ((rates j-ell) / w-(rates k-ell) / w) ^ 2)* + tensorSlice V (krylovModal a rates ell w 3) j k + + xiConstant (ell / w) ((rates j-ell) / w) ((rates k-ell) / w)* + (∑ i, (a i * ((rates i-ell) / w) ^ 2) * V i j k)) := by + simp only [tensorSlice, xiWeighted, krylovModal, Finset.mul_sum, + ← Finset.sum_add_distrib, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro i hi + rw [xi_band_expansion _ _ _ ell w hw] + ring + _ = _ := by rw [h2]; ring + +end C145DRE8 + +namespace C145DRE8 +open scoped BigOperators +open C145.H2 +variable {n : ℕ} + +/-- B=-A is the full decay matrix, including the known decay mu. -/ +def shiftedDecayAction (A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (ell w : ℝ) (x : Fin (n + 1) → ℝ) : Fin (n + 1) → ℝ := + fun v => (-(A.mulVec x) v-ell * x v) / w + +/-- Literal source h0,h1,h2. No spectral certificate is part of this definition. -/ +def physicalKrylov (A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (b : Fin (n + 1) → ℝ) (ell w : ℝ) : Fin 3 → Fin (n + 1) → ℝ := + ![centeredPort b, shiftedDecayAction A ell w (centeredPort b), + shiftedDecayAction A ell w (shiftedDecayAction A ell w (centeredPort b))] + +theorem eigenframe_mulVec (A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (U : Fin (n + 1) → Fin (n + 1) → ℝ) (rates x : Fin (n + 1) → ℝ) + (hEig : ∀ i, A.mulVec (fun v => U v i) = (-rates i) • (fun v => U v i)) : + A.mulVec ((Matrix.of U).mulVec x) = + (Matrix.of U).mulVec (fun i => -rates i * x i) := by + classical + funext v + simp only [Matrix.mulVec, dotProduct, Matrix.of_apply, Finset.mul_sum] + rw [Finset.sum_comm] + calc + _ = ∑ i, x i * (∑ u, A v u * U u i) := by + apply Finset.sum_congr rfl; intro i hi + rw [Finset.mul_sum] + apply Finset.sum_congr rfl; intro u hu; ring + _ = _ := by + apply Finset.sum_congr rfl; intro i hi + have h := congrFun (hEig i) v + change (∑ u, A v u * U u i) = (-rates i) * U v i at h + rw [h]; ring + +theorem shiftedDecayAction_eigenframe + (A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (U : Fin (n + 1) → Fin (n + 1) → ℝ) (rates x : Fin (n + 1) → ℝ) + (hEig : ∀ i, A.mulVec (fun v => U v i) = (-rates i) • (fun v => U v i)) + (ell w : ℝ) : + shiftedDecayAction A ell w ((Matrix.of U).mulVec x) = + (Matrix.of U).mulVec (fun i => x i * ((rates i-ell) / w)) := by + unfold shiftedDecayAction + rw [eigenframe_mulVec A U rates x hEig] + funext v + simp only [Matrix.mulVec, dotProduct, Matrix.of_apply, + ← Finset.sum_neg_distrib, Finset.mul_sum, ← Finset.sum_sub_distrib, Finset.sum_div] + apply Finset.sum_congr rfl; intro i hi; ring + +/-- Physical powers of (B-ell I)/w are the actual modal weighted powers. +The ground coordinate remains zero because the port was centered. -/ +theorem physicalKrylov_modal + (A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (U : Fin (n + 1) → Fin (n + 1) → ℝ) (rates b : Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) (hG : ∀ v, U v 0 = c) + (hEig : ∀ i, A.mulVec (fun v => U v i) = (-rates i) • (fun v => U v i)) + (ell w : ℝ) (r : Fin 3) : + physicalKrylov A b ell w r = + (Matrix.of U).mulVec (residualVector (krylovModal + (fun i : Fin n => C145.Pulse.modalOverlap U b i.succ) + (fun i : Fin n => rates i.succ) ell w r.val)) := by + let a : Fin n → ℝ := fun i => C145.Pulse.modalOverlap U b i.succ + have h0 := actual_residual_signature U b c hU hG + have hstep (p : ℕ) : + shiftedDecayAction A ell w ((Matrix.of U).mulVec (residualVector + (krylovModal a (fun i : Fin n => rates i.succ) ell w p))) = + (Matrix.of U).mulVec (residualVector + (krylovModal a (fun i : Fin n => rates i.succ) ell w (p + 1))) := by + rw [shiftedDecayAction_eigenframe A U rates _ hEig] + congr 1 + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp [residualVector] + · simp only [residualVector, Fin.cases_succ, krylovModal, pow_succ] + ring + have h0' : centeredPort b = (Matrix.of U).mulVec (residualVector + (krylovModal a (fun i : Fin n => rates i.succ) ell w 0)) := by + have hk : krylovModal a (fun i : Fin n => rates i.succ) ell w 0 = a := by + funext i; simp [krylovModal] + rw [hk] + exact h0.symm + fin_cases r + · exact h0' + · change shiftedDecayAction A ell w (centeredPort b) = _ + rw [h0', hstep 0] + · change shiftedDecayAction A ell w (shiftedDecayAction A ell w (centeredPort b)) = _ + rw [h0', hstep 0, hstep 1] + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8OptimalContraction.lean b/LeanPool/C145/C145DRE8OptimalContraction.lean new file mode 100644 index 0000000000..67984b6e9a --- /dev/null +++ b/LeanPool/C145/C145DRE8OptimalContraction.lean @@ -0,0 +1,131 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8ProjectionResiduals +public import LeanPool.C145.C145DRE8SpectralContraction + +/-! True orthogonal projection residuals joined to the DRE8 raw-kernel +contraction. The finite index set is the nonground modal set of the source. +The p=3,4,5 interfaces support all three quadratic-Krylov slices. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 C145.ThreePlane +variable {n : ℕ} + +/-- The three annihilated moments remove any quadratic from every power slice. -/ +theorem power_quadratic_residual_slice (a t : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a t V) (p : ℕ) (c0 c1 c2 : ℝ) : + tensorSlice V (fun i => a i * t i ^ p) = + tensorSlice V (fun i => a i * (t i ^ p-(c0 + c1 * t i + c2 * t i ^ 2))) := by + classical + funext j k + have h0 := hm.1 0 (by omega) j k + have h1 := hm.1 1 (by omega) j k + have h2 := hm.1 2 (by omega) j k + calc + _ = tensorSlice V (fun i => a i * t i ^ p) j k - + c0 * (∑ i, (a i * t i ^ 0) * V i j k) - + c1 * (∑ i, (a i * t i ^ 1) * V i j k) - + c2 * (∑ i, (a i * t i ^ 2) * V i j k) := by rw [h0,h1,h2]; ring + _ = _ := by + simp only [tensorSlice, Finset.mul_sum, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro i hi + ring + +/-- Literal source moment slice equals the actual optimal projection residual slice. -/ +theorem power_projection_residual_slice (a t : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a t V) (p : ℕ) : + tensorSlice V (fun i => a i * t i ^ p) = + tensorSlice V (fun i => projectionResidual a t p i) := by + obtain ⟨c0,c1,c2,hc⟩ := exists_projection_residual_coefficients a t p + rw [power_quadratic_residual_slice a t V hm p c0 c1 c2] + congr 1 + funext i + exact (hc i).symm + +/-- Cauchy--Schwarz in actual finite-coordinate norms, with true κ_p. -/ +theorem projection_residual_slice_cauchy (a t : Fin n → ℝ) (V : Tensor n) (p : ℕ) : + matrixSq (tensorSlice V (fun i => projectionResidual a t p i)) ≤ + kappa a t p ^ 2 * tensorSq V := by + rw [kappa_sq_eq_sum] + exact tensorSlice_cauchy V _ + +/-- Source power-slice bound, with no residual/minimizer supplied as a premise. -/ +theorem power_slice_kappa_bound (a t : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a t V) (p : ℕ) : + matrixSq (tensorSlice V (fun i => a i * t i ^ p)) ≤ + kappa a t p ^ 2 * tensorSq V := by + rw [power_projection_residual_slice a t V hm p] + exact projection_residual_slice_cauchy a t V p + +/-- True κ₃ is no larger than the standard monic Chebyshev residual. -/ +theorem kappa_three_chebyshev_sq (a t : Fin n → ℝ) + (ht0 : ∀ i, 0 ≤ t i) (ht1 : ∀ i, t i ≤ 1) : + 1024 * kappa a t 3 ^ 2 ≤ ∑ i, a i ^ 2 := by + have hm := kappa_sq_le_quadratic_residual a t 3 (1 / 32) (-9 / 16) (3 / 2) + have hc := chebyshev_vector_bound a t ht0 ht1 + have heq : (∑ i, (a i * (t i ^ 3-((1 / 32 : ℝ) + (-9 / 16) * t i + (3 / 2) * t i ^ 2))) ^ 2) = + ∑ i, (a i * chebyshevResidual (t i)) ^ 2 := by + apply Finset.sum_congr rfl + intro i hi + dsimp [chebyshevResidual] + ring + rw [heq] at hm + linarith + +/-- Source κ₃ ≤ ‖a‖₂/32 in the true Euclidean norm. -/ +theorem kappa_three_le_norm_div32 (a t : Fin n → ℝ) + (ht0 : ∀ i, 0 ≤ t i) (ht1 : ∀ i, t i ≤ 1) : + kappa a t 3 ≤ ‖momentVector a t 0‖ / 32 := by + have hc := kappa_three_chebyshev_sq a t ht0 ht1 + have heq : ‖momentVector a t 0‖ ^ 2 = ∑ i, a i ^ 2 := by + simpa only [momentVector_apply, pow_zero, mul_one] using + EuclideanSpace.real_norm_sq_eq (momentVector a t 0) + have hs : (32 * kappa a t 3) ^ 2 ≤ ‖momentVector a t 0‖ ^ 2 := by + rw [heq] + nlinarith + have hn : 0 ≤ 32 * kappa a t 3 := mul_nonneg (by norm_num) (kappa_nonneg a t 3) + have hle := (sq_le_sq₀ hn (norm_nonneg (momentVector a t 0))).mp hs + linarith + +/-- Optimal DRE8 (6.4), squared, with actual attained κ₃ rather than an +explicit or hypothesized residual. -/ +theorem kernel_optimal_contraction (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (ell u : ℝ) (hw : ell < u) + (hband : u < 2 * ell) (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) : + (2 * ell-u) ^ 6 * matrixSq (tensorSlice (xiWeighted rates V) a) ≤ + (u-ell) ^ 6 * kappa a (fun i => (rates i-ell) / (u-ell)) 3 ^ 2 * + tensorSq (xiWeighted rates V) := by + obtain ⟨c0,c1,c2,hc⟩ := exists_kappa_coefficients a (fun i => (rates i-ell) / (u-ell)) 3 + have h := kernel_residual_contraction a rates V hm ell u hw hband hlo hhi c0 c1 c2 + rw [hc] at h + exact h + +/-- Actual ordinary H₂ data gives the sharp κ₃ contraction. The weighted +moments, polynomial factor and minimizer are all derived, never premises. -/ +theorem actual_H2_optimal_contraction (a rates : Fin n → ℝ) + (ha : ∀ i, a i ≠ 0) (hRates : Function.Injective rates) + (E : Tensor n) (hSym : FullSymTensor E) + (hData : NullRegular rates (weightedTensor a E)) (ell u : ℝ) (hw : ell < u) + (hband : u < 2 * ell) (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) : + (2 * ell-u) ^ 6 * matrixSq (tensorSlice E a) ≤ + (u-ell) ^ 6 * kappa a (fun i => (rates i-ell) / (u-ell)) 3 ^ 2 * tensorSq E := by + obtain ⟨R,_,_,hE,hm,_⟩ := actual_H2_physical_kernel a rates ha hRates E hSym hData ell (u-ell) + rw [hE] + exact kernel_optimal_contraction a rates _ hm ell u hw hband hlo hhi + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8OriginalGraphInverse.lean b/LeanPool/C145/C145DRE8OriginalGraphInverse.lean new file mode 100644 index 0000000000..cec81c4a8c --- /dev/null +++ b/LeanPool/C145/C145DRE8OriginalGraphInverse.lean @@ -0,0 +1,276 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8TransferInverse + +/-! The original fixed-horizon graph/port inverse under the DRE8 scalar +signature sufficient condition, with unrestricted-size admissible competitors. +Caller actual response and local C2 regularity are retained exactly as in the +accepted small-graph endpoint. The graph result identifies L, generator and +signed b; it does not identify unobservable self-loop weights. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators Topology ContDiff +open MeasureTheory Set C145.DelayKernel +open C145.ActualResponse C145.ObservedKernelRecovery +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +private theorem rates_pos_of_ground {n : ℕ} (μ : ℝ) (hμ : 0 < μ) + (rates : Fin (n + 1) → ℝ) (hGround : rates 0 = μ) + (hAbove : ∀ i : Fin n, μ < rates i.succ) : ∀ i, 0 < rates i := by + intro i + rcases Fin.eq_zero_or_eq_succ i with hi | ⟨j, hj⟩ + · rw [hi, hGround] + exact hμ + · rw [hj] + exact lt_trans hμ (hAbove j) + +theorem actual_time_kernel_theoremA_vertex_identification {m n : ℕ} + (μ c0 c1 : ℝ) (hμ : 0 < μ) + (Q0 : Fin (m + 1) → Fin (m + 1) → ℝ) + (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates0 b0 : Fin (m + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround0 : ∀ v, Q0 v 0 = c0) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hRateGround0 : rates0 0 = μ) + (hRateGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < C145.Pulse.modalOverlap Q0 b0 i) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i : Fin m, ell ≤ rates0 i.succ) (hhi : ∀ i : Fin m, rates0 i.succ ≤ u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ (b0 j-b0 k) ^ 2) + (hq : sourceQChebyshevSq b0 ell u delta < 1) + (hK1 : ∀ r : ℝ, 0 ≤ r → + firstKernel Q0 rates0 b0 r = firstKernel Q1 rates1 b1 r) + (hK2 : ∀ r₁ r₂ : ℝ, 0 ≤ r₁ → 0 ≤ r₂ → + delayKernel Q0 rates0 b0 r₁ r₂ = + delayKernel Q1 rates1 b1 r₁ r₂) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap Q0 b0 i) ∧ + c0 = c1 ∧ (∑ v, b0 v) = (∑ w, b1 w) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u) ∧ + (∀ v : Fin (m + 1), b1 (π v) = b0 v) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u) := by + have hPos0 := rates_pos_of_ground μ hμ rates0 hRateGround0 hAbove0 + have hPos1 := rates_pos_of_ground μ hμ rates1 hRateGround1 hAbove1 + have hH1 : ∀ s : ℝ, 0 < s → + C145.H1.firstTransfer rates0 (C145.Pulse.modalOverlap Q0 b0) s = + C145.H1.firstTransfer rates1 (C145.Pulse.modalOverlap Q1 b1) s := by + intro s hs + rw [← (firstKernel_transform Q0 rates0 b0 hPos0 s hs).2, + ← (firstKernel_transform Q1 rates1 b1 hPos1 s hs).2] + unfold laplace + apply setIntegral_congr_fun measurableSet_Ioi + intro r hr + change Real.exp (-s * r) * firstKernel Q0 rates0 b0 r = + Real.exp (-s * r) * firstKernel Q1 rates1 b1 r + rw [hK1 r hr.le] + have hH2 : ∀ s t : ℝ, 0 < s → 0 < t → + C145.H2.H rates0 (C145PhysicalFrame.T Q0 (C145.Pulse.modalOverlap Q0 b0)) s t = + C145.H2.H rates1 (C145PhysicalFrame.T Q1 (C145.Pulse.modalOverlap Q1 b1)) s t := by + intro s t hs ht + rw [← (delayKernel_transform Q0 rates0 b0 hPos0 s t hs ht).2, + ← (delayKernel_transform Q1 rates1 b1 hPos1 s t hs ht).2] + unfold doubleLaplace + apply setIntegral_congr_fun measurableSet_Ioi + intro r₁ hr₁ + apply setIntegral_congr_fun measurableSet_Ioi + intro r₂ hr₂ + change Real.exp (-s * r₁) * Real.exp (-t * r₂) * delayKernel Q0 rates0 b0 r₁ r₂ = + Real.exp (-s * r₁) * Real.exp (-t * r₂) * delayKernel Q1 rates1 b1 r₁ r₂ + rw [hK2 r₁ r₂ hr₁.le hr₂.le] + exact actual_H1_H2_theoremA_vertex_identification + μ c0 c1 hμ Q0 Q1 rates0 b0 rates1 b1 hQ0 hQ1 hGround0 hGround1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 ha0 ha1 + ell u hw hband hlo hhi delta hd hsep hq + hH1 hH2 + +theorem ordinary_C2_jets_determine_theoremA_spectral_model {m n : ℕ} {T : ℝ} + (hT : 0 < T) + (μ c0 c1 : ℝ) (hμ : 0 < μ) + (Q0 : Fin (m + 1) → Fin (m + 1) → ℝ) + (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates0 b0 : Fin (m + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround0 : ∀ v, Q0 v 0 = c0) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hRateGround0 : rates0 0 = μ) + (hRateGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < C145.Pulse.modalOverlap Q0 b0 i) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i : Fin m, ell ≤ rates0 i.succ) (hhi : ∀ i : Fin m, rates0 i.succ ≤ u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ (b0 j-b0 k) ^ 2) + (hq : sourceQChebyshevSq b0 ell u delta < 1) + (R0 : Input T → Path m T) (R1 : Input T → Path n T) + (hR0 : IsActualResponse hT Q0 rates0 b0 R0) + (hR1 : IsActualResponse hT Q1 rates1 b1 R1) + (hcR0 : ContDiffAt ℝ 2 R0 0) (hcR1 : ContDiffAt ℝ 2 R1 0) + (hFirst : ∀ (g : ℝ → ℝ) (hg : SmoothTemporalTest T g), + rawFirst b0 R0 (restrictInput T g hg.1.continuous) (endTime T hT) = + rawFirst b1 R1 (restrictInput T g hg.1.continuous) (endTime T hT)) + (hMixed : ∀ (g h : ℝ → ℝ) (hg : SmoothTemporalTest T g) (hh : SmoothTemporalTest T h), + rawMixed b0 R0 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT) = + rawMixed b1 R1 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT)) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap Q0 b0 i) ∧ + c0 = c1 ∧ (∑ v, b0 v) = (∑ w, b1 w) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u) ∧ + (∀ v : Fin (m + 1), b1 (π v) = b0 v) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u) := by + have hObserved := ordinary_C2_jets_recover_observed_time_kernels hT + Q0 rates0 b0 Q1 rates1 b1 hQ0 hQ1 R0 R1 hR0 hR1 hcR0 hcR1 hFirst hMixed + have hAll := C145.TimeKernelContinuation.observed_time_kernels_determine_all_nonnegative_delays + hT Q0 rates0 b0 Q1 rates1 b1 hObserved.1 hObserved.2 + exact actual_time_kernel_theoremA_vertex_identification + μ c0 c1 hμ Q0 Q1 rates0 b0 rates1 b1 hQ0 hQ1 hGround0 hGround1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 ha0 ha1 + ell u hw hband hlo hhi delta hd hsep hq hAll.1 hAll.2 + +open Matrix C145.WeightedGraph C145.CyclicSpectral C145.GraphSpectralRealization + +/-- An original-matrix statement of the source spectral band. The rates here +are the full decay rates including mu. Only nonground eigenvalues are bounded; +there is no condition on the competitor. This avoids assuming a desired +oriented frame, its transport, a permutation, or a tensor identity. -/ +def NonGroundDecayBand {m : ℕ} (μ : ℝ) + (W : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) (ell u : ℝ) : Prop := + ∀ (r : ℝ) (x : Fin (m + 1) → ℝ), x ≠ 0 → + generator μ W *ᵥ x = (-r) • x → r ≠ μ → ell ≤ r ∧ r ≤ u + +/-- Every oriented spectral realization obtained from the original connected +cyclic graph inherits the original-matrix band. -/ +theorem orientedRealization_decayBand {m : ℕ} {μ : ℝ} + {W : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ} {b : Fin (m + 1) → ℝ} + (S : OrientedRealization μ W b) (ell u : ℝ) + (hSpectrum : NonGroundDecayBand μ W ell u) : + ∀ i : Fin m, ell ≤ S.rates i.succ ∧ S.rates i.succ ≤ u := by + intro i + have hne : (fun v => S.Q v i.succ) ≠ 0 := by + intro hz + have hn := S.orthonormal i.succ i.succ + have hz' : ∀ v, S.Q v i.succ = 0 := congrFun hz + simp [hz'] at hn + exact hSpectrum (S.rates i.succ) (fun v => S.Q v i.succ) hne + (S.eigenvectors i.succ) (ne_of_gt (S.higher i)) + +/-- DRE8 Theorem A for the actual original graph and signed port from fixed +positive-horizon ordinary response jets. Source q_Ch is expressed by its exact +square, and source interval/separation bounds may be conservative. Modal +calibration, common signed ground, physical transport, residual H2 equality, +size equality and the simultaneous vertex bijection are all derived. -/ +theorem ordinary_C2_jets_determine_theoremA_graph {m n : ℕ} {T : ℝ} + (hT : 0 < T) (μ : ℝ) (hμ : 0 < μ) + (W0 : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (W1 : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hs0 : W0.IsSymm) (hs1 : W1.IsSymm) + (hn0 : ∀ v u, 0 ≤ W0 v u) (hn1 : ∀ v u, 0 ≤ W1 v u) + (hc0 : (supportGraph W0 hs0).Connected) (hc1 : (supportGraph W1 hs1).Connected) + (b0 : State m) (b1 : State n) + (hcyc0 : KrylovCyclic (generator μ W0) b0) + (hcyc1 : KrylovCyclic (generator μ W1) b1) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hSpectrum : NonGroundDecayBand μ W0 ell u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ (b0 j - b0 k) ^ 2) + (hq : sourceQChebyshevSq b0 ell u delta < 1) + (R0 : Input T → Path m T) (R1 : Input T → Path n T) + (hR0 : IsGraphResponse hT μ W0 b0 R0) (hR1 : IsGraphResponse hT μ W1 b1 R1) + (hC0 : ContDiffAt ℝ 2 R0 0) (hC1 : ContDiffAt ℝ 2 R1 0) + (hFirst : ∀ (g : ℝ → ℝ) (hg : SmoothTemporalTest T g), + rawFirst b0 R0 (restrictInput T g hg.1.continuous) (endTime T hT) = + rawFirst b1 R1 (restrictInput T g hg.1.continuous) (endTime T hT)) + (hMixed : ∀ (g h : ℝ → ℝ) (hg : SmoothTemporalTest T g) (hh : SmoothTemporalTest T h), + rawMixed b0 R0 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT) = + rawMixed b1 R1 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT)) : + ∃ (S0 : OrientedRealization μ W0 b0) (S1 : OrientedRealization μ W1 b1) + (e : Fin (m + 1) ≃ Fin (n + 1)), + m = n ∧ e 0 = 0 ∧ (∀ i, S1.rates (e i) = S0.rates i) ∧ + (∀ i, C145.Pulse.modalOverlap S1.Q b1 (e i) = + C145.Pulse.modalOverlap S0.Q b0 i) ∧ + S0.c = S1.c ∧ (∑ v, b0 v) = (∑ v, b1 v) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ v i, S1.Q (π v) (e i) = S0.Q v i) ∧ + (∀ v u, generator μ W1 (π v) (π u) = generator μ W0 v u) ∧ + (∀ v, b1 (π v) = b0 v) ∧ + (∀ v u, laplacian W1 (π v) (π u) = laplacian W0 v u) := by + obtain ⟨S0⟩ := connected_cyclic_graph_has_oriented_spectral_realization + μ hμ W0 hs0 hn0 hc0 b0 hcyc0 + obtain ⟨S1⟩ := connected_cyclic_graph_has_oriented_spectral_realization + μ hμ W1 hs1 hn1 hc1 b1 hcyc1 + have hBounds := orientedRealization_decayBand S0 ell u hSpectrum + obtain ⟨e, hmn, he0, hr, ha, hc, hb, π, _, hQ, hA, hport, hL⟩ := + ordinary_C2_jets_determine_theoremA_spectral_model + hT μ S0.c S1.c hμ S0.Q S1.Q S0.rates b0 S1.rates b1 + S0.orthonormal S1.orthonormal S0.ground S1.ground S0.simple S1.simple + S0.ground_rate S1.ground_rate S0.higher S1.higher + S0.positive_overlap S1.positive_overlap + ell u hw hband (fun i => (hBounds i).1) (fun i => (hBounds i).2) + delta hd hsep hq R0 R1 + (S0.actualResponse hT R0 hR0) (S1.actualResponse hT R1 hR1) + hC0 hC1 hFirst hMixed + refine ⟨S0, S1, e, hmn, he0, hr, ha, hc, hb, π, hQ, ?_, hport, ?_⟩ + · simpa only [S0.original_generator, S1.original_generator] using hA + · simpa only [S0.original_laplacian, S1.original_laplacian] using hL + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8OrthogonalTransport.lean b/LeanPool/C145/C145DRE8OrthogonalTransport.lean new file mode 100644 index 0000000000..b1b3caae4b --- /dev/null +++ b/LeanPool/C145/C145DRE8OrthogonalTransport.lean @@ -0,0 +1,167 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8SpectralContraction + +/-! Exact orthogonal change of coordinates for tensor and slice energies. +This is the modal-to-vertex bridge needed to apply physical Lemma B. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +/-- Apply the transport matrix to the first tensor index. -/ +def rotateFirst (U : Matrix ι ι ℝ) (E : ι → ι → ι → ℝ) : ι → ι → ι → ℝ := + fun i j k => ∑ r, U i r * E r j k + +/-- Apply the transport matrix to the second tensor index. -/ +def rotateSecond (U : Matrix ι ι ℝ) (E : ι → ι → ι → ℝ) : ι → ι → ι → ℝ := + fun i j k => ∑ r, U j r * E i r k + +/-- Apply the transport matrix to the third tensor index. -/ +def rotateThird (U : Matrix ι ι ℝ) (E : ι → ι → ι → ℝ) : ι → ι → ι → ℝ := + fun i j k => ∑ r, U k r * E i j r + +/-- Same orthogonal U in each of the three slots. -/ +def rotateTensor (U : Matrix ι ι ℝ) (E : ι → ι → ι → ℝ) : ι → ι → ι → ℝ := + rotateFirst U (rotateSecond U (rotateThird U E)) + +omit [DecidableEq ι] in +theorem tensorSq_sum_order (E : ι → ι → ι → ℝ) : + (∑ j, ∑ k, ∑ i, E i j k ^ 2) = tensorSq E := by + unfold tensorSq + calc + _ = ∑ j, ∑ i, ∑ k, E i j k ^ 2 := by + apply Finset.sum_congr rfl; intro j hj; exact Finset.sum_comm + _ = _ := Finset.sum_comm + +theorem tensorSq_rotateFirst (U : Matrix ι ι ℝ) (hU : U.transpose * U = 1) + (E : ι → ι → ι → ℝ) : tensorSq (rotateFirst U E) = tensorSq E := by + rw [← tensorSq_sum_order] + simp only [rotateFirst, orthogonal_energy U hU] + exact tensorSq_sum_order E + +theorem tensorSq_rotateSecond (U : Matrix ι ι ℝ) (hU : U.transpose * U = 1) + (E : ι → ι → ι → ℝ) : tensorSq (rotateSecond U E) = tensorSq E := by + unfold tensorSq + apply Finset.sum_congr rfl; intro i hi + rw [Finset.sum_comm] + calc + _ = ∑ k, ∑ r, E i r k ^ 2 := by + apply Finset.sum_congr rfl; intro k hk + exact orthogonal_energy U hU (fun r => E i r k) + _ = _ := Finset.sum_comm + +theorem tensorSq_rotateThird (U : Matrix ι ι ℝ) (hU : U.transpose * U = 1) + (E : ι → ι → ι → ℝ) : tensorSq (rotateThird U E) = tensorSq E := by + unfold tensorSq rotateThird + simp_rw [orthogonal_energy U hU] + +/-- Frobenius tensor energy is preserved in the actual orthogonal frame. -/ +theorem tensorSq_rotateTensor (U : Matrix ι ι ℝ) (hU : U.transpose * U = 1) + (E : ι → ι → ι → ℝ) : tensorSq (rotateTensor U E) = tensorSq E := by + simp only [rotateTensor, tensorSq_rotateFirst U hU, + tensorSq_rotateSecond U hU, tensorSq_rotateThird U hU] + +/-- The signature is rotated by the very same U as the tensor. -/ +theorem signature_pairing (U : Matrix ι ι ℝ) (hU : U.transpose * U = 1) + (a : ι → ℝ) (r : ι) : ∑ i, (U.mulVec a) i * U i r = a r := by + simp only [Matrix.mulVec, dotProduct, Finset.sum_mul] + rw [Finset.sum_comm] + calc + _ = ∑ s, (∑ i, U i s * U i r) * a s := by + apply Finset.sum_congr rfl; intro s hs + rw [Finset.sum_mul] + apply Finset.sum_congr rfl; intro i hi; ring + _ = _ := by simp_rw [orthogonal_columns_entry U hU]; simp + +theorem slice_rotateFirst (U : Matrix ι ι ℝ) (hU : U.transpose * U = 1) + (E : ι → ι → ι → ℝ) (a : ι → ℝ) : + tensorSlice (rotateFirst U E) (U.mulVec a) = tensorSlice E a := by + funext j k + simp only [tensorSlice, rotateFirst, Finset.mul_sum] + rw [Finset.sum_comm] + calc + _ = ∑ r, (∑ i, (U.mulVec a) i * U i r) * E r j k := by + apply Finset.sum_congr rfl; intro r hr + rw [Finset.sum_mul] + apply Finset.sum_congr rfl; intro i hi; ring + _ = _ := by simp_rw [signature_pairing U hU] + +omit [DecidableEq ι] in +theorem slice_rotateSecond (U : Matrix ι ι ℝ) + (E : ι → ι → ι → ℝ) (a : ι → ℝ) : + tensorSlice (rotateSecond U E) a = U * tensorSlice E a := by + funext j k + simp only [tensorSlice, rotateSecond, Matrix.mul_apply, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro r hr + apply Finset.sum_congr rfl; intro i hi; ring + +omit [DecidableEq ι] in +theorem slice_rotateThird (U : Matrix ι ι ℝ) + (E : ι → ι → ι → ℝ) (a : ι → ℝ) : + tensorSlice (rotateThird U E) a = tensorSlice E a * U.transpose := by + funext j k + simp only [tensorSlice, rotateThird, Matrix.mul_apply, Matrix.transpose_apply, + Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro r hr + apply Finset.sum_congr rfl; intro i hi; ring + +/-- Exact slice covariance and its actual frame identity. -/ +theorem slice_rotateTensor (U : Matrix ι ι ℝ) (hU : U.transpose * U = 1) + (E : ι → ι → ι → ℝ) (a : ι → ℝ) : + tensorSlice (rotateTensor U E) (U.mulVec a) = + U * tensorSlice E a * U.transpose := by + rw [rotateTensor, slice_rotateFirst U hU, slice_rotateSecond, + slice_rotateThird, Matrix.mul_assoc] + +theorem matrixSq_slice_rotateTensor (U : Matrix ι ι ℝ) (hU : U.transpose * U = 1) + (E : ι → ι → ι → ℝ) (a : ι → ℝ) : + matrixSq (tensorSlice (rotateTensor U E) (U.mulVec a)) = + matrixSq (tensorSlice E a) := by + rw [slice_rotateTensor U hU, matrixSq_right U.transpose] + · exact matrixSq_left U _ hU + · simpa using orthogonal_rows U hU + +variable {n : ℕ} + +/-- Modal signature of b_perp: zero in the calibrated ground direction. -/ +def residualVector (a : Fin n → ℝ) : Fin (n + 1) → ℝ := Fin.cases 0 a + +/-- Embedding a residual tensor adds no ground energy, including n=0. -/ +theorem tensorSq_groundZero (E : Tensor n) : tensorSq (groundZero E) = tensorSq E := by + simp [tensorSq, Fin.sum_univ_succ, groundZero] + +/-- The embedded residual slice likewise adds zero rows and columns. -/ +theorem matrixSq_slice_groundZero (E : Tensor n) (a : Fin n → ℝ) : + matrixSq (tensorSlice (groundZero E) (residualVector a)) = + matrixSq (tensorSlice E a) := by + simp [matrixSq, tensorSlice, Fin.sum_univ_succ, residualVector, groundZero] + +/-- Full modal-to-vertex tensor and signature energy transport, with exactly +one shared orthogonal basis map U and the zero-ground embedding explicit. -/ +theorem residual_transport (U : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hU : U.transpose * U = 1) (E : Tensor n) (a : Fin n → ℝ) : + tensorSq (rotateTensor U (groundZero E)) = tensorSq E ∧ + matrixSq (tensorSlice (rotateTensor U (groundZero E)) (U.mulVec (residualVector a))) = + matrixSq (tensorSlice E a) := by + constructor + · rw [tensorSq_rotateTensor U hU, tensorSq_groundZero] + · rw [matrixSq_slice_rotateTensor U hU, matrixSq_slice_groundZero] + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8PhysicalStability.lean b/LeanPool/C145/C145DRE8PhysicalStability.lean new file mode 100644 index 0000000000..a0a91b6161 --- /dev/null +++ b/LeanPool/C145/C145DRE8PhysicalStability.lean @@ -0,0 +1,398 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8PositiveGridKernel +public import LeanPool.C145.C145DRE8HilbertStability +public import LeanPool.C145.C145DRE8ActualFrame +public import LeanPool.C145.C145DRE8OrthogonalTransport + +/-! Theorem E uses Lemma B on the full actual physical secant, without H2 equality. +The modal and vertex slices are related by the same calibrated orthogonal frame. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 +variable {n : ℕ} {ρ : Type*} [Fintype ρ] + +/-- Full actual physical secant estimate. No equality of second-transfer data +is assumed. All source signatures may be used jointly. -/ +theorem actual_full_physical_slice_rigidity + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) + (g : ρ → Fin (n + 1) → ℝ) (delta : ℝ) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ + signatureSq (fun r => (Matrix.of U).mulVec (g r)) j k) : + delta ^ 2 * tensorSq (C145PhysicalFrame.C V-C145PhysicalFrame.C U) ≤ + ((n + 1 : ℕ) + 2 : ℝ) * sliceSq (C145PhysicalFrame.C V-C145PhysicalFrame.C U) g := by + let Q : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ := Matrix.of U * (Matrix.of V).transpose + have hQ : Q.transpose * Q = 1 := by + have hh := columnOrthonormal_matrix (C145CoordinatePermutation.transport V U) + (C145CoordinatePermutation.transport_columnOrthonormal V U hV hU) + rw [C145CoordinatePermutation.transport_eq_matrix_mul_transpose] at hh + exact hh + have hunit : ∀ i, ∑ v, Q i v = 1 := actual_frame_common_unit U V c hU hV hGU hGV + have hh := physical_slice_rigidity Q hQ hunit + (fun r => (Matrix.of U).mulVec (g r)) delta hsep + rw [actual_frame_physical_difference U V hU, + tensorSq_rotateTensor (Matrix.of U) (columnOrthonormal_matrix U hU)] at hh + simpa only [sliceSq, matrixSq_slice_rotateTensor (Matrix.of U) + (columnOrthonormal_matrix U hU), Fintype.card_fin] using hh + + +/-- The fixed signed-ground calibration removes every slot containing mode zero. +This is the source space V0; projection and its singular value are taken here. -/ +def physicalDifferenceSpace (n : ℕ) : Submodule ℝ (TensorSpace (n + 1)) where + carrier := {E | FullSymTensor (toTensor E) ∧ + ∀ i j k, i = 0 ∨ j = 0 ∨ k = 0 → toTensor E i j k = 0} + zero_mem' := by + constructor + · intro e a; rfl + · intro i j k h; rfl + add_mem' := by + intro E F hE hF + constructor + · intro e a + exact congrArg₂ (· + ·) (hE.1 e a) (hF.1 e a) + · intro i j k h + change toTensor E i j k + toTensor F i j k = 0 + rw [hE.2 i j k h, hF.2 i j k h, add_zero] + smul_mem' := by + intro a E hE + constructor + · intro e v + exact congrArg (fun t : ℝ => a * t) (hE.1 e v) + · intro i j k h + change a * toTensor E i j k = 0 + rw [hE.2 i j k h, mul_zero] + +/-- Actual secants lie in V0 solely from orthonormality and common signed ground. -/ +theorem actual_difference_mem_physicalDifferenceSpace + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) : + fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U) ∈ physicalDifferenceSpace n := by + constructor + · rw [toTensor_fromTensor] + exact fullSymTensor_sub _ _ (actual_cubic_fullSym V) (actual_cubic_fullSym U) + · intro i j k h + rw [toTensor_fromTensor] + exact sub_eq_zero.mpr (actual_cubic_common_ground U V c hU hV hGU hGV i j k h) + +/-- All signature slices in a single Euclidean vector, with Frobenius matrix norms. -/ +def sliceBundle {N : ℕ} (g : ρ → Fin N → ℝ) : + TensorSpace N →ₗ[ℝ] EuclideanSpace ℝ (ρ × Fin N × Fin N) where + toFun E := WithLp.toLp 2 (fun p => tensorSlice (toTensor E) (g p.1) p.2.1 p.2.2) + map_add' := by + intro E F + ext p + simp [tensorSlice, toTensor, mul_add, Finset.sum_add_distrib] + map_smul' := by + intro a E + ext p + simp [tensorSlice, toTensor, Finset.mul_sum, mul_left_comm] + +/-- The bundle norm is exactly the source sum of squared Frobenius slice norms. -/ +theorem norm_sliceBundle_sq {N : ℕ} (g : ρ → Fin N → ℝ) (E : TensorSpace N) : + ‖sliceBundle g E‖ ^ 2 = sliceSq (toTensor E) g := by + simp [EuclideanSpace.real_norm_sq_eq, sliceBundle, sliceSq, matrixSq, + Fintype.sum_prod_type] + +/-- Source B_H uses Euclidean norms on the signatures in modal coordinates. -/ +def signatureNorm (g : ρ → Fin (n + 1) → ℝ) : ℝ := + Real.sqrt (∑ r, ∑ i, (g r i) ^ 2) + +/-- Orthogonal modal transport preserves B_H, so this is also the norm of +exactly the vertex signature family appearing in separation. -/ +theorem signatureNorm_rotate + (U : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) (hU : U.transpose * U = 1) + (g : ρ → Fin (n + 1) → ℝ) : + signatureNorm (fun r => U.mulVec (g r)) = signatureNorm g := by + unfold signatureNorm + congr 1 + apply Finset.sum_congr rfl + intro r hr + exact orthogonal_energy U hU (g r) + +/-- Cauchy--Schwarz gives the global slice estimate on every ambient tensor; +no physicality is assumed for any projected component. -/ +theorem sliceBundle_global_bound (g : ρ → Fin (n + 1) → ℝ) (E : TensorSpace (n + 1)) : + ‖sliceBundle g E‖ ≤ signatureNorm g * ‖E‖ := by + have hh : sliceSq (toTensor E) g ≤ (∑ r, ∑ i, (g r i) ^ 2) * tensorSq (toTensor E) := by + calc + _ ≤ ∑ r, (∑ i, (g r i) ^ 2) * tensorSq (toTensor E) := by + apply Finset.sum_le_sum + intro r hr + exact tensorSlice_cauchy (toTensor E) (g r) + _ = _ := by rw [Finset.sum_mul] + have hnon : (0 : ℝ) ≤ ∑ r, ∑ i, (g r i) ^ 2 := by positivity + have hs := Real.sq_sqrt hnon + have hE := norm_sq_eq_tensorSq E + have hS := norm_sliceBundle_sq g E + have hB : 0 ≤ signatureNorm g := Real.sqrt_nonneg _ + apply (sq_le_sq₀ (norm_nonneg _) (mul_nonneg hB (norm_nonneg _))).mp + simpa only [mul_pow, signatureNorm, hs, hE, hS] using hh + +/-- Lemma B in precisely the Euclidean/Frobenius norm used for Theorem E. -/ +theorem actual_full_physical_norm_bound + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) + (g : ρ → Fin (n + 1) → ℝ) (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ + signatureSq (fun r => (Matrix.of U).mulVec (g r)) j k) : + ‖fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U)‖ ≤ + (Real.sqrt ((n + 1 : ℕ) + 2) / delta)* + ‖sliceBundle g (fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U))‖ := by + let E := fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U) + have hr := actual_full_physical_slice_rigidity U V c hU hV hGU hGV g delta hsep + have hE := norm_sq_eq_tensorSq E + have hS := norm_sliceBundle_sq g E + simp only [E, toTensor_fromTensor] at hE hS + have hN : (0 : ℝ) ≤ ((n + 1 : ℕ) + 2 : ℝ) := by positivity + have hs := Real.sq_sqrt hN + have hn : 0 ≤ Real.sqrt ((n + 1 : ℕ) + 2) := Real.sqrt_nonneg _ + rw [div_mul_eq_mul_div] + apply (le_div_iff₀ hd).mpr + apply (sq_le_sq₀ (mul_nonneg (norm_nonneg _) hd.le) + (mul_nonneg hn (norm_nonneg _))).mp + rw [mul_pow, mul_pow, hs] + nlinarith only [hr, hE, hS] + + +/-- The exact sampled operator on the source V0, with its inherited Frobenius norm. -/ +def physicalGridMap (a rates : Fin (n + 1) → ℝ) + (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) := + (positiveGridMap a rates sNodes tNodes).comp (physicalDifferenceSpace n).subtype + +/-- The full actual positive-response kernel inside V0. -/ +def physicalH2Kernel (a rates : Fin (n + 1) → ℝ) := + (actualPositiveKernel a rates).comap (physicalDifferenceSpace n).subtype + +/-- The bundle is restricted to the same V0 as the orthogonal projection. -/ +def physicalSliceBundle (g : ρ → Fin (n + 1) → ℝ) := + (sliceBundle g).comp (physicalDifferenceSpace n).subtype + +/-- Source Lemma D, now with the exact domain used by source Theorem E. -/ +theorem ker_physicalGridMap (a rates : Fin (n + 1) → ℝ) + (hRates : ∀ i, 0 < rates i) (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (hsPos : ∀ i, 0 < sNodes i) (htPos : ∀ i, 0 < tNodes i) : + LinearMap.ker (physicalGridMap a rates sNodes tNodes) = physicalH2Kernel a rates := by + exact ker_positiveGridMap_restrict (by omega) a rates hRates sNodes tNodes + hsNodes htNodes hsPos htPos (physicalDifferenceSpace n) + +/-- A positive measurement lower gain exists on K-perp *inside V0*. +For nontrivial K-perp the Hilbert engine also proves that its least value is attained. -/ +theorem physicalGrid_exists_positive_gain (a rates : Fin (n + 1) → ℝ) + (hRates : ∀ i, 0 < rates i) (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (hsPos : ∀ i, 0 < sNodes i) (htPos : ∀ i, 0 < tNodes i) : + ∃ sigma : ℝ, 0 < sigma ∧ ∀ r : physicalDifferenceSpace n, + r ∈ (physicalH2Kernel a rates)ᗮ → + sigma * ‖r‖ ≤ ‖physicalGridMap a rates sNodes tNodes r‖ := by + exact C145DRE8HilbertStability.exists_positive_complement_gain + (physicalGridMap a rates sNodes tNodes) (physicalH2Kernel a rates) + (ker_physicalGridMap a rates hRates sNodes tNodes hsNodes htNodes hsPos htPos) + +/-- The source least singular value is attained on the unit sphere of the +actual response-kernel complement inside V0, whenever that complement is nonzero. -/ +theorem physicalGrid_exists_least_gain (a rates : Fin (n + 1) → ℝ) + (hRates : ∀ i, 0 < rates i) (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (hsPos : ∀ i, 0 < sNodes i) (htPos : ∀ i, 0 < tNodes i) + [Nontrivial (physicalH2Kernel a rates)ᗮ] : + ∃ (sigma : ℝ) (u : (physicalH2Kernel a rates)ᗮ), + 0 < sigma ∧ ‖u‖ = 1 ∧ + ‖physicalGridMap a rates sNodes tNodes (u : physicalDifferenceSpace n)‖ = sigma ∧ + (∀ v : (physicalH2Kernel a rates)ᗮ, ‖v‖ = 1 → + sigma ≤ ‖physicalGridMap a rates sNodes tNodes (v : physicalDifferenceSpace n)‖) ∧ + (∀ r : physicalDifferenceSpace n, r ∈ (physicalH2Kernel a rates)ᗮ → + sigma * ‖r‖ ≤ ‖physicalGridMap a rates sNodes tNodes r‖) := by + exact C145DRE8HilbertStability.exists_attained_positive_complement_gain + (physicalGridMap a rates sNodes tNodes) (physicalH2Kernel a rates) + (ker_physicalGridMap a rates hRates sNodes tNodes hsNodes htNodes hsPos htPos) + +/-- A pure one-mode cube; its only nonzero entry is (i,i,i). -/ +def pureModeCube (i : Fin (n + 1)) : Tensor (n + 1) := + C145PhysicalFrame.C (fun v j => if v = 0 ∧ j = i then 1 else 0) + +@[simp] theorem pureModeCube_apply (i j k l : Fin (n + 1)) : + pureModeCube i j k l = if j = i ∧ k = i ∧ l = i then 1 else 0 := by + classical + by_cases hj : j = i <;> by_cases hk : k = i <;> by_cases hl : l = i <;> + simp [pureModeCube, C145PhysicalFrame.C, hj, hk, hl] + +/-- A nonground pure cube belongs to the source symmetric ground-zero space. -/ +theorem pureModeCube_mem (i : Fin (n + 1)) (hi : i ≠ 0) : + fromTensor (pureModeCube i) ∈ physicalDifferenceSpace n := by + constructor + · simpa only [toTensor_fromTensor, pureModeCube] using + (actual_cubic_fullSym (fun v j : Fin (n + 1) => if v = 0 ∧ j = i then 1 else 0)) + · intro j k l h + simp only [toTensor_fromTensor, pureModeCube_apply] + rcases h with rfl | rfl | rfl <;> simp [Ne.symm hi] + +/-- Its calibrated actual response is a single nonzero rational summand. -/ +theorem pureModeCube_response (i : Fin (n + 1)) (a rates : Fin (n + 1) → ℝ) + (s t : ℝ) : + responseMap a rates s t (fromTensor (pureModeCube i)) = + a i ^ 3 / ((s + rates i) * (t + rates i) * (s + t + rates i)) := by + classical + simp [responseMap, H, weightedTensor, pureModeCube_apply, ite_and, mul_ite, ite_div, pow_succ] + +/-- A nonzero calibrated nonground overlap makes this cube observable at every +positive response pair; positivity derives every denominator guard. -/ +theorem pureModeCube_response_ne_zero (i : Fin (n + 1)) + (a rates : Fin (n + 1) → ℝ) (ha : a i ≠ 0) (hRates : ∀ j, 0 < rates j) + (s t : ℝ) (hs : 0 < s) (ht : 0 < t) : + responseMap a rates s t (fromTensor (pureModeCube i)) ≠ 0 := by + rw [pureModeCube_response] + have hp := hRates i + exact div_ne_zero (pow_ne_zero 3 ha) (ne_of_gt (by positivity)) + +/-- The full actual response kernel is proper in V0 as soon as one nonground +overlap is nonzero, in particular under the source cyclic calibration. -/ +theorem physicalH2Kernel_ne_top_of_nonzero_overlap + (a rates : Fin (n + 1) → ℝ) (hRates : ∀ j, 0 < rates j) + (i : Fin (n + 1)) (hi : i ≠ 0) (ha : a i ≠ 0) : + physicalH2Kernel a rates ≠ ⊤ := by + let x : physicalDifferenceSpace n := ⟨fromTensor (pureModeCube i), pureModeCube_mem i hi⟩ + have hx : x ∉ physicalH2Kernel a rates := by + intro h + change ∀ s t, 0 < s → 0 < t → responseMap a rates s t (x : TensorSpace (n + 1)) = 0 at h + exact pureModeCube_response_ne_zero i a rates ha hRates 1 1 (by norm_num) (by norm_num) + (h 1 1 (by norm_num) (by norm_num)) + intro htop + exact hx (by rw [htop]; trivial) + +/-- The kernel complement inside V0 is derived to be nontrivial. -/ +theorem physicalH2Kernel_orthogonal_nontrivial_of_nonzero_overlap + (a rates : Fin (n + 1) → ℝ) (hRates : ∀ j, 0 < rates j) + (i : Fin (n + 1)) (hi : i ≠ 0) (ha : a i ≠ 0) : + Nontrivial (physicalH2Kernel a rates)ᗮ := by + apply Submodule.nontrivial_iff_ne_bot.mpr + intro hzero + exact physicalH2Kernel_ne_top_of_nonzero_overlap a rates hRates i hi ha + (Submodule.orthogonal_eq_bot_iff.mp hzero) + +/-- In particular the literal sampled response operator on V0 is nonzero. -/ +theorem physicalGrid_nonzero_of_nonzero_overlap + (a rates : Fin (n + 1) → ℝ) (hRates : ∀ j, 0 < rates j) + (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (hsPos : ∀ j, 0 < sNodes j) (htPos : ∀ j, 0 < tNodes j) + (i : Fin (n + 1)) (hi : i ≠ 0) (ha : a i ≠ 0) : + physicalGridMap a rates sNodes tNodes ≠ 0 := by + intro hzero + apply physicalH2Kernel_ne_top_of_nonzero_overlap a rates hRates i hi ha + rw [← ker_physicalGridMap a rates hRates sNodes tNodes hsNodes htNodes hsPos htPos, + hzero] + exact LinearMap.ker_zero + +/-- Source-level genuine least singular value: no nontriviality certificate is +supplied. One nonzero nonground overlap proves it from a pure mode cube. -/ +theorem physicalGrid_exists_least_gain_of_nonzero_overlap + (a rates : Fin (n + 1) → ℝ) (hRates : ∀ j, 0 < rates j) + (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (hsPos : ∀ j, 0 < sNodes j) (htPos : ∀ j, 0 < tNodes j) + (i : Fin (n + 1)) (hi : i ≠ 0) (ha : a i ≠ 0) : + ∃ (sigma : ℝ) (u : (physicalH2Kernel a rates)ᗮ), + 0 < sigma ∧ ‖u‖ = 1 ∧ + ‖physicalGridMap a rates sNodes tNodes (u : physicalDifferenceSpace n)‖ = sigma ∧ + (∀ v : (physicalH2Kernel a rates)ᗮ, ‖v‖ = 1 → + sigma ≤ ‖physicalGridMap a rates sNodes tNodes (v : physicalDifferenceSpace n)‖) ∧ + (∀ r : physicalDifferenceSpace n, r ∈ (physicalH2Kernel a rates)ᗮ → + sigma * ‖r‖ ≤ ‖physicalGridMap a rates sNodes tNodes r‖) := by + have := physicalH2Kernel_orthogonal_nontrivial_of_nonzero_overlap a rates hRates i hi ha + exact physicalGrid_exists_least_gain a rates hRates sNodes tNodes + hsNodes htNodes hsPos htPos + + +/-- Fixed-calibration source Theorem E for the actual full physical tensor secant. +The two H2 responses may differ. The kernel bundle estimate is exactly source (8.1); +physical rigidity and the global slice bound are derived, not supplied premises. +The singular-value gain and all projections use K-perp inside V0. -/ +theorem actual_calibrated_grid_stability + (a rates : Fin (n + 1) → ℝ) (hRates : ∀ i, 0 < rates i) + (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (hsPos : ∀ i, 0 < sNodes i) (htPos : ∀ i, 0 < tNodes i) + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) + (g : ρ → Fin (n + 1) → ℝ) (delta beta sigma : ℝ) + (hd : 0 < delta) (hb : 0 ≤ beta) (hsigma : 0 < sigma) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ + signatureSq (fun r => (Matrix.of U).mulVec (g r)) j k) + (hq : Real.sqrt ((n + 1 : ℕ) + 2) * beta / delta < 1) + (hgain : ∀ r : physicalDifferenceSpace n, + r ∈ (physicalH2Kernel a rates)ᗮ → + sigma * ‖r‖ ≤ ‖physicalGridMap a rates sNodes tNodes r‖) + (hkernel : ∀ k : physicalDifferenceSpace n, k ∈ physicalH2Kernel a rates → + ‖physicalSliceBundle g k‖ ≤ beta * ‖k‖) : + ‖fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U)‖ ≤ + (Real.sqrt ((n + 1 : ℕ) + 2) * signatureNorm g / + (delta * (1-Real.sqrt ((n + 1 : ℕ) + 2) * beta / delta) * sigma)) * + ‖positiveGridMap a rates sNodes tNodes + (fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U))‖ := by + let x : physicalDifferenceSpace n := + ⟨fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U), + actual_difference_mem_physicalDifferenceSpace U V c hU hV hGU hGV⟩ + have hphysical : ‖x‖ ≤ (Real.sqrt ((n + 1 : ℕ) + 2) / delta) * ‖physicalSliceBundle g x‖ := + actual_full_physical_norm_bound U V c hU hV hGU hGV g delta hd hsep + have hglobal (r : physicalDifferenceSpace n) : + ‖physicalSliceBundle g r‖ ≤ signatureNorm g * ‖r‖ := + sliceBundle_global_bound g r + exact C145DRE8HilbertStability.fixed_calibration_tensor_stability + (physicalGridMap a rates sNodes tNodes) (physicalH2Kernel a rates) + (physicalSliceBundle g) + (ker_physicalGridMap a rates hRates sNodes tNodes hsNodes htNodes hsPos htPos) + x (n + 1) delta beta (signatureNorm g) sigma hd hb (Real.sqrt_nonneg _) hsigma + hq hgain hphysical hkernel hglobal + +/-- The measured vector in the stability theorem consists of the literal +second-transfer differences of the two physical tensors with common a/rates. -/ +theorem actual_grid_coordinate_difference + (a rates : Fin (n + 1) → ℝ) (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) + (p : Fin (2 * (n + 1) - 1) × Fin (2 * (n + 1) - 1)) : + positiveGridMap a rates sNodes tNodes + (fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U)) p = + H rates (weightedTensor a (C145PhysicalFrame.C V)) (sNodes p.1) (tNodes p.2) - + H rates (weightedTensor a (C145PhysicalFrame.C U)) (sNodes p.1) (tNodes p.2) := by + change responseMap a rates (sNodes p.1) (tNodes p.2) + (tensorEquiv.symm (C145PhysicalFrame.C V-C145PhysicalFrame.C U)) = _ + rw [map_sub, map_sub] + rfl + + +/-- The same coordinate identity in the accepted physical response notation T. -/ +theorem actual_grid_coordinate_physical_response + (a rates : Fin (n + 1) → ℝ) (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) + (p : Fin (2 * (n + 1) - 1) × Fin (2 * (n + 1) - 1)) : + positiveGridMap a rates sNodes tNodes + (fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U)) p = + H rates (C145PhysicalFrame.T V a) (sNodes p.1) (tNodes p.2) - + H rates (C145PhysicalFrame.T U a) (sNodes p.1) (tNodes p.2) := + actual_grid_coordinate_difference a rates sNodes tNodes U V p + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8PhysicalTensor.lean b/LeanPool/C145/C145DRE8PhysicalTensor.lean new file mode 100644 index 0000000000..03d20f00b1 --- /dev/null +++ b/LeanPool/C145/C145DRE8PhysicalTensor.lean @@ -0,0 +1,172 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8CommonUnit +public import LeanPool.C145.C145DRE8Frobenius + +/-! Actual coordinatewise multiplication tensors in orthogonal frames, sharing the unit. -/ + +@[expose] public section + +namespace C145DRE8 +open scoped BigOperators +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +/-- The cubic coordinate tensor with unit entries on the full diagonal. -/ +noncomputable def coordinateTensor (i j k : ι) : ℝ := if i = j ∧ j = k then 1 else 0 +/-- Sum the cubic outer products of the columns of the candidate transport matrix. -/ +noncomputable def competitorTensor (Q : Matrix ι ι ℝ) (i j k : ι) : ℝ := + ∑ v, Q i v * Q j v * Q k v +/-- The candidate cubic tensor minus the coordinate tensor. -/ +noncomputable def physicalDifference (Q : Matrix ι ι ℝ) (i j k : ι) : ℝ := + competitorTensor Q i j k - coordinateTensor i j k +/-- Contract a cubic tensor against a vector on its first index. -/ +noncomputable def tensorSlice (E : ι → ι → ι → ℝ) (h : ι → ℝ) : Matrix ι ι ℝ := + fun j k => ∑ i, h i * E i j k + +/-- Fix the first index of the physical tensor difference to obtain a matrix. -/ +noncomputable def differenceMatrix (Q : Matrix ι ι ℝ) (i : ι) : Matrix ι ι ℝ := + fun j k => physicalDifference Q i j k + +omit [DecidableEq ι] in +theorem competitor_symm12 (Q : Matrix ι ι ℝ) (i j k : ι) : + competitorTensor Q i j k = competitorTensor Q j i k := by + unfold competitorTensor + apply Finset.sum_congr rfl; intro v hv; ring + +omit [DecidableEq ι] in +theorem competitor_symm13 (Q : Matrix ι ι ℝ) (i j k : ι) : + competitorTensor Q i j k = competitorTensor Q k j i := by + unfold competitorTensor + apply Finset.sum_congr rfl; intro v hv; ring + +omit [Fintype ι] in +theorem coordinate_symm12 (i j k : ι) : coordinateTensor i j k = coordinateTensor j i k := by + unfold coordinateTensor + split_ifs <;> simp_all + +omit [Fintype ι] in +theorem coordinate_symm13 (i j k : ι) : coordinateTensor i j k = coordinateTensor k j i := by + unfold coordinateTensor + split_ifs <;> simp_all + +theorem difference_symm12 (Q : Matrix ι ι ℝ) (i j k : ι) : + physicalDifference Q i j k = physicalDifference Q j i k := by + unfold physicalDifference + rw [competitor_symm12 Q i j k, coordinate_symm12 i j k] + +theorem difference_symm13 (Q : Matrix ι ι ℝ) (i j k : ι) : + physicalDifference Q i j k = physicalDifference Q k j i := by + unfold physicalDifference + rw [competitor_symm13 Q i j k, coordinate_symm13 i j k] + +/-- A real orthogonal matrix fixing the vector of ones also has column sums one. -/ +theorem orthogonal_column_unit (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (hunit : ∀ i, ∑ v, Q i v = 1) (v : ι) : ∑ i, Q i v = 1 := by + calc + _ = ∑ i, Q i v * (∑ w, Q i w) := by simp_rw [hunit]; simp + _ = ∑ w, ∑ i, Q i v * Q i w := by + simp_rw [Finset.mul_sum] + exact Finset.sum_comm + _ = 1 := by simp_rw [orthogonal_columns_entry Q hQ]; simp + +theorem competitor_common_unit (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (hunit : ∀ i, ∑ v, Q i v = 1) (j k : ι) : + (∑ i, competitorTensor Q i j k) = if j = k then 1 else 0 := by + unfold competitorTensor + rw [Finset.sum_comm] + calc + _ = ∑ v, (∑ i, Q i v) * Q j v * Q k v := by + simp_rw [Finset.sum_mul] + _ = ∑ v, Q j v * Q k v := by simp_rw [orthogonal_column_unit Q hQ hunit]; simp + _ = _ := by + simpa only [Matrix.transpose_apply] using + orthogonal_columns_entry Q.transpose (by simpa using orthogonal_rows Q hQ) j k + +theorem difference_common_unit (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (hunit : ∀ i, ∑ v, Q i v = 1) (j k : ι) : + (∑ i, physicalDifference Q i j k) = 0 := by + unfold physicalDifference + rw [Finset.sum_sub_distrib, competitor_common_unit Q hQ hunit] + have hc : (∑ i, coordinateTensor i j k) = if j = k then 1 else 0 := by + simp only [coordinateTensor, ite_and] + simp + rw [hc, sub_self] + +theorem physicalMatrix_entry (Q : Matrix ι ι ℝ) (i j k : ι) : + physicalMatrix Q i j k = competitorTensor Q i j k := by + unfold physicalMatrix competitorTensor + rw [Matrix.mul_apply] + simp only [Matrix.mul_diagonal, Matrix.transpose_apply] + apply Finset.sum_congr rfl; intro v hv; ring + +omit [Fintype ι] in +theorem coordinateSlice (i : ι) : + (fun j k => coordinateTensor i j k) = Matrix.diagonal (fun j => if i = j then (1 : ℝ) else 0) + := by + ext j k + simp only [coordinateTensor, Matrix.diagonal_apply] + split_ifs <;> simp_all + +theorem physicalMatrices_commute (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (i j : ι) : physicalMatrix Q i * physicalMatrix Q j = + physicalMatrix Q j * physicalMatrix Q i := by + have hcancel (X : Matrix ι ι ℝ) : Q.transpose * (Q * X) = X := by + rw [← Matrix.mul_assoc, hQ, Matrix.one_mul] + unfold physicalMatrix + simp only [Matrix.mul_assoc, hcancel] + have hd : Matrix.diagonal (Q i) * Matrix.diagonal (Q j) = + Matrix.diagonal (Q j) * Matrix.diagonal (Q i) := by + rw [Matrix.diagonal_mul_diagonal, Matrix.diagonal_mul_diagonal] + congr 1 + ext v; ring + simpa only [Matrix.mul_assoc] using congrArg (fun X => Q * X * Q.transpose) hd + +theorem differenceMatrix_eq (Q : Matrix ι ι ℝ) (i : ι) : + differenceMatrix Q i = physicalMatrix Q i - + Matrix.diagonal (fun j => if i = j then (1 : ℝ) else 0) := by + ext j k + change competitorTensor Q i j k - coordinateTensor i j k = _ + rw [← physicalMatrix_entry Q i j k] + rw [show coordinateTensor i j k = + Matrix.diagonal (fun j => if i = j then (1 : ℝ) else 0) j k from + congrFun (congrFun (coordinateSlice i) j) k] + rfl + +theorem physical_slice_eq_sum (Q : Matrix ι ι ℝ) (h : ι → ℝ) : + (∑ i, h i • physicalMatrix Q i) = Matrix.diagonal h + tensorSlice (physicalDifference Q) h := by + ext j k + simp only [Matrix.sum_apply, Matrix.smul_apply, smul_eq_mul, Matrix.add_apply, tensorSlice, + physicalMatrix_entry, physicalDifference, mul_sub, Finset.sum_sub_distrib] + have hc : (∑ i, h i * coordinateTensor i j k) = Matrix.diagonal h j k := by + simp only [coordinateTensor, ite_and, mul_ite, mul_zero, mul_one] + simp [Matrix.diagonal_apply] + rw [hc] + ring + +theorem physical_slice_commutes (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (h : ι → ℝ) (i : ι) : + (∑ j, h j • physicalMatrix Q j) * physicalMatrix Q i = + physicalMatrix Q i * (∑ j, h j • physicalMatrix Q j) := by + simp only [Matrix.sum_mul, Matrix.mul_sum, smul_mul_assoc, mul_smul_comm] + apply Finset.sum_congr rfl; intro j hj + rw [physicalMatrices_commute Q hQ] + +/-- Actual DRE8 physical common-unit tensor satisfies the entire combinatorial energy estimate. -/ +theorem physical_common_unit_tensor_bound (Q : Matrix ι ι ℝ) + (hQ : Q.transpose * Q = 1) (hunit : ∀ i, ∑ v, Q i v = 1) : + 2 * tensorSq (physicalDifference Q) ≤ ((Fintype.card ι : ℝ) + 2) * offSq (physicalDifference + Q) := by + exact common_unit_tensor_bound _ (difference_symm13 Q) (difference_symm12 Q) + (fun j => difference_common_unit Q hQ hunit j j) + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8PositiveGridKernel.lean b/LeanPool/C145/C145DRE8PositiveGridKernel.lean new file mode 100644 index 0000000000..215ba0fd49 --- /dev/null +++ b/LeanPool/C145/C145DRE8PositiveGridKernel.lean @@ -0,0 +1,112 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145H2PositiveGrid +public import LeanPool.C145.C145DRE8TensorSpace +public import LeanPool.C145.C145DRE8WeightedKernel + +/-! DRE8 Lemma D as actual Euclidean tensor measurement maps. +The domain norm is literal unweighted Frobenius, and the codomain norm is +Euclidean on the full Cartesian grid. Calibration parameters are fixed exactly. +The kernel theorem is proved on the ambient tensor space, hence on source V0 +by restriction; no symmetry or ground-zero premise is needed for interpolation. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open C145.H2 +open scoped BigOperators +variable {N : ℕ} + +/-- The actual calibrated second-transfer difference, linear in the physical +orthonormal tensor; overlap weights occur only inside the measured response. -/ +def responseMap (a rates : Fin N → ℝ) (s t : ℝ) : TensorSpace N →ₗ[ℝ] ℝ where + toFun E := H rates (weightedTensor a (toTensor E)) s t + map_add' E F := by + simp [H, weightedTensor, toTensor, mul_add, add_div, Finset.sum_add_distrib] + map_smul' c E := by + simp only [H, weightedTensor, toTensor, PiLp.smul_apply, smul_eq_mul, Finset.mul_sum] + apply Finset.sum_congr rfl; intro i hi + apply Finset.sum_congr rfl; intro j hj + apply Finset.sum_congr rfl; intro k hk + simp only [RingHom.id_apply] + ring + +@[simp] theorem responseMap_apply (a rates : Fin N → ℝ) (s t : ℝ) (E : TensorSpace N) : + responseMap a rates s t E = H rates (weightedTensor a (toTensor E)) s t := rfl + +/-- The literal `(2N-1)×(2N-1)` sampled actual response operator. -/ +def positiveGridMap (a rates : Fin N → ℝ) + (sNodes tNodes : Fin (2 * N - 1) → ℝ) : + TensorSpace N →ₗ[ℝ] EuclideanSpace ℝ (Fin (2 * N - 1) × Fin (2 * N - 1)) where + toFun E := WithLp.toLp 2 (fun p => responseMap a rates (sNodes p.1) (tNodes p.2) E) + map_add' E F := by + ext p + exact (responseMap a rates (sNodes p.1) (tNodes p.2)).map_add E F + map_smul' c E := by + ext p + exact (responseMap a rates (sNodes p.1) (tNodes p.2)).map_smul c E + +@[simp] theorem positiveGridMap_apply (a rates : Fin N → ℝ) + (sNodes tNodes : Fin (2 * N - 1) → ℝ) (E : TensorSpace N) + (p : Fin (2 * N - 1) × Fin (2 * N - 1)) : + positiveGridMap a rates sNodes tNodes E p = + H rates (weightedTensor a (toTensor E)) (sNodes p.1) (tNodes p.2) := rfl + +/-- The actual all-positive H2 nullspace, rather than a supplied model kernel. -/ +def actualPositiveKernel (a rates : Fin N → ℝ) : Submodule ℝ (TensorSpace N) where + carrier := {E | ∀ s t, 0 < s → 0 < t → responseMap a rates s t E = 0} + zero_mem' := by intro s t hs ht; exact (responseMap a rates s t).map_zero + add_mem' := by + intro E F hE hF s t hs ht + rw [map_add, hE s t hs ht, hF s t hs ht, add_zero] + smul_mem' := by + intro c E hE s t hs ht + rw [map_smul, hE s t hs ht, smul_zero] + +@[simp] theorem mem_actualPositiveKernel (a rates : Fin N → ℝ) (E : TensorSpace N) : + E ∈ actualPositiveKernel a rates ↔ NullPositive rates (weightedTensor a (toTensor E)) := + Iff.rfl + +/-- Source Lemma D: *any* two internally distinct positive grids have exactly +the full actual H2 nullspace. Positive rates derive all denominator guards. +No rate distinctness or nonzero overlaps are needed for this lemma itself. -/ +theorem ker_positiveGridMap (hN : 0 < N) (a rates : Fin N → ℝ) + (hRates : ∀ i, 0 < rates i) (sNodes tNodes : Fin (2 * N - 1) → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (hsPos : ∀ i, 0 < sNodes i) (htPos : ∀ i, 0 < tNodes i) : + LinearMap.ker (positiveGridMap a rates sNodes tNodes) = actualPositiveKernel a rates := by + ext E + rw [LinearMap.mem_ker, mem_actualPositiveKernel, + ← positive_grid_iff_nullPositive hN rates hRates (weightedTensor a (toTensor E)) + sNodes tNodes hsNodes htNodes hsPos htPos] + constructor + · intro h i j + exact congrArg (fun v => v (i,j)) h + · intro h + ext p + exact h p.1 p.2 + +/-- In particular the exact kernel identity holds on any chosen linear tensor +space, including the source's fully symmetric ground-zero space V0. -/ +theorem ker_positiveGridMap_restrict (hN : 0 < N) (a rates : Fin N → ℝ) + (hRates : ∀ i, 0 < rates i) (sNodes tNodes : Fin (2 * N - 1) → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (hsPos : ∀ i, 0 < sNodes i) (htPos : ∀ i, 0 < tNodes i) + (V : Submodule ℝ (TensorSpace N)) : + LinearMap.ker ((positiveGridMap a rates sNodes tNodes).comp V.subtype) = + (actualPositiveKernel a rates).comap V.subtype := by + rw [LinearMap.ker_comp, ker_positiveGridMap hN a rates hRates sNodes tNodes + hsNodes htNodes hsPos htPos] + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8ProjectionResiduals.lean b/LeanPool/C145/C145DRE8ProjectionResiduals.lean new file mode 100644 index 0000000000..9eca203cf5 --- /dev/null +++ b/LeanPool/C145/C145DRE8ProjectionResiduals.lean @@ -0,0 +1,126 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import Mathlib.Analysis.InnerProductSpace.PiL2 + +/-! True weighted Euclidean least-squares residuals for DRE8 (3.5), §§6–7. +No independence/nonzero-weight hypothesis is required: the finite-dimensional +subspace projection also covers degenerate moment families. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +variable {n : ℕ} + +/-- Weighted modal power with the Euclidean L² norm, never the Pi sup norm. -/ +def momentVector (a t : Fin n → ℝ) (p : ℕ) : EuclideanSpace ℝ (Fin n) := + WithLp.toLp 2 (fun i => a i * t i ^ p) + +@[simp] theorem momentVector_apply (a t : Fin n → ℝ) (p : ℕ) (i : Fin n) : + momentVector a t p i = a i * t i ^ p := rfl + +/-- Exactly the source span of the first three weighted modal moments. -/ +def quadraticMomentSpace (a t : Fin n → ℝ) : Submodule ℝ (EuclideanSpace ℝ (Fin n)) := + Submodule.span ℝ {momentVector a t 0, momentVector a t 1, momentVector a t 2} + +/-- A general weighted quadratic, with all three real coefficients explicit. -/ +def quadraticVector (a t : Fin n → ℝ) (c0 c1 c2 : ℝ) : EuclideanSpace ℝ (Fin n) := + c0 • momentVector a t 0 + c1 • momentVector a t 1 + c2 • momentVector a t 2 + +@[simp] theorem quadraticVector_apply (a t : Fin n → ℝ) (c0 c1 c2 : ℝ) (i : Fin n) : + quadraticVector a t c0 c1 c2 i = a i * (c0 + c1 * t i + c2 * t i ^ 2) := by + simp [quadraticVector, momentVector] + ring + +theorem quadraticVector_mem (a t : Fin n → ℝ) (c0 c1 c2 : ℝ) : + quadraticVector a t c0 c1 c2 ∈ quadraticMomentSpace a t := by + exact Submodule.mem_span_triple.mpr ⟨c0,c1,c2,rfl⟩ + +/-- The actual orthogonal residual, defined without any supplied minimizer. -/ +def projectionResidual (a t : Fin n → ℝ) (p : ℕ) : EuclideanSpace ℝ (Fin n) := + momentVector a t p - (quadraticMomentSpace a t).starProjection (momentVector a t p) + +/-- The source κ_p: norm of the true orthogonal residual. -/ +def kappa (a t : Fin n → ℝ) (p : ℕ) : ℝ := ‖projectionResidual a t p‖ + +@[simp] theorem kappa_nonneg (a t : Fin n → ℝ) (p : ℕ) : 0 ≤ kappa a t p := + norm_nonneg _ + +/-- κ_p is literally the distance to the source quadratic-moment subspace. -/ +theorem kappa_eq_infDist (a t : Fin n → ℝ) (p : ℕ) : + kappa a t p = Metric.infDist (momentVector a t p) (quadraticMomentSpace a t) := by + simpa only [kappa, projectionResidual, dist_eq_norm] using + (quadraticMomentSpace a t).dist_starProjection_eq_infDist (momentVector a t p) + +/-- Projection lies in the span, hence genuine coefficients always exist, +even if the three moment vectors are linearly dependent. -/ +theorem exists_projection_coefficients (a t : Fin n → ℝ) (p : ℕ) : + ∃ c0 c1 c2 : ℝ, + quadraticVector a t c0 c1 c2 = + (quadraticMomentSpace a t).starProjection (momentVector a t p) := by + exact Submodule.mem_span_triple.mp + ((quadraticMomentSpace a t).starProjection_apply_mem (momentVector a t p)) + +/-- Pointwise attained residual coefficients; no projection certificate is a premise. -/ +theorem exists_projection_residual_coefficients (a t : Fin n → ℝ) (p : ℕ) : + ∃ c0 c1 c2 : ℝ, ∀ i, + projectionResidual a t p i = a i * (t i ^ p-(c0 + c1 * t i + c2 * t i ^ 2)) := by + obtain ⟨c0,c1,c2,hc⟩ := exists_projection_coefficients a t p + refine ⟨c0,c1,c2,fun i => ?_⟩ + simp only [projectionResidual, ← hc, PiLp.sub_apply, momentVector_apply, + quadraticVector_apply] + ring + +/-- Exact finite-coordinate L² norm bridge. -/ +theorem kappa_sq_eq_sum (a t : Fin n → ℝ) (p : ℕ) : + kappa a t p ^ 2 = ∑ i, projectionResidual a t p i ^ 2 := + EuclideanSpace.real_norm_sq_eq _ + +/-- An attained weighted polynomial least-squares objective, valid for all p. -/ +theorem exists_kappa_coefficients (a t : Fin n → ℝ) (p : ℕ) : + ∃ c0 c1 c2 : ℝ, + (∑ i, (a i * (t i ^ p-(c0 + c1 * t i + c2 * t i ^ 2))) ^ 2) = kappa a t p ^ 2 := by + obtain ⟨c0,c1,c2,hc⟩ := exists_projection_residual_coefficients a t p + refine ⟨c0,c1,c2,?_⟩ + rw [kappa_sq_eq_sum] + apply Finset.sum_congr rfl + intro i hi + rw [hc i] + +/-- The actual projection is no farther than every explicit quadratic. -/ +theorem kappa_le_quadratic_residual (a t : Fin n → ℝ) (p : ℕ) (c0 c1 c2 : ℝ) : + kappa a t p ≤ ‖momentVector a t p - quadraticVector a t c0 c1 c2‖ := by + rw [kappa_eq_infDist] + simpa only [dist_eq_norm] using + (Metric.infDist_le_dist_of_mem (x := momentVector a t p) + (quadraticVector_mem a t c0 c1 c2)) + +/-- Full global minimality against every coefficient triple, in literal sums. -/ +theorem kappa_sq_le_quadratic_residual (a t : Fin n → ℝ) (p : ℕ) (c0 c1 c2 : ℝ) : + kappa a t p ^ 2 ≤ ∑ i, (a i * (t i ^ p-(c0 + c1 * t i + c2 * t i ^ 2))) ^ 2 := by + have h := pow_le_pow_left₀ (kappa_nonneg a t p) + (kappa_le_quadratic_residual a t p c0 c1 c2) 2 + rw [EuclideanSpace.real_norm_sq_eq] at h + convert h using 1 + apply Finset.sum_congr rfl + intro i hi + simp only [PiLp.sub_apply, momentVector_apply, quadraticVector_apply] + ring + +/-- Residual is orthogonal to the full source moment span. -/ +theorem projectionResidual_orthogonal (a t : Fin n → ℝ) (p : ℕ) : + projectionResidual a t p ∈ (quadraticMomentSpace a t)ᗮ := + (quadraticMomentSpace a t).sub_starProjection_mem_orthogonal _ + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8SignedGroundResidue.lean b/LeanPool/C145/C145DRE8SignedGroundResidue.lean new file mode 100644 index 0000000000..181e5654c1 --- /dev/null +++ b/LeanPool/C145/C145DRE8SignedGroundResidue.lean @@ -0,0 +1,97 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8ActualFrame + +/-! Source §4.2 signed-ground calibration directly from ordinary H2. We evaluate +the already verified cleared numerator identity at the ground input pole and +a fixed positive second variable. No equality of totalized H2 values at poles +is used. Additive resonances remain permitted. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 C145.ThreePlane +variable {n : ℕ} + +theorem signed_ground_from_actual_H2 + (μ : ℝ) (hμ : 0 < μ) (rates : Fin (n + 1) → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (hGroundRate : rates 0 = μ) + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) + (c0 c1 : ℝ) (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (hGU : ∀ v, U v 0 = c0) (hGV : ∀ v, V v 0 = c1) + (ha : ∀ i, 0 < a i) + (hH : SamePositive rates (C145PhysicalFrame.T U a) (C145PhysicalFrame.T V a)) : + c0 = c1 := by + classical + have hPlane := (samePositive_iff_plane rates hPos _ _).mp hH + have hEval := congrArg (MvPolynomial.eval ![-μ,μ]) hPlane + rw [eval_rhoZ] at hEval + simp only [neg_add_cancel, map_zero] at hEval + have hNode (i : Fin (n + 1)) : (Li rates i).eval (-μ) = if i = 0 then di rates 0 else 0 := by + rw [← hGroundRate] + exact eval_Li_grid rates i 0 + have hSummand (j k : Fin (n + 1)) : + (C145PhysicalFrame.T U a 0 j k-C145PhysicalFrame.T V a 0 j k) * di rates 0* + (Li rates j).eval μ * (Li rates k).eval 0 = + if j = k then + (c0 - c1) * a 0 * di rates 0 * (a j ^ 2 * (Li rates j).eval μ * (Li rates j).eval 0) + else 0 := + by + rw [C145PhysicalFrame.ground_slice U a c0 hU hGU, + C145PhysicalFrame.ground_slice V a c1 hV hGV] + by_cases hjk : j = k + · subst k; simp only [ite_true, mul_one]; ring + · simp only [hjk, ite_false, mul_zero, sub_self, zero_mul] + have hExpansion : + MvPolynomial.eval ![0,-μ,μ] + (numerator rates (C145PhysicalFrame.T U a-C145PhysicalFrame.T V a)) = + (c0-c1) * a 0 * di rates 0* + (∑ j, a j ^ 2 * (Li rates j).eval μ * (Li rates j).eval 0) := by + simp only [numerator, map_sum, map_mul, MvPolynomial.eval_C, eval_L] + change (∑ i, ∑ j, ∑ k, + (C145PhysicalFrame.T U a i j k-C145PhysicalFrame.T V a i j k)* + (Li rates i).eval (-μ) * (Li rates j).eval μ * (Li rates k).eval 0) = _ + simp_rw [hNode] + rw [Fin.sum_univ_succ] + simp only [ite_true, Fin.succ_ne_zero, ite_false, mul_zero, zero_mul, + Finset.sum_const_zero, add_zero] + simp_rw [hSummand] + simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true] + rw [Finset.mul_sum] + rw [hExpansion] at hEval + have hLiPos (j : Fin (n + 1)) (s : ℝ) (hs : 0 ≤ s) : 0 < (Li rates j).eval s := by + simp only [Li, Polynomial.eval_prod, Polynomial.eval_add, + Polynomial.eval_X, Polynomial.eval_C] + apply Finset.prod_pos + intro i hi + exact add_pos_of_nonneg_of_pos hs (hPos i) + have hSum : 0 < (∑ j, a j ^ 2 * (Li rates j).eval μ * (Li rates j).eval 0) := by + apply Finset.sum_pos + · intro j hj + exact mul_pos (mul_pos (sq_pos_of_ne_zero (ne_of_gt (ha j))) + (hLiPos j μ hμ.le)) (hLiPos j 0 le_rfl) + · exact ⟨0,Finset.mem_univ 0⟩ + have hFactor : a 0 * di rates 0* + (∑ j, a j ^ 2 * (Li rates j).eval μ * (Li rates j).eval 0) ≠ 0 := + mul_ne_zero (mul_ne_zero (ne_of_gt (ha 0)) (di_ne_zero rates hRates 0)) (ne_of_gt hSum) + have hProduct : (c0-c1) * (a 0 * di rates 0* + (∑ j, a j ^ 2 * (Li rates j).eval μ * (Li rates j).eval 0)) = 0 := by + convert hEval using 1 + ring + exact sub_eq_zero.mp ((mul_eq_zero.mp hProduct).resolve_right hFactor) + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8SliceRigidity.lean b/LeanPool/C145/C145DRE8SliceRigidity.lean new file mode 100644 index 0000000000..6e9ed2b1ea --- /dev/null +++ b/LeanPool/C145/C145DRE8SliceRigidity.lean @@ -0,0 +1,129 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8PhysicalTensor + +/-! Global finite-dimensional physical slice rigidity, C145 DRE8 Lemma B. -/ + +@[expose] public section + +namespace C145DRE8 +open scoped BigOperators +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +omit [DecidableEq ι] in +theorem matrixSq_neg (R : Matrix ι ι ℝ) : matrixSq (-R) = matrixSq R := by + simp [matrixSq] + +theorem physical_commutator_identity (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (h : ι → ℝ) (i : ι) : + commutator (Matrix.diagonal h) (differenceMatrix Q i) = + -commutator (tensorSlice (physicalDifference Q) h) (physicalMatrix Q i) := by + have hc := physical_slice_commutes Q hQ h i + rw [physical_slice_eq_sum] at hc + have hd : Matrix.diagonal h * Matrix.diagonal (fun j => if i = j then (1 : ℝ) else 0) = + Matrix.diagonal (fun j => if i = j then (1 : ℝ) else 0) * Matrix.diagonal h := by + rw [Matrix.diagonal_mul_diagonal, Matrix.diagonal_mul_diagonal] + congr 1; ext j; ring + rw [differenceMatrix_eq] + unfold commutator + calc + _ = Matrix.diagonal h * physicalMatrix Q i - physicalMatrix Q i * Matrix.diagonal h := by + rw [Matrix.mul_sub, Matrix.sub_mul, hd] + abel + _ = -(tensorSlice (physicalDifference Q) h * physicalMatrix Q i - + physicalMatrix Q i * tensorSlice (physicalDifference Q) h) := by + apply eq_neg_iff_add_eq_zero.mpr + calc + _ = (Matrix.diagonal h + tensorSlice (physicalDifference Q) h) * physicalMatrix Q i - + physicalMatrix Q i * (Matrix.diagonal h + tensorSlice (physicalDifference Q) h) := by + simp only [Matrix.add_mul, Matrix.mul_add] + abel + _ = 0 := sub_eq_zero.mpr hc + +theorem diagonal_difference_commutator_entry (Q : Matrix ι ι ℝ) (h : ι → ℝ) (i j k : ι) : + commutator (Matrix.diagonal h) (differenceMatrix Q i) j k = + (h j - h k) * physicalDifference Q i j k := by + simp only [commutator, Matrix.sub_apply, Matrix.diagonal_mul, Matrix.mul_diagonal, + differenceMatrix] + ring + +/-- The physical slice commutator is bounded using actual orthogonal tensor multiplication. -/ +theorem physical_slice_commutator_bound (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (h : ι → ℝ) : + (∑ i, matrixSq (commutator (Matrix.diagonal h) (differenceMatrix Q i))) ≤ + 2 * matrixSq (tensorSlice (physicalDifference Q) h) := by + simp_rw [physical_commutator_identity Q hQ, matrixSq_neg] + exact physical_commutator_bound Q _ hQ + +variable {ρ : Type*} [Fintype ρ] + +/-- Squared distance between vertices in the full family of signature coordinates. -/ +noncomputable def signatureSq (h : ρ → ι → ℝ) (j k : ι) : ℝ := + ∑ r, (h r j - h r k) ^ 2 +/-- Sum of the squared Frobenius norms of the slices along all signature vectors. -/ +noncomputable def sliceSq (E : ι → ι → ι → ℝ) (h : ρ → ι → ℝ) : ℝ := + ∑ r, matrixSq (tensorSlice E (h r)) + +theorem signature_separation_energy (Q : Matrix ι ι ℝ) (h : ρ → ι → ℝ) (δ : ℝ) + (hsep : ∀ j k, j ≠ k → δ ^ 2 ≤ signatureSq h j k) : + δ ^ 2 * offSq (physicalDifference Q) ≤ + ∑ r, ∑ i, matrixSq (commutator (Matrix.diagonal (h r)) (differenceMatrix Q i)) := by + have hp (i j k : ι) : + δ ^ 2 * (if j = k then 0 else physicalDifference Q i j k ^ 2) ≤ + ∑ r, ((h r j - h r k) * physicalDifference Q i j k) ^ 2 := by + by_cases hjk : j = k + · simp [hjk] + · simp only [hjk, ↓reduceIte] + have hh := mul_le_mul_of_nonneg_right (hsep j k hjk) (sq_nonneg (physicalDifference Q i j k)) + simpa only [signatureSq, mul_pow, Finset.sum_mul] using hh + have hh := Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => + Finset.sum_le_sum (fun j (_ : j ∈ Finset.univ) => + Finset.sum_le_sum (fun k (_ : k ∈ Finset.univ) => hp i j k))) + simp only [← Finset.mul_sum] at hh + change δ ^ 2 * offSq (physicalDifference Q) ≤ _ at hh + refine hh.trans_eq ?_ + simp only [matrixSq, diagonal_difference_commutator_entry] + symm + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro i hi + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro j hj + exact Finset.sum_comm + +/-- DRE8 equation (5.4), with the separating-signature lower bound stated pointwise. -/ +theorem physical_off_slice_bound (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (h : ρ → ι → ℝ) (δ : ℝ) + (hsep : ∀ j k, j ≠ k → δ ^ 2 ≤ signatureSq h j k) : + δ ^ 2 * offSq (physicalDifference Q) ≤ 2 * sliceSq (physicalDifference Q) h := by + apply (signature_separation_energy Q h δ hsep).trans + have hh := Finset.sum_le_sum (fun r (_ : r ∈ Finset.univ) => + physical_slice_commutator_bound Q hQ (h r)) + simpa only [sliceSq, Finset.mul_sum] using hh + +/-- Full global physical slice rigidity, DRE8 Lemma B (5.1). +Q is an actual finite real orthogonal matrix fixing the vector of ones. +No physical commutation or target norm inequality is supplied as an assumption. -/ +theorem physical_slice_rigidity (Q : Matrix ι ι ℝ) (hQ : Q.transpose * Q = 1) + (hunit : ∀ i, ∑ v, Q i v = 1) (h : ρ → ι → ℝ) (δ : ℝ) + (hsep : ∀ j k, j ≠ k → δ ^ 2 ≤ signatureSq h j k) : + δ ^ 2 * tensorSq (physicalDifference Q) ≤ + ((Fintype.card ι : ℝ) + 2) * sliceSq (physicalDifference Q) h := by + have hc := physical_common_unit_tensor_bound Q hQ hunit + have hs := physical_off_slice_bound Q hQ h δ hsep + have hδ := sq_nonneg δ + have hN : (0 : ℝ) ≤ (Fintype.card ι : ℝ) + 2 := by positivity + have h1 := mul_le_mul_of_nonneg_left hc hδ + have h2 := mul_le_mul_of_nonneg_left hs hN + nlinarith + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8SpectralContraction.lean b/LeanPool/C145/C145DRE8SpectralContraction.lean new file mode 100644 index 0000000000..cce79a85d5 --- /dev/null +++ b/LeanPool/C145/C145DRE8SpectralContraction.lean @@ -0,0 +1,213 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8CubicCancellation + +/-! DRE8 (6.4), squared Frobenius form, in orthonormal modal coordinates. +The spectral band is an explicit premise: ell <= full rates <= u < 2ell. +All norms are literal finite sums. No target norm bound is a certificate. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 C145.ThreePlane +variable {n : ℕ} + +/-- The cubic monomial minus the quadratic approximation used in the spectral bound. -/ +def chebyshevResidual (t : ℝ) : ℝ := + t ^ 3 - (1 / 32 - 9 / 16 * t + 3 / 2 * t ^ 2) + +/-- Standard monic Chebyshev residual, with exact rational coefficients. -/ +theorem chebyshev_residual_bound (t : ℝ) (ht0 : 0 ≤ t) (ht1 : t ≤ 1) : + chebyshevResidual t ^ 2 ≤ (1 / 1024 : ℝ) := by + have hlow := mul_nonneg ht0 (sq_nonneg (t-3 / 4)) + have hhigh := mul_nonneg (sub_nonneg.mpr ht1) (sq_nonneg (t-1 / 4)) + have hlo : -(1 / 32 : ℝ) ≤ chebyshevResidual t := by + dsimp [chebyshevResidual]; nlinarith [hlow] + have hhi : chebyshevResidual t ≤ (1 / 32 : ℝ) := by + dsimp [chebyshevResidual]; nlinarith [hhigh] + nlinarith [sq_nonneg (chebyshevResidual t)] + +theorem tensorSq_nonneg (V : Tensor n) : 0 ≤ tensorSq V := by + unfold tensorSq; positivity + +/-- Cauchy--Schwarz followed by the exact three-index Frobenius sum. -/ +theorem tensorSlice_cauchy (V : Tensor n) (x : Fin n → ℝ) : + matrixSq (tensorSlice V x) ≤ (∑ i, x i ^ 2) * tensorSq V := by + classical + have hsum : (∑ j, ∑ k, ∑ i, V i j k ^ 2) = tensorSq V := by + unfold tensorSq + calc + _ = ∑ j, ∑ i, ∑ k, V i j k ^ 2 := by + apply Finset.sum_congr rfl; intro j hj + exact Finset.sum_comm + _ = _ := Finset.sum_comm + calc + _ ≤ ∑ j, ∑ k, (∑ i, x i ^ 2) * (∑ i, V i j k ^ 2) := by + apply Finset.sum_le_sum; intro j hj + apply Finset.sum_le_sum; intro k hk + simpa only [tensorSlice, Finset.mem_univ, Finset.sum_const_zero, + Finset.sum_filter, Finset.filter_true_of_mem, true_and] using + (Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset (Fin n)) x + (fun i => V i j k)) + _ = _ := by simp_rw [← Finset.mul_sum]; rw [hsum] + +/-- The interval-normalized modal coordinate really lies in [0,1]. -/ +theorem band_coordinate (rates : Fin n → ℝ) (ell u : ℝ) (hw : ell < u) + (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) (i : Fin n) : + 0 ≤ (rates i-ell) / (u-ell) ∧ (rates i-ell) / (u-ell) ≤ 1 := by + constructor + · exact div_nonneg (sub_nonneg.mpr (hlo i)) (sub_nonneg.mpr hw.le) + · exact (div_le_one (sub_pos.mpr hw)).mpr (by linarith [hhi i]) + +/-- Every positive triangle gap is at least 2ell-u. Rates include mu already. -/ +theorem spectral_triangle_gap (rates : Fin n → ℝ) (ell u : ℝ) + (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) (i j k : Fin n) : + 2 * ell-u ≤ rates i + rates j-rates k := by linarith [hlo i,hlo j,hhi k] + +/-- Literal Xi is bounded away from zero only under the stated source band. -/ +theorem spectral_xi_square (rates : Fin n → ℝ) (ell u : ℝ) + (hband : u < 2 * ell) (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) + (i j k : Fin n) : + (2 * ell-u) ^ 6 ≤ (MvPolynomial.eval ![-rates k,-rates i,-rates j] Xi) ^ 2 := by + let g := 2 * ell-u + have hg : 0 ≤ g := by dsimp [g]; linarith + have h1 := spectral_triangle_gap rates ell u hlo hhi i j k + have h2 := spectral_triangle_gap rates ell u hlo hhi i k j + have h3 := spectral_triangle_gap rates ell u hlo hhi j k i + have hg1 : 0 ≤ rates i + rates j-rates k := hg.trans h1 + have hg2 : 0 ≤ rates i + rates k-rates j := hg.trans h2 + have hp : g ^ 3 ≤ (rates i + rates j-rates k) * + (rates i + rates k-rates j) * (rates j + rates k-rates i) := by + have hh := mul_le_mul h1 h2 hg (hg.trans h1) + have hh2 := mul_le_mul hh h3 hg (mul_nonneg hg1 hg2) + simpa [g, pow_succ] using hh2 + rw [xi_negative_node_factors, neg_sq] + have hg3 : 0 ≤ g ^ 3 := by positivity + have hp2 := pow_le_pow_left₀ hg3 hp 2 + simpa only [← pow_mul] using hp2 + +/-- Full orthonormal tensor energy is controlled by Xi multiplication. -/ +theorem spectral_tensor_bound (rates : Fin n → ℝ) (V : Tensor n) (ell u : ℝ) + (hband : u < 2 * ell) (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) : + (2 * ell-u) ^ 6 * tensorSq V ≤ tensorSq (xiWeighted rates V) := by + classical + unfold tensorSq + simp only [Finset.mul_sum] + apply Finset.sum_le_sum; intro i hi + apply Finset.sum_le_sum; intro j hj + apply Finset.sum_le_sum; intro k hk + have h := mul_le_mul_of_nonneg_right + (spectral_xi_square rates ell u hband hlo hhi i j k) (sq_nonneg (V i j k)) + simpa only [xiWeighted, mul_pow] using h + +/-- Residual weighted-vector energy has the exact source factor 1/32 squared. -/ +theorem chebyshev_vector_bound (a t : Fin n → ℝ) + (ht0 : ∀ i, 0 ≤ t i) (ht1 : ∀ i, t i ≤ 1) : + 1024 * (∑ i, (a i * chebyshevResidual (t i)) ^ 2) ≤ ∑ i, a i ^ 2 := by + classical + rw [Finset.mul_sum] + apply Finset.sum_le_sum; intro i hi + have h := mul_le_mul_of_nonneg_left + (chebyshev_residual_bound (t i) (ht0 i) (ht1 i)) (sq_nonneg (a i)) + rw [mul_pow] + nlinarith + +/-- Exact scaled slice energy, avoiding any default matrix/Pi norm. -/ +theorem matrixSq_scale (M : Matrix (Fin n) (Fin n) ℝ) (c : ℝ) : + matrixSq (fun j k => c * M j k) = c ^ 2 * matrixSq M := by + unfold matrixSq + simp only [mul_pow, Finset.mul_sum] + +/-- Quantitative kernel contraction for any explicit quadratic residual. +Choosing a least-squares projection gives source kappa_3; its existence or +minimization is not presumed by this finite-coordinate theorem. -/ +theorem kernel_residual_contraction (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (ell u : ℝ) (hw : ell < u) + (hband : u < 2 * ell) (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) + (c0 c1 c2 : ℝ) : + (2 * ell-u) ^ 6 * matrixSq (tensorSlice (xiWeighted rates V) a) ≤ + (u-ell) ^ 6 * + (∑ i, (a i * (((rates i-ell) / (u-ell)) ^ 3 - + (c0 + c1 * ((rates i-ell) / (u-ell)) + c2 * ((rates i-ell) / (u-ell)) ^ 2))) ^ 2) * + tensorSq (xiWeighted rates V) := by + let t := fun i => (rates i-ell) / (u-ell) + let r := fun i => a i * (t i ^ 3-(c0 + c1 * t i + c2 * t i ^ 2)) + have hshift := shifted_weighted_moments a rates V hm ell (u-ell) + have hs : tensorSlice (xiWeighted rates V) a = + fun j k => (u-ell) ^ 3 * tensorSlice V r j k := by + rw [cubic_cancellation a rates V hm ell (u-ell) (sub_ne_zero.mpr (ne_of_gt hw))] + rw [cubic_residual_slice a t V hshift c0 c1 c2] + have he : matrixSq (tensorSlice (xiWeighted rates V) a) = + (u-ell) ^ 6 * matrixSq (tensorSlice V r) := by + rw [hs, matrixSq_scale]; ring + have hc := tensorSlice_cauchy V r + have hb := spectral_tensor_bound rates V ell u hband hlo hhi + have hw6 : 0 ≤ (u-ell) ^ 6 := by positivity + have hg6 : 0 ≤ (2 * ell-u) ^ 6 := by positivity + have hr : 0 ≤ ∑ i, r i ^ 2 := by positivity + calc + _ = (u-ell) ^ 6 * ((2 * ell-u) ^ 6 * matrixSq (tensorSlice V r)) := by rw [he]; ring + _ ≤ (u-ell) ^ 6 * ((2 * ell-u) ^ 6 * ((∑ i, r i ^ 2) * tensorSq V)) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hc hg6) hw6 + _ = (u-ell) ^ 6 * (∑ i, r i ^ 2) * ((2 * ell-u) ^ 6 * tensorSq V) := by ring + _ ≤ (u-ell) ^ 6 * (∑ i, r i ^ 2) * tensorSq (xiWeighted rates V) := + mul_le_mul_of_nonneg_left hb (mul_nonneg hw6 hr) + +/-- DRE8 explicit Chebyshev bound (6.4), squared, with source factor 1/1024. -/ +theorem kernel_chebyshev_contraction (a rates : Fin n → ℝ) (V : Tensor n) + (hm : WeightedMoments a rates V) (ell u : ℝ) (hw : ell < u) + (hband : u < 2 * ell) (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) : + 1024 * (2 * ell-u) ^ 6 * matrixSq (tensorSlice (xiWeighted rates V) a) ≤ + (u-ell) ^ 6 * (∑ i, a i ^ 2) * tensorSq (xiWeighted rates V) := by + let t := fun i => (rates i-ell) / (u-ell) + have ht : ∀ i, 0 ≤ t i ∧ t i ≤ 1 := band_coordinate rates ell u hw hlo hhi + have hc := kernel_residual_contraction a rates V hm ell u hw hband hlo hhi + (1 / 32) (-9 / 16) (3 / 2) + have hpoly : (∑ i, (a i * (t i ^ 3 - ((1 / 32 : ℝ) + (-9 / 16) * t i + (3 / 2) * t i ^ 2))) ^ 2) = + ∑ i, (a i * chebyshevResidual (t i)) ^ 2 := by + apply Finset.sum_congr rfl; intro i hi + dsimp [chebyshevResidual]; ring + change (2 * ell-u) ^ 6 * matrixSq (tensorSlice (xiWeighted rates V) a) ≤ + (u - ell) ^ 6 * + (∑ i, (a i * (t i ^ 3 - ((1 / 32 : ℝ) + (-9 / 16) * t i + (3 / 2) * t i ^ 2))) ^ 2) * + tensorSq (xiWeighted rates V) at hc + rw [hpoly] at hc + have hr := chebyshev_vector_bound a t (fun i => (ht i).1) (fun i => (ht i).2) + have hw6 : 0 ≤ (u-ell) ^ 6 := by positivity + have hE := tensorSq_nonneg (xiWeighted rates V) + have h1 := mul_le_mul_of_nonneg_left hc (by norm_num : (0 : ℝ) ≤ 1024) + have h2 := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hr hw6) hE + calc + _ = 1024 * ((2 * ell-u) ^ 6 * matrixSq (tensorSlice (xiWeighted rates V) a)) := by ring + _ ≤ 1024 * ((u-ell) ^ 6 * (∑ i, (a i * chebyshevResidual (t i)) ^ 2) * + tensorSq (xiWeighted rates V)) := h1 + _ = ((u-ell) ^ 6 * (1024 * ∑ i, (a i * chebyshevResidual (t i)) ^ 2)) * + tensorSq (xiWeighted rates V) := by ring + _ ≤ _ := h2 + +/-- Actual ordinary H2 data implies the quantitative physical modal estimate. +No moment, Xi factorization, or desired norm inequality is an input. -/ +theorem actual_H2_chebyshev_contraction (a rates : Fin n → ℝ) + (ha : ∀ i, a i ≠ 0) (hRates : Function.Injective rates) + (E : Tensor n) (hSym : FullSymTensor E) + (hData : NullRegular rates (weightedTensor a E)) (ell u : ℝ) (hw : ell < u) + (hband : u < 2 * ell) (hlo : ∀ i, ell ≤ rates i) (hhi : ∀ i, rates i ≤ u) : + 1024 * (2 * ell-u) ^ 6 * matrixSq (tensorSlice E a) ≤ + (u-ell) ^ 6 * (∑ i, a i ^ 2) * tensorSq E := by + obtain ⟨R,_,_,hE,hm,_⟩ := actual_H2_physical_kernel a rates ha hRates E hSym hData ell (u-ell) + rw [hE] + exact kernel_chebyshev_contraction a rates _ hm ell u hw hband hlo hhi + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8TensorSpace.lean b/LeanPool/C145/C145DRE8TensorSpace.lean new file mode 100644 index 0000000000..fee21f5fd0 --- /dev/null +++ b/LeanPool/C145/C145DRE8TensorSpace.lean @@ -0,0 +1,67 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8CommonUnit +public import LeanPool.C145.C145H2NumeratorData +public import Mathlib.Analysis.InnerProductSpace.PiL2 + +/-! Shared literal Euclidean realization of the source Frobenius tensor space. +The norm is unweighted; calibrated overlaps belong inside the response map. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +variable {N : ℕ} + +/-- The Euclidean space whose coordinates are triples of finite indices. -/ +abbrev TensorSpace (N : ℕ) := EuclideanSpace ℝ (Fin N × Fin N × Fin N) + +/-- Read the Euclidean coordinate at an index triple as a tensor entry. -/ +def toTensor (E : TensorSpace N) : C145.H2.Tensor N := fun i j k => E (i,j,k) +/-- Place the tensor entries into Euclidean space indexed by triples. -/ +def fromTensor (E : C145.H2.Tensor N) : TensorSpace N := + WithLp.toLp 2 (fun p => E p.1 p.2.1 p.2.2) + +@[simp] theorem toTensor_apply (E : TensorSpace N) (i j k : Fin N) : + toTensor E i j k = E (i,j,k) := rfl +@[simp] theorem fromTensor_apply (E : C145.H2.Tensor N) (p : Fin N × Fin N × Fin N) : + fromTensor E p = E p.1 p.2.1 p.2.2 := rfl +@[simp] theorem toTensor_fromTensor (E : C145.H2.Tensor N) : + toTensor (fromTensor E) = E := rfl +@[simp] theorem fromTensor_toTensor (E : TensorSpace N) : fromTensor (toTensor E) = E := by + ext p + rfl + +/-- Exact unweighted Frobenius-coordinate linear equivalence. -/ +def tensorEquiv : TensorSpace N ≃ₗ[ℝ] C145.H2.Tensor N where + toFun := toTensor + invFun := fromTensor + left_inv := fromTensor_toTensor + right_inv := toTensor_fromTensor + map_add' E F := by funext i j k; rfl + map_smul' c E := by funext i j k; rfl + +@[simp] theorem tensorEquiv_apply (E : TensorSpace N) : tensorEquiv E = toTensor E := rfl +@[simp] theorem tensorEquiv_symm_apply (E : C145.H2.Tensor N) : + tensorEquiv.symm E = fromTensor E := rfl + +/-- The Hilbert norm is literally the source squared Frobenius norm. -/ +theorem norm_sq_eq_tensorSq (E : TensorSpace N) : ‖E‖ ^ 2 = tensorSq (toTensor E) := by + rw [EuclideanSpace.real_norm_sq_eq] + simp only [tensorSq, toTensor, Fintype.sum_prod_type] + +theorem norm_fromTensor_sq (E : C145.H2.Tensor N) : ‖fromTensor E‖ ^ 2 = tensorSq E := by + rw [norm_sq_eq_tensorSq, toTensor_fromTensor] + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8TransferInverse.lean b/LeanPool/C145/C145DRE8TransferInverse.lean new file mode 100644 index 0000000000..c5e8d261f2 --- /dev/null +++ b/LeanPool/C145/C145DRE8TransferInverse.lean @@ -0,0 +1,190 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8ActualCalibratedInverse +public import LeanPool.C145.C145DRE8SignedGroundResidue + +/-! Source Theorem A from own H1/H2 alone. H1 derives the unknown size, +mode matching and positive overlaps; the fixed-positive-variable cleared +numerator argument derives the signed common ground from H2. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.UncalibratedSmallH2 + +theorem actual_H1_H2_theoremA_vertex_identification {m n : ℕ} + (μ c0 c1 : ℝ) (hμ : 0 < μ) + (Q0 : Fin (m + 1) → Fin (m + 1) → ℝ) + (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates0 b0 : Fin (m + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround0 : ∀ v, Q0 v 0 = c0) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hRateGround0 : rates0 0 = μ) + (hRateGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < C145.Pulse.modalOverlap Q0 b0 i) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hlo : ∀ i : Fin m, ell ≤ rates0 i.succ) (hhi : ∀ i : Fin m, rates0 i.succ ≤ u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ (b0 j-b0 k) ^ 2) + (hq : sourceQChebyshevSq b0 ell u delta < 1) + (hH1 : ∀ s : ℝ, 0 < s → + C145.H1.firstTransfer rates0 (C145.Pulse.modalOverlap Q0 b0) s = + C145.H1.firstTransfer rates1 (C145.Pulse.modalOverlap Q1 b1) s) + (hH2 : ∀ s t : ℝ, 0 < s → 0 < t → + C145.H2.H rates0 + (C145PhysicalFrame.T Q0 (C145.Pulse.modalOverlap Q0 b0)) s t = + C145.H2.H rates1 + (C145PhysicalFrame.T Q1 (C145.Pulse.modalOverlap Q1 b1)) s t) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap Q0 b0 i) ∧ + c0 = c1 ∧ (∑ v, b0 v) = (∑ w, b1 w) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u) ∧ + (∀ v : Fin (m + 1), b1 (π v) = b0 v) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u) := by + classical + let a0 : Fin (m + 1) → ℝ := C145.Pulse.modalOverlap Q0 b0 + let a1 : Fin (n + 1) → ℝ := C145.Pulse.modalOverlap Q1 b1 + obtain ⟨e, hSize, heGround, heRates, heOverlaps⟩ := + C145.H1.known_ground_positive_modal_identification μ hμ rates0 a0 rates1 a1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 ha0 ha1 hH1 + -- Size equality is a data-derived fact; the modal map is retained. + subst n + let Q1e : Fin (m + 1) → Fin (m + 1) → ℝ := columnReindex Q1 e + let r0 : Fin m → ℝ := fun i => rates0 i.succ + have hQ1e : C145PhysicalFrame.ColumnOrthonormal Q1e := + columnReindex_columnOrthonormal Q1 e hQ1 + have hG1ePre : ∀ v, Q1e v 0 = c1 := by + intro v + change Q1 v (e 0) = c1 + rw [heGround,hGround1] + have hResidualRates : Function.Injective r0 := by + intro i j hij + apply Fin.succ_inj.mp + apply hRates0 + exact hij + have hResidualPos : ∀ i : Fin m, 0 < r0 i := by + intro i + exact lt_trans hμ (hAbove0 i) + have hFull : C145.H2.fullRates μ r0 = rates0 := + fullRates_eq_own μ rates0 hRateGround0 + have hA : (fun i => a1 (e i)) = a0 := funext heOverlaps + have hLam : (fun i => rates1 (e i)) = rates0 := funext heRates + have hT : C145PhysicalFrame.T Q1e a0 = + (fun i j k => C145PhysicalFrame.T Q1 a1 (e i) (e j) (e k)) := by + funext i j k + simpa only [Q1e, hA] using tensor_columnReindex Q1 a1 e i j k + have hAlignedResponse : ∀ s t : ℝ, + C145.H2.H rates0 (C145PhysicalFrame.T Q1e a0) s t = + C145.H2.H rates1 (C145PhysicalFrame.T Q1 a1) s t := by + intro s t + have h := H_modal_reindex rates1 (C145PhysicalFrame.T Q1 a1) e s t + rw [hLam, ← hT] at h + exact h + have hHAligned : C145.H2.SamePositive (C145.H2.fullRates μ r0) + (C145PhysicalFrame.T Q0 a0) (C145PhysicalFrame.T Q1e a0) := by + intro s t hs ht + rw [hFull] + exact (hH2 s t hs ht).trans (hAlignedResponse s t).symm + have hPos0 : ∀ i, 0 < rates0 i := by + intro i + rcases Fin.eq_zero_or_eq_succ i with hi | ⟨j,hj⟩ + · rw [hi,hRateGround0]; exact hμ + · rw [hj]; exact hμ.trans (hAbove0 j) + have hHOwn : C145.H2.SamePositive rates0 + (C145PhysicalFrame.T Q0 a0) (C145PhysicalFrame.T Q1e a0) := by + rw [← hFull] + exact hHAligned + have hConstant : c0 = c1 := signed_ground_from_actual_H2 μ hμ rates0 hRates0 hPos0 + hRateGround0 Q0 Q1e a0 c0 c1 hQ0 hQ1e hGround0 hG1ePre ha0 hHOwn + have hG1e : ∀ v, Q1e v 0 = c0 := by + intro v + rw [hG1ePre,← hConstant] + -- This derives the arbitrary-dimension vertex map from actual full H2. + obtain ⟨π, hDeltaRaw, hRowsRaw⟩ := + actual_calibrated_H2_vertex_identification μ r0 hResidualRates Q0 Q1e b0 c0 + hQ0 hQ1e (fun i => ne_of_gt (ha0 i)) hGround0 hG1e hHAligned + ell u hw hband hlo hhi delta hd hsep hq + have hDelta : ∀ (w v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0 := by + intro w v + exact hDeltaRaw w v + have hRows : ∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i := by + intro v i + exact hRowsRaw v i + have hGenerator : ∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u := by + intro v u + unfold C145CoordinatePermutation.spectralGenerator + congr 1 + calc + (∑ j, rates1 j * Q1 (π v) j * Q1 (π u) j) = + ∑ i, rates1 (e i) * Q1 (π v) (e i) * Q1 (π u) (e i) := + (e.sum_comp (fun j => rates1 j * Q1 (π v) j * Q1 (π u) j)).symm + _ = ∑ i, rates0 i * Q0 v i * Q0 u i := by + apply Finset.sum_congr rfl + intro i hi + rw [heRates i, hRows v i, hRows u i] + have hPort : ∀ v : Fin (m + 1), b1 (π v) = b0 v := by + intro v + have hReconstruct1 := congrFun (spectralPort_modalOverlap Q1 b1 hQ1) (π v) + have hReconstruct0 := congrFun (spectralPort_modalOverlap Q0 b0 hQ0) v + change (∑ j, a1 j * Q1 (π v) j) = b1 (π v) at hReconstruct1 + change (∑ i, a0 i * Q0 v i) = b0 v at hReconstruct0 + calc + b1 (π v) = ∑ j, a1 j * Q1 (π v) j := hReconstruct1.symm + _ = ∑ i, a1 (e i) * Q1 (π v) (e i) := + (e.sum_comp (fun j => a1 j * Q1 (π v) j)).symm + _ = ∑ i, a0 i * Q0 v i := by + apply Finset.sum_congr rfl + intro i hi + rw [heOverlaps i, hRows v i] + _ = b0 v := hReconstruct0 + have hMeans : (∑ v,b0 v) = (∑ v,b1 v) := by + calc + _ = ∑ v,b1 (π v) := by + apply Finset.sum_congr rfl; intro v hv; exact (hPort v).symm + _ = _ := Equiv.sum_comp π b1 + have hL : ∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u := by + intro v u + simp only [C145CoordinatePermutation.decayLaplacian, hGenerator, + π.apply_eq_iff_eq] + exact ⟨e, rfl, heGround, heRates, heOverlaps, hConstant, hMeans, + π, hDelta, hRows, hGenerator, hPort, hL⟩ + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DRE8WeightedKernel.lean b/LeanPool/C145/C145DRE8WeightedKernel.lean new file mode 100644 index 0000000000..c054a0e54d --- /dev/null +++ b/LeanPool/C145/C145DRE8WeightedKernel.lean @@ -0,0 +1,176 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145SixFixedProducts +public import Mathlib.Tactic.FieldSimp +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.Positivity +public import Mathlib.Tactic.Ring +public import Mathlib.Tactic.SplitIfs + +/-! DRE8 (6.1): normalize the accepted *weighted* ordinary H2 kernel into +orthonormal modal coordinates. Nonzero calibrated overlaps are explicit. +All moments below are conclusions of actual H2 null data, never premises +in the final response bridge. Rates are the full rates, including decay. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 C145.ThreePlane +variable {n : ℕ} + +/-- Multiply each tensor entry by the product of its three modal overlaps. -/ +def weightedTensor (a : Fin n → ℝ) (E : Tensor n) : Tensor n := + fun i j k => a i * a j * a k * E i j k + +/-- Divide each tensor entry by the product of its three modal overlaps. -/ +def unweightedTensor (a : Fin n → ℝ) (T : Tensor n) : Tensor n := + fun i j k => T i j k / (a i * a j * a k) + +/-- The weighted moment and contraction identities used by the residual-kernel proof. -/ +def WeightedMoments (a rates : Fin n → ℝ) (V : Tensor n) : Prop := + (∀ p : ℕ, p ≤ 2 → ∀ j k, ∑ i, (a i * rates i ^ p) * V i j k = 0) ∧ + (∀ p : ℕ, p ≤ 2 → ∀ i k, ∑ j, (a j * rates j ^ p) * V i j k = 0) ∧ + (∀ p : ℕ, p ≤ 2 → ∀ i j, ∑ k, (a k * rates k ^ p) * V i j k = 0) + +/-- Nonzero calibration makes normalization an actual inverse, including n=0. -/ +theorem unweighted_weighted (a : Fin n → ℝ) (ha : ∀ i, a i ≠ 0) (E : Tensor n) : + unweightedTensor a (weightedTensor a E) = E := by + funext i j k + simp [unweightedTensor, weightedTensor, ha] + +/-- Calibration preserves full three-slot symmetry; the weight is a symmetric product. -/ +theorem weightedTensor_symmetric (a : Fin n → ℝ) (E : Tensor n) + (hE : FullSymTensor E) : FullSymTensor (weightedTensor a E) := by + intro e v + have hw : a (v (e 1)) * a (v (e 2)) * a (v (e 0)) = + a (v 1) * a (v 2) * a (v 0) := by + have h := Fintype.prod_equiv e (fun r => a (v (e r))) (fun r => a (v r)) + (fun r => rfl) + convert h using 1 <;> simp [Fin.prod_univ_succ] <;> ring + have hh := hE e v + change E (v (e 1)) (v (e 2)) (v (e 0)) = E (v 1) (v 2) (v 0) at hh + change a (v (e 1)) * a (v (e 2)) * a (v (e 0)) * + E (v (e 1)) (v (e 2)) (v (e 0)) = + a (v 1) * a (v 2) * a (v 0) * E (v 1) (v 2) (v 0) + rw [hw, hh] + +/-- Literal auxiliary physical V in DRE8 (6.1). -/ +def physicalV (a rates : Fin n → ℝ) (R : P3) : Tensor n := + unweightedTensor a (gridResidue rates R) + +/-- Actual weighted residue factorization becomes E=Xi*V, without changing norms. -/ +theorem normalize_residue (a rates : Fin n → ℝ) (ha : ∀ i, a i ≠ 0) + (E : Tensor n) (R : P3) (hE : weightedTensor a E = Res rates R) : + E = xiWeighted rates (physicalV a rates R) := by + funext i j k + have h := congrFun (congrFun (congrFun hE i) j) k + rw [res_eq_xiWeighted_gridResidue] at h + change a i * a j * a k * E i j k = + MvPolynomial.eval ![-rates k, -rates i, -rates j] Xi * gridResidue rates R i j k at h + dsimp [xiWeighted, physicalV, unweightedTensor] + field_simp [ha i, ha j, ha k] + nlinarith [h] + +/-- Divide the accepted quotient moments by the *other* two overlaps. -/ +theorem normalize_moments (a rates : Fin n → ℝ) (ha : ∀ i, a i ≠ 0) + (T : Tensor n) (hT : AllSlotMoments rates T) : + WeightedMoments a rates (unweightedTensor a T) := by + classical + refine ⟨?_, ?_, ?_⟩ + · intro p hp j k + calc + _ = (∑ i, rates i ^ p * T i j k) / (a j * a k) := by + rw [Finset.sum_div] + apply Finset.sum_congr rfl; intro i hi + dsimp [unweightedTensor] + field_simp [ha i, ha j, ha k] + _ = 0 := by rw [hT.1 p hp]; simp + · intro p hp i k + calc + _ = (∑ j, rates j ^ p * T i j k) / (a i * a k) := by + rw [Finset.sum_div] + apply Finset.sum_congr rfl; intro j hj + dsimp [unweightedTensor] + field_simp [ha i, ha j, ha k] + _ = 0 := by rw [hT.2.1 p hp]; simp + · intro p hp i j + calc + _ = (∑ k, rates k ^ p * T i j k) / (a i * a j) := by + rw [Finset.sum_div] + apply Finset.sum_congr rfl; intro k hk + dsimp [unweightedTensor] + field_simp [ha i, ha j, ha k] + _ = 0 := by rw [hT.2.2 p hp]; simp + +/-- A scalar affine change of rate preserves the three annihilated moments. +No positivity or nonzero width is needed for this algebraic assertion. -/ +theorem affine_scalar_moments (a rates f : Fin n → ℝ) (ell w : ℝ) + (hm : ∀ p : ℕ, p ≤ 2 → ∑ i, (a i * rates i ^ p) * f i = 0) + (p : ℕ) (hp : p ≤ 2) : + ∑ i, (a i * ((rates i - ell) / w) ^ p) * f i = 0 := by + classical + have h0 := hm 0 (by omega) + have h1 := hm 1 (by omega) + have h2 := hm 2 (by omega) + rcases (show p = 0 ∨ p = 1 ∨ p = 2 by omega) with rfl | rfl | rfl + · simpa using h0 + · calc + _ = ((∑ i, (a i * rates i ^ 1) * f i) - + ell * (∑ i, (a i * rates i ^ 0) * f i)) / w := by + simp only [Finset.sum_div, Finset.mul_sum, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl; intro i hi; ring + _ = 0 := by rw [h1, h0]; simp + · calc + _ = ((∑ i, (a i * rates i ^ 2) * f i) - + (2 * ell) * (∑ i, (a i * rates i ^ 1) * f i) + + ell ^ 2 * (∑ i, (a i * rates i ^ 0) * f i)) / w ^ 2 := by + simp only [Finset.sum_div, Finset.mul_sum, ← Finset.sum_sub_distrib, + ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl; intro i hi; ring + _ = 0 := by rw [h2, h1, h0]; simp + +theorem shifted_weighted_moments (a rates : Fin n → ℝ) (V : Tensor n) + (hV : WeightedMoments a rates V) (ell w : ℝ) : + WeightedMoments a (fun i => (rates i - ell) / w) V := by + refine ⟨?_, ?_, ?_⟩ + · intro p hp j k + exact affine_scalar_moments a rates (fun i => V i j k) ell w + (fun p hp => hV.1 p hp j k) p hp + · intro p hp i k + exact affine_scalar_moments a rates (fun j => V i j k) ell w + (fun p hp => hV.2.1 p hp i k) p hp + · intro p hp i j + exact affine_scalar_moments a rates (fun k => V i j k) ell w + (fun p hp => hV.2.2 p hp i j) p hp + +/-- Source-faithful actual H2 bridge. The desired weighted and shifted +moments, and E=Xi*V, are all derived from the accepted ordinary response. +The tensor E is orthonormal; only weightedTensor a E enters H2. -/ +theorem actual_H2_physical_kernel (a rates : Fin n → ℝ) + (ha : ∀ i, a i ≠ 0) (hRates : Function.Injective rates) + (E : Tensor n) (hSym : FullSymTensor E) + (hData : NullRegular rates (weightedTensor a E)) (ell w : ℝ) : + ∃ R : P3, SymPoly R ∧ QAdmissible n R ∧ + E = xiWeighted rates (physicalV a rates R) ∧ + WeightedMoments a rates (physicalV a rates R) ∧ + WeightedMoments a (fun i => (rates i - ell) / w) (physicalV a rates R) := by + obtain ⟨R, hR, _⟩ := + (complete_ordinary_H2_receiving_kernel rates hRates (weightedTensor a E) + (weightedTensor_symmetric a E hSym)).mp hData + have hm := normalize_moments a rates ha (gridResidue rates R) hR.2.2.2 + exact ⟨R, hR.1, hR.2.1, normalize_residue a rates ha E R hR.2.2.1, + hm, shifted_weighted_moments a rates _ hm ell w⟩ + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145DelayKernelTransfer.lean b/LeanPool/C145/C145DelayKernelTransfer.lean new file mode 100644 index 0000000000..cecfed6bb0 --- /dev/null +++ b/LeanPool/C145/C145DelayKernelTransfer.lean @@ -0,0 +1,738 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145UncalibratedSmallH2 +public import Mathlib.Analysis.Convolution +public import Mathlib.Analysis.Normed.Operator.Mul +public import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals +public import Mathlib.MeasureTheory.Integral.Prod +public import Mathlib.MeasureTheory.Integral.Bochner.Set +public import Mathlib.Tactic.FunProp +public import Mathlib.Tactic.FieldSimp +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.Ring + +/-! +# Transfer of response kernels between the time and Laplace domains. +-/ + +@[expose] public section + +noncomputable section +namespace C145.DelayKernel +open MeasureTheory Set +open scoped BigOperators + +/-- Observe the heat action on the port through the same port. -/ +def firstKernel {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (t : ℝ) : ℝ := + ∑ v, b v * C145.Pulse.heatAction Q rates t b v + +/-- Observe the heat-propagated product of the two delayed port heat actions. -/ +def delayIntegrand {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (r₁ r₂ a : ℝ) : ℝ := + ∑ v, b v * C145.Pulse.heatAction Q rates a + (fun u => C145.Pulse.heatAction Q rates (r₁ - a) b u * + C145.Pulse.heatAction Q rates (r₂ - a) b u) v + +/-- Integrate the quadratic delay integrand up to the smaller input delay. -/ +def delayKernel {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (r₁ r₂ : ℝ) : ℝ := + ∫ a in (0 : ℝ)..min r₁ r₂, delayIntegrand Q rates b r₁ r₂ a + +/-- The three-exponential delay integral for one triple of modal rates. -/ +def scalarDelay (α β γ r₁ r₂ : ℝ) : ℝ := + ∫ a in (0 : ℝ)..min r₁ r₂, + Real.exp (-α * (r₁ - a)) * Real.exp (-β * (r₂ - a)) * Real.exp (-γ * a) + +/-- The one-variable Laplace integral over positive times. -/ +def laplace (f : ℝ → ℝ) (s : ℝ) : ℝ := + ∫ r in Ioi (0 : ℝ), Real.exp (-s * r) * f r + +/-- The iterated Laplace integral over the positive delay quadrant. -/ +def doubleLaplace (f : ℝ → ℝ → ℝ) (s t : ℝ) : ℝ := + ∫ r₁ in Ioi (0 : ℝ), ∫ r₂ in Ioi (0 : ℝ), + Real.exp (-s * r₁) * Real.exp (-t * r₂) * f r₁ r₂ + +private theorem heatAction_port_expansion {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (t : ℝ) (v : Fin (n + 1)) : + C145.Pulse.heatAction Q rates t b v = + ∑ i, C145.Pulse.modalOverlap Q b i * Real.exp (-rates i * t) * Q v i := by + classical + unfold C145.Pulse.heatAction + apply Finset.sum_congr rfl + intro i hi + have hInner : (∑ u, Q u i * b u) = C145.Pulse.modalOverlap Q b i := by + unfold C145.Pulse.modalOverlap + apply Finset.sum_congr rfl + intro u hu + ring + rw [hInner] + ring + +private theorem delayIntegrand_expansion {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (r₁ r₂ a : ℝ) : + delayIntegrand Q rates b r₁ r₂ a = + ∑ i, ∑ j, ∑ k, + C145PhysicalFrame.T Q (C145.Pulse.modalOverlap Q b) i j k * + Real.exp (-rates i * (r₁ - a)) * + Real.exp (-rates j * (r₂ - a)) * Real.exp (-rates k * a) := by + classical + let a₀ := C145.Pulse.modalOverlap Q b + have hProduct (u : Fin (n + 1)) : + C145.Pulse.heatAction Q rates (r₁ - a) b u * + C145.Pulse.heatAction Q rates (r₂ - a) b u = + ∑ i, ∑ j, (a₀ i * a₀ j * Q u i * Q u j) * + Real.exp (-rates i * (r₁ - a)) * Real.exp (-rates j * (r₂ - a)) := by + rw [heatAction_port_expansion, heatAction_port_expansion, Finset.sum_mul_sum] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + dsimp [a₀] + ring + have hOutput (x : Fin (n + 1) → ℝ) : + (∑ v, b v * C145.Pulse.heatAction Q rates a x v) = + ∑ k, a₀ k * Real.exp (-rates k * a) * (∑ u, Q u k * x u) := by + calc + (∑ v, b v * C145.Pulse.heatAction Q rates a x v) = + ∑ v, ∑ k, b v * (Q v k * Real.exp (-rates k * a) * + (∑ u, Q u k * x u)) := by + unfold C145.Pulse.heatAction + simp only [Finset.mul_sum] + _ = ∑ k, ∑ v, b v * (Q v k * Real.exp (-rates k * a) * + (∑ u, Q u k * x u)) := by rw [Finset.sum_comm] + _ = ∑ k, a₀ k * Real.exp (-rates k * a) * (∑ u, Q u k * x u) := by + apply Finset.sum_congr rfl + intro k hk + dsimp [a₀, C145.Pulse.modalOverlap] + simp only [Finset.sum_mul] + apply Finset.sum_congr rfl + intro v hv + ring + have hProjection (k : Fin (n + 1)) : + (∑ u, Q u k * (C145.Pulse.heatAction Q rates (r₁ - a) b u * + C145.Pulse.heatAction Q rates (r₂ - a) b u)) = + ∑ i, ∑ j, (a₀ i * a₀ j * C145PhysicalFrame.C Q i j k) * + Real.exp (-rates i * (r₁ - a)) * Real.exp (-rates j * (r₂ - a)) := by + simp_rw [hProduct] + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + calc + (∑ i, ∑ u, ∑ j, Q u k * ((a₀ i * a₀ j * Q u i * Q u j) * + Real.exp (-rates i * (r₁ - a)) * Real.exp (-rates j * (r₂ - a)))) = + ∑ i, ∑ j, ∑ u, Q u k * ((a₀ i * a₀ j * Q u i * Q u j) * + Real.exp (-rates i * (r₁ - a)) * Real.exp (-rates j * (r₂ - a))) := by + apply Finset.sum_congr rfl + intro i hi + rw [Finset.sum_comm] + _ = ∑ i, ∑ j, (a₀ i * a₀ j * C145PhysicalFrame.C Q i j k) * + Real.exp (-rates i * (r₁ - a)) * Real.exp (-rates j * (r₂ - a)) := by + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + simp only [C145PhysicalFrame.C, Finset.mul_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro u hu + ring + unfold delayIntegrand + rw [hOutput] + simp_rw [hProjection] + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + calc + (∑ i, ∑ k, ∑ j, a₀ k * Real.exp (-rates k * a) * + ((a₀ i * a₀ j * C145PhysicalFrame.C Q i j k) * + Real.exp (-rates i * (r₁ - a)) * Real.exp (-rates j * (r₂ - a)))) = + ∑ i, ∑ j, ∑ k, a₀ k * Real.exp (-rates k * a) * + ((a₀ i * a₀ j * C145PhysicalFrame.C Q i j k) * + Real.exp (-rates i * (r₁ - a)) * Real.exp (-rates j * (r₂ - a))) := by + apply Finset.sum_congr rfl + intro i hi + rw [Finset.sum_comm] + _ = _ := by + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + dsimp [a₀, C145PhysicalFrame.T] + ring + +theorem firstKernel_expansion {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (t : ℝ) : + firstKernel Q rates b t = + ∑ i, (C145.Pulse.modalOverlap Q b i) ^ 2 * Real.exp (-rates i * t) := by + classical + unfold firstKernel + simp_rw [heatAction_port_expansion] + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i hi + calc + (∑ v, b v * (C145.Pulse.modalOverlap Q b i * Real.exp (-rates i * t) * Q v i)) = + (∑ v, b v * Q v i) * C145.Pulse.modalOverlap Q b i * Real.exp (-rates i * t) := by + simp only [Finset.sum_mul] + apply Finset.sum_congr rfl + intro v hv + ring + _ = (C145.Pulse.modalOverlap Q b i) ^ 2 * Real.exp (-rates i * t) := by + change C145.Pulse.modalOverlap Q b i * C145.Pulse.modalOverlap Q b i * _ = _ + ring + +theorem delayKernel_expansion {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (r₁ r₂ : ℝ) : + delayKernel Q rates b r₁ r₂ = + ∑ i, ∑ j, ∑ k, + C145PhysicalFrame.T Q (C145.Pulse.modalOverlap Q b) i j k * + scalarDelay (rates i) (rates j) (rates k) r₁ r₂ := by + classical + have hTerm (i j k : Fin (n + 1)) : + IntervalIntegrable (fun a : ℝ => + C145PhysicalFrame.T Q (C145.Pulse.modalOverlap Q b) i j k * + Real.exp (-rates i * (r₁ - a)) * Real.exp (-rates j * (r₂ - a)) * + Real.exp (-rates k * a)) volume 0 (min r₁ r₂) := by + apply Continuous.intervalIntegrable + fun_prop + have hRow (i j : Fin (n + 1)) : + IntervalIntegrable (fun a : ℝ => ∑ k, + C145PhysicalFrame.T Q (C145.Pulse.modalOverlap Q b) i j k * + Real.exp (-rates i * (r₁ - a)) * Real.exp (-rates j * (r₂ - a)) * + Real.exp (-rates k * a)) volume 0 (min r₁ r₂) := by + apply Continuous.intervalIntegrable + fun_prop + have hPlane (i : Fin (n + 1)) : + IntervalIntegrable (fun a : ℝ => ∑ j, ∑ k, + C145PhysicalFrame.T Q (C145.Pulse.modalOverlap Q b) i j k * + Real.exp (-rates i * (r₁ - a)) * Real.exp (-rates j * (r₂ - a)) * + Real.exp (-rates k * a)) volume 0 (min r₁ r₂) := by + apply Continuous.intervalIntegrable + fun_prop + unfold delayKernel + simp_rw [delayIntegrand_expansion] + rw [intervalIntegral.integral_finsetSum (fun i _ => hPlane i)] + apply Finset.sum_congr rfl + intro i hi + rw [intervalIntegral.integral_finsetSum (fun j _ => hRow i j)] + apply Finset.sum_congr rfl + intro j hj + rw [intervalIntegral.integral_finsetSum (fun k _ => hTerm i j k)] + apply Finset.sum_congr rfl + intro k hk + simp only [scalarDelay, ← intervalIntegral.integral_const_mul] + apply intervalIntegral.integral_congr + intro a ha + ring + +private theorem integral_exp_linear (q u : ℝ) : + (∫ a in (0 : ℝ)..u, Real.exp (q * a)) = + if q = 0 then u else (Real.exp (q * u) - 1) / q := by + by_cases hq : q = 0 + · simp [hq] + · rw [ite_eq_right hq] + have hSubstitution := intervalIntegral.mul_integral_comp_mul_left + (f := Real.exp) (a := (0 : ℝ)) (b := u) q + simp only [mul_zero, _root_.integral_exp, Real.exp_zero] at hSubstitution + apply (eq_div_iff hq).2 + simpa only [mul_comm] using hSubstitution + +private theorem scalarDelay_factor (α β γ r₁ r₂ : ℝ) : + scalarDelay α β γ r₁ r₂ = + Real.exp (-α * r₁ - β * r₂) * + (∫ a in (0 : ℝ)..min r₁ r₂, Real.exp ((α + β - γ) * a)) := by + unfold scalarDelay + rw [← intervalIntegral.integral_const_mul] + apply intervalIntegral.integral_congr + intro a ha + simp only [← Real.exp_add] + congr 1 + ring + +private theorem scalarDelay_continuous (α β γ : ℝ) : + Continuous (fun p : ℝ × ℝ => scalarDelay α β γ p.1 p.2) := by + by_cases hq : α + β - γ = 0 + · simp_rw [scalarDelay_factor, integral_exp_linear, ite_eq_left hq] + fun_prop + · simp_rw [scalarDelay_factor, integral_exp_linear, ite_eq_right hq] + fun_prop + +private theorem scalarDelay_nonneg (α β γ r₁ r₂ : ℝ) + (h₁ : 0 ≤ r₁) (h₂ : 0 ≤ r₂) : 0 ≤ scalarDelay α β γ r₁ r₂ := by + unfold scalarDelay + apply intervalIntegral.integral_nonneg_of_forall (le_min h₁ h₂) + intro a + exact mul_nonneg (mul_nonneg (Real.exp_pos _).le (Real.exp_pos _).le) + (Real.exp_pos _).le + +private theorem truncated_exp_integrable (q r : ℝ) (_hr : 0 ≤ r) : + IntegrableOn ((Iic r).indicator (fun a : ℝ => Real.exp (-q * a))) + (Ioi (0 : ℝ)) := by + have hc : Continuous (fun a : ℝ => Real.exp (-q * a)) := by fun_prop + have hI : Iic r ∩ Ioi (0 : ℝ) = Ioc 0 r := by + ext x + simp only [mem_inter_iff, mem_Iic, mem_Ioi, mem_Ioc, and_comm] + rw [IntegrableOn, integrable_indicator_iff measurableSet_Iic] + simpa only [IntegrableOn, Measure.restrict_restrict measurableSet_Iic, hI] using + (hc.integrableOn_Ioc (a := (0 : ℝ)) (b := r)) + +private theorem scalarDelay_weighted_truncation (α β γ t r z : ℝ) + (hr : 0 ≤ r) (hz : 0 ≤ z) : + Real.exp (-t * z) * scalarDelay α β γ r z = + Real.exp (-α * r) * + (∫ a in (0 : ℝ)..z, + (Iic r).indicator (fun x : ℝ => Real.exp (-(t + γ - α) * x)) a * + Real.exp (-(t + β) * (z - a))) := by + have hFactor : + Real.exp (-t * z) * scalarDelay α β γ r z = + Real.exp (-α * r) * + (∫ a in (0 : ℝ)..min r z, + Real.exp (-(t + γ - α) * a) * Real.exp (-(t + β) * (z - a))) := by + unfold scalarDelay + rw [← intervalIntegral.integral_const_mul, ← intervalIntegral.integral_const_mul] + apply intervalIntegral.integral_congr + intro a ha + simp only [← Real.exp_add] + congr 1 + ring + have hIndicator : + (fun a : ℝ => (Iic r).indicator (fun x : ℝ => Real.exp (-(t + γ - α) * x)) a * + Real.exp (-(t + β) * (z - a))) = + (Iic r).indicator (fun a : ℝ => + Real.exp (-(t + γ - α) * a) * Real.exp (-(t + β) * (z - a))) := by + funext a + by_cases ha : a ∈ Iic r <;> simp [ha] + rw [hFactor, hIndicator] + congr 1 + rcases le_total r z with hrz | hzr + · rw [min_eq_left hrz] + exact (intervalIntegral.integral_indicator ⟨hr, hrz⟩).symm + · rw [min_eq_right hzr] + symm + apply intervalIntegral.integral_congr + intro a ha + have haz : a ≤ z := (show a ∈ Icc (0 : ℝ) z from by + simpa only [Set.uIcc_of_le hz] using ha).2 + exact Set.indicator_of_mem (show a ∈ Iic r from le_trans haz hzr) _ + +private theorem scalarDelay_laplace_right (α β γ t r : ℝ) + (hr : 0 ≤ r) (hB : 0 < t + β) : + IntegrableOn (fun z : ℝ => Real.exp (-t * z) * scalarDelay α β γ r z) + (Ioi (0 : ℝ)) ∧ + (∫ z in Ioi (0 : ℝ), Real.exp (-t * z) * scalarDelay α β γ r z) = + Real.exp (-α * r) / (t + β) * + (∫ a in (0 : ℝ)..r, Real.exp (-(t + γ - α) * a)) := by + let f : ℝ → ℝ := (Iic r).indicator (fun a : ℝ => Real.exp (-(t + γ - α) * a)) + let g : ℝ → ℝ := fun v => Real.exp (-(t + β) * v) + let c : ℝ → ℝ := fun z => ∫ a in (0 : ℝ)..z, f a * g (z - a) + have hf : IntegrableOn f (Ioi (0 : ℝ)) := truncated_exp_integrable _ _ hr + have hg : IntegrableOn g (Ioi (0 : ℝ)) := + integrableOn_exp_mul_Ioi (neg_neg_of_pos hB) 0 + have hc : IntegrableOn c (Ioi (0 : ℝ)) := by + have h := (integrable_posConvolution (μ := volume) (ν := volume) hf hg + (ContinuousLinearMap.mul ℝ ℝ)).integrableOn (s := Ioi (0 : ℝ)) + apply h.congr_fun _ measurableSet_Ioi + intro z hz + simp only [posConvolution, Set.indicator_of_mem hz, + ContinuousLinearMap.mul_apply', c] + have hPoint (z : ℝ) (hz : 0 ≤ z) : + Real.exp (-t * z) * scalarDelay α β γ r z = Real.exp (-α * r) * c z := + scalarDelay_weighted_truncation α β γ t r z hr hz + have hInt : IntegrableOn + (fun z : ℝ => Real.exp (-t * z) * scalarDelay α β γ r z) (Ioi (0 : ℝ)) := by + exact IntegrableOn.congr_fun + (f := fun z : ℝ => Real.exp (-α * r) * c z) + (g := fun z : ℝ => Real.exp (-t * z) * scalarDelay α β γ r z) + (s := Ioi (0 : ℝ)) (μ := volume) + (hc.const_mul (Real.exp (-α * r))) + (fun z hz => (hPoint z hz.le).symm) measurableSet_Ioi + have hF : (∫ a in Ioi (0 : ℝ), f a) = + ∫ a in (0 : ℝ)..r, Real.exp (-(t + γ - α) * a) := by + dsimp only [f] + rw [setIntegral_indicator measurableSet_Iic] + have hSet : Ioi (0 : ℝ) ∩ Iic r = Ioc 0 r := rfl + rw [hSet, ← intervalIntegral.integral_of_le hr] + have hG : (∫ v in Ioi (0 : ℝ), g v) = 1 / (t + β) := by + dsimp only [g] + rw [integral_exp_mul_Ioi (neg_neg_of_pos hB) 0] + simp only [mul_zero, Real.exp_zero] + field_simp [ne_of_gt hB] + have hC : (∫ z in Ioi (0 : ℝ), c z) = + (∫ a in Ioi (0 : ℝ), f a) * (∫ v in Ioi (0 : ℝ), g v) := by + simpa only [c, ContinuousLinearMap.mul_apply'] using + (integral_posConvolution (μ := volume) (ν := volume) hf hg + (ContinuousLinearMap.mul ℝ ℝ)) + refine ⟨hInt, ?_⟩ + calc + (∫ z in Ioi (0 : ℝ), Real.exp (-t * z) * scalarDelay α β γ r z) = + ∫ z in Ioi (0 : ℝ), Real.exp (-α * r) * c z := + setIntegral_congr_fun measurableSet_Ioi (fun z hz => hPoint z hz.le) + _ = Real.exp (-α * r) * (∫ z in Ioi (0 : ℝ), c z) := integral_const_mul _ _ + _ = Real.exp (-α * r) / (t + β) * + (∫ a in (0 : ℝ)..r, Real.exp (-(t + γ - α) * a)) := by + rw [hC, hF, hG] + ring + +private theorem scalarDelay_transform (α β γ s t : ℝ) + (hA : 0 < s + α) (hB : 0 < t + β) (hC : 0 < s + t + γ) : + Integrable + (fun p : ℝ × ℝ => Real.exp (-s * p.1) * Real.exp (-t * p.2) * + scalarDelay α β γ p.1 p.2) + ((volume.restrict (Ioi (0 : ℝ))).prod + (volume.restrict (Ioi (0 : ℝ)))) ∧ + doubleLaplace (scalarDelay α β γ) s t = + 1 / ((s + α) * (t + β) * (s + t + γ)) := by + let ρ : Measure ℝ := volume.restrict (Ioi (0 : ℝ)) + let A : ℝ := s + α + let B : ℝ := t + β + let C : ℝ := s + t + γ + let f : ℝ → ℝ := fun a => Real.exp (-C * a) + let g : ℝ → ℝ := fun v => Real.exp (-A * v) + let c : ℝ → ℝ := fun r => ∫ a in (0 : ℝ)..r, f a * g (r - a) + let F : ℝ × ℝ → ℝ := fun p => + Real.exp (-s * p.1) * Real.exp (-t * p.2) * scalarDelay α β γ p.1 p.2 + have hf : IntegrableOn f (Ioi (0 : ℝ)) := + integrableOn_exp_mul_Ioi (neg_neg_of_pos hC) 0 + have hg : IntegrableOn g (Ioi (0 : ℝ)) := + integrableOn_exp_mul_Ioi (neg_neg_of_pos hA) 0 + have hc : IntegrableOn c (Ioi (0 : ℝ)) := by + have h := (integrable_posConvolution (μ := volume) (ν := volume) hf hg + (ContinuousLinearMap.mul ℝ ℝ)).integrableOn (s := Ioi (0 : ℝ)) + apply h.congr_fun _ measurableSet_Ioi + intro r hr + simp only [posConvolution, Set.indicator_of_mem hr, + ContinuousLinearMap.mul_apply', c] + have hOuter (r : ℝ) : + Real.exp (-s * r) * + (Real.exp (-α * r) / B * + (∫ a in (0 : ℝ)..r, Real.exp (-(t + γ - α) * a))) = + (1 / B) * c r := by + calc + Real.exp (-s * r) * (Real.exp (-α * r) / B * + (∫ a in (0 : ℝ)..r, Real.exp (-(t + γ - α) * a))) = + (1 / B) * (∫ a in (0 : ℝ)..r, + Real.exp (-s * r) * Real.exp (-α * r) * + Real.exp (-(t + γ - α) * a)) := by + simp only [intervalIntegral.integral_const_mul] + ring + _ = (1 / B) * c r := by + congr 1 + apply intervalIntegral.integral_congr + intro a ha + dsimp only [c, f, g, A, C] + simp only [← Real.exp_add] + congr 1 + ring + have hSection (r : ℝ) (hr : 0 ≤ r) : Integrable (fun z => F (r, z)) ρ := by + have h := (scalarDelay_laplace_right α β γ t r hr hB).1.const_mul (Real.exp (-s * r)) + apply h.congr + exact Filter.Eventually.of_forall (fun z => by dsimp [F]; ring) + have hSectionIntegral (r : ℝ) (hr : 0 ≤ r) : + (∫ z, F (r, z) ∂ρ) = (1 / B) * c r := by + change (∫ z in Ioi (0 : ℝ), Real.exp (-s * r) * Real.exp (-t * z) * + scalarDelay α β γ r z) = _ + simp_rw [mul_assoc] + rw [integral_const_mul, (scalarDelay_laplace_right α β γ t r hr hB).2] + exact hOuter r + have hNonneg (r z : ℝ) (hr : 0 ≤ r) (hz : 0 ≤ z) : 0 ≤ F (r, z) := by + dsimp only [F] + exact mul_nonneg (mul_nonneg (Real.exp_pos _).le (Real.exp_pos _).le) + (scalarDelay_nonneg α β γ r z hr hz) + have hNorm (r : ℝ) (hr : 0 ≤ r) : + (∫ z, ‖F (r, z)‖ ∂ρ) = (1 / B) * c r := by + calc + (∫ z, ‖F (r, z)‖ ∂ρ) = ∫ z, F (r, z) ∂ρ := by + apply setIntegral_congr_fun measurableSet_Ioi + intro z hz + exact Real.norm_of_nonneg (hNonneg r z hr hz.le) + _ = (1 / B) * c r := hSectionIntegral r hr + have hContinuous : Continuous F := by + exact ((by fun_prop : Continuous (fun p : ℝ × ℝ => + Real.exp (-s * p.1) * Real.exp (-t * p.2))).mul + (scalarDelay_continuous α β γ)) + have hProduct : Integrable F (ρ.prod ρ) := by + apply (integrable_prod_iff hContinuous.aestronglyMeasurable).2 + constructor + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with r hr + exact hSection r hr.le + · exact IntegrableOn.congr_fun + (f := fun r : ℝ => (1 / B) * c r) + (g := fun r : ℝ => ∫ z, ‖F (r, z)‖ ∂ρ) + (s := Ioi (0 : ℝ)) (μ := volume) + (hc.const_mul (1 / B)) + (fun r hr => (hNorm r hr.le).symm) measurableSet_Ioi + have hFIntegral : (∫ a in Ioi (0 : ℝ), f a) = 1 / C := by + change (∫ a in Ioi (0 : ℝ), Real.exp (-(s + t + γ) * a)) = 1 / (s + t + γ) + rw [integral_exp_mul_Ioi (neg_neg_of_pos hC) 0] + simp only [mul_zero, Real.exp_zero] + field_simp [ne_of_gt hC] + have hGIntegral : (∫ v in Ioi (0 : ℝ), g v) = 1 / A := by + change (∫ v in Ioi (0 : ℝ), Real.exp (-(s + α) * v)) = 1 / (s + α) + rw [integral_exp_mul_Ioi (neg_neg_of_pos hA) 0] + simp only [mul_zero, Real.exp_zero] + field_simp [ne_of_gt hA] + have hCIntegral : (∫ r in Ioi (0 : ℝ), c r) = (1 / C) * (1 / A) := by + have h := integral_posConvolution (μ := volume) (ν := volume) hf hg + (ContinuousLinearMap.mul ℝ ℝ) + simpa only [ContinuousLinearMap.mul_apply', hFIntegral, hGIntegral, c] using h + refine ⟨hProduct, ?_⟩ + change (∫ r in Ioi (0 : ℝ), ∫ z, F (r, z) ∂ρ) = _ + calc + (∫ r in Ioi (0 : ℝ), ∫ z, F (r, z) ∂ρ) = + ∫ r in Ioi (0 : ℝ), (1 / B) * c r := + setIntegral_congr_fun measurableSet_Ioi (fun r hr => hSectionIntegral r hr.le) + _ = (1 / B) * ((1 / C) * (1 / A)) := by + rw [integral_const_mul, hCIntegral] + _ = 1 / ((s + α) * (t + β) * (s + t + γ)) := by + dsimp only [A, B, C] + field_simp [ne_of_gt hA, ne_of_gt hB, ne_of_gt hC] + +theorem delayKernel_diagonal {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (t : ℝ) : + delayKernel Q rates b t t = C145.Pulse.coincidentPulse Q rates b t := by + unfold delayKernel C145.Pulse.coincidentPulse + rw [min_self] + have hSub := intervalIntegral.integral_comp_sub_left + (fun a : ℝ => delayIntegrand Q rates b t t a) (a := (0 : ℝ)) (b := t) t + simp only [sub_self, sub_zero] at hSub + rw [← hSub] + apply intervalIntegral.integral_congr + intro s hs + unfold delayIntegrand + apply Finset.sum_congr rfl + intro v hv + have hArg : t - (t - s) = s := by ring + simp only [hArg, pow_two] + +theorem firstKernel_transform {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) + (hRates : ∀ i, 0 < rates i) (s : ℝ) (hs : 0 < s) : + IntegrableOn (fun r : ℝ => Real.exp (-s * r) * firstKernel Q rates b r) + (Ioi (0 : ℝ)) ∧ + laplace (firstKernel Q rates b) s = + C145.H1.firstTransfer rates (C145.Pulse.modalOverlap Q b) s := by + classical + let a₀ := C145.Pulse.modalOverlap Q b + let f : Fin (n + 1) → ℝ → ℝ := fun i r => a₀ i ^ 2 * Real.exp (-(s + rates i) * r) + have hPos (i : Fin (n + 1)) : 0 < s + rates i := add_pos hs (hRates i) + have hInt (i : Fin (n + 1)) : IntegrableOn (f i) (Ioi (0 : ℝ)) := + (integrableOn_exp_mul_Ioi (neg_neg_of_pos (hPos i)) 0).const_mul (a₀ i ^ 2) + have hExpansion (r : ℝ) : Real.exp (-s * r) * firstKernel Q rates b r = ∑ i, f i r := by + rw [firstKernel_expansion, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + dsimp only [f, a₀] + calc + Real.exp (-s * r) * (C145.Pulse.modalOverlap Q b i ^ 2 * Real.exp (-rates i * r)) = + C145.Pulse.modalOverlap Q b i ^ 2 * (Real.exp (-s * r) * Real.exp (-rates i * r)) := by + ring + _ = C145.Pulse.modalOverlap Q b i ^ 2 * Real.exp (-(s + rates i) * r) := by + rw [← Real.exp_add] + congr 2 + ring + have hSum := integrable_finsetSum Finset.univ (fun i _ => hInt i) + refine ⟨hSum.congr (Filter.Eventually.of_forall (fun r => (hExpansion r).symm)), ?_⟩ + unfold laplace C145.H1.firstTransfer C145.H1.weightedTransfer + simp_rw [hExpansion] + rw [integral_finsetSum Finset.univ (fun i _ => hInt i)] + apply Finset.sum_congr rfl + intro i hi + dsimp only [f, a₀] + rw [integral_const_mul, integral_exp_mul_Ioi (neg_neg_of_pos (hPos i)) 0] + simp only [mul_zero, Real.exp_zero] + field_simp [ne_of_gt (hPos i)] + +theorem delayKernel_transform {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) + (hRates : ∀ i, 0 < rates i) (s t : ℝ) (hs : 0 < s) (ht : 0 < t) : + Integrable + (fun p : ℝ × ℝ => Real.exp (-s * p.1) * Real.exp (-t * p.2) * + delayKernel Q rates b p.1 p.2) + ((volume.restrict (Ioi (0 : ℝ))).prod + (volume.restrict (Ioi (0 : ℝ)))) ∧ + doubleLaplace (delayKernel Q rates b) s t = + C145.H2.H rates + (C145PhysicalFrame.T Q (C145.Pulse.modalOverlap Q b)) s t := by + classical + let ρ : Measure ℝ := volume.restrict (Ioi (0 : ℝ)) + let T := C145PhysicalFrame.T Q (C145.Pulse.modalOverlap Q b) + let f : Fin (n + 1) → Fin (n + 1) → Fin (n + 1) → ℝ × ℝ → ℝ := + fun i j k p => Real.exp (-s * p.1) * Real.exp (-t * p.2) * + scalarDelay (rates i) (rates j) (rates k) p.1 p.2 + let F : ℝ × ℝ → ℝ := fun p => + Real.exp (-s * p.1) * Real.exp (-t * p.2) * delayKernel Q rates b p.1 p.2 + have hA (i : Fin (n + 1)) : 0 < s + rates i := add_pos hs (hRates i) + have hB (j : Fin (n + 1)) : 0 < t + rates j := add_pos ht (hRates j) + have hC (k : Fin (n + 1)) : 0 < s + t + rates k := add_pos (add_pos hs ht) (hRates k) + have hScalar (i j k : Fin (n + 1)) : Integrable (f i j k) (ρ.prod ρ) := + (scalarDelay_transform (rates i) (rates j) (rates k) s t (hA i) (hB j) (hC k)).1 + have hTerm (i j k : Fin (n + 1)) : + Integrable (fun p => T i j k * f i j k p) (ρ.prod ρ) := + (hScalar i j k).const_mul (T i j k) + have hRow (i j : Fin (n + 1)) : + Integrable (fun p => ∑ k, T i j k * f i j k p) (ρ.prod ρ) := + integrable_finsetSum Finset.univ (fun k _ => hTerm i j k) + have hPlane (i : Fin (n + 1)) : + Integrable (fun p => ∑ j, ∑ k, T i j k * f i j k p) (ρ.prod ρ) := + integrable_finsetSum Finset.univ (fun j _ => hRow i j) + have hSum : Integrable (fun p => ∑ i, ∑ j, ∑ k, T i j k * f i j k p) (ρ.prod ρ) := + integrable_finsetSum Finset.univ (fun i _ => hPlane i) + have hExpansion (p : ℝ × ℝ) : F p = ∑ i, ∑ j, ∑ k, T i j k * f i j k p := by + dsimp only [F] + rw [delayKernel_expansion] + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + dsimp only [T, f] + ring + have hActual : Integrable F (ρ.prod ρ) := + hSum.congr (Filter.Eventually.of_forall (fun p => (hExpansion p).symm)) + refine ⟨hActual, ?_⟩ + calc + doubleLaplace (delayKernel Q rates b) s t = ∫ p, F p ∂(ρ.prod ρ) := + (integral_prod F hActual).symm + _ = ∫ p, (∑ i, ∑ j, ∑ k, T i j k * f i j k p) ∂(ρ.prod ρ) := + integral_congr_ae (Filter.Eventually.of_forall hExpansion) + _ = ∑ i, ∑ j, ∑ k, ∫ p, T i j k * f i j k p ∂(ρ.prod ρ) := by + rw [integral_finsetSum Finset.univ (fun i _ => hPlane i)] + apply Finset.sum_congr rfl + intro i hi + rw [integral_finsetSum Finset.univ (fun j _ => hRow i j)] + apply Finset.sum_congr rfl + intro j hj + exact integral_finsetSum Finset.univ (fun k _ => hTerm i j k) + _ = C145.H2.H rates (C145PhysicalFrame.T Q (C145.Pulse.modalOverlap Q b)) s t := by + unfold C145.H2.H + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + rw [integral_const_mul, integral_prod (f i j k) (hScalar i j k)] + change T i j k * doubleLaplace (scalarDelay (rates i) (rates j) (rates k)) s t = _ + rw [(scalarDelay_transform (rates i) (rates j) (rates k) s t + (hA i) (hB j) (hC k)).2] + dsimp only [T] + ring + +private theorem rates_pos_of_ground {n : ℕ} (μ : ℝ) (hμ : 0 < μ) + (rates : Fin (n + 1) → ℝ) (hGround : rates 0 = μ) + (hAbove : ∀ i : Fin n, μ < rates i.succ) : ∀ i, 0 < rates i := by + intro i + rcases Fin.eq_zero_or_eq_succ i with hi | ⟨j, hj⟩ + · rw [hi, hGround] + exact hμ + · rw [hj] + exact lt_trans hμ (hAbove j) + +theorem actual_time_kernel_vertex_identification {m n : ℕ} + (μ c0 c1 : ℝ) (hμ : 0 < μ) + (Q0 : Fin (m + 1) → Fin (m + 1) → ℝ) + (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates0 b0 : Fin (m + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround0 : ∀ v, Q0 v 0 = c0) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hRateGround0 : rates0 0 = μ) + (hRateGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < C145.Pulse.modalOverlap Q0 b0 i) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (hm : m ≤ 4) + (hK1 : ∀ r : ℝ, 0 ≤ r → + firstKernel Q0 rates0 b0 r = firstKernel Q1 rates1 b1 r) + (hK2 : ∀ r₁ r₂ : ℝ, 0 ≤ r₁ → 0 ≤ r₂ → + delayKernel Q0 rates0 b0 r₁ r₂ = + delayKernel Q1 rates1 b1 r₁ r₂) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap Q0 b0 i) ∧ + c0 = c1 ∧ (∑ v, b0 v) = (∑ w, b1 w) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u) ∧ + (∀ v : Fin (m + 1), b1 (π v) = b0 v) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u) := by + have hPos0 := rates_pos_of_ground μ hμ rates0 hRateGround0 hAbove0 + have hPos1 := rates_pos_of_ground μ hμ rates1 hRateGround1 hAbove1 + have hH1 : ∀ s : ℝ, 0 < s → + C145.H1.firstTransfer rates0 (C145.Pulse.modalOverlap Q0 b0) s = + C145.H1.firstTransfer rates1 (C145.Pulse.modalOverlap Q1 b1) s := by + intro s hs + rw [← (firstKernel_transform Q0 rates0 b0 hPos0 s hs).2, + ← (firstKernel_transform Q1 rates1 b1 hPos1 s hs).2] + unfold laplace + apply setIntegral_congr_fun measurableSet_Ioi + intro r hr + change Real.exp (-s * r) * firstKernel Q0 rates0 b0 r = + Real.exp (-s * r) * firstKernel Q1 rates1 b1 r + rw [hK1 r hr.le] + have hB : ∀ t : ℝ, 0 ≤ t → + C145.Pulse.coincidentPulse Q0 rates0 b0 t = + C145.Pulse.coincidentPulse Q1 rates1 b1 t := by + intro t ht + rw [← delayKernel_diagonal Q0 rates0 b0 t, + ← delayKernel_diagonal Q1 rates1 b1 t] + exact hK2 t t ht ht + have hH2 : ∀ s t : ℝ, 0 < s → 0 < t → + C145.H2.H rates0 (C145PhysicalFrame.T Q0 (C145.Pulse.modalOverlap Q0 b0)) s t = + C145.H2.H rates1 (C145PhysicalFrame.T Q1 (C145.Pulse.modalOverlap Q1 b1)) s t := by + intro s t hs ht + rw [← (delayKernel_transform Q0 rates0 b0 hPos0 s t hs ht).2, + ← (delayKernel_transform Q1 rates1 b1 hPos1 s t hs ht).2] + unfold doubleLaplace + apply setIntegral_congr_fun measurableSet_Ioi + intro r₁ hr₁ + apply setIntegral_congr_fun measurableSet_Ioi + intro r₂ hr₂ + change Real.exp (-s * r₁) * Real.exp (-t * r₂) * delayKernel Q0 rates0 b0 r₁ r₂ = + Real.exp (-s * r₁) * Real.exp (-t * r₂) * delayKernel Q1 rates1 b1 r₁ r₂ + rw [hK2 r₁ r₂ hr₁.le hr₂.le] + exact C145.UncalibratedSmallH2.actual_small_H2_vertex_identification + μ c0 c1 hμ Q0 Q1 rates0 b0 rates1 b1 hQ0 hQ1 hGround0 hGround1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 ha0 ha1 hm + hH1 hB hH2 + + +end C145.DelayKernel +end + +end diff --git a/LeanPool/C145/C145EightAffineFamilies.lean b/LeanPool/C145/C145EightAffineFamilies.lean new file mode 100644 index 0000000000..ec9d8a1e2c --- /dev/null +++ b/LeanPool/C145/C145EightAffineFamilies.lean @@ -0,0 +1,484 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145SixFixedProducts +public import LeanPool.C145.C145PhysicalFrame + +/-! +DRE6 Lemma 4.1: actual weighted physical necessity and exact whole-H2-fiber +affinity. +All Pair sums include the ground output and the literal weights 1 / a(r)^2. +Power inputs range only over Fin n; v0 is not a ground mode. Real division +is totalized in the algebra. Nonzero overlaps enter physical necessity; +positive/injective nonground rates enter only the actual positive-data join. +Common rates, metric and ground entries are explicit calibration premises. +-/ + +@[expose] public section + +noncomputable section +namespace C145.H2 +open scoped BigOperators +variable {n : ℕ} + +/-- Literal DRE6 (3.2), ordered d0,...,d5, with all n+1 outputs. -/ +def fixedProducts (rates : Fin n → ℝ) (S : Tensor (n + 1)) : + Fin 6 → Fin (n + 1) → ℝ := + ![fullPower rates S 0 0, fullPower rates S 0 1, + fullPower rates S 0 2, fullPower rates S 1 1, + fullPower rates S 0 3 + fullPower rates S 1 2, + fullPower rates S 2 2 + (2 : ℝ) • fullPower rates S 0 4 + + (2 : ℝ) • fullPower rates S 1 3] + +/-- Literal eight rows A,...,H of (4.1), with the six covectors fixed. -/ +def eightWith (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (d : Fin 6 → Fin (n + 1) → ℝ) (S : Tensor (n + 1)) + (f : Fin 8) (t : ℕ) : ℝ := + let B := C145PhysicalFrame.Pair a + let P := fullPower rates S + ![B (d 0) (P 1 t) - B (d 1) (P 0 t), + B (d 1) (P 1 t) - B (d 3) (P 0 t), + B (d 0) (P 2 t) - B (d 2) (P 0 t), + B (d 1) (P 2 t) - B (d 2) (P 1 t), + B (d 0) (P 3 t) + B (d 2) (P 1 t) - B (d 4) (P 0 t), + 2 * B (d 0) (P 4 t) + B (d 2) (P 2 t) + + 2 * B (d 1) (P 3 t) - B (d 5) (P 0 t), + B (d 3) (P 2 t) + B (d 1) (P 3 t) - B (d 4) (P 1 t), + B (d 4) (P 2 t) + B ((2 : ℝ) • d 3 - d 2) (P 3 t) + + 2 * B (d 1) (P 4 t) - B (d 5) (P 1 t)] f + +/-- The eight indexed affine constraints specialized to the tensor's own fixed products. -/ +def eight (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (S : Tensor (n + 1)) (f : Fin 8) (t : ℕ) : ℝ := + eightWith a rates (fixedProducts rates S) S f t + +/-- The difference of the two pairings of the four modal powers. -/ +def powerCurvature (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (S : Tensor (n + 1)) (i j k l : ℕ) : ℝ := + C145PhysicalFrame.Pair a (fullPower rates S i k) (fullPower rates S j l) - + C145PhysicalFrame.Pair a (fullPower rates S i l) (fullPower rates S j k) + +/-- The eight signed source curvature combinations, in the same A,...,H order. -/ +def curvatureCombination (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (S : Tensor (n + 1)) (f : Fin 8) (t : ℕ) : ℝ := + let R := powerCurvature a rates S + ![R 0 1 0 t, R 0 1 1 t, R 0 2 0 t, + R 0 2 1 t - R 0 1 2 t, R 0 3 0 t + R 0 1 2 t, + 2 * R 0 4 0 t + R 0 2 2 t + 2 * R 0 3 1 t, + R 1 2 1 t + R 0 3 1 t - R 0 1 3 t, + -2 * R 0 1 4 t + R 0 2 3 t - R 0 3 2 t + + 2 * R 0 4 1 t + R 1 2 2 t + 2 * R 1 3 1 t] f + +theorem pair_comm (a u v : Fin (n + 1) → ℝ) : + C145PhysicalFrame.Pair a u v = C145PhysicalFrame.Pair a v u := by + simp only [C145PhysicalFrame.Pair, mul_comm] + +theorem pair_add_right (a u v w : Fin (n + 1) → ℝ) : + C145PhysicalFrame.Pair a u (v + w) = + C145PhysicalFrame.Pair a u v + C145PhysicalFrame.Pair a u w := by + simp only [C145PhysicalFrame.Pair, Pi.add_apply, mul_add, add_div, + Finset.sum_add_distrib] + +theorem pair_sub_right (a u v w : Fin (n + 1) → ℝ) : + C145PhysicalFrame.Pair a u (v - w) = + C145PhysicalFrame.Pair a u v - C145PhysicalFrame.Pair a u w := by + simp only [C145PhysicalFrame.Pair, Pi.sub_apply, mul_sub, sub_div, + Finset.sum_sub_distrib] + +theorem pair_smul_right (a u v : Fin (n + 1) → ℝ) (c : ℝ) : + C145PhysicalFrame.Pair a u (c • v) = c * C145PhysicalFrame.Pair a u v := by + simp only [C145PhysicalFrame.Pair, Pi.smul_apply, smul_eq_mul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro r hr + ring + +private theorem pair_add_left (a u v w : Fin (n + 1) → ℝ) : + C145PhysicalFrame.Pair a (u + v) w = + C145PhysicalFrame.Pair a u w + C145PhysicalFrame.Pair a v w := by + rw [pair_comm a (u + v) w, pair_add_right, pair_comm a w u, pair_comm a w v] + +private theorem pair_sub_left (a u v w : Fin (n + 1) → ℝ) : + C145PhysicalFrame.Pair a (u - v) w = + C145PhysicalFrame.Pair a u w - C145PhysicalFrame.Pair a v w := by + rw [pair_comm a (u - v) w, pair_sub_right, pair_comm a w u, pair_comm a w v] + +private theorem pair_smul_left (a u v : Fin (n + 1) → ℝ) (c : ℝ) : + C145PhysicalFrame.Pair a (c • u) v = c * C145PhysicalFrame.Pair a u v := by + rw [pair_comm a (c • u) v, pair_smul_right, pair_comm a v u] + +theorem fullPower_add (rates : Fin n → ℝ) (U V : Tensor (n + 1)) + (p q : ℕ) (r : Fin (n + 1)) : + fullPower rates (U + V) p q r = + fullPower rates U p q r + fullPower rates V p q r := by + simp only [fullPower, Pi.add_apply, mul_add, Finset.sum_add_distrib] + +theorem fullPower_smul (rates : Fin n → ℝ) (U : Tensor (n + 1)) (c : ℝ) + (p q : ℕ) (r : Fin (n + 1)) : + fullPower rates (c • U) p q r = c * fullPower rates U p q r := by + simp only [fullPower, Pi.smul_apply, smul_eq_mul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + ring + +private theorem fullPower_add_vector (rates : Fin n → ℝ) (U V : Tensor (n + 1)) + (p q : ℕ) : fullPower rates (U + V) p q = + fullPower rates U p q + fullPower rates V p q := by + funext r + exact fullPower_add rates U V p q r + +private theorem fullPower_sub_vector (rates : Fin n → ℝ) (U V : Tensor (n + 1)) + (p q : ℕ) : fullPower rates (V - U) p q = + fullPower rates V p q - fullPower rates U p q := by + funext r + exact fullPower_sub rates U V p q r + +private theorem fullPower_smul_vector (rates : Fin n → ℝ) (U : Tensor (n + 1)) + (c : ℝ) (p q : ℕ) : fullPower rates (c • U) p q = c • fullPower rates U p q := by + funext r + exact fullPower_smul rates U c p q r + +/-- The literal six-vector table is exactly the accepted SameFullSix predicate. -/ +theorem fixedProducts_eq_iff (rates : Fin n → ℝ) (U V : Tensor (n + 1)) : + fixedProducts rates V = fixedProducts rates U ↔ SameFullSix rates U V := by + constructor + · intro h r + have hd (f : Fin 6) := congrFun (congrFun h f) r + exact ⟨by simpa [fixedProducts] using hd 0, + by simpa [fixedProducts] using hd 1, + by simpa [fixedProducts] using hd 2, + by simpa [fixedProducts] using hd 3, + by simpa [fixedProducts] using hd 4, + by simpa [fixedProducts, smul_eq_mul] using hd 5⟩ + · intro h + funext f r + obtain ⟨h00, h01, h02, h11, h0312, h220413⟩ := h r + fin_cases f + · simpa [fixedProducts] using h00 + · simpa [fixedProducts] using h01 + · simpa [fixedProducts] using h02 + · simpa [fixedProducts] using h11 + · simpa [fixedProducts] using h0312 + · simpa [fixedProducts, smul_eq_mul] using h220413 + +theorem eightWith_add (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (d : Fin 6 → Fin (n + 1) → ℝ) (U V : Tensor (n + 1)) (f : Fin 8) (t : ℕ) : + eightWith a rates d (U + V) f t = + eightWith a rates d U f t + eightWith a rates d V f t := by + fin_cases f <;> + simp [eightWith, fullPower_add_vector, pair_add_right] <;> ring + +theorem eightWith_sub (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (d : Fin 6 → Fin (n + 1) → ℝ) (U V : Tensor (n + 1)) (f : Fin 8) (t : ℕ) : + eightWith a rates d (V - U) f t = + eightWith a rates d V f t - eightWith a rates d U f t := by + fin_cases f <;> + simp [eightWith, fullPower_sub_vector, pair_sub_right] <;> ring + +theorem eightWith_smul (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (d : Fin 6 → Fin (n + 1) → ℝ) (U : Tensor (n + 1)) (c : ℝ) + (f : Fin 8) (t : ℕ) : + eightWith a rates d (c • U) f t = c * eightWith a rates d U f t := by + fin_cases f <;> + simp [eightWith, fullPower_smul_vector, pair_smul_right] <;> ring + +/-- Only the two input slots are used for the power swap. -/ +theorem fullPower_swap (rates : Fin n → ℝ) (S : Tensor (n + 1)) + (hInput : ∀ x y r, S x y r = S y x r) (p q : ℕ) : + fullPower rates S p q = fullPower rates S q p := by + classical + funext r + unfold fullPower + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro i hi + rw [hInput i.succ j.succ r] + ring + +/-- Symmetry is derived from the actual cubic vertex sum for arbitrary Q,a. -/ +theorem physical_input_symmetry + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) + (x y r : Fin (n + 1)) : + C145PhysicalFrame.T Q a x y r = C145PhysicalFrame.T Q a y x r := by + have hC : C145PhysicalFrame.C Q x y r = C145PhysicalFrame.C Q y x r := by + unfold C145PhysicalFrame.C + apply Finset.sum_congr rfl + intro v hv + ring + unfold C145PhysicalFrame.T + rw [hC] + ring + +/-- Expand the actual two power sums into four inputs and the full output sum. +No symmetry, nonzero weight, data, quotient or physicality hypothesis is used. -/ +private theorem pair_fullPower_expansion (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (S : Tensor (n + 1)) (i j k l : ℕ) : + C145PhysicalFrame.Pair a (fullPower rates S i k) (fullPower rates S j l) = + ∑ α : Fin n, ∑ β : Fin n, ∑ γ : Fin n, ∑ δ : Fin n, + (rates α ^ i * rates β ^ j * rates γ ^ k * rates δ ^ l) * + ∑ r : Fin (n + 1), S α.succ γ.succ r * S β.succ δ.succ r / a r ^ 2 := by + classical + calc + C145PhysicalFrame.Pair a (fullPower rates S i k) (fullPower rates S j l) = + ∑ r : Fin (n + 1), ∑ α : Fin n, ∑ β : Fin n, ∑ γ : Fin n, ∑ δ : Fin n, + (rates α ^ i * rates γ ^ k * S α.succ γ.succ r) * + (rates β ^ j * rates δ ^ l * S β.succ δ.succ r) / a r ^ 2 := by + simp only [C145PhysicalFrame.Pair, fullPower, Finset.sum_mul_sum, Finset.sum_div] + _ = ∑ α : Fin n, ∑ β : Fin n, ∑ γ : Fin n, ∑ δ : Fin n, + ∑ r : Fin (n + 1), + (rates α ^ i * rates γ ^ k * S α.succ γ.succ r) * + (rates β ^ j * rates δ ^ l * S β.succ δ.succ r) / a r ^ 2 := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro α hα + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro β hβ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro γ hγ + rw [Finset.sum_comm] + _ = _ := by + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro α hα + apply Finset.sum_congr rfl + intro β hβ + apply Finset.sum_congr rfl + intro γ hγ + apply Finset.sum_congr rfl + intro δ hδ + apply Finset.sum_congr rfl + intro r hr + ring + +/-- Actual fivefold contraction to accepted modal Assoc, with its ground term. -/ +theorem powerCurvature_eq_weighted_assoc (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (S : Tensor (n + 1)) (i j k l : ℕ) : + powerCurvature a rates S i j k l = + ∑ α : Fin n, ∑ β : Fin n, ∑ γ : Fin n, ∑ δ : Fin n, + (rates α ^ i * rates β ^ j * rates γ ^ k * rates δ ^ l) * + C145PhysicalFrame.Assoc a S α.succ β.succ γ.succ δ.succ := by + classical + have hCross : + C145PhysicalFrame.Pair a (fullPower rates S i l) (fullPower rates S j k) = + ∑ α : Fin n, ∑ β : Fin n, ∑ γ : Fin n, ∑ δ : Fin n, + (rates α ^ i * rates β ^ j * rates γ ^ k * rates δ ^ l) * + ∑ r : Fin (n + 1), S α.succ δ.succ r * S β.succ γ.succ r / a r ^ 2 := by + rw [pair_fullPower_expansion] + apply Finset.sum_congr rfl + intro α hα + apply Finset.sum_congr rfl + intro β hβ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro γ hγ + apply Finset.sum_congr rfl + intro δ hδ + ring + rw [powerCurvature, pair_fullPower_expansion, hCross] + simp only [C145PhysicalFrame.Assoc, sub_div, Finset.sum_sub_distrib, mul_sub] + +/-- All eight source combinations and signs. In particular D uses P21=P12; +H cancels P14 and P23=P32 and retains the coefficient 2*d3-d2. -/ +theorem eight_eq_curvatureCombination (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (S : Tensor (n + 1)) + (hInput : ∀ x y r, S x y r = S y x r) (f : Fin 8) (t : ℕ) : + eight a rates S f t = curvatureCombination a rates S f t := by + have h10 := fullPower_swap rates S hInput 1 0 + have h20 := fullPower_swap rates S hInput 2 0 + have h30 := fullPower_swap rates S hInput 3 0 + have h40 := fullPower_swap rates S hInput 4 0 + have h21 := fullPower_swap rates S hInput 2 1 + have h31 := fullPower_swap rates S hInput 3 1 + have h41 := fullPower_swap rates S hInput 4 1 + have h32 := fullPower_swap rates S hInput 3 2 + fin_cases f <;> + simp [eight, eightWith, fixedProducts, curvatureCombination, powerCurvature, + h10, h20, h30, h40, h21, h31, h41, h32, + pair_add_right, pair_sub_right, pair_smul_right, pair_comm] <;> ring + +/-- Physical necessity comes from actual modal_associativity, never a desired +curvature premise. All n, all real rates and all power labels t are retained. -/ +theorem physical_eight_necessary (rates : Fin n → ℝ) + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) (ha : ∀ r, a r ≠ 0) + (f : Fin 8) (t : ℕ) : eight a rates (C145PhysicalFrame.T Q a) f t = 0 := by + have hR (i j k l : ℕ) : + powerCurvature a rates (C145PhysicalFrame.T Q a) i j k l = 0 := by + rw [powerCurvature_eq_weighted_assoc] + simp only [C145PhysicalFrame.modal_associativity Q a hQ ha, + mul_zero, Finset.sum_const_zero] + rw [eight_eq_curvatureCombination a rates (C145PhysicalFrame.T Q a) + (physical_input_symmetry Q a)] + fin_cases f <;> simp [curvatureCombination, hR] + +/-- Restriction selects successor indices in every slot, never a ground input. -/ +def residual (U : Tensor (n + 1)) : Tensor n := + fun i j k => U i.succ j.succ k.succ + +/-- Prepend the common ground decay rate to the residual rates. -/ +def fullRates (μ : ℝ) (rates : Fin n → ℝ) : Fin (n + 1) → ℝ := + Fin.cases μ rates + +/-- Two tensors agree whenever any index is the ground mode. -/ +def CommonGround (U0 U : Tensor (n + 1)) : Prop := + ∀ i j k, (i = 0 ∨ j = 0 ∨ k = 0) → U i j k = U0 i j k + +/-- An explicitly calibrated full ordinary positive-H2 fiber; no physicality +or desired products, moments, curvature, affinity or rank is assumed. -/ +def CommonGroundFiber (μ : ℝ) (rates : Fin n → ℝ) (U0 U : Tensor (n + 1)) : Prop := + FullSymTensor U ∧ CommonGround U0 U ∧ SamePositive (fullRates μ rates) U0 U + +theorem commonGround_difference (U0 U : Tensor (n + 1)) (hG : CommonGround U0 U) : + U - U0 = groundZero (residual U - residual U0) := by + funext i j k + refine Fin.cases ?_ (fun x => ?_) i + · change U 0 j k - U0 0 j k = 0 + exact sub_eq_zero.mpr (hG 0 j k (Or.inl rfl)) + · refine Fin.cases ?_ (fun y => ?_) j + · change U x.succ 0 k - U0 x.succ 0 k = 0 + exact sub_eq_zero.mpr (hG x.succ 0 k (Or.inr (Or.inl rfl))) + · refine Fin.cases ?_ (fun z => ?_) k + · change U x.succ y.succ 0 - U0 x.succ y.succ 0 = 0 + exact sub_eq_zero.mpr (hG x.succ y.succ 0 (Or.inr (Or.inr rfl))) + · rfl + +/-- Literal three full-index sums reduce only for the ground-zero difference. +No ground summand is deleted from a base tensor's physical pairing. -/ +theorem H_groundZero (μ : ℝ) (rates : Fin n → ℝ) (E : Tensor n) (s t : ℝ) : + H (fullRates μ rates) (groundZero E) s t = H rates E s t := by + simp [H, Fin.sum_univ_succ, groundZero, fullRates] + +theorem residual_fullSym (U : Tensor (n + 1)) (hU : FullSymTensor U) : + FullSymTensor (residual U) := by + intro e v + exact hU e (Fin.succ ∘ v) + +/-- Full positive ordinary data and explicit common ground imply the actual +residual data equality; neither calibration nor a quotient is supplied. -/ +theorem samePositive_residual_of_commonGround (μ : ℝ) (rates : Fin n → ℝ) + (U0 U : Tensor (n + 1)) (hG : CommonGround U0 U) + (hH : SamePositive (fullRates μ rates) U0 U) : + SamePositive rates (residual U0) (residual U) := by + intro s t hs ht + have hz : H (fullRates μ rates) (U - U0) s t = 0 := by + rw [H_sub, ← hH s t hs ht, sub_self] + rw [commonGround_difference U0 U hG, H_groundZero, H_sub] at hz + exact (sub_eq_zero.mp hz).symm + +/-- Reuse the accepted actual kernel/moments/six-products chain. -/ +theorem commonGround_fiber_fixedProducts (μ : ℝ) (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (U0 U : Tensor (n + 1)) (hU0 : FullSymTensor U0) + (hFiber : CommonGroundFiber μ rates U0 U) : + fixedProducts rates U = fixedProducts rates U0 := by + apply (fixedProducts_eq_iff rates U0 U).mpr + exact positive_H2_full_six_fixed rates hRates hPos (residual U0) (residual U) + (residual_fullSym U0 hU0) (residual_fullSym U hFiber.1) + (samePositive_residual_of_commonGround μ rates U0 U hFiber.2.1 hFiber.2.2) + U0 U (commonGround_difference U0 U hFiber.2.1) + +/-- Finite algebra helper: its fixed-product hypothesis is discharged from +actual ordinary H2 data in each source theorem below. -/ +private theorem eight_affine_of_fixedProducts (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (U0 U : Tensor (n + 1)) + (hFixed : fixedProducts rates U = fixedProducts rates U0) (f : Fin 8) (t : ℕ) : + eight a rates U f t = eight a rates U0 f t + + eightWith a rates (fixedProducts rates U0) (U - U0) f t := by + simp only [eight, hFixed] + rw [eightWith_sub] + ring + +/-- Ordinary regular-data form: arbitrary injective real rates; explicit +full-ground difference; no positivity or physical-source assumption. -/ +theorem ordinary_H2_eight_affine (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (a : Fin (n + 1) → ℝ) (E : Tensor n) (hSym : FullSymTensor E) + (hData : NullRegular rates E) (U0 U : Tensor (n + 1)) + (hDiff : U - U0 = groundZero E) (f : Fin 8) (t : ℕ) : + eight a rates U f t = eight a rates U0 f t + + eightWith a rates (fixedProducts rates U0) (U - U0) f t := by + apply eight_affine_of_fixedProducts a rates U0 U + exact (fixedProducts_eq_iff rates U0 U).mpr + (ordinary_H2_full_six_fixed rates hRates E hSym hData U0 U hDiff) + +/-- Exact global difference identity at every point of the explicit full-data +fiber. It is not a tangent approximation, smallness claim, or uniqueness result. -/ +theorem commonGround_fiber_eight_affine (μ : ℝ) (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (a : Fin (n + 1) → ℝ) (U0 U : Tensor (n + 1)) (hU0 : FullSymTensor U0) + (hFiber : CommonGroundFiber μ rates U0 U) (f : Fin 8) (t : ℕ) : + eight a rates U f t = eight a rates U0 f t + + eightWith a rates (fixedProducts rates U0) (U - U0) f t := by + exact eight_affine_of_fixedProducts a rates U0 U + (commonGround_fiber_fixedProducts μ rates hRates hPos U0 U hU0 hFiber) f t + +private theorem H_add (rates : Fin n → ℝ) (U V : Tensor n) (s t : ℝ) : + H rates (U + V) s t = H rates U s t + H rates V s t := by + simp only [H, Pi.add_apply, add_div, Finset.sum_add_distrib] + +private theorem H_smul (rates : Fin n → ℝ) (U : Tensor n) (c s t : ℝ) : + H rates (c • U) s t = c * H rates U s t := by + simp only [H, Pi.smul_apply, smul_eq_mul, mul_div_assoc, Finset.mul_sum] + +/-- Every real barycentric combination remains in the actual common-ground +fiber, and all eight quadratic expressions obey the exact affine identity. -/ +theorem commonGround_fiber_barycentric (μ : ℝ) (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (a : Fin (n + 1) → ℝ) (U0 U1 U2 : Tensor (n + 1)) (hU0 : FullSymTensor U0) + (h1 : CommonGroundFiber μ rates U0 U1) (h2 : CommonGroundFiber μ rates U0 U2) + (θ : ℝ) (f : Fin 8) (t : ℕ) : + CommonGroundFiber μ rates U0 ((1 - θ) • U1 + θ • U2) ∧ + eight a rates ((1 - θ) • U1 + θ • U2) f t = + (1 - θ) * eight a rates U1 f t + θ * eight a rates U2 f t := by + have hMix : CommonGroundFiber μ rates U0 ((1 - θ) • U1 + θ • U2) := by + refine ⟨?_, ?_, ?_⟩ + · intro e v + exact congrArg₂ (fun x y : ℝ => (1 - θ) * x + θ * y) (h1.1 e v) (h2.1 e v) + · intro i j k hg + change (1 - θ) * U1 i j k + θ * U2 i j k = U0 i j k + rw [h1.2.1 i j k hg, h2.2.1 i j k hg] + ring + · intro s u hs hu + rw [H_add, H_smul, H_smul, ← h1.2.2 s u hs hu, ← h2.2.2 s u hs hu] + ring + have hd1 := commonGround_fiber_fixedProducts μ rates hRates hPos U0 U1 hU0 h1 + have hd2 := commonGround_fiber_fixedProducts μ rates hRates hPos U0 U2 hU0 h2 + have hdMix := commonGround_fiber_fixedProducts μ rates hRates hPos U0 + ((1 - θ) • U1 + θ • U2) hU0 hMix + refine ⟨hMix, ?_⟩ + simp only [eight, hdMix, hd1, hd2, eightWith_add, eightWith_smul] + +/-- Actual physical members satisfy the fixed-d equations even when the +chosen common-data origin is nonphysical. This alone asserts no injectivity. -/ +theorem physical_member_fiber_constraints (μ : ℝ) (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (a : Fin (n + 1) → ℝ) (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) (ha : ∀ r, a r ≠ 0) + (U0 : Tensor (n + 1)) (hU0 : FullSymTensor U0) + (hFiber : CommonGroundFiber μ rates U0 (C145PhysicalFrame.T Q a)) + (f : Fin 8) (t : ℕ) : + eightWith a rates (fixedProducts rates U0) (C145PhysicalFrame.T Q a) f t = 0 := by + have hd := commonGround_fiber_fixedProducts μ rates hRates hPos U0 + (C145PhysicalFrame.T Q a) hU0 hFiber + simpa only [eight, hd] using physical_eight_necessary rates Q a hQ ha f t + +/-- Empty nonground inputs give zero in all eight rows, including the one +remaining ground output. No finite residual index is chosen. -/ +theorem eight_n0 (a : Fin 1 → ℝ) (rates : Fin 0 → ℝ) + (S : Tensor 1) (f : Fin 8) (t : ℕ) : eight a rates S f t = 0 := by + fin_cases f <;> simp [eight, eightWith, fixedProducts, fullPower, C145PhysicalFrame.Pair] + +end C145.H2 + +end diff --git a/LeanPool/C145/C145FixedHorizonSmallInverse.lean b/LeanPool/C145/C145FixedHorizonSmallInverse.lean new file mode 100644 index 0000000000..27d1dcce1d --- /dev/null +++ b/LeanPool/C145/C145FixedHorizonSmallInverse.lean @@ -0,0 +1,95 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145ObservedKernelRecovery +public import LeanPool.C145.C145TimeKernelContinuation + +/-! +Fixed-positive-horizon ordinary response jets determine the retained small +finite spectral model under its explicit calibration and positivity hypotheses. +Modal matching and vertex relabelling remain distinct. No general graph +spectral reduction, noisy inverse, or continuum conclusion is asserted. +-/ + +@[expose] public section + +noncomputable section +namespace C145.FixedHorizonSmallInverse +open C145.ActualResponse C145.ObservedKernelRecovery +open scoped BigOperators Topology ContDiff +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +theorem ordinary_C2_jets_determine_small_spectral_model {m n : ℕ} {T : ℝ} + (hT : 0 < T) + (μ c0 c1 : ℝ) (hμ : 0 < μ) + (Q0 : Fin (m + 1) → Fin (m + 1) → ℝ) + (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates0 b0 : Fin (m + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround0 : ∀ v, Q0 v 0 = c0) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hRateGround0 : rates0 0 = μ) + (hRateGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < C145.Pulse.modalOverlap Q0 b0 i) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (hm : m ≤ 4) + (R0 : Input T → Path m T) (R1 : Input T → Path n T) + (hR0 : IsActualResponse hT Q0 rates0 b0 R0) + (hR1 : IsActualResponse hT Q1 rates1 b1 R1) + (hcR0 : ContDiffAt ℝ 2 R0 0) (hcR1 : ContDiffAt ℝ 2 R1 0) + (hFirst : ∀ (g : ℝ → ℝ) (hg : SmoothTemporalTest T g), + rawFirst b0 R0 (restrictInput T g hg.1.continuous) (endTime T hT) = + rawFirst b1 R1 (restrictInput T g hg.1.continuous) (endTime T hT)) + (hMixed : ∀ (g h : ℝ → ℝ) (hg : SmoothTemporalTest T g) (hh : SmoothTemporalTest T h), + rawMixed b0 R0 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT) = + rawMixed b1 R1 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT)) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap Q0 b0 i) ∧ + c0 = c1 ∧ (∑ v, b0 v) = (∑ w, b1 w) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u) ∧ + (∀ v : Fin (m + 1), b1 (π v) = b0 v) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u) := by + have hObserved := ordinary_C2_jets_recover_observed_time_kernels hT + Q0 rates0 b0 Q1 rates1 b1 hQ0 hQ1 R0 R1 hR0 hR1 hcR0 hcR1 hFirst hMixed + have hAll := C145.TimeKernelContinuation.observed_time_kernels_determine_all_nonnegative_delays + hT Q0 rates0 b0 Q1 rates1 b1 hObserved.1 hObserved.2 + exact C145.DelayKernel.actual_time_kernel_vertex_identification + μ c0 c1 hμ Q0 Q1 rates0 b0 rates1 b1 hQ0 hQ1 hGround0 hGround1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 ha0 ha1 hm hAll.1 hAll.2 + +end C145.FixedHorizonSmallInverse +end + +end diff --git a/LeanPool/C145/C145GraphSpectralRealization.lean b/LeanPool/C145/C145GraphSpectralRealization.lean new file mode 100644 index 0000000000..c817b15d10 --- /dev/null +++ b/LeanPool/C145/C145GraphSpectralRealization.lean @@ -0,0 +1,262 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145WeightedGraph +public import LeanPool.C145.C145OrientedEigenframe +public import LeanPool.C145.C145FixedHorizonSmallInverse + +/-! Connected symmetric nonnegative weighted graphs with an actual cyclic port +admit the oriented spectral interface of the accepted fixed-horizon inverse. +The port is real and may have either sign; the ground column's sign is derived. +-/ + +@[expose] public section + +noncomputable section +namespace C145.GraphSpectralRealization +open scoped BigOperators Topology ContDiff +open Matrix C145.WeightedGraph C145.CyclicSpectral C145.OrientedEigenframe + +/-- The negative Laplacian shifted by the common decay rate. -/ +def generator {n : ℕ} (μ : ℝ) (W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) : + Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ := -μ • 1 - laplacian W + +theorem generator_symm {n : ℕ} (μ : ℝ) + (W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) (hs : W.IsSymm) : + (generator μ W).IsSymm := + ((Matrix.isSymm_one).smul (-μ)).sub (laplacian_symm W hs) + +theorem generator_eigenvector {n : ℕ} (μ : ℝ) + (W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (x : Fin (n + 1) → ℝ) (a : ℝ) (h : laplacian W *ᵥ x = a • x) : + generator μ W *ᵥ x = (-(μ + a)) • x := by + rw [generator, Matrix.sub_mulVec, Matrix.smul_mulVec, Matrix.one_mulVec, h] + module + +/-- A spectral realization with an orthonormal eigenframe and oriented port overlaps. -/ +structure OrientedRealization {n : ℕ} (μ : ℝ) + (W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) (b : Fin (n + 1) → ℝ) where + /-- The vertex-coordinate columns of the modal eigenframe. -/ + Q : Fin (n + 1) → Fin (n + 1) → ℝ + /-- The decay rates of the modal columns. -/ + rates : Fin (n + 1) → ℝ + /-- The common vertex value in the ground eigenvector. -/ + c : ℝ + orthonormal : C145PhysicalFrame.ColumnOrthonormal Q + ground : ∀ v, Q v 0 = c + simple : Function.Injective rates + ground_rate : rates 0 = μ + higher : ∀ i : Fin n, μ < rates i.succ + positive_overlap : ∀ i, 0 < C145.Pulse.modalOverlap Q b i + eigenvectors : ∀ i, generator μ W *ᵥ (fun v => Q v i) = + (-rates i) • (fun v => Q v i) + original_generator : C145CoordinatePermutation.spectralGenerator rates Q = generator μ W + original_laplacian : C145CoordinatePermutation.decayLaplacian μ rates Q = laplacian W + +theorem connected_cyclic_graph_has_oriented_spectral_realization {n : ℕ} + (μ : ℝ) (_hμ : 0 < μ) + (W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hs : W.IsSymm) (hn : ∀ v u, 0 ≤ W v u) + (hc : (supportGraph W hs).Connected) + (b : Fin (n + 1) → ℝ) (hcyc : KrylovCyclic (generator μ W) b) : + Nonempty (OrientedRealization μ W b) := by + let hp := laplacian_posSemidef W hs hn + let hL := hp.isHermitian + let U : Fin (n + 1) → Fin (n + 1) → ℝ := fun v i => (hL.eigenvectorBasis i) v + let a : Fin (n + 1) → ℝ := hL.eigenvalues + have hU : C145PhysicalFrame.ColumnOrthonormal U := hermitian_frame _ hL + have heL : ∀ i, laplacian W *ᵥ (fun v => U v i) = a i • (fun v => U v i) := + hL.mulVec_eigenvectorBasis + have heA : ∀ i, generator μ W *ᵥ (fun v => U v i) = + (-(μ + a i)) • (fun v => U v i) := fun i => generator_eigenvector μ W _ _ (heL i) + have hsimpleA := eigenvalues_injective_of_cyclic (generator μ W) + (generator_symm μ W hs) b hcyc U _ hU heA + have hsimple : Function.Injective a := by + intro i j hij; apply hsimpleA; dsimp; rw [hij] + have ha : ∀ i, 0 ≤ a i := hp.eigenvalues_nonneg + have hdet : (laplacian W).det = 0 := by + apply Matrix.det_eq_zero_of_mulVec_eq_zero_of_mem_nonZeroDivisors + (i := (0 : Fin (n + 1))) (laplacian_const W 1) + simp + have hprod : ∏ i, a i = 0 := by + simpa [Matrix.IsHermitian.det_eq_prod_eigenvalues hL, a] using hdet + obtain ⟨g, _, hg⟩ := Finset.prod_eq_zero_iff.mp hprod + have hgroundL : laplacian W *ᵥ (fun v => U v g) = 0 := by + rw [heL, hg, zero_smul] + have hconst := laplacian_kernel_const W hs hn hc (fun v => U v g) hgroundL + have hUne : ∀ i, (fun v => U v i) ≠ 0 := by + intro i hz + have hh := hU i i + have hz' : ∀ v, U v i = 0 := congrFun hz + simp [hz'] at hh + have hOverlap : ∀ i, (fun v => U v i) ⬝ᵥ b ≠ 0 := fun i => + eigenvector_overlap_ne_zero (generator μ W) (generator_symm μ W hs) + b _ hcyc _ (heA i) (hUne i) + let e : Fin (n + 1) ≃ Fin (n + 1) := Equiv.swap 0 g + let s : Fin (n + 1) → ℝ := fun i => orientation ((fun v => U v (e i)) ⬝ᵥ b) + let Q : Fin (n + 1) → Fin (n + 1) → ℝ := fun v i => s i * U v (e i) + let rates : Fin (n + 1) → ℝ := fun i => μ + a (e i) + have he0 : e 0 = g := by simp [e] + have hQ : C145PhysicalFrame.ColumnOrthonormal Q := + oriented_frame U hU e s (fun i => orientation_sq _) + have hQr : ∀ i, generator μ W *ᵥ (fun v => Q v i) = + (-rates i) • (fun v => Q v i) := by + intro i + change generator μ W *ᵥ (s i • (fun v => U v (e i))) = _ + rw [Matrix.mulVec_smul, heA] + dsimp [rates, Q] + ext v; simp; ring + have hgen := generator_eq_of_eigenframe (generator μ W) Q rates hQ hQr + refine ⟨⟨Q, rates, s 0 * U 0 g, hQ, ?_, ?_, ?_, ?_, ?_, hQr, hgen, ?_⟩⟩ + · intro v; dsimp [Q]; rw [he0, hconst v 0] + · intro i j hij; apply e.injective; apply hsimple; dsimp [rates] at hij; linarith + · dsimp [rates]; rw [he0, hg, add_zero] + · intro i + have hne : a (e i.succ) ≠ 0 := by + intro h; have hh := hsimple (h.trans hg.symm) + have : i.succ = 0 := e.injective (hh.trans he0.symm) + exact Fin.succ_ne_zero i this + have hp' : 0 < a (e i.succ) := lt_of_le_of_ne (ha _) (Ne.symm hne) + dsimp [rates]; linarith + · intro i + change 0 < ∑ v, b v * (s i * U v (e i)) + have heq : (∑ v, b v * (s i * U v (e i))) = + s i * ((fun v => U v (e i)) ⬝ᵥ b) := by + rw [dotProduct, Finset.mul_sum] + apply Finset.sum_congr rfl; intro v _; ring + rw [heq] + exact oriented_pos ((fun v => U v (e i)) ⬝ᵥ b) (hOverlap (e i)) + · funext v u + change -C145CoordinatePermutation.spectralGenerator rates Q v u - + μ * (if v = u then 1 else 0) = _ + rw [hgen] + simp [generator, Matrix.sub_apply, Matrix.smul_apply, Matrix.one_apply] + +/-- Exact normalization and positive actual ground overlap determine the signed +ground orientation from the signed port mean. Neither is assumed positive. -/ +theorem OrientedRealization.signed_ground {n : ℕ} {μ : ℝ} + {W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ} {b : Fin (n + 1) → ℝ} + (S : OrientedRealization μ W b) : + (n + 1 : ℝ) * S.c ^ 2 = 1 ∧ S.c ≠ 0 ∧ + 0 < S.c * (∑ v, b v) ∧ (∑ v, b v) ≠ 0 := by + have heq : C145.Pulse.modalOverlap S.Q b 0 = S.c * (∑ v, b v) := by + unfold C145.Pulse.modalOverlap + simp_rw [S.ground] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl; intro v _; ring + have hp := S.positive_overlap 0 + rw [heq] at hp + refine ⟨C145PhysicalFrame.ground_normalization S.Q S.c S.orthonormal S.ground, + C145PhysicalFrame.ground_ne_zero S.Q S.c S.orthonormal S.ground, hp, ?_⟩ + intro hz + rw [hz, mul_zero] at hp + exact lt_irrefl _ hp + +/-- The ground rate is attained at exactly the derived ground index. -/ +theorem OrientedRealization.unique_ground_rate {n : ℕ} {μ : ℝ} + {W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ} {b : Fin (n + 1) → ℝ} + (S : OrientedRealization μ W b) (i : Fin (n + 1)) : S.rates i = μ ↔ i = 0 := by + constructor + · intro h; exact S.simple (h.trans S.ground_rate.symm) + · rintro rfl; exact S.ground_rate + +open C145.ActualResponse C145.ObservedKernelRecovery +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +/-- The original graph ODE, stated in vertex coordinates with its actual matrix. -/ +def graphVectorField {n : ℕ} (μ : ℝ) + (W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) (b : State n) + (f : ℝ → ℝ) (t : ℝ) (x : State n) : State n := + fun v => (∑ w, generator μ W v w * x w) + x v ^ 2 + b v * f t + +/-- A response map satisfying the local dynamics of the given weighted graph and port. -/ +def IsGraphResponse {n : ℕ} {T : ℝ} (hT : 0 < T) (μ : ℝ) + (W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) (b : State n) + (R : Input T → Path n T) : Prop := + R 0 = 0 ∧ ∀ᶠ f in 𝓝 (0 : Input T), + extendPath hT (R f) 0 = 0 ∧ ∀ t ∈ Set.Icc (0 : ℝ) T, + HasDerivWithinAt (extendPath hT (R f)) + (graphVectorField μ W b (extendInput hT f) t (extendPath hT (R f) t)) + (Set.Icc (0 : ℝ) T) t + +/-- Matrix equality transports the caller's own actual response, including its +fixed-horizon neighborhood; no existence-only replacement response is used. -/ +theorem OrientedRealization.actualResponse {n : ℕ} {T : ℝ} (hT : 0 < T) + {μ : ℝ} {W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ} {b : State n} + (S : OrientedRealization μ W b) (R : Input T → Path n T) + (hR : IsGraphResponse hT μ W b R) : IsActualResponse hT S.Q S.rates b R := by + have hv : vectorField S.Q S.rates b = graphVectorField μ W b := by + unfold vectorField graphVectorField + rw [S.original_generator] + unfold IsGraphResponse at hR + unfold IsActualResponse + rw [hv] + exact hR + +/-- Smooth terminal ordinary J2 data identify the original connected cyclic +weighted graph against an initially unrestricted-size competitor. Modal `e` +and vertex `π` are separately derived; all rates are full decay rates. -/ +theorem ordinary_C2_jets_determine_small_graph {m n : ℕ} {T : ℝ} + (hT : 0 < T) (μ : ℝ) (hμ : 0 < μ) + (W0 : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (W1 : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hs0 : W0.IsSymm) (hs1 : W1.IsSymm) + (hn0 : ∀ v u, 0 ≤ W0 v u) (hn1 : ∀ v u, 0 ≤ W1 v u) + (hc0 : (supportGraph W0 hs0).Connected) (hc1 : (supportGraph W1 hs1).Connected) + (b0 : State m) (b1 : State n) + (hcyc0 : KrylovCyclic (generator μ W0) b0) + (hcyc1 : KrylovCyclic (generator μ W1) b1) + (hm : m ≤ 4) + (R0 : Input T → Path m T) (R1 : Input T → Path n T) + (hR0 : IsGraphResponse hT μ W0 b0 R0) (hR1 : IsGraphResponse hT μ W1 b1 R1) + (hC0 : ContDiffAt ℝ 2 R0 0) (hC1 : ContDiffAt ℝ 2 R1 0) + (hFirst : ∀ (g : ℝ → ℝ) (hg : SmoothTemporalTest T g), + rawFirst b0 R0 (restrictInput T g hg.1.continuous) (endTime T hT) = + rawFirst b1 R1 (restrictInput T g hg.1.continuous) (endTime T hT)) + (hMixed : ∀ (g h : ℝ → ℝ) (hg : SmoothTemporalTest T g) (hh : SmoothTemporalTest T h), + rawMixed b0 R0 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT) = + rawMixed b1 R1 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT)) : + ∃ (S0 : OrientedRealization μ W0 b0) (S1 : OrientedRealization μ W1 b1) + (e : Fin (m + 1) ≃ Fin (n + 1)), + m = n ∧ e 0 = 0 ∧ (∀ i, S1.rates (e i) = S0.rates i) ∧ + (∀ i, C145.Pulse.modalOverlap S1.Q b1 (e i) = + C145.Pulse.modalOverlap S0.Q b0 i) ∧ + S0.c = S1.c ∧ (∑ v, b0 v) = (∑ v, b1 v) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ v i, S1.Q (π v) (e i) = S0.Q v i) ∧ + (∀ v u, generator μ W1 (π v) (π u) = generator μ W0 v u) ∧ + (∀ v, b1 (π v) = b0 v) ∧ + (∀ v u, laplacian W1 (π v) (π u) = laplacian W0 v u) := by + obtain ⟨S0⟩ := connected_cyclic_graph_has_oriented_spectral_realization + μ hμ W0 hs0 hn0 hc0 b0 hcyc0 + obtain ⟨S1⟩ := connected_cyclic_graph_has_oriented_spectral_realization + μ hμ W1 hs1 hn1 hc1 b1 hcyc1 + obtain ⟨e, hmn, he0, hr, ha, hc, hb, π, _, hQ, hA, hport, hL⟩ := + C145.FixedHorizonSmallInverse.ordinary_C2_jets_determine_small_spectral_model + hT μ S0.c S1.c hμ S0.Q S1.Q S0.rates b0 S1.rates b1 + S0.orthonormal S1.orthonormal S0.ground S1.ground S0.simple S1.simple + S0.ground_rate S1.ground_rate S0.higher S1.higher + S0.positive_overlap S1.positive_overlap hm R0 R1 + (S0.actualResponse hT R0 hR0) (S1.actualResponse hT R1 hR1) + hC0 hC1 hFirst hMixed + refine ⟨S0, S1, e, hmn, he0, hr, ha, hc, hb, π, hQ, ?_, hport, ?_⟩ + · simpa only [S0.original_generator, S1.original_generator] using hA + · simpa only [S0.original_laplacian, S1.original_laplacian] using hL + +end C145.GraphSpectralRealization + +end diff --git a/LeanPool/C145/C145H1ModalCalibration.lean b/LeanPool/C145/C145H1ModalCalibration.lean new file mode 100644 index 0000000000..8f32ad5082 --- /dev/null +++ b/LeanPool/C145/C145H1ModalCalibration.lean @@ -0,0 +1,315 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145H2NumeratorData +public import Mathlib.Algebra.Polynomial.Roots +public import Mathlib.Algebra.Polynomial.Derivative +public import Mathlib.Algebra.BigOperators.GroupWithZero.Finset +public import Mathlib.Algebra.Order.Ring.Basic +public import Mathlib.Algebra.Order.Ring.Unbundled.Basic +public import Mathlib.Data.Fintype.Card +public import Mathlib.Logic.Equiv.Defs +public import Mathlib.Order.Interval.Set.Infinite +public import Mathlib.Tactic.FieldSimp +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.Ring + +/-! +C145: literal finite H1 data determine visible simple positive modes. + +The two finite sizes start unrelated. Each rate family's injection, positive +rates, and each residue's nonvanishing are explicit source-class assumptions. +One cleared polynomial identity gives both rate matches and, by its formal +derivative, actual residues. The modal bijection and equal size are derived. +Positive overlap orientation is explicit. The strict-known-mu corollary fixes +only the ground modal index; H1 does not determine signed beta or the constant +ground column. In the accepted fullRates convention, successors are physical +rates, never mu plus physical rates. Empty finite families remain algebraic. +-/ + +@[expose] public section + +noncomputable section +namespace C145.H1 +open scoped BigOperators + +/-- The first transfer function as simple fractions with specified modal weights. -/ +def weightedTransfer {N : ℕ} + (rates weights : Fin N → ℝ) (s : ℝ) : ℝ := + ∑ i, weights i / (s + rates i) + +/-- The first transfer function with squared modal overlaps as its weights. -/ +def firstTransfer {N : ℕ} + (rates a : Fin N → ℝ) (s : ℝ) : ℝ := + weightedTransfer rates (fun i => a i ^ 2) s + +/-- The common-denominator numerator of the weighted first transfer function. -/ +def numerator {N : ℕ} + (rates weights : Fin N → ℝ) : Polynomial ℝ := + ∑ i, Polynomial.C (weights i) * C145.H2.Li rates i + +private theorem denominator_eval_node {N : ℕ} + (rates : Fin N → ℝ) (i : Fin N) : + (C145.H2.D rates).eval (-rates i) = 0 := by + rw [C145.H2.eval_D_factor rates i (-rates i)] + simp + +private theorem numerator_eval_node {N : ℕ} + (rates weights : Fin N → ℝ) (i : Fin N) : + (numerator rates weights).eval (-rates i) = + weights i * C145.H2.di rates i := by + classical + simp [numerator, Polynomial.eval_finsetSum, C145.H2.eval_Li_grid] + +private theorem clear_denominator {N : ℕ} + (rates weights : Fin N → ℝ) (s : ℝ) + (hRegular : ∀ i, s + rates i ≠ 0) : + (numerator rates weights).eval s = + (C145.H2.D rates).eval s * weightedTransfer rates weights s := by + classical + simp only [numerator, Polynomial.eval_finsetSum, Polynomial.eval_C_mul, + weightedTransfer, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + rw [C145.H2.eval_D_factor rates i s] + field_simp [hRegular i] + + +private theorem cross_identity {M N : ℕ} + (rates0 weights0 : Fin M → ℝ) + (rates1 weights1 : Fin N → ℝ) + (hPos0 : ∀ i, 0 < rates0 i) + (hPos1 : ∀ j, 0 < rates1 j) + (hData : ∀ s : ℝ, 0 < s → + weightedTransfer rates0 weights0 s = weightedTransfer rates1 weights1 s) : + numerator rates0 weights0 * C145.H2.D rates1 = + numerator rates1 weights1 * C145.H2.D rates0 := by + apply Polynomial.eq_of_infinite_eval_eq + refine Set.Infinite.mono ?_ (Set.Ioi_infinite (0 : ℝ)) + intro s hs + change (numerator rates0 weights0 * C145.H2.D rates1).eval s = + (numerator rates1 weights1 * C145.H2.D rates0).eval s + rw [Polynomial.eval_mul, Polynomial.eval_mul, + clear_denominator rates0 weights0 s + (fun i => ne_of_gt (add_pos hs (hPos0 i))), + clear_denominator rates1 weights1 s + (fun j => ne_of_gt (add_pos hs (hPos1 j))), hData s hs] + ring + +private theorem rate_match_of_cross {M N : ℕ} + (rates0 weights0 : Fin M → ℝ) + (rates1 weights1 : Fin N → ℝ) + (hRates0 : Function.Injective rates0) + (hWeights0 : ∀ i, weights0 i ≠ 0) + (hCross : numerator rates0 weights0 * C145.H2.D rates1 = + numerator rates1 weights1 * C145.H2.D rates0) + (i : Fin M) : + ∃ j : Fin N, rates1 j = rates0 i := by + classical + have hNode := congrArg (fun P : Polynomial ℝ => P.eval (-rates0 i)) hCross + rw [Polynomial.eval_mul, Polynomial.eval_mul, numerator_eval_node, + denominator_eval_node rates0 i, mul_zero] at hNode + have hDen : (C145.H2.D rates1).eval (-rates0 i) = 0 := + (mul_eq_zero.mp hNode).resolve_left + (mul_ne_zero (hWeights0 i) (C145.H2.di_ne_zero rates0 hRates0 i)) + have hProd : (∏ j : Fin N, (-rates0 i + rates1 j)) = 0 := by + simpa only [C145.H2.D, Polynomial.eval_prod, Polynomial.eval_add, + Polynomial.eval_X, Polynomial.eval_C] using hDen + obtain ⟨j, hj, hZero⟩ := Finset.prod_eq_zero_iff.mp hProd + exact ⟨j, by linarith⟩ + +private theorem matched_weight_eq_of_cross {M N : ℕ} + (rates0 weights0 : Fin M → ℝ) + (rates1 weights1 : Fin N → ℝ) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hCross : numerator rates0 weights0 * C145.H2.D rates1 = + numerator rates1 weights1 * C145.H2.D rates0) + (i : Fin M) (j : Fin N) (hMatch : rates1 j = rates0 i) : + weights1 j = weights0 i := by + have hNode0 := denominator_eval_node rates0 i + have hNode1 : (C145.H2.D rates1).eval (-rates0 i) = 0 := by + rw [← hMatch] + exact denominator_eval_node rates1 j + have hNum1 : (numerator rates1 weights1).eval (-rates0 i) = + weights1 j * C145.H2.di rates1 j := by + rw [← hMatch] + exact numerator_eval_node rates1 weights1 j + have hDeriv1 : (C145.H2.D rates1).derivative.eval (-rates0 i) = + C145.H2.di rates1 j := by + rw [← hMatch] + exact C145.H2.eval_derivative_D_node rates1 j + have hDerivative := + congrArg (fun P : Polynomial ℝ => P.derivative.eval (-rates0 i)) hCross + simp only [Polynomial.derivative_mul, Polynomial.eval_add, + Polynomial.eval_mul, hNode0, hNode1, mul_zero, zero_add] at hDerivative + rw [numerator_eval_node, hNum1, C145.H2.eval_derivative_D_node, + hDeriv1] at hDerivative + apply mul_right_cancel₀ + (mul_ne_zero (C145.H2.di_ne_zero rates0 hRates0 i) + (C145.H2.di_ne_zero rates1 hRates1 j)) + calc + weights1 j * (C145.H2.di rates0 i * C145.H2.di rates1 j) = + (weights1 j * C145.H2.di rates1 j) * C145.H2.di rates0 i := by ring + _ = (weights0 i * C145.H2.di rates0 i) * C145.H2.di rates1 j := + hDerivative.symm + _ = weights0 i * (C145.H2.di rates0 i * C145.H2.di rates1 j) := by ring + +/-- Exact visible simple-mode identification from the actual positive-s sums. +Real signed residues are allowed; only their nonvanishing is assumed. -/ +theorem nonzero_weights_modal_identification {M N : ℕ} + (rates0 weights0 : Fin M → ℝ) + (rates1 weights1 : Fin N → ℝ) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hPos0 : ∀ i, 0 < rates0 i) + (hPos1 : ∀ j, 0 < rates1 j) + (hWeights0 : ∀ i, weights0 i ≠ 0) + (hWeights1 : ∀ j, weights1 j ≠ 0) + (hData : ∀ s : ℝ, 0 < s → + weightedTransfer rates0 weights0 s = weightedTransfer rates1 weights1 s) : + ∃ e : Fin M ≃ Fin N, + M = N ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, weights1 (e i) = weights0 i) := by + classical + have hCross := cross_identity rates0 weights0 rates1 weights1 hPos0 hPos1 hData + have hForward (i : Fin M) : ∃ j : Fin N, rates1 j = rates0 i := + rate_match_of_cross rates0 weights0 rates1 weights1 hRates0 hWeights0 hCross i + have hBackward (j : Fin N) : ∃ i : Fin M, rates0 i = rates1 j := + rate_match_of_cross rates1 weights1 rates0 weights0 hRates1 hWeights1 hCross.symm j + let p : Fin M → Fin N := fun i => Classical.choose (hForward i) + have hp (i : Fin M) : rates1 (p i) = rates0 i := + Classical.choose_spec (hForward i) + have hInjective : Function.Injective p := by + intro i k h + apply hRates0 + calc + rates0 i = rates1 (p i) := (hp i).symm + _ = rates1 (p k) := congrArg rates1 h + _ = rates0 k := hp k + have hSurjective : Function.Surjective p := by + intro j + obtain ⟨i, hi⟩ := hBackward j + refine ⟨i, hRates1 ?_⟩ + exact (hp i).trans hi + let e : Fin M ≃ Fin N := Equiv.ofBijective p ⟨hInjective, hSurjective⟩ + have heRates (i : Fin M) : rates1 (e i) = rates0 i := hp i + refine ⟨e, ?_, heRates, ?_⟩ + · simpa only [Fintype.card_fin] using Fintype.card_congr e + · intro i + exact matched_weight_eq_of_cross rates0 weights0 rates1 weights1 + hRates0 hRates1 hCross i (e i) (heRates i) + +/-- H1 identifies squared overlaps before any eigenvector orientation. -/ +theorem overlap_squares_modal_identification {M N : ℕ} + (rates0 a0 : Fin M → ℝ) + (rates1 a1 : Fin N → ℝ) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hPos0 : ∀ i, 0 < rates0 i) + (hPos1 : ∀ j, 0 < rates1 j) + (ha0 : ∀ i, a0 i ≠ 0) + (ha1 : ∀ j, a1 j ≠ 0) + (hData : ∀ s : ℝ, 0 < s → + firstTransfer rates0 a0 s = firstTransfer rates1 a1 s) : + ∃ e : Fin M ≃ Fin N, + M = N ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, a1 (e i) ^ 2 = a0 i ^ 2) := by + exact nonzero_weights_modal_identification rates0 (fun i => a0 i ^ 2) + rates1 (fun j => a1 j ^ 2) hRates0 hRates1 hPos0 hPos1 + (fun i => ne_of_gt (sq_pos_of_ne_zero (ha0 i))) + (fun j => ne_of_gt (sq_pos_of_ne_zero (ha1 j))) hData + +/-- Positive orientation is an explicit assumption in each representation. -/ +theorem positive_overlap_modal_identification {M N : ℕ} + (rates0 a0 : Fin M → ℝ) + (rates1 a1 : Fin N → ℝ) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hPos0 : ∀ i, 0 < rates0 i) + (hPos1 : ∀ j, 0 < rates1 j) + (ha0 : ∀ i, 0 < a0 i) + (ha1 : ∀ j, 0 < a1 j) + (hData : ∀ s : ℝ, 0 < s → + firstTransfer rates0 a0 s = firstTransfer rates1 a1 s) : + ∃ e : Fin M ≃ Fin N, + M = N ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, a1 (e i) = a0 i) := by + obtain ⟨e, hCard, hRates, hSquares⟩ := + overlap_squares_modal_identification rates0 a0 rates1 a1 + hRates0 hRates1 hPos0 hPos1 (fun i => ne_of_gt (ha0 i)) + (fun j => ne_of_gt (ha1 j)) hData + refine ⟨e, hCard, hRates, ?_⟩ + intro i + apply (mul_self_inj (le_of_lt (ha1 (e i))) (le_of_lt (ha0 i))).mp + simpa only [pow_two] using hSquares i + +/-- A known strict ground minimum identifies its modal index only. -/ +theorem known_ground_positive_modal_identification {m n : ℕ} + (μ : ℝ) (hμ : 0 < μ) + (rates0 a0 : Fin (m + 1) → ℝ) + (rates1 a1 : Fin (n + 1) → ℝ) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hGround0 : rates0 0 = μ) + (hGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < a0 i) + (ha1 : ∀ j, 0 < a1 j) + (hData : ∀ s : ℝ, 0 < s → + firstTransfer rates0 a0 s = firstTransfer rates1 a1 s) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, a1 (e i) = a0 i) := by + have hPos0 : ∀ i, 0 < rates0 i := by + intro i + rcases Fin.eq_zero_or_eq_succ i with h | ⟨j, h⟩ + · rw [h, hGround0] + exact hμ + · rw [h] + exact lt_trans hμ (hAbove0 j) + have hPos1 : ∀ j, 0 < rates1 j := by + intro j + rcases Fin.eq_zero_or_eq_succ j with h | ⟨k, h⟩ + · rw [h, hGround1] + exact hμ + · rw [h] + exact lt_trans hμ (hAbove1 k) + obtain ⟨e, hCard, hRates, hOverlaps⟩ := + positive_overlap_modal_identification rates0 a0 rates1 a1 + hRates0 hRates1 hPos0 hPos1 ha0 ha1 hData + have hGroundIndex : e 0 = 0 := by + rcases Fin.eq_zero_or_eq_succ (e 0) with h | ⟨j, h⟩ + · exact h + · have hRateAt : rates1 j.succ = μ := by + calc + rates1 j.succ = rates1 (e 0) := by rw [h] + _ = rates0 0 := hRates 0 + _ = μ := hGround0 + exact False.elim ((ne_of_gt (hAbove1 j)) hRateAt) + exact ⟨e, Nat.succ.inj hCard, hGroundIndex, hRates, hOverlaps⟩ + +/-- Literal H1 is insensitive to global reversal of all overlap signs. -/ +theorem firstTransfer_neg {N : ℕ} + (rates a : Fin N → ℝ) (s : ℝ) : + firstTransfer rates (fun i => -a i) s = firstTransfer rates a s := by + have hSquare (i : Fin N) : (-a i) ^ 2 = a i ^ 2 := by ring + simp only [firstTransfer, weightedTransfer, hSquare] + + +end C145.H1 +end + +end diff --git a/LeanPool/C145/C145H2GridResidueInverse.lean b/LeanPool/C145/C145H2GridResidueInverse.lean new file mode 100644 index 0000000000..b8d66155eb --- /dev/null +++ b/LeanPool/C145/C145H2GridResidueInverse.lean @@ -0,0 +1,313 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145H2NumeratorData +public import Mathlib.Algebra.Polynomial.Eval.Degree + +/-! +C145 ordinary H2: actual fixed-three-variable grid unisolvence and the +literal numerator/residue inverse. + +The public polynomial domain is the accepted support predicate Box n F. +The n=0 case is retained separately. Coordinates remain z=X 0, x=X 1, +y=X 2; tensor entry i j k therefore uses the vector ![-rates k,-rates i,-rates j]. +Only injectivity of the individual real rates is needed. Neither positivity, +additive nonresonance, supplied reconstruction nor supplied grid uniqueness +occurs as a premise. The accepted numerator, gap product, Box, tensor symmetry +and polynomial symmetry definitions are imported unchanged. + +This module does not yet join Xi quotients to the response kernel, derive +moment cancellations or assert any physical/continuum recovery theorem. +-/ + +@[expose] public section + +noncomputable section + +namespace C145.H2 + +open MvPolynomial C145.ThreePlane +open scoped BigOperators + +variable {n : ℕ} + +/-- The actual support Box is stable under subtraction, including n=0. -/ +theorem box_sub {F G : P3} (hF : Box n F) (hG : Box n G) : Box n (F - G) := by + classical + intro m hm r + rcases Finset.mem_union.mp (MvPolynomial.support_sub (Fin 3) F G hm) with hmF | hmG + · exact hF m hmF r + · exact hG m hmG r + +/-- Isolate coordinate zero after a permutation, then evaluate the other +two variables in ℝ. This helper is confined to the accepted fixed Fin 3 ring. -/ +private def realSlice (e : Equiv.Perm (Fin 3)) (F : P3) (v : Fin 2 → ℝ) : + Polynomial ℝ := + Polynomial.map (MvPolynomial.eval v) (finSuccEquiv ℝ 2 (rename e F)) + +private theorem eval_realSlice (e : Equiv.Perm (Fin 3)) (F : P3) + (v : Fin 2 → ℝ) (u : ℝ) : + (realSlice e F v).eval u = + MvPolynomial.eval ((Fin.cons u v : Fin 3 → ℝ) ∘ e) F := by + unfold realSlice + rw [← MvPolynomial.eval_eq_eval_mv_eval', MvPolynomial.eval_rename] + +/-- Partial real evaluation cannot increase the isolated coordinate degree. +No coefficient-bound hypothesis is introduced: the bound comes from Box. -/ +private theorem realSlice_natDegree_lt (hn : 0 < n) (F : P3) (hF : Box n F) + (e : Equiv.Perm (Fin 3)) (v : Fin 2 → ℝ) : + (realSlice e F v).natDegree < n := by + have he : degreeOf (0 : Fin 3) (rename e F) = degreeOf (e.symm 0) F := by + simpa only [e.apply_symm_apply] using + (degreeOf_rename_of_injective (p := F) e.injective (e.symm 0)) + calc + (realSlice e F v).natDegree ≤ + (finSuccEquiv ℝ 2 (rename e F)).natDegree := Polynomial.natDegree_map_le + _ = degreeOf (0 : Fin 3) (rename e F) := natDegree_finSuccEquiv _ + _ = degreeOf (e.symm 0) F := he + _ < n := (box_iff_degree_lt hn F).mp hF (e.symm 0) + +/-- One real line is determined by its n distinct negative-rate nodes. +The finset cardinal is the actual n; no selected/root-list premise occurs. -/ +private theorem realLine_zero (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hn : 0 < n) (F : P3) (hF : Box n F) + (e : Equiv.Perm (Fin 3)) (v : Fin 2 → ℝ) + (hnode : ∀ i : Fin n, + MvPolynomial.eval ((Fin.cons (-rates i) v : Fin 3 → ℝ) ∘ e) F = 0) + (u : ℝ) : + MvPolynomial.eval ((Fin.cons u v : Fin 3 → ℝ) ∘ e) F = 0 := by + classical + have hi : Function.Injective (fun i : Fin n => -rates i) := by + intro i j hij + exact hRates (neg_injective hij) + have hp : realSlice e F v = 0 := by + apply Polynomial.eq_zero_of_degree_lt_of_eval_index_eq_zero + (Finset.univ : Finset (Fin n)) hi.injOn + · have hnat := realSlice_natDegree_lt hn F hF e v + have hcast : ((realSlice e F v).natDegree : WithBot ℕ) < (n : WithBot ℕ) := + WithBot.coe_lt_coe.mpr hnat + have hdeg := (Polynomial.degree_le_natDegree (p := realSlice e F v)).trans_lt hcast + simpa only [Finset.card_univ, Fintype.card_fin] using hdeg + · intro i hi + rw [eval_realSlice] + exact hnode i + rw [← eval_realSlice, hp, Polynomial.eval_zero] + +/-- Actual all-n finite-grid unisolvence in the fixed three-variable ring. +Three successive finite-root arguments free z, then x, then y. -/ +theorem box_grid_eq_zero (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (F : P3) (hF : Box n F) + (hgrid : ∀ i j k : Fin n, + MvPolynomial.eval ![-rates k, -rates i, -rates j] F = 0) : F = 0 := by + by_cases hn : n = 0 + · subst n + exact (box_zero_iff F).mp hF + · have hnpos : 0 < n := Nat.pos_of_ne_zero hn + have hz (i j : Fin n) (u : ℝ) : + MvPolynomial.eval ![u, -rates i, -rates j] F = 0 := by + have hnode (k : Fin n) : + MvPolynomial.eval + ((Fin.cons (-rates k) ![-rates i, -rates j] : Fin 3 → ℝ) ∘ + Equiv.refl (Fin 3)) F = 0 := by + have hv : + (Fin.cons (-rates k) ![-rates i, -rates j] : Fin 3 → ℝ) ∘ + Equiv.refl (Fin 3) = ![-rates k, -rates i, -rates j] := by + funext r + fin_cases r <;> rfl + rw [hv] + exact hgrid i j k + have h := realLine_zero rates hRates hnpos F hF + (Equiv.refl (Fin 3)) ![-rates i, -rates j] hnode u + have hv : (Fin.cons u ![-rates i, -rates j] : Fin 3 → ℝ) ∘ + Equiv.refl (Fin 3) = ![u, -rates i, -rates j] := by + funext r + fin_cases r <;> rfl + rw [hv] at h + exact h + have hx (j : Fin n) (u v : ℝ) : + MvPolynomial.eval ![u, v, -rates j] F = 0 := by + have hnode (i : Fin n) : + MvPolynomial.eval + ((Fin.cons (-rates i) ![u, -rates j] : Fin 3 → ℝ) ∘ + Equiv.swap 0 1) F = 0 := by + have hv : (Fin.cons (-rates i) ![u, -rates j] : Fin 3 → ℝ) ∘ + Equiv.swap 0 1 = ![u, -rates i, -rates j] := by + funext r + fin_cases r <;> simp [Function.comp_apply, Equiv.swap_apply_def] + rw [hv] + exact hz i j u + have h := realLine_zero rates hRates hnpos F hF + (Equiv.swap 0 1) ![u, -rates j] hnode v + have hv : (Fin.cons v ![u, -rates j] : Fin 3 → ℝ) ∘ + Equiv.swap 0 1 = ![u, v, -rates j] := by + funext r + fin_cases r <;> simp [Function.comp_apply, Equiv.swap_apply_def] + rw [hv] at h + exact h + have hy (u v w : ℝ) : MvPolynomial.eval ![u, v, w] F = 0 := by + have hnode (j : Fin n) : + MvPolynomial.eval + ((Fin.cons (-rates j) ![v, u] : Fin 3 → ℝ) ∘ + Equiv.swap 0 2) F = 0 := by + have hv : (Fin.cons (-rates j) ![v, u] : Fin 3 → ℝ) ∘ + Equiv.swap 0 2 = ![u, v, -rates j] := by + funext r + fin_cases r <;> simp [Function.comp_apply, Equiv.swap_apply_def] + rw [hv] + exact hx j u v + have h := realLine_zero rates hRates hnpos F hF + (Equiv.swap 0 2) ![v, u] hnode w + have hv : (Fin.cons w ![v, u] : Fin 3 → ℝ) ∘ + Equiv.swap 0 2 = ![u, v, w] := by + funext r + fin_cases r <;> simp [Function.comp_apply, Equiv.swap_apply_def] + rw [hv] at h + exact h + apply MvPolynomial.funext + intro w + have hw : w = ![w 0, w 1, w 2] := by + funext r + fin_cases r <;> rfl + rw [hw, map_zero] + exact hy (w 0) (w 1) (w 2) + +/-- Box polynomials agreeing on all n^3 actual negative-node values agree. -/ +theorem box_grid_ext (rates : Fin n → ℝ) (hRates : Function.Injective rates) + {F G : P3} (hF : Box n F) (hG : Box n G) + (hgrid : ∀ i j k : Fin n, + MvPolynomial.eval ![-rates k, -rates i, -rates j] F = + MvPolynomial.eval ![-rates k, -rates i, -rates j] G) : F = G := by + apply sub_eq_zero.mp + apply box_grid_eq_zero rates hRates (F - G) (box_sub hF hG) + intro i j k + rw [map_sub, hgrid i j k, sub_self] + +/-- The literal source residue inverse, with x-input/y-input/z-output order. +Its denominator is the accepted oriented product, equal to D' at the node. -/ +def gridResidue (rates : Fin n → ℝ) (F : P3) : Tensor n := + fun i j k => MvPolynomial.eval ![-rates k, -rates i, -rates j] F / + (di rates i * di rates j * di rates k) + +/-- Direct grid evaluation proves the tensor-side inverse. -/ +theorem gridResidue_numerator (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (E : Tensor n) : + gridResidue rates (numerator rates E) = E := by + funext i j k + unfold gridResidue + rw [numerator_eval_grid] + field_simp [di_ne_zero rates hRates i, di_ne_zero rates hRates j, + di_ne_zero rates hRates k] + + +/-- The actual Box condition and finite-grid theorem prove the polynomial +side inverse. Reconstruction is a conclusion, including n=0. -/ +theorem numerator_gridResidue (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (F : P3) (hF : Box n F) : + numerator rates (gridResidue rates F) = F := by + apply box_grid_ext rates hRates (numerator_box rates _) hF + intro i j k + rw [numerator_eval_grid] + unfold gridResidue + field_simp [di_ne_zero rates hRates i, di_ne_zero rates hRates j, + di_ne_zero rates hRates k] + + +/-- Uniqueness in the actual Box domain, without tensor symmetry. -/ +theorem gridResidue_injective_on_box (rates : Fin n → ℝ) + (hRates : Function.Injective rates) {F G : P3} (hF : Box n F) (hG : Box n G) + (h : gridResidue rates F = gridResidue rates G) : F = G := by + calc + F = numerator rates (gridResidue rates F) := (numerator_gridResidue rates hRates F hF).symm + _ = numerator rates (gridResidue rates G) := congrArg (numerator rates) h + _ = G := numerator_gridResidue rates hRates G hG + +/-- Exact forward/backward inverse characterization on the actual domain. -/ +theorem numerator_eq_iff_gridResidue (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (E : Tensor n) (F : P3) (hF : Box n F) : + numerator rates E = F ↔ E = gridResidue rates F := by + constructor + · intro h + calc + E = gridResidue rates (numerator rates E) := (gridResidue_numerator rates hRates E).symm + _ = gridResidue rates F := congrArg (gridResidue rates) h + · rintro rfl + exact numerator_gridResidue rates hRates F hF + +theorem existsUnique_numerator (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (F : P3) (hF : Box n F) : + ∃! E : Tensor n, numerator rates E = F := by + refine ⟨gridResidue rates F, numerator_gridResidue rates hRates F hF, ?_⟩ + intro E hE + exact (numerator_eq_iff_gridResidue rates hRates E F hF).mp hE + +private theorem gridVector_eq (rates : Fin n → ℝ) (a : Fin 3 → Fin n) : + ![-rates (a 0), -rates (a 1), -rates (a 2)] = + (fun r : Fin 3 => -rates (a r)) := by + funext r + fin_cases r <;> rfl + +private theorem gapDen_eq_prod (rates : Fin n → ℝ) (a : Fin 3 → Fin n) : + di rates (a 1) * di rates (a 2) * di rates (a 0) = + ∏ r : Fin 3, di rates (a r) := by + simp [Fin.prod_univ_succ]; ring + +/-- The three-gap denominator is fully symmetric even before injection. -/ +theorem gapDen_permute (rates : Fin n → ℝ) (e : Equiv.Perm (Fin 3)) + (a : Fin 3 → Fin n) : + di rates ((a ∘ e) 1) * di rates ((a ∘ e) 2) * di rates ((a ∘ e) 0) = + di rates (a 1) * di rates (a 2) * di rates (a 0) := by + rw [gapDen_eq_prod, gapDen_eq_prod] + exact _root_.Equiv.prod_comp e (fun r => di rates (a r)) + +/-- Polynomial symmetry transfers to every tensor slot of the actual +residue. No Box/injection premise is needed just to establish symmetry. -/ +theorem gridResidue_symmetric (rates : Fin n → ℝ) (F : P3) (hF : SymPoly F) : + FullSymTensor (gridResidue rates F) := by + intro e a + change + MvPolynomial.eval + ![-rates ((a ∘ e) 0), -rates ((a ∘ e) 1), -rates ((a ∘ e) 2)] F / + (di rates ((a ∘ e) 1) * di rates ((a ∘ e) 2) * di rates ((a ∘ e) 0)) = + MvPolynomial.eval ![-rates (a 0), -rates (a 1), -rates (a 2)] F / + (di rates (a 1) * di rates (a 2) * di rates (a 0)) + have heval : + MvPolynomial.eval (fun r : Fin 3 => -rates ((a ∘ e) r)) F = + MvPolynomial.eval (fun r : Fin 3 => -rates (a r)) F := by + have h := congrArg (MvPolynomial.eval (fun r : Fin 3 => -rates (a r))) (hF e) + rw [MvPolynomial.eval_rename] at h + exact h + rw [gridVector_eq, gridVector_eq, heval, gapDen_permute] + +/-- The accepted forward symmetry and the new actual inverse give the +exact full-symmetry correspondence. -/ +theorem numerator_symmetric_iff (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (E : Tensor n) : + SymPoly (numerator rates E) ↔ FullSymTensor E := by + constructor + · intro h + have hsym := gridResidue_symmetric rates (numerator rates E) h + rw [gridResidue_numerator rates hRates E] at hsym + exact hsym + · exact numerator_symmetric rates E + +/-- Every symmetric actual Box polynomial has exactly one fully symmetric +tensor preimage, supplied by its explicit negative-node residues. -/ +theorem existsUnique_symmetric_numerator (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (F : P3) (hBox : Box n F) (hSym : SymPoly F) : + ∃! E : Tensor n, FullSymTensor E ∧ numerator rates E = F := by + refine ⟨gridResidue rates F, + ⟨gridResidue_symmetric rates F hSym, numerator_gridResidue rates hRates F hBox⟩, ?_⟩ + intro E hE + exact (numerator_eq_iff_gridResidue rates hRates E F hBox).mp hE.2 + + +end C145.H2 + +end diff --git a/LeanPool/C145/C145H2NumeratorData.lean b/LeanPool/C145/C145H2NumeratorData.lean new file mode 100644 index 0000000000..377c553fd6 --- /dev/null +++ b/LeanPool/C145/C145H2NumeratorData.lean @@ -0,0 +1,501 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145ThreePlaneFactor +public import Mathlib.Algebra.MvPolynomial.Funext +public import Mathlib.Algebra.MvPolynomial.Polynomial +public import Mathlib.LinearAlgebra.Lagrange +public import Mathlib.Algebra.BigOperators.Field +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Mathlib.Algebra.BigOperators.GroupWithZero.Finset +public import Mathlib.Data.Fintype.BigOperators +public import Mathlib.Order.Interval.Set.Infinite +public import Mathlib.Tactic.FieldSimp +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.Order + +/-! +C145 ordinary residual H2: actual finite numerator, regular positive data, +and injectivity when n <= 3. + +Coordinates are z=X 0, x=X 1, y=X 2, exactly as in C145ThreePlaneFactor. +E i j k means the x-input, y-input, z-output coefficient. All three slots +are symmetric only where FullSymTensor is explicitly assumed. + +Products remain symbolic and unexpanded. Distinctness is used only for +individual gaps; positivity is used only in the named physical corollaries. +No grid inverse, all-n residue converse, moments, or physical trace is assumed. +-/ + +@[expose] public section + +noncomputable section + +namespace C145.H2 + +open MvPolynomial C145.ThreePlane +open scoped BigOperators + +/-- A real cubic tensor on a finite modal index set. -/ +abbrev Tensor (n : ℕ) := Fin n → Fin n → Fin n → ℝ + +/-- D(u) = product_h (u + lambda_h), including D=1 when n=0. -/ +def D {n : ℕ} (rates : Fin n → ℝ) : Polynomial ℝ := + ∏ h, (Polynomial.X + Polynomial.C (rates h)) + +/-- The literal erased product, not a quotient in a rational-function field. -/ +def Li {n : ℕ} (rates : Fin n → ℝ) (i : Fin n) : Polynomial ℝ := + ∏ h ∈ (Finset.univ.erase i), (Polynomial.X + Polynomial.C (rates h)) + +/-- Oriented gap product D'(-lambda_i); signs are lambda_h-lambda_i. -/ +def di {n : ℕ} (rates : Fin n → ℝ) (i : Fin n) : ℝ := + ∏ h ∈ (Finset.univ.erase i), (rates h - rates i) + +/-- Place the literal Li product in one of the three coordinates. -/ +def L {n : ℕ} (rates : Fin n → ℝ) (i : Fin n) (r : Fin 3) : P3 := + ∏ h ∈ (Finset.univ.erase i), (X r + C (rates h)) + +/-- The actual common-denominator numerator, with the source slot order. -/ +def numerator {n : ℕ} (rates : Fin n → ℝ) (E : Tensor n) : P3 := + ∑ i, ∑ j, ∑ k, C (E i j k) * L rates i 1 * L rates j 2 * L rates k 0 + +/-- Support formulation retains the exact n=0 meaning. -/ +def Box (n : ℕ) (F : P3) : Prop := + ∀ m ∈ F.support, ∀ r : Fin 3, m r < n + +/-- Read a tensor entry with the index order used in the permutation formulas. -/ +def entry {n : ℕ} (E : Tensor n) (a : Fin 3 → Fin n) : ℝ := + E (a 1) (a 2) (a 0) + +/-- Invariance under every permutation of all three slots, including output. -/ +def FullSymTensor {n : ℕ} (E : Tensor n) : Prop := + ∀ (e : Equiv.Perm (Fin 3)) (a : Fin 3 → Fin n), + entry E (a ∘ e) = entry E a + +/-- Exactly the ordinary residual response from DRE4/DRE6. -/ +def H {n : ℕ} (rates : Fin n → ℝ) (E : Tensor n) (s t : ℝ) : ℝ := + ∑ i, ∑ j, ∑ k, + E i j k / ((s + rates i) * (t + rates j) * (s + t + rates k)) + +/-- Guard every factor; no equality of totalized values at poles is inferred. -/ +def Regular {n : ℕ} (rates : Fin n → ℝ) (s t : ℝ) : Prop := + (∀ i, s + rates i ≠ 0) ∧ (∀ i, t + rates i ≠ 0) ∧ + (∀ i, s + t + rates i ≠ 0) + +/-- The second transfer function vanishes at all positive regular inputs. -/ +def NullRegular {n : ℕ} (rates : Fin n → ℝ) (E : Tensor n) : Prop := + ∀ s t, 0 < s → 0 < t → Regular rates s t → H rates E s t = 0 + +/-- The second transfer function vanishes at all positive inputs. -/ +def NullPositive {n : ℕ} (rates : Fin n → ℝ) (E : Tensor n) : Prop := + ∀ s t, 0 < s → 0 < t → H rates E s t = 0 + +/-- The second transfer functions agree at all positive regular inputs. -/ +def SameRegular {n : ℕ} (rates : Fin n → ℝ) (S T : Tensor n) : Prop := + ∀ s t, 0 < s → 0 < t → Regular rates s t → H rates S s t = H rates T s t + +/-- The second transfer functions agree at all positive inputs. -/ +def SamePositive {n : ℕ} (rates : Fin n → ℝ) (S T : Tensor n) : Prop := + ∀ s t, 0 < s → 0 < t → H rates S s t = H rates T s t + +variable {n : ℕ} + +/-- These are the actual literal products under polynomial substitution. -/ +theorem L_eq_eval₂ (rates : Fin n → ℝ) (i : Fin n) (r : Fin 3) : + L rates i r = Polynomial.eval₂ C (X r) (Li rates i) := by + simp [L, Li, Polynomial.eval₂_finsetProd] + +theorem eval_L (rates : Fin n → ℝ) (i : Fin n) (r : Fin 3) + (w : Fin 3 → ℝ) : + MvPolynomial.eval w (L rates i r) = (Li rates i).eval (w r) := by + simp [L, Li, Polynomial.eval_prod] + +theorem D_factor (rates : Fin n → ℝ) (i : Fin n) : + D rates = (Polynomial.X + Polynomial.C (rates i)) * Li rates i := by + exact (Finset.mul_prod_erase Finset.univ + (fun h => Polynomial.X + Polynomial.C (rates h)) (Finset.mem_univ i)).symm + +theorem eval_D_factor (rates : Fin n → ℝ) (i : Fin n) (u : ℝ) : + (D rates).eval u = (u + rates i) * (Li rates i).eval u := by + rw [D_factor rates i] + simp + +theorem eval_Li_node (rates : Fin n → ℝ) (i : Fin n) : + (Li rates i).eval (-rates i) = di rates i := by + simp [Li, di, Polynomial.eval_prod, sub_eq_add_neg, add_comm] + +theorem di_ne_zero (rates : Fin n → ℝ) (hRates : Function.Injective rates) (i : Fin n) : + di rates i ≠ 0 := by + classical + unfold di + apply Finset.prod_ne_zero_iff.mpr + intro h hh + exact sub_ne_zero.mpr (fun he => (Finset.mem_erase.mp hh).1 (hRates he)) + +/-- Binds the source derivative notation to the same oriented erased product. -/ +theorem eval_derivative_D_node (rates : Fin n → ℝ) (i : Fin n) : + (D rates).derivative.eval (-rates i) = di rates i := by + have hD : D rates = Lagrange.nodal Finset.univ (fun h => -rates h) := by + simp [D, Lagrange.nodal] + have hL : Li rates i = Lagrange.nodal (Finset.univ.erase i) (fun h => -rates h) := by + simp [Li, Lagrange.nodal] + rw [hD, Lagrange.eval_nodal_derivative_eval_node_eq + (s := Finset.univ) (v := fun h : Fin n => -rates h) (i := i) (Finset.mem_univ i), + ← hL, eval_Li_node] + +/-- Off-diagonal vanishing uses a literal zero factor and needs no injection. -/ +theorem eval_Li_other (rates : Fin n → ℝ) (i h : Fin n) (hhi : h ≠ i) : + (Li rates i).eval (-rates h) = 0 := by + classical + simp only [Li, Polynomial.eval_prod, Polynomial.eval_add, + Polynomial.eval_X, Polynomial.eval_C] + exact Finset.prod_eq_zero (Finset.mem_erase.mpr ⟨hhi, Finset.mem_univ h⟩) (by ring) + +theorem eval_Li_grid (rates : Fin n → ℝ) (i h : Fin n) : + (Li rates i).eval (-rates h) = if i = h then di rates h else 0 := by + by_cases hi : i = h + · subst i + simp [eval_Li_node] + · simp [hi, eval_Li_other rates i h (Ne.symm hi)] + +/-- Direct finite-sum evaluation; this is not an interpolation premise. -/ +theorem numerator_eval_grid (rates : Fin n → ℝ) (E : Tensor n) (i j k : Fin n) : + MvPolynomial.eval ![-rates k, -rates i, -rates j] (numerator rates E) = + E i j k * di rates i * di rates j * di rates k := by + classical + simp [numerator, eval_L, eval_Li_grid] + +/-- Numerator injection is obtained from its actual negative-node values. -/ +theorem numerator_injective (rates : Fin n → ℝ) (hRates : Function.Injective rates) : + Function.Injective (numerator rates) := by + intro E F h + funext i j k + have hg := congrArg (MvPolynomial.eval ![-rates k, -rates i, -rates j]) h + rw [numerator_eval_grid, numerator_eval_grid] at hg + have h₁ := mul_right_cancel₀ (di_ne_zero rates hRates k) hg + have h₂ := mul_right_cancel₀ (di_ne_zero rates hRates j) h₁ + exact mul_right_cancel₀ (di_ne_zero rates hRates i) h₂ + +theorem numerator_zero (rates : Fin n → ℝ) : numerator rates (0 : Tensor n) = 0 := by + simp [numerator] + +theorem numerator_eq_zero_iff (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (E : Tensor n) : numerator rates E = 0 ↔ E = 0 := by + constructor + · intro h + apply numerator_injective rates hRates + rw [h, numerator_zero] + · rintro rfl + exact numerator_zero rates + +/-- Empty residual tensor and empty sums are retained, with no chosen grid node. -/ +theorem numerator_n0 (rates : Fin 0 → ℝ) (E : Tensor 0) : numerator rates E = 0 := by + simp [numerator] + +theorem box_zero_iff (F : P3) : Box 0 F ↔ F = 0 := by + classical + constructor + · intro hb + ext m + change F.coeff m = 0 + by_contra hm + have hlt := hb m (MvPolynomial.mem_support_iff.mpr hm) 0 + omega + · rintro rfl + simp [Box] + +theorem box_iff_degree_lt (hn : 0 < n) (F : P3) : + Box n F ↔ ∀ r : Fin 3, degreeOf r F < n := by + constructor + · intro hb r + exact (degreeOf_lt_iff hn).mpr (fun m hm => hb m hm r) + · intro hd m hm r + exact (monomial_le_degreeOf r hm).trans_lt (hd r) + +private def tripleEquiv : (Fin n × (Fin n × Fin n)) ≃ (Fin 3 → Fin n) where + toFun p := ![p.2.2, p.1, p.2.1] + invFun a := (a 1, a 2, a 0) + left_inv p := by rcases p with ⟨i, j, k⟩; rfl + right_inv a := by funext r; fin_cases r <;> rfl + +/-- A change of finite indexing only, exposing all-slot symmetry without +expanding the n-dependent Li products. The definition itself is the triple sum. -/ +theorem numerator_as_sum (rates : Fin n → ℝ) (E : Tensor n) : + numerator rates E = ∑ a : Fin 3 → Fin n, + C (entry E a) * ∏ r : Fin 3, L rates (a r) r := by + classical + calc + numerator rates E = ∑ p : Fin n × (Fin n × Fin n), + C (E p.1 p.2.1 p.2.2) * L rates p.1 1 * L rates p.2.1 2 * L rates p.2.2 0 := by + simp only [numerator, Fintype.sum_prod_type] + _ = _ := Fintype.sum_equiv tripleEquiv _ _ (by + intro p + simp [tripleEquiv, entry, Fin.prod_univ_succ]; ring) + +private theorem degree_L_le (rates : Fin n → ℝ) (i : Fin n) (r c : Fin 3) : + degreeOf c (L rates i r) ≤ if c = r then n - 1 else 0 := by + classical + calc + degreeOf c (L rates i r) ≤ ∑ h ∈ Finset.univ.erase i, + degreeOf c (X r + C (rates h) : P3) := degreeOf_prod_le c _ _ + _ ≤ ∑ _h ∈ Finset.univ.erase i, (if c = r then 1 else 0) := by + apply Finset.sum_le_sum + intro h hh + exact (degreeOf_add_le c _ _).trans (by simp [degreeOf_X]) + _ = if c = r then n - 1 else 0 := by + by_cases h : c = r <;> simp [h, Finset.card_erase_of_mem] + +private theorem degree_term_le (rates : Fin n → ℝ) (E : Tensor n) + (a : Fin 3 → Fin n) (c : Fin 3) : + degreeOf c (C (entry E a) * ∏ r : Fin 3, L rates (a r) r) ≤ n - 1 := by + classical + calc + degreeOf c (C (entry E a) * ∏ r : Fin 3, L rates (a r) r) ≤ + 0 + ∑ r : Fin 3, degreeOf c (L rates (a r) r) := + (degreeOf_mul_le c _ _).trans (by + rw [degreeOf_C] + exact Nat.add_le_add_left (degreeOf_prod_le c _ _) 0) + _ ≤ 0 + ∑ r : Fin 3, (if c = r then n - 1 else 0) := by + exact Nat.add_le_add_left (Finset.sum_le_sum (fun r _ => degree_L_le rates (a r) r c)) 0 + _ = n - 1 := by simp + +/-- Support Box is derived from the literal numerator at every n, without +rate injection, tensor symmetry, or any caller-supplied degree bound. -/ +theorem numerator_box (rates : Fin n → ℝ) (E : Tensor n) : Box n (numerator rates E) := by + classical + by_cases hn : n = 0 + · subst n + exact (box_zero_iff _).mpr (numerator_n0 rates E) + · have hnpos : 0 < n := Nat.pos_of_ne_zero hn + apply (box_iff_degree_lt hnpos _).mpr + intro c + have hd : degreeOf c (numerator rates E) ≤ n - 1 := by + rw [numerator_as_sum] + exact (degreeOf_sum_le c _ _).trans (Finset.sup_le (fun a _ => degree_term_le rates E a c)) + omega + +private theorem rename_L (rates : Fin n → ℝ) (i : Fin n) + (e : Equiv.Perm (Fin 3)) (r : Fin 3) : + rename e (L rates i r) = L rates i (e r) := by + simp [L] + +private def reindex (e : Equiv.Perm (Fin 3)) : + (Fin 3 → Fin n) ≃ (Fin 3 → Fin n) where + toFun a := a ∘ e.symm + invFun a := a ∘ e + left_inv a := by funext r; simp + right_inv a := by funext r; simp + +/-- Full tensor symmetry gives the accepted all-coordinate SymPoly interface. -/ +theorem numerator_symmetric (rates : Fin n → ℝ) (E : Tensor n) + (hE : FullSymTensor E) : SymPoly (numerator rates E) := by + classical + intro e + let f : (Fin 3 → Fin n) → P3 := fun a => + C (entry E a) * ∏ r : Fin 3, L rates (a r) r + have hf : numerator rates E = ∑ a : Fin 3 → Fin n, f a := + numerator_as_sum rates E + have hterm (a : Fin 3 → Fin n) : rename e (f a) = f (reindex e a) := by + have hc : entry E (reindex e a) = entry E a := hE e.symm a + have hp : (∏ r : Fin 3, L rates (a r) (e r)) = + ∏ r : Fin 3, L rates ((reindex e a) r) r := by + calc + (∏ r : Fin 3, L rates (a r) (e r)) = + ∏ r : Fin 3, L rates ((reindex e a) (e r)) (e r) := by + apply Finset.prod_congr rfl + intro r hr + change L rates (a r) (e r) = L rates (a (e.symm (e r))) (e r) + rw [e.symm_apply_apply] + _ = ∏ r : Fin 3, L rates ((reindex e a) r) r := + _root_.Equiv.prod_comp e (fun r => L rates ((reindex e a) r) r) + change rename e (C (entry E a) * ∏ r : Fin 3, L rates (a r) r) = + C (entry E (reindex e a)) * ∏ r : Fin 3, L rates ((reindex e a) r) r + simp only [map_mul, rename_C, map_prod, rename_L] + rw [hc, hp] + calc + rename e (numerator rates E) = rename e (∑ a : Fin 3 → Fin n, f a) := + congrArg (fun F : P3 => rename e F) hf + _ = ∑ a : Fin 3 → Fin n, rename e (f a) := by rw [map_sum] + _ = ∑ a : Fin 3 → Fin n, f (reindex e a) := + Finset.sum_congr rfl (fun a _ => hterm a) + _ = ∑ a : Fin 3 → Fin n, f a := _root_.Equiv.sum_comp (reindex e) f + _ = numerator rates E := hf.symm + +/-- Exact finite denominator identity on its actual regular domain. -/ +theorem clear_response_denominators (rates : Fin n → ℝ) (E : Tensor n) + (s t : ℝ) (hreg : Regular rates s t) : + MvPolynomial.eval ![s + t, s, t] (numerator rates E) = + (D rates).eval s * (D rates).eval t * (D rates).eval (s + t) * H rates E s t := by + classical + simp only [numerator, map_sum, map_mul, eval_C, eval_L, H, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + simp only [Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two, + Matrix.head_cons, Matrix.tail_cons] + rw [eval_D_factor rates i s, eval_D_factor rates j t, eval_D_factor rates k (s + t)] + field_simp [hreg.1 i, hreg.2.1 j, hreg.2.2 k] + + +theorem denominator_ne_zero (rates : Fin n → ℝ) (s t : ℝ) (hreg : Regular rates s t) : + (D rates).eval s * (D rates).eval t * (D rates).eval (s + t) ≠ 0 := by + classical + have hd (u : ℝ) (hu : ∀ i, u + rates i ≠ 0) : (D rates).eval u ≠ 0 := by + simp only [D, Polynomial.eval_prod, Polynomial.eval_add, Polynomial.eval_X, Polynomial.eval_C] + exact Finset.prod_ne_zero_iff.mpr (fun i _ => hu i) + exact mul_ne_zero (mul_ne_zero (hd s hreg.1) (hd t hreg.2.1)) (hd (s + t) hreg.2.2) + +/-- Commutes the accepted literal rhoZ with real evaluation. -/ +theorem eval_rhoZ (F : P3) (s t : ℝ) : + MvPolynomial.eval ![s,t] (rhoZ F) = MvPolynomial.eval ![s + t,s,t] F := by + change MvPolynomial.eval ![s,t] + (eval₂Hom C ![(X 0 : P2) + X 1, X 0, X 1] F) = _ + rw [coe_eval₂Hom, ← MvPolynomial.eval_assoc] + have hv : (MvPolynomial.eval ![s,t]) ∘ + (![(X 0 : P2) + X 1, X 0, X 1] : Fin 3 → P2) = ![s + t,s,t] := by + funext r + fin_cases r <;> simp + rw [hv] + +/-- A finite-rate positive tail exists even for arbitrary real rates. -/ +def tailBound (rates : Fin n → ℝ) : ℝ := 1 + ∑ i, |rates i| + +theorem tailBound_pos (rates : Fin n → ℝ) : 0 < tailBound rates := by + have hs : 0 ≤ ∑ i, |rates i| := Finset.sum_nonneg (fun i _ => abs_nonneg (rates i)) + unfold tailBound + linarith + +theorem tail_regular (rates : Fin n → ℝ) (s t : ℝ) + (hs : tailBound rates < s) (ht : tailBound rates < t) : Regular rates s t := by + have hneg (i : Fin n) : -rates i ≤ ∑ j, |rates j| := + (neg_le_abs (rates i)).trans (Finset.single_le_sum (fun j _ => abs_nonneg (rates j)) + (Finset.mem_univ i)) + have hs0 := lt_trans (tailBound_pos rates) hs + refine ⟨?_, ?_, ?_⟩ <;> intro i + · apply ne_of_gt + have hi := hneg i + unfold tailBound at hs + linarith + · apply ne_of_gt + have hi := hneg i + unfold tailBound at ht + linarith + · apply ne_of_gt + have hi := hneg i + unfold tailBound at ht + linarith + +/-- Actual positive regular data, with no rate sign or injection assumption, +are equivalent to the polynomial plane identity. -/ +theorem ordinary_data_iff_plane (rates : Fin n → ℝ) (E : Tensor n) : + NullRegular rates E ↔ rhoZ (numerator rates E) = 0 := by + constructor + · intro h + apply MvPolynomial.funext_set (fun _ : Fin 2 => Set.Ioi (tailBound rates)) + (fun _ => Set.Ioi_infinite _) + intro w hw + have hs : tailBound rates < w 0 := hw 0 (Set.mem_univ 0) + have ht : tailBound rates < w 1 := hw 1 (Set.mem_univ 1) + have hwv : w = ![w 0,w 1] := by funext r; fin_cases r <;> rfl + rw [hwv, eval_rhoZ, clear_response_denominators rates E _ _ (tail_regular rates _ _ hs ht), + h _ _ (lt_trans (tailBound_pos rates) hs) (lt_trans (tailBound_pos rates) ht) + (tail_regular rates _ _ hs ht), mul_zero, map_zero] + · intro h s t hs ht hreg + have hz : MvPolynomial.eval ![s + t,s,t] (numerator rates E) = 0 := by + rw [← eval_rhoZ, h, map_zero] + rw [clear_response_denominators rates E s t hreg] at hz + exact (mul_eq_zero.mp hz).resolve_left (denominator_ne_zero rates s t hreg) + +theorem positive_regular (rates : Fin n → ℝ) (hpos : ∀ i, 0 < rates i) + (s t : ℝ) (hs : 0 < s) (ht : 0 < t) : Regular rates s t := by + exact ⟨fun i => ne_of_gt (add_pos hs (hpos i)), + fun i => ne_of_gt (add_pos ht (hpos i)), + fun i => ne_of_gt (add_pos (add_pos hs ht) (hpos i))⟩ + +theorem nullPositive_iff_nullRegular (rates : Fin n → ℝ) (hpos : ∀ i, 0 < rates i) + (E : Tensor n) : NullPositive rates E ↔ NullRegular rates E := by + exact ⟨fun h s t hs ht _ => h s t hs ht, + fun h s t hs ht => h s t hs ht (positive_regular rates hpos s t hs ht)⟩ + +theorem positive_data_iff_plane (rates : Fin n → ℝ) (hpos : ∀ i, 0 < rates i) + (E : Tensor n) : NullPositive rates E ↔ rhoZ (numerator rates E) = 0 := by + rw [nullPositive_iff_nullRegular rates hpos, ordinary_data_iff_plane] + +theorem H_sub (rates : Fin n → ℝ) (S T : Tensor n) (s t : ℝ) : + H rates (S - T) s t = H rates S s t - H rates T s t := by + simp [H, sub_div, Finset.sum_sub_distrib] + +theorem sameRegular_iff_plane (rates : Fin n → ℝ) (S T : Tensor n) : + SameRegular rates S T ↔ rhoZ (numerator rates (S - T)) = 0 := by + rw [← ordinary_data_iff_plane] + simp only [SameRegular, NullRegular, H_sub, sub_eq_zero] + +theorem samePositive_iff_plane (rates : Fin n → ℝ) (hpos : ∀ i, 0 < rates i) + (S T : Tensor n) : + SamePositive rates S T ↔ rhoZ (numerator rates (S - T)) = 0 := by + rw [← positive_data_iff_plane rates hpos] + simp only [SamePositive, NullPositive, H_sub, sub_eq_zero] + +/-- Accepted factor/degree results and the derived Box force zero in small n. -/ +theorem small_n_polynomial_zero (hn : n ≤ 3) (F : P3) + (hbox : Box n F) (hsym : SymPoly F) (hz : rhoZ F = 0) : F = 0 := by + by_cases hn0 : n = 0 + · subst n + exact (box_zero_iff F).mp hbox + · by_contra hF + obtain ⟨R, hR⟩ := xi_dvd hsym hz + have hdeg := factor_degree hR hF 0 + have hlt := (box_iff_degree_lt (Nat.pos_of_ne_zero hn0) F).mp hbox 0 + omega + +/-- Actual regular-data injection on unrestricted fully symmetric residual + tensors for n<=3 (N<=4 after a separately calibrated ground subtraction). -/ +theorem small_n_nullRegular (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (hn : n ≤ 3) (E : Tensor n) (hsym : FullSymTensor E) + (hdata : NullRegular rates E) : E = 0 := by + apply (numerator_eq_zero_iff rates hRates E).mp + exact small_n_polynomial_zero hn _ (numerator_box rates E) + (numerator_symmetric rates E hsym) ((ordinary_data_iff_plane rates E).mp hdata) + +theorem small_n_nullPositive (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (hpos : ∀ i, 0 < rates i) (hn : n ≤ 3) (E : Tensor n) + (hsym : FullSymTensor E) (hdata : NullPositive rates E) : E = 0 := by + exact small_n_nullRegular rates hRates hn E hsym + ((nullPositive_iff_nullRegular rates hpos E).mp hdata) + +theorem fullSymTensor_sub (S T : Tensor n) (hS : FullSymTensor S) + (hT : FullSymTensor T) : FullSymTensor (S - T) := by + intro e a + exact congrArg₂ (· - ·) (hS e a) (hT e a) + +theorem small_n_sameRegular (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (hn : n ≤ 3) (S T : Tensor n) (hS : FullSymTensor S) (hT : FullSymTensor T) + (hdata : SameRegular rates S T) : S = T := by + apply sub_eq_zero.mp + apply small_n_nullRegular rates hRates hn (S - T) (fullSymTensor_sub S T hS hT) + intro s t hs ht hreg + rw [H_sub, hdata s t hs ht hreg, sub_self] + +theorem small_n_samePositive (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (hpos : ∀ i, 0 < rates i) (hn : n ≤ 3) (S T : Tensor n) + (hS : FullSymTensor S) (hT : FullSymTensor T) + (hdata : SamePositive rates S T) : S = T := by + apply sub_eq_zero.mp + apply small_n_nullPositive rates hRates hpos hn (S - T) (fullSymTensor_sub S T hS hT) + intro s t hs ht + rw [H_sub, hdata s t hs ht, sub_self] + + +end C145.H2 + +end diff --git a/LeanPool/C145/C145H2PositiveGrid.lean b/LeanPool/C145/C145H2PositiveGrid.lean new file mode 100644 index 0000000000..2afbae1397 --- /dev/null +++ b/LeanPool/C145/C145H2PositiveGrid.lean @@ -0,0 +1,180 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145H2NumeratorData +public import Mathlib.Algebra.Polynomial.Eval.Degree + +/-! C145 DRE8 Lemma D: exact arbitrary positive H2 sampling grids. +The literal full-N denominator numerator is restricted to z=s+t. Its two +coordinate degrees are derived from the erased products, without a supplied +unisolvence, degree, rank, or kernel certificate. Symmetry/ground-zero are not +needed for interpolation, so the result restricts to the source V0. -/ + +@[expose] public section + +noncomputable section +namespace C145.H2 +open MvPolynomial C145.ThreePlane +open scoped BigOperators +variable {n : ℕ} + +/-- The actual two-variable numerator after imposing the response plane. -/ +def planeNumerator (rates : Fin n → ℝ) (E : Tensor n) : P2 := + rhoZ (numerator rates E) + +private def erasedProduct (rates : Fin n → ℝ) (i : Fin n) (p : P2) : P2 := + ∏ h ∈ Finset.univ.erase i, (p + C (rates h)) + +private theorem planeNumerator_formula (rates : Fin n → ℝ) (E : Tensor n) : + planeNumerator rates E = ∑ i, ∑ j, ∑ k, + C (E i j k) * erasedProduct rates i (X 0) * + erasedProduct rates j (X 1) * erasedProduct rates k (X 0 + X 1) := by + have hrho (F : P3) : rhoZ F = + eval₂Hom C ![(X 0 : P2) + X 1, X 0, X 1] F := rfl + unfold planeNumerator + rw [hrho] + simp [numerator, L, erasedProduct] + +private theorem erasedProduct_degree_le (rates : Fin n → ℝ) (i : Fin n) + (p : P2) (c : Fin 2) : + degreeOf c (erasedProduct rates i p) ≤ (n - 1) * degreeOf c p := by + classical + calc + _ ≤ ∑ h ∈ Finset.univ.erase i, degreeOf c (p + C (rates h)) := + degreeOf_prod_le c _ _ + _ ≤ ∑ _h ∈ Finset.univ.erase i, degreeOf c p := by + apply Finset.sum_le_sum + intro h hh + exact (degreeOf_add_le c p _).trans (by simp) + _ = (n - 1) * degreeOf c p := by simp [Finset.card_erase_of_mem] + +private theorem plane_term_degree_le (rates : Fin n → ℝ) (E : Tensor n) + (i j k : Fin n) (c : Fin 2) : + degreeOf c (C (E i j k) * erasedProduct rates i (X 0) * + erasedProduct rates j (X 1) * erasedProduct rates k (X 0 + X 1)) ≤ + 2 * n - 2 := by + have h0 := erasedProduct_degree_le rates i (X 0) c + have h1 := erasedProduct_degree_le rates j (X 1) c + have hs := erasedProduct_degree_le rates k (X 0 + X 1) c + have hsum : degreeOf c ((X 0 : P2) + X 1) ≤ 1 := + (degreeOf_add_le c _ _).trans (by fin_cases c <;> simp [degreeOf_X]) + have hdeg := degreeOf_mul_le c + (C (E i j k) * erasedProduct rates i (X 0) * erasedProduct rates j (X 1)) + (erasedProduct rates k (X 0 + X 1)) + have hdeg' := degreeOf_mul_le c + (C (E i j k) * erasedProduct rates i (X 0)) (erasedProduct rates j (X 1)) + have hdeg'' := degreeOf_mul_le c (C (E i j k)) (erasedProduct rates i (X 0)) + have hlast : degreeOf c (erasedProduct rates k (X 0 + X 1)) ≤ n - 1 := + hs.trans (by simpa using Nat.mul_le_mul_left (n - 1) hsum) + fin_cases c <;> simp [degreeOf_X] at h0 h1 hdeg hdeg' hdeg'' hlast ⊢ <;> omega + +/-- Literal denominator clearing has bidegree at most 2N-2, for every full +N-index tensor. This bound is proved, never supplied by the caller. -/ +theorem planeNumerator_degree_le (rates : Fin n → ℝ) (E : Tensor n) (c : Fin 2) : + degreeOf c (planeNumerator rates E) ≤ 2 * n - 2 := by + classical + rw [planeNumerator_formula] + apply (degreeOf_sum_le c _ _).trans + apply Finset.sup_le; intro i hi + apply (degreeOf_sum_le c _ _).trans + apply Finset.sup_le; intro j hj + apply (degreeOf_sum_le c _ _).trans + exact Finset.sup_le (fun k hk => plane_term_degree_le rates E i j k c) + +private def gridSlice (e : Equiv.Perm (Fin 2)) (F : P2) (v : ℝ) : Polynomial ℝ := + Polynomial.map (MvPolynomial.eval ![v]) (finSuccEquiv ℝ 1 (rename e F)) + +private theorem eval_gridSlice (e : Equiv.Perm (Fin 2)) (F : P2) (v u : ℝ) : + (gridSlice e F v).eval u = MvPolynomial.eval ((![u,v] : Fin 2 → ℝ) ∘ e) F := by + unfold gridSlice + rw [← MvPolynomial.eval_eq_eval_mv_eval', MvPolynomial.eval_rename] + rfl + +private theorem gridSlice_natDegree_le (e : Equiv.Perm (Fin 2)) (F : P2) (v : ℝ) : + (gridSlice e F v).natDegree ≤ degreeOf (e.symm 0) F := by + have he : degreeOf (0 : Fin 2) (rename e F) = degreeOf (e.symm 0) F := by + simpa only [e.apply_symm_apply] using + (degreeOf_rename_of_injective (p := F) e.injective (e.symm 0)) + calc + _ ≤ (finSuccEquiv ℝ 1 (rename e F)).natDegree := Polynomial.natDegree_map_le + _ = degreeOf (0 : Fin 2) (rename e F) := natDegree_finSuccEquiv _ + _ = degreeOf (e.symm 0) F := he + +private theorem gridLine_zero {m : ℕ} (nodes : Fin m → ℝ) + (hnodes : Function.Injective nodes) (F : P2) + (hdegree : ∀ c : Fin 2, degreeOf c F < m) + (e : Equiv.Perm (Fin 2)) (v : ℝ) + (hnode : ∀ i, MvPolynomial.eval ((![nodes i,v] : Fin 2 → ℝ) ∘ e) F = 0) + (u : ℝ) : MvPolynomial.eval ((![u,v] : Fin 2 → ℝ) ∘ e) F = 0 := by + classical + have hp : gridSlice e F v = 0 := by + apply Polynomial.eq_zero_of_degree_lt_of_eval_index_eq_zero + (Finset.univ : Finset (Fin m)) hnodes.injOn + · have hn : (gridSlice e F v).natDegree < m := + (gridSlice_natDegree_le e F v).trans_lt (hdegree (e.symm 0)) + have hc : ((gridSlice e F v).natDegree : WithBot ℕ) < (m : WithBot ℕ) := + WithBot.coe_lt_coe.mpr hn + simpa only [Finset.card_univ, Fintype.card_fin] using + (Polynomial.degree_le_natDegree (p := gridSlice e F v)).trans_lt hc + · intro i hi + rw [eval_gridSlice] + exact hnode i + rw [← eval_gridSlice, hp, Polynomial.eval_zero] + +/-- Successive univariate finite-root interpolation on any Cartesian grid. +The two axes may overlap, and diagonal samples are retained. -/ +theorem bidegree_grid_eq_zero {m : ℕ} (sNodes tNodes : Fin m → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (F : P2) (hdegree : ∀ c : Fin 2, degreeOf c F < m) + (hgrid : ∀ i j, MvPolynomial.eval ![sNodes i, tNodes j] F = 0) : F = 0 := by + have hs (s : ℝ) (j : Fin m) : MvPolynomial.eval ![s,tNodes j] F = 0 := by + simpa using gridLine_zero sNodes hsNodes F hdegree (Equiv.refl (Fin 2)) + (tNodes j) (fun i => by simpa using hgrid i j) s + have hst (s t : ℝ) : MvPolynomial.eval ![s,t] F = 0 := by + have hv (u : ℝ) : (fun x => (![u,s] : Fin 2 → ℝ) (Equiv.swap 0 1 x)) = ![s,u] := by + funext r; fin_cases r <;> simp + have hnode (j : Fin m) : + MvPolynomial.eval ((![tNodes j,s] : Fin 2 → ℝ) ∘ Equiv.swap 0 1) F = 0 := by + rw [show ((![tNodes j,s] : Fin 2 → ℝ) ∘ Equiv.swap 0 1) = ![s,tNodes j] from hv _] + exact hs s j + have h := gridLine_zero tNodes htNodes F hdegree (Equiv.swap 0 1) s hnode t + simpa only [show ((![t,s] : Fin 2 → ℝ) ∘ Equiv.swap 0 1) = ![s,t] from hv _] using h + apply MvPolynomial.funext + intro w + have hw : w = ![w 0,w 1] := by funext c; fin_cases c <;> rfl + rw [hw, map_zero] + exact hst _ _ + +/-- Exact source grid count, with nonvanishing positive denominators derived +from the rates and positivity. No symmetry, rate injection, or nonzero overlap +assumption is needed for this interpolation step. -/ +theorem positive_grid_iff_nullPositive (hn : 0 < n) (rates : Fin n → ℝ) + (hRates : ∀ i, 0 < rates i) (E : Tensor n) + (sNodes tNodes : Fin (2 * n - 1) → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (hsPos : ∀ i, 0 < sNodes i) (htPos : ∀ i, 0 < tNodes i) : + (∀ i j, H rates E (sNodes i) (tNodes j) = 0) ↔ NullPositive rates E := by + constructor + · intro hg + apply (positive_data_iff_plane rates hRates E).mpr + change planeNumerator rates E = 0 + apply bidegree_grid_eq_zero sNodes tNodes hsNodes htNodes + · intro c + have hd := planeNumerator_degree_le rates E c + omega + · intro i j + rw [planeNumerator, eval_rhoZ, clear_response_denominators rates E _ _ + (positive_regular rates hRates _ _ (hsPos i) (htPos j)), hg i j, mul_zero] + · intro h i j + exact h _ _ (hsPos i) (htPos j) + +end C145.H2 + +end diff --git a/LeanPool/C145/C145N6CalibratedTransport.lean b/LeanPool/C145/C145N6CalibratedTransport.lean new file mode 100644 index 0000000000..ff7dc3d976 --- /dev/null +++ b/LeanPool/C145/C145N6CalibratedTransport.lean @@ -0,0 +1,64 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6PhysicalWitness +public import LeanPool.C145.C145CoordinatePermutation + +/-! +# Calibrated transport for the explicit six-vertex source. +-/ + +@[expose] public section +noncomputable section +namespace C145N6Frame +open scoped BigOperators +open C145CoordinatePermutation + +theorem saved_response_cubic_equality (μ : ℝ) (Q : Fin 6 → Fin 6 → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (hground : ∀ v, Q v 0 = 1 / Real.sqrt 6) + (hresponse : C145.H2.SamePositive (C145.H2.fullRates μ C145N6.rates) + (C145PhysicalFrame.T frame overlap) (C145PhysicalFrame.T Q overlap)) : + C145PhysicalFrame.C frame = C145PhysicalFrame.C Q := by + have he := (actual_tensor_saved_base).trans (saved_frame_response_unique μ Q hQ hground + hresponse).symm + funext i j k + have h := congrFun (congrFun (congrFun he i) j) k + exact (mul_left_cancel₀ (mul_ne_zero (mul_ne_zero (overlap_nonzero i) (overlap_nonzero j)) + (overlap_nonzero k))) h + +theorem saved_spectralPort : spectralPort overlap frame = port := by + funext v + simp only [spectralPort, overlap_frame_feature] + fin_cases v <;> norm_num [feature, helmert, numerator, gramWeight, port, Fin.sum_univ_succ] + +/-- One common vertex permutation transports all reconstructed spectral data. +The competitor's vertex port is reconstructed, not assumed equal coordinatewise. -/ +theorem calibrated_response_spectral_transport (μ : ℝ) (Q : Fin 6 → Fin 6 → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (hground : ∀ v, Q v 0 = 1 / Real.sqrt 6) + (hresponse : C145.H2.SamePositive (C145.H2.fullRates μ C145N6.rates) + (C145PhysicalFrame.T frame overlap) (C145PhysicalFrame.T Q overlap)) : + ∃ π : Equiv.Perm (Fin 6), + (∀ w v, transport frame Q w v = if w = π v then 1 else 0) ∧ + (∀ v i, Q (π v) i = frame v i) ∧ + (∀ v u, spectralGenerator (C145.H2.fullRates μ C145N6.rates) Q (π v) (π u) = + spectralGenerator (C145.H2.fullRates μ C145N6.rates) frame v u) ∧ + (∀ v, spectralPort overlap Q (π v) = port v) ∧ + (∀ v u, decayLaplacian μ (C145.H2.fullRates μ C145N6.rates) Q (π v) (π u) = + decayLaplacian μ (C145.H2.fullRates μ C145N6.rates) frame v u) := by + obtain ⟨π,hπ,hrow,hgen,hport,hlap⟩ := cubic_equality_spectral_transport frame Q + frame_orthonormal hQ + (saved_response_cubic_equality μ Q hQ hground hresponse) (C145.H2.fullRates μ C145N6.rates) + overlap μ + exact ⟨π,hπ,hrow,hgen,by simpa only [saved_spectralPort] using hport,hlap⟩ +end C145N6Frame + +end diff --git a/LeanPool/C145/C145N6GraphResponse.lean b/LeanPool/C145/C145N6GraphResponse.lean new file mode 100644 index 0000000000..83bba1d706 --- /dev/null +++ b/LeanPool/C145/C145N6GraphResponse.lean @@ -0,0 +1,65 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6OrdinaryJets +public import LeanPool.C145.C145GraphSpectralRealization + +/-! +# Local responses for the explicit six-vertex graph. +-/ + +@[expose] public section +noncomputable section +namespace C145N6Frame +open C145.ActualResponse C145.ObservedKernelRecovery +open scoped BigOperators Topology ContDiff +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +/-- An actual response germ continuous at zero inherits C2 from local uniqueness. -/ +theorem actual_response_C2_of_continuous {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (R : Input T → C145.ActualResponse.Path n T) + (hR : IsActualResponse hT Q rates b R) (hc : ContinuousAt R 0) : + ContDiffAt ℝ 2 R 0 := by + obtain ⟨S,hS,hCS⟩ := exists_actual_C2_response hT Q rates b hQ + exact hCS.congr_of_eventuallyEq (actual_response_germ_unique hT Q rates b hQ R S hR hS hc + hCS.continuousAt) + +theorem literal_graph_generator : C145.GraphSpectralRealization.generator 1 edgeWeight = generator + := by + have h := actual_generator_laplacian + simpa only [C145.GraphSpectralRealization.generator, neg_smul, one_smul] using h.symm + +theorem literal_graph_vectorField : vectorField frame literalRates port = + C145.GraphSpectralRealization.graphVectorField 1 edgeWeight port := by + unfold vectorField C145.GraphSpectralRealization.graphVectorField + rw [actual_spectral_generator, literal_graph_generator] + +theorem literal_graph_response_iff {T : ℝ} (hT : 0 < T) + (R : Input T → C145.ActualResponse.Path 5 T) : + C145.GraphSpectralRealization.IsGraphResponse hT 1 edgeWeight port R ↔ + IsActualResponse hT frame literalRates port R := by + unfold C145.GraphSpectralRealization.IsGraphResponse IsActualResponse + rw [literal_graph_vectorField] + +theorem literal_graph_response_exists {T : ℝ} (hT : 0 < T) : + ∃ R : Input T → C145.ActualResponse.Path 5 T, + C145.GraphSpectralRealization.IsGraphResponse hT 1 edgeWeight port R ∧ ContDiffAt ℝ 2 R 0 := + by + obtain ⟨R,hR,hC⟩ := literal_source_actual_C2_response hT + exact ⟨R,(literal_graph_response_iff hT R).mpr hR,hC⟩ +end C145N6Frame + +end diff --git a/LeanPool/C145/C145N6HelmertFrame.lean b/LeanPool/C145/C145N6HelmertFrame.lean new file mode 100644 index 0000000000..e8e03b9c30 --- /dev/null +++ b/LeanPool/C145/C145N6HelmertFrame.lean @@ -0,0 +1,88 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6ResponseLine + +/-! +# The Helmert eigenframe of the six-vertex source. +-/ + +@[expose] public section +noncomputable section +namespace C145N6Frame +open scoped BigOperators + +/-- The six-column integer Helmert array before column normalization. -/ +def helmert : Fin 6 → Fin 6 → ℝ := + !![1,1,1,1,1,1; 1,-1,1,1,1,1; 1,0,-2,1,1,1; + 1,0,0,-3,1,1; 1,0,0,0,-4,1; 1,0,0,0,0,-5] +/-- The squared lengths of the unnormalized Helmert columns. -/ +def gramWeight : Fin 6 → ℝ := ![6,2,6,12,20,30] +/-- The integer numerators of the signed port's projections on the Helmert columns. -/ +def numerator : Fin 6 → ℝ := ![119,79,119,119,119,119] +/-- The explicit six-vertex port with two nonzero vertex entries. -/ +def port : Fin 6 → ℝ := ![99 / 101,20 / 101,0,0,0,0] +/-- The Helmert array normalized by the square roots of its Gram weights. -/ +def frame (v i : Fin 6) : ℝ := helmert v i / Real.sqrt (gramWeight i) +/-- The modal overlap of the port with one normalized Helmert column. -/ +def overlap (i : Fin 6) : ℝ := numerator i / (101 * Real.sqrt (gramWeight i)) +/-- The contribution of a single modal overlap to a vertex coordinate. -/ +def feature (v i : Fin 6) : ℝ := helmert v i * numerator i / (101 * gramWeight i) + +theorem gramWeight_pos (i : Fin 6) : 0 < gramWeight i := by + fin_cases i <;> norm_num [gramWeight] +theorem sqrtWeight_ne (i : Fin 6) : Real.sqrt (gramWeight i) ≠ 0 := + ne_of_gt (Real.sqrt_pos.2 (gramWeight_pos i)) +theorem sqrtWeight_sq (i : Fin 6) : Real.sqrt (gramWeight i) ^ 2 = gramWeight i := + Real.sq_sqrt (le_of_lt (gramWeight_pos i)) +theorem helmert_gram (i j : Fin 6) : + (∑ v, helmert v i * helmert v j) = if i = j then gramWeight i else 0 := by + fin_cases i <;> fin_cases j <;> norm_num [helmert, gramWeight, Fin.sum_univ_succ] + +theorem frame_orthonormal : C145PhysicalFrame.ColumnOrthonormal frame := by + intro i j + have hh : (∑ v, frame v i * frame v j) = + (∑ v, helmert v i * helmert v j) / (Real.sqrt (gramWeight i) * Real.sqrt (gramWeight j)) := by + simp only [frame, div_mul_div_comm, Finset.sum_div] + rw [hh, helmert_gram] + split_ifs with he + · subst j + rw [← pow_two, sqrtWeight_sq] + exact div_self (ne_of_gt (gramWeight_pos i)) + · simp + +theorem frame_ground (v : Fin 6) : frame v 0 = 1 / Real.sqrt 6 := by + fin_cases v <;> simp [frame, helmert, gramWeight] +theorem raw_port_projection (i : Fin 6) : + (∑ v, helmert v i * port v) = numerator i / 101 := by + fin_cases i <;> norm_num [helmert, port, numerator, Fin.sum_univ_succ] +theorem overlap_actual_projection (i : Fin 6) : + overlap i = ∑ v, frame v i * port v := by + have h : (∑ v, frame v i * port v) = (∑ v, helmert v i * port v) / Real.sqrt (gramWeight i) := by + simp only [frame, div_mul_eq_mul_div, Finset.sum_div] + rw [h, raw_port_projection] + simp only [overlap, div_div] +theorem overlap_nonzero (i : Fin 6) : overlap i ≠ 0 := by + apply div_ne_zero + · fin_cases i <;> norm_num [numerator] + · exact mul_ne_zero (by norm_num) (sqrtWeight_ne i) +theorem port_normalized : (∑ v, port v ^ 2) = 1 := by + norm_num [port, Fin.sum_univ_succ] +theorem overlap_square (i : Fin 6) : overlap i ^ 2 = C145N6Literal.overlapSquare i := by + simp only [overlap, div_pow, mul_pow, sqrtWeight_sq] + fin_cases i <;> norm_num [numerator, gramWeight, C145N6Literal.overlapSquare] +theorem overlap_frame_feature (v i : Fin 6) : overlap i * frame v i = feature v i := by + unfold overlap frame feature + field_simp [sqrtWeight_ne i, ne_of_gt (gramWeight_pos i)] + rw [sqrtWeight_sq] + ring +end C145N6Frame + +end diff --git a/LeanPool/C145/C145N6LineExclusion.lean b/LeanPool/C145/C145N6LineExclusion.lean new file mode 100644 index 0000000000..d4bb574e78 --- /dev/null +++ b/LeanPool/C145/C145N6LineExclusion.lean @@ -0,0 +1,59 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6LiteralRows + +/-! +# Exclusion of additional solutions on the six-vertex tensor line. +-/ + +@[expose] public section +namespace C145N6Literal +noncomputable section + +/-- The two-by-two coefficient matrix for the quadratic and linear line constraints. -/ +def liftedMinor : Matrix (Fin 2) (Fin 2) ℝ := !![q0,l0; q1,l1] + +theorem liftedMinor_actual_det : + liftedMinor.det = + (461469337602175026166685008812416395118620104965845242542112 : ℝ) / 1685159 := by + norm_num [liftedMinor,Matrix.det_fin_two,q0,l0,q1,l1] + +theorem liftedMinor_det_ne_zero : liftedMinor.det ≠ 0 := by + rw [liftedMinor_actual_det] + norm_num + +/-- Two actual associativity rows exclude every nonzero parameter on the saved line. -/ +theorem actual_rows_force_zero (t : ℝ) + (h0 : assocResidual (tensorLine t) 1 2 1 2 = 0) + (h1 : assocResidual (tensorLine t) 1 2 1 3 = 0) : t = 0 := by + rw [first_actual_row] at h0 + rw [second_actual_row] at h1 + have hz : (q0 * l1-q1 * l0) * t = 0 := by + linear_combination q0 * h1-q1 * h0 + have hd : q0 * l1-q1 * l0 ≠ 0 := by + simpa [liftedMinor,Matrix.det_fin_two,mul_comm] using liftedMinor_det_ne_zero + exact (mul_eq_zero.mp hz).resolve_left hd + +/-- A full associative tensor on this literal affine line must be the saved base tensor. +No assertion is made that every physical response fiber lies on this line. -/ +theorem associative_literal_line_unique (t : ℝ) + (h : ∀ i j k l, assocResidual (tensorLine t) i j k l = 0) : + t = 0 ∧ tensorLine t = baseTensor := by + have ht := actual_rows_force_zero t (h 1 2 1 2) (h 1 2 1 3) + refine ⟨ht,?_⟩ + subst t + funext i j k + simp [tensorLine] + +end +end C145N6Literal + +end diff --git a/LeanPool/C145/C145N6LiteralRows.lean b/LeanPool/C145/C145N6LiteralRows.lean new file mode 100644 index 0000000000..eaf39b9e56 --- /dev/null +++ b/LeanPool/C145/C145N6LiteralRows.lean @@ -0,0 +1,170 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import Mathlib.Tactic + +/-! +# Exact tensor entries and polynomial coefficients for the six-vertex source. +-/ + +@[expose] public section +namespace C145N6Literal +open scoped BigOperators +noncomputable section +/-- A real cubic tensor on the six modal indices of the explicit witness. -/ +abbrev Tensor := Fin 6 → Fin 6 → Fin 6 → ℝ + +/-- Literal symmetric lookup from the saved N6 certificate; not a constructed physical frame. -/ +def baseTensor : Tensor := + ![![![(1685159 : ℝ) / 37090836, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (742679 : ℝ) / 12363612, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 37090836, (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 74181672, (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 123636120, (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 185454180]], + ![![(0 : ℝ), (742679 : ℝ) / 12363612, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(742679 : ℝ) / 12363612, (0 : ℝ), (742679 : ℝ) / 12363612, (742679 : ℝ) / 24727224, + (742679 : ℝ) / 41212040, (742679 : ℝ) / 61818060], + ![(0 : ℝ), (742679 : ℝ) / 12363612, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (742679 : ℝ) / 24727224, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (742679 : ℝ) / 41212040, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (742679 : ℝ) / 61818060, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)]], + ![![(0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 37090836, (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (742679 : ℝ) / 12363612, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(1685159 : ℝ) / 37090836, (0 : ℝ), (-1685159 : ℝ) / 37090836, (1685159 : ℝ) / 74181672, + (1685159 : ℝ) / 123636120, (1685159 : ℝ) / 185454180], + ![(0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 74181672, (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 123636120, (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 185454180, (0 : ℝ), (0 : ℝ), (0 : ℝ)]], + ![![(0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 74181672, (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (742679 : ℝ) / 24727224, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 74181672, (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(1685159 : ℝ) / 74181672, (0 : ℝ), (0 : ℝ), (-1685159 : ℝ) / 74181672, (1685159 : ℝ) / + 247272240, (1685159 : ℝ) / 370908360], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 247272240, (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 370908360, (0 : ℝ), (0 : ℝ)]], + ![![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 123636120, (0 : ℝ)], + ![(0 : ℝ), (742679 : ℝ) / 41212040, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 123636120, (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 247272240, (0 : ℝ), (0 : ℝ)], + ![(1685159 : ℝ) / 123636120, (0 : ℝ), (0 : ℝ), (0 : ℝ), (-5055477 : ℝ) / 412120400, (1685159 + : ℝ) / 618180600], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 618180600, (0 : ℝ)]], + ![![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 185454180], + ![(0 : ℝ), (742679 : ℝ) / 61818060, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 185454180, (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 370908360, (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (1685159 : ℝ) / 618180600, (0 : ℝ)], + ![(1685159 : ℝ) / 185454180, (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (-1685159 : ℝ) / 231817725]]] + +/-- Literal symmetric lookup from the saved N6 certificate; not a constructed physical frame. -/ +def directionTensor : Tensor := + ![![![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)]], + ![![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (-131195799009504000 : ℝ), (224416828079216073 : ℝ), (157226402562638904 : ℝ), + (-457258594958495199 : ℝ), (206578275412165632 : ℝ)], + ![(0 : ℝ), (224416828079216073 : ℝ), (-256093853474518400 : ℝ), (-673543715039251686 : ℝ), + (1206639763951171968 : ℝ), (-500950835029969075 : ℝ)], + ![(0 : ℝ), (157226402562638904 : ℝ), (-673543715039251686 : ℝ), (1074255690533299200 : ℝ), + (-756179004188024550 : ℝ), (198233388155263032 : ℝ)], + ![(0 : ℝ), (-457258594958495199 : ℝ), (1206639763951171968 : ℝ), (-756179004188024550 : ℝ), + (-269200838429827200 : ℝ), (275540135773292901 : ℝ)], + ![(0 : ℝ), (206578275412165632 : ℝ), (-500950835029969075 : ℝ), (198233388155263032 : ℝ), + (275540135773292901 : ℝ), (-179170489055465600 : ℝ)]], + ![![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (224416828079216073 : ℝ), (-256093853474518400 : ℝ), (-673543715039251686 : ℝ), + (1206639763951171968 : ℝ), (-500950835029969075 : ℝ)], + ![(0 : ℝ), (-256093853474518400 : ℝ), (-224177920739540208 : ℝ), (2393180972536210560 : ℝ), + (-3069902940264534928 : ℝ), (1156150064172658176 : ℝ)], + ![(0 : ℝ), (-673543715039251686 : ℝ), (2393180972536210560 : ℝ), (-3056286288025816524 : ℝ), + (1631839289399953920 : ℝ), (-295468356481815150 : ℝ)], + ![(0 : ℝ), (1206639763951171968 : ℝ), (-3069902940264534928 : ℝ), (1631839289399953920 : ℝ), + (1095799815451630800 : ℝ), (-863161453954205120 : ℝ)], + ![(0 : ℝ), (-500950835029969075 : ℝ), (1156150064172658176 : ℝ), (-295468356481815150 : ℝ), + (-863161453954205120 : ℝ), (502869693603109329 : ℝ)]], + ![![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (157226402562638904 : ℝ), (-673543715039251686 : ℝ), (1074255690533299200 : ℝ), + (-756179004188024550 : ℝ), (198233388155263032 : ℝ)], + ![(0 : ℝ), (-673543715039251686 : ℝ), (2393180972536210560 : ℝ), (-3056286288025816524 : ℝ), + (1631839289399953920 : ℝ), (-295468356481815150 : ℝ)], + ![(0 : ℝ), (1074255690533299200 : ℝ), (-3056286288025816524 : ℝ), (2476186674354160416 : ℝ), + (-97161462687094092 : ℝ), (-396116893485941760 : ℝ)], + ![(0 : ℝ), (-756179004188024550 : ℝ), (1631839289399953920 : ℝ), (-97161462687094092 : ℝ), + (-1659562174672858368 : ℝ), (880171155507265650 : ℝ)], + ![(0 : ℝ), (198233388155263032 : ℝ), (-295468356481815150 : ℝ), (-396116893485941760 : ℝ), + (880171155507265650 : ℝ), (-386519482155827592 : ℝ)]], + ![![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (-457258594958495199 : ℝ), (1206639763951171968 : ℝ), (-756179004188024550 : ℝ), + (-269200838429827200 : ℝ), (275540135773292901 : ℝ)], + ![(0 : ℝ), (1206639763951171968 : ℝ), (-3069902940264534928 : ℝ), (1631839289399953920 : ℝ), + (1095799815451630800 : ℝ), (-863161453954205120 : ℝ)], + ![(0 : ℝ), (-756179004188024550 : ℝ), (1631839289399953920 : ℝ), (-97161462687094092 : ℝ), + (-1659562174672858368 : ℝ), (880171155507265650 : ℝ)], + ![(0 : ℝ), (-269200838429827200 : ℝ), (1095799815451630800 : ℝ), (-1659562174672858368 : ℝ), + (1108404605266198704 : ℝ), (-275466286678150656 : ℝ)], + ![(0 : ℝ), (275540135773292901 : ℝ), (-863161453954205120 : ℝ), (880171155507265650 : ℝ), + (-275466286678150656 : ℝ), (-16922411676573175 : ℝ)]], + ![![(0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ), (0 : ℝ)], + ![(0 : ℝ), (206578275412165632 : ℝ), (-500950835029969075 : ℝ), (198233388155263032 : ℝ), + (275540135773292901 : ℝ), (-179170489055465600 : ℝ)], + ![(0 : ℝ), (-500950835029969075 : ℝ), (1156150064172658176 : ℝ), (-295468356481815150 : ℝ), + (-863161453954205120 : ℝ), (502869693603109329 : ℝ)], + ![(0 : ℝ), (198233388155263032 : ℝ), (-295468356481815150 : ℝ), (-396116893485941760 : ℝ), + (880171155507265650 : ℝ), (-386519482155827592 : ℝ)], + ![(0 : ℝ), (275540135773292901 : ℝ), (-863161453954205120 : ℝ), (880171155507265650 : ℝ), + (-275466286678150656 : ℝ), (-16922411676573175 : ℝ)], + ![(0 : ℝ), (-179170489055465600 : ℝ), (502869693603109329 : ℝ), (-386519482155827592 : ℝ), + (-16922411676573175 : ℝ), (79612151209118208 : ℝ)]]] + +/-- The exact rational squares of the six modal overlaps. -/ +def overlapSquare (i : Fin 6) : ℝ := + ![(14161 : ℝ) / 61206,(6241 : ℝ) / 20402,(14161 : ℝ) / 61206,(14161 : ℝ) / 122412,(14161 : ℝ) / + 204020,(14161 : ℝ) / 306030] i + +/-- The affine tensor family through the literal base in the literal direction. -/ +def tensorLine (t : ℝ) : Tensor := fun i j k => baseTensor i j k + t * directionTensor i j k +/-- Full weighted associativity residual, INCLUDING the ground summand r=0. -/ +def assocResidual (X : Tensor) (i j k l : Fin 6) : ℝ := + ∑ r : Fin 6, (X i k r * X j l r-X i l r * X j k r) / overlapSquare r + +/-- The coefficient of the squared line parameter in the first associativity constraint. -/ +def q0 : ℝ := (-31708838956059081706040731104129454182624 : ℝ) / 14161 + +/-- The coefficient of the line parameter in the first associativity constraint. -/ +def l0 : ℝ := (-1013041997662421555867 : ℝ) / 12019 + +/-- The coefficient of the squared line parameter in the second associativity constraint. -/ +def q1 : ℝ := (100153572046061606829291436418360265632064 : ℝ) / 14161 + +/-- The coefficient of the line parameter in the second associativity constraint. -/ +def l1 : ℝ := (1729844844737481701199 : ℝ) / 12019 + +theorem overlapSquare_positive (i : Fin 6) : 0 < overlapSquare i := by + fin_cases i <;> norm_num [overlapSquare] + +theorem first_actual_row (t : ℝ) : + assocResidual (tensorLine t) 1 2 1 2 = q0 * t ^ 2 + l0 * t := by + norm_num [assocResidual, Fin.sum_univ_succ, tensorLine, baseTensor, directionTensor, + overlapSquare, q0, l0]; ring + +theorem second_actual_row (t : ℝ) : + assocResidual (tensorLine t) 1 2 1 3 = q1 * t ^ 2 + l1 * t := by + norm_num [assocResidual, Fin.sum_univ_succ, tensorLine, baseTensor, directionTensor, + overlapSquare, q1, l1]; ring + +end +end C145N6Literal + +end diff --git a/LeanPool/C145/C145N6OrdinaryJets.lean b/LeanPool/C145/C145N6OrdinaryJets.lean new file mode 100644 index 0000000000..1a5277ef26 --- /dev/null +++ b/LeanPool/C145/C145N6OrdinaryJets.lean @@ -0,0 +1,85 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6TimeKernels +public import LeanPool.C145.C145ObservedKernelRecovery +public import LeanPool.C145.C145TimeKernelContinuation + +/-! +# Ordinary terminal response derivatives for the six-vertex identification. +-/ + +@[expose] public section +noncomputable section +namespace C145N6Frame +open C145.ActualResponse C145.ObservedKernelRecovery +open scoped BigOperators Topology ContDiff +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +theorem literal_source_actual_C2_response {T : ℝ} (hT : 0 < T) : + ∃ R : Input T → C145.ActualResponse.Path 5 T, + IsActualResponse hT frame literalRates port R ∧ ContDiffAt ℝ 2 R 0 := + exists_actual_C2_response hT frame literalRates port frame_orthonormal + +theorem literal_N6_ordinary_C2_jets_identification {n : ℕ} {T : ℝ} + (hT : 0 < T) + (c1 : ℝ) (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates1 : Function.Injective rates1) + (hRateGround1 : rates1 0 = 1) + (hAbove1 : ∀ j : Fin n, 1 < rates1 j.succ) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (R0 : Input T → C145.ActualResponse.Path 5 T) (R1 : Input T → C145.ActualResponse.Path n T) + (hR0 : IsActualResponse hT frame literalRates port R0) + (hR1 : IsActualResponse hT Q1 rates1 b1 R1) + (hcR0 : ContDiffAt ℝ 2 R0 0) (hcR1 : ContDiffAt ℝ 2 R1 0) + (hFirst : ∀ (g : ℝ → ℝ) (hg : SmoothTemporalTest T g), + rawFirst port R0 (restrictInput T g hg.1.continuous) (endTime T hT) = + rawFirst b1 R1 (restrictInput T g hg.1.continuous) (endTime T hT)) + (hMixed : ∀ (g h : ℝ → ℝ) (hg : SmoothTemporalTest T g) (hh : SmoothTemporalTest T h), + rawMixed port R0 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT) = + rawMixed b1 R1 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT)) : + ∃ e : Fin (5 + 1) ≃ Fin (n + 1), + 5 = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = literalRates i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap frame port i) ∧ + (1 / Real.sqrt 6) = c1 ∧ (∑ v, port v) = (∑ w, b1 w) ∧ + ∃ π : Fin (5 + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (5 + 1)), + (∑ i : Fin (5 + 1), Q1 w (e i) * frame v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (5 + 1)), Q1 (π v) (e i) = frame v i) ∧ + (∀ (v u : Fin (5 + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator literalRates frame v u) ∧ + (∀ v : Fin (5 + 1), b1 (π v) = port v) ∧ + (∀ (v u : Fin (5 + 1)), + C145CoordinatePermutation.decayLaplacian 1 rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian 1 literalRates frame v u) := by + have hObserved := ordinary_C2_jets_recover_observed_time_kernels hT + frame literalRates port Q1 rates1 b1 frame_orthonormal hQ1 R0 R1 hR0 hR1 hcR0 hcR1 hFirst hMixed + have hAll := C145.TimeKernelContinuation.observed_time_kernels_determine_all_nonnegative_delays + hT frame literalRates port Q1 rates1 b1 hObserved.1 hObserved.2 + exact literal_N6_time_kernels_identification c1 Q1 rates1 b1 hQ1 hGround1 hRates1 + hRateGround1 hAbove1 ha1 hAll.1 hAll.2 + +end C145N6Frame + +end diff --git a/LeanPool/C145/C145N6OriginalGraph.lean b/LeanPool/C145/C145N6OriginalGraph.lean new file mode 100644 index 0000000000..116151daed --- /dev/null +++ b/LeanPool/C145/C145N6OriginalGraph.lean @@ -0,0 +1,92 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6GraphResponse + +/-! +# Identification of the explicit six-vertex graph in vertex coordinates. +-/ + +@[expose] public section +noncomputable section +namespace C145N6Frame +open C145.ActualResponse C145.ObservedKernelRecovery +open scoped BigOperators Topology ContDiff +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +theorem zero_diagonal_weights_of_laplacian_transport {n : ℕ} + (W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) (π : Fin 6 ≃ Fin (n + 1)) + (hdiag : ∀ v, W v v = 0) + (hL : ∀ v u, C145.WeightedGraph.laplacian W (π v) (π u) = + C145.WeightedGraph.laplacian edgeWeight v u) : + ∀ v u, W (π v) (π u) = edgeWeight v u := by + intro v u + by_cases h : v = u + · subst u; rw [hdiag, edgeWeight_diagonal] + · have he := hL v u + have hp : π v ≠ π u := fun h' => h (π.injective h') + simp only [C145.WeightedGraph.laplacian, Matrix.sub_apply, Matrix.diagonal_apply, + ite_eq_right h, ite_eq_right hp, zero_sub] at he + exact neg_injective he + +/-- Original graph identification for the literal N6 source. Spectral frames, +simple rates, positive-oriented overlaps and C2 regularity are derived, not supplied. +Diagonal self-loop weights require the separately explicit zero-diagonal condition. -/ +theorem literal_N6_original_graph_identification {n : ℕ} {T : ℝ} + (hT : 0 < T) + (W1 : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hs1 : W1.IsSymm) (hn1 : ∀ v u, 0 ≤ W1 v u) + (hconnected1 : (C145.WeightedGraph.supportGraph W1 hs1).Connected) + (b1 : State n) + (hcyclic1 : C145.CyclicSpectral.KrylovCyclic (C145.GraphSpectralRealization.generator 1 W1) b1) + (R0 : Input T → C145.ActualResponse.Path 5 T) + (R1 : Input T → C145.ActualResponse.Path n T) + (hR0 : C145.GraphSpectralRealization.IsGraphResponse hT 1 edgeWeight port R0) + (hR1 : C145.GraphSpectralRealization.IsGraphResponse hT 1 W1 b1 R1) + (hc0 : ContinuousAt R0 0) (hc1 : ContinuousAt R1 0) + (hFirst : ∀ (g : ℝ → ℝ) (hg : SmoothTemporalTest T g), + rawFirst port R0 (restrictInput T g hg.1.continuous) (endTime T hT) = + rawFirst b1 R1 (restrictInput T g hg.1.continuous) (endTime T hT)) + (hMixed : ∀ (g h : ℝ → ℝ) (hg : SmoothTemporalTest T g) (hh : SmoothTemporalTest T h), + rawMixed port R0 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT) = + rawMixed b1 R1 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT)) : + 5 = n ∧ ∃ π : Fin 6 ≃ Fin (n + 1), + (∀ v u, C145.GraphSpectralRealization.generator 1 W1 (π v) (π u) = + C145.GraphSpectralRealization.generator 1 edgeWeight v u) ∧ + (∀ v, b1 (π v) = port v) ∧ + (∀ v u, C145.WeightedGraph.laplacian W1 (π v) (π u) = + C145.WeightedGraph.laplacian edgeWeight v u) ∧ + ((∀ v, W1 v v = 0) → ∀ v u, W1 (π v) (π u) = edgeWeight v u) := by + obtain ⟨S1⟩ := + C145.GraphSpectralRealization.connected_cyclic_graph_has_oriented_spectral_realization + 1 (by norm_num) W1 hs1 hn1 hconnected1 b1 hcyclic1 + have hActual0 := (literal_graph_response_iff hT R0).mp hR0 + have hActual1 := S1.actualResponse hT R1 hR1 + have hC0 := actual_response_C2_of_continuous hT frame literalRates port frame_orthonormal R0 + hActual0 hc0 + have hC1 := actual_response_C2_of_continuous hT S1.Q S1.rates b1 S1.orthonormal R1 hActual1 hc1 + obtain ⟨e,hn,_,_,_,_,_,π,_,_,hG,hP,hL⟩ := literal_N6_ordinary_C2_jets_identification hT + S1.c S1.Q S1.rates b1 S1.orthonormal S1.ground S1.simple S1.ground_rate S1.higher + S1.positive_overlap R0 R1 hActual0 hActual1 hC0 hC1 hFirst hMixed + have hLap : ∀ v u, C145.WeightedGraph.laplacian W1 (π v) (π u) = + C145.WeightedGraph.laplacian edgeWeight v u := by + simpa only [S1.original_laplacian, actual_decay_laplacian] using hL + refine ⟨hn,π,?_,hP,hLap,fun hd => zero_diagonal_weights_of_laplacian_transport W1 π hd hLap⟩ + simpa only [S1.original_generator, actual_spectral_generator, literal_graph_generator] using hG +end C145N6Frame + +end diff --git a/LeanPool/C145/C145N6PhysicalWitness.lean b/LeanPool/C145/C145N6PhysicalWitness.lean new file mode 100644 index 0000000000..e7cb54bf4d --- /dev/null +++ b/LeanPool/C145/C145N6PhysicalWitness.lean @@ -0,0 +1,91 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6HelmertFrame + +/-! +# Realization of the six-vertex tensor data by physical frames. +-/ + +@[expose] public section +noncomputable section +namespace C145N6Frame +open scoped BigOperators + +theorem physical_tensor_feature_sum (i j k : Fin 6) : + C145PhysicalFrame.T frame overlap i j k = ∑ v, feature v i * feature v j * feature v k := by + simp only [C145PhysicalFrame.T, C145PhysicalFrame.C, Finset.mul_sum] + apply Finset.sum_congr rfl + intro v _ + rw [← overlap_frame_feature, ← overlap_frame_feature, ← overlap_frame_feature] + ring + +theorem actual_tensor_slice_0 (j k : Fin 6) : + C145PhysicalFrame.T frame overlap 0 j k = C145N6Literal.baseTensor 0 j k := by + rw [physical_tensor_feature_sum] + fin_cases j <;> fin_cases k <;> + norm_num [feature, helmert, numerator, gramWeight, C145N6Literal.baseTensor, Fin.sum_univ_succ] + +theorem actual_tensor_slice_1 (j k : Fin 6) : + C145PhysicalFrame.T frame overlap 1 j k = C145N6Literal.baseTensor 1 j k := by + rw [physical_tensor_feature_sum] + fin_cases j <;> fin_cases k <;> + norm_num [feature, helmert, numerator, gramWeight, C145N6Literal.baseTensor, Fin.sum_univ_succ] + +theorem actual_tensor_slice_2 (j k : Fin 6) : + C145PhysicalFrame.T frame overlap 2 j k = C145N6Literal.baseTensor 2 j k := by + rw [physical_tensor_feature_sum] + fin_cases j <;> fin_cases k <;> + norm_num [feature, helmert, numerator, gramWeight, C145N6Literal.baseTensor, Fin.sum_univ_succ] + +theorem actual_tensor_slice_3 (j k : Fin 6) : + C145PhysicalFrame.T frame overlap 3 j k = C145N6Literal.baseTensor 3 j k := by + rw [physical_tensor_feature_sum] + fin_cases j <;> fin_cases k <;> + norm_num [feature, helmert, numerator, gramWeight, C145N6Literal.baseTensor, Fin.sum_univ_succ] + +theorem actual_tensor_slice_4 (j k : Fin 6) : + C145PhysicalFrame.T frame overlap 4 j k = C145N6Literal.baseTensor 4 j k := by + rw [physical_tensor_feature_sum] + fin_cases j <;> fin_cases k <;> + norm_num [feature, helmert, numerator, gramWeight, C145N6Literal.baseTensor, Fin.sum_univ_succ] + +theorem actual_tensor_slice_5 (j k : Fin 6) : + C145PhysicalFrame.T frame overlap 5 j k = C145N6Literal.baseTensor 5 j k := by + rw [physical_tensor_feature_sum] + fin_cases j <;> fin_cases k <;> + norm_num [feature, helmert, numerator, gramWeight, C145N6Literal.baseTensor, Fin.sum_univ_succ] + +theorem actual_tensor_saved_base : C145PhysicalFrame.T frame overlap = C145N6Literal.baseTensor := + by + funext i j k + fin_cases i + · exact actual_tensor_slice_0 j k + · exact actual_tensor_slice_1 j k + · exact actual_tensor_slice_2 j k + · exact actual_tensor_slice_3 j k + · exact actual_tensor_slice_4 j k + · exact actual_tensor_slice_5 j k + +/-- The saved literal witness has an actual calibrated orthonormal-frame realization. +This is not a graph or differential-equation realization theorem. -/ +theorem saved_frame_response_unique (μ : ℝ) (Q : Fin 6 → Fin 6 → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (hground : ∀ v, Q v 0 = 1 / Real.sqrt 6) + (hresponse : C145.H2.SamePositive (C145.H2.fullRates μ C145N6.rates) + (C145PhysicalFrame.T frame overlap) (C145PhysicalFrame.T Q overlap)) : + C145PhysicalFrame.T Q overlap = C145N6Literal.baseTensor := by + exact C145N6.physical_saved_base_unique μ frame Q overlap (1 / Real.sqrt 6) + frame_orthonormal hQ overlap_nonzero frame_ground hground overlap_square + actual_tensor_saved_base hresponse + +end C145N6Frame + +end diff --git a/LeanPool/C145/C145N6PositiveGraph.lean b/LeanPool/C145/C145N6PositiveGraph.lean new file mode 100644 index 0000000000..d623e427ec --- /dev/null +++ b/LeanPool/C145/C145N6PositiveGraph.lean @@ -0,0 +1,135 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6CalibratedTransport +public import LeanPool.C145.C145WeightedGraph + +/-! +# Positive weights and connectedness of the explicit six-vertex graph. +-/ + +@[expose] public section +noncomputable section +namespace C145N6Frame +open scoped BigOperators +open C145CoordinatePermutation + +/-- The six exact decay rates for the explicit graph, including the ground rate one. -/ +def literalRates : Fin 6 → ℝ := ![1,20,21,22,23,24] +/-- The generator reconstructed from the Helmert array and the six exact rates. -/ +def generator : Matrix (Fin 6) (Fin 6) ℝ := + fun v u => -(∑ i, literalRates i * helmert v i * helmert u i / gramWeight i) +/-- The off-diagonal part of the generator, giving the graph's edge weights. -/ +def edgeWeight : Matrix (Fin 6) (Fin 6) ℝ := generator - Matrix.diagonal (fun v => generator v v) + +theorem literalRates_full : literalRates = C145.H2.fullRates 1 C145N6.rates := by + funext i; fin_cases i <;> rfl +theorem frame_pair_product (v u i : Fin 6) : + frame v i * frame u i = helmert v i * helmert u i / gramWeight i := by + unfold frame + field_simp [sqrtWeight_ne i, ne_of_gt (gramWeight_pos i)] + rw [sqrtWeight_sq] + ring + +theorem actual_spectral_generator : spectralGenerator literalRates frame = generator := by + funext v u + apply congrArg Neg.neg + apply Finset.sum_congr rfl + intro i _ + rw [mul_assoc, frame_pair_product] + ring + +theorem generator_symmetric : generator.IsSymm := by + apply Matrix.IsSymm.ext + intro v u + dsimp [generator] + congr 1 + apply Finset.sum_congr rfl + intro i _ + ring + +theorem generator_row_sum (v : Fin 6) : (∑ u, generator v u) = -1 := by + fin_cases v <;> norm_num [generator, literalRates, helmert, gramWeight, Fin.sum_univ_succ] +theorem generator_offdiagonal_lower (v u : Fin 6) (h : v ≠ u) : 51 / 20 ≤ generator v u := by + fin_cases v <;> fin_cases u <;> norm_num [generator, literalRates, helmert, gramWeight, + Fin.sum_univ_succ] at * +theorem generator_minimum_attained : generator 0 1 = 51 / 20 := by + norm_num [generator, literalRates, helmert, gramWeight, Fin.sum_univ_succ] + +theorem edgeWeight_symmetric : edgeWeight.IsSymm := + generator_symmetric.sub (Matrix.isSymm_diagonal _) +theorem edgeWeight_diagonal (v : Fin 6) : edgeWeight v v = 0 := by + simp [edgeWeight] +theorem edgeWeight_offdiagonal (v u : Fin 6) (h : v ≠ u) : edgeWeight v u = generator v u := by + simp [edgeWeight, h] +theorem edgeWeight_nonnegative (v u : Fin 6) : 0 ≤ edgeWeight v u := by + by_cases h : v = u + · subst u; rw [edgeWeight_diagonal] + · rw [edgeWeight_offdiagonal v u h] + have hh := generator_offdiagonal_lower v u h + linarith + +theorem edgeWeight_row_sum (v : Fin 6) : (∑ u, edgeWeight v u) = -1-generator v v := by + simp only [edgeWeight, Matrix.sub_apply, Finset.sum_sub_distrib, generator_row_sum] + congr 1 + simp [Matrix.diagonal_apply] + +theorem actual_generator_laplacian : generator = -1 - C145.WeightedGraph.laplacian edgeWeight := by + ext v u + simp only [C145.WeightedGraph.laplacian, Matrix.sub_apply, + Matrix.neg_apply, Matrix.one_apply, Matrix.diagonal_apply, edgeWeight] + by_cases h : v = u + · subst u; simp [generator_row_sum] + · simp [h] + +theorem actual_decay_laplacian : decayLaplacian 1 literalRates frame = + C145.WeightedGraph.laplacian edgeWeight := by + funext v u + rw [decayLaplacian, actual_spectral_generator] + have h := congrFun (congrFun actual_generator_laplacian v) u + simp only [Matrix.sub_apply, Matrix.neg_apply, Matrix.one_apply] at h + linarith +theorem edgeWeight_positive (v u : Fin 6) (h : v ≠ u) : 0 < edgeWeight v u := by + rw [edgeWeight_offdiagonal v u h] + have hh := generator_offdiagonal_lower v u h + linarith + +theorem literal_graph_connected : (C145.WeightedGraph.supportGraph edgeWeight + edgeWeight_symmetric).Connected := by + rw [SimpleGraph.connected_iff_exists_forall_reachable] + refine ⟨0, fun v => ?_⟩ + by_cases h : (0 : Fin 6) = v + · subst v; exact SimpleGraph.Reachable.refl _ + · exact (show (C145.WeightedGraph.supportGraph edgeWeight edgeWeight_symmetric).Adj 0 v from + ⟨h,edgeWeight_positive 0 v h⟩).reachable + +/-- Calibrated rational H2 data transports the literal positive graph generator, +its reconstructed vertex port and its Laplacian by the same permutation. +No time-domain or unknown-calibration statement is made. -/ +theorem calibrated_literal_graph_transport (Q : Fin 6 → Fin 6 → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (hground : ∀ v, Q v 0 = 1 / Real.sqrt 6) + (hresponse : C145.H2.SamePositive literalRates + (C145PhysicalFrame.T frame overlap) (C145PhysicalFrame.T Q overlap)) : + ∃ π : Equiv.Perm (Fin 6), + (∀ v i, Q (π v) i = frame v i) ∧ + (∀ v u, spectralGenerator literalRates Q (π v) (π u) = generator v u) ∧ + (∀ v, spectralPort overlap Q (π v) = port v) ∧ + (∀ v u, decayLaplacian 1 literalRates Q (π v) (π u) = + C145.WeightedGraph.laplacian edgeWeight v u) := by + rw [literalRates_full] at hresponse + obtain ⟨π,_,hframe,hgen,hport,hlap⟩ := calibrated_response_spectral_transport 1 Q hQ hground + hresponse + refine ⟨π,hframe,?_,hport,?_⟩ + · simpa only [← literalRates_full, actual_spectral_generator] using hgen + · simpa only [← literalRates_full, actual_decay_laplacian] using hlap +end C145N6Frame + +end diff --git a/LeanPool/C145/C145N6ResponseLine.lean b/LeanPool/C145/C145N6ResponseLine.lean new file mode 100644 index 0000000000..9316e8e8af --- /dev/null +++ b/LeanPool/C145/C145N6ResponseLine.lean @@ -0,0 +1,111 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6TraceLine +public import LeanPool.C145.C145N6LineExclusion + +/-! +# Reduction of compatible six-vertex tensors to an affine line. +-/ + +@[expose] public section +noncomputable section +namespace C145N6 +open C145.H2 C145.ThreePlane +open scoped BigOperators + +theorem saved_residue_entries (t : ℝ) (i j k : Fin 5) : + Res rates (fourForm (fun h => t * savedQ h)) i j k = + t * C145N6Literal.directionTensor i.succ j.succ k.succ := by + rw [res_entry, eval_fourForm, xi_negative_node_factors] + simp only [rates_di] + fin_cases i <;> fin_cases j <;> fin_cases k <;> + norm_num [rates, savedQ, C145N6Literal.directionTensor] <;> ring + +theorem ground_saved_residue (t : ℝ) : + groundZero (Res rates (fourForm (fun h => t * savedQ h))) = + fun i j k => t * C145N6Literal.directionTensor i j k := by + funext i j k + refine Fin.cases ?_ (fun i => ?_) i + · rw [groundZero_ground_first] + fin_cases j <;> fin_cases k <;> norm_num [C145N6Literal.directionTensor] + · refine Fin.cases ?_ (fun j => ?_) j + · rw [groundZero_ground_second] + fin_cases i <;> fin_cases k <;> norm_num [C145N6Literal.directionTensor] + · refine Fin.cases ?_ (fun k => ?_) k + · rw [groundZero_ground_output] + fin_cases i <;> fin_cases j <;> norm_num [C145N6Literal.directionTensor] + · exact saved_residue_entries t i j k + +theorem admissible_trace_residue_line (R : Poly) (hs : SymPoly R) + (ha : QAdmissible 5 R) (a : Fin 6 → ℝ) + (hw : ∀ i, a i ^ 2 = C145N6Literal.overlapSquare i) + (ht : ResidualTraceFree a (Res rates R)) : + ∃ t : ℝ, groundZero (Res rates R) = fun i j k => t * C145N6Literal.directionTensor i j k := by + obtain ⟨c,rfl⟩ := admissible_five_four R hs ha + have hc : ∀ i, literalTrace c i = 0 := by + intro i + simpa only [literalTrace, ResidualTraceFree, residualCountingTrace, hw] using ht i + have he := trace_kernel_saved_line c hc + refine ⟨c 3 / savedQ 3, ?_⟩ + conv_lhs => rw [he] + exact ground_saved_residue _ + +theorem rates_injective : Function.Injective rates := by + intro i j h; fin_cases i <;> fin_cases j <;> norm_num [rates] at * +theorem rates_positive : ∀ i, 0 < rates i := by + intro i; fin_cases i <;> norm_num [rates] + +/-- Actual response-to-line consequence for two physical frames with the saved weights. +No existence or construction of a frame realizing the saved base tensor is asserted. -/ +theorem physical_response_saved_line + (μ : ℝ) (Q0 Q1 : Fin 6 → Fin 6 → ℝ) (a : Fin 6 → ℝ) (c : ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (ha : ∀ i, a i ≠ 0) + (hG0 : ∀ v, Q0 v 0 = c) (hG1 : ∀ v, Q1 v 0 = c) + (hw : ∀ i, a i ^ 2 = C145N6Literal.overlapSquare i) + (hH : SamePositive (fullRates μ rates) (C145PhysicalFrame.T Q0 a) (C145PhysicalFrame.T Q1 a)) : + ∃ t : ℝ, C145PhysicalFrame.T Q1 a - C145PhysicalFrame.T Q0 a = + fun i j k => t * C145N6Literal.directionTensor i j k := by + obtain ⟨R,hR,_⟩ := (physical_pair_H2_counting_trace_residue μ rates rates_injective + rates_positive Q0 Q1 a c hQ0 hQ1 ha hG0 hG1).mp hH + obtain ⟨t,ht⟩ := admissible_trace_residue_line R hR.1 hR.2.1 a hw hR.2.2.2.1 + exact ⟨t,hR.2.2.1.trans ht⟩ + +/-- Conditional physical uniqueness at the saved tensor, with realization kept explicit. -/ +theorem physical_saved_base_unique + (μ : ℝ) (Q0 Q1 : Fin 6 → Fin 6 → ℝ) (a : Fin 6 → ℝ) (c : ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (ha : ∀ i, a i ≠ 0) + (hG0 : ∀ v, Q0 v 0 = c) (hG1 : ∀ v, Q1 v 0 = c) + (hw : ∀ i, a i ^ 2 = C145N6Literal.overlapSquare i) + (hbase : C145PhysicalFrame.T Q0 a = C145N6Literal.baseTensor) + (hH : SamePositive (fullRates μ rates) (C145PhysicalFrame.T Q0 a) (C145PhysicalFrame.T Q1 a)) : + C145PhysicalFrame.T Q1 a = C145N6Literal.baseTensor := by + obtain ⟨t,ht⟩ := physical_response_saved_line μ Q0 Q1 a c hQ0 hQ1 ha hG0 hG1 hw hH + have hline : C145PhysicalFrame.T Q1 a = C145N6Literal.tensorLine t := by + funext i j k + have he := congrFun (congrFun (congrFun ht i) j) k + rw [hbase] at he + change C145PhysicalFrame.T Q1 a i j k - C145N6Literal.baseTensor i j k = + t * C145N6Literal.directionTensor i j k at he + dsimp [C145N6Literal.tensorLine] + linarith + have hassoc : ∀ i j k l, C145N6Literal.assocResidual (C145N6Literal.tensorLine t) i j k l = 0 := + by + intro i j k l + have hh := C145PhysicalFrame.modal_associativity Q1 a hQ1 ha i j k l + simpa only [C145PhysicalFrame.Assoc, hw, hline, C145N6Literal.assocResidual] using hh + exact hline.trans (C145N6Literal.associative_literal_line_unique t hassoc).2 +end C145N6 + +end diff --git a/LeanPool/C145/C145N6Squarefree.lean b/LeanPool/C145/C145N6Squarefree.lean new file mode 100644 index 0000000000..a215fb3647 --- /dev/null +++ b/LeanPool/C145/C145N6Squarefree.lean @@ -0,0 +1,99 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import Mathlib.Algebra.MvPolynomial.Degrees +public import Mathlib.Algebra.MvPolynomial.Rename +public import Mathlib.Tactic + +/-! +# Squarefree polynomial certificates for the six-vertex tensor constraints. +-/ + +@[expose] public section +noncomputable section +open MvPolynomial +namespace C145N6 +/-- Real polynomials in the three variables of the squarefree calculation. -/ +abbrev Poly := MvPolynomial (Fin 3) ℝ +/-- The finitely supported exponent vector for a monomial in three variables. -/ +def exponent (a b c : ℕ) : Fin 3 →₀ ℕ := Finsupp.equivFunOnFinite.symm ![a,b,c] +@[simp] theorem exponent_apply (a b c : ℕ) (i : Fin 3) : + exponent a b c i = ![a,b,c] i := rfl +theorem exponent_ext (d : Fin 3 →₀ ℕ) : d = exponent (d 0) (d 1) (d 2) := by + ext i; fin_cases i <;> rfl +theorem squarefree_expansion (R : Poly) (hd : ∀ i, degreeOf i R ≤ 1) : + R = ∑ a : Fin 2, ∑ b : Fin 2, ∑ c : Fin 2, + monomial (exponent a.val b.val c.val) (R.coeff (exponent a.val b.val c.val)) := by + ext d + by_cases h : ∀ i, d i ≤ 1 + · have h0 := h 0; have h1 := h 1; have h2 := h 2 + rw [exponent_ext d] + interval_cases hd0 : d 0 <;> interval_cases hd1 : d 1 <;> interval_cases hd2 : d 2 <;> + simp [Fin.sum_univ_two, coeff_monomial, exponent] + · have hz : R.coeff d = 0 := by + by_contra hc + have hm : d ∈ R.support := mem_support_iff.mpr hc + exact h (fun i => degreeOf_le_iff.mp (hd i) d hm) + rw [hz] + simp only [coeff_sum] + symm + apply Finset.sum_eq_zero + intro a _ + apply Finset.sum_eq_zero + intro b _ + apply Finset.sum_eq_zero + intro c _ + rw [coeff_monomial] + split_ifs with he + · exfalso + apply h + intro i + rw [← he] + fin_cases i + · change a.val ≤ 1; omega + · change b.val ≤ 1; omega + · change c.val ≤ 1; omega + · rfl +theorem symmetric_coeff (R : Poly) (hs : ∀ e : Equiv.Perm (Fin 3), rename e R = R) + (e : Equiv.Perm (Fin 3)) (d : Fin 3 →₀ ℕ) : + R.coeff (d.mapDomain e) = R.coeff d := by + simpa only [hs e] using coeff_rename_mapDomain e e.injective R d + +theorem swap01_exponent (a b c : ℕ) : + (exponent a b c).mapDomain (Equiv.swap (0:Fin 3) 1) = exponent b a c := by + ext i; fin_cases i <;> norm_num [Finsupp.mapDomain_equiv_apply, exponent, Equiv.swap_apply_def] +theorem swap12_exponent (a b c : ℕ) : + (exponent a b c).mapDomain (Equiv.swap (1:Fin 3) 2) = exponent a c b := by + ext i; fin_cases i <;> norm_num [Finsupp.mapDomain_equiv_apply, exponent, Equiv.swap_apply_def] +/-- The symmetric squarefree form with one coefficient for each total degree from zero to three. -/ +def fourForm (c : Fin 4 → ℝ) : Poly := + monomial (exponent 0 0 0) (c 0) + + (monomial (exponent 1 0 0) (c 1) + monomial (exponent 0 1 0) (c 1) + monomial (exponent 0 0 1) + (c 1)) + + (monomial (exponent 1 1 0) (c 2) + monomial (exponent 1 0 1) (c 2) + monomial (exponent 0 1 1) + (c 2)) + + monomial (exponent 1 1 1) (c 3) + +theorem symmetric_squarefree_four (R : Poly) (hd : ∀ i, degreeOf i R ≤ 1) + (hs : ∀ e : Equiv.Perm (Fin 3), rename e R = R) : ∃ c, R = fourForm c := by + have h01 (a b c : ℕ) := symmetric_coeff R hs (Equiv.swap 0 1) (exponent a b c) + simp only [swap01_exponent] at h01 + have h12 (a b c : ℕ) := symmetric_coeff R hs (Equiv.swap 1 2) (exponent a b c) + simp only [swap12_exponent] at h12 + refine ⟨![R.coeff (exponent 0 0 0), R.coeff (exponent 1 0 0), + R.coeff (exponent 1 1 0), R.coeff (exponent 1 1 1)], ?_⟩ + conv_lhs => rw [squarefree_expansion R hd] + simp only [Fin.sum_univ_two, fourForm, Matrix.cons_val_zero, Matrix.cons_val_one, + Matrix.cons_val, Fin.val_zero, Fin.val_one] + rw [h12 0 1 0, h01 1 0 0, h01 1 0 1, h12 1 1 0] + abel +end C145N6 + +end diff --git a/LeanPool/C145/C145N6TimeKernels.lean b/LeanPool/C145/C145N6TimeKernels.lean new file mode 100644 index 0000000000..8690e14484 --- /dev/null +++ b/LeanPool/C145/C145N6TimeKernels.lean @@ -0,0 +1,101 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6Uncalibrated +public import LeanPool.C145.C145DelayKernelTransfer + +/-! +# Recovery of six-vertex time kernels from terminal observations. +-/ + +@[expose] public section +noncomputable section +namespace C145N6Frame +open MeasureTheory Set C145.DelayKernel +open scoped BigOperators + +theorem literal_N6_time_kernels_identification {n : ℕ} + (c1 : ℝ) (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates1 : Function.Injective rates1) + (hRateGround1 : rates1 0 = 1) + (hAbove1 : ∀ j : Fin n, 1 < rates1 j.succ) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (hK1 : ∀ r : ℝ, 0 ≤ r → + firstKernel frame literalRates port r = firstKernel Q1 rates1 b1 r) + (hK2 : ∀ r₁ r₂ : ℝ, 0 ≤ r₁ → 0 ≤ r₂ → + delayKernel frame literalRates port r₁ r₂ = + delayKernel Q1 rates1 b1 r₁ r₂) : + ∃ e : Fin (5 + 1) ≃ Fin (n + 1), + 5 = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = literalRates i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap frame port i) ∧ + (1 / Real.sqrt 6) = c1 ∧ (∑ v, port v) = (∑ w, b1 w) ∧ + ∃ π : Fin (5 + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (5 + 1)), + (∑ i : Fin (5 + 1), Q1 w (e i) * frame v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (5 + 1)), Q1 (π v) (e i) = frame v i) ∧ + (∀ (v u : Fin (5 + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator literalRates frame v u) ∧ + (∀ v : Fin (5 + 1), b1 (π v) = port v) ∧ + (∀ (v u : Fin (5 + 1)), + C145CoordinatePermutation.decayLaplacian 1 rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian 1 literalRates frame v u) := by + have hPos0 : ∀ i, 0 < literalRates i := by + intro i; fin_cases i <;> norm_num [literalRates] + have hPos1 : ∀ i, 0 < rates1 i := by + intro i + rcases Fin.eq_zero_or_eq_succ i with h | ⟨j,rfl⟩ + · rw [h,hRateGround1]; norm_num + · exact lt_trans (by norm_num : (0 : ℝ) < 1) (hAbove1 j) + have hH1 : ∀ s : ℝ, 0 < s → + C145.H1.firstTransfer literalRates (C145.Pulse.modalOverlap frame port) s = + C145.H1.firstTransfer rates1 (C145.Pulse.modalOverlap Q1 b1) s := by + intro s hs + rw [← (firstKernel_transform frame literalRates port hPos0 s hs).2, + ← (firstKernel_transform Q1 rates1 b1 hPos1 s hs).2] + unfold laplace + apply setIntegral_congr_fun measurableSet_Ioi + intro r hr + change Real.exp (-s * r) * firstKernel frame literalRates port r = + Real.exp (-s * r) * firstKernel Q1 rates1 b1 r + rw [hK1 r hr.le] + have hB : ∀ t : ℝ, 0 ≤ t → + C145.Pulse.coincidentPulse frame literalRates port t = + C145.Pulse.coincidentPulse Q1 rates1 b1 t := by + intro t ht + rw [← delayKernel_diagonal frame literalRates port t, + ← delayKernel_diagonal Q1 rates1 b1 t] + exact hK2 t t ht ht + have hH2 : ∀ s t : ℝ, 0 < s → 0 < t → + C145.H2.H literalRates (C145PhysicalFrame.T frame (C145.Pulse.modalOverlap frame port)) s t = + C145.H2.H rates1 (C145PhysicalFrame.T Q1 (C145.Pulse.modalOverlap Q1 b1)) s t := by + intro s t hs ht + rw [← (delayKernel_transform frame literalRates port hPos0 s t hs ht).2, + ← (delayKernel_transform Q1 rates1 b1 hPos1 s t hs ht).2] + unfold doubleLaplace + apply setIntegral_congr_fun measurableSet_Ioi + intro r₁ hr₁ + apply setIntegral_congr_fun measurableSet_Ioi + intro r₂ hr₂ + change Real.exp (-s * r₁) * Real.exp (-t * r₂) * delayKernel frame literalRates port r₁ r₂ = + Real.exp (-s * r₁) * Real.exp (-t * r₂) * delayKernel Q1 rates1 b1 r₁ r₂ + rw [hK2 r₁ r₂ hr₁.le hr₂.le] + exact literal_N6_uncalibrated_identification c1 Q1 rates1 b1 hQ1 hGround1 hRates1 + hRateGround1 hAbove1 ha1 hH1 hB hH2 + +end C145N6Frame + +end diff --git a/LeanPool/C145/C145N6TraceLine.lean b/LeanPool/C145/C145N6TraceLine.lean new file mode 100644 index 0000000000..0d3890a2dc --- /dev/null +++ b/LeanPool/C145/C145N6TraceLine.lean @@ -0,0 +1,118 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6Squarefree +public import LeanPool.C145.C145PhysicalTraceResidue +public import LeanPool.C145.C145N6LiteralRows + +/-! +# Trace constraints on the six-vertex affine tensor line. +-/ + +@[expose] public section +namespace C145N6 +open MvPolynomial C145.H2 C145.ThreePlane +open scoped BigOperators +noncomputable section +/-- The five exact non-ground rates of the six-vertex source. -/ +def rates : Fin 5 → ℝ := ![20,21,22,23,24] +/-- The four rational-basis coefficients of the saved polynomial direction. -/ +def savedQ : Fin 4 → ℝ := + ![325764900351929037312, 14674136896174112640, 660275376511893120, 29677554006883200] +theorem admissible_five_four (R : Poly) (hs : SymPoly R) (ha : QAdmissible 5 R) : ∃ c, R = + fourForm c := by + apply symmetric_squarefree_four R _ hs + rcases ha with rfl | ⟨_,h⟩ + · simp + · simpa using h + +theorem univ_five : (Finset.univ : Finset (Fin 5)) = {0,1,2,3,4} := by decide + +theorem rates_di (i : Fin 5) : di rates i = (![24,-6,4,-6,24] : Fin 5 → ℝ) i := by + fin_cases i + · have he : (Finset.univ : Finset (Fin 5)).erase 0 = {1,2,3,4} := by decide + norm_num [di, he, rates] + · have he : (Finset.univ : Finset (Fin 5)).erase 1 = {0,2,3,4} := by decide + norm_num [di, he, rates] + · have he : (Finset.univ : Finset (Fin 5)).erase 2 = {0,1,3,4} := by decide + norm_num [di, he, rates] + · have he : (Finset.univ : Finset (Fin 5)).erase 3 = {0,1,2,4} := by decide + norm_num [di, he, rates] + · have he : (Finset.univ : Finset (Fin 5)).erase 4 = {0,1,2,3} := by decide + norm_num [di, he, rates] + +theorem eval_exponent (v : Fin 3 → ℝ) (a b c : ℕ) (r : ℝ) : + eval v (monomial (exponent a b c) r) = r * v 0 ^ a * v 1 ^ b * v 2 ^ c := by + rw [eval_monomial, Finsupp.prod_fintype _ _ (fun i => pow_zero (v i))] + simp only [Fin.prod_univ_succ, Fin.prod_univ_zero, mul_one] + simp only [exponent_apply, Matrix.cons_val_zero, Matrix.cons_val_succ, Matrix.cons_val_fin_one] + change r * (v 0 ^ a * (v 1 ^ b * v 2 ^ c)) = _ + ring + +theorem eval_fourForm (c : Fin 4 → ℝ) (v : Fin 3 → ℝ) : + eval v (fourForm c) = c 0 + c 1 * (v 0 + v 1 + v 2)+ + c 2 * (v 0 * v 1 + v 0 * v 2 + v 1 * v 2) + c 3 * v 0 * v 1 * v 2 := by + simp only [fourForm, map_add, eval_exponent, pow_zero, pow_one] + ring + +/-- The modal trace obtained by dividing by the literal squared overlaps before summing. -/ +def literalTrace (c : Fin 4 → ℝ) (i : Fin 5) : ℝ := + ∑ j, Res rates (fourForm c) i j j / C145N6Literal.overlapSquare j.succ + +theorem literalTrace_0 (c : Fin 4 → ℝ) : literalTrace c 0 = ((-2161682433875 : ℝ) / 4772455254) * + c 0 + ((2590386854600 : ℝ) / 88378801) * c 1 + ((-502389654429350 : ℝ) / 795409209) * c 2 + + ((10813930971581000 : ℝ) / 2386227627) * c 3 := by + simp only [literalTrace, Fin.sum_univ_succ, Fin.sum_univ_zero, add_zero, + res_entry, eval_fourForm, xi_negative_node_factors, rates_di] + norm_num [rates, di, C145N6Literal.overlapSquare, Fin.prod_univ_succ, univ_five, + Finset.erase_insert]; ring + +theorem literalTrace_1 (c : Fin 4 → ℝ) : literalTrace c 1 = ((41477827055 : ℝ) / 21643788) * c 0 + + ((-5451258232891 : ℝ) / 43287576) * c 1 + ((119398730088541 : ℝ) / 43287576) * c 2 + + ((-72635063655595 : ℝ) / 3607298) * c 3 := by + simp only [literalTrace, Fin.sum_univ_succ, Fin.sum_univ_zero, add_zero, + res_entry, eval_fourForm, xi_negative_node_factors, rates_di] + norm_num [rates, di, C145N6Literal.overlapSquare, Fin.prod_univ_succ, univ_five, + Finset.erase_insert]; ring + +theorem literalTrace_2 (c : Fin 4 → ℝ) : literalTrace c 2 = ((-3204241771555 : ℝ) / 1060545612) * + c 0 + ((53444263864673 : ℝ) / 265136403) * c 1 + ((-1188931306461074 : ℝ) / 265136403) * c 2 + + ((8819156627521306 : ℝ) / 265136403) * c 3 := by + simp only [literalTrace, Fin.sum_univ_succ, Fin.sum_univ_zero, add_zero, + res_entry, eval_fourForm, xi_negative_node_factors, rates_di] + norm_num [rates, di, C145N6Literal.overlapSquare, Fin.prod_univ_succ, univ_five, + Finset.erase_insert]; ring + + +theorem trace_kernel_saved_line (c : Fin 4 → ℝ) + (h : ∀ i, literalTrace c i = 0) : c = fun j => (c 3 / savedQ 3) * savedQ j := by + have h0 := h 0 + have h1 := h 1 + have h2 := h 2 + rw [literalTrace_0] at h0 + rw [literalTrace_1] at h1 + rw [literalTrace_2] at h2 + funext j + fin_cases j + · norm_num [savedQ] + linear_combination (-1012140890719171805529 / 2189964760013133125 : ℝ) * h0 + + (-19131961758132556272 / 87598590400525325 : ℝ) * h1 + (-733947426801789698946 / + 10599429438463564325 : ℝ) * h2 + · norm_num [savedQ] + linear_combination (-24154892621559002709 / 1751971808010506500 : ℝ) * h0 + (-1130255387454988 + / 173462555248565 : ℝ) * h1 + (-8759224410433715323 / 4239771775385425730 : ℝ) * h2 + · norm_num [savedQ] + linear_combination (-7846778375163 / 25446583218500 : ℝ) * h0 + (-37086758476 / 254465832185 : + ℝ) * h1 + (-2845910411141 / 61580731388770 : ℝ) * h2 + · norm_num [savedQ] +end +end C145N6 + +end diff --git a/LeanPool/C145/C145N6Uncalibrated.lean b/LeanPool/C145/C145N6Uncalibrated.lean new file mode 100644 index 0000000000..94e90ee6c2 --- /dev/null +++ b/LeanPool/C145/C145N6Uncalibrated.lean @@ -0,0 +1,190 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145N6PositiveGraph +public import LeanPool.C145.C145UncalibratedSmallH2 + +/-! +# Recovery of the six-vertex calibration from response data. +-/ + +@[expose] public section +noncomputable section +namespace C145N6Frame +open scoped BigOperators +open C145.UncalibratedSmallH2 + +theorem source_modal_overlap : C145.Pulse.modalOverlap frame port = overlap := by + funext i + simpa only [C145.Pulse.modalOverlap, mul_comm] using (overlap_actual_projection i).symm + +theorem source_overlap_positive : ∀ i, 0 < C145.Pulse.modalOverlap frame port i := by + intro i + rw [source_modal_overlap] + unfold overlap + apply div_pos + · fin_cases i <;> norm_num [numerator] + · exact mul_pos (by norm_num) (Real.sqrt_pos.2 (gramWeight_pos i)) +theorem literalRates_injective : Function.Injective literalRates := by + intro i j h; fin_cases i <;> fin_cases j <;> norm_num [literalRates] at * +theorem literalRates_above : ∀ i : Fin 5, 1 < literalRates i.succ := by + intro i; fin_cases i <;> norm_num [literalRates] + +theorem literal_N6_uncalibrated_identification {n : ℕ} + (c1 : ℝ) (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates1 : Function.Injective rates1) + (hRateGround1 : rates1 0 = 1) + (hAbove1 : ∀ j : Fin n, 1 < rates1 j.succ) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (hH1 : ∀ s : ℝ, 0 < s → + C145.H1.firstTransfer literalRates (C145.Pulse.modalOverlap frame port) s = + C145.H1.firstTransfer rates1 (C145.Pulse.modalOverlap Q1 b1) s) + (hB : ∀ t : ℝ, 0 ≤ t → + C145.Pulse.coincidentPulse frame literalRates port t = + C145.Pulse.coincidentPulse Q1 rates1 b1 t) + (hH2 : ∀ s t : ℝ, 0 < s → 0 < t → + C145.H2.H literalRates + (C145PhysicalFrame.T frame (C145.Pulse.modalOverlap frame port)) s t = + C145.H2.H rates1 + (C145PhysicalFrame.T Q1 (C145.Pulse.modalOverlap Q1 b1)) s t) : + ∃ e : Fin (5 + 1) ≃ Fin (n + 1), + 5 = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = literalRates i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap frame port i) ∧ + (1 / Real.sqrt 6) = c1 ∧ (∑ v, port v) = (∑ w, b1 w) ∧ + ∃ π : Fin (5 + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (5 + 1)), + (∑ i : Fin (5 + 1), Q1 w (e i) * frame v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (5 + 1)), Q1 (π v) (e i) = frame v i) ∧ + (∀ (v u : Fin (5 + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator literalRates frame v u) ∧ + (∀ v : Fin (5 + 1), b1 (π v) = port v) ∧ + (∀ (v u : Fin (5 + 1)), + C145CoordinatePermutation.decayLaplacian 1 rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian 1 literalRates frame v u) := by + let μ : ℝ := 1 + let c0 : ℝ := 1 / Real.sqrt 6 + let Q0 := frame + let rates0 := literalRates + let b0 := port + have hμ : 0 < μ := by norm_num [μ] + have hQ0 := frame_orthonormal + have hGround0 := frame_ground + have hRates0 := literalRates_injective + have hRateGround0 : rates0 0 = μ := rfl + have hAbove0 := literalRates_above + have ha0 := source_overlap_positive + classical + let a0 : Fin 6 → ℝ := C145.Pulse.modalOverlap Q0 b0 + let a1 : Fin (n + 1) → ℝ := C145.Pulse.modalOverlap Q1 b1 + obtain ⟨e, hSize, heGround, heRates, heOverlaps, hConstant, hMeans⟩ := + C145.Pulse.actual_signed_ground_calibration μ c0 c1 hμ Q0 Q1 + rates0 b0 a0 rates1 b1 a1 hQ0 hQ1 hGround0 hGround1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 + ha0 ha1 (fun _ => rfl) (fun _ => rfl) hH1 hB + -- Size equality is a data-derived fact; the modal map is retained. + subst n + let Q1e : Fin 6 → Fin 6 → ℝ := columnReindex Q1 e + let r0 : Fin 5 → ℝ := fun i => rates0 i.succ + have hQ1e : C145PhysicalFrame.ColumnOrthonormal Q1e := + columnReindex_columnOrthonormal Q1 e hQ1 + have hG1e : ∀ v, Q1e v 0 = c0 := by + intro v + change Q1 v (e 0) = c0 + rw [heGround, hGround1, ← hConstant] + have hResidualRates : Function.Injective r0 := by + intro i j hij + apply Fin.succ_inj.mp + apply hRates0 + exact hij + have hResidualPos : ∀ i : Fin 5, 0 < r0 i := by + intro i + exact lt_trans hμ (hAbove0 i) + have hFull : C145.H2.fullRates μ r0 = rates0 := + fullRates_eq_own μ rates0 hRateGround0 + have hA : (fun i => a1 (e i)) = a0 := funext heOverlaps + have hLam : (fun i => rates1 (e i)) = rates0 := funext heRates + have hT : C145PhysicalFrame.T Q1e a0 = + (fun i j k => C145PhysicalFrame.T Q1 a1 (e i) (e j) (e k)) := by + funext i j k + simpa only [Q1e, hA] using tensor_columnReindex Q1 a1 e i j k + have hAlignedResponse : ∀ s t : ℝ, + C145.H2.H rates0 (C145PhysicalFrame.T Q1e a0) s t = + C145.H2.H rates1 (C145PhysicalFrame.T Q1 a1) s t := by + intro s t + have h := H_modal_reindex rates1 (C145PhysicalFrame.T Q1 a1) e s t + rw [hLam, ← hT] at h + exact h + have hHAligned : C145.H2.SamePositive (C145.H2.fullRates μ r0) + (C145PhysicalFrame.T Q0 a0) (C145PhysicalFrame.T Q1e a0) := by + intro s t hs ht + rw [hFull] + exact (hH2 s t hs ht).trans (hAlignedResponse s t).symm + have ha0eq : a0 = overlap := source_modal_overlap + have hAlignedN6 : C145.H2.SamePositive (C145.H2.fullRates 1 C145N6.rates) + (C145PhysicalFrame.T frame overlap) (C145PhysicalFrame.T Q1e overlap) := by + simpa only [hFull, ha0eq, ← literalRates_full] using hHAligned + obtain ⟨π, hDeltaRaw, hRowsRaw, _, _, _⟩ := + calibrated_response_spectral_transport 1 Q1e hQ1e hG1e hAlignedN6 + have hDelta : ∀ (w v : Fin 6), + (∑ i : Fin 6, Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0 := by + intro w v + exact hDeltaRaw w v + have hRows : ∀ (v i : Fin 6), Q1 (π v) (e i) = Q0 v i := by + intro v i + exact hRowsRaw v i + have hGenerator : ∀ (v u : Fin 6), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u := by + intro v u + unfold C145CoordinatePermutation.spectralGenerator + congr 1 + calc + (∑ j, rates1 j * Q1 (π v) j * Q1 (π u) j) = + ∑ i, rates1 (e i) * Q1 (π v) (e i) * Q1 (π u) (e i) := + (e.sum_comp (fun j => rates1 j * Q1 (π v) j * Q1 (π u) j)).symm + _ = ∑ i, rates0 i * Q0 v i * Q0 u i := by + apply Finset.sum_congr rfl + intro i hi + rw [heRates i, hRows v i, hRows u i] + have hPort : ∀ v : Fin 6, b1 (π v) = b0 v := by + intro v + have hReconstruct1 := congrFun (spectralPort_modalOverlap Q1 b1 hQ1) (π v) + have hReconstruct0 := congrFun (spectralPort_modalOverlap Q0 b0 hQ0) v + change (∑ j, a1 j * Q1 (π v) j) = b1 (π v) at hReconstruct1 + change (∑ i, a0 i * Q0 v i) = b0 v at hReconstruct0 + calc + b1 (π v) = ∑ j, a1 j * Q1 (π v) j := hReconstruct1.symm + _ = ∑ i, a1 (e i) * Q1 (π v) (e i) := + (e.sum_comp (fun j => a1 j * Q1 (π v) j)).symm + _ = ∑ i, a0 i * Q0 v i := by + apply Finset.sum_congr rfl + intro i hi + rw [heOverlaps i, hRows v i] + _ = b0 v := hReconstruct0 + have hL : ∀ (v u : Fin 6), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u := by + intro v u + simp only [C145CoordinatePermutation.decayLaplacian, hGenerator, + π.apply_eq_iff_eq] + exact ⟨e, rfl, heGround, heRates, heOverlaps, hConstant, hMeans, + π, hDelta, hRows, hGenerator, hPort, hL⟩ + +end C145N6Frame + +end diff --git a/LeanPool/C145/C145ObservedKernelRecovery.lean b/LeanPool/C145/C145ObservedKernelRecovery.lean new file mode 100644 index 0000000000..0139116bc7 --- /dev/null +++ b/LeanPool/C145/C145ObservedKernelRecovery.lean @@ -0,0 +1,296 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145ActualTimeConvolution +public import Mathlib.Analysis.Distribution.AEEqOfIntegralContDiff +public import Mathlib.MeasureTheory.Measure.OpenPos + +/-! +Observed first and quadratic time-kernel recovery from ordinary response jets. +Tests are globally smooth and compactly supported inside the physical interval. +Only the terminal-time response derivatives are used. No continuation beyond +that interval, spectral calibration, graph premise or noisy inverse is asserted. +-/ + +@[expose] public section + +noncomputable section +namespace C145.ObservedKernelRecovery +open MeasureTheory Set Filter +open C145.ActualResponse +open scoped Topology ContDiff +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +/-- The source's smooth temporal directions, with compact support in (0,T). -/ +def SmoothTemporalTest (T : ℝ) (g : ℝ → ℝ) : Prop := + ContDiff ℝ ∞ g ∧ HasCompactSupport g ∧ tsupport g ⊆ Ioo (0 : ℝ) T + +/-- The real-time reflection that sends a time to its difference from the horizon. -/ +def reflection (T : ℝ) : ℝ ≃ₜ ℝ where + toFun s := T - s + invFun s := T - s + left_inv s := by dsimp; ring + right_inv s := by dsimp; ring + continuous_toFun := continuous_const.sub continuous_id + continuous_invFun := continuous_const.sub continuous_id + +/-- Reflection of a smooth test remains a physically allowed smooth test. -/ +theorem smoothTemporalTest_reflect {T : ℝ} {g : ℝ → ℝ} + (hg : SmoothTemporalTest T g) : + SmoothTemporalTest T (fun s => g (T - s)) := by + refine ⟨hg.1.comp (contDiff_const.sub contDiff_id), ?_, ?_⟩ + · exact hg.2.1.comp_homeomorph (reflection T) + · change tsupport (g ∘ reflection T) ⊆ Ioo (0 : ℝ) T + rw [tsupport_comp_eq_preimage] + intro s hs + have h := hg.2.2 hs + change 0 < T - s ∧ T - s < T at h + constructor <;> linarith + +/-- The imported distribution lemma separates smooth compact test functions; +continuity makes the resulting almost-everywhere equality pointwise. -/ +theorem continuous_zero_of_smooth_tests {T : ℝ} (hT : 0 < T) + (f : ℝ → ℝ) (hf : Continuous f) + (hTest : ∀ g : ℝ → ℝ, SmoothTemporalTest T g → + (∫ r in (0 : ℝ)..T, f r * g r) = 0) : + ∀ r ∈ Icc (0 : ℝ) T, f r = 0 := by + have hae : ∀ᵐ r : ℝ, r ∈ Ioo (0 : ℝ) T → f r = 0 := by + apply isOpen_Ioo.ae_eq_zero_of_integral_contDiff_smul_eq_zero + (hf.continuousOn.locallyIntegrableOn measurableSet_Ioo) + intro g hgd hgc hgs + have hsupport : Function.support (fun r => g r * f r) ⊆ Ioc (0 : ℝ) T := by + intro r hr + have hgzero : g r ≠ 0 := by + intro he + exact hr (by simp [he]) + have hin := hgs (subset_tsupport g (show r ∈ Function.support g from hgzero)) + exact ⟨hin.1, hin.2.le⟩ + change (∫ x : ℝ, g x * f x) = 0 + rw [← intervalIntegral.integral_eq_integral_of_support_subset hsupport] + simpa only [smul_eq_mul, mul_comm] using hTest g ⟨hgd, hgc, hgs⟩ + have haeU : f =ᵐ[volume.restrict (Ioo (0 : ℝ) T)] (fun _ => 0) := by + filter_upwards [ae_restrict_of_ae hae, ae_restrict_mem measurableSet_Ioo] with r hr hmem + exact hr hmem + have hinside : EqOn f (fun _ => 0) (Ioo (0 : ℝ) T) := + MeasureTheory.Measure.eqOn_open_of_ae_eq haeU isOpen_Ioo hf.continuousOn + continuous_const.continuousOn + have hclosure : Icc (0 : ℝ) T ⊆ closure (Ioo (0 : ℝ) T) := by + rw [closure_Ioo hT.ne] + exact hinside.of_subset_closure hf.continuousOn continuous_const.continuousOn + Ioo_subset_Icc_self hclosure + +/-- Product smooth temporal tests separate a continuous kernel on the square. +One-dimensional smooth-test separation is applied twice, without additional data. -/ +theorem continuous_square_zero_of_smooth_product_tests {T : ℝ} (hT : 0 < T) + (K : ℝ → ℝ → ℝ) (hK : Continuous (fun p : ℝ × ℝ => K p.1 p.2)) + (hTest : ∀ g h : ℝ → ℝ, SmoothTemporalTest T g → SmoothTemporalTest T h → + (∫ r in (0 : ℝ)..T, ∫ s in (0 : ℝ)..T, K r s * g r * h s) = 0) : + ∀ r ∈ Icc (0 : ℝ) T, ∀ s ∈ Icc (0 : ℝ) T, K r s = 0 := by + have hmarg (h : ℝ → ℝ) (hh : SmoothTemporalTest T h) : + ∀ r ∈ Icc (0 : ℝ) T, (∫ s in (0 : ℝ)..T, K r s * h s) = 0 := by + have hcontinuous : Continuous (fun r : ℝ => ∫ s in (0 : ℝ)..T, K r s * h s) := by + apply intervalIntegral.continuous_parametric_intervalIntegral_of_continuous' + (a₀ := (0 : ℝ)) (b₀ := T) + exact hK.mul (hh.1.continuous.comp continuous_snd) + apply continuous_zero_of_smooth_tests hT _ hcontinuous + intro g hg + calc + (∫ r in (0 : ℝ)..T, (∫ s in (0 : ℝ)..T, K r s * h s) * g r) = + ∫ r in (0 : ℝ)..T, ∫ s in (0 : ℝ)..T, K r s * g r * h s := by + apply intervalIntegral.integral_congr + intro r hr + change (∫ s in (0 : ℝ)..T, K r s * h s) * g r = + ∫ s in (0 : ℝ)..T, K r s * g r * h s + rw [← intervalIntegral.integral_mul_const] + apply intervalIntegral.integral_congr + intro s hs + change (K r s * h s) * g r = K r s * g r * h s + ring + _ = 0 := hTest g h hg hh + intro r hr + apply continuous_zero_of_smooth_tests hT (K r) + (hK.comp (continuous_const.prodMk continuous_id)) + intro h hh + exact hmarg h hh r hr + +theorem firstKernel_continuous {n : ℕ} (Q : Frame n) (rates b : State n) : + Continuous (C145.DelayKernel.firstKernel Q rates b) := by + change Continuous (fun r : ℝ => C145.DelayKernel.firstKernel Q rates b r) + simp_rw [C145.DelayKernel.firstKernel_expansion] + fun_prop + +theorem delayKernel_continuous {n : ℕ} (Q : Frame n) (rates b : State n) : + Continuous (fun p : ℝ × ℝ => C145.DelayKernel.delayKernel Q rates b p.1 p.2) := by + unfold C145.DelayKernel.delayKernel + apply intervalIntegral.continuous_parametric_intervalIntegral_of_continuous + · unfold C145.DelayKernel.delayIntegrand C145.Pulse.heatAction + fun_prop + · exact continuous_fst.min continuous_snd + +theorem extendInput_reflected {T : ℝ} (hT : 0 < T) (g : ℝ → ℝ) + (hg : Continuous g) (r : ℝ) (hr : r ∈ Icc (0 : ℝ) T) : + extendInput hT (restrictInput T (fun s => g (T - s)) + (hg.comp (continuous_const.sub continuous_id))) (T - r) = g r := by + have hlow : 0 ≤ T - r := by linarith [hr.2] + have hupp : T - r ≤ T := by linarith [hr.1] + change g (T - max 0 (min T (T - r))) = g r + rw [min_eq_right hupp, max_eq_right hlow] + congr 1 + ring + +/-- Canonical first derivative, tested with a reflected smooth direction. -/ +theorem rawFirst_reflected {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (R : Input T → Path n T) (hR : IsActualResponse hT Q rates b R) + (hcR : ContDiffAt ℝ 2 R 0) (g : ℝ → ℝ) (hg : Continuous g) : + rawFirst b R (restrictInput T (fun s => g (T - s)) + (hg.comp (continuous_const.sub continuous_id))) (endTime T hT) = + ∫ r in (0 : ℝ)..T, C145.DelayKernel.firstKernel Q rates b r * g r := by + rw [(C145.ActualTimeConvolution.actual_response_time_kernel hT Q rates b hQ R hR hcR + (restrictInput T (fun s => g (T - s)) (hg.comp (continuous_const.sub continuous_id))) + (restrictInput T (fun s => g (T - s)) (hg.comp (continuous_const.sub continuous_id))) + (endTime T hT)).1] + apply intervalIntegral.integral_congr + intro r hr + change C145.DelayKernel.firstKernel Q rates b r * + extendInput hT (restrictInput T (fun s => g (T - s)) + (hg.comp (continuous_const.sub continuous_id))) (T - r) = + C145.DelayKernel.firstKernel Q rates b r * g r + rw [extendInput_reflected hT g hg r (by simpa [endTime, uIcc_of_le hT.le] using hr)] + +/-- The factor one half is already in canonical rawMixed; no rescaling occurs. -/ +theorem rawMixed_reflected {n : ℕ} {T : ℝ} (hT : 0 < T) + (Q : Frame n) (rates b : State n) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (R : Input T → Path n T) (hR : IsActualResponse hT Q rates b R) + (hcR : ContDiffAt ℝ 2 R 0) (g h : ℝ → ℝ) (hg : Continuous g) (hh : Continuous h) : + rawMixed b R + (restrictInput T (fun s => g (T - s)) (hg.comp (continuous_const.sub continuous_id))) + (restrictInput T (fun s => h (T - s)) (hh.comp (continuous_const.sub continuous_id))) + (endTime T hT) = + ∫ r in (0 : ℝ)..T, ∫ s in (0 : ℝ)..T, + C145.DelayKernel.delayKernel Q rates b r s * g r * h s := by + rw [(C145.ActualTimeConvolution.actual_response_time_kernel hT Q rates b hQ R hR hcR + (restrictInput T (fun s => g (T - s)) (hg.comp (continuous_const.sub continuous_id))) + (restrictInput T (fun s => h (T - s)) (hh.comp (continuous_const.sub continuous_id))) + (endTime T hT)).2.1] + apply intervalIntegral.integral_congr + intro r hr + apply intervalIntegral.integral_congr + intro s hs + change C145.DelayKernel.delayKernel Q rates b r s * + extendInput hT (restrictInput T (fun s => g (T - s)) + (hg.comp (continuous_const.sub continuous_id))) (T - r) * + extendInput hT (restrictInput T (fun s => h (T - s)) + (hh.comp (continuous_const.sub continuous_id))) (T - s) = + C145.DelayKernel.delayKernel Q rates b r s * g r * h s + rw [extendInput_reflected hT g hg r (by simpa [endTime, uIcc_of_le hT.le] using hr), + extendInput_reflected hT h hh s (by simpa [endTime, uIcc_of_le hT.le] using hs)] + +/-- Actual ordinary C2 response data on smooth compact temporal directions +recover the two observed kernels, without any supplied kernel equality. -/ +theorem ordinary_C2_jets_recover_observed_time_kernels {m n : ℕ} {T : ℝ} + (hT : 0 < T) + (Q0 : Frame m) (rates0 b0 : State m) (Q1 : Frame n) (rates1 b1 : State n) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (R0 : Input T → Path m T) (R1 : Input T → Path n T) + (hR0 : IsActualResponse hT Q0 rates0 b0 R0) + (hR1 : IsActualResponse hT Q1 rates1 b1 R1) + (hcR0 : ContDiffAt ℝ 2 R0 0) (hcR1 : ContDiffAt ℝ 2 R1 0) + (hFirst : ∀ (g : ℝ → ℝ) (hg : SmoothTemporalTest T g), + rawFirst b0 R0 (restrictInput T g hg.1.continuous) (endTime T hT) = + rawFirst b1 R1 (restrictInput T g hg.1.continuous) (endTime T hT)) + (hMixed : ∀ (g h : ℝ → ℝ) (hg : SmoothTemporalTest T g) (hh : SmoothTemporalTest T h), + rawMixed b0 R0 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT) = + rawMixed b1 R1 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT)) : + (∀ r ∈ Icc (0 : ℝ) T, + C145.DelayKernel.firstKernel Q0 rates0 b0 r = + C145.DelayKernel.firstKernel Q1 rates1 b1 r) ∧ + (∀ r ∈ Icc (0 : ℝ) T, ∀ s ∈ Icc (0 : ℝ) T, + C145.DelayKernel.delayKernel Q0 rates0 b0 r s = + C145.DelayKernel.delayKernel Q1 rates1 b1 r s) := by + have hk0 := firstKernel_continuous Q0 rates0 b0 + have hk1 := firstKernel_continuous Q1 rates1 b1 + have hK0 := delayKernel_continuous Q0 rates0 b0 + have hK1 := delayKernel_continuous Q1 rates1 b1 + constructor + · have hz := continuous_zero_of_smooth_tests hT + (fun r => C145.DelayKernel.firstKernel Q0 rates0 b0 r - + C145.DelayKernel.firstKernel Q1 rates1 b1 r) (hk0.sub hk1) ?_ + · intro r hr + exact sub_eq_zero.mp (hz r hr) + · intro g hg + have heq := hFirst (fun s => g (T - s)) (smoothTemporalTest_reflect hg) + rw [rawFirst_reflected hT Q0 rates0 b0 hQ0 R0 hR0 hcR0 g hg.1.continuous, + rawFirst_reflected hT Q1 rates1 b1 hQ1 R1 hR1 hcR1 g hg.1.continuous] at heq + simp_rw [sub_mul] + rw [intervalIntegral.integral_sub + (f := fun r => C145.DelayKernel.firstKernel Q0 rates0 b0 r * g r) + (g := fun r => C145.DelayKernel.firstKernel Q1 rates1 b1 r * g r) + ((hk0.mul hg.1.continuous).intervalIntegrable _ _) + ((hk1.mul hg.1.continuous).intervalIntegrable _ _), heq, sub_self] + · have hz := continuous_square_zero_of_smooth_product_tests hT + (fun r s => C145.DelayKernel.delayKernel Q0 rates0 b0 r s - + C145.DelayKernel.delayKernel Q1 rates1 b1 r s) (hK0.sub hK1) ?_ + · intro r hr s hs + exact sub_eq_zero.mp (hz r hr s hs) + · intro g h hg hh + have heq := hMixed (fun s => g (T - s)) (fun s => h (T - s)) + (smoothTemporalTest_reflect hg) (smoothTemporalTest_reflect hh) + rw [rawMixed_reflected hT Q0 rates0 b0 hQ0 R0 hR0 hcR0 g h + hg.1.continuous hh.1.continuous, + rawMixed_reflected hT Q1 rates1 b1 hQ1 R1 hR1 hcR1 g h + hg.1.continuous hh.1.continuous] at heq + have hcont0 : Continuous (fun p : ℝ × ℝ => + C145.DelayKernel.delayKernel Q0 rates0 b0 p.1 p.2 * g p.1 * h p.2) := + (hK0.mul (hg.1.continuous.comp continuous_fst)).mul + (hh.1.continuous.comp continuous_snd) + have hcont1 : Continuous (fun p : ℝ × ℝ => + C145.DelayKernel.delayKernel Q1 rates1 b1 p.1 p.2 * g p.1 * h p.2) := + (hK1.mul (hg.1.continuous.comp continuous_fst)).mul + (hh.1.continuous.comp continuous_snd) + have hc0 : Continuous (fun r : ℝ => ∫ s in (0 : ℝ)..T, + C145.DelayKernel.delayKernel Q0 rates0 b0 r s * g r * h s) := + intervalIntegral.continuous_parametric_intervalIntegral_of_continuous' hcont0 0 T + have hc1 : Continuous (fun r : ℝ => ∫ s in (0 : ℝ)..T, + C145.DelayKernel.delayKernel Q1 rates1 b1 r s * g r * h s) := + intervalIntegral.continuous_parametric_intervalIntegral_of_continuous' hcont1 0 T + simp_rw [sub_mul] + have hsubinner (r : ℝ) : + (∫ s in (0 : ℝ)..T, + C145.DelayKernel.delayKernel Q0 rates0 b0 r s * g r * h s - + C145.DelayKernel.delayKernel Q1 rates1 b1 r s * g r * h s) = + (∫ s in (0 : ℝ)..T, C145.DelayKernel.delayKernel Q0 rates0 b0 r s * g r * h s) - + (∫ s in (0 : ℝ)..T, C145.DelayKernel.delayKernel Q1 rates1 b1 r s * g r * h s) := by + exact intervalIntegral.integral_sub + (f := fun s => C145.DelayKernel.delayKernel Q0 rates0 b0 r s * g r * h s) + (g := fun s => C145.DelayKernel.delayKernel Q1 rates1 b1 r s * g r * h s) + ((hcont0.comp (continuous_const.prodMk continuous_id)).intervalIntegrable _ _) + ((hcont1.comp (continuous_const.prodMk continuous_id)).intervalIntegrable _ _) + simp_rw [hsubinner] + rw [intervalIntegral.integral_sub + (f := fun r => ∫ s in (0 : ℝ)..T, C145.DelayKernel.delayKernel Q0 rates0 b0 r s * g r * h s) + (g := fun r => ∫ s in (0 : ℝ)..T, C145.DelayKernel.delayKernel Q1 rates1 b1 r s * g r * h s) + (hc0.intervalIntegrable _ _) (hc1.intervalIntegrable _ _), heq, sub_self] + + +end C145.ObservedKernelRecovery +end + +end diff --git a/LeanPool/C145/C145OrientedEigenframe.lean b/LeanPool/C145/C145OrientedEigenframe.lean new file mode 100644 index 0000000000..e0d059bb93 --- /dev/null +++ b/LeanPool/C145/C145OrientedEigenframe.lean @@ -0,0 +1,78 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145CyclicSpectral +public import LeanPool.C145.C145CoordinatePermutation +public import LeanPool.C145.C145SignedGroundPulseCalibration + +/-! Elementary sign orientation, reindexing and reconstruction of the original matrix. -/ + +@[expose] public section + +noncomputable section +namespace C145.OrientedEigenframe +open scoped BigOperators +open Matrix + +/-- The sign used to orient a mode, positive for a positive overlap and negative otherwise. -/ +def orientation (a : ℝ) : ℝ := if 0 < a then 1 else -1 + +theorem orientation_sq (a : ℝ) : orientation a * orientation a = 1 := by + unfold orientation; split <;> norm_num + +theorem oriented_pos (a : ℝ) (ha : a ≠ 0) : 0 < orientation a * a := by + unfold orientation + split_ifs with h + · simpa using h + · have : a < 0 := lt_of_le_of_ne (le_of_not_gt h) ha + simpa using neg_pos.mpr this + +theorem oriented_frame {n : ℕ} (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (e : Fin (n + 1) ≃ Fin (n + 1)) (s : Fin (n + 1) → ℝ) + (hs : ∀ i, s i * s i = 1) : + C145PhysicalFrame.ColumnOrthonormal (fun v i => s i * Q v (e i)) := by + intro i j + calc + (∑ v, (s i * Q v (e i)) * (s j * Q v (e j))) = + s i * s j * (∑ v, Q v (e i) * Q v (e j)) := by + rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro v _; ring + _ = if i = j then 1 else 0 := by + rw [hQ] + by_cases h : i = j + · subst j; simp [hs] + · simp [h, e.injective.ne h] + +theorem generator_eq_of_eigenframe {n : ℕ} + (A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) (rates : Fin (n + 1) → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (he : ∀ i, A *ᵥ (fun v => Q v i) = (-rates i) • (fun v => Q v i)) : + C145CoordinatePermutation.spectralGenerator rates Q = A := by + funext v u + have hev : ∀ i, ∑ w, A v w * Q w i = -rates i * Q v i := by + intro i; exact congrFun (he i) v + calc + -(∑ i, rates i * Q v i * Q u i) = + ∑ i, (∑ w, A v w * Q w i) * Q u i := by + simp only [hev, ← Finset.sum_neg_distrib] + apply Finset.sum_congr rfl; intro i _; ring + _ = ∑ w, A v w * (∑ i, Q w i * Q u i) := by + simp_rw [Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro w _ + apply Finset.sum_congr rfl; intro i _; ring + _ = A v u := by + simp_rw [C145PhysicalFrame.columnOrthonormal_rowComplete Q hQ _ _] + simp + +end C145.OrientedEigenframe + +end diff --git a/LeanPool/C145/C145PaperActualResponse.lean b/LeanPool/C145/C145PaperActualResponse.lean new file mode 100644 index 0000000000..ff9702ffea --- /dev/null +++ b/LeanPool/C145/C145PaperActualResponse.lean @@ -0,0 +1,184 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8OriginalGraphInverse + +/-! +The local C2 response is a consequence of the original graph hypotheses, rather +than an additional existence premise of the inverse problem. Selection below +uses only this proved existence. Its ordinary measured jets agree with those +of every other actual C2 response of the same graph. + +The final application presents Theorem A directly through these terminal jets, +without carrying auxiliary modal realizations in its conclusion. +-/ + +@[expose] public section + +noncomputable section +namespace C145.PaperActualResponse + +open Matrix C145.WeightedGraph C145.CyclicSpectral + C145.GraphSpectralRealization C145.ActualResponse C145.ObservedKernelRecovery +open scoped BigOperators Topology ContDiff + +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +/-- The same path-valued response solves the spectral ODE exactly when it solves +the original vertex-coordinate graph ODE. In particular the input neighborhood, +initial state, and coordinatewise quadratic reaction are all unchanged. -/ +theorem actualResponse_iff_graphResponse {n : ℕ} {T : ℝ} (hT : 0 < T) + {μ : ℝ} {W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ} {b : State n} + (S : OrientedRealization μ W b) (R : Input T → Path n T) : + IsActualResponse hT S.Q S.rates b R ↔ IsGraphResponse hT μ W b R := by + unfold IsActualResponse IsGraphResponse vectorField graphVectorField + rw [S.original_generator] + +/-- Proved local C2 existence for the original graph ODE, from an actual +orthonormal spectral realization of its original generator. -/ +theorem exists_graph_C2_response_of_realization {n : ℕ} {T : ℝ} (hT : 0 < T) + {μ : ℝ} {W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ} {b : State n} + (S : OrientedRealization μ W b) : + ∃ R : Input T → Path n T, + IsGraphResponse hT μ W b R ∧ ContDiffAt ℝ 2 R 0 := by + obtain ⟨R, hR, hC⟩ := exists_actual_C2_response hT S.Q S.rates b S.orthonormal + exact ⟨R, (actualResponse_iff_graphResponse hT S R).mp hR, hC⟩ + +section OriginalGraph + +variable {n : ℕ} {T : ℝ} (hT : 0 < T) (μ : ℝ) (hμ : 0 < μ) + (W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hs : W.IsSymm) (hn : ∀ v u, 0 ≤ W v u) + (hc : (supportGraph W hs).Connected) (b : State n) + (hcyc : KrylovCyclic (generator μ W) b) + +include hμ hs hn hc hcyc in +/-- Every connected symmetric nonnegative graph with positive uniform decay and +a cyclic real port has an actual response germ on every fixed positive horizon, +with C2 dependence on the continuous temporal input. -/ +theorem exists_graph_C2_response : + ∃ R : Input T → Path n T, + IsGraphResponse hT μ W b R ∧ ContDiffAt ℝ 2 R 0 := by + obtain ⟨S⟩ := connected_cyclic_graph_has_oriented_spectral_realization + μ hμ W hs hn hc b hcyc + exact exists_graph_C2_response_of_realization hT S + +/-- A named mathematical response selected from proved original-graph existence. +Only its local input germ is used; no global large-forcing solution is claimed. -/ +def selectedResponse : Input T → Path n T := + Classical.choose (exists_graph_C2_response hT μ hμ W hs hn hc b hcyc) + +/-- The selected response satisfies the actual original graph equation and the +regularity required by the ordinary-jet inverse theorems. -/ +theorem selectedResponse_spec : + IsGraphResponse hT μ W b (selectedResponse hT μ hμ W hs hn hc b hcyc) ∧ + ContDiffAt ℝ 2 (selectedResponse hT μ hμ W hs hn hc b hcyc) 0 := + Classical.choose_spec (exists_graph_C2_response hT μ hμ W hs hn hc b hcyc) + +/-- The selected response's ordinary derivatives are the accepted exact first +and half-second variations. The realization is arbitrary, so selection does +not impose a preferred modal frame on the physical experiment. -/ +theorem selectedResponse_variations (S : OrientedRealization μ W b) + (g h : Input T) (t : Time T) : + rawFirst b (selectedResponse hT μ hμ W hs hn hc b hcyc) g t = + observe b (firstState hT S.Q S.rates b g t) ∧ + rawMixed b (selectedResponse hT μ hμ W hs hn hc b hcyc) g h t = + observe b (secondState hT S.Q S.rates b g h t) ∧ + rawQuadratic b (selectedResponse hT μ hμ W hs hn hc b hcyc) g t = + observe b (secondState hT S.Q S.rates b g g t) := by + have hspec := selectedResponse_spec hT μ hμ W hs hn hc b hcyc + exact actual_response_variations hT S.Q S.rates b S.orthonormal + (selectedResponse hT μ hμ W hs hn hc b hcyc) + (S.actualResponse hT _ hspec.1) hspec.2 g h t + +/-- The named response supplies the same measured jets as any actual C2 +response of this graph. Hence arbitrary behavior of a chosen representative +away from zero input cannot affect the data used in the application below. -/ +theorem measured_jets_eq_selectedResponse (R : Input T → Path n T) + (hR : IsGraphResponse hT μ W b R) (hC : ContDiffAt ℝ 2 R 0) + (g h : Input T) (t : Time T) : + rawFirst b R g t = rawFirst b (selectedResponse hT μ hμ W hs hn hc b hcyc) g t ∧ + rawMixed b R g h t = + rawMixed b (selectedResponse hT μ hμ W hs hn hc b hcyc) g h t ∧ + rawQuadratic b R g t = + rawQuadratic b (selectedResponse hT μ hμ W hs hn hc b hcyc) g t := by + obtain ⟨S⟩ := connected_cyclic_graph_has_oriented_spectral_realization + μ hμ W hs hn hc b hcyc + have hmeas := actual_response_variations hT S.Q S.rates b S.orthonormal + R (S.actualResponse hT R hR) hC g h t + have hsel := selectedResponse_variations hT μ hμ W hs hn hc b hcyc S g h t + exact ⟨hmeas.1.trans hsel.1.symm, hmeas.2.1.trans hsel.2.1.symm, + hmeas.2.2.trans hsel.2.2.symm⟩ + +end OriginalGraph + +/-- Equality of the exact first and half-mixed-second terminal derivatives in +all smooth temporal directions on the one fixed horizon. This is a predicate +on actual observed derivatives, not a target graph-identification certificate. -/ +def TerminalJetsAgree {m n : ℕ} {T : ℝ} (hT : 0 < T) + (b0 : State m) (R0 : Input T → Path m T) + (b1 : State n) (R1 : Input T → Path n T) : Prop := + (∀ (g : ℝ → ℝ) (hg : SmoothTemporalTest T g), + rawFirst b0 R0 (restrictInput T g hg.1.continuous) (endTime T hT) = + rawFirst b1 R1 (restrictInput T g hg.1.continuous) (endTime T hT)) ∧ + (∀ (g h : ℝ → ℝ) (hg : SmoothTemporalTest T g) (hh : SmoothTemporalTest T h), + rawMixed b0 R0 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT) = + rawMixed b1 R1 (restrictInput T g hg.1.continuous) (restrictInput T h hh.1.continuous) + (endTime T hT)) + +/-- Theorem A as an application to the two original graphs' named measured +responses. Existence and C2 regularity are derived above, so callers provide +only graph hypotheses, the source criterion, and equality of measured data. +The same vertex bijection identifies the original generator, signed port, and +Laplacian; the competitor's size and topology are initially unrestricted. -/ +theorem selected_response_theoremA_graph {m n : ℕ} {T : ℝ} + (hT : 0 < T) (μ : ℝ) (hμ : 0 < μ) + (W0 : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (W1 : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hs0 : W0.IsSymm) (hs1 : W1.IsSymm) + (hn0 : ∀ v u, 0 ≤ W0 v u) (hn1 : ∀ v u, 0 ≤ W1 v u) + (hc0 : (supportGraph W0 hs0).Connected) (hc1 : (supportGraph W1 hs1).Connected) + (b0 : State m) (b1 : State n) + (hcyc0 : KrylovCyclic (generator μ W0) b0) + (hcyc1 : KrylovCyclic (generator μ W1) b1) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hSpectrum : C145DRE8.NonGroundDecayBand μ W0 ell u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ (b0 j - b0 k) ^ 2) + (hq : C145DRE8.sourceQChebyshevSq b0 ell u delta < 1) + (hData : TerminalJetsAgree hT + b0 (selectedResponse hT μ hμ W0 hs0 hn0 hc0 b0 hcyc0) + b1 (selectedResponse hT μ hμ W1 hs1 hn1 hc1 b1 hcyc1)) : + m = n ∧ ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ v u, generator μ W1 (π v) (π u) = generator μ W0 v u) ∧ + (∀ v, b1 (π v) = b0 v) ∧ + (∀ v u, laplacian W1 (π v) (π u) = laplacian W0 v u) := by + have hspec0 := selectedResponse_spec hT μ hμ W0 hs0 hn0 hc0 b0 hcyc0 + have hspec1 := selectedResponse_spec hT μ hμ W1 hs1 hn1 hc1 b1 hcyc1 + obtain ⟨S0, S1, e, hmn, he0, hr, ha, hc, hb, π, hQ, hA, hport, hL⟩ := + C145DRE8.ordinary_C2_jets_determine_theoremA_graph hT μ hμ W0 W1 + hs0 hs1 hn0 hn1 hc0 hc1 b0 b1 hcyc0 hcyc1 + ell u hw hband hSpectrum delta hd hsep hq + (selectedResponse hT μ hμ W0 hs0 hn0 hc0 b0 hcyc0) + (selectedResponse hT μ hμ W1 hs1 hn1 hc1 b1 hcyc1) + hspec0.1 hspec1.1 hspec0.2 hspec1.2 hData.1 hData.2 + exact ⟨hmn, π, hA, hport, hL⟩ + + +end C145.PaperActualResponse +end + +end diff --git a/LeanPool/C145/C145PaperApplication.lean b/LeanPool/C145/C145PaperApplication.lean new file mode 100644 index 0000000000..218414da93 --- /dev/null +++ b/LeanPool/C145/C145PaperApplication.lean @@ -0,0 +1,54 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145PaperPositiveWitness +public import LeanPool.C145.C145PaperActualResponse + +/-! A proof-checked application of the paper-facing inverse theorem to a +nontrivial normalized source. The source's graph, spectrum, contraction +criterion and local response are proved; only an admissible competitor and +equality of its actual terminal data remain conditional. -/ + +@[expose] public section + +noncomputable section +namespace C145.PaperApplication +open Matrix C145.WeightedGraph C145.CyclicSpectral C145.GraphSpectralRealization + C145.ActualResponse C145.PaperActualResponse C145.PaperPositiveWitness +open scoped Topology ContDiff + +theorem path_three_has_actual_C2_response {T : ℝ} (hT : 0 < T) : + ∃ R : Input T → C145.ActualResponse.Path 2 T, + IsGraphResponse hT 10 weights port R ∧ ContDiffAt ℝ 2 R 0 := + exists_graph_C2_response hT 10 (by norm_num) weights weights_symmetric + weights_nonnegative support_connected port port_cyclic + +theorem path_three_identified_against_arbitrary_competitor {n : ℕ} {T : ℝ} + (hT : 0 < T) + (W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hs : W.IsSymm) (hn : ∀ v u, 0 ≤ W v u) + (hc : (supportGraph W hs).Connected) (b : State n) + (hcyc : KrylovCyclic (generator 10 W) b) + (hData : TerminalJetsAgree hT + port (selectedResponse hT 10 (by norm_num) weights weights_symmetric + weights_nonnegative support_connected port port_cyclic) + b (selectedResponse hT 10 (by norm_num) W hs hn hc b hcyc)) : + 2 = n ∧ ∃ π : Fin 3 ≃ Fin (n + 1), + (∀ v u, generator 10 W (π v) (π u) = generator 10 weights v u) ∧ + (∀ v, b (π v) = port v) ∧ + (∀ v u, laplacian W (π v) (π u) = laplacian weights v u) := by + exact selected_response_theoremA_graph hT 10 (by norm_num) weights W + weights_symmetric hs weights_nonnegative hn support_connected hc port b + port_cyclic hcyc 11 13 (by norm_num) (by norm_num) nonground_decay_band + delta delta_pos port_separation source_q_lt_one hData + +end C145.PaperApplication + +end diff --git a/LeanPool/C145/C145PaperDomainChecks.lean b/LeanPool/C145/C145PaperDomainChecks.lean new file mode 100644 index 0000000000..8498779e68 --- /dev/null +++ b/LeanPool/C145/C145PaperDomainChecks.lean @@ -0,0 +1,94 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8PositiveGridKernel +public import LeanPool.C145.C145GraphSpectralRealization + +/-! Application checks for the actual response and norm definitions. +The first is a counterexample to dropping positive-grid hypotheses: totalized +division hides a nonzero tensor at a pole. The second distinguishes the source +Frobenius norm from the ordinary function-space maximum norm. -/ + +@[expose] public section + +namespace C145.PaperChecks +open C145.H2 C145DRE8 +open scoped BigOperators + +/-- The one-mode tensor with its only entry equal to one. -/ +def unitTensor : Tensor 1 := fun _ _ _ => 1 +/-- The unit rate in the one-mode domain check. -/ +def unitRates : Fin 1 → ℝ := fun _ => 1 +/-- The unit overlap in the one-mode domain check. -/ +def unitOverlap : Fin 1 → ℝ := fun _ => 1 + +theorem response_at_pole : H unitRates unitTensor (-1) 1 = 0 := by + norm_num [H, unitRates, unitTensor, Fin.sum_univ_one] + +theorem response_at_positive_point : H unitRates unitTensor 1 1 = 1 / 12 := by + norm_num [H, unitRates, unitTensor, Fin.sum_univ_one] + +theorem nonpositive_grid_can_hide_nonzero_response : + positiveGridMap unitOverlap unitRates + (fun _ => -1) (fun _ => 1) (fromTensor unitTensor) = 0 ∧ + fromTensor unitTensor ∉ actualPositiveKernel unitOverlap unitRates := by + constructor + · ext p + change H unitRates (weightedTensor unitOverlap unitTensor) (-1) 1 = 0 + simp [weightedTensor, H, unitRates, unitOverlap, unitTensor] + · intro hz + have h := hz 1 1 (by norm_num) (by norm_num) + norm_num [responseMap_apply, weightedTensor, toTensor_fromTensor, + H, unitRates, unitOverlap, unitTensor, Fin.sum_univ_one] at h + +theorem constant_tensor_frobenius_sq : + ‖fromTensor (fun _ _ _ : Fin 2 => (1 : ℝ))‖ ^ 2 = 8 := by + rw [norm_fromTensor_sq] + norm_num [tensorSq, Fin.sum_univ_two] + +theorem constant_tensor_function_norm : + ‖(fun _ _ _ : Fin 2 => (1 : ℝ))‖ = 1 := by + change ‖(1 : Fin 2 → Fin 2 → Fin 2 → ℝ)‖ = 1 + exact norm_one + +/-- A constant port on three vertices cannot be cyclic for ANY graph +Laplacian. Thus the graph theorem's cyclicity condition rejects a genuine +unobservable-mode boundary, rather than accepting the zero-overlap case. -/ +theorem constant_port_not_cyclic + (μ : ℝ) (W : Matrix (Fin 3) (Fin 3) ℝ) : + ¬ C145.CyclicSpectral.KrylovCyclic + (C145.GraphSpectralRealization.generator μ W) (fun _ => 1) := by + open Matrix C145.WeightedGraph C145.GraphSpectralRealization in + intro hcyc + let A := generator μ W + let b : Fin 3 → ℝ := fun _ => 1 + have he : A *ᵥ b = (-μ) • b := by + change (-μ • (1 : Matrix (Fin 3) (Fin 3) ℝ) - laplacian W) *ᵥ b = _ + rw [Matrix.sub_mulVec, Matrix.smul_mulVec, Matrix.one_mulVec, + show laplacian W *ᵥ b = 0 from laplacian_const W 1] + simp + have hk : ∀ k : ℕ, A ^ k *ᵥ b = (-μ) ^ k • b := by + intro k + induction k with + | zero => simp + | succ k ih => + rw [pow_succ', ← Matrix.mulVec_mulVec, ih, Matrix.mulVec_smul, he, smul_smul] + congr 1 + have hz : (![1,-1,0] : Fin 3 → ℝ) = 0 := + C145.CyclicSpectral.cyclic_annihilator A b ![1,-1,0] hcyc (by + intro k + rw [hk] + norm_num [dotProduct, b, Fin.sum_univ_succ]) + have hv := congrFun hz 0 + norm_num at hv + +end C145.PaperChecks + +end diff --git a/LeanPool/C145/C145PaperPositiveWitness.lean b/LeanPool/C145/C145PaperPositiveWitness.lean new file mode 100644 index 0000000000..7cb4229f23 --- /dev/null +++ b/LeanPool/C145/C145PaperPositiveWitness.lean @@ -0,0 +1,193 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8OriginalGraphInverse + +/-! A nonvacuity control for the original-graph hypotheses of Theorem A. +The source is the three-vertex unit-weight path, with decay shift ten and +the Euclidean-normalized real port (1,2,4)/sqrt(21). No numerical test is used. +This is an application check, with no claim of new science or novelty. -/ + +@[expose] public section + +noncomputable section +namespace C145.PaperPositiveWitness +open scoped BigOperators +open Matrix C145.WeightedGraph C145.CyclicSpectral C145.GraphSpectralRealization + +/-- The unit weights on the edges of the three-vertex path. -/ +def weights : Matrix (Fin 3) (Fin 3) ℝ := !![0,1,0; 1,0,1; 0,1,0] +/-- The unnormalized separated port of the three-vertex witness. -/ +def rawPort : Fin 3 → ℝ := ![1,2,4] +/-- The Euclidean normalization of the three-vertex witness port. -/ +def port : Fin 3 → ℝ := (Real.sqrt 21)⁻¹ • rawPort +/-- The chosen port separation bound after normalization. -/ +def delta : ℝ := (Real.sqrt 21)⁻¹ +/-- The generator of the three-vertex witness with common decay ten. -/ +def A : Matrix (Fin 3) (Fin 3) ℝ := generator 10 weights + +theorem weights_symmetric : weights.IsSymm := by + apply Matrix.IsSymm.ext + intro i j + fin_cases i <;> fin_cases j <;> norm_num [weights] + +theorem weights_nonnegative : ∀ i j, 0 ≤ weights i j := by + intro i j + fin_cases i <;> fin_cases j <;> norm_num [weights] + +theorem support_connected : (supportGraph weights weights_symmetric).Connected := by + apply (SimpleGraph.connected_iff_exists_forall_reachable _).mpr + refine ⟨1, ?_⟩ + intro v + fin_cases v + · apply SimpleGraph.Adj.reachable + norm_num [supportGraph, weights] + · exact SimpleGraph.Reachable.refl _ + · apply SimpleGraph.Adj.reachable + norm_num [supportGraph, weights] + +theorem generator_explicit : A = !![-11,1,0; 1,-12,1; 0,1,-11] := by + ext i j + fin_cases i <;> fin_cases j <;> + norm_num [A, generator, laplacian, weights, Fin.sum_univ_succ] + +theorem raw_first_krylov : A *ᵥ rawPort = ![-9,-19,-42] := by + rw [generator_explicit] + ext i + fin_cases i <;> norm_num [rawPort, Matrix.mulVec, dotProduct, Fin.sum_univ_succ] + +theorem raw_second_krylov : A ^ 2 *ᵥ rawPort = ![80,177,443] := by + rw [pow_two, ← Matrix.mulVec_mulVec, raw_first_krylov, generator_explicit] + ext i + fin_cases i <;> norm_num [Matrix.mulVec, dotProduct, Fin.sum_univ_succ] + +theorem raw_port_cyclic : KrylovCyclic A rawPort := by + let S := Submodule.span ℝ (Set.range (fun k : ℕ => A ^ k *ᵥ rawPort)) + have h0 : rawPort ∈ S := by + simpa using (Submodule.subset_span (Set.mem_range_self 0) : A ^ 0 *ᵥ rawPort ∈ S) + have h1 : ![-9,-19,-42] ∈ S := by + simpa [pow_one, raw_first_krylov] using + (Submodule.subset_span (Set.mem_range_self 1) : A ^ 1 *ᵥ rawPort ∈ S) + have h2 : ![80,177,443] ∈ S := by + simpa [raw_second_krylov] using + (Submodule.subset_span (Set.mem_range_self 2) : A ^ 2 *ᵥ rawPort ∈ S) + apply top_unique + intro x _ + have hx : x = + ((983 * x 0-627 * x 1 + 73 * x 2) / 21) • rawPort + + ((178 * x 0-123 * x 1 + 17 * x 2) / 21) • ![-9,-19,-42] + + ((8 * x 0-6 * x 1 + x 2) / 21) • ![80,177,443] := by + ext i + fin_cases i <;> simp [rawPort] <;> ring + rw [hx] + exact S.add_mem (S.add_mem (S.smul_mem _ h0) (S.smul_mem _ h1)) (S.smul_mem _ h2) + +theorem sqrt_pos : 0 < Real.sqrt (21 : ℝ) := Real.sqrt_pos.2 (by norm_num) + +theorem port_cyclic : KrylovCyclic (generator 10 weights) port := by + have hs : Real.sqrt (21 : ℝ) ≠ 0 := ne_of_gt sqrt_pos + change Submodule.span ℝ (Set.range (fun k : ℕ => A ^ k *ᵥ port)) = ⊤ + apply top_unique + rw [← raw_port_cyclic] + apply Submodule.span_le.mpr + rintro _ ⟨k,rfl⟩ + have hk : A ^ k *ᵥ rawPort = Real.sqrt 21 • (A ^ k *ᵥ port) := by + simp [port, Matrix.mulVec_smul, smul_smul, hs] + change A ^ k *ᵥ rawPort ∈ _ + rw [hk] + exact Submodule.smul_mem _ _ (Submodule.subset_span (Set.mem_range_self k)) + +theorem delta_pos : 0 < delta := inv_pos.2 sqrt_pos + +theorem delta_sq : delta ^ 2 = (1 : ℝ) / 21 := by + unfold delta + rw [inv_pow, Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 21)] + norm_num + +theorem port_normalized : (∑ i, (port i) ^ 2) = 1 := by + have hd := delta_sq + change (∑ i, (delta * rawPort i) ^ 2) = 1 + norm_num [rawPort, Fin.sum_univ_succ] at * + nlinarith + +theorem port_separation : ∀ j k : Fin 3, j ≠ k → + delta ^ 2 ≤ (port j-port k) ^ 2 := by + intro j k hjk + change delta ^ 2 ≤ (delta * rawPort j-delta * rawPort k) ^ 2 + fin_cases j <;> fin_cases k <;> norm_num [rawPort] at * <;> nlinarith [sq_nonneg delta] + +theorem source_q_exact : C145DRE8.sourceQChebyshevSq port 11 13 delta = + (35 : ℝ) / 12754584 := by + have hn : delta ≠ 0 := ne_of_gt delta_pos + have hp : ∀ v, port v = delta * rawPort v := fun _ => rfl + unfold C145DRE8.sourceQChebyshevSq C145DRE8.centeredPort + simp_rw [hp] + norm_num [rawPort, Fin.sum_univ_succ] + field_simp [hn]; ring + +theorem source_q_lt_one : C145DRE8.sourceQChebyshevSq port 11 13 delta < 1 := by + rw [source_q_exact] + norm_num + +/-- Exact original-matrix nonground spectral band, derived from all eigenvectors. -/ +theorem nonground_decay_band : C145DRE8.NonGroundDecayBand 10 weights 11 13 := by + intro r x hx he hr + change A *ᵥ x = (-r) • x at he + rw [generator_explicit] at he + have h0 : (r-11) * x 0 + x 1 = 0 := by + have hh := congrFun he 0 + simp [Matrix.mulVec, dotProduct, Fin.sum_univ_succ] at hh + linarith + have h1 : x 0 + (r-12) * x 1 + x 2 = 0 := by + have hh := congrFun he 1 + simp [Matrix.mulVec, dotProduct, Fin.sum_univ_succ] at hh + linarith + have h2 : x 1 + (r-11) * x 2 = 0 := by + have hh := congrFun he 2 + simp [Matrix.mulVec, dotProduct, Fin.sum_univ_succ] at hh + linarith + have hx0 : x 0 ≠ 0 := by + intro hz + have hz1 : x 1 = 0 := by simpa [hz] using h0 + have hz2 : x 2 = 0 := by simpa [hz, hz1] using h1 + apply hx + ext i + fin_cases i <;> simp_all + have hp : (r-10) * (r-11) * (r-13) * x 0 = 0 := by + linear_combination ((r-11) * (r-12)-1) * h0 - (r-11) * h1 + h2 + have hp' : (r-10) * (r-11) * (r-13) = 0 := (mul_eq_zero.mp hp).resolve_right hx0 + rcases mul_eq_zero.mp hp' with h | h + · rcases mul_eq_zero.mp h with h | h + · exact (hr (sub_eq_zero.mp h)).elim + · have : r = 11 := sub_eq_zero.mp h + subst r + norm_num + · have : r = 13 := sub_eq_zero.mp h + subst r + norm_num + +/-- The concrete graph meets every graph-side structural/criterion premise of +Theorem A; the equal-response premise still refers to actual response jets. -/ +theorem theoremA_source_witness : + weights.IsSymm ∧ (∀ i j, 0 ≤ weights i j) ∧ + (supportGraph weights weights_symmetric).Connected ∧ + KrylovCyclic (generator 10 weights) port ∧ + (∑ i, (port i) ^ 2) = 1 ∧ + (11 : ℝ) < 13 ∧ (13 : ℝ) < 2 * 11 ∧ + C145DRE8.NonGroundDecayBand 10 weights 11 13 ∧ + 0 < delta ∧ (∀ j k : Fin 3, j ≠ k → delta ^ 2 ≤ (port j-port k) ^ 2) ∧ + C145DRE8.sourceQChebyshevSq port 11 13 delta < 1 := by + exact ⟨weights_symmetric, weights_nonnegative, support_connected, port_cyclic, + port_normalized, by norm_num, by norm_num, nonground_decay_band, + delta_pos, port_separation, source_q_lt_one⟩ + +end C145.PaperPositiveWitness + +end diff --git a/LeanPool/C145/C145PaperRealizationInvariance.lean b/LeanPool/C145/C145PaperRealizationInvariance.lean new file mode 100644 index 0000000000..b69b831158 --- /dev/null +++ b/LeanPool/C145/C145PaperRealizationInvariance.lean @@ -0,0 +1,216 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145GraphSpectralRealization + +/-! Any two actual positively oriented realizations of one graph and port +have the same columns, rates and actual overlaps after a derived permutation. +The permutation fixes ground and restricts to the nonground coordinates. -/ + +@[expose] public section + +noncomputable section +namespace C145.PaperRealizationInvariance +open scoped BigOperators +open Matrix C145.GraphSpectralRealization + +private theorem frame_expansion {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (x : Fin (n + 1) → ℝ) (v : Fin (n + 1)) : + (∑ j, Q v j * ((fun w => Q w j) ⬝ᵥ x)) = x v := by + unfold dotProduct + simp_rw [Finset.mul_sum] + rw [Finset.sum_comm] + calc + (∑ w, ∑ j, Q v j * (Q w j * x w)) = + ∑ w, (∑ j, Q v j * Q w j) * x w := by + apply Finset.sum_congr rfl + intro w _ + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro j _ + ring + _ = x v := by + simp_rw [C145PhysicalFrame.columnOrthonormal_rowComplete Q hQ v] + simp + +variable {n : ℕ} {μ : ℝ} + {W : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ} {b : Fin (n + 1) → ℝ} + +private theorem realization_generator_symm (S : OrientedRealization μ W b) : + (generator μ W).IsSymm := by + rw [← S.original_generator] + apply Matrix.IsSymm.ext + intro v w + unfold C145CoordinatePermutation.spectralGenerator + congr 1 + apply Finset.sum_congr rfl + intro i _ + ring + +private theorem cross_overlap_zero (S0 S1 : OrientedRealization μ W b) + (i j : Fin (n + 1)) (h : S1.rates j ≠ S0.rates i) : + (fun v => S1.Q v j) ⬝ᵥ (fun v => S0.Q v i) = 0 := by + have hs := realization_generator_symm S0 + have he := hs.dotProduct_mulVec_comm + (x := fun v => S1.Q v j) (y := fun v => S0.Q v i) + rw [S0.eigenvectors i, S1.eigenvectors j, dotProduct_smul, + dotProduct_smul, dotProduct_comm (fun v => S0.Q v i) (fun v => S1.Q v j)] at he + change -S0.rates i * _ = -S1.rates j * _ at he + exact (mul_eq_zero.mp (by nlinarith : + (S1.rates j - S0.rates i) * + ((fun v => S1.Q v j) ⬝ᵥ (fun v => S0.Q v i)) = 0)).resolve_left + (sub_ne_zero.mpr h) + +/-- Every rate of either realization is actually a rate of the other one. -/ +theorem realization_rate_exists (S0 S1 : OrientedRealization μ W b) + (i : Fin (n + 1)) : ∃ j, S1.rates j = S0.rates i := by + by_contra h + have hz : ∀ j, (fun v => S1.Q v j) ⬝ᵥ (fun v => S0.Q v i) = 0 := by + intro j + apply cross_overlap_zero S0 S1 i j + exact fun hj => h ⟨j, hj⟩ + have hcol : ∀ v, S0.Q v i = 0 := by + intro v + have hx := frame_expansion S1.Q S1.orthonormal (fun w => S0.Q w i) v + simpa only [hz, mul_zero, Finset.sum_const_zero] using hx.symm + have hh := S0.orthonormal i i + simp [hcol] at hh + +/-- Simple spectrum, normalization and positive actual port overlaps force +literal equality, including the sign, of columns with equal rates. -/ +theorem realization_columns_eq_of_rate_eq (S0 S1 : OrientedRealization μ W b) + (i j : Fin (n + 1)) (hr : S1.rates j = S0.rates i) : + ∀ v, S1.Q v j = S0.Q v i := by + let a : ℝ := (fun v => S1.Q v j) ⬝ᵥ (fun v => S0.Q v i) + have hcol : ∀ v, S0.Q v i = a * S1.Q v j := by + intro v + have hx := frame_expansion S1.Q S1.orthonormal (fun w => S0.Q w i) v + have hsum : (∑ k, S1.Q v k * + ((fun w => S1.Q w k) ⬝ᵥ (fun w => S0.Q w i))) = S1.Q v j * a := by + apply Finset.sum_eq_single j + · intro k _ hkj + rw [cross_overlap_zero S0 S1 i k (by + intro hk + exact hkj (S1.simple (hk.trans hr.symm)))] + exact mul_zero _ + · intro hj + exact (hj (Finset.mem_univ j)).elim + rw [hsum] at hx + exact hx.symm.trans (mul_comm _ _) + have haa : a * a = 1 := by + have h0 : (∑ v, S0.Q v i * S0.Q v i) = 1 := by + simpa using S0.orthonormal i i + have h1 : (∑ v, S1.Q v j * S1.Q v j) = 1 := by + simpa using S1.orthonormal j j + calc + a * a = a * a * (∑ v, S1.Q v j * S1.Q v j) := by rw [h1, mul_one] + _ = ∑ v, S0.Q v i * S0.Q v i := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro v _ + rw [hcol] + ring + _ = 1 := h0 + have hov : C145.Pulse.modalOverlap S0.Q b i = + a * C145.Pulse.modalOverlap S1.Q b j := by + unfold C145.Pulse.modalOverlap + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro v _ + rw [hcol] + ring + have hp0 := S0.positive_overlap i + have hp1 := S1.positive_overlap j + rw [hov] at hp0 + have ha : 0 < a := (mul_pos_iff_of_pos_right hp1).mp hp0 + have ha1 : a = 1 := by nlinarith + intro v + simpa only [ha1, one_mul] using (hcol v).symm + +/-- The modal relabeling is derived from the actual common generator, rather +than assumed as an additional equivalence premise. -/ +theorem realizations_equivalent (S0 S1 : OrientedRealization μ W b) : + ∃ e : Fin (n + 1) ≃ Fin (n + 1), + e 0 = 0 ∧ (∀ i, S1.rates (e i) = S0.rates i) ∧ + (∀ v i, S1.Q v (e i) = S0.Q v i) ∧ + (∀ i, C145.Pulse.modalOverlap S1.Q b (e i) = + C145.Pulse.modalOverlap S0.Q b i) ∧ S0.c = S1.c := by + choose f hf using realization_rate_exists S0 S1 + have hinj : Function.Injective f := by + intro i j hij + apply S0.simple + rw [← hf i, ← hf j, hij] + let e : Fin (n + 1) ≃ Fin (n + 1) := Equiv.ofBijective f + ((Fintype.bijective_iff_injective_and_card f).mpr ⟨hinj, rfl⟩) + have he : ∀ i, S1.rates (e i) = S0.rates i := hf + have he0 : e 0 = 0 := by + apply S1.simple + rw [he, S0.ground_rate, S1.ground_rate] + have hQ : ∀ v i, S1.Q v (e i) = S0.Q v i := + fun v i => realization_columns_eq_of_rate_eq S0 S1 i (e i) (he i) v + refine ⟨e, he0, he, hQ, ?_, ?_⟩ + · intro i + unfold C145.Pulse.modalOverlap + simp_rw [hQ] + · have h := hQ 0 0 + rw [he0, S0.ground, S1.ground] at h + exact h.symm + +/-- Any permutation fixing ground has an actual permutation of `Fin n` whose +successor coordinates commute with the original permutation. -/ +def nongroundEquiv (e : Fin (n + 1) ≃ Fin (n + 1)) (he0 : e 0 = 0) : Fin n ≃ Fin n := by + have hn : ∀ i : Fin n, e i.succ ≠ 0 := by + intro i h + exact Fin.succ_ne_zero i (e.injective (h.trans he0.symm)) + let f : Fin n → Fin n := fun i => (e i.succ).pred (hn i) + have hf : ∀ i, (f i).succ = e i.succ := fun i => Fin.succ_pred _ _ + have hi : Function.Injective f := by + intro i j h + apply Fin.succ_injective + apply e.injective + rw [← hf i, ← hf j, h] + exact Equiv.ofBijective f + ((Fintype.bijective_iff_injective_and_card f).mpr ⟨hi, rfl⟩) + +@[simp] theorem nongroundEquiv_succ (e : Fin (n + 1) ≃ Fin (n + 1)) + (he0 : e 0 = 0) (i : Fin n) : + (nongroundEquiv e he0 i).succ = e i.succ := by + have hn : e i.succ ≠ 0 := fun h => + Fin.succ_ne_zero i (e.injective (h.trans he0.symm)) + change ((e i.succ).pred hn).succ = e i.succ + exact Fin.succ_pred _ hn + +/-- Practical full and nonground matching package for ordering-independent +paper quantities. It includes the literal columns and the positive overlaps. -/ +theorem realizations_full_and_nonground_equivalent + (S0 S1 : OrientedRealization μ W b) : + ∃ (e : Fin (n + 1) ≃ Fin (n + 1)) (p : Fin n ≃ Fin n), + e 0 = 0 ∧ (∀ i, (p i).succ = e i.succ) ∧ + (∀ i, S1.rates (e i) = S0.rates i) ∧ + (∀ v i, S1.Q v (e i) = S0.Q v i) ∧ + (∀ i, C145.Pulse.modalOverlap S1.Q b (e i) = + C145.Pulse.modalOverlap S0.Q b i) ∧ + (∀ i : Fin n, S1.rates (p i).succ = S0.rates i.succ) ∧ + (∀ v (i : Fin n), S1.Q v (p i).succ = S0.Q v i.succ) ∧ + (∀ i : Fin n, C145.Pulse.modalOverlap S1.Q b (p i).succ = + C145.Pulse.modalOverlap S0.Q b i.succ) ∧ S0.c = S1.c := by + obtain ⟨e, he0, hr, hQ, ha, hc⟩ := realizations_equivalent S0 S1 + let p := nongroundEquiv e he0 + have hp : ∀ i : Fin n, (p i).succ = e i.succ := nongroundEquiv_succ e he0 + refine ⟨e, p, he0, hp, hr, hQ, ha, ?_, ?_, ?_, hc⟩ + · intro i; rw [hp]; exact hr i.succ + · intro v i; rw [hp]; exact hQ v i.succ + · intro i; rw [hp]; exact ha i.succ + +end C145.PaperRealizationInvariance + +end diff --git a/LeanPool/C145/C145PaperResidualInvariance.lean b/LeanPool/C145/C145PaperResidualInvariance.lean new file mode 100644 index 0000000000..bef861961a --- /dev/null +++ b/LeanPool/C145/C145PaperResidualInvariance.lean @@ -0,0 +1,145 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8JointSignatureInverse + +/-! +# Invariance of the manuscript's weighted residual and joint constants + +The manuscript's `v_p = (a_i t_i^p)` uses an enumeration of non-ground modal +coordinates. Simultaneously reindexing the weights `a` and nodes `t` does not +change the literal weighted least-squares objective, its attained minimum +`kappa^2`, or the resulting joint constants in Theorem C. + +The proof uses the accepted global minimality and attainment theorems for the +actual orthogonal projection. No chosen projection coefficients, independence +of the first three moments, or positive/nonzero weights are assumptions. +-/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators + +variable {m n : ℕ} + +/-- The exact weighted objective in the manuscript is independent of the +enumeration of the modal pairs `(a_i, t_i)`. -/ +theorem weighted_least_squares_sum_reindex (e : Fin m ≃ Fin n) + (a t : Fin n → ℝ) (p : ℕ) (c0 c1 c2 : ℝ) : + (∑ i : Fin m, a (e i) ^ 2 * + (t (e i) ^ p-c0-c1 * t (e i)-c2 * t (e i) ^ 2) ^ 2) = + ∑ i : Fin n, a i ^ 2 * (t i ^ p-c0-c1 * t i-c2 * t i ^ 2) ^ 2 := by + exact e.sum_comp (fun i => a i ^ 2 * (t i ^ p-c0-c1 * t i-c2 * t i ^ 2) ^ 2) + +/-- The product-square form used by the accepted projection-minimality +interface has the same finite-coordinate invariance. -/ +theorem quadratic_residual_sum_reindex (e : Fin m ≃ Fin n) + (a t : Fin n → ℝ) (p : ℕ) (c0 c1 c2 : ℝ) : + (∑ i : Fin m, + (a (e i) * (t (e i) ^ p-(c0 + c1 * t (e i) + c2 * t (e i) ^ 2))) ^ 2) = + ∑ i : Fin n, (a i * (t i ^ p-(c0 + c1 * t i + c2 * t i ^ 2))) ^ 2 := by + exact e.sum_comp (fun i => (a i * (t i ^ p-(c0 + c1 * t i + c2 * t i ^ 2))) ^ 2) + +/-- The true least-squares minimum is unchanged by a simultaneous modal +reindexing. The two inequalities use attained minimizers of the two actual +projection problems, rather than supplied coefficients or certificates. -/ +theorem kappa_sq_reindex (e : Fin m ≃ Fin n) + (a t : Fin n → ℝ) (p : ℕ) : + kappa (a ∘ e) (t ∘ e) p ^ 2 = kappa a t p ^ 2 := by + apply le_antisymm + · obtain ⟨c0, c1, c2, hc⟩ := exists_kappa_coefficients a t p + calc + kappa (a ∘ e) (t ∘ e) p ^ 2 ≤ + ∑ i : Fin m, + (a (e i) * (t (e i) ^ p-(c0 + c1 * t (e i) + c2 * t (e i) ^ 2))) ^ 2 := + kappa_sq_le_quadratic_residual (a ∘ e) (t ∘ e) p c0 c1 c2 + _ = ∑ i : Fin n, (a i * (t i ^ p-(c0 + c1 * t i + c2 * t i ^ 2))) ^ 2 := + quadratic_residual_sum_reindex e a t p c0 c1 c2 + _ = kappa a t p ^ 2 := hc + · obtain ⟨c0, c1, c2, hc⟩ := exists_kappa_coefficients (a ∘ e) (t ∘ e) p + calc + kappa a t p ^ 2 ≤ + ∑ i : Fin n, (a i * (t i ^ p-(c0 + c1 * t i + c2 * t i ^ 2))) ^ 2 := + kappa_sq_le_quadratic_residual a t p c0 c1 c2 + _ = ∑ i : Fin m, + (a (e i) * (t (e i) ^ p-(c0 + c1 * t (e i) + c2 * t (e i) ^ 2))) ^ 2 := + (quadratic_residual_sum_reindex e a t p c0 c1 c2).symm + _ = kappa (a ∘ e) (t ∘ e) p ^ 2 := hc + +/-- The manuscript's nonnegative residual norm itself is invariant. -/ +theorem kappa_reindex (e : Fin m ≃ Fin n) + (a t : Fin n → ℝ) (p : ℕ) : + kappa (a ∘ e) (t ∘ e) p = kappa a t p := by + have hs := kappa_sq_reindex e a t p + have h0 := kappa_nonneg (a ∘ e) (t ∘ e) p + have h1 := kappa_nonneg a t p + nlinarith + +/-- All three literal Theorem C numerators are invariant, retaining the +distinct residuals `kappa_3`, `kappa_4`, and `kappa_5`. -/ +theorem jointNumerator_reindex (e : Fin m ≃ Fin n) + (a t : Fin n → ℝ) (theta : ℝ) : + jointNumerator (a ∘ e) (t ∘ e) theta = jointNumerator a t theta := by + simp only [jointNumerator, kappa_reindex] + +/-- Each of the three literal constants `beta_r` is invariant. -/ +theorem jointBeta_reindex (e : Fin m ≃ Fin n) + (a t : Fin n → ℝ) (theta : ℝ) (r : Fin 3) : + jointBeta (a ∘ e) (t ∘ e) theta r = jointBeta a t theta r := by + rw [jointBeta, jointBeta, jointNumerator_reindex e a t theta] + +/-- The sum of the squares of the three Theorem C constants is invariant. -/ +theorem jointBetaSq_reindex (e : Fin m ≃ Fin n) + (a t : Fin n → ℝ) (theta : ℝ) : + jointBetaSq (a ∘ e) (t ∘ e) theta = jointBetaSq a t theta := by + simp only [jointBetaSq, jointBeta_reindex] + +/-- The manuscript's joint norm `beta` is invariant. -/ +theorem jointBetaNorm_reindex (e : Fin m ≃ Fin n) + (a t : Fin n → ℝ) (theta : ℝ) : + jointBetaNorm (a ∘ e) (t ∘ e) theta = jointBetaNorm a t theta := by + rw [jointBetaNorm, jointBetaNorm, jointBetaSq_reindex e a t theta] + +/-- Pointwise coordinate transport is enough to identify residuals of two +enumerated modal data sets. -/ +theorem kappa_eq_of_reindex (e : Fin m ≃ Fin n) + (a0 t0 : Fin m → ℝ) (a1 t1 : Fin n → ℝ) + (ha : ∀ i, a0 i = a1 (e i)) (ht : ∀ i, t0 i = t1 (e i)) (p : ℕ) : + kappa a0 t0 p = kappa a1 t1 p := by + have ha' : a0 = a1 ∘ e := funext ha + have ht' : t0 = t1 ∘ e := funext ht + rw [ha', ht', kappa_reindex e a1 t1 p] + +/-- Pointwise coordinate transport preserves exactly the joint squared +constant used by the accepted original-graph criterion. -/ +theorem jointBetaSq_eq_of_reindex (e : Fin m ≃ Fin n) + (a0 t0 : Fin m → ℝ) (a1 t1 : Fin n → ℝ) + (ha : ∀ i, a0 i = a1 (e i)) (ht : ∀ i, t0 i = t1 (e i)) (theta : ℝ) : + jointBetaSq a0 t0 theta = jointBetaSq a1 t1 theta := by + have ha' : a0 = a1 ∘ e := funext ha + have ht' : t0 = t1 ∘ e := funext ht + rw [ha', ht', jointBetaSq_reindex e a1 t1 theta] + +/-- The same data-level transport also preserves the joint norm appearing +in the manuscript's strict identification bound. -/ +theorem jointBetaNorm_eq_of_reindex (e : Fin m ≃ Fin n) + (a0 t0 : Fin m → ℝ) (a1 t1 : Fin n → ℝ) + (ha : ∀ i, a0 i = a1 (e i)) (ht : ∀ i, t0 i = t1 (e i)) (theta : ℝ) : + jointBetaNorm a0 t0 theta = jointBetaNorm a1 t1 theta := by + have ha' : a0 = a1 ∘ e := funext ha + have ht' : t0 = t1 ∘ e := funext ht + rw [ha', ht', jointBetaNorm_reindex e a1 t1 theta] + + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145PaperStability.lean b/LeanPool/C145/C145PaperStability.lean new file mode 100644 index 0000000000..6abab2d573 --- /dev/null +++ b/LeanPool/C145/C145PaperStability.lean @@ -0,0 +1,159 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DRE8PhysicalStability + +/-! Paper-facing Theorem E: the least measurement gain is an attained, +positive minimum derived from the actual grid and cyclic source overlaps. +The signatures below live in source vertex coordinates. Calibration is exact; +this result does not assert recovery from perturbed calibration or noisy jets. -/ + +@[expose] public section + +noncomputable section +namespace C145DRE8 +open scoped BigOperators +open C145.H2 +variable {n : ℕ} {ρ : Type*} [Fintype ρ] + +omit [Fintype ρ] in +/-- Modal coordinates of a source vertex signature reconstruct that very +signature under the actual orthonormal source frame. -/ +theorem paper_signature_reconstruction + (U : Fin (n + 1) → Fin (n + 1) → ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (h : ρ → Fin (n + 1) → ℝ) : + (fun r => (Matrix.of U).mulVec (C145.Pulse.modalOverlap U (h r))) = h := by + funext r v + have hr := congrFun + (C145.UncalibratedSmallH2.spectralPort_modalOverlap U (h r) hU) v + simpa only [Matrix.mulVec, dotProduct, Matrix.of_apply, + C145CoordinatePermutation.spectralPort, mul_comm] using hr + +/-- B_H is literally the Euclidean norm of the source vertex signature family; +moving the signatures into the modal tensor coordinates preserves it. -/ +theorem paper_signatureNorm_modal + (U : Fin (n + 1) → Fin (n + 1) → ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (h : ρ → Fin (n + 1) → ℝ) : + signatureNorm (fun r => C145.Pulse.modalOverlap U (h r)) = signatureNorm h := by + have hr := signatureNorm_rotate (Matrix.of U) (columnOrthonormal_matrix U hU) + (fun r => C145.Pulse.modalOverlap U (h r)) + rw [paper_signature_reconstruction U hU h] at hr + exact hr.symm + +/-- The measured vector contains the literal ideal H2 differences of the +actual two frames and their own actual ports. Its ambient norm is Euclidean. +Overlap weights remain inside T, never in the tensor Frobenius norm. -/ +def paperH2SampleDifference + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) + (b b' rates : Fin (n + 1) → ℝ) + (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) : + EuclideanSpace ℝ (Fin (2 * (n + 1)-1) × Fin (2 * (n + 1)-1)) := + WithLp.toLp 2 (fun p => + H rates (C145PhysicalFrame.T V (C145.Pulse.modalOverlap V b')) + (sNodes p.1) (tNodes p.2) - + H rates (C145PhysicalFrame.T U (C145.Pulse.modalOverlap U b)) + (sNodes p.1) (tNodes p.2)) + +/-- Exact overlap calibration identifies the abstract grid vector with the +actual own-port second-transfer differences, without assuming H2 equality. -/ +theorem paperH2SampleDifference_eq_grid + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) + (b b' rates : Fin (n + 1) → ℝ) + (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) + (hcalibration : C145.Pulse.modalOverlap V b' = C145.Pulse.modalOverlap U b) : + paperH2SampleDifference U V b b' rates sNodes tNodes = + positiveGridMap (C145.Pulse.modalOverlap U b) rates sNodes tNodes + (fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U)) := by + ext p + change H rates (C145PhysicalFrame.T V (C145.Pulse.modalOverlap V b')) + (sNodes p.1) (tNodes p.2) - + H rates (C145PhysicalFrame.T U (C145.Pulse.modalOverlap U b)) + (sNodes p.1) (tNodes p.2) = _ + rw [hcalibration] + exact (actual_grid_coordinate_physical_response + (C145.Pulse.modalOverlap U b) rates sNodes tNodes U V p).symm + +/-- Paper Theorem E with no caller-supplied singular gain or complement +nontriviality certificate. Here N=n+1≥3. Source/competitor frames are actual +orthonormal frames with the same constant signed ground column. Their rates +are common and positive, and their own port overlaps are exactly calibrated. + +The positive separation lower bound delta, beta≥0, the universal kernel bundle +estimate and q<1 are precisely the remaining manuscript premises. The kernel +and its orthogonal complement are taken inside V0. The conclusion supplies a +positive attained least gain, its unit-sphere minimality, its homogeneous gain +bound, and the literal unweighted Frobenius/Euclidean physical stability bound. +No equality of the two H2 responses is required. -/ +theorem paper_fixed_calibration_stability + (hN : 3 ≤ n + 1) + (U V : Fin (n + 1) → Fin (n + 1) → ℝ) (c : ℝ) + (hU : C145PhysicalFrame.ColumnOrthonormal U) + (hV : C145PhysicalFrame.ColumnOrthonormal V) + (hGU : ∀ v, U v 0 = c) (hGV : ∀ v, V v 0 = c) + (b b' rates : Fin (n + 1) → ℝ) + (ha : ∀ i, 0 < C145.Pulse.modalOverlap U b i) + (hcalibration : C145.Pulse.modalOverlap V b' = C145.Pulse.modalOverlap U b) + (hRates : ∀ i, 0 < rates i) + (sNodes tNodes : Fin (2 * (n + 1) - 1) → ℝ) + (hsNodes : Function.Injective sNodes) (htNodes : Function.Injective tNodes) + (hsPos : ∀ i, 0 < sNodes i) (htPos : ∀ i, 0 < tNodes i) + (h : ρ → Fin (n + 1) → ℝ) (delta beta : ℝ) + (hd : 0 < delta) (hb : 0 ≤ beta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ signatureSq h j k) + (hq : Real.sqrt ((n + 1 : ℕ) + 2) * beta / delta < 1) + (hkernel : ∀ k : physicalDifferenceSpace n, + k ∈ physicalH2Kernel (C145.Pulse.modalOverlap U b) rates → + ‖physicalSliceBundle (fun r => C145.Pulse.modalOverlap U (h r)) k‖ ≤ beta * ‖k‖) : + ∃ (sigma : ℝ) (u : (physicalH2Kernel (C145.Pulse.modalOverlap U b) rates)ᗮ), + 0 < sigma ∧ ‖u‖ = 1 ∧ + ‖physicalGridMap (C145.Pulse.modalOverlap U b) rates sNodes tNodes + (u : physicalDifferenceSpace n)‖ = sigma ∧ + (∀ v : (physicalH2Kernel (C145.Pulse.modalOverlap U b) rates)ᗮ, ‖v‖ = 1 → + sigma ≤ ‖physicalGridMap (C145.Pulse.modalOverlap U b) rates sNodes tNodes + (v : physicalDifferenceSpace n)‖) ∧ + (∀ r : physicalDifferenceSpace n, + r ∈ (physicalH2Kernel (C145.Pulse.modalOverlap U b) rates)ᗮ → + sigma * ‖r‖ ≤ ‖physicalGridMap (C145.Pulse.modalOverlap U b) rates sNodes tNodes r‖) ∧ + Real.sqrt (tensorSq (C145PhysicalFrame.C V-C145PhysicalFrame.C U)) ≤ + (Real.sqrt ((n + 1 : ℕ) + 2) * signatureNorm h / + (delta * (1-Real.sqrt ((n + 1 : ℕ) + 2) * beta / delta) * sigma)) * + ‖paperH2SampleDifference U V b b' rates sNodes tNodes‖ := by + let i : Fin (n + 1) := ⟨1, by omega⟩ + have hi : i ≠ 0 := by + intro heq + have hv := congrArg Fin.val heq + norm_num [i] at hv + obtain ⟨sigma, u, hsigma, hu, hvalue, hminimal, hgain⟩ := + physicalGrid_exists_least_gain_of_nonzero_overlap + (C145.Pulse.modalOverlap U b) rates hRates sNodes tNodes + hsNodes htNodes hsPos htPos i hi (ne_of_gt (ha i)) + refine ⟨sigma, u, hsigma, hu, hvalue, hminimal, hgain, ?_⟩ + have hmodalSep : ∀ j k, j ≠ k → delta ^ 2 ≤ + signatureSq (fun r => (Matrix.of U).mulVec (C145.Pulse.modalOverlap U (h r))) j k := by + rw [paper_signature_reconstruction U hU h] + exact hsep + have hbound := actual_calibrated_grid_stability + (C145.Pulse.modalOverlap U b) rates hRates sNodes tNodes + hsNodes htNodes hsPos htPos U V c hU hV hGU hGV + (fun r => C145.Pulse.modalOverlap U (h r)) delta beta sigma + hd hb hsigma hmodalSep hq hgain hkernel + rw [paper_signatureNorm_modal U hU h] at hbound + rw [paperH2SampleDifference_eq_grid U V b b' rates sNodes tNodes hcalibration] + have hFrob : Real.sqrt (tensorSq (C145PhysicalFrame.C V-C145PhysicalFrame.C U)) = + ‖fromTensor (C145PhysicalFrame.C V-C145PhysicalFrame.C U)‖ := by + rw [←norm_fromTensor_sq, Real.sqrt_sq (norm_nonneg _)] + rw [hFrob] + exact hbound + +end C145DRE8 + +end diff --git a/LeanPool/C145/C145PaperTheoremC.lean b/LeanPool/C145/C145PaperTheoremC.lean new file mode 100644 index 0000000000..24587bc0e0 --- /dev/null +++ b/LeanPool/C145/C145PaperTheoremC.lean @@ -0,0 +1,141 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145PaperResidualInvariance +public import LeanPool.C145.C145PaperRealizationInvariance +public import LeanPool.C145.C145PaperActualResponse +public import LeanPool.C145.C145DRE8JointOriginalGraph + +/-! Theorem C's criterion is independent of the chosen oriented eigenbasis. +The application accepts the displayed square-root criterion computed in ANY +actual source realization, including the manuscript's increasing-rate basis. +No all-realizations criterion, response-existence premise or reconstruction +certificate is required. -/ + +@[expose] public section + +noncomputable section +namespace C145.PaperTheoremC +open Matrix C145.WeightedGraph C145.CyclicSpectral + C145.GraphSpectralRealization C145.ActualResponse + C145.PaperActualResponse C145DRE8 +open scoped BigOperators Topology ContDiff + +theorem realization_kappa_eq {m : ℕ} {μ : ℝ} + {W : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ} {b : State m} + (S0 S1 : OrientedRealization μ W b) (ell u : ℝ) (k : ℕ) : + kappa (fun i : Fin m => C145.Pulse.modalOverlap S0.Q b i.succ) + (fun i => (S0.rates i.succ-ell) / (u-ell)) k = + kappa (fun i : Fin m => C145.Pulse.modalOverlap S1.Q b i.succ) + (fun i => (S1.rates i.succ-ell) / (u-ell)) k := by + obtain ⟨e, p, he0, hp, hr, hQ, ha, hrN, hQN, haN, hc⟩ := + C145.PaperRealizationInvariance.realizations_full_and_nonground_equivalent S0 S1 + apply kappa_eq_of_reindex p + · intro i; exact (haN i).symm + · intro i; rw [hrN] + +theorem realization_jointBetaSq_eq {m : ℕ} {μ : ℝ} + {W : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ} {b : State m} + (S0 S1 : OrientedRealization μ W b) (ell u : ℝ) : + jointBetaSq (fun i : Fin m => C145.Pulse.modalOverlap S0.Q b i.succ) + (fun i => (S0.rates i.succ-ell) / (u-ell)) (ell / (u-ell)) = + jointBetaSq (fun i : Fin m => C145.Pulse.modalOverlap S1.Q b i.succ) + (fun i => (S1.rates i.succ-ell) / (u-ell)) (ell / (u-ell)) := by + obtain ⟨e, p, he0, hp, hr, hQ, ha, hrN, hQN, haN, hc⟩ := + C145.PaperRealizationInvariance.realizations_full_and_nonground_equivalent S0 S1 + apply jointBetaSq_eq_of_reindex p + · intro i; exact (haN i).symm + · intro i; rw [hrN] + +theorem realization_jointBetaNorm_eq {m : ℕ} {μ : ℝ} + {W : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ} {b : State m} + (S0 S1 : OrientedRealization μ W b) (ell u : ℝ) : + jointBetaNorm (fun i : Fin m => C145.Pulse.modalOverlap S0.Q b i.succ) + (fun i => (S0.rates i.succ-ell) / (u-ell)) (ell / (u-ell)) = + jointBetaNorm (fun i : Fin m => C145.Pulse.modalOverlap S1.Q b i.succ) + (fun i => (S1.rates i.succ-ell) / (u-ell)) (ell / (u-ell)) := by + unfold jointBetaNorm + rw [realization_jointBetaSq_eq S0 S1 ell u] + +/-- The original graph criterion's chosen realization may be replaced by any +genuine oriented realization; the value itself, not just its sign, is equal. -/ +theorem originalSourceJointBetaSq_eq_realization {m : ℕ} + (μ : ℝ) (hμ : 0 < μ) + (W : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (hs : W.IsSymm) (hn : ∀ v u, 0 ≤ W v u) + (hc : (supportGraph W hs).Connected) (b : State m) + (hcyc : KrylovCyclic (generator μ W) b) + (S : OrientedRealization μ W b) (ell u : ℝ) : + originalSourceJointBetaSq μ hμ W hs hn hc b hcyc ell u = + jointBetaSq (fun i : Fin m => C145.Pulse.modalOverlap S.Q b i.succ) + (fun i => (S.rates i.succ-ell) / (u-ell)) (ell / (u-ell)) := by + exact realization_jointBetaSq_eq + (sourceOrientedRealization μ hμ W hs hn hc b hcyc) S ell u + +/-- The displayed paper criterion and the existing graph theorem's squared +criterion agree for every genuine oriented source basis. -/ +theorem displayed_criterion_iff_original {m : ℕ} + (μ : ℝ) (hμ : 0 < μ) + (W : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (hs : W.IsSymm) (hn : ∀ v u, 0 ≤ W v u) + (hc : (supportGraph W hs).Connected) (b : State m) + (hcyc : KrylovCyclic (generator μ W) b) + (S : OrientedRealization μ W b) (ell u delta : ℝ) (hd : 0 < delta) : + (Real.sqrt ((m + 1 : ℕ) + 2) * + jointBetaNorm (fun i : Fin m => C145.Pulse.modalOverlap S.Q b i.succ) + (fun i => (S.rates i.succ-ell) / (u-ell)) (ell / (u-ell)) / delta < 1) ↔ + ((m + 1 : ℕ) + 2 : ℝ) * + originalSourceJointBetaSq μ hμ W hs hn hc b hcyc ell u < delta ^ 2 := by + rw [originalSourceJointBetaSq_eq_realization μ hμ W hs hn hc b hcyc S ell u] + exact joint_qH_lt_one_iff_sq (m + 1) _ _ _ delta hd + +/-- Theorem C on original graphs, their proved actual response jets, and the +paper's literal q_H computed in any oriented source eigenbasis. -/ +theorem selected_response_theoremC_graph {m n : ℕ} {T : ℝ} + (hT : 0 < T) (μ : ℝ) (hμ : 0 < μ) + (W0 : Matrix (Fin (m + 1)) (Fin (m + 1)) ℝ) + (W1 : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hs0 : W0.IsSymm) (hs1 : W1.IsSymm) + (hn0 : ∀ v u, 0 ≤ W0 v u) (hn1 : ∀ v u, 0 ≤ W1 v u) + (hc0 : (supportGraph W0 hs0).Connected) (hc1 : (supportGraph W1 hs1).Connected) + (b0 : State m) (b1 : State n) + (hcyc0 : KrylovCyclic (generator μ W0) b0) + (hcyc1 : KrylovCyclic (generator μ W1) b1) + (S : OrientedRealization μ W0 b0) + (ell u : ℝ) (hw : ell < u) (hband : u < 2 * ell) + (hSpectrum : NonGroundDecayBand μ W0 ell u) + (delta : ℝ) (hd : 0 < delta) + (hsep : ∀ j k, j ≠ k → delta ^ 2 ≤ + signatureSq (physicalKrylov (generator μ W0) b0 ell (u - ell)) j k) + (hq : Real.sqrt ((m + 1 : ℕ) + 2) * + jointBetaNorm (fun i : Fin m => C145.Pulse.modalOverlap S.Q b0 i.succ) + (fun i => (S.rates i.succ-ell) / (u-ell)) (ell / (u-ell)) / delta < 1) + (hData : TerminalJetsAgree hT + b0 (selectedResponse hT μ hμ W0 hs0 hn0 hc0 b0 hcyc0) + b1 (selectedResponse hT μ hμ W1 hs1 hn1 hc1 b1 hcyc1)) : + m = n ∧ ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ v u, generator μ W1 (π v) (π u) = generator μ W0 v u) ∧ + (∀ v, b1 (π v) = b0 v) ∧ + (∀ v u, laplacian W1 (π v) (π u) = laplacian W0 v u) := by + have hqSq := (displayed_criterion_iff_original μ hμ W0 hs0 hn0 hc0 b0 hcyc0 + S ell u delta hd).mp hq + have hspec0 := selectedResponse_spec hT μ hμ W0 hs0 hn0 hc0 b0 hcyc0 + have hspec1 := selectedResponse_spec hT μ hμ W1 hs1 hn1 hc1 b1 hcyc1 + obtain ⟨S0, S1, e, hmn, he0, hr, ha, hc, hb, π, hQ, hA, hport, hL⟩ := + ordinary_C2_jets_determine_theoremC_graph hT μ hμ W0 W1 hs0 hs1 hn0 hn1 hc0 hc1 + b0 b1 hcyc0 hcyc1 ell u hw hband hSpectrum delta hd hsep hqSq + (selectedResponse hT μ hμ W0 hs0 hn0 hc0 b0 hcyc0) + (selectedResponse hT μ hμ W1 hs1 hn1 hc1 b1 hcyc1) + hspec0.1 hspec1.1 hspec0.2 hspec1.2 hData.1 hData.2 + exact ⟨hmn, π, hA, hport, hL⟩ + +end C145.PaperTheoremC + +end diff --git a/LeanPool/C145/C145PhysicalFrame.lean b/LeanPool/C145/C145PhysicalFrame.lean new file mode 100644 index 0000000000..a7de802934 --- /dev/null +++ b/LeanPool/C145/C145PhysicalFrame.lean @@ -0,0 +1,289 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import Mathlib.Basic.Real.Basic +public import Mathlib.Algebra.BigOperators.Field +public import Mathlib.Data.Fintype.Card +public import Mathlib.LinearAlgebra.Matrix.SemiringInverse +public import Mathlib.Tactic.FieldSimp +public import Mathlib.Tactic.Ring + +/-! +# Physical frames + +`Fin (n + 1)` indexes both vertices and modes. Mode zero is retained in every +contraction, even when `n = 0`. These are finite counting-metric identities. +Nonzero modal overlaps/diagonal weights suffice for the algebra; positivity, +spectral calibration, graph realization, and response recovery are later work. +-/ + +@[expose] public section + +namespace C145PhysicalFrame + +noncomputable section + +open scoped BigOperators + +/-- Unit-norm pairwise orthogonal columns of the square coordinate frame. -/ +def ColumnOrthonormal {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) : Prop := + ∀ i j, (∑ v, Q v i * Q v j) = if i = j then 1 else 0 + +/-- The source's cubic coordinate multiplication tensor. -/ +def C {n : ℕ} (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (i j k : Fin (n + 1)) : ℝ := + ∑ v, Q v i * Q v j * Q v k + +/-- The source's modal tensor with all three port-overlap factors. -/ +def T {n : ℕ} (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) (i j k : Fin (n + 1)) : ℝ := + a i * a j * a k * C Q i j k + +/-- Pairing of covectors, summing over every output mode including ground. -/ +def Pair {n : ℕ} (a r s : Fin (n + 1) → ℝ) : ℝ := + ∑ k, r k * s k / a k ^ 2 + +/-- The source's weighted associativity residual; the ground summand remains. -/ +def Assoc {n : ℕ} (a : Fin (n + 1) → ℝ) + (S : Fin (n + 1) → Fin (n + 1) → Fin (n + 1) → ℝ) + (i j k l : Fin (n + 1)) : ℝ := + ∑ r, (S i k r * S j l r - S i l r * S j k r) / a r ^ 2 + +/-- The frame rows have Kronecker-delta inner products. -/ +def RowComplete {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) : Prop := + ∀ v u, (∑ r, Q v r * Q u r) = if v = u then 1 else 0 + +/-- A left inverse supplied by the explicit weighted Gram sums is also a right +inverse because the frame is square. No row-completeness premise is supplied. -/ +theorem weighted_row_complete {n : ℕ} + (F : Fin (n + 1) → Fin (n + 1) → ℝ) (w : Fin (n + 1) → ℝ) + (hw : ∀ i, w i ≠ 0) + (hgram : ∀ i j, (∑ v, F v i * F v j) = + w i * (if i = j then 1 else 0)) + (v u : Fin (n + 1)) : + (∑ r, F v r * F u r / w r) = if v = u then 1 else 0 := by + classical + let A : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ := Matrix.of F + let B : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ := + Matrix.of (fun i x => F x i / w i) + have hBF : B * A = 1 := by + ext i j + simp only [Matrix.mul_apply, Matrix.one_apply, A, B, Matrix.of_apply] + calc + (∑ x, F x i / w i * F x j) = (∑ x, F x i * F x j) / w i := by + rw [Finset.sum_div] + apply Finset.sum_congr rfl + intro x hx + ring + _ = if i = j then 1 else 0 := by + rw [hgram i j] + by_cases hij : i = j <;> simp [hij, hw j] + have hFB : A * B = 1 := + (Matrix.mul_eq_one_comm_of_equiv (Equiv.refl (Fin (n + 1)))).mp hBF + have hentry := congrFun (congrFun hFB v) u + simpa only [Matrix.mul_apply, Matrix.one_apply, A, B, Matrix.of_apply, + mul_div_assoc] using hentry + +/-- Expanding two actual cubic tensors and using the derived weighted row sum +collapses their contraction to a quartic vertex sum. -/ +theorem weighted_cubic_contraction {n : ℕ} + (F : Fin (n + 1) → Fin (n + 1) → ℝ) (w : Fin (n + 1) → ℝ) + (hw : ∀ i, w i ≠ 0) + (hgram : ∀ i j, (∑ v, F v i * F v j) = + w i * (if i = j then 1 else 0)) + (i j k l : Fin (n + 1)) : + (∑ r, C F i k r * C F j l r / w r) = + ∑ v, F v i * F v j * F v k * F v l := by + classical + calc + (∑ r, C F i k r * C F j l r / w r) = + ∑ r, ∑ v, ∑ u, + (F v i * F v k * F v r) * (F u j * F u l * F u r) / w r := by + simp only [C, Finset.sum_mul_sum, Finset.sum_div] + _ = ∑ v, ∑ u, ∑ r, + (F v i * F v k * F v r) * (F u j * F u l * F u r) / w r := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro v hv + rw [Finset.sum_comm] + _ = ∑ v, ∑ u, (F v i * F v k * F u j * F u l) * + (∑ r, F v r * F u r / w r) := by + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro v hv + apply Finset.sum_congr rfl + intro u hu + apply Finset.sum_congr rfl + intro r hr + ring + _ = ∑ v, ∑ u, (F v i * F v k * F u j * F u l) * + (if v = u then 1 else 0) := by + simp_rw [weighted_row_complete F w hw hgram] + _ = ∑ v, F v i * F v j * F v k * F v l := by + apply Finset.sum_congr rfl + intro v hv + simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq, + Finset.mem_univ, ite_true] + ring + +theorem columnOrthonormal_rowComplete {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ : ColumnOrthonormal Q) : RowComplete Q := by + intro v u + simpa only [div_one] using + weighted_row_complete Q (fun _ => 1) (fun _ => one_ne_zero) + (fun i j => by simpa only [one_mul] using hQ i j) v u + +theorem cubic_contraction {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (hQ : ColumnOrthonormal Q) (i j k l : Fin (n + 1)) : + (∑ r, C Q i k r * C Q j l r) = + ∑ v, Q v i * Q v j * Q v k * Q v l := by + simpa only [div_one] using + weighted_cubic_contraction Q (fun _ => 1) (fun _ => one_ne_zero) + (fun x y => by simpa only [one_mul] using hQ x y) i j k l + +/-- The constant ground column is normalized by column orthonormality itself. -/ +theorem ground_normalization {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) (c : ℝ) + (hQ : ColumnOrthonormal Q) (hground : ∀ v, Q v 0 = c) : + (n + 1 : ℝ) * c ^ 2 = 1 := by + simpa only [hground, ite_true, Finset.sum_const, Finset.card_univ, + Fintype.card_fin, nsmul_eq_mul, Nat.cast_add, Nat.cast_one, pow_two] using hQ 0 0 + +theorem ground_ne_zero {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) (c : ℝ) + (hQ : ColumnOrthonormal Q) (hground : ∀ v, Q v 0 = c) : c ≠ 0 := by + intro hc + have h := ground_normalization Q c hQ hground + exact (zero_ne_one : (0 : ℝ) ≠ 1) (by simp [hc] at h) + +theorem ground_slice {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ : ColumnOrthonormal Q) (hground : ∀ v, Q v 0 = c) + (j k : Fin (n + 1)) : + T Q a 0 j k = a 0 * c * a j ^ 2 * (if j = k then 1 else 0) := by + have hC : C Q 0 j k = c * (if j = k then 1 else 0) := by + calc + C Q 0 j k = c * ∑ v, Q v j * Q v k := by + simp only [C, hground, Finset.mul_sum] + apply Finset.sum_congr rfl + intro v hv + ring + _ = c * (if j = k then 1 else 0) := by rw [hQ j k] + rw [T, hC] + by_cases hjk : j = k + · subst k + simp only + ring + · simp [hjk] + +theorem modal_associativity {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) (hQ : ColumnOrthonormal Q) + (ha : ∀ i, a i ≠ 0) (i j k l : Fin (n + 1)) : + Assoc a (T Q a) i j k l = 0 := by + have hcancel (r : Fin (n + 1)) : + (T Q a i k r * T Q a j l r - T Q a i l r * T Q a j k r) / a r ^ 2 = + (a i * a j * a k * a l) * + (C Q i k r * C Q j l r - C Q i l r * C Q j k r) := by + dsimp only [T] + field_simp [ha r] + have hquartic : (∑ v, Q v i * Q v j * Q v k * Q v l) = + ∑ v, Q v i * Q v j * Q v l * Q v k := by + apply Finset.sum_congr rfl + intro v hv + ring + simp only [Assoc, hcancel, ← Finset.mul_sum, Finset.sum_sub_distrib] + rw [cubic_contraction Q hQ i j k l, cubic_contraction Q hQ i j l k, + hquartic, sub_self, mul_zero] + +/-- Counting-metric trace before using orthogonality to the ground column. -/ +theorem modal_counting_trace {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) (hQ : ColumnOrthonormal Q) + (ha : ∀ i, a i ≠ 0) (i : Fin (n + 1)) : + (∑ j, T Q a i j j / a j ^ 2) = a i * ∑ v, Q v i := by + have hdiag (v : Fin (n + 1)) : (∑ j, Q v j * Q v j) = 1 := by + simpa only [ite_true] using columnOrthonormal_rowComplete Q hQ v v + calc + (∑ j, T Q a i j j / a j ^ 2) = ∑ j, a i * C Q i j j := by + apply Finset.sum_congr rfl + intro j hj + dsimp only [T] + field_simp [ha j] + _ = a i * ∑ v, Q v i * (∑ j, Q v j * Q v j) := by + simp only [C, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro v hv + apply Finset.sum_congr rfl + intro j hj + ring + _ = a i * ∑ v, Q v i := by simp_rw [hdiag]; simp only [mul_one] + +theorem nonground_counting_trace {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ : ColumnOrthonormal Q) (ha : ∀ i, a i ≠ 0) + (hground : ∀ v, Q v 0 = c) (i : Fin n) : + (∑ j, T Q a i.succ j j / a j ^ 2) = 0 := by + have hc : c ≠ 0 := ground_ne_zero Q c hQ hground + have horth : (∑ v, Q v i.succ) * c = 0 := by + calc + (∑ v, Q v i.succ) * c = ∑ v, Q v i.succ * c := by rw [Finset.sum_mul] + _ = ∑ v, Q v i.succ * Q v 0 := by simp_rw [hground] + _ = 0 := by simpa only [Fin.succ_ne_zero, ite_false] using hQ i.succ 0 + have hsum : (∑ v, Q v i.succ) = 0 := (mul_eq_zero.mp horth).resolve_right hc + rw [modal_counting_trace Q a hQ ha i.succ, hsum, mul_zero] + +/-- Exactly the first package in the accepted central plan, with every scientific +premise visible. Ground normalization/nonvanishing are proved above, not inputs. -/ +theorem physical_frame_identities + (n : ℕ) (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ : ColumnOrthonormal Q) (ha : ∀ i, a i ≠ 0) + (hground : ∀ v, Q v 0 = c) : + RowComplete Q ∧ + (∀ i j k l, Assoc a (T Q a) i j k l = 0) ∧ + (∀ j k, T Q a 0 j k = a 0 * c * a j ^ 2 * (if j = k then 1 else 0)) ∧ + (∀ i : Fin n, (∑ j, T Q a i.succ j j / a j ^ 2) = 0) := by + exact ⟨columnOrthonormal_rowComplete Q hQ, modal_associativity Q a hQ ha, + ground_slice Q a c hQ hground, nonground_counting_trace Q a c hQ ha hground⟩ + +/-- Rational-frame interface: `C F` is the explicit cubic sum called `TF` in +the plan. No square root, reconstruction, physical realization, or rank input. -/ +theorem weighted_frame_identities + (n : ℕ) (F : Fin (n + 1) → Fin (n + 1) → ℝ) (w : Fin (n + 1) → ℝ) + (hw : ∀ i, w i ≠ 0) + (hgram : ∀ i j, (∑ v, F v i * F v j) = + w i * (if i = j then 1 else 0)) : + (∀ v u, (∑ r, F v r * F u r / w r) = if v = u then 1 else 0) ∧ + (∀ i j k l, (∑ r, + (C F i k r * C F j l r - C F i l r * C F j k r) / w r) = 0) := by + refine ⟨weighted_row_complete F w hw hgram, ?_⟩ + intro i j k l + simp only [sub_div, Finset.sum_sub_distrib] + rw [weighted_cubic_contraction F w hw hgram i j k l, + weighted_cubic_contraction F w hw hgram i j l k] + apply sub_eq_zero.mpr + apply Finset.sum_congr rfl + intro v hv + ring + + +end + +end C145PhysicalFrame + +end diff --git a/LeanPool/C145/C145PhysicalTraceResidue.lean b/LeanPool/C145/C145PhysicalTraceResidue.lean new file mode 100644 index 0000000000..35f8a6f378 --- /dev/null +++ b/LeanPool/C145/C145PhysicalTraceResidue.lean @@ -0,0 +1,507 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145EightAffineFamilies +public import Mathlib.Algebra.Polynomial.Degree.Lemmas +public import Mathlib.Algebra.Polynomial.BigOperators + +/-! +C145: literal physical counting trace on the actual ordinary H2 residue fiber. + +Coordinates are z=X 0, x=X 1, y=X 2; Res i j k uses [-rate k,-rate i,-rate j]. +The oriented di is product_h!=i (rate h-rate i). All divisions are totalized. +Nonzero overlaps are required in the physical theorems, not in the algebraic +factorization. Full ground is retained until a common-ground difference is proved. +Individual zero rates remain allowed in the exact kernel and corrected moments. +The main kernel imposes BOTH ordinary null response and actual counting trace. +No physical separator, rank, calibration recovery, or graph reconstruction is claimed. +-/ + +@[expose] public section + +noncomputable section +namespace C145.H2 +open MvPolynomial C145.ThreePlane +open scoped BigOperators +variable {n : ℕ} + +/-- Full counting-metric trace, including the ground summand. -/ +def fullCountingTrace (a : Fin (n + 1) → ℝ) (U : Tensor (n + 1)) + (i : Fin (n + 1)) : ℝ := ∑ j, U i j j / a j ^ 2 + +/-- Trace of a residual tensor in the same calibrated full-mode metric. -/ +def residualCountingTrace (a : Fin (n + 1) → ℝ) (E : Tensor n) + (i : Fin n) : ℝ := ∑ j, E i j j / a j.succ ^ 2 + +/-- Every weighted counting trace of the residual tensor is zero. -/ +def ResidualTraceFree (a : Fin (n + 1) → ℝ) (E : Tensor n) : Prop := + ∀ i, residualCountingTrace a E i = 0 + +/-- Swap actual x into coordinate zero, evaluate z,y, then substitute -X. -/ +def traceSlice (R : P3) (b : ℝ) : Polynomial ℝ := + (Polynomial.map (MvPolynomial.eval ![-b,-b]) + (finSuccEquiv ℝ 2 (rename (Equiv.swap 0 1) R))).comp (-Polynomial.X) + +/-- Concrete physical trace polynomial; no interpolation or chosen node. -/ +def tracePolynomial (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (R : P3) : Polynomial ℝ := + ∑ j, Polynomial.C (1 / (a j.succ ^ 2 * di rates j ^ 2)) * + ((Polynomial.X - Polynomial.C (2 * rates j)) * traceSlice R (rates j)) + +theorem fullCountingTrace_sub (a : Fin (n + 1) → ℝ) + (U V : Tensor (n + 1)) (i : Fin (n + 1)) : + fullCountingTrace a (V-U) i = fullCountingTrace a V i - fullCountingTrace a U i := by + simp only [fullCountingTrace, Pi.sub_apply, sub_div, Finset.sum_sub_distrib] + +theorem fullCountingTrace_groundZero_zero (a : Fin (n + 1) → ℝ) (E : Tensor n) : + fullCountingTrace a (groundZero E) 0 = 0 := by + simp [fullCountingTrace, groundZero_ground_first] + +theorem fullCountingTrace_groundZero_succ (a : Fin (n + 1) → ℝ) + (E : Tensor n) (i : Fin n) : + fullCountingTrace a (groundZero E) i.succ = residualCountingTrace a E i := by + simp [fullCountingTrace, residualCountingTrace, Fin.sum_univ_succ, + groundZero_ground_second, groundZero_succ] + +/-- A constant-size slot product representation of the literal physical sum. -/ +private theorem physical_entry_product + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) + (w : Fin 3 → Fin (n + 1)) : + C145PhysicalFrame.T Q a (w 1) (w 2) (w 0) = + ∑ v, ∏ r : Fin 3, a (w r) * Q v (w r) := by + simp only [C145PhysicalFrame.T, C145PhysicalFrame.C, Finset.mul_sum, + Fin.prod_univ_succ, Fin.prod_univ_zero, mul_one, + Fin.succ_zero_eq_one, Fin.succ_one_eq_two] + apply Finset.sum_congr rfl + intro v hv + ring + +/-- Every slot permutation follows from reindexing three factors. -/ +theorem physical_fullSym + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) : + FullSymTensor (C145PhysicalFrame.T Q a) := by + intro e w + change C145PhysicalFrame.T Q a ((w ∘ e) 1) ((w ∘ e) 2) ((w ∘ e) 0) = + C145PhysicalFrame.T Q a (w 1) (w 2) (w 0) + rw [physical_entry_product, physical_entry_product] + apply Finset.sum_congr rfl + intro v hv + exact _root_.Equiv.prod_comp e (fun r => a (w r) * Q v (w r)) + +private theorem trace_swap_inputs (U : Tensor (n + 1)) (hU : FullSymTensor U) + (i j k : Fin (n + 1)) : U i j k = U j i k := by + have h := hU (Equiv.swap 1 2) ![k,i,j] + change U ((![k,i,j] : Fin 3 → Fin (n + 1)) ((Equiv.swap 1 2) 1)) + ((![k,i,j] : Fin 3 → Fin (n + 1)) ((Equiv.swap 1 2) 2)) + ((![k,i,j] : Fin 3 → Fin (n + 1)) ((Equiv.swap 1 2) 0)) = U i j k at h + simpa [Equiv.swap_apply_def] using h.symm + +private theorem trace_swap_first_output (U : Tensor (n + 1)) (hU : FullSymTensor U) + (i j k : Fin (n + 1)) : U i j k = U k j i := by + have h := hU (Equiv.swap 0 1) ![k,i,j] + change U ((![k,i,j] : Fin 3 → Fin (n + 1)) ((Equiv.swap 0 1) 1)) + ((![k,i,j] : Fin 3 → Fin (n + 1)) ((Equiv.swap 0 1) 2)) + ((![k,i,j] : Fin 3 → Fin (n + 1)) ((Equiv.swap 0 1) 0)) = U i j k at h + simpa [Equiv.swap_apply_def] using h.symm + +/-- Common constant ground and orthonormality derive every ground entry. -/ +theorem physical_commonGround + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hG0 : ∀ v, Q0 v 0 = c) (hG1 : ∀ v, Q1 v 0 = c) : + CommonGround (C145PhysicalFrame.T Q0 a) (C145PhysicalFrame.T Q1 a) := by + have hfirst (j k : Fin (n + 1)) : + C145PhysicalFrame.T Q1 a 0 j k = C145PhysicalFrame.T Q0 a 0 j k := by + rw [C145PhysicalFrame.ground_slice Q1 a c hQ1 hG1, + C145PhysicalFrame.ground_slice Q0 a c hQ0 hG0] + intro i j k h + rcases h with rfl | rfl | rfl + · exact hfirst j k + · rw [trace_swap_inputs _ (physical_fullSym Q1 a), + trace_swap_inputs _ (physical_fullSym Q0 a)] + exact hfirst i k + · rw [trace_swap_first_output _ (physical_fullSym Q1 a), + trace_swap_first_output _ (physical_fullSym Q0 a)] + exact hfirst j i + +/-- A physical member relative to an arbitrary common-ground origin has an +inhomogeneous trace target. The origin is not silently assumed physical. -/ +theorem physical_member_commonGround_trace_difference + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) (ha : ∀ r, a r ≠ 0) + (hground : ∀ v, Q v 0 = c) (U0 : Tensor (n + 1)) + (hG : CommonGround U0 (C145PhysicalFrame.T Q a)) (i : Fin n) : + residualCountingTrace a + (residual (C145PhysicalFrame.T Q a) - residual U0) i = + -fullCountingTrace a U0 i.succ := by + calc + _ = fullCountingTrace a (C145PhysicalFrame.T Q a - U0) i.succ := by + rw [commonGround_difference U0 (C145PhysicalFrame.T Q a) hG, + fullCountingTrace_groundZero_succ] + _ = -fullCountingTrace a U0 i.succ := by + rw [fullCountingTrace_sub] + have hz := C145PhysicalFrame.nonground_counting_trace Q a c hQ ha hground i + change fullCountingTrace a (C145PhysicalFrame.T Q a) i.succ = 0 at hz + rw [hz, zero_sub] + +/-- Homogeneous trace follows because both endpoints are actual frames. -/ +theorem physical_pair_difference_trace_free + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) (ha : ∀ r, a r ≠ 0) + (hG0 : ∀ v, Q0 v 0 = c) (hG1 : ∀ v, Q1 v 0 = c) : + ResidualTraceFree a + (residual (C145PhysicalFrame.T Q1 a) - residual (C145PhysicalFrame.T Q0 a)) := by + intro i + rw [physical_member_commonGround_trace_difference Q1 a c hQ1 ha hG1 + (C145PhysicalFrame.T Q0 a) (physical_commonGround Q0 Q1 a c hQ0 hQ1 hG0 hG1)] + have hz := C145PhysicalFrame.nonground_counting_trace Q0 a c hQ0 ha hG0 i + change fullCountingTrace a (C145PhysicalFrame.T Q0 a) i.succ = 0 at hz + rw [hz, neg_zero] + +private theorem traceSlice_eval (R : P3) (b u : ℝ) : + (traceSlice R b).eval u = MvPolynomial.eval ![-b,-u,-b] R := by + unfold traceSlice + rw [Polynomial.eval_comp] + simp only [Polynomial.eval_neg, Polynomial.eval_X] + rw [← MvPolynomial.eval_eq_eval_mv_eval', MvPolynomial.eval_rename] + have hv : (Fin.cons (-u) ![-b,-b] : Fin 3 → ℝ) ∘ Equiv.swap 0 1 = + ![-b,-u,-b] := by + funext r + fin_cases r <;> simp [Equiv.swap_apply_def] + rw [hv] + +private theorem traceSlice_natDegree (R : P3) (b : ℝ) : + (traceSlice R b).natDegree ≤ degreeOf (1 : Fin 3) R := by + unfold traceSlice + calc + _ ≤ (Polynomial.map (MvPolynomial.eval ![-b,-b]) + (finSuccEquiv ℝ 2 (rename (Equiv.swap 0 1) R))).natDegree * + (-Polynomial.X : Polynomial ℝ).natDegree := Polynomial.natDegree_comp_le + _ = (Polynomial.map (MvPolynomial.eval ![-b,-b]) + (finSuccEquiv ℝ 2 (rename (Equiv.swap 0 1) R))).natDegree := by simp + _ ≤ (finSuccEquiv ℝ 2 (rename (Equiv.swap 0 1) R)).natDegree := + Polynomial.natDegree_map_le + _ = degreeOf (0 : Fin 3) (rename (Equiv.swap 0 1) R) := natDegree_finSuccEquiv _ + _ = degreeOf (1 : Fin 3) R := by + simpa using (degreeOf_rename_of_injective (p := R) + (Equiv.swap (0 : Fin 3) 1).injective (1 : Fin 3)) + +/-- Evaluation of P is exactly the metric-weighted repeated-node expression. -/ +theorem tracePolynomial_eval (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (R : P3) (u : ℝ) : + (tracePolynomial a rates R).eval u = + ∑ j, ((u - 2 * rates j) * MvPolynomial.eval ![-rates j,-u,-rates j] R) / + (a j.succ ^ 2 * di rates j ^ 2) := by + classical + simp only [tracePolynomial, Polynomial.eval_finsetSum, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_sub, Polynomial.eval_X, traceSlice_eval] + apply Finset.sum_congr rfl + intro j hj + ring + +theorem tracePolynomial_zero (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) : + tracePolynomial a rates (0 : P3) = 0 := by + simp [tracePolynomial, traceSlice] + +/-- Coordinate-x degree alone bounds P; symmetry is unnecessary here. -/ +theorem tracePolynomial_natDegree (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (hn4 : 4 ≤ n) (R : P3) (hR : QAdmissible n R) : + (tracePolynomial a rates R).natDegree ≤ n - 3 := by + classical + rcases hR with rfl | ⟨_, hDegree⟩ + · rw [tracePolynomial_zero] + simp + · unfold tracePolynomial + refine Polynomial.natDegree_sum_le_of_forall_le Finset.univ _ ?_ + intro j hj + have hlin : (Polynomial.X - Polynomial.C (2 * rates j) : Polynomial ℝ).natDegree ≤ 1 := by + calc + _ ≤ max (Polynomial.X : Polynomial ℝ).natDegree + (Polynomial.C (2 * rates j)).natDegree := Polynomial.natDegree_sub_le _ _ + _ = 1 := by rw [Polynomial.natDegree_X, Polynomial.natDegree_C]; norm_num + have hSlice : (traceSlice R (rates j)).natDegree ≤ n - 4 := + (traceSlice_natDegree R (rates j)).trans (hDegree 1) + calc + _ ≤ (Polynomial.C (1 / (a j.succ ^ 2 * di rates j ^ 2))).natDegree + + ((Polynomial.X - Polynomial.C (2 * rates j)) * traceSlice R (rates j)).natDegree := + Polynomial.natDegree_mul_le + _ ≤ 0 + (1 + (n - 4)) := + add_le_add (le_of_eq (Polynomial.natDegree_C _)) + (Polynomial.natDegree_mul_le.trans (add_le_add hlin hSlice)) + _ ≤ n - 3 := by omega + +/-- The literal repeated Xi factors give lambda_i^2*(lambda_i-2lambda_j). +This is an inverse-product identity, valid even at zero denominators under +totalized real division; no cancellation or physical metric is inferred there. -/ +theorem res_counting_trace_factorization (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (R : P3) (i : Fin n) : + residualCountingTrace a (Res rates R) i = + (rates i ^ 2 / di rates i) * (tracePolynomial a rates R).eval (rates i) := by + classical + rw [tracePolynomial_eval, Finset.mul_sum] + unfold residualCountingTrace + apply Finset.sum_congr rfl + intro j hj + rw [res_entry, xi_negative_diagonal] + simp only [div_eq_mul_inv, mul_inv_rev, pow_two] + ring + +/-- An individual zero rate gives a zero trace row; its scalar P(0) is not +cancelled or asserted zero. The all-node kernel argument below retains it. -/ +theorem res_counting_trace_at_zero_rate (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (R : P3) (i : Fin n) (hi : rates i = 0) : + residualCountingTrace a (Res rates R) i = 0 := by + rw [res_counting_trace_factorization, hi] + simp + +/-- X^2 P has all n roots, including an individual zero rate. No division by +lambda_i^2 occurs in this exact trace-compatible quotient characterization. -/ +theorem res_trace_free_iff_tracePolynomial_zero (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (R : P3) (hR : QAdmissible n R) : + ResidualTraceFree a (Res rates R) ↔ tracePolynomial a rates R = 0 := by + classical + rcases hR with rfl | ⟨hn4, hDegree⟩ + · simp [tracePolynomial_zero, res_zero, ResidualTraceFree, residualCountingTrace] + · constructor + · intro hTrace + let P := tracePolynomial a rates R + let Q : Polynomial ℝ := Polynomial.X ^ 2 * P + have hP : P.natDegree ≤ n - 3 := + tracePolynomial_natDegree a rates hn4 R (Or.inr ⟨hn4, hDegree⟩) + have hQbound : Q.natDegree ≤ 2 + P.natDegree := by + calc + _ ≤ ((Polynomial.X : Polynomial ℝ) ^ 2).natDegree + P.natDegree := + Polynomial.natDegree_mul_le + _ = 2 + P.natDegree := congrArg (fun d : ℕ => d + P.natDegree) + (Polynomial.natDegree_X_pow (R := ℝ) 2) + have hQn : Q.natDegree < n := by omega + have hQdegree : Q.degree < (Finset.univ : Finset (Fin n)).card := by + have hcast : (Q.natDegree : WithBot ℕ) < (n : WithBot ℕ) := + WithBot.coe_lt_coe.mpr hQn + have hdeg : Q.degree < (n : WithBot ℕ) := + (Polynomial.degree_le_natDegree (p := Q)).trans_lt hcast + simpa only [Finset.card_univ, Fintype.card_fin, Nat.cast_withBot] using hdeg + have hQzero : Q = 0 := by + apply Polynomial.eq_zero_of_degree_lt_of_eval_index_eq_zero + (s := (Finset.univ : Finset (Fin n))) hRates.injOn hQdegree + intro i hi + have ht := hTrace i + rw [res_counting_trace_factorization] at ht + field_simp [di_ne_zero rates hRates i] at ht + simpa only [Q, P, Polynomial.eval_mul, Polynomial.eval_X_pow, mul_zero] using ht + change (Polynomial.X : Polynomial ℝ) ^ 2 * P = 0 at hQzero + exact (mul_eq_zero.mp hQzero).resolve_left (pow_ne_zero 2 Polynomial.X_ne_zero) + · intro hP i + rw [res_counting_trace_factorization, hP] + simp + +/-- Coefficient extraction at -lambda_i keeps the actual di orientation. +Here the degree is n-3 and p<=1; the older n-4 receiving lemma is not used. -/ +private theorem trace_scalar_moment (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hn4 : 4 ≤ n) + (P : Polynomial ℝ) (hP : P.natDegree ≤ n - 3) (p : ℕ) (hp : p ≤ 1) : + ∑ i, rates i ^ p * P.eval (rates i) / di rates i = 0 := by + classical + let Q : Polynomial ℝ := (Polynomial.X ^ p * P).comp (-Polynomial.X) + have hQbound : Q.natDegree ≤ p + P.natDegree := by + calc + _ ≤ (Polynomial.X ^ p * P).natDegree * (-Polynomial.X : Polynomial ℝ).natDegree := + Polynomial.natDegree_comp_le + _ = (Polynomial.X ^ p * P).natDegree := by simp + _ ≤ p + P.natDegree := by + simpa only [Polynomial.natDegree_X_pow] using + (Polynomial.natDegree_mul_le (p := (Polynomial.X : Polynomial ℝ) ^ p) (q := P)) + have hQlt : Q.natDegree < n - 1 := by omega + have hQn : Q.natDegree < n := by omega + have hQdegree : Q.degree < (Finset.univ : Finset (Fin n)).card := by + have hcast : (Q.natDegree : WithBot ℕ) < (n : WithBot ℕ) := + WithBot.coe_lt_coe.mpr hQn + have hdeg : Q.degree < (n : WithBot ℕ) := + (Polynomial.degree_le_natDegree (p := Q)).trans_lt hcast + simpa only [Finset.card_univ, Fintype.card_fin, Nat.cast_withBot] using hdeg + have hNodes : Function.Injective (fun i : Fin n => -rates i) := by + intro i j hij + exact hRates (neg_injective hij) + have hDen (i : Fin n) : + (∏ j ∈ (Finset.univ : Finset (Fin n)).erase i, + ((-rates i) - (-rates j))) = di rates i := by + unfold di + apply Finset.prod_congr rfl + intro j hj + ring + have hCoeff := Lagrange.coeff_eq_sum (s := (Finset.univ : Finset (Fin n))) + (v := fun i : Fin n => -rates i) (P := Q) hNodes.injOn hQdegree + have hZero : Q.coeff (n - 1) = 0 := Polynomial.coeff_eq_zero_of_natDegree_lt hQlt + have hh := hCoeff.symm.trans (by + simpa only [Finset.card_univ, Fintype.card_fin] using hZero) + simpa only [Finset.card_univ, Fintype.card_fin, hDen, Q, + Polynomial.eval_comp, Polynomial.eval_mul, Polynomial.eval_X_pow, + Polynomial.eval_neg, Polynomial.eval_X, neg_neg] using hh + +/-- The reciprocal-rate row identity remains valid at a zero rate. -/ +theorem res_trace_reciprocal_rate_annihilator (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (R : P3) (hR : QAdmissible n R) : + ∑ i, residualCountingTrace a (Res rates R) i / rates i = 0 := by + classical + rcases hR with rfl | ⟨hn4, hDegree⟩ + · simp [res_zero, residualCountingTrace] + · have hP := tracePolynomial_natDegree a rates hn4 R (Or.inr ⟨hn4, hDegree⟩) + calc + _ = ∑ i, rates i ^ 1 * (tracePolynomial a rates R).eval (rates i) / di rates i := by + apply Finset.sum_congr rfl + intro i hi + rw [res_counting_trace_factorization] + by_cases hi0 : rates i = 0 + · simp [hi0] + · field_simp [hi0, di_ne_zero rates hRates i] + _ = 0 := trace_scalar_moment rates hRates hn4 _ hP 1 (by omega) + +/-- Reciprocal-square cancellation requires every residual rate nonzero. -/ +theorem res_trace_reciprocal_square_annihilator (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (hNZ : ∀ i, rates i ≠ 0) (R : P3) (hR : QAdmissible n R) : + ∑ i, residualCountingTrace a (Res rates R) i / rates i ^ 2 = 0 := by + classical + rcases hR with rfl | ⟨hn4, hDegree⟩ + · simp [res_zero, residualCountingTrace] + · have hP := tracePolynomial_natDegree a rates hn4 R (Or.inr ⟨hn4, hDegree⟩) + calc + _ = ∑ i, rates i ^ 0 * (tracePolynomial a rates R).eval (rates i) / di rates i := by + apply Finset.sum_congr rfl + intro i hi + rw [res_counting_trace_factorization] + field_simp [hNZ i, di_ne_zero rates hRates i] + _ = 0 := trace_scalar_moment rates hRates hn4 _ hP 0 (by omega) + +/-- Exact missing zero-node contribution, without selecting that node. -/ +theorem res_trace_zero_rate_correction (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (R : P3) (hR : QAdmissible n R) : + (∑ i, residualCountingTrace a (Res rates R) i / rates i ^ 2) + + (∑ i ∈ (Finset.univ.filter (fun i => rates i = 0)), + (tracePolynomial a rates R).eval 0 / di rates i) = 0 := by + classical + rcases hR with rfl | ⟨hn4, hDegree⟩ + · simp [res_zero, residualCountingTrace, tracePolynomial_zero] + · have hP := tracePolynomial_natDegree a rates hn4 R (Or.inr ⟨hn4, hDegree⟩) + rw [Finset.sum_filter, ← Finset.sum_add_distrib] + calc + _ = ∑ i, rates i ^ 0 * (tracePolynomial a rates R).eval (rates i) / di rates i := by + apply Finset.sum_congr rfl + intro i hi + rw [res_counting_trace_factorization] + by_cases hi0 : rates i = 0 + · simp [hi0] + · simp only [hi0, ite_false, add_zero, pow_zero, one_mul] + field_simp [hi0, di_ne_zero rates hRates i] + _ = 0 := trace_scalar_moment rates hRates hn4 _ hP 0 (by omega) + +theorem res_trace_positive_annihilators (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (hPos : ∀ i, 0 < rates i) (R : P3) (hR : QAdmissible n R) : + (∑ i, residualCountingTrace a (Res rates R) i / rates i ^ 2 = 0) ∧ + (∑ i, residualCountingTrace a (Res rates R) i / rates i = 0) := by + exact ⟨res_trace_reciprocal_square_annihilator a rates hRates + (fun i => ne_of_gt (hPos i)) R hR, + res_trace_reciprocal_rate_annihilator a rates hRates R hR⟩ + +/-- The imposed trace-free ordinary kernel, not just an appended equivalence. +Its unique quotient has P=0; the desired trace equation is part of the left side. -/ +theorem complete_ordinary_H2_counting_trace_kernel (a : Fin (n + 1) → ℝ) + (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (E : Tensor n) (hSym : FullSymTensor E) : + (NullRegular rates E ∧ ResidualTraceFree a E) ↔ ∃! R : P3, + SymPoly R ∧ QAdmissible n R ∧ E = Res rates R ∧ tracePolynomial a rates R = 0 := by + constructor + · rintro ⟨hData, hTrace⟩ + obtain ⟨R, hR, hUnique⟩ := (complete_ordinary_H2_kernel rates hRates E hSym).mp hData + have hP : tracePolynomial a rates R = 0 := by + apply (res_trace_free_iff_tracePolynomial_zero a rates hRates R hR.2.1).mp + rw [← hR.2.2] + exact hTrace + refine ⟨R, ⟨hR.1, hR.2.1, hR.2.2, hP⟩, ?_⟩ + intro S hS + exact hUnique S ⟨hS.1, hS.2.1, hS.2.2.1⟩ + · rintro ⟨R, ⟨hRSym, hAdm, rfl, hP⟩, _⟩ + exact ⟨res_nullRegular rates hRates R hAdm, + (res_trace_free_iff_tracePolynomial_zero a rates hRates R hAdm).mpr hP⟩ + +/-- Literal physical two-frame/full-H2 equivalence in common calibrated a,c,rates. +Full symmetry, common ground and trace are all derived inside this theorem. +There is no desired trace, P, rank, reconstruction or calibration-recovery premise. -/ +theorem physical_pair_H2_counting_trace_residue + (μ : ℝ) (rates : Fin n → ℝ) (hRates : Function.Injective rates) + (hPos : ∀ i, 0 < rates i) + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) (ha : ∀ r, a r ≠ 0) + (hG0 : ∀ v, Q0 v 0 = c) (hG1 : ∀ v, Q1 v 0 = c) : + SamePositive (fullRates μ rates) + (C145PhysicalFrame.T Q0 a) (C145PhysicalFrame.T Q1 a) ↔ + ∃! R : P3, SymPoly R ∧ QAdmissible n R ∧ + C145PhysicalFrame.T Q1 a - C145PhysicalFrame.T Q0 a = groundZero (Res rates R) ∧ + ResidualTraceFree a (Res rates R) ∧ tracePolynomial a rates R = 0 := by + have hG := physical_commonGround Q0 Q1 a c hQ0 hQ1 hG0 hG1 + have hSym0 := physical_fullSym Q0 a + have hSym1 := physical_fullSym Q1 a + have hTrace := physical_pair_difference_trace_free Q0 Q1 a c hQ0 hQ1 ha hG0 hG1 + constructor + · intro hData + have hResidual := samePositive_residual_of_commonGround μ rates _ _ hG hData + obtain ⟨R, hR, hUnique⟩ := + (equal_positive_H2_iff_residue_difference rates hRates hPos _ _ + (residual_fullSym _ hSym0) (residual_fullSym _ hSym1)).mp hResidual + have hFull : C145PhysicalFrame.T Q1 a - C145PhysicalFrame.T Q0 a = + groundZero (Res rates R) := by + rw [commonGround_difference _ _ hG, hR.2.2] + have hTraceR : ResidualTraceFree a (Res rates R) := by + rw [← hR.2.2] + exact hTrace + have hP := (res_trace_free_iff_tracePolynomial_zero a rates hRates R hR.2.1).mp hTraceR + refine ⟨R, ⟨hR.1, hR.2.1, hFull, hTraceR, hP⟩, ?_⟩ + intro S hS + apply res_injective_on_admissible rates hRates hS.2.1 hR.2.1 + funext i j k + have hh := congrArg (fun U : Tensor (n + 1) => U i.succ j.succ k.succ) + (hS.2.2.1.symm.trans hFull) + simpa only [groundZero_succ] using hh + · rintro ⟨R, hR, _⟩ s t hs ht + have hz := (nullPositive_iff_nullRegular rates hPos (Res rates R)).mpr + (res_nullRegular rates hRates R hR.2.1) s t hs ht + have hh : H (fullRates μ rates) + (C145PhysicalFrame.T Q1 a - C145PhysicalFrame.T Q0 a) s t = 0 := by + rw [hR.2.2.1, H_groundZero] + exact hz + rw [H_sub] at hh + exact (sub_eq_zero.mp hh).symm + +/-- The zero admissible branch precedes saturated natural subtraction. -/ +theorem trace_small_quotient (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (hn : n ≤ 3) (R : P3) (hR : QAdmissible n R) : + R = 0 ∧ tracePolynomial a rates R = 0 ∧ ResidualTraceFree a (Res rates R) := by + have hzero := (admissible_small_iff_zero hn R).mp hR + subst R + simp [tracePolynomial_zero, res_zero, ResidualTraceFree, residualCountingTrace] + +/-- Empty residual indices need no selected node, nonzero metric, or admissibility. -/ +theorem trace_n0 (a : Fin 1 → ℝ) (rates : Fin 0 → ℝ) (E : Tensor 0) (R : P3) : + ResidualTraceFree a E ∧ tracePolynomial a rates R = 0 := by + constructor + · intro i + exact Fin.elim0 i + · simp [tracePolynomial] + +end C145.H2 + +end diff --git a/LeanPool/C145/C145ReceivingLagrangeMoments.lean b/LeanPool/C145/C145ReceivingLagrangeMoments.lean new file mode 100644 index 0000000000..44888d9d21 --- /dev/null +++ b/LeanPool/C145/C145ReceivingLagrangeMoments.lean @@ -0,0 +1,266 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145CompleteOrdinaryH2Kernel + +/-! +C145: actual receiving Lagrange moments of the unique admissible H2 quotient. + +All accepted definitions and sources are imported unchanged. Coordinates are +z=X 0, x=X 1, y=X 2; gridResidue rates R i j k evaluates R at +![-rates k,-rates i,-rates j]. Only individual-rate injection is used for the +moments. Positivity occurs solely in the positive-data difference corollary. +No desired moment, divisibility, reconstruction, trace or physical premise +is supplied. This file stops before six-product and ground/physical joins. +-/ + +@[expose] public section + +noncomputable section + +namespace C145.H2 + +open MvPolynomial C145.ThreePlane +open scoped BigOperators + +variable {n : ℕ} + +/-- The three literal finite-sum moments, with the power on the summed slot. -/ +def AllSlotMoments (rates : Fin n → ℝ) (T : Tensor n) : Prop := + (∀ p : ℕ, p ≤ 2 → ∀ j k : Fin n, ∑ i, rates i ^ p * T i j k = 0) ∧ + (∀ p : ℕ, p ≤ 2 → ∀ i k : Fin n, ∑ j, rates j ^ p * T i j k = 0) ∧ + (∀ p : ℕ, p ≤ 2 → ∀ i j : Fin n, ∑ k, rates k ^ p * T i j k = 0) + +/-- Coefficient extraction at the actual negative nodes, with the actual +oriented gaps. The guard n>=4 comes from nonzero admissibility downstream. -/ +theorem receiving_scalar_moment (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hn4 : 4 ≤ n) + (P : Polynomial ℝ) (hP : P.natDegree ≤ n - 4) + (p : ℕ) (hp : p ≤ 2) : + ∑ i, rates i ^ p * P.eval (-rates i) / di rates i = 0 := by + classical + let Q : Polynomial ℝ := Polynomial.X ^ p * P + have hQbound : Q.natDegree ≤ p + P.natDegree := by + simpa only [Q, Polynomial.natDegree_X_pow] using + (Polynomial.natDegree_mul_le (p := (Polynomial.X : Polynomial ℝ) ^ p) (q := P)) + have hQlt : Q.natDegree < n - 1 := by omega + have hQn : Q.natDegree < n := by omega + have hcast : (Q.natDegree : WithBot ℕ) < (n : WithBot ℕ) := + WithBot.coe_lt_coe.mpr hQn + have hQdegree : Q.degree < (Finset.univ : Finset (Fin n)).card := by + simpa only [Finset.card_univ, Fintype.card_fin] using + (Polynomial.degree_le_natDegree (p := Q)).trans_lt hcast + have hNodes : Function.Injective (fun i : Fin n => -rates i) := by + intro i j hij + exact hRates (neg_injective hij) + have hDen (i : Fin n) : + (∏ j ∈ (Finset.univ : Finset (Fin n)).erase i, + ((-rates i) - (-rates j))) = di rates i := by + unfold di + apply Finset.prod_congr rfl + intro j hj + ring + have hCoeff := Lagrange.coeff_eq_sum + (s := (Finset.univ : Finset (Fin n))) + (v := fun i : Fin n => -rates i) (P := Q) hNodes.injOn hQdegree + have hZero : Q.coeff (n - 1) = 0 := + Polynomial.coeff_eq_zero_of_natDegree_lt hQlt + have hRaw : ∑ i, (-rates i) ^ p * P.eval (-rates i) / di rates i = 0 := by + have hh := hCoeff.symm.trans (by + simpa only [Finset.card_univ, Fintype.card_fin] using hZero) + simpa only [Finset.card_univ, Fintype.card_fin, hDen, Q, + Polynomial.eval_mul, Polynomial.eval_X_pow] using hh + rcases (show p = 0 ∨ p = 1 ∨ p = 2 by omega) with rfl | rfl | rfl + · simpa only [pow_zero, one_mul] using hRaw + · calc + (∑ i, rates i ^ 1 * P.eval (-rates i) / di rates i) = + -(∑ i, (-rates i) ^ 1 * P.eval (-rates i) / di rates i) := by + rw [← Finset.sum_neg_distrib] + apply Finset.sum_congr rfl + intro i hi + ring + _ = 0 := by rw [hRaw, neg_zero] + · calc + (∑ i, rates i ^ 2 * P.eval (-rates i) / di rates i) = + ∑ i, (-rates i) ^ 2 * P.eval (-rates i) / di rates i := by + apply Finset.sum_congr rfl + intro i hi + ring + _ = 0 := hRaw + +/-- Isolate only the actual output coordinate zero; no generic slice API. -/ +private def receivingSlice (R : P3) (v : Fin 2 → ℝ) : Polynomial ℝ := + Polynomial.map (MvPolynomial.eval v) (finSuccEquiv ℝ 2 R) + +private theorem receivingSlice_eval (R : P3) (v : Fin 2 → ℝ) (u : ℝ) : + (receivingSlice R v).eval u = + MvPolynomial.eval (Fin.cons u v : Fin 3 → ℝ) R := by + unfold receivingSlice + rw [← MvPolynomial.eval_eq_eval_mv_eval'] + +private theorem receivingSlice_natDegree (R : P3) (v : Fin 2 → ℝ) : + (receivingSlice R v).natDegree ≤ degreeOf (0 : Fin 3) R := by + calc + (receivingSlice R v).natDegree ≤ (finSuccEquiv ℝ 2 R).natDegree := + Polynomial.natDegree_map_le + _ = degreeOf (0 : Fin 3) R := natDegree_finSuccEquiv _ + +/-- The literal quotient-residue output moments follow from admissibility. +The zero branch precedes every use of n-4, retaining all small dimensions. -/ +theorem gridResidue_output_moment (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (R : P3) (hR : QAdmissible n R) + (p : ℕ) (hp : p ≤ 2) (i j : Fin n) : + ∑ k, rates k ^ p * gridResidue rates R i j k = 0 := by + classical + rcases hR with rfl | ⟨hn4, hDegree⟩ + · simp [gridResidue] + · have hSlice : (receivingSlice R ![-rates i, -rates j]).natDegree ≤ n - 4 := + (receivingSlice_natDegree R ![-rates i, -rates j]).trans (hDegree 0) + have hm := receiving_scalar_moment rates hRates hn4 + (receivingSlice R ![-rates i, -rates j]) hSlice p hp + have hm' : + (∑ k, rates k ^ p * + MvPolynomial.eval ![-rates k, -rates i, -rates j] R / di rates k) = 0 := by + have hv (k : Fin n) : + (Fin.cons (-rates k) ![-rates i, -rates j] : Fin 3 → ℝ) = + ![-rates k, -rates i, -rates j] := by + funext r + fin_cases r <;> rfl + simpa only [receivingSlice_eval, hv] using hm + calc + (∑ k, rates k ^ p * gridResidue rates R i j k) = + (∑ k, rates k ^ p * + MvPolynomial.eval ![-rates k, -rates i, -rates j] R / di rates k) / + (di rates i * di rates j) := by + rw [Finset.sum_div] + apply Finset.sum_congr rfl + intro k hk + unfold gridResidue + field_simp [di_ne_zero rates hRates i, di_ne_zero rates hRates j, + di_ne_zero rates hRates k] + _ = 0 := by rw [hm']; exact zero_div _ + +private theorem receiving_swap_first_output (T : Tensor n) + (hT : FullSymTensor T) (i j k : Fin n) : T i j k = T k j i := by + have h := hT (Equiv.swap 0 1) ![k, i, j] + change T ((![k, i, j] : Fin 3 → Fin n) ((Equiv.swap 0 1) 1)) + ((![k, i, j] : Fin 3 → Fin n) ((Equiv.swap 0 1) 2)) + ((![k, i, j] : Fin 3 → Fin n) ((Equiv.swap 0 1) 0)) = T i j k at h + simpa [Equiv.swap_apply_def] using h.symm + +private theorem receiving_swap_second_output (T : Tensor n) + (hT : FullSymTensor T) (i j k : Fin n) : T i j k = T i k j := by + have h := hT (Equiv.swap 0 2) ![k, i, j] + change T ((![k, i, j] : Fin 3 → Fin n) ((Equiv.swap 0 2) 1)) + ((![k, i, j] : Fin 3 → Fin n) ((Equiv.swap 0 2) 2)) + ((![k, i, j] : Fin 3 → Fin n) ((Equiv.swap 0 2) 0)) = T i j k at h + simpa [Equiv.swap_apply_def] using h.symm + +/-- Full symmetry and all three moments are derived from the actual accepted +symmetric admissible quotient, for every n and every p=0,1,2. -/ +theorem gridResidue_receiving_moments (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (R : P3) + (hSym : SymPoly R) (hR : QAdmissible n R) : + FullSymTensor (gridResidue rates R) ∧ + AllSlotMoments rates (gridResidue rates R) := by + have hT := gridResidue_symmetric rates R hSym + refine ⟨hT, ?_, ?_, ?_⟩ + · intro p hp j k + calc + (∑ i, rates i ^ p * gridResidue rates R i j k) = + ∑ i, rates i ^ p * gridResidue rates R k j i := by + apply Finset.sum_congr rfl + intro i hi + rw [receiving_swap_first_output (gridResidue rates R) hT i j k] + _ = 0 := gridResidue_output_moment rates hRates R hR p hp k j + · intro p hp i k + calc + (∑ j, rates j ^ p * gridResidue rates R i j k) = + ∑ j, rates j ^ p * gridResidue rates R i k j := by + apply Finset.sum_congr rfl + intro j hj + rw [receiving_swap_second_output (gridResidue rates R) hT i j k] + _ = 0 := gridResidue_output_moment rates hRates R hR p hp i k + · intro p hp i j + exact gridResidue_output_moment rates hRates R hR p hp i j + +/-- Actual ordinary data equivalence, strengthened by derived receiving +moments of the unique quotient. The desired moments are never a premise. -/ +theorem complete_ordinary_H2_receiving_kernel (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (E : Tensor n) (hSym : FullSymTensor E) : + NullRegular rates E ↔ + ∃! R : P3, SymPoly R ∧ QAdmissible n R ∧ E = Res rates R ∧ + AllSlotMoments rates (gridResidue rates R) := by + constructor + · intro hData + obtain ⟨R, hR, hUnique⟩ := + (complete_ordinary_H2_kernel rates hRates E hSym).mp hData + refine ⟨R, ⟨hR.1, hR.2.1, hR.2.2, + (gridResidue_receiving_moments rates hRates R hR.1 hR.2.1).2⟩, ?_⟩ + intro S hS + exact hUnique S ⟨hS.1, hS.2.1, hS.2.2.1⟩ + · rintro ⟨R, hR, _⟩ + rw [hR.2.2.1] + exact res_nullRegular rates hRates R hR.2.1 + +/-- Equality of actual positive ordinary H2 data yields the unique literal +S2-S1 residue difference and its derived all-slot quotient moments. -/ +theorem equal_positive_H2_iff_receiving_residue_difference (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (S1 S2 : Tensor n) (hS1 : FullSymTensor S1) (hS2 : FullSymTensor S2) : + SamePositive rates S1 S2 ↔ + ∃! R : P3, SymPoly R ∧ QAdmissible n R ∧ S2 - S1 = Res rates R ∧ + AllSlotMoments rates (gridResidue rates R) := by + constructor + · intro hData + obtain ⟨R, hR, hUnique⟩ := + (equal_positive_H2_iff_residue_difference rates hRates hPos S1 S2 hS1 hS2).mp hData + refine ⟨R, ⟨hR.1, hR.2.1, hR.2.2, + (gridResidue_receiving_moments rates hRates R hR.1 hR.2.1).2⟩, ?_⟩ + intro S hS + exact hUnique S ⟨hS.1, hS.2.1, hS.2.2.1⟩ + · rintro ⟨R, hR, hUnique⟩ + apply (equal_positive_H2_iff_residue_difference rates hRates hPos S1 S2 hS1 hS2).mpr + refine ⟨R, ⟨hR.1, hR.2.1, hR.2.2.1⟩, ?_⟩ + intro S hS + exact hUnique S ⟨hS.1, hS.2.1, hS.2.2, + (gridResidue_receiving_moments rates hRates S hS.1 hS.2.1).2⟩ + +/-- Literal zero quotient, without injectivity or a selected grid point. -/ +theorem receiving_gridResidue_zero (rates : Fin n → ℝ) : + gridResidue rates (0 : P3) = 0 := by + funext i j k + simp [gridResidue] + +/-- Small n forces the actual quotient to vanish; the moments then follow +without rates, positivity or symmetry assumptions beyond admissibility. -/ +theorem receiving_small_quotient (rates : Fin n → ℝ) (hn : n ≤ 3) + (R : P3) (hR : QAdmissible n R) : + gridResidue rates R = 0 ∧ AllSlotMoments rates (gridResidue rates R) := by + have hZero := (admissible_small_iff_zero hn R).mp hR + rw [hZero, receiving_gridResidue_zero] + simp [AllSlotMoments] + +/-- The empty residual index has vacuous slot moments for every tensor; +no node, nonzero gap, or finite element is selected at n=0. -/ +theorem receiving_n0 (rates : Fin 0 → ℝ) (T : Tensor 0) : + AllSlotMoments rates T := by + refine ⟨?_, ?_, ?_⟩ + · intro p hp j + exact Fin.elim0 j + · intro p hp i + exact Fin.elim0 i + · intro p hp i + exact Fin.elim0 i + + +end C145.H2 + +end diff --git a/LeanPool/C145/C145SignedGroundPulseCalibration.lean b/LeanPool/C145/C145SignedGroundPulseCalibration.lean new file mode 100644 index 0000000000..4051db649e --- /dev/null +++ b/LeanPool/C145/C145SignedGroundPulseCalibration.lean @@ -0,0 +1,652 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145PhysicalFrame +public import LeanPool.C145.C145H1ModalCalibration +public import Mathlib.Analysis.SpecialFunctions.Integrals.Basic +public import Mathlib.Analysis.SpecialFunctions.Exp +public import Mathlib.Order.Filter.AtTopBot.Field +public import Mathlib.Topology.Algebra.GroupWithZero +public import Mathlib.Topology.Algebra.Monoid +public import Mathlib.Topology.Separation.Hausdorff +public import Mathlib.Algebra.Order.BigOperators.Group.Finset +public import Mathlib.Algebra.BigOperators.Fin +public import Mathlib.Tactic.FieldSimp +public import Mathlib.Tactic.FunProp +public import Mathlib.Tactic.Linarith +public import Mathlib.Tactic.Ring + +/-! +C145: actual finite coincident-pulse data calibrate the signed ground column. + +The heat action is a finite vertex-space formula, and B is its literal integral +with a vertexwise square. Its tensor expansion and its large-time limit are +proved below, rather than supplied as data. Each model has its own frame, port, +constant ground column and physical rates. Positive overlap orientation and a +simple visible spectrum are explicit. The modal equivalence and common signed +constant/port mean are conclusions. A modal equivalence is not a vertex map. + +The physical mode set is Fin (n + 1), including the one-vertex case n = 0. +Successor rate entries are physical rates, never mu plus physical rates. +No graph realization, response extraction, raw-jet, H2 or stability join occurs. +-/ + +@[expose] public section + +noncomputable section +namespace C145.Pulse +open Filter +open scoped BigOperators Topology + +/-- The actual signed-port scalar product with a frame column. -/ +def modalOverlap {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (b : Fin (n + 1) → ℝ) (i : Fin (n + 1)) : ℝ := + ∑ v, b v * Q v i + +/-- Actual finite spectral action on an arbitrary vertex vector. -/ +def heatAction {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates : Fin (n + 1) → ℝ) (t : ℝ) + (x : Fin (n + 1) → ℝ) (v : Fin (n + 1)) : ℝ := + ∑ i, Q v i * Real.exp (-rates i * t) * (∑ u, Q u i * x u) + +/-- The square is formed at each vertex before the output heat action. -/ +def coincidentPulse {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (t : ℝ) : ℝ := + ∫ s in (0 : ℝ)..t, ∑ v, b v * + heatAction Q rates (t - s) (fun u => (heatAction Q rates s b u) ^ 2) v + +/-- A scalar integral auxiliary; it is not a definition of the observed B. -/ +def decayConvolution (α γ t : ℝ) : ℝ := + ∫ s in (0 : ℝ)..t, Real.exp (-α * (t - s)) * Real.exp (-γ * s) + +/-- The factor whose positivity and occurrence in the actual limit are proved. -/ +def groundFactor {n : ℕ} (μ : ℝ) + (rates a : Fin (n + 1) → ℝ) : ℝ := + a 0 * ∑ i, a i ^ 2 / (2 * rates i - μ) + +private theorem heatAction_port {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b a : Fin (n + 1) → ℝ) + (hOverlap : ∀ i, a i = modalOverlap Q b i) + (t : ℝ) (v : Fin (n + 1)) : + heatAction Q rates t b v = + ∑ i, a i * Real.exp (-rates i * t) * Q v i := by + classical + unfold heatAction + apply Finset.sum_congr rfl + intro i hi + have hInner : (∑ u, Q u i * b u) = a i := by + rw [hOverlap i, modalOverlap] + apply Finset.sum_congr rfl + intro u hu + ring + rw [hInner] + ring + +private theorem pulse_integrand_expansion {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b a : Fin (n + 1) → ℝ) + (hOverlap : ∀ i, a i = modalOverlap Q b i) (t s : ℝ) : + (∑ v, b v * heatAction Q rates (t - s) + (fun u => (heatAction Q rates s b u) ^ 2) v) = + ∑ i, ∑ j, ∑ k, C145PhysicalFrame.T Q a i j k * + Real.exp (-rates k * (t - s)) * + Real.exp (-(rates i + rates j) * s) := by + classical + -- First expand the actual square at a fixed vertex. + have hSquare (u : Fin (n + 1)) : + (heatAction Q rates s b u) ^ 2 = + ∑ i, ∑ j, (a i * a j * Q u i * Q u j) * + Real.exp (-(rates i + rates j) * s) := by + rw [heatAction_port Q rates b a hOverlap s u, pow_two, + Finset.sum_mul_sum] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + calc + (a i * Real.exp (-rates i * s) * Q u i) * + (a j * Real.exp (-rates j * s) * Q u j) = + (a i * a j * Q u i * Q u j) * + (Real.exp (-rates i * s) * Real.exp (-rates j * s)) := by ring + _ = (a i * a j * Q u i * Q u j) * + Real.exp (-(rates i + rates j) * s) := by + rw [← Real.exp_add] + have hArg : -rates i * s + -rates j * s = + -(rates i + rates j) * s := by ring + rw [hArg] + -- Contract the actual output with b; the third overlap is derived here. + have hOutput (x : Fin (n + 1) → ℝ) : + (∑ v, b v * heatAction Q rates (t - s) x v) = + ∑ k, a k * Real.exp (-rates k * (t - s)) * + (∑ u, Q u k * x u) := by + calc + (∑ v, b v * heatAction Q rates (t - s) x v) = + ∑ v, ∑ k, b v * (Q v k * Real.exp (-rates k * (t - s)) * + (∑ u, Q u k * x u)) := by + unfold heatAction + apply Finset.sum_congr rfl + intro v hv + rw [Finset.mul_sum] + _ = ∑ k, ∑ v, b v * (Q v k * Real.exp (-rates k * (t - s)) * + (∑ u, Q u k * x u)) := by rw [Finset.sum_comm] + _ = ∑ k, a k * Real.exp (-rates k * (t - s)) * + (∑ u, Q u k * x u) := by + apply Finset.sum_congr rfl + intro k hk + calc + (∑ v, b v * (Q v k * Real.exp (-rates k * (t - s)) * + (∑ u, Q u k * x u))) = + (∑ v, b v * Q v k) * Real.exp (-rates k * (t - s)) * + (∑ u, Q u k * x u) := by + simp only [Finset.sum_mul] + apply Finset.sum_congr rfl + intro v hv + ring + _ = a k * Real.exp (-rates k * (t - s)) * + (∑ u, Q u k * x u) := by + change modalOverlap Q b k * Real.exp (-rates k * (t - s)) * + (∑ u, Q u k * x u) = _ + rw [← hOverlap k] + -- Project the square onto k, keeping the cubic as its actual vertex sum. + have hProjection (k : Fin (n + 1)) : + (∑ u, Q u k * (heatAction Q rates s b u) ^ 2) = + ∑ i, ∑ j, (a i * a j * C145PhysicalFrame.C Q i j k) * + Real.exp (-(rates i + rates j) * s) := by + simp_rw [hSquare] + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + calc + (∑ i, ∑ u, ∑ j, Q u k * ((a i * a j * Q u i * Q u j) * + Real.exp (-(rates i + rates j) * s))) = + ∑ i, ∑ j, ∑ u, Q u k * ((a i * a j * Q u i * Q u j) * + Real.exp (-(rates i + rates j) * s)) := by + apply Finset.sum_congr rfl + intro i hi + rw [Finset.sum_comm] + _ = ∑ i, ∑ j, (a i * a j * C145PhysicalFrame.C Q i j k) * + Real.exp (-(rates i + rates j) * s) := by + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + simp only [C145PhysicalFrame.C, Finset.mul_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro u hu + ring + rw [hOutput] + simp_rw [hProjection] + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + calc + (∑ i, ∑ k, ∑ j, a k * Real.exp (-rates k * (t - s)) * + ((a i * a j * C145PhysicalFrame.C Q i j k) * + Real.exp (-(rates i + rates j) * s))) = + ∑ i, ∑ j, ∑ k, a k * Real.exp (-rates k * (t - s)) * + ((a i * a j * C145PhysicalFrame.C Q i j k) * + Real.exp (-(rates i + rates j) * s)) := by + apply Finset.sum_congr rfl + intro i hi + rw [Finset.sum_comm] + _ = _ := by + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + unfold C145PhysicalFrame.T + ring + +private theorem exp_mul_interval_integral (q t : ℝ) (hq : q ≠ 0) : + (∫ s in (0 : ℝ)..t, Real.exp (q * s)) = (Real.exp (q * t) - 1) / q := by + have hSubstitution := intervalIntegral.mul_integral_comp_mul_left + (f := Real.exp) (a := (0 : ℝ)) (b := t) q + simp only [mul_zero, _root_.integral_exp, Real.exp_zero] at hSubstitution + apply (eq_div_iff hq).2 + simpa only [mul_comm] using hSubstitution + +private theorem decayConvolution_ne (α γ t : ℝ) (hne : α ≠ γ) : + decayConvolution α γ t = + (Real.exp (-α * t) - Real.exp (-γ * t)) / (γ - α) := by + have hq : α - γ ≠ 0 := sub_ne_zero.mpr hne + have hFactor : decayConvolution α γ t = Real.exp (-α * t) * + (∫ s in (0 : ℝ)..t, Real.exp ((α - γ) * s)) := by + rw [decayConvolution, ← intervalIntegral.integral_const_mul] + apply intervalIntegral.integral_congr + intro s hs + simp only [← Real.exp_add] + congr 1 + ring + have hProduct : Real.exp (-α * t) * Real.exp ((α - γ) * t) = + Real.exp (-γ * t) := by + rw [← Real.exp_add] + congr 1 + ring + rw [hFactor, exp_mul_interval_integral (α - γ) t hq] + calc + Real.exp (-α * t) * ((Real.exp ((α - γ) * t) - 1) / (α - γ)) = + (Real.exp (-α * t) * Real.exp ((α - γ) * t) - + Real.exp (-α * t)) / (α - γ) := by ring + _ = (Real.exp (-γ * t) - Real.exp (-α * t)) / (α - γ) := by rw [hProduct] + _ = (Real.exp (-α * t) - Real.exp (-γ * t)) / (γ - α) := by + have hNeg : γ - α = -(α - γ) := by ring + rw [hNeg, div_neg] + ring + +private theorem decayConvolution_eq (α t : ℝ) : + decayConvolution α α t = t * Real.exp (-α * t) := by + calc + decayConvolution α α t = ∫ _s in (0 : ℝ)..t, Real.exp (-α * t) := by + unfold decayConvolution + apply intervalIntegral.integral_congr + intro s hs + change Real.exp (-α * (t - s)) * Real.exp (-α * s) = Real.exp (-α * t) + rw [← Real.exp_add] + congr 1 + ring + _ = t * Real.exp (-α * t) := by + rw [intervalIntegral.integral_const] + simp only [sub_zero, smul_eq_mul] + +private theorem tendsto_scaled_exp (δ : ℝ) (hδ : 0 < δ) : + Tendsto (fun t : ℝ => Real.exp (-δ * t)) atTop (𝓝 0) := by + have hScale : Tendsto (fun t : ℝ => δ * t) atTop atTop := + Filter.Tendsto.const_mul_atTop hδ tendsto_id + simpa only [Function.comp_def, neg_mul] using + Real.tendsto_exp_neg_atTop_nhds_zero.comp hScale + +private theorem tendsto_time_scaled_exp (δ : ℝ) (hδ : 0 < δ) : + Tendsto (fun t : ℝ => t * Real.exp (-δ * t)) atTop (𝓝 0) := by + have hScale : Tendsto (fun t : ℝ => δ * t) atTop atTop := + Filter.Tendsto.const_mul_atTop hδ tendsto_id + have hBase : Tendsto (fun t : ℝ => (δ * t) * Real.exp (-(δ * t))) + atTop (𝓝 0) := by + simpa only [Function.comp_def, pow_one] using + (Real.tendsto_pow_mul_exp_neg_atTop_nhds_zero 1).comp hScale + have hEq (t : ℝ) : ((δ * t) * Real.exp (-(δ * t))) / δ = + t * Real.exp (-δ * t) := by + have hArg : -(δ * t) = -δ * t := by ring + rw [hArg] + field_simp [ne_of_gt hδ] + simpa only [zero_div] using (hBase.div_const δ).congr hEq + +private theorem decayConvolution_ground_limit (γ : ℝ) (hγ : 0 < γ) : + Tendsto (decayConvolution 0 γ) atTop (𝓝 (1 / γ)) := by + have hQuotient : Tendsto (fun t : ℝ => (1 - Real.exp (-γ * t)) / γ) + atTop (𝓝 (1 / γ)) := by + simpa only [sub_zero] using + ((tendsto_const_nhds : Tendsto (fun _t : ℝ => (1 : ℝ)) atTop (𝓝 1)).sub + (tendsto_scaled_exp γ hγ)).div_const γ + apply hQuotient.congr + intro t + rw [decayConvolution_ne 0 γ t (ne_of_lt hγ)] + simp only [neg_zero, zero_mul, Real.exp_zero, sub_zero] + +private theorem decayConvolution_positive_limit (α γ : ℝ) + (hα : 0 < α) (hγ : 0 < γ) : + Tendsto (decayConvolution α γ) atTop (𝓝 0) := by + by_cases hEqual : α = γ + · subst γ + have hTime := tendsto_time_scaled_exp α hα + exact hTime.congr (fun t => (decayConvolution_eq α t).symm) + · have hQuotient := ((tendsto_scaled_exp α hα).sub + (tendsto_scaled_exp γ hγ)).div_const (γ - α) + have hZero : Tendsto + (fun t : ℝ => (Real.exp (-α * t) - Real.exp (-γ * t)) / (γ - α)) + atTop (𝓝 0) := by + simpa only [sub_self, zero_div] using hQuotient + exact hZero.congr (fun t => (decayConvolution_ne α γ t hEqual).symm) + +private theorem ground_output_slice {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (hGround : ∀ v, Q v 0 = c) (i j : Fin (n + 1)) : + C145PhysicalFrame.T Q a i j 0 = + a 0 * c * a i ^ 2 * (if i = j then 1 else 0) := by + have hSymmetry : C145PhysicalFrame.T Q a i j 0 = + C145PhysicalFrame.T Q a 0 i j := by + have hC : C145PhysicalFrame.C Q i j 0 = C145PhysicalFrame.C Q 0 i j := by + unfold C145PhysicalFrame.C + apply Finset.sum_congr rfl + intro v hv + ring + unfold C145PhysicalFrame.T + rw [hC] + ring + rw [hSymmetry] + exact C145PhysicalFrame.ground_slice Q a c hQ hGround i j + +private theorem rates_ge_ground {n : ℕ} (μ : ℝ) + (rates : Fin (n + 1) → ℝ) (hGround : rates 0 = μ) + (hAbove : ∀ i : Fin n, μ < rates i.succ) (i : Fin (n + 1)) : + μ ≤ rates i := by + rcases Fin.eq_zero_or_eq_succ i with h | ⟨j, h⟩ + · rw [h, hGround] + · rw [h] + exact le_of_lt (hAbove j) + +private theorem groundFactor_reindex {m n : ℕ} (μ : ℝ) + (rates0 a0 : Fin (m + 1) → ℝ) + (rates1 a1 : Fin (n + 1) → ℝ) + (e : Fin (m + 1) ≃ Fin (n + 1)) (heGround : e 0 = 0) + (heRates : ∀ i, rates1 (e i) = rates0 i) + (heOverlaps : ∀ i, a1 (e i) = a0 i) : + groundFactor μ rates1 a1 = groundFactor μ rates0 a0 := by + have hZero : a1 0 = a0 0 := by + simpa only [heGround] using heOverlaps 0 + unfold groundFactor + rw [hZero, ← e.sum_comp (fun j => a1 j ^ 2 / (2 * rates1 j - μ))] + simp_rw [heRates, heOverlaps] + +private theorem ground_overlap_mean {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (b a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (hGround : ∀ v, Q v 0 = c) + (hOverlap : ∀ i, a i = modalOverlap Q b i) : + a 0 = c * (∑ v, b v) ∧ + a 0 * c = (∑ v, b v) / (n + 1 : ℝ) := by + have hOverlapZero : a 0 = c * (∑ v, b v) := by + rw [hOverlap 0, modalOverlap] + simp only [hGround, Finset.mul_sum] + apply Finset.sum_congr rfl + intro v hv + ring + have hN : (n + 1 : ℝ) ≠ 0 := by + have hn : (0 : ℝ) ≤ n := Nat.cast_nonneg n + linarith + have hNormalization := C145PhysicalFrame.ground_normalization Q c hQ hGround + refine ⟨hOverlapZero, ?_⟩ + apply (eq_div_iff hN).2 + rw [hOverlapZero] + calc + (c * ∑ v, b v) * c * (n + 1 : ℝ) = + (∑ v, b v) * ((n + 1 : ℝ) * c ^ 2) := by ring + _ = ∑ v, b v := by rw [hNormalization, mul_one] + +/-- Actual vertex-space B equals the derived finite modal convolution sum. -/ +theorem coincidentPulse_expansion {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b a : Fin (n + 1) → ℝ) + (hOverlap : ∀ i, a i = modalOverlap Q b i) (t : ℝ) : + coincidentPulse Q rates b t = + ∑ i, ∑ j, ∑ k, C145PhysicalFrame.T Q a i j k * + decayConvolution (rates k) (rates i + rates j) t := by + classical + let f := fun (i j k : Fin (n + 1)) (s : ℝ) => + C145PhysicalFrame.T Q a i j k * Real.exp (-rates k * (t - s)) * + Real.exp (-(rates i + rates j) * s) + have hContinuous (i j k : Fin (n + 1)) : Continuous (f i j k) := by + dsimp only [f] + fun_prop + have hIntegrable (i j k : Fin (n + 1)) : + IntervalIntegrable (f i j k) MeasureTheory.volume 0 t := + (hContinuous i j k).intervalIntegrable 0 t + have hSumJ (i : Fin (n + 1)) : + IntervalIntegrable (fun s => ∑ j, ∑ k, f i j k s) + MeasureTheory.volume 0 t := by + have h : Continuous (fun s => ∑ j, ∑ k, f i j k s) := by fun_prop + exact h.intervalIntegrable 0 t + have hSumK (i j : Fin (n + 1)) : + IntervalIntegrable (fun s => ∑ k, f i j k s) + MeasureTheory.volume 0 t := by + have h : Continuous (fun s => ∑ k, f i j k s) := by fun_prop + exact h.intervalIntegrable 0 t + calc + coincidentPulse Q rates b t = ∫ s in (0 : ℝ)..t, ∑ i, ∑ j, ∑ k, f i j k s := by + unfold coincidentPulse + apply intervalIntegral.integral_congr + intro s hs + exact pulse_integrand_expansion Q rates b a hOverlap t s + _ = ∑ i, ∫ s in (0 : ℝ)..t, ∑ j, ∑ k, f i j k s := + intervalIntegral.integral_finsetSum (fun i hi => hSumJ i) + _ = ∑ i, ∑ j, ∑ k, ∫ s in (0 : ℝ)..t, f i j k s := by + apply Finset.sum_congr rfl + intro i hi + rw [intervalIntegral.integral_finsetSum (fun j hj => hSumK i j)] + apply Finset.sum_congr rfl + intro j hj + exact intervalIntegral.integral_finsetSum (fun k hk => hIntegrable i j k) + _ = _ := by + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + dsimp only [f, decayConvolution] + rw [← intervalIntegral.integral_const_mul] + apply intervalIntegral.integral_congr + intro s hs + ring + +/-- Ground scaling is derived inside the actual finite integral, at every t. -/ +theorem scaled_coincidentPulse_expansion {n : ℕ} + (μ : ℝ) (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b a : Fin (n + 1) → ℝ) + (hOverlap : ∀ i, a i = modalOverlap Q b i) (t : ℝ) : + Real.exp (μ * t) * coincidentPulse Q rates b t = + ∑ i, ∑ j, ∑ k, C145PhysicalFrame.T Q a i j k * + decayConvolution (rates k - μ) (rates i + rates j - μ) t := by + classical + have hScale (α γ : ℝ) : + Real.exp (μ * t) * decayConvolution α γ t = + decayConvolution (α - μ) (γ - μ) t := by + unfold decayConvolution + rw [← intervalIntegral.integral_const_mul] + apply intervalIntegral.integral_congr + intro s hs + simp only [← Real.exp_add] + congr 1 + ring + rw [coincidentPulse_expansion Q rates b a hOverlap t] + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro k hk + calc + Real.exp (μ * t) * (C145PhysicalFrame.T Q a i j k * + decayConvolution (rates k) (rates i + rates j) t) = + C145PhysicalFrame.T Q a i j k * + (Real.exp (μ * t) * decayConvolution (rates k) (rates i + rates j) t) := by ring + _ = _ := by rw [hScale] + +/-- The actual empty-interval coefficient vanishes without spectral premises. -/ +theorem coincidentPulse_zero {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) : coincidentPulse Q rates b 0 = 0 := by + unfold coincidentPulse + exact intervalIntegral.integral_same + +/-- The signed constant is the only sign in the derived large-time factor. -/ +theorem signed_ground_limit {n : ℕ} (μ c : ℝ) (hμ : 0 < μ) + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b a : Fin (n + 1) → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) + (hGround : ∀ v, Q v 0 = c) + (hRateGround : rates 0 = μ) + (hAbove : ∀ i : Fin n, μ < rates i.succ) + (hOverlap : ∀ i, a i = modalOverlap Q b i) : + Tendsto (fun t : ℝ => Real.exp (μ * t) * coincidentPulse Q rates b t) + atTop (𝓝 (c * groundFactor μ rates a)) := by + classical + have hGamma (i j : Fin (n + 1)) : 0 < rates i + rates j - μ := by + have hi := rates_ge_ground μ rates hRateGround hAbove i + have hj := rates_ge_ground μ rates hRateGround hAbove j + linarith + let L := fun (i j k : Fin (n + 1)) => + if k = 0 then C145PhysicalFrame.T Q a i j 0 / (rates i + rates j - μ) else 0 + have hTerm (i j k : Fin (n + 1)) : + Tendsto (fun t : ℝ => C145PhysicalFrame.T Q a i j k * + decayConvolution (rates k - μ) (rates i + rates j - μ) t) + atTop (𝓝 (L i j k)) := by + by_cases hk : k = 0 + · subst k + have h := (decayConvolution_ground_limit (rates i + rates j - μ) + (hGamma i j)).const_mul (C145PhysicalFrame.T Q a i j 0) + simpa only [hRateGround, sub_self, L, ite_eq_left rfl, div_eq_mul_inv, one_mul] using h + · have hAlpha : 0 < rates k - μ := by + rcases Fin.eq_zero_or_eq_succ k with hZero | ⟨r, hr⟩ + · exact False.elim (hk hZero) + · rw [hr] + linarith [hAbove r] + -- This helper handles alpha = gamma with t * exp(-alpha*t). + have h := (decayConvolution_positive_limit (rates k - μ) + (rates i + rates j - μ) hAlpha (hGamma i j)).const_mul + (C145PhysicalFrame.T Q a i j k) + simpa only [L, ite_eq_right hk, mul_zero] using h + have hFinite : Tendsto (fun t : ℝ => ∑ i, ∑ j, ∑ k, + C145PhysicalFrame.T Q a i j k * + decayConvolution (rates k - μ) (rates i + rates j - μ) t) + atTop (𝓝 (∑ i, ∑ j, ∑ k, L i j k)) := by + apply tendsto_finsetSum + intro i hi + apply tendsto_finsetSum + intro j hj + apply tendsto_finsetSum + intro k hk + exact hTerm i j k + have hK (i j : Fin (n + 1)) : + (∑ k, L i j k) = C145PhysicalFrame.T Q a i j 0 / + (rates i + rates j - μ) := by + rw [Fin.sum_univ_succ] + simp only [L, ite_eq_left rfl, Fin.succ_ne_zero, ite_false, + Finset.sum_const_zero, add_zero] + have hJ (i : Fin (n + 1)) : + (∑ j, C145PhysicalFrame.T Q a i j 0 / (rates i + rates j - μ)) = + a 0 * c * a i ^ 2 / (2 * rates i - μ) := by + have hSummand (j : Fin (n + 1)) : + C145PhysicalFrame.T Q a i j 0 / (rates i + rates j - μ) = + if i = j then a 0 * c * a i ^ 2 / (2 * rates i - μ) else 0 := by + rw [ground_output_slice Q a c hQ hGround i j] + by_cases hij : i = j + · subst j + have hDenominator : rates i + rates i - μ = 2 * rates i - μ := by ring + simp only [ite_true, mul_one, hDenominator] + · simp only [ite_eq_right hij, mul_zero, zero_div] + simp_rw [hSummand] + simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true] + have hMean := ground_overlap_mean Q b a c hQ hGround hOverlap + have hCollapse : (∑ i, ∑ j, ∑ k, L i j k) = c * groundFactor μ rates a := by + simp_rw [hK, hJ] + calc + (∑ i, a 0 * c * a i ^ 2 / (2 * rates i - μ)) = + (a 0 * c) * (∑ i, a i ^ 2 / (2 * rates i - μ)) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + ring + _ = ((∑ v, b v) / (n + 1 : ℝ)) * + (∑ i, a i ^ 2 / (2 * rates i - μ)) := by rw [hMean.2] + _ = c * groundFactor μ rates a := by + rw [← hMean.2] + unfold groundFactor + ring + rw [hCollapse] at hFinite + exact hFinite.congr (fun t => + (scaled_coincidentPulse_expansion μ Q rates b a hOverlap t).symm) + +/-- Every denominator is positive before the positive factor is used to cancel. -/ +theorem groundFactor_pos {n : ℕ} (μ : ℝ) (hμ : 0 < μ) + (rates a : Fin (n + 1) → ℝ) + (hRateGround : rates 0 = μ) + (hAbove : ∀ i : Fin n, μ < rates i.succ) + (ha : ∀ i, 0 < a i) : 0 < groundFactor μ rates a := by + have hDenominator (i : Fin (n + 1)) : 0 < 2 * rates i - μ := by + have hi := rates_ge_ground μ rates hRateGround hAbove i + linarith + have hSummand (i : Fin (n + 1)) : 0 < a i ^ 2 / (2 * rates i - μ) := + div_pos (sq_pos_of_ne_zero (ne_of_gt (ha i))) (hDenominator i) + have hSum : 0 < ∑ i, a i ^ 2 / (2 * rates i - μ) := by + apply Finset.sum_pos (fun i hi => hSummand i) + exact ⟨0, Finset.mem_univ 0⟩ + exact mul_pos (ha 0) hSum + +/-- Literal H1 and actual nonnegative-time B data force common signed c and mean. +No matching arrays, size equality, modal equivalence or asymptotic amplitude is +supplied. Each frame and vertex port remains in its own original space. -/ +theorem actual_signed_ground_calibration {m n : ℕ} + (μ c0 c1 : ℝ) (hμ : 0 < μ) + (Q0 : Fin (m + 1) → Fin (m + 1) → ℝ) + (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates0 b0 a0 : Fin (m + 1) → ℝ) + (rates1 b1 a1 : Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround0 : ∀ v, Q0 v 0 = c0) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hRateGround0 : rates0 0 = μ) + (hRateGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < a0 i) + (ha1 : ∀ j, 0 < a1 j) + (hOverlap0 : ∀ i, a0 i = modalOverlap Q0 b0 i) + (hOverlap1 : ∀ j, a1 j = modalOverlap Q1 b1 j) + (hH1 : ∀ s : ℝ, 0 < s → + C145.H1.firstTransfer rates0 a0 s = C145.H1.firstTransfer rates1 a1 s) + (hB : ∀ t : ℝ, 0 ≤ t → + coincidentPulse Q0 rates0 b0 t = coincidentPulse Q1 rates1 b1 t) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, a1 (e i) = a0 i) ∧ + c0 = c1 ∧ (∑ v, b0 v) = (∑ v, b1 v) := by + obtain ⟨e, hSize, heGround, heRates, heOverlaps⟩ := + C145.H1.known_ground_positive_modal_identification μ hμ rates0 a0 rates1 a1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 ha0 ha1 hH1 + have hFactor : groundFactor μ rates1 a1 = groundFactor μ rates0 a0 := + groundFactor_reindex μ rates0 a0 rates1 a1 e heGround heRates heOverlaps + have hLimit0 := signed_ground_limit μ c0 hμ Q0 rates0 b0 a0 + hQ0 hGround0 hRateGround0 hAbove0 hOverlap0 + have hLimit1 := signed_ground_limit μ c1 hμ Q1 rates1 b1 a1 + hQ1 hGround1 hRateGround1 hAbove1 hOverlap1 + have hEventual : + (fun t : ℝ => Real.exp (μ * t) * coincidentPulse Q0 rates0 b0 t) =ᶠ[atTop] + (fun t : ℝ => Real.exp (μ * t) * coincidentPulse Q1 rates1 b1 t) := by + filter_upwards [Filter.eventually_ge_atTop (0 : ℝ)] with t ht + rw [hB t ht] + have hLimits : c0 * groundFactor μ rates0 a0 = c1 * groundFactor μ rates1 a1 := + tendsto_nhds_unique_of_eventuallyEq hLimit0 hLimit1 hEventual + have hPositive : 0 < groundFactor μ rates0 a0 := + groundFactor_pos μ hμ rates0 a0 hRateGround0 hAbove0 ha0 + have hConstant : c0 = c1 := by + apply mul_right_cancel₀ (ne_of_gt hPositive) + calc + c0 * groundFactor μ rates0 a0 = c1 * groundFactor μ rates1 a1 := hLimits + _ = c1 * groundFactor μ rates0 a0 := by rw [hFactor] + have hOverlapGround : a1 0 = a0 0 := by + simpa only [heGround] using heOverlaps 0 + have hMean0 := ground_overlap_mean Q0 b0 a0 c0 hQ0 hGround0 hOverlap0 + have hMean1 := ground_overlap_mean Q1 b1 a1 c1 hQ1 hGround1 hOverlap1 + have hMeans : (∑ v, b0 v) = (∑ v, b1 v) := by + apply mul_left_cancel₀ (C145PhysicalFrame.ground_ne_zero Q0 c0 hQ0 hGround0) + calc + c0 * (∑ v, b0 v) = a0 0 := hMean0.1.symm + _ = a1 0 := hOverlapGround.symm + _ = c1 * (∑ v, b1 v) := hMean1.1 + _ = c0 * (∑ v, b1 v) := by rw [hConstant] + exact ⟨e, hSize, heGround, heRates, heOverlaps, hConstant, hMeans⟩ + + +end C145.Pulse +end + +end diff --git a/LeanPool/C145/C145SixFixedProducts.lean b/LeanPool/C145/C145SixFixedProducts.lean new file mode 100644 index 0000000000..967d35f8e3 --- /dev/null +++ b/LeanPool/C145/C145SixFixedProducts.lean @@ -0,0 +1,397 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145ReceivingLagrangeMoments + +/-! +DRE6 Lemma 3.1 on the actual complete ordinary residual H2 kernel. +The receiving moments are those of V = gridResidue rates R, never Res rates R. +Only rate injectivity is used in the actual kernel joins. Positivity occurs +solely in the positive-data corollaries. Ground extension is literally zero +on every ground-containing entry and retains all n+1 output coordinates. +-/ + +@[expose] public section + +noncomputable section +namespace C145.H2 +open MvPolynomial C145.ThreePlane +open scoped BigOperators +variable {n : ℕ} + +/-- Two non-ground power inputs and one residual output. Wpq is this same +contraction applied to the auxiliary tensor V. -/ +def powerContract (rates : Fin n → ℝ) (T : Tensor n) (p q : ℕ) (k : Fin n) : ℝ := + ∑ i, ∑ j, rates i ^ p * rates j ^ q * T i j k + +/-- Source notation Wpq for the same actual contraction of the auxiliary V. -/ +abbrev Wpq (rates : Fin n → ℝ) (V : Tensor n) (p q : ℕ) (k : Fin n) : ℝ := + powerContract rates V p q k + +/-- Literal Xi at the negative nodes, multiplied by the auxiliary V. -/ +def xiWeighted (rates : Fin n → ℝ) (V : Tensor n) : Tensor n := + fun i j k => MvPolynomial.eval ![-rates k, -rates i, -rates j] Xi * V i j k + +/-- Six literal vector identities, stated pointwise on every output. -/ +def SixNull (rates : Fin n → ℝ) (T : Tensor n) : Prop := + ∀ k : Fin n, + powerContract rates T 0 0 k = 0 ∧ powerContract rates T 0 1 k = 0 ∧ + powerContract rates T 0 2 k = 0 ∧ powerContract rates T 1 1 k = 0 ∧ + powerContract rates T 0 3 k + powerContract rates T 1 2 k = 0 ∧ + powerContract rates T 2 2 k + 2 * powerContract rates T 0 4 k + + 2 * powerContract rates T 1 3 k = 0 + +/-- The first auxiliary moment kills every contraction of first degree <=2. -/ +theorem powerContract_moment_left (rates : Fin n → ℝ) (V : Tensor n) + (hMom : AllSlotMoments rates V) (p q : ℕ) (hp : p ≤ 2) (k : Fin n) : + powerContract rates V p q k = 0 := by + classical + calc + powerContract rates V p q k = + ∑ j, rates j ^ q * (∑ i, rates i ^ p * V i j k) := by + unfold powerContract + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + ring + _ = 0 := by simp only [hMom.1 p hp, mul_zero, Finset.sum_const_zero] + +/-- The second auxiliary moment kills every contraction of second degree <=2. -/ +theorem powerContract_moment_right (rates : Fin n → ℝ) (V : Tensor n) + (hMom : AllSlotMoments rates V) (p q : ℕ) (hq : q ≤ 2) (k : Fin n) : + powerContract rates V p q k = 0 := by + classical + calc + powerContract rates V p q k = + ∑ i, rates i ^ p * (∑ j, rates j ^ q * V i j k) := by + unfold powerContract + apply Finset.sum_congr rfl + intro i hi + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j hj + ring + _ = 0 := by simp only [hMom.2.1 q hq, mul_zero, Finset.sum_const_zero] + +/-- Only the symmetry of the two contracted slots is needed for Wpq=Wqp. -/ +theorem powerContract_swap (rates : Fin n → ℝ) (V : Tensor n) + (hInput : ∀ i j k, V i j k = V j i k) (p q : ℕ) (k : Fin n) : + powerContract rates V p q k = powerContract rates V q p k := by + classical + unfold powerContract + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro i hi + rw [hInput i j k] + ring + +/-- The entire ten-term Xi cubic contraction, before any moments or symmetry. +This explicitly retains W(p+3,q), W(p,q+3), and all output-rate terms. -/ +theorem powerContract_xiWeighted (rates : Fin n → ℝ) (V : Tensor n) + (p q : ℕ) (k : Fin n) : + powerContract rates (xiWeighted rates V) p q k = + powerContract rates V (p + 3) q k + powerContract rates V p (q + 3) k + + rates k ^ 3 * powerContract rates V p q k - + powerContract rates V (p + 2) (q + 1) k - + rates k * powerContract rates V (p + 2) q k - + powerContract rates V (p + 1) (q + 2) k - + rates k * powerContract rates V p (q + 2) k - + rates k ^ 2 * powerContract rates V (p + 1) q k - + rates k ^ 2 * powerContract rates V p (q + 1) k + + 2 * rates k * powerContract rates V (p + 1) (q + 1) k := by + classical + calc + powerContract rates (xiWeighted rates V) p q k = + ∑ i, ∑ j, + (rates i ^ (p + 3) * rates j ^ q * V i j k + + rates i ^ p * rates j ^ (q + 3) * V i j k + + rates k ^ 3 * (rates i ^ p * rates j ^ q * V i j k) - + rates i ^ (p + 2) * rates j ^ (q + 1) * V i j k - + rates k * (rates i ^ (p + 2) * rates j ^ q * V i j k) - + rates i ^ (p + 1) * rates j ^ (q + 2) * V i j k - + rates k * (rates i ^ p * rates j ^ (q + 2) * V i j k) - + rates k ^ 2 * (rates i ^ (p + 1) * rates j ^ q * V i j k) - + rates k ^ 2 * (rates i ^ p * rates j ^ (q + 1) * V i j k) + + (2 * rates k) * (rates i ^ (p + 1) * rates j ^ (q + 1) * V i j k)) := by + unfold powerContract xiWeighted + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + rw [xi_negative_node_expansion] + simp only [pow_add] + ring + _ = _ := by + simp only [powerContract, Finset.sum_add_distrib, + Finset.sum_sub_distrib, Finset.mul_sum] + +/-- Before input symmetry, P13 has W43-W34 as well as -rate(k)*W33. +Neither W43 nor W34 is individually eliminated by the receiving moments. -/ +theorem p13_before_input_swap (rates : Fin n → ℝ) (V : Tensor n) + (hMom : AllSlotMoments rates V) (k : Fin n) : + powerContract rates (xiWeighted rates V) 1 3 k = + powerContract rates V 4 3 k - powerContract rates V 3 4 k - + rates k * powerContract rates V 3 3 k := by + have hL := powerContract_moment_left rates V hMom + have hR := powerContract_moment_right rates V hMom + simpa [hL, hR] using powerContract_xiWeighted rates V 1 3 k + +/-- All nine relevant contractions. The last two use exactly W43=W34, +proved from input symmetry; no output-rate restriction or positivity occurs. -/ +theorem nine_xi_contractions (rates : Fin n → ℝ) (V : Tensor n) + (hInput : ∀ i j k, V i j k = V j i k) (hMom : AllSlotMoments rates V) + (k : Fin n) : + powerContract rates (xiWeighted rates V) 0 0 k = 0 ∧ + powerContract rates (xiWeighted rates V) 0 1 k = 0 ∧ + powerContract rates (xiWeighted rates V) 0 2 k = 0 ∧ + powerContract rates (xiWeighted rates V) 1 1 k = 0 ∧ + powerContract rates (xiWeighted rates V) 0 3 k = powerContract rates V 3 3 k ∧ + powerContract rates (xiWeighted rates V) 1 2 k = -powerContract rates V 3 3 k ∧ + powerContract rates (xiWeighted rates V) 0 4 k = powerContract rates V 3 4 k ∧ + powerContract rates (xiWeighted rates V) 1 3 k = + -rates k * powerContract rates V 3 3 k ∧ + powerContract rates (xiWeighted rates V) 2 2 k = + -2 * powerContract rates V 3 4 k + 2 * rates k * powerContract rates V 3 3 k := by + have hL := powerContract_moment_left rates V hMom + have hR := powerContract_moment_right rates V hMom + have h43 := powerContract_swap rates V hInput 4 3 k + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · simpa [hL, hR] using powerContract_xiWeighted rates V 0 0 k + · simpa [hL, hR] using powerContract_xiWeighted rates V 0 1 k + · simpa [hL, hR] using powerContract_xiWeighted rates V 0 2 k + · simpa [hL, hR] using powerContract_xiWeighted rates V 1 1 k + · simpa [hL, hR] using powerContract_xiWeighted rates V 0 3 k + · simpa [hL, hR] using powerContract_xiWeighted rates V 1 2 k + · simpa [hL, hR] using powerContract_xiWeighted rates V 0 4 k + · rw [p13_before_input_swap rates V hMom k, h43] + ring + · have h := powerContract_xiWeighted rates V 2 2 k + simp only [Nat.reduceAdd] at h + simp only [Std.le_refl, hR, hL, add_zero, mul_zero, h43, zero_sub, sub_zero] at h + rw [h] + ring + +/-- Abstract finite algebra helper. Its moment and symmetry hypotheses are +fully discharged by the actual quotient in res_six_fixed_products below. -/ +theorem six_fixed_products_of_moment_null (rates : Fin n → ℝ) (V : Tensor n) + (hInput : ∀ i j k, V i j k = V j i k) (hMom : AllSlotMoments rates V) : + SixNull rates (xiWeighted rates V) := by + intro k + obtain ⟨h00, h01, h02, h11, h03, h12, h04, h13, h22⟩ := + nine_xi_contractions rates V hInput hMom k + refine ⟨h00, h01, h02, h11, ?_, ?_⟩ + · rw [h03, h12] + ring + · rw [h22, h04, h13] + ring + +private theorem fixed_input_symmetry (V : Tensor n) (hV : FullSymTensor V) + (i j k : Fin n) : V i j k = V j i k := by + have h := hV (Equiv.swap 1 2) ![k, i, j] + change V ((![k, i, j] : Fin 3 → Fin n) ((Equiv.swap 1 2) 1)) + ((![k, i, j] : Fin 3 → Fin n) ((Equiv.swap 1 2) 2)) + ((![k, i, j] : Fin 3 → Fin n) ((Equiv.swap 1 2) 0)) = V i j k at h + simpa [Equiv.swap_apply_def] using h.symm + +/-- Actual quotient identity, with no moment claim about Res itself. -/ +theorem res_eq_xiWeighted_gridResidue (rates : Fin n → ℝ) (R : P3) : + Res rates R = xiWeighted rates (gridResidue rates R) := by + funext i j k + rw [res_entry] + simp only [xiWeighted, gridResidue, div_eq_mul_inv] + ring + +/-- DRE6 Lemma 3.1 for every actual symmetric admissible quotient, all n. +The accepted receiving theorem supplies all moments from degree bounds. -/ +theorem res_six_fixed_products (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (R : P3) + (hSym : SymPoly R) (hR : QAdmissible n R) : SixNull rates (Res rates R) := by + obtain ⟨hV, hMom⟩ := gridResidue_receiving_moments rates hRates R hSym hR + rw [res_eq_xiWeighted_gridResidue] + exact six_fixed_products_of_moment_null rates (gridResidue rates R) + (fixed_input_symmetry (gridResidue rates R) hV) hMom + +/-- Every fully symmetric actual ordinary residual kernel element has the six +identities. No desired moment, product, quotient or physical premise occurs. -/ +theorem ordinary_H2_six_fixed_products (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (E : Tensor n) + (hSym : FullSymTensor E) (hData : NullRegular rates E) : SixNull rates E := by + obtain ⟨R, hR, _⟩ := (complete_ordinary_H2_kernel rates hRates E hSym).mp hData + rw [hR.2.2] + exact res_six_fixed_products rates hRates R hR.1 hR.2.1 + +/-- Literal zero extension: any ground input or output gives zero. -/ +def groundZero (E : Tensor n) : Tensor (n + 1) := + Fin.cases (fun _ _ => 0) + (fun i => Fin.cases (fun _ => 0) (fun j => Fin.cases 0 (fun k => E i j k))) + +/-- Input sums remain on Fin n; output k ranges over all Fin(n+1). -/ +def fullPower (rates : Fin n → ℝ) (S : Tensor (n + 1)) (p q : ℕ) + (k : Fin (n + 1)) : ℝ := + ∑ i : Fin n, ∑ j : Fin n, rates i ^ p * rates j ^ q * S i.succ j.succ k + +/-- The same six null combinations with the ground output retained. -/ +def FullSixNull (rates : Fin n → ℝ) (S : Tensor (n + 1)) : Prop := + ∀ k : Fin (n + 1), + fullPower rates S 0 0 k = 0 ∧ fullPower rates S 0 1 k = 0 ∧ + fullPower rates S 0 2 k = 0 ∧ fullPower rates S 1 1 k = 0 ∧ + fullPower rates S 0 3 k + fullPower rates S 1 2 k = 0 ∧ + fullPower rates S 2 2 k + 2 * fullPower rates S 0 4 k + + 2 * fullPower rates S 1 3 k = 0 + +theorem groundZero_ground_first (E : Tensor n) (j k : Fin (n + 1)) : + groundZero E 0 j k = 0 := rfl + +theorem groundZero_ground_second (E : Tensor n) (i k : Fin (n + 1)) : + groundZero E i 0 k = 0 := by + refine Fin.cases ?_ (fun a => ?_) i <;> rfl + +theorem groundZero_ground_output (E : Tensor n) (i j : Fin (n + 1)) : + groundZero E i j 0 = 0 := by + refine Fin.cases ?_ (fun a => ?_) i + · rfl + · refine Fin.cases ?_ (fun b => ?_) j <;> rfl + +theorem groundZero_succ (E : Tensor n) (i j k : Fin n) : + groundZero E i.succ j.succ k.succ = E i j k := rfl + +theorem fullPower_groundZero_zero (rates : Fin n → ℝ) (E : Tensor n) (p q : ℕ) : + fullPower rates (groundZero E) p q 0 = 0 := by + simp [fullPower, groundZero_ground_output] + +theorem fullPower_groundZero_succ (rates : Fin n → ℝ) (E : Tensor n) + (p q : ℕ) (k : Fin n) : + fullPower rates (groundZero E) p q k.succ = powerContract rates E p q k := rfl + +/-- Honest all-output join, including n=0: ground plus every successor output. -/ +theorem full_six_groundZero_iff (rates : Fin n → ℝ) (E : Tensor n) : + FullSixNull rates (groundZero E) ↔ SixNull rates E := by + constructor + · intro h k + simpa only [fullPower_groundZero_succ] using h k.succ + · intro h k + refine Fin.cases ?_ (fun a => ?_) k + · simp [fullPower_groundZero_zero] + · simpa only [fullPower_groundZero_succ] using h a + +/-- Complete actual kernel, strengthened by DERIVED auxiliary moments and six +full-output null products. These extra conclusions are never hypotheses. -/ +theorem complete_ordinary_H2_six_fixed_kernel (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (E : Tensor n) (hSym : FullSymTensor E) : + NullRegular rates E ↔ ∃! R : P3, + SymPoly R ∧ QAdmissible n R ∧ E = Res rates R ∧ + AllSlotMoments rates (gridResidue rates R) ∧ FullSixNull rates (groundZero E) := by + constructor + · intro hData + obtain ⟨R, hR, hUnique⟩ := + (complete_ordinary_H2_receiving_kernel rates hRates E hSym).mp hData + refine ⟨R, ⟨hR.1, hR.2.1, hR.2.2.1, hR.2.2.2, ?_⟩, ?_⟩ + · exact (full_six_groundZero_iff rates E).mpr + (ordinary_H2_six_fixed_products rates hRates E hSym hData) + · intro S hS + exact hUnique S ⟨hS.1, hS.2.1, hS.2.2.1, hS.2.2.2.1⟩ + · rintro ⟨R, hR, _⟩ + rw [hR.2.2.1] + exact res_nullRegular rates hRates R hR.2.1 + +/-- Equality means all six literal vector values agree, at every output. -/ +def SameFullSix (rates : Fin n → ℝ) (S1 S2 : Tensor (n + 1)) : Prop := + ∀ k : Fin (n + 1), + fullPower rates S2 0 0 k = fullPower rates S1 0 0 k ∧ + fullPower rates S2 0 1 k = fullPower rates S1 0 1 k ∧ + fullPower rates S2 0 2 k = fullPower rates S1 0 2 k ∧ + fullPower rates S2 1 1 k = fullPower rates S1 1 1 k ∧ + fullPower rates S2 0 3 k + fullPower rates S2 1 2 k = + fullPower rates S1 0 3 k + fullPower rates S1 1 2 k ∧ + fullPower rates S2 2 2 k + 2 * fullPower rates S2 0 4 k + + 2 * fullPower rates S2 1 3 k = + fullPower rates S1 2 2 k + 2 * fullPower rates S1 0 4 k + + 2 * fullPower rates S1 1 3 k + +theorem fullPower_sub (rates : Fin n → ℝ) (S1 S2 : Tensor (n + 1)) + (p q : ℕ) (k : Fin (n + 1)) : + fullPower rates (S2 - S1) p q k = fullPower rates S2 p q k - + fullPower rates S1 p q k := by + simp only [fullPower, Pi.sub_apply, mul_sub, Finset.sum_sub_distrib] + +/-- Linearity of precisely the six displayed combinations. -/ +theorem sameFullSix_iff_difference (rates : Fin n → ℝ) (S1 S2 : Tensor (n + 1)) : + SameFullSix rates S1 S2 ↔ FullSixNull rates (S2 - S1) := by + constructor + · intro h k + obtain ⟨h00, h01, h02, h11, h0312, h220413⟩ := h k + simp only [fullPower_sub] + exact ⟨by linarith, by linarith, by linarith, by linarith, by linarith, by linarith⟩ + · intro h k + obtain ⟨h00, h01, h02, h11, h0312, h220413⟩ := h k + simp only [fullPower_sub] at h00 h01 h02 h11 h0312 h220413 + exact ⟨by linarith, by linarith, by linarith, by linarith, by linarith, by linarith⟩ + +/-- Actual residual-data invariance for full tensors whose difference is the +literal zero-ground extension. The common ground entries are explicit in hDiff. -/ +theorem ordinary_H2_full_six_fixed (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (E : Tensor n) (hSym : FullSymTensor E) + (hData : NullRegular rates E) (S1 S2 : Tensor (n + 1)) + (hDiff : S2 - S1 = groundZero E) : SameFullSix rates S1 S2 := by + apply (sameFullSix_iff_difference rates S1 S2).mpr + rw [hDiff] + exact (full_six_groundZero_iff rates E).mpr + (ordinary_H2_six_fixed_products rates hRates E hSym hData) + +/-- Positive-data S2-S1 join. Positivity is needed only to pass from actual +all-positive response equality to the accepted ordinary residue description. -/ +theorem positive_H2_difference_six_fixed (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (S1 S2 : Tensor n) (hS1 : FullSymTensor S1) (hS2 : FullSymTensor S2) + (hData : SamePositive rates S1 S2) : + FullSixNull rates (groundZero (S2 - S1)) := by + obtain ⟨R, hR, _⟩ := + (equal_positive_H2_iff_receiving_residue_difference rates hRates hPos S1 S2 hS1 hS2).mp hData + apply (full_six_groundZero_iff rates (S2 - S1)).mpr + rw [hR.2.2.1] + exact res_six_fixed_products rates hRates R hR.1 hR.2.1 + +/-- Positive-data equality, with the complete unique quotient retained and +its six full-output identities derived on the right side of the equivalence. -/ +theorem equal_positive_H2_iff_six_fixed_difference (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (S1 S2 : Tensor n) (hS1 : FullSymTensor S1) (hS2 : FullSymTensor S2) : + SamePositive rates S1 S2 ↔ + (∃! R : P3, SymPoly R ∧ QAdmissible n R ∧ S2 - S1 = Res rates R ∧ + AllSlotMoments rates (gridResidue rates R)) ∧ + FullSixNull rates (groundZero (S2 - S1)) := by + constructor + · intro hData + exact ⟨(equal_positive_H2_iff_receiving_residue_difference + rates hRates hPos S1 S2 hS1 hS2).mp hData, + positive_H2_difference_six_fixed rates hRates hPos S1 S2 hS1 hS2 hData⟩ + · intro h + exact (equal_positive_H2_iff_receiving_residue_difference + rates hRates hPos S1 S2 hS1 hS2).mpr h.1 + +/-- The six vectors agree on full tensors with the displayed residual +positive-H2 difference. No physical calibration or response inference is claimed. -/ +theorem positive_H2_full_six_fixed (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (S1 S2 : Tensor n) (hS1 : FullSymTensor S1) (hS2 : FullSymTensor S2) + (hData : SamePositive rates S1 S2) (U1 U2 : Tensor (n + 1)) + (hDiff : U2 - U1 = groundZero (S2 - S1)) : SameFullSix rates U1 U2 := by + apply (sameFullSix_iff_difference rates U1 U2).mpr + rw [hDiff] + exact positive_H2_difference_six_fixed rates hRates hPos S1 S2 hS1 hS2 hData + +end C145.H2 + +end diff --git a/LeanPool/C145/C145SmallPhysicalTraceSeparation.lean b/LeanPool/C145/C145SmallPhysicalTraceSeparation.lean new file mode 100644 index 0000000000..8996e5b20e --- /dev/null +++ b/LeanPool/C145/C145SmallPhysicalTraceSeparation.lean @@ -0,0 +1,181 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145PhysicalTraceResidue + +/-! +C145: actual counting trace separates the ordinary H2 fiber through five modes. + +The algebraic kernel permits arbitrary injective real residual rates, including +one zero rate. The accepted X^2 P argument supplies the trace-polynomial zero. +The physical corollaries retain both full orthonormal frames, both constant +grounds, and the common calibrated rates/a/c. Ground is retained in the accepted +full trace before taking the actual T Q1 a - T Q0 a difference. +-/ + +@[expose] public section + +noncomputable section +namespace C145.H2 +open MvPolynomial C145.ThreePlane +open scoped BigOperators +variable {n : ℕ} + +/-- The boundary admissible quotient is a literal constant polynomial. -/ +theorem admissible_four_eq_constant + (R : P3) (hR : QAdmissible 4 R) : + R = MvPolynomial.C (R.coeff 0) := by + classical + rcases hR with rfl | ⟨_, hDegree⟩ + · simp + · have hDegreeZero : ∀ r : Fin 3, degreeOf r R ≤ 0 := by + intro r + simpa using hDegree r + rw [MvPolynomial.C_apply] + apply MvPolynomial.eq_monomial_of_support_subset_singleton + intro m hm + apply Finsupp.ext + intro r + change m r = 0 + have hmZero := (MvPolynomial.degreeOf_le_iff.mp (hDegreeZero r)) m hm + omega + +/-- The affine slope from public evaluations; no denominator is cancelled. -/ +theorem tracePolynomial_constant_slope + (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) (k : ℝ) : + (tracePolynomial a rates (MvPolynomial.C k)).eval 1 - + (tracePolynomial a rates (MvPolynomial.C k)).eval 0 = + k * ∑ j, 1 / (a j.succ ^ 2 * di rates j ^ 2) := by + classical + rw [tracePolynomial_eval, tracePolynomial_eval] + simp only [MvPolynomial.eval_C] + rw [← Finset.sum_sub_distrib, Finset.mul_sum] + apply Finset.sum_congr rfl + intro j hj + simp only [div_eq_mul_inv] + ring + +/-- A nonempty sum of positive squared-denominator weights kills the constant. -/ +theorem tracePolynomial_constant_zero + (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (hRates : Function.Injective rates) + (ha : ∀ j : Fin n, a j.succ ≠ 0) (hn : 0 < n) + (k : ℝ) (hP : tracePolynomial a rates (MvPolynomial.C k) = 0) : + k = 0 := by + classical + have hWeight : 0 < ∑ j : Fin n, 1 / (a j.succ ^ 2 * di rates j ^ 2) := by + apply Finset.sum_pos + · intro j hj + exact one_div_pos.mpr (mul_pos (sq_pos_of_ne_zero (ha j)) + (sq_pos_of_ne_zero (di_ne_zero rates hRates j))) + · exact ⟨⟨0, hn⟩, Finset.mem_univ _⟩ + have hSlope := tracePolynomial_constant_slope a rates k + have hProduct : k * (∑ j : Fin n, 1 / (a j.succ ^ 2 * di rates j ^ 2)) = 0 := by + simpa only [hP, Polynomial.eval_zero, sub_self] using hSlope.symm + exact (mul_eq_zero.mp hProduct).resolve_right (ne_of_gt hWeight) + +/-- The small branch includes n=0 before a nonempty witness is introduced. -/ +theorem small_trace_quotient_zero + (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (hRates : Function.Injective rates) + (ha : ∀ j : Fin n, a j.succ ≠ 0) (hn : n ≤ 4) + (R : P3) (hR : QAdmissible n R) + (hP : tracePolynomial a rates R = 0) : + R = 0 := by + by_cases hn3 : n ≤ 3 + · exact (admissible_small_iff_zero hn3 R).mp hR + · have hn4 : n = 4 := by omega + subst n + have hConstant := admissible_four_eq_constant R hR + have hPConstant : tracePolynomial a rates (MvPolynomial.C (R.coeff 0)) = 0 := by + rw [← hConstant] + exact hP + have hk := tracePolynomial_constant_zero a rates hRates ha (by omega) + (R.coeff 0) hPConstant + calc + R = MvPolynomial.C (R.coeff 0) := hConstant + _ = 0 := by rw [hk, MvPolynomial.C_0] + +/-- Exact intersection of the actual symmetric ordinary kernel and trace. -/ +theorem small_ordinary_H2_counting_trace_kernel + (a : Fin (n + 1) → ℝ) (rates : Fin n → ℝ) + (hRates : Function.Injective rates) + (ha : ∀ j : Fin n, a j.succ ≠ 0) (hn : n ≤ 4) + (E : Tensor n) (hSym : FullSymTensor E) : + (NullRegular rates E ∧ ResidualTraceFree a E) ↔ E = 0 := by + constructor + · intro h + obtain ⟨R, hR, _⟩ := + (complete_ordinary_H2_counting_trace_kernel a rates hRates E hSym).mp h + have hZero := small_trace_quotient_zero a rates hRates ha hn R hR.2.1 hR.2.2.2 + calc + E = Res rates R := hR.2.2.1 + _ = 0 := by rw [hZero, res_zero] + · rintro rfl + constructor + · intro s t hs ht hreg + simp [H] + · intro i + simp [residualCountingTrace] + +/-- Full calibrated physical tensor equality for total size n+1 ≤ 5. -/ +theorem physical_small_H2_tensor_equality + (μ : ℝ) (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (ha : ∀ r, a r ≠ 0) + (hG0 : ∀ v, Q0 v 0 = c) (hG1 : ∀ v, Q1 v 0 = c) + (hn : n ≤ 4) + (hH : SamePositive (fullRates μ rates) + (C145PhysicalFrame.T Q0 a) (C145PhysicalFrame.T Q1 a)) : + C145PhysicalFrame.T Q0 a = C145PhysicalFrame.T Q1 a := by + obtain ⟨R, hR, _⟩ := + (physical_pair_H2_counting_trace_residue μ rates hRates hPos Q0 Q1 a c + hQ0 hQ1 ha hG0 hG1).mp hH + have hZero := small_trace_quotient_zero a rates hRates (fun j => ha j.succ) + hn R hR.2.1 hR.2.2.2.2 + have hZeroExtension : groundZero (0 : Tensor n) = 0 := by + funext i j k + refine Fin.cases ?_ (fun x => ?_) i + · rfl + · refine Fin.cases ?_ (fun y => ?_) j + · rfl + · refine Fin.cases ?_ (fun z => ?_) k <;> rfl + have hDifference := hR.2.2.1 + rw [hZero, res_zero, hZeroExtension] at hDifference + exact (sub_eq_zero.mp hDifference).symm + +/-- Cancel all three common nonzero modal factors in every full tensor entry. -/ +theorem physical_small_H2_multiplication_equality + (μ : ℝ) (rates : Fin n → ℝ) + (hRates : Function.Injective rates) (hPos : ∀ i, 0 < rates i) + (Q0 Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) (c : ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (ha : ∀ r, a r ≠ 0) + (hG0 : ∀ v, Q0 v 0 = c) (hG1 : ∀ v, Q1 v 0 = c) + (hn : n ≤ 4) + (hH : SamePositive (fullRates μ rates) + (C145PhysicalFrame.T Q0 a) (C145PhysicalFrame.T Q1 a)) : + C145PhysicalFrame.C Q0 = C145PhysicalFrame.C Q1 := by + have hTensor := physical_small_H2_tensor_equality μ rates hRates hPos Q0 Q1 a c + hQ0 hQ1 ha hG0 hG1 hn hH + funext i j k + apply mul_left_cancel₀ (mul_ne_zero (mul_ne_zero (ha i) (ha j)) (ha k)) + have hEntry := congrArg (fun U : Tensor (n + 1) => U i j k) hTensor + simpa only [C145PhysicalFrame.T] using hEntry + +end C145.H2 + +end diff --git a/LeanPool/C145/C145ThreePlaneFactor.lean b/LeanPool/C145/C145ThreePlaneFactor.lean new file mode 100644 index 0000000000..afd7835935 --- /dev/null +++ b/LeanPool/C145/C145ThreePlaneFactor.lean @@ -0,0 +1,358 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import Mathlib.Algebra.MvPolynomial.Equiv +public import Mathlib.Algebra.MvPolynomial.CommRing +public import Mathlib.Algebra.MvPolynomial.NoZeroDivisors +public import Mathlib.Algebra.Polynomial.Div +public import Mathlib.Algebra.BigOperators.Fin +public import Mathlib.Basic.Real.Basic +public import Mathlib.Data.Fin.VecNotation +public import Mathlib.Tactic.FinCases +public import Mathlib.Tactic.NormNum +public import Mathlib.Tactic.Ring + +/-! +Concrete ordinary three-plane factor interface for C145. + +The indexing is z = X 0, x = X 1, y = X 2. The factors have the exact +DRE4/DRE6 signs. This module starts from a polynomial plane identity; +it does not yet construct a response numerator or prove a tensor kernel. +-/ + +@[expose] public section + +noncomputable section + +namespace C145.ThreePlane + +open MvPolynomial +open scoped BigOperators + +/-- The real polynomial ring in the three variables of the plane-factor argument. -/ +abbrev P3 := MvPolynomial (Fin 3) ℝ +/-- The real polynomial ring in the two variables remaining on a plane. -/ +abbrev P2 := MvPolynomial (Fin 2) ℝ + +/-- The variable in coordinate zero of the three-variable polynomial ring. -/ +def z : P3 := X 0 +/-- The variable in coordinate one of the three-variable polynomial ring. -/ +def x : P3 := X 1 +/-- The variable in coordinate two of the three-variable polynomial ring. -/ +def y : P3 := X 2 + +/-- The linear form vanishing on the plane where the first two named variables sum to the third. -/ +def Lz : P3 := x + y - z +/-- The linear form whose zero plane is given by the equation `x + z = y`. -/ +def Ly : P3 := x + z - y +/-- The linear form whose zero plane is given by the equation `y + z = x`. -/ +def Lx : P3 := y + z - x +/-- The product of the three defining linear forms. -/ +def Xi : P3 := Lz * Ly * Lx + +/-- Full coordinate symmetry, including the output coordinate. -/ +def SymPoly (F : P3) : Prop := + ∀ e : Equiv.Perm (Fin 3), rename e F = F + +/-- The variable in coordinate zero of the two-variable polynomial ring. -/ +def u : P2 := X 0 +/-- The variable in coordinate one of the two-variable polynomial ring. -/ +def v : P2 := X 1 +/-- The sum of the two retained plane variables. -/ +def q : P2 := u + v + +/-- z = x+y, with the surviving variables x=u, y=v. -/ +def rhoZ : P3 →+* P2 := eval₂Hom C ![q, u, v] +/-- y = x+z, with the surviving variables x=u, z=v. -/ +def rhoY : P3 →+* P2 := eval₂Hom C ![v, u, q] +/-- x = y+z, with the surviving variables z=u, y=v. -/ +def rhoX : P3 →+* P2 := eval₂Hom C ![u, q, v] + +/-- The equivalence viewing a three-variable polynomial as a polynomial in one distinguished +variable. -/ +def phi : P3 ≃ₐ[ℝ] Polynomial P2 := finSuccEquiv ℝ 2 +private def sy : Equiv.Perm (Fin 3) := Equiv.swap 0 2 +private def sx : Equiv.Perm (Fin 3) := Equiv.swap 0 1 + +private theorem phi_z : phi z = Polynomial.X := + finSuccEquiv_X_zero + +private theorem phi_x : phi x = Polynomial.C u := by + simpa only [phi, x, u, Fin.succ_zero_eq_one] using + (finSuccEquiv_X_succ (R := ℝ) (n := 2) (j := 0)) + +private theorem phi_y : phi y = Polynomial.C v := by + simpa only [phi, y, v, Fin.succ_one_eq_two] using + (finSuccEquiv_X_succ (R := ℝ) (n := 2) (j := 1)) + +/-- Explicit generator bridge; the coefficient ring here is P2, not ℝ. -/ +theorem rhoZ_eq_eval_finSucc (F : P3) : + rhoZ F = Polynomial.eval q (phi F) := by + have hh : rhoZ = (Polynomial.evalRingHom q).comp + (phi : P3 →+* Polynomial P2) := by + apply MvPolynomial.ringHom_ext + · intro r + simp [rhoZ, phi, finSuccEquiv_apply] + · intro i + fin_cases i + · change rhoZ z = Polynomial.eval q (phi z) + rw [phi_z] + simp [rhoZ, z] + · change rhoZ x = Polynomial.eval q (phi x) + rw [phi_x] + simp [rhoZ, x] + · change rhoZ y = Polynomial.eval q (phi y) + rw [phi_y] + simp [rhoZ, y] + exact congrArg (fun h : P3 →+* P2 => h F) hh + +private theorem phi_Lz : phi Lz = -(Polynomial.X - Polynomial.C q) := by + rw [Lz, map_sub, map_add, phi_x, phi_y, phi_z] + simp only [q, map_add] + ring + +theorem rhoZ_Lz : rhoZ Lz = 0 := by + simp [rhoZ, Lz, x, y, z, q, u, v] + +theorem rhoY_Ly : rhoY Ly = 0 := by + simp [rhoY, Ly, x, y, z, q, u, v] + +theorem rhoX_Lx : rhoX Lx = 0 := by + simp [rhoX, Lx, x, y, z, q, u, v]; ring + +/-- The installed univariate root theorem supplies the first actual divisor. -/ +theorem plane_factor_z (F : P3) : rhoZ F = 0 ↔ Lz ∣ F := by + constructor + · intro h + have hr : Polynomial.IsRoot (phi F) q := by + change Polynomial.eval q (phi F) = 0 + rw [← rhoZ_eq_eval_finSucc] + exact h + obtain ⟨A, hA⟩ := Polynomial.dvd_iff_isRoot.mpr hr + refine ⟨phi.symm (-A), ?_⟩ + apply phi.injective + rw [map_mul, phi.apply_symm_apply, phi_Lz, hA] + ring + · rintro ⟨A, rfl⟩ + rw [map_mul, rhoZ_Lz, zero_mul] + +private theorem renameY_twice (F : P3) : rename sy (rename sy F) = F := by + rw [rename_rename] + have hh : (sy : Fin 3 → Fin 3) ∘ sy = id := by + funext i + exact Equiv.swap_apply_self 0 2 i + rw [hh, rename_id_apply] + +private theorem renameX_twice (F : P3) : rename sx (rename sx F) = F := by + rw [rename_rename] + have hh : (sx : Fin 3 → Fin 3) ∘ sx = id := by + funext i + exact Equiv.swap_apply_self 0 1 i + rw [hh, rename_id_apply] + +private theorem renameY_Lz : rename sy Lz = Ly := by + norm_num [sy, Lz, Ly, x, y, z, Equiv.swap_apply_def] + +private theorem renameX_Lz : rename sx Lz = Lx := by + norm_num [sx, Lz, Lx, x, y, z, Equiv.swap_apply_def]; ring + +private theorem rhoY_via_swap (F : P3) : rhoY F = rhoZ (rename sy F) := by + rw [rhoZ, eval₂Hom_rename] + have hh : (![q, u, v] : Fin 3 → P2) ∘ sy = ![v, u, q] := by + funext i + fin_cases i <;> norm_num [sy, Equiv.swap_apply_def] + rw [hh] + rfl + +private theorem rhoX_via_swap (F : P3) : rhoX F = rhoZ (rename sx F) := by + rw [rhoZ, eval₂Hom_rename] + have hh : (![q, u, v] : Fin 3 → P2) ∘ sx = ![u, q, v] := by + funext i + fin_cases i <;> norm_num [sx, Equiv.swap_apply_def] + rw [hh] + rfl + +theorem plane_factor_y (F : P3) : rhoY F = 0 ↔ Ly ∣ F := by + constructor + · intro h + obtain ⟨A, hA⟩ := (plane_factor_z (rename sy F)).mp + ((rhoY_via_swap F) ▸ h) + refine ⟨rename sy A, ?_⟩ + have hh := congrArg (fun G : P3 => rename sy G) hA + simpa only [map_mul, renameY_twice, renameY_Lz] using hh + · rintro ⟨A, rfl⟩ + rw [map_mul, rhoY_Ly, zero_mul] + +theorem plane_factor_x (F : P3) : rhoX F = 0 ↔ Lx ∣ F := by + constructor + · intro h + obtain ⟨A, hA⟩ := (plane_factor_z (rename sx F)).mp + ((rhoX_via_swap F) ▸ h) + refine ⟨rename sx A, ?_⟩ + have hh := congrArg (fun G : P3 => rename sx G) hA + simpa only [map_mul, renameX_twice, renameX_Lz] using hh + · rintro ⟨A, rfl⟩ + rw [map_mul, rhoX_Lx, zero_mul] + +/-- Full symmetry derives both unobserved plane identities. -/ +theorem all_plane_identities {F : P3} (hs : SymPoly F) (hz : rhoZ F = 0) : + rhoY F = 0 ∧ rhoX F = 0 := by + constructor + · rw [rhoY_via_swap, hs sy] + exact hz + · rw [rhoX_via_swap, hs sx] + exact hz + +theorem all_oriented_divisors {F : P3} (hs : SymPoly F) (hz : rhoZ F = 0) : + Lz ∣ F ∧ Ly ∣ F ∧ Lx ∣ F := by + obtain ⟨hy, hx⟩ := all_plane_identities hs hz + exact ⟨(plane_factor_z F).mp hz, (plane_factor_y F).mp hy, + (plane_factor_x F).mp hx⟩ + +/-- Exact off-plane images; these are the nonzero cancellation factors. -/ +theorem off_plane_images : + rhoY Lz = 2 * u ∧ rhoX Lz = 2 * v ∧ rhoX Ly = 2 * u := by + refine ⟨?_, ?_, ?_⟩ <;> + simp [rhoY, rhoX, Lz, Ly, x, y, z, q, u, v] <;> ring + +private theorem two_u_ne : (2 : P2) * u ≠ 0 := by + intro h + have hh := congrArg (fun G : P2 => MvPolynomial.eval (fun _ => (1 : ℝ)) G) h + norm_num [u] at hh + +private theorem two_v_ne : (2 : P2) * v ≠ 0 := by + intro h + have hh := congrArg (fun G : P2 => MvPolynomial.eval (fun _ => (1 : ℝ)) G) h + norm_num [v] at hh + +/-- Two domain cancellations extract the product; no Bezout premise is used. -/ +theorem xi_dvd {F : P3} (hs : SymPoly F) (hz : rhoZ F = 0) : Xi ∣ F := by + obtain ⟨hy, hx⟩ := all_plane_identities hs hz + obtain ⟨A, hA⟩ := (plane_factor_z F).mp hz + obtain ⟨hyz, hxz, hxy⟩ := off_plane_images + have hAy : rhoY A = 0 := by + rw [hA, map_mul, hyz] at hy + exact (mul_eq_zero.mp hy).resolve_left two_u_ne + obtain ⟨B, hB⟩ := (plane_factor_y A).mp hAy + have hBx : rhoX B = 0 := by + rw [hA, hB, map_mul, map_mul, hxz, hxy, ← mul_assoc] at hx + exact (mul_eq_zero.mp hx).resolve_left (mul_ne_zero two_v_ne two_u_ne) + obtain ⟨R, hR⟩ := (plane_factor_x B).mp hBx + refine ⟨R, ?_⟩ + rw [hA, hB, hR, Xi] + ring + +private theorem linear_degree_le (a b c i : Fin 3) : + degreeOf i (X a + X b - X c : P3) ≤ 1 := by + have hX (j : Fin 3) : degreeOf i (X j : P3) ≤ 1 := by + by_cases h : i = j <;> simp [degreeOf_X, h] + exact (degreeOf_sub_le i _ _).trans + (max_le ((degreeOf_add_le i _ _).trans (max_le (hX a) (hX b))) (hX c)) + +private theorem one_le_degree_of_coeff {F : P3} (i : Fin 3) + (h : F.coeff (Finsupp.single i 1) ≠ 0) : 1 ≤ degreeOf i F := by + simpa using monomial_le_degreeOf i (MvPolynomial.mem_support_iff.mpr h) + +theorem degree_Lz (i : Fin 3) : degreeOf i Lz = 1 := by + apply Nat.le_antisymm (linear_degree_le 1 2 0 i) + apply one_le_degree_of_coeff + fin_cases i <;> + norm_num [Lz, x, y, z, AddMonoidAlgebra.coeff_add, MvPolynomial.coeff_sub, coeff_X, + Finsupp.single_eq_single_iff] + +theorem degree_Ly (i : Fin 3) : degreeOf i Ly = 1 := by + apply Nat.le_antisymm (linear_degree_le 1 0 2 i) + apply one_le_degree_of_coeff + fin_cases i <;> + norm_num [Ly, x, y, z, AddMonoidAlgebra.coeff_add, MvPolynomial.coeff_sub, coeff_X, + Finsupp.single_eq_single_iff] + +theorem degree_Lx (i : Fin 3) : degreeOf i Lx = 1 := by + apply Nat.le_antisymm (linear_degree_le 2 0 1 i) + apply one_le_degree_of_coeff + fin_cases i <;> + norm_num [Lx, x, y, z, AddMonoidAlgebra.coeff_add, MvPolynomial.coeff_sub, coeff_X, + Finsupp.single_eq_single_iff] + +theorem Lz_ne : Lz ≠ 0 := ne_zero_of_degreeOf_ne_zero (by rw [degree_Lz 0]; decide) +theorem Ly_ne : Ly ≠ 0 := ne_zero_of_degreeOf_ne_zero (by rw [degree_Ly 0]; decide) +theorem Lx_ne : Lx ≠ 0 := ne_zero_of_degreeOf_ne_zero (by rw [degree_Lx 0]; decide) + +theorem xi_ne : Xi ≠ 0 := mul_ne_zero (mul_ne_zero Lz_ne Ly_ne) Lx_ne + +/-- Coordinate degree three is proved separately for every coordinate. -/ +theorem xi_degree (i : Fin 3) : degreeOf i Xi = 3 := by + rw [Xi, degreeOf_mul_eq (mul_ne_zero Lz_ne Ly_ne) Lx_ne, + degreeOf_mul_eq Lz_ne Ly_ne, degree_Lz, degree_Ly, degree_Lx] + +/-- A three-element indexed form is used only to reindex these exact factors. -/ +private def linear (r : Fin 3) : P3 := (∑ j : Fin 3, X j) - 2 * X r + +private theorem xi_as_prod : Xi = ∏ r : Fin 3, linear r := by + simp [Xi, Lz, Ly, Lx, x, y, z, linear, Fin.prod_univ_succ, + Fin.sum_univ_succ]; ring + +private theorem rename_linear (e : Equiv.Perm (Fin 3)) (r : Fin 3) : + rename e (linear r) = linear (e r) := by + have hh : (∑ j : Fin 3, (X (e j) : P3)) = ∑ j : Fin 3, X j := + _root_.Equiv.sum_comp e (fun j => (X j : P3)) + have ht : rename e (2 : P3) = 2 := by + calc + rename e (2 : P3) = rename e ((1 : P3) + 1) := congrArg (fun G : P3 => rename e G) (by + norm_num) + _ = (1 : P3) + 1 := by rw [map_add, map_one] + _ = 2 := by norm_num + simp [linear, hh, ht] + +theorem xi_symmetric : SymPoly Xi := by + intro e + calc + rename e Xi = rename e (∏ r : Fin 3, linear r) := + congrArg (fun G : P3 => rename e G) xi_as_prod + _ = ∏ r : Fin 3, linear (e r) := by simp only [map_prod, rename_linear] + _ = ∏ r : Fin 3, linear r := _root_.Equiv.prod_comp e linear + _ = Xi := xi_as_prod.symm + +theorem quotient_symmetric {F R : P3} (hs : SymPoly F) (h : F = Xi * R) : + SymPoly R := by + intro e + apply mul_left_cancel₀ xi_ne + calc + Xi * rename e R = rename e (Xi * R) := by rw [map_mul, xi_symmetric e] + _ = rename e F := congrArg (fun G : P3 => rename e G) h.symm + _ = F := hs e + _ = Xi * R := h + +theorem quotient_unique {F R S : P3} (hR : F = Xi * R) (hS : F = Xi * S) : + R = S := + mul_left_cancel₀ xi_ne (hR.symm.trans hS) + +theorem factor_degree {F R : P3} (h : F = Xi * R) (hF : F ≠ 0) + (i : Fin 3) : degreeOf i F = 3 + degreeOf i R := by + have hR : R ≠ 0 := by + intro hR + apply hF + rw [h, hR, mul_zero] + rw [h, degreeOf_mul_eq xi_ne hR, xi_degree] + +/-- No divisibility or quotient-symmetry assumption: both are conclusions. -/ +theorem symmetric_three_plane_factor {F : P3} (hs : SymPoly F) + (hz : rhoZ F = 0) : + ∃! R : P3, F = Xi * R ∧ SymPoly R ∧ + (F ≠ 0 → ∀ i : Fin 3, degreeOf i F = 3 + degreeOf i R) := by + obtain ⟨R, hR⟩ := xi_dvd hs hz + refine ⟨R, ⟨hR, quotient_symmetric hs hR, fun hF i => factor_degree hR hF i⟩, ?_⟩ + intro S hS + exact quotient_unique hS.1 hR + + +end C145.ThreePlane + +end diff --git a/LeanPool/C145/C145TimeKernelContinuation.lean b/LeanPool/C145/C145TimeKernelContinuation.lean new file mode 100644 index 0000000000..ea344395d6 --- /dev/null +++ b/LeanPool/C145/C145TimeKernelContinuation.lean @@ -0,0 +1,257 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145DelayKernelTransfer +public import Mathlib.Analysis.Analytic.Uniqueness +public import Mathlib.Analysis.SpecialFunctions.ExpDeriv + +/-! +Finite first/delay time kernels are determined at every nonnegative delay by +one positive observed interval/square. The proof uses finite resonance-safe +sector formulas and the real analytic identity theorem separately in each +coordinate. It needs no nonlinear response at later times and no spectral, +cyclicity, graph, positivity, or nonresonance assumptions. +-/ + +@[expose] public section + +noncomputable section +namespace C145.TimeKernelContinuation +open MeasureTheory Set Filter +open scoped BigOperators Topology +attribute [local instance 1001] + NormedAddCommGroup.toAddCommGroup + AddCommGroup.toAddCommMonoid + NormedSpace.toModule + PseudoMetricSpace.toUniformSpace + UniformSpace.toTopologicalSpace + +/-- Resonance-safe primitive of `exp (q*x)`, with its resonant value explicit. -/ +def expPrimitive (q x : ℝ) : ℝ := + if q = 0 then x else (Real.exp (q * x) - 1) / q + +theorem integral_exp_eq_expPrimitive (q u : ℝ) : + (∫ a in (0 : ℝ)..u, Real.exp (q * a)) = expPrimitive q u := by + by_cases hq : q = 0 + · simp [expPrimitive, hq] + · rw [expPrimitive, ite_eq_right hq] + have hSubstitution := intervalIntegral.mul_integral_comp_mul_left + (f := Real.exp) (a := (0 : ℝ)) (b := u) q + simp only [mul_zero, _root_.integral_exp, Real.exp_zero] at hSubstitution + apply (eq_div_iff hq).2 + simpa only [mul_comm] using hSubstitution + +/-- Exact scalar formula, valid also at additive resonance and on the diagonal. -/ +theorem scalarDelay_formula (α β γ r₁ r₂ : ℝ) : + C145.DelayKernel.scalarDelay α β γ r₁ r₂ = + Real.exp (-α * r₁ - β * r₂) * + expPrimitive (α + β - γ) (min r₁ r₂) := by + rw [← integral_exp_eq_expPrimitive] + unfold C145.DelayKernel.scalarDelay + rw [← intervalIntegral.integral_const_mul] + apply intervalIntegral.integral_congr + intro a ha + simp only [← Real.exp_add] + congr 1 + ring + +/-- The finite formula on either ordered sector, extended to the entire plane. +`first = true` is the sector r₁ ≤ r₂; `false` is r₂ ≤ r₁. -/ +def sectorKernel {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (first : Bool) (r₁ r₂ : ℝ) : ℝ := + ∑ i, ∑ j, ∑ k, + C145PhysicalFrame.T Q (C145.Pulse.modalOverlap Q b) i j k * + (Real.exp (-rates i * r₁ - rates j * r₂) * + expPrimitive (rates i + rates j - rates k) (if first then r₁ else r₂)) + +theorem delayKernel_eq_sectorKernel {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (first : Bool) (r₁ r₂ : ℝ) + (hsector : if first then r₁ ≤ r₂ else r₂ ≤ r₁) : + C145.DelayKernel.delayKernel Q rates b r₁ r₂ = sectorKernel Q rates b first r₁ r₂ := by + rw [C145.DelayKernel.delayKernel_expansion] + simp_rw [scalarDelay_formula] + cases first + · simp only [Bool.false_eq_true, ↓reduceIte] at hsector ⊢ + simp only [sectorKernel, Bool.false_eq_true, ↓reduceIte, min_eq_right hsector] + · simp only [↓reduceIte] at hsector ⊢ + simp only [sectorKernel, ↓reduceIte, min_eq_left hsector] + +theorem expPrimitive_analytic {q : ℝ} {f : ℝ → ℝ} {x : ℝ} + (hf : AnalyticAt ℝ f x) : AnalyticAt ℝ (fun y => expPrimitive q (f y)) x := by + by_cases hq : q = 0 + · simpa only [expPrimitive, ite_eq_left hq] using hf + · simp only [expPrimitive, ite_eq_right hq] + exact ((analyticAt_const.mul hf).rexp.sub analyticAt_const).div + analyticAt_const hq + +theorem firstKernel_analytic {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) : + AnalyticOnNhd ℝ (C145.DelayKernel.firstKernel Q rates b) univ := by + intro x hx + change AnalyticAt ℝ (fun t => C145.DelayKernel.firstKernel Q rates b t) x + simp_rw [C145.DelayKernel.firstKernel_expansion] + fun_prop + +theorem sectorKernel_analytic_first {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (first : Bool) (r₂ : ℝ) : + AnalyticOnNhd ℝ (fun r₁ => sectorKernel Q rates b first r₁ r₂) univ := by + intro x hx + unfold sectorKernel + apply Finset.analyticAt_fun_sum + intro i hi + apply Finset.analyticAt_fun_sum + intro j hj + apply Finset.analyticAt_fun_sum + intro k hk + apply AnalyticAt.mul analyticAt_const + apply AnalyticAt.mul + · fun_prop + · apply expPrimitive_analytic + cases first + · exact analyticAt_const + · exact analyticAt_id + +theorem sectorKernel_analytic_second {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates b : Fin (n + 1) → ℝ) (first : Bool) (r₁ : ℝ) : + AnalyticOnNhd ℝ (fun r₂ => sectorKernel Q rates b first r₁ r₂) univ := by + intro x hx + unfold sectorKernel + apply Finset.analyticAt_fun_sum + intro i hi + apply Finset.analyticAt_fun_sum + intro j hj + apply Finset.analyticAt_fun_sum + intro k hk + apply AnalyticAt.mul analyticAt_const + apply AnalyticAt.mul + · fun_prop + · apply expPrimitive_analytic + cases first + · exact analyticAt_id + · exact analyticAt_const + +/-- One-variable identity theorem from any nonempty open interval. -/ +theorem analytic_eq_of_Ioo {f g : ℝ → ℝ} {a b : ℝ} (hab : a < b) + (hf : AnalyticOnNhd ℝ f univ) (hg : AnalyticOnNhd ℝ g univ) + (heq : EqOn f g (Ioo a b)) : f = g := by + apply hf.eq_of_eventuallyEq hg (z₀ := (a + b) / 2) + have ha : a < (a + b) / 2 := by linarith + have hb : (a + b) / 2 < b := by linarith + filter_upwards [Ioo_mem_nhds ha hb] with x hx + exact heq hx + +/-- Two successive one-variable identity theorems, with only a rectangle of data. -/ +theorem separately_analytic_eq_of_rectangle {f g : ℝ → ℝ → ℝ} + {a b c d : ℝ} (hab : a < b) (hcd : c < d) + (hf₁ : ∀ y, AnalyticOnNhd ℝ (fun x => f x y) univ) + (hg₁ : ∀ y, AnalyticOnNhd ℝ (fun x => g x y) univ) + (hf₂ : ∀ x, AnalyticOnNhd ℝ (f x) univ) + (hg₂ : ∀ x, AnalyticOnNhd ℝ (g x) univ) + (heq : ∀ x ∈ Ioo a b, ∀ y ∈ Ioo c d, f x y = g x y) : + ∀ x y, f x y = g x y := by + have hstrip : ∀ y ∈ Ioo c d, ∀ x, f x y = g x y := by + intro y hy x + exact congrFun (analytic_eq_of_Ioo hab (hf₁ y) (hg₁ y) (fun z hz => heq z hz y hy)) x + intro x y + exact congrFun (analytic_eq_of_Ioo hcd (hf₂ x) (hg₂ x) (fun z hz => hstrip z hz x)) y + +/-- First-kernel continuation needs no common modal indexing or physical premise. -/ +theorem firstKernel_eq_of_observed_interval {m n : ℕ} {T : ℝ} (hT : 0 < T) + (Q₀ : Fin (m + 1) → Fin (m + 1) → ℝ) (rates₀ b₀ : Fin (m + 1) → ℝ) + (Q₁ : Fin (n + 1) → Fin (n + 1) → ℝ) (rates₁ b₁ : Fin (n + 1) → ℝ) + (heq : ∀ r ∈ Icc (0 : ℝ) T, + C145.DelayKernel.firstKernel Q₀ rates₀ b₀ r = + C145.DelayKernel.firstKernel Q₁ rates₁ b₁ r) : + ∀ r : ℝ, C145.DelayKernel.firstKernel Q₀ rates₀ b₀ r = + C145.DelayKernel.firstKernel Q₁ rates₁ b₁ r := by + intro r + exact congrFun (analytic_eq_of_Ioo hT (firstKernel_analytic Q₀ rates₀ b₀) + (firstKernel_analytic Q₁ rates₁ b₁) (fun x hx => heq x ⟨hx.1.le, hx.2.le⟩)) r + +/-- Continue each ordered sector from an interior rectangle of the observed square. -/ +theorem sectorKernel_eq_of_observed_square {m n : ℕ} {T : ℝ} (hT : 0 < T) + (Q₀ : Fin (m + 1) → Fin (m + 1) → ℝ) (rates₀ b₀ : Fin (m + 1) → ℝ) + (Q₁ : Fin (n + 1) → Fin (n + 1) → ℝ) (rates₁ b₁ : Fin (n + 1) → ℝ) + (heq : ∀ r ∈ Icc (0 : ℝ) T, ∀ s ∈ Icc (0 : ℝ) T, + C145.DelayKernel.delayKernel Q₀ rates₀ b₀ r s = + C145.DelayKernel.delayKernel Q₁ rates₁ b₁ r s) + (first : Bool) : + ∀ r s : ℝ, sectorKernel Q₀ rates₀ b₀ first r s = + sectorKernel Q₁ rates₁ b₁ first r s := by + let a := if first then T / 8 else T / 2 + let b := if first then T / 4 else 3 * T / 4 + let c := if first then T / 2 else T / 8 + let d := if first then 3 * T / 4 else T / 4 + have hab : a < b := by cases first <;> dsimp [a, b] <;> linarith + have hcd : c < d := by cases first <;> dsimp [c, d] <;> linarith + apply separately_analytic_eq_of_rectangle hab hcd + (sectorKernel_analytic_first Q₀ rates₀ b₀ first) + (sectorKernel_analytic_first Q₁ rates₁ b₁ first) + (sectorKernel_analytic_second Q₀ rates₀ b₀ first) + (sectorKernel_analytic_second Q₁ rates₁ b₁ first) + intro r hr s hs + have hrT : r ∈ Icc (0 : ℝ) T := by + cases first <;> dsimp [a, b] at hr <;> constructor <;> linarith [hr.1, hr.2] + have hsT : s ∈ Icc (0 : ℝ) T := by + cases first <;> dsimp [c, d] at hs <;> constructor <;> linarith [hs.1, hs.2] + have hsector : if first then r ≤ s else s ≤ r := by + cases first <;> dsimp [a, b, c, d] at hr hs ⊢ <;> linarith [hr.1, hr.2, hs.1, hs.2] + rw [← delayKernel_eq_sectorKernel Q₀ rates₀ b₀ first r s hsector, + ← delayKernel_eq_sectorKernel Q₁ rates₁ b₁ first r s hsector] + exact heq r hrT s hsT + +/-- Both sectors include their diagonal, so their exact formulas also cover +endpoints; no extra response or boundary-data assumption is needed. -/ +theorem delayKernel_eq_of_observed_square {m n : ℕ} {T : ℝ} (hT : 0 < T) + (Q₀ : Fin (m + 1) → Fin (m + 1) → ℝ) (rates₀ b₀ : Fin (m + 1) → ℝ) + (Q₁ : Fin (n + 1) → Fin (n + 1) → ℝ) (rates₁ b₁ : Fin (n + 1) → ℝ) + (heq : ∀ r ∈ Icc (0 : ℝ) T, ∀ s ∈ Icc (0 : ℝ) T, + C145.DelayKernel.delayKernel Q₀ rates₀ b₀ r s = + C145.DelayKernel.delayKernel Q₁ rates₁ b₁ r s) : + ∀ r s : ℝ, C145.DelayKernel.delayKernel Q₀ rates₀ b₀ r s = + C145.DelayKernel.delayKernel Q₁ rates₁ b₁ r s := by + intro r s + by_cases hrs : r ≤ s + · rw [delayKernel_eq_sectorKernel Q₀ rates₀ b₀ true r s hrs, + delayKernel_eq_sectorKernel Q₁ rates₁ b₁ true r s hrs] + exact sectorKernel_eq_of_observed_square hT Q₀ rates₀ b₀ Q₁ rates₁ b₁ heq true r s + · have hsr : s ≤ r := (lt_of_not_ge hrs).le + rw [delayKernel_eq_sectorKernel Q₀ rates₀ b₀ false r s hsr, + delayKernel_eq_sectorKernel Q₁ rates₁ b₁ false r s hsr] + exact sectorKernel_eq_of_observed_square hT Q₀ rates₀ b₀ Q₁ rates₁ b₁ heq false r s + +/-- The intended finite continuation checkpoint, for unrelated finite systems. +The hypotheses are precisely the observed first interval and delay square +identities; no later-time response, size bound, or spectral restriction enters. -/ +theorem observed_time_kernels_determine_all_nonnegative_delays + {m n : ℕ} {T : ℝ} (hT : 0 < T) + (Q₀ : Fin (m + 1) → Fin (m + 1) → ℝ) (rates₀ b₀ : Fin (m + 1) → ℝ) + (Q₁ : Fin (n + 1) → Fin (n + 1) → ℝ) (rates₁ b₁ : Fin (n + 1) → ℝ) + (hfirst : ∀ r ∈ Icc (0 : ℝ) T, + C145.DelayKernel.firstKernel Q₀ rates₀ b₀ r = + C145.DelayKernel.firstKernel Q₁ rates₁ b₁ r) + (hdelay : ∀ r ∈ Icc (0 : ℝ) T, ∀ s ∈ Icc (0 : ℝ) T, + C145.DelayKernel.delayKernel Q₀ rates₀ b₀ r s = + C145.DelayKernel.delayKernel Q₁ rates₁ b₁ r s) : + (∀ r : ℝ, 0 ≤ r → C145.DelayKernel.firstKernel Q₀ rates₀ b₀ r = + C145.DelayKernel.firstKernel Q₁ rates₁ b₁ r) ∧ + (∀ r s : ℝ, 0 ≤ r → 0 ≤ s → C145.DelayKernel.delayKernel Q₀ rates₀ b₀ r s = + C145.DelayKernel.delayKernel Q₁ rates₁ b₁ r s) := by + exact ⟨fun r _ => firstKernel_eq_of_observed_interval hT Q₀ rates₀ b₀ Q₁ rates₁ b₁ hfirst r, + fun r s _ _ => delayKernel_eq_of_observed_square hT Q₀ rates₀ b₀ Q₁ rates₁ b₁ hdelay r s⟩ + +end C145.TimeKernelContinuation + +end diff --git a/LeanPool/C145/C145UncalibratedSmallH2.lean b/LeanPool/C145/C145UncalibratedSmallH2.lean new file mode 100644 index 0000000000..c2f63629d7 --- /dev/null +++ b/LeanPool/C145/C145UncalibratedSmallH2.lean @@ -0,0 +1,267 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import LeanPool.C145.C145CoordinatePermutation +public import LeanPool.C145.C145SignedGroundPulseCalibration +public import Mathlib.Algebra.BigOperators.Group.Finset.Defs + +/-! +C145: own finite H1, actual coincident pulse and ordinary H2 data identify one +vertex bijection through total size N <= 5. Each model has its own full real +orthonormal frame, constant ground column, simple physical rates and signed +vertex port. Actual positively oriented visible overlaps are scalar products. + +H1 and the actual pulse derive size, modal matching and the common signed +constant. Only the second frame's modal columns are then reindexed. The small +ordinary H2/counting-trace theorem derives a vertex map, retained for frame +rows, original generators, actual ports and decay Laplacians. Ground remains +in all full sums; the empty nonground family at N=1 is permitted. Physical +successor rates are not shifted by mu, and additive resonances are permitted. + +Finite spectral data and the stated source-class assumptions are inputs. +Raw ODE/response extraction, temporal jets, graph positivity, normalization, +cyclicity-to-spectrum derivation and identification beyond N=5 are outside +this statement. The modal map and vertex map are distinct derived objects. +-/ + +@[expose] public section + +noncomputable section +namespace C145.UncalibratedSmallH2 +open scoped BigOperators + +/-- Relabel the modal columns of a frame while preserving vertex indices. -/ +def columnReindex {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (e : Equiv.Perm (Fin (n + 1))) : + Fin (n + 1) → Fin (n + 1) → ℝ := + fun v i => Q v (e i) + +/-- Reindexing columns preserves the full Gram identities. -/ +theorem columnReindex_columnOrthonormal {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (e : Equiv.Perm (Fin (n + 1))) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) : + C145PhysicalFrame.ColumnOrthonormal (columnReindex Q e) := by + classical + intro i j + change (∑ v, Q v (e i) * Q v (e j)) = if i = j then 1 else 0 + simpa only [e.apply_eq_iff_eq] using hQ (e i) (e j) + +/-- All three tensor slots and their actual overlap factors move together. -/ +theorem tensor_columnReindex {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (a : Fin (n + 1) → ℝ) + (e : Equiv.Perm (Fin (n + 1))) + (i j k : Fin (n + 1)) : + C145PhysicalFrame.T (columnReindex Q e) (fun r => a (e r)) i j k = + C145PhysicalFrame.T Q a (e i) (e j) (e k) := by + rfl + +/-- Literal equality of the complete triple sum, without pole evaluation. -/ +theorem H_modal_reindex {N : ℕ} + (rates : Fin N → ℝ) (E : C145.H2.Tensor N) + (e : Equiv.Perm (Fin N)) (s t : ℝ) : + C145.H2.H (fun i => rates (e i)) + (fun i j k => E (e i) (e j) (e k)) s t = + C145.H2.H rates E s t := by + classical + let F : Fin N → Fin N → Fin N → ℝ := fun i j k => + E i j k / ((s + rates i) * (t + rates j) * (s + t + rates k)) + change (∑ i, ∑ j, ∑ k, F (e i) (e j) (e k)) = ∑ i, ∑ j, ∑ k, F i j k + calc + (∑ i, ∑ j, ∑ k, F (e i) (e j) (e k)) = + ∑ i, ∑ j, ∑ k, F (e i) (e j) k := by + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro j hj + exact Equiv.sum_comp e (fun k => F (e i) (e j) k) + _ = ∑ i, ∑ j, ∑ k, F (e i) j k := by + apply Finset.sum_congr rfl + intro i hi + exact Equiv.sum_comp e (fun j => ∑ k, F (e i) j k) + _ = ∑ i, ∑ j, ∑ k, F i j k := + Equiv.sum_comp e (fun i => ∑ j, ∑ k, F i j k) + +/-- The accepted successor family consists of physical rates themselves. -/ +theorem fullRates_eq_own {n : ℕ} + (μ : ℝ) (rates : Fin (n + 1) → ℝ) + (hGround : rates 0 = μ) : + C145.H2.fullRates μ (fun i : Fin n => rates i.succ) = rates := by + funext i + rcases Fin.eq_zero_or_eq_succ i with hi | ⟨j, hj⟩ + · rw [hi] + simpa only [C145.H2.fullRates, Fin.cases_zero] using hGround.symm + · rw [hj] + rfl + +/-- Full-frame reconstruction recovers the actual signed vertex port. -/ +theorem spectralPort_modalOverlap {n : ℕ} + (Q : Fin (n + 1) → Fin (n + 1) → ℝ) + (b : Fin (n + 1) → ℝ) + (hQ : C145PhysicalFrame.ColumnOrthonormal Q) : + C145CoordinatePermutation.spectralPort (C145.Pulse.modalOverlap Q b) Q = b := by + classical + funext v + simpa only [C145CoordinatePermutation.spectralPort, C145.Pulse.modalOverlap, + mul_comm] using C145CoordinatePermutation.frame_reconstruction Q hQ b v + +/-- Own actual data derive modal calibration and one common vertex bijection. -/ +theorem actual_small_H2_vertex_identification {m n : ℕ} + (μ c0 c1 : ℝ) (hμ : 0 < μ) + (Q0 : Fin (m + 1) → Fin (m + 1) → ℝ) + (Q1 : Fin (n + 1) → Fin (n + 1) → ℝ) + (rates0 b0 : Fin (m + 1) → ℝ) + (rates1 b1 : Fin (n + 1) → ℝ) + (hQ0 : C145PhysicalFrame.ColumnOrthonormal Q0) + (hQ1 : C145PhysicalFrame.ColumnOrthonormal Q1) + (hGround0 : ∀ v, Q0 v 0 = c0) + (hGround1 : ∀ v, Q1 v 0 = c1) + (hRates0 : Function.Injective rates0) + (hRates1 : Function.Injective rates1) + (hRateGround0 : rates0 0 = μ) + (hRateGround1 : rates1 0 = μ) + (hAbove0 : ∀ i : Fin m, μ < rates0 i.succ) + (hAbove1 : ∀ j : Fin n, μ < rates1 j.succ) + (ha0 : ∀ i, 0 < C145.Pulse.modalOverlap Q0 b0 i) + (ha1 : ∀ j, 0 < C145.Pulse.modalOverlap Q1 b1 j) + (hm : m ≤ 4) + (hH1 : ∀ s : ℝ, 0 < s → + C145.H1.firstTransfer rates0 (C145.Pulse.modalOverlap Q0 b0) s = + C145.H1.firstTransfer rates1 (C145.Pulse.modalOverlap Q1 b1) s) + (hB : ∀ t : ℝ, 0 ≤ t → + C145.Pulse.coincidentPulse Q0 rates0 b0 t = + C145.Pulse.coincidentPulse Q1 rates1 b1 t) + (hH2 : ∀ s t : ℝ, 0 < s → 0 < t → + C145.H2.H rates0 + (C145PhysicalFrame.T Q0 (C145.Pulse.modalOverlap Q0 b0)) s t = + C145.H2.H rates1 + (C145PhysicalFrame.T Q1 (C145.Pulse.modalOverlap Q1 b1)) s t) : + ∃ e : Fin (m + 1) ≃ Fin (n + 1), + m = n ∧ e 0 = 0 ∧ + (∀ i, rates1 (e i) = rates0 i) ∧ + (∀ i, C145.Pulse.modalOverlap Q1 b1 (e i) = + C145.Pulse.modalOverlap Q0 b0 i) ∧ + c0 = c1 ∧ (∑ v, b0 v) = (∑ w, b1 w) ∧ + ∃ π : Fin (m + 1) ≃ Fin (n + 1), + (∀ (w : Fin (n + 1)) (v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0) ∧ + (∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u) ∧ + (∀ v : Fin (m + 1), b1 (π v) = b0 v) ∧ + (∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u) := by + classical + let a0 : Fin (m + 1) → ℝ := C145.Pulse.modalOverlap Q0 b0 + let a1 : Fin (n + 1) → ℝ := C145.Pulse.modalOverlap Q1 b1 + obtain ⟨e, hSize, heGround, heRates, heOverlaps, hConstant, hMeans⟩ := + C145.Pulse.actual_signed_ground_calibration μ c0 c1 hμ Q0 Q1 + rates0 b0 a0 rates1 b1 a1 hQ0 hQ1 hGround0 hGround1 + hRates0 hRates1 hRateGround0 hRateGround1 hAbove0 hAbove1 + ha0 ha1 (fun _ => rfl) (fun _ => rfl) hH1 hB + -- Size equality is a data-derived fact; the modal map is retained. + subst n + let Q1e : Fin (m + 1) → Fin (m + 1) → ℝ := columnReindex Q1 e + let r0 : Fin m → ℝ := fun i => rates0 i.succ + have hQ1e : C145PhysicalFrame.ColumnOrthonormal Q1e := + columnReindex_columnOrthonormal Q1 e hQ1 + have hG1e : ∀ v, Q1e v 0 = c0 := by + intro v + change Q1 v (e 0) = c0 + rw [heGround, hGround1, ← hConstant] + have hResidualRates : Function.Injective r0 := by + intro i j hij + apply Fin.succ_inj.mp + apply hRates0 + exact hij + have hResidualPos : ∀ i : Fin m, 0 < r0 i := by + intro i + exact lt_trans hμ (hAbove0 i) + have hFull : C145.H2.fullRates μ r0 = rates0 := + fullRates_eq_own μ rates0 hRateGround0 + have hA : (fun i => a1 (e i)) = a0 := funext heOverlaps + have hLam : (fun i => rates1 (e i)) = rates0 := funext heRates + have hT : C145PhysicalFrame.T Q1e a0 = + (fun i j k => C145PhysicalFrame.T Q1 a1 (e i) (e j) (e k)) := by + funext i j k + simpa only [Q1e, hA] using tensor_columnReindex Q1 a1 e i j k + have hAlignedResponse : ∀ s t : ℝ, + C145.H2.H rates0 (C145PhysicalFrame.T Q1e a0) s t = + C145.H2.H rates1 (C145PhysicalFrame.T Q1 a1) s t := by + intro s t + have h := H_modal_reindex rates1 (C145PhysicalFrame.T Q1 a1) e s t + rw [hLam, ← hT] at h + exact h + have hHAligned : C145.H2.SamePositive (C145.H2.fullRates μ r0) + (C145PhysicalFrame.T Q0 a0) (C145PhysicalFrame.T Q1e a0) := by + intro s t hs ht + rw [hFull] + exact (hH2 s t hs ht).trans (hAlignedResponse s t).symm + -- This is the sole call that derives the vertex map. + obtain ⟨π, hDeltaRaw, hRowsRaw, _, _, _⟩ := + C145CoordinatePermutation.calibrated_small_H2_vertex_identification μ r0 + hResidualRates hResidualPos Q0 Q1e a0 c0 hQ0 hQ1e + (fun i => ne_of_gt (ha0 i)) hGround0 hG1e hm hHAligned + have hDelta : ∀ (w v : Fin (m + 1)), + (∑ i : Fin (m + 1), Q1 w (e i) * Q0 v i) = + if w = π v then 1 else 0 := by + intro w v + exact hDeltaRaw w v + have hRows : ∀ (v i : Fin (m + 1)), Q1 (π v) (e i) = Q0 v i := by + intro v i + exact hRowsRaw v i + have hGenerator : ∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.spectralGenerator rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.spectralGenerator rates0 Q0 v u := by + intro v u + unfold C145CoordinatePermutation.spectralGenerator + congr 1 + calc + (∑ j, rates1 j * Q1 (π v) j * Q1 (π u) j) = + ∑ i, rates1 (e i) * Q1 (π v) (e i) * Q1 (π u) (e i) := + (e.sum_comp (fun j => rates1 j * Q1 (π v) j * Q1 (π u) j)).symm + _ = ∑ i, rates0 i * Q0 v i * Q0 u i := by + apply Finset.sum_congr rfl + intro i hi + rw [heRates i, hRows v i, hRows u i] + have hPort : ∀ v : Fin (m + 1), b1 (π v) = b0 v := by + intro v + have hReconstruct1 := congrFun (spectralPort_modalOverlap Q1 b1 hQ1) (π v) + have hReconstruct0 := congrFun (spectralPort_modalOverlap Q0 b0 hQ0) v + change (∑ j, a1 j * Q1 (π v) j) = b1 (π v) at hReconstruct1 + change (∑ i, a0 i * Q0 v i) = b0 v at hReconstruct0 + calc + b1 (π v) = ∑ j, a1 j * Q1 (π v) j := hReconstruct1.symm + _ = ∑ i, a1 (e i) * Q1 (π v) (e i) := + (e.sum_comp (fun j => a1 j * Q1 (π v) j)).symm + _ = ∑ i, a0 i * Q0 v i := by + apply Finset.sum_congr rfl + intro i hi + rw [heOverlaps i, hRows v i] + _ = b0 v := hReconstruct0 + have hL : ∀ (v u : Fin (m + 1)), + C145CoordinatePermutation.decayLaplacian μ rates1 Q1 (π v) (π u) = + C145CoordinatePermutation.decayLaplacian μ rates0 Q0 v u := by + intro v u + simp only [C145CoordinatePermutation.decayLaplacian, hGenerator, + π.apply_eq_iff_eq] + exact ⟨e, rfl, heGround, heRates, heOverlaps, hConstant, hMeans, + π, hDelta, hRows, hGenerator, hPort, hL⟩ + + +end C145.UncalibratedSmallH2 +end + +end diff --git a/LeanPool/C145/C145WeightedGraph.lean b/LeanPool/C145/C145WeightedGraph.lean new file mode 100644 index 0000000000..415dbc8d34 --- /dev/null +++ b/LeanPool/C145/C145WeightedGraph.lean @@ -0,0 +1,102 @@ +/- +Copyright (c) 2026 Mark Gladden. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Mark Gladden +-/ + +/- Modified from the C145 v0.6 release for Lean Pool's pinned toolchain. -/ + +module + +public import Mathlib.Analysis.Matrix.PosDef +public import Mathlib.Combinatorics.SimpleGraph.LapMatrix + +/-! Concrete counting-metric weighted graph Laplacian and its exact ground kernel. -/ + +@[expose] public section + +noncomputable section +namespace C145.WeightedGraph +open scoped BigOperators +open Matrix +variable {V : Type*} [Fintype V] [DecidableEq V] + +/-- The weighted degree diagonal minus the weight matrix. -/ +def laplacian (W : Matrix V V ℝ) : Matrix V V ℝ := + Matrix.diagonal (fun v => ∑ u, W v u) - W + +/-- The simple graph of positive off-diagonal weights in a symmetric weight matrix. -/ +def supportGraph (W : Matrix V V ℝ) (hs : W.IsSymm) : SimpleGraph V where + Adj v u := v ≠ u ∧ 0 < W v u + symm := ⟨by intro v u h; exact ⟨h.1.symm, by rw [hs.apply]; exact h.2⟩⟩ + loopless := ⟨by intro v h; exact h.1 rfl⟩ + +theorem laplacian_symm (W : Matrix V V ℝ) (hs : W.IsSymm) : + (laplacian W).IsSymm := (Matrix.isSymm_diagonal _).sub hs + +theorem laplacian_mulVec (W : Matrix V V ℝ) (x : V → ℝ) (v : V) : + (laplacian W *ᵥ x) v = ∑ u, W v u * (x v - x u) := by + rw [laplacian, Matrix.sub_mulVec] + simp only [Pi.sub_apply, Matrix.mulVec_diagonal] + change (∑ u, W v u) * x v - ∑ u, W v u * x u = _ + rw [Finset.sum_mul, ← Finset.sum_sub_distrib] + congr 1; ext u; ring + +theorem laplacian_const (W : Matrix V V ℝ) (c : ℝ) : + laplacian W *ᵥ (fun _ => c) = 0 := by + ext v; simp [laplacian_mulVec] + +theorem laplacian_energy (W : Matrix V V ℝ) (hs : W.IsSymm) (x : V → ℝ) : + x ⬝ᵥ (laplacian W *ᵥ x) = + (∑ v, ∑ u, W v u * (x v - x u) ^ 2) / 2 := by + simp only [dotProduct, laplacian_mulVec, Finset.mul_sum] + have hswap : (∑ v, ∑ u, x v * (W v u * (x v - x u))) = + ∑ v, ∑ u, x u * (W v u * (x u - x v)) := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro v _ + apply Finset.sum_congr rfl; intro u _ + rw [hs.apply] + rw [← add_self_div_two (∑ v, ∑ u, x v * (W v u * (x v - x u)))] + conv_lhs => enter [1, 2]; rw [hswap] + rw [← Finset.sum_add_distrib] + congr 1 + apply Finset.sum_congr rfl; intro v _ + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl; intro u _; ring + +theorem laplacian_posSemidef (W : Matrix V V ℝ) (hs : W.IsSymm) + (hn : ∀ v u, 0 ≤ W v u) : (laplacian W).PosSemidef := by + apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg + · simpa [Matrix.IsHermitian, Matrix.conjTranspose_eq_transpose_of_trivial] using + (laplacian_symm W hs).eq + · intro x + rw [star_trivial, laplacian_energy W hs] + exact div_nonneg (Finset.sum_nonneg fun v _ => + Finset.sum_nonneg fun u _ => mul_nonneg (hn v u) (sq_nonneg _)) (by norm_num) + +theorem laplacian_kernel_const (W : Matrix V V ℝ) (hs : W.IsSymm) + (hn : ∀ v u, 0 ≤ W v u) (hc : (supportGraph W hs).Connected) + (x : V → ℝ) (hx : laplacian W *ᵥ x = 0) : ∀ v u, x v = x u := by + have he : (∑ v, ∑ u, W v u * (x v - x u) ^ 2) = 0 := by + have hh := laplacian_energy W hs x + rw [hx, dotProduct_zero] at hh + linarith + have ht : ∀ v u, W v u * (x v - x u) ^ 2 = 0 := by + have hh := (Finset.sum_eq_zero_iff_of_nonneg (fun v _ => + Finset.sum_nonneg fun u _ => mul_nonneg (hn v u) (sq_nonneg _))).mp he + intro v u + exact (Finset.sum_eq_zero_iff_of_nonneg + (fun u _ => mul_nonneg (hn v u) (sq_nonneg _))).mp (hh v (by simp)) u (by simp) + have hadj : ∀ v u, (supportGraph W hs).Adj v u → x v = x u := by + intro v u h + have hh := (mul_eq_zero.mp (ht v u)).resolve_left (ne_of_gt h.2) + exact sub_eq_zero.mp (sq_eq_zero_iff.mp hh) + intro v u + obtain ⟨p⟩ := hc.preconnected v u + induction p with + | nil => rfl + | cons h _ ih => exact (hadj _ _ h).trans ih + +end C145.WeightedGraph + +end diff --git a/LeanPool/C145/Imports.lean b/LeanPool/C145/Imports.lean new file mode 100644 index 0000000000..ffa7dceaaf --- /dev/null +++ b/LeanPool/C145/Imports.lean @@ -0,0 +1,80 @@ +/- +Copyright (c) 2026 Lean Pool contributors. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Lean Pool contributors +-/ +module -- shake: keep-all --deprecated_module: ignore + +-- Generated project imports; run `lake exe mk_all`. +public import LeanPool.C145 +public import LeanPool.C145.C145ActualResponseC2 +public import LeanPool.C145.C145ActualTimeConvolution +public import LeanPool.C145.C145CompleteOrdinaryH2Kernel +public import LeanPool.C145.C145CoordinatePermutation +public import LeanPool.C145.C145CyclicSpectral +public import LeanPool.C145.C145DRE8ActualCalibratedInverse +public import LeanPool.C145.C145DRE8ActualFrame +public import LeanPool.C145.C145DRE8CalibratedUniqueness +public import LeanPool.C145.C145DRE8CommonUnit +public import LeanPool.C145.C145DRE8CubicCancellation +public import LeanPool.C145.C145DRE8Frobenius +public import LeanPool.C145.C145DRE8HilbertStability +public import LeanPool.C145.C145DRE8JointOriginalGraph +public import LeanPool.C145.C145DRE8JointSignatureInverse +public import LeanPool.C145.C145DRE8JointTransferInverse +public import LeanPool.C145.C145DRE8KrylovSlices +public import LeanPool.C145.C145DRE8OptimalContraction +public import LeanPool.C145.C145DRE8OriginalGraphInverse +public import LeanPool.C145.C145DRE8OrthogonalTransport +public import LeanPool.C145.C145DRE8PhysicalStability +public import LeanPool.C145.C145DRE8PhysicalTensor +public import LeanPool.C145.C145DRE8PositiveGridKernel +public import LeanPool.C145.C145DRE8ProjectionResiduals +public import LeanPool.C145.C145DRE8SignedGroundResidue +public import LeanPool.C145.C145DRE8SliceRigidity +public import LeanPool.C145.C145DRE8SpectralContraction +public import LeanPool.C145.C145DRE8TensorSpace +public import LeanPool.C145.C145DRE8TransferInverse +public import LeanPool.C145.C145DRE8WeightedKernel +public import LeanPool.C145.C145DelayKernelTransfer +public import LeanPool.C145.C145EightAffineFamilies +public import LeanPool.C145.C145FixedHorizonSmallInverse +public import LeanPool.C145.C145GraphSpectralRealization +public import LeanPool.C145.C145H1ModalCalibration +public import LeanPool.C145.C145H2GridResidueInverse +public import LeanPool.C145.C145H2NumeratorData +public import LeanPool.C145.C145H2PositiveGrid +public import LeanPool.C145.C145N6CalibratedTransport +public import LeanPool.C145.C145N6GraphResponse +public import LeanPool.C145.C145N6HelmertFrame +public import LeanPool.C145.C145N6LineExclusion +public import LeanPool.C145.C145N6LiteralRows +public import LeanPool.C145.C145N6OrdinaryJets +public import LeanPool.C145.C145N6OriginalGraph +public import LeanPool.C145.C145N6PhysicalWitness +public import LeanPool.C145.C145N6PositiveGraph +public import LeanPool.C145.C145N6ResponseLine +public import LeanPool.C145.C145N6Squarefree +public import LeanPool.C145.C145N6TimeKernels +public import LeanPool.C145.C145N6TraceLine +public import LeanPool.C145.C145N6Uncalibrated +public import LeanPool.C145.C145ObservedKernelRecovery +public import LeanPool.C145.C145OrientedEigenframe +public import LeanPool.C145.C145PaperActualResponse +public import LeanPool.C145.C145PaperApplication +public import LeanPool.C145.C145PaperDomainChecks +public import LeanPool.C145.C145PaperPositiveWitness +public import LeanPool.C145.C145PaperRealizationInvariance +public import LeanPool.C145.C145PaperResidualInvariance +public import LeanPool.C145.C145PaperStability +public import LeanPool.C145.C145PaperTheoremC +public import LeanPool.C145.C145PhysicalFrame +public import LeanPool.C145.C145PhysicalTraceResidue +public import LeanPool.C145.C145ReceivingLagrangeMoments +public import LeanPool.C145.C145SignedGroundPulseCalibration +public import LeanPool.C145.C145SixFixedProducts +public import LeanPool.C145.C145SmallPhysicalTraceSeparation +public import LeanPool.C145.C145ThreePlaneFactor +public import LeanPool.C145.C145TimeKernelContinuation +public import LeanPool.C145.C145UncalibratedSmallH2 +public import LeanPool.C145.C145WeightedGraph diff --git a/LeanPool/projects/c145.yaml b/LeanPool/projects/c145.yaml new file mode 100644 index 0000000000..7362013ab9 --- /dev/null +++ b/LeanPool/projects/c145.yaml @@ -0,0 +1,41 @@ +slug: c145 +title: Exact single-port graph identification from two response derivatives +entry_module: LeanPool.C145 +authors: [Mark Gladden] +provenance: AI +license: Apache-2.0 +source: + url: https://github.com/VanGogh7777/c145-lean/blob/75d25568c084c8aab4faee30bd94905a6d20c3ad/paper/C145_v0.6.pdf + github_repo: VanGogh7777/c145-lean + commit: 75d25568c084c8aab4faee30bd94905a6d20c3ad +status: verified +summary: >- + Identifies a weighted graph Laplacian and signed port up to simultaneous vertex relabeling + from the first and mixed second terminal response derivatives in all smooth temporal + directions at one positive horizon. The general result assumes a common known positive + decay, connected symmetric nonnegative weighted graphs, cyclic ports, and a separation, + spectral-band and contraction criterion on the source. The project also identifies one + explicit six-vertex source under a separate set of assumptions. +branch: main +main_declarations: + - C145.PaperActualResponse.selected_response_theoremA_graph + - C145N6Frame.literal_N6_original_graph_identification +main_results: + - declaration: C145.PaperActualResponse.selected_response_theoremA_graph + source_ref: "C145 v0.6, Theorem 1 (§2.1, p. 2; Theorem A in Lean) and Appendix D (pp. 14–15)" + informal: >- + For connected symmetric nonnegative weighted graphs with a common known positive decay + and cyclic ports, equality of the first and mixed second terminal response derivatives + in all smooth temporal directions determines the source Laplacian and signed port up to + one vertex relabeling, when the source satisfies the stated separation, spectral-band + and contraction criterion. + - declaration: C145N6Frame.literal_N6_original_graph_identification + source_ref: "C145 v0.6, §10 (pp. 10–11), explicit six-vertex source" + informal: >- + The explicit six-vertex source has the same Laplacian and signed port up to a vertex + relabeling as any connected symmetric nonnegative weighted competitor with a cyclic + port, the same known decay, and matching first and mixed second terminal derivatives + of actual responses continuous at zero. A zero competitor diagonal also gives equality + of the full weight matrices under that relabeling. +msc: ['93B30', '05C50'] +tags: [graph identification, inverse problems, reaction diffusion]