import F02NavierStokes.LinearAlgebra3D import Mathlib.Analysis.Calculus.MeanValue import Mathlib.Tactic.Linarith import Mathlib.Tactic.Positivity import Mathlib.Tactic.Ring /-! # Planar Periodic All-Time Signed-Shell Ceiling (`Section 9.3`, `eq:rev-planar`) Formalizes Section 9.3 (`eq:rev-planar`, lines 1650--1673) and `C6` of F02: - `planar_multiplier_preserves_e3`: real-calculus ODE proof that if `H'(s) = H(s) B(s)` with `H(0) = I` and `B(s) e₃ = 0`, then `H(s) e₃ = e₃` identically on `[0, t]`. - `planar_shell_ceiling`: from `ω = ζ e₃` (`|ζ| ≤ M₀`), `D_R = δ • outer e₃`, `δ = ζ² + Q₃₃ - C₃₃` with `0 ≤ Q₃₃ ≤ M₀² - ζ²` and `0 ≤ C₃₃ ≤ M₀²`, `A = K₀ I + D_R`, and `K₀ ≥ M₀²`: 1. `ζ² - M₀² ≤ δ ≤ M₀²`, 2. `0 ⪯ A ⪯ (K₀ + M₀²) I`, 3. exact nonnegative quadratic deficit `2 K₀² + (K₀ + M₀²)² - tr(A²) = (M₀² - δ)(2 K₀ + M₀² + δ) ≥ 0`, 4. `E_A(t) ≤ 2 K₀² + (K₀ + M₀²)²` and `W(t) ≤ K₀ M₀² + M₀⁴ / 2` (`eq:rev-planar`). -/ namespace F02NavierStokes.PlanarCeiling open scoped Matrix BigOperators open Matrix F02NavierStokes.LinearAlgebra3D noncomputable section /-- The vertical unit basis vector `e₃ = (0, 0, 1)`. -/ def e3 : Vec3 := ![0, 0, 1] theorem e3_sqNorm : vecSqNorm e3 = 1 := by simp [e3, vecSqNorm, Fin.sum_univ_three] /-- Right-ordered planar preservation (`Section 9.3`, line 1655): if `H : ℝ → Mat3` satisfies `H 0 = 1`, componentwise `HasDerivAt` with `H'(s) = H(s) * B(s)` on `[0, t]`, and `B(s) *ᵥ e₃ = 0` for all `s ∈ [0, t]`, then `H(s) *ᵥ e₃ = e₃` for all `s ∈ [0, t]`! -/ theorem planar_multiplier_preserves_e3 {H B : ℝ → Mat3} {t : ℝ} (hH0 : H 0 = 1) (hHderiv : ∀ s ∈ Set.Icc 0 t, ∀ i j : Fin 3, HasDerivAt (fun u => H u i j) ((H s * B s) i j) s) (hBe3 : ∀ s ∈ Set.Icc 0 t, B s *ᵥ e3 = 0) : ∀ s ∈ Set.Icc 0 t, H s *ᵥ e3 = e3 := by intro s hs funext i let f : ℝ → ℝ := fun u => (H u *ᵥ e3) i have hf_deriv : ∀ u ∈ Set.Icc 0 t, HasDerivAt f 0 u := by intro u hu have hrow : HasDerivAt (fun r => ∑ j : Fin 3, H r i j * e3 j) (∑ j : Fin 3, (H u * B u) i j * e3 j) u := by apply HasDerivAt.fun_sum intro j _ exact (hHderiv u hu i j).mul_const (e3 j) have hzero : (∑ j : Fin 3, (H u * B u) i j * e3 j) = 0 := by have hvec : (H u * B u) *ᵥ e3 = 0 := by rw [← Matrix.mulVec_mulVec, hBe3 u hu, Matrix.mulVec_zero] have hi := congrFun hvec i simpa [Matrix.mulVec, dotProduct] using hi rw [hzero] at hrow simpa [f, Matrix.mulVec, dotProduct] using hrow have hcont : ContinuousOn f (Set.Icc 0 t) := fun u hu => (hf_deriv u hu).continuousAt.continuousWithinAt have hf0 : f 0 = e3 i := by simp [f, hH0] have hle : f s ≤ f 0 := image_le_of_deriv_right_le_deriv_boundary hcont (f' := fun _ => 0) (fun u hu => (hf_deriv u ⟨hu.1, le_of_lt hu.2⟩).hasDerivWithinAt) (B := fun _ => f 0) (B' := fun _ => 0) le_rfl continuousOn_const (fun u _ => hasDerivWithinAt_const u (Set.Ici u) (f 0)) (fun _ _ => le_rfl) hs have hge : -f s ≤ -f 0 := image_le_of_deriv_right_le_deriv_boundary hcont.neg (f' := fun _ => 0) (fun u hu => by simpa using (hf_deriv u ⟨hu.1, le_of_lt hu.2⟩).neg.hasDerivWithinAt) (B := fun _ => -f 0) (B' := fun _ => 0) le_rfl continuousOn_const (fun u _ => hasDerivWithinAt_const u (Set.Ici u) (-f 0)) (fun _ _ => le_rfl) hs change f s = e3 i linarith /-- Complete planar signed-shell ceiling (`Section 9.3`, `eq:rev-planar`, lines 1658--1672): with `|ζ| ≤ M₀`, `0 ≤ Q₃₃ ≤ M₀² - ζ²`, `0 ≤ C₃₃ ≤ M₀²`, `δ = ζ² + Q₃₃ - C₃₃`, `D_R = δ • outer e₃`, `A = K₀ I + D_R`, and `K₀ ≥ M₀²`: 1. `ζ² - M₀² ≤ δ ≤ M₀²`, 2. `0 ⪯ A ⪯ (K₀ + M₀²) I`, 3. exact identity `tr(A²) = 2 K₀² + (K₀ + δ)²` and nonnegative gap `2 K₀² + (K₀ + M₀²)² - tr(A²) = (M₀² - δ)(2 K₀ + M₀² + δ) ≥ 0`, 4. `tr(A²) ≤ 2 K₀² + (K₀ + M₀²)²`. -/ theorem planar_shell_pointwise_ceiling (K₀ M₀ ζ Q33 C33 : ℝ) (hK₀ : M₀ ^ 2 ≤ K₀) (hQ0 : 0 ≤ Q33) (hQle : Q33 ≤ M₀ ^ 2 - ζ ^ 2) (hC0 : 0 ≤ C33) (hCle : C33 ≤ M₀ ^ 2) : let δ := ζ ^ 2 + Q33 - C33 let D_R := δ • outer e3 let A := K₀ • (1 : Mat3) + D_R (ζ ^ 2 - M₀ ^ 2 ≤ δ ∧ δ ≤ M₀ ^ 2) ∧ (0 ≤ K₀ + δ ∧ K₀ + δ ≤ K₀ + M₀ ^ 2) ∧ IsPSD A ∧ (A ⪯ₗ (K₀ + M₀ ^ 2) • (1 : Mat3)) ∧ ((A * A).trace = 2 * K₀ ^ 2 + (K₀ + δ) ^ 2) ∧ (2 * K₀ ^ 2 + (K₀ + M₀ ^ 2) ^ 2 - (A * A).trace = (M₀ ^ 2 - δ) * (2 * K₀ + M₀ ^ 2 + δ)) ∧ ((A * A).trace ≤ 2 * K₀ ^ 2 + (K₀ + M₀ ^ 2) ^ 2) := by intro δ D_R A have hδ_lo : ζ ^ 2 - M₀ ^ 2 ≤ δ := by dsimp [δ]; linarith have hδ_hi : δ ≤ M₀ ^ 2 := by dsimp [δ]; linarith have hKδ_lo : 0 ≤ K₀ + δ := by nlinarith [sq_nonneg ζ] have hKδ_hi : K₀ + δ ≤ K₀ + M₀ ^ 2 := by linarith have hK₀_nn : 0 ≤ K₀ := (sq_nonneg M₀).trans hK₀ have hApsd : IsPSD A := by refine ⟨by simp [A, D_R, Matrix.transpose_add, Matrix.transpose_smul, outer_transpose], fun x => ?_⟩ simp only [A, D_R, Matrix.add_mulVec, Matrix.smul_mulVec, Matrix.one_mulVec, dotProduct_add, dotProduct_smul, smul_eq_mul, outer_dotProduct, ← vecSqNorm_eq_dotProduct] have hexp : K₀ * vecSqNorm x + δ * (vecDot e3 x) ^ 2 = K₀ * ((x 0) ^ 2 + (x 1) ^ 2) + (K₀ + δ) * (x 2) ^ 2 := by simp only [vecSqNorm, vecDot, e3, Fin.sum_univ_three, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two, Matrix.head_cons, Matrix.tail_cons] ring rw [hexp] nlinarith [sq_nonneg (x 0), sq_nonneg (x 1), sq_nonneg (x 2)] have hAle : A ⪯ₗ (K₀ + M₀ ^ 2) • (1 : Mat3) := by refine ⟨by simp [A, D_R, Matrix.transpose_sub, Matrix.transpose_add, Matrix.transpose_smul, outer_transpose], fun x => ?_⟩ simp only [A, D_R, Matrix.sub_mulVec, Matrix.add_mulVec, Matrix.smul_mulVec, Matrix.one_mulVec, dotProduct_sub, dotProduct_add, dotProduct_smul, smul_eq_mul, outer_dotProduct, ← vecSqNorm_eq_dotProduct] have hexp : (K₀ + M₀ ^ 2) * vecSqNorm x - (K₀ * vecSqNorm x + δ * (vecDot e3 x) ^ 2) = M₀ ^ 2 * ((x 0) ^ 2 + (x 1) ^ 2) + (M₀ ^ 2 - δ) * (x 2) ^ 2 := by simp only [vecSqNorm, vecDot, e3, Fin.sum_univ_three, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two, Matrix.head_cons, Matrix.tail_cons] ring rw [hexp] nlinarith [sq_nonneg M₀, sq_nonneg (x 0), sq_nonneg (x 1), sq_nonneg (x 2)] have htrA : (A * A).trace = 2 * K₀ ^ 2 + (K₀ + δ) ^ 2 := by have htr1 : (1 : Mat3).trace = 3 := by simp [Matrix.trace, Matrix.diag] have htrO : (outer e3).trace = 1 := by rw [outer_trace, e3_sqNorm] have htrO2 : (outer e3 * outer e3).trace = 1 := by rw [trace_outer_sq, e3_sqNorm]; ring dsimp only [A, D_R] rw [Matrix.add_mul, Matrix.mul_add, Matrix.mul_add, Matrix.trace_add, Matrix.trace_add, Matrix.trace_add] simp only [Matrix.smul_mul, Matrix.mul_smul, Matrix.one_mul, Matrix.mul_one, Matrix.trace_smul, smul_eq_mul, htr1, htrO, htrO2] ring have hgap : 2 * K₀ ^ 2 + (K₀ + M₀ ^ 2) ^ 2 - (A * A).trace = (M₀ ^ 2 - δ) * (2 * K₀ + M₀ ^ 2 + δ) := by rw [htrA]; ring have htr_le : (A * A).trace ≤ 2 * K₀ ^ 2 + (K₀ + M₀ ^ 2) ^ 2 := by have h1 : 0 ≤ M₀ ^ 2 - δ := by linarith have h2 : 0 ≤ 2 * K₀ + M₀ ^ 2 + δ := by nlinarith [sq_nonneg M₀] nlinarith [hgap, mul_nonneg h1 h2] exact ⟨⟨hδ_lo, hδ_hi⟩, ⟨hKδ_lo, hKδ_hi⟩, hApsd, hAle, htrA, hgap, htr_le⟩ /-- Integrated planar energy and complete signed work ceiling (`eq:rev-planar`, line 1666): from `E_A(t) ≤ 2 K₀² + (K₀ + M₀²)²` and `E_A(t) = 3 K₀² + 2 W(t)`, we obtain `W(t) ≤ K₀ M₀² + M₀⁴ / 2`! -/ theorem planar_energy_work_ceiling (K₀ M₀ E_A W : ℝ) (hE_le : E_A ≤ 2 * K₀ ^ 2 + (K₀ + M₀ ^ 2) ^ 2) (hWork : E_A = 3 * K₀ ^ 2 + 2 * W) : W ≤ K₀ * M₀ ^ 2 + M₀ ^ 4 / 2 := by nlinarith end end F02NavierStokes.PlanarCeiling