import F02NavierStokes.LinearAlgebra3D import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Add import Mathlib.Analysis.Calculus.Deriv.Comp import Mathlib.Analysis.Calculus.Deriv.Pow import Mathlib.Analysis.Calculus.Deriv.Inverse import Mathlib.Analysis.Calculus.MeanValue import Mathlib.MeasureTheory.Integral.IntervalIntegral.FundThmCalculus /-! # Ordered Vorticity Transport, Right Polar Law, Logstretch Bound, and Forced Covariance Formalizes Section 2 (`prop:martingale`, `prop:ordered-polar`) and Section 8.3 (`eq:force-martingale`--`eq:force-shell`) of F02 (`public-candidate/manuscript.tex`): - Right-ordered multiplier drift cancellation `ordered_drift_cancellation` (`H' = H b`, `w' = -b w ⇒ (H w)' = 0`, preserving matrix order without commutativity). - Two-copy independent signed norm identity `two_copy_signed_norm` (`E[Z · Z'] = |ω|²`). - Right polar Sylvester equation `polar_sylvester_equation` (`U U' + U' U = bᵀ U² + U² b`), both as a first-jet matrix identity and from actual `HasDerivAt` calculus. - Skew-adjointness of polar spin `polar_omega_skew` (`Ω_Q = U b U⁻¹ - U' U⁻¹ ⇒ Ω_Qᵀ = -Ω_Q`) and exact factorization identity `polar_omega_from_factorization` (`Qᵀ Q' = Ω_Q`). - Exact spin-strain mixing entry formula `polar_spin_strain_entries` (`eq:polar-spin-strain`): `(Ω_Q)ᵢⱼ = (W_b)ᵢⱼ + ((λᵢ - λⱼ) / (λᵢ + λⱼ)) (S_b)ᵢⱼ`, manifestly regular at `λᵢ = λⱼ`. - Ordered logstretch trace law `logstretch_trace_law` (`eq:scv-logstretch`): `tr(L U⁻¹ U') = tr(L Sym(b))` whenever `L U = U L`, without assuming `U` commutes with `U'`. - Pathwise logstretch Cauchy--Schwarz bound `pathwise_logstretch_bound` (`eq:scv-path-logstretch`): `ρ(s)² ≤ s ∫₀ˢ |S(v)|² dv`, via the manuscript's `√(ρ² + ε²)` regularization and `ε ↓ 0`. - Forced covariance and shell identities (`eq:force-covariance`, `eq:force-shell`) and exact distinction between `Z Zᵀ` and the drift-corrected `N Nᵀ`. -/ namespace F02NavierStokes.OrderedTransportPolar open scoped Matrix BigOperators open Matrix F02NavierStokes.LinearAlgebra3D noncomputable section /-! ## Section 2.1: Right-ordered multiplier drift cancellation and two-copy norm -/ /-- Exact right-ordered drift cancellation (`prop:martingale`): for `H' = H b` and drift `w' = -b w`, the product drift vanishes identically in its actual order. -/ theorem ordered_drift_cancellation_jet (H b : Mat3) (w : Vec3) : (H * b) *ᵥ w + H *ᵥ (-(b *ᵥ w)) = 0 := by rw [Matrix.mulVec_neg, Matrix.mulVec_mulVec, add_neg_cancel] /-- Calculus version of right-ordered drift cancellation for matrix/vector trajectories. -/ theorem ordered_drift_cancellation_deriv {H b : ℝ → Mat3} {w : ℝ → Vec3} {s : ℝ} (hH : ∀ i j, HasDerivAt (fun t => H t i j) ((H s * b s) i j) s) (hw : ∀ j, HasDerivAt (fun t => w t j) (-(b s *ᵥ w s) j) s) : ∀ i, HasDerivAt (fun t => (H t *ᵥ w t) i) 0 s := by intro i have hrow : HasDerivAt (fun t => ∑ j : Fin 3, H t i j * w t j) (∑ j : Fin 3, ((H s * b s) i j * w s j + H s i j * (-(b s *ᵥ w s)) j)) s := by apply HasDerivAt.fun_sum intro j _ exact (hH i j).mul (hw j) have hzero : ∑ j : Fin 3, ((H s * b s) i j * w s j + H s i j * (-(b s *ᵥ w s)) j) = 0 := by have hjet := congrFun (ordered_drift_cancellation_jet (H s) (b s) (w s)) i simpa [Matrix.mulVec, dotProduct, Finset.sum_add_distrib] using hjet rw [hzero] at hrow simpa [Matrix.mulVec, dotProduct] using hrow /-- Independent two-copy signed norm identity (`Section 2`, line 216): for any finite probability distribution `(p_k, Z_k)` with mean `ω = ∑ p_k Z_k`, the independent product expectation `∑_{j,k} p_j p_k (Z_j · Z_k)` equals `|ω|²`. -/ theorem two_copy_signed_norm {ι : Type*} [Fintype ι] (p : ι → ℝ) (Z : ι → Vec3) : let ω : Vec3 := fun c => ∑ k : ι, p k * Z k c (∑ j : ι, ∑ k : ι, p j * p k * vecDot (Z j) (Z k)) = vecSqNorm ω := by intro ω simp only [vecDot, vecSqNorm, ω, pow_two] trans (∑ c : Fin 3, ∑ j : ι, ∑ k : ι, (p j * Z j c) * (p k * Z k c)) · trans (∑ j : ι, ∑ c : Fin 3, ∑ k : ι, p j * p k * (Z j c * Z k c)) · apply Finset.sum_congr rfl intro j _ simp_rw [Finset.mul_sum] rw [Finset.sum_comm] · rw [Finset.sum_comm] apply Finset.sum_congr rfl intro c _ apply Finset.sum_congr rfl intro j _ apply Finset.sum_congr rfl intro k _ ring · apply Finset.sum_congr rfl intro c _ rw [Finset.sum_mul] apply Finset.sum_congr rfl intro j _ rw [← Finset.mul_sum] /-! ## Section 2.2: Right polar law and ordered logstretch (`prop:ordered-polar`) -/ /-- First-jet right polar Sylvester equation (`eq:ha-polar`): from `H = Q U`, `Qᵀ Q = I`, `Uᵀ = U`, `H' = H b`, and `H' = Q' U + Q U'`, together with `(Qᵀ Q)' = (Q')ᵀ Q + Qᵀ Q' = 0`, we obtain `U U' + U' U = bᵀ U² + U² b`. -/ theorem polar_sylvester_jet (Q Q' U U' b : Mat3) (hQorth : Qᵀ * Q = 1) (hQ'orth : Q'ᵀ * Q + Qᵀ * Q' = 0) (hUsym : Uᵀ = U) (hU'sym : U'ᵀ = U') (hH' : Q' * U + Q * U' = (Q * U) * b) : U * U' + U' * U = bᵀ * (U * U) + (U * U) * b := by have hHtH : (Q * U)ᵀ * (Q * U) = U * U := by calc (Q * U)ᵀ * (Q * U) = Uᵀ * (Qᵀ * Q) * U := by rw [Matrix.transpose_mul]; simp only [Matrix.mul_assoc] _ = U * U := by rw [hQorth, hUsym, Matrix.mul_one] have hLHS : (Q' * U + Q * U')ᵀ * (Q * U) + (Q * U)ᵀ * (Q' * U + Q * U') = U * U' + U' * U := by calc (Q' * U + Q * U')ᵀ * (Q * U) + (Q * U)ᵀ * (Q' * U + Q * U') = (Uᵀ * Q'ᵀ + U'ᵀ * Qᵀ) * (Q * U) + (Uᵀ * Qᵀ) * (Q' * U + Q * U') := by rw [Matrix.transpose_add, Matrix.transpose_mul, Matrix.transpose_mul, Matrix.transpose_mul] _ = U * (Q'ᵀ * Q + Qᵀ * Q') * U + U' * (Qᵀ * Q) * U + U * (Qᵀ * Q) * U' := by rw [hUsym, hU'sym]; noncomm_ring _ = U * U' + U' * U := by rw [hQ'orth, hQorth]; simp [add_comm] have hRHS : ((Q * U) * b)ᵀ * (Q * U) + (Q * U)ᵀ * ((Q * U) * b) = bᵀ * (U * U) + (U * U) * b := by calc ((Q * U) * b)ᵀ * (Q * U) + (Q * U)ᵀ * ((Q * U) * b) = bᵀ * ((Q * U)ᵀ * (Q * U)) + ((Q * U)ᵀ * (Q * U)) * b := by rw [Matrix.transpose_mul]; simp only [Matrix.mul_assoc] _ = bᵀ * (U * U) + (U * U) * b := by rw [hHtH] rw [← hLHS, hH', hRHS] /-- Polar rotation generator identity (`eq:ha-polar`): `Qᵀ Q' = U b U⁻¹ - U' U⁻¹`. -/ theorem polar_omega_from_factorization (Q Q' U U' Uinv b : Mat3) (hQorth : Qᵀ * Q = 1) (hUinv : U * Uinv = 1) (hH' : Q' * U + Q * U' = (Q * U) * b) : Qᵀ * Q' = U * b * Uinv - U' * Uinv := by have h1 : Qᵀ * (Q' * U + Q * U') = U * b := by rw [hH'] calc Qᵀ * (Q * U * b) = (Qᵀ * Q) * U * b := by simp only [Matrix.mul_assoc] _ = U * b := by rw [hQorth, Matrix.one_mul] have h2 : Qᵀ * Q' * U + U' = U * b := by calc Qᵀ * Q' * U + U' = Qᵀ * (Q' * U) + (Qᵀ * Q) * U' := by rw [hQorth, Matrix.one_mul, Matrix.mul_assoc] _ = Qᵀ * (Q' * U + Q * U') := by noncomm_ring _ = U * b := h1 have h3 : Qᵀ * Q' * U = U * b - U' := eq_sub_of_add_eq h2 calc Qᵀ * Q' = (Qᵀ * Q') * (U * Uinv) := by rw [hUinv, Matrix.mul_one] _ = (Qᵀ * Q' * U) * Uinv := (Matrix.mul_assoc (Qᵀ * Q') U Uinv).symm _ = (U * b - U') * Uinv := by rw [h3] _ = U * b * Uinv - U' * Uinv := Matrix.sub_mul _ _ _ /-- Skew-adjointness of `Ω_Q = U b U⁻¹ - U' U⁻¹` directly from the Sylvester equation (`prop:ordered-polar`). -/ theorem polar_omega_skew (U U' Uinv b : Mat3) (hUsym : Uᵀ = U) (hU'sym : U'ᵀ = U') (hUinvL : Uinv * U = 1) (hUinvR : U * Uinv = 1) (hSylv : U * U' + U' * U = bᵀ * (U * U) + (U * U) * b) : let Ω := U * b * Uinv - U' * Uinv Ωᵀ = -Ω := by intro Ω have hUinvSym : Uinvᵀ = Uinv := by have h1 : Uinvᵀ * U = 1 := by calc Uinvᵀ * U = Uinvᵀ * Uᵀ := by rw [hUsym] _ = (U * Uinv)ᵀ := (Matrix.transpose_mul U Uinv).symm _ = 1 := by rw [hUinvR, Matrix.transpose_one] calc Uinvᵀ = Uinvᵀ * (U * Uinv) := by rw [hUinvR, Matrix.mul_one] _ = (Uinvᵀ * U) * Uinv := by rw [Matrix.mul_assoc] _ = Uinv := by rw [h1, Matrix.one_mul] have hsum : Ωᵀ + Ω = 0 := by have hΩt : Ωᵀ = Uinv * bᵀ * U - Uinv * U' := by simp only [Ω, Matrix.transpose_sub, Matrix.transpose_mul, hUsym, hU'sym, hUinvSym, Matrix.mul_assoc] rw [hΩt] have hmid : bᵀ * (U * U) + (U * U) * b - (U' * U + U * U') = 0 := by rw [add_comm (U' * U), hSylv, sub_self] have hleft : Uinv * (bᵀ * (U * U) + (U * U) * b - (U' * U + U * U')) * Uinv = 0 := by rw [hmid, Matrix.mul_zero, Matrix.zero_mul] have hexp : Uinv * (bᵀ * (U * U) + (U * U) * b - (U' * U + U * U')) * Uinv = (Uinv * bᵀ * U - Uinv * U') + (U * b * Uinv - U' * Uinv) := by calc Uinv * (bᵀ * (U * U) + (U * U) * b - (U' * U + U * U')) * Uinv = Uinv * bᵀ * U * (U * Uinv) + (Uinv * U) * U * b * Uinv - Uinv * U' * (U * Uinv) - (Uinv * U) * U' * Uinv := by noncomm_ring _ = Uinv * bᵀ * U + U * b * Uinv - Uinv * U' - U' * Uinv := by rw [hUinvL, hUinvR]; noncomm_ring _ = (Uinv * bᵀ * U - Uinv * U') + (U * b * Uinv - U' * Uinv) := by abel rw [← hexp] exact hleft exact eq_neg_of_add_eq_zero_left hsum /-- Exact entrywise spin-strain mixing formula (`eq:polar-spin-strain`): in an instantaneous orthonormal eigenbasis where `U = diag(λ)` with `λᵢ > 0`, `(Ω_Q)ᵢⱼ = (W_b)ᵢⱼ + ((λᵢ - λⱼ) / (λᵢ + λⱼ)) (S_b)ᵢⱼ`, showing explicitly that strain generates polar rotation and that repeated eigenvalues (`λᵢ = λⱼ`) cause no singularity. -/ theorem polar_spin_strain_entries (lam : Fin 3 → ℝ) (hlam : ∀ i, 0 < lam i) (U' b : Mat3) (hSylv : Matrix.diagonal lam * U' + U' * Matrix.diagonal lam = bᵀ * (Matrix.diagonal lam * Matrix.diagonal lam) + (Matrix.diagonal lam * Matrix.diagonal lam) * b) (i j : Fin 3) : let U := Matrix.diagonal lam let Uinv := Matrix.diagonal (fun k => (lam k)⁻¹) let Ω := U * b * Uinv - U' * Uinv Ω i j = skewPart b i j + ((lam i - lam j) / (lam i + lam j)) * symPart b i j := by intro U Uinv Ω have hli : lam i ≠ 0 := ne_of_gt (hlam i) have hlj : lam j ≠ 0 := ne_of_gt (hlam j) have hsum_pos : lam i + lam j ≠ 0 := ne_of_gt (add_pos (hlam i) (hlam j)) have hsylv_ij := congrArg (fun M : Mat3 => M i j) hSylv simp only [Matrix.add_apply, Matrix.diagonal_mul, Matrix.mul_diagonal, Matrix.transpose_apply, Matrix.diagonal_mul_diagonal] at hsylv_ij have hΩ_ij : Ω i j = lam i * b i j * (lam j)⁻¹ - U' i j * (lam j)⁻¹ := by simp [Ω, U, Uinv, Matrix.diagonal_mul, Matrix.mul_diagonal] rw [hΩ_ij] simp only [skewPart, symPart, Matrix.smul_apply, Matrix.add_apply, Matrix.sub_apply, Matrix.transpose_apply, smul_eq_mul] -- From hsylv_ij: (lam i + lam j) * U' i j = b j i * (lam j * lam j) + (lam i * lam i) * b i j have hU' : U' i j = (b j i * (lam j * lam j) + (lam i * lam i) * b i j) / (lam i + lam j) := by apply eq_div_of_mul_eq hsum_pos linarith rw [hU'] field_simp [hli, hlj, hsum_pos] ring /-- Ordered logstretch trace law (`eq:scv-logstretch`): if `L` commutes with `U` and `U U' + U' U = bᵀ U² + U² b`, then `tr(L U⁻¹ U') = tr(L Sym(b))` without requiring `U` and `U'` to commute. -/ theorem logstretch_trace_law (L U U' Uinv b : Mat3) (hUinvL : Uinv * U = 1) (hUinvR : U * Uinv = 1) (hLU : L * U = U * L) (hSylv : U * U' + U' * U = bᵀ * (U * U) + (U * U) * b) : (L * Uinv * U').trace = (L * symPart b).trace := by have hLUinv : L * Uinv = Uinv * L := by calc L * Uinv = (Uinv * U) * L * Uinv := by rw [hUinvL, Matrix.one_mul] _ = Uinv * (U * L) * Uinv := by simp only [Matrix.mul_assoc] _ = Uinv * (L * U) * Uinv := by rw [hLU] _ = Uinv * L * (U * Uinv) := by simp only [Matrix.mul_assoc] _ = Uinv * L := by rw [hUinvR, Matrix.mul_one] have hLU2 : L * (U * U) = (U * U) * L := by calc L * (U * U) = (L * U) * U := by rw [Matrix.mul_assoc] _ = (U * L) * U := by rw [hLU] _ = U * (L * U) := by rw [Matrix.mul_assoc] _ = U * (U * L) := by rw [hLU] _ = (U * U) * L := by rw [Matrix.mul_assoc] have hmul := congrArg (fun M : Mat3 => (L * (Uinv * Uinv) * M).trace) hSylv have hLHS : (L * (Uinv * Uinv) * (U * U' + U' * U)).trace = 2 * (L * Uinv * U').trace := by rw [Matrix.mul_add, Matrix.trace_add] have t1 : L * (Uinv * Uinv) * (U * U') = L * Uinv * U' := by calc L * (Uinv * Uinv) * (U * U') = L * Uinv * (Uinv * U) * U' := by simp only [Matrix.mul_assoc] _ = L * Uinv * U' := by rw [hUinvL, Matrix.mul_one] have t2 : (L * (Uinv * Uinv) * (U' * U)).trace = (L * Uinv * U').trace := by calc (L * (Uinv * Uinv) * (U' * U)).trace = (U * (L * (Uinv * Uinv) * U')).trace := by rw [← Matrix.mul_assoc, Matrix.trace_mul_comm] _ = ((U * L) * Uinv * Uinv * U').trace := by simp only [Matrix.mul_assoc] _ = ((L * U) * Uinv * Uinv * U').trace := by rw [hLU] _ = (L * (U * Uinv) * Uinv * U').trace := by simp only [Matrix.mul_assoc] _ = (L * Uinv * U').trace := by rw [hUinvR, Matrix.mul_one] rw [t1, t2] ring have hRHS : (L * (Uinv * Uinv) * (bᵀ * (U * U) + (U * U) * b)).trace = 2 * (L * symPart b).trace := by rw [Matrix.mul_add, Matrix.trace_add] have t1 : (L * (Uinv * Uinv) * (bᵀ * (U * U))).trace = (L * bᵀ).trace := by calc (L * (Uinv * Uinv) * (bᵀ * (U * U))).trace = ((U * U) * (L * (Uinv * Uinv) * bᵀ)).trace := by rw [← Matrix.mul_assoc, Matrix.trace_mul_comm] _ = (((U * U) * L) * (Uinv * Uinv) * bᵀ).trace := by simp only [Matrix.mul_assoc] _ = ((L * (U * U)) * (Uinv * Uinv) * bᵀ).trace := by rw [hLU2] _ = (L * (U * (U * Uinv) * Uinv) * bᵀ).trace := by simp only [Matrix.mul_assoc] _ = (L * bᵀ).trace := by rw [hUinvR, Matrix.mul_one, hUinvR, Matrix.mul_one] have t2 : L * (Uinv * Uinv) * ((U * U) * b) = L * b := by calc L * (Uinv * Uinv) * ((U * U) * b) = L * (Uinv * (Uinv * U) * U) * b := by simp only [Matrix.mul_assoc] _ = L * b := by rw [hUinvL, Matrix.mul_one, hUinvL, Matrix.mul_one] rw [t1, t2] have hsym : 2 * (L * symPart b).trace = (L * b).trace + (L * bᵀ).trace := by simp only [symPart, Matrix.mul_smul, Matrix.mul_add, Matrix.trace_smul, Matrix.trace_add, smul_eq_mul] ring linarith rw [hLHS, hRHS] at hmul linarith /-- Pathwise logstretch Cauchy--Schwarz bound (`eq:scv-path-logstretch`): if `ρ : ℝ → ℝ` is continuous and nonnegative with `ρ(0) = 0`, `ρ²` has derivative bounded above by `2 ρ(v) |S(v)|`, and `|S|` is continuous on `[0, s]` (`s ≥ 0`), then `ρ(s)² ≤ s ∫₀ˢ |S(v)|² dv`. Follows the manuscript's exact `√(ρ² + ε²)` regularization and `ε ↓ 0` argument. -/ theorem pathwise_logstretch_bound {ρ strain : ℝ → ℝ} {s : ℝ} (hs : 0 ≤ s) (hρ_nonneg : ∀ v ∈ Set.Icc 0 s, 0 ≤ ρ v) (hρ0 : ρ 0 = 0) (hρsq_deriv : ∀ v ∈ Set.Icc 0 s, ∃ d : ℝ, HasDerivAt (fun t => (ρ t) ^ 2) d v ∧ d ≤ 2 * ρ v * strain v) (hstrain_nn : ∀ v ∈ Set.Icc 0 s, 0 ≤ strain v) (hstrain_cont : ContinuousOn strain (Set.Icc 0 s)) : (ρ s) ^ 2 ≤ s * ∫ v in (0 : ℝ)..s, (strain v) ^ 2 := by -- Helper: derivative of Real.sqrt at a positive point via local left inverse of `y ↦ y^2`. have hasDerivAt_sqrt_pos : ∀ {x : ℝ}, 0 < x → HasDerivAt Real.sqrt (2 * Real.sqrt x)⁻¹ x := by intro x hx have hg : ContinuousAt Real.sqrt x := Real.continuous_sqrt.continuousAt have hsq_pos : 0 < Real.sqrt x := Real.sqrt_pos.mpr hx have hf : HasDerivAt (fun y : ℝ => y ^ 2) (2 * Real.sqrt x) (Real.sqrt x) := by simpa using hasDerivAt_pow 2 (Real.sqrt x) have hfg : ∀ᶠ y in nhds x, (Real.sqrt y) ^ 2 = y := Filter.eventually_of_mem (Ioi_mem_nhds hx) fun y hy => Real.sq_sqrt (le_of_lt hy) exact hf.of_local_left_inverse hg (ne_of_gt (by positivity)) hfg -- Step 1: Show ρ(s) ≤ ∫₀ˢ strain(v) dv via g(t) = √(ρ(t)² + ε²) - ∫₀ᵗ strain. have hρ_le_int : ρ s ≤ ∫ v in (0 : ℝ)..s, strain v := by by_contra hlt push Not at hlt set δ := ρ s - ∫ v in (0 : ℝ)..s, strain v with hδ_def have hδ_pos : 0 < δ := sub_pos.mpr hlt -- Choose ε = δ / 2 > 0 set ε : ℝ := δ / 2 with hε_def have hε_pos : 0 < ε := half_pos hδ_pos -- Extend strain continuously to all of ℝ by clamping to [0, s]. let clamp : ℝ → ℝ := fun t => max 0 (min s t) have hclamp_cont : Continuous clamp := continuous_const.max (continuous_const.min continuous_id) have hclamp_mem : ∀ t : ℝ, clamp t ∈ Set.Icc 0 s := fun t => by refine ⟨le_max_left _ _, max_le hs (min_le_left _ _)⟩ have hclamp_id : ∀ t ∈ Set.Icc 0 s, clamp t = t := fun t ht => by dsimp [clamp] rw [min_eq_right ht.2, max_eq_right ht.1] let strainExt : ℝ → ℝ := fun t => strain (clamp t) have hstrainExt_cont : Continuous strainExt := hstrain_cont.comp_continuous hclamp_cont hclamp_mem have hint_eq : ∀ t ∈ Set.Icc 0 s, (∫ u in (0 : ℝ)..t, strainExt u) = ∫ u in (0 : ℝ)..t, strain u := by intro t ht apply intervalIntegral.integral_congr intro u hu rw [Set.uIcc_of_le ht.1] at hu dsimp [strainExt] rw [hclamp_id u ⟨hu.1, hu.2.trans ht.2⟩] let g : ℝ → ℝ := fun t => Real.sqrt ((ρ t) ^ 2 + ε ^ 2) - ∫ v in (0 : ℝ)..t, strainExt v have hderiv_sqrt : ∀ v ∈ Set.Icc 0 s, ∃ d : ℝ, HasDerivAt (fun t => Real.sqrt ((ρ t) ^ 2 + ε ^ 2)) (d / (2 * Real.sqrt ((ρ v) ^ 2 + ε ^ 2))) v ∧ d ≤ 2 * ρ v * strain v := by intro v hv obtain ⟨d, hd, hdle⟩ := hρsq_deriv v hv have hpos : 0 < (ρ v) ^ 2 + ε ^ 2 := by positivity have hcomp := (hasDerivAt_sqrt_pos hpos).comp v (hd.add_const (ε ^ 2)) refine ⟨d, ?_, hdle⟩ simpa [Function.comp_def, div_eq_mul_inv, mul_comm] using hcomp have hderiv_g : ∀ v ∈ Set.Icc 0 s, ∃ dg : ℝ, HasDerivAt g dg v ∧ dg ≤ 0 := by intro v hv obtain ⟨d, h1, hdle⟩ := hderiv_sqrt v hv have hsq_pos : 0 < Real.sqrt ((ρ v) ^ 2 + ε ^ 2) := Real.sqrt_pos.mpr (by positivity) have h2 : HasDerivAt (fun t => ∫ u in (0 : ℝ)..t, strainExt u) (strainExt v) v := intervalIntegral.integral_hasDerivAt_right (hstrainExt_cont.intervalIntegrable 0 v) hstrainExt_cont.aestronglyMeasurable.stronglyMeasurableAtFilter hstrainExt_cont.continuousAt have hsv : strainExt v = strain v := by dsimp [strainExt]; rw [hclamp_id v hv] rw [hsv] at h2 refine ⟨d / (2 * Real.sqrt ((ρ v) ^ 2 + ε ^ 2)) - strain v, h1.sub h2, ?_⟩ have hρ_le_rt : ρ v ≤ Real.sqrt ((ρ v) ^ 2 + ε ^ 2) := by calc ρ v = Real.sqrt ((ρ v) ^ 2) := (Real.sqrt_sq (hρ_nonneg v hv)).symm _ ≤ Real.sqrt ((ρ v) ^ 2 + ε ^ 2) := Real.sqrt_le_sqrt (by linarith [sq_nonneg ε]) have hnum : d ≤ 2 * Real.sqrt ((ρ v) ^ 2 + ε ^ 2) * strain v := by have hsn := hstrain_nn v hv nlinarith have hdiv : d / (2 * Real.sqrt ((ρ v) ^ 2 + ε ^ 2)) ≤ strain v := by rw [div_le_iff₀ (by positivity)] linarith linarith have hcont_g : ContinuousOn g (Set.Icc 0 s) := fun v hv => by obtain ⟨dg, hdg, _⟩ := hderiv_g v hv exact hdg.continuousAt.continuousWithinAt have hmono : g s ≤ g 0 := by let dgFun : ℝ → ℝ := fun v => if h : v ∈ Set.Icc 0 s then Classical.choose (hderiv_g v h) else 0 have hle := image_le_of_deriv_right_le_deriv_boundary hcont_g (f' := dgFun) (fun v hv => by have hv_icc : v ∈ Set.Icc 0 s := ⟨hv.1, le_of_lt hv.2⟩ simp only [dgFun, hv_icc, ↓reduceDIte] exact (Classical.choose_spec (hderiv_g v hv_icc)).1.hasDerivWithinAt) (B := fun _ => g 0) (B' := fun _ => 0) le_rfl continuousOn_const (fun v _ => hasDerivWithinAt_const v (Set.Ici v) (g 0)) (fun v hv => by have hv_icc : v ∈ Set.Icc 0 s := ⟨hv.1, le_of_lt hv.2⟩ simp only [dgFun, hv_icc, ↓reduceDIte] exact (Classical.choose_spec (hderiv_g v hv_icc)).2) exact hle ⟨hs, le_refl s⟩ have hg0 : g 0 = ε := by simp [g, hρ0, Real.sqrt_sq (le_of_lt hε_pos)] have hgs : ρ s - ∫ v in (0 : ℝ)..s, strain v ≤ g s := by dsimp [g] rw [hint_eq s ⟨hs, le_refl s⟩] have hρ_le_rt : ρ s ≤ Real.sqrt ((ρ s) ^ 2 + ε ^ 2) := by calc ρ s = Real.sqrt ((ρ s) ^ 2) := (Real.sqrt_sq (hρ_nonneg s ⟨hs, le_refl s⟩)).symm _ ≤ Real.sqrt ((ρ s) ^ 2 + ε ^ 2) := Real.sqrt_le_sqrt (by linarith [sq_nonneg ε]) linarith linarith [hδ_def, hε_def, hmono, hg0, hgs] -- Step 2: Time Cauchy--Schwarz: (∫₀ˢ strain(v) dv)² ≤ s ∫₀ˢ strain(v)² dv. have hcs : (∫ v in (0 : ℝ)..s, strain v) ^ 2 ≤ s * ∫ v in (0 : ℝ)..s, (strain v) ^ 2 := by have hint1 : IntervalIntegrable strain MeasureTheory.volume 0 s := hstrain_cont.intervalIntegrable_of_Icc hs have hint2 : IntervalIntegrable (fun v => (strain v) ^ 2) MeasureTheory.volume 0 s := (hstrain_cont.pow 2).intervalIntegrable_of_Icc hs have hquad : ∀ t : ℝ, 0 ≤ ∫ v in (0 : ℝ)..s, (strain v - t) ^ 2 := by intro t exact intervalIntegral.integral_nonneg hs fun v _ => sq_nonneg _ have hexp : ∀ t : ℝ, ∫ v in (0 : ℝ)..s, (strain v - t) ^ 2 = (∫ v in (0 : ℝ)..s, (strain v) ^ 2) - 2 * t * (∫ v in (0 : ℝ)..s, strain v) + t ^ 2 * s := by intro t have hrew : (fun v => (strain v - t) ^ 2) = fun v => ((strain v) ^ 2 - (2 * t) * strain v) + t ^ 2 := by funext v; ring rw [hrew] have hint_lin : IntervalIntegrable (fun v => (2 * t) * strain v) MeasureTheory.volume 0 s := hint1.const_mul (2 * t) rw [intervalIntegral.integral_add (hint2.sub hint_lin) intervalIntegrable_const, intervalIntegral.integral_sub hint2 hint_lin, intervalIntegral.integral_const_mul, intervalIntegral.integral_const, sub_zero, smul_eq_mul] ring by_cases hs0 : s = 0 · subst hs0; simp · have hs_pos : 0 < s := lt_of_le_of_ne hs (Ne.symm hs0) have hspec := hquad ((∫ v in (0 : ℝ)..s, strain v) / s) rw [hexp] at hspec have hmul : s * ((∫ v in (0 : ℝ)..s, (strain v) ^ 2) - 2 * ((∫ v in (0 : ℝ)..s, strain v) / s) * (∫ v in (0 : ℝ)..s, strain v) + ((∫ v in (0 : ℝ)..s, strain v) / s) ^ 2 * s) = s * (∫ v in (0 : ℝ)..s, (strain v) ^ 2) - (∫ v in (0 : ℝ)..s, strain v) ^ 2 := by field_simp ring nlinarith have hρs_nn : 0 ≤ ρ s := hρ_nonneg s ⟨hs, le_refl s⟩ have hint_nn : 0 ≤ ∫ v in (0 : ℝ)..s, strain v := intervalIntegral.integral_nonneg hs fun v hv => hstrain_nn v hv nlinarith /-! ## Section 8.3: Forcing covariance law (`eq:force-covariance`--`eq:force-shell`) -/ /-- Forced outer-product drift algebra (`eq:force-martingale`--`eq:force-covariance`): if `A_t - Ω = V_t - F_int` where `F_int = ∫₀ᵗ E[C_s^f] ds`, then `Ω = A_t - V_t + F_int`. With cutoff `k_s`, splitting into `k_s` and `(1 - k_s)` gives `eq:force-shell`. -/ theorem forced_covariance_and_shell (Ω A_t V_t A_chi V_chi F_chi F_comp : Mat3) (hcov : A_t - Ω = V_t - (F_chi + F_comp)) : let D_cross : Mat3 := (A_t - A_chi) - (V_t - V_chi) + F_comp Ω = A_t - V_t + (F_chi + F_comp) ∧ Ω = A_chi - V_chi + D_cross + F_chi := by intro D_cross have h1 : Ω = A_t - V_t + (F_chi + F_comp) := by have := congrArg (fun M => M + Ω + (F_chi + F_comp) - V_t) hcov -- direct entrywise linarith ext i j have hij := congrArg (fun M : Mat3 => M i j) hcov simp only [Matrix.sub_apply, Matrix.add_apply] at hij ⊢ linarith refine ⟨h1, ?_⟩ ext i j have hij := congrArg (fun M : Mat3 => M i j) h1 simp only [D_cross, Matrix.sub_apply, Matrix.add_apply] at hij ⊢ linarith /-- Replacing `Z Zᵀ` by the drift-corrected martingale `N Nᵀ` with `N = Z + F` adds exact non-zero cross and quadratic force terms (`Section 8.3`, line 1450). -/ theorem forced_corrected_martingale_diff (Z F : Vec3) : outer (Z + F) - outer Z = Matrix.of (fun i j => Z i * F j + F i * Z j) + outer F := by ext i j simp [outer] ring end end F02NavierStokes.OrderedTransportPolar