import NavierStokes.PartitionedCovariance import NavierStokes.FlatCovariance import NavierStokes.WeightedQuotients import NavierStokes.WeightedClasses /-! # Signed covariance updates with the constructed primary waves The signed solve uses the existing primary square roots, pulse columns, physical masks, covering powers, and angular phases. Distinct labels are separated by the constructed padded slots. A signed square is retained as a separate term; it is not included in the linear covariance identity. -/ noncomputable section namespace NavierStokes.SignedCovariance open Set Function Filter MeasureTheory Matrix open PartitionedCovariance open scoped BigOperators Topology ContDiff abbrev Vec2 := Fin 2 → ℝ abbrev Mat2 := Matrix (Fin 2) (Fin 2) ℝ abbrev Plane := TorusInverse.Plane /-- The numerator is the actual inverse-matrix solve. -/ noncomputable def increment (H : Mat2) (T R : Vec2) (j : Fin 2) : ℝ := (H⁻¹.mulVec R) j / (2 * SmoothCovariance.amplitudes H T j) theorem increment_eq_inverse (H : Mat2) (T R : Vec2) (hcone : SmoothCovariance.StrictCone H T) (j : Fin 2) : increment H T R j = (H⁻¹.mulVec R) j / (2 * Real.sqrt ((H⁻¹.mulVec T) j)) := by rw [increment, (amplitudes_are_inverse_weights hcone j).2] private theorem edge_zero_one : FlatCutoff.edge 0 1 = 1 := by rw [FlatCutoff.edge_of_pos 0 (by norm_num : (0 : ℝ) < 1)] norm_num private theorem edge_matrix_zero (H : Mat2) : FlatCovariance.edgeMatrix 0 (fun _ => H) 1 = H := by ext i j simp [FlatCovariance.edgeMatrix, FlatCovariance.columns, edge_zero_one] private theorem edge_target_zero (R : Vec2) : FlatCovariance.edgeTarget 0 (fun _ => R) 1 = R := by ext i simp [FlatCovariance.edgeTarget, FlatCovariance.scaledTarget, edge_zero_one] /-- The scalar solve is the already proved flat-edge solve at unit edge weight. -/ theorem increment_eq_flat (H : Mat2) (T R : Vec2) (hcone : SmoothCovariance.StrictCone H T) : increment H T R = FlatCovariance.signedAmplitude 0 0 0 (fun _ => H) (fun _ => T) (fun _ => R) 1 := by funext j simp only [increment, FlatCovariance.signedAmplitude, FlatCovariance.primaryAmplitude, FlatCovariance.inverseCoefficients, edge_matrix_zero, edge_target_zero] rw [SmoothCovariance.inverse_formula H T hcone.det_ne_zero] rfl /-- Exact two-sided covariance, reusing `FlatCovariance.signed_cross_reconstruct`. -/ theorem cross_reconstruct (H : Mat2) (T R : Vec2) (hcone : SmoothCovariance.StrictCone H T) : H.mulVec (fun j => 2 * SmoothCovariance.amplitudes H T j * increment H T R j) = R := by have he := FlatCovariance.signed_cross_reconstruct (σ := 0) (τ := 0) (κ := 0) (G := fun _ => H) (T := fun _ => T) (R := fun _ => R) (x := 1) hcone rw [← increment_eq_flat H T R hcone] at he simp only [FlatCovariance.primaryAmplitude, FlatCovariance.inverseCoefficients, edge_matrix_zero, edge_target_zero] at he rw [SmoothCovariance.inverse_formula H T hcone.det_ne_zero] at he exact he /-! ## A bilinear average of the actual waves -/ theorem wave_product_rescale (a b : ℝ) (n : ℕ) (f g : Plane → ℝ) (mode : ℤ) (phase : Plane → ℝ) (Y : Plane) (θ : ℝ) : wave a n f mode phase Y θ * wave b n g mode phase Y θ = (a * b) * (wave 1 n f mode phase Y θ * wave 1 n g mode phase Y θ) := by unfold wave ring theorem angularMean_bilinear (a b : ℝ) (n : ℕ) (f g : Plane → ℝ) (mode : ℤ) (hmode : mode ≠ 0) (phase : Plane → ℝ) (Y : Plane) : SmoothLoop.angularMean (fun θ => wave a n f mode phase Y θ * wave b n g mode phase Y θ) = (a * b) * ((covered n f Y * covered n g Y) * (1 / 2)) := by rw [show (fun θ => wave a n f mode phase Y θ * wave b n g mode phase Y θ) = (fun θ => (a * b) * (wave 1 n f mode phase Y θ * wave 1 n g mode phase Y θ)) from funext (fun θ => wave_product_rescale a b n f g mode phase Y θ)] rw [SmoothLoop.angularMean_const_mul, angularMean_wave_product 1 n f g mode hmode phase] ring theorem angularMean_bilinear_continuous (a b : ℝ) (n : ℕ) {f g : Plane → ℝ} (hf : Continuous f) (hcf : HasCompactSupport f) (hg : Continuous g) (hcg : HasCompactSupport g) (mode : ℤ) (hmode : mode ≠ 0) (phase : Plane → ℝ) : Continuous (fun Y => SmoothLoop.angularMean (fun θ => wave a n f mode phase Y θ * wave b n g mode phase Y θ)) := by simp_rw [angularMean_bilinear a b n f g mode hmode phase] exact continuous_const.mul (((covered_continuous hf hcf n).mul (covered_continuous hg hcg n)).mul continuous_const) /-- Both scalar coefficients multiply precisely the same native pulse. -/ theorem PairData.bilinear_diagonal {D h : ℝ} {vr vt : Plane} {sys : SlotSystem D h vr vt} {U : UnsignedLabel} (P : PairData sys U) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (a b : ℝ) (j i : Fin 2) : doubleAverage (fun Y θ => wave a (SlotColoring.nativeIndex h U.1) (P.rawRadial hdet j) (P.modes j) (P.phases j) Y θ * wave b (SlotColoring.nativeIndex h U.1) (P.rawTangent hdet j i) (P.modes j) (P.phases j) Y θ) = a * b * P.matrix i j := by have heq : (fun Y θ => wave a (SlotColoring.nativeIndex h U.1) (P.rawRadial hdet j) (P.modes j) (P.phases j) Y θ * wave b (SlotColoring.nativeIndex h U.1) (P.rawTangent hdet j i) (P.modes j) (P.phases j) Y θ) = fun Y θ => (a * b) * (wave 1 (SlotColoring.nativeIndex h U.1) (P.rawRadial hdet j) (P.modes j) (P.phases j) Y θ * wave 1 (SlotColoring.nativeIndex h U.1) (P.rawTangent hdet j i) (P.modes j) (P.phases j) Y θ) := by funext Y θ exact wave_product_rescale _ _ _ _ _ _ _ _ _ rw [heq] rw [doubleAverage_const_mul] have hu := (P.pulses j).wave_covariance vr vt (slotCenter h (signedLabel U j)) hdet (P.ci j) sys.radius (P.ci_pos j) sys.radius_pos (slotSet h sys.radius vr vt (signedLabel U j)) (sys.injective _) (P.rawRadial_support hdet j) (fun i => P.rawTangent_support hdet j i) 1 (SlotColoring.nativeIndex h U.1) (P.phases j) (P.modes j) (P.modes_ne j) i simpa only [PairData.rawRadial, PairData.rawTangent, PairData.matrix, pairMatrix, one_pow, one_mul] using congrArg (fun z : ℝ => a * b * z) hu /-! ## The same physical masks, slots, and phases for arbitrary coefficients -/ noncomputable def radialWith {D h : ℝ} {vr vt : Plane} {sys : SlotSystem D h vr vt} {U : UnsignedLabel} (P : PairData sys U) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (outer ε : ℝ) (a : Vec2) (q : ℝ) (x : SlotColoring.Position) (j : Fin 2) : Plane → ℝ → ℝ := wave (outer * (Real.sqrt ε * a j * mask D U q x)) (SlotColoring.nativeIndex h U.1) (P.rawRadial hdet j) (P.modes j) (P.phases j) noncomputable def tangentWith {D h : ℝ} {vr vt : Plane} {sys : SlotSystem D h vr vt} {U : UnsignedLabel} (P : PairData sys U) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (outer ε : ℝ) (a : Vec2) (q : ℝ) (x : SlotColoring.Position) (j i : Fin 2) : Plane → ℝ → ℝ := wave (outer * (Real.sqrt ε * a j * mask D U q x)) (SlotColoring.nativeIndex h U.1) (P.rawTangent hdet j i) (P.modes j) (P.phases j) /-- Pointwise diagonal reduction uses padded-slot disjointness, including when different labels carry the same angular harmonic. -/ theorem finite_product_diagonal {D h : ℝ} {vr vt : Plane} (sys : SlotSystem D h vr vt) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (N : ℕ) (hN : 1 ≤ N) (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (outer ε : UnsignedLabel → ℝ) (a b : UnsignedLabel → Vec2) (F : Finset UnsignedLabel) {q : ℝ} (hq : 0 < q) (x : SlotColoring.Position) (i : Fin 2) (Y : Plane) (θ : ℝ) : (∑ v ∈ F.product (Finset.univ : Finset (Fin 2)), radialWith (P v.1) hdet (outer v.1) (ε v.1) (a v.1) q x v.2 Y θ) * (∑ v ∈ F.product (Finset.univ : Finset (Fin 2)), tangentWith (P v.1) hdet (outer v.1) (ε v.1) (b v.1) q x v.2 i Y θ) = ∑ v ∈ F.product (Finset.univ : Finset (Fin 2)), radialWith (P v.1) hdet (outer v.1) (ε v.1) (a v.1) q x v.2 Y θ * tangentWith (P v.1) hdet (outer v.1) (ε v.1) (b v.1) q x v.2 i Y θ := by apply sum_product_diagonal intro v hv w hw hvw have hz := sys.wave_cross_zero (L := signedTailLabel N v) (M := signedTailLabel N w) (by change 1 ≤ v.1.1 + N; omega) (by change 1 ≤ w.1.1 + N; omega) (fun he => hvw (signedTailLabel_injective N he)) ((P v.1).rawRadial_support hdet v.2) ((P w.1).rawTangent_support hdet w.2 i) hq x Y θ (outer v.1 * Real.sqrt (ε v.1) * a v.1 v.2) (outer w.1 * Real.sqrt (ε w.1) * b w.1 w.2) ((P v.1).modes v.2) ((P w.1).modes w.2) ((P v.1).phases v.2) ((P w.1).phases w.2) simpa only [radialWith, tangentWith, signedTailLabel, physicalMask_signedLabel, signedLabel, physicalMask, mask, mul_assoc] using hz theorem finite_bilinear_covariance {D h : ℝ} {vr vt : Plane} (sys : SlotSystem D h vr vt) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (N : ℕ) (hN : 1 ≤ N) (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (outer ε : UnsignedLabel → ℝ) (a b : UnsignedLabel → Vec2) (F : Finset UnsignedLabel) (hε : ∀ U ∈ F, 0 ≤ ε U) {q : ℝ} (hq : 0 < q) (x : SlotColoring.Position) (i : Fin 2) : doubleAverage (fun Y θ => (∑ v ∈ F.product (Finset.univ : Finset (Fin 2)), radialWith (P v.1) hdet (outer v.1) (ε v.1) (a v.1) q x v.2 Y θ) * (∑ v ∈ F.product (Finset.univ : Finset (Fin 2)), tangentWith (P v.1) hdet (outer v.1) (ε v.1) (b v.1) q x v.2 i Y θ)) = ∑ U ∈ F, outer U ^ 2 * ε U * mask D (tailLabel N U) q x ^ 2 * ((P U).matrix.mulVec (fun j => a U j * b U j)) i := by simp_rw [finite_product_diagonal sys hdet N hN P outer ε a b F hq x i] rw [doubleAverage_sum] · apply (Finset.sum_product F Finset.univ _).trans apply Finset.sum_congr rfl intro U hU simp only [radialWith, tangentWith, PairData.bilinear_diagonal, Matrix.mulVec, dotProduct, Fin.sum_univ_two] have hs := Real.sq_sqrt (hε U hU) calc _ = outer U ^ 2 * (Real.sqrt (ε U)) ^ 2 * mask D (tailLabel N U) q x ^ 2 * ((P U).matrix i 0 * (a U 0 * b U 0) + (P U).matrix i 1 * (a U 1 * b U 1)) := by ring _ = _ := by rw [hs] · intro v hv Y exact (wave_continuous_theta _ _ _ _ _ _).mul (wave_continuous_theta _ _ _ _ _ _) · intro v hv exact angularMean_bilinear_continuous _ _ _ ((P v.1).rawRadial_continuous hdet v.2) ((P v.1).rawRadial_compact hdet v.2) ((P v.1).rawTangent_continuous hdet v.2 i) ((P v.1).rawTangent_compact hdet v.2 i) ((P v.1).modes v.2) ((P v.1).modes_ne v.2) ((P v.1).phases v.2) noncomputable def assembledRadialWith {D h : ℝ} {vr vt : Plane} {sys : SlotSystem D h vr vt} {N : ℕ} (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (outer ε : UnsignedLabel → ℝ) (a : UnsignedLabel → Vec2) (q : ℝ) (x : SlotColoring.Position) (Y : Plane) (θ : ℝ) : ℝ := ∑ᶠ v : UnsignedLabel × Fin 2, radialWith (P v.1) hdet (outer v.1) (ε v.1) (a v.1) q x v.2 Y θ noncomputable def assembledTangentWith {D h : ℝ} {vr vt : Plane} {sys : SlotSystem D h vr vt} {N : ℕ} (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (outer ε : UnsignedLabel → ℝ) (a : UnsignedLabel → Vec2) (q : ℝ) (x : SlotColoring.Position) (i : Fin 2) (Y : Plane) (θ : ℝ) : ℝ := ∑ᶠ v : UnsignedLabel × Fin 2, tangentWith (P v.1) hdet (outer v.1) (ε v.1) (a v.1) q x v.2 i Y θ theorem assembledRadialWith_finite {D h : ℝ} {vr vt : Plane} {sys : SlotSystem D h vr vt} {N : ℕ} (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (outer ε : UnsignedLabel → ℝ) (a : UnsignedLabel → Vec2) {q : ℝ} (hq : 0 < q) (x : SlotColoring.Position) (Y : Plane) (θ : ℝ) : assembledRadialWith P hdet outer ε a q x Y θ = ∑ v ∈ (finite_active_masks D N hq x).toFinset.product (Finset.univ : Finset (Fin 2)), radialWith (P v.1) hdet (outer v.1) (ε v.1) (a v.1) q x v.2 Y θ := by classical apply finsum_eq_sum_of_support_subset intro v hv refine Finset.mem_product.mpr ⟨?_, Finset.mem_univ _⟩ apply (finite_active_masks D N hq x).mem_toFinset.mpr intro hm exact hv (by simp [radialWith, wave, hm]) theorem assembledTangentWith_finite {D h : ℝ} {vr vt : Plane} {sys : SlotSystem D h vr vt} {N : ℕ} (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (outer ε : UnsignedLabel → ℝ) (a : UnsignedLabel → Vec2) {q : ℝ} (hq : 0 < q) (x : SlotColoring.Position) (i : Fin 2) (Y : Plane) (θ : ℝ) : assembledTangentWith P hdet outer ε a q x i Y θ = ∑ v ∈ (finite_active_masks D N hq x).toFinset.product (Finset.univ : Finset (Fin 2)), tangentWith (P v.1) hdet (outer v.1) (ε v.1) (a v.1) q x v.2 i Y θ := by classical apply finsum_eq_sum_of_support_subset intro v hv refine Finset.mem_product.mpr ⟨?_, Finset.mem_univ _⟩ apply (finite_active_masks D N hq x).mem_toFinset.mpr intro hm exact hv (by simp [tangentWith, wave, hm]) theorem assembled_bilinear_covariance {D h : ℝ} {vr vt : Plane} (sys : SlotSystem D h vr vt) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (N : ℕ) (hN : 1 ≤ N) (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (outer ε : UnsignedLabel → ℝ) (a b : UnsignedLabel → Vec2) {q : ℝ} (hq : 0 < q) (x : SlotColoring.Position) (hε : ∀ U, mask D (tailLabel N U) q x ≠ 0 → 0 ≤ ε U) (i : Fin 2) : doubleAverage (fun Y θ => assembledRadialWith P hdet outer ε a q x Y θ * assembledTangentWith P hdet outer ε b q x i Y θ) = ∑ᶠ U : UnsignedLabel, outer U ^ 2 * ε U * mask D (tailLabel N U) q x ^ 2 * ((P U).matrix.mulVec (fun j => a U j * b U j)) i := by classical simp_rw [assembledRadialWith_finite P hdet outer ε a hq x, assembledTangentWith_finite P hdet outer ε b hq x i] rw [finite_bilinear_covariance sys hdet N hN P outer ε a b _ (fun U hU => hε U ((finite_active_masks D N hq x).mem_toFinset.mp hU)) hq x i] symm apply finsum_eq_sum_of_support_subset intro U hU apply (finite_active_masks D N hq x).mem_toFinset.mpr intro hm exact hU (by simp [hm]) /-- Off-diagonal products vanish before either integral, so interchanging the two scalar coefficient families leaves the product unchanged pointwise. -/ theorem assembled_bilinear_symmetry {D h : ℝ} {vr vt : Plane} (sys : SlotSystem D h vr vt) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (N : ℕ) (hN : 1 ≤ N) (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (outer ε : UnsignedLabel → ℝ) (a b : UnsignedLabel → Vec2) {q : ℝ} (hq : 0 < q) (x : SlotColoring.Position) (i : Fin 2) (Y : Plane) (θ : ℝ) : assembledRadialWith P hdet outer ε a q x Y θ * assembledTangentWith P hdet outer ε b q x i Y θ = assembledRadialWith P hdet outer ε b q x Y θ * assembledTangentWith P hdet outer ε a q x i Y θ := by classical simp_rw [assembledRadialWith_finite P hdet outer ε _ hq x, assembledTangentWith_finite P hdet outer ε _ hq x i, finite_product_diagonal sys hdet N hN P outer ε _ _ _ hq x i] apply Finset.sum_congr rfl intro v hv unfold radialWith tangentWith wave ring noncomputable def signedRadial {D h : ℝ} {vr vt : Plane} {sys : SlotSystem D h vr vt} {N : ℕ} (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (outer ε : UnsignedLabel → ℝ) (T R : UnsignedLabel → Vec2) (q : ℝ) (x : SlotColoring.Position) : Plane → ℝ → ℝ := assembledRadialWith P hdet outer ε (fun U => increment (P U).matrix (T U) (R U)) q x noncomputable def signedTangent {D h : ℝ} {vr vt : Plane} {sys : SlotSystem D h vr vt} {N : ℕ} (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (outer ε : UnsignedLabel → ℝ) (T R : UnsignedLabel → Vec2) (q : ℝ) (x : SlotColoring.Position) (i : Fin 2) : Plane → ℝ → ℝ := assembledTangentWith P hdet outer ε (fun U => increment (P U).matrix (T U) (R U)) q x i theorem cross_reconstruct_component (H : Mat2) (T R : Vec2) (hcone : SmoothCovariance.StrictCone H T) (i : Fin 2) : 2 * (H.mulVec (fun j => SmoothCovariance.amplitudes H T j * increment H T R j)) i = R i := by have hc := congrFun (cross_reconstruct H T R hcone) i simp only [Matrix.mulVec, dotProduct, Fin.sum_univ_two] at hc ⊢ calc _ = H i 0 * (2 * SmoothCovariance.amplitudes H T 0 * increment H T R 0) + H i 1 * (2 * SmoothCovariance.amplitudes H T 1 * increment H T R 1) := by ring _ = _ := hc /-- The assembled two-sided primary/signed cross covariance. Positivity is required only for primary weights; the signed target is arbitrary. -/ theorem assembled_cross_covariance {D h : ℝ} {vr vt : Plane} (sys : SlotSystem D h vr vt) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (N : ℕ) (hN : 1 ≤ N) (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) (outer ε : UnsignedLabel → ℝ) (T R : UnsignedLabel → Vec2) {q : ℝ} (hq : 0 < q) (x : SlotColoring.Position) (hε : ∀ U, mask D (tailLabel N U) q x ≠ 0 → 0 ≤ ε U) (hcone : ∀ U, mask D (tailLabel N U) q x ≠ 0 → SmoothCovariance.StrictCone (P U).matrix (T U)) (i : Fin 2) : doubleAverage (fun Y θ => assembledRadial P hdet outer ε T q x Y θ * signedTangent P hdet outer ε T R q x i Y θ + signedRadial P hdet outer ε T R q x Y θ * assembledTangent P hdet outer ε T q x i Y θ) = ∑ᶠ U : UnsignedLabel, outer U ^ 2 * ε U * mask D (tailLabel N U) q x ^ 2 * R U i := by let a : UnsignedLabel → Vec2 := fun U => SmoothCovariance.amplitudes (P U).matrix (T U) let b : UnsignedLabel → Vec2 := fun U => increment (P U).matrix (T U) (R U) have heq : (fun Y θ => assembledRadial P hdet outer ε T q x Y θ * signedTangent P hdet outer ε T R q x i Y θ + signedRadial P hdet outer ε T R q x Y θ * assembledTangent P hdet outer ε T q x i Y θ) = fun Y θ => 2 * (assembledRadialWith P hdet outer ε a q x Y θ * assembledTangentWith P hdet outer ε b q x i Y θ) := by funext Y θ change assembledRadialWith P hdet outer ε a q x Y θ * assembledTangentWith P hdet outer ε b q x i Y θ + assembledRadialWith P hdet outer ε b q x Y θ * assembledTangentWith P hdet outer ε a q x i Y θ = _ rw [assembled_bilinear_symmetry sys hdet N hN P outer ε b a hq x i] ring rw [heq, doubleAverage_const_mul, assembled_bilinear_covariance sys hdet N hN P outer ε a b hq x hε i] have hf : (support (fun U : UnsignedLabel => outer U ^ 2 * ε U * mask D (tailLabel N U) q x ^ 2 * ((P U).matrix.mulVec (fun j => a U j * b U j)) i)).Finite := by apply (finite_active_masks D N hq x).subset intro U hU hm exact hU (by simp [hm]) rw [mul_finsum _ 2] apply finsum_congr intro U by_cases hm : mask D (tailLabel N U) q x = 0 · simp [hm] · calc _ = (outer U ^ 2 * ε U * mask D (tailLabel N U) q x ^ 2) * (2 * ((P U).matrix.mulVec (fun j => a U j * b U j)) i) := by ring _ = _ := by rw [cross_reconstruct_component (P U).matrix (T U) (R U) (hcone U hm) i] /-! ## The physical signed target -/ /-- Section 10.2's chart stress `Q^(2 A) σ / ε`. -/ noncomputable def chartStress (h : ℝ) (N : ℕ) (σ : Vec2) (U : UnsignedLabel) : Vec2 := fun i => ChartScales.Q (U.1 + N) ^ (2 * velocityExponent h) * σ i / physicalViscosity h N U theorem physical_signed_scale (h : ℝ) (N : ℕ) (σ : Vec2) (U : UnsignedLabel) (i : Fin 2) : physicalOuter h N U ^ 2 * physicalViscosity h N U * chartStress h N σ U i = σ i := by have hQ := ChartScales.Q_pos (U.1 + N) have hε := ChartScales.epsilon_pos h (U.1 + N) have hp : (ChartScales.Q (U.1 + N) ^ (-velocityExponent h)) ^ 2 * ChartScales.Q (U.1 + N) ^ (2 * velocityExponent h) = 1 := by rw [← Real.rpow_mul_natCast hQ.le, ← Real.rpow_add hQ] have he : -velocityExponent h * (2 : ℝ) + 2 * velocityExponent h = 0 := by ring simp only [Nat.cast_ofNat, he, Real.rpow_zero] unfold physicalOuter chartStress change _ * ChartScales.epsilon h (U.1 + N) * (_ * σ i / ChartScales.epsilon h (U.1 + N)) = _ calc _ = ((ChartScales.Q (U.1 + N) ^ (-velocityExponent h)) ^ 2 * ChartScales.Q (U.1 + N) ^ (2 * velocityExponent h)) * σ i := by field_simp _ = _ := by rw [hp, one_mul] /-- The actual two-sided primary/signed covariance equals the prescribed physical stress, for the same constructed squared partition as the primary. -/ theorem physical_signed_cross_covariance {D h : ℝ} {vr vt : Plane} (sys : SlotSystem D h vr vt) (hdet : vr.1 * vt.2 - vr.2 * vt.1 ≠ 0) (N : ℕ) (hN : 1 ≤ N) (P : (U : UnsignedLabel) → PairData sys (tailLabel N U)) {q : ℝ} (hq : 0 < q) (hqN : q ≤ ChartScales.Q N) (x : SlotColoring.Position) (T0 σ : Vec2) (hcone : ∀ U, mask D (tailLabel N U) q x ≠ 0 → SmoothCovariance.StrictCone (P U).matrix (chartTarget h q N T0 U)) (i : Fin 2) : doubleAverage (fun Y θ => assembledRadial P hdet (physicalOuter h N) (physicalViscosity h N) (chartTarget h q N T0) q x Y θ * signedTangent P hdet (physicalOuter h N) (physicalViscosity h N) (chartTarget h q N T0) (chartStress h N σ) q x i Y θ + signedRadial P hdet (physicalOuter h N) (physicalViscosity h N) (chartTarget h q N T0) (chartStress h N σ) q x Y θ * assembledTangent P hdet (physicalOuter h N) (physicalViscosity h N) (chartTarget h q N T0) q x i Y θ) = σ i := by rw [assembled_cross_covariance sys hdet N hN P (physicalOuter h N) (physicalViscosity h N) (chartTarget h q N T0) (chartStress h N σ) hq x (fun U _ => (ChartScales.epsilon_pos h (U.1 + N)).le) hcone i] have heq (U : UnsignedLabel) : physicalOuter h N U ^ 2 * physicalViscosity h N U * mask D (tailLabel N U) q x ^ 2 * chartStress h N σ U i = mask D (tailLabel N U) q x ^ 2 * σ i := by calc _ = mask D (tailLabel N U) q x ^ 2 * (physicalOuter h N U ^ 2 * physicalViscosity h N U * chartStress h N σ U i) := by ring _ = _ := by rw [physical_signed_scale] simp_rw [heq] have hf : (support (fun U : UnsignedLabel => mask D (tailLabel N U) q x ^ 2)).Finite := by apply (finite_active_masks D N hq x).subset intro U hU hz exact hU (by simp [hz]) rw [← finsum_mul _ _, physical_mask_tail_sum_sq D N hq hqN x, one_mul] /-! ## Uniform weighted jets from input classes and a primary lower bound -/ open WeightedClasses section Weighted variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] /-- A polynomial reciprocal bound, imposed only on the positive primary weight. No regularity of a quotient by the envelope is assumed. -/ noncomputable def InverseControl (s : StripData E) (w g : ℕ → E → ℝ) : Prop := ∃ C : ℝ, 0 ≤ C ∧ ∃ p : ℕ, ∀ n x, x ∈ s.domain → w n x / g n x ≤ C * s.growth n x ^ p theorem inverseControl_of_lower {s : StripData E} {w g : ℕ → E → ℝ} (hg : ∀ n x, x ∈ s.domain → 0 < g n x) {c : ℝ} (hc : 0 < c) (p : ℕ) (hlower : ∀ n x, x ∈ s.domain → c * w n x / s.growth n x ^ p ≤ g n x) : InverseControl s w g := by refine ⟨c⁻¹, (inv_pos.mpr hc).le, p, ?_⟩ intro n x hx have hG : 0 < s.growth n x ^ p := pow_pos (zero_lt_one.trans_le (s.one_le_growth n x)) _ have hl := (div_le_iff₀ hG).mp (hlower n x hx) apply (div_le_iff₀ (hg n x hx)).mpr calc w n x = c⁻¹ * (c * w n x) := by rw [← mul_assoc, inv_mul_cancel₀ hc.ne', one_mul] _ ≤ c⁻¹ * (g n x * s.growth n x ^ p) := mul_le_mul_of_nonneg_left hl (inv_pos.mpr hc).le _ = _ := by ring /-- A common finite envelope for input jets and the positive lower bound, uniform in the discrete band and every point of the strip. -/ theorem class_input_envelope {s : StripData E} {w g r : ℕ → E → ℝ} (hw : ∀ n x, x ∈ s.domain → 0 < w n x) (hp : ∀ n x, x ∈ s.domain → 0 < g n x) (hg : MemClass s w 0 g) (hr : MemClass s w 0 r) (hlower : InverseControl s w g) (m : ℕ) : ∃ C : ℝ, 1 ≤ C ∧ ∃ p : ℕ, ∀ n x, x ∈ s.domain → 1 ≤ C * s.growth n x ^ p ∧ w n x / (C * s.growth n x ^ p) ≤ g n x ∧ (∀ j ≤ m, ‖iteratedFDeriv ℝ j (g n) x‖ ≤ w n x * (C * s.growth n x ^ p)) ∧ (∀ j ≤ m, ‖iteratedFDeriv ℝ j (r n) x‖ ≤ w n x * (C * s.growth n x ^ p)) := by obtain ⟨Cg, hCg, pg, hgj⟩ := hg.bounds m obtain ⟨Cr, hCr, pr, hrj⟩ := hr.bounds m obtain ⟨C0, hC0, p0, hl⟩ := hlower let C := Cg + Cr + C0 + 1 let p := pg + pr + p0 have hC : 1 ≤ C := by dsimp [C]; linarith refine ⟨C, hC, p, ?_⟩ intro n x hx have hm (A : ℝ) (hA : 0 ≤ A) (hAC : A ≤ C) (k : ℕ) (hkp : k ≤ p) : A * s.growth n x ^ k ≤ C * s.growth n x ^ p := by exact mul_le_mul hAC (pow_le_pow_right₀ (s.one_le_growth n x) hkp) (pow_nonneg (s.growth_nonneg n x) k) (zero_le_one.trans hC) have hB : 1 ≤ C * s.growth n x ^ p := one_le_mul_of_one_le_of_one_le hC (one_le_pow₀ (s.one_le_growth n x)) refine ⟨hB, ?_, ?_, ?_⟩ · apply (div_le_iff₀ (zero_lt_one.trans_le hB)).mpr have hl' : w n x / g n x ≤ C * s.growth n x ^ p := (hl n x hx).trans (hm C0 hC0 (by dsimp [C]; linarith) p0 (by dsimp [p]; omega)) simpa only [mul_comm] using (div_le_iff₀ (hp n x hx)).mp hl' · intro j hj calc _ ≤ Cg * s.growth n x ^ pg * w n x := by simpa only [majorant, Real.rpow_zero, mul_one] using hgj n x hx j hj _ ≤ (C * s.growth n x ^ p) * w n x := mul_le_mul_of_nonneg_right (hm Cg hCg (by dsimp [C]; linarith) pg (by dsimp [p]; omega)) (hw n x hx).le _ = _ := by ring · intro j hj calc _ ≤ Cr * s.growth n x ^ pr * w n x := by simpa only [majorant, Real.rpow_zero, mul_one] using hrj n x hx j hj _ ≤ (C * s.growth n x ^ p) * w n x := mul_le_mul_of_nonneg_right (hm Cr hCr (by dsimp [C]; linarith) pr (by dsimp [p]; omega)) (hw n x hx).le _ = _ := by ring noncomputable def signedJetCost (j : ℕ) : ℝ := WeightedQuotients.chooseSum j * WeightedQuotients.orderBound (-(1 / 2 : ℝ)) j / 2 noncomputable def prefixJetCost (m : ℕ) : ℝ := 1 + ∑ j ∈ Finset.range (m + 1), |signedJetCost j| theorem prefixJetCost_pos (m : ℕ) : 0 < prefixJetCost m := by have hs := Finset.sum_nonneg (s := Finset.range (m + 1)) (fun j _ => abs_nonneg (signedJetCost j)) dsimp [prefixJetCost] linarith theorem signedJetCost_le {j m : ℕ} (hj : j ≤ m) : signedJetCost j ≤ prefixJetCost m := by have hs := Finset.single_le_sum (f := fun j => |signedJetCost j|) (fun k _ => abs_nonneg (signedJetCost k)) (Finset.mem_range.mpr (Nat.lt_succ_of_le hj)) exact (le_abs_self _).trans (hs.trans (by dsimp [prefixJetCost]; linarith)) /-- Derive the all-order signed quotient class from weighted input jets. The weight is never differentiated or divided out as a variable function. -/ theorem signed_quotient_class_zero {s : StripData E} {w g r : ℕ → E → ℝ} (hw : ∀ n x, x ∈ s.domain → 0 < w n x) (hp : ∀ n x, x ∈ s.domain → 0 < g n x) (hg : MemClass s w 0 g) (hr : MemClass s w 0 r) (hlower : InverseControl s w g) : MemClass s (fun n x => Real.sqrt (w n x)) 0 (fun n x => r n x / (2 * Real.sqrt (g n x))) := by have hsmooth (n : ℕ) : ContDiffOn ℝ ∞ (fun x => r n x / (2 * Real.sqrt (g n x))) s.domain := (hr.smooth n).div (contDiffOn_const.mul ((hg.smooth n).sqrt (fun x hx => (hp n x hx).ne'))) (fun x hx => mul_ne_zero (by norm_num) (Real.sqrt_pos.mpr (hp n x hx)).ne') refine ⟨fun n x hx => Real.sqrt_nonneg _, hsmooth, ?_⟩ intro m obtain ⟨C, hC, p, henv⟩ := class_input_envelope hw hp hg hr hlower m refine ⟨prefixJetCost m * C ^ (2 * m + 2), mul_nonneg (prefixJetCost_pos m).le (pow_nonneg (zero_le_one.trans hC) _), p * (2 * m + 2), ?_⟩ intro n x hx j hj obtain ⟨hB, hlo, hgj, hrj⟩ := henv n x hx have hb := WeightedQuotients.signed_jet_bound s.isOpen_domain (hg.smooth n) (hr.smooth n) (hp n) hx (hw n x hx) hB j hlo (fun k hk => hgj k (hk.trans hj)) (fun k hk => hrj k (hk.trans hj)) calc _ ≤ Real.sqrt (w n x) * signedJetCost j * (C * s.growth n x ^ p) ^ (2 * j + 2) := hb _ ≤ Real.sqrt (w n x) * prefixJetCost m * (C * s.growth n x ^ p) ^ (2 * m + 2) := by apply mul_le_mul · exact mul_le_mul_of_nonneg_left (signedJetCost_le hj) (Real.sqrt_nonneg _) · exact pow_le_pow_right₀ hB (by omega) · exact pow_nonneg (zero_le_one.trans hB) _ · exact mul_nonneg (Real.sqrt_nonneg _) (prefixJetCost_pos m).le _ = majorant s (fun n x => Real.sqrt (w n x)) 0 (prefixJetCost m * C ^ (2 * m + 2)) (p * (2 * m + 2)) n x := by simp only [majorant, Real.rpow_zero, mul_one, mul_pow, pow_mul] ring /-- Discrete powers of epsilon pass through the quotient without a jet loss. -/ theorem signed_quotient_class {s : StripData E} {w g r : ℕ → E → ℝ} {β : ℝ} (hw : ∀ n x, x ∈ s.domain → 0 < w n x) (hp : ∀ n x, x ∈ s.domain → 0 < g n x) (hg : MemClass s w 0 g) (hr : MemClass s w β r) (hlower : InverseControl s w g) : MemClass s (fun n x => Real.sqrt (w n x)) β (fun n x => r n x / (2 * Real.sqrt (g n x))) := by have hr0 : MemClass s w 0 (fun n x => s.epsilon n ^ (-β) * r n x) := by simpa only [smul_eq_mul, add_neg_cancel] using hr.band_smul (bandBound_rpow s (-β)) have hq0 := signed_quotient_class_zero hw hp hg hr0 hlower have hq := hq0.band_smul (bandBound_rpow s β) have heq : (fun n x => s.epsilon n ^ β • (s.epsilon n ^ (-β) * r n x / (2 * Real.sqrt (g n x)))) = (fun n x => r n x / (2 * Real.sqrt (g n x))) := by funext n x simp only [smul_eq_mul, ← mul_div_assoc, ← mul_assoc, ← Real.rpow_add (s.epsilon_pos n), add_neg_cancel, Real.rpow_zero, one_mul] simpa only [zero_add, heq] using hq /-- A companion primary square-root bound from the same genuine inputs. -/ theorem sqrt_class {s : StripData E} {w g : ℕ → E → ℝ} (hw : ∀ n x, x ∈ s.domain → 0 < w n x) (hp : ∀ n x, x ∈ s.domain → 0 < g n x) (hg : MemClass s w 0 g) (hlower : InverseControl s w g) : MemClass s (fun n x => Real.sqrt (w n x)) 0 (fun n x => Real.sqrt (g n x)) := by have hq := signed_quotient_class_zero hw hp hg hg hlower have htwo : BandBound s 0 (fun _ => (2 : ℝ)) := by refine ⟨2, by norm_num, 0, ?_⟩ intro n simp have heq : (fun n x => (2 : ℝ) • (g n x / (2 * Real.sqrt (g n x)))) = (fun n x => Real.sqrt (g n x)) := by funext n x simp only [smul_eq_mul] calc 2 * (g n x / (2 * Real.sqrt (g n x))) = g n x / Real.sqrt (g n x) := by ring _ = _ := Real.div_sqrt simpa only [zero_add, heq] using hq.band_smul htwo theorem memClass_congrOn {s : StripData E} {w f g : ℕ → E → ℝ} {β : ℝ} (hf : MemClass s w β f) (heq : ∀ n x, x ∈ s.domain → f n x = g n x) : MemClass s w β g := by refine ⟨hf.weight_nonneg, fun n => (hf.smooth n).congr (fun x hx => (heq n x hx).symm), ?_⟩ intro m obtain ⟨C, hC, p, hb⟩ := hf.bounds m refine ⟨C, hC, p, ?_⟩ intro n x hx j hj have he : g n =ᶠ[𝓝 x] f n := by filter_upwards [s.isOpen_domain.mem_nhds hx] with y hy exact (heq n y hy).symm rw [WeightedQuotients.jet_congr he j] exact hb n x hx j hj /-- The actual matrix-inverse signed coefficient has the half-weight class, derived from the inverse numerator jets and positive primary inverse jets. -/ theorem increment_wave_class {s : StripData E} {H : ℕ → E → Mat2} {T R : ℕ → E → Vec2} {β : ℝ} (j : Fin 2) (hζ : ∀ x ∈ s.domain, 0 < s.zeta x) (hcone : ∀ n x, x ∈ s.domain → SmoothCovariance.StrictCone (H n x) (T n x)) (hY : MeanClass s 0 (fun n x => ((H n x)⁻¹.mulVec (T n x)) j)) (hR : MeanClass s β (fun n x => ((H n x)⁻¹.mulVec (R n x)) j)) (hlower : InverseControl s (fun _ x => s.zeta x) (fun n x => ((H n x)⁻¹.mulVec (T n x)) j)) : WaveClass s (fun _ _ => 1) β (fun n x => increment (H n x) (T n x) (R n x) j) := by have hq := signed_quotient_class (fun n x hx => hζ x hx) (fun n x hx => (amplitudes_are_inverse_weights (hcone n x hx) j).1) hY hR hlower have he := memClass_congrOn hq (fun n x hx => (increment_eq_inverse (H n x) (T n x) (R n x) (hcone n x hx) j).symm) simpa only [WaveClass, mul_one] using he end Weighted /-! ## A quantitative bound for the complete assembled signed square -/ /-! ## Smooth edge extension of the actual inverse amplitudes -/ section Edge variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] end Edge end NavierStokes.SignedCovariance