import NavierStokes.PrimaryCopyBounds import NavierStokes.SignedCopyBounds import NavierStokes.PhysicalSignedWave /-! # Controls from the actual shared primary construction The reference matrix, target, unit pulse, normal motion and action below are computed from the same prepared primary family. Their native-copy estimates have constants before all labels, bands and copies. -/ noncomputable section namespace NavierStokes.ActualSignedControl open Set Function Filter PhaseJetBounds PrimaryPulseBounds PrimaryCopyBounds open WeightedClasses PeriodizedWaveBounds open scoped ContDiff Topology InnerProductSpace BigOperators abbrev Mat2 := SmoothCovariance.Mat2 abbrev Vec2 := SmoothCovariance.Vec2 abbrev Space := ProblemStatement.Space variable {ι Λ I D X E : Type} [NormedAddCommGroup D] [NormedSpace ℝ D] [NormedAddCommGroup X] [NormedSpace ℝ X] [NormedAddCommGroup E] [NormedSpace ℝ E] noncomputable def phaseNormal {U : Domain ι PhaseCalculus.Slow} (F : PhaseConstruction U) (χ : ι → D → PhaseCalculus.Slow × ℝ) : ι → D → Space := fun i x => F.phase.normal i (PrimaryCopyBounds.phasePoint F χ i x) /-- A proved reference certificate. The prepared-family constructor below derives its target and mask estimates and all three scalar margins. -/ structure ReferenceBounds (V : JetDomain ι D) (U : Domain ι PhaseCalculus.Slow) (F : Fin 2 → PhaseConstruction U) (pref : Fin 2 → ι → ℝ) (χ : ι → D → PhaseCalculus.Slow × ℝ) (T : ι → D → Vec2) (mask ζ : ι → D → ℝ) where scale : ∀ i, U.scale i = V.scale i coordinate_jets : PolynomialJets V.toDomain χ coordinate_mem : ∀ i x, x ∈ V.carrier i → χ i x ∈ U.carrier i ×ˢ Ioo (0 : ℝ) 1 prefactor_jets : ∀ j, PolynomialJets U (fun i _ => pref j i) target_jets : ∀ q, NativeJets V ζ (fun i x => T i x q) mask_jets : PolynomialJets V.toDomain mask weight_pos : ∀ i x, x ∈ V.carrier i → 0 < ζ i x determinantGap : ℝ entryBound : ℝ primaryLower : ℝ gap_pos : 0 < determinantGap entry_one : 1 ≤ entryBound lower_pos : 0 < primaryLower zero_order : ∀ i x, x ∈ V.carrier i → PrimaryCovarianceBounds.ZeroOrderBounds (Real.sqrt (V.scale i)) determinantGap entryBound primaryLower (ζ i x) (pulseMatrix F pref χ i x) (T i x) namespace ReferenceBounds variable {V : JetDomain ι D} {U : Domain ι PhaseCalculus.Slow} {F : Fin 2 → PhaseConstruction U} {pref : Fin 2 → ι → ℝ} {χ : ι → D → PhaseCalculus.Slow × ℝ} {T : ι → D → Vec2} {mask ζ : ι → D → ℝ} (h : ReferenceBounds V U F pref χ T mask ζ) include h theorem cutoff_jets : PolynomialJets V.toDomain (fun i x => GaussianTailFlat.profile (χ i x).2) := by apply (h.coordinate_jets.clm (ContinuousLinearMap.snd ℝ PhaseCalculus.Slow ℝ)).compact_comp isOpen_univ GaussianTailFlat.profile_contDiff.contDiffOn isCompact_Icc (subset_univ _) intro i x hx exact ⟨(h.coordinate_mem i x hx).2.1.le, (h.coordinate_mem i x hx).2.2.le⟩ end ReferenceBounds /-- Only affine coordinate geometry and weight/scale comparisons are stored here. No copied field or copied derivative bound is an input. -/ structure CopyChart (s : StripData X) (V : JetDomain ι D) (ζ : ι → D → ℝ) (K : Λ → ℕ → I → Set X) where index : Λ → ℕ → ι linear : Λ → ℕ → I → X →L[ℝ] D shift : Λ → ℕ → I → D maps : ∀ l n i x, x ∈ s.domain → x ∈ K l n i → linear l n i x + shift l n i ∈ V.carrier (index l n) growthConstant : ℝ linearConstant : ℝ growth_one : 1 ≤ growthConstant linear_one : 1 ≤ linearConstant growthDegree : ℕ linearDegree : ℕ growth_bound : ∀ l n i x, x ∈ s.domain → x ∈ K l n i → V.growth (index l n) (linear l n i x + shift l n i) ≤ growthConstant * s.growth n x ^ growthDegree linear_bound : ∀ l n i, ‖linear l n i‖ ≤ linearConstant * s.slow n ^ linearDegree weight_eq : ∀ l n i x, x ∈ s.domain → x ∈ K l n i → ζ (index l n) (linear l n i x + shift l n i) = s.zeta x ratioLower : ℝ ratioUpper : ℝ ratio_pos : 0 < ratioLower ratio_one : 1 ≤ ratioUpper scale_ratio : ∀ l n, ratioLower ≤ Real.sqrt (s.slow n) / Real.sqrt (V.scale (index l n)) ∧ Real.sqrt (s.slow n) / Real.sqrt (V.scale (index l n)) ≤ ratioUpper namespace CopyChart variable {s : StripData X} {V : JetDomain ι D} {ζ : ι → D → ℝ} {K : Λ → ℕ → I → Set X} (c : CopyChart s V ζ K) noncomputable def pull (f : ι → D → E) : Λ → ℕ → I → X → E := affineCopy f c.index c.linear c.shift theorem weighted {f : ι → D → E} (hf : NativeJets V ζ f) : UniformLocalJets s (fun _ _ x => s.zeta x) 0 K (c.pull f) := by apply hf.copy_localJets s (fun _ _ x => s.zeta x) 0 c.index c.linear c.shift K (fun _ _ x hx => s.zeta_nonneg x hx) c.maps c.growth_one c.linear_one c.growthDegree c.linearDegree c.growth_bound c.linear_bound intro l n i x hx hi simp only [Real.rpow_zero, one_mul, c.weight_eq l n i x hx hi, le_refl] theorem envelope {w : ι → D → ℝ} {f : ι → D → E} (hf : NativeJets V w f) {W : Λ → ℕ → X → ℝ} (hW : ∀ l n x, x ∈ s.domain → 0 ≤ W l n x) (hw : ∀ l n i x, x ∈ s.domain → x ∈ K l n i → w (c.index l n) (c.linear l n i x + c.shift l n i) ≤ W l n x) : UniformLocalJets s W 0 K (c.pull f) := by apply hf.copy_localJets s W 0 c.index c.linear c.shift K hW c.maps c.growth_one c.linear_one c.growthDegree c.linearDegree c.growth_bound c.linear_bound simpa only [Real.rpow_zero, one_mul] using hw end CopyChart /-! ## The reference certificate is produced from the same actual profile -/ section Prepared variable {F₀ : OutgoingProfile.Profile} {W₀ : NominalProfile.Witness F₀} (H₀ : NominalConeAssembly.Certificate W₀) {ld : ModulatedProfileAssembly.LoopData W₀} (v₀ : ModulatedProfileAssembly.Witness ld) {upper : ℝ} {B : ℕ} {r0 : ℝ} {N0 : ℕ} /-- Primitive local chart geometry for a selected prepared family. The target, matrix, mask and pulse jets are not fields of this record. -/ structure PreparedChart (a : PrimaryGeometryAssembly.Prepared H₀ v₀ upper B r0 N0) (D : Type) [NormedAddCommGroup D] [NormedSpace ℝ D] where native : JetDomain (PrimaryGeometryAssembly.Index W₀ a.N) D slow : JetDomain (PrimaryGeometryAssembly.Index W₀ a.N) PhaseCalculus.Slow coordinate : PrimaryGeometryAssembly.Index W₀ a.N → D → PhaseCalculus.Slow × ℝ scale : ∀ L, (PrimaryGeometryAssembly.domain W₀ a.N).scale L = native.scale L coordinate_jets : PolynomialJets native.toDomain coordinate maps : ∀ L x, x ∈ native.carrier L → coordinate L x ∈ (PrimaryGeometryAssembly.domain W₀ a.N).carrier L ×ˢ Ioo (0 : ℝ) 1 positive : ∀ L x, x ∈ native.carrier L → (coordinate L x).1 ∈ PositiveRepresentatives.positivePart (PrimaryGeometryAssembly.referenceSet W₀) slow_maps : ∀ L x, x ∈ native.carrier L → (coordinate L x).1 ∈ slow.carrier L slow_growth : ∀ L x, x ∈ native.carrier L → slow.growth L (coordinate L x).1 ≤ native.growth L x radiusLower : ℝ normUpper : ℝ qLower : ℝ qUpper : ℝ radius_pos : 0 < radiusLower q_pos : 0 < qLower geometry : BaseChartJets.GeometryBounds slow.toDomain F₀.data.h radiusLower normUpper qLower qUpper (NominalConeAssembly.activeLeft W₀) (NominalConeAssembly.activeRight W₀) inverse_edge : ∀ L p, p ∈ slow.carrier L → (FinalSlowBase.edgeDistance W₀ (BaseChartJets.normalizedCoordinates F₀.data.h p).2)⁻¹ ≤ slow.growth L p namespace PreparedChart variable {H₀ v₀} {a : PrimaryGeometryAssembly.Prepared H₀ v₀ upper B r0 N0} (c : PreparedChart H₀ v₀ a D) noncomputable def target : PrimaryGeometryAssembly.Index W₀ a.N → D → Vec2 := fun L x k => PrimaryTargetBounds.actualTarget v₀ (c.coordinate L x).1 k noncomputable def weight : PrimaryGeometryAssembly.Index W₀ a.N → D → ℝ := fun L x => PrimaryTargetBounds.movingWeight W₀ (c.coordinate L x).1 noncomputable def mask : PrimaryGeometryAssembly.Index W₀ a.N → D → ℝ := fun L x => PrimaryRepresentatives.nativeMask (PrimaryGeometryAssembly.label W₀ L).1 (PrimaryGeometryAssembly.label W₀ L).2 (c.coordinate L x).1 theorem target_jets (hcone : LeadingStressWeights.FullTrueCone v₀) (k : Fin 2) : NativeJets c.native c.weight (fun L x => c.target L x k) := by have ht := (PrimaryCopyBounds.actualTarget_jets v₀ hcone c.slow c.radius_pos c.q_pos c.geometry c.inverse_edge).comp (c.coordinate_jets.clm (ContinuousLinearMap.fst ℝ PhaseCalculus.Slow ℝ)) c.slow_maps c.slow_growth exact ht.map (PiLp.proj 2 (fun _ : Fin 2 => ℝ) k) theorem mask_jets : PolynomialJets c.native.toDomain c.mask := by apply nativeMask_comp_jets c.native.toDomain (fun L x => (c.coordinate L x).1) (c.coordinate_jets.clm (ContinuousLinearMap.fst ℝ PhaseCalculus.Slow ℝ)) (fun L => (PrimaryGeometryAssembly.label W₀ L).1) (fun L => (PrimaryGeometryAssembly.label W₀ L).2) (fun L => L.val.property.1) intro L rw [← c.scale L] rfl theorem weight_pos (L : PrimaryGeometryAssembly.Index W₀ a.N) {x : D} (hx : x ∈ c.native.carrier L) : 0 < c.weight L x := by have hs := c.slow_maps L x hx rw [weight, PrimaryTargetBounds.movingWeight_eq W₀ (c.geometry.time L _ hs) (c.radius_pos.trans_le (c.geometry.radius L _ hs))] apply ActiveAnnulusWeight.radialWeight_pos simp only [FinalSlowBase.logLeft, FinalSlowBase.logRight, Real.exp_log (NominalConeAssembly.activeLeft_pos W₀), Real.exp_log (FinalSlowBase.terminal_pos W₀)] exact c.geometry.x_range L _ hs /-- Every jet field in this reference certificate is derived from the actual prepared phase, actual leading target and actual grid mask. -/ noncomputable def referenceBounds (hcone : LeadingStressWeights.FullTrueCone v₀) (hr0 : 0 < r0) (vr vt : TorusInverse.Plane) (dg eb il : ℝ) (hdg : 0 < dg) (heb : 1 ≤ eb) (hil : 0 < il) (hz : ∀ (L : PrimaryGeometryAssembly.Index W₀ a.N) (p : PhaseCalculus.Slow), p ∈ PositiveRepresentatives.positivePart (PrimaryGeometryAssembly.referenceSet W₀) → p ∈ (PrimaryGeometryAssembly.domain W₀ a.N).carrier L → PrimaryCovarianceBounds.ZeroOrderBounds (Real.sqrt (ChartScales.S (BaseChartJets.cellBand L))) dg eb il (PrimaryTargetBounds.movingWeight W₀ p) (PrimaryTargetBounds.preparedCovariance H₀ v₀ a vr vt L p) (fun k => PrimaryTargetBounds.actualTarget v₀ p k)) : ReferenceBounds c.native (PrimaryGeometryAssembly.domain W₀ a.N) (PrimaryGeometryAssembly.construction H₀ v₀ a hr0) (preparedPrefactor r0 vr vt) c.coordinate c.target c.mask c.weight where scale := c.scale coordinate_jets := c.coordinate_jets coordinate_mem := c.maps prefactor_jets := fun j => preparedPrefactor_jets r0 vr vt a.N j target_jets := c.target_jets hcone mask_jets := c.mask_jets weight_pos := fun L _ hx => c.weight_pos L hx determinantGap := dg entryBound := eb primaryLower := il gap_pos := hdg entry_one := heb lower_pos := hil zero_order := by intro L x hx have h := hz L (c.coordinate L x).1 (c.positive L x hx) (c.maps L x hx).1 have hscale : c.native.scale L = ChartScales.S (BaseChartJets.cellBand L) := (c.scale L).symm simp only [hscale, pulseMatrix, weight] at h ⊢ exact h end PreparedChart end Prepared /-! ## Transport through the actual affine views -/ /-- Positive band scalars with uniform primitive zeroth-order margins. -/ structure PositiveScale (Λ : Type) where value : Λ → ℕ → ℝ lower : ℝ upper : ℝ lower_pos : 0 < lower upper_one : 1 ≤ upper bounds : ∀ l n, lower ≤ value l n ∧ value l n ≤ upper namespace PositiveScale variable (a b : PositiveScale Λ) theorem value_pos (l : Λ) (n : ℕ) : 0 < a.value l n := a.lower_pos.trans_le (a.bounds l n).1 noncomputable def mul : PositiveScale Λ where value l n := a.value l n * b.value l n lower := a.lower * b.lower upper := a.upper * b.upper lower_pos := mul_pos a.lower_pos b.lower_pos upper_one := one_le_mul_of_one_le_of_one_le a.upper_one b.upper_one bounds l n := ⟨mul_le_mul (a.bounds l n).1 (b.bounds l n).1 b.lower_pos.le (a.value_pos l n).le, mul_le_mul (a.bounds l n).2 (b.bounds l n).2 (b.value_pos l n).le (zero_le_one.trans a.upper_one)⟩ end PositiveScale theorem uniform_local_congr {s : StripData X} {K : Λ → ℕ → I → Set X} {w : Λ → ℕ → X → ℝ} {α : ℝ} {f g : Λ → ℕ → I → X → E} (hf : UniformLocalJets s w α K f) (he : ∀ l n i x, x ∈ s.domain → x ∈ K l n i → f l n i =ᶠ[𝓝 x] g l n i) : UniformLocalJets s w α K g := by refine ⟨fun l n i x hx hi => (hf.smooth l n i x hx hi).congr_of_eventuallyEq (he l n i x hx hi).symm, ?_⟩ intro m obtain ⟨C, hC, p, hb⟩ := hf.bounds m refine ⟨C, hC, p, ?_⟩ intro l n i x hx hi j hj rw [← PeriodizedWaveBounds.jets_eq_of_germ (he l n i x hx hi) j] exact hb l n i x hx hi j hj /-- Changing the band's normalization and scaling the actual target preserves quantitative Cramer margins with explicit constants. -/ theorem rescale_margins {r R dg eb il ζ c clo rlo rhi : ℝ} {H : Mat2} {T : Vec2} (h : PrimaryCovarianceBounds.ZeroOrderBounds r dg eb il ζ H T) (hr : 1 ≤ r) (hdg : 0 ≤ dg) (hil : 0 ≤ il) (hζ : 0 ≤ ζ) (hclo : 0 < clo) (hc : clo ≤ c) (hrlo : 0 < rlo) (hlo : rlo ≤ R / r) (hhi : R / r ≤ rhi) : rlo ^ 2 * dg ≤ |(normalizedMatrix R H).det| ∧ (∀ i j, |R * H i j| ≤ rhi * eb) ∧ (∀ j, (clo ^ 2 * il) * ζ ≤ SmoothCovariance.weights H (c ^ 2 • T) j) := by have hrp : 0 < r := zero_lt_one.trans_le hr have hratio : 0 < R / r := hrlo.trans_le hlo have he : normalizedMatrix R H = normalizedMatrix (R / r) (normalizedMatrix r H) := by ext i j simp only [normalizedMatrix] field_simp have hdet : |(normalizedMatrix R H).det| = (R / r) ^ 2 * |(normalizedMatrix r H).det| := by rw [he, normalizedMatrix_det, abs_mul, abs_of_nonneg (sq_nonneg _)] refine ⟨?_, ?_, ?_⟩ · rw [hdet] exact mul_le_mul (pow_le_pow_left₀ hrlo.le hlo 2) h.determinant hdg (sq_nonneg _) · intro i j have hentry : R * H i j = (R / r) * (r * H i j) := by field_simp rw [hentry, abs_mul, abs_of_pos hratio] exact mul_le_mul hhi (h.entries i j) (abs_nonneg _) (by linarith [hratio, hhi]) · intro j rw [PhysicalSignedWave.weights_smul_target, Pi.smul_apply, smul_eq_mul] have hbase : il * ζ ≤ SmoothCovariance.weights H T j := by apply le_trans _ (h.weights j) nlinarith [mul_nonneg hil hζ] have hh := mul_le_mul (pow_le_pow_left₀ hclo.le hc 2) hbase (mul_nonneg hil hζ) (sq_nonneg c) simpa only [mul_assoc] using hh namespace ReferenceBounds variable [Countable Λ] [Nonempty Λ] {V : JetDomain ι D} {U : Domain ι PhaseCalculus.Slow} {F : Fin 2 → PhaseConstruction U} {pref : Fin 2 → ι → ℝ} {χ : ι → D → PhaseCalculus.Slow × ℝ} {T : ι → D → Vec2} {mask ζ : ι → D → ℝ} (h : ReferenceBounds V U F pref χ T mask ζ) {s : StripData X} {K : Λ → ℕ → I → Set X} (c : CopyChart s V ζ K) (scale : PositiveScale Λ) include h end ReferenceBounds namespace ReferenceBounds variable [Countable Λ] [Nonempty Λ] {V : JetDomain ι D} {U : Domain ι PhaseCalculus.Slow} {F : Fin 2 → PhaseConstruction U} {pref : Fin 2 → ι → ℝ} {χ : ι → D → PhaseCalculus.Slow × ℝ} {T : ι → D → Vec2} {mask ζ : ι → D → ℝ} (h : ReferenceBounds V U F pref χ T mask ζ) {s : StripData X} {K : Λ → ℕ → I → Set X} (c : CopyChart s V ζ K) (scale normal clock : PositiveScale Λ) include h end ReferenceBounds /-! ## The signed request is the measured current-state request -/ theorem uniformLocalJets_of_memClass {s : StripData X} {w : ℕ → X → ℝ} {α : ℝ} {f : ℕ → X → E} (hf : MemClass s w α f) (K : Λ → ℕ → I → Set X) : UniformLocalJets s (fun _ => w) α K (fun _ n _ => f n) := by refine ⟨fun _ n _ x hx _ => (hf.smooth n).contDiffAt (s.isOpen_domain.mem_nhds hx), ?_⟩ intro m obtain ⟨C, hC, p, hb⟩ := hf.bounds m exact ⟨C, hC, p, fun _ n _ x hx _ j hj => hb n x hx j hj⟩ theorem fullRequest_localJets (s : StripData LocalSignedRequest.Point) (P : SignedStressPrimitive.Patch) (coord : ℝ) (ctx : CorrectionState.Context LocalSignedRequest.Point) (u : CorrectionState.State LocalSignedRequest.Point) {β : ℝ} (h : ∀ q, MeanClass s β (fun n x => LocalSignedRequest.normalizedRequest s P coord ctx u n x q)) (K : Λ → ℕ → I → Set (LocalSignedRequest.Point × ℝ)) : ∀ q, UniformLocalJets (HarmonicWaveInteraction.productStrip s) (fun _ _ x => s.zeta x.1) β K (fun _ n _ x => LocalSignedRequest.fullRequest s P coord ctx u n x q) := fun q => uniformLocalJets_of_memClass (LocalSignedRequest.fullRequest_class s P coord ctx u h q) K /-- The actual residuals, their support, and their incoming mean classes give the complete copy-uniform request estimate. No request jet is assumed. -/ theorem physical_fullRequest_localJets {coord : ℝ} (U : LocalSignedRequest.SlowRegion coord) (P : SignedStressPrimitive.Patch) {cL cR : ℝ} (hcL : 0 < cL) (hcR : 0 < cR) (ε L : ℕ → ℝ) (hε : ∀ n, 0 < ε n) (hεone : ∀ n, ε n ≤ 1) (hL : ∀ n, 1 ≤ L n) (ctx : CorrectionState.Context LocalSignedRequest.Point) (u : CorrectionState.State LocalSignedRequest.Point) (α : ℝ) (hθ : ∀ n, ContDiffOn ℝ ∞ (u.thetaResidual ctx n) (PhysicalMeanDomain.slowDomain U.carrier)) (hz : ∀ n, ContDiffOn ℝ ∞ (u.axialResidual ctx n) (PhysicalMeanDomain.slowDomain U.carrier)) (hsθ : ∀ n, LocalSignedRequest.MovingSupport P.a P.b coord U.carrier (u.thetaResidual ctx n)) (hsz : ∀ n, LocalSignedRequest.MovingSupport P.a P.b coord U.carrier (u.axialResidual ctx n)) (hcθ : MeanClass (LocalSignedRequest.movingStripData U P.a P.b cL cR P.a_pos hcL hcR ε L hε hεone hL) α (u.thetaResidual ctx)) (hcz : MeanClass (LocalSignedRequest.movingStripData U P.a P.b cL cR P.a_pos hcL hcR ε L hε hεone hL) α (u.axialResidual ctx)) (K : Λ → ℕ → I → Set (LocalSignedRequest.Point × ℝ)) : let s := LocalSignedRequest.movingStripData U P.a P.b cL cR P.a_pos hcL hcR ε L hε hεone hL ∀ q, UniformLocalJets (HarmonicWaveInteraction.productStrip s) (fun _ _ x => s.zeta x.1) (α - 1) K (fun _ n _ x => LocalSignedRequest.fullRequest s P coord ctx u n x q) := by dsimp only exact fullRequest_localJets _ P coord ctx u (LocalSignedRequest.normalizedRequest_class U P hcL hcR ε L hε hεone hL ctx u α hθ hz hsθ hsz hcθ hcz) K /-! ## One selected reference family supplies the complete signed input -/ section Combined variable [Countable Λ] [Nonempty Λ] {F₀ : OutgoingProfile.Profile} {W₀ : NominalProfile.Witness F₀} {H₀ : NominalConeAssembly.Certificate W₀} {ld : ModulatedProfileAssembly.LoopData W₀} {v₀ : ModulatedProfileAssembly.Witness ld} {upper : ℝ} {B : ℕ} {r0 : ℝ} {N0 : ℕ} namespace PreparedChart variable {a : PrimaryGeometryAssembly.Prepared H₀ v₀ upper B r0 N0} (C : PreparedChart H₀ v₀ a D) (hr0 : 0 < r0) (vr vt : TorusInverse.Plane) {s : StripData X} {K : Λ → ℕ → I → Set X} (copy : CopyChart s C.native C.weight K) end PreparedChart end Combined end NavierStokes.ActualSignedControl