nlinarith only [hplus.1,hplus.2,hminus.1,hminus.2]
+ have habs : |A*B*H a b|≤C*P a a*P b b := abs_le.mpr hbounds
+ have hright : 0≤C*P a a*P b b := mul_nonneg (mul_nonneg hC (hpos a)) (hpos b)
+ have hsq := (sq_le_sq₀ (abs_nonneg _) hright).mpr habs
+ rw [sq_abs] at hsq
+ have heq₁ : (A*B*H a b)^2=(P a a*P b b)*(H a b)^2 := by
+ rw [mul_pow,mul_pow,hA,hB]
+ ring
+ have heq₂ : (C*P a a*P b b)^2=(P a a*P b b)*(C^2*P a a*P b b) := by ring
+ rw [heq₁,heq₂] at hsq
+ exact (mul_le_mul_iff_right₀ (mul_pos ha0 hb0)).mp hsq
+
+/-- The square form of the diagonal estimate gives the same sharp mixed
+estimate, with no division by the density or by a Gram eigenvalue. -/
+theorem bilinear_mixed_sq_bound_of_diagonal
+ (P H : Euclidean m →ₗ[ℝ] Euclidean m →ₗ[ℝ] ℝ)
+ (hP : ∀ a b, P a b=P b a) (hpos : ∀ a, 0≤P a a)
+ (hH : ∀ a b, H a b=H b a) (B : ℝ) (hB : 0≤B)
+ (hdiag : ∀ a, (H a a)^2≤B*(P a a)^2) (a b : Euclidean m) :
+ (H a b)^2≤B*P a a*P b b := by
+ have hroot : (Real.sqrt B)^2=B := Real.sq_sqrt hB
+ have hbound (x : Euclidean m) : |H x x|≤Real.sqrt B*P x x := by
+ apply (sq_le_sq₀ (abs_nonneg _) (mul_nonneg (Real.sqrt_nonneg B) (hpos x))).mp
+ rw [sq_abs,mul_pow,hroot]
+ exact hdiag x
+ simpa only [hroot] using bilinear_mixed_bound_of_diagonal P H hP hpos hH
+ (Real.sqrt B) (Real.sqrt_nonneg B) hbound a b
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/BilinearHeatEnvelope.lean b/lean/OAI/Geometry/RCD/Coordinates/BilinearHeatEnvelope.lean
new file mode 100644
index 0000000000000000000000000000000000000000..7a2147382b37f4a53db6b087c1bf8bf5f9717d18
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/BilinearHeatEnvelope.lean
@@ -0,0 +1,86 @@
+import OAI.Geometry.RCD.Heat.SlowHeatGrowth
+import OAI.Geometry.RCD.Coordinates.SymmetricDomination
+
+namespace OAI
+
+/-! # From a scalar source envelope to the bilinear heat comparison -/
+
+open scoped BigOperators InnerProductSpace
+
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem geometric_causal_sum_succ (f : ℕ → ℝ) (β : ℝ) (i : ℕ) :
+ (∑ j ∈ Finset.range (i + 1 + 1), β ^ (i + 1 - j) * f j) =
+ β * (∑ j ∈ Finset.range (i + 1), β ^ (i - j) * f j) + f (i + 1) := by
+ rw [Finset.sum_range_succ, Nat.sub_self, pow_zero, one_mul, Finset.mul_sum]
+ congr 1
+ apply Finset.sum_congr rfl
+ intro j hj
+ have hji : j ≤ i := by simpa only [Finset.mem_range, Nat.lt_succ_iff] using hj
+ rw [show i + 1 - j = (i - j) + 1 by omega, pow_succ]
+ ring
+
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+
+/-- The actual geometric source envelope is bounded by the current heat
+metric under slow growth and small mass. Its finite background is explicit. -/
+theorem heat_envelope_le_current (Q N F : ℕ → E →L[ℝ] E)
+ (hQ : ∀ i, (Q i).IsPositive) {b T ε : ℝ} (hb : 0 ≤ b) (hT : 0 ≤ T) (hε : 0 ≤ ε)
+ (hstep : ∀ i v, ⟪v, Q i v⟫_ℝ ≤ (9 / 8 : ℝ) * ⟪v, Q (i + 1) v⟫_ℝ)
+ (hbase : ∀ v, ‖v‖ ^ 2 ≤ T * ⟪v, Q 0 v⟫_ℝ)
+ (hsmall : ∀ i v, ⟪v, N i v⟫_ℝ ≤ ε * ⟪v, Q i v⟫_ℝ)
+ (henv : ∀ i v, ⟪v, F i v⟫_ℝ ≤ b * (3 / 4 : ℝ) ^ i * ‖v‖ ^ 2 +
+ ∑ j ∈ Finset.range (i + 1), (3 / 4 : ℝ) ^ (i - j) * ⟪v, N j v⟫_ℝ)
+ (i : ℕ) (v : E) :
+ ⟪v, F i v⟫_ℝ ≤ (b * T + 8 * ε) * ⟪v, Q i v⟫_ℝ := by
+ have hmass : ∀ i, (∑ j ∈ Finset.range (i + 1),
+ (3 / 4 : ℝ) ^ (i - j) * ⟪v, N j v⟫_ℝ) ≤ 8 * ε * ⟪v, Q i v⟫_ℝ := by
+ intro k
+ induction k with
+ | zero =>
+ simp only [Nat.zero_add, Finset.sum_range_one, Nat.sub_self, pow_zero, one_mul]
+ have hn := hsmall 0 v
+ have hp := (hQ 0).inner_nonneg_right v
+ nlinarith only [hn, mul_nonneg hε hp]
+ | succ k ih =>
+ rw [geometric_causal_sum_succ]
+ have hm := mul_le_mul_of_nonneg_left ih (by norm_num : (0 : ℝ) ≤ 3 / 4)
+ have ht := mul_le_mul_of_nonneg_left (hstep k v) (by positivity : 0 ≤ (3 / 4 : ℝ) * (8 * ε))
+ have hn := hsmall (k + 1) v
+ have hp := (hQ (k + 1)).inner_nonneg_right v
+ nlinarith only [hm, ht, hn, mul_nonneg hε hp]
+ have hg := geometric_form_growth Q (by norm_num : (0 : ℝ) ≤ 9 / 8) hstep (Nat.zero_le i) v
+ simp only [Nat.sub_zero] at hg
+ have hinit := mul_le_mul_of_nonneg_left ((hbase v).trans (mul_le_mul_of_nonneg_left hg hT))
+ (by positivity : 0 ≤ b * (3 / 4 : ℝ) ^ i)
+ have hpow : (3 / 4 : ℝ) ^ i * (9 / 8 : ℝ) ^ i ≤ 1 := by
+ rw [← mul_pow]
+ exact pow_le_one₀ (by norm_num) (by norm_num)
+ have hpow' := mul_le_mul_of_nonneg_left hpow
+ (mul_nonneg (mul_nonneg hb hT) ((hQ i).inner_nonneg_right v))
+ have hinitial : b * (3 / 4 : ℝ) ^ i * ‖v‖ ^ 2 ≤ b * T * ⟪v, Q i v⟫_ℝ := by
+ nlinarith only [hinit, hpow']
+ nlinarith only [henv i v, hmass i, hinitial]
+
+/-- Once the signed scalar source estimate is proved, polarization gives
+exactly the asymmetric bilinear estimate required by the coordinate argument. -/
+theorem bilinear_heat_comparison_of_envelope (Q F D : E →L[ℝ] E)
+ (hF : F.IsPositive) (hD : D.IsSymmetric) {C B : ℝ}
+ (hsource : ∀ v, |⟪v, D v⟫_ℝ| ≤ C * ⟪v, F v⟫_ℝ)
+ (hcurrent : ∀ v, ⟪v, F v⟫_ℝ ≤ B * ⟪v, Q v⟫_ℝ) (v w : E) :
+ ⟪v, D w⟫_ℝ ^ 2 ≤ (C ^ 2 * B) * ⟪v, Q v⟫_ℝ * ⟪w, F w⟫_ℝ := by
+ have hd : ∀ u, |⟪u, D u⟫_ℝ| ≤ ⟪u, (C • F) u⟫_ℝ := by
+ intro u
+ simpa only [smul_apply, inner_smul_right] using hsource u
+ have h := symmetric_domination_cauchy_schwarz D (C • F) hD hd v w
+ simp only [smul_apply, inner_smul_right] at h
+ have hs := mul_le_mul_of_nonneg_right (hcurrent v)
+ (mul_nonneg (sq_nonneg C) (hF.inner_nonneg_right w))
+ nlinarith only [h, hs]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/BilinearIntervalAverage.lean b/lean/OAI/Geometry/RCD/Coordinates/BilinearIntervalAverage.lean
new file mode 100644
index 0000000000000000000000000000000000000000..246de4c1edb4bdda669557bbc92b060cae0c5173
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/BilinearIntervalAverage.lean
@@ -0,0 +1,59 @@
+import OAI.Geometry.RCD.Coordinates.IntervalBilinearEnergy
+import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap
+
+namespace OAI
+
+/-! # Weighted quadratic energy of an actual time average
+
+Positivity of the bilinear form gives Jensen's inequality directly on the
+finite interval used to smooth the Sobolev time family.
+-/
+
+open Set Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem positive_bilinear_interval_average
+ {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+ (P : E →L[ℝ] E →L[ℝ] ℝ) (hpos : ∀ x, 0 ≤ P x x)
+ (hsymm : ∀ x y, P x y = P y x)
+ {a b : ℝ} (hab : a < b) (u : ℝ → E) (hu : IntegrableOn u (Icc a b))
+ (hE : IntegrableOn (fun t => P (u t) (u t)) (Icc a b)) :
+ let m := (b-a)⁻¹ • ∫ t in Icc a b, u t
+ P m m ≤ (b-a)⁻¹ * ∫ t in Icc a b, P (u t) (u t) := by
+ intro m
+ have hmass : volume.real (Icc a b) = b-a := by
+ rw [Real.volume_real_Icc_of_le hab.le]
+ have hmean : (b-a) • m = ∫ t in Icc a b, u t := by
+ dsimp only [m]
+ rw [smul_smul,mul_inv_cancel₀ (sub_pos.mpr hab).ne',one_smul]
+ have hpair : (∫ t in Icc a b, P m (u t)) = (b-a)*P m m := by
+ rw [(P m).integral_comp_comm hu,← hmean,map_smul,smul_eq_mul]
+ have hconst : (∫ _ in Icc a b, P m m) = (b-a)*P m m := by
+ rw [setIntegral_const,hmass,smul_eq_mul]
+ have hmix : IntegrableOn (fun t => P m (u t)) (Icc a b) :=
+ (P m).integrable_comp hu
+ have hle : (∫ t in Icc a b, 2*P m (u t)-P m m) ≤
+ ∫ t in Icc a b, P (u t) (u t) := by
+ apply integral_mono_ae ((hmix.const_mul 2).sub (integrableOn_const
+ (isCompact_Icc.measure_lt_top.ne))) hE
+ exact Eventually.of_forall fun t => by
+ change 2*P m (u t)-P m m ≤ P (u t) (u t)
+ have hh := hpos (u t-m)
+ simp only [map_sub,sub_apply] at hh
+ rw [hsymm (u t) m] at hh
+ linarith
+ have he : (∫ t in Icc a b, 2*P m (u t)-P m m) = (b-a)*P m m := by
+ rw [integral_sub (hmix.const_mul 2) (integrableOn_const (isCompact_Icc.measure_lt_top.ne)),
+ integral_const_mul,hpair,hconst]
+ ring
+ rw [he] at hle
+ have hh := mul_le_mul_of_nonneg_left hle (inv_nonneg.mpr (sub_pos.mpr hab).le)
+ simpa only [← mul_assoc,inv_mul_cancel₀ (sub_pos.mpr hab).ne',one_mul] using hh
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/BochnerFrameCompletion.lean b/lean/OAI/Geometry/RCD/Coordinates/BochnerFrameCompletion.lean
new file mode 100644
index 0000000000000000000000000000000000000000..e125b4b5c67277c3d5e835b07318b672ef363964
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/BochnerFrameCompletion.lean
@@ -0,0 +1,86 @@
+import OAI.Geometry.RCD.Sobolev.BochnerSquareSaturation
+import OAI.Geometry.RCD.Sobolev.FiniteDimensionalBochnerAE
+
+namespace OAI
+
+/-! # Exact frame completion from the scalar dimensional Bochner inequality -/
+
+open Finset Set Filter MeasureTheory TopologicalSpace
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem ae_finite_bochner_bound {X : Type*} [MeasurableSpace X] {m : ℕ}
+ (μ : Measure X) (B : X → Euclidean m →ₗ[ℝ] Euclidean m →ₗ[ℝ] ℝ)
+ (D : X → Euclidean m →ₗ[ℝ] ℝ) (N : ℝ)
+ (h : ∀ a, ∀ᵐ x ∂μ, (D x a)^2≤N*B x a a) :
+ ∀ᵐ x ∂μ, ∀ a, (D x a)^2≤N*B x a a := by
+ obtain ⟨S,hS,hdense⟩ := exists_countable_dense (Euclidean m)
+ let : Countable S := hS.to_subtype
+ filter_upwards [MeasureTheory.ae_all_iff.mpr (fun a : S => h a)] with x hx
+ have hc : IsClosed {a : Euclidean m | (D x a)^2≤N*B x a a} :=
+ isClosed_le ((D x).toContinuousLinearMap.continuous.pow 2)
+ (continuous_const.mul (bilinear_diagonal_continuous (B x)))
+ have hall := closure_minimal (fun a ha => hx ⟨a,ha⟩) hc
+ rw [hdense.closure_eq] at hall
+ exact fun a => hall (Set.mem_univ a)
+
+theorem dimensional_cross_equality {N r s : ℝ} (hN : 0 by rw [Real.norm_eq_abs, abs_of_nonneg (kernelAverage_bounds μ hQ hk ht A z).1]
+ exact (kernelAverage_bounds μ hQ hk ht A z).2)
+
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]
+ {U : E →L[ℝ] SobolevSpace μ hQ} {M : PositiveBilinearMeasure X E}
+ {κ : ℝ} {p : X} {r : ℝ} {L : ℝ≥0} {v : E}
+
+/-- Exact mass, curvature and cutoff-density decomposition of the actual
+averaged signed source. No absolute-continuity replacement of M is made. -/
+theorem LocalHarmonicEnergy.average_cutoffSource
+ (G : LocalHarmonicEnergy μ hQ U M κ p r L v)
+ (χ : X →ᵇ ℝ) (hcompact : HasCompactSupport (χ : X → ℝ))
+ (c : SobolevSpace μ hQ) (q : Lp ℝ 2 μ) {t : ℝ} (ht : 0 < t)
+ (A : Set X) (hA : MeasurableSet A) (hbounded : Bornology.IsBounded A) :
+ (∫ᵛ z, kernelAverage μ ker t A z ∂<•(G.cutoffSource μ hQ χ c q)) =
+ 2 * ⟪v, cutoffAverageHeatMass μ hQ hk χ.continuous hcompact M ht A hA hbounded v⟫_ℝ -
+ 2 * κ * (∫ z, χ z * kernelAverage μ ker t A z * localGamma μ hQ (U v) (U v) z ∂μ) +
+ ∫ z, kernelAverage μ ker t A z * cutoffSourceDensity μ hQ G.energy c q z ∂μ := by
+ let w := boundedKernelAverage μ hQ hk ht A hA hbounded
+ have hM : M.weightedOperator (w * χ) =
+ cutoffAverageHeatMass μ hQ hk χ.continuous hcompact M ht A hA hbounded := by
+ unfold cutoffAverageHeatMass
+ congr 1
+ ext z
+ change kernelAverage μ ker t A z * χ z = χ z * kernelAverage μ ker t A z
+ ring
+ have hG : (∫ z, (w * χ) z * localGamma μ hQ (U v) (U v) z ∂μ) =
+ ∫ z, χ z * kernelAverage μ ker t A z * localGamma μ hQ (U v) (U v) z ∂μ := by
+ apply integral_congr_ae
+ exact Filter.Eventually.of_forall fun z => by
+ change (kernelAverage μ ker t A z * χ z) * _ = _
+ ring
+ have he := G.integral_cutoffSource μ hQ χ w c q
+ rw [hM, hG] at he
+ exact he
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AverageQuadraticError.lean b/lean/OAI/Geometry/RCD/Harmonic/AverageQuadraticError.lean
new file mode 100644
index 0000000000000000000000000000000000000000..162bd6ff19aa277b81b948060cddc82018159ec4
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AverageQuadraticError.lean
@@ -0,0 +1,62 @@
+import OAI.Analysis.RCDHeat.ExistingAnalytic
+
+namespace OAI
+
+/-! # Passing an additive transport error from averages to continuous values -/
+
+open Set Filter MeasureTheory Metric
+open scoped Topology NNReal
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [SecondCountableTopology X] {μ : Measure X} [IsLocallyFiniteMeasure μ]
+ [IsUnifLocDoublingMeasure μ] [μ.IsOpenPosMeasure]
+
+theorem quadratic_comparison_of_average_bound_add
+ (u v U V : X → ℝ) (hu : LocallyIntegrable u μ) (hv : LocallyIntegrable v μ)
+ (hU : Continuous U) (hV : Continuous V) (heU : u =ᵐ[μ] U) (heV : v =ᵐ[μ] V)
+ (c e : ℝ) (h : ∀ x y : X, ∀ r : ℝ, 0 < r →
+ (⨍z in closedBall x r, u z ∂μ) - (⨍z in closedBall y r, v z ∂μ) ≤
+ c*(dist x y + 2*r)^2+e) :
+ ∀ x y, U x-V y ≤ c*dist x y^2+e := by
+ let S := {x : X | Tendsto (fun r : ℝ => ⨍z in closedBall x r, u z ∂μ)
+ (𝓝[>] 0) (𝓝 (U x))}
+ let T := {x : X | Tendsto (fun r : ℝ => ⨍z in closedBall x r, v z ∂μ)
+ (𝓝[>] 0) (𝓝 (V x))}
+ have hS : ∀ᵐ x ∂μ, x ∈ S := by
+ filter_upwards [IsUnifLocDoublingMeasure.ae_tendsto_average μ hu (1:ℝ),heU] with x hx he
+ change Tendsto _ _ (𝓝 (U x))
+ rw [←he]
+ exact hx (fun _ : ℝ => x) id tendsto_id (by
+ filter_upwards [self_mem_nhdsWithin] with r hr
+ simp only [mem_closedBall,dist_self,one_mul]
+ exact le_of_lt hr)
+ have hT : ∀ᵐ x ∂μ, x ∈ T := by
+ filter_upwards [IsUnifLocDoublingMeasure.ae_tendsto_average μ hv (1:ℝ),heV] with x hx he
+ change Tendsto _ _ (𝓝 (V x))
+ rw [←he]
+ exact hx (fun _ : ℝ => x) id tendsto_id (by
+ filter_upwards [self_mem_nhdsWithin] with r hr
+ simp only [mem_closedBall,dist_self,one_mul]
+ exact le_of_lt hr)
+ have hST : ∀ x ∈ S, ∀ y ∈ T, U x-V y ≤ c*dist x y^2+e := by
+ intro x hx y hy
+ have hc : Tendsto (fun r : ℝ => c*(dist x y+2*r)^2+e) (𝓝[>] 0)
+ (𝓝 (c*dist x y^2+e)) := by
+ have hh : Continuous (fun r : ℝ => c*(dist x y+2*r)^2+e) := by fun_prop
+ simpa using (hh.continuousAt (x := 0)).tendsto.mono_left nhdsWithin_le_nhds
+ have hb : ∀ᶠ r in 𝓝[>] (0:ℝ),
+ (⨍z in closedBall x r, u z ∂μ) - (⨍z in closedBall y r, v z ∂μ) ≤
+ c*(dist x y+2*r)^2+e := by
+ filter_upwards [self_mem_nhdsWithin] with r hr using h x y r hr
+ exact le_of_tendsto_of_tendsto (hx.sub hy) hc hb
+ have hd : Dense (S ×ˢ T) := (Measure.dense_of_ae hS).prod (Measure.dense_of_ae hT)
+ have hc : IsClosed {z : X×X | U z.1-V z.2 ≤ c*dist z.1 z.2^2+e} :=
+ isClosed_le ((hU.comp continuous_fst).sub (hV.comp continuous_snd)) (by fun_prop)
+ have hs : closure (S ×ˢ T) ⊆ {z : X×X | U z.1-V z.2 ≤ c*dist z.1 z.2^2+e} :=
+ hc.closure_subset_iff.mpr (fun z hz => hST z.1 hz.1 z.2 hz.2)
+ intro x y
+ exact hs (hd (x,y))
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AveragedEndpointPairing.lean b/lean/OAI/Geometry/RCD/Harmonic/AveragedEndpointPairing.lean
new file mode 100644
index 0000000000000000000000000000000000000000..595f167a6fd4e1339f2a8b9a6dc781db37e86bbd
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AveragedEndpointPairing.lean
@@ -0,0 +1,51 @@
+import OAI.Geometry.RCD.Sobolev.CompactLaplacian
+
+namespace OAI
+
+/-! # Pairing the exact derivative of the averaged potential
+
+On the inner ball the cutoff is one, so its L2 derivative has precisely
+the normalized endpoint pairing appearing in the energy estimate.
+-/
+
+open Set Filter MeasureTheory Metric
+open scoped NNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) [IsFiniteMeasureOnCompacts μ]
+
+theorem averaged_endpoint_pairing (z : X) {r h : ℝ} (hr : 0 < r) (hh : 0 < h)
+ (F G : X → ℝ) (hF : ContinuousOn F (closedBall z r)) (hG : ContinuousOn G (closedBall z r))
+ (D : Lp ℝ 2 μ)
+ (hD : D =ᵐ[μ] fun x => radialCutoff z r x*((G x-F x)/(2*h)))
+ (φ : X → ℝ) {L : ℝ≥0} (hφ : LipschitzWith L φ) (hs : tsupport φ ⊆ ball z r) :
+ h⁻¹*((∫ x in closedBall z r, φ x*G x ∂μ)-(∫ x in closedBall z r, φ x*F x ∂μ)) =
+ 2*(∫ x, φ x*D x ∂μ) := by
+ have hzero (x : X) (hx : x ∉ closedBall z r) : φ x = 0 :=
+ image_eq_zero_of_notMem_tsupport (fun hp => hx (ball_subset_closedBall (hs hp)))
+ have hiF : IntegrableOn (fun x => φ x*F x) (closedBall z r) μ :=
+ (hφ.continuous.continuousOn.mul hF).integrableOn_compact (isCompact_closedBall z r)
+ have hiG : IntegrableOn (fun x => φ x*G x) (closedBall z r) μ :=
+ (hφ.continuous.continuousOn.mul hG).integrableOn_compact (isCompact_closedBall z r)
+ have he : (∫ x, φ x*D x ∂μ) = ∫ x in closedBall z r, φ x*D x ∂μ :=
+ (setIntegral_eq_integral_of_ae_compl_eq_zero
+ (Eventually.of_forall fun x hx => by rw [hzero x hx,zero_mul])).symm
+ rw [he,← integral_const_mul]
+ calc
+ _ = ∫ x in closedBall z r, h⁻¹*(φ x*G x-φ x*F x) ∂μ := by
+ rw [← integral_sub hiG hiF,← integral_const_mul]
+ _ = ∫ x in closedBall z r, 2*(φ x*D x) ∂μ := by
+ apply integral_congr_ae
+ filter_upwards [ae_restrict_of_ae hD] with x hx
+ by_cases hφx : φ x = 0
+ · simp only [hφx,zero_mul,sub_self,mul_zero]
+ · have hxin := hs (subset_tsupport φ hφx)
+ rw [hx,radialCutoff_eq_one z hr (mem_closedBall'.mp (ball_subset_closedBall hxin)),one_mul]
+ field_simp
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AveragedLpPairing.lean b/lean/OAI/Geometry/RCD/Harmonic/AveragedLpPairing.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ed65b9962c6482ad4b497a2bf3fe25575484e3a9
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AveragedLpPairing.lean
@@ -0,0 +1,112 @@
+import OAI.Geometry.RCD.Heat.HeatTimeContinuity
+
+namespace OAI
+
+/-! # Exact averaged kernel pairings with bounded Sobolev densities -/
+
+open Set MeasureTheory Filter
+open scoped InnerProductSpace ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) [μ.Regular] (hQ : QuadraticCheegerEnergy μ)
+ {ker : ℝ → X → X → ℝ} (hk : IsContinuousHeatKernel μ hQ ker)
+
+include hk in
+/-- The actual averaged kernel pairing is an L2 heat pairing. This also
+justifies its initial-time limit without a pointwise kernel limit. -/
+theorem kernelAverage_integral_lp {t : ℝ} (ht : 0 < t)
+ (A : Set X) (hA : MeasurableSet A) (hAt : μ A ≠ ∞) (f : Lp ℝ 2 μ) :
+ (∫ z, kernelAverage μ ker t A z * f z ∂μ) =
+ ⟪heatAt μ hQ t (uniformDensityLp μ A hA hAt), f⟫_ℝ := by
+ rw [L2.inner_def]
+ apply integral_congr_ae
+ filter_upwards [kernelAverage_heatSobolev_coe μ hQ hk ht A hA hAt] with z hz
+ rw [heatSobolev_toLp] at hz
+ simp only [hz, RCLike.inner_apply, conj_trivial]
+ ring
+
+include hk in
+/-- The full averaged pairing is integrable down to zero time for L2
+densities, including the compact curvature density. -/
+theorem kernelAverage_integral_lp_intervalIntegrable_zero
+ (A : Set X) (hA : MeasurableSet A) (hAt : μ A ≠ ∞) (f : Lp ℝ 2 μ)
+ {T : ℝ} (hT : 0 ≤ T) :
+ IntervalIntegrable (fun t => ∫ z, kernelAverage μ ker t A z * f z ∂μ) volume 0 T := by
+ have hc : Continuous (fun t => ⟪heatAt μ hQ t (uniformDensityLp μ A hA hAt), f⟫_ℝ) :=
+ (heatAt_continuous μ hQ _).inner continuous_const
+ apply (hc.intervalIntegrable 0 T).congr_ae
+ filter_upwards [ae_restrict_mem measurableSet_uIoc] with t ht
+ have ht' : 0 < t := by
+ rw [uIoc_of_le hT] at ht
+ exact ht.1
+ exact (kernelAverage_integral_lp μ hQ hk ht' A hA hAt f).symm
+
+include hk in
+/-- The same pairing is the actual average of the heat-evolved density. -/
+theorem kernelAverage_integral_lp_eq_average {t : ℝ} (ht : 0 < t)
+ (A : Set X) (hA : MeasurableSet A) (hAt : μ A ≠ ∞) (f : Lp ℝ 2 μ) :
+ (∫ z, kernelAverage μ ker t A z * f z ∂μ) =
+ (μ.real A)⁻¹ * ∫ z in A, heatAt μ hQ t f z ∂μ := by
+ rw [kernelAverage_integral_lp μ hQ hk ht A hA hAt f, heatAt_inner, uniformDensityLp_inner]
+
+include hk in
+/-- Each positive-time averaged kernel pairing is an ordinary integrable
+product of two L2 representatives. -/
+theorem kernelAverage_mul_lp_integrable {t : ℝ} (ht : 0 < t)
+ (A : Set X) (hA : MeasurableSet A) (hAt : μ A ≠ ∞) (f : Lp ℝ 2 μ) :
+ Integrable (fun z => kernelAverage μ ker t A z * f z) μ := by
+ have he := kernelAverage_heatSobolev_coe μ hQ hk ht A hA hAt
+ rw [heatSobolev_toLp] at he
+ apply (L2.integrable_inner (𝕜 := ℝ) (heatAt μ hQ t (uniformDensityLp μ A hA hAt)) f).congr
+ filter_upwards [he] with z hz
+ simp only [hz, RCLike.inner_apply, conj_trivial]
+ ring
+
+include hk in
+/-- The pointwise kernel pairing is also an integrable L2 product. -/
+theorem kernel_mul_lp_integrable {t : ℝ} (ht : 0 < t) (x : X) (f : Lp ℝ 2 μ) :
+ Integrable (fun z => ker t x z * f z) μ := by
+ apply (L2.integrable_inner (𝕜 := ℝ) (heatKernelRow μ hQ hk t x) f).congr
+ filter_upwards [heatKernelRow_coe μ hQ hk ht x] with z hz
+ simp only [hz, RCLike.inner_apply, conj_trivial]
+ ring
+
+/-- Kernel subtraction is valid for these actual integrable products. -/
+theorem kernelAverage_difference_integral_lp {t : ℝ} (ht : 0 < t)
+ (A : Set X) (hA : MeasurableSet A) (hAt : μ A ≠ ∞) (x : X) (f : Lp ℝ 2 μ) :
+ (∫ z, (kernelAverage μ ker t A z - ker t x z) * f z ∂μ) =
+ ⟪heatAt μ hQ t (uniformDensityLp μ A hA hAt), f⟫_ℝ - kernelHeat μ hQ hk t f x := by
+ simp_rw [sub_mul]
+ rw [integral_sub (kernelAverage_mul_lp_integrable μ hQ hk ht A hA hAt f)
+ (kernel_mul_lp_integrable μ hQ hk ht x f),
+ kernelAverage_integral_lp μ hQ hk ht A hA hAt f, kernelHeat_eq_integral μ hQ hk ht f x]
+
+include hk in
+/-- All positive-time difference pairings with an L2 density are
+integrable on compact time intervals. -/
+theorem kernelAverage_difference_lp_intervalIntegrable
+ (A : Set X) (hA : MeasurableSet A) (hAt : μ A ≠ ∞) (x : X) (f : Lp ℝ 2 μ)
+ {s t : ℝ} (hs : 0 < s) (hst : s ≤ t) :
+ IntervalIntegrable (fun r => ∫ z, (kernelAverage μ ker r A z - ker r x z) * f z ∂μ)
+ volume s t := by
+ have ha : Continuous (fun r => ⟪heatAt μ hQ r (uniformDensityLp μ A hA hAt), f⟫_ℝ) :=
+ (heatAt_continuous μ hQ _).inner continuous_const
+ have hp : ContinuousOn (fun r => kernelHeat μ hQ hk r f x) (Icc s t) :=
+ (kernelHeat_continuousOn_time_space μ hQ hk f).comp
+ (continuous_id.prodMk continuous_const).continuousOn
+ (fun r hr => ⟨hs.trans_le hr.1, mem_univ _⟩)
+ apply ((ha.continuousOn.sub hp).intervalIntegrable_of_Icc hst).congr_ae
+ filter_upwards [ae_restrict_mem measurableSet_uIoc] with r hr
+ have hr' : 0 < r := by
+ rw [uIoc_of_le hst] at hr
+ exact hs.trans hr.1
+ exact (kernelAverage_difference_integral_lp μ hQ hk hr' A hA hAt x f).symm
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/BalancedQuadraticError.lean b/lean/OAI/Geometry/RCD/Harmonic/BalancedQuadraticError.lean
new file mode 100644
index 0000000000000000000000000000000000000000..5f1bcbf471c47322ec3357ba203d8adabab89bf7
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/BalancedQuadraticError.lean
@@ -0,0 +1,62 @@
+import OAI.Geometry.RCD.Harmonic.EventualQuadraticError
+
+namespace OAI
+
+/-! # Radius-preserving balance of the quadratic Young parameter -/
+
+open Filter
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem eventual_balanced_error {Y : Type*} (f : ℕ → Y → ℝ)
+ {C V M B : ℝ} (hV : 0 ‖z‖^2/2) (closedBall 0 T)) :
+ ∀ᶠ k in atTop, (fun x => (‖V k x‖^2/2)*localGamma μ hQ (u k) (w k) x)=ᵐ[μ]
+ (fun x => F (V k x)*localGamma μ hQ (u k) (w k) x) := by
+ filter_upwards [hε.eventually (gt_mem_nhds (show 0<(T-c)/2 by linarith))] with k hk
+ filter_upwards [hz k,localGamma_zero_on_level μ hQ (u k) (w k) 0] with x hx hγ
+ by_cases hxc : x∈ball (p k) (c*r k)
+ · have hxs : dist x (p k)≤S*r k :=
+ hxc.le.trans (mul_le_mul_of_nonneg_right (hcT.trans hTS).le (hr k).le)
+ have hd := (abs_le.mp (pointed_radial_distance (hr k) hS.le (hV k).metric hxs)).2
+ have hdc : dist x (p k)/r k by rw [hzero x hx,zero_mul])]
+ field_simp [hV.ne',hp.ne']
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/EuclideanGevreyCutoff.lean b/lean/OAI/Geometry/RCD/Coordinates/EuclideanGevreyCutoff.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0a06776648f75a2034fdf3663c8d51228d478c02
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/EuclideanGevreyCutoff.lean
@@ -0,0 +1,66 @@
+import OAI.Geometry.RCD.Coordinates.PatchCoverData
+import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
+import OAI.Geometry.RCD.Coordinates.FrozenJetTransport
+
+namespace OAI
+
+/-!
+# Euclidean Gevrey cutoffs of order two
+
+L. Hörmander, *Between distributions and hyperfunctions*, Astérisque 131
+(1985), pp. 89–106, §2, equations (2.2) and (2.6), p. 90, describes
+nonquasianalytic Gevrey classes containing compactly supported functions.
+Squaring a nonzero bump and convolving its normalized dilation with a ball
+indicator gives a fixed core and support. Equivalence of coordinate
+and finite-dimensional multilinear derivative bounds changes only the
+exponential constant.
+
+https://numdam.org/item/AST_1985__131__89_0.pdf
+-/
+
+open Set Metric
+open scoped ContDiff
+
+noncomputable section
+namespace RegularPointCoordinates
+
+/-- A single fixed radial-scale cutoff with all-order Gevrey-two bounds. -/
+structure EuclideanGevreyCutoff (n : ℕ) where
+ value : Euclidean n → ℝ
+ constant : ℝ
+ constant_ge_one : 1 ≤ constant
+ smooth : ContDiff ℝ ∞ value
+ nonneg : ∀ z, 0 ≤ value z
+ le_one : ∀ z, value z ≤ 1
+ core : ∀ z, ‖z‖ ≤ 2 → value z = 1
+ support : tsupport value ⊆ closedBall 0 3
+ jet : ∀ (m : ℕ) (z : Euclidean n),
+ ‖iteratedFDeriv ℝ m value z‖ ≤ constant ^ (m + 1) * (m.factorial : ℝ) ^ 2
+
+/-- The precise compact Gevrey specialization needed by the chart proof. -/
+def EuclideanGevreyCutoffInput (n : ℕ) : Prop := Nonempty (EuclideanGevreyCutoff n)
+
+/-- A fixed affine change preserves the Gevrey order. The base records the
+actual operator norm, while the derivative order remains unrestricted. -/
+theorem EuclideanGevreyCutoff.affine_jet_le {n : ℕ} (psi : EuclideanGevreyCutoff n)
+ (L : Euclidean n →L[ℝ] Euclidean n) (a z : Euclidean n) (m : ℕ)
+ {M : ℝ} (hM : 1 ≤ M) (hL : ‖L‖ ≤ M) :
+ ‖iteratedFDeriv ℝ m (fun w => psi.value (a + L w)) z‖ ≤
+ (psi.constant * M) ^ (m + 1) * (m.factorial : ℝ) ^ 2 := by
+ have hc : 0 ≤ psi.constant := zero_le_one.trans psi.constant_ge_one
+ have hbound := norm_iteratedFDeriv_comp_affine_le L psi.value a z m
+ (psi.smooth.of_le (by simp)).contDiffAt
+ have hp : ‖L‖ ^ m ≤ M ^ (m + 1) :=
+ (pow_le_pow_left₀ (norm_nonneg L) hL m).trans
+ (pow_le_pow_right₀ hM (by omega))
+ calc
+ _ ≤ ‖iteratedFDeriv ℝ m psi.value (a + L z)‖ * ‖L‖ ^ m := hbound
+ _ ≤ (psi.constant ^ (m + 1) * (m.factorial : ℝ) ^ 2) * M ^ (m + 1) :=
+ mul_le_mul (psi.jet m _) hp (by positivity) (by positivity)
+ _ = _ := by rw [mul_pow]; ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/EuclideanWeakHarmonicRegularity.lean b/lean/OAI/Geometry/RCD/Coordinates/EuclideanWeakHarmonicRegularity.lean
new file mode 100644
index 0000000000000000000000000000000000000000..6b339379520ef72768544eaef2bf2f86e23886da
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/EuclideanWeakHarmonicRegularity.lean
@@ -0,0 +1,105 @@
+import OAI.Geometry.RCD.Sobolev.EuclideanWeakHarmonicMean
+
+namespace OAI
+
+/-! # Classical harmonicity from the local compact-test Laplace equation -/
+
+open Set Metric Filter MeasureTheory InnerProductSpace
+open scoped ContDiff Convolution Topology
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem compact_continuous_weak_harmonic {n : ℕ} {f : Euclidean n → ℝ} {S : ℝ}
+ (hf : Continuous f) (hfs : HasCompactSupport f) (hw : EuclideanWeakHarmonicOn f S) :
+ HarmonicOnNhd f (ball 0 S) := by
+ intro p hp
+ have hpS : ‖p‖ χ x*f x) := by
+ apply continuous_iff_continuousAt.mpr
+ intro x
+ by_cases hx : x∈Ω
+ · exact hχ.continuousAt.mul (hf.continuousAt (hΩ.mem_nhds hx))
+ · have ht : x∉tsupport χ := fun h => hx (hs h)
+ apply (continuousAt_const (y := (0:ℝ))).congr_of_eventuallyEq
+ filter_upwards [notMem_tsupport_iff_eventuallyEq.mp ht] with y hy
+ simp only [hy,Pi.zero_apply,zero_mul]
+
+theorem continuous_weak_harmonic {n : ℕ} {f : Euclidean n → ℝ} {S : ℝ}
+ (hf : ContinuousOn f (ball 0 S)) (hw : EuclideanWeakHarmonicOn f S) :
+ HarmonicOnNhd f (ball 0 S) := by
+ intro p hp
+ have hpS : ‖p‖ χ x*f x
+ have hFc : Continuous F := continuous_mul_of_tsupport_subset isOpen_ball hf χ.continuous
+ (by rw [χ.tsupport_eq]; exact closedBall_subset_ball hbS)
+ have hFs : HasCompactSupport F := χ.hasCompactSupport.mul_right
+ have he : EqOn F f (ball 0 a) := by
+ intro x hx
+ change χ x*f x=f x
+ rw [χ.one_of_mem_closedBall (ball_subset_closedBall hx),one_mul]
+ have hFw : EuclideanWeakHarmonicOn F a :=
+ (hw.mono (by dsimp only [a]; linarith)).congr he.symm
+ have hpa : p∈ball (0:Euclidean n) a := by
+ simp only [mem_ball,dist_zero_right]
+ dsimp only [a]
+ linarith
+ have hevent : F =ᶠ[𝓝 p] f := by
+ filter_upwards [isOpen_ball.mem_nhds hpa] with y hy
+ exact he hy
+ apply (harmonicAt_congr_nhds hevent).mp
+ exact compact_continuous_weak_harmonic hFc hFs hFw p hpa
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/ExactNormalizationComparison.lean b/lean/OAI/Geometry/RCD/Coordinates/ExactNormalizationComparison.lean
new file mode 100644
index 0000000000000000000000000000000000000000..b537551e57709f3e12f2f1aace4b55cf2dcf05cb
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/ExactNormalizationComparison.lean
@@ -0,0 +1,81 @@
+import OAI.Geometry.RCD.Harmonic.NearbyMeanGrams
+import OAI.Geometry.RCD.Harmonic.TransformedColumns
+
+namespace OAI
+
+/-!
+# Relative comparison from exact harmonic normalization
+
+Restricting a normalized splitting map to a subball costs only its volume
+ratio. The comparison is relative to the original mean Gram, even if that
+Gram has arbitrarily small eigenvalues.
+-/
+
+open Set Metric MeasureTheory
+open scoped InnerProductSpace ENNReal
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [ProperSpace X] (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- Exact mean normalization identifies the inverse-coordinate norm
+with the original mean energy, even for a very anisotropic Gram. -/
+theorem exact_mean_inverse_norm_sq {n : ℕ}
+ (U : Euclidean n →L[ℝ] SobolevSpace μ hQ)
+ (s : Set X) (hs : MeasurableSet s) (A : Euclidean n ≃L[ℝ] Euclidean n)
+ (hA : IsExactMeanNormalization μ hQ U s hs A) (v : Euclidean n) :
+ ‖A.symm v‖ ^ 2 = ⟪v, sobolevMeanGram μ hQ U s hs v⟫_ℝ := by
+ have hh : ⟪A.symm v, sobolevMeanGram μ hQ
+ (U.comp (A : Euclidean n →L[ℝ] Euclidean n)) s hs (A.symm v)⟫_ℝ =
+ ‖A.symm v‖ ^ 2 := by
+ rw [hA]
+ simp only [ContinuousLinearMap.id_apply, real_inner_self_eq_norm_sq]
+ rw [sobolevMeanGram_comp] at hh
+ simpa only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.adjoint_inner_right,
+ ContinuousLinearEquiv.coe_coe, ContinuousLinearEquiv.apply_symm_apply] using hh.symm
+
+/-- Exact normalization on the large ball improves the two-mean comparison:
+only the restricted mean incurs an error. -/
+theorem exact_normalization_subball_bounds {n : ℕ}
+ (u : Fin n → SobolevSpace μ hQ) (A : Euclidean n ≃L[ℝ] Euclidean n)
+ {p : X} {r ε C : ℝ} {w : X → Euclidean n}
+ (hfirst : FirstOrderSplittingOn μ hQ p r ε (transformedColumn μ hQ u A) w)
+ (hexact : IsExactMeanNormalization μ hQ (sobolevColumnMap μ hQ u)
+ (ball p r) measurableSet_ball A)
+ (s : Set X) (hs : MeasurableSet s) (hsub : s ⊆ ball p r)
+ (hszero : μ s ≠ 0) (hsfin : μ s ≠ ∞)
+ (hrzero : μ (ball p r) ≠ 0) (hrfin : μ (ball p r) ≠ ∞)
+ (hC : 0 ≤ C) (hε : 0 ≤ ε)
+ (hvol : μ.real (ball p r) ≤ C * μ.real s) (v : Euclidean n) :
+ (1 - (n : ℝ) ^ 2 * (C * ε)) *
+ ⟪v, sobolevMeanGram μ hQ (sobolevColumnMap μ hQ u) (ball p r) measurableSet_ball v⟫_ℝ ≤
+ ⟪v, sobolevMeanGram μ hQ (sobolevColumnMap μ hQ u) s hs v⟫_ℝ ∧
+ ⟪v, sobolevMeanGram μ hQ (sobolevColumnMap μ hQ u) s hs v⟫_ℝ ≤
+ (1 + (n : ℝ) ^ 2 * (C * ε)) *
+ ⟪v, sobolevMeanGram μ hQ (sobolevColumnMap μ hQ u) (ball p r) measurableSet_ball v⟫_ℝ := by
+ let U := sobolevColumnMap μ hQ u
+ have hnorm := meanGram_sub_id_norm_le_of_subset μ hQ (transformedColumn μ hQ u A)
+ hs hsub hszero hsfin hrzero hrfin hC hε hvol hfirst.gram
+ rw [sobolevColumnMap_transformed] at hnorm
+ have hform (b : Set X) (hb : MeasurableSet b) :
+ ⟪A.symm v, sobolevMeanGram μ hQ (U.comp (A : Euclidean n →L[ℝ] Euclidean n)) b hb (A.symm v)⟫_ℝ =
+ ⟪v, sobolevMeanGram μ hQ U b hb v⟫_ℝ := by
+ rw [sobolevMeanGram_comp]
+ simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.adjoint_inner_right,
+ ContinuousLinearEquiv.coe_coe, ContinuousLinearEquiv.apply_symm_apply]
+ have hv : ‖A.symm v‖ ^ 2 =
+ ⟪v, sobolevMeanGram μ hQ U (ball p r) measurableSet_ball v⟫_ℝ := by
+ exact exact_mean_inverse_norm_sq μ hQ U (ball p r) measurableSet_ball A hexact v
+ have hlo := inner_lower_of_sub_id_norm _ hnorm (A.symm v)
+ have hup := inner_upper_of_sub_id_norm _ hnorm (A.symm v)
+ rw [hform s hs, hv] at hlo hup
+ exact ⟨hlo, hup⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/FactorialMajorant.lean b/lean/OAI/Geometry/RCD/Coordinates/FactorialMajorant.lean
new file mode 100644
index 0000000000000000000000000000000000000000..422bc2d22d631fbb33e6f5d05eaf5aec26ebeb96
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/FactorialMajorant.lean
@@ -0,0 +1,194 @@
+import OAI.Geometry.RCD.Coordinates.InverseMajorant
+import Mathlib.Analysis.SpecificLimits.Basic
+import Mathlib.Data.Nat.Factorial.Basic
+import Mathlib.Algebra.BigOperators.Intervals
+
+namespace OAI
+
+/-!
+# Factorial weights for the inverse-jet estimate
+
+We use the fixed admissible Gevrey exponent `σ = 2`. The weight
+`L m = (m + 1) * ((m + 1)!)²` is positive, has `L 0 = 1`, and its
+normalized interior convolution tends to zero. Consequently the
+abstract inverse majorant gives one constant for every derivative order.
+-/
+
+open Finset Filter
+open scoped BigOperators Topology
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+def factorialMajorant (m : ℕ) : ℝ :=
+ ((m : ℝ) + 1) * ((m + 1).factorial : ℝ) ^ 2
+
+@[simp] theorem factorialMajorant_zero : factorialMajorant 0 = 1 := by
+ norm_num [factorialMajorant]
+
+@[simp] theorem factorialMajorant_one : factorialMajorant 1 = 8 := by
+ norm_num [factorialMajorant]
+
+theorem factorialMajorant_pos (m : ℕ) : 0 < factorialMajorant m := by
+ unfold factorialMajorant
+ positivity
+
+theorem factorialMajorant_succ (m : ℕ) :
+ factorialMajorant (m + 1) = ((m : ℝ) + 2) ^ 3 * ((m + 1).factorial : ℝ) ^ 2 := by
+ unfold factorialMajorant
+ rw [Nat.factorial_succ]
+ push_cast
+ ring
+
+/-- The consecutive ratios of the weight are increasing. -/
+theorem factorialMajorant_pair_step {p q : ℕ} (hpq : p ≤ q) :
+ factorialMajorant (p + 1) * factorialMajorant q ≤
+ factorialMajorant p * factorialMajorant (q + 1) := by
+ have hp : (1 : ℝ) ≤ (p : ℝ) + 1 := by linarith [Nat.cast_nonneg (α := ℝ) p]
+ have hq : (1 : ℝ) ≤ (q : ℝ) + 1 := by linarith [Nat.cast_nonneg (α := ℝ) q]
+ have hmul := one_le_mul_of_one_le_of_one_le hp hq
+ have hlarge : (1 : ℝ) ≤ (p : ℝ) + q + 5 := by linarith
+ have hprod := one_le_mul_of_one_le_of_one_le hmul hlarge
+ have hd : (0 : ℝ) ≤ (q : ℝ) - p := sub_nonneg.mpr (by exact_mod_cast hpq)
+ have hnon := mul_nonneg hd (sub_nonneg.mpr hprod)
+ have hpoly : ((p : ℝ) + 2) ^ 3 * ((q : ℝ) + 1) ≤
+ ((p : ℝ) + 1) * ((q : ℝ) + 2) ^ 3 := by nlinarith only [hnon]
+ have hscaled := mul_le_mul_of_nonneg_right hpoly
+ (by positivity : (0 : ℝ) ≤ ((p + 1).factorial : ℝ) ^ 2 *
+ ((q + 1).factorial : ℝ) ^ 2)
+ rw [factorialMajorant_succ, factorialMajorant_succ]
+ unfold factorialMajorant
+ convert hscaled using 1 <;> ring
+
+/-- For fixed total order, the largest positive-order product is at an endpoint. -/
+theorem factorialMajorant_pair_le_endpoint {l q : ℕ} (hl : 1 ≤ l) (hq : 1 ≤ q) :
+ factorialMajorant l * factorialMajorant q ≤
+ factorialMajorant 1 * factorialMajorant (l + q - 1) := by
+ induction l using Nat.strong_induction_on generalizing q with
+ | h l ih =>
+ by_cases hlone : l = 1
+ · subst l
+ simp
+ by_cases hlq : l ≤ q
+ · have hlprev : 1 ≤ l - 1 := by omega
+ have hpq : l - 1 ≤ q := by omega
+ have hstep := factorialMajorant_pair_step hpq
+ have heq : l - 1 + 1 = l := by omega
+ rw [heq] at hstep
+ have hbound := ih (l - 1) (by omega) hlprev (by omega : 1 ≤ q + 1)
+ have hsum : l - 1 + (q + 1) - 1 = l + q - 1 := by omega
+ exact hstep.trans (by simpa only [hsum] using hbound)
+ · have hbound := ih q (by omega) hq hl
+ simpa only [mul_comm, Nat.add_comm] using hbound
+
+theorem factorialMajorant_endpoint_ratio {m : ℕ} (hm : 1 ≤ m) :
+ factorialMajorant 1 * factorialMajorant (m - 1) / factorialMajorant m =
+ 8 * (m : ℝ) / ((m : ℝ) + 1) ^ 3 := by
+ have hm' : m - 1 + 1 = m := by omega
+ have hfact : ((m + 1).factorial : ℝ) = ((m : ℝ) + 1) * (m.factorial : ℝ) := by
+ rw [Nat.factorial_succ]
+ push_cast
+ ring
+ have hfactpos : (0 : ℝ) < (m.factorial : ℝ) := by positivity
+ rw [factorialMajorant_one]
+ unfold factorialMajorant
+ rw [hm', hfact]
+ have hmreal : (m - 1 : ℕ) + (1 : ℝ) = (m : ℝ) := by
+ exact_mod_cast hm'
+ rw [hmreal]
+ field_simp [ne_of_gt hfactpos]
+
+/-- A direct bound sufficient for convolution decay. -/
+theorem factorialMajorant_normalized_convolution_le (m : ℕ) :
+ normalizedInteriorConvolution factorialMajorant m ≤ 8 / ((m : ℝ) + 1) := by
+ by_cases hmzero : m = 0
+ · subst m
+ norm_num [normalizedInteriorConvolution, interiorConvolution]
+ have hm : 1 ≤ m := Nat.one_le_iff_ne_zero.mpr hmzero
+ have hsum : interiorConvolution factorialMajorant m ≤
+ (m : ℝ) * (factorialMajorant 1 * factorialMajorant (m - 1)) := by
+ calc
+ _ ≤ ∑ _l ∈ Finset.Icc 1 (m - 1),
+ factorialMajorant 1 * factorialMajorant (m - 1) := by
+ apply Finset.sum_le_sum
+ intro l hl
+ have hl' := Finset.mem_Icc.mp hl
+ have hq : 1 ≤ m - l := by omega
+ have h := factorialMajorant_pair_le_endpoint hl'.1 hq
+ have heq : l + (m - l) - 1 = m - 1 := by omega
+ simpa only [heq] using h
+ _ ≤ (m : ℝ) * (factorialMajorant 1 * factorialMajorant (m - 1)) := by
+ rw [Finset.sum_const, nsmul_eq_mul]
+ apply mul_le_mul_of_nonneg_right _
+ (mul_nonneg (factorialMajorant_pos 1).le (factorialMajorant_pos (m - 1)).le)
+ have hcard : (Finset.Icc 1 (m - 1)).card ≤ m := by
+ rw [Nat.card_Icc]
+ omega
+ exact_mod_cast hcard
+ have hdiv := div_le_div_of_nonneg_right hsum (factorialMajorant_pos m).le
+ change normalizedInteriorConvolution factorialMajorant m ≤ _ at hdiv
+ calc
+ _ ≤ (m : ℝ) * (8 * (m : ℝ) / ((m : ℝ) + 1) ^ 3) := by
+ simpa only [mul_div_assoc, factorialMajorant_endpoint_ratio hm] using hdiv
+ _ ≤ 8 / ((m : ℝ) + 1) := by
+ have hp : (0 : ℝ) < (m : ℝ) + 1 := by positivity
+ rw [← mul_div_assoc, div_le_div_iff₀ (pow_pos hp 3) hp]
+ nlinarith [sq_nonneg (m : ℝ), Nat.cast_nonneg (α := ℝ) m]
+
+theorem factorialMajorant_convolution_tendsto_zero :
+ Tendsto (normalizedInteriorConvolution factorialMajorant) atTop (𝓝 0) := by
+ have hnon (m : ℕ) : 0 ≤ normalizedInteriorConvolution factorialMajorant m :=
+ div_nonneg (interiorConvolution_nonneg (fun j => (factorialMajorant_pos j).le) m)
+ (factorialMajorant_pos m).le
+ have hlim : Tendsto (fun m : ℕ => 8 / ((m : ℝ) + 1)) atTop (𝓝 0) := by
+ have h := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).const_mul 8
+ simpa only [mul_zero, mul_one_div] using h
+ exact squeeze_zero hnon factorialMajorant_normalized_convolution_le hlim
+
+/-- Restoring the endpoint terms gives the uniform full-convolution estimate. -/
+theorem factorialMajorant_full_convolution_le (m : ℕ) :
+ (∑ l ∈ Finset.range (m + 1), factorialMajorant l * factorialMajorant (m - l)) ≤
+ 10 * factorialMajorant m := by
+ have hdelta : normalizedInteriorConvolution factorialMajorant m ≤ 8 := by
+ apply (factorialMajorant_normalized_convolution_le m).trans
+ apply (div_le_iff₀ (by positivity : (0 : ℝ) < (m : ℝ) + 1)).mpr
+ nlinarith [Nat.cast_nonneg (α := ℝ) m]
+ have hinterior : interiorConvolution factorialMajorant m ≤ 8 * factorialMajorant m := by
+ have h := mul_le_mul_of_nonneg_right hdelta (factorialMajorant_pos m).le
+ rwa [normalizedInteriorConvolution_mul factorialMajorant_pos m] at h
+ by_cases hmzero : m = 0
+ · subst m
+ norm_num
+ have hm : 0 < m := Nat.pos_of_ne_zero hmzero
+ have hIcc : Finset.Ico 1 m = Finset.Icc 1 (m - 1) := by
+ ext l
+ simp only [Finset.mem_Ico, Finset.mem_Icc]
+ omega
+ have hsplit : (∑ l ∈ Finset.range (m + 1),
+ factorialMajorant l * factorialMajorant (m - l)) =
+ 2 * factorialMajorant m + interiorConvolution factorialMajorant m := by
+ rw [Finset.sum_range_succ,
+ Finset.sum_range_eq_add_Ico
+ (fun l => factorialMajorant l * factorialMajorant (m - l)) hm, hIcc]
+ simp only [Nat.sub_zero, Nat.sub_self, factorialMajorant_zero, one_mul, mul_one]
+ unfold interiorConvolution
+ ring
+ rw [hsplit]
+ linarith
+
+/-- The factorial weights satisfy the inverse-coefficient bound with one
+constant, uniformly over all orders and all admissible coefficient sequences. -/
+theorem factorial_inverse_coefficients_uniform_bound {A : ℝ} (hA : 1 ≤ A) :
+ ∃ C : ℝ, Real.sqrt A ≤ C ∧ 2 * A ≤ C ∧
+ ∀ a : ℕ → ℝ, a 0 ≤ Real.sqrt A →
+ HasInverseMajorantRecurrence factorialMajorant a A →
+ ∀ m, a m ≤ C * factorialMajorant m :=
+ inverse_coefficients_uniform_bound factorialMajorant_pos factorialMajorant_zero hA
+ factorialMajorant_convolution_tendsto_zero
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/FieldEstimates.lean b/lean/OAI/Geometry/RCD/Coordinates/FieldEstimates.lean
new file mode 100644
index 0000000000000000000000000000000000000000..759a41a82d755fcb49bfea2bbdbbe35d8db1a5e6
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/FieldEstimates.lean
@@ -0,0 +1,86 @@
+import OAI.Geometry.RCD.Coordinates.PositiveForms
+import Mathlib.Analysis.Calculus.FDeriv.Mul
+
+namespace OAI
+
+/-!
+# First derivatives of the value-space patch field
+
+The local mass operators may be singular. Their positivity controls the
+error from differentiating the cutoffs by the directional mass, rather than
+by the full norm of the local metric.
+-/
+
+open scoped BigOperators InnerProductSpace
+
+namespace RegularPointCoordinates
+
+variable {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+
+/-- The field used by the renormalization, written as a finite patch sum. -/
+def patchField (s : Finset ι) (phi : ι → E → ℝ) (D : ι → E →L[ℝ] E)
+ (c : ι → E) (P : E) : E :=
+ ∑ j ∈ s, phi j P • D j (P - c j)
+
+/-- Its derivative consists of the principal positive mass plus cutoff errors. -/
+theorem hasFDerivAt_patchField (s : Finset ι) (phi : ι → E → ℝ)
+ (dphi : ι → E →L[ℝ] ℝ) (D : ι → E →L[ℝ] E) (c : ι → E) (P : E)
+ (hphi : ∀ j ∈ s, HasFDerivAt (phi j) (dphi j) P) :
+ HasFDerivAt (patchField s phi D c)
+ (∑ j ∈ s, ((phi j P) • D j + (dphi j).smulRight (D j (P - c j)))) P := by
+ have hterm : ∀ j ∈ s, HasFDerivAt (fun y => phi j y • D j (y - c j))
+ ((phi j P) • D j + (dphi j).smulRight (D j (P - c j))) P := by
+ intro j hj
+ have hD := (D j).hasFDerivAt.comp P ((hasFDerivAt_id P).sub_const (c j))
+ simpa [Function.comp_def] using (hphi j hj).fun_smul hD
+ convert HasFDerivAt.sum hterm using 1
+ ext y
+ simp [patchField]
+
+/-- A finite cutoff error is bounded by the square root of the directional
+mass times the square root of the displacement energy. -/
+theorem patch_error_inner_le (s : Finset ι) (D : ι → E →L[ℝ] E)
+ (w : ι → E) (a : ι → ℝ) (xi : E) {K : ℝ} (hK : 0 ≤ K)
+ (hD : ∀ j ∈ s, (D j).IsPositive) (ha : ∀ j ∈ s, |a j| ≤ K) :
+ |⟪xi, ∑ j ∈ s, a j • D j (w j)⟫_ℝ| ≤
+ K * Real.sqrt (∑ j ∈ s, ⟪xi, D j xi⟫_ℝ) *
+ Real.sqrt (∑ j ∈ s, ⟪w j, D j (w j)⟫_ℝ) := by
+ have hcs := Real.sum_mul_le_sqrt_mul_sqrt s
+ (fun j => Real.sqrt ⟪xi, D j xi⟫_ℝ)
+ (fun j => Real.sqrt ⟪w j, D j (w j)⟫_ℝ)
+ have hx : (∑ j ∈ s, (Real.sqrt ⟪xi, D j xi⟫_ℝ) ^ 2) =
+ ∑ j ∈ s, ⟪xi, D j xi⟫_ℝ :=
+ Finset.sum_congr rfl (fun j hj => Real.sq_sqrt ((hD j hj).inner_nonneg_right xi))
+ have hw : (∑ j ∈ s, (Real.sqrt ⟪w j, D j (w j)⟫_ℝ) ^ 2) =
+ ∑ j ∈ s, ⟪w j, D j (w j)⟫_ℝ :=
+ Finset.sum_congr rfl (fun j hj => Real.sq_sqrt ((hD j hj).inner_nonneg_right (w j)))
+ rw [hx, hw] at hcs
+ calc
+ _ = |∑ j ∈ s, a j * ⟪xi, D j (w j)⟫_ℝ| := by
+ simp only [inner_sum, inner_smul_right]
+ _ ≤ ∑ j ∈ s, |a j * ⟪xi, D j (w j)⟫_ℝ| := Finset.abs_sum_le_sum_abs _ _
+ _ ≤ ∑ j ∈ s, K *
+ (Real.sqrt ⟪xi, D j xi⟫_ℝ * Real.sqrt ⟪w j, D j (w j)⟫_ℝ) := by
+ apply Finset.sum_le_sum
+ intro j hj
+ rw [abs_mul]
+ exact mul_le_mul (ha j hj) (positive_form_inner_abs_le (hD j hj) xi (w j))
+ (abs_nonneg _) hK
+ _ = K * ∑ j ∈ s,
+ Real.sqrt ⟪xi, D j xi⟫_ℝ * Real.sqrt ⟪w j, D j (w j)⟫_ℝ := by
+ rw [Finset.mul_sum]
+ _ ≤ _ := by
+ simpa only [mul_assoc] using mul_le_mul_of_nonneg_left hcs hK
+
+/-- The principal part of the derivative is positive when the cutoffs are. -/
+theorem patch_principal_isPositive (s : Finset ι) (phi : ι → ℝ)
+ (D : ι → E →L[ℝ] E)
+ (hphi : ∀ j ∈ s, 0 ≤ phi j) (hD : ∀ j ∈ s, (D j).IsPositive) :
+ (∑ j ∈ s, phi j • D j).IsPositive := by
+ apply ContinuousLinearMap.isPositive_sum
+ intro j hj
+ exact (hD j hj).smul_of_nonneg (hphi j hj)
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/FiniteBilinearAE.lean b/lean/OAI/Geometry/RCD/Coordinates/FiniteBilinearAE.lean
new file mode 100644
index 0000000000000000000000000000000000000000..aae0b721a6ca683efd0c913550fe822eaefb83e3
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/FiniteBilinearAE.lean
@@ -0,0 +1,57 @@
+import OAI.Geometry.RCD.Coordinates.BilinearDiagonalBound
+
+namespace OAI
+
+/-! # A common null set for all mixed directions of finite quadratic forms -/
+
+open Set Filter MeasureTheory TopologicalSpace
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {m : ℕ}
+
+theorem bilinear_coordinates (B : Euclidean m →ₗ[ℝ] Euclidean m →ₗ[ℝ] ℝ) :
+ coordinateBilinear (fun i j => B (EuclideanSpace.single i 1) (EuclideanSpace.single j 1))=B := by
+ apply (EuclideanSpace.basisFun (Fin m) ℝ).toBasis.ext
+ intro i
+ apply (EuclideanSpace.basisFun (Fin m) ℝ).toBasis.ext
+ intro j
+ simp [coordinateBilinear,EuclideanSpace.basisFun_apply]
+
+theorem bilinear_diagonal_continuous (B : Euclidean m →ₗ[ℝ] Euclidean m →ₗ[ℝ] ℝ) :
+ Continuous (fun a => B a a) := by
+ rw [← bilinear_coordinates B]
+ simp only [coordinateBilinear_apply,smul_eq_mul]
+ fun_prop
+
+/-- Bounds established separately in each real direction yield one
+null set outside which every mixed-direction bound holds. -/
+theorem ae_bilinear_mixed_bound_of_diagonal {X : Type*} [MeasurableSpace X] (μ : Measure X)
+ (P H : X → Euclidean m →ₗ[ℝ] Euclidean m →ₗ[ℝ] ℝ) (b : X → ℝ)
+ (hP : ∀ x a c, P x a c=P x c a) (hH : ∀ x a c, H x a c=H x c a)
+ (hpos : ∀ a, ∀ᵐ x ∂μ, 0≤P x a a) (hb : ∀ᵐ x ∂μ, 0≤b x)
+ (hdiag : ∀ a, ∀ᵐ x ∂μ, (H x a a)^2≤b x*(P x a a)^2) :
+ ∀ᵐ x ∂μ, ∀ a c, (H x a c)^2≤b x*P x a a*P x c c := by
+ obtain ⟨D,hD,hdense⟩ := exists_countable_dense (Euclidean m)
+ let : Countable D := hD.to_subtype
+ filter_upwards [hb,ae_all_iff.mpr (fun a : D => (hpos a).and (hdiag a))] with x hb hx
+ have hPc := bilinear_diagonal_continuous (P x)
+ have hHc := bilinear_diagonal_continuous (H x)
+ have hc : IsClosed {a : Euclidean m | 0≤P x a a ∧ (H x a a)^2≤b x*(P x a a)^2} :=
+ (isClosed_le continuous_const hPc).inter
+ (isClosed_le (hHc.pow 2) (continuous_const.mul (hPc.pow 2)))
+ have hsub : D ⊆ {a : Euclidean m | 0≤P x a a ∧ (H x a a)^2≤b x*(P x a a)^2} :=
+ fun a ha => hx ⟨a,ha⟩
+ have hall := closure_minimal hsub hc
+ rw [hdense.closure_eq] at hall
+ intro a c
+ exact bilinear_mixed_sq_bound_of_diagonal (P x) (H x) (hP x)
+ (fun z => (hall (mem_univ z)).1) (hH x) (b x) hb
+ (fun z => (hall (mem_univ z)).2) a c
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/FiniteDepthNormalization.lean b/lean/OAI/Geometry/RCD/Coordinates/FiniteDepthNormalization.lean
new file mode 100644
index 0000000000000000000000000000000000000000..778f2c4900f25201abefa16f0c3bdfcb90bcfe62
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/FiniteDepthNormalization.lean
@@ -0,0 +1,69 @@
+import OAI.Geometry.RCD.Coordinates.ComparableRadiusSplitting
+
+namespace OAI
+
+/-! # Fixed finite depths cannot contain a failing normalization scale -/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.finite_depth_splitting {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2 ≤ n)
+ (N : ℕ) (β : ℝ) (hβ : 0 < β) :
+ ∃ δ : ℝ, 0 < δ ∧ ∀ (p : X) (R : ℝ), 0 < R → -1 ≤ K*(2*R)^2 →
+ ∀ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic) (v : X → Euclidean n),
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p (2*R) δ u v →
+ ∀ t : ℝ, R/(2 : ℝ)^N ≤ t → t ≤ R → ∃ A : Euclidean n ≃L[ℝ] Euclidean n,
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p t β
+ (transformedColumn (hausdorff n X) hX.quadratic u A)
+ (fun x => (A : Euclidean n →L[ℝ] Euclidean n).adjoint (v x)) ∧
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u) (ball p t) measurableSet_ball A := by
+ obtain ⟨δ,hδ,hgood⟩ := hX.interior_radius_splitting hn (1/(2 : ℝ)^N)
+ (by positivity) ((div_le_one (by positivity)).mpr (one_le_pow₀ (by norm_num))) β hβ
+ refine ⟨δ,hδ,?_⟩
+ intro p R hR hK u v hfirst t ht htR
+ apply hgood p R hR hK u v hfirst t _ htR
+ simpa only [div_eq_mul_inv,one_mul,mul_comm] using ht
+
+theorem NoncollapsedRCD.failing_depth_tends_to_infinity {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2 ≤ n)
+ (β : ℝ) (hβ : 0 < β) (p : ℕ → X) (R ε : ℕ → ℝ)
+ (u : ℕ → Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ (v : ℕ → X → Euclidean n) (d : ℕ → ℕ)
+ (hR : ∀ k, 0 < R k) (hK : ∀ k, -1 ≤ K*(2*R k)^2)
+ (hε : ∀ k, 0 ≤ ε k) (hεlim : Tendsto ε atTop (𝓝 0))
+ (hfirst : ∀ k, FirstOrderSplittingOn (hausdorff n X) hX.quadratic
+ (p k) (2*R k) (ε k) (u k) (v k))
+ (hbad : ∀ k, ¬∃ A : Euclidean n ≃L[ℝ] Euclidean n,
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic (p k) (R k/(2 : ℝ)^(d k)) β
+ (transformedColumn (hausdorff n X) hX.quadratic (u k) A)
+ (fun x => (A : Euclidean n →L[ℝ] Euclidean n).adjoint (v k x)) ∧
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic (u k))
+ (ball (p k) (R k/(2 : ℝ)^(d k))) measurableSet_ball A) :
+ Tendsto d atTop atTop := by
+ refine tendsto_atTop.2 fun N => ?_
+ obtain ⟨δ,hδ,hgood⟩ := hX.finite_depth_splitting hn N β hβ
+ filter_upwards [hεlim.eventually (eventually_lt_nhds hδ)] with k hk
+ have hlarge : N < d k := by
+ by_contra hnot
+ have hd : d k ≤ N := le_of_not_gt hnot
+ have hlo : R k/(2 : ℝ)^N ≤ R k/(2 : ℝ)^(d k) :=
+ div_le_div_of_nonneg_left (hR k).le (by positivity)
+ (pow_le_pow_right₀ (by norm_num) hd)
+ have hhi : R k/(2 : ℝ)^(d k) ≤ R k :=
+ div_le_self (hR k).le (one_le_pow₀ (by norm_num))
+ exact hbad k (hgood (p k) (R k) (hR k) (hK k) (u k) (v k)
+ ((hfirst k).mono_error (hausdorff n X) hX.quadratic (hε k) hk.le)
+ (R k/(2 : ℝ)^(d k)) hlo hhi)
+ exact hlarge.le
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/FiniteNormalizerGrowth.lean b/lean/OAI/Geometry/RCD/Coordinates/FiniteNormalizerGrowth.lean
new file mode 100644
index 0000000000000000000000000000000000000000..3bc77264a2eddadac86584ea4839dc641120240c
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/FiniteNormalizerGrowth.lean
@@ -0,0 +1,87 @@
+import OAI.Geometry.RCD.Coordinates.DyadicNormalizedError
+
+namespace OAI
+
+/-! # Polynomial norm control of exact normalizers over a finite range -/
+
+open Set Metric MeasureTheory
+open scoped InnerProductSpace
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {X E : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+
+/-- Relative growth of means gives the squared norm bound for the exact
+normalizer at the smaller scale. The larger mean is already normalized. -/
+theorem normalizer_norm_sq_le_of_mean_growth (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ (U : E →L[ℝ] SobolevSpace μ hQ) (s t : Set X)
+ (hs : MeasurableSet s) (ht : MeasurableSet t)
+ (A : E ≃L[ℝ] E) (hA : IsExactMeanNormalization μ hQ U s hs A)
+ (htId : sobolevMeanGram μ hQ U t ht = ContinuousLinearMap.id ℝ E)
+ {B : ℝ} (hB : 0 ≤ B)
+ (hgrowth : ∀ v : E, ⟪v, sobolevMeanGram μ hQ U t ht v⟫_ℝ ≤
+ B * ⟪v, sobolevMeanGram μ hQ U s hs v⟫_ℝ) :
+ ‖(A : E →L[ℝ] E)‖ ^ 2 ≤ B := by
+ have hv (v : E) : ‖A v‖ ^ 2 ≤ B * ‖v‖ ^ 2 := by
+ have hh := hgrowth (A v)
+ rw [htId, ContinuousLinearMap.id_apply, real_inner_self_eq_norm_sq] at hh
+ rw [meanGram_energy_of_exact_normalization μ hQ U s hs A hA] at hh
+ simpa only [ContinuousLinearEquiv.symm_apply_apply] using hh
+ have hnorm : ‖(A : E →L[ℝ] E)‖ ≤ Real.sqrt B := by
+ apply ContinuousLinearMap.opNorm_le_bound _ (Real.sqrt_nonneg _)
+ intro v
+ have hh := hv v
+ have hp : 0 ≤ Real.sqrt B * ‖v‖ := mul_nonneg (Real.sqrt_nonneg _) (norm_nonneg _)
+ change ‖A v‖ ≤ Real.sqrt B * ‖v‖
+ apply (sq_le_sq₀ (norm_nonneg _) hp).mp
+ rwa [mul_pow, Real.sq_sqrt hB]
+ nlinarith [Real.sq_sqrt hB, norm_nonneg (A : E →L[ℝ] E)]
+
+omit [CompleteSpace E] in
+/-- The frame growth bound yields a bound for every transformed direction. -/
+theorem norm_apply_sq_le_of_norm_sq_le (A : E →L[ℝ] E) {B : ℝ}
+ (hA : ‖A‖ ^ 2 ≤ B) (v : E) : ‖A v‖ ^ 2 ≤ B * ‖v‖ ^ 2 := by
+ calc
+ _ ≤ (‖A‖ * ‖v‖) ^ 2 := pow_le_pow_left₀ (norm_nonneg _) (A.le_opNorm v) 2
+ _ = ‖A‖ ^ 2 * ‖v‖ ^ 2 := mul_pow _ _ _
+ _ ≤ _ := mul_le_mul_of_nonneg_right hA (sq_nonneg _)
+
+/-- A normalized working-scale mean gives polynomial growth of every
+smaller exact frame from the proved adjacent mean comparisons. -/
+theorem dyadic_normalizer_norm_sq_bound {K : ℝ} (m : ℕ) (hX : NoncollapsedRCD K (m + 1) X)
+ {a : ℝ} (ha : 0 ≤ a)
+ (hBG : BallVolumeComparison (hausdorff (m + 1) X) (comparisonModelVolume m a))
+ (u : Fin (m + 1) → SobolevSpace (hausdorff (m + 1) X) hX.quadratic)
+ (p : X) {r ε : ℝ} (hr : 0 < r) (hε : 0 ≤ ε)
+ (hsmall : ((m + 1 : ℕ) : ℝ) ^ 2 * (normalizationVolumeRatio m * ε) ≤ 1 / 2)
+ (A : Euclidean (m + 1) ≃L[ℝ] Euclidean (m + 1))
+ (hA : IsExactMeanNormalization (hausdorff (m + 1) X) hX.quadratic
+ (sobolevColumnMap (hausdorff (m + 1) X) hX.quadratic u) (ball p r) measurableSet_ball A)
+ (k : ℕ) (hscale : ∀ j ≤ k, a * (3 * (2 ^ j * r)) ≤ 1)
+ (hnormal : ∀ j ≤ k, ∃ (S : Euclidean (m + 1) ≃L[ℝ] Euclidean (m + 1))
+ (w : X → Euclidean (m + 1)),
+ FirstOrderSplittingOn (hausdorff (m + 1) X) hX.quadratic p (2 ^ j * r) ε
+ (transformedColumn (hausdorff (m + 1) X) hX.quadratic u S) w ∧
+ IsExactMeanNormalization (hausdorff (m + 1) X) hX.quadratic
+ (sobolevColumnMap (hausdorff (m + 1) X) hX.quadratic u)
+ (ball p (2 ^ j * r)) measurableSet_ball S)
+ (hroot : sobolevMeanGram (hausdorff (m + 1) X) hX.quadratic
+ (sobolevColumnMap (hausdorff (m + 1) X) hX.quadratic u)
+ (Metric.ball p (2 ^ k * r)) measurableSet_ball =
+ ContinuousLinearMap.id ℝ (Euclidean (m + 1))) :
+ ‖(A : Euclidean (m + 1) →L[ℝ] Euclidean (m + 1))‖ ^ 2 ≤ 2 ^ k := by
+ apply normalizer_norm_sq_le_of_mean_growth _ _ _ (Metric.ball p r)
+ (Metric.ball p (2 ^ k * r)) measurableSet_ball measurableSet_ball A hA hroot
+ (pow_nonneg (by norm_num) k)
+ intro v
+ simpa only [pow_zero, one_mul] using
+ (dyadic_mean_growth m hX ha hBG u p hr hε hsmall k hscale hnormal v).1
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/FirstFailingDyadicScale.lean b/lean/OAI/Geometry/RCD/Coordinates/FirstFailingDyadicScale.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ff05be0d97cbe084689209f43dd1e51b47a99131
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/FirstFailingDyadicScale.lean
@@ -0,0 +1,71 @@
+import OAI.Geometry.RCD.Coordinates.DyadicTransformationReduction
+
+namespace OAI
+
+/-! # The first failing exact normalization retains every preceding frame -/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.first_failing_dyadic_scale {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2 ≤ n)
+ (β : ℝ) (hβ : 0 < β) :
+ ∃ η : ℝ, 0 < η ∧ η ≤ 1 ∧ ∀ γ : ℝ, 0 ≤ γ → γ ≤ η →
+ ∀ (p : X) (R : ℝ), 0 < R → -1 ≤ K*(2*R)^2 →
+ ∀ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic) (v : X → Euclidean n),
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p (2*R) γ u v →
+ (∃ t : ℝ, 0 < t ∧ t ≤ R ∧ ¬∃ A : Euclidean n ≃L[ℝ] Euclidean n,
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p t β
+ (transformedColumn (hausdorff n X) hX.quadratic u A)
+ (fun x => (A : Euclidean n →L[ℝ] Euclidean n).adjoint (v x)) ∧
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u) (ball p t) measurableSet_ball A) →
+ ∃ d : ℕ,
+ (¬∃ A : Euclidean n ≃L[ℝ] Euclidean n,
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p (R/(2 : ℝ)^d) γ
+ (transformedColumn (hausdorff n X) hX.quadratic u A)
+ (fun x => (A : Euclidean n →L[ℝ] Euclidean n).adjoint (v x)) ∧
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u)
+ (ball p (R/(2 : ℝ)^d)) measurableSet_ball A) ∧
+ ∀ j < d, ∃ A : Euclidean n ≃L[ℝ] Euclidean n,
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p (R/(2 : ℝ)^j) γ
+ (transformedColumn (hausdorff n X) hX.quadratic u A)
+ (fun x => (A : Euclidean n →L[ℝ] Euclidean n).adjoint (v x)) ∧
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u)
+ (ball p (R/(2 : ℝ)^j)) measurableSet_ball A := by
+ classical
+ obtain ⟨η,hη,hη1,hall⟩ := hX.dyadic_splitting_implies_all_scales hn β hβ
+ refine ⟨η,hη,hη1,?_⟩
+ intro γ hγ hγη p R hR hK u v hfirst hbad
+ let Good : ℕ → Prop := fun j => ∃ A : Euclidean n ≃L[ℝ] Euclidean n,
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p (R/(2 : ℝ)^j) γ
+ (transformedColumn (hausdorff n X) hX.quadratic u A)
+ (fun x => (A : Euclidean n →L[ℝ] Euclidean n).adjoint (v x)) ∧
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u)
+ (ball p (R/(2 : ℝ)^j)) measurableSet_ball A
+ have hex : ∃ j, ¬Good j := by
+ by_contra hnot
+ have hg : ∀ j, Good j := by simpa only [not_exists,not_not] using hnot
+ obtain ⟨t,ht,htR,htbad⟩ := hbad
+ apply htbad
+ apply hall p R hR hK u v (hfirst.mono_error _ _ hγ hγη)
+ · intro j
+ obtain ⟨A,hA,_⟩ := hg j
+ exact ⟨A,hA.mono_error _ _ hγ hγη⟩
+ · exact ht
+ · exact htR
+ refine ⟨Nat.find hex,Nat.find_spec hex,?_⟩
+ intro j hj
+ exact not_not.mp (Nat.find_min hex hj)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/FirstFailingRootFrame.lean b/lean/OAI/Geometry/RCD/Coordinates/FirstFailingRootFrame.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0dd7c39340dc14b16ef8cc5ad8a00b4cfd3b5dc3
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/FirstFailingRootFrame.lean
@@ -0,0 +1,91 @@
+import OAI.Geometry.RCD.Coordinates.FirstFailingDyadicScale
+
+namespace OAI
+
+/-! # A genuine root frame and all ancestors at a first failing scale -/
+
+open Set Metric MeasureTheory
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem dyadic_ancestor_radius (R : ℝ) {d j : ℕ} (hj : j ≤ d) :
+ (2 : ℝ)^j*(R/(2 : ℝ)^d) = R/(2 : ℝ)^(d-j) := by
+ have hp : (2 : ℝ)^d = (2 : ℝ)^(d-j)*(2 : ℝ)^j := by
+ rw [← pow_add,Nat.sub_add_cancel hj]
+ rw [hp]
+ field_simp
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.first_failing_root_frame {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2 ≤ n)
+ (κ : ℝ) (hκ : 0 < κ) :
+ ∃ δ : ℝ, 0 < δ ∧ δ ≤ κ ∧ ∀ γ : ℝ, 0 ≤ γ → γ ≤ δ →
+ ∀ (p : X) (R : ℝ) (d : ℕ), 0 < R → 0 < d → -1 ≤ K*(2*R)^2 →
+ ∀ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic) (v : X → Euclidean n),
+ (∀ j < d, ∃ S : Euclidean n ≃L[ℝ] Euclidean n,
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p (R/(2 : ℝ)^j) γ
+ (transformedColumn (hausdorff n X) hX.quadratic u S)
+ (fun x => (S : Euclidean n →L[ℝ] Euclidean n).adjoint (v x)) ∧
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u)
+ (ball p (R/(2 : ℝ)^j)) measurableSet_ball S) →
+ ∃ A : Euclidean n ≃L[ℝ] Euclidean n,
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p (R/(2 : ℝ)^d) κ
+ (transformedColumn (hausdorff n X) hX.quadratic u A)
+ (fun x => (A : Euclidean n →L[ℝ] Euclidean n).adjoint (v x)) ∧
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u)
+ (ball p (R/(2 : ℝ)^d)) measurableSet_ball A ∧
+ ∀ j ≤ d, ∃ S : Euclidean n ≃L[ℝ] Euclidean n,
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p
+ ((2 : ℝ)^j*(R/(2 : ℝ)^d)) κ
+ (transformedColumn (hausdorff n X) hX.quadratic u S)
+ (fun x => (S : Euclidean n →L[ℝ] Euclidean n).adjoint (v x)) ∧
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u)
+ (ball p ((2 : ℝ)^j*(R/(2 : ℝ)^d))) measurableSet_ball S := by
+ obtain ⟨η,hη,hstep⟩ := hX.comparable_radius_splitting hn κ hκ
+ refine ⟨min η κ,lt_min hη hκ,min_le_right _ _,?_⟩
+ intro γ hγ hγδ p R d hR hd hK u v hbefore
+ let r := R/(2 : ℝ)^d
+ have hr : 0 < r := by dsimp only [r]; positivity
+ have hrR : r ≤ R := div_le_self hR.le (one_le_pow₀ (by norm_num))
+ have hrK : -1 ≤ K*(2*r)^2 := by
+ have hsq : (2*r)^2 ≤ (2*R)^2 :=
+ (sq_le_sq₀ (by positivity) (by positivity)).mpr (by linarith)
+ by_cases hK0 : 0 ≤ K
+ · exact (by norm_num : (-1 : ℝ) ≤ 0).trans (mul_nonneg hK0 (sq_nonneg _))
+ · exact hK.trans (mul_le_mul_of_nonpos_left hsq (le_of_not_ge hK0))
+ obtain ⟨S,hS,_⟩ := hbefore (d-1) (by omega)
+ have he : 2*r = R/(2 : ℝ)^(d-1) := by
+ simpa only [pow_one] using dyadic_ancestor_radius R (d:=d) (j:=1) hd
+ rw [← he] at hS
+ obtain ⟨B,hB,hBn⟩ := hstep p r hr hrK
+ (transformedColumn (hausdorff n X) hX.quadratic u S)
+ (fun x => (S : Euclidean n →L[ℝ] Euclidean n).adjoint (v x))
+ (hS.mono_error _ _ hγ (hγδ.trans (min_le_left _ _))) r (by linarith) le_rfl
+ let A := B.trans S
+ have hA := firstOrderSplitting_comp (hausdorff n X) hX.quadratic u S B v p r κ hB
+ have hAn := exact_mean_normalization_comp (hausdorff n X) hX.quadratic u S B
+ (ball p r) measurableSet_ball hBn
+ refine ⟨A,hA,hAn,?_⟩
+ intro j hj
+ by_cases hj0 : j = 0
+ · subst j
+ simpa only [pow_zero,one_mul] using (show ∃ S : Euclidean n ≃L[ℝ] Euclidean n,
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p r κ
+ (transformedColumn (hausdorff n X) hX.quadratic u S)
+ (fun x => (S : Euclidean n →L[ℝ] Euclidean n).adjoint (v x)) ∧
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u) (ball p r) measurableSet_ball S
+ from ⟨A,hA,hAn⟩)
+ · obtain ⟨T,hT,hTn⟩ := hbefore (d-j) (by omega)
+ rw [dyadic_ancestor_radius R hj]
+ exact ⟨T,hT.mono_error _ _ hγ (hγδ.trans (min_le_right _ _)),hTn⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/FirstFailingSequence.lean b/lean/OAI/Geometry/RCD/Coordinates/FirstFailingSequence.lean
new file mode 100644
index 0000000000000000000000000000000000000000..b4cb2b5fc8a347f10082ec699e3b5307a49c135c
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/FirstFailingSequence.lean
@@ -0,0 +1,108 @@
+import OAI.Geometry.RCD.Coordinates.DyadicRootEventualSplitting
+import OAI.Geometry.RCD.Coordinates.FirstFailingRootFrame
+import OAI.Geometry.RCD.Metric.CommonMeasuredApproximations
+import OAI.Geometry.RCD.Metric.DyadicFlatnessLimit
+
+namespace OAI
+
+/-! # A first failing dyadic scale contradicts the actual root estimates -/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.no_first_failing_sequence {K : ℝ} (m : ℕ) (hm : 2 ≤ m+1)
+ (hX : NoncollapsedRCD K (m+1) X) [(hausdorff (m+1) X).Regular]
+ {a κ : ℝ} (ha : 0 ≤ a)
+ (hBG : BallVolumeComparison (hausdorff (m+1) X) (comparisonModelVolume m a))
+ (hMeasured : LocalMeasuredCoordinateInput hX) (hκ : 0 < κ) (hκ1 : κ ≤ 1)
+ (hsmall : ((m+1 : ℕ) : ℝ)^2*(normalizationVolumeRatio m*κ) ≤ 1/2) :
+ ∃ γ₀ : ℝ, 0 < γ₀ ∧ ∀ γ : ℝ, 0 < γ → γ ≤ γ₀ →
+ ∀ (p : ℕ → X) (R ε : ℕ → ℝ) (d : ℕ → ℕ),
+ (∀ k, 0 < R k) → (∀ k, 2 ≤ d k) → Tendsto d atTop atTop →
+ (∀ k, -1 ≤ K*(2*R k)^2) →
+ (∀ δ : ℝ, 0 < δ → ∀ᶠ k in atTop, -δ ≤ K*(R k)^2) →
+ (∀ k, a*(3*R k) ≤ 1) → Tendsto ε atTop (𝓝 0) →
+ (∀ k, ∀ t : ℝ, 0 < t → t ≤ R k →
+ ∃ f : X → Euclidean (m+1), IsPointedApproximation (p k) 0 t 1 (ε k) f) →
+ ∀ (u : ℕ → Fin (m+1) → SobolevSpace (hausdorff (m+1) X) hX.quadratic)
+ (v : ℕ → X → Euclidean (m+1)),
+ (∀ k, FirstOrderSplittingOn (hausdorff (m+1) X) hX.quadratic (p k) (2*R k) (ε k) (u k) (v k)) →
+ (∀ k, ∀ j < d k, ∃ S : Euclidean (m+1) ≃L[ℝ] Euclidean (m+1),
+ FirstOrderSplittingOn (hausdorff (m+1) X) hX.quadratic (p k) (R k/(2 : ℝ)^j) γ
+ (transformedColumn (hausdorff (m+1) X) hX.quadratic (u k) S)
+ (fun x => (S : Euclidean (m+1) →L[ℝ] Euclidean (m+1)).adjoint (v k x)) ∧
+ IsExactMeanNormalization (hausdorff (m+1) X) hX.quadratic
+ (sobolevColumnMap (hausdorff (m+1) X) hX.quadratic (u k))
+ (ball (p k) (R k/(2 : ℝ)^j)) measurableSet_ball S) →
+ (∀ k, ¬∃ S : Euclidean (m+1) ≃L[ℝ] Euclidean (m+1),
+ FirstOrderSplittingOn (hausdorff (m+1) X) hX.quadratic (p k) (R k/(2 : ℝ)^(d k)) γ
+ (transformedColumn (hausdorff (m+1) X) hX.quadratic (u k) S)
+ (fun x => (S : Euclidean (m+1) →L[ℝ] Euclidean (m+1)).adjoint (v k x)) ∧
+ IsExactMeanNormalization (hausdorff (m+1) X) hX.quadratic
+ (sobolevColumnMap (hausdorff (m+1) X) hX.quadratic (u k))
+ (ball (p k) (R k/(2 : ℝ)^(d k))) measurableSet_ball S) → False := by
+ obtain ⟨γ₀,hγ₀,_,hroot⟩ := hX.first_failing_root_frame hm κ hκ
+ refine ⟨γ₀,hγ₀,?_⟩
+ intro γ hγ hγle p R ε d hR hd2 hd hK hKsmall hscale hε hflat u v hfirst hbefore hbad
+ let r := fun k => R k/(2 : ℝ)^(d k)
+ have hr (k : ℕ) : 0 < r k := div_pos (hR k) (by positivity)
+ have hrR (k : ℕ) : r k ≤ R k := div_le_self (hR k).le (one_le_pow₀ (by norm_num))
+ have hcurv_mono (k : ℕ) {s t : ℝ} (hs : 0 ≤ s) (hst : s ≤ t) :
+ K*t^2 ≤ K*s^2 ∨ 0 ≤ K*s^2 := by
+ by_cases hK0 : 0 ≤ K
+ · exact Or.inr (mul_nonneg hK0 (sq_nonneg _))
+ · exact Or.inl (mul_le_mul_of_nonpos_left (pow_le_pow_left₀ hs hst 2) (le_of_not_ge hK0))
+ have hc (k : ℕ) : -1 ≤ K*(r k)^2 := by
+ rcases hcurv_mono k (hr k).le (show r k ≤ 2*R k by linarith [hrR k,hR k]) with h | h
+ · exact (hK k).trans h
+ · linarith
+ have hc5 (k : ℕ) : -1 ≤ K*(5*r k)^2 := by
+ have hp : (4 : ℝ) ≤ (2 : ℝ)^(d k) := by
+ simpa only [show (2 : ℝ)^2=4 by norm_num] using
+ pow_le_pow_right₀ (by norm_num : (1:ℝ)≤2) (hd2 k)
+ have hrad : 5*r k ≤ 2*R k := by
+ have hh : r k*(2 : ℝ)^(d k)=R k := by dsimp only [r]; field_simp
+ nlinarith [mul_le_mul_of_nonneg_left hp (hr k).le,hr k]
+ rcases hcurv_mono k (mul_nonneg (by norm_num) (hr k).le) hrad with h | h
+ · exact (hK k).trans h
+ · linarith
+ have hcs : ∀ δ : ℝ, 0 < δ → ∀ᶠ k in atTop, -δ ≤ K*(r k)^2 := by
+ intro δ hδ
+ filter_upwards [hKsmall δ hδ] with k hk
+ rcases hcurv_mono k (hr k).le (hrR k) with h | h
+ · exact hk.trans h
+ · linarith
+ obtain ⟨ε',V,hε',hε'lim,hV⟩ := hMeasured.common_approximations hm p r hr hcs
+ (dyadic_flatness_limit p R ε d hR hd hε hflat)
+ choose A hAfirst hAn hframes using fun k =>
+ hroot γ hγ.le hγle (p k) (R k) (d k) (hR k) (by have := hd2 k; omega)
+ (hK k) (u k) (v k) (hbefore k)
+ have hRroot (k : ℕ) : (2 : ℝ)^(d k)*r k=R k := by dsimp only [r]; field_simp
+ have hscale' (k j : ℕ) (hj : j ≤ d k) : a*(3*((2 : ℝ)^j*r k)) ≤ 1 := by
+ have hjR : (2 : ℝ)^j*r k ≤ R k := by
+ dsimp only [r]
+ rw [dyadic_ancestor_radius (R k) hj]
+ exact div_le_self (hR k).le (one_le_pow₀ (by norm_num))
+ exact (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hjR (by norm_num)) ha).trans (hscale k)
+ have hΩ (k : ℕ) : ball (p k) ((2 : ℝ)^(d k)*r k) ⊆ ball (p k) (2*R k) := by
+ rw [hRroot]
+ exact ball_subset_ball (by linarith [hR k])
+ have hsplit := dyadic_root_eventual_splitting m hm hX ha hBG hκ.le hκ1 hsmall p r ε' d hr hd
+ hc hc5 (fun k => (hε' k).1.le) (fun k => (hε' k).2) hε'lim V hV u v A hAn hscale'
+ (fun k j hj => by
+ obtain ⟨S,hS,hSn⟩ := hframes k j hj
+ exact ⟨S,_,hS,hSn⟩)
+ (fun k => (hfirst k).continuous.mono (hΩ k))
+ (fun k i => ae_restrict_of_ae_restrict_of_subset (hΩ k) ((hfirst k).representative i))
+ (fun k i => ((hfirst k).harmonic i).mono _ _ (hΩ k)) γ hγ
+ obtain ⟨k,hk⟩ := hsplit.exists
+ exact hbad k ⟨A k,hk,hAn k⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/FirstOrderCoordinateDistance.lean b/lean/OAI/Geometry/RCD/Coordinates/FirstOrderCoordinateDistance.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0eb2c31c798b4e77329284360459acd344d88069
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/FirstOrderCoordinateDistance.lean
@@ -0,0 +1,84 @@
+import OAI.Geometry.RCD.Harmonic.NearbyGramColumn
+import OAI.Geometry.RCD.Harmonic.NearColumnDistance
+import OAI.Geometry.RCD.Coordinates.SplittingCoordinateLipschitz
+
+namespace OAI
+
+/-! # The original coordinates do not increase distance in the limit -/
+
+open Set Filter MeasureTheory Metric
+open scoped Topology NNReal InnerProductSpace
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.first_order_coordinate_distance {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2≤n) (hK : K≤0)
+ (p x y : ℕ → X) (r ε : ℕ → ℝ) (hr : ∀ k, 0 d.subsequence k+d.shift
+ have ha₀ : StrictMono a₀ := fun _ _ hij => Nat.add_lt_add_right (d.strictMono hij) d.shift
+ have hTS : T≤S := by linarith
+ have hnorm := hX.coordinate_target_norm_eventually hT hTS (p∘a₀) (r∘a₀) (ε∘a₀) (V∘a₀)
+ (fun k => hr (a₀ k)) (hεlim.comp ha₀.tendsto_atTop) (fun k => hV (a₀ k))
+ (fun k => d.target (d.subsequence k)) i (hc T hT hTR 1 zero_lt_one)
+ obtain ⟨N,hN⟩ := eventually_atTop.mp hnorm
+ let a₁ := fun k => a₀ (k+N)
+ have hadd : StrictMono (fun k : ℕ => k+N) := fun _ _ hij => Nat.add_lt_add_right hij N
+ have ha₁ : StrictMono a₁ := ha₀.comp hadd
+ obtain ⟨b,hb,hbV⟩ := inner_measured_subsequence hS hT hTS
+ (p:=p∘a₁) (r:=r∘a₁) (ε:=ε∘a₁) (V:=V∘a₁) (η:=fun k => 1/((k:ℝ)+1))
+ (fun k => hr (a₁ k)) (fun k => hε (a₁ k)) (fun k => hV (a₁ k))
+ (fun _ => (hX.finiteOnBounded _ isBounded_ball).ne)
+ (fun k => ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hS (hr (a₁ k)))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne)
+ (hεlim.comp ha₁.tendsto_atTop) (fun k => by positivity)
+ refine ⟨a₁∘b,ha₁.comp hb,(fun k => d.target (d.subsequence (b k+N))),hbV,?_,?_,?_⟩
+ · intro k
+ exact (d.harmonic (d.subsequence (b k+N))).mono (hausdorff n X) hX.quadratic
+ (ball_subset_ball (mul_le_mul_of_nonneg_right hTR.le (hr _).le))
+ · intro k
+ exact hN (b k+N) (Nat.le_add_left N (b k))
+ · intro W hW hWT δ hδ
+ exact (hadd.comp hb).tendsto_atTop.eventually (hc W hW (hWT.trans hTR) δ hδ)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/IntervalBilinearEnergy.lean b/lean/OAI/Geometry/RCD/Coordinates/IntervalBilinearEnergy.lean
new file mode 100644
index 0000000000000000000000000000000000000000..06bca05d9187502ee4ceefa865f71a07ed579f62
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/IntervalBilinearEnergy.lean
@@ -0,0 +1,51 @@
+import OAI.Geometry.RCD.Coordinates.PositiveBilinearIntegralLower
+import Mathlib.MeasureTheory.Integral.Bochner.Set
+import Mathlib.MeasureTheory.Measure.Lebesgue.Basic
+
+namespace OAI
+
+/-! # Real-time integrals of a bounded measurable Sobolev quadratic form -/
+
+open Set Filter MeasureTheory
+open scoped Topology ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+
+def intervalExtension {a b : ℝ} (f : Ioo a b → ℝ) (t : ℝ) : ℝ :=
+ if ht : t ∈ Ioo a b then f ⟨t,ht⟩ else 0
+
+theorem intervalExtension_eq {a b : ℝ} (f : Ioo a b → ℝ) (t : Ioo a b) :
+ intervalExtension f t = f t := by simp only [intervalExtension,dite_eq_left t.property]
+
+theorem integral_intervalExtension {a b : ℝ} (f : Ioo a b → ℝ) (θ : ℝ → ℝ) :
+ (∫ t in Ioo a b, θ t*intervalExtension f t) =
+ ∫ t : Ioo a b, θ t*f t ∂volume.comap Subtype.val := by
+ rw [← integral_subtype_comap measurableSet_Ioo (fun t => θ t*intervalExtension f t)]
+ apply integral_congr_ae
+ exact Eventually.of_forall fun t => by
+ change θ t*intervalExtension f t = θ t*f t
+ rw [intervalExtension_eq]
+
+theorem interval_bilinear_energy_integrable {E : Type*} [NormedAddCommGroup E]
+ [NormedSpace ℝ E] {a b : ℝ} (P : E →L[ℝ] E →L[ℝ] ℝ)
+ (v : Ioo a b → E) (hv : AEStronglyMeasurable v (volume.comap Subtype.val))
+ {C : ℝ} (hC : 0 ≤ C) (hb : ∀ t, ‖v t‖ ≤ C) :
+ IntegrableOn (intervalExtension (fun t => P (v t) (v t))) (Ioo a b) := by
+ have hfin : volume (Ioo a b) ≠ ∞ :=
+ ((measure_mono Ioo_subset_Icc_self).trans_lt isCompact_Icc.measure_lt_top).ne
+ have hi : IntegrableOn (fun _ : ℝ => (1:ℝ)) (Ioo a b) := integrableOn_const hfin
+ have hi' : Integrable (fun _ : Ioo a b => (1:ℝ)) (volume.comap Subtype.val) :=
+ (integrableOn_iff_comap_subtypeVal measurableSet_Ioo).mp hi
+ have hp : Integrable (fun t => P (v t) (v t)) (volume.comap Subtype.val) := by
+ have hh := hi'.mul_bdd (P.aestronglyMeasurable_comp₂ hv hv)
+ (Eventually.of_forall fun t => (P.le_opNorm₂ _ _).trans (show
+ ‖P‖*‖v t‖*‖v t‖ ≤ ‖P‖*C*C from by gcongr <;> exact hb t))
+ simpa only [one_mul] using hh
+ apply (integrableOn_iff_comap_subtypeVal measurableSet_Ioo).mpr
+ simpa only [Function.comp_def,intervalExtension_eq] using hp
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/IntervalVectorExtension.lean b/lean/OAI/Geometry/RCD/Coordinates/IntervalVectorExtension.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0e15c2edd5420439ebcb053d5496dea8b740159a
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/IntervalVectorExtension.lean
@@ -0,0 +1,52 @@
+import OAI.Geometry.RCD.Coordinates.IntervalBilinearEnergy
+import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic
+
+namespace OAI
+
+/-! # Integrating the actual Sobolev time family on the real line -/
+
+open Set Filter MeasureTheory
+open scoped Topology ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+
+def intervalVectorExtension {E : Type*} [Zero E] {a b : ℝ}
+ (u : Ioo a b → E) (t : ℝ) : E :=
+ if ht : t ∈ Ioo a b then u ⟨t,ht⟩ else 0
+
+theorem intervalVectorExtension_eq {E : Type*} [Zero E] {a b : ℝ}
+ (u : Ioo a b → E) (t : Ioo a b) : intervalVectorExtension u t = u t := by
+ simp only [intervalVectorExtension,dite_eq_left t.property]
+
+theorem intervalVectorExtension_integrable
+ {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {a b : ℝ}
+ (u : Ioo a b → E) (hu : AEStronglyMeasurable u (volume.comap Subtype.val))
+ {C : ℝ} (hb : ∀ t, ‖u t‖ ≤ C) : Integrable (intervalVectorExtension u) := by
+ have hfin : volume (Ioo a b) ≠ ∞ :=
+ ((measure_mono Ioo_subset_Icc_self).trans_lt isCompact_Icc.measure_lt_top).ne
+ have hi : Integrable (fun _ : Ioo a b => C) (volume.comap Subtype.val) :=
+ (integrableOn_iff_comap_subtypeVal measurableSet_Ioo).mp (integrableOn_const hfin)
+ have hiu : Integrable u (volume.comap Subtype.val) :=
+ hi.mono' hu (Eventually.of_forall hb)
+ have he : IntegrableOn (intervalVectorExtension u) (Ioo a b) := by
+ apply (integrableOn_iff_comap_subtypeVal measurableSet_Ioo).mpr
+ simpa only [Function.comp_def,intervalVectorExtension_eq] using hiu
+ apply (integrableOn_iff_integrable_of_support_subset ?_).mp he
+ intro t ht
+ by_contra hn
+ exact ht (by simp only [intervalVectorExtension,dite_eq_right hn])
+
+theorem bilinear_intervalVectorExtension
+ {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {a b : ℝ}
+ (P : E →L[ℝ] E →L[ℝ] ℝ) (u : Ioo a b → E) (t : ℝ) :
+ P (intervalVectorExtension u t) (intervalVectorExtension u t) =
+ intervalExtension (fun q => P (u q) (u q)) t := by
+ by_cases ht : t ∈ Ioo a b
+ · simp only [intervalVectorExtension,intervalExtension,dite_eq_left ht]
+ · simp only [intervalVectorExtension,intervalExtension,dite_eq_right ht,map_zero]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/InverseDerivative.lean b/lean/OAI/Geometry/RCD/Coordinates/InverseDerivative.lean
new file mode 100644
index 0000000000000000000000000000000000000000..951295e7bd9028625333828774381758f9c40541
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/InverseDerivative.lean
@@ -0,0 +1,138 @@
+import Mathlib.Analysis.Calculus.FDeriv.Mul
+import Mathlib.Analysis.InnerProductSpace.Adjoint
+import Mathlib.Tactic.Ring
+
+namespace OAI
+
+/-!
+# Inverse-transpose differentiation and contraction
+
+The metric iteration uses cancellation before estimating the derivative of
+an inverse transpose. These identities work with bounded operators on any
+real Hilbert space; no matrix coordinates or condition-number bounds enter
+the cancellation itself.
+-/
+
+noncomputable section
+
+open ContinuousLinearMap
+open scoped InnerProduct InnerProductSpace
+
+namespace RegularPointCoordinates
+
+variable {E X : Type*}
+variable [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+variable [NormedAddCommGroup X] [NormedSpace ℝ X]
+
+/-- The adjoint of the inverse of a bounded linear equivalence. -/
+def inverseTranspose (J : E ≃L[ℝ] E) : E →L[ℝ] E :=
+ (J.symm : E →L[ℝ] E).adjoint
+
+/-- The inverse transpose cancels the undifferentiated Jacobian in an inner product. -/
+theorem inner_apply_inverseTranspose (J : E ≃L[ℝ] E) (ξ w : E) :
+ ⟪J ξ, inverseTranspose J w⟫_ℝ = ⟪ξ, w⟫_ℝ := by
+ rw [inverseTranspose, adjoint_inner_right]
+ simp
+
+/-- The first variation of an inverse transpose. -/
+def inverseTransposeVariation (J : E ≃L[ℝ] E) (dJ : E →L[ℝ] E) : E →L[ℝ] E :=
+ -(inverseTranspose J ∘L dJ.adjoint ∘L inverseTranspose J)
+
+/-- Exact cancellation in the differentiated inverse-transpose term.
+This is the operator form of `re:inverse-transpose-contraction`. -/
+theorem inner_apply_inverseTransposeVariation (J : E ≃L[ℝ] E)
+ (dJ : E →L[ℝ] E) (ξ w : E) :
+ ⟪J ξ, inverseTransposeVariation J dJ w⟫_ℝ =
+ -⟪dJ ξ, inverseTranspose J w⟫_ℝ := by
+ simp only [inverseTransposeVariation, neg_apply, comp_apply, inner_neg_right]
+ rw [inner_apply_inverseTranspose, adjoint_inner_right]
+
+/-- The differentiated-inverse error is controlled by the diagonal
+Jacobian derivative, with no operator norm of that derivative. -/
+theorem abs_inner_apply_inverseTransposeVariation_le (J : E ≃L[ℝ] E)
+ (dJ : E →L[ℝ] E) (ξ w : E) :
+ |⟪J ξ, inverseTransposeVariation J dJ w⟫_ℝ| ≤
+ ‖dJ ξ‖ * ‖inverseTranspose J w‖ := by
+ rw [inner_apply_inverseTransposeVariation, abs_neg]
+ exact abs_real_inner_le_norm _ _
+
+/-- The exact metric increment splits into the principal term, the
+diagonal differentiated-inverse error, and the squared increment. -/
+theorem norm_sq_inverseTranspose_increment (J : E ≃L[ℝ] E)
+ (dJ : E →L[ℝ] E) (ξ dv v : E) :
+ ‖J ξ + (inverseTranspose J dv + inverseTransposeVariation J dJ v)‖ ^ 2 -
+ ‖J ξ‖ ^ 2 =
+ 2 * ⟪ξ, dv⟫_ℝ - 2 * ⟪dJ ξ, inverseTranspose J v⟫_ℝ +
+ ‖inverseTranspose J dv + inverseTransposeVariation J dJ v‖ ^ 2 := by
+ rw [norm_add_sq_real, inner_add_right, inner_apply_inverseTranspose,
+ inner_apply_inverseTransposeVariation]
+ ring
+
+/-- Fréchet derivative of inversion at a bounded linear equivalence. -/
+theorem hasFDerivAt_operator_inverse (J : E ≃L[ℝ] E) :
+ HasFDerivAt (Ring.inverse : (E →L[ℝ] E) → E →L[ℝ] E)
+ (-mulLeftRight ℝ (E →L[ℝ] E) (J.symm : E →L[ℝ] E)
+ (J.symm : E →L[ℝ] E)) (J : E →L[ℝ] E) := by
+ exact hasFDerivAt_ringInverse J.toUnit
+
+/-- The adjoint operation, viewed as a real continuous linear map. -/
+def adjointOperator : (E →L[ℝ] E) →L[ℝ] (E →L[ℝ] E) :=
+ ((ContinuousLinearMap.adjoint (𝕜 := ℝ) (E := E) (F := E)).toContinuousLinearEquiv).toContinuousLinearMap
+
+/-- The inverse-transpose operation on all bounded operators. Only its
+behavior at an invertible operator is used. -/
+def operatorInverseTranspose (J : E →L[ℝ] E) : E →L[ℝ] E :=
+ (Ring.inverse J).adjoint
+
+@[simp] theorem operatorInverseTranspose_equiv (J : E ≃L[ℝ] E) :
+ operatorInverseTranspose (J : E →L[ℝ] E) = inverseTranspose J := by
+ change (Ring.inverse (J.toUnit : E →L[ℝ] E)).adjoint = _
+ rw [Ring.inverse_unit]
+ rfl
+
+/-- Differentiating the inverse transpose of a varying Jacobian. -/
+theorem hasFDerivAt_operator_inverseTranspose (J : E ≃L[ℝ] E) :
+ HasFDerivAt (operatorInverseTranspose : (E →L[ℝ] E) → E →L[ℝ] E)
+ (adjointOperator ∘L
+ (-mulLeftRight ℝ (E →L[ℝ] E) (J.symm : E →L[ℝ] E)
+ (J.symm : E →L[ℝ] E))) (J : E →L[ℝ] E) := by
+ exact adjointOperator.hasFDerivAt.comp _ (hasFDerivAt_operator_inverse J)
+
+/-- The derivative above is exactly the inverse-transpose variation. -/
+theorem inverseTranspose_derivative_apply (J : E ≃L[ℝ] E) (dJ : E →L[ℝ] E) :
+ (adjointOperator ∘L
+ (-mulLeftRight ℝ (E →L[ℝ] E) (J.symm : E →L[ℝ] E)
+ (J.symm : E →L[ℝ] E))) dJ = inverseTransposeVariation J dJ := by
+ simp [adjointOperator, inverseTransposeVariation, inverseTranspose,
+ mulLeftRight_apply, mul_def, comp_assoc]
+
+/-- The cancellation for the actual directional Fréchet derivative of
+a variable inverse transpose. -/
+theorem inverseTranspose_fderiv_contraction
+ {J : X → E →L[ℝ] E} {J' : X →L[ℝ] (E →L[ℝ] E)} {x : X}
+ (e : E ≃L[ℝ] E) (he : J x = (e : E →L[ℝ] E))
+ (hJ : HasFDerivAt J J' x) (u : X) (ξ w : E) :
+ ⟪e ξ, (fderiv ℝ (fun y => operatorInverseTranspose (J y)) x u) w⟫_ℝ =
+ -⟪J' u ξ, inverseTranspose e w⟫_ℝ := by
+ have hi := hasFDerivAt_operator_inverseTranspose e
+ rw [← he] at hi
+ have hd := (hi.comp x hJ).fderiv
+ change fderiv ℝ (fun y => operatorInverseTranspose (J y)) x = _ at hd
+ rw [hd, comp_apply, inverseTranspose_derivative_apply]
+ exact inner_apply_inverseTransposeVariation e (J' u) ξ w
+
+/-- The same diagonal bound for the actual directional derivative. -/
+theorem abs_inverseTranspose_fderiv_contraction_le
+ {J : X → E →L[ℝ] E} {J' : X →L[ℝ] (E →L[ℝ] E)} {x : X}
+ (e : E ≃L[ℝ] E) (he : J x = (e : E →L[ℝ] E))
+ (hJ : HasFDerivAt J J' x) (u : X) (ξ w : E) :
+ |⟪e ξ, (fderiv ℝ (fun y => operatorInverseTranspose (J y)) x u) w⟫_ℝ| ≤
+ ‖J' u ξ‖ * ‖inverseTranspose e w‖ := by
+ rw [inverseTranspose_fderiv_contraction e he hJ, abs_neg]
+ exact abs_real_inner_le_norm _ _
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/InverseJetBounds.lean b/lean/OAI/Geometry/RCD/Coordinates/InverseJetBounds.lean
new file mode 100644
index 0000000000000000000000000000000000000000..58e3a175da718e660c555ab2c689ba6a3450a1ed
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/InverseJetBounds.lean
@@ -0,0 +1,431 @@
+import OAI.Geometry.RCD.Coordinates.FactorialMajorant
+import OAI.Geometry.RCD.Coordinates.InverseDerivative
+import Mathlib.Analysis.Calculus.ContDiff.Bounds
+
+namespace OAI
+
+/-!
+# Higher derivatives of inverse fields
+
+The resolvent identity subtracts the value of the original field at the
+base point before the higher product estimate is applied. Its zeroth
+derivative is then zero, so the inverse recurrence has no occurrence of
+the current unknown derivative on the right. These are actual iterated
+Fréchet derivatives in a real Banach algebra, including bounded operators.
+-/
+
+open Finset Filter
+open scoped BigOperators ContDiff Topology
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {X A : Type*} [NormedAddCommGroup X] [NormedSpace ℝ X]
+variable [NormedRing A] [NormedAlgebra ℝ A]
+
+omit [NormedAddCommGroup X] [NormedSpace ℝ X] [NormedAlgebra ℝ A] in
+/-- The resolvent identity in the order needed for a one-sided inverse. -/
+theorem inverse_field_resolvent {J K : X → A} {s : Set X} {x : X}
+ (hleft : K x * J x = 1)
+ (hright : ∀ y ∈ s, J y * K y = 1) :
+ Set.EqOn K (fun y => K x - K x * ((J y - J x) * K y)) s := by
+ intro y hy
+ change K y = K x - K x * ((J y - J x) * K y)
+ rw [sub_mul, mul_sub, hright y hy, mul_one,
+ ← mul_assoc (K x) (J x) (K y), hleft, one_mul]
+ abel
+
+/-- At positive orders, subtracting the value at the base point does not
+change the iterated derivative. -/
+theorem iteratedFDerivWithin_sub_basepoint {J : X → A} {s : Set X} {x : X}
+ {n : ℕ} (hJ : ContDiffWithinAt ℝ n J s x)
+ (hs : UniqueDiffOn ℝ s) (hx : x ∈ s) (hn : n ≠ 0) :
+ iteratedFDerivWithin ℝ n (fun y => J y - J x) s x =
+ iteratedFDerivWithin ℝ n J s x := by
+ rw [show (fun y => J y - J x) = J - (fun _ => J x) from rfl,
+ iteratedFDerivWithin_sub_apply hJ contDiffWithinAt_const hs hx,
+ iteratedFDerivWithin_const_of_ne hn]
+ simp
+
+/-- A higher inverse derivative is bounded by strictly lower inverse
+derivatives. The smoothness and inverse identities are explicit. -/
+theorem norm_iteratedFDerivWithin_inverse_field_le
+ {J K : X → A} {s : Set X} {x : X} {n : ℕ}
+ (hJ : ContDiffOn ℝ n J s) (hK : ContDiffOn ℝ n K s)
+ (hs : UniqueDiffOn ℝ s) (hx : x ∈ s) (hn : 0 < n)
+ (hleft : K x * J x = 1) (hright : ∀ y ∈ s, J y * K y = 1) :
+ ‖iteratedFDerivWithin ℝ n K s x‖ ≤ ‖K x‖ *
+ ∑ i ∈ Finset.Icc 1 n, (n.choose i : ℝ) *
+ ‖iteratedFDerivWithin ℝ i J s x‖ *
+ ‖iteratedFDerivWithin ℝ (n - i) K s x‖ := by
+ let f : X → A := fun y => J y - J x
+ let g : X → A := fun y => f y * K y
+ let L : A →L[ℝ] A := ContinuousLinearMap.mul ℝ A (K x)
+ have hf : ContDiffOn ℝ n f s := hJ.sub contDiffOn_const
+ have hg : ContDiffOn ℝ n g s := hf.mul hK
+ have hLg : ContDiffOn ℝ n (L ∘ g) s := L.contDiff.comp_contDiffOn hg
+ have hres : Set.EqOn K ((fun _ => K x) - (L ∘ g)) s :=
+ inverse_field_resolvent hleft hright
+ have hnorm : ‖iteratedFDerivWithin ℝ n K s x‖ ≤
+ ‖K x‖ * ‖iteratedFDerivWithin ℝ n g s x‖ := by
+ rw [iteratedFDerivWithin_congr hres hx n,
+ iteratedFDerivWithin_sub_apply contDiffWithinAt_const (hLg x hx) hs hx,
+ iteratedFDerivWithin_const_of_ne (Nat.ne_of_gt hn)]
+ simp only [Pi.zero_apply, zero_sub, norm_neg]
+ exact (L.norm_iteratedFDerivWithin_comp_left (hg x hx) hs hx le_rfl).trans
+ (mul_le_mul_of_nonneg_right (ContinuousLinearMap.opNorm_mul_apply_le ℝ A (K x))
+ (norm_nonneg _))
+ have hsum :
+ (∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) *
+ ‖iteratedFDerivWithin ℝ i f s x‖ *
+ ‖iteratedFDerivWithin ℝ (n - i) K s x‖) =
+ ∑ i ∈ Finset.Icc 1 n, (n.choose i : ℝ) *
+ ‖iteratedFDerivWithin ℝ i J s x‖ *
+ ‖iteratedFDerivWithin ℝ (n - i) K s x‖ := by
+ symm
+ calc
+ _ = ∑ i ∈ Finset.Icc 1 n, (n.choose i : ℝ) *
+ ‖iteratedFDerivWithin ℝ i f s x‖ *
+ ‖iteratedFDerivWithin ℝ (n - i) K s x‖ := by
+ apply Finset.sum_congr rfl
+ intro i hi
+ rw [iteratedFDerivWithin_sub_basepoint
+ ((hJ x hx).of_le (by exact_mod_cast (Finset.mem_Icc.mp hi).2)) hs hx
+ (by have := (Finset.mem_Icc.mp hi).1; omega)]
+ _ = _ := by
+ apply Finset.sum_subset
+ · intro i hi
+ exact Finset.mem_range.mpr (by have := (Finset.mem_Icc.mp hi).2; omega)
+ · intro i hi hnot
+ have hi0 : i = 0 := by
+ have := Finset.mem_range.mp hi
+ simp only [Finset.mem_Icc, not_and_or, not_le] at hnot
+ omega
+ subst i
+ simp [norm_iteratedFDerivWithin_zero, f]
+ exact hnorm.trans (mul_le_mul_of_nonneg_left
+ ((norm_iteratedFDerivWithin_mul_le hf hK hs hx le_rfl).trans_eq hsum)
+ (norm_nonneg _))
+
+/-- A unit-valued smooth field has a smooth inverse field on the same set. -/
+theorem contDiffOn_ringInverse_field [CompleteSpace A]
+ {J : X → A} {s : Set X} {n : ℕ∞ω}
+ (hJ : ContDiffOn ℝ n J s) (hunit : ∀ y ∈ s, IsUnit (J y)) :
+ ContDiffOn ℝ n (fun y => Ring.inverse (J y)) s := by
+ intro y hy
+ obtain ⟨u, hu⟩ := hunit y hy
+ have hi := contDiffAt_ringInverse ℝ (n := n) u
+ rw [hu] at hi
+ exact hi.comp_contDiffWithinAt y (hJ y hy)
+
+/-- The preceding recurrence for the genuine inverse in a Banach algebra. -/
+theorem norm_iteratedFDerivWithin_ringInverse_le [CompleteSpace A]
+ {J : X → A} {s : Set X} {x : X} {n : ℕ}
+ (hJ : ContDiffOn ℝ n J s) (hunit : ∀ y ∈ s, IsUnit (J y))
+ (hs : UniqueDiffOn ℝ s) (hx : x ∈ s) (hn : 0 < n) :
+ ‖iteratedFDerivWithin ℝ n (fun y => Ring.inverse (J y)) s x‖ ≤
+ ‖Ring.inverse (J x)‖ * ∑ i ∈ Finset.Icc 1 n, (n.choose i : ℝ) *
+ ‖iteratedFDerivWithin ℝ i J s x‖ *
+ ‖iteratedFDerivWithin ℝ (n - i) (fun y => Ring.inverse (J y)) s x‖ := by
+ exact norm_iteratedFDerivWithin_inverse_field_le hJ
+ (contDiffOn_ringInverse_field hJ hunit) hs hx hn
+ (Ring.inverse_mul_cancel _ (hunit x hx))
+ (fun y hy => Ring.mul_inverse_cancel _ (hunit y hy))
+
+/-- The pointwise recurrence requires invertibility only at the base
+point: continuity supplies an invertible neighborhood. -/
+theorem norm_iteratedFDeriv_ringInverse_le [CompleteSpace A]
+ {J : X → A} {x : X} {n : ℕ}
+ (hJ : ContDiffAt ℝ n J x) (hunit : IsUnit (J x)) (hn : 0 < n) :
+ ‖iteratedFDeriv ℝ n (fun y => Ring.inverse (J y)) x‖ ≤
+ ‖Ring.inverse (J x)‖ * ∑ i ∈ Finset.Icc 1 n, (n.choose i : ℝ) *
+ ‖iteratedFDeriv ℝ i J x‖ *
+ ‖iteratedFDeriv ℝ (n - i) (fun y => Ring.inverse (J y)) x‖ := by
+ obtain ⟨u, hu, hJu⟩ := hJ.contDiffOn le_rfl (by simp)
+ have hv : {y | IsUnit (J y)} ∈ nhds x :=
+ hJ.continuousAt.preimage_mem_nhds (Units.isOpen.mem_nhds hunit)
+ obtain ⟨s, hsu, hs, hx⟩ := mem_nhds_iff.mp (inter_mem hu hv)
+ have hJs : ContDiffOn ℝ n J s := hJu.mono (fun y hy => (hsu hy).1)
+ have hus : ∀ y ∈ s, IsUnit (J y) := fun y hy => (hsu hy).2
+ have h := norm_iteratedFDerivWithin_ringInverse_le hJs hus hs.uniqueDiffOn hx hn
+ have heq (m : ℕ) (f : X → A) : iteratedFDerivWithin ℝ m f s x =
+ iteratedFDeriv ℝ m f x := iteratedFDerivWithin_of_isOpen m hs hx
+ simpa only [heq] using h
+
+/-- Exponential and factorial scaling for the coefficient of order `m`. -/
+def jetCoefficientScale (B : ℝ) (m : ℕ) : ℝ :=
+ B ^ m * (m.factorial : ℝ)
+
+theorem jetCoefficientScale_pos {B : ℝ} (hB : 0 < B) (m : ℕ) :
+ 0 < jetCoefficientScale B m := by
+ unfold jetCoefficientScale
+ positivity
+
+@[simp] theorem jetCoefficientScale_zero (B : ℝ) : jetCoefficientScale B 0 = 1 := by
+ simp [jetCoefficientScale]
+
+/-- Binomial coefficients exactly cancel the factorial scaling; there
+is no loss in the exponential base. -/
+theorem choose_mul_jetCoefficientScale {B : ℝ} {m i : ℕ} (hi : i ≤ m) :
+ (m.choose i : ℝ) * jetCoefficientScale B i * jetCoefficientScale B (m - i) =
+ jetCoefficientScale B m := by
+ have hfactorial : (m.choose i : ℝ) * (i.factorial : ℝ) *
+ ((m - i).factorial : ℝ) = (m.factorial : ℝ) := by
+ exact_mod_cast Nat.choose_mul_factorial_mul_factorial hi
+ have hp : B ^ i * B ^ (m - i) = B ^ m := by
+ rw [← pow_add, Nat.add_sub_of_le hi]
+ unfold jetCoefficientScale
+ calc
+ _ = ((m.choose i : ℝ) * (i.factorial : ℝ) * ((m - i).factorial : ℝ)) *
+ (B ^ i * B ^ (m - i)) := by ring
+ _ = _ := by rw [hfactorial, hp]; ring
+
+/-- A binomial inverse recurrence becomes the convolution recurrence
+after division by its exact exponential-factorial scaling. -/
+theorem normalized_inverse_jet_recurrence {B H : ℝ} {j k : ℕ → ℝ}
+ (hB : 0 < B) (hH : 0 ≤ H) (hk : ∀ m, 0 ≤ k m)
+ (hj : ∀ m, 0 < m → j m ≤ factorialMajorant m * jetCoefficientScale B m)
+ (hrec : ∀ m, 0 < m → k m ≤ H * ∑ i ∈ Finset.Icc 1 m,
+ (m.choose i : ℝ) * j i * k (m - i))
+ {m : ℕ} (hm : 0 < m) :
+ k m / jetCoefficientScale B m ≤ H * ∑ i ∈ Finset.Icc 1 m,
+ factorialMajorant i * (k (m - i) / jetCoefficientScale B (m - i)) := by
+ apply (div_le_iff₀ (jetCoefficientScale_pos hB m)).mpr
+ calc
+ _ ≤ H * ∑ i ∈ Finset.Icc 1 m, (m.choose i : ℝ) * j i * k (m - i) := hrec m hm
+ _ ≤ H * ∑ i ∈ Finset.Icc 1 m, jetCoefficientScale B m *
+ (factorialMajorant i * (k (m - i) / jetCoefficientScale B (m - i))) := by
+ apply mul_le_mul_of_nonneg_left _ hH
+ apply Finset.sum_le_sum
+ intro i hi
+ have hi' := Finset.mem_Icc.mp hi
+ have hkm : 0 ≤ k (m - i) := hk (m - i)
+ calc
+ _ ≤ (m.choose i : ℝ) * (factorialMajorant i * jetCoefficientScale B i) *
+ k (m - i) := by
+ gcongr
+ exact hj i (by omega)
+ _ = _ := by
+ rw [← choose_mul_jetCoefficientScale (B := B) hi'.2]
+ field_simp [ne_of_gt (jetCoefficientScale_pos hB (m - i))]
+ _ = _ := by rw [← Finset.mul_sum]; ring
+
+/-- The normalized inverse recurrence has the form required by the
+factorial majorant, including its zeroth-order endpoint. -/
+theorem normalized_inverse_jet_hasMajorant {B D : ℝ} {j k : ℕ → ℝ}
+ (hB : 0 < B) (hD : 0 ≤ D) (hk : ∀ m, 0 ≤ k m)
+ (hkzero : k 0 ≤ Real.sqrt D)
+ (hj : ∀ m, 0 < m → j m ≤ factorialMajorant m * jetCoefficientScale B m)
+ (hrec : ∀ m, 0 < m → k m ≤ Real.sqrt D * ∑ i ∈ Finset.Icc 1 m,
+ (m.choose i : ℝ) * j i * k (m - i)) :
+ HasInverseMajorantRecurrence factorialMajorant
+ (fun m => k m / jetCoefficientScale B m) D := by
+ intro m hm
+ have hsplit : Finset.Icc 1 m = insert m (Finset.Icc 1 (m - 1)) := by
+ ext i
+ simp only [Finset.mem_Icc, Finset.mem_insert]
+ omega
+ have hmnot : m ∉ Finset.Icc 1 (m - 1) := by simp; omega
+ have h := normalized_inverse_jet_recurrence hB (Real.sqrt_nonneg D) hk hj hrec hm
+ rw [hsplit, Finset.sum_insert hmnot, Nat.sub_self, jetCoefficientScale_zero, div_one] at h
+ calc
+ _ ≤ Real.sqrt D * (factorialMajorant m * k 0 +
+ ∑ i ∈ Finset.Icc 1 (m - 1),
+ factorialMajorant i * (k (m - i) / jetCoefficientScale B (m - i))) := h
+ _ ≤ D * factorialMajorant m + Real.sqrt D *
+ ∑ i ∈ Finset.Icc 1 (m - 1),
+ factorialMajorant i * (k (m - i) / jetCoefficientScale B (m - i)) := by
+ have he := mul_le_mul_of_nonneg_left hkzero
+ (mul_nonneg (Real.sqrt_nonneg D) (factorialMajorant_pos m).le)
+ have hsq : Real.sqrt D * factorialMajorant m * Real.sqrt D =
+ D * factorialMajorant m := by
+ calc
+ _ = Real.sqrt D ^ 2 * factorialMajorant m := by ring
+ _ = _ := by rw [Real.sq_sqrt hD]
+ nlinarith
+
+/-- Uniform inverse bounds for every order, with exactly the original
+exponential base and one order-independent constant. -/
+theorem inverse_jet_uniform_bound {D : ℝ} (hD : 1 ≤ D) :
+ ∃ C : ℝ, Real.sqrt D ≤ C ∧ 2 * D ≤ C ∧ ∀ B : ℝ, 0 < B → ∀ j k : ℕ → ℝ,
+ (∀ m, 0 ≤ k m) → k 0 ≤ Real.sqrt D →
+ (∀ m, 0 < m → j m ≤ factorialMajorant m * jetCoefficientScale B m) →
+ (∀ m, 0 < m → k m ≤ Real.sqrt D * ∑ i ∈ Finset.Icc 1 m,
+ (m.choose i : ℝ) * j i * k (m - i)) →
+ ∀ m, k m ≤ C * factorialMajorant m * jetCoefficientScale B m := by
+ obtain ⟨C, hC0, hCD, hC⟩ := factorial_inverse_coefficients_uniform_bound hD
+ refine ⟨C, hC0, hCD, ?_⟩
+ intro B hB j k hk hkzero hj hrec m
+ have ha0 : k 0 / jetCoefficientScale B 0 ≤ Real.sqrt D := by simpa using hkzero
+ have hbound := hC (fun m => k m / jetCoefficientScale B m) ha0
+ (normalized_inverse_jet_hasMajorant hB (zero_le_one.trans hD) hk hkzero hj hrec) m
+ exact (div_le_iff₀ (jetCoefficientScale_pos hB m)).mp hbound
+
+/-- Applying a field of operators preserves the same factorial weights.
+This is the product estimate used for the coordinate increment. -/
+theorem clm_apply_factorialMajorant_bound
+ {F G : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F]
+ [NormedAddCommGroup G] [NormedSpace ℝ G]
+ {f : X → F →L[ℝ] G} {g : X → F} {s : Set X} {x : X}
+ {B C D : ℝ} {m : ℕ} (hB : 0 < B) (hC : 0 ≤ C) (hD : 0 ≤ D)
+ (hf : ContDiffOn ℝ m f s) (hg : ContDiffOn ℝ m g s)
+ (hs : UniqueDiffOn ℝ s) (hx : x ∈ s)
+ (hfbound : ∀ i, i ≤ m → ‖iteratedFDerivWithin ℝ i f s x‖ ≤
+ C * factorialMajorant i * jetCoefficientScale B i)
+ (hgbound : ∀ i, i ≤ m → ‖iteratedFDerivWithin ℝ i g s x‖ ≤
+ D * factorialMajorant i * jetCoefficientScale B i) :
+ ‖iteratedFDerivWithin ℝ m (fun y => f y (g y)) s x‖ ≤
+ (10 * C * D) * factorialMajorant m * jetCoefficientScale B m := by
+ calc
+ _ ≤ ∑ i ∈ Finset.range (m + 1), (m.choose i : ℝ) *
+ ‖iteratedFDerivWithin ℝ i f s x‖ *
+ ‖iteratedFDerivWithin ℝ (m - i) g s x‖ :=
+ norm_iteratedFDerivWithin_clm_apply hf hg hs hx le_rfl
+ _ ≤ ∑ i ∈ Finset.range (m + 1),
+ (C * D * jetCoefficientScale B m) *
+ (factorialMajorant i * factorialMajorant (m - i)) := by
+ apply Finset.sum_le_sum
+ intro i hi
+ have hi' : i ≤ m := by have := Finset.mem_range.mp hi; omega
+ calc
+ _ ≤ (m.choose i : ℝ) *
+ (C * factorialMajorant i * jetCoefficientScale B i) *
+ (D * factorialMajorant (m - i) * jetCoefficientScale B (m - i)) := by
+ apply mul_le_mul
+ · exact mul_le_mul_of_nonneg_left (hfbound i hi') (Nat.cast_nonneg _)
+ · exact hgbound (m - i) (Nat.sub_le _ _)
+ · exact norm_nonneg _
+ · exact mul_nonneg (Nat.cast_nonneg _)
+ (mul_nonneg (mul_nonneg hC (factorialMajorant_pos i).le)
+ (jetCoefficientScale_pos hB i).le)
+ _ = _ := by rw [← choose_mul_jetCoefficientScale (B := B) hi']; ring
+ _ = (C * D * jetCoefficientScale B m) *
+ ∑ i ∈ Finset.range (m + 1), factorialMajorant i * factorialMajorant (m - i) := by
+ rw [Finset.mul_sum]
+ _ ≤ (C * D * jetCoefficientScale B m) * (10 * factorialMajorant m) :=
+ mul_le_mul_of_nonneg_left (factorialMajorant_full_convolution_le m)
+ (mul_nonneg (mul_nonneg hC hD) (jetCoefficientScale_pos hB m).le)
+ _ = _ := by ring
+
+/-- Actual higher derivatives of the inverse of a unit-valued Banach
+algebra field satisfy the factorial majorant without changing `B`.
+The same constant works for every field, set, and base point. -/
+theorem ringInverse_iteratedFDerivWithin_uniform_bound [CompleteSpace A]
+ {D : ℝ} (hD : 1 ≤ D) :
+ ∃ C : ℝ, Real.sqrt D ≤ C ∧ 2 * D ≤ C ∧
+ ∀ (B : ℝ), 0 < B → ∀ (J : X → A) (s : Set X) (x : X),
+ (∀ m : ℕ, ContDiffOn ℝ m J s) → (∀ y ∈ s, IsUnit (J y)) →
+ UniqueDiffOn ℝ s → x ∈ s → ‖Ring.inverse (J x)‖ ≤ Real.sqrt D →
+ (∀ m, 0 < m → ‖iteratedFDerivWithin ℝ m J s x‖ ≤
+ factorialMajorant m * jetCoefficientScale B m) →
+ ∀ m, ‖iteratedFDerivWithin ℝ m (fun y => Ring.inverse (J y)) s x‖ ≤
+ C * factorialMajorant m * jetCoefficientScale B m := by
+ obtain ⟨C, hC0, hCD, hC⟩ := inverse_jet_uniform_bound hD
+ refine ⟨C, hC0, hCD, ?_⟩
+ intro B hB J s x hJ hunit hs hx hInv hbound
+ apply hC B hB (fun m => ‖iteratedFDerivWithin ℝ m J s x‖)
+ (fun m => ‖iteratedFDerivWithin ℝ m (fun y => Ring.inverse (J y)) s x‖)
+ · exact fun _ => norm_nonneg _
+ · simpa only [norm_iteratedFDerivWithin_zero] using hInv
+ · exact hbound
+ · intro m hm
+ apply (norm_iteratedFDerivWithin_ringInverse_le (hJ m) hunit hs hx hm).trans
+ apply mul_le_mul_of_nonneg_right hInv
+ apply Finset.sum_nonneg
+ intro i _
+ positivity
+
+/-- Pointwise form of the manuscript's inverse majorant: only smoothness
+and invertibility at the point are assumed, and the constant is uniform
+in both the order and the exponential base. -/
+theorem ringInverse_iteratedFDeriv_uniform_bound [CompleteSpace A]
+ {D : ℝ} (hD : 1 ≤ D) :
+ ∃ C : ℝ, Real.sqrt D ≤ C ∧ 2 * D ≤ C ∧
+ ∀ (B : ℝ), 0 < B → ∀ (J : X → A) (x : X),
+ (∀ m : ℕ, ContDiffAt ℝ m J x) → IsUnit (J x) →
+ ‖Ring.inverse (J x)‖ ≤ Real.sqrt D →
+ (∀ m, 0 < m → ‖iteratedFDeriv ℝ m J x‖ ≤
+ factorialMajorant m * jetCoefficientScale B m) →
+ ∀ m, ‖iteratedFDeriv ℝ m (fun y => Ring.inverse (J y)) x‖ ≤
+ C * factorialMajorant m * jetCoefficientScale B m := by
+ obtain ⟨C, hC0, hCD, hC⟩ := inverse_jet_uniform_bound hD
+ refine ⟨C, hC0, hCD, ?_⟩
+ intro B hB J x hJ hunit hInv hbound
+ apply hC B hB (fun m => ‖iteratedFDeriv ℝ m J x‖)
+ (fun m => ‖iteratedFDeriv ℝ m (fun y => Ring.inverse (J y)) x‖)
+ · exact fun _ => norm_nonneg _
+ · simpa only [norm_iteratedFDeriv_zero] using hInv
+ · exact hbound
+ · intro m hm
+ apply (norm_iteratedFDeriv_ringInverse_le (hJ m) hunit hm).trans
+ apply mul_le_mul_of_nonneg_right hInv
+ apply Finset.sum_nonneg
+ intro i _
+ positivity
+
+section InverseTranspose
+
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+
+/-- Taking the transpose preserves every iterated derivative norm. -/
+theorem norm_iteratedFDerivWithin_inverseTranspose
+ (J : X → E →L[ℝ] E) {s : Set X} {x : X}
+ (hs : UniqueDiffOn ℝ s) (hx : x ∈ s) (m : ℕ) :
+ ‖iteratedFDerivWithin ℝ m (fun y => operatorInverseTranspose (J y)) s x‖ =
+ ‖iteratedFDerivWithin ℝ m (fun y => Ring.inverse (J y)) s x‖ := by
+ let adj : (E →L[ℝ] E) ≃ₗᵢ[ℝ] (E →L[ℝ] E) := ContinuousLinearMap.adjoint
+ exact adj.norm_iteratedFDerivWithin_comp_left (fun y => Ring.inverse (J y)) hs hx m
+
+theorem norm_iteratedFDeriv_inverseTranspose
+ (J : X → E →L[ℝ] E) (x : X) (m : ℕ) :
+ ‖iteratedFDeriv ℝ m (fun y => operatorInverseTranspose (J y)) x‖ =
+ ‖iteratedFDeriv ℝ m (fun y => Ring.inverse (J y)) x‖ := by
+ let adj : (E →L[ℝ] E) ≃ₗᵢ[ℝ] (E →L[ℝ] E) := ContinuousLinearMap.adjoint
+ exact adj.norm_iteratedFDeriv_comp_left (fun y => Ring.inverse (J y)) x m
+
+/-- The all-order inverse-transpose estimate uses the same constant and
+the same exponential base as the inverse estimate. -/
+theorem inverseTranspose_iteratedFDerivWithin_uniform_bound
+ {D : ℝ} (hD : 1 ≤ D) :
+ ∃ C : ℝ, Real.sqrt D ≤ C ∧ 2 * D ≤ C ∧
+ ∀ (B : ℝ), 0 < B → ∀ (J : X → E →L[ℝ] E) (s : Set X) (x : X),
+ (∀ m : ℕ, ContDiffOn ℝ m J s) → (∀ y ∈ s, IsUnit (J y)) →
+ UniqueDiffOn ℝ s → x ∈ s → ‖Ring.inverse (J x)‖ ≤ Real.sqrt D →
+ (∀ m, 0 < m → ‖iteratedFDerivWithin ℝ m J s x‖ ≤
+ factorialMajorant m * jetCoefficientScale B m) →
+ ∀ m, ‖iteratedFDerivWithin ℝ m (fun y => operatorInverseTranspose (J y)) s x‖ ≤
+ C * factorialMajorant m * jetCoefficientScale B m := by
+ obtain ⟨C, hC0, hCD, hC⟩ :=
+ ringInverse_iteratedFDerivWithin_uniform_bound (X := X) (A := E →L[ℝ] E) hD
+ refine ⟨C, hC0, hCD, ?_⟩
+ intro B hB J s x hJ hunit hs hx hInv hbound m
+ rw [norm_iteratedFDerivWithin_inverseTranspose J hs hx m]
+ exact hC B hB J s x hJ hunit hs hx hInv hbound m
+
+/-- Pointwise inverse-transpose majorant, with the same constant as the
+inverse and no loss of exponential base. -/
+theorem inverseTranspose_iteratedFDeriv_uniform_bound
+ {D : ℝ} (hD : 1 ≤ D) :
+ ∃ C : ℝ, Real.sqrt D ≤ C ∧ 2 * D ≤ C ∧
+ ∀ (B : ℝ), 0 < B → ∀ (J : X → E →L[ℝ] E) (x : X),
+ (∀ m : ℕ, ContDiffAt ℝ m J x) → IsUnit (J x) →
+ ‖Ring.inverse (J x)‖ ≤ Real.sqrt D →
+ (∀ m, 0 < m → ‖iteratedFDeriv ℝ m J x‖ ≤
+ factorialMajorant m * jetCoefficientScale B m) →
+ ∀ m, ‖iteratedFDeriv ℝ m (fun y => operatorInverseTranspose (J y)) x‖ ≤
+ C * factorialMajorant m * jetCoefficientScale B m := by
+ obtain ⟨C, hC0, hCD, hC⟩ :=
+ ringInverse_iteratedFDeriv_uniform_bound (X := X) (A := E →L[ℝ] E) hD
+ refine ⟨C, hC0, hCD, ?_⟩
+ intro B hB J x hJ hunit hInv hbound m
+ rw [norm_iteratedFDeriv_inverseTranspose J x m]
+ exact hC B hB J x hJ hunit hInv hbound m
+
+end InverseTranspose
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/InverseMajorant.lean b/lean/OAI/Geometry/RCD/Coordinates/InverseMajorant.lean
new file mode 100644
index 0000000000000000000000000000000000000000..f9dfef0f4c987e05a76846df3eca1dd7af659b88
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/InverseMajorant.lean
@@ -0,0 +1,156 @@
+import Mathlib.Analysis.SpecialFunctions.Pow.Real
+import Mathlib.Topology.Algebra.Order.Field
+import Mathlib.Tactic
+
+namespace OAI
+
+/-!
+# An inverse-coefficient majorant without exponential loss
+
+The normalized interior convolution of a positive weight sequence tends
+to zero. This makes the inverse recurrence contractive at large orders.
+Finite initial orders are bounded uniformly over every sequence satisfying
+the recurrence. The final constant is independent of the sequence and
+the order, so it introduces no new exponential base.
+-/
+
+open Finset Filter
+open scoped BigOperators Topology
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+/-- The convolution with the two endpoint terms omitted. -/
+def interiorConvolution (L : ℕ → ℝ) (m : ℕ) : ℝ :=
+ ∑ l ∈ Finset.Icc 1 (m - 1), L l * L (m - l)
+
+/-- Normalized interior convolution from `re:convolution-decay`. -/
+def normalizedInteriorConvolution (L : ℕ → ℝ) (m : ℕ) : ℝ :=
+ interiorConvolution L m / L m
+
+/-- The positive-order recurrence after removing the exponential jet base. -/
+def HasInverseMajorantRecurrence (L a : ℕ → ℝ) (A : ℝ) : Prop :=
+ ∀ m, 0 < m → a m ≤ A * L m + Real.sqrt A *
+ ∑ l ∈ Finset.Icc 1 (m - 1), L l * a (m - l)
+
+theorem interiorConvolution_nonneg {L : ℕ → ℝ} (hL : ∀ m, 0 ≤ L m) (m : ℕ) :
+ 0 ≤ interiorConvolution L m := by
+ exact Finset.sum_nonneg fun l _ => mul_nonneg (hL l) (hL (m - l))
+
+theorem normalizedInteriorConvolution_mul {L : ℕ → ℝ}
+ (hL : ∀ m, 0 < L m) (m : ℕ) :
+ normalizedInteriorConvolution L m * L m = interiorConvolution L m :=
+ div_mul_cancel₀ _ (ne_of_gt (hL m))
+
+/-- A bound at smaller orders controls the convolution in the recurrence. -/
+theorem inverse_recurrence_step {L a : ℕ → ℝ} {A C : ℝ}
+ (hL : ∀ m, 0 < L m) (hrec : HasInverseMajorantRecurrence L a A)
+ {m : ℕ} (hm : 0 < m) (hprev : ∀ j < m, a j ≤ C * L j) :
+ a m ≤ (A + Real.sqrt A * C * normalizedInteriorConvolution L m) * L m := by
+ have hsum : (∑ l ∈ Finset.Icc 1 (m - 1), L l * a (m - l)) ≤
+ C * interiorConvolution L m := by
+ calc
+ _ ≤ ∑ l ∈ Finset.Icc 1 (m - 1), L l * (C * L (m - l)) := by
+ apply Finset.sum_le_sum
+ intro l hl
+ have hlone : 1 ≤ l := (Finset.mem_Icc.mp hl).1
+ exact mul_le_mul_of_nonneg_left (hprev (m - l) (by omega)) (hL l).le
+ _ = _ := by
+ unfold interiorConvolution
+ rw [Finset.mul_sum]
+ apply Finset.sum_congr rfl
+ intro l _
+ ring
+ calc
+ a m ≤ A * L m + Real.sqrt A *
+ ∑ l ∈ Finset.Icc 1 (m - 1), L l * a (m - l) := hrec m hm
+ _ ≤ A * L m + Real.sqrt A * (C * interiorConvolution L m) :=
+ add_le_add le_rfl (mul_le_mul_of_nonneg_left hsum (Real.sqrt_nonneg A))
+ _ = _ := by rw [← normalizedInteriorConvolution_mul hL m]; ring
+
+/-- All orders below a finite cutoff have a common bound derived from
+the recurrence itself, uniform over every admissible sequence. -/
+theorem inverse_majorant_finite_prefix {L : ℕ → ℝ} {A initial : ℝ}
+ (hL : ∀ m, 0 < L m) (hinitial : 0 ≤ initial) (N : ℕ) :
+ ∃ C : ℝ, 0 ≤ C ∧ ∀ a : ℕ → ℝ,
+ a 0 ≤ initial * L 0 → HasInverseMajorantRecurrence L a A →
+ ∀ m < N, a m ≤ C * L m := by
+ induction N with
+ | zero => exact ⟨initial, hinitial, fun _ _ _ m hm => (Nat.not_lt_zero m hm).elim⟩
+ | succ N ih =>
+ obtain ⟨C, hC, hbound⟩ := ih
+ let D := max C (max initial
+ (A + Real.sqrt A * C * normalizedInteriorConvolution L N))
+ refine ⟨D, hC.trans (le_max_left _ _), ?_⟩
+ intro a ha0 hrec m hm
+ by_cases hmN : m < N
+ · exact (hbound a ha0 hrec m hmN).trans
+ (mul_le_mul_of_nonneg_right (le_max_left _ _) (hL m).le)
+ · have hmEq : m = N := by omega
+ subst m
+ by_cases hN : N = 0
+ · subst N
+ exact ha0.trans (mul_le_mul_of_nonneg_right
+ ((le_max_left initial _).trans (le_max_right C _)) (hL 0).le)
+ · exact (inverse_recurrence_step hL hrec (Nat.pos_of_ne_zero hN)
+ (hbound a ha0 hrec)).trans (mul_le_mul_of_nonneg_right
+ ((le_max_right initial _).trans (le_max_right C _)) (hL N).le)
+
+/-- Vanishing normalized convolution implies a uniform inverse majorant.
+The same constant works for every admissible sequence. -/
+theorem inverse_majorant_uniform {L : ℕ → ℝ} {A initial : ℝ}
+ (hL : ∀ m, 0 < L m) (hA : 0 ≤ A) (hinitial : 0 ≤ initial)
+ (hdecay : Tendsto (normalizedInteriorConvolution L) atTop (𝓝 0)) :
+ ∃ C : ℝ, initial ≤ C ∧ 2 * A ≤ C ∧ 0 ≤ C ∧
+ ∀ a : ℕ → ℝ, a 0 ≤ initial * L 0 →
+ HasInverseMajorantRecurrence L a A → ∀ m, a m ≤ C * L m := by
+ have hlim : Tendsto (fun m => Real.sqrt A * normalizedInteriorConvolution L m)
+ atTop (𝓝 0) := by
+ simpa using tendsto_const_nhds.mul hdecay
+ have hsmall : ∀ᶠ m in atTop,
+ Real.sqrt A * normalizedInteriorConvolution L m ≤ 1 / 2 := by
+ exact (hlim.eventually (eventually_lt_nhds (by norm_num : (0 : ℝ) < 1 / 2))).mono
+ fun _ h => h.le
+ obtain ⟨M₀, hM₀⟩ := Filter.eventually_atTop.mp hsmall
+ let M := max M₀ 1
+ obtain ⟨D, _, hprefix⟩ := inverse_majorant_finite_prefix hL hinitial M
+ let C := max initial (max (2 * A) D)
+ have hIC : initial ≤ C := le_max_left _ _
+ have hAC : 2 * A ≤ C := (le_max_left _ _).trans (le_max_right _ _)
+ have hDC : D ≤ C := (le_max_right _ _).trans (le_max_right _ _)
+ have hC : 0 ≤ C := (mul_nonneg (by norm_num : (0 : ℝ) ≤ 2) hA).trans hAC
+ refine ⟨C, hIC, hAC, hC, ?_⟩
+ intro a ha0 hrec m
+ induction m using Nat.strong_induction_on with
+ | h m ih =>
+ by_cases hm : m < M
+ · exact (hprefix a ha0 hrec m hm).trans
+ (mul_le_mul_of_nonneg_right hDC (hL m).le)
+ · have hmM : M ≤ m := Nat.le_of_not_gt hm
+ have hmpos : 0 < m := lt_of_lt_of_le (by dsimp [M]; omega) hmM
+ have hsmallm := hM₀ m ((le_max_left M₀ 1).trans hmM)
+ have hcontract : A + Real.sqrt A * C * normalizedInteriorConvolution L m ≤ C := by
+ have hmul := mul_le_mul_of_nonneg_left hsmallm hC
+ nlinarith
+ exact (inverse_recurrence_step hL hrec hmpos ih).trans
+ (mul_le_mul_of_nonneg_right hcontract (hL m).le)
+
+/-- Specialization to the initial inverse norm `√A` used by the manuscript. -/
+theorem inverse_coefficients_uniform_bound {L : ℕ → ℝ} {A : ℝ}
+ (hL : ∀ m, 0 < L m) (hLzero : L 0 = 1) (hA : 1 ≤ A)
+ (hdecay : Tendsto (normalizedInteriorConvolution L) atTop (𝓝 0)) :
+ ∃ C : ℝ, Real.sqrt A ≤ C ∧ 2 * A ≤ C ∧
+ ∀ a : ℕ → ℝ, a 0 ≤ Real.sqrt A →
+ HasInverseMajorantRecurrence L a A → ∀ m, a m ≤ C * L m := by
+ obtain ⟨C, hIC, hAC, _, hbound⟩ := inverse_majorant_uniform hL
+ (zero_le_one.trans hA) (Real.sqrt_nonneg A) hdecay
+ refine ⟨C, hIC, hAC, ?_⟩
+ intro a ha0 hrec
+ exact hbound a (by simpa [hLzero] using ha0) hrec
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/InverseMetricFrames.lean b/lean/OAI/Geometry/RCD/Coordinates/InverseMetricFrames.lean
new file mode 100644
index 0000000000000000000000000000000000000000..5b65972f858f1e2abfcb08b9a25818202235fb33
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/InverseMetricFrames.lean
@@ -0,0 +1,102 @@
+import OAI.Geometry.RCD.Coordinates.LinearNormalization
+import OAI.Geometry.RCD.Coordinates.WeightedInverse
+
+namespace OAI
+
+/-! # Exact Euclidean frames for the inverse heat metrics -/
+
+open scoped InnerProductSpace
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+ [FiniteDimensional ℝ E]
+
+omit [FiniteDimensional ℝ E] in
+/-- An invertible positive form is strictly positive on nonzero vectors. -/
+theorem positive_equiv_strict (Q : E ≃L[ℝ] E)
+ (hQ : Q.toContinuousLinearMap.IsPositive) {v : E} (hv : v ≠ 0) :
+ 0 < ⟪v, Q v⟫_ℝ := by
+ have hn := hQ.inner_nonneg_right v
+ apply lt_of_le_of_ne hn
+ intro hz
+ have h := positive_form_cauchy_schwarz hQ (Q v) v
+ simp only [ContinuousLinearEquiv.coe_coe] at h hz
+ rw [← hz, mul_zero, real_inner_self_eq_norm_sq] at h
+ have hs : ‖Q v‖ ^ 2 = 0 := by nlinarith [sq_nonneg (‖Q v‖ ^ 2)]
+ have hzero : Q v = 0 := norm_eq_zero.mp (sq_eq_zero_iff.mp hs)
+ exact hv (Q.injective (by simpa only [map_zero] using hzero))
+
+/-- A finite-dimensional inverse metric represented by an actual linear frame. -/
+def inverseMetricFrame (Q : E ≃L[ℝ] E)
+ (hQ : Q.toContinuousLinearMap.IsPositive) : E ≃L[ℝ] E :=
+ (Classical.choose (exists_exact_operator_normalization Q.symm.toContinuousLinearMap
+ (positive_equiv_symm Q hQ).isSymmetric
+ (fun _ hv => positive_equiv_strict Q.symm (positive_equiv_symm Q hQ) hv))).symm
+
+@[simp] theorem inverseMetricFrame_norm_sq (Q : E ≃L[ℝ] E)
+ (hQ : Q.toContinuousLinearMap.IsPositive) (v : E) :
+ ‖inverseMetricFrame Q hQ v‖ ^ 2 = ⟪v, Q.symm v⟫_ℝ := by
+ let A := (inverseMetricFrame Q hQ).symm
+ have he : A.toContinuousLinearMap.adjoint.comp
+ (Q.symm.toContinuousLinearMap.comp A.toContinuousLinearMap) =
+ ContinuousLinearMap.id ℝ E :=
+ Classical.choose_spec (exists_exact_operator_normalization Q.symm.toContinuousLinearMap
+ (positive_equiv_symm Q hQ).isSymmetric
+ (fun _ hv => positive_equiv_strict Q.symm (positive_equiv_symm Q hQ) hv))
+ have h := congrArg (fun T : E →L[ℝ] E => ⟪A.symm v, T (A.symm v)⟫_ℝ) he
+ simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.adjoint_inner_right,
+ ContinuousLinearEquiv.coe_coe, ContinuousLinearEquiv.apply_symm_apply,
+ ContinuousLinearMap.id_apply, real_inner_self_eq_norm_sq] at h
+ exact h.symm
+
+/-- Decreasing positive forms have increasing inverse-frame norms. -/
+theorem inverseMetricFrame_mono (P Q : E ≃L[ℝ] E)
+ (hP : P.toContinuousLinearMap.IsPositive) (hQ : Q.toContinuousLinearMap.IsPositive)
+ (hD : (P.toContinuousLinearMap - Q.toContinuousLinearMap).IsPositive) (v : E) :
+ ‖inverseMetricFrame P hP v‖ ≤ ‖inverseMetricFrame Q hQ v‖ := by
+ have h := (inverse_increment_isPositive P Q hP hQ hD).inner_nonneg_right v
+ simp only [sub_apply, inner_sub_right, ContinuousLinearEquiv.coe_coe] at h
+ apply (sq_le_sq₀ (norm_nonneg _) (norm_nonneg _)).mp
+ simp only [inverseMetricFrame_norm_sq]
+ linarith only [h]
+
+/-- Slow heat decay gives a uniform comparison of successive frozen frames. -/
+theorem inverseMetricFrame_step (P Q : E ≃L[ℝ] E)
+ (hP : P.toContinuousLinearMap.IsPositive) (hQ : Q.toContinuousLinearMap.IsPositive)
+ (hstep : ∀ v, ⟪v, P v⟫_ℝ ≤ (9 / 8 : ℝ) * ⟪v, Q v⟫_ℝ) (v : E) :
+ ‖inverseMetricFrame Q hQ v‖ ≤ 2 * ‖inverseMetricFrame P hP v‖ := by
+ have hc (w : E) : (8 / 9 : ℝ) * ⟪w, P w⟫_ℝ ≤ ⟪w, Q w⟫_ℝ := by
+ have h := hstep w
+ linarith
+ have h := (relative_inverse_bounds P Q hP hQ (by norm_num : (0 : ℝ) < 8 / 9) hc v).1
+ rw [← inverseMetricFrame_norm_sq Q hQ, ← inverseMetricFrame_norm_sq P hP] at h
+ nlinarith [sq_nonneg (‖inverseMetricFrame P hP v‖), norm_nonneg (inverseMetricFrame Q hQ v),
+ norm_nonneg (inverseMetricFrame P hP v)]
+
+omit [FiniteDimensional ℝ E] in
+/-- A relative half-small decrement controls the inverse discrepancy in
+both endpoint metrics, including the finer metric used by patch assembly. -/
+theorem inverse_difference_energy_le (P Q : E ≃L[ℝ] E)
+ (hP : P.toContinuousLinearMap.IsPositive) (hQ : Q.toContinuousLinearMap.IsPositive)
+ (hD : (P.toContinuousLinearMap - Q.toContinuousLinearMap).IsPositive)
+ (hstep : ∀ v, ⟪v, P v⟫_ℝ ≤ 2 * ⟪v, Q v⟫_ℝ) (xi : E) :
+ let d := Q.symm xi - P.symm xi
+ ⟪d, Q d⟫_ℝ ≤ ⟪xi, Q.symm xi⟫_ℝ - ⟪xi, P.symm xi⟫_ℝ := by
+ intro d
+ have hsmall (v : E) : ⟪v, (P.toContinuousLinearMap - Q.toContinuousLinearMap) v⟫_ℝ ≤
+ (1 / 2 : ℝ) * ⟪v, P v⟫_ℝ := by
+ simp only [sub_apply, inner_sub_right, ContinuousLinearEquiv.coe_coe]
+ linarith only [hstep v]
+ have h := inverse_increment_weighted_square_le P Q hP hQ hD hsmall xi
+ have hm := hD.inner_nonneg_right d
+ simp only [sub_apply, inner_sub_right, ContinuousLinearEquiv.coe_coe] at h hm
+ change ⟪d, P d⟫_ℝ ≤ ⟪xi, Q.symm xi⟫_ℝ - ⟪xi, P.symm xi⟫_ℝ at h
+ linarith only [h, hm]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/IterationLimit.lean b/lean/OAI/Geometry/RCD/Coordinates/IterationLimit.lean
new file mode 100644
index 0000000000000000000000000000000000000000..b16b843e547b09aa732de205bde0eb7f1216cb2b
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/IterationLimit.lean
@@ -0,0 +1,392 @@
+import OAI.Geometry.RCD.Coordinates.MetricIteration
+import OAI.Geometry.RCD.Coordinates.LimitChart
+
+namespace OAI
+
+/-!
+# The metric iteration produces the limiting chart estimates
+
+Finite-stage differential estimates imply geometric increment and Taylor
+bounds. Pair geometry controls the original coordinates, the selected
+scale, and the frozen metrics along each coordinate-value segment.
+-/
+
+open Filter Set
+open scoped Topology ContDiff BigOperators
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+section Analytic
+
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+
+namespace AnalyticIterationData
+
+theorem energy_le {Ω : Set E} {r0 T F B epsilon : ℝ}
+ (d : AnalyticIterationData Ω r0 T F B epsilon) (i : ℕ) (x : E) (hx : x ∈ Ω) :
+ d.energy i x ≤ epsilon := by
+ exact (Finset.single_le_sum (fun j _ => d.energy_nonneg j x hx)
+ (Finset.mem_range.mpr (Nat.lt_succ_self i))).trans (d.energy_budget (i + 1) x hx)
+
+/-- Increasing the permitted defect changes no maps or metrics. -/
+def withLargerParameter {Ω : Set E} {r0 T F B epsilon delta : ℝ}
+ (d : AnalyticIterationData Ω r0 T F B epsilon) (hr0 : 0 < r0)
+ (hF : 0 ≤ F) (hB : 0 < B) (hed : epsilon ≤ delta) :
+ AnalyticIterationData Ω r0 T F B delta where
+ frozen := d.frozen
+ correction := d.correction
+ principal := d.principal
+ mass := d.mass
+ energy := d.energy
+ frozen_mono := d.frozen_mono
+ correction_smooth := d.correction_smooth
+ energy_nonneg := d.energy_nonneg
+ energy_budget := fun k x hx => (d.energy_budget k x hx).trans hed
+ mass_nonneg := d.mass_nonneg
+ principal_nonneg := d.principal_nonneg
+ principal_le_mass := d.principal_le_mass
+ mass_budget := d.mass_budget
+ principal_budget := d.principal_budget
+ value_bound := by
+ intro i x hx
+ have hr := iterationRadius_pos hr0 i
+ exact (d.value_bound i x hx).trans (by gcongr)
+ first_bound := by
+ intro i x hx xi
+ exact (d.first_bound i x hx xi).trans (by gcongr)
+ second_bound := d.second_bound
+ linear_bound := d.linear_bound
+ correction_jets := by
+ intro i x hx m
+ exact (d.correction_jets i x hx m).trans
+ (mul_le_mul_of_nonneg_right
+ (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hed hF)
+ (factorialMajorant_pos m).le) (jetCoefficientScale_pos hB m).le)
+
+end AnalyticIterationData
+
+/-- Only the second normalized jet is needed for the final pair estimate. -/
+structure FiniteIterationControl {Ω : Set E} {r0 T F B epsilon : ℝ}
+ (d : AnalyticIterationData Ω r0 T F B epsilon) : Prop where
+ smooth : ∀ i x, x ∈ Ω → ∀ m : ℕ, ContDiffAt ℝ m (metricIterate d.correction i) x
+ metric : ∀ i x, x ∈ Ω → ∀ xi,
+ (4 * T)⁻¹ * ‖d.frozen i x xi‖ ^ 2 ≤ ‖fderiv ℝ (metricIterate d.correction i) x xi‖ ^ 2 ∧
+ ‖fderiv ℝ (metricIterate d.correction i) x xi‖ ^ 2 ≤ (4 * T) * ‖d.frozen i x xi‖ ^ 2
+ second_jet : ∀ i x, x ∈ Ω →
+ ‖iteratedFDeriv ℝ 2 (normalizedCoordinates (iterationRadius r0 i)
+ (d.frozen i x) x (metricIterate d.correction i)) 0‖ ≤ 8 * B
+
+omit [CompleteSpace E] in
+/-- Recover the actual second directional derivative from the normalized
+second jet, without an ambient operator norm or condition-number loss. -/
+theorem second_derivative_le_of_normalized_jet
+ {h : E → E} {x : E} {r B : ℝ} (hr : 0 < r) (T : E ≃L[ℝ] E)
+ (hh : ContDiffAt ℝ 2 h x)
+ (hjet : ‖iteratedFDeriv ℝ 2 (normalizedCoordinates r T x h) 0‖ ≤ 8 * B)
+ (xi : E) :
+ ‖fderiv ℝ (fderiv ℝ h) x xi xi‖ ≤ 8 * B / r * ‖T xi‖ ^ 2 := by
+ have ht := normalized_jet_apply T h x 0 r (by norm_num : 0 < (2 : ℕ))
+ (by simpa using hh) (fun _ => T xi)
+ have hfactor : r⁻¹ * r ^ 2 = r := by field_simp
+ change iteratedFDeriv ℝ 2 (normalizedCoordinates r T x h) 0 (fun _ => T xi) = _ at ht
+ simp only [map_zero, smul_zero, add_zero, ContinuousLinearEquiv.symm_apply_apply,
+ hfactor, iteratedFDeriv_two_apply] at ht
+ have hn : ‖iteratedFDeriv ℝ 2 (normalizedCoordinates r T x h) 0 (fun _ => T xi)‖ ≤
+ 8 * B * ‖T xi‖ ^ 2 := by
+ calc
+ _ ≤ ‖iteratedFDeriv ℝ 2 (normalizedCoordinates r T x h) 0‖ * ‖T xi‖ ^ 2 := by
+ simpa using (iteratedFDeriv ℝ 2 (normalizedCoordinates r T x h) 0).le_opNorm
+ (fun _ => T xi)
+ _ ≤ _ := mul_le_mul_of_nonneg_right hjet (sq_nonneg _)
+ rw [iteratedFDeriv_two_apply, ht, norm_smul, Real.norm_eq_abs, abs_of_pos hr] at hn
+ calc
+ _ ≤ (8 * B * ‖T xi‖ ^ 2) / r := (le_div_iff₀ hr).mpr (by nlinarith)
+ _ = _ := by ring
+
+/-- The correction value and coercivity give a genuine geometric increment
+bound for the recursively defined maps. -/
+theorem metricIterate_step_le [FiniteDimensional ℝ E]
+ {Ω : Set E} {r0 T F B epsilon : ℝ} (d : AnalyticIterationData Ω r0 T F B epsilon)
+ (hT : 1 ≤ T) (hF : 0 ≤ F) (hepsilon : 0 ≤ epsilon) (hr0 : 0 < r0)
+ (hc : FiniteIterationControl d) (i : ℕ) (x : E) (hx : x ∈ Ω) :
+ dist (metricIterate d.correction i x) (metricIterate d.correction (i + 1) x) ≤
+ (4 * T) * F * epsilon * iterationRadius r0 i := by
+ have hA : 1 ≤ 4 * T := by linarith
+ have hA0 : 0 ≤ 4 * T := by linarith
+ obtain ⟨e, he, hinv⟩ := exists_equiv_inverseTranspose_bound
+ (d.frozen i x) (fderiv ℝ (metricIterate d.correction i) x) hA
+ (fun xi => (hc.metric i x hx xi).1)
+ have hsqrt : Real.sqrt (4 * T) ≤ 4 * T := by
+ nlinarith [Real.sq_sqrt hA0, Real.sqrt_nonneg (4 * T)]
+ have henergy : Real.sqrt (d.energy i x) ≤ Real.sqrt epsilon :=
+ Real.sqrt_le_sqrt (d.energy_le i x hx)
+ have hr := iterationRadius_pos hr0 i
+ rw [metricIterate_succ, dist_eq_norm]
+ simp only [sub_add_eq_sub_sub, sub_self, zero_sub, norm_neg]
+ rw [← he, operatorInverseTranspose_equiv]
+ calc
+ _ ≤ Real.sqrt (4 * T) *
+ ‖(d.frozen i x).symm.toContinuousLinearMap.adjoint (d.correction i x)‖ := hinv _
+ _ ≤ Real.sqrt (4 * T) *
+ (F * Real.sqrt epsilon * iterationRadius r0 i * Real.sqrt (d.energy i x)) :=
+ mul_le_mul_of_nonneg_left (d.value_bound i x hx) (Real.sqrt_nonneg _)
+ _ ≤ (4 * T) * (F * Real.sqrt epsilon * iterationRadius r0 i * Real.sqrt epsilon) := by
+ gcongr
+ _ = (4 * T) * F * (Real.sqrt epsilon * Real.sqrt epsilon) * iterationRadius r0 i := by ring
+ _ = _ := by rw [Real.mul_self_sqrt hepsilon]
+
+end Analytic
+
+section Pairs
+
+variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
+
+/-- A convenient non-sharp constant for converting metric squares to linear
+separation. It avoids introducing a square root into the final chart ratio. -/
+theorem linear_comparison_of_frozen_metric
+ (T : E ≃L[ℝ] E) (J : E →L[ℝ] E) {A G t : ℝ} (hA : 1 ≤ A) (hG : 1 ≤ G)
+ (ht : 0 ≤ t) (w : E)
+ (hmetric : ∀ xi, A⁻¹ * ‖T xi‖ ^ 2 ≤ ‖J xi‖ ^ 2 ∧
+ ‖J xi‖ ^ 2 ≤ A * ‖T xi‖ ^ 2)
+ (hlower : G⁻¹ * t ≤ ‖T w‖) (hupper : ‖T w‖ ≤ G * t) :
+ (2 * (A * G))⁻¹ * t ≤ ‖J w‖ ∧ ‖J w‖ ≤ 2 * (A * G) * t := by
+ have hA0 : 0 < A := by linarith
+ have hG0 : 0 < G := by linarith
+ have hsqrt : Real.sqrt A ≤ A := by
+ nlinarith [Real.sq_sqrt hA0.le, Real.sqrt_nonneg A]
+ have hlow := norm_le_sqrt_mul_of_metric_lower T J hA (fun xi => (hmetric xi).1) w
+ have hlow' : ‖T w‖ ≤ A * ‖J w‖ :=
+ hlow.trans (mul_le_mul_of_nonneg_right hsqrt (norm_nonneg _))
+ have hnorm : ‖J w‖ ≤ Real.sqrt A * ‖T w‖ := by
+ apply (sq_le_sq₀ (norm_nonneg _) (mul_nonneg (Real.sqrt_nonneg _) (norm_nonneg _))).mp
+ simpa only [mul_pow, Real.sq_sqrt hA0.le] using (hmetric w).2
+ have hnorm' : ‖J w‖ ≤ A * (G * t) := hnorm.trans
+ ((mul_le_mul_of_nonneg_right hsqrt (norm_nonneg _)).trans
+ (mul_le_mul_of_nonneg_left hupper hA0.le))
+ have ht' : t ≤ G * ‖T w‖ := by
+ rw [← div_eq_inv_mul] at hlower
+ exact (div_le_iff₀ hG0).mp hlower |>.trans_eq (mul_comm _ _)
+ constructor
+ · rw [← div_eq_inv_mul]
+ apply (div_le_iff₀ (by positivity : 0 < 2 * (A * G))).mpr
+ have hh := ht'.trans (mul_le_mul_of_nonneg_left hlow' hG0.le)
+ nlinarith [mul_nonneg hA0.le (mul_nonneg hG0.le (norm_nonneg (J w)))]
+ · nlinarith [mul_nonneg hA0.le (mul_nonneg hG0.le ht)]
+
+end Pairs
+
+/-- The chart ratio and pair radius are fixed before the final smallness
+parameter is chosen. -/
+def iterationChartRatio (T G : ℝ) : ℝ := (4 * T) * G
+
+def iterationPairMultiplier (T B G : ℝ) : ℝ :=
+ 64 * iterationChartRatio T G * B * G ^ 4
+
+/-- A diameter restriction supplies the required dyadic pair scale. -/
+theorem exists_iteration_pair_scale {r0 L t : ℝ} (hr0 : 0 < r0) (hL : 0 < L)
+ (ht : 0 < t) (hdiam : L * t ≤ r0) :
+ ∃ i, L * t ≤ iterationRadius r0 i ∧ iterationRadius r0 i ≤ 2 * L * t := by
+ obtain ⟨i, hi, hi'⟩ := exists_dyadic_scale (div_pos (mul_pos hL ht) hr0)
+ ((div_le_one hr0).mpr hdiam)
+ have hri : iterationRadius r0 i = r0 * (1 / 2 : ℝ) ^ i := by
+ unfold iterationRadius
+ rw [one_div_pow]
+ ring
+ have hl := (div_le_iff₀ hr0).mp hi
+ have hu' : (1 / 2 : ℝ) ^ i < (2 * L * t) / r0 := by convert hi' using 1; ring
+ have hu := (lt_div_iff₀ hr0).mp hu'
+ exact ⟨i, by rw [hri]; nlinarith, by rw [hri]; nlinarith⟩
+
+/-- Raw geometric information about the original coordinates and frozen
+metrics. No derivative, increment, or Taylor estimate occurs here. -/
+def IterationPairGeometry {X E : Type*} [MetricSpace X]
+ [NormedAddCommGroup E] [NormedSpace ℝ E]
+ (u : X → E) (Ω : Set E) (frozen : ℕ → E → E ≃L[ℝ] E)
+ (r0 T B G : ℝ) : Prop :=
+ ∀ x z, x ≠ z → ∃ i,
+ iterationPairMultiplier T B G * dist x z ≤ iterationRadius r0 i ∧
+ iterationRadius r0 i ≤ 2 * iterationPairMultiplier T B G * dist x z ∧
+ G⁻¹ * dist x z ≤ ‖frozen i (u x) (u z - u x)‖ ∧
+ ‖frozen i (u x) (u z - u x)‖ ≤ G * dist x z ∧
+ segment ℝ (u x) (u z) ⊆ Ω ∧
+ ∀ y ∈ segment ℝ (u x) (u z),
+ ‖frozen i y (u z - u x)‖ ≤ G * ‖frozen i (u x) (u z - u x)‖
+
+/-- Uniform geometric estimates at comparable scales, together with a
+diameter bound, construct the pair-selected data. -/
+theorem iterationPairGeometry_of_all_scales {X E : Type*} [MetricSpace X]
+ [NormedAddCommGroup E] [NormedSpace ℝ E]
+ (u : X → E) (Ω : Set E) (frozen : ℕ → E → E ≃L[ℝ] E)
+ {r0 T B G : ℝ} (hr0 : 0 < r0) (hT : 1 ≤ T) (hB : 1 ≤ B) (hG : 1 ≤ G)
+ (hdiam : ∀ x z : X, iterationPairMultiplier T B G * dist x z ≤ r0)
+ (hgeometry : ∀ i x z, x ≠ z →
+ iterationPairMultiplier T B G * dist x z ≤ iterationRadius r0 i →
+ iterationRadius r0 i ≤ 2 * iterationPairMultiplier T B G * dist x z →
+ G⁻¹ * dist x z ≤ ‖frozen i (u x) (u z - u x)‖ ∧
+ ‖frozen i (u x) (u z - u x)‖ ≤ G * dist x z ∧
+ segment ℝ (u x) (u z) ⊆ Ω ∧
+ ∀ y ∈ segment ℝ (u x) (u z),
+ ‖frozen i y (u z - u x)‖ ≤ G * ‖frozen i (u x) (u z - u x)‖) :
+ IterationPairGeometry u Ω frozen r0 T B G := by
+ intro x z hxz
+ have hL : 0 < iterationPairMultiplier T B G := by
+ unfold iterationPairMultiplier iterationChartRatio
+ positivity
+ obtain ⟨i, hi, hi'⟩ := exists_iteration_pair_scale hr0 hL (dist_pos.mpr hxz) (hdiam x z)
+ exact ⟨i, hi, hi', hgeometry i x z hxz hi hi'⟩
+
+section Limit
+
+variable {X : Type*} [MetricSpace X] {n : ℕ}
+
+/-- Analytic iteration bounds and pair geometry supply scale-selected Taylor
+estimates for the limit. -/
+theorem exists_limit_dist_bounds_of_analytic_iteration
+ {Ω : Set (Euclidean n)} {r0 T F B G epsilon : ℝ}
+ (d : AnalyticIterationData Ω r0 T F B epsilon)
+ (hT : 1 ≤ T) (hF : 1 ≤ F) (hB : 1 ≤ B) (hG : 1 ≤ G)
+ (hr0 : 0 < r0) (hepsilon : 0 ≤ epsilon) (hc : FiniteIterationControl d)
+ (u : X → Euclidean n) (hu : ∀ x, u x ∈ Ω)
+ (hgeometry : IterationPairGeometry u Ω d.frozen r0 T B G)
+ (hsmall : 8 * (4 * T) * F * epsilon * iterationPairMultiplier T B G ≤
+ (8 * iterationChartRatio T G)⁻¹) :
+ ∃ H : X → Euclidean n,
+ (∀ x, Tendsto (fun i => metricIterate d.correction i (u x)) atTop (𝓝 (H x))) ∧
+ ∀ x z, (4 * iterationChartRatio T G)⁻¹ * dist x z ≤ dist (H x) (H z) ∧
+ dist (H x) (H z) ≤ (4 * iterationChartRatio T G) * dist x z := by
+ let q := iterationChartRatio T G
+ let L := iterationPairMultiplier T B G
+ let C := (4 * T) * F * epsilon * r0
+ have hq : 1 ≤ q := by dsimp [q, iterationChartRatio]; nlinarith
+ have hq0 : 0 < q := by linarith
+ have hL : 0 < L := by dsimp [L, iterationPairMultiplier, iterationChartRatio]; positivity
+ have hstep (i : ℕ) (x : X) :
+ dist (metricIterate d.correction i (u x))
+ (metricIterate d.correction (i + 1) (u x)) ≤ C * (1 / 2 : ℝ) ^ i := by
+ have hi := metricIterate_step_le d hT (by linarith) hepsilon hr0 hc i (u x) (hu x)
+ convert hi using 1
+ dsimp [C, iterationRadius]
+ rw [one_div_pow]
+ ring
+ apply exists_limit_dist_bounds_of_taylor u (metricIterate d.correction)
+ (fun i => fderiv ℝ (metricIterate d.correction i))
+ (fun i => fderiv ℝ (fderiv ℝ (metricIterate d.correction i))) hq hstep
+ intro x z hxz
+ obtain ⟨i, hscale, hscale', hlower, hupper, hsegment, hnear⟩ := hgeometry x z hxz
+ let w := u z - u x
+ let M := 8 * B / iterationRadius r0 i * G ^ 4 * (dist x z) ^ 2
+ have hr := iterationRadius_pos hr0 i
+ have hdist : 0 < dist x z := dist_pos.mpr hxz
+ have hM : 0 ≤ M := by dsimp [M]; positivity
+ have hlinear := linear_comparison_of_frozen_metric (d.frozen i (u x))
+ (fderiv ℝ (metricIterate d.correction i) (u x)) (by linarith : 1 ≤ 4 * T)
+ hG hdist.le w (hc.metric i (u x) (hu x)) hlower hupper
+ refine ⟨i, M, hM, ?_, ?_, ?_, hlinear.1, hlinear.2, ?_, ?_⟩
+ · intro y hy
+ exact ((hc.smooth i y (hsegment hy) 1).differentiableAt (by norm_num)).hasFDerivAt
+ · intro y hy
+ exact (((hc.smooth i y (hsegment hy) 2).fderiv_right (m := 1)
+ (by norm_num)).differentiableAt (by norm_num)).hasFDerivAt
+ · intro y hy
+ have hnorm : ‖d.frozen i y w‖ ≤ G ^ 2 * dist x z := by
+ calc
+ _ ≤ G * ‖d.frozen i (u x) w‖ := hnear y hy
+ _ ≤ G * (G * dist x z) := mul_le_mul_of_nonneg_left hupper (by linarith)
+ _ = _ := by ring
+ calc
+ _ ≤ 8 * B / iterationRadius r0 i * ‖d.frozen i y w‖ ^ 2 :=
+ second_derivative_le_of_normalized_jet hr (d.frozen i y)
+ (hc.smooth i y (hsegment hy) 2) (hc.second_jet i y (hsegment hy)) w
+ _ ≤ 8 * B / iterationRadius r0 i * (G ^ 2 * dist x z) ^ 2 := by gcongr
+ _ = M := by dsimp [M]; ring
+ · have hcoeff : (8 * q)⁻¹ * L = 8 * B * G ^ 4 := by
+ dsimp [L, iterationPairMultiplier]
+ change (8 * q)⁻¹ * (64 * q * B * G ^ 4) = _
+ field_simp
+ ring
+ change 8 * B / iterationRadius r0 i * G ^ 4 * dist x z ^ 2 ≤ (8 * q)⁻¹ * dist x z
+ have heq : 8 * B / iterationRadius r0 i * G ^ 4 * dist x z ^ 2 =
+ (8 * B * G ^ 4 * dist x z ^ 2) / iterationRadius r0 i := by ring
+ rw [heq]
+ apply (div_le_iff₀ hr).mpr
+ calc
+ _ = ((8 * q)⁻¹ * dist x z) * (L * dist x z) := by rw [← hcoeff]; ring
+ _ ≤ _ := mul_le_mul_of_nonneg_left hscale (by positivity)
+ · have hrad : C * (1 / 2 : ℝ) ^ i = (4 * T) * F * epsilon * iterationRadius r0 i := by
+ dsimp [C, iterationRadius]
+ rw [one_div_pow]
+ ring
+ calc
+ 4 * C * (1 / 2 : ℝ) ^ i = 4 * (C * (1 / 2 : ℝ) ^ i) := by ring
+ _ = 4 * ((4 * T) * F * epsilon * iterationRadius r0 i) := by rw [hrad]
+ _ ≤ 4 * ((4 * T) * F * epsilon * (2 * L * dist x z)) := by
+ gcongr
+ _ = (8 * (4 * T) * F * epsilon * L) * dist x z := by ring
+ _ ≤ _ := mul_le_mul_of_nonneg_right hsmall hdist.le
+
+end Limit
+
+section FinalChart
+
+variable {X : Type*} [MetricSpace X] {n : ℕ}
+
+/-- One small parameter controls the analytic iteration, Taylor errors, and
+limiting tails; invariance of domain gives the open image. -/
+theorem exists_analytic_iteration_limit_chart
+ (hIOD : EuclideanInvarianceOfDomain n) {T F B G : ℝ}
+ (hT : 1 ≤ T) (hF : 1 ≤ F) (hB : 1 ≤ B) (hG : 1 ≤ G) :
+ ∃ epsilon : ℝ, 0 < epsilon ∧ epsilon ≤ 1 ∧
+ ∀ (p : X) (Ω : Set (Euclidean n)), IsOpen Ω →
+ ∀ (U : Set X), IsOpen U → p ∈ U →
+ ∀ (O : Set (Euclidean n)), IsOpen O → O ⊆ Ω → ∀ u : U ≃ₜ O,
+ ∀ (r0 : ℝ), 0 < r0 → ∀ d : AnalyticIterationData Ω r0 T F B epsilon,
+ IterationPairGeometry (fun x : U => (u x : Euclidean n)) Ω d.frozen r0 T B G →
+ HasOpenBilipschitzChart n p := by
+ obtain ⟨delta, hdelta, hdelta1, hcontrol⟩ :=
+ exists_analytic_metric_iteration (E := Euclidean n) hT hF hB
+ let q := iterationChartRatio T G
+ let L := iterationPairMultiplier T B G
+ have hq : 1 ≤ q := by dsimp [q, iterationChartRatio]; nlinarith
+ have hq0 : 0 < q := by linarith
+ have hA0 : 0 < 4 * T := by linarith
+ have hF0 : 0 < F := by linarith
+ have hL0 : 0 < L := by dsimp [L, iterationPairMultiplier, iterationChartRatio]; positivity
+ let epsilon := min delta (64 * q * (4 * T) * F * L)⁻¹
+ have hepsilon : 0 < epsilon := by dsimp [epsilon]; positivity
+ have hed : epsilon ≤ delta := min_le_left _ _
+ have hes : epsilon ≤ (64 * q * (4 * T) * F * L)⁻¹ := min_le_right _ _
+ have hsmall : 8 * (4 * T) * F * epsilon * L ≤ (8 * q)⁻¹ := by
+ calc
+ _ ≤ 8 * (4 * T) * F * (64 * q * (4 * T) * F * L)⁻¹ * L := by gcongr
+ _ = _ := by field_simp; ring
+ refine ⟨epsilon, hepsilon, hed.trans hdelta1, ?_⟩
+ intro p Ω hΩ U hU hp O hO hOΩ u r0 hr0 d hgeometry
+ let d' := d.withLargerParameter hr0 (by linarith : 0 ≤ F) (by linarith : 0 < B) hed
+ have hc : FiniteIterationControl d := by
+ constructor
+ · intro i x hx m
+ exact (hcontrol Ω hΩ r0 hr0 d' i x hx).1 m
+ · intro i x hx xi
+ exact (hcontrol Ω hΩ r0 hr0 d' i x hx).2.1 xi
+ · intro i x hx
+ have hh := (hcontrol Ω hΩ r0 hr0 d' i x hx).2.2 2 (by norm_num)
+ change ‖iteratedFDeriv ℝ 2 (normalizedCoordinates (iterationRadius r0 i)
+ (d.frozen i x) x (metricIterate d.correction i)) 0‖ ≤
+ B ^ (2 - 1) * ((2 : ℕ).factorial : ℝ) ^ 3 at hh
+ norm_num at hh
+ nlinarith
+ obtain ⟨H, _, hbound⟩ := exists_limit_dist_bounds_of_analytic_iteration d hT hF hB hG
+ hr0 hepsilon.le hc (fun x : U => (u x : Euclidean n)) (fun x => hOΩ (u x).property)
+ hgeometry hsmall
+ exact hasOpenBilipschitzChart_of_coordinates_and_bounds hIOD hU hp hO u
+ (by change 1 ≤ 4 * q; linarith) hbound
+
+end FinalChart
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/IterationOpenness.lean b/lean/OAI/Geometry/RCD/Coordinates/IterationOpenness.lean
new file mode 100644
index 0000000000000000000000000000000000000000..e7ff86a4c426d701b1e9ade68b6f61884f3a1e6d
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/IterationOpenness.lean
@@ -0,0 +1,123 @@
+import OAI.Geometry.RCD.Coordinates.IterationLimit
+import OAI.Geometry.RCD.Coordinates.OpenLimitChart
+
+namespace OAI
+
+/-! # Direct openness of the analytic coordinate limit
+
+The frozen metrics increase, and the zeroth iterate is the identity.
+Consequently every finite iterate has the same lower differential bound.
+The uniform tail bound then passes the open-image property to the limit.
+-/
+
+open Set Filter
+open scoped Topology
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {n : ℕ}
+
+/-- The lower bound on the derivative is uniform in the iteration index. -/
+theorem FiniteIterationControl.inverse_differential_bound
+ {Ω : Set (Euclidean n)} {r0 T F B epsilon : ℝ}
+ {d : AnalyticIterationData Ω r0 T F B epsilon}
+ (hc : FiniteIterationControl d) (hT : 1 ≤ T)
+ (i : ℕ) (x : Euclidean n) (hx : x ∈ Ω) (v : Euclidean n) :
+ ‖v‖ ≤ (4*T)*‖fderiv ℝ (metricIterate d.correction i) x v‖ := by
+ have hA : 0 < 4*T := by linarith
+ have hzero := (hc.metric 0 x hx v).2
+ simp only [metricIterate_zero, fderiv_id, ContinuousLinearMap.id_apply] at hzero
+ have hmono : ‖d.frozen 0 x v‖ ≤ ‖d.frozen i x v‖ :=
+ monotone_nat_of_le_succ (fun j => d.frozen_mono j x hx v) (Nat.zero_le i)
+ have hlower := (hc.metric i x hx v).1
+ have hmul := mul_le_mul_of_nonneg_left hlower hA.le
+ rw [← mul_assoc, mul_inv_cancel₀ hA.ne', one_mul] at hmul
+ have hs : ‖v‖^2 ≤ ((4*T)*‖fderiv ℝ (metricIterate d.correction i) x v‖)^2 := by
+ calc
+ _ ≤ (4*T)*‖d.frozen 0 x v‖^2 := hzero
+ _ ≤ (4*T)*‖d.frozen i x v‖^2 := by gcongr
+ _ ≤ (4*T)*((4*T)*‖fderiv ℝ (metricIterate d.correction i) x v‖^2) :=
+ mul_le_mul_of_nonneg_left hmul hA.le
+ _ = _ := by ring
+ exact (sq_le_sq₀ (norm_nonneg _) (mul_nonneg hA.le (norm_nonneg _))).mp hs
+
+/-- The analytic iteration produces an open limit without a separate
+invariance-of-domain premise. -/
+theorem exists_analytic_iteration_open_limit_chart
+ {X : Type*} [MetricSpace X] {T F B G : ℝ}
+ (hT : 1 ≤ T) (hF : 1 ≤ F) (hB : 1 ≤ B) (hG : 1 ≤ G) :
+ ∃ epsilon : ℝ, 0 < epsilon ∧ epsilon ≤ 1 ∧
+ ∀ (p : X) (Ω : Set (Euclidean n)), IsOpen Ω →
+ ∀ (U : Set X), IsOpen U → p ∈ U →
+ ∀ (O : Set (Euclidean n)), IsOpen O → O ⊆ Ω → ∀ u : U ≃ₜ O,
+ ∀ (r0 : ℝ), 0 < r0 → ∀ d : AnalyticIterationData Ω r0 T F B epsilon,
+ IterationPairGeometry (fun x : U => (u x : Euclidean n)) Ω d.frozen r0 T B G →
+ HasOpenBilipschitzChart n p := by
+ obtain ⟨delta, hdelta, hdelta1, hcontrol⟩ :=
+ exists_analytic_metric_iteration (E := Euclidean n) hT hF hB
+ let q := iterationChartRatio T G
+ let L := iterationPairMultiplier T B G
+ have hq : 1 ≤ q := by dsimp [q, iterationChartRatio]; nlinarith
+ have hq0 : 0 < q := by linarith
+ have hA0 : 0 < 4*T := by linarith
+ have hF0 : 0 < F := by linarith
+ have hL0 : 0 < L := by dsimp [L, iterationPairMultiplier, iterationChartRatio]; positivity
+ let epsilon := min delta (64*q*(4*T)*F*L)⁻¹
+ have hepsilon : 0 < epsilon := by dsimp [epsilon]; positivity
+ have hed : epsilon ≤ delta := min_le_left _ _
+ have hes : epsilon ≤ (64*q*(4*T)*F*L)⁻¹ := min_le_right _ _
+ have hsmall : 8*(4*T)*F*epsilon*L ≤ (8*q)⁻¹ := by
+ calc
+ _ ≤ 8*(4*T)*F*(64*q*(4*T)*F*L)⁻¹*L := by gcongr
+ _ = _ := by field_simp; ring
+ refine ⟨epsilon, hepsilon, hed.trans hdelta1, ?_⟩
+ intro p Ω hΩ U hU hp O hO hOΩ u r0 hr0 d hgeometry
+ let d' := d.withLargerParameter hr0 (by linarith : 0 ≤ F) (by linarith : 0 < B) hed
+ have hc : FiniteIterationControl d := by
+ constructor
+ · intro i x hx m
+ exact (hcontrol Ω hΩ r0 hr0 d' i x hx).1 m
+ · intro i x hx xi
+ exact (hcontrol Ω hΩ r0 hr0 d' i x hx).2.1 xi
+ · intro i x hx
+ have hh := (hcontrol Ω hΩ r0 hr0 d' i x hx).2.2 2 (by norm_num)
+ change ‖iteratedFDeriv ℝ 2 (normalizedCoordinates (iterationRadius r0 i)
+ (d.frozen i x) x (metricIterate d.correction i)) 0‖ ≤
+ B^(2-1)*((2:ℕ).factorial:ℝ)^3 at hh
+ norm_num at hh
+ nlinarith
+ obtain ⟨H,hlim,hbound⟩ := exists_limit_dist_bounds_of_analytic_iteration d hT hF hB hG
+ hr0 hepsilon.le hc (fun x : U => (u x : Euclidean n)) (fun x => hOΩ (u x).property)
+ hgeometry hsmall
+ let C := (4*T)*F*epsilon*r0
+ have hstep (i : ℕ) (x : U) :
+ dist (metricIterate d.correction i (u x))
+ (metricIterate d.correction (i+1) (u x)) ≤ C*(1/2:ℝ)^i := by
+ have hh := metricIterate_step_le d hT (by linarith) hepsilon.le hr0 hc i
+ (u x) (hOΩ (u x).property)
+ convert hh using 1
+ dsimp [C, iterationRadius]
+ rw [one_div_pow]
+ ring
+ apply hasOpenBilipschitzChart_of_coercive_limit hU hp hO u hA0
+ (show 1 ≤ 4*iterationChartRatio T G by change 1≤4*q; linarith)
+ (f := metricIterate d.correction) (H := H)
+ (e := fun i => C*(1/2:ℝ)^i/(1-1/2))
+ · intro i z hz
+ exact (hc.smooth i z (hOΩ hz) 1).differentiableAt (by norm_num)
+ · intro i z hz v
+ exact hc.inverse_differential_bound hT i z (hOΩ hz) v
+ · have hh := (tendsto_pow_atTop_nhds_zero_of_lt_one
+ (by norm_num : (0:ℝ)≤1/2) (by norm_num : (1/2:ℝ)<1)).const_mul C
+ simpa using hh.div_const (1-1/2)
+ · intro i x
+ exact dist_le_of_le_geometric_of_tendsto (1/2:ℝ) C (by norm_num)
+ (fun j => hstep j x) (hlim x) i
+ · exact hbound
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/JetStep.lean b/lean/OAI/Geometry/RCD/Coordinates/JetStep.lean
new file mode 100644
index 0000000000000000000000000000000000000000..e192b2d6096a3c6e2b8572dfa902738760bf5cf2
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/JetStep.lean
@@ -0,0 +1,137 @@
+import OAI.Geometry.RCD.Coordinates.FactorialMajorant
+
+namespace OAI
+
+/-!
+# Scalar all-order jet step
+
+At Gevrey exponent `σ = 2`, the factorial weights in an increment leave
+only the factor `(m + 1)^3` relative to the allowed jet size. The next
+dyadic scale contributes `2 / 2^m`. A single small parameter controls
+every order `m ≥ 2`. The differential estimates producing the old jet
+and increment are explicit premises of the scalar theorem below.
+-/
+
+namespace RegularPointCoordinates
+
+noncomputable section
+
+/-- The polynomial growth is dominated by the dyadic factor, including
+the largest case at order three. -/
+theorem cubic_le_eight_mul_two_pow (m : ℕ) :
+ ((m : ℝ) + 1) ^ 3 ≤ 8 * (2 : ℝ) ^ m := by
+ induction m using Nat.strong_induction_on with
+ | h m ih =>
+ by_cases hm : m ≤ 3
+ · interval_cases m <;> norm_num
+ have hm4 : (4 : ℝ) ≤ (m : ℝ) := by exact_mod_cast (by omega : 4 ≤ m)
+ have hmone : 1 ≤ m := by omega
+ have hprev : (m : ℝ) ^ 3 ≤ 8 * (2 : ℝ) ^ (m - 1) := by
+ have h := ih (m - 1) (by omega)
+ have hcast : ((m - 1 : ℕ) : ℝ) + 1 = m := by
+ exact_mod_cast (Nat.sub_add_cancel hmone)
+ simpa only [hcast] using h
+ have hfactor : (0 : ℝ) ≤ ((m : ℝ) - 4) * ((m : ℝ) ^ 2 + m + 1) :=
+ mul_nonneg (sub_nonneg.mpr hm4) (by positivity)
+ have hstep : ((m : ℝ) + 1) ^ 3 ≤ 2 * (m : ℝ) ^ 3 := by
+ nlinarith only [hfactor]
+ have hpow : (2 : ℝ) ^ m = 2 * (2 : ℝ) ^ (m - 1) := by
+ calc
+ _ = (2 : ℝ) ^ ((m - 1) + 1) := by rw [Nat.sub_add_cancel hmone]
+ _ = _ := by rw [pow_succ]; ring
+ calc
+ _ ≤ 2 * (m : ℝ) ^ 3 := hstep
+ _ ≤ 2 * (8 * (2 : ℝ) ^ (m - 1)) := mul_le_mul_of_nonneg_left hprev (by norm_num)
+ _ = _ := by rw [hpow]; ring
+
+theorem dyadic_cubic_le_sixteen (m : ℕ) :
+ (2 / (2 : ℝ) ^ m) * ((m : ℝ) + 1) ^ 3 ≤ 16 := by
+ rw [div_mul_eq_mul_div, div_le_iff₀ (by positivity : (0 : ℝ) < (2 : ℝ) ^ m)]
+ nlinarith only [cubic_le_eight_mul_two_pow m]
+
+theorem dyadic_jet_factor_le_half {m : ℕ} (hm : 2 ≤ m) :
+ 2 / (2 : ℝ) ^ m ≤ 1 / 2 := by
+ have hpow : (4 : ℝ) ≤ (2 : ℝ) ^ m := by
+ convert pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 2) hm using 1
+ norm_num
+ apply (div_le_iff₀ (by positivity : (0 : ℝ) < (2 : ℝ) ^ m)).mpr
+ nlinarith
+
+/-- Cancellation of factorials and the old exponential base. -/
+theorem jet_increment_factorization {B : ℝ} {m : ℕ} (hm : 1 ≤ m) :
+ B ^ m * factorialMajorant m * (m.factorial : ℝ) =
+ (B * ((m : ℝ) + 1) ^ 3) *
+ (B ^ (m - 1) * (m.factorial : ℝ) ^ 3) := by
+ have hpow : B ^ m = B ^ (m - 1) * B := by
+ calc
+ _ = B ^ ((m - 1) + 1) := by rw [Nat.sub_add_cancel hm]
+ _ = _ := by rw [pow_succ]
+ rw [hpow]
+ unfold factorialMajorant
+ rw [Nat.factorial_succ]
+ push_cast
+ ring
+
+/-- The all-order scalar jet step with an explicit smallness condition. -/
+theorem scalar_jet_step {B C epsilon old increment : ℝ} {m : ℕ}
+ (hB : 0 ≤ B) (hm : 2 ≤ m) (hsmall : epsilon * C * B ≤ 1 / 32)
+ (hold : old ≤ B ^ (m - 1) * (m.factorial : ℝ) ^ 3)
+ (hincrement : increment ≤ epsilon * C * B ^ m *
+ factorialMajorant m * (m.factorial : ℝ)) :
+ (2 / (2 : ℝ) ^ m) * (old + increment) ≤
+ B ^ (m - 1) * (m.factorial : ℝ) ^ 3 := by
+ let allowance := B ^ (m - 1) * (m.factorial : ℝ) ^ 3
+ have hallowance : 0 ≤ allowance := by dsimp [allowance]; positivity
+ have hincrement' : increment ≤
+ (epsilon * C * B * ((m : ℝ) + 1) ^ 3) * allowance := by
+ calc
+ _ ≤ epsilon * C * B ^ m * factorialMajorant m * (m.factorial : ℝ) := hincrement
+ _ = _ := by
+ have h := jet_increment_factorization (B := B) (m := m) (by omega)
+ dsimp [allowance]
+ calc
+ _ = (epsilon * C) * (B ^ m * factorialMajorant m * (m.factorial : ℝ)) := by ring
+ _ = _ := by rw [h]; ring
+ have hproduct : epsilon * C * B *
+ ((2 / (2 : ℝ) ^ m) * ((m : ℝ) + 1) ^ 3) ≤ 1 / 2 := by
+ have h := mul_le_mul hsmall (dyadic_cubic_le_sixteen m)
+ (by positivity : (0 : ℝ) ≤ (2 / (2 : ℝ) ^ m) * ((m : ℝ) + 1) ^ 3)
+ (by norm_num : (0 : ℝ) ≤ 1 / 32)
+ norm_num at h ⊢
+ exact h
+ have hcoefficient : 2 / (2 : ℝ) ^ m + epsilon * C * B *
+ ((2 / (2 : ℝ) ^ m) * ((m : ℝ) + 1) ^ 3) ≤ 1 := by
+ linarith [dyadic_jet_factor_le_half hm]
+ calc
+ _ ≤ (2 / (2 : ℝ) ^ m) *
+ (allowance + (epsilon * C * B * ((m : ℝ) + 1) ^ 3) * allowance) :=
+ mul_le_mul_of_nonneg_left (add_le_add hold hincrement') (by positivity)
+ _ = (2 / (2 : ℝ) ^ m + epsilon * C * B *
+ ((2 / (2 : ℝ) ^ m) * ((m : ℝ) + 1) ^ 3)) * allowance := by ring
+ _ ≤ 1 * allowance := mul_le_mul_of_nonneg_right hcoefficient hallowance
+ _ = _ := by simp [allowance]
+
+/-- A positive parameter can be fixed once, after fixing the constants,
+so that the scalar jet step holds at every positive order above one. -/
+theorem exists_uniform_scalar_jet_step {B C : ℝ} (hB : 0 ≤ B) (hC : 0 ≤ C) :
+ ∃ epsilon : ℝ, 0 < epsilon ∧ ∀ (m : ℕ) (old increment : ℝ), 2 ≤ m →
+ old ≤ B ^ (m - 1) * (m.factorial : ℝ) ^ 3 →
+ increment ≤ epsilon * C * B ^ m * factorialMajorant m * (m.factorial : ℝ) →
+ (2 / (2 : ℝ) ^ m) * (old + increment) ≤
+ B ^ (m - 1) * (m.factorial : ℝ) ^ 3 := by
+ let epsilon := 1 / (32 * (C * B + 1))
+ have hCB : 0 ≤ C * B := mul_nonneg hC hB
+ have hepsilon : 0 < epsilon := by dsimp [epsilon]; positivity
+ have hsmall : epsilon * C * B ≤ 1 / 32 := by
+ have hden : 0 < 32 * (C * B + 1) := by positivity
+ calc
+ _ = (C * B) / (32 * (C * B + 1)) := by dsimp [epsilon]; ring
+ _ ≤ 1 / 32 := (div_le_iff₀ hden).mpr (by nlinarith)
+ exact ⟨epsilon, hepsilon, fun m old increment hm hold hincrement =>
+ scalar_jet_step hB hm hsmall hold hincrement⟩
+
+end
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/KernelBridgeNormalization.lean b/lean/OAI/Geometry/RCD/Coordinates/KernelBridgeNormalization.lean
new file mode 100644
index 0000000000000000000000000000000000000000..80e18daab752c2db14cc06979023c399044368ec
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/KernelBridgeNormalization.lean
@@ -0,0 +1,69 @@
+import OAI.Geometry.RCD.Heat.NonnegativeKernelBridgeMass
+import Mathlib.MeasureTheory.Measure.WithDensity
+import Mathlib.MeasureTheory.Measure.Typeclasses.Probability
+
+namespace OAI
+
+/-! # Exact normalization of an intermediate kernel bridge
+
+The composed kernel and one endpoint marginal fix the intermediate mass.
+This is the normalization identity for the entropic interpolation.
+-/
+
+open Set Filter MeasureTheory
+open scoped ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {A B Z : Type*} [MeasurableSpace A] [MeasurableSpace B] [MeasurableSpace Z]
+ (μ : Measure A) (ν : Measure B) (σ : Measure Z)
+ [IsProbabilityMeasure μ] [SFinite ν] [SFinite σ]
+
+theorem kernel_bridge_normalized {F : A → ℝ≥0∞} {G : B → ℝ≥0∞}
+ {L : A × Z → ℝ≥0∞} {R : Z × B → ℝ≥0∞} {K : A × B → ℝ≥0∞}
+ (hF : Measurable F) (hG : Measurable G) (hL : Measurable L) (hR : Measurable R)
+ (hconv : ∀ a b, (∫⁻ z, L (a,z)*R (z,b) ∂σ)=K (a,b))
+ (hrow : ∀ a, F a*(∫⁻ b, K (a,b)*G b ∂ν)=1) :
+ (∫⁻ z, (∫⁻ a, F a*L (a,z) ∂μ)*(∫⁻ b, R (z,b)*G b ∂ν) ∂σ)=1 := by
+ rw [nonnegative_kernel_bridge_mass μ ν σ
+ (L := fun z => F z.1 * L z) (R := fun z => R z * G z.2)
+ ((hF.comp measurable_fst).mul hL) (hR.mul (hG.comp measurable_snd))]
+ have hinner (a : A) (b : B) :
+ (∫⁻ z, (F a*L (a,z))*(R (z,b)*G b) ∂σ)=F a*(K (a,b)*G b) := by
+ have he : (fun z => (F a*L (a,z))*(R (z,b)*G b)) =
+ fun z => F a*((L (a,z)*R (z,b))*G b) := by
+ funext z
+ ac_rfl
+ rw [he,lintegral_const_mul (F a) (f := fun z => (L (a,z)*R (z,b))*G b)
+ (((hL.comp (measurable_const.prodMk measurable_id)).mul
+ (hR.comp (measurable_id.prodMk measurable_const))).mul_const (G b)),
+ lintegral_mul_const (G b) (f := fun z => L (a,z)*R (z,b))
+ ((hL.comp (measurable_const.prodMk measurable_id)).mul
+ (hR.comp (measurable_id.prodMk measurable_const))),hconv]
+ simp_rw [hinner]
+ have hKrow (a : A) : Measurable (fun b => K (a,b)) := by
+ have hm : Measurable (fun z : B × Z => L (a,z.2)*R (z.2,z.1)) :=
+ (hL.comp (measurable_const.prodMk measurable_snd)).mul
+ (hR.comp (measurable_snd.prodMk measurable_fst))
+ have hh : Measurable (fun b => ∫⁻ z, L (a,z)*R (z,b) ∂σ) := hm.lintegral_prod_right'
+ simpa only [hconv] using hh
+ have hout (a : A) : (∫⁻ b, F a*(K (a,b)*G b) ∂ν)=1 := by
+ rw [lintegral_const_mul (F a) (f := fun b => K (a,b)*G b) ((hKrow a).mul hG),hrow]
+ simp_rw [hout]
+ simp
+
+theorem kernel_bridge_probability {F : A → ℝ≥0∞} {G : B → ℝ≥0∞}
+ {L : A × Z → ℝ≥0∞} {R : Z × B → ℝ≥0∞} {K : A × B → ℝ≥0∞}
+ (hF : Measurable F) (hG : Measurable G) (hL : Measurable L) (hR : Measurable R)
+ (hconv : ∀ a b, (∫⁻ z, L (a,z)*R (z,b) ∂σ)=K (a,b))
+ (hrow : ∀ a, F a*(∫⁻ b, K (a,b)*G b ∂ν)=1) :
+ IsProbabilityMeasure (σ.withDensity
+ (fun z => (∫⁻ a, F a*L (a,z) ∂μ)*(∫⁻ b, R (z,b)*G b ∂ν))) := by
+ constructor
+ rw [withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ]
+ exact kernel_bridge_normalized μ ν σ hF hG hL hR hconv hrow
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/KernelHeatBoundedRegularity.lean b/lean/OAI/Geometry/RCD/Coordinates/KernelHeatBoundedRegularity.lean
new file mode 100644
index 0000000000000000000000000000000000000000..22e3ba4d9f621c3386318b2cac724e0b14f76066
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/KernelHeatBoundedRegularity.lean
@@ -0,0 +1,38 @@
+import OAI.Geometry.RCD.Heat.KernelHeatL2Representation
+import OAI.Geometry.RCD.Heat.BoundedHeatOrder
+
+namespace OAI
+
+/-! # Bounded heat regularity for the canonical kernel representative -/
+
+open Set Filter MeasureTheory TopologicalSpace
+open scoped NNReal
+noncomputable section
+namespace RegularPointCoordinates.NoncollapsedRCD
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [ProperSpace X] {K : ℝ} {n : ℕ} (hX : NoncollapsedRCD K n X)
+ (hn : 2 ≤ n) (p : X) [SeparableSpace X]
+ [IsLocallyFiniteMeasure (hausdorff n X)] [(hausdorff n X).Regular]
+
+include hn p in
+theorem kernelHeat_bounded_regularity {ker : ℝ → X → X → ℝ}
+ (hk : IsContinuousHeatKernel (hausdorff n X) hX.quadratic ker)
+ (f : Lp ℝ 2 (hausdorff n X)) (C : ℝ≥0)
+ (hC : ∀ᵐ x ∂hausdorff n X, |f x| ≤ C) (t : ℝ) (ht : 0 < t) :
+ LipschitzWith ⟨Real.sqrt ((C:ℝ)^2/(2*t*Real.exp (-2 * |K| * t))),Real.sqrt_nonneg _⟩
+ (kernelHeat (hausdorff n X) hX.quadratic hk t f) ∧
+ ∀ x, |kernelHeat (hausdorff n X) hX.quadratic hk t f x| ≤ C := by
+ have hf : HasBoundedAmplitude f := ⟨C,hC⟩
+ have he : hX.boundedHeat hn p f hf t ht = kernelHeat (hausdorff n X) hX.quadratic hk t f :=
+ hX.boundedHeat_unique hn p f hf t ht
+ (kernelHeat_continuous (hausdorff n X) hX.quadratic hk ht f)
+ (kernelHeat_represents_L2 (hausdorff n X) hX.quadratic hk ht f).symm
+ rw [← he]
+ exact ⟨hX.boundedHeat_lipschitz hn p f hf t ht C hC,
+ hX.boundedHeat_abs_le hn p f hf t ht C hC⟩
+
+end RegularPointCoordinates.NoncollapsedRCD
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/LaplacianCoordinateForm.lean b/lean/OAI/Geometry/RCD/Coordinates/LaplacianCoordinateForm.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ed62491c09b4a644fd0f62567c3ef578f01a90cf
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/LaplacianCoordinateForm.lean
@@ -0,0 +1,75 @@
+import OAI.Geometry.RCD.Coordinates.RegularSquareLaplacian
+import OAI.Geometry.RCD.Coordinates.CoordinateBilinear
+
+namespace OAI
+
+/-! # Pointwise linear representatives of the actual finite Laplacian map -/
+
+open Set Filter MeasureTheory
+open scoped NNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MeasurableSpace X] (μ : Measure X) {m : ℕ}
+
+/-- Evaluation of the finitely many L² source coordinates defines a
+pointwise linear form without choosing representatives for each direction. -/
+def laplacianCoordinateForm (D : Euclidean m →L[ℝ] Lp ℝ 2 μ) (x : X) :
+ Euclidean m →ₗ[ℝ] ℝ :=
+ (EuclideanSpace.basisFun (Fin m) ℝ).toBasis.constr ℝ
+ (fun i => D (EuclideanSpace.single i 1) x)
+
+theorem laplacianCoordinateForm_apply (D : Euclidean m →L[ℝ] Lp ℝ 2 μ)
+ (x : X) (a : Euclidean m) :
+ laplacianCoordinateForm μ D x a=∑ i, a i*D (EuclideanSpace.single i 1) x := by
+ simp only [laplacianCoordinateForm,Module.Basis.constr_apply_fintype,smul_eq_mul]
+ rfl
+
+theorem laplacianCoordinateForm_rep (D : Euclidean m →L[ℝ] Lp ℝ 2 μ) (a : Euclidean m) :
+ D a =ᵐ[μ] fun x => laplacianCoordinateForm μ D x a := by
+ let b := (EuclideanSpace.basisFun (Fin m) ℝ).toBasis
+ have he : b.constr ℝ (fun i => D (EuclideanSpace.single i 1))=D.toLinearMap := by
+ apply b.ext
+ intro i
+ simp [b,EuclideanSpace.basisFun_apply]
+ have hs : D a=∑ i, a i • D (EuclideanSpace.single i 1) := by
+ have h := congrArg (fun F : Euclidean m →ₗ[ℝ] Lp ℝ 2 μ => F a) he
+ rw [Module.Basis.constr_apply_fintype] at h
+ exact h.symm
+ rw [hs]
+ filter_upwards [Lp.coeFn_fun_finsetSum Finset.univ
+ (fun i : Fin m => a i • D (EuclideanSpace.single i 1)),
+ ae_all_iff.mpr (fun i : Fin m => Lp.coeFn_smul (a i) (D (EuclideanSpace.single i 1)))]
+ with x hx hy
+ rw [laplacianCoordinateForm_apply, hx]
+ exact Finset.sum_congr rfl (fun i _ => hy i)
+
+variable [MetricSpace X] [BorelSpace X] [ProperSpace X]
+ (hQ : QuadraticCheegerEnergy μ) [μ.Regular]
+
+/-- The source of an actual squared direction is the exact linear source
+correction used by the shifted quadratic-perturbation argument. -/
+theorem laplacianCoordinateForm_square
+ (U : Euclidean m →L[ℝ] SobolevSpace μ hQ) (D : Euclidean m →L[ℝ] Lp ℝ 2 μ)
+ (hD : ∀ a, IsWeakLaplacian μ hQ (U a) (D a))
+ (w z : Euclidean m) (A L : ℝ≥0)
+ (hA : ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ (U w) x|≤A)
+ (hL : ∀ᵐ x ∂μ, localGamma μ hQ (U w) (U w) x≤(L:ℝ)^2)
+ (hz : U z=SobolevSpace.product μ hQ (U w) (U w) A A) :
+ ∀ᵐ x ∂μ, laplacianCoordinateForm μ D x z =
+ 2*SobolevSpace.toLp μ hQ (U w) x*laplacianCoordinateForm μ D x w+
+ 2*localGamma μ hQ (U w) (U w) x := by
+ obtain ⟨q,hq,hqr⟩ := (hD w).product μ hQ (U w) (U w) (D w) (D w)
+ (hD w) A A L hA hA hL
+ have hqz : D z=q := IsWeakLaplacian.unique μ hQ (by simpa only [hz] using hD z) hq
+ filter_upwards [hqr,laplacianCoordinateForm_rep μ D z,laplacianCoordinateForm_rep μ D w]
+ with x hq hz hw
+ rw [← hz,hqz,hq,hw]
+ ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/LimitChart.lean b/lean/OAI/Geometry/RCD/Coordinates/LimitChart.lean
new file mode 100644
index 0000000000000000000000000000000000000000..670e10fceab7ca5230b01a2cd663a480f5f9a061
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/LimitChart.lean
@@ -0,0 +1,117 @@
+import OAI.Geometry.RCD.Coordinates.ChartTopology
+import OAI.Geometry.RCD.Coordinates.TaylorControl
+
+namespace OAI
+
+/-!
+# From finite-scale Taylor estimates to the limiting chart
+
+Geometric increments, derivative bounds on scale-selected value-space
+segments, and linear separation give two-sided distance bounds for the
+limit. Euclidean invariance of domain gives its open image, as in
+Hatcher, *Algebraic Topology* (2002), Theorem 2B.3.
+-/
+
+open Set Filter
+open scoped Topology
+
+namespace RegularPointCoordinates
+
+private theorem quarter_scale_arithmetic {q t v : ℝ} (hq : 1 ≤ q)
+ (ht : 0 ≤ t)
+ (hl : ((2 * q)⁻¹ - (8 * q)⁻¹ - (8 * q)⁻¹) * t ≤ v)
+ (hu : v ≤ (2 * q + (8 * q)⁻¹ + (8 * q)⁻¹) * t) :
+ (4 * q)⁻¹ * t ≤ v ∧ v ≤ (4 * q) * t := by
+ have heq : (2 * q)⁻¹ - (8 * q)⁻¹ - (8 * q)⁻¹ = (4 * q)⁻¹ := by
+ field_simp; ring
+ have hinv : (8 * q)⁻¹ ≤ 1 := inv_le_one_of_one_le₀ (by linarith)
+ have hcoeff : 2 * q + (8 * q)⁻¹ + (8 * q)⁻¹ ≤ 4 * q := by
+ linarith
+ exact ⟨heq ▸ hl, hu.trans (mul_le_mul_of_nonneg_right hcoeff ht)⟩
+
+/-- The all-pairs metric conclusion from scale-selected Taylor estimates
+and a geometric increment bound. All source distances are ambient ones. -/
+theorem exists_limit_dist_bounds_of_taylor
+ {X : Type*} [MetricSpace X] {n : ℕ}
+ (u : X → Euclidean n) (h : ℕ → Euclidean n → Euclidean n)
+ (dh : ℕ → Euclidean n → Euclidean n →L[ℝ] Euclidean n)
+ (ddh : ℕ → Euclidean n → Euclidean n →L[ℝ]
+ (Euclidean n →L[ℝ] Euclidean n))
+ {q C : ℝ} (hq : 1 ≤ q)
+ (hstep : ∀ i x, dist (h i (u x)) (h (i + 1) (u x)) ≤ C * (1 / 2 : ℝ) ^ i)
+ (hpairs : ∀ x z : X, x ≠ z → ∃ i M,
+ 0 ≤ M ∧
+ (∀ y ∈ segment ℝ (u x) (u z), HasFDerivAt (h i) (dh i y) y) ∧
+ (∀ y ∈ segment ℝ (u x) (u z), HasFDerivAt (dh i) (ddh i y) y) ∧
+ (∀ y ∈ segment ℝ (u x) (u z), ‖ddh i y (u z - u x) (u z - u x)‖ ≤ M) ∧
+ (2 * q)⁻¹ * dist x z ≤ ‖dh i (u x) (u z - u x)‖ ∧
+ ‖dh i (u x) (u z - u x)‖ ≤ (2 * q) * dist x z ∧
+ M ≤ (8 * q)⁻¹ * dist x z ∧
+ 4 * C * (1 / 2 : ℝ) ^ i ≤ (8 * q)⁻¹ * dist x z) :
+ ∃ F : X → Euclidean n,
+ (∀ x, Tendsto (fun i => h i (u x)) atTop (𝓝 (F x))) ∧
+ ∀ x z, (4 * q)⁻¹ * dist x z ≤ dist (F x) (F z) ∧
+ dist (F x) (F z) ≤ (4 * q) * dist x z := by
+ obtain ⟨F, hlim, htail⟩ := exists_limit_of_geometric_step
+ (by norm_num : (1 / 2 : ℝ) < 1) hstep
+ refine ⟨F, hlim, ?_⟩
+ intro x z
+ by_cases hxz : x = z
+ · subst z
+ simp
+ obtain ⟨i, M, hM, hd, hdd, hnorm, hl, hu, hrem, ht⟩ := hpairs x z hxz
+ have happrox := dist_bounds_of_directional_taylor hM hd hdd hnorm hl hu hrem
+ rw [dist_comm (h i (u z)) (h i (u x))] at happrox
+ have htailx : dist (F x) (h i (u x)) ≤ 2 * C * (1 / 2 : ℝ) ^ i := by
+ have hh := htail i x
+ rw [dist_comm] at hh
+ norm_num at hh ⊢
+ nlinarith
+ have htailz : dist (F z) (h i (u z)) ≤ 2 * C * (1 / 2 : ℝ) ^ i := by
+ have hh := htail i z
+ rw [dist_comm] at hh
+ norm_num at hh ⊢
+ nlinarith
+ have herror : dist (F x) (h i (u x)) + dist (F z) (h i (u z)) ≤
+ (8 * q)⁻¹ * dist x z := by linarith
+ have hbound := dist_bounds_of_approximation
+ (f := fun x => h i (u x)) (F := F) x z happrox.1 happrox.2 herror
+ apply quarter_scale_arithmetic hq dist_nonneg
+ · exact hbound.1
+ · exact hbound.2
+
+/-- Scale-selected Taylor bounds and geometric increment estimates give an open
+bi-Lipschitz chart by Euclidean invariance of domain. -/
+theorem hasOpenBilipschitzChart_of_taylor_data
+ {X : Type*} [MetricSpace X] {n : ℕ} {p : X}
+ (hIOD : EuclideanInvarianceOfDomain n)
+ {U : Set X} (hU : IsOpen U) (hp : p ∈ U)
+ {O : Set (Euclidean n)} (hO : IsOpen O) (u : U ≃ₜ O)
+ (h : ℕ → Euclidean n → Euclidean n)
+ (dh : ℕ → Euclidean n → Euclidean n →L[ℝ] Euclidean n)
+ (ddh : ℕ → Euclidean n → Euclidean n →L[ℝ]
+ (Euclidean n →L[ℝ] Euclidean n))
+ {q C : ℝ} (hq : 1 ≤ q)
+ (hstep : ∀ i (x : U),
+ dist (h i (u x)) (h (i + 1) (u x)) ≤ C * (1 / 2 : ℝ) ^ i)
+ (hpairs : ∀ x z : U, x ≠ z → ∃ i M,
+ 0 ≤ M ∧
+ (∀ y ∈ segment ℝ (u x : Euclidean n) (u z : Euclidean n),
+ HasFDerivAt (h i) (dh i y) y) ∧
+ (∀ y ∈ segment ℝ (u x : Euclidean n) (u z : Euclidean n),
+ HasFDerivAt (dh i) (ddh i y) y) ∧
+ (∀ y ∈ segment ℝ (u x : Euclidean n) (u z : Euclidean n),
+ ‖ddh i y ((u z : Euclidean n) - u x) ((u z : Euclidean n) - u x)‖ ≤ M) ∧
+ (2 * q)⁻¹ * dist x z ≤ ‖dh i (u x) ((u z : Euclidean n) - u x)‖ ∧
+ ‖dh i (u x) ((u z : Euclidean n) - u x)‖ ≤ (2 * q) * dist x z ∧
+ M ≤ (8 * q)⁻¹ * dist x z ∧
+ 4 * C * (1 / 2 : ℝ) ^ i ≤ (8 * q)⁻¹ * dist x z) :
+ HasOpenBilipschitzChart n p := by
+ obtain ⟨F, _, hF⟩ := exists_limit_dist_bounds_of_taylor
+ (fun x : U => (u x : Euclidean n)) h dh ddh hq hstep hpairs
+ exact hasOpenBilipschitzChart_of_coordinates_and_bounds hIOD hU hp hO u
+ (by linarith : 1 ≤ 4 * q) hF
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/LinearNormalization.lean b/lean/OAI/Geometry/RCD/Coordinates/LinearNormalization.lean
new file mode 100644
index 0000000000000000000000000000000000000000..b0ab3baf02431bdb260bc3462620f36fdd27f9fb
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/LinearNormalization.lean
@@ -0,0 +1,104 @@
+import OAI.Geometry.RCD.Coordinates.GramNormalization
+
+namespace OAI
+
+/-! # Construction of exact normalizers for positive definite Gram operators -/
+
+open scoped BigOperators InnerProductSpace
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+ [FiniteDimensional ℝ E]
+
+/-- A positive definite symmetric operator admits an exact congruence
+normalization. The proof constructs it in an orthonormal eigenbasis. -/
+theorem exists_exact_operator_normalization (Q : E →L[ℝ] E)
+ (hQ : Q.IsSymmetric) (hpos : ∀ v : E, v ≠ 0 → 0 < ⟪v, Q v⟫_ℝ) :
+ ∃ A : E ≃L[ℝ] E,
+ (A : E →L[ℝ] E).adjoint.comp (Q.comp (A : E →L[ℝ] E)) =
+ ContinuousLinearMap.id ℝ E := by
+ let b := hQ.eigenvectorBasis rfl
+ let lam := hQ.eigenvalues rfl
+ have hlam (i : Fin (Module.finrank ℝ E)) : 0 < lam i := by
+ have hn : b i ≠ 0 := b.orthonormal.ne_zero i
+ have hp := hpos (b i) hn
+ have he : Q (b i) = lam i • b i := hQ.apply_eigenvectorBasis rfl i
+ rw [he, inner_smul_right] at hp
+ simpa only [real_inner_self_eq_norm_sq, b.norm_eq_one, one_pow, mul_one] using hp
+ let L : E →L[ℝ] E := ∑ i : Fin (Module.finrank ℝ E),
+ ((EuclideanSpace.proj i).comp (b.repr.toContinuousLinearEquiv :
+ E →L[ℝ] Euclidean (Module.finrank ℝ E))).smulRight
+ ((Real.sqrt (lam i))⁻¹ • b i)
+ have hL (v : E) (i : Fin (Module.finrank ℝ E)) :
+ b.repr (L v) i = (Real.sqrt (lam i))⁻¹ * b.repr v i := by
+ simp [L, map_sum, map_smul, b.repr_self, Pi.single_apply, mul_comm]
+ have hQL (v : E) (i : Fin (Module.finrank ℝ E)) :
+ b.repr (Q (L v)) i = lam i * ((Real.sqrt (lam i))⁻¹ * b.repr v i) := by
+ have he := hQ.eigenvectorBasis_apply_self_apply rfl (L v) i
+ change b.repr (Q (L v)) i = lam i * b.repr (L v) i at he
+ rw [he, hL]
+ have henergy (v : E) : ⟪L v, Q (L v)⟫_ℝ = ‖v‖ ^ 2 := by
+ rw [← b.repr.inner_map_map]
+ simp only [PiLp.inner_apply, RCLike.inner_apply, conj_trivial]
+ rw [← b.repr.norm_map v, EuclideanSpace.real_norm_sq_eq]
+ apply Finset.sum_congr rfl
+ intro i _
+ rw [hL, hQL]
+ have hs : Real.sqrt (lam i) ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr (hlam i))
+ have hs2 := Real.sq_sqrt (hlam i).le
+ field_simp
+ nlinarith
+ have hinj : Function.Injective L := by
+ apply (LinearMap.ker_eq_bot).mp
+ apply LinearMap.ker_eq_bot'.mpr
+ intro v hv
+ change L v = 0 at hv
+ have he := henergy v
+ rw [hv, inner_zero_left] at he
+ exact norm_eq_zero.mp (sq_eq_zero_iff.mp he.symm)
+ let A : E ≃L[ℝ] E := (LinearEquiv.ofInjectiveEndo L.toLinearMap hinj).toContinuousLinearEquiv
+ refine ⟨A, ?_⟩
+ apply ContinuousLinearMap.ext
+ intro v
+ apply ext_inner_right ℝ
+ intro w
+ simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.adjoint_inner_left,
+ ContinuousLinearMap.id_apply]
+ have hpair : ∀ v w : E, ⟪L v, Q (L w)⟫_ℝ = ⟪v, w⟫_ℝ := by
+ intro v w
+ have hplus := henergy (v + w)
+ have hv := henergy v
+ have hw := henergy w
+ have hsym : ⟪L w, Q (L v)⟫_ℝ = ⟪L v, Q (L w)⟫_ℝ := by
+ calc
+ _ = ⟪Q (L v), L w⟫_ℝ := real_inner_comm _ _
+ _ = _ := hQ _ _
+ simp only [map_add, inner_add_left, inner_add_right, hsym] at hplus
+ rw [norm_add_sq_real] at hplus
+ linarith
+ change ⟪Q (L v), L w⟫_ℝ = ⟪v, w⟫_ℝ
+ exact (hQ _ _).trans (hpair v w)
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : MeasureTheory.Measure X) (hQ : QuadraticCheegerEnergy μ)
+ (U : E →L[ℝ] SobolevSpace μ hQ)
+
+/-- Positive definiteness of the actual mean energy suffices to construct
+the exact normalizer; the normalizer itself need not be assumed. -/
+theorem exists_exact_mean_normalization (s : Set X) (hs : MeasurableSet s)
+ (hpos : ∀ v : E, v ≠ 0 → 0 < ⟪v, sobolevMeanGram μ hQ U s hs v⟫_ℝ) :
+ ∃ A : E ≃L[ℝ] E, IsExactMeanNormalization μ hQ U s hs A := by
+ obtain ⟨A, hA⟩ := exists_exact_operator_normalization
+ (sobolevMeanGram μ hQ U s hs) (sobolevMeanGram_isPositive μ hQ U s hs).isSymmetric hpos
+ refine ⟨A, ?_⟩
+ unfold IsExactMeanNormalization
+ rw [sobolevMeanGram_comp, hA]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/LinearRadialFits.lean b/lean/OAI/Geometry/RCD/Coordinates/LinearRadialFits.lean
new file mode 100644
index 0000000000000000000000000000000000000000..a3a5ede07024602ff257f66135f1cf0ac0a76149
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/LinearRadialFits.lean
@@ -0,0 +1,89 @@
+import OAI.Geometry.RCD.Sobolev.FiniteColumnEnergy
+import OAI.Geometry.RCD.Sobolev.CenteredAffineSobolev
+import OAI.Geometry.RCD.Harmonic.CenteredColumns
+
+namespace OAI
+
+/-! # Linear assembly of the actual centered radial fits -/
+
+open Set MeasureTheory
+open scoped BigOperators InnerProductSpace ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+/-- The original affine coefficients, extended linearly from basis rows. -/
+def finiteCoefficientMap {n : ℕ} (coeff : Fin n → Euclidean n) :
+ Euclidean n →L[ℝ] Euclidean n :=
+ ∑ j, (EuclideanSpace.proj j).smulRight (coeff j)
+
+theorem finiteCoefficientMap_apply {n : ℕ} (coeff : Fin n → Euclidean n) (b : Euclidean n) :
+ finiteCoefficientMap coeff b = ∑ j, b j • coeff j := by
+ simp [finiteCoefficientMap]
+
+theorem finiteCoefficientMap_single {n : ℕ} (coeff : Fin n → Euclidean n) (j : Fin n) :
+ finiteCoefficientMap coeff (EuclideanSpace.single j 1) = coeff j := by
+ classical
+ simp [finiteCoefficientMap_apply, PiLp.single_apply]
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- Centering preserves the linear dependence on the affine covector. -/
+def centeredSobolevMap {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (η : SobolevSpace μ hQ) (v : Euclidean n) : Euclidean n →L[ℝ] SobolevSpace μ hQ :=
+ sobolevColumnMap μ hQ u - (innerSL ℝ v).smulRight η
+
+omit [BorelSpace X] [ProperSpace X] in
+theorem centeredSobolevMap_apply {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (η : SobolevSpace μ hQ) (v a : Euclidean n) :
+ centeredSobolevMap μ hQ u η v a = centeredAffineSobolev μ hQ u η v a := by
+ change sobolevColumnMap μ hQ u a - ⟪v, a⟫_ℝ • η =
+ (-⟪v, a⟫_ℝ) • η + sobolevColumnMap μ hQ u a
+ module
+
+omit [BorelSpace X] [ProperSpace X] in
+/-- Combining centered row fits is exactly the centered fit with the
+combined coefficient, so the value and gradient estimates use one residual. -/
+theorem centered_radial_residual_column {n : ℕ}
+ (u g : Fin n → SobolevSpace μ hQ) (η : SobolevSpace μ hQ) (v : Euclidean n)
+ (coeff : Fin n → Euclidean n) (b : Euclidean n) :
+ sobolevColumnMap μ hQ (fun j => g j - centeredAffineSobolev μ hQ u η v (coeff j)) b =
+ sobolevColumnMap μ hQ g b - centeredAffineSobolev μ hQ u η v (finiteCoefficientMap coeff b) := by
+ let R := sobolevColumnMap μ hQ g - (centeredSobolevMap μ hQ u η v).comp (finiteCoefficientMap coeff)
+ have hrow : (fun j => g j - centeredAffineSobolev μ hQ u η v (coeff j)) =
+ (fun j => R (EuclideanSpace.single j 1)) := by
+ funext j
+ simp only [R, sub_apply, ContinuousLinearMap.comp_apply,
+ sobolevColumnMap_single, finiteCoefficientMap_single, centeredSobolevMap_apply]
+ rw [hrow, sobolevColumnMap_of_linear]
+ simp only [R, sub_apply, ContinuousLinearMap.comp_apply, centeredSobolevMap_apply]
+
+/-- All rowwise W12 bounds from the actual dyadic radial construction
+extend to every covector with the same combined affine coefficient. -/
+theorem linear_centered_radial_bounds {n : ℕ}
+ (u g : Fin n → SobolevSpace μ hQ) (η : SobolevSpace μ hQ) (v : Euclidean n)
+ (coeff : Fin n → Euclidean n) (Ω Ω' : Set X) (hfin : μ Ω ≠ ∞) {E D : ℝ} (hE : 0 ≤ E)
+ (hvalue : ∀ j, ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω
+ (g j - centeredAffineSobolev μ hQ u η v (coeff j)))‖ ^ 2 ≤ E)
+ (henergy : ∀ j, (∫ x in Ω', localGamma μ hQ
+ (g j - centeredAffineSobolev μ hQ u η v (coeff j))
+ (g j - centeredAffineSobolev μ hQ u η v (coeff j)) x ∂μ) ≤ D)
+ (b : Euclidean n) :
+ let R := sobolevColumnMap μ hQ g b - centeredAffineSobolev μ hQ u η v (finiteCoefficientMap coeff b)
+ ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω R)‖ ^ 2 ≤ (n : ℝ) ^ 2 * E * ‖b‖ ^ 2 ∧
+ (∫ x in Ω', localGamma μ hQ R R x ∂μ) ≤ (n : ℝ) ^ 2 * D * ‖b‖ ^ 2 := by
+ dsimp only
+ constructor
+ · have hh := normalized_column_sq_le μ hQ
+ (fun j => g j - centeredAffineSobolev μ hQ u η v (coeff j)) Ω hfin hE hvalue b
+ rwa [centered_radial_residual_column μ hQ] at hh
+ · have hh := column_energy_bound μ hQ
+ (fun j => g j - centeredAffineSobolev μ hQ u η v (coeff j)) Ω' henergy b
+ rwa [centered_radial_residual_column μ hQ] at hh
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/LocalConstantRepresentative.lean b/lean/OAI/Geometry/RCD/Coordinates/LocalConstantRepresentative.lean
new file mode 100644
index 0000000000000000000000000000000000000000..748e95a4bcb07126369b5cd1dee4d32341d30508
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/LocalConstantRepresentative.lean
@@ -0,0 +1,44 @@
+import OAI.Geometry.RCD.Coordinates.OpenRegularCutoff
+import OAI.Geometry.RCD.Sobolev.FiniteEnergyRepresentatives
+
+namespace OAI
+
+/-! # Bounded Sobolev representatives of constants on a fixed ball -/
+
+open Set Filter Metric MeasureTheory
+open scoped NNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- A compact regular plateau represents the local constant without
+requiring a globally square-integrable constant function. -/
+theorem NoncollapsedRCD.local_constant_representative {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2≤n) (p : X) (R c : ℝ) :
+ ∃ d : SobolevSpace (hausdorff n X) hX.quadratic,
+ (∀ᵐ x ∂hausdorff n X, |SobolevSpace.toLp (hausdorff n X) hX.quadratic d x|≤‖c‖₊) ∧
+ SobolevSpace.toLp (hausdorff n X) hX.quadratic d
+ =ᵐ[(hausdorff n X).restrict (ball p R)] fun _ => c := by
+ let := locallyFinite_of_finiteOnBounded (hausdorff n X) hX.finiteOnBounded
+ let μ := hausdorff n X
+ obtain ⟨χ,-,hχ1⟩ := hX.exists_open_regular_cutoff hn isOpen_univ (isCompact_closedBall p R) (subset_univ _)
+ have hrep := sobolev_smul_representative μ hX.quadratic c
+ (Ω := univ) (by simpa only [Measure.restrict_univ] using χ.representative)
+ have hr : SobolevSpace.toLp μ hX.quadratic (c • χ.sobolev)
+ =ᵐ[μ] fun x => c*χ.weight x := by simpa only [Measure.restrict_univ] using hrep
+ refine ⟨c • χ.sobolev,?_,?_⟩
+ · filter_upwards [hr] with x hx
+ rw [hx,abs_mul,coe_nnnorm,Real.norm_eq_abs]
+ calc
+ |c| * |χ.weight x| ≤ |c| * 1 := mul_le_mul_of_nonneg_left (χ.abs_le x) (abs_nonneg c)
+ _ = |c| := mul_one _
+ · filter_upwards [ae_restrict_of_ae hr,ae_restrict_mem measurableSet_ball] with x hx hm
+ rw [hx,hχ1 x (ball_subset_closedBall hm),mul_one]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/LocalCoordinateExtension.lean b/lean/OAI/Geometry/RCD/Coordinates/LocalCoordinateExtension.lean
new file mode 100644
index 0000000000000000000000000000000000000000..78de778c88c3418a1a2c67bf182ba45c286af583
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/LocalCoordinateExtension.lean
@@ -0,0 +1,45 @@
+import OAI.Geometry.RCD.Coordinates.SplittingApproximation
+
+namespace OAI
+
+/-! # Measurable extensions preserving the local metric approximation -/
+
+open Set Metric MeasureTheory
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X]
+
+/-- Only values on the closed testing ball enter a pointed approximation. -/
+theorem IsPointedApproximation.congr_on_ball {Y : Type*} [MetricSpace Y]
+ {p : X} {q : Y} {r R ε : ℝ} {f g : X → Y}
+ (hRr : 0 ≤ R * r) (hf : IsPointedApproximation p q r R ε f)
+ (hfg : EqOn f g (closedBall p (R * r))) :
+ IsPointedApproximation p q r R ε g := by
+ have hp : f p = g p := hfg (by simpa only [mem_closedBall, dist_self] using hRr)
+ refine ⟨by simpa only [hp] using hf.1, ?_, ?_⟩
+ · intro x y hx hy
+ rw [← hfg hx, ← hfg hy]
+ exact hf.2.1 x y hx hy
+ · intro y hy
+ obtain ⟨x, hx, hxy⟩ := hf.2.2 y hy
+ exact ⟨x, hx, by rwa [← hfg hx]⟩
+
+/-- A continuous local coordinate map has a measurable extension which
+agrees pointwise throughout its open domain. -/
+theorem exists_measurable_local_extension [MeasurableSpace X] [BorelSpace X]
+ {n : ℕ} {s : Set X} (hs : MeasurableSet s) {v : X → Euclidean n}
+ (hv : ContinuousOn v s) :
+ ∃ v' : X → Euclidean n, Measurable v' ∧ EqOn v v' s := by
+ classical
+ refine ⟨s.piecewise v (fun _ => 0),
+ hv.measurable_piecewise continuous_const.continuousOn hs, ?_⟩
+ intro x hx
+ simp only [piecewise_eq_of_mem s v (fun _ => 0) hx]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/LocalCoordinateImageMass.lean b/lean/OAI/Geometry/RCD/Coordinates/LocalCoordinateImageMass.lean
new file mode 100644
index 0000000000000000000000000000000000000000..41f9d0403940efe71d461a72f089115ca0870eb2
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/LocalCoordinateImageMass.lean
@@ -0,0 +1,62 @@
+import OAI.Geometry.RCD.Coordinates.CoordinateImageMass
+
+namespace OAI
+
+/-! # Localizing image mass to its actual source preimage -/
+
+open Set Metric MeasureTheory
+open scoped NNReal ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+
+theorem local_source_mass_of_image_defect {n : ℕ}
+ (hEuclidean : hausdorff n (Euclidean n) = volume)
+ {v : X → Euclidean n} {U S : Set X} {C : ℝ≥0}
+ (hU : IsCompact U) (hv : LipschitzOnWith C v U) (hfin : hausdorff n X S ≠ ⊤)
+ (z : Euclidean n) (R δ : ℝ)
+ (hpreimage : ∀ x ∈ U, v x ∈ ball z R → x ∈ S)
+ (hdefect : volume.real (ball z R \ v '' U) ≤ δ*volume.real (ball z R)) :
+ (1-δ)*volume.real (ball z R) ≤ (C:ℝ)^n*(hausdorff n X).real S := by
+ have himage : IsCompact (v '' U) := hU.image_of_continuousOn hv.continuousOn
+ have hsplit := measureReal_inter_add_sdiff (μ := (volume : Measure (Euclidean n)))
+ himage.measurableSet (s := ball z R) measure_ball_ne_top
+ have hcap : hausdorff n X (U ∩ S) ≠ ⊤ := measure_ne_top_of_subset inter_subset_right hfin
+ have hv' := hv.mono (inter_subset_left : U ∩ S ⊆ U)
+ have htargetfin : hausdorff n (Euclidean n) (v '' (U ∩ S)) ≠ ⊤ :=
+ ne_top_of_le_ne_top (ENNReal.mul_ne_top (ENNReal.pow_ne_top ENNReal.coe_ne_top) hcap)
+ (normalized_hausdorff_image_le hv')
+ have hsub : ball z R ∩ v '' U ⊆ v '' (U ∩ S) := by
+ rintro y ⟨hy,x,hx,rfl⟩
+ exact ⟨x,⟨hx,hpreimage x hx hy⟩,rfl⟩
+ have hinter := measureReal_mono hsub (show volume (v '' (U ∩ S)) ≠ ⊤ by
+ rwa [hEuclidean] at htargetfin)
+ have hmass := normalized_hausdorff_real_image_le hv' hcap
+ rw [hEuclidean] at hmass
+ have hcapmass : (hausdorff n X).real (U ∩ S) ≤ (hausdorff n X).real S :=
+ measureReal_mono inter_subset_right hfin
+ have hbound := mul_le_mul_of_nonneg_left hcapmass (pow_nonneg C.coe_nonneg n)
+ nlinarith only [hsplit,hdefect,hinter,hmass,hbound]
+
+theorem local_source_mass_of_image_error {n : ℕ}
+ (hEuclidean : hausdorff n (Euclidean n) = volume)
+ {v : X → Euclidean n} {U S : Set X} {C : ℝ≥0}
+ (hU : IsCompact U) (hv : LipschitzOnWith C v U) (hfin : hausdorff n X S ≠ ⊤)
+ (z : Euclidean n) {R : ℝ} (hR : 0 < R) (E : ℝ)
+ (hpreimage : ∀ x ∈ U, v x ∈ ball z R → x ∈ S)
+ (herror : volume.real (ball z R \ v '' U) ≤ E) :
+ volume.real (ball z R)-E ≤ (C:ℝ)^n*(hausdorff n X).real S := by
+ have hpos : 0 < volume.real (ball z R) := ENNReal.toReal_pos
+ (measure_ball_pos volume z hR).ne' measure_ball_ne_top
+ have hh := local_source_mass_of_image_defect hEuclidean hU hv hfin z R
+ (E/volume.real (ball z R)) hpreimage (by
+ rwa [div_mul_cancel₀ E hpos.ne'])
+ have he : (1-E/volume.real (ball z R))*volume.real (ball z R)=
+ volume.real (ball z R)-E := by field_simp
+ rwa [he] at hh
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/LocalFramePathVelocity.lean b/lean/OAI/Geometry/RCD/Coordinates/LocalFramePathVelocity.lean
new file mode 100644
index 0000000000000000000000000000000000000000..8cf8ca75eed83d89baddf21e57d2af9064e5943a
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/LocalFramePathVelocity.lean
@@ -0,0 +1,76 @@
+import OAI.Geometry.RCD.Coordinates.FrameTestPlanVelocityDefect
+import OAI.Geometry.RCD.Coordinates.FrameVelocityErrorLocality
+
+namespace OAI
+
+/-! # Scalar path derivatives for local coordinate representatives -/
+
+open Set Filter MeasureTheory TopologicalSpace
+open scoped ENNReal InnerProductSpace
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem local_frame_path_velocity (μ : Measure X) (Q : QuadraticCheegerEnergy μ)
+ {n : ℕ} (u U : Fin n → SobolevSpace μ Q) (g : SobolevSpace μ Q)
+ (v W : X → Euclidean n) (φ : X → ℝ) (hW : Continuous W) (hφ : Continuous φ)
+ (hU : ∀ i, SobolevSpace.toLp μ Q (U i) =ᵐ[μ] fun x => W x i)
+ (hg : SobolevSpace.toLp μ Q g =ᵐ[μ] φ)
+ {Ω : Set X} (hΩ : MeasurableSet Ω)
+ (hu : ∀ i, SobolevSpace.toLp μ Q (U i) =ᵐ[μ.restrict Ω] SobolevSpace.toLp μ Q (u i))
+ (hv : EqOn W v Ω)
+ (π : Measure C(Time,X)) [IsFiniteMeasure π]
+ (hgeo : ∀ᵐ γ ∂π, IsGeodesic γ) {C : ℝ≥0∞} (hC : C≠∞)
+ (hcomp : ∀ t : Time, π.map (fun γ => γ t)≤C • μ)
+ (hD : MemLp (fun γ : C(Time,X) => dist (γ 0) (γ 1)) 2 π)
+ (hstay : ∀ᵐ γ ∂π, ∀ t : Time, γ t∈Ω) :
+ ∀ᵐ γ ∂π,
+ AbsolutelyContinuousOnInterval (fun t => φ (geodesicExtension γ t)) 0 1 ∧
+ (∀ i, AbsolutelyContinuousOnInterval (fun t => v (geodesicExtension γ t) i) 0 1) ∧
+ ∀ᵐ t : ℝ, t∈Ioo (0:ℝ) 1 →
+ (deriv (fun s => φ (geodesicExtension γ s)) t-
+ ∑ i, localGamma μ Q (u i) g (geodesicExtension γ t)*
+ deriv (fun s => v (geodesicExtension γ s) i) t)^2≤
+ (dist (γ 0) (γ 1))^2*frameVelocityError μ Q u g (geodesicExtension γ t) := by
+ have hvel := frame_testPlan_velocity_defect μ Q U g W φ hW hφ hU hg π hgeo hC hcomp hD
+ have hf := (SobolevSpace.minimalSlope_isRelaxed μ Q g).testPlan_ae_absolutelyContinuous
+ μ π hgeo hC hcomp hD hφ hg
+ have hc (i : Fin n) := (SobolevSpace.minimalSlope_isRelaxed μ Q (U i)).testPlan_ae_absolutelyContinuous
+ μ π hgeo hC hcomp hD ((EuclideanSpace.proj i).continuous.comp hW) (hU i)
+ have hG (i : Fin n) := localGamma_pair_congr_ae μ Q (hu i)
+ (show SobolevSpace.toLp μ Q g =ᵐ[μ.restrict Ω] SobolevSpace.toLp μ Q g
+ from Eventually.of_forall (fun _ => rfl))
+ have hloc : ∀ᵐ x ∂μ.restrict Ω,
+ frameVelocityError μ Q U g x=frameVelocityError μ Q u g x ∧
+ ∀ i, localGamma μ Q (U i) g x=localGamma μ Q (u i) g x :=
+ (frameVelocityError_frame_congr_ae μ Q g hu).and (ae_all_iff.mpr hG)
+ have hp := testPlan_eval_property_on μ π hcomp hΩ hstay hloc
+ filter_upwards [hvel,hf,ae_all_iff.mpr hc,hstay,hp] with γ hvel hf hc hstay hp
+ have heq : (fun t => W (geodesicExtension γ t))=(fun t => v (geodesicExtension γ t)) := by
+ funext t
+ exact hv (hstay (Set.projIcc 0 1 zero_le_one t))
+ refine ⟨hf.1,?_,?_⟩
+ · intro i
+ have heqi := congrArg (fun F : ℝ → Euclidean n => fun t => F t i) heq
+ exact heqi ▸ (hc i).1
+ · have hp' := (ae_restrict_iff' measurableSet_Icc).mp hp
+ filter_upwards [hvel,hp'] with t ht hp htI
+ have hb := (ht htI).2
+ change _≤(dist (γ 0) (γ 1))^2*frameVelocityError μ Q U g (geodesicExtension γ t) at hb
+ rw [(hp (Ioo_subset_Icc_self htI)).1] at hb
+ have hvect : gradientFrameCoefficients μ Q U g (geodesicExtension γ t)=
+ gradientFrameCoefficients μ Q u g (geodesicExtension γ t) :=
+ congrArg (WithLp.toLp 2) (funext (hp (Ioo_subset_Icc_self htI)).2)
+ rw [hvect] at hb
+ have hder : coordinateDerivative (fun s => W (geodesicExtension γ s)) t=
+ coordinateDerivative (fun s => v (geodesicExtension γ s)) t := congrArg (fun F => coordinateDerivative F t) heq
+ rw [hder] at hb
+ simpa only [gradientFrameCoefficients,coordinateDerivative,PiLp.inner_apply,
+ RCLike.inner_apply,conj_trivial,mul_comm] using hb
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/LocalHarmonicFrameDefect.lean b/lean/OAI/Geometry/RCD/Coordinates/LocalHarmonicFrameDefect.lean
new file mode 100644
index 0000000000000000000000000000000000000000..3d59ed45cac574f07eb471c9f3d31d88d878b829
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/LocalHarmonicFrameDefect.lean
@@ -0,0 +1,108 @@
+import OAI.Geometry.RCD.Coordinates.RegularFrameDefect
+import OAI.Geometry.RCD.Coordinates.LocalPoissonRegularExtension
+
+namespace OAI
+
+/-! # Quantitative gradient expansion in the original local harmonic coordinates -/
+
+open Set Filter MeasureTheory Metric
+open scoped NNReal BoundedContinuousFunction
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.local_harmonic_frame_defect {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2≤n) (hK : K≤0) (p : X)
+ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ {R b : ℝ} (hR : 0 (s k)^(-(n:ℝ))*(hausdorff n X).real (ball (p k) (s k)))
+ atTop (𝓝 (euclideanUnitVolume n)) := by
+ convert hX.regular_moving_volume_limit hn ho p s hp hs hs0 using 1
+ funext k
+ rw [Real.rpow_neg (hs k).le,Real.rpow_natCast,div_eq_inv_mul]
+ have ht : Tendsto (fun k => 2*r k) atTop (𝓝 0) := by
+ simpa only [mul_zero] using hr0.const_mul 2
+ exact hX.distance_sources_from_volume_limits hn hK p r hr hr0 (hv r hr hr0)
+ (hv (fun k => 2*r k) (fun k => mul_pos (by norm_num) (hr k)) ht)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NearRegularPoissonFamily.lean b/lean/OAI/Geometry/RCD/Coordinates/NearRegularPoissonFamily.lean
new file mode 100644
index 0000000000000000000000000000000000000000..e7e70f1c3bd2a63fd6a0c79cf52d2ecbd74fdaa9
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NearRegularPoissonFamily.lean
@@ -0,0 +1,123 @@
+import OAI.Geometry.RCD.Coordinates.NearRegularDistanceSources
+import OAI.Geometry.RCD.Sobolev.DistancePoissonFamily
+import OAI.Geometry.RCD.Metric.AnnularVolume
+
+namespace OAI
+
+/-! # Constructed Poisson families along every near-regular shrinking sequence
+
+One finite initial segment is discarded. Thereafter the actual positive
+sources have vanishing relative mass and the replacement constants are fixed.
+-/
+
+open Set Metric MeasureTheory Filter
+open scoped Topology NNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.near_regular_poisson_family {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2≤n) (hK : K≤0) {o : X} (ho : IsRegular n o)
+ (p : ℕ → X) (r : ℕ → ℝ) (hp : Tendsto p atTop (𝓝 o))
+ (hr : ∀ k, 0 ‖z‖^2/2) (closedBall 0 T))
+ (hlim : Tendsto (fun k => ((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (S*r k),
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic (f k) x-‖V k x‖^2/2)^2
+ ∂hausdorff n X) atTop (𝓝 0)) :
+ Tendsto (fun k => r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ (∫ x in ball (p k) (S*r k), SobolevSpace.toLp (hausdorff n X) hX.quadratic (u k) x*
+ localGamma (hausdorff n X) hX.quadratic (f k) (w k) x ∂hausdorff n X)+
+ r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ (∫ x in ball (p k) (S*r k), F (V k x)*
+ localGamma (hausdorff n X) hX.quadratic (u k) (w k) x ∂hausdorff n X))
+ atTop (𝓝 0) := by
+ let μ := hausdorff n X
+ let U := fun k => ball (p k) (S*r k)
+ let Ω := fun k => ball (p k) (T*r k)
+ let z := fun k x => SobolevSpace.toLp μ hX.quadratic (f k) x-‖V k x‖^2/2
+ let : ∀ k, IsFiniteMeasure (μ.restrict (U k)) := fun k =>
+ ⟨by rw [Measure.restrict_apply_univ]; exact hX.finiteOnBounded (U k) isBounded_ball⟩
+ have hrad (k : ℕ) : MemLp (fun x => ‖V k x‖^2/2) 2 (μ.restrict (U k)) :=
+ measured_radial_memLp μ (hr k) hS.le (V k) (hV k)
+ have hzL (k : ℕ) : MemLp (z k) 2 (μ.restrict (U k)) :=
+ ((Lp.memLp (SobolevSpace.toLp μ hX.quadratic (f k))).restrict (U k)).sub (hrad k)
+ have huT : ∀ᶠ k in atTop, ∀ᵐ x ∂μ.restrict (Ω k),
+ r k^2*localGamma μ hX.quadratic (u k) (u k) x≤Q^2 :=
+ hu.mono fun _ hk => ae_restrict_of_ae hk
+ have huz (k : ℕ) : ∀ᵐ x ∂μ, x∉Ω k → SobolevSpace.toLp μ hX.quadratic (u k) x=0 :=
+ (hz k).mono fun x hx hy => hx (fun hh => hy
+ ((ball_subset_ball (mul_le_mul_of_nonneg_right hcT.le (hr k).le)) hh))
+ have he := supported_gradient_l2_error μ hX.quadratic Ω U
+ (fun k => ball_subset_ball (mul_le_mul_of_nonneg_right hTS.le (hr k).le))
+ (fun k => ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hS (hr k))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne) r (fun k => (hr k).le)
+ u w z hQ hM huT hwb huz hzL hlim
+ have hweight := compact_radial_pullback μ hX.quadratic hS hcT hTS p r ε V hr hε hV u w hz F hF
+ have heq : ∀ᶠ k in atTop,
+ r k^2*(μ.real (U k))⁻¹*(∫ x in U k, SobolevSpace.toLp μ hX.quadratic (u k) x*
+ localGamma μ hX.quadratic (f k) (w k) x ∂μ)+
+ r k^2*(μ.real (U k))⁻¹*(∫ x in U k, F (V k x)*
+ localGamma μ hX.quadratic (u k) (w k) x ∂μ)=
+ -(r k^2*(μ.real (U k))⁻¹*∫ x in U k, z k x*localGamma μ hX.quadratic (u k) (w k) x ∂μ) := by
+ filter_upwards [hu,hweight] with k huk hwk
+ have hγ := scaled_gradient_gamma_memLp μ hX.quadratic (u k) (w k) (hr k) hQ huk
+ have hi := ((Lp.memLp (SobolevSpace.toLp μ hX.quadratic (f k))).restrict (U k)).integrable_mul
+ (hγ.restrict (U k))
+ have hj := (hrad k).integrable_mul (hγ.restrict (U k))
+ have hs := hX.recovery_harmonic_swap hn (f k) (w k) (u k) (p k) (hr k)
+ (hcT.trans hTS) hQ huk (hz k) (hw k)
+ change (∫ x in U k, _ ∂μ)=_ at hs
+ rw [hs]
+ have hrw : (∫ x in U k, F (V k x)*localGamma μ hX.quadratic (u k) (w k) x ∂μ)=
+ ∫ x in U k, (‖V k x‖^2/2)*localGamma μ hX.quadratic (u k) (w k) x ∂μ :=
+ integral_congr_ae (ae_restrict_of_ae hwk.symm)
+ rw [hrw]
+ have hsub : (∫ x in U k, z k x*localGamma μ hX.quadratic (u k) (w k) x ∂μ)=
+ (∫ x in U k, SobolevSpace.toLp μ hX.quadratic (f k) x*localGamma μ hX.quadratic (u k) (w k) x ∂μ)-
+ (∫ x in U k, (‖V k x‖^2/2)*localGamma μ hX.quadratic (u k) (w k) x ∂μ) := by
+ simp only [z,sub_mul]
+ exact integral_sub hi hj
+ rw [hsub]
+ ring
+ simpa only [neg_zero] using he.neg.congr' (heq.mono fun _ hk => hk.symm)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedResidualOuter.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedResidualOuter.lean
new file mode 100644
index 0000000000000000000000000000000000000000..c4dc35bfd63f0f5765d8c45dcf8e1612d0134e07
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedResidualOuter.lean
@@ -0,0 +1,104 @@
+import OAI.Geometry.RCD.Harmonic.LocalResidualOuterBound
+import OAI.Geometry.RCD.Coordinates.NormalizedFitEnergy
+
+namespace OAI
+
+/-! # The transport estimate in normalized local L2 spaces -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal NNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+omit [MetricSpace X] hQ in
+theorem localL2_norm_eq_root_mul_normalized (s : Set X) (hfin : μ s ≠ ∞)
+ (hpos : 0 < μ.real s) (f : Lp ℝ 2 (μ.restrict s)) :
+ ‖f‖ = Real.sqrt (μ.real s) * ‖normalizeLocalL2 μ s hfin f‖ := by
+ rw [normalizeLocalL2, norm_smul, Real.norm_eq_abs, abs_inv, abs_norm, restrictedOne_norm]
+ field_simp [(Real.sqrt_pos.mpr hpos).ne']
+
+variable [BorelSpace X] [ProperSpace X] [IsFiniteMeasureOnCompacts μ]
+
+/-- The outer normalized norm is bounded uniformly from the inner one.
+Only a fixed four-to-one volume ratio is lost in the forcing coefficient. -/
+theorem normalized_residual_outer_bound (n : ℕ) {F E W : ℝ}
+ (hF : 0 ≤ F) (hW : 0 ≤ W) (C : ℝ≥0) :
+ ∃ T : ℝ, 0 ≤ T ∧ ∀ (R a : ℝ), 0 < R → 0 ≤ a → a ≤ (n : ℝ) + 1 →
+ ∀ (z : X) (f w q : SobolevSpace μ hQ) (σ : ℝ), 0 ≤ σ →
+ IsConstantLaplacianOn μ hQ (ball z (4 * R)) f a →
+ ∀ {B : ℝ} (hf : ∀ᵐ x ∂μ.restrict (ball z (4 * R)), localGamma μ hQ f f x ≤ B),
+ (∀ᵐ x ∂μ.restrict (ball z (4 * R)), |SobolevSpace.toLp μ hQ w x| ≤ C) →
+ ∀ e : X → ℝ, MemLp e 2 μ →
+ localRadialDerivative μ hQ (ball z (4 * R)) f hf w =
+ SobolevSpace.restrictLp μ hQ (ball z (4 * R)) (w + q) →
+ localGamma μ hQ f (inwardSobolev μ hQ z (3 * R)) =ᵐ[μ.restrict (ball z (3 * R))]
+ (fun x => e x - dist z x) →
+ μ (sphere z R) = 0 →
+ ∀ (hfin : ∀ t : ℝ, μ (ball z t) ≠ ∞),
+ 0 < μ.real (ball z R) →
+ μ.real (ball z (4 * R)) ≤ W ^ 2 * μ.real (ball z R) →
+ ‖normalizeLocalL2 μ (ball z (4 * R)) (hfin _)
+ (SobolevSpace.restrictLp μ hQ (ball z (4 * R)) q)‖ ≤
+ F * (‖normalizeLocalL2 μ (ball z R) (hfin _)
+ (SobolevSpace.restrictLp μ hQ (ball z R) w)‖ + σ) →
+ (∫ x in ball z (4 * R), (e x) ^ 2 ∂μ) ≤
+ E ^ 2 * R ^ 2 * μ.real (ball z R) * σ ^ 2 →
+ ‖normalizeLocalL2 μ (ball z (2 * R)) (hfin _)
+ (SobolevSpace.restrictLp μ hQ (ball z (2 * R)) w)‖ ≤
+ T * (‖normalizeLocalL2 μ (ball z R) (hfin _)
+ (SobolevSpace.restrictLp μ hQ (ball z R) w)‖ + σ) := by
+ obtain ⟨T, hT, hb⟩ := local_uniform_residual_outer_bound μ hQ n (E := E) (mul_nonneg hF hW) C
+ refine ⟨T, hT, ?_⟩
+ intro R a hR ha han z f w q σ hσ hlap B hf hw e he heuler hradial hsphere hfin hvol hratio hq herr
+ let α := ‖normalizeLocalL2 μ (ball z R) (hfin _)
+ (SobolevSpace.restrictLp μ hQ (ball z R) w)‖
+ let v := Real.sqrt (μ.real (ball z R))
+ let v₂ := Real.sqrt (μ.real (ball z (2 * R)))
+ let v₄ := Real.sqrt (μ.real (ball z (4 * R)))
+ have hv : 0 < v := Real.sqrt_pos.mpr hvol
+ have hvle : v ≤ v₂ := Real.sqrt_le_sqrt
+ (measureReal_mono (ball_subset_ball (by linarith)) (hfin _))
+ have hvol₂ : 0 < μ.real (ball z (2 * R)) :=
+ hvol.trans_le (measureReal_mono (ball_subset_ball (by linarith)) (hfin _))
+ have hvol₄ : 0 < μ.real (ball z (4 * R)) :=
+ hvol.trans_le (measureReal_mono (ball_subset_ball (by linarith)) (hfin _))
+ have hv₄ : v₄ ≤ W * v := by
+ apply (sq_le_sq₀ (Real.sqrt_nonneg _) (mul_nonneg hW hv.le)).mp
+ dsimp only [v₄, v]
+ rw [mul_pow, Real.sq_sqrt hvol.le, Real.sq_sqrt hvol₄.le]
+ exact hratio
+ have hwraw : ‖SobolevSpace.restrictLp μ hQ (ball z R) w‖ = v * α :=
+ localL2_norm_eq_root_mul_normalized μ _ (hfin _) hvol _
+ have hqraw : ‖SobolevSpace.restrictLp μ hQ (ball z (4 * R)) q‖ ≤
+ (F * W) * (‖SobolevSpace.restrictLp μ hQ (ball z R) w‖ + v * σ) := by
+ rw [localL2_norm_eq_root_mul_normalized μ _ (hfin _) hvol₄]
+ calc
+ _ ≤ v₄ * (F * (α + σ)) := mul_le_mul_of_nonneg_left hq (Real.sqrt_nonneg _)
+ _ ≤ (W * v) * (F * (α + σ)) := mul_le_mul_of_nonneg_right hv₄
+ (mul_nonneg hF (add_nonneg (norm_nonneg _) hσ))
+ _ = _ := by rw [hwraw]; ring
+ have heraw : (∫ x in ball z (4 * R), (e x) ^ 2 ∂μ) ≤ E ^ 2 * R ^ 2 * (v * σ) ^ 2 := by
+ rw [mul_pow, show v ^ 2 = μ.real (ball z R) from Real.sq_sqrt hvol.le]
+ simpa only [mul_assoc] using herr
+ have hout := hb R a hR ha han z f w q (v * σ) (mul_nonneg hv.le hσ)
+ hlap hf hw e he heuler hradial hsphere hqraw heraw
+ rw [hwraw, localL2_norm_eq_root_mul_normalized μ _ (hfin _) hvol₂] at hout
+ have hscaled : v * ‖normalizeLocalL2 μ (ball z (2 * R)) (hfin _)
+ (SobolevSpace.restrictLp μ hQ (ball z (2 * R)) w)‖ ≤ v * (T * (α + σ)) := by
+ calc
+ _ ≤ v₂ * ‖normalizeLocalL2 μ (ball z (2 * R)) (hfin _)
+ (SobolevSpace.restrictLp μ hQ (ball z (2 * R)) w)‖ :=
+ mul_le_mul_of_nonneg_right hvle (norm_nonneg _)
+ _ ≤ _ := hout
+ _ = _ := by ring
+ exact (mul_le_mul_iff_right₀ hv).mp hscaled
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedSobolevMoment.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedSobolevMoment.lean
new file mode 100644
index 0000000000000000000000000000000000000000..a6a4436f0276ad03ad2661bc49bb87705967efc6
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedSobolevMoment.lean
@@ -0,0 +1,139 @@
+import OAI.Geometry.RCD.Sobolev.DyadicTailBound
+import OAI.Geometry.RCD.Sobolev.UniformAnnularCoercivity
+import OAI.Geometry.RCD.Sobolev.GeometricTailMoment
+import Mathlib.Analysis.SpecialFunctions.Log.Base
+
+namespace OAI
+
+/-! # A superquadratic moment for normalized Dirichlet functions -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- The dyadic support estimate improves the exponent above two.
+Only the annulus, bounded rescaled curvature, and unit energy normalization
+are needed; all constants precede the center and radius. -/
+theorem NoncollapsedRCD.normalized_dirichlet_moment {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n) :
+ ∃ p C : ℝ, 2 < p ∧ 0 < C ∧ ∀ (x : X) (R : ℝ), 0 < R → -1 ≤ K*(2*R)^2 →
+ 2*(hausdorff n X).real (ball x R) ≤ (hausdorff n X).real (ball x (2*R)) →
+ ∀ w : SobolevSpace.dirichlet (hausdorff n X) hX.quadratic (ball x R),
+ R^2*energyForm (hausdorff n X) hX.quadratic w.val w.val ≤
+ (hausdorff n X).real (ball x R) →
+ IntegrableOn (fun y => |SobolevSpace.toLp (hausdorff n X) hX.quadratic w.val y|^p)
+ (ball x R) (hausdorff n X) ∧
+ (∫ y in ball x R, |SobolevSpace.toLp (hausdorff n X) hX.quadratic w.val y|^p
+ ∂hausdorff n X) ≤ C*(hausdorff n X).real (ball x R) := by
+ obtain ⟨C₀, D, hC₀, hD, htail⟩ := hX.dyadic_tail_bound hn
+ obtain ⟨P, hP, hPoincare⟩ := hX.uniform_annular_coercivity hn
+ let b := Real.sqrt D
+ have hDpos : 0 < D := by linarith
+ have hb0 : 0 < b := Real.sqrt_pos.mpr hDpos
+ have hb2 : b^2 = D := Real.sq_sqrt hDpos.le
+ have hb : 1 < b := by nlinarith
+ let p := 2 + Real.logb b 2
+ have hp : 2 < p := by
+ have hl : 0 < Real.logb b 2 := by
+ unfold Real.logb
+ exact div_pos (Real.log_pos (by norm_num)) (Real.log_pos hb)
+ dsimp only [p]
+ linarith
+ have hp0 : 0 < p := by linarith
+ have hbpow : b^p = 2*D := by
+ dsimp only [p]
+ rw [Real.rpow_add hb0, Real.rpow_two,
+ Real.rpow_logb hb0 (ne_of_gt hb) (by norm_num), hb2]
+ ring
+ let σ := Real.sqrt (2*D*P)
+ have hσ : 0 < σ := Real.sqrt_pos.mpr (by positivity)
+ have hσ2 : σ^2 = 2*D*P := Real.sq_sqrt (by positivity)
+ let S := 2*σ
+ let q := 1/(4*D)
+ have hq : 0 < q := by dsimp only [q]; positivity
+ have hdecay : b^p*q = 1/2 := by rw [hbpow]; dsimp only [q]; field_simp; ring
+ let C := (S*b)^p + 2*(C₀/σ^2)*(S*b^2)^p
+ have hC : 0 < C := by
+ have ha : 0 < (S*b)^p := Real.rpow_pos_of_pos (by dsimp only [S]; positivity) _
+ have hh : 0 < 2*(C₀/σ^2)*(S*b^2)^p := by positivity
+ exact add_pos ha hh
+ refine ⟨p, C, hp, hC, ?_⟩
+ intro x R hR hcurv hann w hnorm
+ let μ := hausdorff n X
+ let u := SobolevSpace.toLp μ hX.quadratic w.val
+ let V := μ.real (ball x R)
+ let E := energyForm μ hX.quadratic w.val w.val
+ have hV : 0 < V := ENNReal.toReal_pos (hX.fullSupport x R hR).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne
+ have hE : 0 ≤ E := by
+ dsimp only [E]
+ rw [energyForm_self]
+ exact mul_nonneg (by norm_num) (SobolevSpace.energy_nonneg μ hX.quadratic w.val)
+ have hnorm' : R^2*E ≤ V := hnorm
+ have hl2 : ‖u‖^2 ≤ P*V := by
+ have hh := hPoincare x R hR hcurv hann w
+ have hm := mul_le_mul_of_nonneg_left hnorm' hP.le
+ change ‖u‖^2 ≤ P*R^2*E at hh
+ nlinarith
+ have hcurvR : -1 ≤ K*R^2 := by
+ by_cases hK : 0 ≤ K
+ · exact (by norm_num : (-1:ℝ)≤0).trans (mul_nonneg hK (sq_nonneg R))
+ · have hh := mul_le_mul_of_nonpos_left (show R^2 ≤ (2*R)^2 by nlinarith)
+ (le_of_not_ge hK)
+ linarith
+ have ht2 (k : ℕ) : (σ*b^k)^2 = (2*D*P)*D^k := by
+ rw [mul_pow, hσ2, ← pow_mul, Nat.mul_comm k 2, pow_mul, hb2]
+ have hfour (k : ℕ) : ((2:ℝ)^k)^2 = (4:ℝ)^k := by
+ rw [← pow_mul, Nat.mul_comm k 2, pow_mul]
+ norm_num
+ have hlevels (k : ℕ) : (μ.restrict (ball x R)).real {y | S*b^k < |u y|} ≤
+ ((C₀/σ^2)*V)*q^k := by
+ let t := σ*b^k
+ have ht : 0 < t := mul_pos hσ (pow_pos hb0 _)
+ have hparam : 2*D^(k+1)*‖u‖^2 ≤ V*t^2 := by
+ calc
+ _ ≤ 2*D^(k+1)*(P*V) := mul_le_mul_of_nonneg_left hl2 (by positivity)
+ _ = _ := by dsimp only [t]; rw [ht2, pow_succ]; ring
+ have hh := htail x R hR hcurvR w t ht k hparam
+ change t^2 * μ.real (ball x R ∩ {y | 2*t < |u y|}) ≤ C₀*(R/2^k)^2*E at hh
+ have hparam' : C₀*(R/2^k)^2*E ≤ C₀*V/(4:ℝ)^k := by
+ rw [div_pow, hfour]
+ have hmul := mul_le_mul_of_nonneg_left hnorm' hC₀.le
+ apply (le_div_iff₀ (pow_pos (by norm_num : (0:ℝ)<4) k)).mpr
+ field_simp at *
+ nlinarith
+ have halg : t^2 * (((C₀/σ^2)*V)*q^k) = C₀*V/(4:ℝ)^k := by
+ dsimp only [t, q]
+ rw [ht2, hσ2, div_pow, one_pow, mul_pow]
+ field_simp
+ have hmeasure : μ.real (ball x R ∩ {y | 2*t < |u y|}) ≤ ((C₀/σ^2)*V)*q^k := by
+ apply (mul_le_mul_iff_right₀ (sq_pos_of_pos ht)).mp
+ rw [halg]
+ exact hh.trans hparam'
+ rw [measureReal_restrict_apply (measurableSet_lt measurable_const
+ (Lp.stronglyMeasurable u).measurable.abs)]
+ simpa only [S, t, mul_assoc, inter_comm] using hmeasure
+ let : IsFiniteMeasure (μ.restrict (ball x R)) :=
+ ⟨by simpa using hX.finiteOnBounded (ball x R) isBounded_ball⟩
+ obtain ⟨hi, hbnd⟩ := geometric_tail_moment (μ.restrict (ball x R))
+ (Lp.stronglyMeasurable u).measurable.abs (fun _ => abs_nonneg _)
+ (show 0 < S by dsimp only [S]; positivity) hb
+ (show 0 ≤ (C₀/σ^2)*V by positivity) hq.le hp0
+ (by rw [hdecay]; norm_num) hlevels
+ refine ⟨hi, ?_⟩
+ have hunit : (μ.restrict (ball x R)).real univ = V := by
+ simp only [Measure.real, Measure.restrict_apply_univ, V]
+ rw [hunit, hdecay] at hbnd
+ calc
+ _ ≤ (S*b)^p*V + ((C₀/σ^2)*V)*(S*b^2)^p/(1-1/2) := hbnd
+ _ = C*V := by dsimp only [C]; ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedSourceGradient.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedSourceGradient.lean
new file mode 100644
index 0000000000000000000000000000000000000000..1895ab7bda023bcd3721de11a552ce99f6f6d309
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedSourceGradient.lean
@@ -0,0 +1,135 @@
+import OAI.Geometry.RCD.Sobolev.BalancedSourceGradient
+
+namespace OAI
+
+/-! # Linear positive-source bounds in normalized ball units -/
+
+open Set MeasureTheory Filter
+open scoped ENNReal Topology
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [ProperSpace X] (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- A normalized Sobolev inequality gives a linear source-mass estimate
+with a constant proportional to the square root of the length-squared scale. -/
+theorem normalized_source_gradient_of_pos (Ω : Set X) (hfin : μ Ω ≠ ∞)
+ (hvol : 0 < μ.real Ω) (H : SobolevSpace.dirichlet μ hQ Ω)
+ (hH : ∀ᵐ x ∂μ, 0 ≤ SobolevSpace.toLp μ hQ H.val x)
+ {d q C s P : ℝ} (hq : 1 < q) (hqd : q < d) (hC : 0 < C) (hs : 0 < s) (hP : 0 < P)
+ (hsob : ∀ φ : SobolevSpace.dirichlet μ hQ Ω,
+ (∫ x in Ω, |SobolevSpace.toLp μ hQ φ.val x| ^ (2 * d) ∂μ) ^ (1 / d) ≤
+ (C * s * (μ.real Ω) ^ (1 / d - 1)) * energyForm μ hQ φ.val φ.val)
+ (hsource : ∀ φ : SobolevSpace.dirichlet μ hQ Ω, ∀ t : ℝ, 0 ≤ t →
+ (∀ᵐ x ∂μ, 0 ≤ SobolevSpace.toLp μ hQ φ.val x ∧ SobolevSpace.toLp μ hQ φ.val x ≤ t) →
+ energyForm μ hQ H.val φ.val ≤ P * t) :
+ IntegrableOn (fun x => SobolevSpace.minimalSlope μ hQ H.val x) Ω μ ∧
+ (∫ x in Ω, SobolevSpace.minimalSlope μ hQ H.val x ∂μ) ≤
+ P * Real.sqrt (balancedGradientConstant d q * C * s) := by
+ let V := μ.real Ω
+ let Cs := C * s * V ^ (1 / d - 1)
+ let PN := V / (C * s)
+ have hPN : 0 < PN := div_pos hvol (mul_pos hC hs)
+ let alpha := PN / P
+ have halpha : 0 < alpha := div_pos hPN hP
+ let N : SobolevSpace.dirichlet μ hQ Ω := alpha • H
+ have hN : ∀ᵐ x ∂μ, 0 ≤ SobolevSpace.toLp μ hQ N.val x := by
+ change ∀ᵐ x ∂μ, 0 ≤ SobolevSpace.toLp μ hQ (alpha • H.val) x
+ rw [map_smul]
+ filter_upwards [hH, Lp.coeFn_smul alpha (SobolevSpace.toLp μ hQ H.val)] with x hx he
+ rw [he]
+ exact mul_nonneg halpha.le hx
+ have hNs : ∀ φ : SobolevSpace.dirichlet μ hQ Ω, ∀ t : ℝ, 0 ≤ t →
+ (∀ᵐ x ∂μ, 0 ≤ SobolevSpace.toLp μ hQ φ.val x ∧ SobolevSpace.toLp μ hQ φ.val x ≤ t) →
+ energyForm μ hQ N.val φ.val ≤ PN * t := by
+ intro φ t ht hb
+ change energyForm μ hQ (alpha • H.val) φ.val ≤ _
+ rw [energyForm_smul_left]
+ calc
+ _ ≤ alpha * (P * t) := mul_le_mul_of_nonneg_left (hsource φ t ht hb) halpha.le
+ _ = _ := by dsimp only [alpha]; field_simp
+ have hCs : 0 ≤ Cs := by dsimp only [Cs]; positivity
+ have hbalance : (Cs * PN) ^ d ≤ V := by
+ have he : Cs * PN = V ^ (1 / d) := by
+ calc
+ _ = V ^ (1 / d - 1) * V := by dsimp only [Cs, PN]; field_simp
+ _ = V ^ (1 / d) := by
+ calc
+ _ = V ^ (1 / d - 1) * V ^ (1 : ℝ) := by rw [Real.rpow_one]
+ _ = V ^ ((1 / d - 1) + 1) := (Real.rpow_add hvol _ _).symm
+ _ = _ := by congr 1; ring
+ rw [he, one_div, Real.rpow_inv_rpow hvol.le (ne_of_gt (zero_lt_one.trans (hq.trans hqd)))]
+ have hn := balanced_positive_source_gradient μ hQ Ω hfin N hN hq hqd hCs hPN.le hsob hNs hbalance
+ have he : (fun x => SobolevSpace.minimalSlope μ hQ N.val x) =ᵐ[μ]
+ fun x => alpha * SobolevSpace.minimalSlope μ hQ H.val x := by
+ change (fun x => SobolevSpace.minimalSlope μ hQ (alpha • H.val) x) =ᵐ[μ] _
+ rw [SobolevSpace.minimalSlope_smul_nonneg μ hQ H.val halpha.le]
+ exact Lp.coeFn_smul alpha (SobolevSpace.minimalSlope μ hQ H.val)
+ have he' : (fun x => alpha⁻¹ * SobolevSpace.minimalSlope μ hQ N.val x) =ᵐ[μ]
+ fun x => SobolevSpace.minimalSlope μ hQ H.val x := by
+ filter_upwards [he] with x hx
+ rw [hx]
+ field_simp
+ have hi : IntegrableOn (fun x => SobolevSpace.minimalSlope μ hQ H.val x) Ω μ :=
+ (hn.1.const_mul alpha⁻¹).congr (ae_restrict_of_ae he')
+ have hI : (∫ x in Ω, SobolevSpace.minimalSlope μ hQ N.val x ∂μ) =
+ alpha * ∫ x in Ω, SobolevSpace.minimalSlope μ hQ H.val x ∂μ := by
+ rw [integral_congr_ae (ae_restrict_of_ae he), integral_const_mul]
+ have hb := mul_le_mul_of_nonneg_left hn.2 (sq_nonneg (P / PN))
+ have hleft : (P / PN) ^ 2 * (∫ x in Ω, SobolevSpace.minimalSlope μ hQ N.val x ∂μ) ^ 2 =
+ (∫ x in Ω, SobolevSpace.minimalSlope μ hQ H.val x ∂μ) ^ 2 := by
+ rw [hI]
+ dsimp only [alpha]
+ field_simp
+ have hright : (P / PN) ^ 2 * (PN * V * balancedGradientConstant d q) =
+ P ^ 2 * (balancedGradientConstant d q * C * s) := by
+ dsimp only [PN]
+ field_simp [ne_of_gt (show 0 < V from hvol)]
+ change (P / PN) ^ 2 * (∫ x in Ω, SobolevSpace.minimalSlope μ hQ N.val x ∂μ) ^ 2 ≤
+ (P / PN) ^ 2 * (PN * V * balancedGradientConstant d q) at hb
+ rw [hleft, hright] at hb
+ have hD : 0 ≤ balancedGradientConstant d q * C * s := by
+ exact mul_nonneg (mul_nonneg (balancedGradientConstant_pos hq hqd).le hC.le) hs.le
+ have hsq := Real.sq_sqrt hD
+ refine ⟨hi, ?_⟩
+ have hpbound : 0 ≤ P * Real.sqrt (balancedGradientConstant d q * C * s) := by positivity
+ apply le_of_sq_le_sq _ hpbound
+ simpa only [mul_pow, hsq] using hb
+
+/-- The scale-correct linear bound also includes zero source mass. -/
+theorem normalized_source_gradient (Ω : Set X) (hfin : μ Ω ≠ ∞)
+ (hvol : 0 < μ.real Ω) (H : SobolevSpace.dirichlet μ hQ Ω)
+ (hH : ∀ᵐ x ∂μ, 0 ≤ SobolevSpace.toLp μ hQ H.val x)
+ {d q C s P : ℝ} (hq : 1 < q) (hqd : q < d) (hC : 0 < C) (hs : 0 < s) (hP : 0 ≤ P)
+ (hsob : ∀ φ : SobolevSpace.dirichlet μ hQ Ω,
+ (∫ x in Ω, |SobolevSpace.toLp μ hQ φ.val x| ^ (2 * d) ∂μ) ^ (1 / d) ≤
+ (C * s * (μ.real Ω) ^ (1 / d - 1)) * energyForm μ hQ φ.val φ.val)
+ (hsource : ∀ φ : SobolevSpace.dirichlet μ hQ Ω, ∀ t : ℝ, 0 ≤ t →
+ (∀ᵐ x ∂μ, 0 ≤ SobolevSpace.toLp μ hQ φ.val x ∧ SobolevSpace.toLp μ hQ φ.val x ≤ t) →
+ energyForm μ hQ H.val φ.val ≤ P * t) :
+ IntegrableOn (fun x => SobolevSpace.minimalSlope μ hQ H.val x) Ω μ ∧
+ (∫ x in Ω, SobolevSpace.minimalSlope μ hQ H.val x ∂μ) ≤
+ P * Real.sqrt (balancedGradientConstant d q * C * s) := by
+ have hb (r : ℝ) (hr : P < r) :
+ IntegrableOn (fun x => SobolevSpace.minimalSlope μ hQ H.val x) Ω μ ∧
+ (∫ x in Ω, SobolevSpace.minimalSlope μ hQ H.val x ∂μ) ≤
+ r * Real.sqrt (balancedGradientConstant d q * C * s) := by
+ apply normalized_source_gradient_of_pos μ hQ Ω hfin hvol H hH hq hqd hC hs
+ (hP.trans_lt hr) hsob
+ intro φ t ht hbound
+ exact (hsource φ t ht hbound).trans (mul_le_mul_of_nonneg_right hr.le ht)
+ refine ⟨(hb (P + 1) (by linarith)).1, ?_⟩
+ have hlim : Tendsto (fun r : ℝ => r * Real.sqrt (balancedGradientConstant d q * C * s))
+ (𝓝[>] P) (𝓝 (P * Real.sqrt (balancedGradientConstant d q * C * s))) :=
+ (continuous_id.mul continuous_const).continuousAt.tendsto.mono_left nhdsWithin_le_nhds
+ apply ge_of_tendsto hlim
+ filter_upwards [self_mem_nhdsWithin] with r hr
+ exact (hb r hr).2
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedSubplanData.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedSubplanData.lean
new file mode 100644
index 0000000000000000000000000000000000000000..aea2da955ccc417dcfac33a7cdb5fa8f791f80ba
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedSubplanData.lean
@@ -0,0 +1,45 @@
+import OAI.Geometry.RCD.Transport.CompressedSubplanNode
+
+namespace OAI
+
+/-! # The actual normalized subplan with its common compression and support -/
+
+open Set Filter MeasureTheory Metric TopologicalSpace
+open scoped ENNReal Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [SeparableSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem normalized_subplan_data (π : Measure C(Time,X)) [IsProbabilityMeasure π]
+ (hg : ∀ᵐ γ ∂π, IsGeodesic γ)
+ (hp : IsOptimalCoupling (π.map (fun γ => γ 0)) (π.map (fun γ => γ 1))
+ (π.map (fun γ => (γ 0,γ 1))))
+ (hfin : transportCost (π.map (fun γ => (γ 0,γ 1))) ≠ ∞)
+ (μ : Measure X) {C : ℝ≥0∞} (hc : ∀ t : Time, π.map (fun γ => γ t) ≤ C • μ)
+ (p : X) {R : ℝ}
+ (hs₀ : ∀ᵐ x ∂π.map (fun γ => γ 0), dist x p ≤ R)
+ (hs₁ : ∀ᵐ x ∂π.map (fun γ => γ 1), dist x p ≤ R)
+ (κ : Measure C(Time,X)) (hk : κ ≤ π) (hk0 : κ univ ≠ 0) :
+ let ρ := (κ univ)⁻¹ • κ
+ IsProbabilityMeasure ρ ∧ (∀ᵐ γ ∂ρ, IsGeodesic γ) ∧
+ IsOptimalCoupling (ρ.map (fun γ => γ 0)) (ρ.map (fun γ => γ 1))
+ (ρ.map (fun γ => (γ 0,γ 1))) ∧
+ (∀ t : Time, ρ.map (fun γ => γ t) ≤ ((κ univ)⁻¹*C) • μ) ∧
+ (∀ᵐ x ∂ρ.map (fun γ => γ 0), dist x p ≤ R) ∧
+ (∀ᵐ x ∂ρ.map (fun γ => γ 1), dist x p ≤ R) := by
+ obtain ⟨hρ,hgρ,hpρ,_⟩ := normalized_optimal_subplan π hg hp hfin κ hk hk0
+ refine ⟨hρ,hgρ,hpρ,normalized_subplan_compression π κ hk hc,?_,?_⟩
+ · rw [Measure.map_smul _ (measurable_path_eval 0).aemeasurable]
+ exact (hs₀.filter_mono (Measure.map_mono hk (measurable_path_eval 0)).absolutelyContinuous.ae_le).filter_mono
+ Measure.smul_absolutelyContinuous.ae_le
+ · rw [Measure.map_smul _ (measurable_path_eval 1).aemeasurable]
+ exact (hs₁.filter_mono (Measure.map_mono hk (measurable_path_eval 1)).absolutelyContinuous.ae_le).filter_mono
+ Measure.smul_absolutelyContinuous.ae_le
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedSubplanNodes.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedSubplanNodes.lean
new file mode 100644
index 0000000000000000000000000000000000000000..a07ac6827e5ed287872125b76447effdc709cc18
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedSubplanNodes.lean
@@ -0,0 +1,88 @@
+import OAI.Geometry.RCD.Coordinates.NormalizedOptimalSubplan
+import OAI.Geometry.RCD.Transport.MaximalScalarMidpoint
+
+namespace OAI
+
+/-! # Bounded transport nodes for the actual normalized length components
+
+Uniform compression of the parent controls both half-nodes. Their
+transport-distance bounds are inherited at exactly half the parent scale.
+-/
+
+open Set Filter MeasureTheory Metric TopologicalSpace
+open scoped Topology ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [SeparableSpace X] [CompleteSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem exists_normalized_subplan_half_nodes {n : ℕ} (a : RenyiTransportNode n X)
+ (π : Measure C(Time,X)) [IsProbabilityMeasure π]
+ (hg : ∀ᵐ γ ∂π, IsGeodesic γ)
+ (hp : IsOptimalCoupling a.left a.right (π.map (fun γ => (γ 0,γ 1))))
+ {C : ℝ≥0∞} (hC : C≠∞) (hcomp : ∀ t : Time, π.map (fun γ => γ t)≤C • hausdorff n X)
+ (κ : Measure C(Time,X)) (hκ : κ≤π) (hκ0 : κ univ≠0) :
+ ∃ a₀ a₁ : RenyiTransportNode n X,
+ a₀.left=(κ univ)⁻¹ • κ.map (fun γ => γ 0) ∧
+ a₀.right=(κ univ)⁻¹ • κ.map (fun γ => γ midpointTime) ∧
+ a₁.left=(κ univ)⁻¹ • κ.map (fun γ => γ midpointTime) ∧
+ a₁.right=(κ univ)⁻¹ • κ.map (fun γ => γ 1) ∧
+ a₀.distance=a.distance/2 ∧ a₁.distance=a.distance/2 := by
+ let : Nonempty X := ⟨a.center⟩
+ let : IsProbabilityMeasure a.left := a.left_probability
+ let : IsProbabilityMeasure a.right := a.right_probability
+ let : IsFiniteMeasure κ := isFiniteMeasure_of_le π hκ
+ have hc : κ univ≠∞ := measure_ne_top κ univ
+ have hi : (κ univ)⁻¹≠∞ := ENNReal.inv_ne_top.mpr hκ0
+ have he := optimalPlan_endpoints a.left a.right π hp
+ have hpp : IsOptimalCoupling (π.map (fun γ => γ 0)) (π.map (fun γ => γ 1))
+ (π.map (fun γ => (γ 0,γ 1))) := by rw [he.1,he.2]; exact hp
+ have hfin := finite_second_moment_cost
+ (finiteSecondMoment_of_bounded a.left a.center a.left_support)
+ (finiteSecondMoment_of_bounded a.right a.center a.right_support) hp.1 hp.2.1
+ let πn := (κ univ)⁻¹ • κ
+ obtain ⟨hπn,hgn,hpn,hfn⟩ := normalized_optimal_subplan π hg hpp hfin κ hκ hκ0
+ let : IsProbabilityMeasure πn := hπn
+ have heval (t : Time) : πn.map (fun γ => γ t)=(κ univ)⁻¹ • κ.map (fun γ => γ t) :=
+ Measure.map_smul _ (measurable_path_eval t).aemeasurable
+ have hDn : OptimalPlanDistanceBound (πn.map (fun γ => γ 0))
+ (πn.map (fun γ => γ 1)) a.distance := by
+ rw [heval,heval]
+ exact a.distance_bound.normalized_subplan π hg hp κ hκ hκ0
+ have hD := OptimalPlanDistanceBound.midpoint_halves πn hgn hpn hfn hDn
+ let c := (κ univ)⁻¹*C
+ have hcf : c≠∞ := ENNReal.mul_ne_top hi hC
+ have hcn (t : Time) : πn.map (fun γ => γ t)≤c • hausdorff n X := by
+ rw [heval]
+ intro B
+ change (κ univ)⁻¹ * (κ.map (fun γ => γ t)) B ≤ c * (hausdorff n X) B
+ calc
+ _ ≤ (κ univ)⁻¹ * (π.map (fun γ => γ t)) B :=
+ mul_le_mul' le_rfl (Measure.map_mono hκ (measurable_path_eval t) B)
+ _ ≤ (κ univ)⁻¹ * (C*(hausdorff n X) B) := mul_le_mul' le_rfl (hcomp t B)
+ _ = _ := (mul_assoc _ _ _).symm
+ have hstay (t : Time) : ∀ᵐ x ∂πn.map (fun γ => γ t), dist x a.center≤3*a.radius := by
+ rw [heval]
+ have hs : ∀ᵐ x ∂π.map (fun γ => γ t), dist x a.center≤3*a.radius := by
+ apply (ae_map_iff (measurable_path_eval t).aemeasurable
+ (measurableSet_le (measurable_id.dist measurable_const) measurable_const)).mpr
+ exact (optimal_geodesic_plan_bounded a.left a.right π hg hp a.center a.radius_nonneg
+ a.left_support a.right_support).mono (fun γ hγ => hγ.2 t)
+ exact (hs.filter_mono (Measure.map_mono hκ (measurable_path_eval t)).absolutelyContinuous.ae_le).filter_mono
+ Measure.smul_absolutelyContinuous.ae_le
+ let a₀ : RenyiTransportNode n X :=
+ ⟨πn.map (fun γ => γ 0),πn.map (fun γ => γ midpointTime),inferInstance,inferInstance,
+ a.center,3*a.radius,mul_nonneg (by norm_num) a.radius_nonneg,hstay 0,hstay midpointTime,
+ c,hcf,hcn 0,hcn midpointTime,a.distance/2,div_nonneg a.distance_nonneg (by norm_num),hD.1⟩
+ let a₁ : RenyiTransportNode n X :=
+ ⟨πn.map (fun γ => γ midpointTime),πn.map (fun γ => γ 1),inferInstance,inferInstance,
+ a.center,3*a.radius,mul_nonneg (by norm_num) a.radius_nonneg,hstay midpointTime,hstay 1,
+ c,hcf,hcn midpointTime,hcn 1,a.distance/2,div_nonneg a.distance_nonneg (by norm_num),hD.2⟩
+ exact ⟨a₀,a₁,heval 0,heval midpointTime,heval midpointTime,heval 1,rfl,rfl⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedSupportedCompression.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedSupportedCompression.lean
new file mode 100644
index 0000000000000000000000000000000000000000..2efabd869ea25a260e662f9526c887ae01b3b2e2
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedSupportedCompression.lean
@@ -0,0 +1,33 @@
+import OAI.Geometry.RCD.Coordinates.NormalizedLocalL1Domination
+
+namespace OAI
+
+/-! # Restricting a normalized compression bound to its actual support -/
+
+open Set Filter MeasureTheory
+open scoped ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MeasurableSpace X]
+
+theorem normalized_supported_compression (μ ν : Measure X) {S : Set X} {B : ℝ≥0∞} {C : ℝ}
+ (hB : B≠∞) (hν : ν≤B • μ) (hs : ∀ᵐ x ∂ν, x∈S)
+ (hV : 0<μ.real S) (hC : B.toReal*μ.real S≤C) :
+ ν≤ENNReal.ofReal (C/μ.real S) • μ.restrict S := by
+ have hcoef : B≤ENNReal.ofReal (C/μ.real S) := by
+ rw [← ENNReal.ofReal_toReal hB]
+ exact ENNReal.ofReal_le_ofReal ((le_div_iff₀ hV).mpr hC)
+ calc
+ ν=ν.restrict S := (Measure.restrict_eq_self_of_ae_mem hs).symm
+ _ ≤ (B • μ).restrict S := Measure.restrict_mono_measure hν S
+ _ = B • μ.restrict S := Measure.restrict_smul _ _ _
+ _ ≤ _ := by
+ apply Measure.le_iff.mpr
+ intro U _hU
+ simpa only [Measure.smul_apply,smul_eq_mul] using mul_le_mul' hcoef (le_refl (μ.restrict S U))
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedTiltLpVariation.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedTiltLpVariation.lean
new file mode 100644
index 0000000000000000000000000000000000000000..c3246dcae2034e655e2400001ab80d0e121126bc
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedTiltLpVariation.lean
@@ -0,0 +1,64 @@
+import OAI.Geometry.RCD.Transport.ExponentialTiltLpVariation
+
+namespace OAI
+
+/-! # The exact strong L² tangent to normalized density perturbations -/
+
+open Set Filter MeasureTheory
+open scoped ENNReal NNReal Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MeasurableSpace X] (μ : Measure X)
+
+ def normalizedTiltLp (r : Lp ℝ 2 μ) {g : X → ℝ} (hg : Measurable g)
+ {M : ℝ≥0} (hgb : ∀ x, |g x| ≤ M) (t : ℝ) : Lp ℝ 2 μ :=
+ (∫ x, Real.exp (t*g x)*r x ∂μ)⁻¹ • exponentialTiltLp μ r hg hgb t
+
+ def normalizedTiltTangent (r : Lp ℝ 2 μ) {g : X → ℝ} (hg : Measurable g)
+ {M : ℝ≥0} (hgb : ∀ x, |g x| ≤ M) : Lp ℝ 2 μ :=
+ lpMultiplier μ (boundedMultiplier μ g hg M hgb) r-(∫ x, g x*r x ∂μ) • r
+
+ theorem normalizedTiltLp_coe (r : Lp ℝ 2 μ) {g : X → ℝ} (hg : Measurable g)
+ {M : ℝ≥0} (hgb : ∀ x, |g x| ≤ M) (t : ℝ) :
+ normalizedTiltLp μ r hg hgb t =ᵐ[μ] fun x =>
+ (∫ y, Real.exp (t*g y)*r y ∂μ)⁻¹*(Real.exp (t*g x)*r x) := by
+ filter_upwards [Lp.coeFn_smul (∫ x, Real.exp (t*g x)*r x ∂μ)⁻¹
+ (exponentialTiltLp μ r hg hgb t),exponentialTiltLp_coe μ r hg hgb t] with x hs he
+ exact hs.trans (by change _*_= _; rw [he])
+
+ theorem normalizedTiltTangent_coe (r : Lp ℝ 2 μ) {g : X → ℝ} (hg : Measurable g)
+ {M : ℝ≥0} (hgb : ∀ x, |g x| ≤ M) :
+ normalizedTiltTangent μ r hg hgb =ᵐ[μ] fun x => r x*(g x-∫ y, g y*r y ∂μ) := by
+ filter_upwards [Lp.coeFn_sub (lpMultiplier μ (boundedMultiplier μ g hg M hgb) r)
+ ((∫ x, g x*r x ∂μ) • r),
+ lpMultiplier_coe μ (boundedMultiplier μ g hg M hgb) r,
+ boundedMultiplier_coe μ g hg M hgb,Lp.coeFn_smul (∫ x, g x*r x ∂μ) r] with x hs hv hgx hm
+ change (lpMultiplier μ (boundedMultiplier μ g hg M hgb) r-(∫ y, g y*r y ∂μ) • r) x = _
+ rw [hs,Pi.sub_apply,hv,hgx,hm,Pi.smul_apply]
+ change g x*r x-(∫ x, g x*r x ∂μ)*r x = _
+ ring
+
+ theorem normalizedTiltLp_zero (r : Lp ℝ 2 μ) (hm : (∫ x, r x ∂μ)=1)
+ {g : X → ℝ} (hg : Measurable g) {M : ℝ≥0} (hgb : ∀ x, |g x| ≤ M) :
+ normalizedTiltLp μ r hg hgb 0=r := by
+ unfold normalizedTiltLp
+ simp only [zero_mul,Real.exp_zero,one_mul,hm,inv_one,one_smul,exponentialTiltLp_zero]
+
+ theorem normalizedTiltLp_hasDerivAt_zero (r : Lp ℝ 2 μ) (hr : Integrable r μ)
+ (hm : (∫ x, r x ∂μ)=1) {g : X → ℝ} (hg : Measurable g)
+ {M : ℝ≥0} (hgb : ∀ x, |g x| ≤ M) :
+ HasDerivAt (normalizedTiltLp μ r hg hgb) (normalizedTiltTangent μ r hg hgb) 0 := by
+ have h0 : (∫ x, Real.exp ((0:ℝ)*g x)*r x ∂μ)=1 := by
+ simpa only [zero_mul,Real.exp_zero,one_mul] using hm
+ have hZ := (exponential_tilt_integral_hasDerivAt_zero μ hr hg hgb).inv (by rw [h0]; norm_num)
+ have hD := hZ.smul (exponentialTiltLp_hasDerivAt_zero μ r hg hgb)
+ convert hD using 1
+ · rfl
+ · simp only [normalizedTiltTangent,Pi.inv_apply,h0,one_pow,div_one,inv_one,one_smul,exponentialTiltLp_zero,
+ neg_smul,sub_eq_add_neg,add_comm]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedTorsion.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedTorsion.lean
new file mode 100644
index 0000000000000000000000000000000000000000..5a7914f2f3909202ff04ef9516358dba4207c62b
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedTorsion.lean
@@ -0,0 +1,101 @@
+import OAI.Geometry.RCD.Sobolev.ScaledStampacchia
+import OAI.Geometry.RCD.Sobolev.PoissonHeight
+
+namespace OAI
+
+/-! # Torsion bounds with the correct radius-squared scaling -/
+
+open Set MeasureTheory Filter
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [ProperSpace X] (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- A normalized Sobolev inequality gives a torsion height proportional to
+its length-squared parameter, uniformly as the volume tends to zero. -/
+theorem exists_normalized_torsion_bound {d C : ℝ} (hd : 1 < d) (hC : 0 ≤ C) :
+ ∃ K : ℝ, 0 < K ∧ ∀ (Ω : Set X), μ Ω ≠ ∞ → 0 < μ.real Ω →
+ ∀ s : ℝ, 0 < s → ∀ u : SobolevSpace.dirichlet μ hQ Ω,
+ (∀ φ : SobolevSpace.dirichlet μ hQ Ω,
+ energyForm μ hQ u.val φ.val = ∫ x in Ω, SobolevSpace.toLp μ hQ φ.val x ∂μ) →
+ (∀ φ : SobolevSpace.dirichlet μ hQ Ω,
+ (∫ x in Ω, |SobolevSpace.toLp μ hQ φ.val x| ^ (2 * d) ∂μ) ^ (1 / d) ≤
+ (C * s * (μ.real Ω) ^ (1 / d - 1)) * energyForm μ hQ φ.val φ.val) →
+ ∀ᵐ x ∂μ.restrict Ω, SobolevSpace.toLp μ hQ u.val x ≤ K * s := by
+ obtain ⟨K, hK, hExt⟩ := exists_scaled_extinction_level
+ (Real.rpow_nonneg hC (2 * d)) (by linarith : 2 < 2 * d)
+ refine ⟨K, hK, ?_⟩
+ intro Ω hfin hvol s hs u hsolve hsob
+ let ν := μ.restrict Ω
+ let : IsFiniteMeasure ν := ⟨by simpa only [ν, Measure.restrict_apply_univ] using hfin.lt_top⟩
+ let U := fun x => SobolevSpace.toLp μ hQ u.val x
+ let Y := fun t : ℝ => ν.real {x | t < U x}
+ let V := μ.real Ω
+ let Cs := C * s * V ^ (1 / d - 1)
+ have hCs : 0 ≤ Cs := mul_nonneg (mul_nonneg hC hs.le) (Real.rpow_nonneg hvol.le _)
+ have hY0 : Y 0 ≤ V := by
+ have hh := measureReal_mono (μ := ν) (subset_univ {x | 0 < U x}) (measure_ne_top ν univ)
+ simpa only [ν, measureReal_restrict_apply_univ, V, Y] using hh
+ have hmono (k l : ℝ) (_hk : 0 ≤ k) (hkl : k ≤ l) : Y l ≤ Y k := by
+ apply measureReal_mono _ (measure_ne_top ν _)
+ intro x hx
+ exact hkl.trans_lt hx
+ have hstep (k l : ℝ) (hk : 0 ≤ k) (hkl : k < l) :
+ Y l ≤ Cs ^ (2 * d) * Y k ^ (2 * d - 1) / (l - k) ^ (2 * d) := by
+ have hm : Y l ≤ ν.real {x | l ≤ U x} := by
+ apply measureReal_mono _ (measure_ne_top ν _)
+ intro x hx
+ exact (show l < U x from hx).le
+ exact hm.trans (torsion_superlevel_le μ hQ Ω hfin u hsolve hd hCs hsob hk hkl)
+ have hz : Y (K * s) = 0 := hExt (Cs ^ (2 * d)) V s hvol hs
+ (normalized_sobolev_coefficient hC hs hvol hd) Y
+ (fun _ _ => measureReal_nonneg) hY0 hmono hstep
+ have hz' : ν {x | K * s < U x} = 0 :=
+ (ENNReal.toReal_eq_zero_iff _).mp hz |>.resolve_right (measure_ne_top ν _)
+ apply ae_iff.mpr
+ simpa only [not_le] using hz'
+
+/-- Coercivity constructs the torsion solution; normalized Sobolev controls
+its height by a uniform multiple of the length-squared parameter. -/
+theorem exists_uniform_normalized_bounded_torsion {d C : ℝ} (hd : 1 < d) (hC : 0 ≤ C) :
+ ∃ K : ℝ, 0 < K ∧ ∀ (Ω : Set X), MeasurableSet Ω → μ Ω ≠ ∞ → 0 < μ.real Ω →
+ ∀ s : ℝ, 0 < s → ∀ P : ℝ, 0 ≤ P →
+ (∀ v : SobolevSpace.dirichlet μ hQ Ω,
+ ‖SobolevSpace.toLp μ hQ v.val‖ ^ 2 ≤ P * energyForm μ hQ v.val v.val) →
+ (∀ φ : SobolevSpace.dirichlet μ hQ Ω,
+ (∫ x in Ω, |SobolevSpace.toLp μ hQ φ.val x| ^ (2 * d) ∂μ) ^ (1 / d) ≤
+ (C * s * (μ.real Ω) ^ (1 / d - 1)) * energyForm μ hQ φ.val φ.val) →
+ ∃ τ : SobolevSpace.dirichlet μ hQ Ω,
+ (∀ φ : SobolevSpace.dirichlet μ hQ Ω,
+ energyForm μ hQ τ.val φ.val = ∫ x in Ω, SobolevSpace.toLp μ hQ φ.val x ∂μ) ∧
+ (∀ᵐ x ∂μ, 0 ≤ SobolevSpace.toLp μ hQ τ.val x ∧
+ SobolevSpace.toLp μ hQ τ.val x ≤ K * s) := by
+ obtain ⟨K, hK, hb⟩ := exists_normalized_torsion_bound μ hQ hd hC
+ refine ⟨K, hK, ?_⟩
+ intro Ω hΩ hfin hvol s hs P hP hpoin hsob
+ let F := dirichletSource μ hQ Ω (indicatorConstLp 2 hΩ hfin 1)
+ have hF (φ : SobolevSpace.dirichlet μ hQ Ω) :
+ F φ = ∫ x in Ω, SobolevSpace.toLp μ hQ φ.val x ∂μ := by
+ simpa only [F, one_mul] using dirichletSource_indicator μ hQ Ω hΩ hfin 1 φ
+ have hpos (φ : SobolevSpace.dirichlet μ hQ Ω)
+ (hφ : ∀ᵐ x ∂μ, 0 ≤ SobolevSpace.toLp μ hQ φ.val x) : 0 ≤ F φ := by
+ rw [hF]
+ exact integral_nonneg_of_ae (ae_restrict_of_ae hφ)
+ obtain ⟨τ, hτ, hτ0⟩ := exists_nonnegative_dirichlet_solution μ hQ Ω hP hpoin F hpos
+ have hsolve (φ : SobolevSpace.dirichlet μ hQ Ω) := (hτ φ).trans (hF φ)
+ have hτK := hb Ω hfin hvol s hs τ hsolve hsob
+ have hupper : ∀ᵐ x ∂μ, SobolevSpace.toLp μ hQ τ.val x ≤ K * s := by
+ apply ae_of_ae_restrict_of_ae_restrict_compl Ω hτK
+ filter_upwards [SobolevSpace.dirichlet_zero_off μ hQ Ω hΩ τ] with x hx
+ rw [hx]
+ exact mul_nonneg hK.le hs.le
+ exact ⟨τ, hsolve, hτ0.and hupper⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedTransportDefect.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedTransportDefect.lean
new file mode 100644
index 0000000000000000000000000000000000000000..61e6738de54657b2e7853b0df0863a36688d77a1
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedTransportDefect.lean
@@ -0,0 +1,74 @@
+import OAI.Geometry.RCD.Transport.ActualRadialTransportDefect
+import OAI.Geometry.RCD.Sobolev.PoissonDefectBudget
+import OAI.Geometry.RCD.Harmonic.RadialVolumeUnits
+import OAI.Geometry.RCD.Metric.VolumeRigidityInput
+
+namespace OAI
+
+/-! # The actual transport error in the normalized source units -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) [IsFiniteMeasureOnCompacts μ] (hQ : QuadraticCheegerEnergy μ)
+
+/-- At the fixed projection radius, the full Poisson defect supplies
+exactly the radial error budget required by normalized transport. -/
+theorem DyadicDistanceReplacements.normalized_transport_defect
+ {n : ℕ} {κ r0 B J C σ : ℝ} {p : X}
+ {S : DyadicDistanceSources μ hQ n κ p r0}
+ (T : DyadicDistanceReplacements μ hQ S B J C) (i : ℕ)
+ (hκ : 0 ≤ κ) (hB : 0 ≤ B)
+ (hbudget : normalizedPoissonDefect μ hQ S i ≤ σ ^ 2)
+ (hvol : |μ.real (ball p (distanceSourceRadius r0 i / 2048)) /
+ (euclideanUnitVolume n * (distanceSourceRadius r0 i / 2048) ^ n) - 1| ≤ 1 / 4) :
+ let R := distanceSourceRadius r0 i / 2048
+ ∃ g : X → ℝ, MemLp g 2 μ ∧
+ (localGamma μ hQ (T.replacement i) (inwardSobolev μ hQ p (3 * R)) =ᵐ[
+ μ.restrict (ball p (3 * R))] fun x => g x - dist p x) ∧
+ (∫ x in ball p (4 * R), (g x) ^ 2 ∂μ) ≤
+ (B * (2048 : ℝ) ^ 2 * ((4 / (3 * euclideanUnitVolume n)) * (2048 : ℝ) ^ n)) *
+ R ^ 2 * μ.real (ball p R) * σ ^ 2 := by
+ dsimp only
+ let s := distanceSourceRadius r0 i
+ let R := s / 2048
+ let V := μ.real (ball p R)
+ let W := (4 / (3 * euclideanUnitVolume n)) * (2048 : ℝ) ^ n
+ have hs : 0 < s := distanceSourceRadius_pos S.radius_pos i
+ have hR : 0 < R := by dsimp only [R]; positivity
+ obtain ⟨hV, hlo, _⟩ := quarter_volume_bounds hR (euclideanUnitVolume_pos n) hvol
+ have hunit : W * ((3 / 4 : ℝ) * euclideanUnitVolume n * R ^ n) = s ^ (n : ℝ) := by
+ dsimp only [W, R]
+ rw [Real.rpow_natCast, div_pow]
+ field_simp [(euclideanUnitVolume_pos n).ne']
+ have hratio : s ^ (n : ℝ) ≤ W * V := by
+ rw [← hunit]
+ exact mul_le_mul_of_nonneg_left hlo (by
+ have homega := euclideanUnitVolume_pos n
+ dsimp only [W]
+ positivity)
+ have hmass : (S.source i).real (ball p s) ≤ s ^ (n : ℝ) * σ ^ 2 := by
+ have hsource : (S.source i).real (ball p s) ≤
+ s ^ (n : ℝ) * normalizedPoissonDefect μ hQ S i := by
+ rw [normalizedPoissonDefect_units]
+ exact le_add_of_nonneg_right (by positivity)
+ exact hsource.trans (mul_le_mul_of_nonneg_left hbudget (Real.rpow_nonneg hs.le _))
+ obtain ⟨g, hg, hradial, he⟩ := T.radial_transport_defect μ hQ i hR
+ (by dsimp only [R]; linarith : 3 * R ≤ 4 * s)
+ refine ⟨g, hg, hradial, ?_⟩
+ have hsize : (S.source i).real (ball p s) ≤ W * V * σ ^ 2 :=
+ hmass.trans (mul_le_mul_of_nonneg_right hratio (sq_nonneg _))
+ calc
+ _ ≤ (W * V * σ ^ 2) * (B * s ^ 2) :=
+ he.trans (mul_le_mul_of_nonneg_right hsize (mul_nonneg hB (sq_nonneg _)))
+ _ = (B * (2048 : ℝ) ^ 2 * W) * R ^ 2 * V * σ ^ 2 := by dsimp only [R]; ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedUniformL2.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedUniformL2.lean
new file mode 100644
index 0000000000000000000000000000000000000000..4a6e017d653144d90344094313442d82b2168bc2
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedUniformL2.lean
@@ -0,0 +1,47 @@
+import OAI.Analysis.RCDHeat.Foundations
+
+namespace OAI
+
+/-! # Uniform almost-everywhere convergence gives normalized L2 convergence
+
+The measures may vary and their masses need not be bounded away from zero.
+Only positivity and finiteness of each normalizing mass are used.
+-/
+
+open Set Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MeasurableSpace X]
+
+theorem normalized_sq_mean_tendsto_zero (μ : ℕ → Measure X)
+ [∀ k, IsFiniteMeasure (μ k)] (hmass : ∀ k, 0<(μ k).real univ)
+ (f : ℕ → X → ℝ) (hf : ∀ k, AEStronglyMeasurable (f k) (μ k))
+ (hlim : ∀ η : ℝ, 0<η → ∀ᶠ k in atTop, ∀ᵐ x ∂μ k, |f k x|≤η) :
+ Tendsto (fun k => ((μ k).real univ)⁻¹*(∫ x, (f k x)^2 ∂μ k)) atTop (𝓝 0) := by
+ apply tendsto_order.mpr
+ constructor
+ · intro a ha
+ exact Eventually.of_forall fun k => ha.trans_le (mul_nonneg
+ (inv_nonneg.mpr (hmass k).le) (integral_nonneg fun _ => sq_nonneg _))
+ · intro b hb
+ let η := Real.sqrt (b/2)
+ have hη : 0<η := Real.sqrt_pos.mpr (half_pos hb)
+ have hηsq : η^2=b/2 := Real.sq_sqrt (half_pos hb).le
+ filter_upwards [hlim η hη] with k hk
+ have hsq : ∀ᵐ x ∂μ k, (f k x)^2≤η^2 := hk.mono fun x hx =>
+ by simpa only [sq_abs] using pow_le_pow_left₀ (abs_nonneg _) hx 2
+ have hi : Integrable (fun x => (f k x)^2) (μ k) :=
+ (integrable_const (η^2)).mono' ((hf k).pow 2)
+ (hsq.mono fun x hx => by simpa only [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg (f k x))] using hx)
+ have hint := integral_mono_ae hi (integrable_const (η^2)) hsq
+ rw [integral_const,smul_eq_mul] at hint
+ have hbound := mul_le_mul_of_nonneg_left hint (inv_nonneg.mpr (hmass k).le)
+ rw [← mul_assoc,inv_mul_cancel₀ (hmass k).ne',one_mul,hηsq] at hbound
+ linarith
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedUniformMean.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedUniformMean.lean
new file mode 100644
index 0000000000000000000000000000000000000000..272dec7decc98fb17f4cad549e0739107e0aff8d
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedUniformMean.lean
@@ -0,0 +1,34 @@
+import OAI.Geometry.RCD.Coordinates.NormalizedUniformL2
+
+namespace OAI
+
+/-! # Normalized integral convergence under varying finite measures -/
+
+open Set Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MeasurableSpace X]
+
+theorem normalized_mean_tendsto_zero (μ : ℕ → Measure X)
+ [∀ k, IsFiniteMeasure (μ k)] (hmass : ∀ k, 0<(μ k).real univ)
+ (f : ℕ → X → ℝ)
+ (hlim : ∀ η : ℝ, 0<η → ∀ᶠ k in atTop, ∀ᵐ x ∂μ k, |f k x|≤η) :
+ Tendsto (fun k => ((μ k).real univ)⁻¹*(∫ x, f k x ∂μ k)) atTop (𝓝 0) := by
+ apply Metric.tendsto_nhds.mpr
+ intro η hη
+ filter_upwards [hlim (η/2) (half_pos hη)] with k hk
+ have hi := norm_integral_le_of_norm_le_const (μ := μ k) (f := f k) (C := η/2)
+ (hk.mono fun x hx => by simpa only [Real.norm_eq_abs] using hx)
+ have hb := mul_le_mul_of_nonneg_left hi (inv_nonneg.mpr (hmass k).le)
+ rw [mul_comm (η/2),← mul_assoc,inv_mul_cancel₀ (hmass k).ne',one_mul] at hb
+ rw [Real.dist_eq,sub_zero,abs_mul,abs_of_nonneg (inv_nonneg.mpr (hmass k).le)]
+ have hb' : ((μ k).real univ)⁻¹*|∫ x, f k x ∂μ k|≤η/2 := by
+ simpa only [Real.norm_eq_abs] using hb
+ exact hb'.trans_lt (half_lt_self hη)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/NormalizedUpdate.lean b/lean/OAI/Geometry/RCD/Coordinates/NormalizedUpdate.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ad17d3c283d5b09126c9331d79cf7f073bd4712b
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/NormalizedUpdate.lean
@@ -0,0 +1,94 @@
+import OAI.Geometry.RCD.Coordinates.FrozenJetTransport
+import OAI.Geometry.RCD.Sobolev.MetricCoercivity
+
+namespace OAI
+
+/-!
+# The coordinate update in frozen coordinates
+
+The source coordinate and its dual covector are transformed together.
+Consequently the inverse-transpose update has exactly the same form in
+the normalized variables; no norm of the coordinate change occurs.
+-/
+
+open scoped InnerProductSpace
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+
+/-- Affine coordinates frozen at a point and a scale. -/
+def frozenSource (r : ℝ) (T : E ≃L[ℝ] E) (x z : E) : E := x + r • T.symm z
+
+/-- The normalized coordinate map, with its value at the center removed. -/
+def normalizedCoordinates (r : ℝ) (T : E ≃L[ℝ] E) (x : E) (h : E → E)
+ (z : E) : E := r⁻¹ • (h (frozenSource r T x z) - h x)
+
+/-- The covector field uses the dual coordinate change. -/
+def normalizedCovector (r : ℝ) (T : E ≃L[ℝ] E) (x : E) (v : E → E)
+ (z : E) : E :=
+ r⁻¹ • (T.symm : E →L[ℝ] E).adjoint (v (frozenSource r T x z))
+
+omit [CompleteSpace E] in
+/-- The scale cancels out of the normalized Jacobian. -/
+theorem fderiv_normalizedCoordinates {r : ℝ} (hr : r ≠ 0)
+ (T : E ≃L[ℝ] E) (x z : E) (h : E → E)
+ (hh : DifferentiableAt ℝ h (frozenSource r T x z)) :
+ fderiv ℝ (normalizedCoordinates r T x h) z =
+ fderiv ℝ h (frozenSource r T x z) ∘L (T.symm : E →L[ℝ] E) := by
+ have hsource : HasFDerivAt (frozenSource r T x)
+ (r • (T.symm : E →L[ℝ] E)) z := by
+ change HasFDerivAt (fun y => x + r • T.symm y) _ z
+ convert (((T.symm : E →L[ℝ] E).hasFDerivAt.const_smul r).const_add x) using 1
+ funext y
+ rfl
+ have hn := ((hh.hasFDerivAt.comp z hsource).sub_const (h x)).const_smul r⁻¹
+ change HasFDerivAt (normalizedCoordinates r T x h) _ z at hn
+ rw [hn.fderiv]
+ ext ξ
+ simp [smul_smul, hr]
+
+/-- Exact covariance of the inverse transpose when the covector uses
+the dual change of basis. -/
+theorem inverseTranspose_normalized_apply (T J : E ≃L[ℝ] E) (w : E) :
+ inverseTranspose (T.symm.trans J) ((T.symm : E →L[ℝ] E).adjoint w) =
+ inverseTranspose J w := by
+ have hinv : ((T.symm.trans J).symm : E →L[ℝ] E) =
+ (T : E →L[ℝ] E) ∘L (J.symm : E →L[ℝ] E) := by
+ ext y
+ rfl
+ change ((↑(T.symm.trans J).symm : E →L[ℝ] E).adjoint)
+ ((T.symm : E →L[ℝ] E).adjoint w) = inverseTranspose J w
+ rw [hinv]
+ exact (inverseTranspose_frozen_factor T J w).symm
+
+/-- The actual normalized update is the normalized old map plus its
+inverse-transpose correction. Centering at the new map only changes
+this expression by a constant, handled by the jet transport lemmas. -/
+theorem normalized_update_identity {r : ℝ} (hr : r ≠ 0)
+ (T : E ≃L[ℝ] E) (x z : E) (h v : E → E)
+ (hh : DifferentiableAt ℝ h (frozenSource r T x z))
+ (J : E ≃L[ℝ] E)
+ (hJ : fderiv ℝ h (frozenSource r T x z) = (J : E →L[ℝ] E)) :
+ r⁻¹ • (h (frozenSource r T x z) +
+ operatorInverseTranspose (fderiv ℝ h (frozenSource r T x z))
+ (v (frozenSource r T x z)) - h x) =
+ normalizedCoordinates r T x h z +
+ operatorInverseTranspose (fderiv ℝ (normalizedCoordinates r T x h) z)
+ (normalizedCovector r T x v z) := by
+ have hnormalized : fderiv ℝ (normalizedCoordinates r T x h) z =
+ (T.symm.trans J : E ≃L[ℝ] E) := by
+ rw [fderiv_normalizedCoordinates hr T x z h hh, hJ]
+ rfl
+ rw [hnormalized, hJ, operatorInverseTranspose_equiv, operatorInverseTranspose_equiv]
+ unfold normalizedCoordinates normalizedCovector
+ rw [map_smul, inverseTranspose_normalized_apply]
+ module
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/OpenCoordinates.lean b/lean/OAI/Geometry/RCD/Coordinates/OpenCoordinates.lean
new file mode 100644
index 0000000000000000000000000000000000000000..37ee0249ef5f2769eefcd99755b50b5a279ad818
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/OpenCoordinates.lean
@@ -0,0 +1,404 @@
+import OAI.Geometry.RCD.Metric.MetricLimit
+import OAI.Analysis.RCDHeat.Foundations
+import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap
+import Mathlib.Topology.Homeomorph.Lemmas
+import Mathlib.Tactic.Abel
+
+namespace OAI
+
+/-!
+# Constructive openness of approximate Euclidean coordinates
+
+The hypotheses below are the scale-dependent approximation and nearby-metric
+estimates used in `co:open-coordinates`. Exact preimages and openness are proved
+by a convergent correction process; neither is an input.
+-/
+
+open Filter Set
+open scoped Topology
+
+namespace RegularPointCoordinates
+
+section Correction
+
+variable {X Y : Type*} [MetricSpace X] [CompleteSpace X] [MetricSpace Y]
+
+/-- A quarter-scale correction process stays strictly inside the working ball
+and converges to an exact preimage. The predicate records the current residual
+in a possibly changing norm. -/
+theorem exists_preimage_of_quarter_corrections
+ {f : X → Y} {x₀ : X} {P : Y} {r M : ℝ} (hr : 0 < r)
+ (control : ℕ → X → Prop) (hzero : control 0 x₀)
+ (hstep : ∀ n x, dist x x₀ < r / 2 → control n x →
+ ∃ y, dist y x ≤ r * (1 / 4 : ℝ) ^ n / 8 ∧ control (n + 1) y)
+ (hresidual : ∀ n x, dist x x₀ < r / 2 → control n x →
+ dist (f x) P ≤ M * (r * (1 / 4 : ℝ) ^ n))
+ (hcont : ContinuousOn f (Metric.ball x₀ (r / 2))) :
+ ∃ y, dist y x₀ ≤ r / 6 ∧ f y = P := by
+ classical
+ let next (n : ℕ) (x : X) : X :=
+ if h : dist x x₀ < r / 2 ∧ control n x then
+ Classical.choose (hstep n x h.1 h.2) else x
+ let a : ℕ → X := fun n => Nat.rec x₀ next n
+ have ha0 : a 0 = x₀ := rfl
+ have hasucc (n : ℕ) : a (n + 1) = next n (a n) := rfl
+ have hinv : ∀ n, dist (a n) x₀ ≤ r / 6 * (1 - (1 / 4 : ℝ) ^ n) ∧
+ control n (a n) := by
+ intro n
+ induction n with
+ | zero => simpa only [ha0, pow_zero, sub_self, mul_zero, dist_self] using
+ And.intro (le_refl (0 : ℝ)) hzero
+ | succ n ih =>
+ have hpow : 0 ≤ (1 / 4 : ℝ) ^ n := pow_nonneg (by norm_num) n
+ have hin : dist (a n) x₀ < r / 2 := by nlinarith [ih.1]
+ have hn := Classical.choose_spec (hstep n (a n) hin ih.2)
+ have hnext : a (n + 1) = Classical.choose (hstep n (a n) hin ih.2) := by
+ simp [hasucc, next, hin, ih.2]
+ rw [hnext]
+ refine ⟨?_, hn.2⟩
+ have ht := dist_triangle (Classical.choose (hstep n (a n) hin ih.2)) (a n) x₀
+ rw [pow_succ]
+ nlinarith [hn.1, ih.1]
+ have hin (n : ℕ) : dist (a n) x₀ < r / 2 := by
+ have hp : 0 ≤ (1 / 4 : ℝ) ^ n := pow_nonneg (by norm_num) n
+ nlinarith [(hinv n).1]
+ have hdist (n : ℕ) : dist (a n) (a (n + 1)) ≤ (r / 8) * (1 / 4 : ℝ) ^ n := by
+ have hn := Classical.choose_spec (hstep n (a n) (hin n) (hinv n).2)
+ have hnxt : a (n + 1) = Classical.choose (hstep n (a n) (hin n) (hinv n).2) := by
+ simp [hasucc, next, hin n, (hinv n).2]
+ rw [dist_comm, hnxt]
+ nlinarith [hn.1]
+ obtain ⟨y, hy⟩ := cauchySeq_tendsto_of_complete
+ (cauchySeq_of_le_geometric (1 / 4 : ℝ) (r / 8) (by norm_num) hdist)
+ have hybound : dist y x₀ ≤ r / 6 := by
+ have hb := dist_le_of_le_geometric_of_tendsto (1 / 4 : ℝ) (r / 8)
+ (by norm_num) hdist hy 0
+ rw [dist_comm]
+ calc
+ dist x₀ y ≤ (r / 8) / (1 - 1 / 4 : ℝ) := by
+ simpa only [ha0, pow_zero, mul_one] using hb
+ _ = r / 6 := by ring
+ have hymem : y ∈ Metric.ball x₀ (r / 2) := by
+ exact lt_of_le_of_lt hybound (by linarith)
+ have hf : Tendsto (fun n => f (a n)) atTop (𝓝 (f y)) :=
+ (hcont.continuousAt (Metric.isOpen_ball.mem_nhds hymem)).tendsto.comp hy
+ have hp : Tendsto (fun n => dist (f (a n)) P) atTop (𝓝 0) := by
+ apply squeeze_zero (fun n => dist_nonneg) (fun n => hresidual n (a n) (hin n) (hinv n).2)
+ simpa only [mul_zero] using (tendsto_const_nhds (x := M)).mul
+ ((tendsto_const_nhds (x := r)).mul
+ (tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0 : ℝ) ≤ 1 / 4)
+ (by norm_num : (1 / 4 : ℝ) < 1)))
+ have heq : dist (f y) P = 0 := tendsto_nhds_unique (hf.dist tendsto_const_nhds) hp
+ exact ⟨y, hybound, dist_eq_zero.mp heq⟩
+
+end Correction
+
+section Normalized
+
+variable {X E : Type*} [MetricSpace X] [CompleteSpace X]
+ [NormedAddCommGroup E] [NormedSpace ℝ E]
+
+omit [CompleteSpace X] in
+/-- Pointed metric approximation and uniform closeness of the normalized
+coordinate map supply the Euclidean correspondence needed below. -/
+theorem euclidean_correspondence_of_pointed_approximation
+ {f g : X → E} {x : X} {r : ℝ} (hr : 0 < r) (N : E ≃L[ℝ] E)
+ (hg : IsPointedApproximation x 0 r 1 (1 / 1024) g)
+ (hclose : ∀ y, dist y x ≤ r →
+ ‖r⁻¹ • N (f y - f x) - g y‖ ≤ 1 / 1024) :
+ ∀ a : E, ‖a‖ < r / 16 →
+ ∃ y, dist y x ≤ ‖a‖ + r / 256 ∧ ‖N (f y - f x) - a‖ ≤ r / 256 := by
+ intro a ha
+ have hscale (b : E) : ‖r⁻¹ • b‖ = ‖b‖ / r := by
+ simp only [norm_smul, Real.norm_eq_abs, abs_inv, abs_of_pos hr, div_eq_inv_mul]
+ have hat : ‖r⁻¹ • a‖ < 1 / 16 := by
+ rw [hscale, div_lt_iff₀ hr]
+ linarith
+ obtain ⟨y, hy, hgy⟩ := hg.2.2 (r⁻¹ • a) (by
+ rw [dist_zero_right]
+ linarith)
+ have hy' : dist y x ≤ r := by simpa only [one_mul] using hy
+ have hmetric := hg.2.1 y x hy (by simp only [dist_self, one_mul]; positivity)
+ have hbase := hg.1
+ have htri := dist_triangle4 (g y) (r⁻¹ • a) 0 (g x)
+ rw [dist_zero_right, dist_zero_left, ← dist_zero_right (g x)] at htri
+ have hdist : dist y x / r ≤ ‖a‖ / r + 3 / 1024 := by
+ rw [hscale] at htri
+ linarith [(abs_le.mp hmetric).1]
+ have hdist' := mul_le_mul_of_nonneg_right hdist hr.le
+ rw [add_mul, div_mul_cancel₀ _ hr.ne', div_mul_cancel₀ _ hr.ne'] at hdist'
+ have hres : ‖r⁻¹ • (N (f y - f x) - a)‖ ≤ 2 / 1024 := by
+ rw [smul_sub]
+ have ht := dist_triangle (r⁻¹ • N (f y - f x)) (g y) (r⁻¹ • a)
+ simp only [dist_eq_norm] at ht hgy
+ linarith [hclose y hy']
+ rw [hscale] at hres
+ have hres' := (div_le_iff₀ hr).mp hres
+ exact ⟨y, by linarith, by linarith⟩
+
+omit [CompleteSpace X] in
+/-- The approximate correction hypothesis follows directly from a normalized
+Euclidean correspondence: test the correspondence at the normalized target.
+The displacement error and coordinate error are both explicit. -/
+theorem approximate_preimage_of_euclidean_correspondence
+ {f : X → E} {x : X} {R : ℝ} (N : E ≃L[ℝ] E)
+ (hcorrespondence : ∀ a : E, ‖a‖ < R / 16 →
+ ∃ y, dist y x ≤ ‖a‖ + R / 256 ∧ ‖N (f y - f x) - a‖ ≤ R / 256)
+ {P : E} (hP : ‖N (P - f x)‖ < R / 16) :
+ ∃ y, dist y x ≤ 17 / 256 * R ∧ ‖N (P - f y)‖ ≤ R / 256 := by
+ obtain ⟨y, hy, herr⟩ := hcorrespondence (N (P - f x)) hP
+ refine ⟨y, by linarith, ?_⟩
+ have hid : N (f y - f x) - N (P - f x) = -(N (P - f y)) := by
+ simp only [map_sub, neg_sub]
+ abel
+ simpa only [hid, norm_neg] using herr
+
+/-- Concrete constants for the correction argument. `N n x` represents the
+inverse square root of the Gram matrix at the current scale and center. -/
+theorem exists_preimage_of_normalized_approximation
+ {f : X → E} {x₀ : X} {P : E} {r C : ℝ} (hr : 0 < r) (hC : 0 ≤ C)
+ (N : ℕ → X → E ≃L[ℝ] E)
+ (hzero : ‖N 0 x₀ (P - f x₀)‖ < r / 16)
+ (happrox : ∀ n x, dist x x₀ < r / 2 →
+ ‖N n x (P - f x)‖ < r * (1 / 4 : ℝ) ^ n / 16 →
+ ∃ y, dist y x ≤ 17 / 256 * (r * (1 / 4 : ℝ) ^ n) ∧
+ ‖N n x (P - f y)‖ ≤ r * (1 / 4 : ℝ) ^ n / 256)
+ (hnear : ∀ n x y, dist x x₀ < r / 2 → dist y x ≤ r * (1 / 4 : ℝ) ^ n / 8 →
+ ∀ w, ‖N (n + 1) y w‖ ≤ 2 * ‖N n x w‖)
+ (hupper : ∀ n x, dist x x₀ < r / 2 → ∀ w, ‖w‖ ≤ C * ‖N n x w‖)
+ (hcont : ContinuousOn f (Metric.ball x₀ (r / 2))) :
+ ∃ y, dist y x₀ ≤ r / 6 ∧ f y = P := by
+ let control : ℕ → X → Prop := fun n x =>
+ ‖N n x (P - f x)‖ < r * (1 / 4 : ℝ) ^ n / 16
+ apply exists_preimage_of_quarter_corrections hr control (by simpa [control] using hzero)
+ (M := C / 16) ?_ ?_ hcont
+ · intro n x hx hc
+ obtain ⟨y, hxy, hy⟩ := happrox n x hx hc
+ have hrn : 0 < r * (1 / 4 : ℝ) ^ n := mul_pos hr (pow_pos (by norm_num) n)
+ have hxy' : dist y x ≤ r * (1 / 4 : ℝ) ^ n / 8 := by nlinarith
+ refine ⟨y, hxy', ?_⟩
+ dsimp [control]
+ have hn := hnear n x y hx hxy' (P - f y)
+ rw [pow_succ]
+ nlinarith
+ · intro n x hx hc
+ have hu := hupper n x hx (P - f x)
+ have hm := mul_le_mul_of_nonneg_left hc.le hC
+ rw [dist_eq_norm, norm_sub_rev]
+ nlinarith
+
+end Normalized
+
+section OpenImage
+
+variable {X E : Type*} [MetricSpace X] [CompleteSpace X]
+ [NormedAddCommGroup E] [NormedSpace ℝ E]
+
+/-- The quarter scales used in the constructive surjectivity argument. -/
+noncomputable def coordinateQuarterRadius (r : ℝ) (i : ℕ) : ℝ := r * (1 / 4 : ℝ) ^ i
+
+theorem coordinateQuarterRadius_add (r : ℝ) (i n : ℕ) :
+ coordinateQuarterRadius r (i + n) =
+ coordinateQuarterRadius r i * (1 / 4 : ℝ) ^ n := by
+ simp only [coordinateQuarterRadius, pow_add, mul_assoc]
+
+/-- Raw approximation data: small normalized targets have approximate
+preimages, and changing the center and going down one quarter-scale costs at
+most two in the residual norm. All conditions are local to the open domain. -/
+structure OpenCoordinateData (Ω : Set X) (f : X → E) (r C : ℝ) where
+ normalization : ℕ → X → E ≃L[ℝ] E
+ approximate : ∀ i x, x ∈ Ω → Metric.closedBall x (coordinateQuarterRadius r i) ⊆ Ω →
+ ∀ P, ‖normalization i x (P - f x)‖ < coordinateQuarterRadius r i / 16 →
+ ∃ y, dist y x ≤ 17 / 256 * coordinateQuarterRadius r i ∧
+ ‖normalization i x (P - f y)‖ ≤ coordinateQuarterRadius r i / 256
+ nearby : ∀ i x y, x ∈ Ω → y ∈ Ω →
+ dist y x ≤ coordinateQuarterRadius r i / 8 →
+ ∀ w, ‖normalization (i + 1) y w‖ ≤ 2 * ‖normalization i x w‖
+ upper : ∀ i x, x ∈ Ω → ∀ w, ‖w‖ ≤ C * ‖normalization i x w‖
+
+namespace OpenCoordinateData
+
+/-- Build the approximation data directly from pointed metric approximations
+and uniform closeness of the normalized coordinate functions. -/
+def of_pointed_approximation {Ω : Set X} {f : X → E} {r C : ℝ} (hr : 0 < r)
+ (N : ℕ → X → E ≃L[ℝ] E)
+ (hcharts : ∀ i x, x ∈ Ω → Metric.closedBall x (coordinateQuarterRadius r i) ⊆ Ω →
+ ∃ g : X → E,
+ IsPointedApproximation x 0 (coordinateQuarterRadius r i) 1 (1 / 1024) g ∧
+ ∀ y, dist y x ≤ coordinateQuarterRadius r i →
+ ‖(coordinateQuarterRadius r i)⁻¹ • N i x (f y - f x) - g y‖ ≤ 1 / 1024)
+ (hnear : ∀ i x y, x ∈ Ω → y ∈ Ω →
+ dist y x ≤ coordinateQuarterRadius r i / 8 →
+ ∀ w, ‖N (i + 1) y w‖ ≤ 2 * ‖N i x w‖)
+ (hupper : ∀ i x, x ∈ Ω → ∀ w, ‖w‖ ≤ C * ‖N i x w‖) :
+ OpenCoordinateData Ω f r C where
+ normalization := N
+ approximate := by
+ intro i x hx hb P hP
+ obtain ⟨g, hg, hclose⟩ := hcharts i x hx hb
+ exact approximate_preimage_of_euclidean_correspondence (N i x)
+ (euclidean_correspondence_of_pointed_approximation
+ (mul_pos hr (pow_pos (by norm_num) i)) (N i x) hg hclose) hP
+ nearby := hnear
+ upper := hupper
+
+/-- An exact ellipsoid is contained in the image of the interior ball. The
+stronger one-sixth radius records the margin left by the Cauchy construction. -/
+theorem exists_preimage {Ω : Set X} {f : X → E} {r C : ℝ}
+ (d : OpenCoordinateData Ω f r C) (hr : 0 < r) (hC : 0 ≤ C)
+ (hcont : ContinuousOn f Ω) (i : ℕ) (x₀ : X)
+ (hball : Metric.ball x₀ (2 * coordinateQuarterRadius r i) ⊆ Ω)
+ {P : E} (hP : ‖d.normalization i x₀ (P - f x₀)‖ <
+ coordinateQuarterRadius r i / 16) :
+ ∃ y, dist y x₀ ≤ coordinateQuarterRadius r i / 6 ∧ f y = P := by
+ let R := coordinateQuarterRadius r i
+ have hR : 0 < R := mul_pos hr (pow_pos (by norm_num) i)
+ have hscale (n : ℕ) : coordinateQuarterRadius r (i + n) = R * (1 / 4 : ℝ) ^ n :=
+ coordinateQuarterRadius_add r i n
+ have hle (n : ℕ) : coordinateQuarterRadius r (i + n) ≤ R := by
+ rw [hscale]
+ exact mul_le_of_le_one_right hR.le (pow_le_one₀ (by norm_num) (by norm_num))
+ have hinside {x : X} (hx : dist x x₀ < R / 2) : x ∈ Ω :=
+ hball (by change dist x x₀ < 2 * R; linarith)
+ apply exists_preimage_of_normalized_approximation hR hC
+ (fun n x => d.normalization (i + n) x) (by simpa using hP) ?_ ?_ ?_ ?_
+ · intro n x hx ht
+ have hb : Metric.closedBall x (coordinateQuarterRadius r (i + n)) ⊆ Ω := by
+ intro z hz
+ apply hball
+ have htri := dist_triangle z x x₀
+ change dist z x₀ < 2 * R
+ have hz' : dist z x ≤ coordinateQuarterRadius r (i + n) := hz
+ linarith [hle n]
+ simpa only [hscale] using d.approximate (i + n) x (hinside hx) hb P
+ (by simpa only [hscale] using ht)
+ · intro n x y hx hxy w
+ have hy : y ∈ Ω := by
+ apply hball
+ have htri := dist_triangle y x x₀
+ have hxy' : dist y x ≤ coordinateQuarterRadius r (i + n) / 8 := by
+ simpa only [hscale] using hxy
+ change dist y x₀ < 2 * R
+ linarith [hle n]
+ simpa only [Nat.add_assoc] using d.nearby (i + n) x y (hinside hx) hy
+ (by simpa only [hscale] using hxy) w
+ · intro n x hx w
+ exact d.upper (i + n) x (hinside hx) w
+ · exact hcont.mono (fun x hx => hinside hx)
+
+/-- Approximation on all quarter-scales gives arbitrarily localized exact
+preimages. The target neighborhood is an explicit frozen ellipsoid. -/
+theorem localized_surjectivity {Ω : Set X} {f : X → E} {r C : ℝ}
+ (d : OpenCoordinateData Ω f r C) (hr : 0 < r) (hC : 0 ≤ C)
+ (hΩ : IsOpen Ω) (hcont : ContinuousOn f Ω) {x : X} (hx : x ∈ Ω)
+ {δ : ℝ} (hδ : 0 < δ) :
+ ∃ i, ∀ P, ‖d.normalization i x (P - f x)‖ < coordinateQuarterRadius r i / 16 →
+ ∃ y ∈ Ω, dist y x < δ ∧ f y = P := by
+ obtain ⟨a, ha, hball⟩ := Metric.isOpen_iff.mp hΩ x hx
+ have hlim : Tendsto (fun i => coordinateQuarterRadius r i) atTop (𝓝 0) := by
+ simpa only [coordinateQuarterRadius, mul_zero] using (tendsto_const_nhds (x := r)).mul
+ (tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0 : ℝ) ≤ 1 / 4)
+ (by norm_num : (1 / 4 : ℝ) < 1))
+ have hev : ∀ᶠ i in atTop, coordinateQuarterRadius r i < min (a / 2) δ :=
+ hlim.eventually (gt_mem_nhds (by positivity : 0 < min (a / 2) δ))
+ obtain ⟨i, hi⟩ := hev.exists
+ have hR : 0 < coordinateQuarterRadius r i := mul_pos hr (pow_pos (by norm_num) i)
+ refine ⟨i, fun P hP => ?_⟩
+ have hb : Metric.ball x (2 * coordinateQuarterRadius r i) ⊆ Ω := by
+ intro y hy
+ apply hball
+ have hy' : dist y x < 2 * coordinateQuarterRadius r i := hy
+ change dist y x < a
+ linarith [lt_of_lt_of_le hi (min_le_left _ _)]
+ obtain ⟨y, hy, hfy⟩ := d.exists_preimage hr hC hcont i x hb hP
+ refine ⟨y, hb ?_, ?_, hfy⟩
+ · change dist y x < 2 * coordinateQuarterRadius r i
+ linarith
+ · linarith [lt_of_lt_of_le hi (min_le_right _ _)]
+
+/-- The restriction of the coordinates to the open working domain is an open
+map. This uses exact preimages, without any invariance-of-domain input. -/
+theorem isOpenMap {Ω : Set X} {f : X → E} {r C : ℝ}
+ (d : OpenCoordinateData Ω f r C) (hr : 0 < r) (hC : 0 ≤ C)
+ (hΩ : IsOpen Ω) (hcont : ContinuousOn f Ω) :
+ IsOpenMap (fun x : Ω => f x) := by
+ intro U hU
+ apply isOpen_iff_mem_nhds.mpr
+ rintro P ⟨x, hx, rfl⟩
+ obtain ⟨δ, hδ, hδU⟩ := Metric.isOpen_iff.mp hU x hx
+ obtain ⟨i, hi⟩ := d.localized_surjectivity hr hC hΩ hcont x.property hδ
+ let V := {P : E | ‖d.normalization i x (P - f x)‖ < coordinateQuarterRadius r i / 16}
+ have hVopen : IsOpen V := isOpen_lt
+ ((d.normalization i x).continuous.comp (continuous_id.sub continuous_const)).norm
+ continuous_const
+ have hxV : f x ∈ V := by
+ change ‖d.normalization i x (f x - f x)‖ < coordinateQuarterRadius r i / 16
+ simp only [sub_self, map_zero, norm_zero]
+ exact div_pos (mul_pos hr (pow_pos (by norm_num) i)) (by norm_num)
+ apply Filter.mem_of_superset (hVopen.mem_nhds hxV)
+ intro P hP
+ obtain ⟨y, hy, hdist, hfy⟩ := hi P hP
+ exact ⟨⟨y, hy⟩, hδU hdist, hfy⟩
+
+/-- Once separation has been proved, the constructive open map is an open
+embedding, hence a homeomorphism onto its open image. -/
+theorem isOpenEmbedding {Ω : Set X} {f : X → E} {r C : ℝ}
+ (d : OpenCoordinateData Ω f r C) (hr : 0 < r) (hC : 0 ≤ C)
+ (hΩ : IsOpen Ω) (hcont : ContinuousOn f Ω) (hinj : Set.InjOn f Ω) :
+ Topology.IsOpenEmbedding (fun x : Ω => f x) := by
+ apply Topology.IsOpenEmbedding.of_continuous_injective_isOpenMap
+ · exact continuousOn_iff_continuous_domRestrict.mp hcont
+ · intro x y hxy
+ exact Subtype.ext (hinj x.property y.property hxy)
+ · exact d.isOpenMap hr hC hΩ hcont
+
+/-- The resulting homeomorphism retains the original coordinate values. -/
+noncomputable def homeomorph {Ω : Set X} {f : X → E} {r C : ℝ}
+ (d : OpenCoordinateData Ω f r C) (hr : 0 < r) (hC : 0 ≤ C)
+ (hΩ : IsOpen Ω) (hcont : ContinuousOn f Ω) (hinj : Set.InjOn f Ω) :
+ Ω ≃ₜ Set.range (fun x : Ω => f x) :=
+ (d.isOpenEmbedding hr hC hΩ hcont hinj).toIsEmbedding.toHomeomorph
+
+theorem isOpen_range {Ω : Set X} {f : X → E} {r C : ℝ}
+ (d : OpenCoordinateData Ω f r C) (hr : 0 < r) (hC : 0 ≤ C)
+ (hΩ : IsOpen Ω) (hcont : ContinuousOn f Ω) :
+ IsOpen (Set.range (fun x : Ω => f x)) := by
+ simpa only [Set.image_univ] using d.isOpenMap hr hC hΩ hcont Set.univ isOpen_univ
+
+end OpenCoordinateData
+
+omit [CompleteSpace X] in
+/-- A normalized distance approximation with error at most half the pair's
+distance separates the pair. The scale may depend on both points. -/
+theorem injOn_of_normalized_separation {Ω : Set X} {f : X → E}
+ (N : ℕ → X → E ≃L[ℝ] E)
+ (hsep : ∀ x ∈ Ω, ∀ z ∈ Ω, x ≠ z → ∃ i,
+ |‖N i x (f z - f x)‖ - dist x z| ≤ dist x z / 2) : Set.InjOn f Ω := by
+ intro x hx z hz heq
+ by_contra hne
+ obtain ⟨i, hi⟩ := hsep x hx z hz hne
+ have hd : 0 < dist x z := dist_pos.mpr hne
+ rw [← heq, sub_self, map_zero, norm_zero, zero_sub, abs_neg,
+ abs_of_nonneg dist_nonneg] at hi
+ linarith
+
+/-- The complete constructive conclusion, with the homeomorphism equal to the
+given coordinate map and its image proved open. -/
+theorem open_homeomorph_of_normalized_separation
+ {Ω : Set X} {f : X → E} {r C : ℝ}
+ (d : OpenCoordinateData Ω f r C) (hr : 0 < r) (hC : 0 ≤ C)
+ (hΩ : IsOpen Ω) (hcont : ContinuousOn f Ω)
+ (hsep : ∀ x ∈ Ω, ∀ z ∈ Ω, x ≠ z → ∃ i,
+ |‖d.normalization i x (f z - f x)‖ - dist x z| ≤ dist x z / 2) :
+ IsOpen (Set.range (fun x : Ω => f x)) ∧
+ ∃ e : Ω ≃ₜ Set.range (fun x : Ω => f x), ∀ x, (e x).val = f x := by
+ refine ⟨d.isOpen_range hr hC hΩ hcont,
+ d.homeomorph hr hC hΩ hcont (injOn_of_normalized_separation d.normalization hsep), ?_⟩
+ intro x
+ rfl
+
+end OpenImage
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/OpenLimitChart.lean b/lean/OAI/Geometry/RCD/Coordinates/OpenLimitChart.lean
new file mode 100644
index 0000000000000000000000000000000000000000..b09fd1ce734ebf1540fd442715f26628caf56ac2
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/OpenLimitChart.lean
@@ -0,0 +1,61 @@
+import OAI.Geometry.RCD.Sobolev.CoerciveOpenMapping
+import OAI.Geometry.RCD.Coordinates.ChartTopology
+
+namespace OAI
+
+/-! # Openness of the coordinate limit from its actual approximating maps -/
+
+open Set Filter Topology
+open scoped Topology
+
+noncomputable section
+namespace RegularPointCoordinates
+
+/-- Only the actual smooth approximants and their uniform lower differential
+bound are needed for openness of the final bi-Lipschitz chart. -/
+theorem hasOpenBilipschitzChart_of_coercive_limit
+ {X : Type*} [MetricSpace X] {n : ℕ} {p : X}
+ {U : Set X} (hU : IsOpen U) (hp : p ∈ U)
+ {O : Set (Euclidean n)} (hO : IsOpen O) (u : U ≃ₜ O)
+ {f : ℕ → Euclidean n → Euclidean n} {H : U → Euclidean n}
+ {M L : ℝ} (hM : 0 < M) (hL : 1 ≤ L)
+ (hd : ∀ i z, z ∈ O → DifferentiableAt ℝ (f i) z)
+ (hb : ∀ i z, z ∈ O → ∀ v, ‖v‖ ≤ M*‖fderiv ℝ (f i) z v‖)
+ {e : ℕ → ℝ} (he : Tendsto e atTop (𝓝 0))
+ (herr : ∀ i x, dist (f i (u x)) (H x) ≤ e i)
+ (hbound : ∀ x z : U, L⁻¹*dist (x:X) (z:X) ≤ dist (H x) (H z) ∧
+ dist (H x) (H z) ≤ L*dist (x:X) (z:X)) :
+ HasOpenBilipschitzChart n p := by
+ classical
+ have hLpos : 0 < L := lt_of_lt_of_le zero_lt_one hL
+ obtain ⟨hLip,hAnti⟩ := lipschitz_antilipschitz_of_dist_bounds
+ (inv_pos.mpr hLpos) hLpos.le hbound
+ let F : Euclidean n → Euclidean n := fun z => if hz : z ∈ O then H (u.symm ⟨z,hz⟩) else 0
+ have hFval (z : O) : F z = H (u.symm z) := by simp only [F, dite_eq_left z.property]
+ have hF : ContinuousOn F O := by
+ apply continuousOn_iff_continuous_domRestrict.mpr
+ convert hLip.continuous.comp u.symm.continuous using 1
+ exact funext hFval
+ have hrange : F '' O = range H := by
+ ext y
+ constructor
+ · rintro ⟨z,hz,rfl⟩
+ rw [hFval ⟨z,hz⟩]
+ exact mem_range_self _
+ · rintro ⟨x,rfl⟩
+ refine ⟨u x, (u x).property, ?_⟩
+ rw [hFval, u.symm_apply_apply]
+ have hopen : IsOpen (range H) := by
+ rw [← hrange]
+ apply isOpen_image_of_uniform_limit_differential_bound hO hF hM hd hb he
+ intro i z hz
+ rw [hFval ⟨z,hz⟩]
+ simpa only [u.apply_symm_apply] using herr i (u.symm ⟨z,hz⟩)
+ have hEmb : IsEmbedding H := hAnti.isEmbedding hLip.continuous
+ exact ⟨U, range H, hU, hp, hopen, hEmb.toHomeomorph, L, hL, hbound⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/OpenRegularCutoff.lean b/lean/OAI/Geometry/RCD/Coordinates/OpenRegularCutoff.lean
new file mode 100644
index 0000000000000000000000000000000000000000..884981b5e82c1a87917a3066e590e861df8ef167
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/OpenRegularCutoff.lean
@@ -0,0 +1,67 @@
+import OAI.Geometry.RCD.Coordinates.RegularCompactCutoff
+
+namespace OAI
+
+/-! # Interior regular cutoffs around compact sets -/
+
+open Set Filter Metric MeasureTheory
+open scoped NNReal Topology
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- Every compact subset of an open set admits a compact Lipschitz plateau
+with an actual L² weak Laplacian. Finite unions of the RCD ball cutoffs
+supply the arbitrary shape without an additional analytic hypothesis. -/
+theorem NoncollapsedRCD.exists_open_regular_cutoff {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n)
+ {Ω S : Set X} (hΩ : IsOpen Ω) (hS : IsCompact S) (hsub : S ⊆ Ω) :
+ letI := locallyFinite_of_finiteOnBounded (hausdorff n X) hX.finiteOnBounded
+ ∃ χ : RegularCompactCutoff (hausdorff n X) hX.quadratic,
+ tsupport χ.weight ⊆ Ω ∧ ∀ x ∈ S, χ.weight x=1 := by
+ let := locallyFinite_of_finiteOnBounded (hausdorff n X) hX.finiteOnBounded
+ let μ := hausdorff n X
+ apply hS.induction_on (p := fun T => ∃ χ : RegularCompactCutoff μ hX.quadratic,
+ tsupport χ.weight ⊆ Ω ∧ ∀ x ∈ T, χ.weight x=1)
+ · refine ⟨RegularCompactCutoff.zero,?_,by simp⟩
+ simp [RegularCompactCutoff.zero]
+ · intro T U hTU hU
+ obtain ⟨χ,hχ,hχ1⟩ := hU
+ exact ⟨χ,hχ,fun x hx => hχ1 x (hTU hx)⟩
+ · intro T U hT hU
+ obtain ⟨χ,hχ,hχ1⟩ := hT
+ obtain ⟨η,hη,hη1⟩ := hU
+ refine ⟨χ.union η,(χ.union_support η).trans (union_subset hχ hη),?_⟩
+ intro x hx
+ rcases hx with hx | hx
+ · exact χ.union_one_left η (hχ1 x hx)
+ · exact χ.union_one_right η (hη1 x hx)
+ · intro x hx
+ obtain ⟨ε,hε,hball⟩ := Metric.isOpen_iff.mp hΩ x (hsub hx)
+ have hr : 0 < ε/3 := by positivity
+ obtain ⟨C,-,⟨χ⟩⟩ := hX.goodCutoff_exists hn x hr
+ let η : RegularCompactCutoff μ hX.quadratic := {
+ weight := χ.weight
+ lip := (C/(ε/3)).toNNReal
+ lipschitz := χ.lipschitz
+ compact := χ.hasCompactSupport μ hX.quadratic
+ bounds := χ.bounds
+ sobolev := χ.sobolev
+ representative := χ.representative
+ laplacian := χ.laplacian
+ weak_laplacian := χ.weak_laplacian }
+ refine ⟨ball x (ε/3),mem_nhdsWithin_of_mem_nhds (ball_mem_nhds x hr),η,?_,χ.one⟩
+ apply (χ.tsupport_subset μ hX.quadratic).trans
+ intro y hy
+ apply hball
+ have hd : dist y x ≤ 2*(ε/3) := hy
+ show dist y x < ε
+ linarith
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/OuterNormalizedSquareLimit.lean b/lean/OAI/Geometry/RCD/Coordinates/OuterNormalizedSquareLimit.lean
new file mode 100644
index 0000000000000000000000000000000000000000..acd6ad5aca5a41ec6f61668c473144c496a0345f
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/OuterNormalizedSquareLimit.lean
@@ -0,0 +1,64 @@
+import OAI.Geometry.RCD.Metric.InnerBallValueMoments
+import OAI.Geometry.RCD.Metric.MeasuredAnnularMass
+import OAI.Geometry.RCD.Coordinates.Proper
+
+namespace OAI
+
+/-! # Quadratic value limits with the original outer mass normalization -/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology NNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+
+private theorem cancel_middle_inverse (a b c : ℝ) (hb : b≠0) :
+ a*b*(b⁻¹*c)=a*c := by
+ calc _ = a*(b*b⁻¹)*c := by ring
+ _ = _ := by rw [mul_inv_cancel₀ hb,mul_one]
+
+theorem NoncollapsedRCD.outer_normalized_square_limit {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) {S ρ τ : ℝ} (hS : 0 ((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (ρ*r k), (SobolevSpace.toLp (hausdorff n X) hX.quadratic (u k) x)^2
+ ∂hausdorff n X) atTop
+ (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*∫ z in ball 0 ρ, (g z)^2)) := by
+ have hρS := hρτ.le.trans hτS
+ have hfin (k : ℕ) := (hX.finiteOnBounded (ball (p k) (S*r k)) isBounded_ball).ne
+ have hpos (k : ℕ) : 0<(hausdorff n X).real (ball (p k) (S*r k)) :=
+ ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hS (hr k))).ne' (hfin k)
+ have hinner (k : ℕ) : 0<(hausdorff n X).real (ball (p k) (ρ*r k)) :=
+ ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hρ (hr k))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne
+ have hi := inner_ball_value_moment_tendsto hS hρ hρτ hτS hr hV hfin hpos hinner hε
+ (fun k => SobolevSpace.toLp (hausdorff n X) hX.quadratic (u k))
+ (fun k => SobolevSpace.toLp (hausdorff n X) hX.quadratic (u k)) g g hg hg
+ (fun k => by simpa only [← pow_two] using (Lp.memLp
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic (u k))).integrable_sq.restrict) hu hu
+ have hm := measured_ball_mass_tendsto hS hρ hρS hr hV hfin hpos hε
+ have hVρ : volume.real (ball (0:Euclidean n) ρ)≠0 :=
+ (ENNReal.toReal_pos (measure_ball_pos volume 0 hρ).ne' measure_ball_ne_top).ne'
+ have ht := hm.mul hi
+ simp only [← pow_two] at ht
+ convert ht using 1
+ · funext k
+ have he := (hinner k).ne'
+ exact (cancel_middle_inverse _ _ _ he).symm
+ · congr 1
+ exact (cancel_middle_inverse _ _ _ hVρ).symm
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/OutwardCovectorGrowth.lean b/lean/OAI/Geometry/RCD/Coordinates/OutwardCovectorGrowth.lean
new file mode 100644
index 0000000000000000000000000000000000000000..804e6c44037ae70e84ad0fb100c012aaa7a11b6a
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/OutwardCovectorGrowth.lean
@@ -0,0 +1,67 @@
+import OAI.Geometry.RCD.Coordinates.DyadicCovectorGrowth
+
+namespace OAI
+
+/-! # The complementary growth bound for shrinking-scale covectors -/
+
+open Set Metric MeasureTheory
+open scoped InnerProductSpace
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- The other half of the same adjacent mean comparison bounds smaller
+scale covectors by the original one. Together with shrinking radii this
+makes the center values of the actual affine fits tend to zero. -/
+theorem dyadic_covector_norm_reverse_growth {K : ℝ} (m : ℕ)
+ (hX : NoncollapsedRCD K (m + 1) X) {a R ε : ℝ} (ha : 0 ≤ a)
+ (hBG : BallVolumeComparison (hausdorff (m + 1) X) (comparisonModelVolume m a))
+ (u : Fin (m + 1) → SobolevSpace (hausdorff (m + 1) X) hX.quadratic)
+ (p : X) (hR : 0 < R) (hscale : a * (3 * R) ≤ 1) (hε : 0 ≤ ε)
+ (hsmall : ((m + 1 : ℕ) : ℝ) ^ 2 * (normalizationVolumeRatio m * ε) ≤ 1 / 64)
+ (S : ℕ → Euclidean (m + 1) ≃L[ℝ] Euclidean (m + 1))
+ (hexact : ∀ i, IsExactMeanNormalization (hausdorff (m + 1) X) hX.quadratic
+ (sobolevColumnMap (hausdorff (m + 1) X) hX.quadratic u)
+ (ball p (R / 2 ^ i)) measurableSet_ball (S i))
+ (hfirst : ∀ i, ∃ w : X → Euclidean (m + 1),
+ FirstOrderSplittingOn (hausdorff (m + 1) X) hX.quadratic p (R / 2 ^ i) ε
+ (transformedColumn (hausdorff (m + 1) X) hX.quadratic u (S i)) w) :
+ ∀ i k (b : Euclidean (m + 1)),
+ ‖(S (i + k)).symm b‖ ≤ (9 / 8 : ℝ) ^ k * ‖(S i).symm b‖ := by
+ let μ := hausdorff (m + 1) X
+ have hstep (i : ℕ) (b : Euclidean (m + 1)) :
+ ‖(S (i + 1)).symm b‖ ≤ (9 / 8 : ℝ) * ‖(S i).symm b‖ := by
+ have hr : 0 < R / (2 : ℝ) ^ i := div_pos hR (by positivity)
+ have hrR : R / (2 : ℝ) ^ i ≤ R := div_le_self hR.le (one_le_pow₀ (by norm_num))
+ have hscaled : a * (3 * ((R / (2 : ℝ) ^ i) / 2)) ≤ 1 := by
+ exact (mul_le_mul_of_nonneg_left (show 3 * ((R / (2 : ℝ) ^ i) / 2) ≤ 3 * R by linarith) ha).trans hscale
+ obtain ⟨w, hw⟩ := hfirst i
+ have hh := (normalized_adjacent_mean_comparison m hX ha hBG u (S i) hr hscaled hε hw (hexact i) b).2
+ have hnext : (R / (2 : ℝ) ^ i) / 2 = R / 2 ^ (i + 1) := by
+ rw [pow_succ]
+ field_simp
+ rw [hnext] at hh
+ rw [← exact_mean_inverse_norm_sq μ hX.quadratic _ _ measurableSet_ball (S i) (hexact i) b,
+ ← exact_mean_inverse_norm_sq μ hX.quadratic _ _ measurableSet_ball (S (i + 1)) (hexact (i + 1)) b] at hh
+ have hs := mul_le_mul_of_nonneg_right hsmall (sq_nonneg ‖(S i).symm b‖)
+ have hsq : ‖(S (i + 1)).symm b‖ ^ 2 ≤ ((9 / 8 : ℝ) * ‖(S i).symm b‖) ^ 2 := by
+ nlinarith [sq_nonneg ‖(S i).symm b‖]
+ exact (sq_le_sq₀ (norm_nonneg _) (by positivity)).mp hsq
+ intro i k b
+ induction k with
+ | zero => simp
+ | succ k ih =>
+ have hh := mul_le_mul_of_nonneg_left ih (by norm_num : (0 : ℝ) ≤ 9 / 8)
+ calc
+ _ ≤ (9 / 8 : ℝ) * ‖(S (i + k)).symm b‖ := by
+ simpa only [Nat.add_assoc] using hstep (i + k) b
+ _ ≤ (9 / 8 : ℝ) * ((9 / 8 : ℝ) ^ k * ‖(S i).symm b‖) := hh
+ _ = _ := by rw [pow_succ]; ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/OverlappingExactFrames.lean b/lean/OAI/Geometry/RCD/Coordinates/OverlappingExactFrames.lean
new file mode 100644
index 0000000000000000000000000000000000000000..537dff6035b01c4364ff137f6333da3c05253131
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/OverlappingExactFrames.lean
@@ -0,0 +1,73 @@
+import OAI.Geometry.RCD.Coordinates.ExactNormalizationComparison
+
+namespace OAI
+
+/-! # Comparing two exact frames through their common overlap -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal InnerProductSpace
+
+noncomputable section
+namespace RegularPointCoordinates
+
+private theorem overlap_square_comparison {a b g t : ℝ}
+ (ha : 0 ≤ a) (hb : 0 ≤ b) (ht : t ≤ 1 / 3)
+ (hlo : (1 - t) * a ≤ g) (hhi : g ≤ (1 + t) * b) : a ≤ 2 * b := by
+ have hl := mul_le_mul_of_nonneg_right (show (2 / 3 : ℝ) ≤ 1 - t by linarith) ha
+ have hh := mul_le_mul_of_nonneg_right (show 1 + t ≤ (4 / 3 : ℝ) by linarith) hb
+ linarith
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- The same positive overlap compares exact normalizers centered at two
+points. Only the already controlled volume-ratio loss enters the bound. -/
+theorem overlapping_exact_frames {n : ℕ}
+ (u : Fin n → SobolevSpace μ hQ) (p q : X) (R : ℝ)
+ (Np Nq : Euclidean n ≃L[ℝ] Euclidean n) {ε C : ℝ}
+ (hε : 0 ≤ ε) (hC : 0 ≤ C) (hsmall : (n : ℝ) ^ 2 * (C * ε) ≤ 1 / 3)
+ (vp vq : X → Euclidean n)
+ (hp : FirstOrderSplittingOn μ hQ p R ε (transformedColumn μ hQ u Np) vp)
+ (hq : FirstOrderSplittingOn μ hQ q R ε (transformedColumn μ hQ u Nq) vq)
+ (hep : IsExactMeanNormalization μ hQ (sobolevColumnMap μ hQ u) (ball p R) measurableSet_ball Np)
+ (heq : IsExactMeanNormalization μ hQ (sobolevColumnMap μ hQ u) (ball q R) measurableSet_ball Nq)
+ (S : Set X) (hS : MeasurableSet S) (hSp : S ⊆ ball p R) (hSq : S ⊆ ball q R)
+ (hS0 : μ S ≠ 0) (hSfin : μ S ≠ ∞)
+ (hp0 : μ (ball p R) ≠ 0) (hpfin : μ (ball p R) ≠ ∞)
+ (hq0 : μ (ball q R) ≠ 0) (hqfin : μ (ball q R) ≠ ∞)
+ (hvp : μ.real (ball p R) ≤ C * μ.real S)
+ (hvq : μ.real (ball q R) ≤ C * μ.real S) :
+ ‖Np.symm.toContinuousLinearMap.comp Nq.toContinuousLinearMap‖ ≤ Real.sqrt 2 ∧
+ ‖Nq.symm.toContinuousLinearMap.comp Np.toContinuousLinearMap‖ ≤ Real.sqrt 2 := by
+ have hforms (b : Euclidean n) :
+ ‖Np.symm b‖ ^ 2 ≤ 2 * ‖Nq.symm b‖ ^ 2 ∧
+ ‖Nq.symm b‖ ^ 2 ≤ 2 * ‖Np.symm b‖ ^ 2 := by
+ have hp' := exact_normalization_subball_bounds μ hQ u Np hp hep S hS hSp
+ hS0 hSfin hp0 hpfin hC hε hvp b
+ have hq' := exact_normalization_subball_bounds μ hQ u Nq hq heq S hS hSq
+ hS0 hSfin hq0 hqfin hC hε hvq b
+ rw [← exact_mean_inverse_norm_sq μ hQ _ (ball p R) measurableSet_ball Np hep b] at hp'
+ rw [← exact_mean_inverse_norm_sq μ hQ _ (ball q R) measurableSet_ball Nq heq b] at hq'
+ exact ⟨overlap_square_comparison (sq_nonneg _) (sq_nonneg _) hsmall hp'.1 hq'.2,
+ overlap_square_comparison (sq_nonneg _) (sq_nonneg _) hsmall hq'.1 hp'.2⟩
+ constructor
+ · apply ContinuousLinearMap.opNorm_le_bound _ (Real.sqrt_nonneg 2)
+ intro b
+ have hh := (hforms (Nq b)).1
+ simp only [ContinuousLinearEquiv.symm_apply_apply] at hh
+ change ‖Np.symm (Nq b)‖ ≤ Real.sqrt 2 * ‖b‖
+ apply (sq_le_sq₀ (norm_nonneg _) (mul_nonneg (Real.sqrt_nonneg _) (norm_nonneg _))).mp
+ simpa only [mul_pow, Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 2)] using hh
+ · apply ContinuousLinearMap.opNorm_le_bound _ (Real.sqrt_nonneg 2)
+ intro b
+ have hh := (hforms (Np b)).2
+ simp only [ContinuousLinearEquiv.symm_apply_apply] at hh
+ change ‖Nq.symm (Np b)‖ ≤ Real.sqrt 2 * ‖b‖
+ apply (sq_le_sq₀ (norm_nonneg _) (mul_nonneg (Real.sqrt_nonneg _) (norm_nonneg _))).mp
+ simpa only [mul_pow, Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 2)] using hh
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PairGeometry.lean b/lean/OAI/Geometry/RCD/Coordinates/PairGeometry.lean
new file mode 100644
index 0000000000000000000000000000000000000000..06f4c2699ef54bc703bbb0d55642efc82d16e332
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PairGeometry.lean
@@ -0,0 +1,93 @@
+import OAI.Geometry.RCD.Coordinates.IterationLimit
+
+namespace OAI
+
+/-!
+# Pair segments from harmonic-coordinate ellipsoids
+
+The final analytic argument only needs a coordinate segment to stay in the
+larger working region, with comparable frozen metrics along it. Central
+ellipsoid containment and the nearby-center comparison imply precisely
+those facts. The source of the final chart may be a smaller open subset.
+-/
+
+open Set
+
+namespace RegularPointCoordinates
+
+variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
+
+theorem norm_frozen_sub_le_of_mem_segment (T : E →L[ℝ] E)
+ {A B P : E} (hP : P ∈ segment ℝ A B) :
+ ‖T (P - A)‖ ≤ ‖T (B - A)‖ := by
+ obtain ⟨a, b, ha, hb, hab, rfl⟩ := hP
+ have haeq : a = 1 - b := by linarith
+ have hbeq : (a • A + b • B) - A = b • (B - A) := by
+ rw [haeq]
+ module
+ rw [hbeq, map_smul, norm_smul, Real.norm_eq_abs, abs_of_nonneg hb]
+ exact mul_le_of_le_one_left (norm_nonneg _) (by linarith)
+
+/-- Every point of the short coordinate segment has a preimage in the
+nearby metric ball. Thus the nearby-center bound applies along the
+whole segment, without any differentiability of the frozen metrics. -/
+theorem segment_geometry_of_ellipsoid
+ {X : Type*} [MetricSpace X] (u : X → E) (frozen : E → E ≃L[ℝ] E)
+ {Ω : Set E} {W : Set X} {x z : X} {r c G : ℝ}
+ (hend : ‖frozen (u x) (u z - u x)‖ < c * r)
+ (hball : ∀ P : E, ‖frozen (u x) (P - u x)‖ < c * r →
+ P ∈ Ω ∧ ∃ y ∈ W, dist x y < r ∧ u y = P)
+ (hnear : ∀ y ∈ W, dist x y < r → ∀ w : E,
+ ‖frozen (u y) w‖ ≤ G * ‖frozen (u x) w‖) :
+ segment ℝ (u x) (u z) ⊆ Ω ∧ ∀ P ∈ segment ℝ (u x) (u z),
+ ‖frozen P (u z - u x)‖ ≤ G * ‖frozen (u x) (u z - u x)‖ := by
+ have hinside (P : E) (hP : P ∈ segment ℝ (u x) (u z)) :
+ P ∈ Ω ∧ ∃ y ∈ W, dist x y < r ∧ u y = P := by
+ apply hball P
+ exact (norm_frozen_sub_le_of_mem_segment (frozen (u x)).toContinuousLinearMap hP).trans_lt hend
+ constructor
+ · intro P hP
+ exact (hinside P hP).1
+ · intro P hP
+ obtain ⟨y, hy, hdist, rfl⟩ := (hinside P hP).2
+ exact hnear y hy hdist _
+
+/-- All ingredients of the final pair geometry follow from endpoint
+separation, ellipsoid containment, nearby metric comparison, and a
+diameter bound on the small source domain. -/
+theorem iterationPairGeometry_of_ellipsoids
+ {X : Type*} [MetricSpace X] (u : X → E) (D W : Set X)
+ (Ω : Set E) (frozen : ℕ → E → E ≃L[ℝ] E)
+ {r0 T B G c : ℝ} (hr0 : 0 < r0) (hT : 1 ≤ T) (hB : 1 ≤ B) (hG : 1 ≤ G)
+ (hc : 0 < c) (hmargin : G < c * iterationPairMultiplier T B G)
+ (hdiam : ∀ x ∈ D, ∀ z ∈ D, iterationPairMultiplier T B G * dist x z ≤ r0)
+ (hend : ∀ i x, x ∈ D → ∀ z, z ∈ D → x ≠ z →
+ iterationPairMultiplier T B G * dist x z ≤ iterationRadius r0 i →
+ iterationRadius r0 i ≤ 2 * iterationPairMultiplier T B G * dist x z →
+ G⁻¹ * dist x z ≤ ‖frozen i (u x) (u z - u x)‖ ∧
+ ‖frozen i (u x) (u z - u x)‖ ≤ G * dist x z)
+ (hball : ∀ i x, x ∈ D → ∀ P : E,
+ ‖frozen i (u x) (P - u x)‖ < c * iterationRadius r0 i →
+ P ∈ Ω ∧ ∃ y ∈ W, dist x y < iterationRadius r0 i ∧ u y = P)
+ (hnear : ∀ i x, x ∈ D → ∀ y, y ∈ W → dist x y < iterationRadius r0 i →
+ ∀ w : E, ‖frozen i (u y) w‖ ≤ G * ‖frozen i (u x) w‖) :
+ IterationPairGeometry (fun x : D => u x) Ω frozen r0 T B G := by
+ apply iterationPairGeometry_of_all_scales (X := D) (fun x => u x) Ω frozen hr0 hT hB hG
+ (fun x z => hdiam x x.property z z.property)
+ intro i x z hxz hscale hscale'
+ have hxz' : (x : X) ≠ z := fun h => hxz (Subtype.ext h)
+ obtain ⟨hl, hu⟩ := hend i x x.property z z.property hxz' hscale hscale'
+ refine ⟨hl, hu, ?_⟩
+ apply segment_geometry_of_ellipsoid u (frozen i) (x := x) (z := z)
+ · calc
+ ‖frozen i (u x) (u z - u x)‖ ≤ G * dist (x : X) z := hu
+ _ < (c * iterationPairMultiplier T B G) * dist (x : X) z :=
+ mul_lt_mul_of_pos_right hmargin (dist_pos.mpr hxz')
+ _ = c * (iterationPairMultiplier T B G * dist (x : X) z) := by ring
+ _ ≤ c * iterationRadius r0 i := mul_le_mul_of_nonneg_left hscale hc.le
+ · exact hball i x x.property
+ · exact hnear i x x.property
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PatchAssembly.lean b/lean/OAI/Geometry/RCD/Coordinates/PatchAssembly.lean
new file mode 100644
index 0000000000000000000000000000000000000000..6ae66da32beca72f0c89f9e25aed00e72bb16867
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PatchAssembly.lean
@@ -0,0 +1,540 @@
+import OAI.Geometry.RCD.Coordinates.MetricIteration
+import OAI.Geometry.RCD.Coordinates.PatchJetBounds
+import OAI.Geometry.RCD.Coordinates.PatchSecondDerivative
+
+namespace OAI
+
+/-!
+# Patch fields as input to the analytic iteration
+
+The frozen covector transformation sends the actual patch field to an
+actual cutoff-affine patch field with conjugated positive operators.
+The estimates here use only patch geometry and cutoff derivatives; no
+coordinate iterate or estimate for its derivatives is an input.
+-/
+
+open Filter Set
+open scoped Topology ContDiff BigOperators InnerProductSpace
+
+noncomputable section
+
+attribute [local instance] Classical.propDecidable
+
+namespace RegularPointCoordinates
+
+variable {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+
+/-- Exact affine displacement under the frozen dual transformation. -/
+theorem frozenConjugate_normalized_displacement {r : ℝ} (hr : r ≠ 0)
+ (T : E ≃L[ℝ] E) (D : E →L[ℝ] E) (x c z : E) :
+ frozenConjugate T D (z - r⁻¹ • T (c - x)) =
+ r⁻¹ • (T.symm : E →L[ℝ] E).adjoint (D (frozenSource r T x z - c)) := by
+ have harg : T.symm (z - r⁻¹ • T (c - x)) =
+ r⁻¹ • (frozenSource r T x z - c) := by
+ simp only [map_sub, map_smul, ContinuousLinearEquiv.symm_apply_apply,
+ frozenSource, smul_sub, smul_add, smul_smul, inv_mul_cancel₀ hr, one_smul]
+ module
+ simp only [frozenConjugate, ContinuousLinearMap.comp_apply, ContinuousLinearEquiv.coe_coe,
+ harg, map_smul]
+
+/-- Frozen normalization is an exact identity between finite patch fields. -/
+theorem normalizedCovector_patchField {r : ℝ} (hr : r ≠ 0)
+ (T : E ≃L[ℝ] E) (x : E) (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) :
+ normalizedCovector r T x (patchField s phi D c) =
+ patchField s (fun j z => phi j (frozenSource r T x z))
+ (fun j => frozenConjugate T (D j)) (fun j => r⁻¹ • T (c j - x)) := by
+ funext z
+ simp only [normalizedCovector, patchField, map_sum, Finset.smul_sum, map_smul]
+ apply Finset.sum_congr rfl
+ intro j _
+ rw [frozenConjugate_normalized_displacement hr]
+ module
+
+omit [CompleteSpace E] in
+/-- A cutoff active after normalization was active at the original center.
+Continuity alone gives the inclusion needed for an overlap bound. -/
+theorem mem_tsupport_frozen_cutoff {r : ℝ} (T : E ≃L[ℝ] E) (x : E)
+ (phi : E → ℝ) (hz : (0 : E) ∈ tsupport (fun z => phi (frozenSource r T x z))) :
+ x ∈ tsupport phi := by
+ have hs : Continuous (frozenSource r T x) := by unfold frozenSource; fun_prop
+ have h := tsupport_comp_subset_preimage phi hs hz
+ simpa [frozenSource] using h
+
+omit [CompleteSpace E] in
+/-- The number of active cutoffs does not increase under normalization. -/
+theorem frozen_cutoff_active_card_le {r : ℝ} (T : E ≃L[ℝ] E) (x : E)
+ (s : Finset ι) (phi : ι → E → ℝ) :
+ (s.filter (fun j => (0 : E) ∈ tsupport (fun z => phi j (frozenSource r T x z)))).card ≤
+ (s.filter (fun j => x ∈ tsupport (phi j))).card := by
+ classical
+ apply Finset.card_le_card
+ intro j hj
+ exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp hj).1,
+ mem_tsupport_frozen_cutoff T x (phi j) (Finset.mem_filter.mp hj).2⟩
+
+omit [CompleteSpace E] in
+/-- Cutoff smoothness at the center transports through the frozen affine map. -/
+theorem contDiffAt_frozen_cutoff {r : ℝ} (T : E ≃L[ℝ] E) (x : E)
+ {phi : E → ℝ} {m : ℕ} (hphi : ContDiffAt ℝ m phi x) :
+ ContDiffAt ℝ m (fun z => phi (frozenSource r T x z)) 0 := by
+ have hp : ContDiffAt ℝ m phi (frozenSource r T x 0) := by
+ simpa [frozenSource] using hphi
+ apply hp.comp
+ unfold frozenSource
+ fun_prop
+
+/-- Small displacement energy gives the normalized affine value bound.
+The local energy budget `energy ≤ epsilon` is what makes this linear in
+`epsilon`, including when the positive mass operator is degenerate. -/
+theorem normalized_patch_displacement_le {r epsilon C energy : ℝ}
+ (hr : 0 < r) (hepsilon : 0 ≤ epsilon) (hC : 0 ≤ C)
+ (henergy : 0 ≤ energy) (hbudget : energy ≤ epsilon)
+ (T : E ≃L[ℝ] E) (D : E →L[ℝ] E) (x c : E)
+ (hD : D.IsPositive) (hsmall : ∀ y, ⟪y, D y⟫_ℝ ≤ epsilon * ‖T y‖ ^ 2)
+ (hvalue : ⟪x - c, D (x - c)⟫_ℝ ≤ C * r ^ 2 * energy) :
+ ‖frozenConjugate T D ((0 : E) - r⁻¹ • T (c - x))‖ ≤ epsilon * Real.sqrt C := by
+ rw [frozenConjugate_normalized_displacement hr.ne']
+ simp only [frozenSource, map_zero, smul_zero, add_zero, norm_smul, Real.norm_eq_abs,
+ abs_inv, abs_of_pos hr]
+ have hv := frozen_positive_form_value_le T hD hepsilon hC hr.le henergy hsmall (x - c) hvalue
+ calc
+ _ ≤ r⁻¹ * (Real.sqrt epsilon * Real.sqrt C * r * Real.sqrt energy) :=
+ mul_le_mul_of_nonneg_left hv (inv_nonneg.mpr hr.le)
+ _ = Real.sqrt epsilon * Real.sqrt C * Real.sqrt energy := by field_simp
+ _ ≤ Real.sqrt epsilon * Real.sqrt C * Real.sqrt epsilon :=
+ mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt hbudget) (by positivity)
+ _ = (Real.sqrt epsilon) ^ 2 * Real.sqrt C := by ring
+ _ = _ := by rw [Real.sq_sqrt hepsilon]
+
+/-- The factorial target weight absorbs the Gevrey-two cutoff weight. -/
+theorem factorial_sq_le_majorant_scale (m : ℕ) :
+ (m.factorial : ℝ) ^ 2 ≤ factorialMajorant m * (m.factorial : ℝ) := by
+ have hm : (1 : ℝ) ≤ (m : ℝ) + 1 := by linarith [Nat.cast_nonneg (α := ℝ) m]
+ have hf : (1 : ℝ) ≤ (m.factorial : ℝ) := by exact_mod_cast Nat.succ_le_of_lt (Nat.factorial_pos m)
+ have hc : (1 : ℝ) ≤ ((m : ℝ) + 1) ^ 3 * (m.factorial : ℝ) :=
+ one_le_mul_of_one_le_of_one_le (one_le_pow₀ hm) hf
+ calc
+ _ = 1 * (m.factorial : ℝ) ^ 2 := by ring
+ _ ≤ (((m : ℝ) + 1) ^ 3 * (m.factorial : ℝ)) * (m.factorial : ℝ) ^ 2 :=
+ mul_le_mul_of_nonneg_right hc (sq_nonneg _)
+ _ = _ := by unfold factorialMajorant; rw [Nat.factorial_succ]; push_cast; ring
+
+/-- Actual normalized correction jets with a fixed base, independent of
+order and of the full net size. Only active patches enter the estimate. -/
+theorem normalized_patchField_jet_le
+ (T : E ≃L[ℝ] E) (x : E) (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (m : ℕ)
+ {r epsilon C energy L N F B : ℝ}
+ (hr : 0 < r) (hepsilon : 0 ≤ epsilon) (hC : 0 ≤ C)
+ (henergy : 0 ≤ energy) (hbudget : energy ≤ epsilon) (hL : 1 ≤ L)
+ (hcard : ((s.filter (fun j => x ∈ tsupport (phi j))).card : ℝ) ≤ N)
+ (hD : ∀ j ∈ s, x ∈ tsupport (phi j) → (D j).IsPositive)
+ (hsmall : ∀ j ∈ s, x ∈ tsupport (phi j) → ∀ y,
+ ⟪y, D j y⟫_ℝ ≤ epsilon * ‖T y‖ ^ 2)
+ (hvalue : ∀ j ∈ s, x ∈ tsupport (phi j) →
+ ⟪x - c j, D j (x - c j)⟫_ℝ ≤ C * r ^ 2 * energy)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ m (phi j) x)
+ (hcutoff : ∀ j ∈ s, x ∈ tsupport (phi j) → ∀ q ≤ m,
+ ‖iteratedFDeriv ℝ q (fun z => phi j (frozenSource r T x z)) 0‖ ≤
+ L ^ (q + 1) * (q.factorial : ℝ) ^ 2)
+ (hF : patchJetBase N (Real.sqrt C) L ≤ F)
+ (hB : patchJetBase N (Real.sqrt C) L ≤ B) :
+ ‖iteratedFDeriv ℝ m (normalizedCovector r T x (patchField s phi D c)) 0‖ ≤
+ epsilon * F * factorialMajorant m * jetCoefficientScale B m := by
+ let J := patchJetBase N (Real.sqrt C) L
+ have hJ : 1 ≤ J := patchJetBase_ge_one hL
+ have hJ0 : 0 ≤ J := zero_le_one.trans hJ
+ have hB0 : 0 ≤ B := hJ0.trans hB
+ have hF0 : 0 ≤ F := hJ0.trans hF
+ have hactive : ∀ j ∈ s, (0 : E) ∈ tsupport (fun z => phi j (frozenSource r T x z)) →
+ x ∈ tsupport (phi j) := fun j _ hj => mem_tsupport_frozen_cutoff T x (phi j) hj
+ rw [normalizedCovector_patchField hr.ne']
+ have hb := patchField_scaled_gevrey_two_active s
+ (fun j z => phi j (frozenSource r T x z)) (fun j => frozenConjugate T (D j))
+ (fun j => r⁻¹ • T (c j - x)) (0 : E) m
+ (r := 1) hepsilon (by norm_num) (Real.sqrt_nonneg C) hL
+ ((show ((s.filter (fun j => (0 : E) ∈
+ tsupport (fun z => phi j (frozenSource r T x z)))).card : ℝ) ≤
+ ((s.filter (fun j => x ∈ tsupport (phi j))).card : ℝ) by
+ exact_mod_cast frozen_cutoff_active_card_le T x s phi).trans hcard)
+ (fun j hj ha => frozen_positive_form_mixed_opNorm_le T (hD j hj (hactive j hj ha))
+ hepsilon (hsmall j hj (hactive j hj ha)))
+ (fun j hj ha => by
+ simpa using normalized_patch_displacement_le hr hepsilon hC henergy hbudget T (D j) x (c j)
+ (hD j hj (hactive j hj ha)) (hsmall j hj (hactive j hj ha)) (hvalue j hj (hactive j hj ha)))
+ (fun j hj => contDiffAt_frozen_cutoff T x (hphi j hj))
+ (fun j hj ha q hq => by simpa using hcutoff j hj (hactive j hj ha) q hq)
+ simp only [one_pow, one_mul, mul_one] at hb
+ calc
+ _ ≤ epsilon * J ^ (m + 1) * (m.factorial : ℝ) ^ 2 := hb
+ _ = epsilon * (J * J ^ m) * (m.factorial : ℝ) ^ 2 := by rw [pow_succ]; ring
+ _ ≤ epsilon * (F * B ^ m) * (factorialMajorant m * (m.factorial : ℝ)) := by
+ apply mul_le_mul
+ · exact mul_le_mul_of_nonneg_left
+ (mul_le_mul hF (pow_le_pow_left₀ hJ0 hB m) (by positivity) hF0) hepsilon
+ · exact factorial_sq_le_majorant_scale m
+ · positivity
+ · positivity
+ _ = _ := by unfold jetCoefficientScale; ring
+
+omit [CompleteSpace E] in
+/-- Local smoothness of the full finite patch field. -/
+theorem contDiffAt_patchField (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x : E) {m : ℕ}
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ m (phi j) x) :
+ ContDiffAt ℝ m (patchField s phi D c) x := by
+ apply ContDiffAt.sum
+ intro j hj
+ exact (hphi j hj).smul ((D j).contDiff.contDiffAt.comp x
+ (contDiffAt_id.sub contDiffAt_const))
+
+omit [CompleteSpace E] in
+/-- At the testing point the field is the sum over active patches. -/
+theorem patchField_eq_active_at (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x : E) :
+ patchField s phi D c x =
+ patchField (s.filter (fun j => x ∈ tsupport (phi j))) phi D c x := by
+ symm
+ apply Finset.sum_subset (Finset.filter_subset _ _)
+ intro j hj hnot
+ have hz : phi j x = 0 := image_eq_zero_of_notMem_tsupport
+ (fun hx => hnot (Finset.mem_filter.mpr ⟨hj, hx⟩))
+ simp [hz]
+
+omit [CompleteSpace E] in
+/-- The first derivative also restricts to active patches. -/
+theorem fderiv_patchField_eq_active_at (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x xi : E)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ 1 (phi j) x) :
+ fderiv ℝ (patchField s phi D c) x xi =
+ fderiv ℝ (patchField (s.filter (fun j => x ∈ tsupport (phi j))) phi D c) x xi := by
+ have h := congrArg (fun A => A (fun _ => xi))
+ (iteratedFDeriv_patchField_eq_active s phi D c x 1 hphi)
+ simpa only [iteratedFDeriv_one_apply] using h
+
+omit [CompleteSpace E] in
+/-- The actual second directional derivative restricts to active patches. -/
+theorem diagonalSecond_patchField_eq_active_at (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x xi : E)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ 2 (phi j) x) :
+ diagonalSecond (patchField s phi D c) x xi =
+ diagonalSecond (patchField (s.filter (fun j => x ∈ tsupport (phi j))) phi D c) x xi := by
+ rw [diagonalSecond_eq (contDiffAt_patchField s phi D c x hphi),
+ diagonalSecond_eq (contDiffAt_patchField _ phi D c x
+ (fun j hj => hphi j (Finset.mem_filter.mp hj).1)),
+ iteratedFDeriv_patchField_eq_active s phi D c x 2 hphi]
+
+/-- All four directional hypotheses of the analytic iteration follow
+from the actual finite patches, with one common coefficient. -/
+theorem patchField_directional_bounds
+ (T : E ≃L[ℝ] E) (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x xi : E) {N : ℕ}
+ {epsilon C K r energy F : ℝ}
+ (hepsilon : 0 ≤ epsilon) (hepsilon1 : epsilon ≤ 1)
+ (hC : 0 ≤ C) (hK : 0 ≤ K) (hr : 0 < r) (henergy : 0 ≤ energy)
+ (hcard : (s.filter (fun j => x ∈ tsupport (phi j))).card ≤ N)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ 2 (phi j) x)
+ (hD : ∀ j ∈ s, x ∈ tsupport (phi j) → (D j).IsPositive)
+ (hphi0 : ∀ j ∈ s, x ∈ tsupport (phi j) → 0 ≤ phi j x)
+ (hphi1 : ∀ j ∈ s, x ∈ tsupport (phi j) → phi j x ≤ 1)
+ (hZ : ∀ y, ⟪y, patchMass (s.filter (fun j => x ∈ tsupport (phi j))) D y⟫_ℝ ≤
+ epsilon * ‖T y‖ ^ 2)
+ (hw : ∀ j ∈ s, x ∈ tsupport (phi j) →
+ ⟪x - c j, D j (x - c j)⟫_ℝ ≤ C * r ^ 2 * energy)
+ (hfirst : ∀ j ∈ s, x ∈ tsupport (phi j) → |fderiv ℝ (phi j) x xi| ≤ K / r * ‖T xi‖)
+ (hsecond : ∀ j ∈ s, x ∈ tsupport (phi j) →
+ |diagonalSecond (phi j) x xi| ≤ K / r ^ 2 * ‖T xi‖ ^ 2)
+ (hF1 : 1 ≤ F) (hFvalue : (N : ℝ) * Real.sqrt C ≤ F)
+ (hFerror : (N : ℝ) * K * Real.sqrt C ≤ F)
+ (hFsecond : 2 * K * Real.sqrt (N : ℝ) ≤ F)
+ (hFlinear : K * Real.sqrt ((N : ℝ) * C) ≤ F) :
+ let active := s.filter (fun j => x ∈ tsupport (phi j))
+ let Z := ⟪xi, patchMass active D xi⟫_ℝ
+ let S := patchPrincipal active (fun j => phi j x) D
+ ‖(T.symm : E →L[ℝ] E).adjoint (patchField s phi D c x)‖ ≤
+ F * Real.sqrt epsilon * r * Real.sqrt energy ∧
+ ‖(T.symm : E →L[ℝ] E).adjoint (fderiv ℝ (patchField s phi D c) x xi)‖ ≤
+ F * Real.sqrt epsilon * (Real.sqrt Z + Real.sqrt energy * ‖T xi‖) ∧
+ ‖(T.symm : E →L[ℝ] E).adjoint (diagonalSecond (patchField s phi D c) x xi)‖ ≤
+ F / r * (Real.sqrt Z * ‖T xi‖ + Real.sqrt energy * ‖T xi‖ ^ 2) ∧
+ |⟪xi, fderiv ℝ (patchField s phi D c) x xi - S xi⟫_ℝ| ≤
+ F * Real.sqrt Z * Real.sqrt energy * ‖T xi‖ := by
+ let active := s.filter (fun j => x ∈ tsupport (phi j))
+ have hd : ∀ j ∈ active, (D j).IsPositive :=
+ fun j hj => hD j (Finset.mem_filter.mp hj).1 (Finset.mem_filter.mp hj).2
+ have hp : ∀ j ∈ active, ContDiffAt ℝ 2 (phi j) x :=
+ fun j hj => hphi j (Finset.mem_filter.mp hj).1
+ have hp0 : ∀ j ∈ active, 0 ≤ phi j x :=
+ fun j hj => hphi0 j (Finset.mem_filter.mp hj).1 (Finset.mem_filter.mp hj).2
+ have hp1 : ∀ j ∈ active, phi j x ≤ 1 :=
+ fun j hj => hphi1 j (Finset.mem_filter.mp hj).1 (Finset.mem_filter.mp hj).2
+ have hsmall : ∀ j ∈ active, ∀ y, ⟪y, D j y⟫_ℝ ≤ epsilon * ‖T y‖ ^ 2 :=
+ fun j hj y => (patch_form_le_mass active D hd hj y).trans (hZ y)
+ have hv : ∀ j ∈ active, ⟪x - c j, D j (x - c j)⟫_ℝ ≤ C * r ^ 2 * energy :=
+ fun j hj => hw j (Finset.mem_filter.mp hj).1 (Finset.mem_filter.mp hj).2
+ have hdf : ∀ j ∈ active, |fderiv ℝ (phi j) x xi| ≤ K / r * ‖T xi‖ :=
+ fun j hj => hfirst j (Finset.mem_filter.mp hj).1 (Finset.mem_filter.mp hj).2
+ have hd2 : ∀ j ∈ active, |diagonalSecond (phi j) x xi| ≤ K / r ^ 2 * ‖T xi‖ ^ 2 :=
+ fun j hj => hsecond j (Finset.mem_filter.mp hj).1 (Finset.mem_filter.mp hj).2
+ have heq := fderiv_patchField_eq_active_at s phi D c x xi
+ (fun j hj => (hphi j hj).of_le (by norm_num))
+ have hdecomp := fderiv_patchField_apply active phi (fun j => fderiv ℝ (phi j) x) D c x xi
+ (fun j hj => (hp j hj).differentiableAt (by norm_num) |>.hasFDerivAt)
+ change fderiv ℝ (patchField s phi D c) x xi = _ at heq
+ have hvb := patchField_frozen_value_le T active phi D c x hcard hepsilon hC hr henergy hd
+ hsmall hv (fun j hj => abs_le.mpr ⟨by linarith [hp0 j hj], hp1 j hj⟩)
+ have hpb := patchPrincipal_frozen_norm_le T active (fun j => phi j x) D hepsilon hd hp0 hp1 hZ xi
+ have heb := patchCutoffError_frozen_norm_le T active D (fun j => x - c j)
+ (fun j => fderiv ℝ (phi j) x xi) xi hcard hepsilon hC hK hr henergy hd hsmall hv hdf
+ have hs2 := patchField_second_directional_frozen_le T active phi D c x xi hcard hepsilon
+ hepsilon1 hC hK hr henergy hp hd hZ hv hdf hd2
+ have hl := patchCutoffError_diagonal_le T active D (fun j => x - c j)
+ (fun j => fderiv ℝ (phi j) x xi) xi hcard hC hK hr henergy hd hv hdf
+ dsimp only
+ constructor
+ · rw [patchField_eq_active_at s phi D c x]
+ have hraw := (div_le_iff₀ hr).1 hvb
+ have hcoeff := mul_le_mul_of_nonneg_right hFvalue
+ (by positivity : 0 ≤ Real.sqrt epsilon * r * Real.sqrt energy)
+ exact hraw.trans (by nlinarith [hcoeff])
+ constructor
+ · rw [heq, hdecomp, map_add]
+ refine (norm_add_le _ _).trans ((add_le_add hpb heb).trans ?_)
+ calc
+ _ = (1 : ℝ) * (Real.sqrt epsilon * Real.sqrt ⟪xi, patchMass active D xi⟫_ℝ) +
+ ((N : ℝ) * K * Real.sqrt C) * (Real.sqrt epsilon * Real.sqrt energy * ‖T xi‖) := by ring
+ _ ≤ F * (Real.sqrt epsilon * Real.sqrt ⟪xi, patchMass active D xi⟫_ℝ) +
+ F * (Real.sqrt epsilon * Real.sqrt energy * ‖T xi‖) :=
+ add_le_add (mul_le_mul_of_nonneg_right hF1 (by positivity))
+ (mul_le_mul_of_nonneg_right hFerror (by positivity))
+ _ = _ := by ring
+ constructor
+ · rw [diagonalSecond_patchField_eq_active_at s phi D c x xi hphi]
+ have hb : (N : ℝ) * K * Real.sqrt C * Real.sqrt energy * ‖T xi‖ ^ 2 +
+ 2 * K * Real.sqrt (N : ℝ) * Real.sqrt ⟪xi, patchMass active D xi⟫_ℝ * ‖T xi‖ ≤
+ F * (Real.sqrt ⟪xi, patchMass active D xi⟫_ℝ * ‖T xi‖ + Real.sqrt energy * ‖T xi‖ ^ 2) := by
+ have hcoeff1 := mul_le_mul_of_nonneg_right hFerror
+ (by positivity : 0 ≤ Real.sqrt energy * ‖T xi‖ ^ 2)
+ have hcoeff2 := mul_le_mul_of_nonneg_right hFsecond
+ (by positivity : 0 ≤ Real.sqrt ⟪xi, patchMass active D xi⟫_ℝ * ‖T xi‖)
+ nlinarith [hcoeff1, hcoeff2]
+ calc
+ _ ≤ F * (Real.sqrt ⟪xi, patchMass active D xi⟫_ℝ * ‖T xi‖ +
+ Real.sqrt energy * ‖T xi‖ ^ 2) / r :=
+ (le_div_iff₀ hr).2 (by simpa only [diagonalSecond, active, mul_comm] using hs2.trans hb)
+ _ = _ := by ring
+ · rw [heq, hdecomp, add_sub_cancel_left]
+ have hcoeff := mul_le_mul_of_nonneg_right hFlinear
+ (by positivity : 0 ≤ Real.sqrt ⟪xi, patchMass active D xi⟫_ℝ * Real.sqrt energy * ‖T xi‖)
+ exact hl.trans (by nlinarith [hcoeff])
+
+/-- Only cutoffs whose closed support contains the point are active. -/
+def activePatches (s : Finset ι) (phi : ι → E → ℝ) (x : E) : Finset ι :=
+ s.filter (fun j => x ∈ tsupport (phi j))
+
+/-- Geometric patch data before the coordinate iteration. The assumptions
+are on cutoffs, positive mass operators, displacement energies and their
+cumulative budgets; no estimate on the resulting field is assumed. -/
+structure PatchIterationGeometry (Ω : Set E) (r0 Theta epsilon : ℝ)
+ (N : ℕ) (C K L : ℝ) where
+ patches : ℕ → Finset ι
+ cutoff : ℕ → ι → E → ℝ
+ operator : ℕ → ι → E →L[ℝ] E
+ center : ℕ → ι → E
+ frozen : ℕ → E → E ≃L[ℝ] E
+ energy : ℕ → E → ℝ
+ frozen_mono : ∀ i x, x ∈ Ω → ∀ xi, ‖frozen i x xi‖ ≤ ‖frozen (i + 1) x xi‖
+ cutoff_smooth : ∀ i j, j ∈ patches i → ∀ x ∈ Ω, ∀ m : ℕ, ContDiffAt ℝ m (cutoff i j) x
+ active_card : ∀ i x, x ∈ Ω → (activePatches (patches i) (cutoff i) x).card ≤ N
+ energy_nonneg : ∀ i x, x ∈ Ω → 0 ≤ energy i x
+ energy_budget : ∀ k x, x ∈ Ω → (∑ i ∈ Finset.range k, energy i x) ≤ epsilon
+ operator_positive : ∀ i j, j ∈ patches i → ∀ x ∈ Ω,
+ x ∈ tsupport (cutoff i j) → (operator i j).IsPositive
+ cutoff_nonneg : ∀ i j, j ∈ patches i → ∀ x ∈ Ω,
+ x ∈ tsupport (cutoff i j) → 0 ≤ cutoff i j x
+ cutoff_le_one : ∀ i j, j ∈ patches i → ∀ x ∈ Ω,
+ x ∈ tsupport (cutoff i j) → cutoff i j x ≤ 1
+ mass_small : ∀ i x, x ∈ Ω → ∀ xi,
+ ⟪xi, patchMass (activePatches (patches i) (cutoff i) x) (operator i) xi⟫_ℝ ≤
+ epsilon * ‖frozen i x xi‖ ^ 2
+ center_energy : ∀ i j, j ∈ patches i → ∀ x ∈ Ω,
+ x ∈ tsupport (cutoff i j) →
+ ⟪x - center i j, operator i j (x - center i j)⟫_ℝ ≤
+ C * (iterationRadius r0 i) ^ 2 * energy i x
+ cutoff_first : ∀ i j, j ∈ patches i → ∀ x ∈ Ω,
+ x ∈ tsupport (cutoff i j) → ∀ xi,
+ |fderiv ℝ (cutoff i j) x xi| ≤ K / iterationRadius r0 i * ‖frozen i x xi‖
+ cutoff_second : ∀ i j, j ∈ patches i → ∀ x ∈ Ω,
+ x ∈ tsupport (cutoff i j) → ∀ xi,
+ |diagonalSecond (cutoff i j) x xi| ≤
+ K / (iterationRadius r0 i) ^ 2 * ‖frozen i x xi‖ ^ 2
+ cutoff_jets : ∀ i j, j ∈ patches i → ∀ x ∈ Ω,
+ x ∈ tsupport (cutoff i j) → ∀ m,
+ ‖iteratedFDeriv ℝ m
+ (fun z => cutoff i j (frozenSource (iterationRadius r0 i) (frozen i x) x z)) 0‖ ≤
+ L ^ (m + 1) * (m.factorial : ℝ) ^ 2
+ mass_budget : ∀ k x, x ∈ Ω → ∀ xi,
+ ‖xi‖ ^ 2 + (∑ i ∈ Finset.range k,
+ ⟪xi, patchMass (activePatches (patches i) (cutoff i) x) (operator i) xi⟫_ℝ) ≤
+ Theta * ‖frozen k x xi‖ ^ 2
+ principal_budget : ∀ k x, x ∈ Ω → ∀ xi,
+ ‖frozen k x xi‖ ^ 2 ≤ Theta * (‖xi‖ ^ 2 + ∑ i ∈ Finset.range k,
+ ⟪xi, patchPrincipal (activePatches (patches i) (cutoff i) x)
+ (fun j => cutoff i j x) (operator i) xi⟫_ℝ)
+
+/-- One explicit coefficient covers all directional and higher-jet
+bounds of the finite patch field. -/
+def patchAssemblyCoefficient (N : ℕ) (C K L : ℝ) : ℝ :=
+ 1 + patchJetBase N (Real.sqrt C) L + (N : ℝ) * Real.sqrt C +
+ (N : ℝ) * K * Real.sqrt C + 2 * K * Real.sqrt (N : ℝ) +
+ K * Real.sqrt ((N : ℝ) * C)
+
+theorem patchAssemblyCoefficient_bounds (N : ℕ) {C K L : ℝ}
+ (hK : 0 ≤ K) (hL : 1 ≤ L) :
+ 1 ≤ patchAssemblyCoefficient N C K L ∧
+ patchJetBase N (Real.sqrt C) L ≤ patchAssemblyCoefficient N C K L ∧
+ (N : ℝ) * Real.sqrt C ≤ patchAssemblyCoefficient N C K L ∧
+ (N : ℝ) * K * Real.sqrt C ≤ patchAssemblyCoefficient N C K L ∧
+ 2 * K * Real.sqrt (N : ℝ) ≤ patchAssemblyCoefficient N C K L ∧
+ K * Real.sqrt ((N : ℝ) * C) ≤ patchAssemblyCoefficient N C K L := by
+ have h0 : 0 ≤ patchJetBase N (Real.sqrt C) L :=
+ zero_le_one.trans (patchJetBase_ge_one hL)
+ have h1 : 0 ≤ (N : ℝ) * Real.sqrt C := by positivity
+ have h2 : 0 ≤ (N : ℝ) * K * Real.sqrt C := by positivity
+ have h3 : 0 ≤ 2 * K * Real.sqrt (N : ℝ) := by positivity
+ have h4 : 0 ≤ K * Real.sqrt ((N : ℝ) * C) := by positivity
+ unfold patchAssemblyCoefficient
+ refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ <;> linarith
+
+namespace PatchIterationGeometry
+
+variable {Ω : Set E} {r0 Theta epsilon C K L : ℝ} {N : ℕ}
+
+omit [CompleteSpace E] in
+/-- An individual nonnegative defect is bounded by the cumulative budget. -/
+theorem energy_le (p : PatchIterationGeometry (ι := ι) Ω r0 Theta epsilon N C K L)
+ (i : ℕ) (x : E) (hx : x ∈ Ω) : p.energy i x ≤ epsilon := by
+ have hi : i ∈ Finset.range (i + 1) := Finset.mem_range.mpr (Nat.lt_succ_self i)
+ exact (Finset.single_le_sum (fun j _ => p.energy_nonneg j x hx) hi).trans
+ (p.energy_budget (i + 1) x hx)
+
+/-- Assemble the analytic iteration inputs from genuine finite patch
+fields. The four field bounds and every correction jet are conclusions
+of the patch calculus, rather than fields of the geometric input. -/
+def toAnalyticIterationData
+ (p : PatchIterationGeometry (ι := ι) Ω r0 Theta epsilon N C K L)
+ (hr0 : 0 < r0) (hepsilon : 0 ≤ epsilon) (hepsilon1 : epsilon ≤ 1)
+ (hC : 0 ≤ C) (hK : 0 ≤ K) (hL : 1 ≤ L) {F B : ℝ}
+ (hF1 : 1 ≤ F) (hFvalue : (N : ℝ) * Real.sqrt C ≤ F)
+ (hFerror : (N : ℝ) * K * Real.sqrt C ≤ F)
+ (hFsecond : 2 * K * Real.sqrt (N : ℝ) ≤ F)
+ (hFlinear : K * Real.sqrt ((N : ℝ) * C) ≤ F)
+ (hFjet : patchJetBase N (Real.sqrt C) L ≤ F)
+ (hB : patchJetBase N (Real.sqrt C) L ≤ B) :
+ AnalyticIterationData Ω r0 Theta F B epsilon := by
+ have hd (i : ℕ) (x : E) (hx : x ∈ Ω) :
+ ∀ j ∈ activePatches (p.patches i) (p.cutoff i) x, (p.operator i j).IsPositive := by
+ intro j hj
+ exact p.operator_positive i j (Finset.mem_filter.mp hj).1 x hx (Finset.mem_filter.mp hj).2
+ have hb (i : ℕ) (x : E) (hx : x ∈ Ω) (xi : E) :=
+ patchField_directional_bounds (p.frozen i x) (p.patches i) (p.cutoff i) (p.operator i)
+ (p.center i) x xi hepsilon hepsilon1 hC hK (iterationRadius_pos hr0 i)
+ (p.energy_nonneg i x hx) (p.active_card i x hx)
+ (fun j hj => p.cutoff_smooth i j hj x hx 2)
+ (fun j hj ha => p.operator_positive i j hj x hx ha)
+ (fun j hj ha => p.cutoff_nonneg i j hj x hx ha)
+ (fun j hj ha => p.cutoff_le_one i j hj x hx ha) (p.mass_small i x hx)
+ (fun j hj ha => p.center_energy i j hj x hx ha)
+ (fun j hj ha => p.cutoff_first i j hj x hx ha xi)
+ (fun j hj ha => p.cutoff_second i j hj x hx ha xi)
+ hF1 hFvalue hFerror hFsecond hFlinear
+ refine {
+ frozen := p.frozen
+ correction := fun i => patchField (p.patches i) (p.cutoff i) (p.operator i) (p.center i)
+ principal := fun i x => patchPrincipal (activePatches (p.patches i) (p.cutoff i) x)
+ (fun j => p.cutoff i j x) (p.operator i)
+ mass := fun i x => patchMass (activePatches (p.patches i) (p.cutoff i) x) (p.operator i)
+ energy := p.energy
+ frozen_mono := p.frozen_mono
+ correction_smooth := fun i x hx m => contDiffAt_patchField _ _ _ _ _
+ (fun j hj => p.cutoff_smooth i j hj x hx m)
+ energy_nonneg := p.energy_nonneg
+ energy_budget := p.energy_budget
+ mass_nonneg := fun i x hx xi => (patchMass_isPositive _ _ (hd i x hx)).inner_nonneg_right xi
+ principal_nonneg := ?_
+ principal_le_mass := ?_
+ mass_budget := p.mass_budget
+ principal_budget := p.principal_budget
+ value_bound := fun i x hx => (hb i x hx 0).1
+ first_bound := fun i x hx xi => (hb i x hx xi).2.1
+ second_bound := fun i x hx xi => (hb i x hx xi).2.2.1
+ linear_bound := fun i x hx xi => (hb i x hx xi).2.2.2
+ correction_jets := ?_ }
+ · intro i x hx xi
+ exact (patch_principal_isPositive _ _ _
+ (fun j hj => p.cutoff_nonneg i j (Finset.mem_filter.mp hj).1 x hx (Finset.mem_filter.mp hj).2)
+ (hd i x hx)).inner_nonneg_right xi
+ · intro i x hx xi
+ exact patchPrincipal_form_le_mass _ _ _ (hd i x hx)
+ (fun j hj => p.cutoff_le_one i j (Finset.mem_filter.mp hj).1 x hx (Finset.mem_filter.mp hj).2) xi
+ · intro i x hx m
+ apply normalized_patchField_jet_le (N := (N : ℝ)) (p.frozen i x) x (p.patches i) (p.cutoff i)
+ (p.operator i) (p.center i) m (iterationRadius_pos hr0 i) hepsilon hC
+ (p.energy_nonneg i x hx) (p.energy_le i x hx) hL
+ (by exact_mod_cast p.active_card i x hx)
+ (fun j hj ha => p.operator_positive i j hj x hx ha)
+ · intro j hj ha xi
+ exact (patch_form_le_mass _ _ (hd i x hx) (Finset.mem_filter.mpr ⟨hj, ha⟩) xi).trans
+ (p.mass_small i x hx xi)
+ · exact fun j hj ha => p.center_energy i j hj x hx ha
+ · exact fun j hj => p.cutoff_smooth i j hj x hx m
+ · exact fun j hj ha q _ => p.cutoff_jets i j hj x hx ha q
+ · exact hFjet
+ · exact hB
+
+/-- The explicit patch constants supply a canonical field coefficient
+and jet base, with no dependence on a coordinate iterate. -/
+def toCanonicalAnalyticIterationData
+ (p : PatchIterationGeometry (ι := ι) Ω r0 Theta epsilon N C K L)
+ (hr0 : 0 < r0) (hepsilon : 0 ≤ epsilon) (hepsilon1 : epsilon ≤ 1)
+ (hC : 0 ≤ C) (hK : 0 ≤ K) (hL : 1 ≤ L) :
+ AnalyticIterationData Ω r0 Theta (patchAssemblyCoefficient N C K L)
+ (patchJetBase N (Real.sqrt C) L) epsilon := by
+ have hb := patchAssemblyCoefficient_bounds N (C := C) hK hL
+ exact p.toAnalyticIterationData hr0 hepsilon hepsilon1 hC hK hL
+ hb.1 hb.2.2.1 hb.2.2.2.1 hb.2.2.2.2.1 hb.2.2.2.2.2 hb.2.1 le_rfl
+
+end PatchIterationGeometry
+
+/-- Geometric patches and cumulative budgets supply the field estimates and
+correction jets for the finite analytic iteration. -/
+theorem exists_patch_metric_iteration [FiniteDimensional ℝ E]
+ (N : ℕ) {Theta C K L : ℝ} (hTheta : 1 ≤ Theta)
+ (hC : 0 ≤ C) (hK : 0 ≤ K) (hL : 1 ≤ L) :
+ ∃ epsilon : ℝ, 0 < epsilon ∧ epsilon ≤ 1 ∧
+ ∀ (Ω : Set E), IsOpen Ω → ∀ (r0 : ℝ), 0 < r0 →
+ ∀ p : PatchIterationGeometry (ι := ι) Ω r0 Theta epsilon N C K L,
+ let v := fun i => patchField (p.patches i) (p.cutoff i) (p.operator i) (p.center i)
+ ∀ k x, x ∈ Ω →
+ (∀ m : ℕ, ContDiffAt ℝ m (metricIterate v k) x) ∧
+ (∀ xi, (4 * Theta)⁻¹ * ‖p.frozen k x xi‖ ^ 2 ≤ ‖fderiv ℝ (metricIterate v k) x xi‖ ^ 2 ∧
+ ‖fderiv ℝ (metricIterate v k) x xi‖ ^ 2 ≤ (4 * Theta) * ‖p.frozen k x xi‖ ^ 2) ∧
+ (∀ m, 2 ≤ m →
+ ‖iteratedFDeriv ℝ m (normalizedCoordinates (iterationRadius r0 k)
+ (p.frozen k x) x (metricIterate v k)) 0‖ ≤
+ (patchJetBase N (Real.sqrt C) L) ^ (m - 1) * (m.factorial : ℝ) ^ 3) := by
+ have hF := (patchAssemblyCoefficient_bounds N (C := C) hK hL).1
+ have hB : 1 ≤ patchJetBase (N : ℝ) (Real.sqrt C) L := patchJetBase_ge_one hL
+ obtain ⟨epsilon, hepsilon, he1, hmain⟩ := exists_analytic_metric_iteration (E := E) hTheta hF hB
+ refine ⟨epsilon, hepsilon, he1, ?_⟩
+ intro Ω hΩ r0 hr0 p
+ dsimp only
+ intro k x hx
+ exact hmain Ω hΩ r0 hr0 (p.toCanonicalAnalyticIterationData hr0 hepsilon.le he1 hC hK hL) k x hx
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PatchBudget.lean b/lean/OAI/Geometry/RCD/Coordinates/PatchBudget.lean
new file mode 100644
index 0000000000000000000000000000000000000000..6433faab6b261c9d3f1a9a20f881d6fa82b79edf
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PatchBudget.lean
@@ -0,0 +1,28 @@
+import OAI.Geometry.RCD.Coordinates.PatchAssembly
+
+namespace OAI
+
+/-! # A positive budget for finitely bounded scalar coefficients -/
+
+namespace RegularPointCoordinates
+
+/-- A common positive budget controls every coefficient below a fixed
+bound, both absolutely and relative to the desired iteration tolerance. -/
+theorem exists_uniform_patch_budget {P epsilon : ℝ} (hP : 0 ≤ P) (hepsilon : 0 < epsilon) :
+ ∃ b : ℝ, 0 < b ∧ b ≤ epsilon ∧ b ≤ 1 / 8192 ∧
+ ∀ t : ℝ, 0 ≤ t → t ≤ P → t * b ≤ min epsilon (1 / 8192) := by
+ let s := min epsilon (1 / 8192)
+ have hs : 0 < s := lt_min hepsilon (by norm_num)
+ let b := s / (P + 1)
+ have hb : 0 < b := div_pos hs (by positivity)
+ have hbS : b ≤ s := div_le_self hs.le (by linarith)
+ refine ⟨b, hb, hbS.trans (min_le_left _ _), hbS.trans (min_le_right _ _), ?_⟩
+ intro t _ht htP
+ calc
+ t * b ≤ P * b := mul_le_mul_of_nonneg_right htP hb.le
+ _ ≤ (P + 1) * b := mul_le_mul_of_nonneg_right (by linarith) hb.le
+ _ = s := by dsimp only [b]; field_simp
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PatchCenters.lean b/lean/OAI/Geometry/RCD/Coordinates/PatchCenters.lean
new file mode 100644
index 0000000000000000000000000000000000000000..c557e407f48c9363fc01784fb4a0fc71fa5c1566
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PatchCenters.lean
@@ -0,0 +1,89 @@
+import OAI.Geometry.RCD.Coordinates.PositiveForms
+
+namespace OAI
+
+/-!
+# Fixed centers for directional patch energies
+
+This is the selection in equation `re:fixed-center`: a positive lower
+energy floor permits one fixed point in each patch with energy at most
+twice every active point's energy. No continuity or measurability of the
+energy function is used. Directional pair bounds then give the actual
+fixed-center bound used to construct the correction fields.
+-/
+
+open Set
+open scoped InnerProductSpace
+
+namespace RegularPointCoordinates
+
+theorem exists_energy_center {X : Type*} {s : Set X} (hs : s.Nonempty)
+ {energy : X → ℝ} {floor : ℝ} (hfloor : 0 < floor)
+ (hlower : ∀ x ∈ s, floor ≤ energy x) :
+ ∃ z ∈ s, ∀ x ∈ s, energy z ≤ 2 * energy x := by
+ have hne : (energy '' s).Nonempty := hs.image energy
+ have hbdd : BddBelow (energy '' s) := by
+ refine ⟨floor, ?_⟩
+ rintro _ ⟨x, hx, rfl⟩
+ exact hlower x hx
+ have hinf : floor ≤ sInf (energy '' s) := by
+ apply le_csInf hne
+ rintro _ ⟨x, hx, rfl⟩
+ exact hlower x hx
+ obtain ⟨_, ⟨z, hz, rfl⟩, hnear⟩ := exists_lt_of_csInf_lt hne
+ (by linarith : sInf (energy '' s) < 2 * sInf (energy '' s))
+ refine ⟨z, hz, ?_⟩
+ intro x hx
+ have hxinf := csInf_le hbdd (mem_image_of_mem energy hx)
+ linarith
+
+theorem exists_patch_energy_centers {X ι : Type*} (patch : ι → Set X)
+ (energy : X → ℝ) (hne : ∀ j, (patch j).Nonempty)
+ (hfloor : ∀ j, ∃ floor : ℝ, 0 < floor ∧ ∀ x ∈ patch j, floor ≤ energy x) :
+ ∃ center : ι → X, ∀ j, center j ∈ patch j ∧
+ ∀ x ∈ patch j, energy (center j) ≤ 2 * energy x := by
+ classical
+ have hc (j : ι) : ∃ z ∈ patch j, ∀ x ∈ patch j, energy z ≤ 2 * energy x := by
+ obtain ⟨floor, hf, hl⟩ := hfloor j
+ exact exists_energy_center (hne j) hf hl
+ choose center hmem henergy using hc
+ exact ⟨center, fun j => ⟨hmem j, henergy j⟩⟩
+
+variable {X E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+
+/-- The pairwise directional estimate becomes a bound against the
+energy at the testing point alone after the fixed-center selection. -/
+theorem centered_patch_energy_le (u : X → E) (D : E →L[ℝ] E)
+ {energy : X → ℝ} {C r : ℝ} {x z : X} (hC : 0 ≤ C)
+ (hz : energy z ≤ 2 * energy x)
+ (hpair : ⟪u x - u z, D (u x - u z)⟫_ℝ ≤
+ C * r ^ 2 * (energy x + energy z)) :
+ ⟪u x - u z, D (u x - u z)⟫_ℝ ≤ (3 * C) * r ^ 2 * energy x := by
+ calc
+ _ ≤ C * r ^ 2 * (energy x + energy z) := hpair
+ _ ≤ C * r ^ 2 * (energy x + 2 * energy x) :=
+ mul_le_mul_of_nonneg_left (by linarith) (mul_nonneg hC (sq_nonneg r))
+ _ = _ := by ring
+
+/-- Simultaneous construction of the fixed affine centers for a family
+of patches. The conclusion is the displacement-energy hypothesis used
+by `PatchIterationGeometry`, without adding regularity to the energies. -/
+theorem exists_patch_centers_with_energy_bound
+ (patch : ι → Set X) (energy : X → ℝ) (u : X → E)
+ (D : ι → E →L[ℝ] E) {C r : ℝ} (hC : 0 ≤ C)
+ (hne : ∀ j, (patch j).Nonempty)
+ (hfloor : ∀ j, ∃ floor : ℝ, 0 < floor ∧ ∀ x ∈ patch j, floor ≤ energy x)
+ (hpair : ∀ j, ∀ x ∈ patch j, ∀ z ∈ patch j,
+ ⟪u x - u z, D j (u x - u z)⟫_ℝ ≤ C * r ^ 2 * (energy x + energy z)) :
+ ∃ center : ι → X, ∀ j, center j ∈ patch j ∧ ∀ x ∈ patch j,
+ ⟪u x - u (center j), D j (u x - u (center j))⟫_ℝ ≤
+ (3 * C) * r ^ 2 * energy x := by
+ obtain ⟨center, hc⟩ := exists_patch_energy_centers patch energy hne hfloor
+ refine ⟨center, fun j => ⟨(hc j).1, ?_⟩⟩
+ intro x hx
+ exact centered_patch_energy_le u (D j) hC ((hc j).2 x hx)
+ (hpair j x hx (center j) (hc j).1)
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PatchCover.lean b/lean/OAI/Geometry/RCD/Coordinates/PatchCover.lean
new file mode 100644
index 0000000000000000000000000000000000000000..160d1d36f4328361bf82916210824d927c369e8e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PatchCover.lean
@@ -0,0 +1,202 @@
+import Mathlib.Topology.MetricSpace.CoveringNumbers
+import Mathlib.Topology.MetricSpace.Bounded
+import Mathlib.MeasureTheory.Measure.Real
+import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic
+import Mathlib.Algebra.Order.Floor.Semiring
+import Mathlib.Tactic
+
+namespace OAI
+
+/-!
+# Finite patch nets and volume bounds for their active multiplicity
+
+The net is chosen by maximal cardinality inside a totally bounded domain.
+The active cardinality estimate is proved by disjoint half-radius balls;
+the distance of active centers from the testing point is kept explicit.
+-/
+
+open Set Metric MeasureTheory
+open scoped ENNReal NNReal BigOperators
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X]
+
+/-- Total boundedness makes every positive-radius packing number finite. -/
+theorem packingNumber_ne_top_of_totallyBounded {A : Set X} (hA : TotallyBounded A)
+ {r : ℝ≥0} (hr : r ≠ 0) : Metric.packingNumber r A ≠ ⊤ := by
+ obtain ⟨C, _, hC, hcover⟩ := Metric.exists_finite_isCover_of_totallyBounded
+ (show r / 2 ≠ 0 by positivity) hA
+ have hp : Metric.packingNumber r A ≤ C.encard := by
+ calc
+ _ = Metric.packingNumber (2 * (r / 2)) A := by congr 1; ring
+ _ ≤ Metric.externalCoveringNumber (r / 2) A :=
+ Metric.packingNumber_two_mul_le_externalCoveringNumber _ _
+ _ ≤ _ := hcover.externalCoveringNumber_le_encard
+ exact ne_top_of_le_ne_top hC.encard_lt_top.ne hp
+
+/-- The standard maximal separated set is finite even in the fallback case. -/
+theorem finite_maximalSeparatedSet (r : ℝ≥0) (A : Set X) :
+ (Metric.maximalSeparatedSet r A).Finite := by
+ by_cases h : Metric.packingNumber r A = ⊤
+ · simp [Metric.maximalSeparatedSet, h]
+ · apply Set.encard_ne_top_iff.mp
+ rwa [Metric.encard_maximalSeparatedSet h]
+
+/-- A concrete finite maximal-cardinality net. -/
+def maximalPatchNet (r : ℝ≥0) (A : Set X) : Finset X :=
+ (finite_maximalSeparatedSet r A).toFinset
+
+@[simp] theorem coe_maximalPatchNet (r : ℝ≥0) (A : Set X) :
+ (maximalPatchNet r A : Set X) = Metric.maximalSeparatedSet r A := by
+ simp [maximalPatchNet]
+
+theorem maximalPatchNet_subset (r : ℝ≥0) (A : Set X) :
+ (maximalPatchNet r A : Set X) ⊆ A := by
+ rw [coe_maximalPatchNet]
+ exact Metric.maximalSeparatedSet_subset
+
+theorem maximalPatchNet_separated (r : ℝ≥0) (A : Set X) :
+ (maximalPatchNet r A : Set X).Pairwise (fun x y => (r : ℝ) < dist x y) := by
+ intro x hx y hy hxy
+ have hsep := Metric.isSeparated_maximalSeparatedSet (ε := r) (A := A)
+ rw [← coe_maximalPatchNet] at hsep
+ have hh := hsep hx hy hxy
+ have hd : r < nndist x y := by
+ simpa only [edist_nndist, ENNReal.coe_lt_coe] using hh
+ exact_mod_cast hd
+
+theorem maximalPatchNet_covers {r : ℝ≥0} {A : Set X}
+ (hr : r ≠ 0) (hA : TotallyBounded A) :
+ ∀ x ∈ A, ∃ y ∈ maximalPatchNet r A, dist x y ≤ r := by
+ intro x hx
+ have hc := Metric.isCover_maximalSeparatedSet
+ (packingNumber_ne_top_of_totallyBounded hA hr)
+ obtain ⟨y, hy, hd⟩ := hc hx
+ change edist x y ≤ (r : ℝ≥0∞) at hd
+ refine ⟨y, ?_, ?_⟩
+ · simpa only [← coe_maximalPatchNet, Finset.mem_coe] using hy
+ · have hd' : nndist x y ≤ r := by
+ simpa only [edist_nndist, ENNReal.coe_le_coe] using hd
+ exact_mod_cast hd'
+
+/-- Maximality is by cardinality, and therefore also rules out adding any
+new separated point from the original domain. -/
+theorem maximalPatchNet_card_maximal {r : ℝ≥0} {A : Set X}
+ (hr : r ≠ 0) (hA : TotallyBounded A) (s : Finset X)
+ (hsub : (s : Set X) ⊆ A) (hsep : Metric.IsSeparated r (s : Set X)) :
+ s.card ≤ (maximalPatchNet r A).card := by
+ have hh := Metric.encard_le_of_isSeparated hsub hsep
+ (packingNumber_ne_top_of_totallyBounded hA hr)
+ rw [← coe_maximalPatchNet] at hh
+ exact_mod_cast hh
+
+/-- In a proper metric space every bounded domain admits the finite net,
+even when the domain is not closed. -/
+theorem maximalPatchNet_covers_bounded [ProperSpace X] {r : ℝ≥0} {A : Set X}
+ (hr : r ≠ 0) (hA : Bornology.IsBounded A) :
+ ∀ x ∈ A, ∃ y ∈ maximalPatchNet r A, dist x y ≤ r :=
+ maximalPatchNet_covers hr (hA.isCompact_closure.totallyBounded.subset subset_closure)
+
+/-- Half-radius balls around separated centers are pairwise disjoint. -/
+theorem separated_half_balls_disjoint (s : Finset X) {r : ℝ}
+ (hsep : (s : Set X).Pairwise (fun x y => r ≤ dist x y)) :
+ Set.PairwiseDisjoint (s : Set X) (fun y => Metric.ball y (r / 2)) := by
+ intro x hx y hy hxy
+ apply Metric.ball_disjoint_ball
+ have hh := hsep hx hy hxy
+ linarith
+
+section Volume
+
+variable [MeasurableSpace X] [OpensMeasurableSpace X]
+
+/-- The disjoint-ball packing estimate, with no volume comparison hidden in
+the statement. Finite measure is only required for the containing ball. -/
+theorem separated_card_mul_volume_le (μ : Measure X) (s : Finset X) (x : X)
+ {r R v : ℝ}
+ (hsep : (s : Set X).Pairwise (fun y z => r ≤ dist y z))
+ (hnear : ∀ y ∈ s, dist y x ≤ R)
+ (hlower : ∀ y ∈ s, v ≤ μ.real (Metric.ball y (r / 2)))
+ (hfinite : μ (Metric.ball x (R + r / 2)) ≠ ∞) :
+ (s.card : ℝ) * v ≤ μ.real (Metric.ball x (R + r / 2)) := by
+ have hsub (y : X) (hy : y ∈ s) : Metric.ball y (r / 2) ⊆
+ Metric.ball x (R + r / 2) := Metric.ball_subset_ball' (by linarith [hnear y hy])
+ have hunion : (⋃ y ∈ s, Metric.ball y (r / 2)) ⊆ Metric.ball x (R + r / 2) := by
+ intro z hz
+ obtain ⟨y, hy, hz⟩ := Set.mem_iUnion₂.mp hz
+ exact hsub y hy hz
+ calc
+ _ = ∑ y ∈ s, v := by rw [Finset.sum_const, nsmul_eq_mul]
+ _ ≤ ∑ y ∈ s, μ.real (Metric.ball y (r / 2)) := Finset.sum_le_sum hlower
+ _ = μ.real (⋃ y ∈ s, Metric.ball y (r / 2)) :=
+ (measureReal_biUnion_finset (separated_half_balls_disjoint s hsep)
+ (fun _ _ => isOpen_ball.measurableSet)
+ (fun y hy => measure_ne_top_of_subset (hsub y hy) hfinite)).symm
+ _ ≤ _ := measureReal_mono hunion hfinite
+
+/-- Two-sided Euclidean volume bounds yield a radius-independent real
+cardinality bound for centers within `C₀ * r` of the testing point. -/
+theorem separated_card_le_of_euclidean_volume (μ : Measure X) (s : Finset X) (x : X)
+ (n : ℕ) {r C₀ a b : ℝ} (hr : 0 < r) (ha : 0 < a)
+ (hsep : (s : Set X).Pairwise (fun y z => r ≤ dist y z))
+ (hnear : ∀ y ∈ s, dist y x ≤ C₀ * r)
+ (hlower : ∀ y ∈ s, a * (r / 2) ^ n ≤ μ.real (Metric.ball y (r / 2)))
+ (hupper : μ.real (Metric.ball x (C₀ * r + r / 2)) ≤ b * (C₀ * r + r / 2) ^ n)
+ (hfinite : μ (Metric.ball x (C₀ * r + r / 2)) ≠ ∞) :
+ (s.card : ℝ) ≤ b / a * (2 * C₀ + 1) ^ n := by
+ have hp := (separated_card_mul_volume_le μ s x hsep hnear hlower hfinite).trans hupper
+ have hrad : C₀ * r + r / 2 = (2 * C₀ + 1) * (r / 2) := by ring
+ rw [hrad, mul_pow] at hp
+ have hpow : 0 < (r / 2) ^ n := pow_pos (by linarith) _
+ have hc : (s.card : ℝ) * a ≤ b * (2 * C₀ + 1) ^ n := by
+ apply (mul_le_mul_iff_left₀ hpow).mp
+ convert hp using 1 <;> ring
+ have hd := (le_div_iff₀ ha).mpr hc
+ convert hd using 1
+ ring
+
+/-- An integer uniform multiplicity constant extracted from the volume
+ratio. No cardinal bound is supplied as a premise. -/
+theorem separated_card_le_ceil_of_euclidean_volume (μ : Measure X) (s : Finset X) (x : X)
+ (n : ℕ) {r C₀ a b : ℝ} (hr : 0 < r) (ha : 0 < a)
+ (hsep : (s : Set X).Pairwise (fun y z => r ≤ dist y z))
+ (hnear : ∀ y ∈ s, dist y x ≤ C₀ * r)
+ (hlower : ∀ y ∈ s, a * (r / 2) ^ n ≤ μ.real (Metric.ball y (r / 2)))
+ (hupper : μ.real (Metric.ball x (C₀ * r + r / 2)) ≤ b * (C₀ * r + r / 2) ^ n)
+ (hfinite : μ (Metric.ball x (C₀ * r + r / 2)) ≠ ∞) :
+ s.card ≤ ⌈b / a * (2 * C₀ + 1) ^ n⌉₊ := by
+ have hh := separated_card_le_of_euclidean_volume μ s x n hr ha hsep hnear hlower hupper hfinite
+ exact_mod_cast hh.trans (Nat.le_ceil _)
+
+/-- The active subfamily of a net satisfies the same uniform cardinal
+bound whenever active centers lie within `C₀ * r` of the point. -/
+theorem active_maximalPatchNet_card_le (μ : Measure X) (A : Set X)
+ (r : ℝ≥0) (x : X) (active : X → Prop) [DecidablePred active] (n : ℕ)
+ (hr : 0 < r) {C₀ a b : ℝ} (ha : 0 < a)
+ (hnear : ∀ y ∈ maximalPatchNet r A, active y → dist y x ≤ C₀ * r)
+ (hlower : ∀ y ∈ maximalPatchNet r A, active y →
+ a * ((r : ℝ) / 2) ^ n ≤ μ.real (Metric.ball y (r / 2)))
+ (hupper : μ.real (Metric.ball x (C₀ * r + r / 2)) ≤ b * (C₀ * r + r / 2) ^ n)
+ (hfinite : μ (Metric.ball x (C₀ * r + r / 2)) ≠ ∞) :
+ ((maximalPatchNet r A).filter active).card ≤ ⌈b / a * (2 * C₀ + 1) ^ n⌉₊ := by
+ apply separated_card_le_ceil_of_euclidean_volume μ _ x n (by exact_mod_cast hr) ha
+ · intro y hy z hz hne
+ exact (maximalPatchNet_separated r A (Finset.mem_filter.mp hy).1
+ (Finset.mem_filter.mp hz).1 hne).le
+ · intro y hy
+ exact hnear y (Finset.mem_filter.mp hy).1 (Finset.mem_filter.mp hy).2
+ · intro y hy
+ exact hlower y (Finset.mem_filter.mp hy).1 (Finset.mem_filter.mp hy).2
+ · exact hupper
+ · exact hfinite
+
+end Volume
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PatchCoverData.lean b/lean/OAI/Geometry/RCD/Coordinates/PatchCoverData.lean
new file mode 100644
index 0000000000000000000000000000000000000000..d2bae5126e693f0a7fc4c60b4be6ebaf398576ab
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PatchCoverData.lean
@@ -0,0 +1,447 @@
+import OAI.Geometry.RCD.Coordinates.PatchLocalization
+import OAI.Geometry.RCD.Coordinates.PatchCenters
+import OAI.Geometry.RCD.Metric.VolumeRegime
+import Mathlib.Analysis.Calculus.BumpFunction.InnerProduct
+
+namespace OAI
+
+/-!
+# Localized finite patch data from a uniform volume regime
+
+The centers form a maximal finite net. Cutoffs are affine pullbacks of a
+fixed Euclidean cutoff. The half-error volume regime, coarse separation,
+and slow normalization growth bound the overlap. The smooth cutoff has
+core radius two and support radius three.
+-/
+
+open Set Metric MeasureTheory
+open scoped NNReal ENNReal ContDiff BigOperators InnerProductSpace
+
+noncomputable section
+
+attribute [local instance] Classical.propDecidable
+
+namespace RegularPointCoordinates
+
+variable {X E F : Type*} [MetricSpace X]
+
+section Normed
+
+variable [NormedAddCommGroup E] [NormedSpace ℝ E]
+ [NormedAddCommGroup F] [NormedSpace ℝ F]
+
+/-- The coordinate cutoff centered at a point of the original metric space. -/
+def normalizedPatchCutoff (r : ℝ) (u : X → E) (T : X → E →L[ℝ] F)
+ (psi : F → ℝ) (y : X) (P : E) : ℝ :=
+ psi (r⁻¹ • T y (P - u y))
+
+/-- The original-space active domain for one actual normalized cutoff. -/
+def normalizedPatchDomain (A : Set X) (r : ℝ) (u : X → E)
+ (T : X → E →L[ℝ] F) (psi : F → ℝ) (y : X) : Set X :=
+ {x | x ∈ A ∧ u x ∈ tsupport (normalizedPatchCutoff r u T psi y)}
+
+omit [MetricSpace X] in
+/-- Every chosen net center belongs to its own active patch. -/
+theorem self_mem_normalizedPatchDomain (A : Set X) (r : ℝ) (u : X → E)
+ (T : X → E →L[ℝ] F) (psi : F → ℝ) {y : X} (hy : y ∈ A)
+ (hzero : psi 0 = 1) : y ∈ normalizedPatchDomain A r u T psi y := by
+ refine ⟨hy, ?_⟩
+ apply subset_tsupport
+ simp only [Function.mem_support, normalizedPatchCutoff, sub_self, map_zero,
+ smul_zero, hzero, ne_eq]
+ norm_num
+
+/-- The metric radius forced by the normalized support and coarse separation. -/
+def patchLocalizationFactor (c M L : ℝ) : ℝ := max 1 ((M * L / c) ^ 2)
+
+theorem patchLocalizationFactor_ge_one (c M L : ℝ) :
+ 1 ≤ patchLocalizationFactor c M L := le_max_left _ _
+
+/-- Undoing the physical scaling in a pointed coordinate approximation
+gives the actual frozen displacement estimate. -/
+theorem normalized_pair_norm_estimate (u : X → E) (T : E →L[ℝ] F)
+ (x y : X) {t R delta : ℝ} (ht : 0 < t) (hR : 0 ≤ R)
+ (hpoint : IsPointedApproximation y (0 : F) t R delta
+ (fun z => t⁻¹ • T (u z - u y)))
+ (hxy : dist x y ≤ R * t) :
+ |‖T (u x - u y)‖ - dist x y| ≤ delta * t := by
+ have hh := hpoint.2.1 x y hxy (by simpa using mul_nonneg hR ht.le)
+ have hscaled : |t⁻¹ * ‖T (u x - u y)‖ - dist x y / t| ≤ delta := by
+ simpa only [sub_self, map_zero, smul_zero, dist_zero_right, norm_smul,
+ Real.norm_of_nonneg (inv_nonneg.mpr ht.le)] using hh
+ have hm := mul_le_mul_of_nonneg_right hscaled ht.le
+ calc
+ _ = |(t⁻¹ * ‖T (u x - u y)‖ - dist x y / t) * t| := by
+ congr 1
+ field_simp [ht.ne']
+ _ = |t⁻¹ * ‖T (u x - u y)‖ - dist x y / t| * t := by
+ rw [abs_mul, abs_of_pos ht]
+ _ ≤ _ := hm
+
+/-- Approximation at four times the fine radius supplies the core-two
+near-pair hypothesis of the finite patch construction. -/
+theorem normalized_near_pair_le (u : X → E) (T : E →L[ℝ] F)
+ (x y : X) {r : ℝ} (hr : 0 < r)
+ (hpoint : IsPointedApproximation y (0 : F) (4 * r) (1 / 2) (1 / 4)
+ (fun z => (4 * r)⁻¹ • T (u z - u y)))
+ (hxy : dist x y ≤ r) : ‖T (u x - u y)‖ ≤ 2 * r := by
+ have hh := normalized_pair_norm_estimate u T x y (by positivity)
+ (by norm_num) hpoint (by linarith)
+ have hu := (abs_le.mp hh).2
+ linarith
+
+/-- A coarse pointed approximation at the pair scale supplies a fixed
+positive separation coefficient, independently of the pair distance. -/
+theorem normalized_coarse_pair_lower (u : X → E) (T : E →L[ℝ] F)
+ (x y : X) (hxy : x ≠ y)
+ (hpoint : IsPointedApproximation y (0 : F) (4 * dist x y) (1 / 2) (1 / 8)
+ (fun z => (4 * dist x y)⁻¹ • T (u z - u y))) :
+ (1 / 2) * dist x y ≤ ‖T (u x - u y)‖ := by
+ have hd := dist_pos.mpr hxy
+ have hh := normalized_pair_norm_estimate u T x y (by positivity)
+ (by norm_num) hpoint (by linarith)
+ have hl := (abs_le.mp hh).1
+ linarith
+
+/-- A dimensional overlap bound in the half-error volume regime. -/
+def patchOverlapBound (n : ℕ) (c M L : ℝ) : ℕ :=
+ ⌈3 * (2 * patchLocalizationFactor c M L + 1) ^ n⌉₊
+
+/-- Concrete geometric and smoothness properties needed before assigning
+positive operators and energy centers to the finite patches. -/
+structure IsLocalizedPatchCover (A : Set X) (r : ℝ≥0) (u : X → E)
+ (s : Finset X) (phi : X → E → ℝ) (N : ℕ) (C L : ℝ) : Prop where
+ center_mem : (s : Set X) ⊆ A
+ separated : (s : Set X).Pairwise (fun y z => (r : ℝ) < dist y z)
+ cutoff_smooth : ∀ y, ContDiff ℝ ∞ (phi y)
+ cutoff_nonneg : ∀ y P, 0 ≤ phi y P
+ cutoff_le_one : ∀ y P, phi y P ≤ 1
+ active_localized : ∀ x ∈ A, ∀ y ∈ s, u x ∈ tsupport (phi y) →
+ dist x y ≤ C * r
+ active_card : ∀ x ∈ A, (s.filter (fun y => u x ∈ tsupport (phi y))).card ≤ N
+ weight_one_cover : ∀ x ∈ A, ∃ y ∈ s,
+ dist x y ≤ r ∧ phi y (u x) = 1 ∧ u x ∈ tsupport (phi y) ∧
+ ball x r ⊆ ball y (L * r)
+
+namespace IsLocalizedPatchCover
+
+variable {A : Set X} {r : ℝ≥0} {u : X → E} {s : Finset X}
+ {phi : X → E → ℝ} {N : ℕ} {C L : ℝ}
+
+/-- The actual cutoff sum is positive throughout the covered domain. -/
+theorem one_le_cutoff_sum (d : IsLocalizedPatchCover A r u s phi N C L)
+ {x : X} (hx : x ∈ A) : 1 ≤ ∑ y ∈ s, phi y (u x) := by
+ obtain ⟨y, hy, _, hyone, _, _⟩ := d.weight_one_cover x hx
+ calc
+ 1 = phi y (u x) := hyone.symm
+ _ ≤ _ := Finset.single_le_sum (fun z _ => d.cutoff_nonneg z (u x)) hy
+
+/-- The same sum is bounded by the geometric overlap constant: inactive
+terms vanish, so the total number of net points never enters the bound. -/
+theorem cutoff_sum_le (d : IsLocalizedPatchCover A r u s phi N C L)
+ {x : X} (hx : x ∈ A) : (∑ y ∈ s, phi y (u x)) ≤ N := by
+ let active := s.filter (fun y => u x ∈ tsupport (phi y))
+ have heq : (∑ y ∈ active, phi y (u x)) = ∑ y ∈ s, phi y (u x) := by
+ apply Finset.sum_subset (Finset.filter_subset _ _)
+ intro y hy hnot
+ apply image_eq_zero_of_notMem_tsupport
+ intro ha
+ exact hnot (Finset.mem_filter.mpr ⟨hy, ha⟩)
+ calc
+ _ = ∑ y ∈ active, phi y (u x) := heq.symm
+ _ ≤ ∑ _y ∈ active, (1 : ℝ) := Finset.sum_le_sum (fun y _ => d.cutoff_le_one y _)
+ _ = (active.card : ℝ) := by simp
+ _ ≤ N := by exact_mod_cast d.active_card x hx
+
+/-- Active support, restricted to the actual coordinate image, comes
+from points in a uniformly enlarged original metric ball. -/
+theorem support_inter_image_subset (d : IsLocalizedPatchCover A r u s phi N C L)
+ {y : X} (hy : y ∈ s) :
+ tsupport (phi y) ∩ u '' A ⊆ u '' (A ∩ closedBall y (C * r)) := by
+ rintro P ⟨hP, x, hx, rfl⟩
+ exact ⟨x, ⟨hx, d.active_localized x hx y hy hP⟩, rfl⟩
+
+/-- The overlap bound in the exact coordinate-domain form used by
+`PatchIterationGeometry.active_card`. No injectivity is needed here. -/
+theorem active_card_of_mem_image (d : IsLocalizedPatchCover A r u s phi N C L)
+ {P : E} (hP : P ∈ u '' A) :
+ (s.filter (fun y => P ∈ tsupport (phi y))).card ≤ N := by
+ obtain ⟨x, hx, rfl⟩ := hP
+ exact d.active_card x hx
+
+end IsLocalizedPatchCover
+
+end Normed
+
+section EnergyCenters
+
+variable [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+ [NormedAddCommGroup F] [NormedSpace ℝ F]
+
+/-- The actual active domains supply the nonemptiness needed to choose
+fixed energy centers. They remain in the original bounded domain and the
+localized metric ball, and their affine displacement obeys the required
+three-times pair-energy bound at every active point. -/
+theorem exists_normalized_patch_energy_centers
+ (A : Set X) (r : ℝ≥0) (u : X → E) (T : X → E →L[ℝ] F)
+ (psi : F → ℝ) (s : Finset X) {N : ℕ} {C L D floor : ℝ}
+ (d : IsLocalizedPatchCover A r u s (normalizedPatchCutoff r u T psi) N C L)
+ (hzero : psi 0 = 1) (energy : X → ℝ) (hfloor : 0 < floor)
+ (hlower : ∀ x ∈ A, floor ≤ energy x)
+ (op : X → E →L[ℝ] E) (hD : 0 ≤ D)
+ (hpair : ∀ y ∈ s, ∀ x ∈ normalizedPatchDomain A r u T psi y,
+ ∀ z ∈ normalizedPatchDomain A r u T psi y,
+ ⟪u x - u z, op y (u x - u z)⟫_ℝ ≤
+ D * (r : ℝ) ^ 2 * (energy x + energy z)) :
+ ∃ center : X → X, ∀ y ∈ s,
+ center y ∈ A ∧ u (center y) ∈ tsupport (normalizedPatchCutoff r u T psi y) ∧
+ dist (center y) y ≤ C * r ∧
+ ∀ x ∈ normalizedPatchDomain A r u T psi y,
+ ⟪u x - u (center y), op y (u x - u (center y))⟫_ℝ ≤
+ (3 * D) * (r : ℝ) ^ 2 * energy x := by
+ have hc (y : X) : ∃ z : X, y ∈ s →
+ z ∈ normalizedPatchDomain A r u T psi y ∧
+ ∀ x ∈ normalizedPatchDomain A r u T psi y, energy z ≤ 2 * energy x := by
+ by_cases hy : y ∈ s
+ · obtain ⟨z, hz, hb⟩ := exists_energy_center
+ ⟨y, self_mem_normalizedPatchDomain A r u T psi (d.center_mem hy) hzero⟩
+ hfloor (fun x hx => hlower x hx.1)
+ exact ⟨z, fun _ => ⟨hz, hb⟩⟩
+ · exact ⟨y, fun hy' => False.elim (hy hy')⟩
+ choose center hcenter using hc
+ refine ⟨center, ?_⟩
+ intro y hy
+ obtain ⟨hz, henergy⟩ := hcenter y hy
+ refine ⟨hz.1, hz.2, d.active_localized _ hz.1 y hy hz.2, ?_⟩
+ intro x hx
+ exact centered_patch_energy_le u (op y) hD (henergy x hx) (hpair y hy x hx _ hz)
+
+end EnergyCenters
+
+/-- The half-error relative-volume estimate gives the two bounds used by
+the packing argument, with their common Euclidean volume factor explicit. -/
+theorem half_volume_bounds {V omega r : ℝ} {n : ℕ}
+ (homega : 0 < omega) (hr : 0 < r)
+ (hvolume : |V / (omega * r ^ n) - 1| ≤ 1 / 2) :
+ (omega / 2) * r ^ n ≤ V ∧ V ≤ (3 * omega / 2) * r ^ n := by
+ have hden : 0 < omega * r ^ n := mul_pos homega (pow_pos hr _)
+ have hv := abs_le.mp hvolume
+ have hl : (1 / 2 : ℝ) ≤ V / (omega * r ^ n) := by linarith [hv.1]
+ have hu : V / (omega * r ^ n) ≤ (3 / 2 : ℝ) := by linarith [hv.2]
+ have hl' := (le_div_iff₀ hden).mp hl
+ have hu' := (div_le_iff₀ hden).mp hu
+ constructor <;> nlinarith
+
+section Volume
+
+variable [NormedAddCommGroup E] [NormedSpace ℝ E]
+ [NormedAddCommGroup F] [NormedSpace ℝ F]
+ [MeasurableSpace X] [OpensMeasurableSpace X]
+
+/-- The actual maximal net and affine cutoff satisfy localization,
+weight-one covering and a scale-independent overlap bound. The measure
+premise is only the uniform half-error ball-volume estimate. -/
+theorem maximal_normalized_patch_cover
+ (μ : Measure X) (A : Set X) (hA : TotallyBounded A)
+ (r : ℝ≥0) (hr : 0 < r) (u : X → E) (T : X → E →L[ℝ] F)
+ (psi : F → ℝ) (n : ℕ) {R omega c M L : ℝ}
+ (homega : 0 < omega) (hc : 0 < c) (hL : 2 ≤ L)
+ (hscale : (patchLocalizationFactor c M L + 1) * r ≤ R)
+ (hvolume : ∀ x ∈ A, ∀ t : ℝ, 0 < t → t ≤ R →
+ |μ.real (ball x t) / (omega * t ^ n) - 1| ≤ 1 / 2)
+ (hfinite : ∀ x t, μ (ball x t) ≠ (⊤ : ℝ≥0∞))
+ (hsmooth : ContDiff ℝ ∞ psi)
+ (hzero : ∀ z, 0 ≤ psi z) (hone : ∀ z, psi z ≤ 1)
+ (hcore : ∀ z, ‖z‖ ≤ 2 → psi z = 1)
+ (hsupport : tsupport psi ⊆ closedBall 0 L)
+ (hnear : ∀ x ∈ A, ∀ y ∈ A, dist x y ≤ r →
+ ‖T y (u x - u y)‖ ≤ 2 * r)
+ (hseparate : ∀ x ∈ A, ∀ y ∈ A, (r : ℝ) < dist x y →
+ ∃ S : E →L[ℝ] F, c * dist x y ≤ ‖S (u x - u y)‖ ∧
+ ‖S (u x - u y)‖ ^ 2 ≤ M ^ 2 * (dist x y / r) * ‖T y (u x - u y)‖ ^ 2) :
+ IsLocalizedPatchCover A r u (maximalPatchNet r A)
+ (normalizedPatchCutoff r u T psi) (patchOverlapBound n c M L)
+ (patchLocalizationFactor c M L) L := by
+ have hr' : 0 < (r : ℝ) := by exact_mod_cast hr
+ have hL0 : 0 ≤ L := by linarith
+ have hfac : 1 ≤ patchLocalizationFactor c M L := patchLocalizationFactor_ge_one _ _ _
+ have hrR : (r : ℝ) / 2 ≤ R := by nlinarith
+ have houter : 0 < patchLocalizationFactor c M L * r + r / 2 := by nlinarith
+ have houterR : patchLocalizationFactor c M L * r + r / 2 ≤ R := by nlinarith
+ have hloc (x : X) (hx : x ∈ A) (y : X) (hy : y ∈ maximalPatchNet r A)
+ (ha : u x ∈ tsupport (normalizedPatchCutoff r u T psi y)) :
+ dist x y ≤ patchLocalizationFactor c M L * r := by
+ by_cases hd : dist x y ≤ r
+ · nlinarith
+ have hd' : (r : ℝ) < dist x y := lt_of_not_ge hd
+ obtain ⟨S, hs, hg⟩ := hseparate x hx y (maximalPatchNet_subset r A hy) hd'
+ exact active_cutoff_distance_le u (T y) S psi x y hr' hc hL0 hsupport ha
+ (fun _ => hs) (fun _ => hg)
+ refine {
+ center_mem := maximalPatchNet_subset r A
+ separated := maximalPatchNet_separated r A
+ cutoff_smooth := ?_
+ cutoff_nonneg := fun y P => hzero _
+ cutoff_le_one := fun y P => hone _
+ active_localized := hloc
+ active_card := ?_
+ weight_one_cover := ?_ }
+ · intro y
+ exact hsmooth.comp (((T y).contDiff.comp (contDiff_id.sub contDiff_const)).const_smul _)
+ · intro x hx
+ have hcount := active_maximalPatchNet_card_le μ A r x
+ (fun y => u x ∈ tsupport (normalizedPatchCutoff r u T psi y)) n hr
+ (show 0 < omega / 2 by positivity)
+ (fun y hy ha => by simpa only [dist_comm] using hloc x hx y hy ha)
+ (fun y hy _ => (half_volume_bounds homega (by positivity)
+ (hvolume y (maximalPatchNet_subset r A hy) _ (by positivity) hrR)).1)
+ (half_volume_bounds homega houter (hvolume x hx _ houter houterR)).2
+ (hfinite x _)
+ have hratio : (3 * omega / 2) / (omega / 2) = 3 := by field_simp [homega.ne']
+ simpa only [hratio, patchOverlapBound] using hcount
+ · intro x hx
+ exact exists_weight_one_covering_patch A hA r hr u T psi hcore
+ (fun x hx y hy hd => hnear x hx y (maximalPatchNet_subset r A hy) hd) x hx hL
+
+/-- Properness is only used to turn a bounded, possibly nonclosed domain
+into the totally bounded set required for the actual finite net. -/
+theorem bounded_maximal_normalized_patch_cover [ProperSpace X]
+ (μ : Measure X) (A : Set X) (hA : Bornology.IsBounded A)
+ (r : ℝ≥0) (hr : 0 < r) (u : X → E) (T : X → E →L[ℝ] F)
+ (psi : F → ℝ) (n : ℕ) {R omega c M L : ℝ}
+ (homega : 0 < omega) (hc : 0 < c) (hL : 2 ≤ L)
+ (hscale : (patchLocalizationFactor c M L + 1) * r ≤ R)
+ (hvolume : ∀ x ∈ A, ∀ t : ℝ, 0 < t → t ≤ R →
+ |μ.real (ball x t) / (omega * t ^ n) - 1| ≤ 1 / 2)
+ (hfinite : ∀ x t, μ (ball x t) ≠ (⊤ : ℝ≥0∞))
+ (hsmooth : ContDiff ℝ ∞ psi)
+ (hzero : ∀ z, 0 ≤ psi z) (hone : ∀ z, psi z ≤ 1)
+ (hcore : ∀ z, ‖z‖ ≤ 2 → psi z = 1)
+ (hsupport : tsupport psi ⊆ closedBall 0 L)
+ (hnear : ∀ x ∈ A, ∀ y ∈ A, dist x y ≤ r → ‖T y (u x - u y)‖ ≤ 2 * r)
+ (hseparate : ∀ x ∈ A, ∀ y ∈ A, (r : ℝ) < dist x y →
+ ∃ S : E →L[ℝ] F, c * dist x y ≤ ‖S (u x - u y)‖ ∧
+ ‖S (u x - u y)‖ ^ 2 ≤ M ^ 2 * (dist x y / r) * ‖T y (u x - u y)‖ ^ 2) :
+ IsLocalizedPatchCover A r u (maximalPatchNet r A)
+ (normalizedPatchCutoff r u T psi) (patchOverlapBound n c M L)
+ (patchLocalizationFactor c M L) L :=
+ maximal_normalized_patch_cover μ A (hA.isCompact_closure.totallyBounded.subset subset_closure)
+ r hr u T psi n homega hc hL hscale hvolume hfinite hsmooth hzero hone hcore hsupport hnear hseparate
+
+/-- The coordinate premises can be stated as actual pointed
+approximations and slow norm growth. Their separation and near-pair
+consequences are derived before constructing the localized patch cover. -/
+theorem normalized_patch_cover_of_pointed_approximations [ProperSpace X]
+ (μ : Measure X) (A : Set X) (hA : Bornology.IsBounded A)
+ (r : ℝ≥0) (hr : 0 < r) (u : X → E) (T : X → E →L[ℝ] F)
+ (psi : F → ℝ) (n : ℕ) {R omega M L exponent : ℝ}
+ (homega : 0 < omega) (hM : 0 ≤ M) (hL : 2 ≤ L) (hexponent : exponent ≤ 1 / 2)
+ (hscale : (patchLocalizationFactor (1 / 2) M L + 1) * r ≤ R)
+ (hvolume : ∀ x ∈ A, ∀ t : ℝ, 0 < t → t ≤ R →
+ |μ.real (ball x t) / (omega * t ^ n) - 1| ≤ 1 / 2)
+ (hfinite : ∀ x t, μ (ball x t) ≠ (⊤ : ℝ≥0∞))
+ (hsmooth : ContDiff ℝ ∞ psi)
+ (hzero : ∀ z, 0 ≤ psi z) (hone : ∀ z, psi z ≤ 1)
+ (hcore : ∀ z, ‖z‖ ≤ 2 → psi z = 1)
+ (hsupport : tsupport psi ⊆ closedBall 0 L)
+ (hpoint : ∀ y ∈ A, IsPointedApproximation y (0 : F) (4 * r) (1 / 2) (1 / 4)
+ (fun z => (4 * r)⁻¹ • T y (u z - u y)))
+ (hcoarse : ∀ x ∈ A, ∀ y ∈ A, (r : ℝ) < dist x y →
+ ∃ S : E →L[ℝ] F,
+ IsPointedApproximation y (0 : F) (4 * dist x y) (1 / 2) (1 / 8)
+ (fun z => (4 * dist x y)⁻¹ • S (u z - u y)) ∧
+ ‖S (u x - u y)‖ ≤
+ M * (dist x y / r) ^ exponent * ‖T y (u x - u y)‖) :
+ IsLocalizedPatchCover A r u (maximalPatchNet r A)
+ (normalizedPatchCutoff r u T psi) (patchOverlapBound n (1 / 2) M L)
+ (patchLocalizationFactor (1 / 2) M L) L := by
+ have hr' : 0 < (r : ℝ) := by exact_mod_cast hr
+ apply bounded_maximal_normalized_patch_cover μ A hA r hr u T psi n homega
+ (by norm_num) hL hscale hvolume hfinite hsmooth hzero hone hcore hsupport
+ · intro x _ y hy hxy
+ exact normalized_near_pair_le u (T y) x y hr' (hpoint y hy) hxy
+ · intro x hx y hy hfar
+ obtain ⟨S, hS, hslow⟩ := hcoarse x hx y hy hfar
+ exact ⟨S, normalized_coarse_pair_lower u S x y (dist_pos.mp (hr'.trans hfar)) hS,
+ squared_growth_of_slow_norm_growth (T y) S (u x - u y) hr' hfar.le hM hexponent hslow⟩
+
+end Volume
+
+section SmoothCutoff
+
+variable [NormedAddCommGroup F] [InnerProductSpace ℝ F]
+
+/-- An actual smooth core-two, support-three cutoff on the coordinate space. -/
+def patchCoreBump : ContDiffBump (0 : F) := ⟨2, 3, by norm_num, by norm_num⟩
+
+theorem patchCoreBump_properties :
+ ContDiff ℝ ∞ (patchCoreBump (F := F)) ∧
+ (∀ z, 0 ≤ patchCoreBump (F := F) z) ∧
+ (∀ z, patchCoreBump (F := F) z ≤ 1) ∧
+ (∀ z, ‖z‖ ≤ 2 → patchCoreBump (F := F) z = 1) ∧
+ tsupport (patchCoreBump (F := F)) ⊆ closedBall 0 3 := by
+ refine ⟨ContDiffBump.contDiff _, fun _ => ContDiffBump.nonneg _,
+ fun _ => ContDiffBump.le_one _, ?_, ?_⟩
+ · intro z hz
+ exact ContDiffBump.one_of_mem_closedBall _ (by simpa [patchCoreBump] using hz)
+ · rw [ContDiffBump.tsupport_eq]
+ exact Subset.rfl
+
+end SmoothCutoff
+
+section RegularVolume
+
+variable [NormedAddCommGroup E] [NormedSpace ℝ E]
+ [NormedAddCommGroup F] [InnerProductSpace ℝ F]
+ [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- The published volume convergence, Bishop--Gromov and density inputs
+give one working neighborhood and one uniform overlap constant for every
+smaller-scale normalized patch family. The remaining premises concern only
+the coordinate normalizations: near-pair control and coarse separation
+with slow growth. No patch conclusion is assumed. -/
+theorem exists_regular_patch_cover_radius
+ (μ : Measure X) (m : ℕ) {p : X} {a omega rho c M : ℝ}
+ (ha : 0 ≤ a) (homega : 0 < omega) (hrho : 0 < rho) (hc : 0 < c)
+ (hcompact : PointedRescalingPrecompactness p) (hregular : IsRegular (m + 1) p)
+ (hvolume : EuclideanRescalingVolumeConvergence μ (m + 1) p omega)
+ (hcomparison : BallVolumeComparison μ (comparisonModelVolume m a))
+ (hdensity : ∀ y, SmallScaleVolumeUpper μ (comparisonModelVolume m a) y omega)
+ (hfinite : ∀ y t, μ (ball y t) ≠ (⊤ : ℝ≥0∞)) :
+ ∃ R : ℝ, 0 < R ∧ R ≤ rho ∧
+ ∀ (r : ℝ≥0), 0 < r → (patchLocalizationFactor c M 3 + 1) * r ≤ R →
+ ∀ (u : X → E) (T : X → E →L[ℝ] F),
+ (∀ x ∈ ball p R, ∀ y ∈ ball p R, dist x y ≤ r →
+ ‖T y (u x - u y)‖ ≤ 2 * r) →
+ (∀ x ∈ ball p R, ∀ y ∈ ball p R, (r : ℝ) < dist x y →
+ ∃ S : E →L[ℝ] F, c * dist x y ≤ ‖S (u x - u y)‖ ∧
+ ‖S (u x - u y)‖ ^ 2 ≤ M ^ 2 * (dist x y / r) * ‖T y (u x - u y)‖ ^ 2) →
+ IsLocalizedPatchCover (ball p R) r u (maximalPatchNet r (ball p R))
+ (normalizedPatchCutoff r u T (patchCoreBump (F := F)))
+ (patchOverlapBound (m + 1) c M 3) (patchLocalizationFactor c M 3) 3 := by
+ obtain ⟨R, hR, hRrho, hvol⟩ := exists_uniform_volume_neighborhood m ha homega
+ (epsilon := 1 / 2) (by norm_num) (by norm_num) hrho
+ hcompact hregular hvolume hcomparison hdensity hfinite
+ refine ⟨R, hR, hRrho, ?_⟩
+ intro r hr hscale u T hnear hsep
+ have hp := patchCoreBump_properties (F := F)
+ apply bounded_maximal_normalized_patch_cover μ (ball p R) isBounded_ball
+ r hr u T (patchCoreBump (F := F)) (m + 1) homega hc (by norm_num) hscale
+ · intro x hx t ht htR
+ exact hvol x (by simpa only [dist_comm] using (mem_ball.mp hx).le) t ht htR
+ · exact hfinite
+ · exact hp.1
+ · exact hp.2.1
+ · exact hp.2.2.1
+ · exact hp.2.2.2.1
+ · exact hp.2.2.2.2
+ · exact hnear
+ · exact hsep
+
+end RegularVolume
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PatchDirectionalBounds.lean b/lean/OAI/Geometry/RCD/Coordinates/PatchDirectionalBounds.lean
new file mode 100644
index 0000000000000000000000000000000000000000..4fec39c614adfcc747408ba1b102a2dc5eebb18f
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PatchDirectionalBounds.lean
@@ -0,0 +1,207 @@
+import OAI.Geometry.RCD.Coordinates.FrozenNorms
+import OAI.Geometry.RCD.Coordinates.FieldEstimates
+
+namespace OAI
+
+/-!
+# Directional estimates for finite patch fields
+
+The finite set is the set of active patches at the point under consideration.
+All metric norms are frozen using a continuous linear equivalence `T`.
+The hypotheses are the individual displacement energies, cutoff derivative
+bounds, overlap bound, and positive mass bounds; no field estimate is assumed.
+-/
+
+open scoped BigOperators InnerProductSpace
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+
+/-- The unweighted mass of the active patches. -/
+def patchMass (s : Finset ι) (D : ι → E →L[ℝ] E) : E →L[ℝ] E :=
+ ∑ j ∈ s, D j
+
+/-- The principal part of the derivative of the patch field. -/
+def patchPrincipal (s : Finset ι) (phi : ι → ℝ) (D : ι → E →L[ℝ] E) :
+ E →L[ℝ] E := ∑ j ∈ s, phi j • D j
+
+/-- The error produced by differentiating the cutoff functions. -/
+def patchCutoffError (s : Finset ι) (D : ι → E →L[ℝ] E)
+ (w : ι → E) (a : ι → ℝ) : E := ∑ j ∈ s, a j • D j (w j)
+
+theorem patchMass_isPositive (s : Finset ι) (D : ι → E →L[ℝ] E)
+ (hD : ∀ j ∈ s, (D j).IsPositive) : (patchMass s D).IsPositive := by
+ exact ContinuousLinearMap.isPositive_sum s hD
+
+theorem inner_patchMass (s : Finset ι) (D : ι → E →L[ℝ] E) (x : E) :
+ ⟪x, patchMass s D x⟫_ℝ = ∑ j ∈ s, ⟪x, D j x⟫_ℝ := by
+ simp [patchMass, inner_sum]
+
+/-- Each positive patch is bounded above by the total positive mass. -/
+theorem patch_form_le_mass (s : Finset ι) (D : ι → E →L[ℝ] E)
+ (hD : ∀ j ∈ s, (D j).IsPositive) {j : ι} (hj : j ∈ s) (x : E) :
+ ⟪x, D j x⟫_ℝ ≤ ⟪x, patchMass s D x⟫_ℝ := by
+ rw [inner_patchMass]
+ exact Finset.single_le_sum (fun k hk => (hD k hk).inner_nonneg_right x) hj
+
+/-- Nonnegative cutoffs bounded by one give `0 ≤ S ≤ Z`. -/
+theorem patchPrincipal_form_le_mass (s : Finset ι) (phi : ι → ℝ)
+ (D : ι → E →L[ℝ] E) (hD : ∀ j ∈ s, (D j).IsPositive)
+ (hphi : ∀ j ∈ s, phi j ≤ 1) (x : E) :
+ ⟪x, patchPrincipal s phi D x⟫_ℝ ≤ ⟪x, patchMass s D x⟫_ℝ := by
+ simp only [patchPrincipal, patchMass, sum_apply, smul_apply, inner_sum,
+ inner_smul_right]
+ apply Finset.sum_le_sum
+ intro j hj
+ exact mul_le_of_le_one_left ((hD j hj).inner_nonneg_right x) (hphi j hj)
+
+variable [CompleteSpace E]
+
+/-- The cumulative smallness `Z ≤ epsilon H` gives the sharp principal bound.
+Individual smallness of each patch alone is not used as a substitute for this
+cumulative hypothesis. -/
+theorem patchPrincipal_frozen_norm_le (T : E ≃L[ℝ] E) (s : Finset ι)
+ (phi : ι → ℝ) (D : ι → E →L[ℝ] E) {epsilon : ℝ}
+ (hepsilon : 0 ≤ epsilon) (hD : ∀ j ∈ s, (D j).IsPositive)
+ (hphi0 : ∀ j ∈ s, 0 ≤ phi j) (hphi1 : ∀ j ∈ s, phi j ≤ 1)
+ (hZ : ∀ x, ⟪x, patchMass s D x⟫_ℝ ≤ epsilon * ‖T x‖ ^ 2) (xi : E) :
+ ‖(T.symm : E →L[ℝ] E).adjoint (patchPrincipal s phi D xi)‖ ≤
+ Real.sqrt epsilon * Real.sqrt ⟪xi, patchMass s D xi⟫_ℝ := by
+ have hS := patch_principal_isPositive s phi D hphi0 hD
+ have hle := patchPrincipal_form_le_mass s phi D hD hphi1
+ have h := frozen_positive_form_norm_le T hS hepsilon (fun x => (hle x).trans (hZ x)) xi
+ exact h.trans (mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt (hle xi))
+ (Real.sqrt_nonneg _))
+
+/-- A weighted finite patch sum in the dual metric. -/
+theorem frozen_patch_weighted_value_le (T : E ≃L[ℝ] E) (s : Finset ι)
+ (D : ι → E →L[ℝ] E) (w : ι → E) (a : ι → ℝ) {N : ℕ}
+ {epsilon C r energy A : ℝ} (hN : s.card ≤ N)
+ (hepsilon : 0 ≤ epsilon) (hC : 0 ≤ C) (hr : 0 ≤ r)
+ (henergy : 0 ≤ energy) (hA : 0 ≤ A)
+ (hD : ∀ j ∈ s, (D j).IsPositive)
+ (hsmall : ∀ j ∈ s, ∀ x, ⟪x, D j x⟫_ℝ ≤ epsilon * ‖T x‖ ^ 2)
+ (hw : ∀ j ∈ s, ⟪w j, D j (w j)⟫_ℝ ≤ C * r ^ 2 * energy)
+ (ha : ∀ j ∈ s, |a j| ≤ A) :
+ ‖(T.symm : E →L[ℝ] E).adjoint (patchCutoffError s D w a)‖ ≤
+ (N : ℝ) * A * (Real.sqrt epsilon * Real.sqrt C * r * Real.sqrt energy) := by
+ rw [patchCutoffError, map_sum]
+ refine (norm_sum_le _ _).trans ?_
+ calc
+ ∑ j ∈ s, ‖(T.symm : E →L[ℝ] E).adjoint (a j • D j (w j))‖
+ ≤ ∑ _j ∈ s, A * (Real.sqrt epsilon * Real.sqrt C * r * Real.sqrt energy) := by
+ apply Finset.sum_le_sum
+ intro j hj
+ rw [map_smul, norm_smul, Real.norm_eq_abs]
+ exact mul_le_mul (ha j hj)
+ (frozen_positive_form_value_le T (hD j hj) hepsilon hC hr henergy
+ (hsmall j hj) (w j) (hw j hj)) (norm_nonneg _) hA
+ _ = (s.card : ℝ) * (A * (Real.sqrt epsilon * Real.sqrt C * r * Real.sqrt energy)) := by
+ simp
+ _ ≤ (N : ℝ) * (A * (Real.sqrt epsilon * Real.sqrt C * r * Real.sqrt energy)) := by
+ exact mul_le_mul_of_nonneg_right (by exact_mod_cast hN) (by positivity)
+ _ = _ := by ring
+
+/-- The normalized value estimate `re:field-value`. -/
+theorem patchField_frozen_value_le (T : E ≃L[ℝ] E) (s : Finset ι)
+ (phi : ι → E → ℝ) (D : ι → E →L[ℝ] E) (c : ι → E) (P : E) {N : ℕ}
+ {epsilon C r energy : ℝ} (hN : s.card ≤ N)
+ (hepsilon : 0 ≤ epsilon) (hC : 0 ≤ C) (hr : 0 < r) (henergy : 0 ≤ energy)
+ (hD : ∀ j ∈ s, (D j).IsPositive)
+ (hsmall : ∀ j ∈ s, ∀ x, ⟪x, D j x⟫_ℝ ≤ epsilon * ‖T x‖ ^ 2)
+ (hw : ∀ j ∈ s, ⟪P - c j, D j (P - c j)⟫_ℝ ≤ C * r ^ 2 * energy)
+ (hphi : ∀ j ∈ s, |phi j P| ≤ 1) :
+ ‖(T.symm : E →L[ℝ] E).adjoint (patchField s phi D c P)‖ / r ≤
+ (N : ℝ) * Real.sqrt C * Real.sqrt epsilon * Real.sqrt energy := by
+ apply (div_le_iff₀ hr).2
+ have h := frozen_patch_weighted_value_le T s D (fun j => P - c j)
+ (fun j => phi j P) hN hepsilon hC hr.le henergy zero_le_one hD hsmall hw hphi
+ change ‖(T.symm : E →L[ℝ] E).adjoint (patchField s phi D c P)‖ ≤ _ at h
+ convert h using 1
+ ring
+
+/-- The dual norm estimate for the linear cutoff error. -/
+theorem patchCutoffError_frozen_norm_le (T : E ≃L[ℝ] E) (s : Finset ι)
+ (D : ι → E →L[ℝ] E) (w : ι → E) (a : ι → ℝ) (xi : E) {N : ℕ}
+ {epsilon C K r energy : ℝ} (hN : s.card ≤ N)
+ (hepsilon : 0 ≤ epsilon) (hC : 0 ≤ C) (hK : 0 ≤ K)
+ (hr : 0 < r) (henergy : 0 ≤ energy)
+ (hD : ∀ j ∈ s, (D j).IsPositive)
+ (hsmall : ∀ j ∈ s, ∀ x, ⟪x, D j x⟫_ℝ ≤ epsilon * ‖T x‖ ^ 2)
+ (hw : ∀ j ∈ s, ⟪w j, D j (w j)⟫_ℝ ≤ C * r ^ 2 * energy)
+ (ha : ∀ j ∈ s, |a j| ≤ K / r * ‖T xi‖) :
+ ‖(T.symm : E →L[ℝ] E).adjoint (patchCutoffError s D w a)‖ ≤
+ (N : ℝ) * K * Real.sqrt C * Real.sqrt epsilon * Real.sqrt energy * ‖T xi‖ := by
+ have h := frozen_patch_weighted_value_le T s D w a hN hepsilon hC hr.le henergy
+ (A := K / r * ‖T xi‖) (by positivity) hD hsmall hw ha
+ convert h using 1
+ field_simp [ne_of_gt hr]
+
+omit [CompleteSpace E] in
+/-- Bounded overlap controls the total displacement energy. -/
+theorem sqrt_patch_energy_sum_le (s : Finset ι) (D : ι → E →L[ℝ] E)
+ (w : ι → E) {N : ℕ} {C r energy : ℝ} (hN : s.card ≤ N)
+ (hC : 0 ≤ C) (hr : 0 ≤ r) (henergy : 0 ≤ energy)
+ (hD : ∀ j ∈ s, (D j).IsPositive)
+ (hw : ∀ j ∈ s, ⟪w j, D j (w j)⟫_ℝ ≤ C * r ^ 2 * energy) :
+ Real.sqrt (∑ j ∈ s, ⟪w j, D j (w j)⟫_ℝ) ≤
+ Real.sqrt ((N : ℝ) * C) * r * Real.sqrt energy := by
+ have hsum0 : 0 ≤ ∑ j ∈ s, ⟪w j, D j (w j)⟫_ℝ :=
+ Finset.sum_nonneg (fun j hj => (hD j hj).inner_nonneg_right _)
+ have hsum : (∑ j ∈ s, ⟪w j, D j (w j)⟫_ℝ) ≤ (N : ℝ) * C * r ^ 2 * energy := by
+ calc
+ _ ≤ ∑ _j ∈ s, C * r ^ 2 * energy := Finset.sum_le_sum hw
+ _ = (s.card : ℝ) * (C * r ^ 2 * energy) := by simp
+ _ ≤ (N : ℝ) * (C * r ^ 2 * energy) :=
+ mul_le_mul_of_nonneg_right (by exact_mod_cast hN) (by positivity)
+ _ = _ := by ring
+ have hroot : (Real.sqrt ((N : ℝ) * C) * r * Real.sqrt energy) ^ 2 =
+ (N : ℝ) * C * r ^ 2 * energy := by
+ rw [mul_pow, mul_pow, Real.sq_sqrt (by positivity), Real.sq_sqrt henergy]
+ have hnonneg : 0 ≤ Real.sqrt ((N : ℝ) * C) * r * Real.sqrt energy := by positivity
+ nlinarith [Real.sq_sqrt hsum0, Real.sqrt_nonneg
+ (∑ j ∈ s, ⟪w j, D j (w j)⟫_ℝ)]
+
+omit [CompleteSpace E] in
+/-- The sharp diagonal estimate retains the directional mass `Z[xi]`.
+It does not replace this mass by a bound in terms of the whole source metric. -/
+theorem patchCutoffError_diagonal_le (T : E ≃L[ℝ] E) (s : Finset ι)
+ (D : ι → E →L[ℝ] E) (w : ι → E) (a : ι → ℝ) (xi : E) {N : ℕ}
+ {C K r energy : ℝ} (hN : s.card ≤ N) (hC : 0 ≤ C) (hK : 0 ≤ K)
+ (hr : 0 < r) (henergy : 0 ≤ energy)
+ (hD : ∀ j ∈ s, (D j).IsPositive)
+ (hw : ∀ j ∈ s, ⟪w j, D j (w j)⟫_ℝ ≤ C * r ^ 2 * energy)
+ (ha : ∀ j ∈ s, |a j| ≤ K / r * ‖T xi‖) :
+ |⟪xi, patchCutoffError s D w a⟫_ℝ| ≤
+ K * Real.sqrt ((N : ℝ) * C) *
+ Real.sqrt ⟪xi, patchMass s D xi⟫_ℝ * Real.sqrt energy * ‖T xi‖ := by
+ have h := patch_error_inner_le s D w a xi (K := K / r * ‖T xi‖)
+ (by positivity) hD ha
+ rw [← inner_patchMass] at h
+ have henergySum := sqrt_patch_energy_sum_le s D w hN hC hr.le henergy hD hw
+ have h' := h.trans (mul_le_mul_of_nonneg_left henergySum
+ (show 0 ≤ K / r * ‖T xi‖ * Real.sqrt ⟪xi, patchMass s D xi⟫_ℝ by positivity))
+ change |⟪xi, patchCutoffError s D w a⟫_ℝ| ≤ _ at h'
+ convert h' using 1
+ field_simp [ne_of_gt hr]
+
+omit [CompleteSpace E] in
+/-- The bounds above apply to the actual derivative, with the exact principal
+and cutoff-error decomposition supplied by differentiation. -/
+theorem fderiv_patchField_apply (s : Finset ι) (phi : ι → E → ℝ)
+ (dphi : ι → E →L[ℝ] ℝ) (D : ι → E →L[ℝ] E) (c : ι → E) (P xi : E)
+ (hphi : ∀ j ∈ s, HasFDerivAt (phi j) (dphi j) P) :
+ fderiv ℝ (patchField s phi D c) P xi =
+ patchPrincipal s (fun j => phi j P) D xi +
+ patchCutoffError s D (fun j => P - c j) (fun j => dphi j xi) := by
+ rw [(hasFDerivAt_patchField s phi dphi D c P hphi).fderiv]
+ simp [patchPrincipal, patchCutoffError, Finset.sum_add_distrib]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PatchGeometryMonotone.lean b/lean/OAI/Geometry/RCD/Coordinates/PatchGeometryMonotone.lean
new file mode 100644
index 0000000000000000000000000000000000000000..27e6b4a9ef21601a8e1b1a37c1723f24a3303818
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PatchGeometryMonotone.lean
@@ -0,0 +1,29 @@
+import OAI.Geometry.RCD.Coordinates.PatchAssembly
+
+namespace OAI
+
+/-! # Enlarging the permissible error of unchanged patch data -/
+
+open Set
+open scoped InnerProductSpace
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+
+/-- Only the allowed mass and energy budget changes; all constructed
+patches, operators and frozen frames are retained exactly. -/
+def PatchIterationGeometry.monoError {Ω : Set E} {r0 Theta epsilon delta : ℝ}
+ {N : ℕ} {C K L : ℝ} (g : PatchIterationGeometry (ι := ι) Ω r0 Theta epsilon N C K L)
+ (h : epsilon ≤ delta) : PatchIterationGeometry (ι := ι) Ω r0 Theta delta N C K L :=
+ { g with
+ energy_budget := fun k x hx => (g.energy_budget k x hx).trans h
+ mass_small := fun i x hx xi => (g.mass_small i x hx xi).trans
+ (mul_le_mul_of_nonneg_right h (sq_nonneg ‖g.frozen i x xi‖)) }
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PatchJetBounds.lean b/lean/OAI/Geometry/RCD/Coordinates/PatchJetBounds.lean
new file mode 100644
index 0000000000000000000000000000000000000000..01c157285a6c786403d440b1fa3e0c3c37c52c6b
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PatchJetBounds.lean
@@ -0,0 +1,347 @@
+import OAI.Geometry.RCD.Coordinates.FieldEstimates
+import OAI.Geometry.RCD.Coordinates.NormalizedJetStep
+
+namespace OAI
+
+/-!
+# Higher jets of finite cutoff-affine patch fields
+
+Only two terms survive in a higher product derivative: all derivatives
+on the cutoff, or one on the affine factor. Iterated Fréchet derivative
+bounds follow from the cutoff jets.
+-/
+
+open Finset Filter
+open scoped BigOperators ContDiff Topology
+
+noncomputable section
+
+attribute [local instance] Classical.propDecidable
+
+namespace RegularPointCoordinates
+
+section SinglePatch
+
+variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
+variable [NormedAddCommGroup F] [NormedSpace ℝ F]
+
+/-- The derivative of an affine patch is the fixed patch operator. -/
+theorem fderiv_affine_patch (D : E →L[ℝ] F) (c : E) :
+ fderiv ℝ (fun y => D (y - c)) = fun _ => D := by
+ funext x
+ exact ((D.hasFDerivAt.comp x ((hasFDerivAt_id x).sub_const c))).fderiv
+
+/-- All derivatives of an affine patch above order one vanish. -/
+theorem norm_iteratedFDeriv_affine_patch (D : E →L[ℝ] F) (c x : E) (m : ℕ) :
+ ‖iteratedFDeriv ℝ m (fun y => D (y - c)) x‖ =
+ if m = 0 then ‖D (x - c)‖ else if m = 1 then ‖D‖ else 0 := by
+ cases m with
+ | zero => simp [norm_iteratedFDeriv_zero]
+ | succ m =>
+ rw [← norm_iteratedFDeriv_fderiv, fderiv_affine_patch]
+ cases m with
+ | zero => simp [norm_iteratedFDeriv_zero]
+ | succ m => simp [iteratedFDeriv_succ_const]
+
+/-- Point-local version of the higher scalar-product bound. -/
+theorem norm_iteratedFDeriv_smul_le_at
+ {f : E → ℝ} {g : E → F} {x : E} {m : ℕ}
+ (hf : ContDiffAt ℝ m f x) (hg : ContDiffAt ℝ m g x) :
+ ‖iteratedFDeriv ℝ m (fun y => f y • g y) x‖ ≤
+ ∑ i ∈ Finset.range (m + 1), (m.choose i : ℝ) *
+ ‖iteratedFDeriv ℝ i f x‖ * ‖iteratedFDeriv ℝ (m - i) g x‖ := by
+ obtain ⟨u, hu, hfu⟩ := hf.contDiffOn le_rfl (by simp)
+ obtain ⟨v, hv, hgv⟩ := hg.contDiffOn le_rfl (by simp)
+ obtain ⟨s, hsu, hs, hx⟩ := mem_nhds_iff.mp (inter_mem hu hv)
+ have h := norm_iteratedFDerivWithin_smul_le
+ (hfu.mono (fun y hy => (hsu hy).1)) (hgv.mono (fun y hy => (hsu hy).2))
+ hs.uniqueDiffOn hx le_rfl
+ have heqf (q : ℕ) : iteratedFDerivWithin ℝ q f s x = iteratedFDeriv ℝ q f x :=
+ iteratedFDerivWithin_of_isOpen q hs hx
+ have heqg (q : ℕ) : iteratedFDerivWithin ℝ q g s x = iteratedFDeriv ℝ q g x :=
+ iteratedFDerivWithin_of_isOpen q hs hx
+ have heqfg : iteratedFDerivWithin ℝ m (fun y => f y • g y) s x =
+ iteratedFDeriv ℝ m (fun y => f y • g y) x := iteratedFDerivWithin_of_isOpen m hs hx
+ simpa only [heqf, heqg, heqfg] using h
+
+/-- The two surviving terms in a higher cutoff-affine derivative. -/
+theorem norm_iteratedFDeriv_cutoff_affine_le
+ (D : E →L[ℝ] F) (c x : E) {phi : E → ℝ} {m : ℕ}
+ (hphi : ContDiffAt ℝ (m + 1) phi x) :
+ ‖iteratedFDeriv ℝ (m + 1) (fun y => phi y • D (y - c)) x‖ ≤
+ ‖iteratedFDeriv ℝ (m + 1) phi x‖ * ‖D (x - c)‖ +
+ (m + 1 : ℝ) * ‖iteratedFDeriv ℝ m phi x‖ * ‖D‖ := by
+ have ha : ContDiffAt ℝ (m + 1) (fun y => D (y - c)) x :=
+ D.contDiff.contDiffAt.comp x (contDiffAt_id.sub contDiffAt_const)
+ have hp := norm_iteratedFDeriv_smul_le_at hphi ha
+ have hz : (∑ i ∈ Finset.range m, ((m + 1).choose i : ℝ) *
+ ‖iteratedFDeriv ℝ i phi x‖ *
+ ‖iteratedFDeriv ℝ (m + 1 - i) (fun y => D (y - c)) x‖) = 0 := by
+ apply Finset.sum_eq_zero
+ intro i hi
+ have hi' := Finset.mem_range.mp hi
+ have hzero : m + 1 - i ≠ 0 := by omega
+ have hone : m + 1 - i ≠ 1 := by omega
+ rw [norm_iteratedFDeriv_affine_patch]
+ simp only [ite_eq_right hzero, ite_eq_right hone, mul_zero]
+ rw [Finset.sum_range_succ, Finset.sum_range_succ, hz] at hp
+ simp only [Nat.sub_self, Nat.add_sub_cancel_left, Nat.choose_self,
+ Nat.choose_succ_self_right, Nat.cast_one, one_mul, zero_add,
+ norm_iteratedFDeriv_affine_patch] at hp
+ norm_num only [ite_true, ite_false, Nat.one_ne_zero, zero_ne_one] at hp
+ simpa only [add_comm, Nat.cast_add, Nat.cast_one] using hp
+
+/-- Multiplication by a cutoff cannot create derivative support outside
+the cutoff support, including at its boundary. -/
+theorem iteratedFDeriv_cutoff_affine_eq_zero_of_not_mem_tsupport
+ (D : E →L[ℝ] F) (c x : E) (phi : E → ℝ) (m : ℕ)
+ (hx : x ∉ tsupport phi) :
+ iteratedFDeriv ℝ m (fun y => phi y • D (y - c)) x = 0 := by
+ by_contra hne
+ apply hx
+ exact tsupport_smul_subset_left phi (fun y => D (y - c))
+ (support_iteratedFDeriv_subset (𝕜 := ℝ) m hne)
+
+/-- The derivative falling on the affine factor fits in the same
+Gevrey-two weight as the term falling wholly on the cutoff. -/
+theorem cutoff_affine_gevrey_weight_le {C : ℝ} (hC : 1 ≤ C) (m : ℕ) :
+ (m + 1 : ℝ) * C ^ (m + 1) * (m.factorial : ℝ) ^ 2 ≤
+ C ^ (m + 2) * ((m + 1).factorial : ℝ) ^ 2 := by
+ have hpow : C ^ (m + 1) ≤ C ^ (m + 2) := pow_le_pow_right₀ hC (by omega)
+ have hfac : (m + 1 : ℝ) * (m.factorial : ℝ) ^ 2 ≤
+ ((m + 1).factorial : ℝ) ^ 2 := by
+ rw [Nat.factorial_succ]
+ push_cast
+ have hm : (m + 1 : ℝ) ≤ (m + 1 : ℝ) ^ 2 := by
+ nlinarith [Nat.cast_nonneg (α := ℝ) m]
+ convert mul_le_mul_of_nonneg_right hm (sq_nonneg (m.factorial : ℝ)) using 1
+ ring
+ calc
+ _ = C ^ (m + 1) * ((m + 1 : ℝ) * (m.factorial : ℝ) ^ 2) := by ring
+ _ ≤ C ^ (m + 2) * ((m + 1).factorial : ℝ) ^ 2 :=
+ mul_le_mul hpow hfac (by positivity) (by positivity)
+
+/-- A cutoff-affine term obeys a uniform Gevrey-two estimate at every
+order, including its value. The small operator and displacement bounds
+are premises; the conclusion is derived from the actual product rule. -/
+theorem scaled_cutoff_affine_jet_le
+ (D : E →L[ℝ] F) (c x : E) {phi : E → ℝ} {m : ℕ}
+ {epsilon r L C : ℝ} (hepsilon : 0 ≤ epsilon) (hr : 0 < r)
+ (_hL : 0 ≤ L) (hC : 1 ≤ C) (hD : ‖D‖ ≤ epsilon)
+ (hvalue : ‖D (x - c)‖ ≤ epsilon * L * r)
+ (hphi : ContDiffAt ℝ m phi x)
+ (hcutoff : ∀ q ≤ m, r ^ q * ‖iteratedFDeriv ℝ q phi x‖ ≤
+ C ^ (q + 1) * (q.factorial : ℝ) ^ 2) :
+ r ^ m * ‖iteratedFDeriv ℝ m (fun y => phi y • D (y - c)) x‖ ≤
+ epsilon * r * (L + 1) * C ^ (m + 1) * (m.factorial : ℝ) ^ 2 := by
+ have hCzero : 0 ≤ C := zero_le_one.trans hC
+ cases m with
+ | zero =>
+ have hc : ‖phi x‖ ≤ C := by simpa [norm_iteratedFDeriv_zero] using hcutoff 0 (by omega)
+ simp only [pow_zero, one_mul, norm_iteratedFDeriv_zero, norm_smul,
+ zero_add, pow_one, Nat.factorial_zero, Nat.cast_one, one_pow, mul_one]
+ calc
+ _ ≤ C * (epsilon * L * r) := mul_le_mul hc hvalue (norm_nonneg _) hCzero
+ _ = epsilon * r * L * C := by ring
+ _ ≤ epsilon * r * (L + 1) * C := by gcongr; linarith
+ | succ m =>
+ have hraw := norm_iteratedFDeriv_cutoff_affine_le D c x hphi
+ have htop := hcutoff (m + 1) (by omega)
+ have hprev := hcutoff m (by omega)
+ have hfirst : r ^ (m + 1) *
+ (‖iteratedFDeriv ℝ (m + 1) phi x‖ * ‖D (x - c)‖) ≤
+ epsilon * r * L * (C ^ (m + 2) * ((m + 1).factorial : ℝ) ^ 2) := by
+ calc
+ _ = (r ^ (m + 1) * ‖iteratedFDeriv ℝ (m + 1) phi x‖) * ‖D (x - c)‖ := by ring
+ _ ≤ (C ^ (m + 2) * ((m + 1).factorial : ℝ) ^ 2) * (epsilon * L * r) :=
+ mul_le_mul htop hvalue (norm_nonneg _) (by positivity)
+ _ = _ := by ring
+ have hsecond : r ^ (m + 1) *
+ ((m + 1 : ℝ) * ‖iteratedFDeriv ℝ m phi x‖ * ‖D‖) ≤
+ epsilon * r * (C ^ (m + 2) * ((m + 1).factorial : ℝ) ^ 2) := by
+ calc
+ _ = (r * (m + 1 : ℝ) * (r ^ m * ‖iteratedFDeriv ℝ m phi x‖)) * ‖D‖ := by
+ rw [pow_succ]
+ ring
+ _ ≤ (r * (m + 1 : ℝ) * (C ^ (m + 1) * (m.factorial : ℝ) ^ 2)) * epsilon :=
+ mul_le_mul (mul_le_mul_of_nonneg_left hprev (by positivity)) hD
+ (norm_nonneg _) (by positivity)
+ _ = epsilon * r * ((m + 1 : ℝ) * C ^ (m + 1) * (m.factorial : ℝ) ^ 2) := by ring
+ _ ≤ _ := mul_le_mul_of_nonneg_left (cutoff_affine_gevrey_weight_le hC m)
+ (mul_nonneg hepsilon hr.le)
+ calc
+ _ ≤ r ^ (m + 1) *
+ (‖iteratedFDeriv ℝ (m + 1) phi x‖ * ‖D (x - c)‖ +
+ (m + 1 : ℝ) * ‖iteratedFDeriv ℝ m phi x‖ * ‖D‖) :=
+ mul_le_mul_of_nonneg_left hraw (by positivity)
+ _ ≤ epsilon * r * L * (C ^ (m + 2) * ((m + 1).factorial : ℝ) ^ 2) +
+ epsilon * r * (C ^ (m + 2) * ((m + 1).factorial : ℝ) ^ 2) := by
+ rw [mul_add]
+ exact add_le_add hfirst hsecond
+ _ = _ := by ring
+
+end SinglePatch
+
+section FiniteField
+
+variable {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+
+/-- The finite patch field has the sum of its actual patch derivatives. -/
+theorem iteratedFDeriv_patchField (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x : E) (m : ℕ)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ m (phi j) x) :
+ iteratedFDeriv ℝ m (patchField s phi D c) x =
+ ∑ j ∈ s, iteratedFDeriv ℝ m (fun y => phi j y • D j (y - c j)) x := by
+ apply iteratedFDeriv_fun_sum_apply
+ intro j hj
+ exact (hphi j hj).smul ((D j).contDiff.contDiffAt.comp x
+ (contDiffAt_id.sub contDiffAt_const))
+
+/-- In a positive derivative order, only two cutoff orders are needed. -/
+theorem norm_iteratedFDeriv_patchField_le (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x : E) (m : ℕ)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ (m + 1) (phi j) x) :
+ ‖iteratedFDeriv ℝ (m + 1) (patchField s phi D c) x‖ ≤
+ ∑ j ∈ s, (‖iteratedFDeriv ℝ (m + 1) (phi j) x‖ * ‖D j (x - c j)‖ +
+ (m + 1 : ℝ) * ‖iteratedFDeriv ℝ m (phi j) x‖ * ‖D j‖) := by
+ rw [iteratedFDeriv_patchField s phi D c x (m + 1) hphi]
+ exact (norm_sum_le _ _).trans (Finset.sum_le_sum fun j hj =>
+ norm_iteratedFDeriv_cutoff_affine_le (D j) (c j) x (hphi j hj))
+
+/-- Every higher field jet can be restricted to the active cutoffs. -/
+theorem iteratedFDeriv_patchField_eq_active (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x : E) (m : ℕ)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ m (phi j) x) :
+ iteratedFDeriv ℝ m (patchField s phi D c) x =
+ iteratedFDeriv ℝ m (patchField (s.filter (fun j => x ∈ tsupport (phi j))) phi D c) x := by
+ classical
+ rw [iteratedFDeriv_patchField s phi D c x m hphi,
+ iteratedFDeriv_patchField _ phi D c x m
+ (fun j hj => hphi j (Finset.mem_filter.mp hj).1)]
+ symm
+ apply Finset.sum_subset (Finset.filter_subset _ _)
+ intro j hj hnot
+ have hx : x ∉ tsupport (phi j) := by
+ intro hx
+ exact hnot (Finset.mem_filter.mpr ⟨hj, hx⟩)
+ exact iteratedFDeriv_cutoff_affine_eq_zero_of_not_mem_tsupport (D j) (c j) x (phi j) m hx
+
+/-- Summing the actual patch jets costs only the number of active terms. -/
+theorem scaled_patchField_jet_le (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x : E) (m : ℕ)
+ {epsilon r L C : ℝ} (hepsilon : 0 ≤ epsilon) (hr : 0 < r)
+ (hL : 0 ≤ L) (hC : 1 ≤ C)
+ (hD : ∀ j ∈ s, ‖D j‖ ≤ epsilon)
+ (hvalue : ∀ j ∈ s, ‖D j (x - c j)‖ ≤ epsilon * L * r)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ m (phi j) x)
+ (hcutoff : ∀ j ∈ s, ∀ q ≤ m,
+ r ^ q * ‖iteratedFDeriv ℝ q (phi j) x‖ ≤ C ^ (q + 1) * (q.factorial : ℝ) ^ 2) :
+ r ^ m * ‖iteratedFDeriv ℝ m (patchField s phi D c) x‖ ≤
+ epsilon * r * (s.card : ℝ) * (L + 1) * C ^ (m + 1) * (m.factorial : ℝ) ^ 2 := by
+ rw [iteratedFDeriv_patchField s phi D c x m hphi]
+ calc
+ _ ≤ r ^ m * ∑ j ∈ s, ‖iteratedFDeriv ℝ m (fun y => phi j y • D j (y - c j)) x‖ :=
+ mul_le_mul_of_nonneg_left (norm_sum_le _ _) (by positivity)
+ _ = ∑ j ∈ s, r ^ m * ‖iteratedFDeriv ℝ m (fun y => phi j y • D j (y - c j)) x‖ :=
+ Finset.mul_sum _ _ _
+ _ ≤ ∑ _j ∈ s, epsilon * r * (L + 1) * C ^ (m + 1) * (m.factorial : ℝ) ^ 2 :=
+ Finset.sum_le_sum fun j hj => scaled_cutoff_affine_jet_le (D j) (c j) x
+ hepsilon hr hL hC (hD j hj) (hvalue j hj) (hphi j hj) (hcutoff j hj)
+ _ = _ := by simp only [Finset.sum_const, nsmul_eq_mul]; ring
+
+/-- A fixed base absorbs the overlap and center-displacement constants. -/
+def patchJetBase (N L C : ℝ) : ℝ := C * max 1 (N * (L + 1))
+
+theorem patchJetBase_ge_one {N L C : ℝ} (hC : 1 ≤ C) :
+ 1 ≤ patchJetBase N L C := by
+ unfold patchJetBase
+ simpa using mul_le_mul hC (le_max_left 1 (N * (L + 1)))
+ zero_le_one (zero_le_one.trans hC)
+
+/-- Uniform all-order Gevrey-two field estimate, with base independent
+of the derivative order and the size of the ambient net. -/
+theorem patchField_scaled_gevrey_two (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x : E) (m : ℕ)
+ {epsilon r L C N : ℝ} (hepsilon : 0 ≤ epsilon) (hr : 0 < r)
+ (hL : 0 ≤ L) (hC : 1 ≤ C) (hcard : (s.card : ℝ) ≤ N)
+ (hD : ∀ j ∈ s, ‖D j‖ ≤ epsilon)
+ (hvalue : ∀ j ∈ s, ‖D j (x - c j)‖ ≤ epsilon * L * r)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ m (phi j) x)
+ (hcutoff : ∀ j ∈ s, ∀ q ≤ m,
+ r ^ q * ‖iteratedFDeriv ℝ q (phi j) x‖ ≤ C ^ (q + 1) * (q.factorial : ℝ) ^ 2) :
+ r ^ m * ‖iteratedFDeriv ℝ m (patchField s phi D c) x‖ ≤
+ epsilon * r * (patchJetBase N L C) ^ (m + 1) * (m.factorial : ℝ) ^ 2 := by
+ have hM : 1 ≤ max 1 (N * (L + 1)) := le_max_left _ _
+ have hcoeff : (s.card : ℝ) * (L + 1) ≤ (max 1 (N * (L + 1))) ^ (m + 1) :=
+ ((mul_le_mul_of_nonneg_right hcard (by linarith)).trans (le_max_right _ _)).trans
+ (le_self_pow₀ hM (by omega))
+ have hweight : (s.card : ℝ) * (L + 1) * C ^ (m + 1) ≤
+ (patchJetBase N L C) ^ (m + 1) := by
+ unfold patchJetBase
+ rw [mul_pow]
+ simpa only [mul_comm] using mul_le_mul_of_nonneg_right hcoeff
+ (pow_nonneg (zero_le_one.trans hC) _)
+ calc
+ _ ≤ epsilon * r * (s.card : ℝ) * (L + 1) * C ^ (m + 1) * (m.factorial : ℝ) ^ 2 :=
+ scaled_patchField_jet_le s phi D c x m hepsilon hr hL hC hD hvalue hphi hcutoff
+ _ = (epsilon * r) * ((s.card : ℝ) * (L + 1) * C ^ (m + 1)) * (m.factorial : ℝ) ^ 2 := by ring
+ _ ≤ _ := mul_le_mul_of_nonneg_right
+ (mul_le_mul_of_nonneg_left hweight (mul_nonneg hepsilon hr.le)) (sq_nonneg _)
+
+/-- The uniform estimate for the full field counts only cutoffs whose
+closed supports contain the testing point. -/
+theorem patchField_scaled_gevrey_two_active (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (x : E) (m : ℕ)
+ {epsilon r L C N : ℝ} (hepsilon : 0 ≤ epsilon) (hr : 0 < r)
+ (hL : 0 ≤ L) (hC : 1 ≤ C)
+ (hcard : ((s.filter (fun j => x ∈ tsupport (phi j))).card : ℝ) ≤ N)
+ (hD : ∀ j ∈ s, x ∈ tsupport (phi j) → ‖D j‖ ≤ epsilon)
+ (hvalue : ∀ j ∈ s, x ∈ tsupport (phi j) → ‖D j (x - c j)‖ ≤ epsilon * L * r)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ m (phi j) x)
+ (hcutoff : ∀ j ∈ s, x ∈ tsupport (phi j) → ∀ q ≤ m,
+ r ^ q * ‖iteratedFDeriv ℝ q (phi j) x‖ ≤ C ^ (q + 1) * (q.factorial : ℝ) ^ 2) :
+ r ^ m * ‖iteratedFDeriv ℝ m (patchField s phi D c) x‖ ≤
+ epsilon * r * (patchJetBase N L C) ^ (m + 1) * (m.factorial : ℝ) ^ 2 := by
+ classical
+ rw [iteratedFDeriv_patchField_eq_active s phi D c x m hphi]
+ exact patchField_scaled_gevrey_two _ phi D c x m hepsilon hr hL hC hcard
+ (fun j hj => hD j (Finset.mem_filter.mp hj).1 (Finset.mem_filter.mp hj).2)
+ (fun j hj => hvalue j (Finset.mem_filter.mp hj).1 (Finset.mem_filter.mp hj).2)
+ (fun j hj => hphi j (Finset.mem_filter.mp hj).1)
+ (fun j hj => hcutoff j (Finset.mem_filter.mp hj).1 (Finset.mem_filter.mp hj).2)
+
+/-- Every repeated directional derivative obeys the same uniform field
+bound, with the expected power of the direction norm. -/
+theorem patchField_scaled_directional_gevrey_two_active
+ (s : Finset ι) (phi : ι → E → ℝ) (D : ι → E →L[ℝ] E)
+ (c : ι → E) (x xi : E) (m : ℕ)
+ {epsilon r L C N : ℝ} (hepsilon : 0 ≤ epsilon) (hr : 0 < r)
+ (hL : 0 ≤ L) (hC : 1 ≤ C)
+ (hcard : ((s.filter (fun j => x ∈ tsupport (phi j))).card : ℝ) ≤ N)
+ (hD : ∀ j ∈ s, x ∈ tsupport (phi j) → ‖D j‖ ≤ epsilon)
+ (hvalue : ∀ j ∈ s, x ∈ tsupport (phi j) → ‖D j (x - c j)‖ ≤ epsilon * L * r)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ m (phi j) x)
+ (hcutoff : ∀ j ∈ s, x ∈ tsupport (phi j) → ∀ q ≤ m,
+ r ^ q * ‖iteratedFDeriv ℝ q (phi j) x‖ ≤ C ^ (q + 1) * (q.factorial : ℝ) ^ 2) :
+ r ^ m * ‖iteratedFDeriv ℝ m (patchField s phi D c) x (fun _ => xi)‖ ≤
+ epsilon * r * (patchJetBase N L C) ^ (m + 1) *
+ (m.factorial : ℝ) ^ 2 * ‖xi‖ ^ m := by
+ have hd : ‖iteratedFDeriv ℝ m (patchField s phi D c) x (fun _ => xi)‖ ≤
+ ‖iteratedFDeriv ℝ m (patchField s phi D c) x‖ * ‖xi‖ ^ m := by
+ simpa using (iteratedFDeriv ℝ m (patchField s phi D c) x).le_opNorm
+ (fun _ => xi)
+ calc
+ _ ≤ r ^ m * (‖iteratedFDeriv ℝ m (patchField s phi D c) x‖ * ‖xi‖ ^ m) :=
+ mul_le_mul_of_nonneg_left hd (by positivity)
+ _ = (r ^ m * ‖iteratedFDeriv ℝ m (patchField s phi D c) x‖) * ‖xi‖ ^ m := by ring
+ _ ≤ _ := mul_le_mul_of_nonneg_right
+ (patchField_scaled_gevrey_two_active s phi D c x m
+ hepsilon hr hL hC hcard hD hvalue hphi hcutoff) (by positivity)
+
+end FiniteField
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PatchLocalization.lean b/lean/OAI/Geometry/RCD/Coordinates/PatchLocalization.lean
new file mode 100644
index 0000000000000000000000000000000000000000..97f58efd70e767396aadcad035154f5609fcd101
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PatchLocalization.lean
@@ -0,0 +1,217 @@
+import OAI.Geometry.RCD.Coordinates.PatchCover
+import Mathlib.Topology.Algebra.Support
+import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap
+import Mathlib.Analysis.SpecialFunctions.Pow.Real
+
+namespace OAI
+
+/-!
+# Localization of active coordinate patches
+
+A cutoff support bounds the finely normalized displacement. Coarse harmonic
+separation and sublinear growth of the normalizations then bound the original
+metric distance. The squared growth hypothesis below is the exponent-one
+bound for squared norms (equivalently, exponent one-half for norms).
+-/
+
+open Set Metric MeasureTheory
+open scoped NNReal ENNReal
+
+noncomputable section
+
+attribute [local instance] Classical.propDecidable
+
+namespace RegularPointCoordinates
+
+variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
+ [NormedAddCommGroup F] [NormedSpace ℝ F]
+
+/-- Membership in the actual topological support of a normalized cutoff
+bounds its normalized displacement, including boundary support points. -/
+theorem normalized_cutoff_support_norm_le (T : E →L[ℝ] F) (c x : E)
+ (psi : F → ℝ) {r L : ℝ} (hr : 0 < r)
+ (hsupport : tsupport psi ⊆ Metric.closedBall 0 L)
+ (hx : x ∈ tsupport (fun P => psi (r⁻¹ • T (P - c)))) :
+ ‖T (x - c)‖ ≤ L * r := by
+ have hcont : Continuous (fun P => r⁻¹ • T (P - c)) := by fun_prop
+ have hm := tsupport_comp_subset_preimage psi hcont hx
+ have hb := hsupport hm
+ have hn : r⁻¹ * ‖T (x - c)‖ ≤ L := by
+ simpa only [Metric.mem_closedBall, dist_zero_right, norm_smul,
+ Real.norm_of_nonneg (inv_nonneg.mpr hr.le)] using hb
+ have hh := mul_le_mul_of_nonneg_left hn hr.le
+ rw [← mul_assoc, mul_inv_cancel₀ hr.ne', one_mul] at hh
+ simpa only [mul_comm] using hh
+
+/-- A coarse lower bound and sublinear normalization growth localize a
+fine-scale displacement. The estimate is uniform in the scale `r`. -/
+theorem distance_le_of_normalization_growth {d r c M L A B : ℝ}
+ (hd : 0 ≤ d) (hr : 0 < r) (hc : 0 < c) (hL : 0 ≤ L)
+ (hA : 0 ≤ A) (hB : 0 ≤ B)
+ (hsmall : A ≤ L * r) (hseparate : c * d ≤ B)
+ (hgrowth : B ^ 2 ≤ M ^ 2 * (d / r) * A ^ 2) :
+ d ≤ (M * L / c) ^ 2 * r := by
+ by_cases hz : d = 0
+ · rw [hz]
+ positivity
+ have hdpos : 0 < d := lt_of_le_of_ne hd (Ne.symm hz)
+ have hsep2 := (sq_le_sq₀ (mul_nonneg hc.le hd) hB).mpr hseparate
+ have hsmall2 := (sq_le_sq₀ hA (mul_nonneg hL hr.le)).mpr hsmall
+ have hcoef : 0 ≤ M ^ 2 * (d / r) := mul_nonneg (sq_nonneg _) (div_nonneg hd hr.le)
+ have hg := hgrowth.trans (mul_le_mul_of_nonneg_left hsmall2 hcoef)
+ have hid : M ^ 2 * (d / r) * (L * r) ^ 2 = (M * L) ^ 2 * r * d := by
+ field_simp [hr.ne']
+ rw [hid] at hg
+ have hcancel : c ^ 2 * d ≤ (M * L) ^ 2 * r := by
+ apply (mul_le_mul_iff_left₀ hdpos).mp
+ calc
+ _ = (c * d) ^ 2 := by ring
+ _ ≤ B ^ 2 := hsep2
+ _ ≤ _ := hg
+ have hquot : d ≤ ((M * L) ^ 2 * r) / c ^ 2 := by
+ apply (le_div_iff₀ (sq_pos_of_pos hc)).mpr
+ simpa only [mul_comm] using hcancel
+ convert hquot using 1
+ ring
+
+variable {X : Type*} [MetricSpace X]
+
+/-- Any slow norm-growth exponent at most one-half gives the squared
+growth bound used in localization, at all coarser scales. -/
+theorem squared_growth_of_slow_norm_growth (T S : E →L[ℝ] F) (w : E)
+ {d r M a : ℝ} (hr : 0 < r) (hdr : r ≤ d) (hM : 0 ≤ M) (ha : a ≤ 1 / 2)
+ (hslow : ‖S w‖ ≤ M * (d / r) ^ a * ‖T w‖) :
+ ‖S w‖ ^ 2 ≤ M ^ 2 * (d / r) * ‖T w‖ ^ 2 := by
+ have hratio : 1 ≤ d / r := (le_div_iff₀ hr).mpr (by simpa using hdr)
+ have hratio0 : 0 ≤ d / r := (by norm_num : (0 : ℝ) ≤ 1).trans hratio
+ have hpower : ((d / r) ^ a) ^ (2 : ℕ) ≤ d / r := by
+ rw [← Real.rpow_mul_natCast hratio0 a 2]
+ simpa only [Real.rpow_one] using
+ Real.rpow_le_rpow_of_exponent_le hratio (show a * (2 : ℕ) ≤ 1 by norm_num; linarith)
+ have hs := (sq_le_sq₀ (norm_nonneg _)
+ (mul_nonneg (mul_nonneg hM (Real.rpow_nonneg hratio0 _)) (norm_nonneg _))).mpr hslow
+ calc
+ _ ≤ (M * (d / r) ^ a * ‖T w‖) ^ 2 := hs
+ _ = M ^ 2 * (((d / r) ^ a) ^ (2 : ℕ)) * ‖T w‖ ^ 2 := by ring
+ _ ≤ _ := mul_le_mul_of_nonneg_right
+ (mul_le_mul_of_nonneg_left hpower (sq_nonneg M)) (sq_nonneg _)
+
+/-- Active support forces an original-metric distance bound. Separation
+and comparison are only required when the distance exceeds the fine scale,
+so nearby pairs need no coarse-scale selection. -/
+theorem active_cutoff_distance_le (u : X → E) (T S : E →L[ℝ] F)
+ (psi : F → ℝ) (x y : X) {r c M L : ℝ}
+ (hr : 0 < r) (hc : 0 < c) (hL : 0 ≤ L)
+ (hsupport : tsupport psi ⊆ Metric.closedBall 0 L)
+ (hactive : u x ∈ tsupport (fun P => psi (r⁻¹ • T (P - u y))))
+ (hseparate : r < dist x y → c * dist x y ≤ ‖S (u x - u y)‖)
+ (hgrowth : r < dist x y →
+ ‖S (u x - u y)‖ ^ 2 ≤ M ^ 2 * (dist x y / r) * ‖T (u x - u y)‖ ^ 2) :
+ dist x y ≤ max 1 ((M * L / c) ^ 2) * r := by
+ by_cases hnear : dist x y ≤ r
+ · exact hnear.trans (by simpa only [one_mul] using
+ mul_le_mul_of_nonneg_right (le_max_left 1 ((M * L / c) ^ 2)) hr.le)
+ have hfar : r < dist x y := lt_of_not_ge hnear
+ have hloc := distance_le_of_normalization_growth dist_nonneg hr hc hL
+ (norm_nonneg _) (norm_nonneg _)
+ (normalized_cutoff_support_norm_le T (u y) (u x) psi hr hsupport hactive)
+ (hseparate hfar) (hgrowth hfar)
+ exact hloc.trans (mul_le_mul_of_nonneg_right (le_max_right _ _) hr.le)
+
+/-- The same localization, stated directly with the manuscript's slow
+power growth instead of its squared consequence. -/
+theorem active_cutoff_distance_le_of_slow_growth (u : X → E) (T S : E →L[ℝ] F)
+ (psi : F → ℝ) (x y : X) {r c M L a : ℝ}
+ (hr : 0 < r) (hc : 0 < c) (hM : 0 ≤ M) (hL : 0 ≤ L) (ha : a ≤ 1 / 2)
+ (hsupport : tsupport psi ⊆ Metric.closedBall 0 L)
+ (hactive : u x ∈ tsupport (fun P => psi (r⁻¹ • T (P - u y))))
+ (hseparate : r < dist x y → c * dist x y ≤ ‖S (u x - u y)‖)
+ (hslow : r < dist x y →
+ ‖S (u x - u y)‖ ≤ M * (dist x y / r) ^ a * ‖T (u x - u y)‖) :
+ dist x y ≤ max 1 ((M * L / c) ^ 2) * r := by
+ apply active_cutoff_distance_le u T S psi x y hr hc hL hsupport hactive hseparate
+ intro hfar
+ exact squared_growth_of_slow_norm_growth T S (u x - u y) hr hfar.le hM ha (hslow hfar)
+
+/-- The cutoff equals one on the fine normalized core. -/
+theorem normalized_cutoff_eq_one_of_norm_le (T : E →L[ℝ] F) (psi : F → ℝ)
+ (c P : E) {r L : ℝ} (hr : 0 < r)
+ (hcore : ∀ v, ‖v‖ ≤ L → psi v = 1)
+ (hnorm : ‖T (P - c)‖ ≤ L * r) :
+ psi (r⁻¹ • T (P - c)) = 1 := by
+ apply hcore
+ rw [norm_smul, Real.norm_of_nonneg (inv_nonneg.mpr hr.le)]
+ have h := mul_le_mul_of_nonneg_left hnorm (inv_nonneg.mpr hr.le)
+ calc
+ _ ≤ r⁻¹ * (L * r) := h
+ _ = L := by field_simp [hr.ne']
+
+/-- Net covering produces an active weight-one patch. Its enlarged source
+ball covers the testing ball, exactly as required for the lower cumulative
+mass comparison. -/
+theorem exists_weight_one_covering_patch (A : Set X) (hA : TotallyBounded A)
+ (r : ℝ≥0) (hr : 0 < r) (u : X → E) (T : X → E →L[ℝ] F)
+ (psi : F → ℝ) (hcore : ∀ v, ‖v‖ ≤ 2 → psi v = 1)
+ (hnear : ∀ x ∈ A, ∀ y ∈ maximalPatchNet r A, dist x y ≤ r →
+ ‖T y (u x - u y)‖ ≤ 2 * r)
+ (x : X) (hx : x ∈ A) {L : ℝ} (hL : 2 ≤ L) :
+ ∃ y ∈ maximalPatchNet r A,
+ dist x y ≤ r ∧ psi ((r : ℝ)⁻¹ • T y (u x - u y)) = 1 ∧
+ u x ∈ tsupport (fun P => psi ((r : ℝ)⁻¹ • T y (P - u y))) ∧
+ Metric.ball x r ⊆ Metric.ball y (L * r) := by
+ obtain ⟨y, hy, hxy⟩ := maximalPatchNet_covers (ne_of_gt hr) hA x hx
+ have hr' : 0 < (r : ℝ) := by exact_mod_cast hr
+ have hvalue := normalized_cutoff_eq_one_of_norm_le (T y) psi (u y) (u x)
+ hr' hcore (hnear x hx y hy hxy)
+ refine ⟨y, hy, hxy, hvalue, ?_, ?_⟩
+ · apply subset_tsupport
+ change psi ((r : ℝ)⁻¹ • T y (u x - u y)) ≠ 0
+ rw [hvalue]
+ norm_num
+ · apply Metric.ball_subset_ball'
+ have hm := mul_le_mul_of_nonneg_right hL hr'.le
+ linarith
+
+section Volume
+
+variable [MeasurableSpace X] [OpensMeasurableSpace X]
+
+/-- The overlap bound for the actual normalized cutoffs: active-center
+distance is derived from support, harmonic separation, and normalization
+growth before the disjoint-ball volume count is applied. -/
+theorem active_normalized_cutoff_card_le (μ : Measure X) (A : Set X)
+ (r : ℝ≥0) (u : X → E) (T S : X → E →L[ℝ] F) (psi : F → ℝ)
+ (x : X) (n : ℕ) (hr : 0 < r) {c M L a b : ℝ}
+ (hc : 0 < c) (hL : 0 ≤ L) (ha : 0 < a)
+ (hsupport : tsupport psi ⊆ Metric.closedBall 0 L)
+ (hseparate : ∀ y ∈ maximalPatchNet r A, (r : ℝ) < dist x y →
+ c * dist x y ≤ ‖S y (u x - u y)‖)
+ (hgrowth : ∀ y ∈ maximalPatchNet r A, (r : ℝ) < dist x y →
+ ‖S y (u x - u y)‖ ^ 2 ≤ M ^ 2 * (dist x y / r) * ‖T y (u x - u y)‖ ^ 2)
+ (hlower : ∀ y ∈ maximalPatchNet r A,
+ a * ((r : ℝ) / 2) ^ n ≤ μ.real (Metric.ball y (r / 2)))
+ (hupper : μ.real (Metric.ball x (max 1 ((M * L / c) ^ 2) * r + r / 2)) ≤
+ b * (max 1 ((M * L / c) ^ 2) * r + r / 2) ^ n)
+ (hfinite : μ (Metric.ball x (max 1 ((M * L / c) ^ 2) * r + r / 2)) ≠ ∞) :
+ ((maximalPatchNet r A).filter (fun y =>
+ u x ∈ tsupport (fun P => psi ((r : ℝ)⁻¹ • T y (P - u y))))).card ≤
+ ⌈b / a * (2 * max 1 ((M * L / c) ^ 2) + 1) ^ n⌉₊ := by
+ classical
+ apply active_maximalPatchNet_card_le μ A r x _ n hr ha
+ · intro y hy hactive
+ have hh := active_cutoff_distance_le u (T y) (S y) psi x y
+ (show 0 < (r : ℝ) by exact_mod_cast hr) hc hL hsupport hactive
+ (hseparate y hy) (hgrowth y hy)
+ simpa only [dist_comm] using hh
+ · intro y hy _
+ exact hlower y hy
+ · exact hupper
+ · exact hfinite
+
+end Volume
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PatchSecondDerivative.lean b/lean/OAI/Geometry/RCD/Coordinates/PatchSecondDerivative.lean
new file mode 100644
index 0000000000000000000000000000000000000000..f63d9415cd580cdde9b10fa93b6b7e9717b35723
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PatchSecondDerivative.lean
@@ -0,0 +1,216 @@
+import OAI.Geometry.RCD.Coordinates.PatchDirectionalBounds
+import Mathlib.Analysis.Calculus.ContDiff.Operations
+
+namespace OAI
+
+/-!
+# The second directional derivative of the patch field
+
+This proves the actual derivative formula and the frozen dual-norm bound
+in `re:field-second`. The only nonzero terms differentiate the cutoff twice,
+or differentiate the cutoff and the affine factor once each.
+-/
+
+open Filter
+open scoped Topology BigOperators InnerProductSpace
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+section Calculus
+
+variable {E F ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
+ [NormedAddCommGroup F] [NormedSpace ℝ F]
+
+/-- The second directional derivative of a cutoff times an affine map. -/
+theorem cutoff_affine_second_directional (phi : E → ℝ) (D : E →L[ℝ] F)
+ (c P xi : E) (hphi : ContDiffAt ℝ 2 phi P) :
+ fderiv ℝ (fun y => fderiv ℝ (fun z => phi z • D (z - c)) y xi) P xi =
+ fderiv ℝ (fun y => fderiv ℝ phi y xi) P xi • D (P - c) +
+ (2 * fderiv ℝ phi P xi) • D xi := by
+ have hdphi := hphi.differentiableAt (by norm_num)
+ have hddphi := (hphi.fderiv_right (m := 1) (by norm_num)).differentiableAt
+ (by norm_num)
+ have hdxi := hddphi.hasFDerivAt.clm_apply (hasFDerivAt_const xi P)
+ have hD : HasFDerivAt (fun y => D (y - c)) D P := by
+ simpa [Function.comp_def] using D.hasFDerivAt.comp P ((hasFDerivAt_id P).sub_const c)
+ have hterm := (hdphi.hasFDerivAt.smul_const (D xi)).add (hdxi.fun_smul hD)
+ have hevent : ∀ᶠ y in 𝓝 P, ContDiffAt ℝ 2 phi y := hphi.eventually (by norm_num)
+ have heq : (fun y => phi y • D xi + fderiv ℝ phi y xi • D (y - c)) =ᶠ[𝓝 P]
+ (fun y => fderiv ℝ (fun z => phi z • D (z - c)) y xi) := by
+ filter_upwards [hevent] with y hy
+ have hDy : HasFDerivAt (fun z => D (z - c)) D y := by
+ simpa [Function.comp_def] using D.hasFDerivAt.comp y ((hasFDerivAt_id y).sub_const c)
+ rw [((hy.differentiableAt (by norm_num)).hasFDerivAt.fun_smul hDy).fderiv]
+ simp
+ have hactual := hterm.congr_of_eventuallyEq heq.symm
+ rw [hactual.fderiv]
+ simp only [add_apply, ContinuousLinearMap.smulRight_apply, smul_apply,
+ ContinuousLinearMap.comp_apply, zero_apply, map_zero,
+ zero_add, ContinuousLinearMap.flip_apply]
+ have hdxi_apply : fderiv ℝ (fun y => fderiv ℝ phi y xi) P xi =
+ fderiv ℝ (fderiv ℝ phi) P xi xi := by
+ rw [hdxi.fderiv]
+ simp
+ rw [hdxi_apply]
+ module
+
+/-- Finite sums commute with the actual second directional derivative. -/
+theorem second_directional_finset_sum (s : Finset ι) (f : ι → E → F) (P xi : E)
+ (hf : ∀ j ∈ s, ContDiffAt ℝ 2 (f j) P) :
+ fderiv ℝ (fun y => fderiv ℝ (fun z => ∑ j ∈ s, f j z) y xi) P xi =
+ ∑ j ∈ s, fderiv ℝ (fun y => fderiv ℝ (f j) y xi) P xi := by
+ have hdiff : ∀ j ∈ s, DifferentiableAt ℝ (fun y => fderiv ℝ (f j) y xi) P := by
+ intro j hj
+ exact ((hf j hj).fderiv_right (m := 1) (by norm_num)).differentiableAt
+ (by norm_num) |>.clm_apply (differentiableAt_const xi)
+ have hevent : ∀ᶠ y in 𝓝 P, ∀ j ∈ s, ContDiffAt ℝ 2 (f j) y :=
+ (eventually_all_finset s).2 (fun j hj => (hf j hj).eventually (by norm_num))
+ have heq : (fun y => ∑ j ∈ s, fderiv ℝ (f j) y xi) =ᶠ[𝓝 P]
+ (fun y => fderiv ℝ (fun z => ∑ j ∈ s, f j z) y xi) := by
+ filter_upwards [hevent] with y hy
+ rw [fderiv_fun_sum (fun j hj => (hy j hj).differentiableAt (by norm_num))]
+ simp
+ have hactual := (HasFDerivAt.fun_sum (fun j hj => (hdiff j hj).hasFDerivAt)).congr_of_eventuallyEq
+ heq.symm
+ rw [hactual.fderiv]
+ simp
+
+end Calculus
+
+variable {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+
+/-- The full finite-patch formula from local twice continuous differentiability
+of the cutoff functions. -/
+theorem patchField_second_directional (s : Finset ι) (phi : ι → E → ℝ)
+ (D : ι → E →L[ℝ] E) (c : ι → E) (P xi : E)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ 2 (phi j) P) :
+ fderiv ℝ (fun y => fderiv ℝ (patchField s phi D c) y xi) P xi =
+ ∑ j ∈ s, (fderiv ℝ (fun y => fderiv ℝ (phi j) y xi) P xi • D j (P - c j) +
+ (2 * fderiv ℝ (phi j) P xi) • D j xi) := by
+ have hterm : ∀ j ∈ s, ContDiffAt ℝ 2 (fun z => phi j z • D j (z - c j)) P := by
+ intro j hj
+ exact (hphi j hj).smul ((D j).contDiff.contDiffAt.comp P
+ (contDiffAt_id.sub contDiffAt_const))
+ change fderiv ℝ (fun y => fderiv ℝ
+ (fun z => ∑ j ∈ s, phi j z • D j (z - c j)) y xi) P xi = _
+ rw [second_directional_finset_sum s _ P xi hterm]
+ exact Finset.sum_congr rfl (fun j hj => cutoff_affine_second_directional
+ (phi j) (D j) (c j) P xi (hphi j hj))
+
+variable [CompleteSpace E]
+
+/-- A derivative-weighted sum of mass values retains the square root of
+the total directional mass. -/
+theorem frozen_patch_directional_sum_le (T : E ≃L[ℝ] E) (s : Finset ι)
+ (D : ι → E →L[ℝ] E) (a : ι → ℝ) (xi : E) {N : ℕ} {epsilon A : ℝ}
+ (hN : s.card ≤ N) (hepsilon : 0 ≤ epsilon) (hA : 0 ≤ A)
+ (hD : ∀ j ∈ s, (D j).IsPositive)
+ (hZ : ∀ x, ⟪x, patchMass s D x⟫_ℝ ≤ epsilon * ‖T x‖ ^ 2)
+ (ha : ∀ j ∈ s, |a j| ≤ A) :
+ ‖(T.symm : E →L[ℝ] E).adjoint (patchCutoffError s D (fun _ => xi) a)‖ ≤
+ A * Real.sqrt epsilon * Real.sqrt (N : ℝ) *
+ Real.sqrt ⟪xi, patchMass s D xi⟫_ℝ := by
+ have hsmall : ∀ j ∈ s, ∀ x, ⟪x, D j x⟫_ℝ ≤ epsilon * ‖T x‖ ^ 2 :=
+ fun j hj x => (patch_form_le_mass s D hD hj x).trans (hZ x)
+ have hcs := Real.sum_mul_le_sqrt_mul_sqrt s (fun _ => (1 : ℝ))
+ (fun j => Real.sqrt ⟪xi, D j xi⟫_ℝ)
+ have hsq : (∑ j ∈ s, (Real.sqrt ⟪xi, D j xi⟫_ℝ) ^ 2) =
+ ⟪xi, patchMass s D xi⟫_ℝ := by
+ rw [inner_patchMass]
+ exact Finset.sum_congr rfl (fun j hj => Real.sq_sqrt ((hD j hj).inner_nonneg_right xi))
+ rw [hsq] at hcs
+ simp only [one_mul, one_pow, Finset.sum_const, nsmul_eq_mul, mul_one] at hcs
+ have hsum : (∑ j ∈ s, Real.sqrt ⟪xi, D j xi⟫_ℝ) ≤
+ Real.sqrt (N : ℝ) * Real.sqrt ⟪xi, patchMass s D xi⟫_ℝ :=
+ hcs.trans (mul_le_mul_of_nonneg_right (Real.sqrt_le_sqrt (by exact_mod_cast hN))
+ (Real.sqrt_nonneg _))
+ calc
+ _ ≤ ∑ j ∈ s, |a j| * (Real.sqrt epsilon * Real.sqrt ⟪xi, D j xi⟫_ℝ) :=
+ frozen_positive_patch_sum_norm_le T s D (fun _ => xi) a hepsilon hD hsmall
+ _ ≤ ∑ j ∈ s, A * (Real.sqrt epsilon * Real.sqrt ⟪xi, D j xi⟫_ℝ) := by
+ exact Finset.sum_le_sum (fun j hj => mul_le_mul_of_nonneg_right (ha j hj) (by positivity))
+ _ = A * Real.sqrt epsilon * ∑ j ∈ s, Real.sqrt ⟪xi, D j xi⟫_ℝ := by
+ simp only [mul_assoc, Finset.mul_sum]
+ _ ≤ A * Real.sqrt epsilon * (Real.sqrt (N : ℝ) * Real.sqrt ⟪xi, patchMass s D xi⟫_ℝ) :=
+ mul_le_mul_of_nonneg_left hsum (by positivity)
+ _ = _ := by ring
+
+/-- The second derivative estimate with the small factor retained. -/
+theorem patchField_second_directional_frozen_le_sqrt (T : E ≃L[ℝ] E) (s : Finset ι)
+ (phi : ι → E → ℝ) (D : ι → E →L[ℝ] E) (c : ι → E) (P xi : E) {N : ℕ}
+ {epsilon C K r energy : ℝ} (hN : s.card ≤ N)
+ (hepsilon : 0 ≤ epsilon) (hC : 0 ≤ C) (hK : 0 ≤ K)
+ (hr : 0 < r) (henergy : 0 ≤ energy)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ 2 (phi j) P)
+ (hD : ∀ j ∈ s, (D j).IsPositive)
+ (hZ : ∀ x, ⟪x, patchMass s D x⟫_ℝ ≤ epsilon * ‖T x‖ ^ 2)
+ (hw : ∀ j ∈ s, ⟪P - c j, D j (P - c j)⟫_ℝ ≤ C * r ^ 2 * energy)
+ (hfirst : ∀ j ∈ s, |fderiv ℝ (phi j) P xi| ≤ K / r * ‖T xi‖)
+ (hsecond : ∀ j ∈ s, |fderiv ℝ (fun y => fderiv ℝ (phi j) y xi) P xi| ≤
+ K / r ^ 2 * ‖T xi‖ ^ 2) :
+ r * ‖(T.symm : E →L[ℝ] E).adjoint
+ (fderiv ℝ (fun y => fderiv ℝ (patchField s phi D c) y xi) P xi)‖ ≤
+ Real.sqrt epsilon * ((N : ℝ) * K * Real.sqrt C * Real.sqrt energy * ‖T xi‖ ^ 2 +
+ 2 * K * Real.sqrt (N : ℝ) * Real.sqrt ⟪xi, patchMass s D xi⟫_ℝ * ‖T xi‖) := by
+ let a : ι → ℝ := fun j => fderiv ℝ (phi j) P xi
+ let b : ι → ℝ := fun j => fderiv ℝ (fun y => fderiv ℝ (phi j) y xi) P xi
+ have hsmall : ∀ j ∈ s, ∀ x, ⟪x, D j x⟫_ℝ ≤ epsilon * ‖T x‖ ^ 2 :=
+ fun j hj x => (patch_form_le_mass s D hD hj x).trans (hZ x)
+ have hb := frozen_patch_weighted_value_le T s D (fun j => P - c j) b hN
+ hepsilon hC hr.le henergy (A := K / r ^ 2 * ‖T xi‖ ^ 2) (by positivity)
+ hD hsmall hw hsecond
+ have ha := frozen_patch_directional_sum_le T s D a xi hN hepsilon
+ (A := K / r * ‖T xi‖) (by positivity) hD hZ hfirst
+ have hformula : fderiv ℝ (fun y => fderiv ℝ (patchField s phi D c) y xi) P xi =
+ patchCutoffError s D (fun j => P - c j) b +
+ (2 : ℝ) • patchCutoffError s D (fun _ => xi) a := by
+ rw [patchField_second_directional s phi D c P xi hphi]
+ simp [patchCutoffError, a, b, Finset.sum_add_distrib, Finset.smul_sum, mul_smul]
+ rw [hformula, map_add, map_smul]
+ calc
+ _ ≤ r * (‖(T.symm : E →L[ℝ] E).adjoint
+ (patchCutoffError s D (fun j => P - c j) b)‖ +
+ 2 * ‖(T.symm : E →L[ℝ] E).adjoint (patchCutoffError s D (fun _ => xi) a)‖) := by
+ apply mul_le_mul_of_nonneg_left _ hr.le
+ simpa only [norm_smul, Real.norm_eq_abs, abs_of_nonneg (by norm_num : (0 : ℝ) ≤ 2)]
+ using norm_add_le ((T.symm : E →L[ℝ] E).adjoint
+ (patchCutoffError s D (fun j => P - c j) b))
+ ((2 : ℝ) • (T.symm : E →L[ℝ] E).adjoint (patchCutoffError s D (fun _ => xi) a))
+ _ ≤ r * ((N : ℝ) * (K / r ^ 2 * ‖T xi‖ ^ 2) *
+ (Real.sqrt epsilon * Real.sqrt C * r * Real.sqrt energy) +
+ 2 * ((K / r * ‖T xi‖) * Real.sqrt epsilon * Real.sqrt (N : ℝ) *
+ Real.sqrt ⟪xi, patchMass s D xi⟫_ℝ)) := by
+ exact mul_le_mul_of_nonneg_left (add_le_add hb (mul_le_mul_of_nonneg_left ha (by norm_num))) hr.le
+ _ = _ := by field_simp [ne_of_gt hr]
+
+/-- With `epsilon ≤ 1`, the small factor may be dropped, giving the two
+terms in `re:field-second` with explicit overlap and cutoff constants. -/
+theorem patchField_second_directional_frozen_le (T : E ≃L[ℝ] E) (s : Finset ι)
+ (phi : ι → E → ℝ) (D : ι → E →L[ℝ] E) (c : ι → E) (P xi : E) {N : ℕ}
+ {epsilon C K r energy : ℝ} (hN : s.card ≤ N)
+ (hepsilon : 0 ≤ epsilon) (hepsilon1 : epsilon ≤ 1) (hC : 0 ≤ C) (hK : 0 ≤ K)
+ (hr : 0 < r) (henergy : 0 ≤ energy)
+ (hphi : ∀ j ∈ s, ContDiffAt ℝ 2 (phi j) P)
+ (hD : ∀ j ∈ s, (D j).IsPositive)
+ (hZ : ∀ x, ⟪x, patchMass s D x⟫_ℝ ≤ epsilon * ‖T x‖ ^ 2)
+ (hw : ∀ j ∈ s, ⟪P - c j, D j (P - c j)⟫_ℝ ≤ C * r ^ 2 * energy)
+ (hfirst : ∀ j ∈ s, |fderiv ℝ (phi j) P xi| ≤ K / r * ‖T xi‖)
+ (hsecond : ∀ j ∈ s, |fderiv ℝ (fun y => fderiv ℝ (phi j) y xi) P xi| ≤
+ K / r ^ 2 * ‖T xi‖ ^ 2) :
+ r * ‖(T.symm : E →L[ℝ] E).adjoint
+ (fderiv ℝ (fun y => fderiv ℝ (patchField s phi D c) y xi) P xi)‖ ≤
+ (N : ℝ) * K * Real.sqrt C * Real.sqrt energy * ‖T xi‖ ^ 2 +
+ 2 * K * Real.sqrt (N : ℝ) * Real.sqrt ⟪xi, patchMass s D xi⟫_ℝ * ‖T xi‖ := by
+ have hsqrt : Real.sqrt epsilon ≤ 1 := by
+ nlinarith [Real.sq_sqrt hepsilon, Real.sqrt_nonneg epsilon]
+ exact (patchField_second_directional_frozen_le_sqrt T s phi D c P xi hN
+ hepsilon hC hK hr henergy hphi hD hZ hw hfirst hsecond).trans
+ (mul_le_of_le_one_left (by positivity) hsqrt)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PointwiseMetricIteration.lean b/lean/OAI/Geometry/RCD/Coordinates/PointwiseMetricIteration.lean
new file mode 100644
index 0000000000000000000000000000000000000000..1ab192ab2bc155875ad896fa128b60f85f386d04
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PointwiseMetricIteration.lean
@@ -0,0 +1,235 @@
+import OAI.Geometry.RCD.Coordinates.DifferentialStep
+import OAI.Geometry.RCD.Coordinates.DifferentialBounds
+
+namespace OAI
+
+/-!
+# Finite pointwise metric iteration
+
+At a fixed point and direction, the map update supplies the metric
+increment and the diagonal second-derivative recurrence. Field estimates,
+inverse costs, cumulative budgets, and a leading comparison then control
+the coordinate metric.
+-/
+
+open scoped BigOperators InnerProductSpace
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+
+/-- A common coefficient for the linear, inverse, squared, and recurrence errors. -/
+def pointwiseIterationCoefficient (C : ℝ) : ℝ := C + 2 * C ^ 2 + 5 * C ^ 4
+
+theorem pointwiseIterationCoefficient_bounds {C : ℝ} (hC : 1 ≤ C) :
+ 0 ≤ pointwiseIterationCoefficient C ∧ C ≤ pointwiseIterationCoefficient C ∧
+ C ^ 2 ≤ pointwiseIterationCoefficient C ∧ 2 * C ^ 2 ≤ pointwiseIterationCoefficient C ∧
+ 5 * C ^ 4 ≤ pointwiseIterationCoefficient C := by
+ have hC0 : 0 ≤ C := by linarith
+ unfold pointwiseIterationCoefficient
+ constructor
+ · positivity
+ constructor
+ · nlinarith [sq_nonneg C, pow_nonneg hC0 4]
+ constructor
+ · nlinarith [sq_nonneg C, pow_nonneg hC0 4]
+ constructor <;> nlinarith [sq_nonneg C, pow_nonneg hC0 4]
+
+theorem sqrt_weighted_defect {energy q : ℝ} (henergy : 0 ≤ energy) (hq : 0 ≤ q) :
+ Real.sqrt (energy * q ^ 2) = Real.sqrt energy * q := by
+ rw [Real.sqrt_mul henergy, Real.sqrt_sq hq]
+
+omit [CompleteSpace E] in
+/-- The first derivative increment of the actual operator-field update. -/
+theorem fderiv_clm_update_increment {h v : E → E} {K : E → E →L[ℝ] E} {x : E}
+ (hh : DifferentiableAt ℝ h x) (hK : DifferentiableAt ℝ K x)
+ (hv : DifferentiableAt ℝ v x) (xi : E) :
+ fderiv ℝ (fun y => h y + K y (v y)) x xi - fderiv ℝ h x xi =
+ K x (fderiv ℝ v x xi) + fderiv ℝ K x xi (v x) := by
+ have hd := hh.hasFDerivAt.fun_add (hK.hasFDerivAt.clm_apply hv.hasFDerivAt)
+ rw [hd.fderiv]
+ simp
+
+omit [CompleteSpace E] in
+/-- The inverse linear error is measured by the normalized old diagonal
+second derivative and the weighted defect. -/
+theorem inverse_diagonal_error_le (K : E →L[ℝ] E) (dual : E → ℝ) (old v : E)
+ {C epsilon r q energy : ℝ} (hC : 1 ≤ C)
+ (hepsilon : 0 ≤ epsilon) (hepsilon1 : epsilon ≤ 1)
+ (hr : 0 < r) (hq : 0 < q) (henergy : 0 ≤ energy)
+ (hK : ∀ w, ‖K w‖ ≤ C * dual w)
+ (hv : dual v ≤ C * Real.sqrt epsilon * r * Real.sqrt energy) :
+ |⟪old, K v⟫_ℝ| ≤ C ^ 2 * (r / q * ‖old‖) * Real.sqrt (energy * q ^ 2) := by
+ have hC0 : 0 ≤ C := by linarith
+ have hsqrt : Real.sqrt epsilon ≤ 1 := by
+ nlinarith [Real.sq_sqrt hepsilon, Real.sqrt_nonneg epsilon]
+ have hvalue : ‖K v‖ ≤ C ^ 2 * r * Real.sqrt energy := by
+ calc
+ _ ≤ C * (C * Real.sqrt epsilon * r * Real.sqrt energy) :=
+ (hK v).trans (mul_le_mul_of_nonneg_left hv hC0)
+ _ = Real.sqrt epsilon * (C ^ 2 * r * Real.sqrt energy) := by ring
+ _ ≤ _ := mul_le_of_le_one_left (by positivity) hsqrt
+ calc
+ _ ≤ ‖old‖ * ‖K v‖ := abs_real_inner_le_norm _ _
+ _ ≤ ‖old‖ * (C ^ 2 * r * Real.sqrt energy) :=
+ mul_le_mul_of_nonneg_left hvalue (norm_nonneg _)
+ _ = _ := by
+ rw [sqrt_weighted_defect henergy hq.le]
+ field_simp [ne_of_gt hq]
+
+/-- The actual maps satisfy the finite metric comparison once their
+explicit analytic estimates and geometric scalar budgets are supplied. -/
+theorem pointwise_metric_iteration
+ (h v : ℕ → E → E) (e : ℕ → E ≃L[ℝ] E)
+ (principal : ℕ → E →L[ℝ] E) (dual : ℕ → E → ℝ)
+ (x xi : E) (q r z energy : ℕ → ℝ) (k : ℕ)
+ {C T epsilon Q : ℝ} (hC : 1 ≤ C) (hT : 1 ≤ T)
+ (hepsilon : 0 ≤ epsilon) (hepsilon1 : epsilon ≤ 1) (hQ : 0 ≤ Q)
+ (hq : ∀ i, 0 < q i) (hr : ∀ i, 0 < r i)
+ (hz : ∀ i, 0 ≤ z i) (henergy : ∀ i, 0 ≤ energy i)
+ (hregular : ∀ i < k, ContDiffAt ℝ 3 (h i) x)
+ (vregular : ∀ i < k, ContDiffAt ℝ 2 (v i) x)
+ (hJacobian : ∀ i < k, fderiv ℝ (h i) x = (e i : E →L[ℝ] E))
+ (hupdate : ∀ i < k, h (i + 1) = fun y => h i y +
+ operatorInverseTranspose (fderiv ℝ (h i) y) (v i y))
+ (hradius : ∀ i < k, r (i + 1) = r i / 2)
+ (hmonotone : ∀ i < k, q i ≤ q (i + 1))
+ (hinitial : diagonalSecond (h 0) x xi = 0)
+ (hK : ∀ i < k, ∀ w,
+ ‖operatorInverseTranspose (fderiv ℝ (h i) x) w‖ ≤ C * dual i w)
+ (hK1 : ∀ i < k, ∀ w,
+ ‖fderiv ℝ (fun y => operatorInverseTranspose (fderiv ℝ (h i) y)) x xi w‖ ≤
+ C * q i / r i * dual i w)
+ (hK2 : ∀ i < k, ∀ w,
+ ‖diagonalSecond (fun y => operatorInverseTranspose (fderiv ℝ (h i) y)) x xi w‖ ≤
+ C * (q i) ^ 2 / (r i) ^ 2 * dual i w)
+ (hv : ∀ i < k, dual i (v i x) ≤
+ C * Real.sqrt epsilon * r i * Real.sqrt (energy i))
+ (hv1 : ∀ i < k, dual i (fderiv ℝ (v i) x xi) ≤
+ C * Real.sqrt epsilon * (Real.sqrt (z i) + Real.sqrt (energy i) * q i))
+ (hv2 : ∀ i < k, dual i (diagonalSecond (v i) x xi) ≤
+ C / r i * (Real.sqrt (z i) * q i + Real.sqrt (energy i) * (q i) ^ 2))
+ (hlinear : ∀ i < k, |⟪xi, fderiv ℝ (v i) x xi - principal i xi⟫_ℝ| ≤
+ C * Real.sqrt (z i) * Real.sqrt (energy i) * q i)
+ (hzbudget : (∑ i ∈ Finset.range k, z i) ≤ T * Q)
+ (hdbudget : (∑ i ∈ Finset.range k, energy i * (q i) ^ 2) ≤ epsilon * Q)
+ (hleadLower : T⁻¹ * Q ≤ ‖fderiv ℝ (h 0) x xi‖ ^ 2 +
+ 2 * ∑ i ∈ Finset.range k, ⟪xi, principal i xi⟫_ℝ)
+ (hleadUpper : ‖fderiv ℝ (h 0) x xi‖ ^ 2 +
+ 2 * ∑ i ∈ Finset.range k, ⟪xi, principal i xi⟫_ℝ ≤ 2 * T * Q)
+ (hsmall : scalarMetricErrorCoefficient (pointwiseIterationCoefficient C) T epsilon ≤
+ (2 * T)⁻¹) :
+ (4 * T)⁻¹ * Q ≤ ‖fderiv ℝ (h k) x xi‖ ^ 2 ∧
+ ‖fderiv ℝ (h k) x xi‖ ^ 2 ≤ (4 * T) * Q := by
+ let K : ℕ → E → E →L[ℝ] E := fun i y => operatorInverseTranspose (fderiv ℝ (h i) y)
+ let m : ℕ → ℝ := fun i => ‖fderiv ℝ (h i) x xi‖ ^ 2
+ let s : ℕ → ℝ := fun i => ⟪xi, principal i xi⟫_ℝ
+ let d : ℕ → ℝ := fun i => energy i * (q i) ^ 2
+ let b : ℕ → ℝ := fun i => r i / q i * ‖diagonalSecond (h i) x xi‖
+ let linear : ℕ → ℝ := fun i => ⟪xi, fderiv ℝ (v i) x xi - principal i xi⟫_ℝ
+ let inverse : ℕ → ℝ := fun i => -⟪diagonalSecond (h i) x xi, K i x (v i x)⟫_ℝ
+ let square : ℕ → ℝ := fun i => ‖fderiv ℝ (h (i + 1)) x xi - fderiv ℝ (h i) x xi‖ ^ 2
+ obtain ⟨hcoef, hcoef1, hcoef2, hcoefRec, hcoefSq⟩ := pointwiseIterationCoefficient_bounds hC
+ have hKregular (i : ℕ) (hi : i < k) : ContDiffAt ℝ 2 (K i) x := by
+ apply contDiffAt_inverseTranspose_field ((hregular i hi).fderiv_right (m := 2) (by norm_num))
+ rw [hJacobian i hi]
+ exact (e i).toUnit.isUnit
+ have hdelta (i : ℕ) (hi : i < k) :
+ fderiv ℝ (h (i + 1)) x xi - fderiv ℝ (h i) x xi =
+ K i x (fderiv ℝ (v i) x xi) + fderiv ℝ (K i) x xi (v i x) := by
+ rw [hupdate i hi]
+ exact fderiv_clm_update_increment ((hregular i hi).differentiableAt (by norm_num))
+ ((hKregular i hi).differentiableAt (by norm_num))
+ ((vregular i hi).differentiableAt (by norm_num)) xi
+ have hsecond (i : ℕ) (hi : i < k) : diagonalSecond (h (i + 1)) x xi =
+ diagonalSecond (h i) x xi + (K i x (diagonalSecond (v i) x xi) +
+ (2 : ℝ) • fderiv ℝ (K i) x xi (fderiv ℝ (v i) x xi) +
+ diagonalSecond (K i) x xi (v i x)) := by
+ rw [hupdate i hi, diagonalSecond_add ((hregular i hi).of_le (by norm_num))
+ ((hKregular i hi).clm_apply (vregular i hi)),
+ diagonalSecond_clm_apply (hKregular i hi) (vregular i hi)]
+ simp only [two_smul]
+ have hd : ∀ i, 0 ≤ d i := fun i => mul_nonneg (henergy i) (sq_nonneg _)
+ have hb : ∀ i, 0 ≤ b i := by
+ intro i
+ exact mul_nonneg (div_nonneg (hr i).le (hq i).le) (norm_nonneg _)
+ have hbzero : b 0 = 0 := by simp [b, hinitial]
+ have hrec : ∀ i < k, b (i + 1) ≤ b i / 2 +
+ pointwiseIterationCoefficient C * (Real.sqrt (z i) + Real.sqrt (d i)) := by
+ intro i hi
+ have hqi := hq i
+ have hbound := differential_diagonal_update_recurrence
+ (K i x) (fderiv ℝ (K i) x xi) (diagonalSecond (K i) x xi) (dual i)
+ (v i x) (fderiv ℝ (v i) x xi) (diagonalSecond (v i) x xi)
+ (diagonalSecond (h i) x xi) (diagonalSecond (h (i + 1)) x xi)
+ hC hepsilon hepsilon1 (hq i) (hr i) (hmonotone i hi)
+ (hK i hi) (hK1 i hi) (hK2 i hi) (hv i hi) (hv1 i hi) (hv2 i hi) (hsecond i hi)
+ have hroot : Real.sqrt (d i) = Real.sqrt (energy i) * q i :=
+ sqrt_weighted_defect (henergy i) (hq i).le
+ dsimp [b]
+ rw [hradius i hi, hroot]
+ exact hbound.trans (add_le_add le_rfl
+ (mul_le_mul_of_nonneg_right hcoefRec (by positivity)))
+ have hlin : ∀ i < k, |linear i| ≤ pointwiseIterationCoefficient C *
+ Real.sqrt (z i) * Real.sqrt (d i) := by
+ intro i hi
+ have hqi := hq i
+ dsimp [linear, d]
+ rw [sqrt_weighted_defect (henergy i) (hq i).le]
+ calc
+ _ ≤ C * Real.sqrt (z i) * Real.sqrt (energy i) * q i := hlinear i hi
+ _ = C * (Real.sqrt (z i) * (Real.sqrt (energy i) * q i)) := by ring
+ _ ≤ pointwiseIterationCoefficient C * (Real.sqrt (z i) * (Real.sqrt (energy i) * q i)) :=
+ mul_le_mul_of_nonneg_right hcoef1 (by positivity)
+ _ = _ := by ring
+ have hinv : ∀ i < k, |inverse i| ≤ pointwiseIterationCoefficient C * b i * Real.sqrt (d i) := by
+ intro i hi
+ have hqi := hq i
+ have hri := hr i
+ dsimp [inverse]
+ rw [abs_neg]
+ have hbound := inverse_diagonal_error_le (K i x) (dual i) (diagonalSecond (h i) x xi)
+ (v i x) hC hepsilon hepsilon1 (hr i) (hq i) (henergy i) (hK i hi) (hv i hi)
+ exact hbound.trans (by
+ dsimp [b, d]
+ exact mul_le_mul_of_nonneg_right
+ (mul_le_mul_of_nonneg_right hcoef2 (by positivity)) (Real.sqrt_nonneg _))
+ have hsquare : ∀ i < k, |square i| ≤ pointwiseIterationCoefficient C * epsilon * (z i + d i) := by
+ intro i hi
+ have hzi := hz i
+ have hEi := henergy i
+ dsimp [square]
+ rw [abs_of_nonneg (sq_nonneg _), hdelta i hi]
+ have hbound := differential_first_increment_sq_le (K i x) (fderiv ℝ (K i) x xi)
+ (dual i) (v i x) (fderiv ℝ (v i) x xi) hC hepsilon (hq i) (hr i)
+ (hz i) (henergy i) (hK i hi) (hK1 i hi) (hv i hi) (hv1 i hi)
+ exact hbound.trans (mul_le_mul_of_nonneg_right
+ (mul_le_mul_of_nonneg_right hcoefSq hepsilon) (by positivity))
+ have hmetricStep : ∀ i < k, m (i + 1) - m i =
+ 2 * s i + 2 * linear i + 2 * inverse i + square i := by
+ intro i hi
+ have hidentity := inverseTranspose_update_metric_increment
+ ((hregular i hi).of_le (by norm_num))
+ ((vregular i hi).differentiableAt (by norm_num)) (e i) (hJacobian i hi) xi
+ dsimp only at hidentity
+ rw [← hupdate i hi] at hidentity
+ have hKvalue : K i x = inverseTranspose (e i) := by
+ dsimp [K]
+ rw [hJacobian i hi, operatorInverseTranspose_equiv]
+ have hJxi : (e i) xi = fderiv ℝ (h i) x xi := by
+ rw [hJacobian i hi]
+ rfl
+ rw [← hKvalue, hJxi] at hidentity
+ dsimp [m, s, linear, inverse, square]
+ rw [inner_sub_right]
+ nlinarith [hidentity]
+ exact scalar_metric_bootstrap hcoef hT hepsilon hQ hz hd hb hbzero k
+ hrec hlin hinv hsquare hmetricStep hzbudget hdbudget hleadLower hleadUpper hsmall
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PoissonBilinearMeasure.lean b/lean/OAI/Geometry/RCD/Coordinates/PoissonBilinearMeasure.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0a10b71cf1c09de6a458414e3c40df64668517ea
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PoissonBilinearMeasure.lean
@@ -0,0 +1,123 @@
+import OAI.Geometry.RCD.Sobolev.PoissonScalarFamily
+import OAI.Geometry.RCD.Sobolev.FiniteEnergyRepresentatives
+import OAI.Geometry.RCD.Sobolev.SignedTestFunctional
+import OAI.Geometry.RCD.Coordinates.LocalPositiveBilinearMeasure
+import OAI.Geometry.RCD.Sobolev.AnnularLipschitzCutoff
+
+namespace OAI
+
+/-! # One positive measure-valued form for the finite Poisson span
+
+Polarization of the actual scalar measures gives the coefficient measures.
+Locality identifies their quadratic tests with each directional scalar
+measure. Positivity is then retained on the common interior ball, including
+the singular part.
+-/
+
+open Set Filter MeasureTheory Metric
+open scoped NNReal BoundedContinuousFunction
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.poisson_bilinear_energy_measure {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2 ≤ n)
+ (κ : ℝ) (hK : -κ ≤ K) (p : X) {r : ℝ} (hr : 0 < r) (L : ℝ≥0)
+ (U : Euclidean (n + 2) →L[ℝ] SobolevSpace (hausdorff n X) hX.quadratic)
+ (ell : Euclidean (n + 2) →ₗ[ℝ] ℝ)
+ (hU : ∀ v, IsConstantLaplacianOn (hausdorff n X) hX.quadratic
+ (ball p (8 * r)) (U v) (ell v))
+ (hL : ∀ v, ∀ᵐ x ∂(hausdorff n X).restrict (ball p (8 * r)),
+ localGamma (hausdorff n X) hX.quadratic (U v) (U v) x ≤ (L : ℝ) ^ 2 * ‖v‖ ^ 2) :
+ ∃ M : PositiveBilinearMeasure X (Euclidean (n + 2)),
+ ∀ v, Nonempty (LocalHarmonicEnergy (hausdorff n X) hX.quadratic U M κ p r L v) := by
+ classical
+ let := hX.separable
+ let μ := hausdorff n X
+ let hQ := hX.quadratic
+ let := locallyFinite_of_finiteOnBounded μ hX.finiteOnBounded
+ obtain ⟨G, σ, hσ, hGb, hGr, hGt⟩ := hX.poisson_scalar_energy_family hn κ hK p hr L U ell hU hL
+ let e (i : Fin (n + 2)) : Euclidean (n + 2) := EuclideanSpace.single i 1
+ let H (i j : Fin (n + 2)) := (1 / 2 : ℝ) • (G (e i + e j) - G (e i) - G (e j))
+ let s (v : Euclidean (n + 2)) : SignedMeasure X := @Measure.toSignedMeasure X _ (σ v) (hσ v)
+ let a (i j : Fin (n + 2)) := (1 / 2 : ℝ) • (s (e i + e j) - s (e i) - s (e j))
+ let B := coordinateBilinear H
+ let Q := coordinateBilinear a
+ have hH (i j : Fin (n + 2)) : SobolevSpace.toLp μ hQ (H i j)
+ =ᵐ[μ.restrict (ball p (5 * r / 2))] localGamma μ hQ (U (e i)) (U (e j)) := by
+ apply polarized_energy_representative μ hQ _ _ _ _ _ (hGr (e i)) (hGr (e j))
+ simpa only [map_add] using hGr (e i + e j)
+ have hB (v w : Euclidean (n + 2)) : SobolevSpace.toLp μ hQ (B v w)
+ =ᵐ[μ.restrict (ball p (5 * r / 2))] localGamma μ hQ (U v) (U w) :=
+ coordinate_energy_representative μ hQ U H hH v w
+ have ha (i j : Fin (n + 2)) : a i j = a j i := by
+ dsimp only [a]
+ rw [add_comm (e i) (e j)]
+ congr 1
+ abel
+ have hentry (i j : Fin (n + 2)) (ψ : SobolevSpace μ hQ) (f : X →ᵇ ℝ)
+ (hfc : HasCompactSupport (f : X → ℝ)) (hfs : tsupport f ⊆ ball p (5 * r / 2))
+ (hψ : SobolevSpace.toLp μ hQ ψ =ᵐ[μ] f) :
+ signedTestIntegral f (a i j) = bochnerTestForm μ hQ κ (H i j) ψ := by
+ have ht (v : Euclidean (n + 2)) : signedTestIntegral f (s v) =
+ bochnerTestForm μ hQ κ (G v) ψ := by
+ have : IsFiniteMeasure (σ v) := hσ v
+ change (∫ᵛ x, f x ∂<•(σ v).toSignedMeasure) = _
+ rw [VectorMeasure.integral_toSignedMeasure]
+ exact (hGt v ψ f f.continuous hfc hfs hψ).symm
+ change signedTestIntegral f ((1 / 2 : ℝ) • (s (e i + e j) - s (e i) - s (e j))) = _
+ simp only [map_smul, map_sub, ht, H, LinearMap.smul_apply, LinearMap.sub_apply, smul_eq_mul]
+ have htest (v : Euclidean (n + 2)) (ψ : SobolevSpace μ hQ) (f : X →ᵇ ℝ)
+ (hfc : HasCompactSupport (f : X → ℝ)) (hfs : tsupport f ⊆ ball p (5 * r / 2))
+ (hψ : SobolevSpace.toLp μ hQ ψ =ᵐ[μ] f) :
+ signedTestIntegral f (Q v v) = bochnerTestForm μ hQ κ (G v) ψ := by
+ have he : signedTestIntegral f (Q v v) = bochnerTestForm μ hQ κ (B v v) ψ := by
+ rw [signedTestIntegral_coordinate]
+ simp_rw [hentry _ _ ψ f hfc hfs hψ]
+ change _ = bochnerTestForm μ hQ κ (coordinateBilinear H v v) ψ
+ rw [coordinateBilinear_apply]
+ simp only [map_sum, map_smul, LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul]
+ exact he.trans (bochnerTestForm_congr_on μ hQ measurableSet_ball κ
+ ((hB v v).trans (hGr v).symm) ψ f hψ hfs)
+ have hpos (v : Euclidean (n + 2)) (f : compactLipschitzTests (ball p (5 * r / 2)))
+ (hf : 0 ≤ (f : X →ᵇ ℝ)) : 0 ≤ ∫ᵛ x, (f : X →ᵇ ℝ) x ∂<•(Q v v) := by
+ let ψ := compactTestSobolev μ hQ _ f
+ have hψ := compactTestSobolev_coe μ hQ _ f
+ change 0 ≤ signedTestIntegral (f : X →ᵇ ℝ) (Q v v)
+ rw [htest v ψ f f.property.choose_spec.2.1 f.property.choose_spec.2.2 hψ,
+ hGt v ψ f (f : X →ᵇ ℝ).continuous f.property.choose_spec.2.1 f.property.choose_spec.2.2 hψ]
+ exact integral_nonneg hf
+ obtain ⟨χ, C, hχ, hχc, hχs, hχb, hχ1⟩ :=
+ exists_annular_lipschitz_cutoff p (a := 2 * r) (b := 9 * r / 4) (by linarith)
+ let M := positiveBilinearMeasure_of_local_tests Q
+ (coordinateBilinear_symmetric a ha) measurableSet_closedBall χ hχ hχc
+ (hχs.trans (closedBall_subset_ball (show 9 * r / 4 < 5 * r / 2 by linarith)))
+ (fun x => (hχb x).1) hχ1 hpos
+ refine ⟨M, ?_⟩
+ intro v
+ have hsmall : ball p (2 * r) ⊆ ball p (5 * r / 2) := ball_subset_ball (by linarith)
+ have hrep := ae_restrict_of_ae_restrict_of_subset hsmall (hGr v)
+ refine ⟨{ energy := G v, representative := hrep, bounded := ?_, measure_laplacian := ?_ }⟩
+ · filter_upwards [hGb v] with x hx
+ rw [abs_of_nonneg hx.1]
+ simpa only [NNReal.coe_mul, NNReal.coe_pow, coe_nnnorm] using hx.2
+ · have hid (ψ : SobolevSpace μ hQ) (f : X → ℝ) (hfc : Continuous f)
+ (hfs : HasCompactSupport f) (hfsub : tsupport f ⊆ ball p (2 * r))
+ (hψ : SobolevSpace.toLp μ hQ ψ =ᵐ[μ] f) :
+ (∫ x, f x ∂M.measure v) = bochnerTestForm μ hQ κ (G v) ψ := by
+ let w : X →ᵇ ℝ := ofCompactSupport f hfc hfs
+ rw [← VectorMeasure.integral_toSignedMeasure, M.measure_toSignedMeasure]
+ change signedTestIntegral w ((Q v v).restrict (closedBall p (2 * r))) = _
+ rw [signedTestIntegral_restrict w _ measurableSet_closedBall
+ (hfsub.trans ball_subset_closedBall)]
+ exact htest v ψ w hfs (hfsub.trans hsmall) hψ
+ have hlap := bochner_measure_laplacian μ hQ measurableSet_ball (U v) (G v) κ (M.measure v) hrep hid
+ simpa only [harmonicBochnerSource, M.measure_toSignedMeasure] using hlap
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PoissonSpanCoordinates.lean b/lean/OAI/Geometry/RCD/Coordinates/PoissonSpanCoordinates.lean
new file mode 100644
index 0000000000000000000000000000000000000000..2ce9034a9bd9286058e955234abd174c6f6cd8c9
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PoissonSpanCoordinates.lean
@@ -0,0 +1,52 @@
+import OAI.Geometry.RCD.Sobolev.PoissonSpan
+
+namespace OAI
+
+/-! # The actual coordinate directions in the finite Poisson span -/
+
+open Set Metric MeasureTheory
+open scoped BigOperators NNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+theorem poissonSpanMap_right {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (f : Fin 2 → SobolevSpace μ hQ) (j : Fin 2) :
+ sobolevColumnMap μ hQ (poissonSpan μ hQ u f)
+ (EuclideanSpace.single (Fin.natAdd n j) 1) = f j := by
+ rw [sobolevColumnMap_single]
+ exact Fin.append_right u f j
+
+theorem poissonSpanMap_left {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (f : Fin 2 → SobolevSpace μ hQ) (j : Fin n) :
+ sobolevColumnMap μ hQ (poissonSpan μ hQ u f)
+ (EuclideanSpace.single (Fin.castAdd 2 j) 1) = u j := by
+ rw [sobolevColumnMap_single]
+ exact Fin.append_left u f j
+
+omit [MetricSpace X] [MeasurableSpace X] in
+theorem poissonSpanLaplacian_single {n : ℕ} (c : ℝ) (j : Fin (n + 2)) :
+ poissonSpanLaplacian n c (EuclideanSpace.single j 1) =
+ Fin.append (fun _ : Fin n => (0 : ℝ)) (fun _ : Fin 2 => c) j := by
+ simp [poissonSpanLaplacian, EuclideanSpace.projₗ, PiLp.projₗ_apply, PiLp.single_apply]
+
+omit [MetricSpace X] [MeasurableSpace X] in
+theorem poissonSpanLaplacian_right {n : ℕ} (c : ℝ) (j : Fin 2) :
+ poissonSpanLaplacian n c (EuclideanSpace.single (Fin.natAdd n j) 1) = c := by
+ rw [poissonSpanLaplacian_single]
+ exact Fin.append_right _ _ _
+
+omit [MetricSpace X] [MeasurableSpace X] in
+theorem poissonSpanLaplacian_left {n : ℕ} (c : ℝ) (j : Fin n) :
+ poissonSpanLaplacian n c (EuclideanSpace.single (Fin.castAdd 2 j) 1) = 0 := by
+ rw [poissonSpanLaplacian_single]
+ exact Fin.append_left _ _ _
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PositiveBilinearIntegralLower.lean b/lean/OAI/Geometry/RCD/Coordinates/PositiveBilinearIntegralLower.lean
new file mode 100644
index 0000000000000000000000000000000000000000..01942c1faa3135be5934069174437f883722f891
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PositiveBilinearIntegralLower.lean
@@ -0,0 +1,72 @@
+import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lemmas
+import Mathlib.MeasureTheory.Integral.DominatedConvergence
+
+namespace OAI
+
+/-! # An integrated lower bound for positive quadratic forms
+
+Weak mixed-pairing convergence and a uniform norm bound suffice. Strong
+convergence of vectors or convergence of pointwise energies is not needed.
+-/
+
+open Set Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {E Y : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace Y]
+
+theorem positive_bilinear_integral_lower
+ (P : E →L[ℝ] E →L[ℝ] ℝ) (hpos : ∀ x, 0 ≤ P x x)
+ (hsymm : ∀ x y, P x y = P y x) (ν : Measure Y)
+ (u : ℕ → Y → E) (v : Y → E)
+ (hu : ∀ k, AEStronglyMeasurable (u k) ν) (hv : AEStronglyMeasurable v ν)
+ {C : ℝ} (hC : 0 ≤ C) (hb : ∀ k, ∀ᵐ t ∂ν, ‖u k t‖ ≤ C)
+ (hvb : ∀ᵐ t ∂ν, ‖v t‖ ≤ C)
+ (hp : ∀ᵐ t ∂ν, Tendsto (fun k => P (u k t) (v t)) atTop (𝓝 (P (v t) (v t))))
+ (θ : Y → ℝ) (hθ : Integrable θ ν) (hθ0 : ∀ᵐ t ∂ν, 0 ≤ θ t)
+ {A : ℝ} (he : Tendsto (fun k => ∫ t, θ t*P (u k t) (u k t) ∂ν) atTop (𝓝 A)) :
+ (∫ t, θ t*P (v t) (v t) ∂ν) ≤ A := by
+ let D := ‖P‖*C*C
+ have hbound {f g : Y → E} (hf : ∀ᵐ t ∂ν, ‖f t‖ ≤ C)
+ (hg : ∀ᵐ t ∂ν, ‖g t‖ ≤ C) : ∀ᵐ t ∂ν, ‖P (f t) (g t)‖ ≤ D := by
+ filter_upwards [hf,hg] with t ht hs
+ exact (P.le_opNorm₂ _ _).trans (by dsimp only [D]; gcongr)
+ have hInt {f g : Y → E} (hf : AEStronglyMeasurable f ν) (hg : AEStronglyMeasurable g ν)
+ (hfb : ∀ᵐ t ∂ν, ‖f t‖ ≤ C) (hgb : ∀ᵐ t ∂ν, ‖g t‖ ≤ C) :
+ Integrable (fun t => θ t*P (f t) (g t)) ν :=
+ hθ.mul_bdd (P.aestronglyMeasurable_comp₂ hf hg) (hbound hfb hgb)
+ have hmix : Tendsto (fun k => ∫ t, θ t*P (u k t) (v t) ∂ν) atTop
+ (𝓝 (∫ t, θ t*P (v t) (v t) ∂ν)) := by
+ apply tendsto_integral_of_dominated_convergence (fun t => |θ t| *D)
+ · intro k
+ exact hθ.aestronglyMeasurable.mul (P.aestronglyMeasurable_comp₂ (hu k) hv)
+ · exact hθ.abs.mul_const D
+ · intro k
+ filter_upwards [hbound (hb k) hvb] with t ht
+ rw [norm_mul,Real.norm_eq_abs (θ t)]
+ exact mul_le_mul_of_nonneg_left ht (abs_nonneg _)
+ · filter_upwards [hp] with t ht
+ exact ht.const_mul (θ t)
+ have hi (k : ℕ) :
+ 2*(∫ t, θ t*P (u k t) (v t) ∂ν)-(∫ t, θ t*P (v t) (v t) ∂ν) ≤
+ ∫ t, θ t*P (u k t) (u k t) ∂ν := by
+ rw [← integral_const_mul,← integral_sub ((hInt (hu k) hv (hb k) hvb).const_mul 2)
+ (hInt hv hv hvb hvb)]
+ apply integral_mono_ae ((hInt (hu k) hv (hb k) hvb).const_mul 2 |>.sub (hInt hv hv hvb hvb))
+ (hInt (hu k) (hu k) (hb k) (hb k))
+ filter_upwards [hθ0] with t ht
+ have hn := hpos (u k t-v t)
+ simp only [map_sub,sub_apply] at hn
+ rw [hsymm (v t) (u k t)] at hn
+ have hh := mul_nonneg ht hn
+ change 2*(θ t*P (u k t) (v t))-θ t*P (v t) (v t) ≤ θ t*P (u k t) (u k t)
+ nlinarith only [hh]
+ have hh := le_of_tendsto_of_tendsto
+ ((hmix.const_mul 2).sub_const (∫ t, θ t*P (v t) (v t) ∂ν)) he (Eventually.of_forall hi)
+ linarith
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PositiveBilinearMeasure.lean b/lean/OAI/Geometry/RCD/Coordinates/PositiveBilinearMeasure.lean
new file mode 100644
index 0000000000000000000000000000000000000000..68dd7edba1fa1bf949a1aa26c2002fac122d1256
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PositiveBilinearMeasure.lean
@@ -0,0 +1,177 @@
+import OAI.Geometry.RCD.Coordinates.MatrixNormConversion
+import OAI.Geometry.RCD.Coordinates.PositiveForms
+import Mathlib.MeasureTheory.VectorMeasure.Order
+
+namespace OAI
+
+/-!
+# Positive measure-valued forms on a finite coordinate span
+
+This constructs the real mass operators from a finite family of signed
+measures, retaining singular mass. The existence and local Bochner
+identification of that family are separate analytic obligations.
+-/
+
+open Set MeasureTheory
+open scoped BigOperators InnerProductSpace
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+/-- The finite-dimensional restriction of a positive, symmetric,
+measure-valued quadratic form, such as the local Bochner measure. -/
+structure PositiveBilinearMeasure (X E : Type*) [MeasurableSpace X]
+ [AddCommGroup E] [Module ℝ E] where
+ bilinear : E →ₗ[ℝ] E →ₗ[ℝ] SignedMeasure X
+ symmetric : ∀ v w, bilinear v w = bilinear w v
+ nonneg : ∀ v, 0 ≤ bilinear v v
+
+namespace PositiveBilinearMeasure
+
+variable {X E : Type*} [MeasurableSpace X] [NormedAddCommGroup E]
+ [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]
+ (M : PositiveBilinearMeasure X E)
+
+def evaluated (s : Set X) : E →ₗ[ℝ] E →ₗ[ℝ] ℝ :=
+ LinearMap.mk₂ ℝ (fun v w => M.bilinear v w s)
+ (by intro u v w; simp)
+ (by intro c v w; simp)
+ (by intro u v w; simp)
+ (by intro c v w; simp)
+
+def evaluatedContinuous (s : Set X) : E →L[ℝ] E →L[ℝ] ℝ :=
+ ((LinearMap.toContinuousLinearMap : (E →ₗ[ℝ] ℝ) ≃ₗ[ℝ] (E →L[ℝ] ℝ)).toLinearMap.comp
+ (M.evaluated s)).toContinuousLinearMap
+
+def massOperator (s : Set X) : E →L[ℝ] E :=
+ InnerProductSpace.continuousLinearMapOfBilin (M.evaluatedContinuous s)
+
+theorem massOperator_inner (s : Set X) (v w : E) :
+ ⟪M.massOperator s v, w⟫_ℝ = M.bilinear v w s :=
+ InnerProductSpace.continuousLinearMapOfBilin_apply _ _ _
+
+theorem massOperator_isPositive (s : Set X) (hs : MeasurableSet s) :
+ (M.massOperator s).IsPositive := by
+ constructor
+ · intro v w
+ change ⟪M.massOperator s v, w⟫_ℝ = ⟪v, M.massOperator s w⟫_ℝ
+ calc
+ _ = M.bilinear v w s := M.massOperator_inner s v w
+ _ = M.bilinear w v s := congrArg (fun m : SignedMeasure X => m s) (M.symmetric v w)
+ _ = ⟪M.massOperator s w, v⟫_ℝ := (M.massOperator_inner s w v).symm
+ _ = _ := real_inner_comm _ _
+ · intro v
+ change 0 ≤ ⟪M.massOperator s v, v⟫_ℝ
+ rw [massOperator_inner]
+ simpa using M.nonneg v s hs
+
+/-- Every diagonal signed measure is converted to an actual positive
+finite measure, rather than replaced by a density with respect to volume. -/
+def measure (v : E) : Measure X :=
+ (M.bilinear v v).toMeasureOfZeroLE Set.univ MeasurableSet.univ
+ (by simpa only [VectorMeasure.le_restrict_univ_iff_le] using M.nonneg v)
+
+instance measure_finite (v : E) : IsFiniteMeasure (M.measure v) :=
+ SignedMeasure.toMeasureOfZeroLE_finite _ _ _
+
+theorem measure_real (v : E) (s : Set X) (hs : MeasurableSet s) :
+ (M.measure v).real s = ⟪v, M.massOperator s v⟫_ℝ := by
+ calc
+ _ = M.bilinear v v s := by
+ simpa only [measure, Set.univ_inter] using
+ SignedMeasure.toMeasureOfZeroLE_real_apply (M.bilinear v v) _ MeasurableSet.univ hs
+ _ = ⟪M.massOperator s v, v⟫_ℝ := (M.massOperator_inner s v v).symm
+ _ = _ := real_inner_comm _ _
+
+/-- Change of coordinate columns acts on the full signed measures. -/
+def comap (A : E →ₗ[ℝ] E) : PositiveBilinearMeasure X E where
+ bilinear := M.bilinear.compl₁₂ A A
+ symmetric v w := M.symmetric (A v) (A w)
+ nonneg v := M.nonneg (A v)
+
+theorem comap_massOperator (A : E →L[ℝ] E) (s : Set X) :
+ (M.comap A.toLinearMap).massOperator s =
+ A.adjoint.comp ((M.massOperator s).comp A) := by
+ ext v
+ apply ext_inner_right ℝ
+ intro w
+ rw [massOperator_inner]
+ simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.adjoint_inner_left,
+ massOperator_inner]
+ rfl
+
+/-- The quadratic triangle bound holds for the full measure on every
+measurable set, so singular mass is included. -/
+theorem measure_add_le (v w : E) (s : Set X) (hs : MeasurableSet s) :
+ (M.measure (v + w)).real s ≤ 2 * ((M.measure v).real s + (M.measure w).real s) := by
+ rw [measure_real M _ s hs, measure_real M _ s hs, measure_real M _ s hs]
+ have hD := M.massOperator_isPositive s hs
+ have hp := hD.inner_nonneg_right (v - w)
+ have hsym : ⟪w, M.massOperator s v⟫_ℝ = ⟪v, M.massOperator s w⟫_ℝ := by
+ rw [real_inner_comm, hD.inner_left_eq_inner_right]
+ simp only [map_sub, inner_sub_left, inner_sub_right, hsym] at hp
+ simp only [map_add, inner_add_left, inner_add_right, hsym]
+ linarith
+
+/-- Covariance for the actual positive diagonal measures. -/
+theorem comap_measure_real (A : E →L[ℝ] E) (v : E) (s : Set X)
+ (hs : MeasurableSet s) :
+ ((M.comap A.toLinearMap).measure v).real s = (M.measure (A v)).real s := by
+ rw [measure_real _ _ s hs, comap_massOperator, ContinuousLinearMap.comp_apply,
+ ContinuousLinearMap.adjoint_inner_right, ContinuousLinearMap.comp_apply,
+ measure_real _ _ s hs]
+
+section Trace
+
+variable {n : ℕ} (N : PositiveBilinearMeasure X (Euclidean n))
+
+def traceMass (s : Set X) : ℝ :=
+ ∑ i : Fin n, (N.measure (EuclideanSpace.single i 1)).real s
+
+theorem traceMass_nonneg (s : Set X) : 0 ≤ N.traceMass s :=
+ Finset.sum_nonneg fun _ _ => ENNReal.toReal_nonneg
+
+/-- Positivity bounds every matrix entry by its trace. -/
+theorem mass_entry_le_trace (s : Set X) (hs : MeasurableSet s) (i j : Fin n) :
+ |N.massOperator s (EuclideanSpace.single j 1) i| ≤ N.traceMass s := by
+ let ei : Euclidean n := EuclideanSpace.single i 1
+ let ej : Euclidean n := EuclideanSpace.single j 1
+ let D := N.massOperator s
+ have hD := N.massOperator_isPositive s hs
+ have hii : ⟪ei, D ei⟫_ℝ ≤ N.traceMass s := by
+ rw [← N.measure_real ei s hs]
+ change (N.measure (EuclideanSpace.single i 1)).real s ≤
+ ∑ j : Fin n, (N.measure (EuclideanSpace.single j 1)).real s
+ exact Finset.single_le_sum
+ (f := fun k : Fin n => (N.measure (EuclideanSpace.single k 1)).real s)
+ (fun _ _ => ENNReal.toReal_nonneg) (Finset.mem_univ i)
+ have hjj : ⟪ej, D ej⟫_ℝ ≤ N.traceMass s := by
+ rw [← N.measure_real ej s hs]
+ change (N.measure (EuclideanSpace.single j 1)).real s ≤
+ ∑ i : Fin n, (N.measure (EuclideanSpace.single i 1)).real s
+ exact Finset.single_le_sum
+ (f := fun k : Fin n => (N.measure (EuclideanSpace.single k 1)).real s)
+ (fun _ _ => ENNReal.toReal_nonneg) (Finset.mem_univ j)
+ have hp := positive_form_cauchy_schwarz hD ei ej
+ have habs : |⟪ei, D ej⟫_ℝ| ≤ (⟪ei, D ei⟫_ℝ + ⟪ej, D ej⟫_ℝ) / 2 := by
+ have hsum := add_nonneg (hD.inner_nonneg_right ei) (hD.inner_nonneg_right ej)
+ nlinarith [sq_abs ⟪ei, D ej⟫_ℝ, sq_nonneg (⟪ei, D ei⟫_ℝ - ⟪ej, D ej⟫_ℝ),
+ abs_nonneg ⟪ei, D ej⟫_ℝ]
+ have he := habs.trans (by linarith :
+ (⟪ei, D ei⟫_ℝ + ⟪ej, D ej⟫_ℝ) / 2 ≤ N.traceMass s)
+ simpa only [ei, ej, D, EuclideanSpace.inner_single_left, conj_trivial, one_mul] using he
+
+theorem massOperator_norm_le_trace (s : Set X) (hs : MeasurableSet s) :
+ ‖N.massOperator s‖ ≤ (n : ℝ) ^ 2 * N.traceMass s :=
+ euclidean_operator_norm_le_of_entries _ (N.traceMass_nonneg s) (N.mass_entry_le_trace s hs)
+
+end Trace
+
+end PositiveBilinearMeasure
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PositiveForms.lean b/lean/OAI/Geometry/RCD/Coordinates/PositiveForms.lean
new file mode 100644
index 0000000000000000000000000000000000000000..c37b6fb5738fb4e100ef356e3f5d273396c67df5
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PositiveForms.lean
@@ -0,0 +1,78 @@
+import Mathlib.Analysis.InnerProductSpace.Positive
+import Mathlib.Algebra.QuadraticDiscriminant
+import Mathlib.Tactic
+
+namespace OAI
+
+/-!
+# Directional estimates for positive local mass forms
+
+These are the two positive-matrix inequalities in `re:positive-matrix-bound`,
+in coordinates where the frozen metric is the identity. Positivity permits
+singular mass forms; no inverse of a local mass matrix is used.
+-/
+
+open scoped InnerProductSpace
+
+namespace RegularPointCoordinates
+
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+
+/-- Cauchy--Schwarz for a possibly degenerate positive quadratic form. -/
+theorem positive_form_cauchy_schwarz {D : E →L[ℝ] E} (hD : D.IsPositive) (x y : E) :
+ ⟪x, D y⟫_ℝ ^ 2 ≤ ⟪x, D x⟫_ℝ * ⟪y, D y⟫_ℝ := by
+ have hsym : ⟪y, D x⟫_ℝ = ⟪x, D y⟫_ℝ := by
+ rw [real_inner_comm, hD.inner_left_eq_inner_right]
+ have hpoly : ∀ t : ℝ,
+ 0 ≤ ⟪y, D y⟫_ℝ * (t * t) + (2 * ⟪x, D y⟫_ℝ) * t + ⟪x, D x⟫_ℝ := by
+ intro t
+ have h := hD.inner_nonneg_right (x + t • y)
+ simp only [map_add, map_smul, inner_add_left, inner_add_right,
+ inner_smul_left, inner_smul_right, conj_trivial, hsym] at h
+ nlinarith
+ have hdisc := discrim_le_zero hpoly
+ unfold discrim at hdisc
+ nlinarith
+
+/-- The directional Cauchy--Schwarz inequality in the form used for cutoffs. -/
+theorem positive_form_inner_abs_le {D : E →L[ℝ] E} (hD : D.IsPositive) (x y : E) :
+ |⟪x, D y⟫_ℝ| ≤ Real.sqrt ⟪x, D x⟫_ℝ * Real.sqrt ⟪y, D y⟫_ℝ := by
+ have h := positive_form_cauchy_schwarz hD x y
+ have hx := Real.sq_sqrt (hD.inner_nonneg_right x)
+ have hy := Real.sq_sqrt (hD.inner_nonneg_right y)
+ have hs : 0 ≤ Real.sqrt ⟪x, D x⟫_ℝ * Real.sqrt ⟪y, D y⟫_ℝ := by positivity
+ have habs := sq_abs ⟪x, D y⟫_ℝ
+ nlinarith
+
+/-- A small positive form controls the Euclidean norm of its value by its
+own directional energy. -/
+theorem positive_form_norm_sq_le {D : E →L[ℝ] E} (hD : D.IsPositive)
+ {epsilon : ℝ} (hbound : ∀ v, ⟪v, D v⟫_ℝ ≤ epsilon * ‖v‖ ^ 2) (w : E) :
+ ‖D w‖ ^ 2 ≤ epsilon * ⟪w, D w⟫_ℝ := by
+ have henergy := hD.inner_nonneg_right w
+ have hcs := positive_form_cauchy_schwarz hD (D w) w
+ rw [real_inner_self_eq_norm_sq] at hcs
+ have hsmall := mul_le_mul_of_nonneg_right (hbound (D w)) henergy
+ by_cases hzero : ‖D w‖ = 0
+ · rw [hzero]
+ have hDzero : D w = 0 := norm_eq_zero.mp hzero
+ simp [hDzero]
+ have hpos : 0 < ‖D w‖ ^ 2 := sq_pos_of_ne_zero hzero
+ nlinarith
+
+/-- The norm estimate in square-root form, as used for the patch field. -/
+theorem positive_form_norm_le {D : E →L[ℝ] E} (hD : D.IsPositive)
+ {epsilon : ℝ} (hepsilon : 0 ≤ epsilon)
+ (hbound : ∀ v, ⟪v, D v⟫_ℝ ≤ epsilon * ‖v‖ ^ 2) (w : E) :
+ ‖D w‖ ≤ Real.sqrt epsilon * Real.sqrt ⟪w, D w⟫_ℝ := by
+ have h := positive_form_norm_sq_le hD hbound w
+ have henergy := hD.inner_nonneg_right w
+ have hroot : (Real.sqrt epsilon * Real.sqrt ⟪w, D w⟫_ℝ) ^ 2 =
+ epsilon * ⟪w, D w⟫_ℝ := by
+ rw [mul_pow, Real.sq_sqrt hepsilon, Real.sq_sqrt henergy]
+ have hrootpos : 0 ≤ Real.sqrt epsilon * Real.sqrt ⟪w, D w⟫_ℝ := by positivity
+ nlinarith [norm_nonneg (D w)]
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/ProjectionAffineNormalization.lean b/lean/OAI/Geometry/RCD/Coordinates/ProjectionAffineNormalization.lean
new file mode 100644
index 0000000000000000000000000000000000000000..43e42d46f8020392c5761ea88bd72151d67b451e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/ProjectionAffineNormalization.lean
@@ -0,0 +1,131 @@
+import OAI.Geometry.RCD.Harmonic.ScaledHarmonicAffine
+import OAI.Geometry.RCD.Coordinates.ExactNormalizationComparison
+import OAI.Geometry.RCD.Coordinates.LinearNormalization
+import OAI.Geometry.RCD.Harmonic.RadialVolumeUnits
+import OAI.Geometry.RCD.Metric.VolumeRigidityInput
+import OAI.Geometry.RCD.Harmonic.FirstOrderLocalization
+
+namespace OAI
+
+/-! # Affine nondegeneracy at the two actual projection radii -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal InnerProductSpace
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- A splitting frame normalized on the large ball gives both affine
+bounds needed by the actual projection. The small-ball normalizer is
+constructed from the positive Gram, then compared to that same large frame. -/
+theorem projection_affine_bounds {K : ℝ} {n : ℕ} {hX : NoncollapsedRCD K n X}
+ [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ (hgradient : LocalHarmonicL2GradientInput hX)
+ (hmean : LocalHarmonicL2MeanValueInput hX) (hn : 2 ≤ n)
+ {κ : ℝ} (hκ : 0 ≤ κ) :
+ ∃ H : ℝ, 0 ≤ H ∧ ∀ (p : X) (s R : ℝ), 0 < s → s / 4096 ≤ R → R ≤ s →
+ -κ ≤ K * R ^ 2 →
+ ∀ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic) (V W : X → Euclidean n)
+ (N : Euclidean n ≃L[ℝ] Euclidean n) (epsilon : ℝ), 0 ≤ epsilon →
+ (n : ℝ) ^ 2 * (((5 / 3 : ℝ) * (16384 : ℝ) ^ n) * epsilon) ≤ 1 / 2 →
+ (∀ j, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball p (2 * s)) (u j)) →
+ ContinuousOn V (ball p (2 * s)) → V p = 0 →
+ (∀ j, SobolevSpace.toLp (hausdorff n X) hX.quadratic (u j) =ᵐ[
+ (hausdorff n X).restrict (ball p (2 * s))] fun x => V x j) →
+ FirstOrderSplittingOn (hausdorff n X) hX.quadratic p (2 * s) epsilon
+ (transformedColumn (hausdorff n X) hX.quadratic u N) W →
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u) (ball p (2 * s)) measurableSet_ball N →
+ (∀ t : ℝ, 0 < t → t ≤ 2 * s →
+ |(hausdorff n X).real (ball p t) / (euclideanUnitVolume n * t ^ n) - 1| ≤ 1 / 4) →
+ ∀ eta : SobolevSpace (hausdorff n X) hX.quadratic,
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic eta =ᵐ[
+ (hausdorff n X).restrict (ball p R)] fun _ => (1 : ℝ)) →
+ ∀ c a, |c| + s * ‖N.symm a‖ ≤ H *
+ ‖normalizeLocalL2 (hausdorff n X) (ball p R)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineCoordinateMap (hausdorff n X) hX.quadratic u (ball p R)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c, a))‖ := by
+ obtain ⟨Cg, Cm, hCg, hCm, hbound⟩ := scaled_harmonic_affine_nondegeneracy hgradient hmean hn hκ
+ refine ⟨8193 * (Cm + Cg), by linarith, ?_⟩
+ intro p s R hs hRlo hRhi hcurv u V W N epsilon hepsilon hsmall hu hV hcenter hrep hfirst hN hvolume eta heta c a
+ let μ := hausdorff n X
+ let hQ := hX.quadratic
+ let Cvol := (5 / 3 : ℝ) * (16384 : ℝ) ^ n
+ have hCvol : 0 ≤ Cvol := by dsimp only [Cvol]; positivity
+ let U := sobolevColumnMap μ hQ u
+ have hR : 0 < R := lt_of_lt_of_le (by positivity : 0 < s / 4096) hRlo
+ have hsub : ball p (R / 2) ⊆ ball p (2 * s) := ball_subset_ball (by linarith)
+ have hpos : 0 < μ.real (ball p (R / 2)) :=
+ (quarter_volume_bounds (by positivity : 0 < R / 2) (euclideanUnitVolume_pos n)
+ (hvolume (R / 2) (by positivity) (by linarith))).1
+ have hsmallpos : 0 < μ.real (ball p (s / 8192)) :=
+ (quarter_volume_bounds (by positivity : 0 < s / 8192) (euclideanUnitVolume_pos n)
+ (hvolume (s / 8192) (by positivity) (by linarith))).1
+ have hvol : μ.real (ball p (2 * s)) ≤ Cvol * μ.real (ball p (R / 2)) := by
+ have hh := radial_fraction_volume_ratio (by positivity : 0 < 2 * s)
+ (by norm_num : (0 : ℝ) < 1 / 16384) (euclideanUnitVolume_pos n)
+ (hvolume (2 * s) (by positivity) le_rfl)
+ (hvolume ((1 / 16384) * (2 * s)) (by positivity) (by linarith))
+ have heq : (1 / 16384 : ℝ) * (2 * s) = s / 8192 := by ring
+ have hpow : ((1 / 16384 : ℝ) ^ n)⁻¹ = (16384 : ℝ) ^ n := by simp
+ rw [heq, hpow] at hh
+ have hi := (div_le_iff₀ hsmallpos).mp hh
+ exact hi.trans (mul_le_mul_of_nonneg_left
+ (measureReal_mono (ball_subset_ball (by linarith : s / 8192 ≤ R / 2))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))) hCvol)
+ have hcompare (v : Euclidean n) : ‖N.symm v‖ ^ 2 ≤
+ 2 * ⟪v, sobolevMeanGram μ hQ U (ball p (R / 2)) measurableSet_ball v⟫_ℝ := by
+ have hh := (exact_normalization_subball_bounds μ hQ u N hfirst hN
+ (ball p (R / 2)) measurableSet_ball hsub
+ (ne_of_gt (hX.fullSupport p (R / 2) (by positivity)))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (ne_of_gt (hX.fullSupport p (2 * s) (by positivity)))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ hCvol hepsilon hvol v).1
+ rw [meanGram_energy_of_exact_normalization μ hQ U (ball p (2 * s)) measurableSet_ball N hN] at hh
+ have hmul := mul_le_mul_of_nonneg_right hsmall (sq_nonneg ‖N.symm v‖)
+ change (n : ℝ) ^ 2 * (Cvol * epsilon) * ‖N.symm v‖ ^ 2 ≤ (1 / 2) * ‖N.symm v‖ ^ 2 at hmul
+ nlinarith only [hh, hmul]
+ obtain ⟨Ninner, hinner⟩ := exists_exact_mean_normalization μ hQ U (ball p (R / 2))
+ measurableSet_ball (by
+ intro v hv
+ have hnv : N.symm v ≠ 0 := by
+ intro hz
+ apply hv
+ have hh := congrArg N hz
+ simpa only [N.apply_symm_apply, map_zero] using hh
+ have hp := sq_pos_of_pos (norm_pos_iff.mpr hnv)
+ nlinarith only [hcompare v, hp])
+ have hframe (v : Euclidean n) : ‖N.symm v‖ ≤ 2 * ‖Ninner.symm v‖ := by
+ have hh := hcompare v
+ rw [meanGram_energy_of_exact_normalization μ hQ U (ball p (R / 2)) measurableSet_ball Ninner hinner] at hh
+ apply (sq_le_sq₀ (norm_nonneg _) (by positivity)).mp
+ nlinarith [sq_nonneg ‖Ninner.symm v‖]
+ have hRsub : ball p R ⊆ ball p (2 * s) := ball_subset_ball (by linarith)
+ have hh := hbound p R hR hcurv u V (fun j => (hu j).mono μ hQ hRsub)
+ (hV.mono hRsub) hcenter
+ (fun j => ae_restrict_of_ae_restrict_of_subset hRsub (hrep j)) Ninner hinner eta heta c a
+ let alpha := ‖normalizeLocalL2 μ (ball p R) (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineCoordinateMap μ hQ u (ball p R) (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c, a))‖
+ have hconstant : |c| ≤ (Cm + Cg) * alpha := by
+ change |c| + R * ‖Ninner.symm a‖ ≤ (Cm + Cg) * alpha at hh
+ nlinarith [mul_nonneg hR.le (norm_nonneg (Ninner.symm a))]
+ have hlinear : R * ‖Ninner.symm a‖ ≤ (Cm + Cg) * alpha := by
+ change |c| + R * ‖Ninner.symm a‖ ≤ (Cm + Cg) * alpha at hh
+ linarith [abs_nonneg c]
+ have hterm : s * ‖N.symm a‖ ≤ 8192 * (R * ‖Ninner.symm a‖) := by
+ have hx := mul_le_mul_of_nonneg_left (hframe a) hs.le
+ have hy := mul_le_mul_of_nonneg_right hRlo (norm_nonneg (Ninner.symm a))
+ nlinarith only [hx, hy]
+ have hfinal := mul_le_mul_of_nonneg_left hlinear (by norm_num : (0 : ℝ) ≤ 8192)
+ change |c| + s * ‖N.symm a‖ ≤ 8193 * (Cm + Cg) * alpha
+ nlinarith only [hconstant, hterm, hfinal]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/ProjectionCoordinateValues.lean b/lean/OAI/Geometry/RCD/Coordinates/ProjectionCoordinateValues.lean
new file mode 100644
index 0000000000000000000000000000000000000000..e1aaa03f4919e1c78bfd6fbe5d44cd56a5c15ed7
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/ProjectionCoordinateValues.lean
@@ -0,0 +1,52 @@
+import OAI.Geometry.RCD.Harmonic.ProjectionResidualValues
+import OAI.Geometry.RCD.Harmonic.MetricQuadraticError
+
+namespace OAI
+
+/-! # Actual centered coordinate bounds on the projection region -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+omit [ProperSpace X] in
+/-- The existing metric approximation supplies the physical coordinate
+value estimate used in the two-center projection. The bound is uniform
+in the scale, frame, and covector. -/
+theorem projection_coordinate_values {n : ℕ} {p : X} {s epsilon : ℝ}
+ (hs : 0 < s) (hepsilon : epsilon ≤ 1)
+ (u : Fin n → SobolevSpace μ hQ) (V : X → Euclidean n)
+ (N : Euclidean n ≃L[ℝ] Euclidean n) (hcenter : V p = 0)
+ (hrep : ∀ j, SobolevSpace.toLp μ hQ (u j) =ᵐ[
+ μ.restrict (ball p (s / 512))] fun x => V x j)
+ (hmetric : IsPointedApproximation p 0 (s / 64) 4 epsilon
+ (fun x => (s / 64)⁻¹ • (N : Euclidean n →L[ℝ] Euclidean n).adjoint (V x))) :
+ ∀ b : Euclidean n, ∀ᵐ x ∂μ.restrict (ball p (s / 512)),
+ |SobolevSpace.toLp μ hQ (sobolevColumnMap μ hQ u (N b)) x| ≤ s * ‖b‖ := by
+ have hvalue : ∀ᵐ x ∂μ.restrict (ball p (s / 512)),
+ ‖(N : Euclidean n →L[ℝ] Euclidean n).adjoint (V x)‖ ≤ 1 * s := by
+ filter_upwards [ae_restrict_mem measurableSet_ball] with x hx
+ have hdist : dist x p ≤ 4 * (s / 64) := by
+ have hx' := mem_ball.mp hx
+ linarith
+ have hn := (hmetric.centered_norm_error (by positivity : 0 < s / 64)
+ (by norm_num) (by rw [hcenter, map_zero, smul_zero]) hdist).2
+ rw [norm_smul, Real.norm_eq_abs, abs_of_pos (inv_pos.mpr (by positivity : 0 < s / 64))] at hn
+ have hh := mul_le_mul_of_nonneg_left hn (by positivity : 0 ≤ s / 64)
+ rw [← mul_assoc, mul_inv_cancel₀ (by positivity : s / 64 ≠ 0), one_mul] at hh
+ have hb := mul_le_mul_of_nonneg_left hepsilon hs.le
+ nlinarith only [hh, hb, hs]
+ intro b
+ simpa only [one_mul] using framed_coordinate_value_bound μ hQ (ball p (s / 512))
+ u V N hrep hvalue b
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/ProjectionMeasuredCoordinates.lean b/lean/OAI/Geometry/RCD/Coordinates/ProjectionMeasuredCoordinates.lean
new file mode 100644
index 0000000000000000000000000000000000000000..e625697c3fce7b748e3a07a033701d97edd0cb7d
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/ProjectionMeasuredCoordinates.lean
@@ -0,0 +1,105 @@
+import OAI.Geometry.RCD.Coordinates.MeasuredCoordinateInput
+import OAI.Geometry.RCD.Harmonic.MetricQuadraticError
+import OAI.Geometry.RCD.Coordinates.MetricDyadicNormalization
+
+namespace OAI
+
+/-! # The actual metric coordinates on the projection ball -/
+
+open Set Metric MeasureTheory
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X]
+
+/-- The controlled-normalization theorem uses a half-ball in units s/8.
+This is the same physical ball as the radial fit's radius-four ball in
+units s/64, with the exact corresponding error conversion. -/
+theorem radial_metric_from_controlled {n : ℕ} {p : X} {s epsilon : ℝ}
+ (hs : 0 < s) (V : X → Euclidean n)
+ (hf : IsPointedApproximation p 0 (s / 8) (1 / 2) epsilon
+ (fun x => (s / 8)⁻¹ • V x)) :
+ IsPointedApproximation p 0 (s / 64) 4 (8 * epsilon)
+ (fun x => (s / 64)⁻¹ • V x) := by
+ have hrad : s / 8 = 8 * (s / 64) := by ring
+ rw [hrad] at hf
+ have hh := hf.rescale_eight (by positivity : 0 < s / 64)
+ have hscale : (8 : ℝ) * (8 * (s / 64))⁻¹ = (s / 64)⁻¹ := by field_simp
+ simpa only [smul_smul, hscale] using hh
+
+/-- Restrict the centered metric map used by the radial fits and express
+it in the length units of the two-center projection. -/
+theorem projection_metric_rescale {n : ℕ} {p : X} {s delta : ℝ}
+ (hs : 0 < s) (hdelta : 0 ≤ delta) (f : X → Euclidean n) (hcenter : f p = 0)
+ (hf : IsPointedApproximation p 0 (s / 64) 4 delta f) :
+ IsPointedApproximation p 0 s (2 * (1 / 1024)) (delta / 32)
+ (fun x => (1 / 64 : ℝ) • f x) := by
+ have hr : 0 < s / 64 := by positivity
+ refine ⟨by simp only [hcenter, smul_zero, dist_self]; positivity, ?_, ?_⟩
+ · intro x y hx hy
+ have hx' : dist x p ≤ 4 * (s / 64) := by linarith
+ have hy' : dist y p ≤ 4 * (s / 64) := by linarith
+ have hh := hf.2.1 x y hx' hy'
+ rw [dist_smul₀, Real.norm_eq_abs, abs_of_pos (by norm_num : (0 : ℝ) < 1 / 64)]
+ have heq : (1 / 64 : ℝ) * dist (f x) (f y) - dist x y / s =
+ (1 / 64 : ℝ) * (dist (f x) (f y) - dist x y / (s / 64)) := by
+ field_simp
+ rw [heq, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 1 / 64)]
+ nlinarith
+ · intro y hy
+ have hy' : dist ((64 : ℝ) • y) (0 : Euclidean n) ≤ 4 - delta := by
+ rw [dist_zero_right, norm_smul, Real.norm_eq_abs, abs_of_pos (by norm_num : (0 : ℝ) < 64)]
+ rw [dist_zero_right] at hy
+ nlinarith
+ obtain ⟨x, hx, hxy⟩ := hf.2.2 ((64 : ℝ) • y) hy'
+ have hnorm : ‖f x‖ ≤ 64 * ‖y‖ + delta := by
+ have hh := norm_le_norm_add_norm_sub ((64 : ℝ) • y) (f x)
+ rw [norm_sub_rev ((64 : ℝ) • y) (f x)] at hh
+ rw [norm_smul, Real.norm_eq_abs, abs_of_pos (by norm_num : (0 : ℝ) < 64)] at hh
+ rw [dist_eq_norm] at hxy
+ linarith
+ have hdist := (hf.centered_norm_error hr (by norm_num) hcenter hx).1
+ have hdist' : dist x p / (s / 64) ≤ 64 * ‖y‖ + 2 * delta := by
+ linarith [(abs_le.mp hdist).1]
+ have hxsmall : dist x p ≤ (2 * (1 / 1024 : ℝ)) * s := by
+ rw [dist_zero_right] at hy
+ have hh : dist x p / (s / 64) ≤ 1 / 8 := by nlinarith
+ have hh' := (div_le_iff₀ hr).mp hh
+ linarith
+ refine ⟨x, hxsmall, ?_⟩
+ have hyid : y = (1 / 64 : ℝ) • ((64 : ℝ) • y) := by simp [smul_smul]
+ calc
+ dist ((1 / 64 : ℝ) • f x) y =
+ dist ((1 / 64 : ℝ) • f x) ((1 / 64 : ℝ) • ((64 : ℝ) • y)) := by rw [← hyid]
+ _ = (1 / 64 : ℝ) * dist (f x) ((64 : ℝ) • y) := by
+ rw [dist_smul₀, Real.norm_eq_abs, abs_of_pos (by norm_num : (0 : ℝ) < 1 / 64)]
+ _ ≤ delta / 32 := by nlinarith
+
+variable [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+omit [ProperSpace X] in
+/-- The published measured-convergence input applies to the same centered
+coordinates used by the radial argument, at the fixed projection radius. -/
+theorem projection_measured_coordinates {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n)
+ (hmeasured : LocalMeasuredCoordinateInput hX) {epsilon : ℝ} (hepsilon : 0 < epsilon) :
+ ∃ delta : ℝ, 0 < delta ∧ ∀ (p : X) (s : ℝ), 0 < s →
+ -delta / 32 ≤ K * s ^ 2 →
+ ∀ f : X → Euclidean n, Measurable f → f p = 0 →
+ IsPointedApproximation p 0 (s / 64) 4 delta f →
+ IsMeasuredEuclideanApproximation (hausdorff n X) n p s (1 / 1024) epsilon
+ (fun x => (1 / 64 : ℝ) • f x) := by
+ obtain ⟨eta, heta, happly⟩ := hmeasured hn (1 / 1024) epsilon (by norm_num) hepsilon
+ refine ⟨32 * eta, by positivity, ?_⟩
+ intro p s hs hcurv f hmeas hcenter hf
+ apply happly p s hs (by nlinarith) (fun x => (1 / 64 : ℝ) • f x)
+ ((continuous_const_smul (1 / 64 : ℝ)).measurable.comp hmeas)
+ simpa only [mul_div_cancel_left₀ eta (by norm_num : (32 : ℝ) ≠ 0)] using
+ projection_metric_rescale hs (by positivity : 0 ≤ 32 * eta) f hcenter hf
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/Proper.lean b/lean/OAI/Geometry/RCD/Coordinates/Proper.lean
new file mode 100644
index 0000000000000000000000000000000000000000..c40cd57f16229c0e7cc7276f80fe15779d9a7de7
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/Proper.lean
@@ -0,0 +1,127 @@
+import OAI.Geometry.RCD.Coordinates.PatchCover
+import OAI.Analysis.RCDHeat.VolumeComparison
+
+namespace OAI
+
+/-! # Properness from the actual curvature-dimension volume bound
+
+The existing `FullCD.ball_ratio` theorem bounds the mass of every small
+ball centered in a bounded region from below. Disjoint small balls therefore
+bound every separated set. The resulting finite nets prove total boundedness;
+completeness then gives properness. No compactness hypothesis is added.
+-/
+
+open Set Metric MeasureTheory
+open scoped ENNReal NNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+
+omit [MeasurableSpace X] [BorelSpace X] in
+private theorem separated_encard_le_of_finset_bound {A : Set X} {r : ℝ≥0} {N : ℕ}
+ (hbound : ∀ s : Finset X, (s : Set X) ⊆ A →
+ (s : Set X).Pairwise (fun x y => (r : ℝ) ≤ dist x y) → s.card ≤ N)
+ {C : Set X} (hCA : C ⊆ A) (hC : Metric.IsSeparated r C) : C.encard ≤ N := by
+ classical
+ have hsbound (s : Finset X) (hsC : (s : Set X) ⊆ C) : s.card ≤ N := by
+ apply hbound s (hsC.trans hCA)
+ intro x hx y hy hxy
+ have hh := hC (hsC hx) (hsC hy) hxy
+ have hd : r < nndist x y := by
+ simpa only [edist_nndist, ENNReal.coe_lt_coe] using hh
+ exact_mod_cast hd.le
+ have hfin : C.Finite := by
+ by_contra hinf
+ obtain ⟨t, htC, htfin, htcard⟩ := Set.Infinite.exists_subset_ncard_eq hinf (N + 1)
+ have hh := hsbound htfin.toFinset (by simpa only [htfin.coe_toFinset] using htC)
+ rw [← Set.ncard_coe_finset, htfin.coe_toFinset, htcard] at hh
+ omega
+ rw [hfin.encard_eq_coe_toFinset_card]
+ exact_mod_cast hsbound hfin.toFinset (by simp)
+
+/-- Every bounded ball is totally bounded, directly from CD volume comparison. -/
+theorem NoncollapsedRCD.totallyBounded_closedBall {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n) (p : X) (R : ℝ) :
+ TotallyBounded (closedBall p R) := by
+ classical
+ let := hX.separable
+ let := locallyFinite_of_finiteOnBounded (hausdorff n X) hX.finiteOnBounded
+ by_cases hR : R < 0
+ · simp only [closedBall_eq_empty.mpr hR]
+ exact totallyBounded_empty
+ have hR0 : 0 ≤ R := le_of_not_gt hR
+ apply Metric.totallyBounded_iff.mpr
+ intro epsilon hepsilon
+ let r : ℝ≥0 := ⟨min (epsilon / 2) 1, le_of_lt (lt_min (by positivity) zero_lt_one)⟩
+ have hr : 0 < (r : ℝ) := lt_min (by positivity) zero_lt_one
+ have hr1 : (r : ℝ) ≤ 1 := min_le_right _ _
+ have hre : (r : ℝ) < epsilon := (min_le_left _ _).trans_lt (by linarith)
+ let T := R + 1
+ have hT : 0 < T := by dsimp only [T]; linarith only [hR0]
+ have hrT : (r : ℝ) / 2 ≤ T := by dsimp only [T]; linarith only [hr1, hR0]
+ let b := distortionFloor K n (2 * T) ((r : ℝ) / 2 / T) ^ n
+ have hb0 : b ≠ 0 := by
+ dsimp only [b, distortionFloor]
+ exact pow_ne_zero _ (ne_of_gt (ENNReal.ofReal_pos.mpr (by positivity)))
+ have hbt : b ≠ ∞ := by
+ dsimp only [b, distortionFloor]
+ exact ENNReal.pow_ne_top ENNReal.ofReal_ne_top
+ let v := (b * (hausdorff n X) (ball p 1)).toReal
+ have hv : 0 < v := ENNReal.toReal_pos
+ (mul_ne_zero hb0 (ne_of_gt (hX.fullSupport p 1 zero_lt_one)))
+ (ENNReal.mul_ne_top hbt (hX.finiteOnBounded _ isBounded_ball).ne)
+ have hlower (y : X) (hy : y ∈ closedBall p R) :
+ v ≤ (hausdorff n X).real (ball y ((r : ℝ) / 2)) := by
+ have hsub : ball p 1 ⊆ ball y T := by
+ apply Metric.ball_subset_ball'
+ change 1 + dist p y ≤ R + 1
+ have hh : dist y p ≤ R := hy
+ rw [dist_comm]
+ linarith only [hh]
+ have hratio := hX.cd.ball_ratio (hausdorff n X) K n hX.fullSupport hX.finiteOnBounded
+ hn y ((r : ℝ) / 2) T (by positivity) hrT
+ have hh : b * (hausdorff n X) (ball p 1) ≤
+ (hausdorff n X) (ball y ((r : ℝ) / 2)) :=
+ (mul_le_mul' le_rfl (measure_mono hsub)).trans hratio
+ exact ENNReal.toReal_mono (hX.finiteOnBounded _ isBounded_ball).ne hh
+ let N : ℕ := ⌈(hausdorff n X).real (ball p (R + (r : ℝ) / 2)) / v⌉₊
+ have hcard (s : Finset X) (hs : (s : Set X) ⊆ closedBall p R)
+ (hsep : (s : Set X).Pairwise (fun x y => (r : ℝ) ≤ dist x y)) : s.card ≤ N := by
+ have hh := separated_card_mul_volume_le (hausdorff n X) s p hsep
+ (fun y hy => hs hy) (fun y hy => hlower y (hs hy))
+ (hX.finiteOnBounded _ isBounded_ball).ne
+ have hb := (le_div_iff₀ hv).mpr hh
+ exact_mod_cast hb.trans (Nat.le_ceil _)
+ have hpacking : Metric.packingNumber r (closedBall p R) ≠ ⊤ := by
+ apply ne_top_of_le_ne_top (by simp : (N : ℕ∞) ≠ ⊤)
+ exact iSup_le fun C => iSup_le fun hCA => iSup_le fun hC =>
+ separated_encard_le_of_finset_bound hcard hCA hC
+ let C := Metric.maximalSeparatedSet r (closedBall p R)
+ have hfinite : C.Finite := finite_maximalSeparatedSet r _
+ have hcover := Metric.isCover_maximalSeparatedSet hpacking
+ refine ⟨C, hfinite, ?_⟩
+ intro x hx
+ obtain ⟨y, hy, hxy⟩ := hcover hx
+ change edist x y ≤ (r : ℝ≥0∞) at hxy
+ refine mem_iUnion₂.mpr ⟨y, hy, ?_⟩
+ have hh : nndist x y ≤ r := by
+ simpa only [edist_nndist, ENNReal.coe_le_coe] using hxy
+ have hd : dist x y ≤ (r : ℝ) := by exact_mod_cast hh
+ exact hd.trans_lt hre
+
+/-- The proper-space assumption of the conditional chart theorem is itself
+an RCD consequence in the manuscript's dimension range. -/
+theorem NoncollapsedRCD.properSpace {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n) : ProperSpace X := by
+ let := hX.complete
+ refine ⟨fun p R => ?_⟩
+ exact isCompact_iff_totallyBounded_isComplete.mpr
+ ⟨hX.totallyBounded_closedBall hn p R, isClosed_closedBall.isComplete⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/PullbackDensityLaws.lean b/lean/OAI/Geometry/RCD/Coordinates/PullbackDensityLaws.lean
new file mode 100644
index 0000000000000000000000000000000000000000..17d72b11d5c61bf110abce820f86cf176625d647
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/PullbackDensityLaws.lean
@@ -0,0 +1,63 @@
+import OAI.Geometry.RCD.Coordinates.NormalizedDensityLaw
+
+namespace OAI
+
+/-! # Actual source probability densities with prescribed Euclidean limits -/
+
+open Set Filter MeasureTheory
+open scoped Topology BoundedContinuousFunction
+noncomputable section
+namespace RegularPointCoordinates
+variable {X Y : Type*} [MeasurableSpace X]
+ [MetricSpace Y] [MeasurableSpace Y] [BorelSpace Y]
+
+private theorem pullback_density_integrable (P : ProbabilityMeasure X)
+ (v : X → Y) (hv : Measurable v) (f : Y →ᵇ ℝ) :
+ Integrable (fun x => f (v x)) (P : Measure X) :=
+ (integrable_const ‖f‖).mono' (f.continuous.measurable.comp hv).aestronglyMeasurable
+ (Eventually.of_forall fun x => f.norm_coe_le_norm (v x))
+
+def pullbackDensityLaw (P : ProbabilityMeasure X) (v : X → Y) (hv : Measurable v)
+ (f : Y →ᵇ ℝ) (hn : ∀ y, 0≤f y) (hp : 0<∫ x, f (v x) ∂(P : Measure X)) :
+ ProbabilityMeasure X :=
+ normalizedDensityLaw (P : Measure X)
+ (pullback_density_integrable P v hv f) (fun x => hn (v x)) hp
+
+theorem pullbackDensityLaw_integral (P : ProbabilityMeasure X) (v : X → Y) (hv : Measurable v)
+ (f : Y →ᵇ ℝ) (hn : ∀ y, 0≤f y) (hp : 0<∫ x, f (v x) ∂(P : Measure X)) (g : X → ℝ) :
+ (∫ x, g x ∂(pullbackDensityLaw P v hv f hn hp : Measure X))=
+ (∫ x, f (v x) ∂(P : Measure X))⁻¹*(∫ x, f (v x)*g x ∂(P : Measure X)) :=
+ normalizedDensityLaw_integral _ (f.continuous.measurable.comp hv) _ _ _ g
+
+theorem pullback_density_mass_tendsto (P : ℕ → ProbabilityMeasure X) (v : ℕ → X → Y)
+ (hv : ∀ k, Measurable (v k)) {ν : ProbabilityMeasure Y}
+ (hweak : Tendsto (fun k => (P k).map (v k)) atTop (𝓝 ν)) (f : Y →ᵇ ℝ) :
+ Tendsto (fun k => ∫ x, f (v k x) ∂(P k : Measure X)) atTop
+ (𝓝 (∫ y, f y ∂(ν : Measure Y))) := by
+ have ht := ProbabilityMeasure.tendsto_iff_forall_integral_tendsto.mp hweak f
+ simp_rw [ProbabilityMeasure.toMeasure_map,integral_map (hv _).aemeasurable
+ f.continuous.aestronglyMeasurable] at ht
+ exact ht
+
+theorem pullback_density_laws_tendsto (P : ℕ → ProbabilityMeasure X) (v : ℕ → X → Y)
+ (hv : ∀ k, Measurable (v k)) {ν : ProbabilityMeasure Y}
+ (hweak : Tendsto (fun k => (P k).map (v k)) atTop (𝓝 ν))
+ (f : Y →ᵇ ℝ) (hn : ∀ y, 0≤f y) (hp : 0<∫ y, f y ∂(ν : Measure Y))
+ (hps : ∀ k, 0<∫ x, f (v k x) ∂(P k : Measure X)) :
+ Tendsto (fun k => (pullbackDensityLaw (P k) (v k) (hv k) f hn (hps k)).map (v k)) atTop
+ (𝓝 (normalizedDensityLaw (ν : Measure Y) (f.integrable _) hn hp)) := by
+ apply ProbabilityMeasure.tendsto_iff_forall_integral_tendsto.mpr
+ intro g
+ have hnum := pullback_density_mass_tendsto P v hv hweak (f*g)
+ have hden := pullback_density_mass_tendsto P v hv hweak f
+ have ht := (hden.inv₀ hp.ne').mul hnum
+ simpa only [ProbabilityMeasure.toMeasure_map,
+ integral_map (hv _).aemeasurable g.continuous.aestronglyMeasurable,
+ pullbackDensityLaw_integral,normalizedDensityLaw_integral _ f.continuous.measurable,
+ BoundedContinuousFunction.mul_apply] using ht
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/QuadraticCoordinateGradient.lean b/lean/OAI/Geometry/RCD/Coordinates/QuadraticCoordinateGradient.lean
new file mode 100644
index 0000000000000000000000000000000000000000..e2adfea776245bbdb5c8693d0d9e0a5ccaa1f883
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/QuadraticCoordinateGradient.lean
@@ -0,0 +1,75 @@
+import OAI.Geometry.RCD.Harmonic.HarmonicQuadraticPotential
+
+namespace OAI
+
+/-! # The actual gradient of the quadratic coordinate model -/
+
+open Set MeasureTheory
+open scoped NNReal BigOperators
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+private theorem half_square_gamma (u a : SobolevSpace μ hQ) (C : ℝ≥0)
+ (hu : ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ u x| ≤ C) :
+ localGamma μ hQ ((1 / 2 : ℝ) • SobolevSpace.square μ hQ u C) a =ᵐ[μ]
+ fun x => SobolevSpace.toLp μ hQ u x * localGamma μ hQ u a x := by
+ filter_upwards [localGamma_smul_left μ hQ (1 / 2 : ℝ) (SobolevSpace.square μ hQ u C) a,
+ localGamma_square μ hQ u a C hu] with x hsm hsq
+ rw [hsm, hsq]
+ ring
+
+private theorem finite_half_square_gamma {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (C : ℝ≥0) (a : SobolevSpace μ hQ)
+ (hu : ∀ j, ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ (u j) x| ≤ C)
+ (s : Finset (Fin n)) :
+ localGamma μ hQ (∑ j ∈ s, (1 / 2 : ℝ) • SobolevSpace.square μ hQ (u j) C) a =ᵐ[μ]
+ fun x => ∑ j ∈ s, SobolevSpace.toLp μ hQ (u j) x * localGamma μ hQ (u j) a x := by
+ classical
+ induction s using Finset.induction_on with
+ | empty =>
+ simpa only [Finset.sum_empty, zero_smul, zero_mul] using
+ localGamma_smul_left μ hQ 0 (0 : SobolevSpace μ hQ) a
+ | @insert j s hj ih =>
+ simp only [Finset.sum_insert hj]
+ filter_upwards [localGamma_add_left μ hQ
+ ((1 / 2 : ℝ) • SobolevSpace.square μ hQ (u j) C)
+ (∑ k ∈ s, (1 / 2 : ℝ) • SobolevSpace.square μ hQ (u k) C) a,
+ half_square_gamma μ hQ (u j) a C (hu j), ih] with x hadd hsingle hsum
+ rw [hadd, hsingle, hsum]
+
+theorem coordinateQuadratic_gradient {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (C : ℝ≥0) (a : SobolevSpace μ hQ)
+ (hu : ∀ j, ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ (u j) x| ≤ C) :
+ localGamma μ hQ (coordinateQuadratic μ hQ u C) a =ᵐ[μ]
+ fun x => ∑ j, SobolevSpace.toLp μ hQ (u j) x * localGamma μ hQ (u j) a x :=
+ finite_half_square_gamma μ hQ u C a hu Finset.univ
+
+/-- The quadratic model has the expected energy density, with the actual
+coordinate Gram entries. No Euclidean identity for that Gram is assumed. -/
+theorem coordinateQuadratic_gradient_self {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (C : ℝ≥0) (hu : ∀ j, ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ (u j) x| ≤ C) :
+ localGamma μ hQ (coordinateQuadratic μ hQ u C) (coordinateQuadratic μ hQ u C) =ᵐ[μ]
+ fun x => ∑ i, ∑ j, (SobolevSpace.toLp μ hQ (u i) x * SobolevSpace.toLp μ hQ (u j) x) *
+ localGamma μ hQ (u j) (u i) x := by
+ have hi (i : Fin n) : localGamma μ hQ (u i) (coordinateQuadratic μ hQ u C) =ᵐ[μ]
+ fun x => ∑ j, SobolevSpace.toLp μ hQ (u j) x * localGamma μ hQ (u j) (u i) x :=
+ (localGamma_comm μ hQ (u i) _).trans (coordinateQuadratic_gradient μ hQ u C (u i) hu)
+ have hall := (Filter.eventually_all_finset (Finset.univ : Finset (Fin n))).mpr
+ (fun i _ => hi i)
+ filter_upwards [coordinateQuadratic_gradient μ hQ u C (coordinateQuadratic μ hQ u C) hu,
+ hall] with x hx hix
+ rw [hx]
+ apply Finset.sum_congr rfl
+ intro i hi
+ rw [hix i hi, Finset.mul_sum]
+ exact Finset.sum_congr rfl fun j _ => by ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/QuadraticMetricError.lean b/lean/OAI/Geometry/RCD/Coordinates/QuadraticMetricError.lean
new file mode 100644
index 0000000000000000000000000000000000000000..1c936899c060ac99d4641ab8785ddf2cd22710a0
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/QuadraticMetricError.lean
@@ -0,0 +1,37 @@
+import OAI.Geometry.RCD.Harmonic.PointedRadialDistance
+
+namespace OAI
+
+/-! # Quantitative squared-distance errors for variational test recovery -/
+
+open Set Metric
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem sq_error_of_abs_sub_le {a b B ε : ℝ} (ha : 0≤a) (hb : 0≤b)
+ (hbB : b≤B) (hε : 0≤ε) (he : |a-b|≤ε) :
+ |a^2-b^2|≤ε*(2*B+ε) := by
+ have hpm := abs_le.mp he
+ rw [sq_sub_sq,abs_mul]
+ have hab : 0≤a+b := add_nonneg ha hb
+ rw [abs_of_nonneg hab]
+ simpa only [mul_comm] using (mul_le_mul_of_nonneg_right he hab).trans
+ (mul_le_mul_of_nonneg_left (show a+b≤2*B+ε by linarith) hε)
+
+theorem pointed_square_distance_error {X : Type*} [MetricSpace X]
+ {n : ℕ} {p x y : X} {r S ε B : ℝ} {v : X → Euclidean n}
+ (hr : 0 (2*R)⁻¹ • (v x-v p)) ∧
+ ∀ x∈U, ∀ r : ℝ, 0 (φ.norm_coe_le_norm z).trans hφn)
+ have hi' : |∫ z in ball (0:Euclidean n) R, φ z|≤VR := by
+ simpa only [VR,Real.norm_eq_abs,Measure.real,Measure.restrict_apply_univ,one_mul] using hi
+ change |VS⁻¹*(∫ z in ball (0:Euclidean n) R, φ z)|≤VS⁻¹*VR
+ rw [abs_mul,abs_of_pos (inv_pos.mpr hVS)]
+ exact mul_le_mul_of_nonneg_left hi' (inv_nonneg.mpr hVS.le)
+ have he := normalized_quotient_error hb hlk.le ha (ak:=ak) (bk:=bk)
+ have hea : |ak-a|<δ := htests φ hφ hφn
+ have heb : |bk-b|<δ := by simpa only [Real.dist_eq] using hmk
+ have hsmall : (2/b)*(|ak-a|+|bk-b|)<η := by
+ have hsum : |ak-a|+|bk-b|<2*δ := by linarith
+ have hx := mul_lt_mul_of_pos_left hsum (show 0<2/b from div_pos (by norm_num) hb)
+ have hval : (2/b)*(2*δ)=η/2 := by dsimp only [δ]; field_simp [hb.ne']; ring
+ rw [hval] at hx
+ exact hx.trans (half_lt_self hη)
+ have hbki : μ.real (ball (p k) (R*r k))≠0 := by
+ intro hz
+ have : bk=0 := by simp only [bk,hz,mul_zero]
+ change b/2 (hX.finiteOnBounded _ isBounded_ball).ne)
+ (fun k => ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hS (hr k))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne)
+ (fun k => SobolevSpace.toLp (hausdorff n X) hX.quadratic (u k)) g hgm
+ (fun k => (Lp.memLp (SobolevSpace.toLp (hausdorff n X) hX.quadratic (u k))).mono_measure
+ Measure.restrict_le_self)
+ (fun k => sobolev_mean_sq_le_one_of_normalized (hausdorff n X) hX.quadratic
+ (ball (p k) (S*r k)) (hX.finiteOnBounded _ isBounded_ball).ne (u k) (hnorm k)) hg hconv
+ refine ⟨hLp,?_⟩
+ have hsq := normalizeLocalL2_norm_sq volume (ball (0:Euclidean n) S)
+ measure_ball_ne_top (hLp.toLp g)
+ have he : (∫ z in ball 0 S, ((hLp.toLp g) z)^2)=∫ z in ball 0 S, (g z)^2 := by
+ apply integral_congr_ae
+ filter_upwards [MemLp.coeFn_toLp hLp] with z hz
+ rw [hz]
+ rw [he] at hsq
+ nlinarith [norm_nonneg (normalizeLocalL2 volume (ball 0 S) measure_ball_ne_top (hLp.toLp g))]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/VanishingDiagonalCost.lean b/lean/OAI/Geometry/RCD/Coordinates/VanishingDiagonalCost.lean
new file mode 100644
index 0000000000000000000000000000000000000000..56eb21922a2cdad93dbe32cbc184767f7ddf6aed
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/VanishingDiagonalCost.lean
@@ -0,0 +1,32 @@
+import OAI.Geometry.RCD.Coordinates.VanishingRadiusCost
+
+namespace OAI
+
+/-! # A slowly varying level retaining vanishing nonnegative costs -/
+
+open Filter
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem exists_vanishing_diagonal_cost (e : ℕ → ℕ → ℝ)
+ (he : ∀ m k, 0 ≤ e m k)
+ (hlim : ∀ m, Tendsto (e m) atTop (𝓝 0)) :
+ ∃ d : ℕ → ℕ, Tendsto d atTop atTop ∧
+ Tendsto (fun k => e (d k) k) atTop (𝓝 0) := by
+ let P (m k : ℕ) := e m k ≤ ((m:ℝ)+2)⁻¹
+ have hP (m : ℕ) : ∀ᶠ k in atTop, P m k :=
+ ((hlim m).eventually (Iio_mem_nhds (by positivity : (0:ℝ)<((m:ℝ)+2)⁻¹))).mono
+ (fun _ hk => hk.le)
+ obtain ⟨d,hd,hbound⟩ := exists_eventual_diagonal_level P hP
+ refine ⟨d,hd,?_⟩
+ have htop : Tendsto (fun k => (d k:ℝ)+2) atTop atTop :=
+ tendsto_atTop_add_const_right _ _ (tendsto_natCast_atTop_atTop.comp hd)
+ exact squeeze_zero' (Eventually.of_forall (fun k => he (d k) k)) hbound
+ (tendsto_inv_atTop_zero.comp htop)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/VanishingRadiusCost.lean b/lean/OAI/Geometry/RCD/Coordinates/VanishingRadiusCost.lean
new file mode 100644
index 0000000000000000000000000000000000000000..5a17bb4246a86f1cea8d0aaa50225f5917733ce3
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/VanishingRadiusCost.lean
@@ -0,0 +1,46 @@
+import OAI.Geometry.RCD.Sobolev.EventualDiagonalLevel
+import OAI.Geometry.RCD.Coordinates.NormalizedL2ProductError
+
+namespace OAI
+
+/-! # Shrinking endpoint balls while their normalized error cost vanishes -/
+
+open Filter
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem exists_vanishing_radius_cost (e : ℕ → ℝ) (he : ∀ k, 0 ≤ e k)
+ (he0 : Tendsto e atTop (𝓝 0)) (n : ℕ) :
+ ∃ δ : ℕ → ℝ, (∀ k, 0 < δ k ∧ δ k ≤ 1/2) ∧
+ Tendsto δ atTop (𝓝 0) ∧
+ Tendsto (fun k => e k/(δ k)^n) atTop (𝓝 0) := by
+ let P (m k : ℕ) := e k*((m:ℝ)+2)^n ≤ ((m:ℝ)+2)⁻¹
+ have hP (m : ℕ) : ∀ᶠ k in atTop, P m k := by
+ have hh : Tendsto (fun k => e k*((m:ℝ)+2)^n) atTop (𝓝 0) := by
+ simpa only [zero_mul] using he0.mul_const (((m:ℝ)+2)^n)
+ exact (hh.eventually (Iio_mem_nhds (by positivity : (0:ℝ)<((m:ℝ)+2)⁻¹))).mono
+ (fun _ hk => hk.le)
+ obtain ⟨d,hd,hbound⟩ := exists_eventual_diagonal_level P hP
+ let δ (k : ℕ) := ((d k:ℝ)+2)⁻¹
+ have hδ (k : ℕ) : 0 < δ k ∧ δ k ≤ 1/2 := by
+ dsimp only [δ]
+ constructor
+ · positivity
+ · rw [one_div]
+ exact inv_anti₀ (by norm_num) (by have hh : (0:ℝ) ≤ d k := Nat.cast_nonneg _; linarith)
+ have htop : Tendsto (fun k => (d k:ℝ)+2) atTop atTop :=
+ tendsto_atTop_add_const_right _ _ (tendsto_natCast_atTop_atTop.comp hd)
+ have hδ0 : Tendsto δ atTop (𝓝 0) := tendsto_inv_atTop_zero.comp htop
+ refine ⟨δ,hδ,hδ0,?_⟩
+ apply squeeze_zero' (Eventually.of_forall (fun k => div_nonneg (he k) (pow_nonneg (hδ k).1.le n)))
+ ?_ hδ0
+ filter_upwards [hbound] with k hk
+ change e k*((d k:ℝ)+2)^n ≤ ((d k:ℝ)+2)⁻¹ at hk
+ simpa only [δ,inv_pow,div_inv_eq_mul] using hk
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/VolumeProfileRegularity.lean b/lean/OAI/Geometry/RCD/Coordinates/VolumeProfileRegularity.lean
new file mode 100644
index 0000000000000000000000000000000000000000..9277dd79c13fcade93a9f6e42040770a41826554
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/VolumeProfileRegularity.lean
@@ -0,0 +1,158 @@
+import OAI.Geometry.RCD.Metric.ComparisonModel
+import Mathlib.MeasureTheory.Integral.IntervalIntegral.AbsolutelyContinuousFun
+
+namespace OAI
+
+/-!
+# Absolute continuity of the Euclidean-normalized volume profile
+
+Bishop--Gromov and a positive Lipschitz comparison model make ball volume
+Lipschitz on every compact interval of positive radii. Multiplication by the
+smooth Euclidean normalization then gives the absolute continuity needed by
+the radial source budget.
+-/
+
+open Set Metric MeasureTheory Filter
+open scoped ENNReal NNReal Topology
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+theorem volume_profile_lipschitzOn {V model : ℝ → ℝ} {a b m0 V0 : ℝ}
+ (hm0 : 0 < m0) (hV0 : 0 ≤ V0) (K : ℝ≥0)
+ (hVmono : MonotoneOn V (Icc a b)) (hVnonneg : ∀ t ∈ Icc a b, 0 ≤ V t)
+ (hVupper : ∀ t ∈ Icc a b, V t ≤ V0)
+ (hmodel : ∀ t ∈ Icc a b, m0 ≤ model t)
+ (hLip : LipschitzOnWith K model (Icc a b))
+ (hcross : ∀ s ∈ Icc a b, ∀ t ∈ Icc a b, s ≤ t → V t * model s ≤ V s * model t) :
+ LipschitzOnWith ⟨V0 * K / m0, by positivity⟩ V (Icc a b) := by
+ let C : ℝ≥0 := ⟨V0 * K / m0, by positivity⟩
+ have hdelta (s : ℝ) (hs : s ∈ Icc a b) (t : ℝ) (ht : t ∈ Icc a b) (hst : s ≤ t) :
+ V t - V s ≤ C * (t - s) := by
+ have hinc : 0 ≤ V t - V s := sub_nonneg.mpr (hVmono hs ht hst)
+ have hml := hLip.dist_le_mul t ht s hs
+ rw [Real.dist_eq, Real.dist_eq, abs_of_nonneg (sub_nonneg.mpr hst)] at hml
+ have hb : (V t - V s) * m0 ≤ V0 * K * (t - s) := by
+ calc
+ _ ≤ (V t - V s) * model s := mul_le_mul_of_nonneg_left (hmodel s hs) hinc
+ _ ≤ V s * (model t - model s) := by nlinarith [hcross s hs t ht hst]
+ _ ≤ V s * |model t - model s| :=
+ mul_le_mul_of_nonneg_left (le_abs_self _) (hVnonneg s hs)
+ _ ≤ V s * (K * (t - s)) := mul_le_mul_of_nonneg_left hml (hVnonneg s hs)
+ _ ≤ V0 * K * (t - s) := by
+ have hh := mul_le_mul_of_nonneg_right (hVupper s hs)
+ (mul_nonneg K.coe_nonneg (sub_nonneg.mpr hst))
+ simpa only [mul_assoc] using hh
+ have hd := (le_div_iff₀ hm0).mpr hb
+ exact hd.trans_eq (by
+ change V0 * (K : ℝ) * (t - s) / m0 = (V0 * (K : ℝ) / m0) * (t - s)
+ ring)
+ have hordered (s : ℝ) (hs : s ∈ Icc a b) (t : ℝ) (ht : t ∈ Icc a b) (hst : s ≤ t) :
+ dist (V s) (V t) ≤ C * dist s t := by
+ have hv := hVmono hs ht hst
+ simpa only [Real.dist_eq, abs_of_nonpos (sub_nonpos.mpr hv),
+ abs_of_nonpos (sub_nonpos.mpr hst), neg_sub] using hdelta s hs t ht hst
+ apply LipschitzOnWith.of_dist_le_mul
+ intro s hs t ht
+ rcases le_total s t with hst | hts
+ · exact hordered s hs t ht hst
+ · simpa only [dist_comm] using hordered t ht s hs hts
+
+/-- The fixed negative-curvature comparison volume is continuously differentiable. -/
+theorem contDiff_one_comparisonModelVolume (m : ℕ) (c : ℝ) :
+ ContDiff ℝ 1 (comparisonModelVolume m c) := by
+ have hcont : Continuous (fun t => radialComparison c t ^ m) :=
+ (continuous_radialComparison c).pow m
+ have hd (r : ℝ) : HasDerivAt (comparisonModelVolume m c)
+ ((m + 1 : ℝ) * radialComparison c r ^ m) r := by
+ change HasDerivAt (fun r => (m + 1 : ℝ) * ∫ t in 0..r, radialComparison c t ^ m) _ r
+ exact (intervalIntegral.integral_hasDerivAt_right (hcont.intervalIntegrable 0 r)
+ hcont.aestronglyMeasurable.stronglyMeasurableAtFilter hcont.continuousAt).const_mul _
+ apply contDiff_one_iff_deriv.mpr
+ refine ⟨fun r => (hd r).differentiableAt, ?_⟩
+ have he : deriv (comparisonModelVolume m c) = fun r => (m + 1 : ℝ) * radialComparison c r ^ m :=
+ funext fun r => (hd r).deriv
+ rw [he]
+ exact continuous_const.mul hcont
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+
+/-- Ball volume is absolutely continuous away from radius zero under the
+published Bishop--Gromov comparison with the explicit model. -/
+theorem ball_volume_absolutelyContinuous {μ : Measure X} (m : ℕ) {c : ℝ} (hc : 0 ≤ c)
+ (hBG : BallVolumeComparison μ (comparisonModelVolume m c)) (x : X)
+ {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (hfin : μ (ball x b) ≠ ∞) :
+ AbsolutelyContinuousOnInterval (fun t => μ.real (ball x t)) a b := by
+ have hb : 0 < b := ha.trans_le hab
+ let model := comparisonModelVolume m c
+ obtain ⟨K, hK⟩ := (contDiff_one_comparisonModelVolume m c).contDiffOn.exists_lipschitzOnWith
+ (s := Icc a b) (by decide) (convex_Icc a b) isCompact_Icc
+ have hmono : MonotoneOn (fun t => μ.real (ball x t)) (Icc a b) := by
+ intro s hs t ht hst
+ exact measureReal_mono (ball_subset_ball hst)
+ (measure_ne_top_of_subset (ball_subset_ball ht.2) hfin)
+ have hupper (t : ℝ) (ht : t ∈ Icc a b) : μ.real (ball x t) ≤ μ.real (ball x b) :=
+ measureReal_mono (ball_subset_ball ht.2) hfin
+ have hmodel (t : ℝ) (ht : t ∈ Icc a b) : a ^ (m + 1) ≤ model t := by
+ exact (pow_le_pow_left₀ ha.le ht.1 _).trans
+ (comparisonModelVolume_bounds m hc (ha.le.trans ht.1)).1
+ have hcross (s : ℝ) (hs : s ∈ Icc a b) (t : ℝ) (_ht : t ∈ Icc a b) (hst : s ≤ t) :
+ μ.real (ball x t) * model s ≤ μ.real (ball x s) * model t :=
+ hBG x s t (ha.trans_le hs.1) hst
+ have hLip := volume_profile_lipschitzOn (pow_pos ha _) measureReal_nonneg K hmono
+ (fun _ _ => measureReal_nonneg) hupper hmodel hK hcross
+ rw [← uIcc_of_le hab] at hLip
+ exact hLip.absolutelyContinuousOnInterval
+
+/-- Euclidean-normalized volume retains absolute continuity on positive
+radius intervals; this does not assume monotonicity of that normalization. -/
+theorem normalized_ball_volume_absolutelyContinuous {μ : Measure X} (m : ℕ) {c : ℝ} (hc : 0 ≤ c)
+ (hBG : BallVolumeComparison μ (comparisonModelVolume m c)) (x : X)
+ {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (hfin : μ (ball x b) ≠ ∞) :
+ AbsolutelyContinuousOnInterval (fun t => μ.real (ball x t) / t ^ (m + 1)) a b := by
+ have hV := ball_volume_absolutelyContinuous m hc hBG x ha hab hfin
+ have hpow : ContDiffOn ℝ 1 (fun t : ℝ => (t ^ (m + 1))⁻¹) (uIcc a b) := by
+ apply (contDiffOn_id.pow (m + 1)).inv
+ intro t ht
+ rw [uIcc_of_le hab] at ht
+ exact pow_ne_zero _ (ne_of_gt (ha.trans_le ht.1))
+ have hm := hV.mul hpow.absolutelyContinuousOnInterval
+ change AbsolutelyContinuousOnInterval
+ (fun t => μ.real (ball x t) * (t ^ (m + 1))⁻¹) a b at hm
+ simpa only [div_eq_mul_inv] using hm
+
+variable [BorelSpace X] [ProperSpace X] {μ : Measure X} [IsFiniteMeasureOnCompacts μ]
+
+/-- Bishop--Gromov with a positive continuous model excludes mass on every
+positive-radius sphere, not merely almost every sphere. -/
+theorem sphere_measure_zero_of_comparison {model : ℝ → ℝ}
+ (hBG : BallVolumeComparison μ model) (hcont : Continuous model)
+ (x : X) {r : ℝ} (hr : 0 < r) (hmodel : 0 < model r) : μ (sphere x r) = 0 := by
+ have hle : μ.real (closedBall x r) * model r ≤ μ.real (ball x r) * model r := by
+ have ht : Tendsto (fun i : ℕ => r + 1 / ((i : ℝ) + 1)) atTop (𝓝 r) := by
+ simpa only [add_zero] using tendsto_one_div_add_atTop_nhds_zero_nat.const_add r
+ apply ge_of_tendsto (tendsto_const_nhds.mul (hcont.continuousAt.tendsto.comp ht))
+ apply Eventually.of_forall
+ intro i
+ have hd : r < r + 1 / ((i : ℝ) + 1) := lt_add_of_pos_right _ (by positivity)
+ calc
+ μ.real (closedBall x r) * model r ≤
+ μ.real (ball x (r + 1 / ((i : ℝ) + 1))) * model r :=
+ mul_le_mul_of_nonneg_right
+ (measureReal_mono (closedBall_subset_ball hd) measure_ball_lt_top.ne) hmodel.le
+ _ ≤ _ := hBG x r _ hr hd.le
+ have hreal : μ.real (closedBall x r) = μ.real (ball x r) :=
+ le_antisymm ((mul_le_mul_iff_left₀ hmodel).mp hle)
+ (measureReal_mono ball_subset_closedBall (isCompact_closedBall x r).measure_ne_top)
+ have hm : μ (closedBall x r) = μ (ball x r) :=
+ (measureReal_eq_measureReal_iff (isCompact_closedBall x r).measure_ne_top
+ measure_ball_lt_top.ne).mp hreal
+ rw [← closedBall_sdiff_ball, measure_sdiff ball_subset_closedBall
+ isOpen_ball.measurableSet.nullMeasurableSet measure_ball_lt_top.ne, hm, tsub_self]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/VolumeRegularity.lean b/lean/OAI/Geometry/RCD/Coordinates/VolumeRegularity.lean
new file mode 100644
index 0000000000000000000000000000000000000000..84078cc77c61aed3f32bf18296cf742bea6fd56e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/VolumeRegularity.lean
@@ -0,0 +1,55 @@
+import OAI.Geometry.RCD.Metric.VolumeDerivative
+
+namespace OAI
+
+/-! # Absolute continuity of radial ball volumes from CD alone -/
+
+open Set Metric MeasureTheory
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.ball_volume_absolutelyContinuous {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n) (p : X)
+ {u v : ℝ} (hu : 0 < u) (huv : u ≤ v) :
+ AbsolutelyContinuousOnInterval (fun r => (hausdorff n X).real (ball p r)) u v := by
+ let := hX.separable
+ let := locallyFinite_of_finiteOnBounded (hausdorff n X) hX.finiteOnBounded
+ by_cases hK : 0 ≤ K
+ · exact RegularPointCoordinates.ball_volume_absolutelyContinuous (n - 1) (by norm_num)
+ (hX.zero_model_ballVolumeComparison hn hK) p hu huv
+ (hX.finiteOnBounded _ isBounded_ball).ne
+ have hKneg : K < 0 := lt_of_not_ge hK
+ let a := Real.sqrt (-K / ((n : ℝ) - 1))
+ let model : ℝ → ℝ := fun r => r * Real.sinh (r * a) ^ (n - 1)
+ have hn1 : (1 : ℝ) < n := by exact_mod_cast (show 1 < n by omega)
+ have ha : 0 < a := Real.sqrt_pos.mpr (div_pos (neg_pos.mpr hKneg) (sub_pos.mpr hn1))
+ have hmodel : ContDiff ℝ 1 model := by dsimp only [model]; fun_prop
+ obtain ⟨L, hL⟩ := hmodel.contDiffOn.exists_lipschitzOnWith
+ (s := Icc u v) (by decide) (convex_Icc u v) isCompact_Icc
+ have hm0 : 0 < model u := mul_pos hu (pow_pos (Real.sinh_pos_iff.mpr (mul_pos hu ha)) _)
+ have hVmono : MonotoneOn (fun r => (hausdorff n X).real (ball p r)) (Icc u v) := by
+ intro r hr s hs hrs
+ exact measureReal_mono (ball_subset_ball hrs) (hX.finiteOnBounded _ isBounded_ball).ne
+ have hVupper (r : ℝ) (hr : r ∈ Icc u v) :
+ (hausdorff n X).real (ball p r) ≤ (hausdorff n X).real (ball p v) :=
+ measureReal_mono (ball_subset_ball hr.2) (hX.finiteOnBounded _ isBounded_ball).ne
+ have hmlower (r : ℝ) (hr : r ∈ Icc u v) : model u ≤ model r := by
+ have hs : 0 < Real.sinh (u * a) := Real.sinh_pos_iff.mpr (mul_pos hu ha)
+ have hmon := Real.sinh_le_sinh.mpr (mul_le_mul_of_nonneg_right hr.1 ha.le)
+ exact mul_le_mul hr.1 (pow_le_pow_left₀ hs.le hmon _)
+ (pow_nonneg hs.le _) (hu.le.trans hr.1)
+ have hBG := hX.cd.hyperbolic_radial_ballVolumeComparison (hausdorff n X)
+ hX.fullSupport hX.finiteOnBounded hn hKneg
+ have hcross (r : ℝ) (hr : r ∈ Icc u v) (s : ℝ) (_hs : s ∈ Icc u v) (hrs : r ≤ s) :
+ (hausdorff n X).real (ball p s) * model r ≤
+ (hausdorff n X).real (ball p r) * model s := hBG p r s (hu.trans_le hr.1) hrs
+ have hLip := volume_profile_lipschitzOn hm0 measureReal_nonneg L hVmono
+ (fun _ _ => measureReal_nonneg) hVupper hmlower hL hcross
+ rw [← uIcc_of_le huv] at hLip
+ exact hLip.absolutelyContinuousOnInterval
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/VolumeRigidityMain.lean b/lean/OAI/Geometry/RCD/Coordinates/VolumeRigidityMain.lean
new file mode 100644
index 0000000000000000000000000000000000000000..f90b9cb12fc5787146f73a5620d5511aa18c9f61
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/VolumeRigidityMain.lean
@@ -0,0 +1,31 @@
+import OAI.Geometry.RCD.Coordinates.RegularVolumeConvergence
+import OAI.Geometry.RCD.Coordinates.TwoGeometricInputs
+
+namespace OAI
+
+/-! # Regular-point charts under local volume rigidity
+
+Absolute regular-point volume convergence follows from first-order
+coordinate maps and their image mass. The local volume rigidity
+hypothesis is De Philippis--Gigli (2018), Theorem 1.6.
+-/
+
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+
+theorem regular_coordinates_of_volume_rigidity {K : ℝ} {n : ℕ}
+ (hn : 2≤n) (hX : NoncollapsedRCD K n X) :
+ let _ := hX.properSpace hn
+ ∀ {p : X}, IsRegular n p → LocalVolumeRigidityInput hX → HasOpenBilipschitzChart n p := by
+ let := hX.properSpace hn
+ dsimp only
+ intro p hp hrigidity
+ exact regular_coordinates_of_two_geometric_inputs hn hX hp
+ (hX.regular_volume_convergence hn hp) hrigidity
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/WeightedBilinearMeasure.lean b/lean/OAI/Geometry/RCD/Coordinates/WeightedBilinearMeasure.lean
new file mode 100644
index 0000000000000000000000000000000000000000..562a287aacc34a35a970291a47ab12107e5bd8cb
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/WeightedBilinearMeasure.lean
@@ -0,0 +1,177 @@
+import OAI.Geometry.RCD.Coordinates.PositiveBilinearMeasure
+import Mathlib.MeasureTheory.VectorMeasure.Integral
+import Mathlib.MeasureTheory.VectorMeasure.Variation.SignedMeasure
+import Mathlib.Topology.ContinuousMap.Bounded.Normed
+
+namespace OAI
+
+/-!
+# Integrating full positive measure-valued forms
+
+Bounded continuous weights act on the full signed measures. In particular,
+their singular parts contribute to every weighted quadratic form. These
+constructions do not assert existence of the local Bochner measure.
+-/
+
+open Set MeasureTheory
+open scoped InnerProductSpace BoundedContinuousFunction
+
+noncomputable section
+
+namespace RegularPointCoordinates
+namespace PositiveBilinearMeasure
+
+variable {X E : Type*} [TopologicalSpace X] [MeasurableSpace X] [BorelSpace X]
+ [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]
+ (M : PositiveBilinearMeasure X E)
+
+theorem integrable_weight (w : X →ᵇ ℝ) (ν : SignedMeasure X) :
+ ν.Integrable w := by
+ let : IsFiniteMeasure ν.variation := by
+ rw [← ν.totalVariation_eq_variation]
+ infer_instance
+ exact Integrable.of_bound w.continuous.aestronglyMeasurable ‖w‖
+ (Filter.Eventually.of_forall w.norm_coe_le_norm)
+
+/-- Integration is bilinear in the coordinate directions, including the
+off-diagonal signed measures. -/
+def weightedBilinear (w : X →ᵇ ℝ) : E →ₗ[ℝ] E →ₗ[ℝ] ℝ :=
+ LinearMap.mk₂ ℝ (fun v z => ∫ᵛ x, w x ∂<•(M.bilinear v z))
+ (by
+ intro u v z
+ rw [map_add, LinearMap.add_apply]
+ exact VectorMeasure.integral_add_vectorMeasure
+ (integrable_weight w _) (integrable_weight w _))
+ (by intro c v z; simp)
+ (by
+ intro u v z
+ rw [map_add]
+ exact VectorMeasure.integral_add_vectorMeasure
+ (integrable_weight w _) (integrable_weight w _))
+ (by intro c v z; simp)
+
+def weightedContinuous (w : X →ᵇ ℝ) : E →L[ℝ] E →L[ℝ] ℝ :=
+ ((LinearMap.toContinuousLinearMap : (E →ₗ[ℝ] ℝ) ≃ₗ[ℝ] (E →L[ℝ] ℝ)).toLinearMap.comp
+ (M.weightedBilinear w)).toContinuousLinearMap
+
+def weightedOperator (w : X →ᵇ ℝ) : E →L[ℝ] E :=
+ InnerProductSpace.continuousLinearMapOfBilin (M.weightedContinuous w)
+
+theorem weightedOperator_inner (w : X →ᵇ ℝ) (v z : E) :
+ ⟪M.weightedOperator w v, z⟫_ℝ = ∫ᵛ x, w x ∂<•(M.bilinear v z) :=
+ InnerProductSpace.continuousLinearMapOfBilin_apply _ _ _
+
+omit [TopologicalSpace X] [BorelSpace X] [FiniteDimensional ℝ E] in
+theorem measure_toSignedMeasure (v : E) :
+ (M.measure v).toSignedMeasure = M.bilinear v v :=
+ SignedMeasure.toMeasureOfZeroLE_toSignedMeasure _ _
+
+/-- Diagonal weighted forms are ordinary integrals against the actual
+positive measure, without discarding singular mass. -/
+theorem weightedOperator_energy (w : X →ᵇ ℝ) (v : E) :
+ ⟪v, M.weightedOperator w v⟫_ℝ = ∫ x, w x ∂(M.measure v) := by
+ rw [real_inner_comm, weightedOperator_inner, ← M.measure_toSignedMeasure v]
+ exact VectorMeasure.integral_toSignedMeasure
+
+/-- A real weighted measure-valued form stays symmetric even when the
+weight changes sign. -/
+theorem weightedOperator_isSymmetric (w : X →ᵇ ℝ) :
+ (M.weightedOperator w).IsSymmetric := by
+ intro v z
+ change ⟪M.weightedOperator w v, z⟫_ℝ = ⟪v, M.weightedOperator w z⟫_ℝ
+ calc
+ _ = ∫ᵛ x, w x ∂<•(M.bilinear v z) := M.weightedOperator_inner w v z
+ _ = ∫ᵛ x, w x ∂<•(M.bilinear z v) := by rw [M.symmetric v z]
+ _ = ⟪M.weightedOperator w z, v⟫_ℝ := (M.weightedOperator_inner w z v).symm
+ _ = _ := real_inner_comm _ _
+
+theorem weightedOperator_isPositive (w : X →ᵇ ℝ) (hw : ∀ x, 0 ≤ w x) :
+ (M.weightedOperator w).IsPositive := by
+ constructor
+ · intro v z
+ change ⟪M.weightedOperator w v, z⟫_ℝ = ⟪v, M.weightedOperator w z⟫_ℝ
+ calc
+ _ = ∫ᵛ x, w x ∂<•(M.bilinear v z) := M.weightedOperator_inner w v z
+ _ = ∫ᵛ x, w x ∂<•(M.bilinear z v) := by rw [M.symmetric v z]
+ _ = ⟪M.weightedOperator w z, v⟫_ℝ := (M.weightedOperator_inner w z v).symm
+ _ = _ := real_inner_comm _ _
+ · intro v
+ change 0 ≤ ⟪M.weightedOperator w v, v⟫_ℝ
+ rw [real_inner_comm, weightedOperator_energy]
+ exact integral_nonneg hw
+
+/-- A change of coordinates commutes with integration of full measures. -/
+theorem comap_weightedOperator (A : E →L[ℝ] E) (w : X →ᵇ ℝ) :
+ (M.comap A.toLinearMap).weightedOperator w =
+ A.adjoint.comp ((M.weightedOperator w).comp A) := by
+ ext v
+ apply ext_inner_right ℝ
+ intro z
+ rw [weightedOperator_inner]
+ simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.adjoint_inner_left,
+ weightedOperator_inner]
+ rfl
+
+theorem weightedOperator_energy_mono (w z : X →ᵇ ℝ) (hwz : ∀ x, w x ≤ z x)
+ (v : E) : ⟪v, M.weightedOperator w v⟫_ℝ ≤ ⟪v, M.weightedOperator z v⟫_ℝ := by
+ rw [weightedOperator_energy, weightedOperator_energy]
+ apply integral_mono
+ · exact Integrable.of_bound w.continuous.aestronglyMeasurable ‖w‖
+ (Filter.Eventually.of_forall w.norm_coe_le_norm)
+ · exact Integrable.of_bound z.continuous.aestronglyMeasurable ‖z‖
+ (Filter.Eventually.of_forall z.norm_coe_le_norm)
+ · exact hwz
+
+/-- A kernel lower bound controls the mass of every measurable testing
+set, including the singular part of the measure. -/
+theorem massOperator_le_weightedOperator (w : X →ᵇ ℝ) (hw : ∀ x, 0 ≤ w x)
+ (s : Set X) (hs : MeasurableSet s) (c : ℝ) (hc : ∀ x ∈ s, c ≤ w x) (v : E) :
+ c * ⟪v, M.massOperator s v⟫_ℝ ≤ ⟪v, M.weightedOperator w v⟫_ℝ := by
+ rw [weightedOperator_energy, ← M.measure_real v s hs]
+ have hi : Integrable w (M.measure v) :=
+ Integrable.of_bound w.continuous.aestronglyMeasurable ‖w‖
+ (Filter.Eventually.of_forall w.norm_coe_le_norm)
+ calc
+ _ = ∫ x in s, c ∂(M.measure v) := by simp [mul_comm]
+ _ ≤ ∫ x in s, w x ∂(M.measure v) :=
+ setIntegral_mono_on (integrable_const c) hi.integrableOn hs hc
+ _ ≤ ∫ x, w x ∂(M.measure v) :=
+ setIntegral_le_integral hi (Filter.Eventually.of_forall hw)
+
+/-- A supported, bounded weight is bounded by the full mass on its support. -/
+theorem weightedOperator_le_massOperator (w : X →ᵇ ℝ) (s : Set X)
+ (hs : MeasurableSet s) (hws : ∀ x ∉ s, w x = 0) (C : ℝ)
+ (hC : ∀ x ∈ s, w x ≤ C) (v : E) :
+ ⟪v, M.weightedOperator w v⟫_ℝ ≤ C * ⟪v, M.massOperator s v⟫_ℝ := by
+ rw [weightedOperator_energy, ← M.measure_real v s hs]
+ have hi : Integrable w (M.measure v) :=
+ Integrable.of_bound w.continuous.aestronglyMeasurable ‖w‖
+ (Filter.Eventually.of_forall w.norm_coe_le_norm)
+ calc
+ _ = ∫ x in s, w x ∂(M.measure v) :=
+ (setIntegral_eq_integral_of_forall_compl_eq_zero hws).symm
+ _ ≤ ∫ x in s, C ∂(M.measure v) :=
+ setIntegral_mono_on hi.integrableOn (integrable_const C) hs hC
+ _ = _ := by simp [mul_comm]
+
+/-- A pointwise kernel-difference bound transfers to the full mass measure,
+without assuming that the measure has a density. -/
+theorem weightedOperator_energy_difference_le (w z B : X →ᵇ ℝ)
+ (hB : ∀ x, |w x - z x| ≤ B x) (v : E) :
+ |⟪v, (M.weightedOperator w - M.weightedOperator z) v⟫_ℝ| ≤
+ ⟪v, M.weightedOperator B v⟫_ℝ := by
+ have hi (f : X →ᵇ ℝ) : Integrable f (M.measure v) :=
+ Integrable.of_bound f.continuous.aestronglyMeasurable ‖f‖
+ (Filter.Eventually.of_forall f.norm_coe_le_norm)
+ rw [sub_apply, inner_sub_right, weightedOperator_energy, weightedOperator_energy,
+ weightedOperator_energy, ← integral_sub (hi w) (hi z)]
+ calc
+ _ ≤ ∫ x, |w x - z x| ∂(M.measure v) := abs_integral_le_integral_abs
+ _ ≤ ∫ x, B x ∂(M.measure v) := integral_mono ((hi w).sub (hi z)).abs (hi B) hB
+
+end PositiveBilinearMeasure
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/WeightedConvolution.lean b/lean/OAI/Geometry/RCD/Coordinates/WeightedConvolution.lean
new file mode 100644
index 0000000000000000000000000000000000000000..04b30364f4fb5d84cba5ae2cceab67cf9d88a84f
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/WeightedConvolution.lean
@@ -0,0 +1,192 @@
+import OAI.Geometry.RCD.Coordinates.PositiveForms
+import Mathlib.Analysis.SpecificLimits.Normed
+
+namespace OAI
+
+/-! # Finite weighted convolution estimates for changing inverse metrics -/
+
+open scoped BigOperators InnerProductSpace
+
+namespace RegularPointCoordinates
+
+/-- A positive quadratic form of a finite sum is bounded by the number of
+terms times their total energy. Degeneracy of the form is allowed. -/
+theorem positive_form_sum_le_card {E ι : Type*} [NormedAddCommGroup E]
+ [InnerProductSpace ℝ E] (D : E →L[ℝ] E) (hD : D.IsPositive)
+ (s : Finset ι) (v : ι → E) :
+ ⟪∑ j ∈ s, v j, D (∑ j ∈ s, v j)⟫_ℝ ≤
+ (s.card : ℝ) * ∑ j ∈ s, ⟪v j, D (v j)⟫_ℝ := by
+ have hcross (x y : E) : ⟪x, D y⟫_ℝ ≤ (⟪x, D x⟫_ℝ + ⟪y, D y⟫_ℝ) / 2 := by
+ have hp := hD.inner_nonneg_right (x - y)
+ have hs : ⟪y, D x⟫_ℝ = ⟪x, D y⟫_ℝ := by
+ rw [real_inner_comm, hD.inner_left_eq_inner_right]
+ simp only [map_sub, inner_sub_left, inner_sub_right, hs] at hp
+ linarith
+ calc
+ _ = ∑ j ∈ s, ∑ l ∈ s, ⟪v j, D (v l)⟫_ℝ := by
+ simp only [map_sum, sum_inner, inner_sum]
+ rw [Finset.sum_comm]
+ _ ≤ ∑ j ∈ s, ∑ l ∈ s, (⟪v j, D (v j)⟫_ℝ + ⟪v l, D (v l)⟫_ℝ) / 2 := by
+ exact Finset.sum_le_sum fun j _ => Finset.sum_le_sum fun l _ => hcross (v j) (v l)
+ _ = _ := by
+ simp only [add_div, Finset.sum_add_distrib, Finset.sum_const, nsmul_eq_mul]
+ simp only [← Finset.mul_sum, ← Finset.sum_div]
+ ring
+
+/-- Reindex the lower triangle by the lag and initial index, then enlarge
+to the full square. -/
+theorem triangular_sum_le_square (k : ℕ) (f : ℕ → ℕ → ℝ)
+ (hf : ∀ m j, 0 ≤ f m j) :
+ (∑ i ∈ Finset.range k, ∑ j ∈ Finset.range (i + 1), f (i - j) j) ≤
+ ∑ m ∈ Finset.range k, ∑ j ∈ Finset.range k, f m j := by
+ classical
+ let s := (Finset.range k).sigma (fun i => Finset.range (i + 1))
+ let t := (Finset.range k) ×ˢ (Finset.range k)
+ let g : (Σ _ : ℕ, ℕ) → ℕ × ℕ := fun p => (p.1 - p.2, p.2)
+ have hg : Set.InjOn g s := by
+ intro p hp q hq heq
+ have hp' := Finset.mem_sigma.mp hp
+ have hq' := Finset.mem_sigma.mp hq
+ have hpj : p.2 ≤ p.1 := by simpa only [Finset.mem_range, Nat.lt_succ_iff] using hp'.2
+ have hqj : q.2 ≤ q.1 := by simpa only [Finset.mem_range, Nat.lt_succ_iff] using hq'.2
+ have heq1 := congrArg Prod.fst heq
+ have heq2 := congrArg Prod.snd heq
+ simp only [g] at heq1 heq2
+ have hfirst : p.1 = q.1 := by omega
+ cases p
+ cases q
+ simp_all
+ have hsub : s.image g ⊆ t := by
+ intro p hp
+ obtain ⟨q, hq, rfl⟩ := Finset.mem_image.mp hp
+ obtain ⟨hqi, hqj⟩ := Finset.mem_sigma.mp hq
+ simp only [Finset.mem_range] at hqi hqj
+ simp only [t, g, Finset.mem_product, Finset.mem_range]
+ omega
+ calc
+ _ = ∑ p ∈ s, f (g p).1 (g p).2 := by simp only [s, g, Finset.sum_sigma']
+ _ = ∑ p ∈ s.image g, f p.1 p.2 := by rw [Finset.sum_image hg]
+ _ ≤ ∑ p ∈ t, f p.1 p.2 :=
+ Finset.sum_le_sum_of_subset_of_nonneg hsub (fun p _ _ => hf p.1 p.2)
+ _ = _ := by simp only [t, Finset.sum_product]
+
+/-- Each location belongs to at most `m` forward intervals of length `m`. -/
+theorem sliding_interval_sum_le (k m : ℕ) (b : ℕ → ℝ) (hb : ∀ l, 0 ≤ b l) :
+ (∑ j ∈ Finset.range k, ∑ l ∈ Finset.Ico j (min k (j + m)), b l) ≤
+ (m : ℝ) * ∑ l ∈ Finset.range k, b l := by
+ classical
+ have hset (j : ℕ) : Finset.Ico j (min k (j + m)) =
+ (Finset.range k).filter (fun l => j ≤ l ∧ l < j + m) := by
+ ext l
+ simp only [Finset.mem_Ico, Finset.mem_filter, Finset.mem_range, lt_min_iff]
+ omega
+ have hcount (l : ℕ) :
+ (((Finset.range k).filter (fun j => j ≤ l ∧ l < j + m)).card : ℝ) ≤ m := by
+ have hs : (Finset.range k).filter (fun j => j ≤ l ∧ l < j + m) ⊆
+ Finset.Ico (l + 1 - m) (l + 1) := by
+ intro j hj
+ simp only [Finset.mem_filter, Finset.mem_range] at hj
+ simp only [Finset.mem_Ico]
+ omega
+ have hc := Finset.card_le_card hs
+ have hc' : (Finset.Ico (l + 1 - m) (l + 1)).card ≤ m := by
+ rw [Nat.card_Ico]
+ omega
+ exact_mod_cast hc.trans hc'
+ calc
+ _ = ∑ j ∈ Finset.range k, ∑ l ∈ Finset.range k,
+ if j ≤ l ∧ l < j + m then b l else 0 := by
+ simp only [hset, Finset.sum_filter]
+ _ = ∑ l ∈ Finset.range k, ∑ j ∈ Finset.range k,
+ if j ≤ l ∧ l < j + m then b l else 0 := Finset.sum_comm
+ _ = ∑ l ∈ Finset.range k,
+ (((Finset.range k).filter (fun j => j ≤ l ∧ l < j + m)).card : ℝ) * b l := by
+ congr 1
+ ext l
+ rw [← Finset.sum_filter]
+ simp
+ _ ≤ ∑ l ∈ Finset.range k, (m : ℝ) * b l :=
+ Finset.sum_le_sum fun l _ => mul_le_mul_of_nonneg_right (hcount l) (hb l)
+ _ = _ := by rw [Finset.mul_sum]
+
+/-- The interval-convolution coefficient is the first moment of the lag
+kernel; no dependence on the final index remains. -/
+theorem weighted_interval_convolution_le (k : ℕ) (w b : ℕ → ℝ)
+ (hw : ∀ m, 0 ≤ w m) (hb : ∀ l, 0 ≤ b l) :
+ (∑ i ∈ Finset.range k, ∑ j ∈ Finset.range (i + 1),
+ w (i - j) * ∑ l ∈ Finset.Ico j i, b l) ≤
+ (∑ m ∈ Finset.range k, (m : ℝ) * w m) * ∑ l ∈ Finset.range k, b l := by
+ have heq : (∑ i ∈ Finset.range k, ∑ j ∈ Finset.range (i + 1),
+ w (i - j) * ∑ l ∈ Finset.Ico j i, b l) =
+ ∑ i ∈ Finset.range k, ∑ j ∈ Finset.range (i + 1),
+ w (i - j) * ∑ l ∈ Finset.Ico j (min k (j + (i - j))), b l := by
+ apply Finset.sum_congr rfl
+ intro i hi
+ apply Finset.sum_congr rfl
+ intro j hj
+ have hij : j ≤ i := by simpa only [Finset.mem_range, Nat.lt_succ_iff] using hj
+ have hi' : i < k := Finset.mem_range.mp hi
+ rw [Nat.add_sub_of_le hij, min_eq_right hi'.le]
+ rw [heq]
+ calc
+ _ ≤ ∑ m ∈ Finset.range k, ∑ j ∈ Finset.range k,
+ w m * ∑ l ∈ Finset.Ico j (min k (j + m)), b l :=
+ triangular_sum_le_square k _ (fun m j => mul_nonneg (hw m)
+ (Finset.sum_nonneg fun l _ => hb l))
+ _ = ∑ m ∈ Finset.range k,
+ w m * (∑ j ∈ Finset.range k, ∑ l ∈ Finset.Ico j (min k (j + m)), b l) := by
+ simp only [Finset.mul_sum]
+ _ ≤ ∑ m ∈ Finset.range k, w m * ((m : ℝ) * ∑ l ∈ Finset.range k, b l) :=
+ Finset.sum_le_sum fun m _ => mul_le_mul_of_nonneg_left (sliding_interval_sum_le k m b hb) (hw m)
+ _ = _ := by rw [Finset.sum_mul]; apply Finset.sum_congr rfl; intro m _; ring
+
+/-- The stationary part of the triangular convolution has its ordinary
+geometric-series coefficient. -/
+theorem weighted_stationary_convolution_le (k : ℕ) (w b : ℕ → ℝ)
+ (hw : ∀ m, 0 ≤ w m) (hb : ∀ j, 0 ≤ b j) :
+ (∑ i ∈ Finset.range k, ∑ j ∈ Finset.range (i + 1), w (i - j) * b j) ≤
+ (∑ m ∈ Finset.range k, w m) * ∑ j ∈ Finset.range k, b j := by
+ calc
+ _ ≤ ∑ m ∈ Finset.range k, ∑ j ∈ Finset.range k, w m * b j :=
+ triangular_sum_le_square k _ (fun m j => mul_nonneg (hw m) (hb j))
+ _ = _ := by simp only [Finset.mul_sum, Finset.sum_mul]; rw [Finset.sum_comm]
+
+/-- The constant controlling intervals with exponentially decaying lags. -/
+noncomputable def geometricIntervalConstant (rho : ℝ) : ℝ :=
+ ∑' m : ℕ, (m : ℝ) ^ 2 * rho ^ m
+
+theorem geometricIntervalConstant_nonneg {rho : ℝ} (hrho : 0 ≤ rho) :
+ 0 ≤ geometricIntervalConstant rho :=
+ tsum_nonneg (fun m => mul_nonneg (sq_nonneg _) (pow_nonneg hrho m))
+
+theorem weighted_geometric_interval_convolution_le (k : ℕ) (b : ℕ → ℝ)
+ (hb : ∀ l, 0 ≤ b l) {rho : ℝ} (hrho : 0 ≤ rho) (hrho1 : rho < 1) :
+ (∑ i ∈ Finset.range k, ∑ j ∈ Finset.range (i + 1),
+ ((i - j : ℕ) : ℝ) * rho ^ (i - j) * ∑ l ∈ Finset.Ico j i, b l) ≤
+ geometricIntervalConstant rho * ∑ l ∈ Finset.range k, b l := by
+ have hs : Summable (fun m : ℕ => (m : ℝ) ^ 2 * rho ^ m) :=
+ summable_pow_mul_geometric_of_norm_lt_one 2 (by simpa [abs_of_nonneg hrho] using hrho1)
+ have hsum : (∑ m ∈ Finset.range k, (m : ℝ) * ((m : ℝ) * rho ^ m)) ≤
+ geometricIntervalConstant rho := by
+ simpa only [geometricIntervalConstant, pow_two, mul_assoc] using
+ hs.sum_le_tsum (Finset.range k) (fun m _ => mul_nonneg (sq_nonneg _) (pow_nonneg hrho m))
+ exact (weighted_interval_convolution_le k (fun m => (m : ℝ) * rho ^ m) b
+ (fun m => by positivity) hb).trans
+ (mul_le_mul_of_nonneg_right hsum (Finset.sum_nonneg fun l _ => hb l))
+
+theorem weighted_geometric_stationary_convolution_le (k : ℕ) (b : ℕ → ℝ)
+ (hb : ∀ l, 0 ≤ b l) {rho : ℝ} (hrho : 0 ≤ rho) (hrho1 : rho < 1) :
+ (∑ i ∈ Finset.range k, ∑ j ∈ Finset.range (i + 1), rho ^ (i - j) * b j) ≤
+ (1 - rho)⁻¹ * ∑ l ∈ Finset.range k, b l := by
+ have hs : Summable (fun m : ℕ => rho ^ m) :=
+ summable_geometric_of_abs_lt_one (by simpa [abs_of_nonneg hrho] using hrho1)
+ have hsum : (∑ m ∈ Finset.range k, rho ^ m) ≤ (1 - rho)⁻¹ := by
+ have h := hs.sum_le_tsum (Finset.range k) (fun m _ => pow_nonneg hrho m)
+ rwa [tsum_geometric_of_norm_lt_one (by simpa [abs_of_nonneg hrho] using hrho1)] at h
+ exact (weighted_stationary_convolution_le k (fun m => rho ^ m) b
+ (fun m => pow_nonneg hrho m) hb).trans
+ (mul_le_mul_of_nonneg_right hsum (Finset.sum_nonneg fun l _ => hb l))
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/WeightedFitSmoothing.lean b/lean/OAI/Geometry/RCD/Coordinates/WeightedFitSmoothing.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ba3d4d3f7ecdef69c434dde8cb210111517b0a33
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/WeightedFitSmoothing.lean
@@ -0,0 +1,52 @@
+import OAI.Geometry.RCD.Coordinates.AffineFitSmoothing
+
+namespace OAI
+
+/-! # Smoothing radial fits with changing covector norms -/
+
+namespace RegularPointCoordinates
+
+/-- Dividing by the current covector norm introduces only the proved
+growth loss across the fixed lag. No uniform Euclidean norm is required. -/
+theorem weighted_fit_normalized_step {e w P : ℕ → ℝ} {a C G : ℝ} {m : ℕ}
+ (ha : 0 ≤ a) (hC : 0 ≤ C)
+ (he : ∀ i, 0 ≤ e i) (hw : ∀ i, 0 < w i)
+ (hgrowth : ∀ i, w i ≤ G * w (i + m))
+ (hstep : ∀ i, e (i + m) ≤ a * e i + C * w i * Real.sqrt (P i)) (i : ℕ) :
+ e (i + m) / w (i + m) ≤ (a * G) * (e i / w i) + (C * G) * Real.sqrt (P i) := by
+ have hr : 0 ≤ w i / w (i + m) := div_nonneg (hw i).le (hw _).le
+ have hrG : w i / w (i + m) ≤ G := (div_le_iff₀ (hw _)).mpr (hgrowth i)
+ have hei : 0 ≤ e i / w i := div_nonneg (he i) (hw i).le
+ have h₁ := mul_le_mul_of_nonneg_left hrG (mul_nonneg ha hei)
+ have h₂ := mul_le_mul_of_nonneg_left hrG (mul_nonneg hC (Real.sqrt_nonneg (P i)))
+ calc
+ _ ≤ (a * e i + C * w i * Real.sqrt (P i)) / w (i + m) :=
+ div_le_div_of_nonneg_right (hstep i) (hw _).le
+ _ = (a * (e i / w i)) * (w i / w (i + m)) +
+ (C * Real.sqrt (P i)) * (w i / w (i + m)) := by
+ field_simp [(hw i).ne', (hw (i + m)).ne']
+ _ ≤ (a * (e i / w i)) * G + (C * Real.sqrt (P i)) * G := add_le_add h₁ h₂
+ _ = _ := by ring
+
+/-- The smoothed error controls each original fit in its own covector
+norm. The defect sequence is unchanged by normalization. -/
+theorem weighted_squared_fit_le_forwardDefect {σ η A a C G : ℝ}
+ (hσ : 0 ≤ σ) (hη : 0 ≤ η) (hA : 0 ≤ A)
+ (ha : 0 ≤ a) (hC : 0 ≤ C) (hG : 0 ≤ G)
+ {P e w : ℕ → ℝ} (hP : ∀ i, 0 ≤ P i) (he : ∀ i, 0 ≤ e i) (hw : ∀ i, 0 < w i)
+ {m : ℕ} (hm : 0 < m)
+ (hmargin : (2 * (a * G) ^ 2) * A + 2 * (C * G) ^ 2 ≤ σ ^ m * A)
+ (hinitial : ∀ i < m, (e i / w i) ^ 2 ≤ A * (η * σ ^ i))
+ (hgrowth : ∀ i, w i ≤ G * w (i + m))
+ (hstep : ∀ i, e (i + m) ≤ a * e i + C * w i * Real.sqrt (P i)) :
+ ∀ i, (e i) ^ 2 ≤ A * forwardDefect σ η P i * (w i) ^ 2 := by
+ have hb := squared_fit_le_forwardDefect hσ hη hA (mul_nonneg ha hG) (mul_nonneg hC hG)
+ hP (fun i => div_nonneg (he i) (hw i).le) hm hmargin hinitial
+ (weighted_fit_normalized_step ha hC he hw hgrowth hstep)
+ intro i
+ have hh := mul_le_mul_of_nonneg_right (hb i) (sq_nonneg (w i))
+ rwa [div_pow, div_mul_cancel₀ _ (pow_ne_zero 2 (hw i).ne')] at hh
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/WeightedFramedProjection.lean b/lean/OAI/Geometry/RCD/Coordinates/WeightedFramedProjection.lean
new file mode 100644
index 0000000000000000000000000000000000000000..1410df2081b9eba781321e55eb896a8160c4b766
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/WeightedFramedProjection.lean
@@ -0,0 +1,77 @@
+import OAI.Geometry.RCD.Coordinates.FramedAffineProjection
+
+namespace OAI
+
+/-! # Radius-weighted coefficients of the actual harmonic projection -/
+
+open Set MeasureTheory
+open scoped InnerProductSpace ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- Projection coefficients are bounded in the exact normalization frame;
+no bound for the original coordinate change or its inverse is lost. -/
+theorem weighted_framed_affine_projection_coefficients {n : ℕ}
+ (u : Fin n → SobolevSpace μ hQ) (s : Set X) (hfin : μ s ≠ ∞)
+ (N : Euclidean n ≃L[ℝ] Euclidean n) (R : ℝ) {H : ℝ} (hH : 0 ≤ H)
+ (hbound : ∀ c a, |c| + R * ‖N.symm a‖ ≤ H *
+ ‖normalizeLocalL2 μ s hfin (affineCoordinateMap μ hQ u s hfin (c, a))‖)
+ (f : Lp ℝ 2 (μ.restrict s)) :
+ ∃ (c : ℝ) (b : Euclidean n),
+ affineProjection μ hQ u s hfin f = affineCoordinateMap μ hQ u s hfin (c, N b) ∧
+ |c| + R * ‖b‖ ≤ H * ‖normalizeLocalL2 μ s hfin f‖ := by
+ obtain ⟨c, a, hfit⟩ := affineProjection_has_coefficients μ hQ u s hfin f
+ change affineProjection μ hQ u s hfin f = affineCoordinateMap μ hQ u s hfin (c, a) at hfit
+ refine ⟨c, N.symm a, by simpa only [N.apply_symm_apply] using hfit, ?_⟩
+ have hb := hbound c a
+ rw [← hfit] at hb
+ exact hb.trans (mul_le_mul_of_nonneg_left
+ (normalized_affineProjection_norm_le μ hQ u s hfin f) hH)
+
+variable [BorelSpace X] [ProperSpace X]
+
+/-- The least-squares residual is an actual harmonic Sobolev function on
+the larger working set and equals the orthogonal residual on its inner
+projection set. Its coefficients satisfy the exact-frame value bound. -/
+theorem weighted_framed_harmonic_projection_residual {n : ℕ}
+ (u : Fin n → SobolevSpace μ hQ) (s Ω : Set X) (hfin : μ s ≠ ∞)
+ (hsΩ : s ⊆ Ω) (hΩ : MeasurableSet Ω)
+ (hu : ∀ j, IsSobolevHarmonicOn μ hQ Ω (u j))
+ (v η : SobolevSpace μ hQ) (hv : IsSobolevHarmonicOn μ hQ Ω v)
+ (hη : SobolevSpace.toLp μ hQ η =ᵐ[μ.restrict Ω] fun _ => (1 : ℝ))
+ (N : Euclidean n ≃L[ℝ] Euclidean n) (R : ℝ) {H : ℝ} (hH : 0 ≤ H)
+ (hbound : ∀ c a, |c| + R * ‖N.symm a‖ ≤ H *
+ ‖normalizeLocalL2 μ s hfin (affineCoordinateMap μ hQ u s hfin (c, a))‖) :
+ ∃ (c : ℝ) (b : Euclidean n) (w : SobolevSpace μ hQ),
+ w = v - (c • η + sobolevColumnMap μ hQ u (N b)) ∧
+ IsSobolevHarmonicOn μ hQ Ω w ∧
+ SobolevSpace.restrictLp μ hQ s w = affineResidual μ hQ u s hfin
+ (SobolevSpace.restrictLp μ hQ s v) ∧
+ |c| + R * ‖b‖ ≤ H * ‖normalizeLocalL2 μ s hfin (SobolevSpace.restrictLp μ hQ s v)‖ := by
+ obtain ⟨c, b, hfit, hb⟩ := weighted_framed_affine_projection_coefficients μ hQ u s hfin N R hH hbound
+ (SobolevSpace.restrictLp μ hQ s v)
+ let w := v - (c • η + sobolevColumnMap μ hQ u (N b))
+ have hηharm := isSobolevHarmonicOn_of_local_constant μ hQ Ω hΩ η 1 hη
+ have hwharm : IsSobolevHarmonicOn μ hQ Ω w := by
+ have haff := (hηharm.smul μ hQ c).add μ hQ
+ (IsSobolevHarmonicOn.linearCombination μ hQ hu (N b))
+ intro φ hφ
+ change energyForm μ hQ (v - (c • η + sobolevColumnMap μ hQ u (N b))) φ = 0
+ rw [energyForm_sub_left, hv φ hφ, haff φ hφ, sub_self]
+ refine ⟨c, b, w, rfl, hwharm, ?_, hb⟩
+ have hηs := ae_restrict_of_ae_restrict_of_subset hsΩ hη
+ change SobolevSpace.restrictLp μ hQ s w =
+ SobolevSpace.restrictLp μ hQ s v - affineProjection μ hQ u s hfin (SobolevSpace.restrictLp μ hQ s v)
+ rw [hfit, affineCoordinateMap_apply]
+ dsimp only [w]
+ rw [map_sub, map_add, map_smul, restrictLp_eq_one_of_representative μ hQ η s hfin hηs]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/WeightedInverse.lean b/lean/OAI/Geometry/RCD/Coordinates/WeightedInverse.lean
new file mode 100644
index 0000000000000000000000000000000000000000..a8c63db65d0f7bd35a323882e77a92f745b60dbe
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/WeightedInverse.lean
@@ -0,0 +1,283 @@
+import OAI.Geometry.RCD.Coordinates.FrozenNorms
+
+namespace OAI
+
+/-!
+# Inverse increments without commutation assumptions
+
+The arguments use positive quadratic forms and exact inverse identities.
+Operators from different scales are never assumed to commute.
+-/
+
+open scoped InnerProductSpace BigOperators
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
+
+/-- Positivity is preserved by the inverse of a linear equivalence. -/
+theorem positive_equiv_symm (Q : E ≃L[ℝ] E)
+ (hQ : (Q : E →L[ℝ] E).IsPositive) : (Q.symm : E →L[ℝ] E).IsPositive :=
+ LinearMap.IsPositive.toLinearMap_symm (T := Q.toLinearEquiv) hQ
+
+/-- Exact resolvent identity evaluated on a vector. -/
+theorem inverse_increment_apply (P Q : E ≃L[ℝ] E) (xi : E) :
+ ((Q.symm : E →L[ℝ] E) - (P.symm : E →L[ℝ] E)) xi =
+ Q.symm (((P : E →L[ℝ] E) - (Q : E →L[ℝ] E)) (P.symm xi)) := by
+ simp only [sub_apply, ContinuousLinearEquiv.coe_coe, map_sub,
+ ContinuousLinearEquiv.apply_symm_apply, ContinuousLinearEquiv.symm_apply_apply]
+
+/-- The inverse increment equals the leading conjugated decrement plus a
+nonnegative remainder. -/
+theorem inverse_increment_quadratic_identity (P Q : E ≃L[ℝ] E)
+ (hP : (P : E →L[ℝ] E).IsPositive)
+ (hD : ((P : E →L[ℝ] E) - (Q : E →L[ℝ] E)).IsPositive) (xi : E) :
+ let D := (P : E →L[ℝ] E) - (Q : E →L[ℝ] E)
+ let a := P.symm xi
+ let e := Q.symm (D a)
+ ⟪xi, ((Q.symm : E →L[ℝ] E) - (P.symm : E →L[ℝ] E)) xi⟫_ℝ =
+ ⟪a, D a⟫_ℝ + ⟪e, Q e⟫_ℝ := by
+ dsimp only
+ let D := (P : E →L[ℝ] E) - (Q : E →L[ℝ] E)
+ let a := P.symm xi
+ let e := Q.symm (D a)
+ have he : Q e = D a := Q.apply_symm_apply (D a)
+ have hcross : ⟪a, D e⟫_ℝ = ⟪e, Q e⟫_ℝ := by
+ calc
+ _ = ⟪D a, e⟫_ℝ := (hD.inner_left_eq_inner_right a e).symm
+ _ = ⟪Q e, e⟫_ℝ := by rw [he]
+ _ = _ := real_inner_comm _ _
+ change ⟪xi, ((Q.symm : E →L[ℝ] E) - (P.symm : E →L[ℝ] E)) xi⟫_ℝ =
+ ⟪a, D a⟫_ℝ + ⟪e, Q e⟫_ℝ
+ rw [inverse_increment_apply]
+ change ⟪xi, e⟫_ℝ = _
+ calc
+ _ = ⟪P a, e⟫_ℝ := by simp [a]
+ _ = ⟪a, P e⟫_ℝ := hP.inner_left_eq_inner_right a e
+ _ = ⟪a, Q e + D e⟫_ℝ := by congr 1; simp [D]
+ _ = _ := by simp only [inner_add_right, he, hcross]
+
+/-- The sharp two-sided inverse-increment order for a relatively small
+positive decrement. This replaces the one-matrix spectral calculation. -/
+theorem inverse_increment_order (P Q : E ≃L[ℝ] E)
+ (hP : (P : E →L[ℝ] E).IsPositive) (hQ : (Q : E →L[ℝ] E).IsPositive)
+ (hD : ((P : E →L[ℝ] E) - (Q : E →L[ℝ] E)).IsPositive)
+ {eta : ℝ} (heta : 0 ≤ eta) (heta1 : eta < 1)
+ (hsmall : ∀ v, ⟪v, ((P : E →L[ℝ] E) - (Q : E →L[ℝ] E)) v⟫_ℝ ≤
+ eta * ⟪v, P v⟫_ℝ) (xi : E) :
+ let D := (P : E →L[ℝ] E) - (Q : E →L[ℝ] E)
+ ⟪P.symm xi, D (P.symm xi)⟫_ℝ ≤
+ ⟪xi, ((Q.symm : E →L[ℝ] E) - (P.symm : E →L[ℝ] E)) xi⟫_ℝ ∧
+ ⟪xi, ((Q.symm : E →L[ℝ] E) - (P.symm : E →L[ℝ] E)) xi⟫_ℝ ≤
+ ⟪P.symm xi, D (P.symm xi)⟫_ℝ / (1 - eta) := by
+ dsimp only
+ let D := (P : E →L[ℝ] E) - (Q : E →L[ℝ] E)
+ let a := P.symm xi
+ let e := Q.symm (D a)
+ have he : Q e = D a := Q.apply_symm_apply (D a)
+ have hc : 0 ≤ ⟪e, Q e⟫_ℝ := hQ.inner_nonneg_right e
+ have hb : 0 ≤ ⟪a, D a⟫_ℝ := hD.inner_nonneg_right a
+ have hcross : ⟪a, D e⟫_ℝ = ⟪e, Q e⟫_ℝ := by
+ rw [← hD.inner_left_eq_inner_right, ← he, real_inner_comm]
+ have hcs := positive_form_cauchy_schwarz hD a e
+ change ⟪a, D e⟫_ℝ ^ 2 ≤ ⟪a, D a⟫_ℝ * ⟪e, D e⟫_ℝ at hcs
+ rw [hcross] at hcs
+ have hde : (1 - eta) * ⟪e, D e⟫_ℝ ≤ eta * ⟪e, Q e⟫_ℝ := by
+ have hs := hsmall e
+ change ⟪e, D e⟫_ℝ ≤ eta * ⟪e, P e⟫_ℝ at hs
+ have hid : ⟪e, P e⟫_ℝ = ⟪e, Q e⟫_ℝ + ⟪e, D e⟫_ℝ := by
+ simp [D, inner_sub_right]
+ rw [hid] at hs
+ nlinarith
+ have hrem : (1 - eta) * ⟪e, Q e⟫_ℝ ≤ eta * ⟪a, D a⟫_ℝ := by
+ by_cases hz : ⟪e, Q e⟫_ℝ = 0
+ · rw [hz, mul_zero]
+ exact mul_nonneg heta hb
+ have hcpos : 0 < ⟪e, Q e⟫_ℝ := lt_of_le_of_ne hc (Ne.symm hz)
+ apply (mul_le_mul_iff_left₀ hcpos).mp
+ have h₁ := mul_le_mul_of_nonneg_left hcs (by linarith : 0 ≤ 1 - eta)
+ have h₂ := mul_le_mul_of_nonneg_left hde hb
+ nlinarith only [h₁, h₂]
+ have hid := inverse_increment_quadratic_identity P Q hP hD xi
+ change ⟪xi, ((Q.symm : E →L[ℝ] E) - (P.symm : E →L[ℝ] E)) xi⟫_ℝ =
+ ⟪a, D a⟫_ℝ + ⟪e, Q e⟫_ℝ at hid
+ change ⟪a, D a⟫_ℝ ≤ _ ∧ _ ≤ ⟪a, D a⟫_ℝ / (1 - eta)
+ rw [hid]
+ constructor
+ · linarith
+ · apply (le_div_iff₀ (by linarith : 0 < 1 - eta)).mpr
+ nlinarith only [hrem]
+
+/-- A positive form bounded by `eta Q` satisfies the weighted square bound
+`D Q⁻¹ D ≤ eta D`. -/
+theorem positive_inverse_sandwich_bound (Q : E ≃L[ℝ] E)
+ (hQ : (Q : E →L[ℝ] E).IsPositive) {D : E →L[ℝ] E} (hD : D.IsPositive)
+ {eta : ℝ} (heta : 0 ≤ eta)
+ (hsmall : ∀ v, ⟪v, D v⟫_ℝ ≤ eta * ⟪v, Q v⟫_ℝ) (w : E) :
+ ⟪D w, Q.symm (D w)⟫_ℝ ≤ eta * ⟪w, D w⟫_ℝ := by
+ let v := Q.symm (D w)
+ have hQv : Q v = D w := Q.apply_symm_apply (D w)
+ have heq : ⟪w, D v⟫_ℝ = ⟪v, Q v⟫_ℝ := by
+ rw [← hD.inner_left_eq_inner_right, ← hQv, real_inner_comm]
+ have hc : 0 ≤ ⟪v, Q v⟫_ℝ := hQ.inner_nonneg_right v
+ have hb := hD.inner_nonneg_right w
+ have hcs := positive_form_cauchy_schwarz hD w v
+ rw [heq] at hcs
+ have hm := mul_le_mul_of_nonneg_left (hsmall v) hb
+ have htarget : ⟪v, Q v⟫_ℝ ≤ eta * ⟪w, D w⟫_ℝ := by
+ by_cases hz : ⟪v, Q v⟫_ℝ = 0
+ · rw [hz]; exact mul_nonneg heta hb
+ have hp : 0 < ⟪v, Q v⟫_ℝ := lt_of_le_of_ne hc (Ne.symm hz)
+ nlinarith
+ change ⟪D w, v⟫_ℝ ≤ _
+ calc
+ _ = ⟪v, D w⟫_ℝ := real_inner_comm _ _
+ _ = ⟪v, Q v⟫_ℝ := by rw [hQv]
+ _ ≤ _ := htarget
+
+/-- A monotone positive metric sequence has positive inverse increments. -/
+theorem inverse_increment_isPositive (P Q : E ≃L[ℝ] E)
+ (hP : (P : E →L[ℝ] E).IsPositive) (hQ : (Q : E →L[ℝ] E).IsPositive)
+ (hD : ((P : E →L[ℝ] E) - (Q : E →L[ℝ] E)).IsPositive) :
+ ((Q.symm : E →L[ℝ] E) - (P.symm : E →L[ℝ] E)).IsPositive := by
+ apply (ContinuousLinearMap.isPositive_iff _).mpr
+ refine ⟨(positive_equiv_symm Q hQ).isSymmetric.sub
+ (positive_equiv_symm P hP).isSymmetric, ?_⟩
+ intro xi
+ have hid := inverse_increment_quadratic_identity P Q hP hD xi
+ have h₁ := hD.inner_nonneg_right (P.symm xi)
+ have h₂ := hQ.inner_nonneg_right
+ (Q.symm (((P : E →L[ℝ] E) - (Q : E →L[ℝ] E)) (P.symm xi)))
+ rw [real_inner_comm]
+ exact hid.symm ▸ add_nonneg h₁ h₂
+
+/-- For a half-small decrement the inverse increment satisfies the weighted
+square bound used in the convolution argument. -/
+theorem inverse_increment_weighted_square_le (P Q : E ≃L[ℝ] E)
+ (hP : (P : E →L[ℝ] E).IsPositive) (hQ : (Q : E →L[ℝ] E).IsPositive)
+ (hD : ((P : E →L[ℝ] E) - (Q : E →L[ℝ] E)).IsPositive)
+ (hsmall : ∀ v, ⟪v, ((P : E →L[ℝ] E) - (Q : E →L[ℝ] E)) v⟫_ℝ ≤
+ (1 / 2 : ℝ) * ⟪v, P v⟫_ℝ) (xi : E) :
+ let B := (Q.symm : E →L[ℝ] E) - (P.symm : E →L[ℝ] E)
+ ⟪B xi, P (B xi)⟫_ℝ ≤ ⟪xi, B xi⟫_ℝ := by
+ let B := (Q.symm : E →L[ℝ] E) - (P.symm : E →L[ℝ] E)
+ have hB := inverse_increment_isPositive P Q hP hQ hD
+ have hb : ∀ v, ⟪v, B v⟫_ℝ ≤ ⟪v, P.symm v⟫_ℝ := by
+ intro v
+ have ho := (inverse_increment_order P Q hP hQ hD (by norm_num) (by norm_num) hsmall v).2
+ have ho' := (le_div_iff₀ (by norm_num : (0 : ℝ) < 1 - 1 / 2)).mp ho
+ have hs := hsmall (P.symm v)
+ simp only [ContinuousLinearEquiv.apply_symm_apply] at hs
+ have hi : ⟪P.symm v, v⟫_ℝ = ⟪v, P.symm v⟫_ℝ := real_inner_comm _ _
+ rw [hi] at hs
+ change ⟪v, B v⟫_ℝ * (1 - 1 / 2) ≤
+ ⟪P.symm v, ((P : E →L[ℝ] E) - (Q : E →L[ℝ] E)) (P.symm v)⟫_ℝ at ho'
+ linarith
+ have h := positive_inverse_sandwich_bound P.symm (positive_equiv_symm P hP) hB
+ (by norm_num : (0 : ℝ) ≤ 1) (fun v => by simpa only [B, sub_apply, one_mul] using hb v) xi
+ simpa only [ContinuousLinearEquiv.symm_symm, one_mul] using h
+
+/-- The inverse-energy form of a bilinear comparison, obtained by testing
+at the actual inverse image rather than assuming a duality formula. -/
+theorem inverse_energy_of_bilinear_bound (Q : E ≃L[ℝ] E)
+ (hQ : (Q : E →L[ℝ] E).IsPositive) (z : E) {K : ℝ} (hK : 0 ≤ K)
+ (hbound : ∀ v, ⟪v, z⟫_ℝ ^ 2 ≤ K * ⟪v, Q v⟫_ℝ) :
+ ⟪z, Q.symm z⟫_ℝ ≤ K := by
+ let v := Q.symm z
+ have hv : Q v = z := Q.apply_symm_apply z
+ have hc : 0 ≤ ⟪v, z⟫_ℝ := by
+ simpa only [ContinuousLinearEquiv.coe_coe, hv] using hQ.inner_nonneg_right v
+ have hb := hbound v
+ rw [hv] at hb
+ have ht : ⟪v, z⟫_ℝ ≤ K := by
+ by_cases hz : ⟪v, z⟫_ℝ = 0
+ · simpa only [hz] using hK
+ · have hp : 0 < ⟪v, z⟫_ℝ := lt_of_le_of_ne hc (Ne.symm hz)
+ nlinarith
+ simpa only [real_inner_comm] using ht
+
+/-- Relative comparison of positive metrics gives both inverse order and
+the weighted inverse-square estimate needed for normalization errors. -/
+theorem relative_inverse_bounds (Q R : E ≃L[ℝ] E)
+ (hQ : (Q : E →L[ℝ] E).IsPositive) (hR : (R : E →L[ℝ] E).IsPositive)
+ {c : ℝ} (hc : 0 < c)
+ (hcompare : ∀ v, c * ⟪v, Q v⟫_ℝ ≤ ⟪v, R v⟫_ℝ) (z : E) :
+ ⟪z, R.symm z⟫_ℝ ≤ ⟪z, Q.symm z⟫_ℝ / c ∧
+ ⟪R.symm z, Q (R.symm z)⟫_ℝ ≤ ⟪z, Q.symm z⟫_ℝ / c ^ 2 := by
+ let u := Q.symm z
+ let v := R.symm z
+ have hu : Q u = z := Q.apply_symm_apply z
+ have hv : R v = z := R.apply_symm_apply z
+ have ha : 0 ≤ ⟪z, u⟫_ℝ := by
+ simpa only [ContinuousLinearEquiv.coe_coe, hu, real_inner_comm] using hQ.inner_nonneg_right u
+ have hb : 0 ≤ ⟪z, v⟫_ℝ := by
+ simpa only [ContinuousLinearEquiv.coe_coe, hv, real_inner_comm] using hR.inner_nonneg_right v
+ have hq : 0 ≤ ⟪v, Q v⟫_ℝ := hQ.inner_nonneg_right v
+ have hcs := positive_form_cauchy_schwarz hQ u v
+ change ⟪u, Q v⟫_ℝ ^ 2 ≤ ⟪u, Q u⟫_ℝ * ⟪v, Q v⟫_ℝ at hcs
+ have hid : ⟪u, Q v⟫_ℝ = ⟪z, v⟫_ℝ := by
+ have hh := hQ.inner_left_eq_inner_right u v
+ change ⟪Q u, v⟫_ℝ = ⟪u, Q v⟫_ℝ at hh
+ rw [hu] at hh
+ exact hh.symm
+ rw [hid, hu] at hcs
+ have hinner : ⟪u, z⟫_ℝ = ⟪z, u⟫_ℝ := real_inner_comm _ _
+ rw [hinner] at hcs
+ have hcomp : c * ⟪v, Q v⟫_ℝ ≤ ⟪z, v⟫_ℝ := by
+ simpa only [hv, real_inner_comm] using hcompare v
+ change ⟪z, v⟫_ℝ ≤ ⟪z, u⟫_ℝ / c ∧ ⟪v, Q v⟫_ℝ ≤ ⟪z, u⟫_ℝ / c ^ 2
+ constructor
+ · apply (le_div_iff₀ hc).mpr
+ by_cases hz : ⟪z, v⟫_ℝ = 0
+ · rw [hz, zero_mul]; exact ha
+ have hp : 0 < ⟪z, v⟫_ℝ := lt_of_le_of_ne hb (Ne.symm hz)
+ apply (mul_le_mul_iff_left₀ hp).mp
+ have h₁ := mul_le_mul_of_nonneg_left hcs hc.le
+ have h₂ := mul_le_mul_of_nonneg_left hcomp ha
+ nlinarith only [h₁, h₂]
+ · apply (le_div_iff₀ (sq_pos_of_pos hc)).mpr
+ by_cases hz : ⟪v, Q v⟫_ℝ = 0
+ · rw [hz, zero_mul]; exact ha
+ have hp : 0 < ⟪v, Q v⟫_ℝ := lt_of_le_of_ne hq (Ne.symm hz)
+ apply (mul_le_mul_iff_left₀ hp).mp
+ have hsq := (sq_le_sq₀ (mul_nonneg hc.le hq) hb).mpr hcomp
+ nlinarith only [hsq, hcs]
+
+/-- Exact change of inverse normalization. -/
+theorem inverse_normalization_error_identity (Q R : E ≃L[ℝ] E) (xi : E) :
+ R.symm xi - Q.symm xi =
+ -(R.symm (((R : E →L[ℝ] E) - (Q : E →L[ℝ] E)) (Q.symm xi))) := by
+ simp only [sub_apply, ContinuousLinearEquiv.coe_coe, map_sub,
+ ContinuousLinearEquiv.apply_symm_apply, ContinuousLinearEquiv.symm_apply_apply]
+ abel
+
+/-- Bilinear heat comparison and relative metric comparison imply the
+normalization-error bound. Neither inverse order nor the error is assumed. -/
+theorem inverse_normalization_error_le (Q R : E ≃L[ℝ] E)
+ (hQ : (Q : E →L[ℝ] E).IsPositive) (hR : (R : E →L[ℝ] E).IsPositive)
+ (F : E →L[ℝ] E) (hF : F.IsPositive) {c C : ℝ} (hc : 0 < c) (hC : 0 ≤ C)
+ (hcompare : ∀ v, c * ⟪v, Q v⟫_ℝ ≤ ⟪v, R v⟫_ℝ)
+ (hbilinear : ∀ u v,
+ ⟪v, ((R : E →L[ℝ] E) - (Q : E →L[ℝ] E)) u⟫_ℝ ^ 2 ≤
+ (C * ⟪u, F u⟫_ℝ) * ⟪v, Q v⟫_ℝ) (xi : E) :
+ ⟪R.symm xi - Q.symm xi, Q (R.symm xi - Q.symm xi)⟫_ℝ ≤
+ C / c ^ 2 * ⟪Q.symm xi, F (Q.symm xi)⟫_ℝ := by
+ let z := ((R : E →L[ℝ] E) - (Q : E →L[ℝ] E)) (Q.symm xi)
+ have henergy : ⟪z, Q.symm z⟫_ℝ ≤ C * ⟪Q.symm xi, F (Q.symm xi)⟫_ℝ :=
+ inverse_energy_of_bilinear_bound Q hQ z
+ (mul_nonneg hC (hF.inner_nonneg_right _)) (hbilinear (Q.symm xi))
+ rw [inverse_normalization_error_identity]
+ simp only [map_neg, inner_neg_left, inner_neg_right, neg_neg]
+ calc
+ _ ≤ ⟪z, Q.symm z⟫_ℝ / c ^ 2 := (relative_inverse_bounds Q R hQ hR hc hcompare z).2
+ _ ≤ (C * ⟪Q.symm xi, F (Q.symm xi)⟫_ℝ) / c ^ 2 :=
+ div_le_div_of_nonneg_right henergy (sq_nonneg c)
+ _ = _ := by ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/WeightedSquaredFitCenters.lean b/lean/OAI/Geometry/RCD/Coordinates/WeightedSquaredFitCenters.lean
new file mode 100644
index 0000000000000000000000000000000000000000..c1923c0a4f5c147b981f063bb939f267458e79f9
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/WeightedSquaredFitCenters.lean
@@ -0,0 +1,73 @@
+import OAI.Geometry.RCD.Harmonic.WeightedInwardConstants
+
+namespace OAI
+
+/-! # Inward summation for the squared radial fit estimate -/
+
+open Filter
+open scoped Topology
+
+noncomputable section
+namespace RegularPointCoordinates
+
+/-- The actual two-fit center estimate and the squared radial fit bound
+give a quantitative center bound in the current covector norm. -/
+theorem weighted_centers_from_squared_fit {ρ M Λ Z : ℝ}
+ (hρ : 0 < ρ) (hρ1 : ρ < 1) (hτρ : (9 / 16 : ℝ) < Real.sqrt ρ)
+ (hM : 0 ≤ M) (hΛ : 0 ≤ Λ) (hZ : 0 ≤ Z)
+ {P c r w e : ℕ → ℝ} (hP : ∀ i, 0 ≤ P i) (hPs : Summable P)
+ (hr : ∀ i, 0 ≤ r i) (hw : ∀ i, 0 ≤ w i) (he : ∀ i, 0 ≤ e i)
+ (hradius : ∀ i k, r (i + k) = (1 / 2 : ℝ) ^ k * r i)
+ (hgrowth : ∀ i k, w (i + k) ≤ (9 / 8 : ℝ) ^ k * w i)
+ (hc : Tendsto c atTop (𝓝 0))
+ (hsquare : ∀ i, (e i) ^ 2 ≤ Z * P i * (w i) ^ 2)
+ (hstep : ∀ i, |c i - c (i + 1)| ≤ M * Λ * r i * e i + M * r (i + 1) * e (i + 1))
+ (i : ℕ) :
+ |c i| ≤ (M * (Λ + 1) * Real.sqrt Z) * r i * w i *
+ (1 - (9 / 16 : ℝ) / Real.sqrt ρ)⁻¹ * (1 + (Real.sqrt ρ)⁻¹) *
+ Real.sqrt (symmetricDefect ρ P i) := by
+ have hfit (j : ℕ) : e j ≤ Real.sqrt Z * w j * Real.sqrt (P j) := by
+ apply (sq_le_sq₀ (he j) (mul_nonneg
+ (mul_nonneg (Real.sqrt_nonneg Z) (hw j)) (Real.sqrt_nonneg (P j)))).mp
+ calc
+ (e j) ^ 2 ≤ Z * P j * (w j) ^ 2 := hsquare j
+ _ = (Real.sqrt Z * w j * Real.sqrt (P j)) ^ 2 := by
+ rw [mul_pow, mul_pow, Real.sq_sqrt hZ, Real.sq_sqrt (hP j)]
+ ring
+ have hcoeff : 0 ≤ M * (Λ + 1) * Real.sqrt Z := by positivity
+ apply weighted_affine_constants_le_envelope hρ hρ1 hτρ hcoeff hP hPs hr hw hradius hgrowth hc
+ intro j
+ have hrw : r (j + 1) * w (j + 1) ≤ r j * w j := by
+ have hg := hgrowth j 1
+ simp only [pow_one] at hg
+ rw [hradius j 1, pow_one]
+ have hh := mul_le_mul_of_nonneg_left hg
+ (mul_nonneg (by norm_num : (0 : ℝ) ≤ 1 / 2) (hr j))
+ nlinarith [mul_nonneg (hr j) (hw j)]
+ calc
+ _ ≤ M * Λ * r j * e j + M * r (j + 1) * e (j + 1) := hstep j
+ _ ≤ M * Λ * r j * (Real.sqrt Z * w j * Real.sqrt (P j)) +
+ M * r (j + 1) * (Real.sqrt Z * w (j + 1) * Real.sqrt (P (j + 1))) := by
+ exact add_le_add
+ (mul_le_mul_of_nonneg_left (hfit j) (mul_nonneg (mul_nonneg hM hΛ) (hr j)))
+ (mul_le_mul_of_nonneg_left (hfit (j + 1)) (mul_nonneg hM (hr (j + 1))))
+ _ = M * Real.sqrt Z * (Λ * (r j * w j) * Real.sqrt (P j) +
+ (r (j + 1) * w (j + 1)) * Real.sqrt (P (j + 1))) := by ring
+ _ ≤ M * Real.sqrt Z * (Λ * (r j * w j) * Real.sqrt (P j) +
+ (r j * w j) * Real.sqrt (P (j + 1))) := by
+ exact mul_le_mul_of_nonneg_left
+ (add_le_add_right (mul_le_mul_of_nonneg_right hrw (Real.sqrt_nonneg _)) _)
+ (by positivity)
+ _ ≤ (M * (Λ + 1) * Real.sqrt Z) * r j * w j *
+ (Real.sqrt (P j) + Real.sqrt (P (j + 1))) := by
+ have h0 := mul_nonneg (mul_nonneg (hr j) (hw j)) (Real.sqrt_nonneg (P j))
+ have h1 := mul_nonneg (mul_nonneg (mul_nonneg hΛ (hr j)) (hw j))
+ (Real.sqrt_nonneg (P (j + 1)))
+ have hh := mul_nonneg (mul_nonneg hM (Real.sqrt_nonneg Z)) (add_nonneg h0 h1)
+ nlinarith
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Coordinates/WorkingNormalizerBound.lean b/lean/OAI/Geometry/RCD/Coordinates/WorkingNormalizerBound.lean
new file mode 100644
index 0000000000000000000000000000000000000000..580e8006fab3190d66233da68452c4ddf41efc65
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Coordinates/WorkingNormalizerBound.lean
@@ -0,0 +1,84 @@
+import OAI.Geometry.RCD.Coordinates.FiniteNormalizerGrowth
+import OAI.Geometry.RCD.Metric.UniformVolumeRatio
+
+namespace OAI
+
+/-! # A bounded working frame from a near-identity mean Gram -/
+
+open Set MeasureTheory
+open scoped InnerProductSpace
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {X E : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ [NormedAddCommGroup E] [InnerProductSpace ℝ E] [CompleteSpace E]
+
+/-- Every exact normalizer of a mean Gram within one half of the identity
+has squared norm at most two. This is uniform in the chosen normalizer. -/
+theorem normalizer_norm_sq_le_two_of_sub_id (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ (U : E →L[ℝ] SobolevSpace μ hQ) (s : Set X) (hs : MeasurableSet s)
+ (A : E ≃L[ℝ] E) (hA : IsExactMeanNormalization μ hQ U s hs A)
+ (hgram : ‖sobolevMeanGram μ hQ U s hs - ContinuousLinearMap.id ℝ E‖ ≤ 1 / 2) :
+ ‖(A : E →L[ℝ] E)‖ ^ 2 ≤ 2 := by
+ have hbound (v : E) : ‖A v‖ ^ 2 ≤ 2 * ‖v‖ ^ 2 := by
+ have hlo := inner_lower_of_sub_id_norm (sobolevMeanGram μ hQ U s hs) hgram (A v)
+ rw [meanGram_energy_of_exact_normalization μ hQ U s hs A hA] at hlo
+ simp only [ContinuousLinearEquiv.symm_apply_apply] at hlo
+ linarith
+ have hn : ‖(A : E →L[ℝ] E)‖ ≤ Real.sqrt 2 := by
+ apply ContinuousLinearMap.opNorm_le_bound _ (Real.sqrt_nonneg _)
+ intro v
+ apply (sq_le_sq₀ (norm_nonneg _) (mul_nonneg (Real.sqrt_nonneg _) (norm_nonneg _))).mp
+ rw [mul_pow, Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 2)]
+ exact hbound v
+ nlinarith [Real.sq_sqrt (by norm_num : (0 : ℝ) ≤ 2), norm_nonneg (A : E →L[ℝ] E)]
+
+/-- The initial splitting error and the fixed Bishop--Gromov volume ratio
+construct uniformly bounded working frames at every nearby center. -/
+theorem exists_nearby_working_normalizer {K : ℝ} (m : ℕ)
+ (hX : NoncollapsedRCD K (m + 1) X) {a : ℝ} (ha : 0 ≤ a)
+ (hBG : BallVolumeComparison (hausdorff (m + 1) X) (comparisonModelVolume m a))
+ (u : Fin (m + 1) → SobolevSpace (hausdorff (m + 1) X) hX.quadratic)
+ {p q : X} {R ε : ℝ} {w : X → Euclidean (m + 1)}
+ (hR : 0 < R) (hscale : a * (3 * R) ≤ 1) (hε : 0 ≤ ε)
+ (hsmall : ((m + 1 : ℕ) : ℝ) ^ 2 * (normalizationVolumeRatio m * ε) ≤ 1 / 2)
+ (hfirst : FirstOrderSplittingOn (hausdorff (m + 1) X) hX.quadratic p (2 * R) ε u w)
+ (hq : q ∈ Metric.ball p (R / 4)) :
+ ∃ T : Euclidean (m + 1) ≃L[ℝ] Euclidean (m + 1),
+ IsExactMeanNormalization (hausdorff (m + 1) X) hX.quadratic
+ (sobolevColumnMap (hausdorff (m + 1) X) hX.quadratic u)
+ (Metric.ball q (R / 2)) measurableSet_ball T ∧
+ ‖(T : Euclidean (m + 1) →L[ℝ] Euclidean (m + 1))‖ ^ 2 ≤ 2 := by
+ let μ := hausdorff (m + 1) X
+ let U := sobolevColumnMap μ hX.quadratic u
+ have hsub : Metric.ball q (R / 2) ⊆ Metric.ball p (2 * R) := by
+ intro x hx
+ have hxp := dist_triangle x q p
+ have hxq : dist x q < R / 2 := hx
+ have hqp : dist q p < R / 4 := hq
+ change dist x p < 2 * R
+ linarith
+ have hratio := nearby_normalization_volume_ratio m hX ha hBG hR hscale hq
+ have hnorm : ‖sobolevMeanGram μ hX.quadratic U (Metric.ball q (R / 2)) measurableSet_ball -
+ ContinuousLinearMap.id ℝ (Euclidean (m + 1))‖ ≤ 1 / 2 :=
+ (meanGram_sub_id_norm_le_of_subset μ hX.quadratic u measurableSet_ball hsub
+ (ne_of_gt (hX.fullSupport q _ (by positivity)))
+ (ne_of_lt (hX.finiteOnBounded _ Metric.isBounded_ball))
+ (ne_of_gt (hX.fullSupport p _ (by positivity)))
+ (ne_of_lt (hX.finiteOnBounded _ Metric.isBounded_ball))
+ (zero_le_one.trans (normalizationVolumeRatio_ge_one m)) hε hratio hfirst.gram).trans hsmall
+ obtain ⟨T, hT⟩ := exists_exact_mean_normalization μ hX.quadratic U
+ (Metric.ball q (R / 2)) measurableSet_ball (fun v hv => by
+ have hlo := inner_lower_of_sub_id_norm _ hnorm v
+ have hpos : 0 < (1 / 2 : ℝ) * ‖v‖ ^ 2 := by
+ exact mul_pos (by norm_num) (sq_pos_of_ne_zero (norm_ne_zero_iff.mpr hv))
+ linarith)
+ exact ⟨T, hT, normalizer_norm_sq_le_two_of_sub_id μ hX.quadratic U _ measurableSet_ball T hT hnorm⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ACAffinePairing.lean b/lean/OAI/Geometry/RCD/Harmonic/ACAffinePairing.lean
new file mode 100644
index 0000000000000000000000000000000000000000..548c137984ddc20521040dc0d45b7e69bec2bcf2
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ACAffinePairing.lean
@@ -0,0 +1,40 @@
+import OAI.Geometry.RCD.Heat.ACDerivativeL2Endpoint
+
+namespace OAI
+
+/-! # Pairing a bounded affine residual with a varying coefficient -/
+
+open Set Filter MeasureTheory
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem ac_zero_endpoint_pairing_bound {b z : ℝ → ℝ} {η : ℝ}
+ (hb : AbsolutelyContinuousOnInterval b 0 1)
+ (hz : AbsolutelyContinuousOnInterval z 0 1)
+ (hz0 : z 0=0) (hz1 : z 1=0)
+ (hbound : ∀ t∈Icc (0:ℝ) 1, |z t|≤η) :
+ |∫ t in Icc (0:ℝ) 1, b t*deriv z t| ≤
+ η*(∫ t in Icc (0:ℝ) 1, |deriv b t|) := by
+ have he := hb.integral_mul_deriv_eq_deriv_mul hz
+ simp only [hz0,hz1,mul_zero,sub_zero,zero_sub] at he
+ have hei : (∫ t in Icc (0:ℝ) 1, b t*deriv z t)=
+ -(∫ t in Icc (0:ℝ) 1, deriv b t*z t) := by
+ simpa only [intervalIntegral.integral_of_le zero_le_one,integral_Icc_eq_integral_Ioc] using he
+ have hi : IntegrableOn (fun t => η*|deriv b t|) (Icc (0:ℝ) 1) :=
+ ((intervalIntegrable_iff_integrableOn_Icc_of_le zero_le_one).mp hb.intervalIntegrable_deriv).abs.const_mul η
+ rw [hei,abs_neg]
+ calc
+ |∫ t in Icc (0:ℝ) 1, deriv b t*z t| ≤
+ ∫ t in Icc (0:ℝ) 1, η*|deriv b t| := by
+ rw [← Real.norm_eq_abs]
+ apply norm_integral_le_of_norm_le hi
+ filter_upwards [ae_restrict_mem measurableSet_Icc] with t ht
+ rw [Real.norm_eq_abs,abs_mul,mul_comm η]
+ exact mul_le_mul_of_nonneg_left (hbound t ht) (abs_nonneg _)
+ _ = _ := integral_const_mul _ _
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ActualGramEnvelope.lean b/lean/OAI/Geometry/RCD/Harmonic/ActualGramEnvelope.lean
new file mode 100644
index 0000000000000000000000000000000000000000..cdefd284b23b9a38bcffa5e629268358eccdd133
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ActualGramEnvelope.lean
@@ -0,0 +1,109 @@
+import OAI.Geometry.RCD.Coordinates.CoordinateHeatInput
+import OAI.Geometry.RCD.Harmonic.GramSourceEstimate
+import OAI.Geometry.RCD.Harmonic.HarmonicEndpointBound
+import OAI.Geometry.RCD.Harmonic.HarmonicCurvatureBounds
+import OAI.Geometry.RCD.Sobolev.HarmonicCutoffErrorIntegral
+import OAI.Geometry.RCD.Metric.LongTimeMassSum
+import OAI.Geometry.RCD.Sobolev.DyadicScalarBackground
+
+namespace OAI
+
+/-! # The actual mean/heat discrepancy is controlled by the full mass envelope -/
+
+open Set Metric MeasureTheory
+open scoped InnerProductSpace NNReal ENNReal BoundedContinuousFunction
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) [μ.Regular] [IsLocallyFiniteMeasure μ] (hQ : QuadraticCheegerEnergy μ)
+ {ker : ℝ → X → X → ℝ} (hk : IsContinuousHeatKernel μ hQ ker)
+ {m : ℕ} {U : Euclidean (m + 2) →L[ℝ] SobolevSpace μ hQ}
+ {M : PositiveBilinearMeasure X (Euclidean (m + 2))} {κ : ℝ} {p : X} {r₀ : ℝ} {L : ℝ≥0}
+ (G : ∀ v, LocalHarmonicEnergy μ hQ U M κ p r₀ L v)
+ {ρ C₀ : ℝ} (χ : GoodLaplacianCutoff μ hQ p ρ C₀)
+
+include G in
+/-- All three source components and the terminal value are estimated here
+for the same genuine harmonic map, cutoff, kernel and full Bochner measure. -/
+theorem exists_actual_gram_envelope_bound (hg : HasCoordinateHeatBounds μ ker)
+ (hdiff : HasGaussianHeatDifferenceBounds μ ker) (hρ : 0 < ρ) (hρr : ρ < r₀)
+ {A V W δ R : ℝ} (hA : 0 ≤ A) (hV : 0 < V) (hW : 0 ≤ W)
+ (hδ : 0 < δ) (hR : 0 < R) (hR1 : R ≤ 1) (lambda : ℝ) :
+ ∃ C : ℝ, 0 < C ∧ ∀ (i : ℕ), 1 ≤ i → ∀ (x q : X),
+ μ (ball q (R / 2 ^ i)) ≠ ∞ →
+ V * (R / 2 ^ i) ^ (m + 2) ≤ μ.real (ball q (R / 2 ^ i)) →
+ dist x q ≤ A * (R / 2 ^ i) →
+ (∀ j, μ.real (ball x (R / 2 ^ j)) ≤ W * (R / 2 ^ j) ^ (m + 2)) →
+ (∀ t, 0 < t → t ≤ R ^ 2 → ∀ z ∈ ball x R,
+ V * (Real.sqrt t) ^ (m + 2) ≤ μ.real (ball z (Real.sqrt t))) →
+ closedBall p (2 * ρ) ⊆ ball x R →
+ (∀ z ∉ ball x R, χ.weight z = 0) →
+ (∀ z, ρ ≤ dist p z → dist p z ≤ 2 * ρ → δ ≤ dist x z) →
+ (∀ z ∈ ball q (R / 2 ^ i), χ.weight z = 1) →
+ ∀ v : Euclidean (m + 2),
+ |⟪v, (sobolevMeanGram μ hQ U (ball q (R / 2 ^ i)) measurableSet_ball -
+ cutoffHeatGram μ hQ hk χ.weight.continuous (χ.hasCompactSupport μ hQ)
+ U (sq_pos_of_pos (div_pos hR (pow_pos (by norm_num : (0 : ℝ) < 2) i))) x lambda) v⟫_ℝ| ≤
+ C * ⟪v, dyadicBochnerEnvelope M (m + 2) x R i v⟫_ℝ := by
+ obtain ⟨Ce, hCe, he⟩ := exists_harmonic_endpoint_bound (E := Euclidean (m + 2)) μ hQ hk hg hdiff (m + 2) hA hV hW
+ obtain ⟨Cs, hCs, hs⟩ := exists_short_average_mass_integral_bound μ hQ hk hg m hA hV
+ obtain ⟨Cl, hCl, hl⟩ := exists_long_time_mass_sum_bound μ hQ hk hg hdiff m hA hV
+ obtain ⟨Cc, hCc, hc⟩ := exists_harmonic_curvature_integral_bound (E := Euclidean (m + 2)) μ hQ hk hg hdiff (m + 2) hA hV hW
+ obtain ⟨Cx, hCx, hx⟩ := exists_harmonic_cutoff_error_integral_bound μ hQ hk G χ
+ hg hdiff hρ hρr hA hV hδ
+ let C := Ce * (L : ℝ) ^ 2 + |lambda| * R ^ 2 + 2 * (Cs + Cl) +
+ 4 * |κ| * Cc * (L : ℝ) ^ 2 * R ^ 2 + 2 * Cx * R ^ 2
+ refine ⟨C, by dsimp only [C]; positivity, ?_⟩
+ intro i hi x q hfinite hvolume hcenter hupper hsource hcontain hzero hsep hone v
+ let s := R / (2 : ℝ) ^ i
+ have hspos : 0 < s := div_pos hR (by positivity)
+ have hsR : s ≤ R := div_le_self hR.le (one_le_pow₀ (by norm_num))
+ have hsRhalf : s ≤ R / 2 := by
+ have hp : (2 : ℝ) ≤ 2 ^ i := by simpa using pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 2) hi
+ exact div_le_div_of_nonneg_left hR.le (by norm_num) hp
+ have hsq : s ^ 2 ≤ R ^ 2 := (sq_le_sq₀ hspos.le hR.le).mpr hsR
+ have hpos : 0 < μ.real (ball q s) := (mul_pos hV (pow_pos hspos (m + 2))).trans_le hvolume
+ have hχΩ : tsupport (χ.weight : X → ℝ) ⊆ ball p (2 * r₀) := by
+ intro z hz
+ have hd := χ.tsupport_subset μ hQ hz
+ rw [mem_closedBall] at hd
+ exact lt_of_le_of_lt hd (by linarith)
+ have hsupp : ∀ z, χ.weight z ≠ 0 → z ∈ ball x R := by
+ intro z hz
+ by_contra hn
+ exact hz (hzero z hn)
+ have hterm := he R s x q hR hR1 hspos hsRhalf hfinite hpos hcenter
+ (by simpa only [pow_zero, div_one] using hupper 0)
+ (by simpa only [Real.sqrt_sq hR.le] using hsource (R ^ 2) (sq_pos_of_pos hR) le_rfl)
+ U M κ p r₀ L v (G v) χ.weight χ.bounds hχΩ hzero χ.sobolev χ.representative
+ have hshort := hs M R hR hR1 x χ.weight (χ.hasCompactSupport μ hQ) χ.bounds hzero i q
+ hfinite hvolume hcenter (fun t ht htR z hz => hsource t ht (htR.trans hsq) z (hsupp z hz)) v
+ have hlong := hl M R hR hR1 x χ.weight (χ.hasCompactSupport μ hQ) χ.bounds hzero i q
+ hfinite hpos hcenter (fun t ht htR z hz => hsource t ht htR z (hsupp z hz)) v
+ have hcurv := hc R hR hR1 i x q hfinite hvolume hcenter hupper hsource
+ U M κ p r₀ L v (G v) χ.weight χ.bounds hχΩ hzero χ.sobolev χ.representative
+ have herr := (hx R s x q hR hR1 hspos hsR hfinite hvolume hcenter hsep
+ (fun t ht htR z _ hz => hsource t ht htR z
+ (hcontain (by simpa only [mem_closedBall, dist_comm] using hz))) v).2.2
+ have hmain := (G v).mean_sub_heat_norm_le μ hQ hk χ hρ hρr
+ (ball q s) measurableSet_ball isBounded_ball hone (sq_pos_of_pos hspos) hsq x lambda
+ dsimp only at hmain
+ have hb := dyadic_scalar_background_bounds M (m + 2) x hR hR1 i v
+ have he' := mul_le_mul_of_nonneg_left hb.1 (by positivity : 0 ≤ Ce * (L : ℝ) ^ 2)
+ have hregBound := mul_le_mul_of_nonneg_left hb.2.1 (abs_nonneg lambda)
+ have hc' := mul_le_mul_of_nonneg_left hb.2.2.1
+ (by positivity : 0 ≤ 2 * |κ| * Cc * (L : ℝ) ^ 2)
+ have hx' := mul_le_mul_of_nonneg_left hb.2.2.2 hCx.le
+ have hcurv' := mul_le_mul_of_nonneg_left hcurv (by positivity : 0 ≤ 2 * |κ|)
+ rw [abs_mul, abs_of_nonneg (sq_nonneg s)] at hmain
+ dsimp only [C, s] at *
+ linear_combination hmain + hterm + 2 * hshort + 2 * hlong + hcurv' + herr +
+ he' + hregBound + hc' + hx'
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionConfiguration.lean b/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionConfiguration.lean
new file mode 100644
index 0000000000000000000000000000000000000000..d58f71bdf694caa520c9e6aaa88667d26a4fd4d9
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionConfiguration.lean
@@ -0,0 +1,205 @@
+import OAI.Geometry.RCD.Harmonic.ActualProjectionOuter
+import OAI.Geometry.RCD.Sobolev.SmallBallPoissonQuadratic
+import OAI.Geometry.RCD.Harmonic.ScaledProjectionData
+import OAI.Geometry.RCD.Coordinates.BoundedLocalCoordinates
+
+namespace OAI
+
+/-! # The geometric data for one actual two-center projection
+
+The source measures, equal-Laplacian Poisson replacements and harmonic
+coordinate estimates determine the affine projection and its residual.
+-/
+
+open Set Metric MeasureTheory
+open scoped ENNReal NNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- Equal-Laplacian replacements and harmonic coordinates centered at the
+second point, with their source and normalization bounds. -/
+structure ActualProjectionConfiguration {K : ℝ} {n : ℕ} (hX : NoncollapsedRCD K n X)
+ [IsFiniteMeasureOnCompacts (hausdorff n X)] (κ B J C A Cχ epsilon H D L M : ℝ) where
+ root : ℝ
+ root_le_one : root ≤ 1
+ first : X
+ center : X
+ firstSource : DyadicDistanceSources (hausdorff n X) hX.quadratic n κ first root
+ secondSource : DyadicDistanceSources (hausdorff n X) hX.quadratic n κ center root
+ firstReplacement : DyadicDistanceReplacements (hausdorff n X) hX.quadratic firstSource B J C
+ secondReplacement : DyadicDistanceReplacements (hausdorff n X) hX.quadratic secondSource B J C
+ index : ℕ
+ room : dist center first ≤ distanceSourceRadius root index / 4
+ curvature : -1 ≤ K * distanceSourceRadius root index ^ 2
+ smallCurvature : -κ ≤ K * (distanceSourceRadius root index / 512) ^ 2
+ laplacianBound : (n : ℝ) + κ * (4 * distanceSourceRadius root index) ^ 2 ≤ (n : ℝ) + 1
+ coordinates : Fin n → SobolevSpace (hausdorff n X) hX.quadratic
+ coordinateValues : X → Euclidean n
+ harmonic : ∀ j, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic
+ (ball center (distanceSourceRadius root index / 4)) (coordinates j)
+ gradient : ∀ j, ∀ᵐ x ∂(hausdorff n X).restrict (ball center (distanceSourceRadius root index / 4)),
+ localGamma (hausdorff n X) hX.quadratic (coordinates j) (coordinates j) x ≤ (1 + epsilon) ^ 2
+ firstGradient : ∀ᵐ x ∂(hausdorff n X).restrict (ball center (distanceSourceRadius root index / 4)),
+ localGamma (hausdorff n X) hX.quadratic (firstReplacement.replacement index)
+ (firstReplacement.replacement index) x ≤ (A * distanceSourceRadius root index) ^ 2
+ secondGradient : ∀ᵐ x ∂(hausdorff n X).restrict (ball center (distanceSourceRadius root index / 4)),
+ localGamma (hausdorff n X) hX.quadratic (secondReplacement.replacement index)
+ (secondReplacement.replacement index) x ≤ (A * distanceSourceRadius root index) ^ 2
+ cutoff : GoodLaplacianCutoff (hausdorff n X) hX.quadratic center (distanceSourceRadius root index / 64) Cχ
+ one : SobolevSpace (hausdorff n X) hX.quadratic
+ oneRepresentative : SobolevSpace.toLp (hausdorff n X) hX.quadratic one =ᵐ[
+ (hausdorff n X).restrict (ball center (distanceSourceRadius root index / 512))] fun _ => (1 : ℝ)
+ volume : ∀ t : ℝ, 0 < t → t ≤ root →
+ |(hausdorff n X).real (ball center t) / (euclideanUnitVolume n * t ^ n) - 1| ≤ 1 / 4
+ sphere : (hausdorff n X) (sphere center (distanceSourceRadius root index / 2048)) = 0
+ frame : Euclidean n ≃L[ℝ] Euclidean n
+ frameBound : ‖(frame : Euclidean n →L[ℝ] Euclidean n)‖ ≤ M
+ source : ℝ
+ source_pos : 0 < source
+ pairBudget : normalizedPoissonDefect (hausdorff n X) hX.quadratic firstSource index +
+ normalizedPoissonDefect (hausdorff n X) hX.quadratic secondSource index ≤ source ^ 2
+ affineBound : ∀ c a, |c| + distanceSourceRadius root index * ‖frame.symm a‖ ≤ H *
+ ‖normalizeLocalL2 (hausdorff n X) (ball center (distanceSourceRadius root index / 2048))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineCoordinateMap (hausdorff n X) hX.quadratic coordinates
+ (ball center (distanceSourceRadius root index / 2048))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c, a))‖
+ affineHalfBound : ∀ c a, |c| + distanceSourceRadius root index * ‖frame.symm a‖ ≤ H *
+ ‖normalizeLocalL2 (hausdorff n X) (ball center (distanceSourceRadius root index / 4096))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineCoordinateMap (hausdorff n X) hX.quadratic coordinates
+ (ball center (distanceSourceRadius root index / 4096))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c, a))‖
+ columnBound : ∀ b : Euclidean n, ∀ᵐ x ∂(hausdorff n X).restrict
+ (ball center (distanceSourceRadius root index / 512)),
+ |SobolevSpace.toLp (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic coordinates (frame b)) x| ≤
+ L * distanceSourceRadius root index * ‖b‖
+ radialColumns : Euclidean n →L[ℝ] SobolevSpace (hausdorff n X) hX.quadratic
+ radialMatrix : Euclidean n →L[ℝ] Euclidean n
+ radialRepresentative : ∀ b, SobolevSpace.toLp (hausdorff n X) hX.quadratic (radialColumns b) =ᵐ[
+ (hausdorff n X).restrict (ball center (distanceSourceRadius root index / 512))]
+ localGamma (hausdorff n X) hX.quadratic (secondReplacement.replacement index)
+ (sobolevColumnMap (hausdorff n X) hX.quadratic coordinates b)
+ radialFit : ∀ b, ‖normalizeLocalL2 (hausdorff n X) (ball center (distanceSourceRadius root index / 512))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic (ball center (distanceSourceRadius root index / 512))
+ (radialColumns (frame b) - sobolevColumnMap (hausdorff n X) hX.quadratic coordinates (radialMatrix (frame b))))‖ ≤
+ D * distanceSourceRadius root index * ‖b‖ * source
+ totalSource : ℝ
+ totalSource_nonneg : 0 ≤ totalSource
+ summable : Summable (normalizedPoissonDefect (hausdorff n X) hX.quadratic secondSource)
+ totalBudget : (∑' j, normalizedPoissonDefect (hausdorff n X) hX.quadratic secondSource j) ≤ totalSource
+ approximationError : ℝ
+ approximationError_pos : 0 < approximationError
+ measured : IsMeasuredEuclideanApproximation (hausdorff n X) n center
+ (distanceSourceRadius root index) (1 / 1024) approximationError coordinateValues
+ centered : coordinateValues center = 0
+ representative : ∀ j, SobolevSpace.toLp (hausdorff n X) hX.quadratic
+ (radiusScaledColumns (hausdorff n X) hX.quadratic (distanceSourceRadius root index) coordinates j) =ᵐ[
+ (hausdorff n X).restrict (ball center ((1 / 1024) * distanceSourceRadius root index))]
+ fun x => coordinateValues x j
+
+namespace ActualProjectionConfiguration
+
+variable {K : ℝ} {n : ℕ} {hX : NoncollapsedRCD K n X}
+ [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ {κ B J C A Cχ epsilon H D L M : ℝ}
+
+/-- The physical radius is the actual radius of the chosen replacement. -/
+def radius (d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M) : ℝ :=
+ distanceSourceRadius d.root d.index
+
+theorem radius_pos (d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M) :
+ 0 < d.radius := distanceSourceRadius_pos d.secondSource.radius_pos d.index
+
+theorem radius_le_root (d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M) :
+ d.radius ≤ d.root := by
+ have hh := distanceSourceRadius_outer_le d.secondSource.radius_pos.le d.index
+ change 2 * d.radius ≤ d.root at hh
+ linarith [d.radius_pos]
+
+/-- One explicit approximation error controls both the measured coordinates
+and the actual radial quadratic error. -/
+def error (d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M) : ℝ :=
+ d.approximationError +
+ 2 * (((5 / 3 : ℝ) * (1024 : ℝ) ^ n) *
+ (annularPoincareConstant K n * B / (3 / 4 * euclideanUnitVolume n) * d.totalSource)) +
+ 2 * (d.approximationError * (2 * (1 / 1024 : ℝ) + d.approximationError) / 2) ^ 2
+
+theorem approximationError_le (hB : 0 ≤ B)
+ (d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M) :
+ d.approximationError ≤ d.error := by
+ have hP := annularPoincareConstant_pos K n
+ have hV := euclideanUnitVolume_pos n
+ have hT := d.totalSource_nonneg
+ have hterm : 0 ≤ 2 * (((5 / 3 : ℝ) * (1024 : ℝ) ^ n) *
+ (annularPoincareConstant K n * B / (3 / 4 * euclideanUnitVolume n) * d.totalSource)) := by
+ positivity
+ dsimp only [error]
+ linarith [sq_nonneg (d.approximationError * (2 * (1 / 1024 : ℝ) + d.approximationError) / 2)]
+
+theorem error_pos (hB : 0 ≤ B)
+ (d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M) :
+ 0 < d.error := d.approximationError_pos.trans_le (d.approximationError_le hB)
+
+/-- The actual radial quadratic estimate on the outer projection ball. -/
+theorem quadratic_error
+ (hn : 2 ≤ n) (hκ : 0 ≤ κ) (hB : 0 ≤ B)
+ (d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M) :
+ ((hausdorff n X).real (ball d.center ((1 / 1024) * d.radius)))⁻¹ *
+ (∫ x in ball d.center ((1 / 1024) * d.radius),
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic
+ ((d.radius ^ 2)⁻¹ • d.secondReplacement.replacement d.index) x -
+ ‖d.coordinateValues x‖ ^ 2 / 2) ^ 2 ∂hausdorff n X) ≤ d.error := by
+ let Ccoord : ℝ≥0 := ⟨1 / 1024 + d.approximationError, by
+ linarith [d.approximationError_pos]⟩
+ let u := radiusScaledColumns (hausdorff n X) hX.quadratic d.radius d.coordinates
+ have hb (j : Fin n) : ∀ᵐ x ∂(hausdorff n X).restrict
+ (ball d.center ((1 / 1024) * d.radius)),
+ |SobolevSpace.toLp (hausdorff n X) hX.quadratic (u j) x| ≤ Ccoord := by
+ filter_upwards [d.representative j, ae_restrict_mem measurableSet_ball] with x hx hball
+ change SobolevSpace.toLp (hausdorff n X) hX.quadratic (u j) x = _ at hx
+ rw [hx]
+ have hnorm := (d.measured.metric.centered_norm_error d.radius_pos
+ (by norm_num) d.centered hball.le).2
+ exact (show |d.coordinateValues x j| ≤ ‖d.coordinateValues x‖ by
+ simpa only [Real.norm_eq_abs] using PiLp.norm_apply_le (d.coordinateValues x) j).trans hnorm
+ let w := fun j => boundedLocalVersion (hausdorff n X) hX.quadratic (u j) Ccoord
+ have hw (j : Fin n) : SobolevSpace.toLp (hausdorff n X) hX.quadratic (w j) =ᵐ[
+ (hausdorff n X).restrict (ball d.center ((1 / 1024) * d.radius))]
+ fun x => d.coordinateValues x j :=
+ (boundedLocalVersion_eq (hausdorff n X) hX.quadratic (u j) Ccoord (hb j)).trans
+ (d.representative j)
+ have hh := actual_poisson_small_ball_quadratic_error hX hn d.secondReplacement
+ hκ hB d.totalSource_nonneg d.approximationError_pos.le
+ (by norm_num : (0 : ℝ) < 1 / 1024) (by norm_num : (1 / 1024 : ℝ) ≤ 1 / 4)
+ d.root_le_one (euclideanUnitVolume_pos n) d.volume d.summable d.totalBudget d.index
+ w Ccoord d.coordinateValues
+ (fun j => boundedLocalVersion_bound (hausdorff n X) hX.quadratic (u j) Ccoord)
+ hw d.measured.metric d.centered
+ have hpow : ((1 / 1024 : ℝ)⁻¹) ^ n = (1024 : ℝ) ^ n := by norm_num
+ rw [hpow] at hh
+ change _ ≤ d.error
+ exact hh.trans (by dsimp only [error]; linarith [d.approximationError_pos])
+
+/-- The exact orthogonal residual norm of the actual two-center target. -/
+def projectionNorm (d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M) : ℝ :=
+ ‖normalizeLocalL2 (hausdorff n X) (ball d.center ((1 / 2048) * d.radius))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineResidual (hausdorff n X) hX.quadratic
+ (radiusScaledColumns (hausdorff n X) hX.quadratic d.radius d.coordinates)
+ (ball d.center ((1 / 2048) * d.radius)) (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic
+ (ball d.center ((1 / 2048) * d.radius))
+ ((d.radius ^ 2)⁻¹ • (d.secondReplacement.replacement d.index - d.firstReplacement.replacement d.index))))‖
+
+end ActualProjectionConfiguration
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionOuter.lean b/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionOuter.lean
new file mode 100644
index 0000000000000000000000000000000000000000..19bf51680ee5dd5df27860f861e3312ea33e37ac
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionOuter.lean
@@ -0,0 +1,270 @@
+import OAI.Geometry.RCD.Harmonic.ActualTwoCenterProjection
+import OAI.Geometry.RCD.Coordinates.NormalizedTransportDefect
+import OAI.Geometry.RCD.Harmonic.ScaledProjectionOuter
+import OAI.Geometry.RCD.Harmonic.ProjectionResidualValues
+
+namespace OAI
+
+/-! # Uniform outer estimates for the actual two-center Poisson projection -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal NNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- The same actual projection satisfies a uniform outer estimate. The
+transport error is constructed from the second Poisson replacement and its
+full source measure. All three constants precede the centers and scales. -/
+theorem actual_two_center_projection_outer {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ (hhessian : LocalPoissonHessianActionInput hX)
+ (hproduct : LocalPoissonGradientProductInput hX)
+ (hpoincare : LocalMeanPoincareInput hX)
+ (hgradient : LocalHarmonicL2GradientInput hX) (hn : 2 ≤ n)
+ {κ B J C A Cχ epsilon H D L : ℝ}
+ (hκ : 0 ≤ κ) (hK : -κ ≤ K) (hB : 0 ≤ B) (hJ : 0 ≤ J)
+ (hCχ : 0 ≤ Cχ) (hA : 0 ≤ A) (hepsilon : 0 ≤ epsilon)
+ (hH : 0 ≤ H) (hD : 0 ≤ D) (hL : 0 ≤ L) :
+ ∃ F G₀ T₀ : ℝ, 0 ≤ F ∧ 0 ≤ G₀ ∧ 0 ≤ T₀ ∧ ∀ {r0 : ℝ} (p₁ p₂ : X)
+ (S₁ : DyadicDistanceSources (hausdorff n X) hX.quadratic n κ p₁ r0)
+ (S₂ : DyadicDistanceSources (hausdorff n X) hX.quadratic n κ p₂ r0)
+ (T₁ : DyadicDistanceReplacements (hausdorff n X) hX.quadratic S₁ B J C)
+ (T₂ : DyadicDistanceReplacements (hausdorff n X) hX.quadratic S₂ B J C)
+ (i : ℕ)
+ (_hroom₁ : dist p₂ p₁ ≤ distanceSourceRadius r0 i / 4)
+ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ (_hu : ∀ j, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic
+ (ball p₂ (distanceSourceRadius r0 i / 4)) (u j))
+ (_hgrad : ∀ j, ∀ᵐ x ∂(hausdorff n X).restrict (ball p₂ (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (u j) (u j) x ≤ (1 + epsilon) ^ 2)
+ (_hf₁ : ∀ᵐ x ∂(hausdorff n X).restrict (ball p₂ (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (T₁.replacement i) (T₁.replacement i) x ≤
+ (A * distanceSourceRadius r0 i) ^ 2)
+ (_hf₂ : ∀ᵐ x ∂(hausdorff n X).restrict (ball p₂ (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (T₂.replacement i) (T₂.replacement i) x ≤
+ (A * distanceSourceRadius r0 i) ^ 2)
+ (_χ : GoodLaplacianCutoff (hausdorff n X) hX.quadratic p₂ (distanceSourceRadius r0 i / 64) Cχ)
+ (_hcurv : -κ ≤ K * (distanceSourceRadius r0 i / 512) ^ 2)
+ (η : SobolevSpace (hausdorff n X) hX.quadratic)
+ (_hη : SobolevSpace.toLp (hausdorff n X) hX.quadratic η =ᵐ[
+ (hausdorff n X).restrict (ball p₂ (distanceSourceRadius r0 i / 512))]
+ fun _ => (1 : ℝ))
+ (_hvolume : ∀ t : ℝ, 0 < t → t ≤ distanceSourceRadius r0 i →
+ |(hausdorff n X).real (ball p₂ t) / (euclideanUnitVolume n * t ^ n) - 1| ≤ 1 / 4)
+ (_ha : (n : ℝ) + κ * (4 * distanceSourceRadius r0 i) ^ 2 ≤ (n : ℝ) + 1)
+ (_hsphere : (hausdorff n X) (sphere p₂ (distanceSourceRadius r0 i / 2048)) = 0)
+ (N : Euclidean n ≃L[ℝ] Euclidean n) (σ : ℝ) (_hσ : 0 ≤ σ)
+ (_hbudget : normalizedPoissonDefect (hausdorff n X) hX.quadratic S₁ i +
+ normalizedPoissonDefect (hausdorff n X) hX.quadratic S₂ i ≤ σ ^ 2)
+ (_hbound : ∀ c a, |c| + distanceSourceRadius r0 i * ‖N.symm a‖ ≤ H *
+ ‖normalizeLocalL2 (hausdorff n X) (ball p₂ (distanceSourceRadius r0 i / 2048))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineCoordinateMap (hausdorff n X) hX.quadratic u
+ (ball p₂ (distanceSourceRadius r0 i / 2048))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c, a))‖)
+ (_hboundHalf : ∀ c a, |c| + distanceSourceRadius r0 i * ‖N.symm a‖ ≤ H *
+ ‖normalizeLocalL2 (hausdorff n X) (ball p₂ (distanceSourceRadius r0 i / 4096))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineCoordinateMap (hausdorff n X) hX.quadratic u
+ (ball p₂ (distanceSourceRadius r0 i / 4096))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c, a))‖)
+ (_hcolumn : ∀ b : Euclidean n, ∀ᵐ x ∂(hausdorff n X).restrict
+ (ball p₂ (distanceSourceRadius r0 i / 512)),
+ |SobolevSpace.toLp (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u (N b)) x| ≤
+ L * distanceSourceRadius r0 i * ‖b‖)
+ (G : Euclidean n →L[ℝ] SobolevSpace (hausdorff n X) hX.quadratic)
+ (Az : Euclidean n →L[ℝ] Euclidean n)
+ (_hG : ∀ b, SobolevSpace.toLp (hausdorff n X) hX.quadratic (G b) =ᵐ[
+ (hausdorff n X).restrict (ball p₂ (distanceSourceRadius r0 i / 512))]
+ localGamma (hausdorff n X) hX.quadratic (T₂.replacement i)
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u b))
+ (_hfit : ∀ b, ‖normalizeLocalL2 (hausdorff n X) (ball p₂ (distanceSourceRadius r0 i / 512))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic
+ (ball p₂ (distanceSourceRadius r0 i / 512))
+ (G (N b) - sobolevColumnMap (hausdorff n X) hX.quadratic u (Az (N b))))‖ ≤
+ D * distanceSourceRadius r0 i * ‖b‖ * σ),
+ ∃ (c : ℝ) (b : Euclidean n) (k : ℝ)
+ (w e : SobolevSpace (hausdorff n X) hX.quadratic),
+ let μ := hausdorff n X
+ let s := distanceSourceRadius r0 i
+ let Ω := ball p₂ (s / 512)
+ let I := ball p₂ (s / 2048)
+ w = T₂.replacement i - T₁.replacement i - c • η - sobolevColumnMap μ hX.quadratic u (N b) ∧
+ IsSobolevHarmonicOn μ hX.quadratic Ω w ∧
+ SobolevSpace.restrictLp μ hX.quadratic I w = affineResidual μ hX.quadratic u I
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hX.quadratic I (T₂.replacement i - T₁.replacement i)) ∧
+ |c| + s * ‖b‖ ≤ H * (2 * max 8 B) * s ^ 2 ∧
+ (localGamma μ hX.quadratic (T₂.replacement i) w =ᵐ[μ.restrict Ω]
+ SobolevSpace.toLp μ hX.quadratic
+ (w + sobolevColumnMap μ hX.quadratic u (N b - Az (N b)) + k • η + e)) ∧
+ ‖normalizeLocalL2 μ Ω (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hX.quadratic Ω e)‖ ≤ F * s ^ 2 * σ ∧
+ |(s ^ 2)⁻¹ * k| + (s / 2048) * ‖N.symm ((s ^ 2)⁻¹ • (N b - Az (N b)))‖ ≤
+ G₀ * (‖normalizeLocalL2 μ I (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hX.quadratic I ((s ^ 2)⁻¹ • w))‖ + σ) ∧
+ ‖normalizeLocalL2 μ (ball p₂ (s / 1024))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hX.quadratic (ball p₂ (s / 1024)) ((s ^ 2)⁻¹ • w))‖ ≤
+ T₀ * (‖normalizeLocalL2 μ I (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hX.quadratic I ((s ^ 2)⁻¹ • w))‖ + σ) := by
+ obtain ⟨F, hF, hprojection⟩ := actual_two_center_projection hX hhessian hproduct hpoincare
+ hκ hK hB hJ hCχ hA hepsilon hH hD
+ let V₀ := Real.sqrt ((5 / 3 : ℝ) * (2 : ℝ) ^ n)
+ let W₀ := Real.sqrt ((5 / 3 : ℝ) * (4 : ℝ) ^ n)
+ let D₀ := Real.sqrt (B * (2048 : ℝ) ^ 2 *
+ ((4 / (3 * euclideanUnitVolume n)) * (2048 : ℝ) ^ n))
+ let Cw : ℝ≥0 := ⟨2 * max 8 B + (1 + L) * H * (2 * max 8 B), by positivity⟩
+ obtain ⟨G₀, T₀, hG₀, hT₀, houter⟩ := hgradient.scaled_projected_residual_outer hn hκ hH
+ (Real.sqrt_nonneg _) (Real.sqrt_nonneg _) (mul_nonneg (by norm_num : (0:ℝ) ≤ 2048) hA)
+ (mul_nonneg (by norm_num : (0:ℝ) ≤ 2048) hL) hF Cw (D := D₀)
+ refine ⟨F, G₀, T₀, hF, hG₀, hT₀, ?_⟩
+ intro r0 p₁ p₂ S₁ S₂ T₁ T₂ i hroom₁ u hu hgrad hf₁ hf₂ χ hcurv η hη hvolume ha hsphere
+ N σ hσ hbudget hbound hboundHalf hcolumn G Az hG hfit
+ dsimp only
+ let μ := hausdorff n X
+ let hQ := hX.quadratic
+ let s := distanceSourceRadius r0 i
+ let R := s / 2048
+ let Ω := ball p₂ (s / 512)
+ let I := ball p₂ R
+ have hs : 0 < s := distanceSourceRadius_pos S₁.radius_pos i
+ have hR : 0 < R := by dsimp only [R]; positivity
+ have hv (t : ℝ) (ht : 0 < t) (hts : t ≤ s) := hvolume t ht hts
+ obtain ⟨c, b, k, w, e, hweq, hwharm, hproj, hcoeff, heuler, he⟩ :=
+ hprojection p₁ p₂ p₂ S₁ S₂ T₁ T₂ i hroom₁
+ (by rw [dist_self]; change 0 ≤ s / 4; positivity) u hu hgrad hf₁ hf₂ χ hcurv η hη
+ (hv (s / 64) (by positivity) (by linarith))
+ (hv (s / 512) (by positivity) (by linarith)) N σ hσ hbudget hbound G Az hG hfit
+ have hpositive : 0 < μ.real I :=
+ (quarter_volume_bounds hR (euclideanUnitVolume_pos n)
+ (hv R hR (by dsimp only [R]; linarith))).1
+ have hhalfpos : 0 < μ.real (ball p₂ (R / 2)) :=
+ (quarter_volume_bounds (by positivity : 0 < R / 2) (euclideanUnitVolume_pos n)
+ (hv (R / 2) (by positivity) (by dsimp only [R]; linarith))).1
+ have hhalf : μ.real (ball p₂ R) ≤ V₀ ^ 2 * μ.real (ball p₂ (R / 2)) := by
+ have hh := radial_fraction_volume_ratio hR (by norm_num : (0:ℝ) < 1 / 2)
+ (euclideanUnitVolume_pos n) (hv R hR (by dsimp only [R]; linarith))
+ (hv ((1 / 2) * R) (by positivity) (by dsimp only [R]; linarith))
+ have hpow : ((1 / 2 : ℝ) ^ n)⁻¹ = (2 : ℝ) ^ n := by simp
+ rw [one_div_mul_eq_div, hpow] at hh
+ dsimp only [V₀]
+ rw [Real.sq_sqrt (by positivity)]
+ exact (div_le_iff₀ hhalfpos).mp hh
+ have hfour : μ.real (ball p₂ (4 * R)) ≤ W₀ ^ 2 * μ.real I := by
+ have hh := radial_fraction_volume_ratio (by positivity : 0 < 4 * R)
+ (by norm_num : (0:ℝ) < 1 / 4) (euclideanUnitVolume_pos n)
+ (hv (4 * R) (by positivity) (by dsimp only [R]; linarith))
+ (hv ((1 / 4) * (4 * R)) (by positivity) (by dsimp only [R]; linarith))
+ have hpow : ((1 / 4 : ℝ) ^ n)⁻¹ = (4 : ℝ) ^ n := by simp
+ have heq : (1 / 4 : ℝ) * (4 * R) = R := by ring
+ rw [heq, hpow] at hh
+ dsimp only [W₀]
+ rw [Real.sq_sqrt (by positivity)]
+ exact (div_le_iff₀ hpositive).mp hh
+ have hwvalue : ∀ᵐ x ∂μ.restrict Ω, |SobolevSpace.toLp μ hQ w x| ≤ Cw * s ^ 2 := by
+ have hvv : ∀ᵐ x ∂μ.restrict Ω,
+ |SobolevSpace.toLp μ hQ (T₂.replacement i - T₁.replacement i) x| ≤ (2 * max 8 B) * s ^ 2 := by
+ filter_upwards [ae_restrict_of_ae (T₁.value_bound μ hQ i),
+ ae_restrict_of_ae (T₂.value_bound μ hQ i),
+ ae_restrict_of_ae (Lp.coeFn_sub (SobolevSpace.toLp μ hQ (T₂.replacement i))
+ (SobolevSpace.toLp μ hQ (T₁.replacement i)))] with x h1 h2 hsub
+ rw [map_sub, hsub, Pi.sub_apply]
+ exact (abs_sub _ _).trans (by dsimp only [s] at *; linarith)
+ have hb := physical_projection_residual_bound μ hQ Ω u N
+ (T₂.replacement i - T₁.replacement i) η c b hs hH (by positivity) hL hvv hη (hcolumn b) hcoeff
+ have hscale : s ^ 2 • ((s ^ 2)⁻¹ • w) = w := by
+ rw [smul_smul, mul_inv_cancel₀ (ne_of_gt (sq_pos_of_pos hs)), one_smul]
+ rw [← hweq] at hb
+ filter_upwards [hb, ae_restrict_of_ae (Lp.coeFn_smul (s ^ 2)
+ (SobolevSpace.toLp μ hQ ((s ^ 2)⁻¹ • w)))] with x hb heq
+ have hh := mul_le_mul_of_nonneg_left hb (sq_nonneg s)
+ rw [← hscale, map_smul, heq, Pi.smul_apply, smul_eq_mul, abs_mul,
+ abs_of_nonneg (sq_nonneg s)]
+ exact hh.trans_eq (mul_comm _ _)
+ have hbound' : ∀ c a, |c| + R * ‖N.symm a‖ ≤ H *
+ ‖normalizeLocalL2 μ (ball p₂ (R / 2))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineCoordinateMap μ hQ u (ball p₂ (R / 2))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c, a))‖ := by
+ intro c a
+ have hh := hboundHalf c a
+ have heq : R / 2 = s / 4096 := by dsimp only [R]; ring
+ rw [heq]
+ exact (by dsimp only [R]; nlinarith [norm_nonneg (N.symm a)] :
+ |c| + R * ‖N.symm a‖ ≤ |c| + s * ‖N.symm a‖).trans hh
+ have hU (v : Euclidean n) : ‖normalizeLocalL2 μ Ω
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ Ω (sobolevColumnMap μ hQ u v))‖ ≤ (2048 * L) * (R * ‖N.symm v‖) := by
+ have hh := normalized_norm_le_of_bound μ Ω (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ Ω (sobolevColumnMap μ hQ u v))
+ (by positivity : 0 ≤ L * s * ‖N.symm v‖) ?_
+ · convert hh using 1; dsimp only [R]; ring
+ filter_upwards [hcolumn (N.symm v), SobolevSpace.restrictLp_coe μ hQ Ω
+ (sobolevColumnMap μ hQ u v)] with x hx heq
+ rw [heq]
+ simpa only [N.apply_symm_apply] using hx
+ have hf : ∀ᵐ x ∂μ.restrict (ball p₂ (4 * R)),
+ localGamma μ hQ (T₂.replacement i) (T₂.replacement i) x ≤ ((2048 * A) * R) ^ 2 := by
+ have hh := ae_restrict_of_ae_restrict_of_subset
+ (ball_subset_ball (show 4 * R ≤ s / 4 by dsimp only [R]; linarith)) hf₂
+ have heq : ((2048 * A) * R) ^ 2 = (A * s) ^ 2 := by dsimp only [R]; ring
+ rw [heq]
+ exact hh
+ have hlap := (T₂.laplacian i).mono μ hQ measurableSet_ball
+ (ball_subset_ball (show 4 * R ≤ s by dsimp only [R]; linarith))
+ have hid : localRadialDerivative μ hQ (ball p₂ (4 * R)) (T₂.replacement i) hf w =
+ SobolevSpace.restrictLp μ hQ (ball p₂ (4 * R))
+ (w + sobolevColumnMap μ hQ u (N b - Az (N b)) + k • η + e) := by
+ apply localRadialDerivative_eq_restrict
+ have h4 : 4 * R = s / 512 := by dsimp only [R]; ring
+ simpa only [h4] using heuler.symm
+ have hbudget₂ : normalizedPoissonDefect μ hQ S₂ i ≤ σ ^ 2 := by
+ have hp := normalizedPoissonDefect_nonneg μ hQ S₁ hκ i
+ linarith
+ obtain ⟨g, hg, hradial, hgerror⟩ := T₂.normalized_transport_defect μ hQ i hκ hB hbudget₂
+ (hv R hR (by dsimp only [R]; linarith))
+ have hgerror' : (∫ x in ball p₂ (4 * R), (g x) ^ 2 ∂μ) ≤
+ D₀ ^ 2 * R ^ 2 * μ.real I * σ ^ 2 := by
+ have homega := euclideanUnitVolume_pos n
+ dsimp only [D₀]
+ rw [Real.sq_sqrt (by positivity)]
+ exact hgerror
+ have hcurvR : -κ ≤ K * R ^ 2 := by
+ have hh : K * R ^ 2 = (K * (s / 512) ^ 2) / 16 := by dsimp only [R]; ring
+ rw [hh]
+ linarith
+ have hsmall : IsSobolevHarmonicOn μ hQ (ball p₂ R) w :=
+ hwharm.mono μ hQ (ball_subset_ball (show R ≤ s / 512 by dsimp only [R]; linarith))
+ have h4 : 4 * R = s / 512 := by dsimp only [R]; ring
+ have h2 : 2 * R = s / 1024 := by dsimp only [R]; ring
+ have hb := houter p₂ R ((n : ℝ) + κ * (4 * s) ^ 2) s hR (by positivity) ha hcurvR hs
+ (T₂.replacement i) w η e u N (N b - Az (N b)) k σ hσ hlap hf
+ (by simpa only [h4] using hwvalue) hsmall
+ (by simpa only [h4] using hη) hpositive hhalf hfour hbound' hid
+ (by
+ apply (sq_le_sq₀ (norm_nonneg _) (by positivity)).mp
+ have hh := (sq_le_sq₀ (norm_nonneg _) (by positivity)).mpr he
+ rw [normalized_sobolev_mean_sq] at hh ⊢
+ simpa only [h4] using hh) (fun v => by
+ apply (sq_le_sq₀ (norm_nonneg _) (by positivity)).mp
+ have hh := (sq_le_sq₀ (norm_nonneg _) (by positivity)).mpr (hU v)
+ rw [normalized_sobolev_mean_sq] at hh ⊢
+ simpa only [h4] using hh)
+ g hg hradial hsphere hgerror'
+ refine ⟨c, b, k, w, e, hweq, hwharm, hproj, hcoeff, heuler, he, hb.1, ?_⟩
+ apply (sq_le_sq₀ (norm_nonneg _) (by positivity)).mp
+ have hh := (sq_le_sq₀ (norm_nonneg _) (by positivity)).mpr hb.2
+ rw [normalized_sobolev_mean_sq] at hh ⊢
+ simpa only [h2] using hh
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionThreshold.lean b/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionThreshold.lean
new file mode 100644
index 0000000000000000000000000000000000000000..89190e28d6631a649881fb8667e9e153d3d6231b
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionThreshold.lean
@@ -0,0 +1,79 @@
+import OAI.Geometry.RCD.Harmonic.ActualSharpProjection
+
+namespace OAI
+
+/-! # A geometric smallness threshold for the actual sharp projection -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ {K : ℝ} {n : ℕ} {hX : NoncollapsedRCD K n X}
+ [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ {κ B J C A Cχ epsilon H D L M : ℝ}
+
+/-- Small metric-approximation error and small total original source mass
+make the constructed joint compactness error uniformly small. -/
+theorem actual_projection_error_threshold (hB : 0 ≤ B) {delta : ℝ} (hdelta : 0 < delta) :
+ ∃ tau : ℝ, 0 < tau ∧ ∀ d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M,
+ d.approximationError ≤ tau → d.totalSource ≤ tau → d.error < delta := by
+ let Q := 2 * (((5 / 3 : ℝ) * (1024 : ℝ) ^ n) *
+ (annularPoincareConstant K n * B / (3 / 4 * euclideanUnitVolume n)))
+ have hQ : 0 ≤ Q := by
+ have hp := annularPoincareConstant_pos K n
+ have hv := euclideanUnitVolume_pos n
+ dsimp only [Q]
+ positivity
+ let tau := min 1 (delta / (2 * (Q + 3)))
+ have htau : 0 < tau := lt_min zero_lt_one (div_pos hdelta (by positivity))
+ have htau1 : tau ≤ 1 := min_le_left _ _
+ have htaud : (Q + 3) * tau ≤ delta / 2 := by
+ have hh := (le_div_iff₀ (by positivity : 0 < 2 * (Q + 3))).mp (min_le_right 1 (delta / (2 * (Q + 3))))
+ change tau * (2 * (Q + 3)) ≤ delta at hh
+ linarith
+ refine ⟨tau, htau, ?_⟩
+ intro d he ht
+ have he0 := d.approximationError_pos.le
+ have he1 : d.approximationError ≤ 1 := he.trans htau1
+ have he2 : d.approximationError ^ 2 ≤ d.approximationError := by nlinarith
+ let q := d.approximationError * (2 * (1 / 1024 : ℝ) + d.approximationError) / 2
+ have hq0 : 0 ≤ q := by dsimp only [q]; positivity
+ have hq : q ≤ d.approximationError := by dsimp only [q]; nlinarith only [he2, he0]
+ have hq2 : q ^ 2 ≤ d.approximationError := by
+ exact ((sq_le_sq₀ hq0 he0).mpr hq).trans he2
+ have hsource := mul_le_mul_of_nonneg_left ht hQ
+ have herr : d.error = d.approximationError + Q * d.totalSource + 2 * q ^ 2 := by
+ dsimp only [ActualProjectionConfiguration.error, Q, q]
+ ring
+ rw [herr]
+ nlinarith only [he, hsource, hq2, htaud, hdelta]
+
+/-- The sharp bound now requires only separate geometric approximation
+and original source tolerances, as supplied by the regular-neighborhood
+construction. -/
+theorem actual_sharp_projection_small_data
+ (hhessian : LocalPoissonHessianActionInput hX)
+ (hproduct : LocalPoissonGradientProductInput hX)
+ (hpoincare : LocalMeanPoincareInput hX)
+ (hgradient : LocalHarmonicL2GradientInput hX)
+ (hcompact : LocalPoissonHarmonicCompactnessInput hX) (hn : 2 ≤ n)
+ (hκ : 0 ≤ κ) (hK : -κ ≤ K) (hB : 0 ≤ B) (hJ : 0 ≤ J)
+ (hCχ : 0 ≤ Cχ) (hA : 0 ≤ A) (hepsilon : 0 ≤ epsilon)
+ (hH : 0 ≤ H) (hD : 0 ≤ D) (hL : 0 ≤ L) :
+ ∃ P tau : ℝ, 0 < P ∧ 0 < tau ∧
+ ∀ d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M,
+ d.approximationError ≤ tau → d.totalSource ≤ tau → d.projectionNorm ≤ P * d.source := by
+ obtain ⟨P, hP, delta, hdelta, hbound⟩ := actual_sharp_projection (C := C) (M := M) hX
+ hhessian hproduct hpoincare hgradient hcompact hn hκ hK hB hJ hCχ hA hepsilon hH hD hL
+ obtain ⟨tau, htau, herror⟩ := actual_projection_error_threshold (hX := hX) (κ := κ) (J := J) (C := C)
+ (A := A) (Cχ := Cχ) (epsilon := epsilon) (H := H) (D := D) (L := L) (M := M) hB hdelta
+ exact ⟨P, tau, hP, htau, fun d he ht => hbound d (herror d he ht)⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionUnits.lean b/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionUnits.lean
new file mode 100644
index 0000000000000000000000000000000000000000..a06723c34d84c632427dd95d7d617bd4b8527468
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ActualProjectionUnits.lean
@@ -0,0 +1,84 @@
+import OAI.Geometry.RCD.Harmonic.ScaledProjectionData
+import OAI.Geometry.RCD.Harmonic.RadialVolumeUnits
+import OAI.Geometry.RCD.Harmonic.ForcingCoefficient
+
+namespace OAI
+
+/-! # The exact coefficient and forcing units of the actual projection -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal InnerProductSpace BigOperators
+
+noncomputable section
+namespace RegularPointCoordinates
+
+/-- Passing from the radius-weighted physical covector to the coefficient
+of the rescaled coordinates costs only the fixed radius ratio and frame norm. -/
+theorem projection_coefficient_rescale {n : ℕ} (N : Euclidean n ≃L[ℝ] Euclidean n)
+ {r M G alpha sigma : ℝ} (hr : 0 < r) (hN : ‖(N : Euclidean n →L[ℝ] Euclidean n)‖ ≤ M)
+ (ell : Euclidean n) (k : ℝ)
+ (hbound : |(r ^ 2)⁻¹ * k| + (r / 2048) * ‖N.symm ((r ^ 2)⁻¹ • ell)‖ ≤
+ G * (alpha + sigma)) :
+ ‖r⁻¹ • ell‖ + |(r ^ 2)⁻¹ * k| ≤
+ max 1 (2048 * M) * G * (alpha + sigma) := by
+ have hnorm : ‖(r ^ 2)⁻¹ • ell‖ ≤ M * ‖N.symm ((r ^ 2)⁻¹ • ell)‖ := by
+ calc
+ _ = ‖N (N.symm ((r ^ 2)⁻¹ • ell))‖ := by rw [N.apply_symm_apply]
+ _ ≤ ‖(N : Euclidean n →L[ℝ] Euclidean n)‖ * ‖N.symm ((r ^ 2)⁻¹ • ell)‖ :=
+ by
+ change ‖(N : Euclidean n →L[ℝ] Euclidean n) (N.symm ((r ^ 2)⁻¹ • ell))‖ ≤ _
+ exact (N : Euclidean n →L[ℝ] Euclidean n).le_opNorm _
+ _ ≤ _ := mul_le_mul_of_nonneg_right hN (norm_nonneg _)
+ have heq : r⁻¹ • ell = r • ((r ^ 2)⁻¹ • ell) := by
+ rw [smul_smul]
+ congr 1
+ field_simp
+ have hlin : ‖r⁻¹ • ell‖ ≤ (2048 * M) * ((r / 2048) * ‖N.symm ((r ^ 2)⁻¹ • ell)‖) := by
+ rw [heq, norm_smul, Real.norm_eq_abs, abs_of_pos hr]
+ nlinarith only [mul_le_mul_of_nonneg_left hnorm hr.le]
+ have hweight : 0 ≤ (r / 2048) * ‖N.symm ((r ^ 2)⁻¹ • ell)‖ := by positivity
+ have hterm := mul_le_mul_of_nonneg_right (le_max_right 1 (2048 * M)) hweight
+ have hconst := mul_le_mul_of_nonneg_right (le_max_left 1 (2048 * M)) (abs_nonneg ((r ^ 2)⁻¹ * k))
+ have htotal := mul_le_mul_of_nonneg_left hbound
+ (le_trans zero_le_one (le_max_left 1 (2048 * M)))
+ nlinarith only [hlin, hterm, hconst, htotal]
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- The rescaled Euler equation is exactly the finite-coordinate identity
+used by the published compactness theorem, including its constant term. -/
+theorem radius_scaled_projection_euler_sum {n : ℕ} {r B B' : ℝ} (hr : 0 < r)
+ (Ω : Set X) (hfin : μ Ω ≠ ∞) (u : Fin n → SobolevSpace μ hQ)
+ (f w eta e : SobolevSpace μ hQ) (ell : Euclidean n) (k : ℝ)
+ (heta : SobolevSpace.toLp μ hQ eta =ᵐ[μ.restrict Ω] fun _ => (1 : ℝ))
+ (hf : ∀ᵐ x ∂μ.restrict Ω, localGamma μ hQ f f x ≤ B)
+ (hf' : ∀ᵐ x ∂μ.restrict Ω,
+ localGamma μ hQ ((r ^ 2)⁻¹ • f) ((r ^ 2)⁻¹ • f) x ≤ B')
+ (hid : localRadialDerivative μ hQ Ω f hf w = SobolevSpace.restrictLp μ hQ Ω
+ (w + sobolevColumnMap μ hQ u ell + k • eta + e)) :
+ r ^ 2 • localRadialDerivative μ hQ Ω ((r ^ 2)⁻¹ • f) hf' ((r ^ 2)⁻¹ • w) =
+ SobolevSpace.restrictLp μ hQ Ω ((r ^ 2)⁻¹ • w) +
+ (∑ j, (r⁻¹ • ell) j • SobolevSpace.restrictLp μ hQ Ω (radiusScaledColumns μ hQ r u j)) +
+ ((r ^ 2)⁻¹ * k) • restrictedOne μ Ω hfin +
+ SobolevSpace.restrictLp μ hQ Ω ((r ^ 2)⁻¹ • e) := by
+ rw [radius_scaled_projection_euler μ hQ hr Ω u f w eta e ell k hf hf' hid]
+ simp only [map_add, map_smul, sobolevColumnMap_apply, map_sum,
+ restrictLp_eq_one_of_representative μ hQ eta Ω hfin heta,
+ Finset.smul_sum, smul_smul, PiLp.smul_apply, smul_eq_mul]
+
+omit [BorelSpace X] [ProperSpace X] in
+/-- A mean-square norm is unchanged when only the proof of finiteness or
+the presentation of the same measurable set changes. -/
+theorem normalized_sobolev_norm_congr {s t : Set X} (hst : s = t)
+ (hs : μ s ≠ ∞) (ht : μ t ≠ ∞) (w : SobolevSpace μ hQ) :
+ ‖normalizeLocalL2 μ s hs (SobolevSpace.restrictLp μ hQ s w)‖ =
+ ‖normalizeLocalL2 μ t ht (SobolevSpace.restrictLp μ hQ t w)‖ := by
+ subst t
+ rfl
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ActualRadialError.lean b/lean/OAI/Geometry/RCD/Harmonic/ActualRadialError.lean
new file mode 100644
index 0000000000000000000000000000000000000000..728bb6861ef2da352b37c64e5082597c5b346414
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ActualRadialError.lean
@@ -0,0 +1,61 @@
+import OAI.Geometry.RCD.Harmonic.RadialErrorUnits
+
+namespace OAI
+
+/-! # Actual radial approximation controlled by one normalized defect -/
+
+open Set Metric MeasureTheory
+open scoped NNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- The coefficient is independent of the center, scale and harmonic column.
+The source and curvature terms are exactly the summable complete defect. -/
+theorem actual_distance_radial_error {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ (hn : 2 ≤ n) (hhessian : LocalPoissonHessianInput hX)
+ {κ r0 B J C A epsilon Cχ : ℝ} (hκ : 0 ≤ κ) (hK : -κ ≤ K)
+ (hB : 0 ≤ B) (hJ : 0 ≤ J) (hA : 0 ≤ A) (hepsilon : 0 ≤ epsilon) (hCχ : 0 ≤ Cχ)
+ (p : X) (S : DyadicDistanceSources (hausdorff n X) hX.quadratic n κ p r0)
+ (T : DyadicDistanceReplacements (hausdorff n X) hX.quadratic S B J C) (i : ℕ)
+ (hs1 : distanceSourceRadius r0 i ≤ 1)
+ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ (hu : ∀ j, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic
+ (ball p (distanceSourceRadius r0 i / 4)) (u j))
+ (hgrad : ∀ j, ∀ᵐ x ∂(hausdorff n X).restrict (ball p (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (u j) (u j) x ≤ (1 + epsilon) ^ 2)
+ (hf : ∀ᵐ x ∂(hausdorff n X).restrict (ball p (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (T.replacement i) (T.replacement i) x ≤
+ (A * distanceSourceRadius r0 i) ^ 2)
+ (χ : GoodLaplacianCutoff (hausdorff n X) hX.quadratic p (distanceSourceRadius r0 i / 64) Cχ)
+ (hvol : 0 < (hausdorff n X).real (ball p (distanceSourceRadius r0 i / 64)))
+ (hdouble : 2 * (hausdorff n X).real (ball p (distanceSourceRadius r0 i / 64)) ≤
+ (hausdorff n X).real (ball p (2 * (distanceSourceRadius r0 i / 64)))) :
+ let s := distanceSourceRadius r0 i
+ let q := positiveSquaredDistance (hausdorff n X) hX.quadratic
+ (by have := distanceSourceRadius_pos S.radius_pos i; positivity : 0 ≤ 4 * s) (T.cutoff i)
+ ∀ j : Fin n, ∃ h : SobolevSpace (hausdorff n X) hX.quadratic,
+ IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball p (s / 64)) h ∧
+ (∫ x in ball p (s / 64),
+ (localGamma (hausdorff n X) hX.quadratic q (u j) x -
+ SobolevSpace.toLp (hausdorff n X) hX.quadratic h x) ^ 2 ∂hausdorff n X) ≤
+ radialCorrectionConstant K n epsilon A B J Cχ * s ^ 2 *
+ (s ^ (n : ℝ) * normalizedPoissonDefect (hausdorff n X) hX.quadratic S i) := by
+ dsimp only
+ obtain ⟨L, hL, happrox⟩ := actual_distance_radial_approximation hX hn hhessian
+ hκ hK hB hJ hA hepsilon hCχ p S T i hs1 u hu hgrad hf χ hvol hdouble
+ intro j
+ obtain ⟨h, hh, he⟩ := happrox j
+ refine ⟨h, hh, he.trans ?_⟩
+ rw [normalizedPoissonDefect_units]
+ exact radial_correction_error_units hs1 hκ measureReal_nonneg measureReal_nonneg
+ hB hJ hA hepsilon hCχ hL
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ActualRadialHarmonic.lean b/lean/OAI/Geometry/RCD/Harmonic/ActualRadialHarmonic.lean
new file mode 100644
index 0000000000000000000000000000000000000000..1c29f471e8fcff416105765a7a34c9cd16c885f4
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ActualRadialHarmonic.lean
@@ -0,0 +1,136 @@
+import OAI.Geometry.RCD.Sobolev.ActualPoissonMass
+import OAI.Geometry.RCD.Sobolev.PoissonPairSpan
+import OAI.Geometry.RCD.Coordinates.PoissonSpanCoordinates
+import OAI.Geometry.RCD.Harmonic.RadialHarmonicApproximation
+
+namespace OAI
+
+/-! # Harmonic correction of the actual distance radial derivatives -/
+
+open Set Metric MeasureTheory
+open scoped NNReal ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- The full Poisson mass calculation and localized Hessian input now
+construct a harmonic approximation to each actual coordinate radial
+derivative, with a squared error linear in the same source mass. -/
+theorem actual_distance_radial_approximation {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ (hn : 2 ≤ n) (hhessian : LocalPoissonHessianInput hX)
+ {κ r0 B J C A epsilon Cχ : ℝ} (hκ : 0 ≤ κ) (hK : -κ ≤ K)
+ (hB : 0 ≤ B) (hJ : 0 ≤ J) (hA : 0 ≤ A) (hepsilon : 0 ≤ epsilon) (hCχ : 0 ≤ Cχ)
+ (p : X) (S : DyadicDistanceSources (hausdorff n X) hX.quadratic n κ p r0)
+ (T : DyadicDistanceReplacements (hausdorff n X) hX.quadratic S B J C) (i : ℕ)
+ (hs1 : distanceSourceRadius r0 i ≤ 1)
+ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ (hu : ∀ j, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic
+ (ball p (distanceSourceRadius r0 i / 4)) (u j))
+ (hgrad : ∀ j, ∀ᵐ x ∂(hausdorff n X).restrict (ball p (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (u j) (u j) x ≤ (1 + epsilon) ^ 2)
+ (hf : ∀ᵐ x ∂(hausdorff n X).restrict (ball p (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (T.replacement i) (T.replacement i) x ≤
+ (A * distanceSourceRadius r0 i) ^ 2)
+ (χ : GoodLaplacianCutoff (hausdorff n X) hX.quadratic p (distanceSourceRadius r0 i / 64) Cχ)
+ (hvol : 0 < (hausdorff n X).real (ball p (distanceSourceRadius r0 i / 64)))
+ (hdouble : 2 * (hausdorff n X).real (ball p (distanceSourceRadius r0 i / 64)) ≤
+ (hausdorff n X).real (ball p (2 * (distanceSourceRadius r0 i / 64)))) :
+ let s := distanceSourceRadius r0 i
+ let q := positiveSquaredDistance (hausdorff n X) hX.quadratic
+ (by have := distanceSourceRadius_pos S.radius_pos i; positivity : 0 ≤ 4 * s) (T.cutoff i)
+ let P := annularPoincareConstant K n * (s / 64) ^ 2
+ ∃ L : ℝ≥0, (L : ℝ) = ((n + 2 : ℕ) : ℝ) * max (1 + epsilon) (A * s) ∧
+ ∀ j : Fin n, ∃ h : SobolevSpace (hausdorff n X) hX.quadratic,
+ IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball p (s / 64)) h ∧
+ (∫ x in ball p (s / 64),
+ (localGamma (hausdorff n X) hX.quadratic q (u j) x -
+ SobolevSpace.toLp (hausdorff n X) hX.quadratic h x) ^ 2 ∂hausdorff n X) ≤
+ 2 * (1 + epsilon) ^ 2 * ((S.source i).real (ball p s) * (B * s ^ 2)) +
+ 8 * P * (L : ℝ) ^ 2 *
+ (4096 * Cχ * (J + B / 2) * (S.source i).real (ball p s) +
+ κ * A ^ 2 * s ^ 2 * (hausdorff n X).real (ball p s)) := by
+ let μ := hausdorff n X
+ let hQ := hX.quadratic
+ let s := distanceSourceRadius r0 i
+ have hs : 0 < s := distanceSourceRadius_pos S.radius_pos i
+ let q := positiveSquaredDistance μ hQ (by positivity : 0 ≤ 4 * s) (T.cutoff i)
+ let P := annularPoincareConstant K n * (s / 64) ^ 2
+ have hP : 0 ≤ P := mul_nonneg (annularPoincareConstant_pos K n).le (sq_nonneg _)
+ have hpoin := hX.annular_dirichlet_poincare hn p (by positivity : 0 < s / 64)
+ (by change s ≤ 1 at hs1; linarith : s / 64 ≤ 1) hvol hdouble
+ obtain ⟨L, hL, M, henergy, hshift, hpair⟩ := actual_poisson_pair_span hX hhessian
+ hκ hK hA hepsilon p p p S S T T i
+ (by rw [dist_self]; positivity) (by rw [dist_self]; positivity) u hu hgrad hf hf
+ let f : Fin 2 → SobolevSpace μ hQ := ![T.replacement i, T.replacement i]
+ let U := sobolevColumnMap μ hQ (poissonSpan μ hQ u f)
+ let ell := poissonSpanLaplacian n ((n : ℝ) + κ * (4 * s) ^ 2)
+ let v : Euclidean (n + 2) := EuclideanSpace.single (Fin.natAdd n (0 : Fin 2)) 1
+ have hv : U v = T.replacement i := poissonSpanMap_right μ hQ u f 0
+ have hell : ell v = (n : ℝ) + κ * (4 * s) ^ 2 := poissonSpanLaplacian_right _ 0
+ let _ : IsFiniteMeasure (μ.restrict (ball p (2 * (s / 32)))) :=
+ isFiniteMeasure_restrict.mpr (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ obtain ⟨Genergy⟩ := henergy v
+ have hfsmall : ∀ᵐ x ∂μ.restrict (ball p (2 * (s / 32))),
+ localGamma μ hQ (T.replacement i) (T.replacement i) x ≤ A ^ 2 * s ^ 2 := by
+ have ht := ae_restrict_of_ae_restrict_of_subset
+ (ball_subset_ball (by linarith : 2 * (s / 32) ≤ s / 4)) hf
+ simpa only [mul_pow] using ht
+ have hmass := T.shifted_mass_le μ hQ i hκ hCχ
+ (by rw [dist_self]; positivity) ell Genergy hv hell hshift χ hfsmall
+ let F := 4096 * Cχ * (J + B / 2) * (S.source i).real (ball p s) +
+ κ * A ^ 2 * s ^ 2 * μ.real (ball p s)
+ have hF : 0 ≤ F := by dsimp only [F]; positivity
+ refine ⟨L, hL, ?_⟩
+ intro j
+ let w : Euclidean (n + 2) := EuclideanSpace.single (Fin.castAdd 2 j) 1
+ have hw : U w = u j := poissonSpanMap_left μ hQ u f j
+ have hwnorm : ‖w‖ = 1 := by simp [w, PiLp.norm_single]
+ obtain ⟨G, hG⟩ := hpair v w (s / 64) (by positivity) (by linarith)
+ change LocalHessianPairing μ hQ (ball p (s / 64)) (U v) (U w) at G
+ change ∀ b : ℝ, ∀ φ : SobolevSpace.dirichlet μ hQ (ball p (s / 64)),
+ (G.hessian φ - b * energyForm μ hQ (U w) φ.val) ^ 2 ≤
+ ((L : ℝ) ^ 2 * ‖w‖ ^ 2 * ((M.measure v).real (ball p (s / 64)) -
+ (2 * b * ell v - (n : ℝ) * b ^ 2) * μ.real (ball p (s / 64)))) *
+ energyForm μ hQ φ.val φ.val at hG
+ have hmass' : (M.measure v).real (ball p (s / 64)) -
+ (2 * ell v - (n : ℝ)) * μ.real (ball p (s / 64)) ≤ F := by
+ have hm := ShiftedBochnerMeasure.mass M (μ.restrict (ball p (2 * (s / 32))))
+ ell (n : ℝ) hshift v 1 (ball p (s / 64)) measurableSet_ball
+ rw [measureReal_restrict_apply measurableSet_ball,
+ inter_eq_left.mpr (ball_subset_ball (by linarith : s / 64 ≤ 2 * (s / 32)))] at hm
+ simp only [one_pow, mul_one] at hm
+ change ((shiftedBochnerMeasure M (μ.restrict (ball p (2 * (s / 32))))
+ ell (n : ℝ) hshift).measure (WithLp.toLp 2 (v, (1 : ℝ)))).real
+ (ball p (s / 64)) ≤ F at hmass
+ rwa [hm] at hmass
+ have hhessian' (φ : SobolevSpace.dirichlet μ hQ (ball p (s / 64))) :
+ (G.hessian φ - 1 * energyForm μ hQ (U w) φ.val) ^ 2 ≤
+ ((L : ℝ) ^ 2 * F) * energyForm μ hQ φ.val φ.val := by
+ have ht := hG 1 φ
+ simp only [one_pow, mul_one, one_mul, hwnorm] at ht
+ simpa only [one_mul] using ht.trans (mul_le_mul_of_nonneg_right
+ (mul_le_mul_of_nonneg_left hmass' (sq_nonneg (L : ℝ)))
+ (by rw [energyForm_self]; exact mul_nonneg (by norm_num) (SobolevSpace.energy_nonneg μ hQ _)))
+ have ha := (hu j).mono μ hQ (ball_subset_ball (by linarith : s / 64 ≤ s / 4))
+ have hcoord := ae_restrict_of_ae_restrict_of_subset
+ (ball_subset_ball (by linarith : s / 64 ≤ s / 4)) (hgrad j)
+ have hlap := T.laplacian_on_ball μ hQ i p
+ (by rw [dist_self]; linarith : s / 64 + dist p p ≤ s)
+ have herr := T.local_energy_error μ hQ i (ball p (s / 64))
+ obtain ⟨h, _, hh, _, he⟩ := G.radial_harmonic_approximation μ hQ measurableSet_ball q
+ (by simpa only [hv] using hlap) (by simpa only [hw] using ha)
+ 1 hP (mul_nonneg (sq_nonneg (L : ℝ)) hF) (sq_nonneg (1 + epsilon))
+ (by simpa only [hw] using hcoord) hpoin (by simpa only [hv] using herr) hhessian'
+ rw [hw] at he
+ refine ⟨h, hh, he.trans_eq ?_⟩
+ dsimp only [P, F]
+ ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ActualRadialPairing.lean b/lean/OAI/Geometry/RCD/Harmonic/ActualRadialPairing.lean
new file mode 100644
index 0000000000000000000000000000000000000000..55421c7bc3bca9f2c3c6ee0d24244b78e229367c
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ActualRadialPairing.lean
@@ -0,0 +1,106 @@
+import OAI.Geometry.RCD.Sobolev.ActualPoissonMass
+import OAI.Geometry.RCD.Sobolev.PoissonPairSpan
+import OAI.Geometry.RCD.Sobolev.PoissonSpanLift
+
+namespace OAI
+
+/-! # The genuine Poisson radial derivative in every coordinate covector -/
+
+open Set Metric MeasureTheory
+open scoped NNReal ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- The common published Hessian span supplies the actual radial Sobolev
+function in every covector, with the full shifted mass budget. -/
+theorem actual_distance_radial_pairing {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ (hhessian : LocalPoissonHessianInput hX)
+ {κ r0 B J C A ε Cχ : ℝ} (hκ : 0 ≤ κ) (hK : -κ ≤ K)
+ (hA : 0 ≤ A) (hε : 0 ≤ ε) (hCχ : 0 ≤ Cχ)
+ (p : X) (S : DyadicDistanceSources (hausdorff n X) hX.quadratic n κ p r0)
+ (T : DyadicDistanceReplacements (hausdorff n X) hX.quadratic S B J C) (i : ℕ)
+ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ (hu : ∀ j, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic
+ (ball p (distanceSourceRadius r0 i / 4)) (u j))
+ (hgrad : ∀ j, ∀ᵐ x ∂(hausdorff n X).restrict (ball p (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (u j) (u j) x ≤ (1 + ε) ^ 2)
+ (hf : ∀ᵐ x ∂(hausdorff n X).restrict (ball p (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (T.replacement i) (T.replacement i) x ≤
+ (A * distanceSourceRadius r0 i) ^ 2)
+ (χ : GoodLaplacianCutoff (hausdorff n X) hX.quadratic p (distanceSourceRadius r0 i / 64) Cχ) :
+ let μ := hausdorff n X
+ let s := distanceSourceRadius r0 i
+ ∃ L : ℝ≥0, (L : ℝ) = ((n + 2 : ℕ) : ℝ) * max (1 + ε) (A * s) ∧
+ ∀ b : Euclidean n,
+ ∃ G : LocalHessianPairing μ hX.quadratic (ball p (s / 64)) (T.replacement i)
+ (sobolevColumnMap μ hX.quadratic u b),
+ ∀ φ : SobolevSpace.dirichlet μ hX.quadratic (ball p (s / 64)),
+ (G.hessian φ - energyForm μ hX.quadratic (sobolevColumnMap μ hX.quadratic u b) φ.val) ^ 2 ≤
+ ((L : ℝ) ^ 2 * ‖b‖ ^ 2 *
+ (4096 * Cχ * (J + B / 2) * (S.source i).real (ball p s) +
+ κ * A ^ 2 * s ^ 2 * μ.real (ball p s))) * energyForm μ hX.quadratic φ.val φ.val := by
+ dsimp only
+ let μ := hausdorff n X
+ let hQ := hX.quadratic
+ let s := distanceSourceRadius r0 i
+ have hs : 0 < s := distanceSourceRadius_pos S.radius_pos i
+ obtain ⟨L, hL, M, henergy, hshift, hpair⟩ := actual_poisson_pair_span hX hhessian
+ hκ hK hA hε p p p S S T T i
+ (by rw [dist_self]; positivity) (by rw [dist_self]; positivity) u hu hgrad hf hf
+ let f : Fin 2 → SobolevSpace μ hQ := ![T.replacement i, T.replacement i]
+ let U := sobolevColumnMap μ hQ (poissonSpan μ hQ u f)
+ let ell := poissonSpanLaplacian n ((n : ℝ) + κ * (4 * s) ^ 2)
+ let v : Euclidean (n + 2) := EuclideanSpace.single (Fin.natAdd n (0 : Fin 2)) 1
+ have hv : U v = T.replacement i := poissonSpanMap_right μ hQ u f 0
+ have hell : ell v = (n : ℝ) + κ * (4 * s) ^ 2 := poissonSpanLaplacian_right _ 0
+ let _ : IsFiniteMeasure (μ.restrict (ball p (2 * (s / 32)))) :=
+ isFiniteMeasure_restrict.mpr (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ obtain ⟨Genergy⟩ := henergy v
+ have hfsmall : ∀ᵐ x ∂μ.restrict (ball p (2 * (s / 32))),
+ localGamma μ hQ (T.replacement i) (T.replacement i) x ≤ A ^ 2 * s ^ 2 := by
+ have ht := ae_restrict_of_ae_restrict_of_subset
+ (ball_subset_ball (by linarith : 2 * (s / 32) ≤ s / 4)) hf
+ simpa only [mul_pow] using ht
+ have hmass := T.shifted_mass_le μ hQ i hκ hCχ
+ (by rw [dist_self]; positivity) ell Genergy hv hell hshift χ hfsmall
+ let D := 4096 * Cχ * (J + B / 2) * (S.source i).real (ball p s) +
+ κ * A ^ 2 * s ^ 2 * μ.real (ball p s)
+ have hmass' : (M.measure v).real (ball p (s / 64)) -
+ (2 * ell v - (n : ℝ)) * μ.real (ball p (s / 64)) ≤ D := by
+ have hm := ShiftedBochnerMeasure.mass M (μ.restrict (ball p (2 * (s / 32))))
+ ell (n : ℝ) hshift v 1 (ball p (s / 64)) measurableSet_ball
+ rw [measureReal_restrict_apply measurableSet_ball,
+ inter_eq_left.mpr (ball_subset_ball (by linarith : s / 64 ≤ 2 * (s / 32)))] at hm
+ simp only [one_pow, mul_one] at hm
+ change ((shiftedBochnerMeasure M (μ.restrict (ball p (2 * (s / 32))))
+ ell (n : ℝ) hshift).measure (WithLp.toLp 2 (v, (1 : ℝ)))).real (ball p (s / 64)) ≤ D at hmass
+ rwa [hm] at hmass
+ refine ⟨L, hL, ?_⟩
+ intro b
+ let w := poissonCoordinateLift b
+ have hw : U w = sobolevColumnMap μ hQ u b := poissonSpanMap_lift μ hQ u f b
+ have hwnorm : ‖w‖ = ‖b‖ := poissonCoordinateLift_norm b
+ obtain ⟨G, hG⟩ := hpair v w (s / 64) (by positivity) (by linarith)
+ have hresult : ∃ H : LocalHessianPairing μ hQ (ball p (s / 64)) (U v) (U w),
+ ∀ φ : SobolevSpace.dirichlet μ hQ (ball p (s / 64)),
+ (H.hessian φ - energyForm μ hQ (U w) φ.val) ^ 2 ≤
+ ((L : ℝ) ^ 2 * ‖b‖ ^ 2 * D) * energyForm μ hQ φ.val φ.val := by
+ refine ⟨G, ?_⟩
+ intro φ
+ have ht := hG 1 φ
+ simp only [one_pow, mul_one, one_mul, hwnorm] at ht
+ exact ht.trans (mul_le_mul_of_nonneg_right
+ (mul_le_mul_of_nonneg_left hmass' (mul_nonneg (sq_nonneg (L : ℝ)) (sq_nonneg ‖b‖)))
+ (by rw [energyForm_self]; exact mul_nonneg (by norm_num) (SobolevSpace.energy_nonneg μ hQ _)))
+ rw [hv, hw] at hresult
+ exact hresult
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ActualSharpProjection.lean b/lean/OAI/Geometry/RCD/Harmonic/ActualSharpProjection.lean
new file mode 100644
index 0000000000000000000000000000000000000000..13a3fee6aaca939cd33ba184cdcbe3c874bb1d99
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ActualSharpProjection.lean
@@ -0,0 +1,323 @@
+import OAI.Geometry.RCD.Harmonic.ActualProjectionConfiguration
+import OAI.Geometry.RCD.Harmonic.ActualProjectionUnits
+import OAI.Geometry.RCD.Sobolev.SharpProjectionGradient
+
+namespace OAI
+
+/-! # Sharp projection for the actual two-center Poisson targets -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal NNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- Construct the compactness family from actual sources and replacements.
+No residual, forcing, or outer estimate is assumed in the configuration. -/
+theorem exists_actual_projection_family {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ (hhessian : LocalPoissonHessianActionInput hX)
+ (hproduct : LocalPoissonGradientProductInput hX)
+ (hpoincare : LocalMeanPoincareInput hX)
+ (hgradient : LocalHarmonicL2GradientInput hX) (hn : 2 ≤ n)
+ {κ B J C A Cχ epsilon H D L M : ℝ}
+ (hκ : 0 ≤ κ) (hK : -κ ≤ K) (hB : 0 ≤ B) (hJ : 0 ≤ J)
+ (hCχ : 0 ≤ Cχ) (hA : 0 ≤ A) (hepsilon : 0 ≤ epsilon)
+ (hH : 0 ≤ H) (hD : 0 ≤ D) (hL : 0 ≤ L) :
+ ∃ family : SharpProjectionFamily hX
+ (ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M) (1 / 1024) (1 / 2048),
+ (∀ d, family.error d = d.error) ∧
+ (∀ d, family.source d = d.source) ∧
+ (∀ d, family.size d = d.projectionNorm) := by
+ classical
+ let μ := hausdorff n X
+ let hQ := hX.quadratic
+ let I := ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M
+ obtain ⟨F, G, T, hF, hG, hT, hchoose⟩ := actual_two_center_projection_outer hX
+ hhessian hproduct hpoincare hgradient hn hκ hK hB hJ hCχ hA hepsilon hH hD hL
+ have hdata (d : I) := hchoose d.first d.center d.firstSource d.secondSource
+ d.firstReplacement d.secondReplacement d.index d.room d.coordinates d.harmonic d.gradient
+ d.firstGradient d.secondGradient d.cutoff d.smallCurvature d.one d.oneRepresentative
+ (fun t ht hts => d.volume t ht (hts.trans d.radius_le_root)) d.laplacianBound d.sphere
+ d.frame d.source d.source_pos.le d.pairBudget d.affineBound d.affineHalfBound d.columnBound
+ d.radialColumns d.radialMatrix d.radialRepresentative d.radialFit
+ dsimp only at hdata
+ choose c b k w e hweq hwharm hproj hcb heuler he hcoef houter using hdata
+ let s : I → ℝ := fun d => d.radius
+ let U : I → Fin n → SobolevSpace μ hQ := fun d => radiusScaledColumns μ hQ (s d) d.coordinates
+ let f : I → SobolevSpace μ hQ := fun d => (s d ^ 2)⁻¹ • d.secondReplacement.replacement d.index
+ let w' : I → SobolevSpace μ hQ := fun d => (s d ^ 2)⁻¹ • w d
+ let e' : I → SobolevSpace μ hQ := fun d => (s d ^ 2)⁻¹ • e d
+ let ell : I → Euclidean n := fun d => d.frame (b d) - d.radialMatrix (d.frame (b d))
+ let alpha : I → ℝ := fun d => ‖normalizeLocalL2 μ (ball d.center ((1 / 2048) * s d))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ (ball d.center ((1 / 2048) * s d)) (w' d))‖
+ let A₀ := max (max 8 B) (max ((n : ℝ) + 1) (A ^ 2))
+ let V₀ := Real.sqrt ((5 / 3 : ℝ) * (2 : ℝ) ^ n)
+ have hA₀ : 0 ≤ A₀ := (by positivity : 0 ≤ max 8 B).trans (le_max_left _ _)
+ have hAV : max 8 B ≤ A₀ := le_max_left _ _
+ have hAn : (n : ℝ) + 1 ≤ A₀ := (le_max_left _ _).trans (le_max_right _ _)
+ have hAg : A ^ 2 ≤ A₀ := (le_max_right _ _).trans (le_max_right _ _)
+ have hs (d : I) : 0 < s d := d.radius_pos
+ have hfrac1024 (d : I) : (1 / 1024 : ℝ) * s d = s d / 1024 := by ring
+ have hfrac2048 (d : I) : (1 / 2048 : ℝ) * s d = s d / 2048 := by ring
+ have hvol (d : I) (t : ℝ) (ht : 0 < t) (hts : t ≤ s d) :=
+ d.volume t ht (hts.trans d.radius_le_root)
+ have hgrad (d : I) : ∀ᵐ x ∂μ.restrict (ball d.center ((1 / 1024) * s d)),
+ localGamma μ hQ (f d) (f d) x ≤ A₀ / s d ^ 2 := by
+ have hh := ae_restrict_of_ae_restrict_of_subset
+ (ball_subset_ball (show (1 / 1024 : ℝ) * s d ≤ s d / 4 by linarith [hs d])) d.secondGradient
+ have hh' : ∀ᵐ x ∂μ.restrict (ball d.center ((1 / 1024) * s d)),
+ localGamma μ hQ (d.secondReplacement.replacement d.index)
+ (d.secondReplacement.replacement d.index) x ≤ A ^ 2 * s d ^ 2 := by
+ simpa only [mul_pow, s, ActualProjectionConfiguration.radius, μ, hQ] using hh
+ filter_upwards [rescaled_radial_energy μ hQ _ _ (hs d) hh'] with x hx
+ apply (le_div_iff₀ (sq_pos_of_pos (hs d))).mpr
+ simpa only [mul_comm] using hx.trans hAg
+ have hp (d : I) : SobolevSpace.restrictLp μ hQ (ball d.center ((1 / 2048) * s d)) (w' d) =
+ affineResidual μ hQ (U d) (ball d.center ((1 / 2048) * s d))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ (ball d.center ((1 / 2048) * s d))
+ ((s d ^ 2)⁻¹ • (d.secondReplacement.replacement d.index - d.firstReplacement.replacement d.index))) := by
+ have hh := radius_scaled_projection μ hQ (hs d).ne' d.coordinates
+ (ball d.center (s d / 2048)) (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (d.secondReplacement.replacement d.index - d.firstReplacement.replacement d.index)
+ (w d) (hproj d)
+ rw [hfrac2048 d]
+ exact hh
+ have hforce (d : I) : ‖normalizeLocalL2 μ (ball d.center ((1 / 1024) * s d))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ (ball d.center ((1 / 1024) * s d)) (e' d))‖ ≤
+ (V₀ * F) * d.source := by
+ have hsd := hs d
+ have hposbig := (quarter_volume_bounds (by positivity : 0 < s d / 512)
+ (euclideanUnitVolume_pos n) (hvol d (s d / 512) (by positivity) (by linarith [hs d]))).1
+ have hpossmall := (quarter_volume_bounds (by positivity : 0 < s d / 1024)
+ (euclideanUnitVolume_pos n) (hvol d (s d / 1024) (by positivity) (by linarith [hs d]))).1
+ have hv := radial_fraction_volume_ratio (by positivity : 0 < s d / 512)
+ (by norm_num : (0 : ℝ) < 1 / 2) (euclideanUnitVolume_pos n)
+ (hvol d (s d / 512) (by positivity) (by linarith [hs d]))
+ (hvol d ((1 / 2) * (s d / 512)) (by positivity) (by linarith [hs d]))
+ have hrad : (1 / 2 : ℝ) * (s d / 512) = s d / 1024 := by ring
+ have hpow : ((1 / 2 : ℝ) ^ n)⁻¹ = (2 : ℝ) ^ n := by simp
+ rw [hrad, hpow] at hv
+ have hv' : μ.real (ball d.center (s d / 512)) ≤ V₀ ^ 2 * μ.real (ball d.center (s d / 1024)) := by
+ dsimp only [V₀]
+ rw [Real.sq_sqrt (by positivity)]
+ exact (div_le_iff₀ hpossmall).mp hv
+ have he' : ‖normalizeLocalL2 μ (ball d.center (s d / 512))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ (ball d.center (s d / 512)) (e' d))‖ ≤ F * d.source := by
+ dsimp only [e']
+ rw [map_smul, normalizeLocalL2_smul, norm_smul, Real.norm_eq_abs,
+ abs_of_pos (inv_pos.mpr (sq_pos_of_pos (hs d)))]
+ calc
+ _ ≤ (s d ^ 2)⁻¹ * (F * s d ^ 2 * d.source) :=
+ mul_le_mul_of_nonneg_left (he d) (by positivity)
+ _ = F * d.source := by field_simp [hsd.ne']
+ have hb := normalized_fit_restrict_norm μ hQ
+ (ball_subset_ball (show s d / 1024 ≤ s d / 512 by linarith [hs d]))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) hposbig hpossmall (e' d)
+ (Real.sqrt_nonneg _) (mul_nonneg hF d.source_pos.le) hv' he'
+ rw [normalized_sobolev_norm_congr μ hQ (congrArg (ball d.center) (hfrac1024 d))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (e' d)]
+ exact hb.trans_eq (by ring)
+ have hcoef' (d : I) : ‖(s d)⁻¹ • ell d‖ + |(s d ^ 2)⁻¹ * k d| ≤
+ (max 1 (2048 * M) * G) * (alpha d + d.source) := by
+ have hb := projection_coefficient_rescale d.frame (hs d) d.frameBound (ell d) (k d) (hcoef d)
+ dsimp only [alpha]
+ rw [normalized_sobolev_norm_congr μ hQ (congrArg (ball d.center) (hfrac2048 d))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (w' d)]
+ exact hb
+ let family : SharpProjectionFamily hX I (1 / 1024) (1 / 2048) := {
+ center := fun d => d.center
+ radius := s
+ error := fun d => d.error
+ source := fun d => d.source
+ coordinates := U
+ coordinateValues := fun d => d.coordinateValues
+ radial := f
+ target := fun d => (s d ^ 2)⁻¹ • (d.secondReplacement.replacement d.index - d.firstReplacement.replacement d.index)
+ residual := w'
+ forcing := e'
+ coefficient := fun d => (s d)⁻¹ • ell d
+ constant := fun d => (s d ^ 2)⁻¹ * k d
+ size := alpha
+ radialBound := A₀
+ outerConstant := T
+ coefficientConstant := max 1 (2048 * M) * G
+ sourceConstant := V₀ * F
+ radius_pos := hs
+ curvature := fun d => d.curvature
+ error_pos := fun d => d.error_pos hB
+ source_pos := fun d => d.source_pos
+ radialBound_nonneg := hA₀
+ outerConstant_nonneg := hT
+ coefficientConstant_nonneg := mul_nonneg (le_trans zero_le_one (le_max_left _ _)) hG
+ measured := fun d => d.measured.mono_error (d.approximationError_le hB)
+ representative := fun d => d.representative
+ laplacianCoefficient := fun d => (n : ℝ) + κ * (4 * s d) ^ 2
+ laplacianCoefficient_bound := by
+ intro d
+ rw [abs_of_nonneg (by positivity)]
+ exact d.laplacianBound.trans hAn
+ laplacian := by
+ intro d
+ apply rescaled_radial_laplacian μ hQ
+ exact (d.secondReplacement.laplacian d.index).mono μ hQ measurableSet_ball
+ (ball_subset_ball (show (1 / 1024 : ℝ) * s d ≤ s d by linarith [hs d]))
+ radial_norm := by
+ intro d
+ apply normalized_norm_le_of_bound μ _ _ _ hA₀
+ have hvalue := rescaled_radial_value μ hQ (ball d.center ((1 / 1024) * s d))
+ (d.secondReplacement.replacement d.index) (hs d)
+ (ae_restrict_of_ae (d.secondReplacement.value_bound μ hQ d.index))
+ filter_upwards [hvalue, SobolevSpace.restrictLp_coe μ hQ _ (f d)] with x hx heq
+ rw [heq]
+ exact hx.trans hAV
+ gradient := hgrad
+ quadratic_error := fun d => d.quadratic_error hn hκ hB
+ harmonic := by
+ intro d
+ exact ((hwharm d).mono μ hQ (ball_subset_ball
+ (show (1 / 1024 : ℝ) * s d ≤ s d / 512 by linarith [hs d]))).smul μ hQ _
+ projection := hp
+ size_eq := fun _ => rfl
+ outer_bound := by
+ intro d
+ dsimp only [alpha]
+ rw [normalized_sobolev_norm_congr μ hQ (congrArg (ball d.center) (hfrac1024 d))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (w' d),
+ normalized_sobolev_norm_congr μ hQ (congrArg (ball d.center) (hfrac2048 d))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (w' d)]
+ exact houter d
+ coefficient_bound := hcoef'
+ forcing_bound := hforce
+ euler_identity := by
+ intro d
+ have hsub : ball d.center ((1 / 1024) * s d) ⊆ ball d.center (s d / 512) :=
+ ball_subset_ball (by linarith [hs d])
+ have heta := ae_restrict_of_ae_restrict_of_subset hsub d.oneRepresentative
+ have hf := ae_restrict_of_ae_restrict_of_subset
+ (ball_subset_ball (show (1 / 1024 : ℝ) * s d ≤ s d / 4 by linarith [hs d])) d.secondGradient
+ have hid : localRadialDerivative μ hQ (ball d.center ((1 / 1024) * s d))
+ (d.secondReplacement.replacement d.index) hf (w d) =
+ SobolevSpace.restrictLp μ hQ (ball d.center ((1 / 1024) * s d))
+ (w d + sobolevColumnMap μ hQ d.coordinates (ell d) + k d • d.one + e d) :=
+ localRadialDerivative_eq_restrict μ hQ _ _ _ _ hf
+ (ae_restrict_of_ae_restrict_of_subset hsub (heuler d).symm)
+ exact radius_scaled_projection_euler_sum μ hQ (hs d) _ _ d.coordinates
+ (d.secondReplacement.replacement d.index) (w d) d.one (e d) (ell d) (k d) heta hf (hgrad d) hid
+ }
+ refine ⟨family, fun _ => rfl, fun _ => rfl, ?_⟩
+ intro d
+ change alpha d = d.projectionNorm
+ dsimp only [alpha, ActualProjectionConfiguration.projectionNorm]
+ rw [hp d]
+
+/-- One sharp estimate for every actual two-center target satisfying the
+preceding geometric estimates. The only compactness input is the precise
+published Poisson/harmonic convergence theorem. -/
+theorem actual_sharp_projection {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ (hhessian : LocalPoissonHessianActionInput hX)
+ (hproduct : LocalPoissonGradientProductInput hX)
+ (hpoincare : LocalMeanPoincareInput hX)
+ (hgradient : LocalHarmonicL2GradientInput hX)
+ (hcompact : LocalPoissonHarmonicCompactnessInput hX) (hn : 2 ≤ n)
+ {κ B J C A Cχ epsilon H D L M : ℝ}
+ (hκ : 0 ≤ κ) (hK : -κ ≤ K) (hB : 0 ≤ B) (hJ : 0 ≤ J)
+ (hCχ : 0 ≤ Cχ) (hA : 0 ≤ A) (hepsilon : 0 ≤ epsilon)
+ (hH : 0 ≤ H) (hD : 0 ≤ D) (hL : 0 ≤ L) :
+ ∃ P : ℝ, 0 < P ∧ ∃ delta : ℝ, 0 < delta ∧
+ ∀ d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M,
+ d.error < delta → d.projectionNorm ≤ P * d.source := by
+ obtain ⟨family, herr, hsource, hnorm⟩ := exists_actual_projection_family hX
+ hhessian hproduct hpoincare hgradient hn hκ hK hB hJ hCχ hA hepsilon hH hD hL
+ obtain ⟨P, hP, delta, hdelta, hbound⟩ := family.uniform_bound hcompact hgradient hn
+ (by norm_num) (by norm_num) (by norm_num)
+ refine ⟨P, hP, delta, hdelta, ?_⟩
+ intro d hd
+ simpa only [hsource d, hnorm d] using hbound d (by simpa only [herr d] using hd)
+
+/-- The same sharp estimate controls the actual harmonic residual gradient
+on the smaller testing ball, in physical radius units. -/
+theorem actual_sharp_projection_gradient {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ (hhessian : LocalPoissonHessianActionInput hX)
+ (hproduct : LocalPoissonGradientProductInput hX)
+ (hpoincare : LocalMeanPoincareInput hX)
+ (hgradient : LocalHarmonicL2GradientInput hX)
+ (hcompact : LocalPoissonHarmonicCompactnessInput hX) (hn : 2 ≤ n)
+ {κ B J C A Cχ epsilon H D L M : ℝ}
+ (hκ : 0 ≤ κ) (hK : -κ ≤ K) (hB : 0 ≤ B) (hJ : 0 ≤ J)
+ (hCχ : 0 ≤ Cχ) (hA : 0 ≤ A) (hepsilon : 0 ≤ epsilon)
+ (hH : 0 ≤ H) (hD : 0 ≤ D) (hL : 0 ≤ L) :
+ ∃ Q : ℝ, 0 < Q ∧ ∃ delta : ℝ, 0 < delta ∧
+ ∀ d : ActualProjectionConfiguration hX κ B J C A Cχ epsilon H D L M,
+ d.error < delta → ∀ w : SobolevSpace (hausdorff n X) hX.quadratic,
+ IsSobolevHarmonicOn (hausdorff n X) hX.quadratic
+ (ball d.center ((1 / 2048) * d.radius)) w →
+ SobolevSpace.restrictLp (hausdorff n X) hX.quadratic
+ (ball d.center ((1 / 2048) * d.radius)) w =
+ affineResidual (hausdorff n X) hX.quadratic
+ (radiusScaledColumns (hausdorff n X) hX.quadratic d.radius d.coordinates)
+ (ball d.center ((1 / 2048) * d.radius))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic
+ (ball d.center ((1 / 2048) * d.radius))
+ ((d.radius ^ 2)⁻¹ • (d.secondReplacement.replacement d.index - d.firstReplacement.replacement d.index))) →
+ ∀ᵐ x ∂(hausdorff n X).restrict (ball d.center ((1 / 4096) * d.radius)),
+ d.radius ^ 2 * localGamma (hausdorff n X) hX.quadratic w w x ≤ Q ^ 2 * d.source ^ 2 := by
+ obtain ⟨P, hP, delta, hdelta, hbound⟩ := actual_sharp_projection (C := C) (M := M) hX
+ hhessian hproduct hpoincare hgradient hcompact hn hκ hK hB hJ hCχ hA hepsilon hH hD hL
+ obtain ⟨Cg, hCg, hgrad⟩ := hgradient hn ((1 / 2048 : ℝ) ^ 2) (1 / 2)
+ (sq_nonneg _) (by norm_num) (by norm_num)
+ refine ⟨2048 * Cg * P, mul_pos (mul_pos (by norm_num) (by linarith)) hP, delta, hdelta, ?_⟩
+ intro d hd w hwharm hw
+ let μ := hausdorff n X
+ let hQ := hX.quadratic
+ have hr := d.radius_pos
+ have hcurv : -((1 / 2048 : ℝ) ^ 2) ≤ K * ((1 / 2048) * d.radius) ^ 2 := by
+ have hc := d.curvature
+ change -1 ≤ K * d.radius ^ 2 at hc
+ have hh := mul_le_mul_of_nonneg_left hc (sq_nonneg (1 / 2048 : ℝ))
+ nlinarith only [hh]
+ have hnrm : ‖normalizeLocalL2 μ (ball d.center ((1 / 2048) * d.radius))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ (ball d.center ((1 / 2048) * d.radius)) w)‖ = d.projectionNorm := by
+ rw [hw]
+ rfl
+ have hmean : (μ.real (ball d.center ((1 / 2048) * d.radius)))⁻¹ *
+ (∫ x in ball d.center ((1 / 2048) * d.radius), (SobolevSpace.toLp μ hQ w x) ^ 2 ∂μ) =
+ d.projectionNorm ^ 2 := by
+ rw [← normalized_sobolev_mean_sq μ hQ _ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)), hnrm]
+ have hg := hgrad d.center ((1 / 2048) * d.radius) (by positivity) hcurv w hwharm
+ change ∀ᵐ x ∂μ.restrict (ball d.center ((1 / 2) * ((1 / 2048) * d.radius))),
+ localGamma μ hQ w w x ≤ _ at hg
+ rw [hmean] at hg
+ have hsize : d.projectionNorm ^ 2 ≤ (P * d.source) ^ 2 := by
+ apply (sq_le_sq₀ (norm_nonneg _) (mul_pos hP d.source_pos).le).mpr
+ exact hbound d hd
+ have hrad : (1 / 2 : ℝ) * ((1 / 2048) * d.radius) = (1 / 4096) * d.radius := by ring
+ rw [hrad] at hg
+ filter_upwards [hg] with x hx
+ calc
+ _ ≤ d.radius ^ 2 * ((Cg / ((1 / 2048) * d.radius)) ^ 2 * d.projectionNorm ^ 2) :=
+ mul_le_mul_of_nonneg_left hx (sq_nonneg _)
+ _ ≤ d.radius ^ 2 * ((Cg / ((1 / 2048) * d.radius)) ^ 2 * (P * d.source) ^ 2) :=
+ mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hsize (sq_nonneg _)) (sq_nonneg _)
+ _ = (2048 * Cg * P) ^ 2 * d.source ^ 2 := by field_simp [hr.ne']
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ActualTwoCenterProjection.lean b/lean/OAI/Geometry/RCD/Harmonic/ActualTwoCenterProjection.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ca5dd3825abb0c65ae0a0323cd3c486f32e6a4e0
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ActualTwoCenterProjection.lean
@@ -0,0 +1,184 @@
+import OAI.Geometry.RCD.Sobolev.ActualPoissonEulerForcing
+import OAI.Geometry.RCD.Sobolev.PhysicalProjectionEuler
+
+namespace OAI
+
+/-! # The actual two-center Poisson projection and its scalar forcing -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal NNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- The projected function is constructed from the two actual Poisson
+replacements. Its scalar forcing is controlled by the original defects
+and the already constructed coordinate radial fits. The constant precedes
+all centers, root radii and dyadic indices. -/
+theorem actual_two_center_projection {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [IsFiniteMeasureOnCompacts (hausdorff n X)]
+ (hhessian : LocalPoissonHessianActionInput hX)
+ (hproduct : LocalPoissonGradientProductInput hX)
+ (hpoincare : LocalMeanPoincareInput hX)
+ {κ B J C A Cχ epsilon H D : ℝ}
+ (hκ : 0 ≤ κ) (hK : -κ ≤ K) (hB : 0 ≤ B) (hJ : 0 ≤ J)
+ (hCχ : 0 ≤ Cχ) (hA : 0 ≤ A) (hepsilon : 0 ≤ epsilon)
+ (hH : 0 ≤ H) (hD : 0 ≤ D) :
+ ∃ F : ℝ, 0 ≤ F ∧ ∀ {r0 : ℝ} (p₁ p₂ z : X)
+ (S₁ : DyadicDistanceSources (hausdorff n X) hX.quadratic n κ p₁ r0)
+ (S₂ : DyadicDistanceSources (hausdorff n X) hX.quadratic n κ p₂ r0)
+ (T₁ : DyadicDistanceReplacements (hausdorff n X) hX.quadratic S₁ B J C)
+ (T₂ : DyadicDistanceReplacements (hausdorff n X) hX.quadratic S₂ B J C)
+ (i : ℕ)
+ (_hroom₁ : dist z p₁ ≤ distanceSourceRadius r0 i / 4)
+ (_hroom₂ : dist z p₂ ≤ distanceSourceRadius r0 i / 4)
+ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ (_hu : ∀ j, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic
+ (ball z (distanceSourceRadius r0 i / 4)) (u j))
+ (_hgrad : ∀ j, ∀ᵐ x ∂(hausdorff n X).restrict (ball z (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (u j) (u j) x ≤ (1 + epsilon) ^ 2)
+ (_hf₁ : ∀ᵐ x ∂(hausdorff n X).restrict (ball z (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (T₁.replacement i) (T₁.replacement i) x ≤
+ (A * distanceSourceRadius r0 i) ^ 2)
+ (_hf₂ : ∀ᵐ x ∂(hausdorff n X).restrict (ball z (distanceSourceRadius r0 i / 4)),
+ localGamma (hausdorff n X) hX.quadratic (T₂.replacement i) (T₂.replacement i) x ≤
+ (A * distanceSourceRadius r0 i) ^ 2)
+ (_χ : GoodLaplacianCutoff (hausdorff n X) hX.quadratic z (distanceSourceRadius r0 i / 64) Cχ)
+ (_hcurv : -κ ≤ K * (distanceSourceRadius r0 i / 512) ^ 2)
+ (η : SobolevSpace (hausdorff n X) hX.quadratic)
+ (_hη : SobolevSpace.toLp (hausdorff n X) hX.quadratic η =ᵐ[
+ (hausdorff n X).restrict (ball z (distanceSourceRadius r0 i / 512))]
+ fun _ => (1 : ℝ))
+ (_hvolume : |(hausdorff n X).real (ball z (distanceSourceRadius r0 i / 64)) /
+ (euclideanUnitVolume n * (distanceSourceRadius r0 i / 64) ^ n) - 1| ≤ 1 / 4)
+ (_hvolumeSmall : |(hausdorff n X).real (ball z (distanceSourceRadius r0 i / 512)) /
+ (euclideanUnitVolume n * (distanceSourceRadius r0 i / 512) ^ n) - 1| ≤ 1 / 4)
+ (N : Euclidean n ≃L[ℝ] Euclidean n) (σ : ℝ) (_hσ : 0 ≤ σ)
+ (_hbudget : normalizedPoissonDefect (hausdorff n X) hX.quadratic S₁ i +
+ normalizedPoissonDefect (hausdorff n X) hX.quadratic S₂ i ≤ σ ^ 2)
+ (_hbound : ∀ c a, |c| + distanceSourceRadius r0 i * ‖N.symm a‖ ≤ H *
+ ‖normalizeLocalL2 (hausdorff n X) (ball z (distanceSourceRadius r0 i / 2048))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineCoordinateMap (hausdorff n X) hX.quadratic u
+ (ball z (distanceSourceRadius r0 i / 2048))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c, a))‖)
+ (G : Euclidean n →L[ℝ] SobolevSpace (hausdorff n X) hX.quadratic)
+ (Az : Euclidean n →L[ℝ] Euclidean n)
+ (_hG : ∀ b, SobolevSpace.toLp (hausdorff n X) hX.quadratic (G b) =ᵐ[
+ (hausdorff n X).restrict (ball z (distanceSourceRadius r0 i / 512))]
+ localGamma (hausdorff n X) hX.quadratic (T₂.replacement i)
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u b))
+ (_hfit : ∀ b, ‖normalizeLocalL2 (hausdorff n X) (ball z (distanceSourceRadius r0 i / 512))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic
+ (ball z (distanceSourceRadius r0 i / 512))
+ (G (N b) - sobolevColumnMap (hausdorff n X) hX.quadratic u (Az (N b))))‖ ≤
+ D * distanceSourceRadius r0 i * ‖b‖ * σ),
+ ∃ (c : ℝ) (b : Euclidean n) (k : ℝ)
+ (w e : SobolevSpace (hausdorff n X) hX.quadratic),
+ let μ := hausdorff n X
+ let s := distanceSourceRadius r0 i
+ let Ω := ball z (s / 512)
+ let I := ball z (s / 2048)
+ w = T₂.replacement i - T₁.replacement i - c • η - sobolevColumnMap μ hX.quadratic u (N b) ∧
+ IsSobolevHarmonicOn μ hX.quadratic Ω w ∧
+ SobolevSpace.restrictLp μ hX.quadratic I w = affineResidual μ hX.quadratic u I
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hX.quadratic I (T₂.replacement i - T₁.replacement i)) ∧
+ |c| + s * ‖b‖ ≤ H * (2 * max 8 B) * s ^ 2 ∧
+ (localGamma μ hX.quadratic (T₂.replacement i) w =ᵐ[μ.restrict Ω]
+ SobolevSpace.toLp μ hX.quadratic
+ (w + sobolevColumnMap μ hX.quadratic u (N b - Az (N b)) + k • η + e)) ∧
+ ‖normalizeLocalL2 μ Ω (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hX.quadratic Ω e)‖ ≤ F * s ^ 2 * σ := by
+ obtain ⟨Cp, hCp, hforcing⟩ := actual_poisson_euler_forcing hX hhessian hproduct hpoincare hκ
+ let E := Real.sqrt ((Cp / 512) ^ 2 * ((5 / 3 : ℝ) * (8 : ℝ) ^ n) *
+ poissonEulerGradientConstant n A B J Cχ)
+ let V := 2 * max 8 B
+ have hV : 0 ≤ V := by dsimp only [V]; positivity
+ refine ⟨E + D * H * V, by dsimp only [E]; positivity, ?_⟩
+ intro r0 p₁ p₂ z S₁ S₂ T₁ T₂ i hroom₁ hroom₂ u hu hgrad hf₁ hf₂ χ
+ hcurv η hη hvolume hvolumeSmall N σ hσ hbudget hbound G Az hG hfit
+ dsimp only
+ let μ := hausdorff n X
+ let hQ := hX.quadratic
+ let s := distanceSourceRadius r0 i
+ let Ω := ball z (s / 512)
+ let I := ball z (s / 2048)
+ let v := T₂.replacement i - T₁.replacement i
+ have hs : 0 < s := distanceSourceRadius_pos S₁.radius_pos i
+ have hsub : I ⊆ Ω := ball_subset_ball (by dsimp only [s]; linarith)
+ have hbig : Ω ⊆ ball z (s / 4) := ball_subset_ball (by linarith)
+ have hhu : ∀ j, IsSobolevHarmonicOn μ hQ Ω (u j) :=
+ fun j => (hu j).mono μ hQ hbig
+ have hv : IsSobolevHarmonicOn μ hQ Ω v :=
+ common_replacement_difference_harmonic μ hQ T₁ T₂ i z
+ (by change s / 512 + dist z p₁ ≤ s; change dist z p₁ ≤ s / 4 at hroom₁; linarith)
+ (by change s / 512 + dist z p₂ ≤ s; change dist z p₂ ≤ s / 4 at hroom₂; linarith)
+ have hfv : ∀ T : DyadicDistanceReplacements μ hQ S₁ B J C,
+ ‖normalizeLocalL2 μ I (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ I (T.replacement i))‖ ≤ max 8 B * s ^ 2 := by
+ intro T
+ apply normalized_norm_le_of_bound μ I _ _ (by have : 0 ≤ max 8 B := le_trans (by norm_num) (le_max_left _ _); positivity)
+ filter_upwards [ae_restrict_of_ae (T.value_bound μ hQ i),
+ SobolevSpace.restrictLp_coe μ hQ I (T.replacement i)] with x hx heq
+ rw [heq]
+ exact hx
+ have hfv₂ : ‖normalizeLocalL2 μ I (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ I (T₂.replacement i))‖ ≤ max 8 B * s ^ 2 := by
+ apply normalized_norm_le_of_bound μ I _ _ (by have : 0 ≤ max 8 B := le_trans (by norm_num) (le_max_left _ _); positivity)
+ filter_upwards [ae_restrict_of_ae (T₂.value_bound μ hQ i),
+ SobolevSpace.restrictLp_coe μ hQ I (T₂.replacement i)] with x hx heq
+ rw [heq]
+ exact hx
+ have hvalue : ‖normalizeLocalL2 μ I (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ I v)‖ ≤ V * s ^ 2 := by
+ have hh := (norm_sub_le
+ (normalizeLocalL2 μ I (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ I (T₂.replacement i)))
+ (normalizeLocalL2 μ I (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ I (T₁.replacement i)))).trans (add_le_add hfv₂ (hfv T₁))
+ simpa only [v, map_sub, normalizeLocalL2, smul_sub, V, two_mul, add_mul] using hh
+ obtain ⟨k, ev, hevId, hev⟩ := hforcing hK hB hJ hCχ hA hepsilon p₁ p₂ z S₁ S₂ T₁ T₂ i
+ hroom₁ hroom₂ u hu hgrad hf₁ hf₂ χ hcurv η hη hvolume hvolumeSmall
+ have hE2 : E ^ 2 = (Cp / 512) ^ 2 * ((5 / 3 : ℝ) * (8 : ℝ) ^ n) *
+ poissonEulerGradientConstant n A B J Cχ := by
+ apply Real.sq_sqrt
+ have homega := euclideanUnitVolume_pos n
+ dsimp only [poissonEulerGradientConstant]
+ positivity
+ have heScale : ‖normalizeLocalL2 μ Ω (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ Ω ((s ^ 2)⁻¹ • ev))‖ ≤ E * σ := by
+ apply (sq_le_sq₀ (norm_nonneg _) (by dsimp only [E]; positivity)).mp
+ rw [mul_pow, hE2]
+ exact hev.trans (mul_le_mul_of_nonneg_left hbudget (by rw [← hE2]; positivity))
+ have hev' : ‖normalizeLocalL2 μ Ω (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp μ hQ Ω ev)‖ ≤ E * s ^ 2 * σ := by
+ rw [map_smul, normalizeLocalL2_smul, norm_smul, Real.norm_eq_abs,
+ abs_inv, abs_of_pos (sq_pos_of_pos hs)] at heScale
+ have hh := mul_le_mul_of_nonneg_left heScale (sq_nonneg s)
+ field_simp [hs.ne'] at hh
+ nlinarith only [hh]
+ have hf := ae_restrict_of_ae_restrict_of_subset hbig hf₂
+ have hvId := localRadialDerivative_eq_of_euler μ hQ Ω (T₂.replacement i) v η ev hf k hη hevId
+ have hGId (a) := localRadialDerivative_eq_restrict μ hQ Ω (T₂.replacement i)
+ (sobolevColumnMap μ hQ u a) (G a) hf (hG a)
+ obtain ⟨c, b, hw, hproj, hcoef, hid, he⟩ := physical_projection_euler μ hQ u I Ω
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) hsub measurableSet_ball hhu
+ (T₂.replacement i) v η ev hv hη N hs hH hV (Real.sqrt_nonneg _) hD hσ
+ hbound hvalue hf G Az k hvId hGId hev' hfit
+ let w := v - c • η - sobolevColumnMap μ hQ u (N b)
+ let e := ev - (G (N b) - sobolevColumnMap μ hQ u (Az (N b)))
+ refine ⟨c, b, k + c, w, e, rfl, hw, hproj, hcoef, ?_, he⟩
+ have hre := localRadialDerivative_representative μ hQ Ω (T₂.replacement i) w hf
+ rw [hid] at hre
+ exact hre.symm.trans (SobolevSpace.restrictLp_coe μ hQ Ω _)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineCenterBounds.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineCenterBounds.lean
new file mode 100644
index 0000000000000000000000000000000000000000..80498d7234f0d8db9e275abb413f2bc3646e306b
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineCenterBounds.lean
@@ -0,0 +1,73 @@
+import OAI.Geometry.RCD.Coordinates.AffineFitDifference
+
+namespace OAI
+
+/-! # Size and centering of actual affine projections -/
+
+open Set MeasureTheory
+open scoped InnerProductSpace ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+theorem normalized_affineProjection_norm_le {n : ℕ}
+ (u : Fin n → SobolevSpace μ hQ) (s : Set X) (hs : μ s ≠ ∞)
+ (f : Lp ℝ 2 (μ.restrict s)) :
+ ‖normalizeLocalL2 μ s hs (affineProjection μ hQ u s hs f)‖ ≤
+ ‖normalizeLocalL2 μ s hs f‖ := by
+ unfold normalizeLocalL2
+ rw [← map_smul]
+ exact affineProjection_norm_le μ hQ u s hs _
+
+/-- Any coefficients of the actual fit inherit the harmonic evaluation
+bound and the contraction of orthogonal projection. -/
+theorem affineFit_center_bound {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (s : Set X) (hs : μ s ≠ ∞) (v : Euclidean n) {C : ℝ} (hC : 0 ≤ C)
+ (heval : ∀ c a, |c + ⟪v, a⟫_ℝ| ≤
+ C * ‖normalizeLocalL2 μ s hs (affineCoordinateMap μ hQ u s hs (c, a))‖)
+ (f : Lp ℝ 2 (μ.restrict s)) (c : ℝ) (a : Euclidean n)
+ (hfit : affineProjection μ hQ u s hs f = affineCoordinateMap μ hQ u s hs (c, a)) :
+ |c + ⟪v, a⟫_ℝ| ≤ C * ‖normalizeLocalL2 μ s hs f‖ := by
+ have h := heval c a
+ rw [← hfit] at h
+ exact h.trans (mul_le_mul_of_nonneg_left
+ (normalized_affineProjection_norm_le μ hQ u s hs f) hC)
+
+omit [MetricSpace X] in
+theorem normalized_constant_norm (s : Set X) (hs : μ s ≠ ∞) (hs0 : μ s ≠ 0) (c : ℝ) :
+ ‖normalizeLocalL2 μ s hs (c • restrictedOne μ s hs)‖ = |c| := by
+ have hn : ‖restrictedOne μ s hs‖ ≠ 0 := by
+ rw [restrictedOne_norm]
+ exact ne_of_gt (Real.sqrt_pos.mpr (ENNReal.toReal_pos hs0 hs))
+ simp only [normalizeLocalL2, norm_smul, Real.norm_eq_abs, abs_inv, abs_norm]
+ field_simp
+
+/-- Subtracting the center value from a fit costs exactly its absolute
+value in normalized L². -/
+theorem centered_affineFit_error {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (s : Set X) (hs : μ s ≠ ∞) (hs0 : μ s ≠ 0) (v : Euclidean n)
+ (f : Lp ℝ 2 (μ.restrict s)) (c : ℝ) (a : Euclidean n)
+ (hfit : affineProjection μ hQ u s hs f = affineCoordinateMap μ hQ u s hs (c, a)) :
+ ‖normalizeLocalL2 μ s hs
+ (f - affineCoordinateMap μ hQ u s hs (-⟪v, a⟫_ℝ, a))‖ ≤
+ ‖normalizeLocalL2 μ s hs (affineResidual μ hQ u s hs f)‖ + |c + ⟪v, a⟫_ℝ| := by
+ have he : f - affineCoordinateMap μ hQ u s hs (-⟪v, a⟫_ℝ, a) =
+ affineResidual μ hQ u s hs f + (c + ⟪v, a⟫_ℝ) • restrictedOne μ s hs := by
+ change f - affineCoordinateMap μ hQ u s hs (-⟪v, a⟫_ℝ, a) =
+ (f - affineProjection μ hQ u s hs f) + _
+ rw [hfit, affineCoordinateMap_apply, affineCoordinateMap_apply]
+ module
+ rw [he, normalizeLocalL2, smul_add]
+ have hb := norm_add_le
+ (normalizeLocalL2 μ s hs (affineResidual μ hQ u s hs f))
+ (normalizeLocalL2 μ s hs ((c + ⟪v, a⟫_ℝ) • restrictedOne μ s hs))
+ rwa [normalized_constant_norm μ s hs hs0] at hb
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineChange.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineChange.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0f0f3f203ee8731de0d6e1a7dc499b43af615892
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineChange.lean
@@ -0,0 +1,69 @@
+import OAI.Geometry.RCD.Harmonic.AffineProjection
+
+namespace OAI
+
+/-! # Least-squares affine fits are independent of coordinate normalization -/
+
+open Set MeasureTheory
+open scoped InnerProductSpace ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- An invertible linear coordinate change and a translation by constants
+preserve the actual finite-dimensional affine subspace in local L². -/
+theorem affineCoordinateSpace_eq_of_change {n : ℕ}
+ (u u' : Fin n → SobolevSpace μ hQ) (s : Set X) (hfin : μ s ≠ ∞)
+ (B : Euclidean n ≃L[ℝ] Euclidean n) (b : Euclidean n →L[ℝ] ℝ)
+ (hchange : ∀ v, SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u' v) =
+ SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u (B v)) +
+ b v • restrictedOne μ s hfin) :
+ affineCoordinateSpace μ hQ u' s hfin = affineCoordinateSpace μ hQ u s hfin := by
+ ext f
+ constructor
+ · rintro ⟨⟨c, v⟩, rfl⟩
+ refine ⟨(c + b v, B v), ?_⟩
+ change (c + b v) • restrictedOne μ s hfin +
+ SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u (B v)) =
+ c • restrictedOne μ s hfin +
+ SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u' v)
+ rw [hchange, add_smul]
+ abel
+ · rintro ⟨⟨c, v⟩, rfl⟩
+ refine ⟨(c - b (B.symm v), B.symm v), ?_⟩
+ change (c - b (B.symm v)) • restrictedOne μ s hfin +
+ SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u' (B.symm v)) =
+ c • restrictedOne μ s hfin +
+ SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u v)
+ rw [hchange, B.apply_symm_apply, sub_smul]
+ abel
+
+/-- Consequently the least-squares projection itself is unchanged. -/
+theorem affineProjection_eq_of_change {n : ℕ}
+ (u u' : Fin n → SobolevSpace μ hQ) (s : Set X) (hfin : μ s ≠ ∞)
+ (B : Euclidean n ≃L[ℝ] Euclidean n) (b : Euclidean n →L[ℝ] ℝ)
+ (hchange : ∀ v, SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u' v) =
+ SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u (B v)) +
+ b v • restrictedOne μ s hfin) :
+ affineProjection μ hQ u' s hfin = affineProjection μ hQ u s hfin := by
+ simp only [affineProjection,
+ affineCoordinateSpace_eq_of_change μ hQ u u' s hfin B b hchange]
+
+theorem affineResidual_eq_of_change {n : ℕ}
+ (u u' : Fin n → SobolevSpace μ hQ) (s : Set X) (hfin : μ s ≠ ∞)
+ (B : Euclidean n ≃L[ℝ] Euclidean n) (b : Euclidean n →L[ℝ] ℝ)
+ (hchange : ∀ v, SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u' v) =
+ SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u (B v)) +
+ b v • restrictedOne μ s hfin) :
+ affineResidual μ hQ u' s hfin = affineResidual μ hQ u s hfin := by
+ unfold affineResidual
+ rw [affineProjection_eq_of_change μ hQ u u' s hfin B b hchange]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineCommutatorIdentity.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineCommutatorIdentity.lean
new file mode 100644
index 0000000000000000000000000000000000000000..fccb79fb42d9e4279896bfaa4e8687308f62165d
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineCommutatorIdentity.lean
@@ -0,0 +1,65 @@
+import OAI.Geometry.RCD.Harmonic.TwoCenterCommutator
+import Mathlib.Tactic.Module
+
+namespace OAI
+
+/-! # The affine coefficient identity behind the two-center commutator
+
+Here U is the centered coordinate column, G its radial derivative at z,
+H the difference of the two radial derivatives, and C the constant part
+of the affine approximation to H. D and V are the actual radial derivative
+maps; J is restriction to the common L2 region.
+-/
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {E F W : Type*} [AddCommGroup E] [Module ℝ E]
+ [AddCommGroup F] [Module ℝ F] [AddCommGroup W] [Module ℝ W]
+
+/-- The coefficient expression is a sum of the genuine commutator error
+and the four value/gradient errors of the two radial approximations. -/
+theorem affine_commutator_identity
+ (A B : Module.End ℝ E) (U G H C : E →ₗ[ℝ] F) (D V J : F →ₗ[ℝ] W)
+ (hDU : ∀ a, D (U a) = J (G a))
+ (hVU : ∀ a, V (U a) = J (H a))
+ (hDC : ∀ a, D (C a) = 0) (b : E) :
+ J (U ((A * B - B * (A - 1)) b)) - J (C ((A - 1) b)) =
+ V (G b - U (A b)) - (V (G b) - D (H b) - J (H b)) -
+ D (H b - U (B b) - C b) +
+ J (H ((A - 1) b) - U (B ((A - 1) b)) - C ((A - 1) b)) -
+ J (G (B b) - U (A (B b))) := by
+ simp only [LinearMap.sub_apply, Module.End.mul_apply, Module.End.one_apply,
+ map_sub, hDU, hVU, hDC]
+ module
+
+section Norm
+variable {Y : Type*} [NormedAddCommGroup Y] [NormedSpace ℝ Y]
+
+/-- The exact identity keeps the five analytic errors additive. No small
+matrix term is absorbed before affine coefficient nondegeneracy is used. -/
+theorem affine_commutator_error_bound
+ (A B : Module.End ℝ E) (U G H C : E →ₗ[ℝ] F) (D V J : F →ₗ[ℝ] Y)
+ (hDU : ∀ a, D (U a) = J (G a))
+ (hVU : ∀ a, V (U a) = J (H a))
+ (hDC : ∀ a, D (C a) = 0) (b : E)
+ {e₁ e₂ e₃ e₄ e₅ : ℝ}
+ (h₁ : ‖V (G b - U (A b))‖ ≤ e₁)
+ (h₂ : ‖V (G b) - D (H b) - J (H b)‖ ≤ e₂)
+ (h₃ : ‖D (H b - U (B b) - C b)‖ ≤ e₃)
+ (h₄ : ‖J (H ((A - 1) b) - U (B ((A - 1) b)) - C ((A - 1) b))‖ ≤ e₄)
+ (h₅ : ‖J (G (B b) - U (A (B b)))‖ ≤ e₅) :
+ ‖J (U ((A * B - B * (A - 1)) b)) - J (C ((A - 1) b))‖ ≤
+ e₁ + e₂ + e₃ + e₄ + e₅ := by
+ rw [affine_commutator_identity A B U G H C D V J hDU hVU hDC b]
+ exact (norm_sub_le _ _).trans (add_le_add
+ ((norm_add_le _ _).trans (add_le_add
+ ((norm_sub_le _ _).trans (add_le_add
+ ((norm_sub_le _ _).trans (add_le_add h₁ h₂)) h₃)) h₄)) h₅)
+
+end Norm
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineCommutatorResidual.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineCommutatorResidual.lean
new file mode 100644
index 0000000000000000000000000000000000000000..133c5386ddf34f050b8f8875787fb7f15872255e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineCommutatorResidual.lean
@@ -0,0 +1,102 @@
+import OAI.Geometry.RCD.Harmonic.AffineCommutatorIdentity
+import OAI.Geometry.RCD.Harmonic.RadialDerivativeNorms
+import OAI.Geometry.RCD.Harmonic.RadialLinearRepresentatives
+
+namespace OAI
+
+/-! # The actual affine commutator residual from radial W12 errors -/
+
+open Set MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+theorem normalized_radial_derivative_norm_le (Ω : Set X) (hfin : μ Ω ≠ ∞)
+ (f q : SobolevSpace μ hQ) {B E : ℝ} (hB : 0 ≤ B) (hE : 0 ≤ E)
+ (hf : ∀ᵐ x ∂μ.restrict Ω, localGamma μ hQ f f x ≤ B ^ 2)
+ (hq : (μ.real Ω)⁻¹ * (∫ x in Ω, localGamma μ hQ q q x ∂μ) ≤ E ^ 2) :
+ ‖normalizeLocalL2 μ Ω hfin (localRadialDerivative μ hQ Ω f hf q)‖ ≤ B * E := by
+ have hh := normalized_radial_derivative_norm_sq μ hQ Ω hfin f q hf
+ have he := mul_le_mul_of_nonneg_left hq (sq_nonneg B)
+ have hs : ‖normalizeLocalL2 μ Ω hfin (localRadialDerivative μ hQ Ω f hf q)‖ ^ 2 ≤
+ (B * E) ^ 2 := by nlinarith only [hh, he]
+ exact (sq_le_sq₀ (norm_nonneg _) (mul_nonneg hB hE)).mp hs
+
+/-- All five terms in the exact coefficient identity are controlled by
+the two actual W12 fits and the full-mass commutator error. -/
+theorem normalized_affine_commutator_bound {n : ℕ}
+ (Ω : Set X) (hfin : μ Ω ≠ ∞) (f v η : SobolevSpace μ hQ)
+ {Cf Cv eg dg eh dh k : ℝ}
+ (hCf : 0 ≤ Cf) (hCv : 0 ≤ Cv) (hdg : 0 ≤ dg) (hdh : 0 ≤ dh)
+ (heg : 0 ≤ eg) (heh : 0 ≤ eh)
+ (hf : ∀ᵐ x ∂μ.restrict Ω, localGamma μ hQ f f x ≤ Cf ^ 2)
+ (hv : ∀ᵐ x ∂μ.restrict Ω, localGamma μ hQ v v x ≤ Cv ^ 2)
+ (hη : SobolevSpace.toLp μ hQ η =ᵐ[μ.restrict Ω] fun _ => (1 : ℝ))
+ (U G H : Euclidean n →L[ℝ] SobolevSpace μ hQ)
+ (hG : ∀ a, SobolevSpace.toLp μ hQ (G a) =ᵐ[μ.restrict Ω] localGamma μ hQ f (U a))
+ (hH : ∀ a, SobolevSpace.toLp μ hQ (H a) =ᵐ[μ.restrict Ω] localGamma μ hQ v (U a))
+ (A B : Euclidean n →L[ℝ] Euclidean n) (c : Euclidean n →L[ℝ] ℝ)
+ (hgv : ∀ a, ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω
+ (G a - U (A a)))‖ ≤ eg * ‖a‖)
+ (hge : ∀ a, (μ.real Ω)⁻¹ * (∫ x in Ω, localGamma μ hQ
+ (G a - U (A a)) (G a - U (A a)) x ∂μ) ≤ (dg * ‖a‖) ^ 2)
+ (hhv : ∀ a, ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω
+ (H a - U (B a) - c a • η))‖ ≤ eh * ‖a‖)
+ (hhe : ∀ a, (μ.real Ω)⁻¹ * (∫ x in Ω, localGamma μ hQ
+ (H a - U (B a) - c a • η) (H a - U (B a) - c a • η) x ∂μ) ≤ (dh * ‖a‖) ^ 2)
+ (hcomm : ∀ a, ‖normalizeLocalL2 μ Ω hfin
+ (localRadialDerivative μ hQ Ω v hv (G a) -
+ localRadialDerivative μ hQ Ω f hf (H a) - SobolevSpace.restrictLp μ hQ Ω (H a))‖ ≤ k * ‖a‖)
+ (b : Euclidean n) :
+ ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω
+ (U ((A * B - B * (A - 1)) b) - c ((A - 1) b) • η))‖ ≤
+ (Cv * dg + k + Cf * dh + eh * ‖A - 1‖ + eg * ‖B‖) * ‖b‖ := by
+ let Z : Lp ℝ 2 (μ.restrict Ω) →ₗ[ℝ] Lp ℝ 2 (μ.restrict Ω) :=
+ ‖restrictedOne μ Ω hfin‖⁻¹ • LinearMap.id
+ let D := Z.comp (localRadialDerivative μ hQ Ω f hf)
+ let V := Z.comp (localRadialDerivative μ hQ Ω v hv)
+ let J := Z.comp (SobolevSpace.restrictLp μ hQ Ω).toLinearMap
+ let C : Euclidean n →ₗ[ℝ] SobolevSpace μ hQ := c.toLinearMap.smulRight η
+ have hDU (a) : D (U a) = J (G a) := by
+ dsimp only [D, J, LinearMap.comp_apply]
+ rw [localRadialDerivative_eq_restrict μ hQ Ω f (U a) (G a) hf (hG a)]
+ rfl
+ have hVU (a) : V (U a) = J (H a) := by
+ dsimp only [V, J, LinearMap.comp_apply]
+ rw [localRadialDerivative_eq_restrict μ hQ Ω v (U a) (H a) hv (hH a)]
+ rfl
+ have hDC (a) : D (C a) = 0 := by
+ change Z (localRadialDerivative μ hQ Ω f hf (c a • η)) = 0
+ rw [map_smul, localRadialDerivative_constant μ hQ Ω f η hf 1 hη, smul_zero, map_zero]
+ have h₁ : ‖V (G b - U (A b))‖ ≤ Cv * dg * ‖b‖ := by
+ exact (normalized_radial_derivative_norm_le μ hQ Ω hfin v _ hCv
+ (mul_nonneg hdg (norm_nonneg b)) hv (hge b)).trans_eq (by ring)
+ have h₃ : ‖D (H b - U (B b) - C b)‖ ≤ Cf * dh * ‖b‖ := by
+ exact (normalized_radial_derivative_norm_le μ hQ Ω hfin f _ hCf
+ (mul_nonneg hdh (norm_nonneg b)) hf (hhe b)).trans_eq (by ring)
+ have h₄ : ‖J (H ((A - 1) b) - U (B ((A - 1) b)) - C ((A - 1) b))‖ ≤
+ eh * ‖A - 1‖ * ‖b‖ := by
+ exact (hhv ((A - 1) b)).trans ((mul_le_mul_of_nonneg_left
+ ((A - 1).le_opNorm b) heh).trans_eq (by ring))
+ have h₅ : ‖J (G (B b) - U (A (B b)))‖ ≤ eg * ‖B‖ * ‖b‖ := by
+ exact (hgv (B b)).trans ((mul_le_mul_of_nonneg_left (B.le_opNorm b) heg).trans_eq (by ring))
+ have h₂ : ‖V (G b) - D (H b) - J (H b)‖ ≤ k * ‖b‖ := by
+ change ‖normalizeLocalL2 μ Ω hfin (localRadialDerivative μ hQ Ω v hv (G b)) -
+ normalizeLocalL2 μ Ω hfin (localRadialDerivative μ hQ Ω f hf (H b)) -
+ normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω (H b))‖ ≤ _
+ simpa only [normalizeLocalL2, smul_sub] using hcomm b
+ have hh := affine_commutator_error_bound A.toLinearMap B.toLinearMap
+ U.toLinearMap G.toLinearMap H.toLinearMap C D V J hDU hVU hDC b h₁ h₂ h₃ h₄ h₅
+ change ‖J (U ((A * B - B * (A - 1)) b)) - J (C ((A - 1) b))‖ ≤ _ at hh
+ rw [← map_sub] at hh
+ exact hh.trans_eq (by ring)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineCompactness.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineCompactness.lean
new file mode 100644
index 0000000000000000000000000000000000000000..081ae8aaeb9f35e48c6fb35a563252ffb69ae284
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineCompactness.lean
@@ -0,0 +1,98 @@
+import OAI.Geometry.RCD.Sobolev.FiniteMomentConvergence
+import Mathlib.Topology.Sequences
+
+namespace OAI
+
+/-! # The compactness contradiction for a uniform affine improvement
+
+Convergence of the joint L² moments transfers a strict Euclidean affine
+improvement to the approximating harmonic functions.
+-/
+
+open Filter
+open scoped InnerProductSpace Topology BigOperators
+
+noncomputable section
+namespace RegularPointCoordinates
+
+/-- Target, constant and coordinate functions, in that order. -/
+def affineMomentFamily {H : Type*} (n : ℕ) (f one : H) (u : Fin n → H) :
+ Option (Option (Fin n)) → H
+ | none => f
+ | some none => one
+ | some (some i) => u i
+
+def affineErrorCoefficients {n : ℕ} (c : ℝ) (v : Fin n → ℝ) :
+ Option (Option (Fin n)) → ℝ
+ | none => 1
+ | some none => -c
+ | some (some i) => -v i
+
+theorem affineMomentFamily_sum {H : Type*} [AddCommGroup H] [Module ℝ H]
+ {n : ℕ} (f one : H) (u : Fin n → H) (c : ℝ) (v : Fin n → ℝ) :
+ (∑ i, affineErrorCoefficients c v i • affineMomentFamily n f one u i) =
+ f - c • one - ∑ i, v i • u i := by
+ simp only [Fintype.sum_option, affineErrorCoefficients, affineMomentFamily,
+ one_smul, neg_smul, Finset.sum_neg_distrib]
+ abel
+
+/-- Strict improvement for the limiting model transfers to the same
+coefficients in every sufficiently late actual function space. -/
+theorem affine_error_tendsto_of_moments
+ {n : ℕ} {H : ℕ → Type*} [∀ k, NormedAddCommGroup (H k)]
+ [∀ k, InnerProductSpace ℝ (H k)]
+ {Hlim : Type*} [NormedAddCommGroup Hlim] [InnerProductSpace ℝ Hlim]
+ (f one : ∀ k, H k) (u : ∀ k, Fin n → H k)
+ (flim onelim : Hlim) (ulim : Fin n → Hlim)
+ (h : ∀ i j, Tendsto
+ (fun k => ⟪affineMomentFamily n (f k) (one k) (u k) i,
+ affineMomentFamily n (f k) (one k) (u k) j⟫_ℝ) atTop
+ (𝓝 ⟪affineMomentFamily n flim onelim ulim i,
+ affineMomentFamily n flim onelim ulim j⟫_ℝ))
+ (c : ℝ) (v : Fin n → ℝ) :
+ Tendsto (fun k => ‖f k - c • one k - ∑ i, v i • u k i‖) atTop
+ (𝓝 ‖flim - c • onelim - ∑ i, v i • ulim i‖) := by
+ simpa only [affineMomentFamily_sum] using
+ norm_sum_smul_tendsto_of_inner_tendsto
+ (fun k => affineMomentFamily n (f k) (one k) (u k))
+ (affineMomentFamily n flim onelim ulim) h (affineErrorCoefficients c v)
+
+/-- The uniform threshold follows by contradiction from subsequential
+compactness of the finite moments and the strict Euclidean candidate bound.
+The coefficient choices need not be bounded or continuous in the index. -/
+theorem eventually_affine_fit_of_moment_compactness
+ {n : ℕ} {H : ℕ → Type*} [∀ k, NormedAddCommGroup (H k)]
+ [∀ k, InnerProductSpace ℝ (H k)]
+ {Hlim : Type*} [NormedAddCommGroup Hlim] [InnerProductSpace ℝ Hlim]
+ (f one : ∀ k, H k) (u : ∀ k, Fin n → H k)
+ {Models : Type*} (flim onelim : Models → Hlim) (ulim : Models → Fin n → Hlim)
+ (hcompact : ∀ s : ℕ → ℕ, StrictMono s →
+ ∃ (t : ℕ → ℕ), StrictMono t ∧ ∃ model : Models,
+ ∀ i j, Tendsto
+ (fun k => ⟪affineMomentFamily n (f (s (t k))) (one (s (t k))) (u (s (t k))) i,
+ affineMomentFamily n (f (s (t k))) (one (s (t k))) (u (s (t k))) j⟫_ℝ) atTop
+ (𝓝 ⟪affineMomentFamily n (flim model) (onelim model) (ulim model) i,
+ affineMomentFamily n (flim model) (onelim model) (ulim model) j⟫_ℝ))
+ {η : ℝ}
+ (hmodel : ∀ model : Models, ∃ (c : ℝ) (v : Fin n → ℝ),
+ ‖flim model - c • onelim model - ∑ i, v i • ulim model i‖ < η) :
+ ∀ᶠ k in atTop, ∃ (c : ℝ) (v : Fin n → ℝ),
+ ‖f k - c • one k - ∑ i, v i • u k i‖ < η := by
+ by_contra hbad
+ have hb : ∃ᶠ k in atTop, ¬ ∃ (c : ℝ) (v : Fin n → ℝ),
+ ‖f k - c • one k - ∑ i, v i • u k i‖ < η := by
+ simpa only [Filter.Frequently, not_not] using hbad
+ obtain ⟨s, hs, hfail⟩ := extraction_of_frequently_atTop hb
+ obtain ⟨t, _ht, model, hlimit⟩ := hcompact s hs
+ obtain ⟨c, v, hcv⟩ := hmodel model
+ have he := (affine_error_tendsto_of_moments
+ (fun k => f (s (t k))) (fun k => one (s (t k))) (fun k => u (s (t k)))
+ (flim model) (onelim model) (ulim model) hlimit c v).eventually (gt_mem_nhds hcv)
+ obtain ⟨k, hk⟩ := he.exists
+ exact hfail (t k) ⟨c, v, hk⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineConstantBound.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineConstantBound.lean
new file mode 100644
index 0000000000000000000000000000000000000000..772bd4b057366194669f595f1563901dd9f4c24d
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineConstantBound.lean
@@ -0,0 +1,64 @@
+import OAI.Geometry.RCD.Harmonic.AffineEvaluation
+
+namespace OAI
+
+/-! # Recovering the constant operator of a centered affine residual -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- The published mean-value estimate recovers the constant coefficient
+operator because the same harmonic coordinate map vanishes at the center. -/
+theorem LocalHarmonicL2MeanValueInput.affine_constant_operator_bound
+ {K : ℝ} {n : ℕ} {hX : NoncollapsedRCD K n X}
+ (hinput : LocalHarmonicL2MeanValueInput hX) (hn : 2 ≤ n)
+ {κ : ℝ} (hκ : 0 ≤ κ) :
+ ∃ C : ℝ, 1 ≤ C ∧ ∀ (p : X) (R : ℝ), 0 < R → -κ ≤ K * R ^ 2 →
+ ∀ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic) (V : X → Euclidean n),
+ (∀ j, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball p R) (u j)) →
+ ContinuousOn V (ball p R) → V p = 0 →
+ (∀ j, SobolevSpace.toLp (hausdorff n X) hX.quadratic (u j) =ᵐ[
+ (hausdorff n X).restrict (ball p R)] fun x => V x j) →
+ ∀ η : SobolevSpace (hausdorff n X) hX.quadratic,
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic η =ᵐ[
+ (hausdorff n X).restrict (ball p R)] fun _ => (1 : ℝ)) →
+ ∀ (A : Euclidean n →L[ℝ] Euclidean n) (c : Euclidean n →L[ℝ] ℝ) (d : ℝ), 0 ≤ d →
+ (∀ b, ‖normalizeLocalL2 (hausdorff n X) (ball p R)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic (ball p R)
+ (c b • η + sobolevColumnMap (hausdorff n X) hX.quadratic u (A b)))‖ ≤ d * ‖b‖) →
+ ‖c‖ ≤ C * d := by
+ obtain ⟨C, hC, heval⟩ := affine_evaluation_of_mean_value hX hinput hn hκ
+ refine ⟨C, hC, ?_⟩
+ intro p R hR hcurv u V hu hV hVp hrep η hη A c d hd herror
+ apply ContinuousLinearMap.opNorm_le_bound _ (mul_nonneg (by linarith) hd)
+ intro b
+ have hh := heval p R hR hcurv u V hu hV hrep η hη (c b) (A b)
+ simp only [hVp, inner_zero_left, add_zero] at hh
+ have hr : SobolevSpace.restrictLp (hausdorff n X) hX.quadratic (ball p R)
+ (c b • η + sobolevColumnMap (hausdorff n X) hX.quadratic u (A b)) =
+ affineCoordinateMap (hausdorff n X) hX.quadratic u (ball p R)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c b, A b) := by
+ rw [map_add, map_smul, restrictLp_eq_one_of_representative _ _ η _ _ hη,
+ affineCoordinateMap_apply]
+ have hb := herror b
+ rw [hr] at hb
+ calc
+ ‖c b‖ = |c b| := Real.norm_eq_abs _
+ _ ≤ C * ‖normalizeLocalL2 (hausdorff n X) (ball p R)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineCoordinateMap (hausdorff n X) hX.quadratic u (ball p R)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c b, A b))‖ := hh
+ _ ≤ C * (d * ‖b‖) := mul_le_mul_of_nonneg_left hb (by linarith)
+ _ = _ := by ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineEvaluation.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineEvaluation.lean
new file mode 100644
index 0000000000000000000000000000000000000000..31a2b42d45c2db7120832cdb9e1b9b6e393d8443
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineEvaluation.lean
@@ -0,0 +1,85 @@
+import OAI.Geometry.RCD.Harmonic.HarmonicMeanValueInput
+import OAI.Geometry.RCD.Harmonic.LocalConstantHarmonic
+import OAI.Geometry.RCD.Harmonic.ColumnRepresentatives
+import OAI.Geometry.RCD.Coordinates.AffineFitPerturbation
+
+namespace OAI
+
+/-! # Uniform evaluation of affine fits at their center -/
+
+open Set Metric MeasureTheory
+open scoped InnerProductSpace ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+omit [BorelSpace X] [ProperSpace X] in
+theorem affineSobolev_representative (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ {n : ℕ} (u : Fin n → SobolevSpace μ hQ) (s : Set X) (v : X → Euclidean n)
+ (hu : ∀ i, SobolevSpace.toLp μ hQ (u i) =ᵐ[μ.restrict s] fun x => v x i)
+ (η : SobolevSpace μ hQ) (hη : SobolevSpace.toLp μ hQ η =ᵐ[μ.restrict s] fun _ => (1 : ℝ))
+ (c : ℝ) (a : Euclidean n) :
+ SobolevSpace.toLp μ hQ (c • η + sobolevColumnMap μ hQ u a) =ᵐ[μ.restrict s]
+ fun x => c + ⟪v x, a⟫_ℝ := by
+ change SobolevSpace.toLpCLM μ hQ (c • η + sobolevColumnMap μ hQ u a) =ᵐ[μ.restrict s] _
+ rw [map_add, map_smul]
+ change (c • SobolevSpace.toLp μ hQ η + SobolevSpace.toLp μ hQ (sobolevColumnMap μ hQ u a))
+ =ᵐ[μ.restrict s] _
+ filter_upwards [ae_restrict_of_ae (Lp.coeFn_add (c • SobolevSpace.toLp μ hQ η)
+ (SobolevSpace.toLp μ hQ (sobolevColumnMap μ hQ u a))),
+ ae_restrict_of_ae (Lp.coeFn_smul c (SobolevSpace.toLp μ hQ η)), hη,
+ sobolevColumnMap_representative μ hQ u s v hu a] with x hadd hsmul hconst hcol
+ rw [hadd]
+ simp only [Pi.add_apply, hsmul, Pi.smul_apply, smul_eq_mul, hconst, mul_one, hcol]
+
+/-- Moser's mean-value estimate bounds affine evaluation without requiring
+a choice of unique affine coefficients. -/
+theorem affine_evaluation_of_mean_value {K : ℝ} {n : ℕ} (hX : NoncollapsedRCD K n X)
+ (hmean : LocalHarmonicL2MeanValueInput hX) (hn : 2 ≤ n) {κ : ℝ} (hκ : 0 ≤ κ) :
+ ∃ C : ℝ, 1 ≤ C ∧ ∀ (p : X) (r : ℝ), 0 < r → -κ ≤ K * r ^ 2 →
+ ∀ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic) (v : X → Euclidean n),
+ (∀ i, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball p r) (u i)) →
+ ContinuousOn v (ball p r) →
+ (∀ i, SobolevSpace.toLp (hausdorff n X) hX.quadratic (u i) =ᵐ[
+ (hausdorff n X).restrict (ball p r)] fun x => v x i) →
+ ∀ η : SobolevSpace (hausdorff n X) hX.quadratic,
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic η =ᵐ[
+ (hausdorff n X).restrict (ball p r)] fun _ => (1 : ℝ)) →
+ ∀ (c : ℝ) (a : Euclidean n),
+ |c + ⟪v p, a⟫_ℝ| ≤ C *
+ ‖normalizeLocalL2 (hausdorff n X) (ball p r)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineCoordinateMap (hausdorff n X) hX.quadratic u (ball p r)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c, a))‖ := by
+ obtain ⟨C, hC, hcenter⟩ := hmean.center_bound hn hκ
+ refine ⟨C, hC, ?_⟩
+ intro p r hr hcurv u v hu hv hrep η hη c a
+ let μ := hausdorff n X
+ let F := c • η + sobolevColumnMap μ hX.quadratic u a
+ have hηharm := isSobolevHarmonicOn_of_local_constant μ hX.quadratic
+ (ball p r) measurableSet_ball η 1 hη
+ have hFharm : IsSobolevHarmonicOn μ hX.quadratic (ball p r) F :=
+ (hηharm.smul μ hX.quadratic c).add μ hX.quadratic
+ (IsSobolevHarmonicOn.linearCombination μ hX.quadratic hu a)
+ have hFrep := affineSobolev_representative μ hX.quadratic u (ball p r) v hrep η hη c a
+ have hFcont : ContinuousOn (fun x => c + ⟪v x, a⟫_ℝ) (ball p r) :=
+ continuousOn_const.add (hv.inner continuousOn_const)
+ have hb := hcenter p r hr hcurv F (fun x => c + ⟪v x, a⟫_ℝ) hFharm hFcont hFrep
+ have hrest : SobolevSpace.restrictLp μ hX.quadratic (ball p r) F =
+ affineCoordinateMap μ hX.quadratic u (ball p r)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (c, a) := by
+ rw [affineCoordinateMap_apply]
+ change SobolevSpace.restrictLp μ hX.quadratic (ball p r)
+ (c • η + sobolevColumnMap μ hX.quadratic u a) = _
+ rw [map_add, map_smul, restrictLp_eq_one_of_representative μ hX.quadratic η _ _ hη]
+ change |c + ⟪v p, a⟫_ℝ| ≤ C * ‖normalizeLocalL2 μ (ball p r) _
+ (SobolevSpace.restrictLp μ hX.quadratic (ball p r) F)‖ at hb
+ rwa [hrest] at hb
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineForcingBound.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineForcingBound.lean
new file mode 100644
index 0000000000000000000000000000000000000000..c1b67a5cfb4b8ba44f6ac1011ef33e0e232ed052
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineForcingBound.lean
@@ -0,0 +1,46 @@
+import OAI.Geometry.RCD.Harmonic.ForcingCoefficient
+
+namespace OAI
+
+/-! # The full forcing is controlled before residual normalization -/
+
+open Set MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- The exact-frame coefficient estimate controls the forcing on the
+larger transport ball, including its constant and Sobolev error. -/
+theorem affine_forcing_norm_bound {n : ℕ} (Ω : Set X) (hfin : μ Ω ≠ ∞)
+ (hpos : μ Ω ≠ 0) (η e : SobolevSpace μ hQ)
+ (hη : SobolevSpace.toLp μ hQ η =ᵐ[μ.restrict Ω] fun _ => (1 : ℝ))
+ (U : Euclidean n →L[ℝ] SobolevSpace μ hQ) (N : Euclidean n ≃L[ℝ] Euclidean n)
+ (ell : Euclidean n) (k : ℝ) {R C D α s : ℝ}
+ (hR : 0 ≤ R) (hD : 0 ≤ D) (hα : 0 ≤ α)
+ (hU : ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω (U ell))‖ ≤ R * ‖N.symm ell‖)
+ (hcoeff : |k| + ‖N.symm ell‖ ≤ C * (α + s))
+ (he : ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω e)‖ ≤ D * s) :
+ ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω (U ell + k • η + e))‖ ≤
+ ((1 + R) * C + D) * (α + s) := by
+ have hconst : ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω (k • η))‖ = |k| := by
+ rw [map_smul, restrictLp_eq_one_of_representative μ hQ η Ω hfin hη,
+ normalized_constant_norm μ Ω hfin hpos]
+ have hsum : R * ‖N.symm ell‖ + |k| ≤ (1 + R) * (|k| + ‖N.symm ell‖) := by
+ nlinarith [abs_nonneg k, norm_nonneg (N.symm ell), mul_nonneg hR (abs_nonneg k)]
+ have hb := hsum.trans (mul_le_mul_of_nonneg_left hcoeff (by positivity : 0 ≤ 1 + R))
+ rw [map_add, map_add]
+ simp only [normalizeLocalL2, smul_add] at hU he hconst ⊢
+ apply le_trans ((norm_add_le _ _).trans (add_le_add (norm_add_le _ _) le_rfl))
+ rw [hconst]
+ have hh := add_le_add (add_le_add hU (le_rfl : |k| ≤ |k|)) he
+ exact hh.trans (by nlinarith only [hb, mul_nonneg hD hα])
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineGrowthOnInterval.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineGrowthOnInterval.lean
new file mode 100644
index 0000000000000000000000000000000000000000..82a4008e45fe6e9e8ddda25b843b93d51639dac2
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineGrowthOnInterval.lean
@@ -0,0 +1,36 @@
+import Mathlib.Analysis.ODE.Gronwall
+import Mathlib.Analysis.Calculus.Deriv.MeanValue
+
+namespace OAI
+
+/-! # Gronwall's inequality with only interior differentiation -/
+
+open Set
+namespace RegularPointCoordinates
+
+theorem affine_growth_on_interval {F : ℝ → ℝ} {b c : ℝ} (hb : 0 ≤ b)
+ (hF : ContinuousOn F (Icc 0 b))
+ (hd : ∀ t ∈ Ioo 0 b, DifferentiableAt ℝ F t ∧ deriv F t ≤ c*(F t+1))
+ {t : ℝ} (ht : t ∈ Icc 0 b) :
+ F t+1 ≤ Real.exp (c*t)*(F 0+1) := by
+ have hmono : AntitoneOn (fun s => Real.exp (-c*s)*(F s+1)) (Icc 0 b) := by
+ apply antitoneOn_of_hasDerivWithinAt_nonpos (convex_Icc 0 b)
+ ((Real.continuous_exp.comp (continuous_const.mul continuous_id)).continuousOn.mul
+ (hF.add continuousOn_const))
+ (fun s hs => ((((hasDerivAt_id s).const_mul (-c)).exp).mul
+ (((hd s (by simpa only [interior_Icc] using hs)).1.hasDerivAt).add_const 1)).hasDerivWithinAt)
+ intro s hs
+ have hs' : s ∈ Ioo 0 b := by simpa only [interior_Icc] using hs
+ have hh := mul_le_mul_of_nonneg_left (hd s hs').2 (Real.exp_pos (-c*s)).le
+ simp only [id_eq,mul_one]
+ nlinarith only [hh]
+ have hh := hmono (show (0:ℝ) ∈ Icc 0 b from ⟨le_rfl,hb⟩) ht ht.1
+ simp only [mul_zero,Real.exp_zero,one_mul] at hh
+ have hmul := mul_le_mul_of_nonneg_left hh (Real.exp_pos (c*t)).le
+ have hcancel : Real.exp (c*t)*Real.exp (-c*t) = 1 := by
+ rw [← Real.exp_add,show c*t+ -c*t = 0 by ring,Real.exp_zero]
+ simpa only [← mul_assoc,hcancel,one_mul] using hmul
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineImprovementTransfer.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineImprovementTransfer.lean
new file mode 100644
index 0000000000000000000000000000000000000000..425282efcbc65f4a2c9c611398d341eaedb810cd
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineImprovementTransfer.lean
@@ -0,0 +1,116 @@
+import OAI.Geometry.RCD.Harmonic.HarmonicAffineImprovement
+import OAI.Geometry.RCD.Coordinates.MeasuredCoordinateInput
+import OAI.Geometry.RCD.Harmonic.ColumnRepresentatives
+
+namespace OAI
+
+/-! # Affine improvement in the original harmonic coordinate span
+
+The measured compactness theorem is applied to normalized and recentered
+coordinates. Invertibility and the local constant cutoff identify their
+affine projection exactly with that of the original columns.
+-/
+
+open Set Metric MeasureTheory
+open scoped ENNReal InnerProductSpace BigOperators
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+omit [ProperSpace X] in
+theorem affine_improvement_from_metric_coordinates {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n)
+ (hcompact : LocalHarmonicMomentCompactnessInput hX)
+ (hgradient : LocalHarmonicL2GradientInput hX)
+ (heuclidean : EuclideanHarmonicHessianInput n)
+ (hmeasured : LocalMeasuredCoordinateInput hX) :
+ ∃ m : ℕ, 3 ≤ m ∧ ∃ δ : ℝ, 0 < δ ∧ δ ≤ 1 ∧
+ ∀ (p : X) (r : ℝ), 0 < r → -δ ≤ K * r ^ 2 →
+ ∀ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic) (v : X → Euclidean n),
+ (∀ i, SobolevSpace.toLp (hausdorff n X) hX.quadratic (u i) =ᵐ[
+ (hausdorff n X).restrict (ball p r)] fun x => v x i) →
+ ∀ (B : Euclidean n ≃L[ℝ] Euclidean n)
+ (η : SobolevSpace (hausdorff n X) hX.quadratic),
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic η =ᵐ[
+ (hausdorff n X).restrict (ball p r)] fun _ => (1 : ℝ)) →
+ Measurable (fun x => (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v x) -
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v p)) →
+ IsPointedApproximation p 0 r 2 δ (fun x =>
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v x) -
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v p)) →
+ ∀ w : SobolevSpace (hausdorff n X) hX.quadratic,
+ IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball p r) w →
+ ‖normalizeLocalL2 (hausdorff n X) (ball p r)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic (ball p r) w)‖ ≤ 1 →
+ ‖normalizeLocalL2 (hausdorff n X) (ball p ((1 / 2 : ℝ) ^ m * r))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineResidual (hausdorff n X) hX.quadratic u
+ (ball p ((1 / 2 : ℝ) ^ m * r)) (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic
+ (ball p ((1 / 2 : ℝ) ^ m * r)) w))‖ <
+ (1 / 2 : ℝ) * (1 / 2 : ℝ) ^ m * Real.sqrt ((1 / 2 : ℝ) ^ m) := by
+ obtain ⟨m, hm, happly⟩ := harmonic_affine_improvement_of_measured_approximation
+ hX hn hcompact hgradient heuclidean
+ obtain ⟨ε, hε, hεfit⟩ := happly 1 zero_lt_one
+ obtain ⟨d, hd, hmeasure⟩ := hmeasured hn 1 ε zero_lt_one hε
+ let δ := min d 1
+ have hδ : 0 < δ := lt_min hd zero_lt_one
+ refine ⟨m, hm, δ, hδ, min_le_right _ _, ?_⟩
+ intro p r hr hcurv u v hrep B η hη hmeas happ w hw hnorm
+ let μ := hausdorff n X
+ let b : Euclidean n →L[ℝ] ℝ := -(innerSL ℝ ((B : Euclidean n →L[ℝ] Euclidean n).adjoint (v p)))
+ let u' := affineChangedColumn μ hX.quadratic u B b η
+ let f := fun x => (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v x) -
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v p)
+ have hrep' (i : Fin n) : SobolevSpace.toLp μ hX.quadratic (u' i) =ᵐ[μ.restrict (ball p r)]
+ fun x => f x i := by
+ have hi := affineChangedColumn_representative μ hX.quadratic u (ball p r) v hrep B b η hη i
+ have hb : b (EuclideanSpace.single i 1) =
+ -((B : Euclidean n →L[ℝ] Euclidean n).adjoint (v p)) i := by
+ change -⟪(B : Euclidean n →L[ℝ] Euclidean n).adjoint (v p), EuclideanSpace.single i 1⟫_ℝ = _
+ simp only [EuclideanSpace.inner_single_right, starRingEnd_apply, star_trivial, one_mul]
+ filter_upwards [hi] with x hx
+ change _ = ((B : Euclidean n →L[ℝ] Euclidean n).adjoint (v x) -
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v p)) i
+ rw [PiLp.sub_apply]
+ simpa only [hb, sub_eq_add_neg] using hx
+ have hcurvd : -d ≤ K * r ^ 2 := (neg_le_neg (min_le_left d 1)).trans hcurv
+ have hcurv1 : -1 ≤ K * r ^ 2 := (neg_le_neg (min_le_right d 1)).trans hcurv
+ have hmeasured' := hmeasure p r hr hcurvd f hmeas
+ (by simpa only [mul_one] using happ.mono_error (min_le_left d 1))
+ let test : NormalizedHarmonicTest hX 1 ε := {
+ center := p
+ scale := r
+ scale_pos := hr
+ curvature := hcurv1
+ coordinates := u'
+ values := f
+ target := w
+ approximation := hmeasured'
+ representative := fun i => by simpa only [one_mul] using hrep' i
+ harmonic := by simpa only [one_mul] using hw
+ normalized := by rw [one_mul]; exact hnorm }
+ have hfit := hεfit test
+ dsimp only [NormalizedHarmonicTest.residualNorm, test] at hfit
+ rw [mul_one] at hfit
+ have hsub : ball p ((1 / 2 : ℝ) ^ m * r) ⊆ ball p r :=
+ ball_subset_ball (mul_le_of_le_one_left hr.le (pow_le_one₀ (by norm_num) (by norm_num)))
+ have hη' := ae_restrict_of_ae_restrict_of_subset hsub hη
+ have hηeq := restrictLp_eq_one_of_representative μ hX.quadratic η
+ (ball p ((1 / 2 : ℝ) ^ m * r)) (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) hη'
+ have heq := affineChangedColumn_residual_eq μ hX.quadratic u B b η
+ (ball p ((1 / 2 : ℝ) ^ m * r)) (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) hηeq
+ change ‖normalizeLocalL2 μ (ball p ((1 / 2 : ℝ) ^ m * r)) _
+ (affineResidual μ hX.quadratic u' (ball p ((1 / 2 : ℝ) ^ m * r)) _
+ (SobolevSpace.restrictLp μ hX.quadratic (ball p ((1 / 2 : ℝ) ^ m * r)) w))‖ < _ at hfit
+ rw [heq] at hfit
+ exact hfit
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineMomentConvergence.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineMomentConvergence.lean
new file mode 100644
index 0000000000000000000000000000000000000000..15540379e52dcdf4fcd6f999f579c0348c1033f7
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineMomentConvergence.lean
@@ -0,0 +1,91 @@
+import OAI.Geometry.RCD.Harmonic.AffineValuePairings
+
+namespace OAI
+
+/-! # Finite affine Hilbert moments from the actual pointed value limit -/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology InnerProductSpace NNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+
+theorem NoncollapsedRCD.affine_value_moments_of_limit {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) {S : ℝ} (hS : 0 v k x j)
+ (g : Euclidean n → ℝ) (hg : MemLp g 2 (volume.restrict (ball 0 S)))
+ (hmodel : ∀ τ
+ ⟪localAffineMomentFamily (hausdorff n X) hX.quadratic (u k) (w k)
+ (ball (p k) (ρ*r k)) (hX.finiteOnBounded _ isBounded_ball).ne i,
+ localAffineMomentFamily (hausdorff n X) hX.quadratic (u k) (w k)
+ (ball (p k) (ρ*r k)) (hX.finiteOnBounded _ isBounded_ball).ne j⟫_ℝ)
+ atTop (𝓝 ⟪euclideanValueMoments g hg hρS.le i,euclideanValueMoments g hg hρS.le j⟫_ℝ) := by
+ intro ρ hρ hρS i j
+ let μ := hausdorff n X
+ let τ := (ρ+S)/2
+ have hρτ : ρ<τ := by dsimp only [τ]; linarith
+ have hτS : τ v k x a :=
+ ae_restrict_of_ae_restrict_of_subset
+ (ball_subset_ball (mul_le_mul_of_nonneg_right hρS.le (hr k).le)) (hrep k a)
+ have hprod (k) : Integrable (fun x =>
+ affineValueFamily (SobolevSpace.toLp μ hX.quadratic (w k)) (v k) i x*
+ affineValueFamily (SobolevSpace.toLp μ hX.quadratic (w k)) (v k) j x)
+ (μ.restrict (ball (p k) (ρ*r k))) :=
+ (affineValueFamily_memLp μ hX.quadratic (u k) (w k) (v k) _
+ (hX.finiteOnBounded _ isBounded_ball).ne (hrep' k) i).integrable_mul
+ (affineValueFamily_memLp μ hX.quadratic (u k) (w k) (v k) _
+ (hX.finiteOnBounded _ isBounded_ball).ne (hrep' k) j)
+ have hconv' (a) : ∀ η : ℝ, 0<η → ∀ᶠ k in atTop,
+ ∀ᵐ x ∂μ.restrict (ball (p k) (ρ*r k)),
+ |affineValueFamily (SobolevSpace.toLp μ hX.quadratic (w k)) (v k) a x-
+ affineValueFamily g id a (v k x)|≤η := by
+ rcases a with _ | (_ | k)
+ · exact hconv ρ hρ hρS
+ · intro η hη
+ exact Eventually.of_forall fun _ => Eventually.of_forall fun _ => by
+ simpa only [affineValueFamily,affineMomentFamily,sub_self,abs_zero] using hη.le
+ · intro η hη
+ exact Eventually.of_forall fun _ => Eventually.of_forall fun _ => by
+ simpa only [affineValueFamily,affineMomentFamily,id_eq,sub_self,abs_zero] using hη.le
+ have ht := inner_ball_value_moment_tendsto hS hρ hρτ hτS.le hr hv
+ (fun _ => (hX.finiteOnBounded _ isBounded_ball).ne)
+ (fun k => ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hS (hr k))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne)
+ (fun k => ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hρ (hr k))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne) hε
+ (fun k => affineValueFamily (SobolevSpace.toLp μ hX.quadratic (w k)) (v k) i)
+ (fun k => affineValueFamily (SobolevSpace.toLp μ hX.quadratic (w k)) (v k) j)
+ (affineValueFamily g id i) (affineValueFamily g id j)
+ hLi hLj hprod (hconv' i) (hconv' j)
+ rw [euclideanValueMoments_pairing g hg hρS.le i j]
+ apply ht.congr'
+ exact Eventually.of_forall fun k =>
+ (localAffineMomentFamily_pairing μ hX.quadratic (u k) (w k) (v k)
+ (ball (p k) (ρ*r k)) (hX.finiteOnBounded _ isBounded_ball).ne (hrep' k) i j).symm
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineOperatorBound.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineOperatorBound.lean
new file mode 100644
index 0000000000000000000000000000000000000000..56d3c65a40187cdca5a10d71540933fea7ef20fa
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineOperatorBound.lean
@@ -0,0 +1,70 @@
+import OAI.Geometry.RCD.Sobolev.AffineCoefficientEnergy
+import OAI.Geometry.RCD.Harmonic.AffineEvaluation
+
+namespace OAI
+
+/-! # Recovering affine operator coefficients from actual local L2 errors -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- Exact half-ball normalization recovers the whole linear coefficient
+operator from its affine L2 errors, with one constant before all data. -/
+theorem LocalHarmonicL2GradientInput.affine_operator_bound
+ {K : ℝ} {n : ℕ} {hX : NoncollapsedRCD K n X}
+ (hinput : LocalHarmonicL2GradientInput hX) (hn : 2 ≤ n)
+ {κ : ℝ} (hκ : 0 ≤ κ) :
+ ∃ C : ℝ, 1 ≤ C ∧ ∀ (p : X) (R : ℝ), 0 < R → -κ ≤ K * R ^ 2 →
+ ∀ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ (N : Euclidean n ≃L[ℝ] Euclidean n),
+ IsExactMeanNormalization (hausdorff n X) hX.quadratic
+ (sobolevColumnMap (hausdorff n X) hX.quadratic u)
+ (ball p (R / 2)) measurableSet_ball N →
+ (∀ j, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball p R) (u j)) →
+ ∀ η : SobolevSpace (hausdorff n X) hX.quadratic,
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic η =ᵐ[
+ (hausdorff n X).restrict (ball p R)] fun _ => (1 : ℝ)) →
+ ∀ (A : Euclidean n →L[ℝ] Euclidean n) (c : Euclidean n →L[ℝ] ℝ) (d : ℝ), 0 ≤ d →
+ (∀ b, ‖normalizeLocalL2 (hausdorff n X) (ball p R)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic (ball p R)
+ (c b • η + sobolevColumnMap (hausdorff n X) hX.quadratic u (A b)))‖ ≤ d * ‖b‖) →
+ ‖N.symm.toContinuousLinearMap.comp A‖ ≤ C / R * d := by
+ obtain ⟨C, hC, hcoef⟩ := hinput.affine_coefficient hn hκ
+ refine ⟨C, hC, ?_⟩
+ intro p R hR hcurv u N hN hu η hη A c d hd hbound
+ let μ := hausdorff n X
+ let hQ := hX.quadratic
+ have hηharm := isSobolevHarmonicOn_of_local_constant μ hQ (ball p R) measurableSet_ball η 1 hη
+ apply ContinuousLinearMap.opNorm_le_bound _ (by positivity)
+ intro b
+ change ‖N.symm (A b)‖ ≤ C / R * d * ‖b‖
+ let w := c b • η + sobolevColumnMap μ hQ u (A b)
+ have hw : IsSobolevHarmonicOn μ hQ (ball p R) w :=
+ (hηharm.smul μ hQ (c b)).add μ hQ (IsSobolevHarmonicOn.linearCombination μ hQ hu (A b))
+ have hc : SobolevSpace.toLp μ hQ (w - sobolevColumnMap μ hQ u (A b))
+ =ᵐ[μ.restrict (ball p R)] fun _ => c b := by
+ change SobolevSpace.toLp μ hQ ((c b • η + sobolevColumnMap μ hQ u (A b)) -
+ sobolevColumnMap μ hQ u (A b)) =ᵐ[_] _
+ rw [add_sub_cancel_right, map_smul]
+ filter_upwards [hη, ae_restrict_of_ae (Lp.coeFn_smul (c b) (SobolevSpace.toLp μ hQ η))]
+ with x hx hs
+ rw [hs]
+ change c b * SobolevSpace.toLp μ hQ η x = c b
+ rw [show SobolevSpace.toLp μ hQ η x = 1 from hx, mul_one]
+ have hk := hcoef p R hR hcurv u N hN (A b) w (c b) hw hc
+ have hs := (sq_le_sq₀ (norm_nonneg _) (mul_nonneg hd (norm_nonneg b))).mpr (hbound b)
+ have hh := hk.trans (mul_le_mul_of_nonneg_left hs (sq_nonneg (C / R)))
+ apply (sq_le_sq₀ (norm_nonneg (N.symm (A b))) (by positivity : 0 ≤ C / R * d * ‖b‖)).mp
+ convert hh using 1; ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffinePathDerivative.lean b/lean/OAI/Geometry/RCD/Harmonic/AffinePathDerivative.lean
new file mode 100644
index 0000000000000000000000000000000000000000..56f17561e6258ecd4ff9eca6f17cc42297c835bb
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffinePathDerivative.lean
@@ -0,0 +1,33 @@
+import OAI.Geometry.RCD.Transport.OrthonormalHarmonicGeodesic
+
+namespace OAI
+
+/-! # The interior derivative of an affine coordinate path -/
+
+open Set Filter
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem affine_path_hasDerivAt {X : Type*} [MetricSpace X] {n : ℕ}
+ (γ : C(Time,X)) (v : X → Euclidean n)
+ (hv : ∀ t : Time, v (γ t)=(1-(t:ℝ)) • v (γ 0)+(t:ℝ) • v (γ 1))
+ {s : ℝ} (hs : s∈Ioo (0:ℝ) 1) :
+ HasDerivAt (fun r => v (geodesicExtension γ r)) (v (γ 1)-v (γ 0)) s := by
+ have hd : HasDerivAt (fun r : ℝ => v (γ 0)+r • (v (γ 1)-v (γ 0)))
+ (v (γ 1)-v (γ 0)) s := by
+ simpa only [one_smul,zero_add] using!
+ (hasDerivAt_const s (v (γ 0))).add ((hasDerivAt_id s).smul_const (v (γ 1)-v (γ 0)))
+ apply hd.congr_of_eventuallyEq
+ filter_upwards [Ioo_mem_nhds hs.1 hs.2] with t ht
+ have he := hv ⟨t,Ioo_subset_Icc_self ht⟩
+ rw [← geodesicExtension_eq γ ⟨t,Ioo_subset_Icc_self ht⟩] at he
+ change v (geodesicExtension γ t)=v (γ 0)+t • (v (γ 1)-v (γ 0))
+ rw [he]
+ module
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffinePathMeans.lean b/lean/OAI/Geometry/RCD/Harmonic/AffinePathMeans.lean
new file mode 100644
index 0000000000000000000000000000000000000000..efd7a4ce743cdc5ac221b42a38dba3df8e3821cc
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffinePathMeans.lean
@@ -0,0 +1,69 @@
+import OAI.Geometry.RCD.Sobolev.ContinuousAEEqOnTime
+import Mathlib.MeasureTheory.Function.AEEqOfIntegral
+import Mathlib.Analysis.Normed.Group.Bounded
+
+namespace OAI
+
+/-! # Affine means on every normalized subplan imply affine paths -/
+
+open Set Filter MeasureTheory
+open scoped Topology ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem affine_paths_of_normalized_means (π : Measure C(Time,X)) [IsProbabilityMeasure π]
+ (U : X → ℝ) (hU : Continuous U) (hUc : HasCompactSupport U)
+ (hmean : ∀ κ : Measure C(Time,X), κ ≤ π → κ univ ≠ 0 → ∀ t : Time,
+ (∫ γ, U (γ t) ∂((κ univ)⁻¹ • κ)) =
+ (1-(t:ℝ))*(∫ γ, U (γ 0) ∂((κ univ)⁻¹ • κ))+
+ (t:ℝ)*(∫ γ, U (γ 1) ∂((κ univ)⁻¹ • κ))) :
+ ∀ᵐ γ ∂π, ∀ t : Time, U (γ t)=(1-(t:ℝ))*U (γ 0)+(t:ℝ)*U (γ 1) := by
+ obtain ⟨M,hM⟩ := hUc.exists_bound_of_continuous hU
+ have hi (ν : Measure C(Time,X)) [IsFiniteMeasure ν] (t : Time) :
+ Integrable (fun γ => U (γ t)) ν :=
+ Integrable.of_bound (hU.measurable.comp (measurable_path_eval t)).aestronglyMeasurable M
+ (Eventually.of_forall fun γ => hM (γ t))
+ apply ae_eq_all_time_of_continuous π (fun γ t => U (γ t))
+ (fun γ t => (1-(t:ℝ))*U (γ 0)+(t:ℝ)*U (γ 1))
+ (Eventually.of_forall fun γ => hU.comp γ.continuous)
+ (Eventually.of_forall fun _ => by fun_prop)
+ intro t
+ let f := fun γ : C(Time,X) => U (γ t)-(1-(t:ℝ))*U (γ 0)-(t:ℝ)*U (γ 1)
+ have hif : Integrable f π := ((hi π t).sub ((hi π 0).const_mul _)).sub ((hi π 1).const_mul _)
+ have heq : f =ᵐ[π] 0 := by
+ apply hif.ae_eq_zero_of_forall_setIntegral_eq_zero
+ intro S hS _hSf
+ by_cases hz : π S=0
+ · rw [Measure.restrict_eq_zero.mpr hz]
+ simp
+ let κ := π.restrict S
+ have hk0 : κ univ ≠ 0 := by simpa only [κ,Measure.restrict_apply_univ] using hz
+ have hkt : κ univ ≠ ∞ := measure_ne_top κ univ
+ have ha : (κ univ)⁻¹ ≠ ∞ := ENNReal.inv_ne_top.mpr hk0
+ have ha0 : ((κ univ)⁻¹).toReal ≠ 0 := ENNReal.toReal_ne_zero.mpr
+ ⟨ENNReal.inv_ne_zero.mpr hkt,ha⟩
+ have hh := hmean κ Measure.restrict_le_self hk0 t
+ have hin (s : Time) : Integrable (fun γ => U (γ s)) ((κ univ)⁻¹ • κ) :=
+ (hi κ s).smul_measure ha
+ have hfzero : (∫ γ, f γ ∂((κ univ)⁻¹ • κ))=0 := by
+ change (∫ γ, U (γ t)-(1-(t:ℝ))*U (γ 0)-(t:ℝ)*U (γ 1) ∂((κ univ)⁻¹ • κ))=0
+ rw [integral_sub (f := fun γ : C(Time,X) => U (γ t)-(1-(t:ℝ))*U (γ 0))
+ (g := fun γ : C(Time,X) => (t:ℝ)*U (γ 1))
+ ((hin t).sub ((hin 0).const_mul (1-(t:ℝ)))) ((hin 1).const_mul (t:ℝ)),
+ integral_sub (f := fun γ : C(Time,X) => U (γ t))
+ (g := fun γ : C(Time,X) => (1-(t:ℝ))*U (γ 0))
+ (hin t) ((hin 0).const_mul (1-(t:ℝ))),integral_const_mul,integral_const_mul]
+ linarith only [hh]
+ rw [integral_smul_measure,smul_eq_mul] at hfzero
+ exact (mul_eq_zero.mp hfzero).resolve_left ha0
+ filter_upwards [heq] with γ hγ
+ change U (γ t)-(1-(t:ℝ))*U (γ 0)-(t:ℝ)*U (γ 1)=0 at hγ
+ linarith only [hγ]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineProjection.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineProjection.lean
new file mode 100644
index 0000000000000000000000000000000000000000..6abfca44ea213e27c794237ca6601daf03062adf
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineProjection.lean
@@ -0,0 +1,150 @@
+import OAI.Geometry.RCD.Harmonic.HarmonicGrams
+
+namespace OAI
+
+/-! # The actual `L²` projection onto the affine coordinate span -/
+
+open Set MeasureTheory
+open scoped InnerProductSpace ENNReal
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ {n : ℕ} (u : Fin n → SobolevSpace μ hQ) (s : Set X) (hfin : μ s ≠ ∞)
+
+def restrictedOne : Lp ℝ 2 (μ.restrict s) :=
+ indicatorConstLp 2 MeasurableSet.univ (by simpa using hfin) 1
+
+/-- Constants and linear combinations of the given coordinates, restricted
+as actual `L²` functions on the testing set. -/
+def affineCoordinateMap : (ℝ × Euclidean n) →L[ℝ] Lp ℝ 2 (μ.restrict s) :=
+ (ContinuousLinearMap.fst ℝ ℝ (Euclidean n)).smulRight (restrictedOne μ s hfin) +
+ (SobolevSpace.restrictLp μ hQ s).comp
+ ((sobolevColumnMap μ hQ u).comp (ContinuousLinearMap.snd ℝ ℝ (Euclidean n)))
+
+theorem affineCoordinateMap_apply (c : ℝ) (v : Euclidean n) :
+ affineCoordinateMap μ hQ u s hfin (c, v) =
+ c • restrictedOne μ s hfin +
+ SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u v) := rfl
+
+def affineCoordinateSpace : Submodule ℝ (Lp ℝ 2 (μ.restrict s)) :=
+ (affineCoordinateMap μ hQ u s hfin).range
+
+instance affineCoordinateSpace_finiteDimensional :
+ FiniteDimensional ℝ (affineCoordinateSpace μ hQ u s hfin) :=
+ LinearMap.finiteDimensional_range _
+
+/-- The least-squares affine fit exists without assuming independence of
+its generators. Coefficient uniqueness can be added after normalization. -/
+def affineProjection : Lp ℝ 2 (μ.restrict s) →L[ℝ] Lp ℝ 2 (μ.restrict s) :=
+ (affineCoordinateSpace μ hQ u s hfin).starProjection
+
+theorem affineProjection_has_coefficients (f : Lp ℝ 2 (μ.restrict s)) :
+ ∃ c : ℝ, ∃ v : Euclidean n,
+ affineProjection μ hQ u s hfin f = c • restrictedOne μ s hfin +
+ SobolevSpace.restrictLp μ hQ s (sobolevColumnMap μ hQ u v) := by
+ have hm := (affineCoordinateSpace μ hQ u s hfin).starProjection_apply_mem f
+ rcases hm with ⟨⟨c, v⟩, hcv⟩
+ exact ⟨c, v, hcv.symm⟩
+
+theorem affineProjection_orthogonal (f : Lp ℝ 2 (μ.restrict s))
+ (c : ℝ) (v : Euclidean n) :
+ ⟪f - affineProjection μ hQ u s hfin f,
+ affineCoordinateMap μ hQ u s hfin (c, v)⟫_ℝ = 0 :=
+ (affineCoordinateSpace μ hQ u s hfin).starProjection_inner_eq_zero f _ ⟨(c, v), rfl⟩
+
+/-- The affine fit minimizes the `L²` error among all coordinate-affine
+functions, with the unnormalized integral convention. -/
+theorem affineProjection_best (f : Lp ℝ 2 (μ.restrict s))
+ (c : ℝ) (v : Euclidean n) :
+ ‖f - affineProjection μ hQ u s hfin f‖ ≤
+ ‖f - affineCoordinateMap μ hQ u s hfin (c, v)‖ := by
+ let K := affineCoordinateSpace μ hQ u s hfin
+ let P := affineProjection μ hQ u s hfin
+ let g := affineCoordinateMap μ hQ u s hfin (c, v)
+ have hm : P f - g ∈ K := K.sub_mem (K.starProjection_apply_mem f) ⟨(c, v), rfl⟩
+ have ho : ⟪f - P f, P f - g⟫_ℝ = 0 := K.starProjection_inner_eq_zero f _ hm
+ have he := norm_add_sq_real (f - P f) (P f - g)
+ have hs : f - P f + (P f - g) = f - g := by abel
+ rw [hs, ho] at he
+ change ‖f - P f‖ ≤ ‖f - g‖
+ exact (sq_le_sq₀ (norm_nonneg _) (norm_nonneg _)).mp (by nlinarith [sq_nonneg ‖P f - g‖])
+
+/-- The residual is a bounded linear map, so all scalar directional fits
+can be assembled linearly before taking their matrix coefficients. -/
+def affineResidual : Lp ℝ 2 (μ.restrict s) →L[ℝ] Lp ℝ 2 (μ.restrict s) :=
+ ContinuousLinearMap.id ℝ _ - affineProjection μ hQ u s hfin
+
+theorem affineResidual_norm_le (f : Lp ℝ 2 (μ.restrict s)) :
+ ‖affineResidual μ hQ u s hfin f‖ ≤ ‖f‖ := by
+ have hb := affineProjection_best μ hQ u s hfin f 0 0
+ change ‖f - affineProjection μ hQ u s hfin f‖ ≤
+ ‖f - affineCoordinateMap μ hQ u s hfin 0‖ at hb
+ simpa only [map_zero, sub_zero, affineResidual, sub_apply,
+ ContinuousLinearMap.id_apply] using hb
+
+theorem affineProjection_norm_le (f : Lp ℝ 2 (μ.restrict s)) :
+ ‖affineProjection μ hQ u s hfin f‖ ≤ ‖f‖ :=
+ (affineCoordinateSpace μ hQ u s hfin).norm_starProjection_apply_le f
+
+/-- Orthogonality to constants is the vanishing of the actual integral,
+including when the original ambient measure is infinite. -/
+theorem affineResidual_integral (f : Lp ℝ 2 (μ.restrict s)) :
+ ∫ x, affineResidual μ hQ u s hfin f x ∂μ.restrict s = 0 := by
+ have ho := affineProjection_orthogonal μ hQ u s hfin f 1 0
+ have hi := L2.inner_indicatorConstLp_one
+ (μ := μ.restrict s) MeasurableSet.univ (by simpa using hfin)
+ (affineResidual μ hQ u s hfin f)
+ have ho' : ⟪affineResidual μ hQ u s hfin f, restrictedOne μ s hfin⟫_ℝ = 0 := by
+ simpa only [affineCoordinateMap_apply, map_zero, one_smul, add_zero,
+ affineResidual, sub_apply, ContinuousLinearMap.id_apply] using ho
+ have hi' : ⟪restrictedOne μ s hfin, affineResidual μ hQ u s hfin f⟫_ℝ =
+ ∫ x, affineResidual μ hQ u s hfin f x ∂μ.restrict s := by
+ simpa [restrictedOne] using hi
+ rw [← hi', real_inner_comm]
+ exact ho'
+
+/-- The residual is orthogonal to each original coordinate in `L²`. -/
+theorem affineResidual_coordinate_inner (f : Lp ℝ 2 (μ.restrict s)) (i : Fin n) :
+ ⟪affineResidual μ hQ u s hfin f,
+ SobolevSpace.restrictLp μ hQ s (u i)⟫_ℝ = 0 := by
+ have ho := affineProjection_orthogonal μ hQ u s hfin f 0
+ (EuclideanSpace.single i 1)
+ simpa only [affineCoordinateMap_apply, zero_smul, zero_add,
+ sobolevColumnMap_single, affineResidual, sub_apply,
+ ContinuousLinearMap.id_apply] using ho
+
+/-- Uniform nondegeneracy of the value coordinates gives uniform bounds
+for the coefficients of their least-squares fit. -/
+theorem affineProjection_controlled_coefficients (f : Lp ℝ 2 (μ.restrict s))
+ {C : ℝ} (hC : 0 ≤ C)
+ (hbound : ∀ c v, |c| + ‖v‖ ≤ C * ‖affineCoordinateMap μ hQ u s hfin (c, v)‖) :
+ ∃ c : ℝ, ∃ v : Euclidean n,
+ affineProjection μ hQ u s hfin f = affineCoordinateMap μ hQ u s hfin (c, v) ∧
+ |c| + ‖v‖ ≤ C * ‖f‖ := by
+ obtain ⟨c, v, hcv⟩ := affineProjection_has_coefficients μ hQ u s hfin f
+ change affineProjection μ hQ u s hfin f =
+ affineCoordinateMap μ hQ u s hfin (c, v) at hcv
+ refine ⟨c, v, hcv, ?_⟩
+ have hb := hbound c v
+ rw [← hcv] at hb
+ exact hb.trans (mul_le_mul_of_nonneg_left
+ (affineProjection_norm_le μ hQ u s hfin f) hC)
+
+/-- Vanishing of an affine residual follows from affinity itself. This is
+the final contradiction after Euclidean Euler rigidity in sharp projection. -/
+theorem affineResidual_eq_zero_of_mem (f : Lp ℝ 2 (μ.restrict s))
+ (hf : f ∈ affineCoordinateSpace μ hQ u s hfin) :
+ affineResidual μ hQ u s hfin f = 0 := by
+ have he := (affineCoordinateSpace μ hQ u s hfin).starProjection_eq_self_iff.mpr hf
+ change f - affineProjection μ hQ u s hfin f = 0
+ exact sub_eq_zero.mpr he.symm
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineScaleChoice.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineScaleChoice.lean
new file mode 100644
index 0000000000000000000000000000000000000000..9466d1b4d3c3d8bb385e6df56d8909a4d9813b24
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineScaleChoice.lean
@@ -0,0 +1,42 @@
+import Mathlib.Analysis.SpecialFunctions.Pow.Real
+import Mathlib.Topology.Algebra.InfiniteSum.Real
+import Mathlib.Tactic
+
+namespace OAI
+
+/-! # One dyadic scale for the Euclidean affine improvement -/
+
+open Filter
+open scoped Topology
+
+namespace RegularPointCoordinates
+
+/-- A quadratic Taylor error is strictly smaller than the required
+three-halves decay at one fixed dyadic scale, independent of the function. -/
+theorem exists_dyadic_affine_contraction (C : ℝ) :
+ ∃ m : ℕ, 3 ≤ m ∧
+ C * ((1 / 2 : ℝ) ^ m) ^ 2 <
+ (1 / 4 : ℝ) * (1 / 2 : ℝ) ^ m * Real.sqrt ((1 / 2 : ℝ) ^ m) := by
+ have ht : Tendsto (fun m : ℕ => (1 / 2 : ℝ) ^ m) atTop (𝓝 0) :=
+ tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num) (by norm_num)
+ have hs : Tendsto (fun m : ℕ => C * Real.sqrt ((1 / 2 : ℝ) ^ m)) atTop (𝓝 0) := by
+ simpa only [Function.comp_apply, Real.sqrt_zero, mul_zero] using
+ tendsto_const_nhds.mul (Real.continuous_sqrt.tendsto 0 |>.comp ht)
+ obtain ⟨m, hm, hmC⟩ := ((eventually_ge_atTop 3).and
+ (hs.eventually (gt_mem_nhds (by norm_num : (0 : ℝ) < 1 / 4)))).exists
+ refine ⟨m, hm, ?_⟩
+ have hp : 0 < (1 / 2 : ℝ) ^ m := pow_pos (by norm_num) _
+ have hroot : 0 < Real.sqrt ((1 / 2 : ℝ) ^ m) := Real.sqrt_pos.2 hp
+ have hsq := Real.sq_sqrt hp.le
+ have hh := mul_lt_mul_of_pos_right hmC (mul_pos hp hroot)
+ calc
+ _ = C * (1 / 2 : ℝ) ^ m * (Real.sqrt ((1 / 2 : ℝ) ^ m)) ^ 2 := by
+ rw [hsq]
+ ring
+ _ = (C * Real.sqrt ((1 / 2 : ℝ) ^ m)) *
+ ((1 / 2 : ℝ) ^ m * Real.sqrt ((1 / 2 : ℝ) ^ m)) := by ring
+ _ < _ := by simpa only [mul_assoc] using hh
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineSpatialSelection.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineSpatialSelection.lean
new file mode 100644
index 0000000000000000000000000000000000000000..cb35216d9f79cfaf706776280684c32b56e9988c
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineSpatialSelection.lean
@@ -0,0 +1,49 @@
+import OAI.Geometry.RCD.Transport.FirstOrderNearbyPlanErrors
+
+namespace OAI
+
+/-! # Selecting paths with small uniform affine error and small spatial cost -/
+
+open Set Filter MeasureTheory Metric
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+omit [MeasurableSpace X] [BorelSpace X] in
+theorem affine_spatial_selection {n : ℕ} (π : ℕ → Measure C(Time,X))
+ [∀ k, IsProbabilityMeasure (π k)]
+ (F : ℕ → Fin n → C(Time,X) → C(Time,ℝ)) (E : ℕ → X → ℝ)
+ (hE : ∀ k z, 0 ≤ E k z)
+ (hI : ∀ k, Integrable (affineSpatialPathCost (F k) (E k)) (π k))
+ (hlim : Tendsto (fun k => ∫ γ, affineSpatialPathCost (F k) (E k) γ ∂π k) atTop (𝓝 0))
+ (P : ℕ → C(Time,X) → Prop) (hP : ∀ k, ∀ᵐ γ ∂π k, P k γ) :
+ ∃ (γ : ℕ → C(Time,X)) (a : ℕ → ℝ),
+ (∀ k, P k (γ k)) ∧ (∀ k, 0 ≤ a k) ∧ Tendsto a atTop (𝓝 0) ∧
+ (∀ k i (t : Time), |F k i (γ k) t| ≤ a k) ∧
+ (∀ k, (∫ t in Icc (0:ℝ) 1, E k (geodesicExtension (γ k) t)) ≤ a k) := by
+ classical
+ let a k := ∫ γ, affineSpatialPathCost (F k) (E k) γ ∂π k
+ have hpos (k : ℕ) (γ : C(Time,X)) : 0 ≤ affineSpatialPathCost (F k) (E k) γ :=
+ add_nonneg (Finset.sum_nonneg (fun _ _ => norm_nonneg _)) (integral_nonneg (fun _ => hE k _))
+ have hex (k : ℕ) : ∃ γ, P k γ ∧ affineSpatialPathCost (F k) (E k) γ ≤ a k := by
+ obtain ⟨γ,hγ,hb⟩ := exists_notMem_null_le_integral (hI k) (ae_iff.mp (hP k))
+ exact ⟨γ,of_not_not hγ,hb⟩
+ choose γ hgood hbound using hex
+ refine ⟨γ,a,hgood,fun k => integral_nonneg (hpos k),hlim,?_,?_⟩
+ · intro k i t
+ have hi : ‖F k i (γ k)‖ ≤ ∑ j, ‖F k j (γ k)‖ :=
+ Finset.single_le_sum (fun j _ => norm_nonneg (F k j (γ k))) (Finset.mem_univ i)
+ have ht : |F k i (γ k) t| ≤ ‖F k i (γ k)‖ := (F k i (γ k)).norm_coe_le_norm t
+ have he : 0 ≤ ∫ s in Icc (0:ℝ) 1, E k (geodesicExtension (γ k) s) :=
+ integral_nonneg (fun _ => hE k _)
+ exact (ht.trans hi).trans (le_trans (le_add_of_nonneg_right he) (hbound k))
+ · intro k
+ exact (le_add_of_nonneg_left (Finset.sum_nonneg (fun _ _ => norm_nonneg _))).trans (hbound k)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineValuePairings.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineValuePairings.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ae23ebad29d6a02df02f1dd733c47b59fb0dc1be
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineValuePairings.lean
@@ -0,0 +1,102 @@
+import OAI.Geometry.RCD.Metric.InnerBallValueMoments
+import OAI.Geometry.RCD.Coordinates.NormalizedPairing
+import OAI.Geometry.RCD.Harmonic.LocalL2Restriction
+import OAI.Geometry.RCD.Harmonic.EuclideanHarmonicModel
+
+namespace OAI
+
+/-! # Exact value representatives for all affine-family Hilbert pairings -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal InnerProductSpace
+noncomputable section
+namespace RegularPointCoordinates
+
+/-- The target, constant and coordinate values in the same order as the Hilbert family. -/
+def affineValueFamily {X : Type*} {n : ℕ} (w : X → ℝ) (V : X → Euclidean n) :
+ Option (Option (Fin n)) → X → ℝ :=
+ affineMomentFamily n w (fun _ => 1) (fun j x => V x j)
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+
+private theorem affineValueFamily_representatives (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ {n : ℕ} (u : Fin n → SobolevSpace μ hQ) (w : SobolevSpace μ hQ)
+ (V : X → Euclidean n) (s : Set X) (hfin : μ s≠⊤)
+ (hV : ∀ j, SobolevSpace.toLp μ hQ (u j)=ᵐ[μ.restrict s] fun x => V x j) :
+ ∀ i, affineMomentFamily n (SobolevSpace.restrictLp μ hQ s w)
+ (restrictedOne μ s hfin) (fun j => SobolevSpace.restrictLp μ hQ s (u j)) i =ᵐ[μ.restrict s]
+ affineValueFamily (SobolevSpace.toLp μ hQ w) V i := by
+ intro i
+ rcases i with _ | (_ | j)
+ · exact SobolevSpace.restrictLp_coe μ hQ s w
+ · exact restrictedOne_coe μ s hfin
+ · exact (SobolevSpace.restrictLp_coe μ hQ s (u j)).trans (hV j)
+
+theorem affineValueFamily_memLp (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ {n : ℕ} (u : Fin n → SobolevSpace μ hQ) (w : SobolevSpace μ hQ)
+ (V : X → Euclidean n) (s : Set X) (hfin : μ s≠⊤)
+ (hV : ∀ j, SobolevSpace.toLp μ hQ (u j)=ᵐ[μ.restrict s] fun x => V x j) (i) :
+ MemLp (affineValueFamily (SobolevSpace.toLp μ hQ w) V i) 2 (μ.restrict s) :=
+ (memLp_congr_ae (affineValueFamily_representatives μ hQ u w V s hfin hV i)).mp (Lp.memLp _)
+
+theorem localAffineMomentFamily_pairing (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ {n : ℕ} (u : Fin n → SobolevSpace μ hQ) (w : SobolevSpace μ hQ)
+ (V : X → Euclidean n) (s : Set X) (hfin : μ s≠⊤)
+ (hV : ∀ j, SobolevSpace.toLp μ hQ (u j)=ᵐ[μ.restrict s] fun x => V x j) (i j) :
+ ⟪localAffineMomentFamily μ hQ u w s hfin i,localAffineMomentFamily μ hQ u w s hfin j⟫_ℝ=
+ (μ.real s)⁻¹*∫ x in s,
+ affineValueFamily (SobolevSpace.toLp μ hQ w) V i x*
+ affineValueFamily (SobolevSpace.toLp μ hQ w) V j x ∂μ := by
+ let U := affineMomentFamily n (SobolevSpace.restrictLp μ hQ s w)
+ (restrictedOne μ s hfin) (fun j => SobolevSpace.restrictLp μ hQ s (u j))
+ have he (a) : normalizeLocalL2 μ s hfin (U a)=localAffineMomentFamily μ hQ u w s hfin a := by
+ rcases a with _ | (_ | j) <;> rfl
+ rw [← he i,← he j]
+ exact normalized_inner_of_representatives μ s hfin (U i) (U j) _ _
+ (affineValueFamily_representatives μ hQ u w V s hfin hV i)
+ (affineValueFamily_representatives μ hQ u w V s hfin hV j)
+
+/-- The affine moment family is already meaningful before harmonicity of the limit is identified. -/
+def euclideanValueMoments {n : ℕ} {S : ℝ} (g : Euclidean n → ℝ)
+ (hg : MemLp g 2 (volume.restrict (ball 0 S))) {ρ : ℝ} (hρS : ρ≤S) :
+ Option (Option (Fin n)) → Lp ℝ 2 (volume.restrict (ball (0:Euclidean n) ρ)) :=
+ affineMomentFamily n
+ (normalizeLocalL2 volume (ball 0 ρ) measure_ball_ne_top
+ ((hg.mono_measure (Measure.restrict_mono_set volume (ball_subset_ball hρS))).toLp g))
+ (normalizeLocalL2 volume (ball 0 ρ) measure_ball_ne_top
+ (restrictedOne volume (ball 0 ρ) measure_ball_ne_top))
+ (fun j => normalizeLocalL2 volume (ball 0 ρ) measure_ball_ne_top (euclideanCoordinateLp n ρ j))
+
+theorem euclideanValueMoments_pairing {n : ℕ} {S ρ : ℝ}
+ (g : Euclidean n → ℝ) (hg : MemLp g 2 (volume.restrict (ball 0 S)))
+ (hρS : ρ≤S) (i j) :
+ ⟪euclideanValueMoments g hg hρS i,euclideanValueMoments g hg hρS j⟫_ℝ=
+ (volume.real (ball (0:Euclidean n) ρ))⁻¹*
+ ∫ z in ball 0 ρ, affineValueFamily g id i z*affineValueFamily g id j z := by
+ let gLp := (hg.mono_measure (Measure.restrict_mono_set volume (ball_subset_ball hρS))).toLp g
+ let U := affineMomentFamily n gLp
+ (restrictedOne volume (ball 0 ρ) measure_ball_ne_top) (euclideanCoordinateLp n ρ)
+ have he (a) : normalizeLocalL2 volume (ball 0 ρ) measure_ball_ne_top (U a)=
+ euclideanValueMoments g hg hρS a := by
+ rcases a with _ | (_ | j) <;> rfl
+ have hU (a) : U a=ᵐ[volume.restrict (ball 0 ρ)] affineValueFamily g id a := by
+ rcases a with _ | (_ | j)
+ · exact (hg.mono_measure (Measure.restrict_mono_set volume (ball_subset_ball hρS))).coeFn_toLp
+ · exact restrictedOne_coe volume (ball 0 ρ) measure_ball_ne_top
+ · exact euclideanCoordinateLp_coe n ρ j
+ rw [← he i,← he j]
+ exact normalized_inner_of_representatives volume (ball 0 ρ) measure_ball_ne_top
+ (U i) (U j) _ _ (hU i) (hU j)
+
+theorem EuclideanHarmonicModel.moments_pairing {n : ℕ} {S ρ : ℝ}
+ (model : EuclideanHarmonicModel n S) (hρS : ρ≤S) (i j) :
+ ⟪model.moments hρS i,model.moments hρS j⟫_ℝ=
+ (volume.real (ball (0:Euclidean n) ρ))⁻¹*
+ ∫ z in ball 0 ρ, affineValueFamily model.value id i z*affineValueFamily model.value id j z :=
+ euclideanValueMoments_pairing model.value model.memLp hρS i j
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AffineVariationSelection.lean b/lean/OAI/Geometry/RCD/Harmonic/AffineVariationSelection.lean
new file mode 100644
index 0000000000000000000000000000000000000000..a1bc352ba1defe0221c02d5bac2a02eb0e0a3d5d
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AffineVariationSelection.lean
@@ -0,0 +1,101 @@
+import OAI.Geometry.RCD.Coordinates.VanishingRadiusCost
+import Mathlib.MeasureTheory.Integral.Average
+
+namespace OAI
+
+/-! # Joint selection of a small affine error and controlled coefficient variation -/
+
+open Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+
+private theorem affine_variation_product_bound {a v δ c : ℝ}
+ (hv : 0≤v) (hδ : 0≤δ) (hδ1 : δ≤1) (ha : a≤δ*c) (hb : δ*v^2≤c) :
+ a*v≤(c^2+c)/2 := by
+ have h₁ : 2*(a*v)≤2*(δ*c*v) := by nlinarith [mul_le_mul_of_nonneg_right ha hv]
+ have h₂ : 2*(δ*c*v)≤δ*c^2+δ*v^2 := by nlinarith [mul_nonneg hδ (sq_nonneg (c-v))]
+ have h₃ : δ*c^2≤c^2 := mul_le_of_le_one_left (sq_nonneg c) hδ1
+ linarith
+
+theorem affine_variation_selection {Y : Type*} [MeasurableSpace Y]
+ (μ : ℕ → Measure Y) [∀ k, IsProbabilityMeasure (μ k)]
+ (A B E : ℕ → Y → ℝ) (P : ℕ → Y → Prop)
+ (hA : ∀ k, Integrable (A k) (μ k)) (hB : ∀ k, Integrable (B k) (μ k))
+ (hE : ∀ k, Integrable (E k) (μ k))
+ (hA0 : ∀ k y, 0≤A k y) (hB0 : ∀ k y, 0≤B k y) (hE0 : ∀ k y, 0≤E k y)
+ (hP : ∀ k, ∀ᵐ y ∂μ k, P k y)
+ (hAlim : Tendsto (fun k => ∫ y, A k y ∂μ k) atTop (𝓝 0))
+ (hElim : Tendsto (fun k => ∫ y, E k y ∂μ k) atTop (𝓝 0))
+ {M : ℝ} (hM : ∀ k, (∫ y, B k y ∂μ k)≤M) :
+ ∃ y : ℕ → Y, (∀ k, P k (y k)) ∧
+ Tendsto (fun k => A k (y k)) atTop (𝓝 0) ∧
+ Tendsto (fun k => E k (y k)) atTop (𝓝 0) ∧
+ Tendsto (fun k => A k (y k)*Real.sqrt (B k (y k))) atTop (𝓝 0) := by
+ obtain ⟨δ,hδ,hδ0,hδA⟩ := exists_vanishing_radius_cost
+ (fun k => ∫ y, A k y ∂μ k) (fun k => integral_nonneg (hA0 k)) hAlim 1
+ simp only [pow_one] at hδA
+ have hδB : Tendsto (fun k => δ k*(∫ y, B k y ∂μ k)) atTop (𝓝 0) := by
+ apply squeeze_zero (fun k => mul_nonneg (hδ k).1.le (integral_nonneg (hB0 k)))
+ (fun k => mul_le_mul_of_nonneg_left (hM k) (hδ k).1.le)
+ simpa only [zero_mul] using hδ0.mul_const M
+ let F k y := A k y/δ k+δ k*B k y+E k y
+ have hFI (k : ℕ) : Integrable (F k) (μ k) :=
+ (((hA k).div_const (δ k)).add ((hB k).const_mul (δ k))).add (hE k)
+ have hF0 (k : ℕ) (y : Y) : 0≤F k y :=
+ add_nonneg (add_nonneg (div_nonneg (hA0 k y) (hδ k).1.le)
+ (mul_nonneg (hδ k).1.le (hB0 k y))) (hE0 k y)
+ let c k := ∫ y, F k y ∂μ k
+ have hc0 (k : ℕ) : 0≤c k := integral_nonneg (hF0 k)
+ have hclim : Tendsto c atTop (𝓝 0) := by
+ have hh := (hδA.add hδB).add hElim
+ simp only [add_zero] at hh
+ apply hh.congr'
+ filter_upwards [] with k
+ dsimp only [c,F]
+ symm
+ calc
+ _ = (∫ y, A k y/δ k+δ k*B k y ∂μ k)+(∫ y, E k y ∂μ k) := by
+ simpa only [Pi.add_apply] using
+ integral_add (((hA k).div_const (δ k)).add ((hB k).const_mul (δ k))) (hE k)
+ _ = _ := by
+ congr 1
+ calc
+ _ = (∫ y, A k y/δ k ∂μ k)+(∫ y, δ k*B k y ∂μ k) := by
+ simpa only [Pi.add_apply] using integral_add ((hA k).div_const (δ k)) ((hB k).const_mul (δ k))
+ _ = _ := by rw [integral_div,integral_const_mul]
+ have hex (k : ℕ) : ∃ y, P k y ∧ F k y≤c k := by
+ obtain ⟨y,hy,hb⟩ := exists_notMem_null_le_integral (hFI k) (ae_iff.mp (hP k))
+ exact ⟨y,of_not_not hy,hb⟩
+ choose y hPy hy using hex
+ have hAy (k : ℕ) : A k (y k)≤δ k*c k := by
+ rw [mul_comm (δ k)]
+ apply (div_le_iff₀ (hδ k).1).mp
+ have hh := hy k
+ dsimp only [F] at hh
+ nlinarith [mul_nonneg (hδ k).1.le (hB0 k (y k)),hE0 k (y k)]
+ have hBy (k : ℕ) : δ k*B k (y k)≤c k := by
+ have hh := hy k
+ dsimp only [F] at hh
+ linarith [div_nonneg (hA0 k (y k)) (hδ k).1.le,hE0 k (y k)]
+ have hEy (k : ℕ) : E k (y k)≤c k := by
+ have hh := hy k
+ dsimp only [F] at hh
+ linarith [div_nonneg (hA0 k (y k)) (hδ k).1.le,mul_nonneg (hδ k).1.le (hB0 k (y k))]
+ refine ⟨y,hPy,?_,squeeze_zero (fun k => hE0 k (y k)) hEy hclim,?_⟩
+ · apply squeeze_zero (fun k => hA0 k (y k)) (fun k => (hAy k).trans ?_) hclim
+ exact mul_le_of_le_one_left (hc0 k) (by linarith [(hδ k).2])
+ · apply squeeze_zero (fun k => mul_nonneg (hA0 k (y k)) (Real.sqrt_nonneg _))
+ (g := fun k => ((c k)^2+c k)/2)
+ · intro k
+ apply affine_variation_product_bound (Real.sqrt_nonneg _) (hδ k).1.le
+ (by linarith [(hδ k).2]) (hAy k)
+ simpa only [Real.sq_sqrt (hB0 k (y k))] using hBy k
+ · simpa only [zero_pow (by decide : (2:ℕ)≠0),add_zero,zero_div] using
+ ((hclim.pow 2).add hclim).div_const 2
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/AnnularHarmonicReplacement.lean b/lean/OAI/Geometry/RCD/Harmonic/AnnularHarmonicReplacement.lean
new file mode 100644
index 0000000000000000000000000000000000000000..cbf53aacdc3a64b9a74d65a772b2d4acb22a0cc2
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/AnnularHarmonicReplacement.lean
@@ -0,0 +1,41 @@
+import OAI.Geometry.RCD.Sobolev.HarmonicReplacementEnergy
+import OAI.Geometry.RCD.Sobolev.UniformAnnularCoercivity
+
+namespace OAI
+
+/-! # Uniform normalized bounds for constructed harmonic replacements -/
+
+open Set Metric MeasureTheory
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.annular_harmonic_replacement {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2≤n) :
+ ∃ P : ℝ, 0 M⁻¹ • w k
+ have hvnorm (k : ℕ) : harmonicTargetNorm hX (p k) (S*r k) (v k)≤1 := by
+ rw [harmonicTargetNorm_smul,abs_of_pos (inv_pos.mpr hM)]
+ exact (mul_le_mul_of_nonneg_left (hnorm k) (inv_pos.mpr hM).le).trans_eq
+ (inv_mul_cancel₀ hM.ne')
+ have hvh (k : ℕ) := (hw k).smul (hausdorff n X) hX.quadratic M⁻¹
+ obtain ⟨g,a,ha,hgm,hgc,hgL,hconv,_⟩ := hX.open_ball_harmonic_test_compactness hn hS
+ p r ε hr hcurv hε hε1 hεlim V hV v hvh hvnorm
+ have hconv' : ∀ W : ℝ, 0 r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (S*r k), (euclideanNestedCutoff n hab (V k x))^2*
+ localGamma (hausdorff n X) hX.quadratic (q k) (q k) x ∂hausdorff n X)
+ atTop (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*
+ ∫ z in ball 0 S, (euclideanNestedCutoff n hab z)^2*‖fderiv ℝ F z‖^2))) :
+ Tendsto (fun k => r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (R*r k), (nestedBallCutoff (p k) (a*r k) (b*r k) x)^2*
+ localGamma (hausdorff n X) hX.quadratic (w k-q k) (w k-q k) x ∂hausdorff n X)
+ atTop (𝓝 0) := by
+ obtain ⟨B,hB,hwb⟩ := hX.bounded_harmonic_scaled_energy_bound hn hS
+ (ha.le.trans (hab.le.trans (hbR.le.trans hRT.le))) hTS hM p r hr hcurv w hw hnorm
+ exact hX.harmonic_recovery_strong_of_gradient_bound hn hS ha hab hbR hRT hTS
+ p r ε V hr hcurv hε hε1 hεlim hV w q hw hB hwb g F hg heq hd hconv hqconv hqg hq
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/BoundedHarmonicStrongRecovery.lean b/lean/OAI/Geometry/RCD/Harmonic/BoundedHarmonicStrongRecovery.lean
new file mode 100644
index 0000000000000000000000000000000000000000..021e57e11c33fc85f91de8bf9341162cf2b83b01
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/BoundedHarmonicStrongRecovery.lean
@@ -0,0 +1,88 @@
+import OAI.Geometry.RCD.Harmonic.BoundedHarmonicRecoveryStrong
+import OAI.Geometry.RCD.Harmonic.SmoothHarmonicModelCompactness
+import OAI.Geometry.RCD.Metric.EuclideanInteriorSmoothExtension
+import OAI.Geometry.RCD.Sobolev.SharpWeightedTestRecovery
+import OAI.Geometry.RCD.Sobolev.SmoothRecoveryGradientBound
+
+namespace OAI
+
+/-! # Constructed strong recoveries at the actual coordinate normalization -/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology NNReal BoundedContinuousFunction ContDiff
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.bounded_harmonic_strong_recovery {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2≤n)
+ {S a b R T M : ℝ} (hS : 0 r (k+N)^2*((hausdorff n X).real (ball (p (k+N)) (S*r (k+N))))⁻¹*
+ ∫ x in ball (p (k+N)) (S*r (k+N)), φ (V (k+N) x)*localGamma (hausdorff n X) hX.quadratic
+ (q k).val (q k).val x ∂hausdorff n X) atTop
+ (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*
+ ∫ z in ball 0 S, φ z*‖fderiv ℝ F z‖^2))) ∧
+ Tendsto (fun k => r (k+N)^2*((hausdorff n X).real (ball (p (k+N)) (S*r (k+N))))⁻¹*
+ ∫ x in ball (p (k+N)) (R*r (k+N)),
+ (nestedBallCutoff (p (k+N)) (a*r (k+N)) (b*r (k+N)) x)^2*
+ localGamma (hausdorff n X) hX.quadratic (w (k+N)-(q k).val) (w (k+N)-(q k).val) x
+ ∂hausdorff n X) atTop (𝓝 0) := by
+ obtain ⟨F,hF,heq,hd⟩ := exists_interior_smooth_extension
+ (ha.trans (hab.trans (hbR.trans hRT))) hTS hg
+ obtain ⟨c,hc,hcS,N,q,hqv,hqg,hqz,hqe⟩ :=
+ hX.sharp_weighted_test_recovery hn hS p r ε V hr hcurv hε hε1 hεlim hV hF
+ obtain ⟨Q,hQ,hQb⟩ := compact_recovery_scaled_gradient_bound (hausdorff n X) hX.quadratic
+ (hF.1.of_le (by simp)) hF.2.1 (fun k => p (k+N)) (fun k => r (k+N))
+ (fun k => hr (k+N)) (fun k => V (k+N)) (fun k => (q k).val) hqz (hqg c hc.le hcS)
+ refine ⟨F,hF,heq,hd,N,q,hqv,hqg,⟨Q,hQ,hQb⟩,hqe,?_⟩
+ apply hX.bounded_harmonic_recovery_strong hn hS ha hab hbR hRT hTS hM
+ (fun k => p (k+N)) (fun k => r (k+N)) (fun k => ε (k+N)) (fun k => V (k+N))
+ (fun k => hr (k+N)) (fun k => hcurv (k+N)) (fun k => hε (k+N)) (fun k => hε1 (k+N))
+ (hεlim.comp (tendsto_add_atTop_nat N)) (fun k => hV (k+N))
+ (fun k => w (k+N)) (fun k => (q k).val) (fun k => hw (k+N)) (fun k => hnorm (k+N))
+ g F hgL heq hd
+ (fun W hW hWS δ hδ => (tendsto_add_atTop_nat N).eventually (hconv W hW hWS δ hδ)) hqv hQb
+ let φ : Euclidean n →ᵇ ℝ := (euclideanNestedCutoff n hab)^2
+ apply hqe φ (fun z => sq_nonneg _) ?_
+ have hs : tsupport φ⊆closedBall (0:Euclidean n) b := by
+ change closure (Function.support φ)⊆closedBall 0 b
+ apply closure_minimal _ isClosed_closedBall
+ intro z hz
+ by_contra hx
+ have hz' : b r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (R*r k), (nestedBallCutoff (p k) (a*r k) (b*r k) x)^2*
+ localGamma (hausdorff n X) hX.quadratic (w k-q k) (w k-q k) x ∂hausdorff n X)
+ atTop (𝓝 0)) :
+ Tendsto (fun k => r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ (∫ x in ball (p k) (S*r k), F (V k x)*localGamma (hausdorff n X) hX.quadratic
+ (u k) (w k) x ∂hausdorff n X)-
+ r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ (∫ x in ball (p k) (S*r k), F (V k x)*localGamma (hausdorff n X) hX.quadratic
+ (u k) (q k) x ∂hausdorff n X)) atTop (𝓝 0) := by
+ let μ := hausdorff n X
+ let Ω := fun k => ball (p k) (R*r k)
+ let U := fun k => ball (p k) (S*r k)
+ let A := fun k => ball (p k) (c*r k)
+ let C := fun k => r k^2*(μ.real (U k))⁻¹
+ let χ := fun k => nestedBallCutoff (p k) (a*r k) (b*r k)
+ have hm (k : ℕ) : 0<μ.real (U k) := ENNReal.toReal_pos
+ (hX.fullSupport _ _ (mul_pos hS (hr k))).ne' (hX.finiteOnBounded _ isBounded_ball).ne
+ have hzero (k : ℕ) : ∀ᵐ x ∂μ, x∉Ω k → SobolevSpace.toLp μ hX.quadratic (u k) x=0 :=
+ (huz k).mono fun x hx hn => hx (fun hy => hn
+ ((ball_subset_ball (mul_le_mul_of_nonneg_right (hca.trans (hab.trans hbR)).le (hr k).le)) hy))
+ have henergy : ∀ᶠ k in atTop, C k*(∫ x in Ω k, localGamma μ hX.quadratic (u k) (u k) x ∂μ)≤Q^2 := by
+ filter_upwards [hub] with k hk
+ have hh := rescaled_local_energy_bound μ hX.quadratic (u k)
+ (ball_subset_ball (mul_le_mul_of_nonneg_right hRS.le (hr k).le))
+ (hX.finiteOnBounded (U k) isBounded_ball).ne (hm k) (sq_nonneg Q) (ae_restrict_of_ae hk)
+ simpa only [C,div_eq_mul_inv] using hh
+ have he := compact_mixed_transfer μ hX.quadratic Ω A C
+ (fun k => mul_nonneg (sq_nonneg _) (inv_nonneg.mpr (hm k).le)) u w q
+ (fun k x => F (V k x)) χ (norm_nonneg F) (sq_nonneg Q)
+ (fun k => (F.continuous.measurable.comp (hV k)).aestronglyMeasurable)
+ (fun k => (nestedBallCutoff_lipschitz (p k) (mul_lt_mul_of_pos_right hab (hr k))).continuous.aestronglyMeasurable)
+ (fun k => Eventually.of_forall fun x => by simpa only [Real.norm_eq_abs] using F.norm_coe_le_norm (V k x))
+ (fun k => Eventually.of_forall fun x => by
+ rw [abs_of_nonneg (nestedBallCutoff_bounds _ _ _ _).1]
+ exact (nestedBallCutoff_bounds _ _ _ _).2)
+ (fun k x hx => nestedBallCutoff_eq_one (p k) (mul_lt_mul_of_pos_right hab (hr k))
+ (by rw [dist_comm]; exact hx.le.trans (mul_le_mul_of_nonneg_right hca.le (hr k).le))) huz henergy herror
+ apply he.congr'
+ apply Eventually.of_forall
+ intro k
+ have hsub : Ω k⊆U k := ball_subset_ball (mul_le_mul_of_nonneg_right hRS.le (hr k).le)
+ dsimp only [C]
+ rw [supported_weighted_gamma μ hX.quadratic (u k) (w k) (fun x => F (V k x)) hsub (hzero k),
+ supported_weighted_gamma μ hX.quadratic (u k) (q k) (fun x => F (V k x)) hsub (hzero k)]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/CompactMixedTransfer.lean b/lean/OAI/Geometry/RCD/Harmonic/CompactMixedTransfer.lean
new file mode 100644
index 0000000000000000000000000000000000000000..7617b415fae78dc434ae822de287172e4fbe91b6
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/CompactMixedTransfer.lean
@@ -0,0 +1,86 @@
+import OAI.Geometry.RCD.Harmonic.YoungPairingLimit
+
+namespace OAI
+
+/-! # Strong local harmonic recovery transfers a compact-test mixed pairing -/
+
+open Set Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+private theorem gamma_sub_right (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ (u w q : SobolevSpace μ hQ) :
+ localGamma μ hQ u (w-q)=ᵐ[μ] fun x => localGamma μ hQ u w x-localGamma μ hQ u q x := by
+ filter_upwards [localGamma_sub_left μ hQ w q u,localGamma_comm μ hQ u (w-q),
+ localGamma_comm μ hQ w u,localGamma_comm μ hQ q u] with x hs hc hw hq
+ rw [hc,hs,hw,hq]
+
+theorem compact_mixed_transfer (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ (Ω A : ℕ → Set X) (c : ℕ → ℝ) (hc : ∀ k, 0≤c k)
+ (u w q : ℕ → SobolevSpace μ hQ) (F χ : ℕ → X → ℝ)
+ {B C : ℝ} (hB : 0≤B) (hC : 0≤C)
+ (hF : ∀ k, AEStronglyMeasurable (F k) (μ.restrict (Ω k)))
+ (hχ : ∀ k, AEStronglyMeasurable (χ k) (μ.restrict (Ω k)))
+ (hFb : ∀ k, ∀ᵐ x ∂μ.restrict (Ω k), |F k x|≤B)
+ (hχb : ∀ k, ∀ᵐ x ∂μ.restrict (Ω k), |χ k x|≤1)
+ (hχone : ∀ k x, x∈A k → χ k x=1)
+ (huzero : ∀ k, ∀ᵐ x ∂μ, x∉A k → SobolevSpace.toLp μ hQ (u k) x=0)
+ (henergy : ∀ᶠ k in atTop, c k*(∫ x in Ω k, localGamma μ hQ (u k) (u k) x ∂μ)≤C)
+ (herror : Tendsto (fun k => c k*∫ x in Ω k, (χ k x)^2*
+ localGamma μ hQ (w k-q k) (w k-q k) x ∂μ) atTop (𝓝 0)) :
+ Tendsto (fun k =>
+ c k*(∫ x in Ω k, F k x*localGamma μ hQ (u k) (w k) x ∂μ)-
+ c k*(∫ x in Ω k, F k x*localGamma μ hQ (u k) (q k) x ∂μ))
+ atTop (𝓝 0) := by
+ let φ := fun k x => F k x*χ k x
+ have hφb (k : ℕ) : ∀ᵐ x ∂μ.restrict (Ω k), |φ k x|≤B := by
+ filter_upwards [hFb k,hχb k] with x hx hy
+ change |F k x*χ k x|≤B
+ rw [abs_mul]
+ exact (mul_le_mul hx hy (abs_nonneg _) hB).trans_eq (mul_one B)
+ have hdom : ∀ᶠ k in atTop, ∀ᵐ x ∂μ.restrict (Ω k), |φ k x|≤B*|χ k x| := by
+ apply Eventually.of_forall
+ intro k
+ filter_upwards [hFb k] with x hx
+ change |F k x*χ k x|≤B*|χ k x|
+ rw [abs_mul]
+ exact mul_le_mul_of_nonneg_right hx (abs_nonneg _)
+ have ht := cutoff_mixed_error_tendsto μ hQ Ω c hc (fun k => w k-q k) u φ χ hB hC
+ (fun k => (hF k).mul (hχ k)) hχ hφb hχb hdom henergy herror
+ have heq (k : ℕ) :
+ (∫ x in Ω k, F k x*localGamma μ hQ (u k) (w k) x ∂μ)-
+ (∫ x in Ω k, F k x*localGamma μ hQ (u k) (q k) x ∂μ)=
+ ∫ x in Ω k, φ k x*localGamma μ hQ (w k-q k) (u k) x ∂μ := by
+ have hi (v : SobolevSpace μ hQ) :
+ IntegrableOn (fun x => F k x*localGamma μ hQ (u k) v x) (Ω k) μ :=
+ (localGamma_memL1 μ hQ (u k) v).restrict.bdd_mul (hF k)
+ ((hFb k).mono fun x hx => by simpa only [Real.norm_eq_abs] using hx)
+ rw [← integral_sub (hi (w k)) (hi (q k))]
+ apply integral_congr_ae
+ filter_upwards [ae_restrict_of_ae (huzero k),
+ ae_restrict_of_ae (gamma_sub_right μ hQ (u k) (w k) (q k)),
+ ae_restrict_of_ae (localGamma_comm μ hQ (w k-q k) (u k)),
+ ae_restrict_of_ae (localGamma_zero_on_level μ hQ (u k) (w k-q k) 0)]
+ with x hz hsub hcomm hzero
+ change F k x*localGamma μ hQ (u k) (w k) x-
+ F k x*localGamma μ hQ (u k) (q k) x=_
+ dsimp only [φ]
+ rw [hcomm,hsub]
+ by_cases hx : x∈A k
+ · rw [hχone k x hx]
+ ring
+ · have h0 := hzero (hz hx)
+ rw [hsub] at h0
+ rw [← mul_sub,h0,mul_zero,mul_zero]
+ convert ht using 1
+ funext k
+ rw [← heq k]
+ ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/CompactRadialPairingIdentity.lean b/lean/OAI/Geometry/RCD/Harmonic/CompactRadialPairingIdentity.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0511170102ad619858218d9a24832a57cd78ddac
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/CompactRadialPairingIdentity.lean
@@ -0,0 +1,68 @@
+import OAI.Geometry.RCD.Harmonic.CompactRadialWeight
+
+namespace OAI
+
+/-! # The exact radial integral obtained from compact smooth recoveries -/
+
+open Set Filter MeasureTheory Metric InnerProductSpace
+open scoped BoundedContinuousFunction Topology ContDiff NNReal
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem compact_radial_pairing_identity {n : ℕ} {S R : ℝ} (hS : 0 ‖x‖^2/2) (closedBall 0 R))
+ (hψ : InteriorSmoothTest n S ψ) (hs : tsupport ψ⊆ball 0 R) :
+ (∫ x in ball 0 S, Q x*inner ℝ (gradient ψ x) (gradient G x))=
+ -(∫ x in ball 0 S, ψ x*fderiv ℝ g x x) := by
+ have hψc : Continuous (gradient ψ) :=
+ (toDual ℝ (Euclidean n)).symm.continuous.comp (hψ.1.continuous_fderiv (by simp))
+ have hGc : Continuous (gradient G) :=
+ (toDual ℝ (Euclidean n)).symm.continuous.comp (hG.continuous_fderiv (by simp))
+ have hgzero (x : Euclidean n) (hx : x∉tsupport ψ) : gradient ψ x=0 := by
+ simp only [gradient,fderiv_of_notMem_tsupport ℝ hx,map_zero]
+ have hi1 : Integrable (fun x => (‖x‖^2/2)*inner ℝ (gradient ψ x) (gradient G x)) volume := by
+ apply (((continuous_norm.pow 2).div_const 2).mul (hψc.inner hGc)).integrable_of_hasCompactSupport
+ apply hψ.2.1.mono'
+ intro x hx
+ by_contra hn
+ exact hx (by
+ change (‖x‖^2/2)*inner ℝ (gradient ψ x) (gradient G x)=0
+ simp only [hgzero x hn,inner_zero_left,mul_zero])
+ have hi2 : Integrable (fun x => ψ x*fderiv ℝ G x x) volume := by
+ apply (hψ.1.continuous.mul ((hG.continuous_fderiv (by simp)).clm_apply continuous_id)).integrable_of_hasCompactSupport
+ exact hψ.2.1.mul_right
+ have he1 (x : Euclidean n) :
+ (‖x‖^2/2)*inner ℝ (gradient ψ x) (gradient G x)=
+ (‖x‖^2/2)*inner ℝ (gradient ψ x) (gradient g x) := by
+ by_cases hx : x∈tsupport ψ
+ · simp only [gradient,hd (hs hx)]
+ · simp only [hgzero x hx,inner_zero_left,mul_zero]
+ have he2 (x : Euclidean n) : ψ x*fderiv ℝ G x x=ψ x*fderiv ℝ g x x := by
+ by_cases hx : x∈tsupport ψ
+ · rw [hd (hs hx)]
+ · rw [image_eq_zero_of_notMem_tsupport hx,zero_mul,zero_mul]
+ have hid := weak_harmonic_radial_pairing hS hg hweak hψ
+ (hi1.congr (Eventually.of_forall he1)) (hi2.congr (Eventually.of_forall he2))
+ have hleft (x : Euclidean n) : Q x*inner ℝ (gradient ψ x) (gradient G x)=
+ (‖x‖^2/2)*inner ℝ (gradient ψ x) (gradient g x) := by
+ by_cases hx : x∈tsupport ψ
+ · rw [hQ (ball_subset_closedBall (hs hx)),he1 x]
+ · simp only [hgzero x hx,inner_zero_left,mul_zero]
+ have hzero (x : Euclidean n) (hx : x∉ball (0:Euclidean n) S) : x∉tsupport ψ :=
+ fun hh => hx ((ball_subset_ball hRS.le) (hs hh))
+ rw [setIntegral_eq_integral_of_forall_compl_eq_zero (fun x hx => by
+ rw [hgzero x (hzero x hx),inner_zero_left,mul_zero]),
+ setIntegral_eq_integral_of_forall_compl_eq_zero (fun x hx => by
+ rw [image_eq_zero_of_notMem_tsupport (hzero x hx),zero_mul]),
+ integral_congr_ae (Eventually.of_forall hleft)]
+ exact hid
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/CompactRadialWeight.lean b/lean/OAI/Geometry/RCD/Harmonic/CompactRadialWeight.lean
new file mode 100644
index 0000000000000000000000000000000000000000..a09a18d5a2c24b5c9ba199ad794d30352df2c1dc
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/CompactRadialWeight.lean
@@ -0,0 +1,49 @@
+import OAI.Geometry.RCD.Sobolev.WeakHarmonicRadialPairing
+import OAI.Geometry.RCD.Metric.EuclideanInteriorSmoothExtension
+
+namespace OAI
+
+/-! # A compact nonnegative weight equal to half the squared radius -/
+
+open Set Metric Filter MeasureTheory
+open scoped BoundedContinuousFunction Topology ContDiff
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem exists_compact_radial_weight {n : ℕ} {T S : ℝ} (hT : 0 r k^2*(μ.real (ball (p k) (S*r k)))⁻¹*
+ (∫ x in ball (p k) (S*r k), ψ (V k x)*localGamma μ hQ (f k) (w k) x ∂μ)-
+ r k^2*(μ.real (ball (p k) (S*r k)))⁻¹*
+ (∫ x in ball (p k) (S*r k), SobolevSpace.toLp μ hQ (u k) x*
+ localGamma μ hQ (f k) (w k) x ∂μ)) atTop (𝓝 0) := by
+ let U := fun k => ball (p k) (S*r k)
+ let Ω := fun k => ball (p k) (T*r k)
+ let z := fun k x => ψ (V k x)-SobolevSpace.toLp μ hQ (u k) x
+ have hψL (k : ℕ) : MemLp (fun x => ψ (V k x)) 2 (μ.restrict (U k)) :=
+ MemLp.of_bound (hψ.measurable.comp (hV k).measurable).aestronglyMeasurable B
+ (Eventually.of_forall fun x => by simpa only [Real.norm_eq_abs] using hψB (V k x))
+ have hzL (k : ℕ) : MemLp (z k) 2 (μ.restrict (U k)) :=
+ (hψL k).sub ((Lp.memLp (SobolevSpace.toLp μ hQ (u k))).restrict (U k))
+ have hzl : Tendsto (fun k => (μ.real (U k))⁻¹*∫ x in U k, (z k x)^2 ∂μ) atTop (𝓝 0) := by
+ apply containing_mass_uniform_l2 (fun k => μ.restrict (U k)) (fun k => μ.real (U k)) hmass
+ (fun k => by simp only [Measure.real,Measure.restrict_apply_univ]; exact le_rfl) z
+ (fun k => (hzL k).aestronglyMeasurable)
+ intro δ hδ
+ exact (hconv δ hδ).mono fun k hk => hk.mono fun x hx => by
+ simpa only [z,abs_sub_comm] using hx
+ have hzero : ∀ᶠ k in atTop, ∀ᵐ x ∂μ.restrict (U k), x∉Ω k → z k x=0 := by
+ filter_upwards [hε.eventually (gt_mem_nhds (show 0<(T-d)/2 by linarith))] with k hk
+ filter_upwards [ae_restrict_of_ae (huz k),ae_restrict_mem measurableSet_ball] with x hz hx hn
+ have hu : SobolevSpace.toLp μ hQ (u k) x=0 := hz (fun hy => hn
+ ((ball_subset_ball (mul_le_mul_of_nonneg_right hcT.le (hr k).le)) hy))
+ have hdist : T≤dist x (p k)/r k := (le_div_iff₀ (hr k)).mpr (le_of_not_gt hn)
+ have hd := (abs_le.mp (pointed_radial_distance (hr k) hS.le (hV k).metric hx.le)).1
+ have hnorm : d<‖V k x‖ := by linarith
+ have hψ0 : ψ (V k x)=0 := image_eq_zero_of_notMem_tsupport
+ (fun hs => (lt_irrefl d) (lt_trans hnorm (by simpa only [mem_ball,dist_zero_right] using hψs hs)))
+ change ψ (V k x)-SobolevSpace.toLp μ hQ (u k) x=0
+ rw [hψ0,hu,sub_self]
+ have he := supported_coefficient_l2_gamma_error μ hQ Ω U (fun _ => measurableSet_ball)
+ (fun k => ball_subset_ball (mul_le_mul_of_nonneg_right hTS.le (hr k).le)) hmass
+ r (fun k => (hr k).le) f w z hM hL hf hw hzero hzL hzl
+ apply he.congr'
+ filter_upwards [hconv 1 zero_lt_one] with k hk
+ have hm : AEStronglyMeasurable (fun x => ψ (V k x)) (μ.restrict (U k)) :=
+ (hψ.measurable.comp (hV k).measurable).aestronglyMeasurable
+ have hi : IntegrableOn (fun x => ψ (V k x)*localGamma μ hQ (f k) (w k) x) (U k) μ :=
+ (localGamma_memL1 μ hQ (f k) (w k)).restrict.bdd_mul hm
+ (Eventually.of_forall fun x => by simpa only [Real.norm_eq_abs] using hψB (V k x))
+ have huB : ∀ᵐ x ∂μ.restrict (U k), ‖SobolevSpace.toLp μ hQ (u k) x‖≤B+1 := by
+ filter_upwards [hk] with x hx
+ rw [Real.norm_eq_abs]
+ calc |SobolevSpace.toLp μ hQ (u k) x|
+ = |(SobolevSpace.toLp μ hQ (u k) x-ψ (V k x))+ψ (V k x)| := by congr 1; ring
+ _ ≤ |SobolevSpace.toLp μ hQ (u k) x-ψ (V k x)|+|ψ (V k x)| := abs_add_le _ _
+ _ ≤ B+1 := by linarith [hψB (V k x)]
+ have hj : IntegrableOn (fun x => SobolevSpace.toLp μ hQ (u k) x*localGamma μ hQ (f k) (w k) x) (U k) μ :=
+ (localGamma_memL1 μ hQ (f k) (w k)).restrict.bdd_mul
+ ((Lp.memLp (SobolevSpace.toLp μ hQ (u k))).restrict (U k)).aestronglyMeasurable huB
+ change r k^2*(μ.real (U k))⁻¹*(∫ x in U k, z k x*localGamma μ hQ (f k) (w k) x ∂μ)=_
+ simp only [z,sub_mul]
+ rw [integral_sub hi hj]
+ ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/CompressedRadialTime.lean b/lean/OAI/Geometry/RCD/Harmonic/CompressedRadialTime.lean
new file mode 100644
index 0000000000000000000000000000000000000000..98f69f6d0378a9f01237919909b1282a005f6389
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/CompressedRadialTime.lean
@@ -0,0 +1,106 @@
+import OAI.Geometry.RCD.Harmonic.RadialTime
+import OAI.Geometry.RCD.Transport.OptimalRadialTime
+import OAI.Geometry.RCD.Harmonic.RadialDensityEnvelope
+
+namespace OAI
+
+/-! # Small-time radial contraction with uniform path compression
+
+The prescribed marginal retains the sharp small-time density bound.
+Replacing the intervening transport by a bounded-compression plan preserves
+that marginal and, by optimal cost rigidity, its radial displacement.
+-/
+
+open Set Filter Metric MeasureTheory TopologicalSpace
+open scoped ENNReal
+
+namespace RegularPointCoordinates
+
+noncomputable def radialPathBudget (K : ℝ) (n : ℕ) (κ D : ℝ) (C₀ : ℝ≥0∞) : ℝ≥0∞ :=
+ compressionBudget K n (6 * D) (C₀ * ENNReal.ofReal (1 + 2 ^ n * Real.exp (κ * D ^ 2 / 6)))
+
+theorem radialPathBudget_ne_top (K : ℝ) (n : ℕ) (κ D : ℝ) {C₀ : ℝ≥0∞} (hC₀ : C₀ ≠ ∞) :
+ radialPathBudget K n κ D C₀ ≠ ∞ :=
+ compressionBudget_ne_top K n _ (ENNReal.mul_ne_top hC₀ ENNReal.ofReal_ne_top)
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem NoncollapsedRCD.exists_compressed_radial_time {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n)
+ {κ : ℝ} (hκ : 0 ≤ κ) (hK : -κ ≤ K) (ν₀ : ProbabilityMeasure X)
+ {C₀ : ℝ≥0∞} (hC₀ : C₀ ≠ ∞) (h0 : (ν₀ : Measure X) ≤ C₀ • hausdorff n X)
+ (p : X) {R D : ℝ} (hR : 0 < R) (hRD : R < D)
+ (hs0 : ∀ᵐ x ∂(ν₀ : Measure X), dist x p ≤ R)
+ (t : Time) (ht : 0 < (t : ℝ)) (ht1 : (t : ℝ) ≤ 1 / 2) :
+ ∃ π : Measure C(Time, X), IsProbabilityMeasure π ∧
+ π.map (fun γ => γ 0) = (ν₀ : Measure X) ∧
+ (∀ᵐ γ ∂π, IsGeodesic γ) ∧
+ MemLp (fun γ : C(Time, X) => dist (γ 0) (γ 1)) 2 π ∧
+ (∀ s : Time, π.map (fun γ => γ s) ≤ radialPathBudget K n κ D C₀ • hausdorff n X) ∧
+ π.map (fun γ => γ 1) ≤
+ (C₀ * ENNReal.ofReal (radialContractionDensity n κ D t)) • hausdorff n X ∧
+ ∀ᵐ γ ∂π, dist (γ 0) (γ 1) = (t : ℝ) * dist (γ 0) p ∧
+ dist (γ 1) p = (1 - (t : ℝ)) * dist (γ 0) p ∧
+ dist (γ 0) p = dist (γ 0) (γ 1) + dist (γ 1) p := by
+ let := hX.separable
+ let := locallyFinite_of_finiteOnBounded (hausdorff n X) hX.finiteOnBounded
+ let μ := hausdorff n X
+ have ht1' : (t : ℝ) < 1 := by linarith
+ obtain ⟨q, hq, hq0, hq1, hqm⟩ := hX.exists_radial_time_plan hn hκ hK ν₀ hC₀ h0
+ p hR hRD hs0 t ht1'
+ let η : Measure X := (q.map (fun γ => γ t) : Measure X)
+ let M := 1 + 2 ^ n * Real.exp (κ * D ^ 2 / 6)
+ let A := C₀ * ENNReal.ofReal M
+ have hA : A ≠ ∞ := ENNReal.mul_ne_top hC₀ ENNReal.ofReal_ne_top
+ have hM : 1 ≤ M := by
+ have hh : 0 ≤ (2 : ℝ) ^ n * Real.exp (κ * D ^ 2 / 6) := by positivity
+ dsimp only [M]
+ linarith
+ have hb0 : (ν₀ : Measure X) ≤ A • μ := by
+ have hone : (1 : ℝ≥0∞) ≤ ENNReal.ofReal M := by
+ simpa only [ENNReal.ofReal_one] using ENNReal.ofReal_le_ofReal hM
+ have hh : C₀ ≤ A := by simpa only [mul_one] using mul_le_mul_right hone C₀
+ intro S
+ exact (h0 S).trans (mul_le_mul_left hh (μ S))
+ have hb1 : η ≤ A • μ := by
+ have hle : radialContractionDensity n κ D t ≤ M :=
+ (radialContractionDensity_le n hκ t.2.1 ht1).trans (by dsimp [M]; linarith)
+ intro S
+ exact (hqm S).trans (mul_le_mul_left
+ (mul_le_mul_right (ENNReal.ofReal_le_ofReal hle) C₀) (μ S))
+ have hη : ∀ᵐ x ∂η, dist x p ≤ 3 * D := by
+ change ∀ᵐ x ∂(q.map (fun γ => γ t) : Measure X), dist x p ≤ 3 * D
+ rw [ProbabilityMeasure.toMeasure_map]
+ apply (ae_map_iff (measurable_path_eval t).aemeasurable
+ (measurableSet_le (measurable_id.dist measurable_const) measurable_const)).mpr
+ exact hq.mono fun _ hγ => hγ.2 t
+ have hs0' : ∀ᵐ x ∂(ν₀ : Measure X), dist x p ≤ 3 * D :=
+ hs0.mono fun _ hx => by linarith
+ obtain ⟨π, hπ, hg, hp, hi, hcomp⟩ := hX.exists_bounded_entropy_plan K n hn
+ (ν₀ : Measure X) η hA hb0 hb1 p (by linarith : 0 ≤ 3 * D) hs0' hη
+ let := hπ
+ have hq1' : (q : Measure C(Time, X)).map (fun γ => γ 1) = Measure.dirac p := by
+ have hh := congrArg (fun ν : ProbabilityMeasure X => (ν : Measure X)) hq1
+ change (q.map (fun γ => γ 1) : Measure X) = Measure.dirac p at hh
+ simpa only [ProbabilityMeasure.toMeasure_map] using hh
+ have hq0' : (q : Measure C(Time, X)).map (fun γ => γ 0) = (ν₀ : Measure X) := by
+ have hh := congrArg (fun ν : ProbabilityMeasure X => (ν : Measure X)) hq0
+ simpa only [ProbabilityMeasure.toMeasure_map] using hh
+ have hp' : IsOptimalCoupling ((q : Measure C(Time, X)).map (fun γ => γ 0))
+ ((q : Measure C(Time, X)).map (fun γ => γ t)) (π.map (fun γ => (γ 0, γ 1))) := by
+ rw [hq0']
+ exact hp
+ have he := optimalPlan_endpoints _ _ π hp
+ refine ⟨π, hπ, he.1, hg,
+ (memLp_two_iff_integrable_sq
+ ((measurable_path_eval 0).dist (measurable_path_eval 1)).aestronglyMeasurable).mpr hi,
+ ?_, he.2 ▸ hqm, ?_⟩
+ · intro s
+ simpa only [radialPathBudget, A, M, show 2 * (3 * D) = 6 * D by ring] using (hcomp s).1
+ · exact optimal_radial_time (q : Measure C(Time, X)) p (by linarith : 0 ≤ 3 * D)
+ hq hq1' t ht ht1' π hi hp'
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ConstantDirectionError.lean b/lean/OAI/Geometry/RCD/Harmonic/ConstantDirectionError.lean
new file mode 100644
index 0000000000000000000000000000000000000000..457a9e8cc0a048b0b9eefb884dda5c070be093f2
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ConstantDirectionError.lean
@@ -0,0 +1,76 @@
+import OAI.Geometry.RCD.Harmonic.AffineCenterBounds
+import OAI.Geometry.RCD.Sobolev.LocalAffineCutoff
+import OAI.Geometry.RCD.Coordinates.CovectorConstantRecovery
+
+namespace OAI
+
+/-! # From recovered affine coefficients to the constant direction -/
+
+open Set MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- The two-center radial derivative is close to the actual displacement
+once its affine linear and constant coefficients have been recovered. -/
+theorem normalized_constant_direction_error {n : ℕ}
+ (Ω : Set X) (hfin : μ Ω ≠ ∞) (hpos : μ Ω ≠ 0) (η : SobolevSpace μ hQ)
+ (hη : SobolevSpace.toLp μ hQ η =ᵐ[μ.restrict Ω] fun _ => (1 : ℝ))
+ (U H : Euclidean n →L[ℝ] SobolevSpace μ hQ) (B : Euclidean n →L[ℝ] Euclidean n)
+ (c d : Euclidean n →L[ℝ] ℝ) {e R L D : ℝ} (hR : 0 ≤ R)
+ (hU : ∀ b, ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω (U b))‖ ≤ R * ‖b‖)
+ (hfit : ∀ b, ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω
+ (H b - U (B b) - c b • η))‖ ≤ e * ‖b‖)
+ (hB : ‖B‖ ≤ L) (hconst : ‖c - d‖ ≤ D) (b : Euclidean n) :
+ ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω (H b - d b • η))‖ ≤
+ (e + R * L + D) * ‖b‖ := by
+ have hlin : ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω (U (B b)))‖ ≤
+ R * L * ‖b‖ := by
+ apply (hU (B b)).trans
+ have hb := (B.le_opNorm b).trans (mul_le_mul_of_nonneg_right hB (norm_nonneg b))
+ exact (mul_le_mul_of_nonneg_left hb hR).trans_eq (by ring)
+ have hc : ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω ((c - d) b • η))‖ ≤
+ D * ‖b‖ := by
+ rw [map_smul, restrictLp_eq_one_of_representative μ hQ η Ω hfin hη,
+ normalized_constant_norm μ Ω hfin hpos]
+ change ‖(c - d) b‖ ≤ _
+ exact ((c - d).le_opNorm b).trans (mul_le_mul_of_nonneg_right hconst (norm_nonneg b))
+ have he : H b - d b • η =
+ (H b - U (B b) - c b • η) + U (B b) + (c - d) b • η := by
+ simp only [sub_apply, sub_smul]
+ module
+ rw [he, map_add, map_add]
+ simp only [normalizeLocalL2, smul_add]
+ apply ((norm_add_le _ _).trans (add_le_add (norm_add_le _ _) le_rfl)).trans
+ have hf := hfit b
+ dsimp only [normalizeLocalL2] at hf hlin hc
+ nlinarith only [hf, hlin, hc]
+
+/-- In the two-center application the affine constant is the displaced
+coordinate covector composed with the first radial matrix. Both recovered
+coefficient estimates therefore give the desired constant direction. -/
+theorem normalized_two_center_direction_error {n : ℕ}
+ (Ω : Set X) (hfin : μ Ω ≠ ∞) (hpos : μ Ω ≠ 0) (η : SobolevSpace μ hQ)
+ (hη : SobolevSpace.toLp μ hQ η =ᵐ[μ.restrict Ω] fun _ => (1 : ℝ))
+ (U H : Euclidean n →L[ℝ] SobolevSpace μ hQ)
+ (Ax Az : Euclidean n →L[ℝ] Euclidean n) (c d : Euclidean n →L[ℝ] ℝ)
+ {e R L D M : ℝ} (hR : 0 ≤ R) (hx : ‖Ax - 1‖ ≤ 1 / 2) (hc : c = d.comp Ax)
+ (hU : ∀ b, ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω (U b))‖ ≤ R * ‖b‖)
+ (hfit : ∀ b, ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω
+ (H b - U ((Az - Ax) b) - c b • η))‖ ≤ e * ‖b‖)
+ (hB : ‖Az - Ax‖ ≤ L) (hM : ‖c‖ ≤ M) (hconst : ‖c.comp (Az - 1)‖ ≤ D)
+ (b : Euclidean n) :
+ ‖normalizeLocalL2 μ Ω hfin (SobolevSpace.restrictLp μ hQ Ω (H b - d b • η))‖ ≤
+ (e + R * L + 2 * (D + M * L)) * ‖b‖ := by
+ exact normalized_constant_direction_error μ hQ Ω hfin hpos η hη U H (Az - Ax) c d hR hU hfit
+ hB (covector_constant_recovery Ax Az d c hx hc hB hM hconst) b
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ContinuousAffineImprovement.lean b/lean/OAI/Geometry/RCD/Harmonic/ContinuousAffineImprovement.lean
new file mode 100644
index 0000000000000000000000000000000000000000..d7882f92917658e1e89eb4ef088d42f3cd46a102
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ContinuousAffineImprovement.lean
@@ -0,0 +1,85 @@
+import OAI.Geometry.RCD.Harmonic.AffineImprovementTransfer
+import OAI.Geometry.RCD.Coordinates.LocalCoordinateExtension
+
+namespace OAI
+
+/-! # Uniform affine improvement for continuous local harmonic coordinates -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal InnerProductSpace
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+
+/-- The normalized harmonic estimate in the original affine coordinate span. -/
+def HasNormalizedAffineImprovement {K : ℝ} {n : ℕ} (hX : NoncollapsedRCD K n X)
+ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ (p : X) (r θ : ℝ) : Prop :=
+ ∀ w : SobolevSpace (hausdorff n X) hX.quadratic,
+ IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball p r) w →
+ ‖normalizeLocalL2 (hausdorff n X) (ball p r)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic (ball p r) w)‖ ≤ 1 →
+ ‖normalizeLocalL2 (hausdorff n X) (ball p (θ * r))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (affineResidual (hausdorff n X) hX.quadratic u (ball p (θ * r))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic (ball p (θ * r)) w))‖ <
+ (1 / 2 : ℝ) * θ * Real.sqrt θ
+
+theorem affine_improvement_from_continuous_coordinates [ProperSpace X]
+ {K : ℝ} {n : ℕ} (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n)
+ (hcompact : LocalHarmonicMomentCompactnessInput hX)
+ (hgradient : LocalHarmonicL2GradientInput hX)
+ (heuclidean : EuclideanHarmonicHessianInput n)
+ (hmeasured : LocalMeasuredCoordinateInput hX) :
+ ∃ m : ℕ, 3 ≤ m ∧ ∃ δ : ℝ, 0 < δ ∧ δ ≤ 1 ∧
+ ∀ (p : X) (r : ℝ), 0 < r → -δ ≤ K * r ^ 2 →
+ ∀ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ (v : X → Euclidean n),
+ (∀ i, SobolevSpace.toLp (hausdorff n X) hX.quadratic (u i) =ᵐ[
+ (hausdorff n X).restrict (ball p r)] fun x => v x i) →
+ ContinuousOn v (ball p (4 * r)) →
+ ∀ (B : Euclidean n ≃L[ℝ] Euclidean n)
+ (η : SobolevSpace (hausdorff n X) hX.quadratic),
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic η =ᵐ[
+ (hausdorff n X).restrict (ball p r)] fun _ => (1 : ℝ)) →
+ IsPointedApproximation p 0 r 2 δ (fun x =>
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v x) -
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v p)) →
+ HasNormalizedAffineImprovement hX u p r ((1 / 2 : ℝ) ^ m) := by
+ obtain ⟨m, hm, δ, hδ, hδ1, hfit⟩ := affine_improvement_from_metric_coordinates
+ hX hn hcompact hgradient heuclidean hmeasured
+ refine ⟨m, hm, δ, hδ, hδ1, ?_⟩
+ intro p r hr hcurv u v hrep hv B η hη happ
+ obtain ⟨v', hv', heq⟩ := exists_measurable_local_extension measurableSet_ball hv
+ have hp : p ∈ ball p (4 * r) := mem_ball_self (by positivity)
+ have hsub : ball p r ⊆ ball p (4 * r) := ball_subset_ball (by linarith)
+ have hrep' (i : Fin n) : SobolevSpace.toLp (hausdorff n X) hX.quadratic (u i) =ᵐ[
+ (hausdorff n X).restrict (ball p r)] fun x => v' x i := by
+ filter_upwards [hrep i, ae_restrict_mem measurableSet_ball] with x hx hxs
+ rw [← heq (hsub hxs)]
+ exact hx
+ have hmeas : Measurable (fun x => (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v' x) -
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v' p)) :=
+ ((B : Euclidean n →L[ℝ] Euclidean n).adjoint.continuous.measurable.comp hv').sub measurable_const
+ have happ' : IsPointedApproximation p 0 r 2 δ (fun x =>
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v' x) -
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint (v' p)) := by
+ apply happ.congr_on_ball (by positivity)
+ intro x hx
+ have hx' : x ∈ ball p (4 * r) := by
+ change dist x p < 4 * r
+ exact lt_of_le_of_lt (show dist x p ≤ 2 * r from hx) (by linarith)
+ exact congrArg₂ (fun a b =>
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint a -
+ (B : Euclidean n →L[ℝ] Euclidean n).adjoint b) (heq hx') (heq hp)
+ exact hfit p r hr hcurv u v' hrep' B η hη hmeas happ'
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ContinuousApproximateRepresentative.lean b/lean/OAI/Geometry/RCD/Harmonic/ContinuousApproximateRepresentative.lean
new file mode 100644
index 0000000000000000000000000000000000000000..8580ed61516ba7a85129be917a32592f97aec4f4
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ContinuousApproximateRepresentative.lean
@@ -0,0 +1,53 @@
+import OAI.Geometry.RCD.Harmonic.PointedRadialDistance
+import Mathlib.MeasureTheory.Measure.OpenPos
+import Mathlib.Topology.Sequences
+
+namespace OAI
+
+/-! # From almost everywhere to every point against an approximate map -/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem continuous_approximate_representative {X Y : Type*}
+ [MetricSpace X] [MeasurableSpace X] [OpensMeasurableSpace X]
+ [MetricSpace Y] (μ : Measure X) [μ.IsOpenPosMeasure]
+ {Ω : Set X} (hΩ : IsOpen Ω) (u F : X → Y) (hu : ContinuousOn u Ω)
+ {L ε δ : ℝ}
+ (hF : ∀ x ∈ Ω, ∀ y ∈ Ω, dist (F x) (F y) ≤ L*dist x y+ε)
+ (hAE : ∀ᵐ x ∂μ.restrict Ω, dist (u x) (F x) ≤ δ) :
+ ∀ x ∈ Ω, dist (u x) (F x) ≤ δ+ε := by
+ intro x hx
+ let A := {y | y ∈ Ω ∧ dist (u y) (F y) ≤ δ}
+ have hdense := Measure.dense_of_ae (μ := μ) (ae_imp_of_ae_restrict hAE)
+ have hxcl : x ∈ closure A := by
+ apply Metric.mem_closure_iff.mpr
+ intro η hη
+ obtain ⟨y,hy,hgood⟩ := hdense.exists_mem_open (isOpen_ball.inter hΩ)
+ ⟨x,mem_ball_self hη,hx⟩
+ exact ⟨y,⟨hgood.2,hy hgood.2⟩,by simpa only [mem_ball,dist_comm] using hgood.1⟩
+ obtain ⟨y,hy,hyt⟩ := mem_closure_iff_seq_limit.mp hxcl
+ have hut : Tendsto (fun k => u (y k)) atTop (𝓝 (u x)) :=
+ (hu.continuousAt (hΩ.mem_nhds hx)).tendsto.comp hyt
+ have hdist : Tendsto (fun k => dist (u x) (u (y k))+δ+(L*dist (y k) x+ε))
+ atTop (𝓝 (δ+ε)) := by
+ have h1 := (tendsto_const_nhds : Tendsto (fun _ : ℕ => u x) atTop (𝓝 (u x))).dist hut
+ have h2 := hyt.dist (tendsto_const_nhds : Tendsto (fun _ : ℕ => x) atTop (𝓝 x))
+ simpa only [dist_self,mul_zero,zero_add] using (h1.add_const δ).add ((h2.const_mul L).add_const ε)
+ apply ge_of_tendsto hdist
+ exact Eventually.of_forall fun k => calc
+ dist (u x) (F x) ≤ dist (u x) (u (y k))+dist (u (y k)) (F x) := dist_triangle _ _ _
+ _ ≤ dist (u x) (u (y k))+(dist (u (y k)) (F (y k))+dist (F (y k)) (F x)) := by
+ linarith [dist_triangle (u (y k)) (F (y k)) (F x)]
+ _ ≤ dist (u x) (u (y k))+δ+(L*dist (y k) x+ε) := by
+ have h1 := (hy k).2
+ have h2 := hF (y k) (hy k).1 x hx
+ linarith
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ContinuousHamiltonJacobiComparison.lean b/lean/OAI/Geometry/RCD/Harmonic/ContinuousHamiltonJacobiComparison.lean
new file mode 100644
index 0000000000000000000000000000000000000000..186f364edc81d29b4e44ade3c8c7ed93d4d4b6f0
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ContinuousHamiltonJacobiComparison.lean
@@ -0,0 +1,54 @@
+import OAI.Geometry.RCD.Harmonic.TimeAveragePairing
+
+namespace OAI
+
+/-! # Removing the time average in an endpoint action inequality -/
+
+open Set Filter MeasureTheory
+open scoped Topology NNReal
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem continuous_comparison_of_time_averages
+ {X Y : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [MeasurableSpace Y] (ν : Measure Y) [IsFiniteMeasure ν]
+ (H : ℝ → X → ℝ) (hH : Measurable (Function.uncurry H))
+ {Ω : Set X} (hΩ : IsCompact Ω) {δ a b E : ℝ} {L : ℝ≥0}
+ (hL : LipschitzOnWith L (Function.uncurry H) (Ioo δ 1 ×ˢ Ω))
+ (e₀ e₁ : Y → X) (he₀ : Measurable e₀) (he₁ : Measurable e₁)
+ (hs₀ : ∀ᵐ y ∂ν, e₀ y ∈ Ω) (hs₁ : ∀ᵐ y ∂ν, e₁ y ∈ Ω)
+ (ha : δ < a) (hab : a < b) (hb : b < 1)
+ (hav : ∀ h : ℝ, 0 < h → δ < a-h → b+h < 1 →
+ (∫ y, timeIntervalAverage (fun q => H q (e₀ y)) h a ∂ν) -
+ (∫ y, timeIntervalAverage (fun q => H q (e₁ y)) h b ∂ν) ≤ E) :
+ (∫ y, H a (e₀ y) ∂ν)-(∫ y, H b (e₁ y) ∂ν) ≤ E := by
+ let M := ν.real univ*(L:ℝ)
+ have hM : 0 ≤ M := mul_nonneg measureReal_nonneg L.coe_nonneg
+ apply le_of_forall_pos_le_add
+ intro ε hε
+ have hsmall : 0 < min ((a-δ)/2) (min ((1-b)/2) (ε/(2*(M+1)))) := by positivity
+ obtain ⟨h,hh,hlim⟩ := exists_between hsmall
+ have hha : h < (a-δ)/2 := hlim.trans_le (min_le_left _ _)
+ have hrest := hlim.trans_le (min_le_right _ _)
+ have hhb : h < (1-b)/2 := hrest.trans_le (min_le_left _ _)
+ have hhM : h < ε/(2*(M+1)) := hrest.trans_le (min_le_right _ _)
+ have hha' : δ < a-h := by linarith
+ have hhb' : b+h < 1 := by linarith
+ have herror : 2*M*h < ε := by
+ have hm := (lt_div_iff₀ (by positivity : 0 < 2*(M+1))).mp hhM
+ nlinarith
+ have he₀ := time_average_pairing_error ν H hH hΩ hL e₀ he₀ hs₀ hh hha'
+ (show a+h < 1 by linarith)
+ have he₁ := time_average_pairing_error ν H hH hΩ hL e₁ he₁ hs₁ hh
+ (show δ < b-h by linarith) hhb'
+ have hcmp := hav h hh hha' hhb'
+ have h₀ := (abs_le.mp he₀).1
+ have h₁ := (abs_le.mp he₁).2
+ dsimp only [M] at herror
+ nlinarith
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ContinuousRadialMoment.lean b/lean/OAI/Geometry/RCD/Harmonic/ContinuousRadialMoment.lean
new file mode 100644
index 0000000000000000000000000000000000000000..45cff4331a891d2df22ae419d7768228d19bf30f
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ContinuousRadialMoment.lean
@@ -0,0 +1,40 @@
+import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap
+import Mathlib.MeasureTheory.Function.LocallyIntegrable
+
+namespace OAI
+
+/-! # A finite quadratic tail gives a global weighted moment -/
+
+open Set MeasureTheory Metric Filter
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [ProperSpace X] {μ : Measure X} [IsFiniteMeasureOnCompacts μ]
+
+theorem integrable_one_add_sq_of_tail {f : X → ℝ} (hf : Continuous f)
+ (hf0 : ∀ x, 0 ≤ f x) (p : X) {R : ℝ} (hR : 0 < R)
+ (htail : IntegrableOn (fun x => f x*(dist x p)^2) (ball p R)ᶜ μ) :
+ Integrable (fun x => f x*(1+(dist x p)^2)) μ := by
+ have hc : Continuous (fun x => f x*(1+(dist x p)^2)) := by fun_prop
+ have hi : IntegrableOn (fun x => f x*(1+(dist x p)^2)) (ball p R) μ :=
+ (hc.continuousOn.integrableOn_compact (isCompact_closedBall p R)).mono_set
+ (ball_subset_closedBall : ball p R ⊆ closedBall p R)
+ have ho : IntegrableOn (fun x => f x*(1+(dist x p)^2)) (ball p R)ᶜ μ := by
+ apply (htail.const_mul ((R^2)⁻¹+1)).mono' hc.aestronglyMeasurable
+ filter_upwards [ae_restrict_mem measurableSet_ball.compl] with x hx
+ have hd : R ≤ dist x p := le_of_not_gt hx
+ have hs : R^2 ≤ (dist x p)^2 := pow_le_pow_left₀ hR.le hd 2
+ have hsq : 0 < R^2 := sq_pos_of_pos hR
+ have hinv : (R^2)⁻¹*R^2 = 1 := inv_mul_cancel₀ hsq.ne'
+ have hh := mul_le_mul_of_nonneg_left hs (inv_nonneg.mpr hsq.le)
+ rw [hinv] at hh
+ rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (hf0 x) (by positivity))]
+ have hm := mul_le_mul_of_nonneg_left hh (hf0 x)
+ nlinarith
+ simpa only [union_compl_self,integrableOn_univ] using hi.union ho
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/ControlledCoefficientPathSelection.lean b/lean/OAI/Geometry/RCD/Harmonic/ControlledCoefficientPathSelection.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ef9558694af3010344b64b2dcbdbbb88af1727f6
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/ControlledCoefficientPathSelection.lean
@@ -0,0 +1,86 @@
+import OAI.Geometry.RCD.Coordinates.SobolevFramePathEnergy
+import OAI.Geometry.RCD.Harmonic.AffineVariationSelection
+
+namespace OAI
+
+/-! # Actual coefficient representatives on paths with vanishing affine-variation error -/
+
+open Set Filter MeasureTheory Finset
+open scoped Topology ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem controlled_coefficient_path_selection (μ : Measure X) (Q : QuadraticCheegerEnergy μ)
+ {n : ℕ} (G : ℕ → Fin n → SobolevSpace μ Q)
+ (π : ℕ → Measure C(Time,X)) [∀ k, IsProbabilityMeasure (π k)]
+ (hgeo : ∀ k, ∀ᵐ γ ∂π k, IsGeodesic γ) (C : ℕ → ℝ≥0∞) (hC : ∀ k, C k≠∞)
+ (hcomp : ∀ k (t : Time), (π k).map (fun γ => γ t)≤C k • μ)
+ (hD : ∀ k, MemLp (fun γ : C(Time,X) => dist (γ 0) (γ 1)) 2 (π k))
+ (r : ℕ → ℝ)
+ (hspeed : ∀ k, ∀ᵐ γ ∂π k, dist (γ 0) (γ 1)≤r k)
+ (Ω : ℕ → Set X) (hstay : ∀ k (t : Time), ∀ᵐ x ∂(π k).map (fun γ => γ t), x∈Ω k)
+ {M : ℝ} (henergy : ∀ k, (n:ℝ)*(r k)^2*(C k).toReal*
+ (∑ i, ∫ x in Ω k, localGamma μ Q (G k i) (G k i) x ∂μ)≤M)
+ (F : ℕ → Fin n → C(Time,X) → C(Time,ℝ))
+ (hFI : ∀ k i, Integrable (fun γ => ‖F k i γ‖) (π k))
+ (hFlim : Tendsto (fun k => ∫ γ, ∑ i, ‖F k i γ‖ ∂π k) atTop (𝓝 0))
+ (E : ℕ → X → ℝ) (hE : ∀ k x, 0≤E k x)
+ (hEI : ∀ k, IntegrableOn (E k) (Ω k) μ)
+ (hElim : Tendsto (fun k => ∫ γ, (∫ t in Icc (0:ℝ) 1,
+ E k (geodesicExtension γ t)) ∂π k) atTop (𝓝 0))
+ (P : ℕ → C(Time,X) → Prop) (hP : ∀ k, ∀ᵐ γ ∂π k, P k γ) :
+ ∃ (γ : ℕ → C(Time,X)) (b : ℕ → Fin n → ℝ → ℝ),
+ (∀ k, P k (γ k)) ∧
+ (∀ k i, AbsolutelyContinuousOnInterval (b k i) 0 1) ∧
+ (∀ k i, b k i =ᵐ[volume.restrict (Icc (0:ℝ) 1)]
+ fun t => SobolevSpace.toLp μ Q (G k i) (geodesicExtension (γ k) t)) ∧
+ Tendsto (fun k => ∑ i, ‖F k i (γ k)‖) atTop (𝓝 0) ∧
+ Tendsto (fun k => ∫ t in Icc (0:ℝ) 1, E k (geodesicExtension (γ k) t)) atTop (𝓝 0) ∧
+ Tendsto (fun k => (∑ i, ‖F k i (γ k)‖)*
+ (∑ i, ∫ t in Icc (0:ℝ) 1, |deriv (b k i) t|)) atTop (𝓝 0) := by
+ let A k γ := ∑ i, ‖F k i γ‖
+ let B k γ := (n:ℝ)*(r k)^2*framePathEnergy μ Q (G k) γ
+ let Z k γ := ∫ t in Icc (0:ℝ) 1, E k (geodesicExtension γ t)
+ have hB (k : ℕ) := compressed_frame_path_energy μ Q (G k) (π k) (hC k) (hcomp k) (hstay k)
+ have hZ (k : ℕ) := compressed_segment_integral μ (π k) (hC k) (hcomp k) (hstay k)
+ (hEI k) (Eventually.of_forall (hE k))
+ have hBI (k : ℕ) : Integrable (B k) (π k) := (hB k).1.const_mul _
+ have hBm (k : ℕ) : (∫ γ, B k γ ∂π k)≤M := by
+ rw [show (∫ γ, B k γ ∂π k)=(n:ℝ)*(r k)^2*(∫ γ, framePathEnergy μ Q (G k) γ ∂π k) from
+ integral_const_mul _ _]
+ exact (mul_le_mul_of_nonneg_left (hB k).2 (by positivity)).trans (by
+ simpa only [mul_assoc] using henergy k)
+ let R k γ := ∃ b : Fin n → ℝ → ℝ,
+ (∀ i, AbsolutelyContinuousOnInterval (b i) 0 1) ∧
+ (∀ i, b i =ᵐ[volume.restrict (Icc (0:ℝ) 1)]
+ fun t => SobolevSpace.toLp μ Q (G k i) (geodesicExtension γ t)) ∧
+ (∑ i, ∫ t in Icc (0:ℝ) 1, |deriv (b i) t|)^2≤B k γ
+ have hR (k : ℕ) : ∀ᵐ γ ∂π k, R k γ := by
+ filter_upwards [sobolev_frame_variation_envelope μ Q (G k) (π k) (hgeo k) (hC k) (hcomp k) (hD k),
+ hspeed k] with γ hγ hs
+ obtain ⟨b,hb,_h0,_h1,he,hv⟩ := hγ
+ refine ⟨b,hb,he,hv.trans ?_⟩
+ exact mul_le_mul_of_nonneg_right
+ (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ dist_nonneg hs 2) (Nat.cast_nonneg n))
+ (framePathEnergy_nonneg μ Q (G k) γ)
+ obtain ⟨γ,hγ,hA,hZlim,hprod⟩ := affine_variation_selection π A B Z
+ (fun k γ => P k γ ∧ R k γ)
+ (fun k => integrable_finsetSum _ (fun i _ => hFI k i)) hBI (fun k => (hZ k).1)
+ (fun k γ => sum_nonneg (fun _ _ => norm_nonneg _))
+ (fun k γ => mul_nonneg (by positivity) (framePathEnergy_nonneg μ Q (G k) γ))
+ (fun k γ => integral_nonneg (fun _ => hE k _)) (fun k => (hP k).and (hR k)) hFlim hElim hBm
+ choose b hb he hv using fun k => (hγ k).2
+ refine ⟨γ,b,fun k => (hγ k).1,hb,he,hA,hZlim,?_⟩
+ apply squeeze_zero (fun k => mul_nonneg (sum_nonneg (fun _ _ => norm_nonneg _))
+ (sum_nonneg (fun _ _ => integral_nonneg (fun _ => abs_nonneg _)))) _ hprod
+ intro k
+ apply mul_le_mul_of_nonneg_left (Real.le_sqrt_of_sq_le (hv k))
+ (sum_nonneg (fun _ _ => norm_nonneg _))
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/CurvatureHarmonicLimit.lean b/lean/OAI/Geometry/RCD/Harmonic/CurvatureHarmonicLimit.lean
new file mode 100644
index 0000000000000000000000000000000000000000..240e6a3ea4c7dce76c391135105c5908f1ee5e32
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/CurvatureHarmonicLimit.lean
@@ -0,0 +1,99 @@
+import OAI.Geometry.RCD.Harmonic.CurvatureHarmonicVariation
+import OAI.Geometry.RCD.Sobolev.CompactEnergyHarmonic
+import OAI.Geometry.RCD.Sobolev.SharpRecoveryEnergy
+import OAI.Geometry.RCD.Sobolev.HarmonicScaledEnergy
+import OAI.Geometry.RCD.Coordinates.EuclideanWeakHarmonicRegularity
+
+namespace OAI
+
+/-! # The weak Euclidean equation under the original curvature-scale bound
+
+Sharp recovered test energies and harmonic orthogonality force the compact
+Euclidean gradient pairing to vanish. No energy convergence is assumed.
+-/
+
+open Set Filter MeasureTheory Metric
+open scoped Topology NNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.harmonic_value_limit_weak_of_curvature {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2≤n)
+ {S : ℝ} (hS : 0 p (k+N)) (fun k => r (k+N))
+ (fun k => hr (k+N)) (fun k => hcurv (k+N)) (fun k => w (k+N))
+ (fun k => hw (k+N)) (fun k => hnorm (k+N))
+ obtain ⟨_,_,_,L,_,hL,_,_⟩ := hψ.metric_bounds hS
+ let G := smoothGradientTest (hψ.1.of_le (by simp)) hψ.2.1
+ have hqb : ∀ᶠ k in atTop, ∀ᵐ x ∂hausdorff n X,
+ r (k+N)^2*localGamma (hausdorff n X) hX.quadratic (q k).val (q k).val x≤(‖G‖+1)^2 := by
+ filter_upwards [hqg c hc.le hcS 1 zero_lt_one] with k hk
+ have hfull := supported_recovery_slope (hausdorff n X) hX.quadratic (q k).val
+ measurableSet_ball (fun x => add_nonneg (norm_nonneg _) zero_le_one) (hqz k) hk
+ filter_upwards [hfull,localGamma_self (hausdorff n X) hX.quadratic (q k).val,
+ (Lp.coeFn_nonneg _).mpr (SobolevSpace.minimalSlope_nonneg (hausdorff n X) hX.quadratic (q k).val)]
+ with x hx he hn'
+ have hb : ‖fderiv ℝ ψ (v (k+N) x)‖≤‖G‖ := by
+ simpa only [G,smoothGradientTest_apply,abs_of_nonneg (norm_nonneg _)] using
+ (le_abs_self (G (v (k+N) x))).trans (G.norm_coe_le_norm _)
+ rw [he]
+ simpa only [mul_pow] using pow_le_pow_left₀ (mul_nonneg (hr (k+N)).le hn')
+ (hx.trans (add_le_add hb le_rfl)) 2
+ have hqupper := hX.recovery_energy_upper hS (fun k => p (k+N))
+ (fun k => r (k+N)) (fun k => ε (k+N)) (fun k => v (k+N))
+ (fun k => hr (k+N)) (hεlim.comp (tendsto_add_atTop_nat N))
+ (fun k => hv (k+N)) (hψ.1.of_le (by simp)) hψ.2.1 (fun k => (q k).val)
+ hqz (hqg c hc.le hcS)
+ apply compact_energy_variation_harmonic hS hρS hg hψ
+ (hs.trans (ball_subset_ball haρ.le)) (M := volume.real (ball (0:Euclidean n) S)*M)
+ intro t
+ have hvar := hX.curvature_harmonic_variation hn hS hτ hρτ hτR hRS hcR
+ (fun k => p (k+N)) (fun k => r (k+N)) (fun k => ε (k+N)) (fun k => v (k+N))
+ (fun k => hr (k+N)) (fun k => hcurv (k+N))
+ (fun k => hε (k+N)) (fun k => hε1 (k+N)) (hεlim.comp (tendsto_add_atTop_nat N))
+ (fun k => hv (k+N)) (fun k => w (k+N)) (fun k => hw (k+N)) g ψ hg hL
+ (fun W hW hWS δ hδ => (tendsto_add_atTop_nat N).eventually (hconv W hW hWS δ hδ))
+ q hqc hqz hM (sq_nonneg (‖G‖+1)) hwb hqb
+ (by simpa only [div_eq_mul_inv] using hqupper) t
+ have hV : volume.real (ball (0:Euclidean n) S)≠0 :=
+ (ENNReal.toReal_pos (measure_ball_pos volume (0:Euclidean n) hS).ne' measure_ball_ne_top).ne'
+ convert hvar using 1
+ field_simp
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/CurvatureHarmonicVariation.lean b/lean/OAI/Geometry/RCD/Harmonic/CurvatureHarmonicVariation.lean
new file mode 100644
index 0000000000000000000000000000000000000000..dec10dc3a49390fcdc59986c62ea65388a37de80
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/CurvatureHarmonicVariation.lean
@@ -0,0 +1,148 @@
+import OAI.Geometry.RCD.Sobolev.UniformEventualLowerEnergy
+import OAI.Geometry.RCD.Sobolev.SupportedGammaIntegral
+import OAI.Geometry.RCD.Sobolev.RescaledLocalEnergyBound
+import OAI.Geometry.RCD.Sobolev.DirichletTestRecoverySequence
+import OAI.Geometry.RCD.Sobolev.CorrectionInteriorEnergy
+
+namespace OAI
+
+/-! # The variational lower bound for actual harmonic perturbations
+
+The test is in the original Dirichlet space. Its compact support makes the
+mixed source energy vanish on any containing interior ball.
+-/
+
+open Set Filter MeasureTheory Metric
+open scoped Topology NNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.curvature_harmonic_variation {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2≤n)
+ {S ρ τ R c : ℝ} (hS : 0 g y+t*ψ y) z‖^2)≤
+ volume.real (ball (0:Euclidean n) S)*(M+t^2*P) := by
+ let μ := hausdorff n X
+ let F := fun k => w k+t • (q k).val
+ have hFconv (W : ℝ) (hW : 0 g y+t*ψ y) (closedBall 0 W) := by
+ intro W hWS
+ obtain ⟨B,hB⟩ := hg W hWS
+ exact ⟨_,hB.add ((lipschitzWith_smul t).comp hψ).lipschitzOnWith⟩
+ have hFb : ∀ᶠ k in atTop, ∀ᵐ x ∂μ.restrict (closedBall (p k) (R*r k)),
+ r k^2*localGamma μ hX.quadratic (F k) (F k) x≤2*M+2*t^2*Q := by
+ filter_upwards [hqb] with k hk
+ filter_upwards [hwb k,ae_restrict_of_ae hk,
+ ae_restrict_of_ae (localGamma_add_self_le μ hX.quadratic (w k) (t • (q k).val)),
+ ae_restrict_of_ae (localGamma_smul_left μ hX.quadratic t (q k).val (t • (q k).val)),
+ ae_restrict_of_ae (localGamma_smul_right μ hX.quadratic t (q k).val (q k).val)]
+ with x hwx hqx hx hl hr'
+ have ht : localGamma μ hX.quadratic (t • (q k).val) (t • (q k).val) x=
+ t^2*localGamma μ hX.quadratic (q k).val (q k).val x := by rw [hl,hr']; ring
+ rw [ht] at hx
+ have hh := mul_le_mul_of_nonneg_left hx (sq_nonneg (r k))
+ nlinarith [mul_le_mul_of_nonneg_left hqx (sq_nonneg t)]
+ have hFupper (δ : ℝ) (hδ : 0<δ) : ∀ᶠ k in atTop,
+ (r k^2/μ.real (ball (p k) (S*r k)))*
+ (∫ x in closedBall (p k) (R*r k), localGamma μ hX.quadratic (F k) (F k) x ∂μ)≤
+ (M+t^2*P)+δ := by
+ let a := δ/(1+t^2)
+ have ha : 0 hx (fun hm => hn (ball_subset_closedBall
+ ((ball_subset_ball (mul_le_mul_of_nonneg_right hcR.le (hr k).le)) hm)))
+ have hzeroU : ∀ᵐ x ∂μ, x∉ball (p k) (S*r k) → SobolevSpace.toLp μ hX.quadratic (q k).val x=0 :=
+ hzeroA.mono fun x hx hn => hx (fun hm => hn (hsub hm))
+ have horth : (∫ x in closedBall (p k) (R*r k), localGamma μ hX.quadratic (w k) (q k).val x ∂μ)=0 := by
+ rw [supported_gamma_integral μ hX.quadratic _ _ _ hzeroA,
+ ← supported_gamma_integral μ hX.quadratic _ _ _ hzeroU]
+ exact recovered_dirichlet_harmonic_pairing_zero μ hX.quadratic measurableSet_ball (hw k) (q k)
+ have hqe : (∫ x in closedBall (p k) (R*r k), localGamma μ hX.quadratic (q k).val (q k).val x ∂μ)=
+ ∫ x in ball (p k) (S*r k), localGamma μ hX.quadratic (q k).val (q k).val x ∂μ := by
+ rw [supported_gamma_integral μ hX.quadratic _ _ _ hzeroA,
+ supported_gamma_integral μ hX.quadratic _ _ _ hzeroU]
+ have hpos : 0<μ.real (ball (p k) (S*r k)) := ENNReal.toReal_pos
+ (hX.fullSupport _ _ (mul_pos hS (hr k))).ne' (hX.finiteOnBounded _ isBounded_ball).ne
+ have hb := rescaled_local_energy_bound μ hX.quadratic (w k) hsub
+ (hX.finiteOnBounded _ isBounded_ball).ne hpos hM (hwb k)
+ change _≤P+a at hk
+ change _≤M at hb
+ dsimp only [F]
+ rw [integral_harmonic_perturbation μ hX.quadratic _ _ t _ horth,hqe,mul_add]
+ have he : (r k^2/μ.real (ball (p k) (S*r k)))*
+ (t^2*∫ x in ball (p k) (S*r k), localGamma μ hX.quadratic (q k).val (q k).val x ∂μ)=
+ t^2*((r k^2/μ.real (ball (p k) (S*r k)))*
+ ∫ x in ball (p k) (S*r k), localGamma μ hX.quadratic (q k).val (q k).val x ∂μ) := by ring
+ rw [he]
+ have hh := add_le_add hb (mul_le_mul_of_nonneg_left hk (sq_nonneg t))
+ apply hh.trans
+ have he' : a*(1+t^2)=δ := by dsimp only [a]; field_simp
+ nlinarith [ha.le]
+ exact (hX.gradient_energy_lower_of_curvature_eventual_sequence hn hS hτ hρτ hτR hRS p r ε v
+ hr hcurv hε hε1 hεlim hv F (fun y => g y+t*ψ y) hFlip hFconv
+ (by positivity : 0≤2*M+2*t^2*Q) hFb hFupper).2
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/DefectSegment.lean b/lean/OAI/Geometry/RCD/Harmonic/DefectSegment.lean
new file mode 100644
index 0000000000000000000000000000000000000000..f6b89d9eba54f2360ae4904dc68a030210ae494e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/DefectSegment.lean
@@ -0,0 +1,82 @@
+import OAI.Geometry.RCD.Transport.CompressedSegmentNullSet
+import OAI.Geometry.RCD.Transport.TransportLevelBound
+
+namespace OAI
+
+/-! # An actual geodesic with controlled local defect
+
+Positive endpoint sets are connected by the already constructed RCD
+bounded-compression plan. First-moment selection retains its endpoints,
+geodesicity, and whole-path containment. No segment or splitting input is
+assumed.
+-/
+
+open Set Filter Metric MeasureTheory
+open scoped ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem NoncollapsedRCD.exists_defect_segment {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n)
+ (p : X) {R : ℝ} (hR : 0 < R) {A B : Set X}
+ (hA : MeasurableSet A) (hB : MeasurableSet B)
+ (hA0 : hausdorff n X A ≠ 0) (hB0 : hausdorff n X B ≠ 0)
+ (hsA : A ⊆ closedBall p R) (hsB : B ⊆ closedBall p R)
+ {F : X → ℝ} (hF : IntegrableOn F (ball p (8*R)) (hausdorff n X))
+ (hFpos : ∀ᵐ x ∂(hausdorff n X).restrict (ball p (8*R)), 0 ≤ F x)
+ {P : X → Prop} (hP : ∀ᵐ x ∂(hausdorff n X).restrict (ball p (8*R)), P x) :
+ ∃ γ : C(Time,X), IsGeodesic γ ∧ γ 0 ∈ A ∧ γ 1 ∈ B ∧
+ (∀ t : Time, dist (γ t) p ≤ 3*R) ∧
+ (∀ᵐ t ∂volume.restrict (Icc (0:ℝ) 1), P (geodesicExtension γ t)) ∧
+ IntegrableOn (fun t => F (geodesicExtension γ t)) (Icc (0:ℝ) 1) ∧
+ (∫ t in Icc (0:ℝ) 1, F (geodesicExtension γ t)) ≤
+ (compressionBudget K n (2*R)
+ (max (hausdorff n X A)⁻¹ (hausdorff n X B)⁻¹)).toReal *
+ ∫ x in ball p (8*R), F x ∂hausdorff n X := by
+ let μ := hausdorff n X
+ let C : ℝ≥0∞ := max (μ A)⁻¹ (μ B)⁻¹
+ have hAt : μ A ≠ ∞ := (hX.finiteOnBounded A (isBounded_closedBall.subset hsA)).ne
+ have hBt : μ B ≠ ∞ := (hX.finiteOnBounded B (isBounded_closedBall.subset hsB)).ne
+ have hC : C ≠ ∞ := max_ne_top (ENNReal.inv_ne_top.mpr hA0) (ENNReal.inv_ne_top.mpr hB0)
+ let := uniformOn_probability μ A hA0 hAt
+ let := uniformOn_probability μ B hB0 hBt
+ have hbA : ∀ᵐ x ∂uniformOn μ A, dist x p ≤ R :=
+ (uniformOn_ae_mem μ A hA).mono fun _ hx => hsA hx
+ have hbB : ∀ᵐ x ∂uniformOn μ B, dist x p ≤ R :=
+ (uniformOn_ae_mem μ B hB).mono fun _ hx => hsB hx
+ obtain ⟨π,hπ,hgeo,hopt,_hi,hall⟩ := hX.exists_bounded_entropy_plan K n hn
+ (uniformOn μ A) (uniformOn μ B) hC (uniformOn_le_scaled μ A (le_max_left _ _))
+ (uniformOn_le_scaled μ B (le_max_right _ _)) p hR.le hbA hbB
+ let := hπ
+ have hend := optimalPlan_endpoints (uniformOn μ A) (uniformOn μ B) π hopt
+ have hpaths := optimal_geodesic_plan_bounded (uniformOn μ A) (uniformOn μ B)
+ π hgeo hopt p hR.le hbA hbB
+ have hstay (t : Time) : ∀ᵐ x ∂π.map (fun γ => γ t), x ∈ ball p (8*R) := by
+ apply (ae_map_iff (measurable_path_eval t).aemeasurable measurableSet_ball).mpr
+ filter_upwards [hpaths] with γ hγ
+ linarith [hγ.2 t]
+ have hstart : ∀ᵐ γ ∂π, γ 0 ∈ A := by
+ apply ae_of_ae_map (measurable_path_eval 0).aemeasurable
+ rw [hend.1]
+ exact uniformOn_ae_mem μ A hA
+ have hfinish : ∀ᵐ γ ∂π, γ 1 ∈ B := by
+ apply ae_of_ae_map (measurable_path_eval 1).aemeasurable
+ rw [hend.2]
+ exact uniformOn_ae_mem μ B hB
+ have hgood : ∀ᵐ γ ∂π, IsGeodesic γ ∧ γ 0 ∈ A ∧ γ 1 ∈ B ∧
+ (∀ t : Time, dist (γ t) p ≤ 3*R) ∧
+ (∀ᵐ t ∂volume.restrict (Icc (0:ℝ) 1), P (geodesicExtension γ t)) := by
+ have hPa := compressed_segment_ae μ π (fun t => (hall t).1) hstay hP
+ filter_upwards [hpaths,hstart,hfinish,hPa] with γ hγ ha hb hp
+ exact ⟨hγ.1,ha,hb,hγ.2,hp⟩
+ obtain ⟨γ,hγ,hinner,hbound⟩ := exists_compressed_segment μ π
+ (compressionBudget_ne_top K n (2*R) hC) (fun t => (hall t).1) hstay hF hFpos hgood
+ exact ⟨γ,hγ.1,hγ.2.1,hγ.2.2.1,hγ.2.2.2.1,hγ.2.2.2.2,hinner,hbound⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/DirectionRecoveryScale.lean b/lean/OAI/Geometry/RCD/Harmonic/DirectionRecoveryScale.lean
new file mode 100644
index 0000000000000000000000000000000000000000..e26bc06be773fe7aa9854716fdf3cc0beac981cd
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/DirectionRecoveryScale.lean
@@ -0,0 +1,87 @@
+import OAI.Geometry.RCD.Harmonic.TwoCenterDirectionEstimate
+
+namespace OAI
+
+/-! # Uniform physical scaling of the constant-direction estimate -/
+
+namespace RegularPointCoordinates
+
+noncomputable def directionRecoveryError (A V E C : ℝ) : ℝ :=
+ 2 * A * Real.sqrt E + Real.sqrt C + A * Real.sqrt (2 * E) + Real.sqrt (2 * V) / 4
+
+noncomputable def directionRecoveryConstant (A V E C G M : ℝ) : ℝ :=
+ Real.sqrt (2 * V) + (81920 * G + 4 * M) * directionRecoveryError A V E C
+
+/-- The error obtained from the actual radial fits has one length factor
+and one square root of the original pair source envelope. -/
+theorem direction_recovery_scaled_error {s A V E C x z p : ℝ}
+ (hs : 0 < s) (hA : 0 ≤ A) (hV : 0 ≤ V) (hE : 0 ≤ E) (hC : 0 ≤ C)
+ (hx : 0 ≤ x) (hz : 0 ≤ z) (_hp : 0 ≤ p) (hpS : p ≤ x + z) :
+ (2 * A * s) * Real.sqrt (E * z) + Real.sqrt (C * s ^ 2 * p) +
+ (A * s) * Real.sqrt (2 * (E * z) + 2 * (E * x)) +
+ Real.sqrt (2 * (V * s ^ 2 * z) + 2 * (V * s ^ 2 * x)) / 4 ≤
+ s * directionRecoveryError A V E C * Real.sqrt (x + z) := by
+ have hS : 0 ≤ x + z := add_nonneg hx hz
+ have hzS : z ≤ x + z := by linarith
+ have hzroot := Real.sqrt_le_sqrt (mul_le_mul_of_nonneg_left hzS hE)
+ simp only [Real.sqrt_mul hE] at hzroot
+ have hroot (c : ℝ) (hc : 0 ≤ c) : Real.sqrt (c * s ^ 2 * (x + z)) =
+ s * Real.sqrt c * Real.sqrt (x + z) := by
+ rw [show c * s ^ 2 * (x + z) = s ^ 2 * (c * (x + z)) by ring,
+ Real.sqrt_mul (sq_nonneg s), Real.sqrt_sq hs.le, Real.sqrt_mul hc]
+ ring
+ have hpbound := Real.sqrt_le_sqrt (mul_le_mul_of_nonneg_left hpS
+ (mul_nonneg hC (sq_nonneg s)))
+ rw [hroot C hC] at hpbound
+ have heq : Real.sqrt (2 * (E * z) + 2 * (E * x)) =
+ Real.sqrt (2 * E) * Real.sqrt (x + z) := by
+ rw [show 2 * (E * z) + 2 * (E * x) = (2 * E) * (x + z) by ring,
+ Real.sqrt_mul (by positivity : 0 ≤ 2 * E)]
+ have hvq : Real.sqrt (2 * (V * s ^ 2 * z) + 2 * (V * s ^ 2 * x)) =
+ s * Real.sqrt (2 * V) * Real.sqrt (x + z) := by
+ rw [show 2 * (V * s ^ 2 * z) + 2 * (V * s ^ 2 * x) = (2 * V) * s ^ 2 * (x + z) by ring]
+ exact hroot (2 * V) (by positivity)
+ have hfirst := mul_le_mul_of_nonneg_left hzroot (by positivity : 0 ≤ 2 * A * s)
+ rw [heq, hvq, Real.sqrt_mul hE]
+ dsimp only [directionRecoveryError]
+ nlinarith only [hfirst, hpbound]
+
+/-- The reciprocal length from coefficient recovery cancels the length
+in the error, leaving a uniform physical direction bound. -/
+theorem direction_recovery_scaled_bound {s A V E C G M x z p : ℝ}
+ (hs : 0 < s) (hA : 0 ≤ A) (hV : 0 ≤ V) (hE : 0 ≤ E) (hC : 0 ≤ C)
+ (hG : 0 ≤ G) (hM : 0 ≤ M) (hx : 0 ≤ x) (hz : 0 ≤ z)
+ (hp : 0 ≤ p) (hpS : p ≤ x + z) :
+ let a := 4 * (G / (s / 2048))
+ let err := (2 * A * s) * Real.sqrt (E * z) + Real.sqrt (C * s ^ 2 * p) +
+ (A * s) * Real.sqrt (2 * (E * z) + 2 * (E * x)) +
+ Real.sqrt (2 * (V * s ^ 2 * z) + 2 * (V * s ^ 2 * x)) / 4
+ Real.sqrt (2 * (V * s ^ 2 * z) + 2 * (V * s ^ 2 * x)) +
+ s * (2 * a * err) + 2 * (2 * M * err + (2 * s) * (2 * a * err)) ≤
+ directionRecoveryConstant A V E C G M * s * Real.sqrt (x + z) := by
+ intro a err
+ have he := direction_recovery_scaled_error hs hA hV hE hC hx hz hp hpS
+ have ha : 0 ≤ a := by dsimp only [a]; positivity
+ have hcoeff : 0 ≤ s * (2 * a) + 4 * M + 4 * s * (2 * a) := by positivity
+ have hmul := mul_le_mul_of_nonneg_left he hcoeff
+ have hroot : Real.sqrt (2 * (V * s ^ 2 * z) + 2 * (V * s ^ 2 * x)) =
+ s * Real.sqrt (2 * V) * Real.sqrt (x + z) := by
+ rw [show 2 * (V * s ^ 2 * z) + 2 * (V * s ^ 2 * x) = s ^ 2 * ((2 * V) * (x + z)) by ring,
+ Real.sqrt_mul (sq_nonneg s), Real.sqrt_sq hs.le,
+ Real.sqrt_mul (by positivity : 0 ≤ 2 * V)]
+ ring
+ have hscale : (s * (2 * a) + 4 * M + 4 * s * (2 * a)) *
+ (s * directionRecoveryError A V E C * Real.sqrt (x + z)) =
+ (81920 * G + 4 * M) * s * directionRecoveryError A V E C * Real.sqrt (x + z) := by
+ dsimp only [a]
+ field_simp; ring
+ rw [hscale] at hmul
+ change (s * (2 * a) + 4 * M + 4 * s * (2 * a)) * err ≤ _ at hmul
+ rw [hroot]
+ change _ ≤ _ at hmul
+ dsimp only [directionRecoveryConstant]
+ nlinarith only [hmul]
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/DirectionSmallness.lean b/lean/OAI/Geometry/RCD/Harmonic/DirectionSmallness.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ec02ef5334f19e6f7b31ddf4e68b37eb8ec636d8
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/DirectionSmallness.lean
@@ -0,0 +1,81 @@
+import OAI.Geometry.RCD.Harmonic.DirectionRecoveryScale
+
+namespace OAI
+
+/-! # One scale-independent tolerance for actual direction recovery -/
+
+namespace RegularPointCoordinates
+
+/-- A single tolerance controls the two Gram restrictions, the radial
+matrix error, and the absorption term at every positive physical radius. -/
+theorem direction_smallness_parameters (n : ℕ) (Ca D Q V G : ℝ)
+ (hQ : 0 ≤ Q) (hV : 0 ≤ V) (hG : 0 ≤ G) :
+ ∃ tau : ℝ, 0 < tau ∧ tau ≤ 1 ∧
+ (n : ℝ) ^ 2 * (((5 / 3 : ℝ) * (2 : ℝ) ^ n) * tau) ≤ 1 / 3 ∧
+ (n : ℝ) ^ 2 * (((5 / 3 : ℝ) * (8192 : ℝ) ^ n) * tau) ≤ 1 / 2 ∧
+ ∀ z E : ℝ, 0 ≤ z → z ≤ tau → 0 ≤ E → E ≤ tau →
+ 2 * ((n : ℝ) ^ 4 * Real.sqrt (2 * Ca ^ 2 * (D ^ 2 * E + Q * z))) ≤ 1 / 4 ∧
+ ∀ s : ℝ, 0 < s →
+ (4 * (G / (s / 2048))) * Real.sqrt (V * s ^ 2 * E) ≤ 1 / 2 := by
+ let L1 := (n : ℝ) ^ 2 * ((5 / 3 : ℝ) * (2 : ℝ) ^ n)
+ let L2 := (n : ℝ) ^ 2 * ((5 / 3 : ℝ) * (8192 : ℝ) ^ n)
+ let a := 2 * (n : ℝ) ^ 4 * Real.sqrt (2 * Ca ^ 2 * (D ^ 2 + Q))
+ let b := 8192 * G * Real.sqrt V
+ have hL1 : 0 ≤ L1 := by dsimp only [L1]; positivity
+ have hL2 : 0 ≤ L2 := by dsimp only [L2]; positivity
+ have ha : 0 ≤ a := by dsimp only [a]; positivity
+ have hb : 0 ≤ b := by dsimp only [b]; positivity
+ let t := 1 / (4 * (a + b + 1))
+ have ht : 0 < t := by dsimp only [t]; positivity
+ have hteq : (a + b + 1) * t = 1 / 4 := by
+ dsimp only [t]
+ field_simp
+ let tau := min (1 / (3 * (L1 + 1))) (min (1 / (2 * (L2 + 1))) (min 1 (t ^ 2)))
+ have htau : 0 < tau := by dsimp only [tau]; positivity
+ have hbounds : tau ≤ 1 / (3 * (L1 + 1)) ∧ tau ≤ 1 / (2 * (L2 + 1)) ∧
+ tau ≤ 1 ∧ tau ≤ t ^ 2 := by
+ have h : tau ≤ tau := le_rfl
+ simpa only [tau, le_min_iff] using h
+ have h1 := (le_div_iff₀ (by positivity : 0 < 3 * (L1 + 1))).mp hbounds.1
+ have h2 := (le_div_iff₀ (by positivity : 0 < 2 * (L2 + 1))).mp hbounds.2.1
+ have hroot : Real.sqrt tau ≤ t := by
+ have hh := Real.sqrt_le_sqrt hbounds.2.2.2
+ simpa only [Real.sqrt_sq ht.le] using hh
+ refine ⟨tau, htau, hbounds.2.2.1, ?_, ?_, ?_⟩
+ · have hh : L1 * tau ≤ 1 / 3 := by nlinarith only [h1, htau.le]
+ simpa only [L1, mul_assoc] using hh
+ · have hh : L2 * tau ≤ 1 / 2 := by nlinarith only [h2, htau.le]
+ simpa only [L2, mul_assoc] using hh
+ · intro z E hz hzt hE hEt
+ have hsum : D ^ 2 * E + Q * z ≤ (D ^ 2 + Q) * tau := by
+ nlinarith only [mul_le_mul_of_nonneg_left hEt (sq_nonneg D),
+ mul_le_mul_of_nonneg_left hzt hQ]
+ have hmatrix := Real.sqrt_le_sqrt (mul_le_mul_of_nonneg_left hsum (by positivity : 0 ≤ 2 * Ca ^ 2))
+ rw [show 2 * Ca ^ 2 * ((D ^ 2 + Q) * tau) = (2 * Ca ^ 2 * (D ^ 2 + Q)) * tau by ring,
+ Real.sqrt_mul (by positivity : 0 ≤ 2 * Ca ^ 2 * (D ^ 2 + Q))] at hmatrix
+ have hmatrix' := mul_le_mul_of_nonneg_left hmatrix (by positivity : 0 ≤ 2 * (n : ℝ) ^ 4)
+ have haroot := mul_le_mul_of_nonneg_left hroot ha
+ have hat : a * t ≤ 1 / 4 := by
+ nlinarith only [hteq, mul_nonneg hb ht.le, ht.le]
+ refine ⟨?_, ?_⟩
+ · calc
+ _ ≤ a * Real.sqrt tau := by simpa only [a, mul_assoc] using hmatrix'
+ _ ≤ a * t := haroot
+ _ ≤ 1 / 4 := hat
+ · intro s hs
+ have hEroot := Real.sqrt_le_sqrt hEt
+ have hbt : b * t ≤ 1 / 4 := by
+ nlinarith only [hteq, mul_nonneg ha ht.le, ht.le]
+ have hbe : b * Real.sqrt E ≤ 1 / 4 :=
+ (mul_le_mul_of_nonneg_left (hEroot.trans hroot) hb).trans hbt
+ have heq : (4 * (G / (s / 2048))) * Real.sqrt (V * s ^ 2 * E) = b * Real.sqrt E := by
+ rw [show V * s ^ 2 * E = s ^ 2 * (V * E) by ring,
+ Real.sqrt_mul (sq_nonneg s), Real.sqrt_sq hs.le, Real.sqrt_mul hV]
+ dsimp only [b]
+ field_simp; ring
+ rw [heq]
+ linarith only [hbe]
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/DirectionalToGramError.lean b/lean/OAI/Geometry/RCD/Harmonic/DirectionalToGramError.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ee96b4dd71c896f2ba8bc312cde5eb6a99175c40
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/DirectionalToGramError.lean
@@ -0,0 +1,80 @@
+import OAI.Geometry.RCD.Sobolev.SobolevQuadraticEnergy
+import OAI.Geometry.RCD.Harmonic.GramDirectionalError
+
+namespace OAI
+
+/-! # Recovering all Gram entries from directional L1 errors -/
+
+open Set MeasureTheory
+open scoped InnerProductSpace
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem directional_error_implies_gram (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ {n : ℕ} (u : Fin n → SobolevSpace μ hQ) (S : Set X) (hf : μ S ≠ ⊤)
+ {D : ℝ} (hD : 0 ≤ D)
+ (herr : ∀ z : Euclidean n, (μ.real S)⁻¹*(∫ x in S,
+ |localGamma μ hQ (sobolevColumnMap μ hQ u z) (sobolevColumnMap μ hQ u z) x-‖z‖^2| ∂μ)
+ ≤ D*‖z‖^2) :
+ ∀ i j : Fin n, (μ.real S)⁻¹*(∫ x in S,
+ |localGamma μ hQ (u i) (u j) x-(if i=j then 1 else 0)| ∂μ) ≤ 2*D := by
+ classical
+ have hd (i : Fin n) : (μ.real S)⁻¹*(∫ x in S,
+ |localGamma μ hQ (u i) (u i) x-1| ∂μ) ≤ D := by
+ simpa only [sobolevColumnMap_single,PiLp.norm_single,norm_one,one_pow,mul_one]
+ using herr (EuclideanSpace.single i 1)
+ intro i j
+ by_cases hij : i=j
+ · subst j
+ simpa using (hd i).trans (by linarith : D ≤ 2*D)
+ let ei : Euclidean n := EuclideanSpace.single i 1
+ let ej : Euclidean n := EuclideanSpace.single j 1
+ have hn : ‖ei+ej‖^2=2 := by
+ rw [norm_add_sq_real]
+ norm_num [ei,ej,EuclideanSpace.inner_single_left,hij]
+ have hsum : (μ.real S)⁻¹*(∫ x in S,
+ |localGamma μ hQ (u i+u j) (u i+u j) x-2| ∂μ) ≤ 2*D := by
+ have he := herr (ei+ej)
+ rw [hn,map_add,sobolevColumnMap_single,sobolevColumnMap_single] at he
+ simpa only [mul_comm] using he
+ have hi (g : SobolevSpace μ hQ) (a : ℝ) :
+ IntegrableOn (fun x => |localGamma μ hQ g g x-a|) S μ :=
+ ((localGamma_memL1 μ hQ g g).integrableOn.sub (integrableOn_const hf)).abs
+ have he := localGamma_add_smul_square μ hQ (u i) (u j) 1
+ simp only [one_smul,one_pow,mul_one,one_mul] at he
+ have hpt : ∀ᵐ x ∂μ.restrict S,
+ 2*|localGamma μ hQ (u i) (u j) x| ≤
+ |localGamma μ hQ (u i+u j) (u i+u j) x-2|+
+ (|localGamma μ hQ (u i) (u i) x-1|+|localGamma μ hQ (u j) (u j) x-1|) := by
+ filter_upwards [ae_restrict_of_ae he] with x hx
+ have habs : 2*|localGamma μ hQ (u i) (u j) x| =
+ |(localGamma μ hQ (u i+u j) (u i+u j) x-2)-
+ (localGamma μ hQ (u i) (u i) x-1)-
+ (localGamma μ hQ (u j) (u j) x-1)| := by
+ rw [hx]
+ have hr : localGamma μ hQ (u i) (u i) x+2*localGamma μ hQ (u i) (u j) x+
+ localGamma μ hQ (u j) (u j) x-2-(localGamma μ hQ (u i) (u i) x-1)-
+ (localGamma μ hQ (u j) (u j) x-1)=2*localGamma μ hQ (u i) (u j) x := by ring
+ rw [hr,abs_mul,abs_of_pos (by norm_num : (0 : ℝ) < 2)]
+ rw [habs]
+ exact (abs_sub _ _).trans (by
+ have hh := abs_sub (localGamma μ hQ (u i+u j) (u i+u j) x-2)
+ (localGamma μ hQ (u i) (u i) x-1)
+ linarith)
+ have hint := integral_mono_ae
+ ((localGamma_memL1 μ hQ (u i) (u j)).abs.integrableOn.const_mul 2)
+ ((hi (u i+u j) 2).add ((hi (u i) 1).add (hi (u j) 1))) hpt
+ have hadd := integral_add (hi (u i+u j) 2) ((hi (u i) 1).add (hi (u j) 1))
+ have hadd' := integral_add (hi (u i) 1) (hi (u j) 1)
+ simp only [Pi.add_apply] at hint hadd hadd'
+ rw [integral_const_mul,hadd,hadd'] at hint
+ have hh := mul_le_mul_of_nonneg_left hint (inv_nonneg.mpr (measureReal_nonneg : 0 ≤ μ.real S))
+ simp only [ite_eq_right hij,sub_zero]
+ nlinarith [hd i,hd j]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/DistanceQuadraticPathLimit.lean b/lean/OAI/Geometry/RCD/Harmonic/DistanceQuadraticPathLimit.lean
new file mode 100644
index 0000000000000000000000000000000000000000..cf0a13b5daa7aeb909de6e83d7adf4834c59cef9
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/DistanceQuadraticPathLimit.lean
@@ -0,0 +1,116 @@
+import OAI.Geometry.RCD.Sobolev.PoissonPathDefectLimit
+import OAI.Geometry.RCD.Sobolev.DistancePoissonAbsoluteValues
+import OAI.Geometry.RCD.Harmonic.InteriorQuadraticComparison
+
+namespace OAI
+
+/-! # Absolute quadratic path errors for the actual distance functions -/
+
+open Set Filter Metric MeasureTheory TopologicalSpace
+open scoped Topology NNReal ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ {K : ℝ} {n : ℕ} {hX : NoncollapsedRCD K n X} {hn : 2≤n} [SeparableSpace X]
+ [IsLocallyFiniteMeasure (hausdorff n X)] [(hausdorff n X).Regular]
+ {κ B J C : ℝ} {p : ℕ → X} {r : ℕ → ℝ} {hr : ∀ k, 0 s⁻¹ • (v x-v p)) := by
+ classical
+ by_contra hnot
+ push Not at hnot
+ let e : ℕ → ℝ := fun k => 1/((k:ℝ)+1)
+ have he (k : ℕ) : 0 ((continuous_weak_harmonic d.continuous d.weak x hx).sub (hψh x hx)).2.self_of_nhds)
+ hη hlayer
+ intro x hx
+ have he := hz hx
+ change d.value x-ψ x=0 at he
+ exact sub_eq_zero.mp he
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HarmonicBoundaryLayer.lean b/lean/OAI/Geometry/RCD/Harmonic/HarmonicBoundaryLayer.lean
new file mode 100644
index 0000000000000000000000000000000000000000..647b07c6b3282f2097bc6c7974cef00fb331b2d6
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HarmonicBoundaryLayer.lean
@@ -0,0 +1,56 @@
+import OAI.Geometry.RCD.Sobolev.BoundaryDirichletLayer
+import OAI.Geometry.RCD.Sobolev.HarmonicReplacementEnergy
+
+namespace OAI
+
+/-! # The boundary values retained by actual harmonic replacements -/
+
+open Set Metric MeasureTheory
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.harmonic_replacement_boundary_layer {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2≤n) :
+ ∃ C : ℝ, 0 harmonic_interior_bounded_representative hX hn hmean hgradient
+ (sq_nonneg S) (div_pos (hT m) hS) ((div_lt_one hS).mpr (hTS m))
+ have hC0 (m : ℕ) : 0≤C m := zero_le_one.trans (hC m)
+ have hcurv' (k : ℕ) : -(S^2)≤K*(S*r k)^2 := by
+ have hh := mul_le_mul_of_nonneg_left (hcurv k) (sq_nonneg S)
+ nlinarith only [hh]
+ have hreps (m k : ℕ) : ∃ w : X → ℝ, LipschitzWith (C m/(S*r k)).toNNReal w ∧
+ (∀ x, |w x|≤C m) ∧ SobolevSpace.toLp μ hX.quadratic (u k) =ᵐ[
+ μ.restrict (ball (p k) (T m*r k))] w := by
+ have hh := hrep m (p k) (S*r k) (mul_pos hS (hr k)) (hcurv' k) (u k) (hu k) (hnorm k)
+ have hrad : T m/S*(S*r k)=T m*r k := by field_simp
+ simpa only [hrad] using hh
+ choose w hw hwb hwr using hreps
+ let L : ℕ → ℝ≥0 := fun m => ⟨C m/S,div_nonneg (hC0 m) hS.le⟩
+ have hl (m k : ℕ) (x z : X) : |w m k x-w m k z|≤(L m:ℝ)*(dist x z/r k) := by
+ have hh := (hw m k).dist_le_mul x z
+ rw [Real.dist_eq,Real.coe_toNNReal _ (div_nonneg (hC0 m) (mul_pos hS (hr k)).le)] at hh
+ change |w m k x-w m k z|≤(C m/S)*(dist x z/r k)
+ convert hh using 1; ring
+ obtain ⟨g,a,ha,hg⟩ := countable_pointed_function_compactness hS.le p r ε v hr hε hε1 hεlim hv
+ w L C (fun m k x _ => hwb m k x) (fun m k x z _ _ => hl m k x z)
+ have hsame (i j k : ℕ) : EqOn (w i k) (w j k) (ball (p k) (min (T i) (T j)*r k)) := by
+ have hi : ball (p k) (min (T i) (T j)*r k) ⊆ ball (p k) (T i*r k) :=
+ ball_subset_ball (mul_le_mul_of_nonneg_right (min_le_left _ _) (hr k).le)
+ have hj : ball (p k) (min (T i) (T j)*r k) ⊆ ball (p k) (T j*r k) :=
+ ball_subset_ball (mul_le_mul_of_nonneg_right (min_le_right _ _) (hr k).le)
+ have hij : w i k =ᵐ[μ.restrict (ball (p k) (min (T i) (T j)*r k))] w j k := by
+ filter_upwards [ae_restrict_of_ae_restrict_of_subset hi (hwr i k),
+ ae_restrict_of_ae_restrict_of_subset hj (hwr j k)] with x hxi hxj
+ exact hxi.symm.trans hxj
+ exact Measure.eqOn_open_of_ae_eq hij isOpen_ball
+ (hw i k).continuous.continuousOn (hw j k).continuous.continuousOn
+ refine ⟨g,L,a,ha,fun m => (hg m).1,?_,?_⟩
+ · intro m η hη
+ filter_upwards [(hg m).2 η hη] with k hk
+ filter_upwards [hwr m (a k),ae_restrict_mem measurableSet_ball] with x hx hball
+ rw [hx]
+ apply hk x
+ have hd : dist x (p (a k)) v k x j)
+ (hw : ∀ k, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball (p k) (S*r k)) (w k))
+ (hnorm : ∀ k, harmonicTargetNorm hX (p k) (S*r k) (w k)≤1) :
+ ∃ a : ℕ → ℕ, StrictMono a ∧ ∃ model : EuclideanHarmonicModel n S,
+ (∀ W
+ inner ℝ (localAffineMomentFamily (hausdorff n X) hX.quadratic (u (a k)) (w (a k))
+ (ball (p (a k)) (ρ*r (a k))) (hX.finiteOnBounded _ isBounded_ball).ne i)
+ (localAffineMomentFamily (hausdorff n X) hX.quadratic (u (a k)) (w (a k))
+ (ball (p (a k)) (ρ*r (a k))) (hX.finiteOnBounded _ isBounded_ball).ne j))
+ atTop (𝓝 (inner ℝ (model.moments hρS.le i) (model.moments hρS.le j)))) ∧
+ ∀ ψ : Euclidean n → ℝ, InteriorSmoothTest n S ψ →
+ Tendsto (fun k => ((hausdorff n X).real (ball (p (a k)) (S*r (a k))))⁻¹*
+ ∫ x in ball (p (a k)) (S*r (a k)), ψ (v (a k) x)*
+ SobolevSpace.toLp (hausdorff n X) hX.quadratic (w (a k)) x ∂hausdorff n X)
+ atTop (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*
+ ∫ z in ball 0 S, ψ z*model.value z)) := by
+ obtain ⟨a,ha,g,hLp,hnormal,hgm,hgc,hgL,hconv,hmom,htests⟩ :=
+ hX.harmonic_value_affine_compactness hn hS p r ε hr hcurv hε hε1 hεlim u v w hv hrep hw hnorm
+ have hweak := hX.harmonic_value_limit_weak_of_curvature hn hS (p ∘ a) (r ∘ a) (ε ∘ a)
+ (fun k => hr (a k)) (fun k => hcurv (a k))
+ (fun k => hε (a k)) (fun k => hε1 (a k)) (hεlim.comp ha.tendsto_atTop)
+ (v ∘ a) (w ∘ a) (fun k => hv (a k)) (fun k => hw (a k)) (fun k => hnorm (a k)) g hgL hconv
+ let model : EuclideanHarmonicModel n S :=
+ ⟨g,continuous_weak_harmonic hgc hweak,hLp,hnormal⟩
+ refine ⟨a,ha,model,hgL,hconv,?_,htests⟩
+ intro ρ hρ hρS i j
+ exact hmom ρ hρ hρS i j
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HarmonicMomentCompactnessInput.lean b/lean/OAI/Geometry/RCD/Harmonic/HarmonicMomentCompactnessInput.lean
new file mode 100644
index 0000000000000000000000000000000000000000..3bc5f366a7a8047a75215de659f7484742b0db11
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HarmonicMomentCompactnessInput.lean
@@ -0,0 +1,63 @@
+import OAI.Geometry.RCD.Harmonic.EuclideanHarmonicModel
+import OAI.Geometry.RCD.Metric.MeasuredApproximation
+
+namespace OAI
+
+/-! # The local harmonic-compactness input, restricted to finite moments
+
+Ambrosio--Honda (2018), Local spectral convergence in RCD*(K,N) spaces,
+Theorem 4.2, Theorem 4.4 and Corollary 4.5, specialized to a Euclidean
+measured limit. Strong local L² convergence implies convergence of the
+pairings with constants and the bounded coordinate functions. The
+hypothesis below retains the local rescaled H¹ bound needed by those
+theorems. It asserts neither an affine approximation nor a chart.
+-/
+
+open Set Metric MeasureTheory Filter
+open scoped InnerProductSpace ENNReal Topology
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- Only the normalized moments of one harmonic function and the finite
+coordinate family are retained from the published local compactness theorem.
+All target functions are genuine Sobolev functions of the original space. -/
+def LocalHarmonicMomentCompactnessInput {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) : Prop :=
+ ∀ S : ℝ, 0 < S →
+ ∀ (p : ℕ → X) (r ε : ℕ → ℝ), (∀ k, 0 < r k) →
+ (∀ k, -1 ≤ K * r k ^ 2) → (∀ k, 0 < ε k) → Tendsto ε atTop (𝓝 0) →
+ ∀ (u : ℕ → Fin n → SobolevSpace (hausdorff n X) hX.quadratic)
+ (v : ℕ → X → Euclidean n)
+ (w : ℕ → SobolevSpace (hausdorff n X) hX.quadratic),
+ (∀ k, IsMeasuredEuclideanApproximation (hausdorff n X) n (p k) (r k) S (ε k) (v k)) →
+ (∀ k i, SobolevSpace.toLp (hausdorff n X) hX.quadratic (u k i) =ᵐ[
+ (hausdorff n X).restrict (ball (p k) (S * r k))] fun x => v k x i) →
+ (∀ k, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic
+ (ball (p k) (S * r k)) (w k)) →
+ (∀ k, ‖normalizeLocalL2 (hausdorff n X) (ball (p k) (S * r k))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic
+ (ball (p k) (S * r k)) (w k))‖ ≤ 1) →
+ (∀ ρ : ℝ, 0 < ρ → ρ < S → ∃ C : ℝ, 0 ≤ C ∧ ∀ k,
+ r k ^ 2 * ((hausdorff n X).real (ball (p k) (S * r k)))⁻¹ *
+ (∫ x in ball (p k) (ρ * r k), localGamma (hausdorff n X) hX.quadratic
+ (w k) (w k) x ∂hausdorff n X) ≤ C) →
+ ∃ t : ℕ → ℕ, StrictMono t ∧ ∃ model : EuclideanHarmonicModel n S,
+ ∀ ρ : ℝ, 0 < ρ → ∀ hρS : ρ < S, ∀ i j,
+ Tendsto (fun k =>
+ ⟪localAffineMomentFamily (hausdorff n X) hX.quadratic (u (t k)) (w (t k))
+ (ball (p (t k)) (ρ * r (t k)))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) i,
+ localAffineMomentFamily (hausdorff n X) hX.quadratic (u (t k)) (w (t k))
+ (ball (p (t k)) (ρ * r (t k)))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) j⟫_ℝ) atTop
+ (𝓝 ⟪model.moments hρS.le i, model.moments hρS.le j⟫_ℝ)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HarmonicMomentConstruction.lean b/lean/OAI/Geometry/RCD/Harmonic/HarmonicMomentConstruction.lean
new file mode 100644
index 0000000000000000000000000000000000000000..40e1fef0968f726224c13a8d3f76175c7ac48f39
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HarmonicMomentConstruction.lean
@@ -0,0 +1,34 @@
+import OAI.Geometry.RCD.Harmonic.HarmonicModelCompactness
+
+namespace OAI
+
+/-! # Discharging the published finite harmonic-moment compactness input -/
+
+open Set Filter MeasureTheory Metric
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.harmonicMomentCompactnessInput {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2≤n) :
+ LocalHarmonicMomentCompactnessInput hX := by
+ intro S hS p r ε hr hcurv hε hεlim u v w hv hrep hw hnorm _
+ obtain ⟨N,hN⟩ := eventually_atTop.mp (hεlim.eventually (Iio_mem_nhds zero_lt_one))
+ obtain ⟨a,ha,model,_,_,hmom,_⟩ := hX.harmonic_model_compactness hn hS
+ (fun k => p (k+N)) (fun k => r (k+N)) (fun k => ε (k+N))
+ (fun k => hr (k+N)) (fun k => hcurv (k+N))
+ (fun k => (hε (k+N)).le) (fun k => (hN (k+N) (Nat.le_add_left N k)).le)
+ (hεlim.comp (tendsto_add_atTop_nat N))
+ (fun k => u (k+N)) (fun k => v (k+N)) (fun k => w (k+N))
+ (fun k => hv (k+N)) (fun k j => hrep (k+N) j)
+ (fun k => hw (k+N)) (fun k => hnorm (k+N))
+ refine ⟨fun k => a k+N,fun i j hij => Nat.add_lt_add_right (ha hij) N,model,?_⟩
+ intro ρ hρ hρS i j
+ exact hmom ρ hρ hρS i j
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HarmonicOpenBallCompactness.lean b/lean/OAI/Geometry/RCD/Harmonic/HarmonicOpenBallCompactness.lean
new file mode 100644
index 0000000000000000000000000000000000000000..5fe4639b6e0fd0a85357ab79c9039a8c2a4f379e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HarmonicOpenBallCompactness.lean
@@ -0,0 +1,84 @@
+import OAI.Geometry.RCD.Harmonic.HarmonicCountableCompactness
+import OAI.Geometry.RCD.Metric.BallLimitGluing
+
+namespace OAI
+
+/-! # One harmonic value limit on the whole open Euclidean ball
+
+The exhaustion is used only to construct the function. Convergence holds
+on every strictly smaller physical ball through the original maps.
+Identification of the Euclidean weak equation is a separate step.
+-/
+
+open Set Metric Filter MeasureTheory
+open scoped NNReal ENNReal Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem harmonic_open_ball_value_compactness {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2≤n)
+ (hmean : LocalHarmonicL2MeanValueInput hX) (hgradient : LocalHarmonicL2GradientInput hX)
+ {S : ℝ} (hS : 0 S*(1-1/((m+2:ℕ):ℝ))
+ have hT (m : ℕ) : 0 0)=g := by
+ funext z
+ by_cases h : z∈ball (0:Euclidean n) S
+ · simp only [piecewise_eq_of_mem _ _ _ h]
+ · have hnorm : S≤‖z‖ := by simpa only [mem_ball,dist_zero_right,not_lt] using h
+ simp only [piecewise_eq_of_notMem _ _ _ h,hz z hnorm]
+ rw [← he]
+ exact hg.measurable_piecewise continuous_const.continuousOn measurableSet_ball
+
+theorem NoncollapsedRCD.open_ball_harmonic_L2_compactness {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2≤n)
+ {S : ℝ} (hS : 0 ((hausdorff n X).real (ball (p (a k)) (ρ*r (a k))))⁻¹*
+ ∫ x in ball (p (a k)) (ρ*r (a k)),
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic (u (a k)) x-g (v (a k) x))^2
+ ∂hausdorff n X) atTop (𝓝 0) := by
+ obtain ⟨g,a,ha,hgc,hgL,hg0,hconv⟩ := harmonic_open_ball_value_compactness hX hn
+ hX.harmonicMeanValueInput (hX.harmonicGradientInput hn (p 0)) hS p r ε hr hcurv
+ hε hε1 hεlim v (fun k => (hv k).metric) u hu hnorm
+ have hgm := measurable_zero_extension_ball hgc hg0
+ refine ⟨g,a,ha,hgm,hgc,hgL,?_⟩
+ intro ρ hρ hρS
+ let μ := hausdorff n X
+ let ν : ℕ → Measure X := fun k => μ.restrict (ball (p (a k)) (ρ*r (a k)))
+ let : ∀ k, IsFiniteMeasure (ν k) := fun k =>
+ ⟨by simpa only [ν,Measure.restrict_apply_univ] using (hX.finiteOnBounded
+ (ball (p (a k)) (ρ*r (a k))) isBounded_ball)⟩
+ have hmass (k : ℕ) : 0<(ν k).real univ := by
+ change 0<(μ.restrict (ball (p (a k)) (ρ*r (a k)))).real univ
+ rw [Measure.real,Measure.restrict_apply_univ]
+ exact ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hρ (hr (a k)))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne
+ let F := fun k x => SobolevSpace.toLp μ hX.quadratic (u (a k)) x-g (v (a k) x)
+ have hFm (k : ℕ) : AEStronglyMeasurable (F k) (ν k) :=
+ ((Lp.aestronglyMeasurable (SobolevSpace.toLp μ hX.quadratic (u (a k)))).sub
+ (hgm.comp (hv (a k)).measurable).aestronglyMeasurable).mono_measure Measure.restrict_le_self
+ have hFu : ∀ η : ℝ, 0<η → ∀ᶠ k in atTop, ∀ᵐ x ∂ν k, |F k x|≤η := by
+ intro η hη
+ filter_upwards [hconv ρ hρ hρS η hη] with k hk
+ exact hk.mono fun x hx => hx.le
+ have hh := normalized_sq_mean_tendsto_zero ν hmass F hFm hFu
+ simpa only [F,ν,Measure.real,Measure.restrict_apply_univ] using hh
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HarmonicOperatorEvolution.lean b/lean/OAI/Geometry/RCD/Harmonic/HarmonicOperatorEvolution.lean
new file mode 100644
index 0000000000000000000000000000000000000000..7647f442d0e6195a93ba3fcc7357bdf6eb0f1d5b
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HarmonicOperatorEvolution.lean
@@ -0,0 +1,114 @@
+import OAI.Geometry.RCD.Coordinates.UniformPolarizedError
+import OAI.Geometry.RCD.Heat.HarmonicBochnerHeatSource
+
+namespace OAI
+
+/-! # The full operator-valued harmonic heat equation -/
+
+open Set Metric MeasureTheory
+open scoped NNReal InnerProductSpace
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [ProperSpace X] (μ : Measure X) [μ.Regular] (hQ : QuadraticCheegerEnergy μ)
+ {k : ℝ → X → X → ℝ} (hk : IsContinuousHeatKernel μ hQ k)
+ {n : ℕ} {U : Euclidean n →L[ℝ] SobolevSpace μ hQ}
+ {M : PositiveBilinearMeasure X (Euclidean n)} {κ : ℝ} {p : X} {r : ℝ} {L : ℝ≥0}
+ (G : ∀ v, LocalHarmonicEnergy μ hQ U M κ p r L v)
+ {ρ C : ℝ} (χ : GoodLaplacianCutoff μ hQ p ρ C)
+
+/-- Polarizing the actual scalar Bochner identities yields the full
+operator derivative, with the singular mass measure retained. -/
+theorem harmonicHeatGram_hasDerivAt (hρ : 0 < ρ) (hρr : ρ < r)
+ {t : ℝ} (ht : 0 < t) (x : X) {lambda : ℝ} (hlambda : 0 ≤ lambda) :
+ HasDerivAt
+ (fun s => cutoffHeatGramAt μ hQ hk χ.weight.continuous
+ (χ.hasCompactSupport μ hQ) U s x lambda)
+ ((2 : ℝ) • cutoffHeatMass μ hQ hk χ.weight.continuous
+ (χ.hasCompactSupport μ hQ) M ht x -
+ (2 * κ) • cutoffHeatGram μ hQ hk χ.weight.continuous
+ (χ.hasCompactSupport μ hQ) U ht x 0 +
+ harmonicHeatError μ hQ (k := k) G χ t x +
+ lambda • ContinuousLinearMap.id ℝ (Euclidean n)) t := by
+ let Q := fun s => cutoffHeatGramAt μ hQ hk χ.weight.continuous
+ (χ.hasCompactSupport μ hQ) U s x lambda
+ let B := cutoffHeatMass μ hQ hk χ.weight.continuous
+ (χ.hasCompactSupport μ hQ) M ht x
+ let A := cutoffHeatGram μ hQ hk χ.weight.continuous
+ (χ.hasCompactSupport μ hQ) U ht x 0
+ let e := fun v => ∫ z, k t x z *
+ cutoffSourceDensity μ hQ (G v).energy χ.sobolev χ.laplacian z ∂μ
+ have hQs (s : ℝ) : (Q s).IsSymmetric := by
+ by_cases hs : 0 < s
+ · rw [show Q s = cutoffHeatGram μ hQ hk χ.weight.continuous
+ (χ.hasCompactSupport μ hQ) U hs x lambda from
+ cutoffHeatGramAt_of_pos μ hQ hk _ _ U hs x lambda]
+ exact (cutoffHeatGram_isPositive μ hQ hk _ _ U (fun z => (χ.bounds z).1) hs x hlambda).isSymmetric
+ · simp only [Q, cutoffHeatGramAt, dite_eq_right hs]
+ exact ContinuousLinearMap.isPositive_zero.isSymmetric
+ have hB : B.IsSymmetric :=
+ (cutoffHeatMass_isPositive μ hQ hk _ _ M (fun z => (χ.bounds z).1) ht x).isSymmetric
+ have hA : A.IsSymmetric :=
+ (cutoffHeatGram_isPositive μ hQ hk _ _ U (fun z => (χ.bounds z).1) ht x le_rfl).isSymmetric
+ have hχΩ : tsupport (χ.weight : X → ℝ) ⊆ ball p (2 * r) := by
+ intro z hz
+ have hd : dist z p ≤ 2 * ρ := χ.tsupport_subset μ hQ hz
+ exact lt_of_le_of_lt hd (by linarith)
+ have hχR : ∀ z ∉ closedBall p (2 * ρ), χ.weight z = 0 := by
+ intro z hz
+ apply χ.zero z
+ simpa only [mem_closedBall, dist_comm, not_le] using hz
+ have hqR : ∀ᵐ z ∂μ, z ∉ closedBall p (2 * ρ) → χ.laplacian z = 0 := by
+ filter_upwards [χ.laplacian_locality] with z hz hn
+ apply hz (Or.inr _)
+ simpa only [mem_closedBall, dist_comm, not_le] using hn
+ have hd (v : Euclidean n) : HasDerivAt (fun s => ⟪v, Q s v⟫_ℝ)
+ (2 * ⟪v, B v⟫_ℝ - 2 * κ * ⟪v, A v⟫_ℝ + e v + lambda * ‖v‖ ^ 2) t :=
+ (G v).heatGram_hasDerivAt_mass μ hQ hk χ.weight (χ.hasCompactSupport μ hQ)
+ hχΩ χ.sobolev χ.representative χ.laplacian χ.weak_laplacian p
+ (mul_pos (by norm_num) hρ) hχR hqR ht x lambda
+ have h := hasDerivAt_operator_of_quadratic hQs _ hd
+ have hid := polarizedDerivative_quadratic_form
+ (ContinuousLinearMap.id ℝ (Euclidean n)) ContinuousLinearMap.isPositive_id.isSymmetric
+ simp only [ContinuousLinearMap.id_apply, real_inner_self_eq_norm_sq] at hid
+ simpa only [polarizedDerivative_add, polarizedDerivative_sub, polarizedDerivative_smul,
+ polarizedDerivative_quadratic_form B hB, polarizedDerivative_quadratic_form A hA,
+ hid, Q, B, A, e, harmonicHeatError] using h
+
+include hk in
+/-- The quadratic value of the operator error equals the scalar error
+in every direction, not just those used in polarization. -/
+theorem harmonicHeatError_energy (hρ : 0 < ρ) (hρr : ρ < r)
+ {t : ℝ} (ht : 0 < t) (x : X) (v : Euclidean n) :
+ ⟪v, harmonicHeatError μ hQ (k := k) G χ t x v⟫_ℝ =
+ ∫ z, k t x z * cutoffSourceDensity μ hQ (G v).energy χ.sobolev χ.laplacian z ∂μ := by
+ have h := harmonicHeatGram_hasDerivAt μ hQ hk G χ hρ hρr ht x (lambda := 0) le_rfl
+ have hv := h.clm_apply (hasDerivAt_const t v)
+ have hi := (hasDerivAt_const t v).inner ℝ hv
+ simp only [inner_zero_left, map_zero, add_zero, add_apply, sub_apply,
+ smul_apply, inner_add_right, inner_sub_right, inner_smul_right,
+ zero_smul] at hi
+ have hχΩ : tsupport (χ.weight : X → ℝ) ⊆ ball p (2 * r) := by
+ intro z hz
+ have hd : dist z p ≤ 2 * ρ := χ.tsupport_subset μ hQ hz
+ exact lt_of_le_of_lt hd (by linarith)
+ have hd := (G v).heatGram_hasDerivAt_mass μ hQ hk χ.weight
+ (χ.hasCompactSupport μ hQ) hχΩ χ.sobolev χ.representative χ.laplacian
+ χ.weak_laplacian p (show 0 < 2 * ρ from mul_pos (by norm_num) hρ)
+ (fun z hz => χ.zero z (by simpa only [mem_closedBall, dist_comm, not_le] using hz))
+ (by
+ filter_upwards [χ.laplacian_locality] with z hz hn
+ exact hz (Or.inr (by simpa only [mem_closedBall, dist_comm, not_le] using hn)))
+ ht x 0
+ have heq := hi.unique hd
+ simp only [zero_mul, add_zero] at heq
+ linarith
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HarmonicQuadraticPotential.lean b/lean/OAI/Geometry/RCD/Harmonic/HarmonicQuadraticPotential.lean
new file mode 100644
index 0000000000000000000000000000000000000000..9d9f30df6f3a6ccd78e63ecef623556715472aec
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HarmonicQuadraticPotential.lean
@@ -0,0 +1,125 @@
+import OAI.Geometry.RCD.Sobolev.MeasureProductEnergy
+import OAI.Geometry.RCD.Harmonic.LocalCaccioppoli
+import OAI.Geometry.RCD.Sobolev.DirichletPoisson
+
+namespace OAI
+
+/-! # The local equation for the square of a harmonic coordinate -/
+
+open Set MeasureTheory
+open scoped NNReal BigOperators
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+omit [ProperSpace X] in
+/-- A bounded Sobolev function multiplied by an actual compact Lipschitz
+cutoff belongs to the canonical zero-boundary space. -/
+theorem bounded_cutoff_product_mem_dirichlet (Ω : Set X)
+ (c u : SobolevSpace μ hQ) (C D L : ℝ≥0)
+ (χ : X → ℝ) (hχ : LipschitzWith L χ) (hcpt : HasCompactSupport χ)
+ (hbound : ∀ x, |χ x| ≤ C) (hnonneg : ∀ x, 0 ≤ χ x)
+ (hsupp : tsupport χ ⊆ Ω) (hcrep : SobolevSpace.toLp μ hQ c =ᵐ[μ] χ)
+ (hu : ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ u x| ≤ D) :
+ SobolevSpace.product μ hQ c u C D ∈ SobolevSpace.dirichlet μ hQ Ω := by
+ have hc : ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ c x| ≤ C := by
+ filter_upwards [hcrep] with x hx
+ rw [hx]
+ exact hbound x
+ have he : SobolevSpace.product μ hQ c u C D =
+ SobolevSpace.cutoffCLM μ hQ hχ hcpt hbound hnonneg u := by
+ apply Subtype.ext
+ apply Lp.ext
+ filter_upwards [SobolevSpace.product_coe μ hQ c u C D hc hu, hcrep,
+ SobolevSpace.cutoffCLM_coe μ hQ hχ hcpt hbound hnonneg u] with x hp hx ht
+ exact hp.trans ((congrArg (· * SobolevSpace.toLp μ hQ u x) hx).trans ht.symm)
+ rw [he]
+ exact SobolevSpace.cutoffCLM_mem_dirichlet μ hQ hχ hcpt hbound hnonneg hsupp u
+
+/-- The local distributional Laplacian of half the square of a harmonic
+coordinate is its actual energy density. No second-order input is used. -/
+theorem harmonic_half_square_energy {Ω : Set X} (u φ : SobolevSpace μ hQ)
+ (C D : ℝ≥0) (hu : IsSobolevHarmonicOn μ hQ Ω u)
+ (hub : ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ u x| ≤ C)
+ (hφb : ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ φ x| ≤ D)
+ (hprod : SobolevSpace.product μ hQ u φ C D ∈ SobolevSpace.dirichlet μ hQ Ω) :
+ energyForm μ hQ ((1 / 2 : ℝ) • SobolevSpace.square μ hQ u C) φ =
+ -(∫ x, SobolevSpace.toLp μ hQ φ x * localGamma μ hQ u u x ∂μ) := by
+ have he := energy_product_integration_by_parts μ hQ u u φ C C D hub hub hφb
+ rw [hu _ hprod] at he
+ have hsq : SobolevSpace.product μ hQ u u C C = SobolevSpace.square μ hQ u C := by
+ apply Subtype.ext
+ apply Lp.ext
+ filter_upwards [SobolevSpace.product_coe μ hQ u u C C hub hub,
+ SobolevSpace.square_coe μ hQ u C hub] with x hp hs
+ change SobolevSpace.toLp μ hQ (SobolevSpace.product μ hQ u u C C) x =
+ SobolevSpace.toLp μ hQ (SobolevSpace.square μ hQ u C) x
+ rw [hp, hs, pow_two]
+ rw [hsq] at he
+ rw [energyForm_smul_left, he]
+ ring
+
+/-- The actual Euclidean quadratic model associated to bounded harmonic
+coordinates. Its gradient is used to compare distance gradients. -/
+def coordinateQuadratic {n : ℕ} (u : Fin n → SobolevSpace μ hQ) (C : ℝ≥0) :
+ SobolevSpace μ hQ := ∑ j, (1 / 2 : ℝ) • SobolevSpace.square μ hQ (u j) C
+
+theorem coordinateQuadratic_energy {n : ℕ} {Ω : Set X}
+ (u : Fin n → SobolevSpace μ hQ) (C D : ℝ≥0) (φ : SobolevSpace μ hQ)
+ (hu : ∀ j, IsSobolevHarmonicOn μ hQ Ω (u j))
+ (hub : ∀ j, ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ (u j) x| ≤ C)
+ (hφb : ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ φ x| ≤ D)
+ (hprod : ∀ j, SobolevSpace.product μ hQ (u j) φ C D ∈ SobolevSpace.dirichlet μ hQ Ω) :
+ energyForm μ hQ (coordinateQuadratic μ hQ u C) φ =
+ -(∫ x, SobolevSpace.toLp μ hQ φ x * (∑ j, localGamma μ hQ (u j) (u j) x) ∂μ) := by
+ have hi (j : Fin n) : Integrable (fun x =>
+ SobolevSpace.toLp μ hQ φ x * localGamma μ hQ (u j) (u j) x) μ :=
+ (localGamma_memL1 μ hQ (u j) (u j)).bdd_mul
+ (Lp.aestronglyMeasurable (SobolevSpace.toLp μ hQ φ))
+ (by simpa only [Real.norm_eq_abs] using hφb)
+ calc
+ _ = ∑ j, energyForm μ hQ ((1 / 2 : ℝ) • SobolevSpace.square μ hQ (u j) C) φ := by
+ rw [energyForm_comm]
+ change (sobolevEnergyForm μ hQ φ) (∑ j, _) = _
+ rw [map_sum]
+ exact Finset.sum_congr rfl fun j _ => energyForm_comm μ hQ _ _
+ _ = ∑ j, -(∫ x, SobolevSpace.toLp μ hQ φ x * localGamma μ hQ (u j) (u j) x ∂μ) :=
+ Finset.sum_congr rfl fun j _ => harmonic_half_square_energy μ hQ (u j) φ C D
+ (hu j) (hub j) hφb (hprod j)
+ _ = -(∫ x, ∑ j, SobolevSpace.toLp μ hQ φ x * localGamma μ hQ (u j) (u j) x ∂μ) := by
+ rw [Finset.sum_neg_distrib, integral_finsetSum _ (fun j _ => hi j)]
+ _ = _ := by simp only [Finset.mul_sum]
+
+omit [BorelSpace X] [ProperSpace X] in
+theorem coordinateQuadratic_representative {n : ℕ}
+ (u : Fin n → SobolevSpace μ hQ) (C : ℝ≥0)
+ (hub : ∀ j, ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ (u j) x| ≤ C) :
+ SobolevSpace.toLp μ hQ (coordinateQuadratic μ hQ u C) =ᵐ[μ]
+ fun x => ∑ j, (1 / 2 : ℝ) * (SobolevSpace.toLp μ hQ (u j) x) ^ 2 := by
+ have hj (j : Fin n) : SobolevSpace.toLp μ hQ
+ ((1 / 2 : ℝ) • SobolevSpace.square μ hQ (u j) C) =ᵐ[μ]
+ fun x => (1 / 2 : ℝ) * (SobolevSpace.toLp μ hQ (u j) x) ^ 2 := by
+ filter_upwards [Lp.coeFn_smul (1 / 2 : ℝ)
+ (SobolevSpace.toLp μ hQ (SobolevSpace.square μ hQ (u j) C)),
+ SobolevSpace.square_coe μ hQ (u j) C (hub j)] with x hsm hs
+ change (((1 / 2 : ℝ) • SobolevSpace.toLp μ hQ (SobolevSpace.square μ hQ (u j) C)) x) = _
+ simp only [hsm, Pi.smul_apply, smul_eq_mul, hs]
+ have hall := (Filter.eventually_all_finset (Finset.univ : Finset (Fin n))).mpr
+ (fun j _ => hj j)
+ have hsum := Lp.coeFn_finsetSum (Finset.univ : Finset (Fin n))
+ (fun j => SobolevSpace.toLp μ hQ ((1 / 2 : ℝ) • SobolevSpace.square μ hQ (u j) C))
+ unfold coordinateQuadratic
+ rw [map_sum]
+ filter_upwards [hsum, hall] with x hx hjx
+ rw [hx]
+ simp only [Finset.sum_apply]
+ exact Finset.sum_congr rfl fun j hj => hjx j hj
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HarmonicRadialBound.lean b/lean/OAI/Geometry/RCD/Harmonic/HarmonicRadialBound.lean
new file mode 100644
index 0000000000000000000000000000000000000000..37b78bcccecd80964ffe96eccd03fb7e4ca034cd
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HarmonicRadialBound.lean
@@ -0,0 +1,68 @@
+import OAI.Geometry.RCD.Sobolev.HarmonicGradientInput
+import OAI.Geometry.RCD.Harmonic.RadialDerivativeNorms
+
+namespace OAI
+
+/-! # Radial derivatives of harmonic residuals on an interior ball -/
+
+open Set Metric MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+/-- The published harmonic gradient estimate controls the actual radial
+derivative on the inner ball by the outer value norm. No normalization of
+the function or division by that norm is used. -/
+theorem LocalHarmonicL2GradientInput.radial_derivative_bound
+ {K : ℝ} {n : ℕ} {hX : NoncollapsedRCD K n X}
+ (hinput : LocalHarmonicL2GradientInput hX) (hn : 2 ≤ n)
+ {κ : ℝ} (hκ : 0 ≤ κ) :
+ ∃ C : ℝ, 1 ≤ C ∧ ∀ (p : X) (R : ℝ), 0 < R → -κ ≤ K * R ^ 2 →
+ ∀ (f w : SobolevSpace (hausdorff n X) hX.quadratic) (B : ℝ), 0 ≤ B →
+ ∀ hf : ∀ᵐ x ∂(hausdorff n X).restrict (ball p (R / 2)),
+ localGamma (hausdorff n X) hX.quadratic f f x ≤ B ^ 2,
+ IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball p R) w →
+ ‖normalizeLocalL2 (hausdorff n X) (ball p (R / 2))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (localRadialDerivative (hausdorff n X) hX.quadratic (ball p (R / 2)) f hf w)‖ ≤
+ (B * C / R) * ‖normalizeLocalL2 (hausdorff n X) (ball p R)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ (SobolevSpace.restrictLp (hausdorff n X) hX.quadratic (ball p R) w)‖ := by
+ obtain ⟨C, hC, hgrad⟩ := hinput hn κ (1 / 2) hκ (by norm_num) (by norm_num)
+ refine ⟨C, hC, ?_⟩
+ intro p R hR hcurv f w B hB hf hw
+ let μ := hausdorff n X
+ let hQ := hX.quadratic
+ let s := ball p (R / 2)
+ let hfin : μ s ≠ ∞ := ne_of_lt (hX.finiteOnBounded _ isBounded_ball)
+ let α := ‖normalizeLocalL2 μ (ball p R)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) (SobolevSpace.restrictLp μ hQ (ball p R) w)‖
+ have hpos : 0 < μ.real s := ENNReal.toReal_pos
+ (ne_of_gt (hX.fullSupport p (R / 2) (by linarith))) hfin
+ let : IsFiniteMeasure (μ.restrict s) :=
+ ⟨by simpa only [Measure.restrict_apply_univ] using hfin.lt_top⟩
+ have hg : ∀ᵐ x ∂μ.restrict s, localGamma μ hQ w w x ≤ (C / R) ^ 2 * α ^ 2 := by
+ have he := normalized_sobolev_mean_sq μ hQ (ball p R)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball)) w
+ simpa only [α, he, one_div_mul_eq_div] using hgrad p R hR hcurv w hw
+ have hi : (∫ x in s, localGamma μ hQ w w x ∂μ) ≤ (C / R) ^ 2 * α ^ 2 * μ.real s := by
+ have hh := integral_mono_ae (localGamma_memL1 μ hQ w w).integrableOn
+ (integrable_const ((C / R) ^ 2 * α ^ 2)) hg
+ simpa only [integral_const, smul_eq_mul, Measure.real, Measure.restrict_apply_univ,
+ mul_comm] using hh
+ have hd := normalized_radial_derivative_norm_sq μ hQ s hfin f w hf
+ have hb := hd.trans (mul_le_mul_of_nonneg_left hi (by positivity : 0 ≤ B ^ 2 * (μ.real s)⁻¹))
+ have halg : B ^ 2 * (μ.real s)⁻¹ * ((C / R) ^ 2 * α ^ 2 * μ.real s) =
+ ((B * C / R) * α) ^ 2 := by field_simp
+ rw [halg] at hb
+ exact (sq_le_sq₀ (norm_nonneg _) (mul_nonneg (div_nonneg (mul_nonneg hB (by linarith)) hR.le)
+ (norm_nonneg _))).mp hb
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HarmonicRecoveryStrong.lean b/lean/OAI/Geometry/RCD/Harmonic/HarmonicRecoveryStrong.lean
new file mode 100644
index 0000000000000000000000000000000000000000..530a163ce077f239f5a6e1e4a33072d7a4606e25
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HarmonicRecoveryStrong.lean
@@ -0,0 +1,144 @@
+import OAI.Geometry.RCD.Sobolev.RadialCutoffStrongComparison
+import OAI.Geometry.RCD.Harmonic.LocalUniformDifference
+import OAI.Geometry.RCD.Sobolev.WeightedBallEnergyLiminf
+
+namespace OAI
+
+/-! # Strong local comparison of an actual harmonic sequence and its recovery -/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology NNReal BoundedContinuousFunction
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.harmonic_recovery_strong_of_gradient_bound {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2≤n)
+ {S a b R T Q : ℝ} (hS : 0 r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (S*r k), (euclideanNestedCutoff n hab (V k x))^2*
+ localGamma (hausdorff n X) hX.quadratic (q k) (q k) x ∂hausdorff n X)
+ atTop (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*
+ ∫ z in ball 0 S, (euclideanNestedCutoff n hab z)^2*‖fderiv ℝ F z‖^2))) :
+ Tendsto (fun k => r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (R*r k), (nestedBallCutoff (p k) (a*r k) (b*r k) x)^2*
+ localGamma (hausdorff n X) hX.quadratic (w k-q k) (w k-q k) x ∂hausdorff n X)
+ atTop (𝓝 0) := by
+ let μ := hausdorff n X
+ let φ : Euclidean n →ᵇ ℝ := (euclideanNestedCutoff n hab)^2
+ let ρ := (b+R)/2
+ have hbρ : b<ρ := by dsimp only [ρ]; linarith
+ have hρR : ρ r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (S*r k), (euclideanNestedCutoff n hab (V k x))^2*
+ localGamma (hausdorff n X) hX.quadratic (q k) (q k) x ∂hausdorff n X)
+ atTop (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*
+ ∫ z in ball 0 S, (euclideanNestedCutoff n hab z)^2*‖fderiv ℝ F z‖^2))) :
+ Tendsto (fun k => r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (R*r k), (nestedBallCutoff (p k) (a*r k) (b*r k) x)^2*
+ localGamma (hausdorff n X) hX.quadratic (w k-q k) (w k-q k) x ∂hausdorff n X)
+ atTop (𝓝 0) := by
+ obtain ⟨M,hM,hwb⟩ := hX.harmonic_scaled_energy_bound hn hS (ha.le.trans (hab.le.trans (hbR.le.trans hRT.le))) hTS
+ p r hr hcurv w hw hnorm
+ exact hX.harmonic_recovery_strong_of_gradient_bound hn hS ha hab hbR hRT hTS
+ p r ε V hr hcurv hε hε1 hεlim hV w q hw hM hwb g F hg heq hd hconv hqconv hqg hq
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HarmonicReplacementFamily.lean b/lean/OAI/Geometry/RCD/Harmonic/HarmonicReplacementFamily.lean
new file mode 100644
index 0000000000000000000000000000000000000000..2e846df68195d033ff846ca707378d89c0912d1e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HarmonicReplacementFamily.lean
@@ -0,0 +1,83 @@
+import OAI.Geometry.RCD.Harmonic.AnnularHarmonicReplacement
+import OAI.Geometry.RCD.Metric.MeasuredAnnularMass
+
+namespace OAI
+
+/-! # Harmonic replacements on a fixed inner physical ball
+
+The annular condition is derived from the actual measured maps. The
+normalization remains the mass of the larger approximation ball.
+-/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.harmonic_replacement_family {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2≤n) {S R L E : ℝ}
+ (hS : 0 (hX.finiteOnBounded _ isBounded_ball).ne)
+ (fun k => ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hS (hr k))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne) hε
+ obtain ⟨N,hN⟩ := eventually_atTop.mp (hann.and hub)
+ obtain ⟨P,hP,hreplace⟩ := hX.annular_harmonic_replacement hn
+ let C := 2*L+2*P*(R^2*E)+1
+ have hC : 0 r (k+N)^2*((hausdorff n X).real (ball (p (k+N)) (S*r (k+N))))⁻¹*
+ ∫ x in ball (p (k+N)) (S*r (k+N)), φ (V (k+N) x)*localGamma (hausdorff n X) hX.quadratic
+ (q k).val (q k).val x ∂hausdorff n X) atTop
+ (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*
+ ∫ z in ball 0 S, φ z*‖fderiv ℝ F z‖^2))) ∧
+ Tendsto (fun k => r (k+N)^2*((hausdorff n X).real (ball (p (k+N)) (S*r (k+N))))⁻¹*
+ ∫ x in ball (p (k+N)) (R*r (k+N)),
+ (nestedBallCutoff (p (k+N)) (a*r (k+N)) (b*r (k+N)) x)^2*
+ localGamma (hausdorff n X) hX.quadratic (w (k+N)-(q k).val) (w (k+N)-(q k).val) x
+ ∂hausdorff n X) atTop (𝓝 0) := by
+ obtain ⟨F,hF,heq,hd⟩ := exists_interior_smooth_extension
+ (ha.trans (hab.trans (hbR.trans hRT))) hTS hg
+ obtain ⟨c,hc,hcS,N,q,hqv,hqg,hqz,hqe⟩ :=
+ hX.sharp_weighted_test_recovery hn hS p r ε V hr hcurv hε hε1 hεlim hV hF
+ obtain ⟨Q,hQ,hQb⟩ := compact_recovery_scaled_gradient_bound (hausdorff n X) hX.quadratic
+ (hF.1.of_le (by simp)) hF.2.1 (fun k => p (k+N)) (fun k => r (k+N))
+ (fun k => hr (k+N)) (fun k => V (k+N)) (fun k => (q k).val) hqz (hqg c hc.le hcS)
+ refine ⟨F,hF,heq,hd,N,q,hqv,⟨Q,hQ,hQb⟩,hqe,?_⟩
+ apply hX.harmonic_recovery_strong hn hS ha hab hbR hRT hTS
+ (fun k => p (k+N)) (fun k => r (k+N)) (fun k => ε (k+N)) (fun k => V (k+N))
+ (fun k => hr (k+N)) (fun k => hcurv (k+N)) (fun k => hε (k+N)) (fun k => hε1 (k+N))
+ (hεlim.comp (tendsto_add_atTop_nat N)) (fun k => hV (k+N))
+ (fun k => w (k+N)) (fun k => (q k).val) (fun k => hw (k+N)) (fun k => hnorm (k+N))
+ g F hgL heq hd
+ (fun W hW hWS δ hδ => (tendsto_add_atTop_nat N).eventually (hconv W hW hWS δ hδ)) hqv hQb
+ let φ : Euclidean n →ᵇ ℝ := (euclideanNestedCutoff n hab)^2
+ apply hqe φ (fun z => sq_nonneg _) ?_
+ have hs : tsupport φ⊆closedBall (0:Euclidean n) b := by
+ change closure (Function.support φ)⊆closedBall 0 b
+ apply closure_minimal _ isClosed_closedBall
+ intro z hz
+ by_contra hx
+ have hz' : b v k x j)
+ (hw : ∀ k, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball (p k) (S*r k)) (w k))
+ (hnorm : ∀ k, harmonicTargetNorm hX (p k) (S*r k) (w k)≤1) :
+ ∃ (a : ℕ → ℕ), StrictMono a ∧ ∃ (g : Euclidean n → ℝ)
+ (hLp : MemLp g 2 (volume.restrict (ball 0 S))),
+ ‖normalizeLocalL2 volume (ball 0 S) measure_ball_ne_top (hLp.toLp g)‖≤1 ∧
+ Measurable g ∧ ContinuousOn g (ball 0 S) ∧
+ (∀ τ
+ ⟪localAffineMomentFamily (hausdorff n X) hX.quadratic (u (a k)) (w (a k))
+ (ball (p (a k)) (ρ*r (a k))) (hX.finiteOnBounded _ isBounded_ball).ne i,
+ localAffineMomentFamily (hausdorff n X) hX.quadratic (u (a k)) (w (a k))
+ (ball (p (a k)) (ρ*r (a k))) (hX.finiteOnBounded _ isBounded_ball).ne j⟫_ℝ)
+ atTop (𝓝 ⟪euclideanValueMoments g hLp hρS.le i,
+ euclideanValueMoments g hLp hρS.le j⟫_ℝ)) ∧
+ ∀ ψ : Euclidean n → ℝ, InteriorSmoothTest n S ψ →
+ Tendsto (fun k => ((hausdorff n X).real (ball (p (a k)) (S*r (a k))))⁻¹*
+ ∫ x in ball (p (a k)) (S*r (a k)), ψ (v (a k) x)*
+ SobolevSpace.toLp (hausdorff n X) hX.quadratic (w (a k)) x ∂hausdorff n X)
+ atTop (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*
+ ∫ z in ball 0 S, ψ z*g z)) := by
+ obtain ⟨g,a,ha,hgm,hgc,hgL,hconv,htests⟩ :=
+ hX.open_ball_harmonic_test_compactness hn hS p r ε hr hcurv hε hε1 hεlim v hv w hw hnorm
+ have hconv' : ∀ ρ : ℝ, 0<ρ → ρ hk.mono fun _ hx => hx.le
+ obtain ⟨hLp,hgNorm⟩ := hX.value_limit_normalized hS (p ∘ a) (r ∘ a) (ε ∘ a) (v ∘ a)
+ (fun k => hr (a k)) (hεlim.comp ha.tendsto_atTop) (fun k => hv (a k))
+ (w ∘ a) (fun k => hnorm (a k)) g hgm hgL hconv'
+ refine ⟨a,ha,g,hLp,hgNorm,hgm,hgc,hgL,hconv',?_,htests⟩
+ exact hX.affine_value_moments_of_limit hS (p ∘ a) (r ∘ a) (ε ∘ a)
+ (fun k => hr (a k)) (u ∘ a) (v ∘ a) (w ∘ a) (fun k => hv (a k))
+ (hεlim.comp ha.tendsto_atTop) (fun k j => hrep (a k) j) g hLp hgL hconv'
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HoleDefectCharge.lean b/lean/OAI/Geometry/RCD/Harmonic/HoleDefectCharge.lean
new file mode 100644
index 0000000000000000000000000000000000000000..a3fda5ab1a3f1f30aa0df5a6bd0985a616de4f98
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HoleDefectCharge.lean
@@ -0,0 +1,65 @@
+import OAI.Geometry.RCD.Metric.NearbySmallBallMass
+import OAI.Geometry.RCD.Sobolev.FiniteDisjointIntegral
+
+namespace OAI
+
+/-! # Charging a finite disjoint hole family to the actual RCD defect
+
+Only relative Bishop--Gromov volume is used. The source balls and their
+large defect averages are explicit, so no coordinate-surjectivity result
+is hidden in this estimate.
+-/
+
+open Set Metric MeasureTheory
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.hole_defect_charge {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n) {ι : Type*} [Fintype ι]
+ {p : X} {R t : ℝ} (hR : 0 < R) (ht : 0 < t) (hcurv : -1 ≤ K*(2*R)^2)
+ {Ω : Set X} {f : X → ℝ} (hf : IntegrableOn f Ω (hausdorff n X))
+ (hf0 : ∀ᵐ x ∂(hausdorff n X).restrict Ω, 0 ≤ f x)
+ {z : ι → X} {r s : ι → ℝ} (hz : ∀ i, dist (z i) p ≤ R)
+ (hr : ∀ i, 0 < r i) (hrs : ∀ i, r i ≤ s i) (hsR : ∀ i, s i ≤ R)
+ (hsub : ∀ i, ball (z i) (s i) ⊆ Ω)
+ (hdisj : Pairwise (fun i j => Disjoint (ball (z i) (s i)) (ball (z j) (s j))))
+ (havg : ∀ i, t*(hausdorff n X).real (ball (z i) (s i)) ≤
+ ∫ x in ball (z i) (s i), f x ∂hausdorff n X) :
+ (∑ i, (r i)^n) ≤
+ ((Real.cosh 1^(n-1)*2^n)*R^n/(t*(hausdorff n X).real (ball p R)))*
+ ∫ x in Ω, f x ∂hausdorff n X := by
+ let μ := hausdorff n X
+ let A := (Real.cosh 1^(n-1)*2^n)*R^n
+ have hA : 0 ≤ A := by dsimp only [A]; positivity
+ have hm : 0 < μ.real (ball p R) := ENNReal.toReal_pos
+ (hX.fullSupport p R hR).ne' (hX.finiteOnBounded _ isBounded_ball).ne
+ have hi (i : ι) : (t*μ.real (ball p R))*(r i)^n ≤
+ A*(∫ x in ball (z i) (s i), f x ∂μ) := by
+ have hv : μ.real (ball p R)*(r i)^n ≤ A*μ.real (ball (z i) (s i)) := by
+ apply (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (hr i).le (hrs i) n)
+ (measureReal_nonneg)).trans
+ exact hX.nearby_small_ball_mass hn hR (hz i) ((hr i).trans_le (hrs i)) (hsR i) hcurv
+ calc
+ _ = t*(μ.real (ball p R)*(r i)^n) := by ring
+ _ ≤ t*(A*μ.real (ball (z i) (s i))) := mul_le_mul_of_nonneg_left hv ht.le
+ _ = A*(t*μ.real (ball (z i) (s i))) := by ring
+ _ ≤ _ := mul_le_mul_of_nonneg_left (havg i) hA
+ have hsums : (∑ i, ∫ x in ball (z i) (s i), f x ∂μ) ≤ ∫ x in Ω, f x ∂μ :=
+ finite_disjoint_setIntegral_le μ hf hf0 (fun _ => measurableSet_ball) hsub hdisj
+ have htot : (∑ i, (r i)^n)*(t*μ.real (ball p R)) ≤ A*∫ x in Ω, f x ∂μ := by
+ calc
+ _ = ∑ i, (t*μ.real (ball p R))*(r i)^n := by rw [mul_comm,Finset.mul_sum]
+ _ ≤ ∑ i, A*(∫ x in ball (z i) (s i), f x ∂μ) := Finset.sum_le_sum (fun i _ => hi i)
+ _ = A*(∑ i, ∫ x in ball (z i) (s i), f x ∂μ) := (Finset.mul_sum _ _ _).symm
+ _ ≤ _ := mul_le_mul_of_nonneg_left hsums hA
+ calc
+ _ ≤ (A*∫ x in Ω, f x ∂μ)/(t*μ.real (ball p R)) :=
+ (le_div_iff₀ (mul_pos ht hm)).mpr htot
+ _ = _ := by dsimp only [A]; ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/HomogeneousAffineImprovement.lean b/lean/OAI/Geometry/RCD/Harmonic/HomogeneousAffineImprovement.lean
new file mode 100644
index 0000000000000000000000000000000000000000..c62b794b3feef75c9de33e5a3edc36add66a5472
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/HomogeneousAffineImprovement.lean
@@ -0,0 +1,91 @@
+import OAI.Geometry.RCD.Harmonic.ContinuousAffineImprovement
+
+namespace OAI
+
+/-! # Removing the unit-norm restriction in harmonic affine improvement -/
+
+open Set Metric MeasureTheory
+open scoped InnerProductSpace ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ {K : ℝ} {n : ℕ} (hX : NoncollapsedRCD K n X)
+
+theorem harmonicTargetNorm_smul (p : X) (r c : ℝ)
+ (w : SobolevSpace (hausdorff n X) hX.quadratic) :
+ harmonicTargetNorm hX p r (c • w) = |c| * harmonicTargetNorm hX p r w := by
+ unfold harmonicTargetNorm
+ rw [map_smul]
+ unfold normalizeLocalL2
+ rw [smul_comm, norm_smul, Real.norm_eq_abs]
+
+theorem harmonicAffineResidualNorm_smul
+ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic) (p : X) (r c : ℝ)
+ (w : SobolevSpace (hausdorff n X) hX.quadratic) :
+ harmonicAffineResidualNorm hX u p r (c • w) =
+ |c| * harmonicAffineResidualNorm hX u p r w := by
+ unfold harmonicAffineResidualNorm
+ rw [map_smul, map_smul]
+ unfold normalizeLocalL2
+ rw [smul_comm, norm_smul, Real.norm_eq_abs]
+
+/-- Full support makes the averaging factor nonzero on every positive ball. -/
+theorem restrictLp_eq_zero_of_harmonicTargetNorm_eq_zero (p : X) {r : ℝ} (hr : 0 < r)
+ (w : SobolevSpace (hausdorff n X) hX.quadratic)
+ (hw : harmonicTargetNorm hX p r w = 0) :
+ SobolevSpace.restrictLp (hausdorff n X) hX.quadratic (ball p r) w = 0 := by
+ have hvol : 0 < (hausdorff n X).real (ball p r) :=
+ ENNReal.toReal_pos (ne_of_gt (hX.fullSupport p r hr))
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))
+ have hone : ‖restrictedOne (hausdorff n X) (ball p r)
+ (ne_of_lt (hX.finiteOnBounded _ isBounded_ball))‖ ≠ 0 := by
+ rw [restrictedOne_norm]
+ exact ne_of_gt (Real.sqrt_pos.2 hvol)
+ have hz := norm_eq_zero.mp hw
+ exact (smul_eq_zero.mp hz).resolve_left (inv_ne_zero hone)
+
+/-- A zero target on the outer ball has zero affine residual on any inner ball. -/
+theorem harmonicAffineResidualNorm_eq_zero_on_smaller
+ (u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic) (p : X) {r t : ℝ}
+ (hr : 0 < r) (htr : t ≤ r) (w : SobolevSpace (hausdorff n X) hX.quadratic)
+ (hw : harmonicTargetNorm hX p r w = 0) :
+ harmonicAffineResidualNorm hX u p t w = 0 := by
+ have hz := restrictLp_eq_zero_of_harmonicTargetNorm_eq_zero hX p hr w hw
+ have hreps := (SobolevSpace.restrictLp_eq_zero_iff (hausdorff n X) hX.quadratic
+ (ball p r) w).mp hz
+ have hzt := (SobolevSpace.restrictLp_eq_zero_iff (hausdorff n X) hX.quadratic
+ (ball p t) w).mpr (ae_restrict_of_ae_restrict_of_subset (ball_subset_ball htr) hreps)
+ simp only [harmonicAffineResidualNorm, hzt, map_zero, normalizeLocalL2, smul_zero, norm_zero]
+
+/-- The unit-norm estimate implies the full homogeneous estimate, including
+the zero-norm case. -/
+theorem HasNormalizedAffineImprovement.homogeneous
+ {u : Fin n → SobolevSpace (hausdorff n X) hX.quadratic} {p : X} {r θ : ℝ}
+ (hfit : HasNormalizedAffineImprovement hX u p r θ) (hr : 0 < r) (hθ : θ ≤ 1)
+ (w : SobolevSpace (hausdorff n X) hX.quadratic)
+ (hw : IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball p r) w) :
+ harmonicAffineResidualNorm hX u p (θ * r) w ≤
+ (1 / 2 : ℝ) * θ * Real.sqrt θ * harmonicTargetNorm hX p r w := by
+ by_cases hz : harmonicTargetNorm hX p r w = 0
+ · rw [harmonicAffineResidualNorm_eq_zero_on_smaller hX u p hr
+ (mul_le_of_le_one_left hr.le hθ) w hz, hz, mul_zero]
+ have ht : 0 < harmonicTargetNorm hX p r w :=
+ lt_of_le_of_ne (norm_nonneg _) (Ne.symm hz)
+ have hn : harmonicTargetNorm hX p r ((harmonicTargetNorm hX p r w)⁻¹ • w) ≤ 1 := by
+ rw [harmonicTargetNorm_smul, abs_of_pos (inv_pos.2 ht), inv_mul_cancel₀ hz]
+ have hh := hfit ((harmonicTargetNorm hX p r w)⁻¹ • w)
+ (hw.smul (hausdorff n X) hX.quadratic _) hn
+ change harmonicAffineResidualNorm hX u p (θ * r)
+ ((harmonicTargetNorm hX p r w)⁻¹ • w) < _ at hh
+ rw [harmonicAffineResidualNorm_smul, abs_of_pos (inv_pos.2 ht)] at hh
+ have hh' := mul_lt_mul_of_pos_left hh ht
+ rw [← mul_assoc, mul_inv_cancel₀ hz, one_mul] at hh'
+ exact hh'.le.trans_eq (mul_comm _ _)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/InnerHarmonicLimit.lean b/lean/OAI/Geometry/RCD/Harmonic/InnerHarmonicLimit.lean
new file mode 100644
index 0000000000000000000000000000000000000000..760f5269a5023b27e5b802718b1538407dedf5dd
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/InnerHarmonicLimit.lean
@@ -0,0 +1,64 @@
+import OAI.Geometry.RCD.Metric.InnerMeasuredSubsequence
+import OAI.Geometry.RCD.Harmonic.InnerHarmonicNormBound
+import OAI.Geometry.RCD.Harmonic.BoundedHarmonicCompactness
+
+namespace OAI
+
+/-! # A classical limit for the actual inner-ball harmonic candidates
+
+Both the measured maps and the normalizing bound on the smaller ball are
+derived from the original outer approximation and global L2 bound.
+-/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology ContDiff NNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.inner_harmonic_limit {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) [(hausdorff n X).Regular] (hn : 2≤n)
+ {S R C : ℝ} (hS : 0 1/((k+1:ℕ):ℝ)
+ have hη (k : ℕ) : 0<η k := by dsimp only [η]; positivity
+ have hη1 (k : ℕ) : η k≤1 := by
+ apply (div_le_one (by positivity : (0:ℝ)<((k+1:ℕ):ℝ))).mpr
+ exact_mod_cast (Nat.succ_le_succ (Nat.zero_le k))
+ have hηlim : Tendsto η atTop (𝓝 0) :=
+ tendsto_one_div_atTop_nhds_zero_nat.comp (tendsto_add_atTop_nat 1)
+ obtain ⟨a,ha,hVa⟩ := inner_measured_subsequence hS hR hRS hr hε hV
+ (fun k => (hX.finiteOnBounded _ isBounded_ball).ne)
+ (fun k => ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hS (hr k))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne) hεlim hη
+ obtain ⟨M,hM,hMb⟩ := hX.inner_harmonic_norm_bound hS hR hRS hC p r ε V hr hV hεlim w hbound
+ obtain ⟨N,hN⟩ := eventually_atTop.mp (ha.tendsto_atTop.eventually hMb)
+ let b : ℕ → ℕ := fun k => a (k+N)
+ have hb : StrictMono b := ha.comp (fun _ _ h => Nat.add_lt_add_right h N)
+ obtain ⟨c,hc,g,hgm,hgc,hgw,hgs,hgL,hconv⟩ := hX.bounded_harmonic_compactness hn hR hM
+ (p∘b) (r∘b) (fun k => η (k+N)) (V∘b)
+ (fun k => hr (b k)) (fun k => hcurv (b k)) (fun k => (hη (k+N)).le)
+ (fun k => hη1 (k+N)) (hηlim.comp (tendsto_add_atTop_nat N))
+ (fun k => hVa (k+N)) (w∘b) (fun k => hw (b k))
+ (fun k => hN (k+N) (Nat.le_add_left N k))
+ exact ⟨b∘c,hb.comp hc,g,hgm,hgc,hgw,hgs,hgL,hconv⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/InnerHarmonicNormBound.lean b/lean/OAI/Geometry/RCD/Harmonic/InnerHarmonicNormBound.lean
new file mode 100644
index 0000000000000000000000000000000000000000..618ca8c810cd4df1c3e941a02bfc32d43a26d337
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/InnerHarmonicNormBound.lean
@@ -0,0 +1,78 @@
+import OAI.Geometry.RCD.Metric.MeasuredAnnularMass
+import OAI.Geometry.RCD.Harmonic.HarmonicAffineImprovement
+import OAI.Geometry.RCD.Sobolev.DirichletPoincare
+
+namespace OAI
+
+/-! # Changing the normalization of actual harmonic candidates -/
+
+open Set Metric Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+omit [ProperSpace X] in
+theorem NoncollapsedRCD.inner_harmonic_norm_bound {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) {S R C : ℝ}
+ (hS : 0 (hX.finiteOnBounded _ isBounded_ball).ne)
+ (fun k => ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hS (hr k))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne) hε
+ refine ⟨Real.sqrt (2*C/b),Real.sqrt_pos.mpr (by positivity),?_⟩
+ filter_upwards [hmass.eventually (Ioi_mem_nhds (show b/2 sq_nonneg _)
+ have hsq := normalized_sobolev_mean_sq μ hX.quadratic (ball (p k) (R*r k))
+ (hX.finiteOnBounded _ isBounded_ball).ne (w k)
+ change harmonicTargetNorm hX (p k) (R*r k) (w k)^2=_ at hsq
+ have hi : (∫ x in ball (p k) (R*r k),
+ (SobolevSpace.toLp μ hX.quadratic (w k) x)^2 ∂μ)≤
+ (2*C/b)*μ.real (ball (p k) (R*r k)) := by
+ have hh := mul_le_mul_of_nonneg_left hratio hC.le
+ have hu := hint.trans (hw k)
+ calc _ ≤ C*μ.real (ball (p k) (S*r k)) := hu
+ _ ≤ _ := by convert hh using 1; ring
+ apply (sq_le_sq₀ (norm_nonneg _) (Real.sqrt_nonneg _)).mp
+ change harmonicTargetNorm hX (p k) (R*r k) (w k)^2≤(Real.sqrt (2*C/b))^2
+ rw [Real.sq_sqrt (by positivity),hsq]
+ have hh := mul_le_mul_of_nonneg_left hi (inv_pos.mpr hmR).le
+ convert hh using 1
+ field_simp
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/IntegrableRadialTail.lean b/lean/OAI/Geometry/RCD/Harmonic/IntegrableRadialTail.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0f734d9a07bc46b9c4a61a1a18902b3827784a50
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/IntegrableRadialTail.lean
@@ -0,0 +1,33 @@
+import Mathlib.MeasureTheory.Integral.Bochner.Set
+
+namespace OAI
+
+/-! # Vanishing tails of an integrable function outside metric balls -/
+
+open Set Filter MeasureTheory Metric
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [PseudoMetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ {μ : Measure X} {f : X → ℝ}
+
+theorem integrable_radial_tail (hf : Integrable f μ) (p : X) :
+ Tendsto (fun k : ℕ => ∫ x in (ball p (k:ℝ))ᶜ, f x ∂μ) atTop (nhds 0) := by
+ have hanti : Antitone (fun k : ℕ => (ball p (k:ℝ))ᶜ) := by
+ intro i j hij
+ exact compl_subset_compl.mpr (ball_subset_ball (by exact_mod_cast hij))
+ have hempty : (⋂ k : ℕ, (ball p (k:ℝ))ᶜ) = ∅ := by
+ apply eq_empty_iff_forall_notMem.mpr
+ intro x hx
+ obtain ⟨k,hk⟩ := exists_nat_gt (dist x p)
+ have hh := mem_iInter.mp hx k
+ exact hh (mem_ball.mpr hk)
+ have ht := tendsto_setIntegral_of_antitone
+ (fun k : ℕ => (measurableSet_ball : MeasurableSet (ball p (k:ℝ))).compl)
+ hanti ⟨0,hf.integrableOn⟩
+ simpa only [hempty,setIntegral_empty] using ht
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/IntegratedPolarization.lean b/lean/OAI/Geometry/RCD/Harmonic/IntegratedPolarization.lean
new file mode 100644
index 0000000000000000000000000000000000000000..a2080d3a2213a72a17646dd0fbe2c48ffacea66d
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/IntegratedPolarization.lean
@@ -0,0 +1,86 @@
+import OAI.Geometry.RCD.Harmonic.OperatorQuadraticDerivative
+import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap
+import Mathlib.MeasureTheory.SpecificCodomains.Pi
+
+namespace OAI
+
+/-! # Integrating the finite polarization used by the cutoff error -/
+
+open MeasureTheory
+open scoped InnerProductSpace
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MeasurableSpace X] (μ : Measure X) {n : ℕ}
+
+/-- Integration of a symmetric operator family preserves the quadratic
+identity supplied by its finite polarizing tests. -/
+theorem integrated_polarization_energy (B : X → Euclidean n →L[ℝ] Euclidean n)
+ (hB : ∀ x, (B x).IsSymmetric)
+ (hint : ∀ v, Integrable (fun x => ⟪v, B x v⟫_ℝ) μ) (v : Euclidean n) :
+ ⟪v, polarizedDerivative (fun w => ∫ x, ⟪w, B x w⟫_ℝ ∂μ) v⟫_ℝ =
+ ∫ x, ⟪v, B x v⟫_ℝ ∂μ := by
+ have hi : Integrable B μ := by
+ have h := integrable_polarizedDerivative μ (fun x w => ⟪w, B x w⟫_ℝ)
+ (fun i => hint _) (fun i j => hint _)
+ simpa only [polarizedDerivative_quadratic_form _ (hB _)] using h
+ let S := ∫ x, B x ∂μ
+ have hquad (w z : Euclidean n) : ⟪w, S z⟫_ℝ = ∫ x, ⟪w, B x z⟫_ℝ ∂μ := by
+ dsimp only [S]
+ rw [ContinuousLinearMap.integral_apply hi z]
+ exact ((innerSL ℝ w).integral_comp_comm
+ ((ContinuousLinearMap.apply ℝ (Euclidean n) z).integrable_comp hi)).symm
+ have hsym : S.IsSymmetric := by
+ intro w z
+ change ⟪S w, z⟫_ℝ = ⟪w, S z⟫_ℝ
+ rw [real_inner_comm, hquad, hquad]
+ apply integral_congr_ae
+ exact Filter.Eventually.of_forall fun x => by
+ exact (real_inner_comm _ _).trans ((hB x) w z)
+ have he : (fun w => ∫ x, ⟪w, B x w⟫_ℝ ∂μ) = fun w => ⟪w, S w⟫_ℝ :=
+ funext fun w => (hquad w w).symm
+ rw [he, polarizedDerivative_quadratic_form S hsym, hquad]
+
+/-- One finite L1 budget controls every polarized integral operator. -/
+theorem exists_polarized_integral_bound (g : Euclidean n → X → ℝ) :
+ ∃ C : ℝ, 0 < C ∧ ∀ (k : X → ℝ) (a : ℝ), 0 ≤ a →
+ (∀ v, |∫ x, k x * g v x ∂μ| ≤ a * ∫ x, |g v x| ∂μ) →
+ ‖polarizedDerivative (fun v => ∫ x, k x * g v x ∂μ)‖ ≤ C * a := by
+ classical
+ let m := fun v : Euclidean n => ∫ x, |g v x| ∂μ
+ have hm (v) : 0 ≤ m v := integral_nonneg fun x => abs_nonneg _
+ let B := 1 + (∑ i : Fin n, m (EuclideanSpace.single i 1)) +
+ ∑ i : Fin n, ∑ j : Fin n, m (EuclideanSpace.single i 1 + EuclideanSpace.single j 1)
+ have hS : 0 ≤ ∑ i : Fin n, m (EuclideanSpace.single i 1) := Finset.sum_nonneg fun _ _ => hm _
+ have hP : 0 ≤ ∑ i : Fin n, ∑ j : Fin n,
+ m (EuclideanSpace.single i 1 + EuclideanSpace.single j 1) :=
+ Finset.sum_nonneg fun _ _ => Finset.sum_nonneg fun _ _ => hm _
+ have hB : 0 < B := by dsimp only [B]; linarith
+ have hs (i : Fin n) : m (EuclideanSpace.single i 1) ≤ B := by
+ have hh := Finset.single_le_sum (fun j (_ : j ∈ Finset.univ) => hm (EuclideanSpace.single j 1))
+ (Finset.mem_univ i)
+ dsimp only [B]
+ linarith
+ have hp (i j : Fin n) : m (EuclideanSpace.single i 1 + EuclideanSpace.single j 1) ≤ B := by
+ have hh := Finset.single_le_sum
+ (fun l (_ : l ∈ Finset.univ) => hm (EuclideanSpace.single i 1 + EuclideanSpace.single l 1))
+ (Finset.mem_univ j)
+ have hh' := Finset.single_le_sum (fun l (_ : l ∈ Finset.univ) =>
+ Finset.sum_nonneg (fun k (_ : k ∈ Finset.univ) => hm (EuclideanSpace.single l 1 + EuclideanSpace.single k 1)))
+ (Finset.mem_univ i)
+ dsimp only [B]
+ linarith
+ refine ⟨(n : ℝ) ^ 2 * (3 / 2 * B) + 1, by positivity, ?_⟩
+ intro k a ha hb
+ have ht := polarizedDerivative_norm_le (fun v => ∫ x, k x * g v x ∂μ) (mul_nonneg ha hB.le)
+ (fun i => (hb _).trans (mul_le_mul_of_nonneg_left (hs i) ha))
+ (fun i j => (hb _).trans (mul_le_mul_of_nonneg_left (hp i j) ha))
+ apply ht.trans
+ nlinarith only [ha]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/IntegratedRadialDensity.lean b/lean/OAI/Geometry/RCD/Harmonic/IntegratedRadialDensity.lean
new file mode 100644
index 0000000000000000000000000000000000000000..582d3ad694e7d0d1f12a6c7a8c1d9cc8deb7463e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/IntegratedRadialDensity.lean
@@ -0,0 +1,54 @@
+import Mathlib
+
+namespace OAI
+
+/-! # Integrating the radial area-density comparison on positive intervals -/
+
+open Set MeasureTheory
+
+namespace RegularPointCoordinates
+
+theorem integrated_radial_density_ratio {V w : ℝ → ℝ} {a b c : ℝ}
+ (hab : a ≤ b) (hbc : b ≤ c) (hw : Continuous w)
+ (hV : AbsolutelyContinuousOnInterval V a c)
+ (hcomp : ∀ x ∈ Icc a b, ∀ y ∈ Icc b c,
+ DifferentiableAt ℝ V x → DifferentiableAt ℝ V y →
+ w x * deriv V y ≤ w y * deriv V x) :
+ (V c - V a) * (∫ s in a..b, w s) ≤
+ (V b - V a) * (∫ s in a..c, w s) := by
+ have hVac : ∀ᵐ x ∂volume, x ∈ Icc a c → DifferentiableAt ℝ V x := by
+ simpa only [uIcc_of_le (hab.trans hbc)] using hV.ae_differentiableAt
+ have hVab : AbsolutelyContinuousOnInterval V a b := hV.mono (by
+ rw [uIcc_of_le hab, uIcc_of_le (hab.trans hbc)]
+ exact Icc_subset_Icc_right hbc)
+ have hVbc : AbsolutelyContinuousOnInterval V b c := hV.mono (by
+ rw [uIcc_of_le hbc, uIcc_of_le (hab.trans hbc)]
+ exact Icc_subset_Icc_left hab)
+ have hWab : IntervalIntegrable w volume a b := hw.intervalIntegrable a b
+ have hWbc : IntervalIntegrable w volume b c := hw.intervalIntegrable b c
+ have hfirst (y : ℝ) (hy : y ∈ Icc b c) (hdy : DifferentiableAt ℝ V y) :
+ (∫ x in a..b, w x) * deriv V y ≤ w y * (V b - V a) := by
+ have hp : (fun x => w x * deriv V y) ≤ᵐ[volume.restrict (Icc a b)]
+ fun x => w y * deriv V x := by
+ filter_upwards [ae_restrict_of_ae hVac, ae_restrict_mem measurableSet_Icc] with x hx hxab
+ exact hcomp x hxab y hy (hx ⟨hxab.1, hxab.2.trans hbc⟩) hdy
+ have hi := intervalIntegral.integral_mono_ae_restrict hab
+ (hWab.mul_const (deriv V y)) (hVab.intervalIntegrable_deriv.const_mul (w y)) hp
+ simpa only [intervalIntegral.integral_mul_const, intervalIntegral.integral_const_mul,
+ hVab.integral_deriv_eq_sub] using hi
+ have hp : (fun y => (∫ x in a..b, w x) * deriv V y) ≤ᵐ[volume.restrict (Icc b c)]
+ fun y => w y * (V b - V a) := by
+ filter_upwards [ae_restrict_of_ae hVac, ae_restrict_mem measurableSet_Icc] with y hy hybc
+ exact hfirst y hybc (hy ⟨hab.trans hybc.1, hybc.2⟩)
+ have hi := intervalIntegral.integral_mono_ae_restrict hbc
+ (hVbc.intervalIntegrable_deriv.const_mul (∫ x in a..b, w x))
+ (hWbc.mul_const (V b - V a)) hp
+ rw [intervalIntegral.integral_const_mul, intervalIntegral.integral_mul_const,
+ hVbc.integral_deriv_eq_sub] at hi
+ have hadd := intervalIntegral.integral_add_adjacent_intervals hWab hWbc
+ rw [← hadd]
+ nlinarith only [hi]
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/InteriorQuadraticComparison.lean b/lean/OAI/Geometry/RCD/Harmonic/InteriorQuadraticComparison.lean
new file mode 100644
index 0000000000000000000000000000000000000000..e1435c35beaf24ae5d78422f65182bc8402d754f
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/InteriorQuadraticComparison.lean
@@ -0,0 +1,44 @@
+import OAI.Geometry.RCD.Harmonic.InteriorQuadraticDefect
+
+namespace OAI
+
+/-! # Stability of the interior quadratic defect under value errors -/
+
+open Set MeasureTheory
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem abs_three_point_difference_le {θ : ℝ} (hθ0 : 0≤θ) (hθ1 : θ≤1) (a b c : ℝ) :
+ |a-(1-θ)*b-θ*c|≤|a|+|b|+|c| := by
+ calc
+ _ ≤ |a|+|(1-θ)*b|+|θ*c| := (abs_sub _ _).trans (add_le_add (abs_sub _ _) le_rfl)
+ _ = |a|+(1-θ)*|b|+θ*|c| := by
+ rw [abs_mul,abs_mul,abs_of_nonneg (show 0≤1-θ by linarith),abs_of_nonneg hθ0]
+ _ ≤ _ := by nlinarith [abs_nonneg b,abs_nonneg c]
+
+variable {X : Type*} [MetricSpace X]
+
+theorem interiorQuadraticDefect_comparison (U V : X → ℝ) (l h t : Time)
+ (hlh : (l:ℝ) ((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (R*r k),
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic (w k-q k) x)^2 ∂hausdorff n X)
+ atTop (𝓝 0) := by
+ let μ := hausdorff n X
+ let Ω := fun k => ball (p k) (R*r k)
+ let m := fun k => μ.real (ball (p k) (S*r k))
+ let z := fun k x => SobolevSpace.toLp μ hX.quadratic (w k-q k) x
+ let : ∀ k, IsFiniteMeasure (μ.restrict (Ω k)) := fun k => ⟨by
+ simpa only [Measure.restrict_apply_univ] using hX.finiteOnBounded (Ω k) isBounded_ball⟩
+ have hsub (k : ℕ) : Ω k⊆ball (p k) (S*r k) :=
+ ball_subset_ball (mul_le_mul_of_nonneg_right (hRT.trans hTS).le (hr k).le)
+ apply containing_mass_uniform_l2 (fun k => μ.restrict (Ω k)) m
+ (fun k => ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hS (hr k))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne)
+ (fun k => by
+ simp only [Measure.real,Measure.restrict_apply_univ]
+ exact ENNReal.toReal_mono (hX.finiteOnBounded _ isBounded_ball).ne (measure_mono (hsub k)))
+ z (fun k => (Lp.aestronglyMeasurable (SobolevSpace.toLp μ hX.quadratic (w k-q k))).mono_measure
+ Measure.restrict_le_self)
+ intro δ hδ
+ have hsmall : ∀ᶠ k in atTop, ε k<(T-R)/2 :=
+ hεlim.eventually (Iio_mem_nhds (by linarith))
+ filter_upwards [hw (δ/2) (half_pos hδ),hq (δ/2) (half_pos hδ),hsmall] with k hwk hqk hek
+ filter_upwards [hwk,ae_restrict_of_ae_restrict_of_subset (hsub k) hqk,
+ ae_restrict_mem measurableSet_ball,ae_restrict_of_ae (Lp.coeFn_sub
+ (SobolevSpace.toLp μ hX.quadratic (w k)) (SobolevSpace.toLp μ hX.quadratic (q k)))]
+ with x hwx hqx hx hsubx
+ have hd := (abs_le.mp (pointed_radial_distance (hr k) hS.le (hV k).metric (hsub k hx).le)).2
+ have hxR : dist x (p k)/r k ((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (S*r k),
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic (f k) x-‖V k x‖^2/2)^2
+ ∂hausdorff n X) atTop (𝓝 0))
+ {ψ : Euclidean n → ℝ} (hψ : InteriorSmoothTest n S ψ) :
+ Tendsto (fun k => r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (S*r k), ψ (V k x)*localGamma (hausdorff n X) hX.quadratic
+ (f k) (w k) x ∂hausdorff n X) atTop
+ (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*
+ ∫ z in ball 0 S, ψ z*fderiv ℝ g z z)) := by
+ have hweak := hX.harmonic_value_limit_weak_of_curvature hn hS p r ε hr hcurv hε hε1 hεlim
+ V w hV hw hnorm g hgL hconv
+ obtain ⟨d,hd,hds⟩ := exists_pos_lt_subset_ball hS (isClosed_tsupport ψ) hψ.2.2
+ obtain ⟨c₀,hc₀,hc₀S,N,u,huv,hug,huz,hue⟩ :=
+ hX.sharp_weighted_test_recovery hn hS p r ε V hr hcurv hε hε1 hεlim hV hψ
+ obtain ⟨Q,hQ,hub⟩ := compact_recovery_scaled_gradient_bound (hausdorff n X) hX.quadratic
+ (hψ.1.of_le (by simp)) hψ.2.1 (fun k => p (k+N)) (fun k => r (k+N))
+ (fun k => hr (k+N)) (fun k => V (k+N)) (fun k => (u k).val) huz (hug c₀ hc₀.le hc₀S)
+ let c := max d c₀
+ have hc : 0 ‖z‖^2/2) (closedBall 0 T))
+ (hue : Tendsto (fun k => r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (S*r k), F (V k x)*localGamma (hausdorff n X) hX.quadratic
+ (u k) (u k) x ∂hausdorff n X) atTop
+ (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*∫ z in ball 0 S, F z*‖fderiv ℝ ψ z‖^2)))
+ (hqe : Tendsto (fun k => r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (S*r k), F (V k x)*localGamma (hausdorff n X) hX.quadratic
+ (q k) (q k) x ∂hausdorff n X) atTop
+ (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*∫ z in ball 0 S, F z*‖fderiv ℝ G z‖^2)))
+ (herror : Tendsto (fun k => r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (R*r k), (nestedBallCutoff (p k) (a*r k) (b*r k) x)^2*
+ localGamma (hausdorff n X) hX.quadratic (w k-q k) (w k-q k) x ∂hausdorff n X)
+ atTop (𝓝 0))
+ (hflim : Tendsto (fun k => ((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (S*r k),
+ (SobolevSpace.toLp (hausdorff n X) hX.quadratic (f k) x-‖V k x‖^2/2)^2
+ ∂hausdorff n X) atTop (𝓝 0)) :
+ Tendsto (fun k => r k^2*((hausdorff n X).real (ball (p k) (S*r k)))⁻¹*
+ ∫ x in ball (p k) (S*r k), ψ (V k x)*localGamma (hausdorff n X) hX.quadratic
+ (f k) (w k) x ∂hausdorff n X) atTop
+ (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*
+ ∫ z in ball 0 S, ψ z*fderiv ℝ g z z)) := by
+ let μ := hausdorff n X
+ let : ∀ k, IsFiniteMeasure (μ.restrict (ball (p k) (S*r k))) := fun k => ⟨by
+ simpa only [Measure.restrict_apply_univ] using hX.finiteOnBounded _ isBounded_ball⟩
+ have hcT := hca.trans (hab.trans (hbR.trans hRT))
+ obtain ⟨B,hB⟩ := hψ.2.1.exists_bound_of_continuous hψ.1.continuous
+ have hcoeff := compact_recovery_coefficient μ hX.quadratic hS hcT hcT hTS p r ε V hr hεlim hV
+ (fun k => ENNReal.toReal_pos (hX.fullSupport _ _ (mul_pos hS (hr k))).ne'
+ (hX.finiteOnBounded _ isBounded_ball).ne) u f w ψ hψ.1.continuous
+ (fun x => by simpa only [Real.norm_eq_abs] using hB x) hψs huz huv hA hM hfb hwb
+ have hswap := hX.normalized_recovery_radial_swap hn hS hcT hTS p r ε V hr hεlim hV
+ f w u hw hQ hM hub hwb huz F hFr hflim
+ have htransfer := hX.compact_harmonic_transfer hS hca hab hbR (hRT.trans hTS) p r hr V
+ (fun k => (hV k).measurable) u w q F hub huz herror
+ have hmix := hX.compact_recovery_mixed_energy hn hS p r ε V hr hcurv hε hε1 hεlim hV
+ u q hψ hG huv hqv (sq_nonneg Q) (sq_nonneg P) hub hqb F hFn hF.2.2 hue hqe
+ have hid := compact_radial_pairing_identity hS hTS F hgL hgweak hG.1 hd hFr hψ
+ (hψs.trans (ball_subset_ball hcT.le))
+ rw [hid,mul_neg] at hmix
+ have ht := ((hcoeff.add hswap).sub htransfer).sub hmix
+ convert ht using 1
+ · funext k
+ ring
+ · simp
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialMomentBound.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialMomentBound.lean
new file mode 100644
index 0000000000000000000000000000000000000000..7f5aae6a5b9bd1ee0fa06035af769a64f37d3909
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialMomentBound.lean
@@ -0,0 +1,53 @@
+import Mathlib.MeasureTheory.Integral.Bochner.Set
+
+namespace OAI
+
+/-! # A tail moment controls the total quadratic moment -/
+
+open Set Filter MeasureTheory Metric
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [PseudoMetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ {μ : Measure X} {f : X → ℝ}
+
+theorem weighted_moment_le_of_tail (p : X) (R : ℝ) (hf0 : ∀ x, 0 ≤ f x)
+ (hf : Integrable f μ)
+ (hw : Integrable (fun x => f x*(1+(dist x p)^2)) μ)
+ (ht : (∫ x in (ball p R)ᶜ, f x*(dist x p)^2 ∂μ) ≤ 1) :
+ (∫ x, f x*(1+(dist x p)^2) ∂μ) ≤ (1+R^2)*(∫ x, f x ∂μ)+1 := by
+ have hsq : Integrable (fun x => f x*(dist x p)^2) μ := by
+ have hm : AEStronglyMeasurable (fun x => f x*(dist x p)^2) μ :=
+ (hw.aestronglyMeasurable.sub hf.aestronglyMeasurable).congr
+ (Eventually.of_forall (fun x => by dsimp only [Pi.sub_apply,Pi.add_apply]; ring))
+ apply hw.mono' hm
+ apply Eventually.of_forall
+ intro x
+ rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (hf0 x) (sq_nonneg _))]
+ nlinarith [hf0 x]
+ have hind := hsq.indicator (s := (ball p R)ᶜ) measurableSet_ball.compl
+ have hpoint (x : X) : f x*(dist x p)^2 ≤ R^2*f x+
+ (ball p R)ᶜ.indicator (fun y => f y*(dist y p)^2) x := by
+ by_cases hx : x ∈ ball p R
+ · rw [indicator_of_notMem (show x ∉ (ball p R)ᶜ by simpa using hx)]
+ have hd : dist x p < R := mem_ball.mp hx
+ have hh : (dist x p)^2 ≤ R^2 := pow_le_pow_left₀ dist_nonneg hd.le 2
+ nlinarith [mul_le_mul_of_nonneg_left hh (hf0 x)]
+ · rw [indicator_of_mem hx]
+ nlinarith [mul_nonneg (sq_nonneg R) (hf0 x)]
+ have hb := integral_mono hsq ((hf.const_mul (R^2)).add hind) hpoint
+ simp only [Pi.add_apply] at hb
+ rw [integral_add (hf.const_mul (R^2)) hind,integral_const_mul,
+ integral_indicator measurableSet_ball.compl] at hb
+ have he : (∫ x, f x*(1+(dist x p)^2) ∂μ) =
+ (∫ x, f x ∂μ)+(∫ x, f x*(dist x p)^2 ∂μ) := by
+ rw [← integral_add hf hsq]
+ apply integral_congr_ae
+ exact Eventually.of_forall (fun x => by dsimp only [Pi.sub_apply,Pi.add_apply]; ring)
+ rw [he]
+ nlinarith
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialPairingSize.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialPairingSize.lean
new file mode 100644
index 0000000000000000000000000000000000000000..169489343f9b985e6a92e2cff1265b3f4caee0c9
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialPairingSize.lean
@@ -0,0 +1,56 @@
+import OAI.Geometry.RCD.Harmonic.RadialDerivativeError
+import OAI.Geometry.RCD.Coordinates.NormalizedLocalL2
+
+namespace OAI
+
+/-! # The averaged size of the actual radial pairing -/
+
+open Set MeasureTheory
+open scoped ENNReal
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- Pointwise gradient bounds give the normalized L² size used to show
+that the center values of affine fits vanish at shrinking radii. -/
+theorem normalized_gamma_size (s : Set X) (hs : μ s ≠ ∞) (hs0 : μ s ≠ 0)
+ (q a : SobolevSpace μ hQ) {A B : ℝ} (hA : 0 ≤ A) (hB : 0 ≤ B)
+ (hq : ∀ᵐ x ∂μ.restrict s, localGamma μ hQ q q x ≤ A)
+ (ha : ∀ᵐ x ∂μ.restrict s, localGamma μ hQ a a x ≤ B) :
+ ‖normalizeLocalL2 μ s hs
+ ((localGamma_memLp_two_of_bound μ hQ s q a ha).toLp (localGamma μ hQ q a))‖ ≤
+ Real.sqrt (A * B) := by
+ let rawmem := localGamma_memLp_two_of_bound μ hQ s q a ha
+ let raw := rawmem.toLp (localGamma μ hQ q a)
+ have hpoint : ∀ᵐ x ∂μ.restrict s, (raw x) ^ 2 ≤ A * B := by
+ filter_upwards [MemLp.coeFn_toLp rawmem, hq, ha,
+ ae_restrict_of_ae (localGamma_sq_le μ hQ q a),
+ ae_restrict_of_ae (localGamma_self μ hQ a)] with x he hqx hax hcs hself
+ change raw x = localGamma μ hQ q a x at he
+ rw [he]
+ exact hcs.trans (mul_le_mul hqx hax (by rw [hself]; positivity) hA)
+ let : IsFiniteMeasure (μ.restrict s) :=
+ ⟨by simpa only [Measure.restrict_apply_univ] using hs.lt_top⟩
+ have hi : (∫ x, (raw x) ^ 2 ∂μ.restrict s) ≤ (A * B) * μ.real s := by
+ calc
+ _ ≤ ∫ _x, A * B ∂μ.restrict s :=
+ integral_mono_ae (Lp.memLp raw).integrable_sq (integrable_const _) hpoint
+ _ = _ := by simp only [integral_const, smul_eq_mul, Measure.real,
+ Measure.restrict_apply_univ, mul_comm]
+ have hvol : μ.real s ≠ 0 := ne_of_gt (ENNReal.toReal_pos hs0 hs)
+ have hn : ‖normalizeLocalL2 μ s hs raw‖ ^ 2 ≤ A * B := by
+ rw [normalizeLocalL2_norm_sq]
+ have hm := mul_le_mul_of_nonneg_left hi (by positivity : 0 ≤ (μ.real s)⁻¹)
+ exact hm.trans_eq (by field_simp [hvol])
+ change ‖normalizeLocalL2 μ s hs raw‖ ≤ _
+ exact (sq_le_sq₀ (norm_nonneg _) (Real.sqrt_nonneg _)).mp
+ (by simpa only [Real.sq_sqrt (mul_nonneg hA hB)] using hn)
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialQuadraticL2Limit.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialQuadraticL2Limit.lean
new file mode 100644
index 0000000000000000000000000000000000000000..07717b8aa00396457d8edaf0d5bca8b923ed1956
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialQuadraticL2Limit.lean
@@ -0,0 +1,118 @@
+import OAI.Geometry.RCD.Harmonic.RadialQuadraticLimit
+import OAI.Geometry.RCD.Harmonic.QuadraticModelValues
+
+namespace OAI
+
+/-! # The quadratic radial limit from mean-square Poisson error -/
+
+open Set Metric MeasureTheory Filter
+open scoped ENNReal NNReal Topology
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+omit [ProperSpace X] in
+/-- Metric approximation controls the dimensionless distance quadratic
+against the actual bounded coordinate quadratic. -/
+theorem coordinateQuadratic_dimensionless_error {n : ℕ} {p : X} {r S ε : ℝ}
+ (hr : 0 < r) (hS : 0 ≤ S) (hε : 0 ≤ ε)
+ (u : Fin n → SobolevSpace μ hQ) (C : ℝ≥0) (V : X → Euclidean n)
+ (hu : ∀ j, ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ (u j) x| ≤ C)
+ (hrep : ∀ j, SobolevSpace.toLp μ hQ (u j) =ᵐ[μ.restrict (ball p (S * r))] fun x => V x j)
+ (hmetric : IsPointedApproximation p 0 r S ε V) (hcenter : V p = 0)
+ (q : SobolevSpace μ hQ)
+ (hq : SobolevSpace.toLp μ hQ q =ᵐ[μ.restrict (ball p (S * r))]
+ fun x => dist p x ^ 2 / (2 * r ^ 2)) :
+ ∀ᵐ x ∂μ.restrict (ball p (S * r)),
+ |SobolevSpace.toLp μ hQ (q - coordinateQuadratic μ hQ u C) x| ≤
+ ε * (2 * S + ε) / 2 := by
+ filter_upwards [hq, coordinateQuadratic_eq_norm μ hQ u C V hu hrep,
+ ae_restrict_of_ae (Lp.coeFn_sub (SobolevSpace.toLp μ hQ q)
+ (SobolevSpace.toLp μ hQ (coordinateQuadratic μ hQ u C))),
+ ae_restrict_mem measurableSet_ball] with x hqx hHx hsub hx
+ rw [map_sub, hsub, Pi.sub_apply, hHx]
+ have hzero : |r ^ 2 * SobolevSpace.toLp μ hQ q x - dist p x ^ 2 / 2| ≤ r ^ 2 * 0 := by
+ rw [hqx]
+ have heq : r ^ 2 * (dist p x ^ 2 / (2 * r ^ 2)) - dist p x ^ 2 / 2 = 0 := by
+ field_simp
+ ring
+ rw [heq, abs_zero, mul_zero]
+ simpa only [zero_add] using radial_quadratic_value_error hr hS hε hmetric hcenter hx.le hzero
+
+omit [ProperSpace X] in
+/-- The normalized coordinate error is bounded by the Poisson L2 error
+plus the metric approximation error. No uniform vanishing height is needed. -/
+theorem radial_quadratic_l2_bound {n : ℕ} {p : X} {r S ε : ℝ}
+ (hr : 0 < r) (hS : 0 ≤ S) (hε : 0 ≤ ε)
+ (hfin : μ (ball p (S * r)) ≠ ∞)
+ (u : Fin n → SobolevSpace μ hQ) (C : ℝ≥0) (V : X → Euclidean n)
+ (hu : ∀ j, ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ (u j) x| ≤ C)
+ (hrep : ∀ j, SobolevSpace.toLp μ hQ (u j) =ᵐ[μ.restrict (ball p (S * r))] fun x => V x j)
+ (hmetric : IsPointedApproximation p 0 r S ε V) (hcenter : V p = 0)
+ (f q : SobolevSpace μ hQ)
+ (hq : SobolevSpace.toLp μ hQ q =ᵐ[μ.restrict (ball p (S * r))]
+ fun x => dist p x ^ 2 / (2 * r ^ 2)) :
+ ‖normalizeLocalL2 μ (ball p (S * r)) hfin (SobolevSpace.restrictLp μ hQ
+ (ball p (S * r)) (f - coordinateQuadratic μ hQ u C))‖ ≤
+ ‖normalizeLocalL2 μ (ball p (S * r)) hfin (SobolevSpace.restrictLp μ hQ
+ (ball p (S * r)) (f - q))‖ + ε * (2 * S + ε) / 2 := by
+ have hb : ‖normalizeLocalL2 μ (ball p (S * r)) hfin (SobolevSpace.restrictLp μ hQ
+ (ball p (S * r)) (q - coordinateQuadratic μ hQ u C))‖ ≤ ε * (2 * S + ε) / 2 := by
+ apply normalized_norm_le_of_bound μ _ hfin _ (by positivity)
+ filter_upwards [coordinateQuadratic_dimensionless_error μ hQ hr hS hε u C V hu hrep hmetric hcenter q hq,
+ SobolevSpace.restrictLp_coe μ hQ (ball p (S * r)) (q - coordinateQuadratic μ hQ u C)] with x hx heq
+ rwa [heq]
+ have heq : f - coordinateQuadratic μ hQ u C = (f - q) + (q - coordinateQuadratic μ hQ u C) := by abel
+ rw [heq, map_add]
+ simp only [normalizeLocalL2, smul_add] at hb ⊢
+ exact (norm_add_le _ _).trans (add_le_add le_rfl hb)
+
+omit [ProperSpace X] in
+/-- Strong mean-square convergence to squared distance and metric
+approximation give the radial value limit in the Euclidean coordinates. -/
+theorem radial_quadratic_l2_limit {n : ℕ} {S : ℝ} (hS : 0 ≤ S)
+ (p : ℕ → X) (r ε : ℕ → ℝ) (u : ℕ → Fin n → SobolevSpace μ hQ)
+ (C : ℕ → ℝ≥0) (V : ℕ → X → Euclidean n) (f q : ℕ → SobolevSpace μ hQ)
+ (hr : ∀ i, 0 < r i) (hε : ∀ i, 0 ≤ ε i) (hε0 : Tendsto ε atTop (𝓝 0))
+ (hfin : ∀ i, μ (ball (p i) (S * r i)) ≠ ∞)
+ (hu : ∀ i j, ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ (u i j) x| ≤ C i)
+ (hrep : ∀ i j, SobolevSpace.toLp μ hQ (u i j) =ᵐ[μ.restrict (ball (p i) (S * r i))]
+ fun x => V i x j)
+ (hmetric : ∀ i, IsPointedApproximation (p i) 0 (r i) S (ε i) (V i))
+ (hcenter : ∀ i, V i (p i) = 0)
+ (hq : ∀ i, SobolevSpace.toLp μ hQ (q i) =ᵐ[μ.restrict (ball (p i) (S * r i))]
+ fun x => dist (p i) x ^ 2 / (2 * r i ^ 2))
+ (herror : Tendsto (fun i => ‖normalizeLocalL2 μ (ball (p i) (S * r i)) (hfin i)
+ (SobolevSpace.restrictLp μ hQ (ball (p i) (S * r i)) (f i - q i))‖) atTop (𝓝 0)) :
+ Tendsto (fun i => (μ.real (ball (p i) (S * r i)))⁻¹ *
+ ∫ x in ball (p i) (S * r i), (SobolevSpace.toLp μ hQ (f i) x - ‖V i x‖ ^ 2 / 2) ^ 2 ∂μ)
+ atTop (𝓝 0) := by
+ let H i := coordinateQuadratic μ hQ (u i) (C i)
+ have hlim : Tendsto (fun i => ‖normalizeLocalL2 μ (ball (p i) (S * r i)) (hfin i)
+ (SobolevSpace.restrictLp μ hQ (ball (p i) (S * r i)) (f i - H i))‖) atTop (𝓝 0) := by
+ apply squeeze_zero (fun _ => norm_nonneg _)
+ (fun i => radial_quadratic_l2_bound μ hQ (hr i) hS (hε i) (hfin i)
+ (u i) (C i) (V i) (hu i) (hrep i) (hmetric i) (hcenter i) (f i) (q i) (hq i))
+ have hb := herror.add ((hε0.mul ((tendsto_const_nhds (x := 2 * S)).add hε0)).div_const 2)
+ simpa using hb
+ have heq (i : ℕ) : ‖normalizeLocalL2 μ (ball (p i) (S * r i)) (hfin i)
+ (SobolevSpace.restrictLp μ hQ (ball (p i) (S * r i)) (f i - H i))‖ ^ 2 =
+ (μ.real (ball (p i) (S * r i)))⁻¹ *
+ ∫ x in ball (p i) (S * r i), (SobolevSpace.toLp μ hQ (f i) x - ‖V i x‖ ^ 2 / 2) ^ 2 ∂μ := by
+ rw [normalized_sobolev_mean_sq]
+ congr 1
+ apply integral_congr_ae
+ filter_upwards [coordinateQuadratic_eq_norm μ hQ (u i) (C i) (V i) (hu i) (hrep i),
+ ae_restrict_of_ae (Lp.coeFn_sub (SobolevSpace.toLp μ hQ (f i))
+ (SobolevSpace.toLp μ hQ (H i)))] with x hx hs
+ rw [map_sub, hs, Pi.sub_apply, hx]
+ simpa only [heq, zero_pow (by decide : 2 ≠ 0)] using hlim.pow 2
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialQuadraticLimit.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialQuadraticLimit.lean
new file mode 100644
index 0000000000000000000000000000000000000000..7db62bc51cd881a63b6b2244fa275d2abc025b44
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialQuadraticLimit.lean
@@ -0,0 +1,107 @@
+import OAI.Geometry.RCD.Harmonic.MetricQuadraticError
+import OAI.Geometry.RCD.Coordinates.NormalizedPairing
+
+namespace OAI
+
+/-! # The radial value limit from Poisson height and metric approximation -/
+
+open Set Metric MeasureTheory Filter
+open scoped ENNReal Topology
+
+noncomputable section
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X]
+
+omit [MeasurableSpace X] in
+/-- The dimensionless radial value error is the sum of the Poisson height
+error and the explicitly squared metric approximation error. -/
+theorem radial_quadratic_value_error {n : ℕ} {p : X} {r S ε D : ℝ}
+ (hr : 0 < r) (hS : 0 ≤ S) (hε : 0 ≤ ε) {V : X → Euclidean n}
+ (hmetric : IsPointedApproximation p 0 r S ε V) (hcenter : V p = 0)
+ {F : X → ℝ} {x : X} (hx : dist x p ≤ S * r)
+ (hheight : |r ^ 2 * F x - dist p x ^ 2 / 2| ≤ r ^ 2 * D) :
+ |F x - ‖V x‖ ^ 2 / 2| ≤ D + ε * (2 * S + ε) / 2 := by
+ have hmetricx := hmetric.quadratic_value_error hr hS hε hcenter hx
+ have hsum : |r ^ 2 * F x - r ^ 2 * ‖V x‖ ^ 2 / 2| ≤
+ r ^ 2 * D + r ^ 2 * (ε * (2 * S + ε) / 2) :=
+ (abs_sub_le (r ^ 2 * F x) (dist p x ^ 2 / 2)
+ (r ^ 2 * ‖V x‖ ^ 2 / 2)).trans (add_le_add hheight hmetricx)
+ have heq : r ^ 2 * F x - r ^ 2 * ‖V x‖ ^ 2 / 2 =
+ r ^ 2 * (F x - ‖V x‖ ^ 2 / 2) := by ring
+ rw [heq, abs_mul, abs_of_pos (sq_pos_of_pos hr)] at hsum
+ nlinarith [sq_pos_of_pos hr]
+
+/-- A bounded radial value error controls its normalized mean square.
+The reference measure need only be finite on the ball. -/
+theorem radial_quadratic_mean_bound (μ : Measure X) [BorelSpace X]
+ {n : ℕ} {p : X} {r S ε D : ℝ} (hr : 0 < r) (hS : 0 ≤ S)
+ (hε : 0 ≤ ε) (hD : 0 ≤ D) (hfin : μ (ball p (S * r)) ≠ ∞)
+ {V : X → Euclidean n} (hV : Measurable V)
+ (hmetric : IsPointedApproximation p 0 r S ε V) (hcenter : V p = 0)
+ {F : X → ℝ} (hF : AEStronglyMeasurable F (μ.restrict (ball p (S * r))))
+ (hheight : ∀ᵐ x ∂μ.restrict (ball p (S * r)),
+ |r ^ 2 * F x - dist p x ^ 2 / 2| ≤ r ^ 2 * D) :
+ (μ.real (ball p (S * r)))⁻¹ *
+ (∫ x in ball p (S * r), (F x - ‖V x‖ ^ 2 / 2) ^ 2 ∂μ) ≤
+ (D + ε * (2 * S + ε) / 2) ^ 2 := by
+ let Ω := ball p (S * r)
+ let C := D + ε * (2 * S + ε) / 2
+ have hC : 0 ≤ C := by dsimp only [C]; positivity
+ let e : X → ℝ := fun x => F x - ‖V x‖ ^ 2 / 2
+ have hb : ∀ᵐ x ∂μ.restrict Ω, |e x| ≤ C := by
+ filter_upwards [hheight, ae_restrict_mem measurableSet_ball] with x hh hx
+ exact radial_quadratic_value_error hr hS hε hmetric hcenter hx.le hh
+ have hmV : Measurable (fun x => ‖V x‖ ^ 2 / 2) := by fun_prop
+ have hm : AEStronglyMeasurable e (μ.restrict Ω) :=
+ hF.sub hmV.aestronglyMeasurable
+ let : IsFiniteMeasure (μ.restrict Ω) :=
+ ⟨by simpa only [Ω, Measure.restrict_apply_univ] using hfin.lt_top⟩
+ have he : MemLp e 2 (μ.restrict Ω) :=
+ MemLp.of_bound hm C (by simpa only [Real.norm_eq_abs] using hb)
+ have hi : (∫ x in Ω, e x ^ 2 ∂μ) ≤ C ^ 2 * μ.real Ω := by
+ have hb' : ∀ᵐ x ∂μ.restrict Ω, e x ^ 2 ≤ C ^ 2 := by
+ filter_upwards [hb] with x hx
+ simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg _) hC).mpr hx
+ have hh := integral_mono_ae he.integrable_sq (integrable_const (C ^ 2)) hb'
+ simpa only [integral_const, smul_eq_mul, Measure.real, Measure.restrict_apply_univ,
+ mul_comm] using hh
+ change (μ.real Ω)⁻¹ * (∫ x in Ω, e x ^ 2 ∂μ) ≤ C ^ 2
+ by_cases hz : μ.real Ω = 0
+ · simp only [hz, inv_zero, zero_mul]
+ positivity
+ · calc
+ _ ≤ (μ.real Ω)⁻¹ * (C ^ 2 * μ.real Ω) :=
+ mul_le_mul_of_nonneg_left hi (by positivity)
+ _ = C ^ 2 := by field_simp
+
+/-- Vanishing height error and vanishing metric error imply the exact
+quadratic value limit needed by local Poisson/harmonic compactness. -/
+theorem radial_quadratic_mean_tendsto_zero (μ : Measure X) [BorelSpace X]
+ {n : ℕ} {S : ℝ} (hS : 0 ≤ S)
+ (p : ℕ → X) (r ε D : ℕ → ℝ) (V : ℕ → X → Euclidean n) (F : ℕ → X → ℝ)
+ (hr : ∀ i, 0 < r i) (hε : ∀ i, 0 ≤ ε i) (hD : ∀ i, 0 ≤ D i)
+ (hfin : ∀ i, μ (ball (p i) (S * r i)) ≠ ∞)
+ (hV : ∀ i, Measurable (V i))
+ (hmetric : ∀ i, IsPointedApproximation (p i) 0 (r i) S (ε i) (V i))
+ (hcenter : ∀ i, V i (p i) = 0)
+ (hF : ∀ i, AEStronglyMeasurable (F i) (μ.restrict (ball (p i) (S * r i))))
+ (hheight : ∀ i, ∀ᵐ x ∂μ.restrict (ball (p i) (S * r i)),
+ |r i ^ 2 * F i x - dist (p i) x ^ 2 / 2| ≤ r i ^ 2 * D i)
+ (hε0 : Tendsto ε atTop (𝓝 0)) (hD0 : Tendsto D atTop (𝓝 0)) :
+ Tendsto (fun i => (μ.real (ball (p i) (S * r i)))⁻¹ *
+ (∫ x in ball (p i) (S * r i), (F i x - ‖V i x‖ ^ 2 / 2) ^ 2 ∂μ))
+ atTop (𝓝 0) := by
+ have hbound := fun i => radial_quadratic_mean_bound μ (hr i) hS (hε i) (hD i)
+ (hfin i) (hV i) (hmetric i) (hcenter i) (hF i) (hheight i)
+ have hlim : Tendsto (fun i => (D i + ε i * (2 * S + ε i) / 2) ^ 2) atTop (𝓝 0) := by
+ have h := (hD0.add ((hε0.mul ((tendsto_const_nhds (x := 2 * S)).add hε0)).div_const 2)).pow 2
+ simpa using h
+ exact squeeze_zero (fun i => mul_nonneg (by positivity) (integral_nonneg fun _ => sq_nonneg _))
+ hbound hlim
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialSquaredDistance.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialSquaredDistance.lean
new file mode 100644
index 0000000000000000000000000000000000000000..13f6bc53908b0da11a53ad83c62dc1e03976a28e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialSquaredDistance.lean
@@ -0,0 +1,89 @@
+import OAI.Geometry.RCD.Sobolev.RadialCutoffMass
+
+namespace OAI
+
+/-!
+# Applying the radial test to an actual squared-distance representative
+
+The squared-distance function is cut off only at the larger working radius.
+Locality transfers its radial pairing to each smaller ball. The resulting
+mass estimate takes precisely the local weak Laplacian-defect identity and
+the eikonal input, rather than an assumed annular source formula.
+-/
+
+open Set Metric MeasureTheory
+open scoped NNReal
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [ProperSpace X] (μ : Measure X) [IsFiniteMeasureOnCompacts μ]
+ (hQ : QuadraticCheegerEnergy μ)
+
+theorem inwardQuadratic_gamma_smaller (c : X) {R T : ℝ} (hR : 0 ≤ R) (hRT : R ≤ T)
+ (heik : ∀ᵐ x ∂μ, x ∈ ball c R →
+ localGamma μ hQ (inwardSobolev μ hQ c R) (inwardSobolev μ hQ c R) x = 1) :
+ ∀ᵐ x ∂μ, x ∈ ball c R →
+ localGamma μ hQ (inwardQuadratic μ hQ c (hR.trans hRT)) (inwardSobolev μ hQ c R) x =
+ -dist c x := by
+ let u := inwardSobolev μ hQ c R
+ let w := inwardSobolev μ hQ c T
+ have hb : ∀ᵐ x ∂μ, |SobolevSpace.toLp μ hQ w x| ≤ (⟨T, hR.trans hRT⟩ : ℝ≥0) := by
+ filter_upwards [inwardSobolev_bounds μ hQ c (hR.trans hRT)] with x hx
+ change |SobolevSpace.toLp μ hQ (inwardSobolev μ hQ c T) x| ≤ T
+ simpa only [abs_of_nonneg hx.1] using hx.2
+ filter_upwards [heik, inwardSobolev_coe μ hQ c R, inwardSobolev_coe μ hQ c T,
+ Lp.coeFn_sub (SobolevSpace.toLp μ hQ w) (SobolevSpace.toLp μ hQ u),
+ localGamma_sub_left μ hQ w u u,
+ localGamma_zero_on_level μ hQ (w - u) u (T - R),
+ localGamma_sub_left μ hQ ((1 / 2 : ℝ) • SobolevSpace.square μ hQ w ⟨T, hR.trans hRT⟩) (T • w) u,
+ localGamma_smul_left μ hQ (1 / 2 : ℝ) (SobolevSpace.square μ hQ w ⟨T, hR.trans hRT⟩) u,
+ localGamma_smul_left μ hQ T w u,
+ localGamma_square μ hQ w u ⟨T, hR.trans hRT⟩ hb] with x he hu hw hsub hγsub hz hs ha ht hsq hx
+ have hd : dist c x < R := by simpa only [mem_ball, dist_comm] using hx
+ have hu' : SobolevSpace.toLp μ hQ u x = R - dist c x :=
+ hu.trans (max_eq_left (sub_nonneg.mpr hd.le))
+ have hw' : SobolevSpace.toLp μ hQ w x = T - dist c x :=
+ hw.trans (max_eq_left (sub_nonneg.mpr (hd.le.trans hRT)))
+ have hdif : SobolevSpace.toLp μ hQ (w - u) x = T - R := by
+ change (SobolevSpace.toLp μ hQ w - SobolevSpace.toLp μ hQ u) x = _
+ simp only [hsub, Pi.sub_apply, hu', hw']
+ ring
+ have hp : localGamma μ hQ w u x = 1 := by
+ have hz' := hz hdif
+ rw [hγsub, he hx] at hz'
+ linarith
+ change localGamma μ hQ ((1 / 2 : ℝ) • SobolevSpace.square μ hQ w ⟨T, hR.trans hRT⟩ - T • w) u x = _
+ rw [hs, ha, ht, hsq, hp, hw']
+ ring
+
+/-- The actual positive squared-distance defect satisfies the volume-drop
+bound on an inner ball. Its two published inputs are the local weak defect
+identity and the distance eikonal property. Bishop--Gromov removes the sphere
+exception. -/
+theorem squaredDistance_source_mass_le {n r R T curvature : ℝ}
+ (hn : 0 < n) (hr : 0 < r) (hrR : r < R) (hRT : R < T)
+ (hcurvature : 0 ≤ curvature) (c : X) (σ : Measure X) [IsFiniteMeasure σ]
+ {model : ℝ → ℝ} (hBG : BallVolumeComparison μ model) (hmodelcont : Continuous model)
+ (hmodelr : 0 < model r)
+ (heik : ∀ᵐ x ∂μ, x ∈ ball c R →
+ localGamma μ hQ (inwardSobolev μ hQ c R) (inwardSobolev μ hQ c R) x = 1)
+ (hdefect : ∀ (ψ : SobolevSpace μ hQ) (v : X → ℝ) (C : ℝ≥0),
+ LipschitzWith C v → HasCompactSupport v → tsupport v ⊆ ball c T →
+ SobolevSpace.toLp μ hQ ψ =ᵐ[μ] v →
+ energyForm μ hQ (inwardQuadratic μ hQ c ((hr.trans hrR).trans hRT).le) ψ +
+ (n + curvature) * (∫ x, v x ∂μ) = ∫ x, v x ∂σ) :
+ ((r ^ (-n) - R ^ (-n)) / n) * σ.real (ball c r) ≤
+ r ^ (-n) * μ.real (ball c r) - R ^ (-n) * μ.real (ball c R) +
+ curvature * ((r ^ (-n) - R ^ (-n)) / n) * μ.real (ball c R) := by
+ apply radial_source_cutoff_mass_le μ hQ hn hr hrR hRT hcurvature c _ σ hdefect
+ · exact inwardQuadratic_gamma_smaller μ hQ c (hr.trans hrR).le hRT.le heik
+ · exact sphere_measure_zero_of_comparison hBG hmodelcont c hr hmodelr
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialTime.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialTime.lean
new file mode 100644
index 0000000000000000000000000000000000000000..ab9ed678ab96b4187fd4174065a02c1ae07411eb
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialTime.lean
@@ -0,0 +1,91 @@
+import OAI.Geometry.RCD.Metric.ConcentratedTimeLimit
+import OAI.Geometry.RCD.Harmonic.RadialContractionFactor
+
+namespace OAI
+
+/-! # Radial plans with the small-time CD density bound
+
+The terminal laws are actual normalized balls shrinking to the pole.
+The one-sided source bound remains uniform and passes to the limit.
+-/
+
+open Set Filter Metric MeasureTheory TopologicalSpace
+open scoped ENNReal Topology
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem NoncollapsedRCD.exists_radial_time_plan {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n)
+ {κ : ℝ} (hκ : 0 ≤ κ) (hK : -κ ≤ K) (ν₀ : ProbabilityMeasure X)
+ {C₀ : ℝ≥0∞} (hC₀ : C₀ ≠ ∞) (h0 : (ν₀ : Measure X) ≤ C₀ • hausdorff n X)
+ (p : X) {R D : ℝ} (hR : 0 < R) (hRD : R < D)
+ (hs0 : ∀ᵐ x ∂(ν₀ : Measure X), dist x p ≤ R)
+ (t : Time) (ht1 : (t : ℝ) < 1) :
+ ∃ π : ProbabilityMeasure C(Time, X),
+ (∀ᵐ γ ∂(π : Measure C(Time, X)), IsGeodesic γ ∧ ∀ s, dist (γ s) p ≤ 3 * D) ∧
+ π.map (fun γ => γ 0) = ν₀ ∧
+ π.map (fun γ => γ 1) = (⟨Measure.dirac p, inferInstance⟩ : ProbabilityMeasure X) ∧
+ (π.map (fun γ => γ t) : Measure X) ≤
+ (C₀ * ENNReal.ofReal (radialContractionDensity n κ D t)) • hausdorff n X := by
+ let := hX.separable
+ let := locallyFinite_of_finiteOnBounded (hausdorff n X) hX.finiteOnBounded
+ let μ := hausdorff n X
+ let ε (k : ℕ) : ℝ := (D - R) / ((k : ℝ) + 1)
+ have hDR : 0 < D - R := sub_pos.mpr hRD
+ have hD : 0 < D := hR.trans hRD
+ have hε (k : ℕ) : 0 < ε k := div_pos hDR (by positivity)
+ have hεle (k : ℕ) : ε k ≤ D - R := by
+ apply (div_le_iff₀ (show 0 < (k : ℝ) + 1 by positivity)).mpr
+ nlinarith [Nat.cast_nonneg (α := ℝ) k]
+ have hεlim : Tendsto ε atTop (𝓝 0) := by
+ simpa only [ε, div_eq_mul_inv, one_div, one_mul, mul_zero] using
+ tendsto_one_div_add_atTop_nhds_zero_nat.const_mul (D - R)
+ have hball0 (k : ℕ) : μ (ball p (ε k)) ≠ 0 := (hX.fullSupport p (ε k) (hε k)).ne'
+ have hballtop (k : ℕ) : μ (ball p (ε k)) ≠ ∞ :=
+ (hX.finiteOnBounded _ isBounded_ball).ne
+ let ν (k : ℕ) : ProbabilityMeasure X :=
+ ⟨uniformOn μ (ball p (ε k)), uniformOn_probability μ _ (hball0 k) (hballtop k)⟩
+ have hsν (k : ℕ) : ∀ᵐ x ∂(ν k : Measure X), dist x p ≤ ε k :=
+ (uniformOn_ae_mem μ (ball p (ε k)) measurableSet_ball).mono fun _ hx => hx.le
+ have hνlim := probability_tendsto_dirac_of_radius hεlim hsν
+ have hC : C₀ * ENNReal.ofReal (radialContractionDensity n κ D t) ≠ ∞ :=
+ ENNReal.mul_ne_top hC₀ ENNReal.ofReal_ne_top
+ apply exists_concentrated_time_limit μ p (by positivity : 0 ≤ 3 * D) t ν₀ ν hνlim hC
+ intro k
+ have h1 : (ν k : Measure X) ≤ (μ (ball p (ε k)))⁻¹ • μ := by
+ intro A
+ exact mul_le_mul_right (Measure.restrict_le_self (μ := μ) (s := ball p (ε k)) A) _
+ have hs0D : ∀ᵐ x ∂(ν₀ : Measure X), dist x p ≤ D :=
+ hs0.mono fun _ hx => hx.trans hRD.le
+ have hsk : ∀ᵐ x ∂(ν k : Measure X), dist x p ≤ D :=
+ (hsν k).mono fun _ hx => by linarith [hεle k]
+ have hβ : ∀ x ∈ closedBall p R, ∀ y ∈ closedBall p (ε k),
+ radialContractionFloor n κ D t ≤ tau K n (1 - (t : ℝ)) (dist x y) := by
+ intro x hx y hy
+ apply radialContractionFloor_le_tau hn hκ hK dist_nonneg _ t.2.1 t.2.2
+ have hxy := dist_triangle x p y
+ rw [dist_comm p y] at hxy
+ change dist x p ≤ R at hx
+ change dist y p ≤ ε k at hy
+ linarith [hεle k]
+ obtain ⟨π, hπ, hg, hp, hm⟩ := hX.exists_time_compression hn (ν₀ : Measure X)
+ (ν k : Measure X) hC₀ (ENNReal.inv_ne_top.mpr (hball0 k)) h0 h1 p hD.le hs0D hsk
+ t (radialContractionFloor_pos n κ D ht1).ne' (radialContractionFloor_ne_top n κ D t)
+ (closedBall p R) (closedBall p (ε k)) hs0 (hsν k) hβ
+ let := hπ
+ have he := optimalPlan_endpoints (ν₀ : Measure X) (ν k : Measure X) π hp
+ refine ⟨⟨π, hπ⟩, optimal_geodesic_plan_bounded _ _ π hg hp p hD.le hs0D hsk, ?_, ?_, ?_⟩
+ · apply Subtype.ext
+ exact he.1
+ · apply Subtype.ext
+ exact he.2
+ · change π.map (fun γ => γ t) ≤ _
+ simpa only [div_eq_mul_inv, radialContractionFloor_inv_pow (by omega : 0 < n) κ D ht1]
+ using hm
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialTimeAverageRepresentative.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialTimeAverageRepresentative.lean
new file mode 100644
index 0000000000000000000000000000000000000000..240306a41767b3fb2230586b73871688707e563e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialTimeAverageRepresentative.lean
@@ -0,0 +1,70 @@
+import OAI.Geometry.RCD.Sobolev.SobolevAverageRepresentative
+import OAI.Geometry.RCD.Coordinates.IntervalVectorExtension
+import OAI.Geometry.RCD.Sobolev.RadialLocalSobolev
+
+namespace OAI
+
+/-! # Pointwise identification of the averaged local heat representative -/
+
+open Set Filter MeasureTheory Metric
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) [SigmaFinite μ] [IsFiniteMeasureOnCompacts μ] (Q : QuadraticCheegerEnergy μ)
+
+theorem radial_time_average_representative
+ {a b : ℝ} (v : Ioo a b → SobolevSpace μ Q)
+ (hv : AEStronglyMeasurable v (volume.comap Subtype.val))
+ {C : ℝ} (hb : ∀ q, ‖v q‖ ≤ C)
+ (z : X) {r : ℝ} (hr : 0 < r) (H : ℝ → X → ℝ)
+ (hH : Measurable (Function.uncurry H)) (N : Set ℝ) (hN : N.Countable)
+ (hrep : ∀ q : Ioo a b, (q:ℝ) ∉ N → SobolevSpace.toLp μ Q (v q) =ᵐ[μ]
+ fun x => radialCutoff z r x*H q x)
+ {h t M : ℝ} (hh : 0 < h) (hM : 0 ≤ M)
+ (hsub : Icc (t-h) (t+h) ⊆ Ioo a b)
+ (hbound : ∀ q ∈ Icc (t-h) (t+h), ∀ x ∈ closedBall z (2*r), |H q x| ≤ M) :
+ SobolevSpace.toLp μ Q (timeIntervalAverage (intervalVectorExtension v) h t) =ᵐ[μ]
+ fun x => radialCutoff z r x*timeIntervalAverage (fun q => H q x) h t := by
+ let f := fun q x => radialCutoff z r x*H q x
+ have hf : StronglyMeasurable (Function.uncurry f) :=
+ (((radialCutoff_lipschitz z hr).continuous.measurable.comp measurable_snd).mul hH).stronglyMeasurable
+ have hz (q : ℝ) (x : X) (hx : x ∉ closedBall z (2*r)) : f q x = 0 := by
+ dsimp only [f]
+ rw [radialCutoff_eq_zero z hr (by
+ have hxx : 2*r < dist x z := lt_of_not_ge hx
+ rw [dist_comm]
+ exact hxx.le),zero_mul]
+ have hgood : ∀ᵐ q ∂volume.restrict (Icc (t-h) (t+h)),
+ q ∈ Icc (t-h) (t+h) ∧ q ∉ N :=
+ (ae_restrict_mem measurableSet_Icc).and (ae_restrict_of_ae (hN.ae_notMem volume))
+ have hre : ∀ᵐ q ∂volume.restrict (Icc (t-h) (t+h)),
+ SobolevSpace.toLp μ Q (intervalVectorExtension v q) =ᵐ[μ] f q := by
+ filter_upwards [hgood] with q hq
+ have he := intervalVectorExtension_eq v (⟨q,hsub hq.1⟩ : Ioo a b)
+ rw [he]
+ exact hrep ⟨q,hsub hq.1⟩ hq.2
+ have hbf : ∀ᵐ q ∂volume.restrict (Icc (t-h) (t+h)), ∀ x, |f q x| ≤ M := by
+ filter_upwards [ae_restrict_mem measurableSet_Icc] with q hq
+ intro x
+ by_cases hx : x ∈ closedBall z (2*r)
+ · dsimp only [f]
+ rw [abs_mul,abs_of_nonneg (radialCutoff_bounds z r x).1]
+ exact (mul_le_of_le_one_left (abs_nonneg _) (radialCutoff_bounds z r x).2).trans
+ (hbound q hq x hx)
+ · rw [hz q x hx,abs_zero]
+ exact hM
+ have he := sobolev_time_average_representative μ Q (intervalVectorExtension v)
+ (intervalVectorExtension_integrable v hv hb) f hf measurableSet_closedBall
+ (isCompact_closedBall z (2*r)).measure_lt_top.ne hh hre hbf (Eventually.of_forall hz)
+ have hscalar (x : X) : timeIntervalAverage (fun q => f q x) h t =
+ radialCutoff z r x*timeIntervalAverage (fun q => H q x) h t := by
+ simp only [f,timeIntervalAverage,smul_eq_mul,intervalIntegral.integral_const_mul]
+ ring
+ simpa only [hscalar] using he
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialTimeCapacity.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialTimeCapacity.lean
new file mode 100644
index 0000000000000000000000000000000000000000..e9fb88bd3203b61cd4974dd9b338170305cc7d68
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialTimeCapacity.lean
@@ -0,0 +1,60 @@
+import OAI.Geometry.RCD.Transport.RadialTimeCompression
+import OAI.Geometry.RCD.Coordinates.Proper
+
+namespace OAI
+
+/-! # Source-density control for arbitrary-time radial contraction -/
+
+open Set Filter Metric MeasureTheory
+open scoped ENNReal
+
+namespace RegularPointCoordinates
+
+theorem timeSupportFactor_eq {n : ℕ} (hn : 0 < n) (β C₀ : ℝ≥0∞) :
+ timeSupportFactor n β C₀ = β ^ n * C₀⁻¹ := by
+ have hn0 : (n : ℝ) ≠ 0 := by exact_mod_cast hn.ne'
+ unfold timeSupportFactor
+ rw [mul_pow]
+ congr 1
+ rw [← ENNReal.rpow_natCast, ← ENNReal.rpow_mul, neg_mul,
+ one_div_mul_cancel hn0, ENNReal.rpow_neg_one]
+
+theorem timeSupportFactor_inv {n : ℕ} (hn : 0 < n) {β : ℝ≥0∞}
+ (hβ0 : β ≠ 0) (hβtop : β ≠ ∞) (C₀ : ℝ≥0∞) :
+ (timeSupportFactor n β C₀)⁻¹ = C₀ / β ^ n := by
+ rw [timeSupportFactor_eq hn,
+ ENNReal.mul_inv (Or.inl (pow_ne_zero _ hβ0)) (Or.inl (ENNReal.pow_ne_top hβtop)),
+ inv_inv, div_eq_mul_inv, mul_comm]
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem NoncollapsedRCD.exists_time_compression {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n)
+ (ν₀ ν₁ : Measure X) [IsProbabilityMeasure ν₀] [IsProbabilityMeasure ν₁]
+ {C₀ C₁ : ℝ≥0∞} (hC₀ : C₀ ≠ ∞) (hC₁ : C₁ ≠ ∞)
+ (h0 : ν₀ ≤ C₀ • hausdorff n X) (h1 : ν₁ ≤ C₁ • hausdorff n X)
+ (p : X) {R : ℝ} (hR : 0 ≤ R)
+ (hs0 : ∀ᵐ x ∂ν₀, dist x p ≤ R) (hs1 : ∀ᵐ x ∂ν₁, dist x p ≤ R)
+ (t : Time) {β : ℝ≥0∞} (hβ0 : β ≠ 0) (hβtop : β ≠ ∞)
+ (s₀ s₁ : Set X) (hs₀ : ∀ᵐ x ∂ν₀, x ∈ s₀) (hs₁ : ∀ᵐ x ∂ν₁, x ∈ s₁)
+ (hβ : ∀ x ∈ s₀, ∀ y ∈ s₁, β ≤ tau K n (1 - (t : ℝ)) (dist x y)) :
+ ∃ π : Measure C(Time, X), IsProbabilityMeasure π ∧
+ (∀ᵐ γ ∂π, IsGeodesic γ) ∧
+ IsOptimalCoupling ν₀ ν₁ (π.map (fun γ => (γ 0, γ 1))) ∧
+ π.map (fun γ => γ t) ≤ (C₀ / β ^ n) • hausdorff n X := by
+ let := hX.separable
+ let := locallyFinite_of_finiteOnBounded (hausdorff n X) hX.finiteOnBounded
+ let : IsFiniteMeasure ((hausdorff n X).restrict (closedBall p (3 * R))) :=
+ ⟨by simpa using hX.finiteOnBounded (closedBall p (3 * R)) isBounded_closedBall⟩
+ have hz0 := probability_capacity_ne_zero (hausdorff n X) ν₀ h0
+ have hC : C₀ / β ^ n ≠ ∞ := ENNReal.div_ne_top hC₀ (pow_ne_zero _ hβ0)
+ have hCpos : C₀ / β ^ n ≠ 0 := (ENNReal.div_pos hz0 (ENNReal.pow_ne_top hβtop)).ne'
+ apply hX.cd.exists_compressed_time (hausdorff n X) K n ν₀ ν₁ hC₀ hC₁ hC hCpos
+ h0 h1 (finiteSecondMoment_of_bounded ν₀ p hs0) (finiteSecondMoment_of_bounded ν₁ p hs1)
+ p hR hs0 hs1 hn t β s₀ s₁ hs₀ hs₁ hβ
+ rw [← timeSupportFactor_inv (by omega : 0 < n) hβ0 hβtop C₀, inv_inv]
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialTimeReplacement.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialTimeReplacement.lean
new file mode 100644
index 0000000000000000000000000000000000000000..b8170e4ba9a19bc620d98f759206fda713309812
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialTimeReplacement.lean
@@ -0,0 +1,142 @@
+import OAI.Geometry.RCD.Harmonic.RadialTimeSupport
+
+namespace OAI
+
+/-! # Replacing a radial-time region while retaining its source capacity
+
+The replacement preserves both endpoint marginals. The one-sided CD
+support estimate holds at the chosen time and survives endpoint concentration.
+-/
+
+open Set Filter Metric MeasureTheory
+open scoped ENNReal
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem FullCD.replace_time_region (μ : Measure X) [SigmaFinite μ]
+ (K : ℝ) (n : ℕ) (hcd : FullCD μ K n) (ν₀ ν₁ : Measure X)
+ [IsProbabilityMeasure ν₀] [IsProbabilityMeasure ν₁]
+ {C₀ C₁ : ℝ≥0∞} (hC₀ : C₀ ≠ ∞)
+ (h0 : ν₀ ≤ C₀ • μ) (h1 : ν₁ ≤ C₁ • μ)
+ (hm0 : FiniteSecondMoment ν₀) (hm1 : FiniteSecondMoment ν₁)
+ (s₀ s₁ : Set X) (hs0 : ∀ᵐ x ∂ν₀, x ∈ s₀) (hs1 : ∀ᵐ x ∂ν₁, x ∈ s₁)
+ (hn : 2 ≤ n) (t : Time) (β : ℝ≥0∞)
+ (hβ : ∀ x ∈ s₀, ∀ y ∈ s₁, β ≤ tau K n (1 - (t : ℝ)) (dist x y))
+ (π : Measure C(Time, X)) [IsProbabilityMeasure π]
+ (hg : ∀ᵐ γ ∂π, IsGeodesic γ)
+ (hp : IsOptimalCoupling ν₀ ν₁ (π.map (fun γ => (γ 0, γ 1))))
+ (B : Set X) (hB : MeasurableSet B)
+ (hm : (π.map (fun γ => γ t)) B ≠ 0)
+ {a : ℝ≥0∞} (ha0 : 0 < a) (ha1 : a ≤ 1) :
+ ∃ π' : Measure C(Time, X), ∃ η : Measure X,
+ IsProbabilityMeasure π' ∧ IsFiniteMeasure η ∧
+ (∀ᵐ γ ∂π', IsGeodesic γ) ∧
+ IsOptimalCoupling ν₀ ν₁ (π'.map (fun γ => (γ 0, γ 1))) ∧
+ π'.map (fun γ => γ t) =
+ π.map (fun γ => γ t) - a • (π.map (fun γ => γ t)).restrict B + η ∧
+ η univ = a * (π.map (fun γ => γ t)) B ∧
+ timeSupportFactor n β C₀ * (π.map (fun γ => γ t)) B ≤
+ μ {x | η.rnDeriv μ x ≠ 0} := by
+ let κ := π.restrict ((fun γ => γ t) ⁻¹' B)
+ have hκ : κ ≤ π := Measure.restrict_le_self
+ have hmass : κ univ = (π.map (fun γ => γ t)) B := by
+ rw [Measure.map_apply (measurable_path_eval t) hB]
+ exact Measure.restrict_apply_univ _
+ have hκ0 : κ univ ≠ 0 := hmass ▸ hm
+ have hκtop : κ univ ≠ ∞ := measure_ne_top κ univ
+ let : NeZero κ := ⟨by intro he; exact hκ0 (by rw [he]; rfl)⟩
+ let η₀ := (κ univ)⁻¹ • κ.map (fun γ => γ 0)
+ let η₁ := (κ univ)⁻¹ • κ.map (fun γ => γ 1)
+ have htprob : IsProbabilityMeasure ((κ univ)⁻¹ • κ) := inferInstance
+ have he0 : (((κ univ)⁻¹ • κ).map (fun γ => γ 0)) = η₀ := Measure.map_smul _ (measurable_path_eval 0).aemeasurable
+ have he1 : (((κ univ)⁻¹ • κ).map (fun γ => γ 1)) = η₁ := Measure.map_smul _ (measurable_path_eval 1).aemeasurable
+ have hprob0 : IsProbabilityMeasure η₀ := he0 ▸
+ inferInstance
+ have hprob1 : IsProbabilityMeasure η₁ := he1 ▸
+ inferInstance
+ have hend := optimalPlan_endpoints ν₀ ν₁ π hp
+ have hle0 : κ.map (fun γ => γ 0) ≤ ν₀ := by
+ rw [← hend.1]
+ exact Measure.map_mono hκ (measurable_path_eval 0)
+ have hle1 : κ.map (fun γ => γ 1) ≤ ν₁ := by
+ rw [← hend.2]
+ exact Measure.map_mono hκ (measurable_path_eval 1)
+ have hden0 : η₀ ≤ (C₀ * (κ univ)⁻¹) • μ := fun S => by
+ simpa only [η₀, Measure.smul_apply, smul_eq_mul, mul_assoc, mul_comm, mul_left_comm] using
+ mul_le_mul_right ((hle0.trans h0) S) (κ univ)⁻¹
+ have hden1 : η₁ ≤ (C₁ * (κ univ)⁻¹) • μ := fun S => by
+ simpa only [η₁, Measure.smul_apply, smul_eq_mul, mul_assoc, mul_comm, mul_left_comm] using
+ mul_le_mul_right ((hle1.trans h1) S) (κ univ)⁻¹
+ have hi : (κ univ)⁻¹ ≠ ∞ := ENNReal.inv_ne_top.mpr hκ0
+ have hs0' : ∀ᵐ x ∂η₀, x ∈ s₀ := by
+ have ht : ∀ᵐ x ∂κ.map (fun γ => γ 0), x ∈ s₀ :=
+ hs0.filter_mono hle0.absolutelyContinuous.ae_le
+ exact ht.filter_mono Measure.smul_absolutelyContinuous.ae_le
+ have hs1' : ∀ᵐ x ∂η₁, x ∈ s₁ := by
+ have ht : ∀ᵐ x ∂κ.map (fun γ => γ 1), x ∈ s₁ :=
+ hs1.filter_mono hle1.absolutelyContinuous.ae_le
+ exact ht.filter_mono Measure.smul_absolutelyContinuous.ae_le
+ obtain ⟨τ, hτ, hgτ, hpτ, hvolτ⟩ := hcd.exists_time_ac_support_bound μ η₀ η₁
+ hden0 hden1 ((hm0.of_le hle0).smul hi) ((hm1.of_le hle1).smul hi)
+ s₀ s₁ hs0' hs1' hn t β hβ
+ let := hτ
+ have hatop : a ≠ ∞ := ne_top_of_le_ne_top (by simp) ha1
+ let q := a * κ univ
+ have hq0 : q ≠ 0 := mul_ne_zero ha0.ne' hκ0
+ have hqtop : q ≠ ∞ := ENNReal.mul_ne_top hatop hκtop
+ have hcancel : q * (κ univ)⁻¹ = a := by
+ dsimp only [q]
+ rw [mul_assoc, ENNReal.mul_inv_cancel hκ0 hκtop, mul_one]
+ have hasub : a • κ ≤ π := by
+ calc
+ _ ≤ (1 : ℝ≥0∞) • κ := fun S => by
+ simpa only [Measure.smul_apply, smul_eq_mul] using mul_le_mul_left ha1 (κ S)
+ _ = κ := one_smul _ _
+ _ ≤ π := hκ
+ have hscaled : IsOptimalCoupling ((a • κ).map (fun γ => γ 0))
+ ((a • κ).map (fun γ => γ 1)) ((q • τ).map (fun γ => (γ 0, γ 1))) := by
+ have hh := hpτ.smul hq0 hqtop
+ simpa only [η₀, η₁, Measure.map_smul _ (measurable_path_eval 0).aemeasurable,
+ Measure.map_smul _ (measurable_path_eval 1).aemeasurable, Measure.map_smul _ ((measurable_path_eval 0).prodMk (measurable_path_eval 1)).aemeasurable, smul_smul, hcancel] using hh
+ have hgscaled : ∀ᵐ γ ∂(q • τ), IsGeodesic γ :=
+ hgτ.filter_mono Measure.smul_absolutelyContinuous.ae_le
+ obtain ⟨hprob', hg', hp'⟩ := optimalPlan_replace_subplan hp hg hasub hscaled hgscaled
+ let η := (q • τ).map (fun γ => γ t)
+ let : IsFiniteMeasure (q • τ) := ⟨by
+ simp only [Measure.smul_apply, smul_eq_mul, measure_univ, mul_one]
+ exact hqtop.lt_top⟩
+ have hκmid : κ.map (fun γ => γ t) =
+ (π.map (fun γ => γ t)).restrict B :=
+ (Measure.restrict_map (measurable_path_eval t) hB).symm
+ refine ⟨π - a • κ + q • τ, η, hprob', inferInstance, hg', hp', ?_, ?_, ?_⟩
+ · rw [Measure.map_add _ _ (measurable_path_eval t),
+ map_sub_of_le π (a • κ) hasub _ (measurable_path_eval t),
+ Measure.map_smul _ (measurable_path_eval t).aemeasurable, hκmid]
+ · simp only [η, Measure.map_smul _ (measurable_path_eval t).aemeasurable, Measure.smul_apply, smul_eq_mul,
+ Measure.map_apply_of_aemeasurable (measurable_path_eval t).aemeasurable
+ MeasurableSet.univ, preimage_univ, measure_univ, mul_one, q, hmass]
+ · have hsupport : μ {x | η.rnDeriv μ x ≠ 0} =
+ μ {x | (τ.map (fun γ => γ t)).rnDeriv μ x ≠ 0} := by
+ apply measure_congr
+ have hr := Measure.rnDeriv_smul_left_of_ne_top
+ (τ.map (fun γ => γ t)) μ hqtop
+ change ∀ᵐ x ∂μ, (η.rnDeriv μ x ≠ 0) =
+ ((τ.map (fun γ => γ t)).rnDeriv μ x ≠ 0)
+ dsimp only [η]
+ rw [Measure.map_smul _ (measurable_path_eval t).aemeasurable]
+ filter_upwards [hr] with x hx
+ rw [hx, Pi.smul_apply, smul_eq_mul]
+ rw [mul_ne_zero_iff]
+ apply propext
+ exact ⟨And.right, fun h => ⟨hq0, h⟩⟩
+ rw [hsupport]
+ change timeSupportFactor n β (C₀ * (κ univ)⁻¹) ≤ _ at hvolτ
+ rw [timeSupportFactor_scale (by omega : 0 < n) β hC₀ hκ0, hmass] at hvolτ
+ exact hvolτ
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialTimeSupport.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialTimeSupport.lean
new file mode 100644
index 0000000000000000000000000000000000000000..310ccdcece00d925ddc79a335c27d456a09fe68f
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialTimeSupport.lean
@@ -0,0 +1,101 @@
+import OAI.Geometry.RCD.Transport.AsymmetricMidpoint
+
+namespace OAI
+
+/-! # One-sided CD support bounds at an arbitrary contraction time
+
+Only the initial density bound is retained. This is the contribution which
+survives when the other endpoint concentrates at the pole.
+-/
+
+open Set Filter Metric MeasureTheory
+open scoped ENNReal
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem cd_time_renyi_lower (μ ν₀ ν₁ : Measure X) [SigmaFinite μ]
+ (π : Measure C(Time, X)) [IsProbabilityMeasure π]
+ (hp : IsOptimalCoupling ν₀ ν₁ (π.map (fun γ => (γ 0, γ 1))))
+ {C₀ : ℝ≥0∞} (h0 : ν₀ ≤ C₀ • μ) (K N : ℝ) (hN : 1 < N)
+ (t : Time) (β : ℝ≥0∞)
+ (hβ : ∀ᵐ γ ∂π, β ≤ tau K N (1 - (t : ℝ)) (dist (γ 0) (γ 1)))
+ (hR : (∫⁻ γ, tau K N (1 - (t : ℝ)) (dist (γ 0) (γ 1)) *
+ (ν₀.rnDeriv μ (γ 0)) ^ (-(1 / N)) +
+ tau K N (t : ℝ) (dist (γ 0) (γ 1)) *
+ (ν₁.rnDeriv μ (γ 1)) ^ (-(1 / N)) ∂π) ≤
+ renyiIntegral μ (π.map (fun γ => γ t)) N) :
+ β * C₀ ^ (-(1 / N)) ≤ renyiIntegral μ (π.map (fun γ => γ t)) N := by
+ have hend := optimalPlan_endpoints ν₀ ν₁ π hp
+ have he0 : ν₀ ≪ μ := Measure.absolutelyContinuous_of_le_smul h0
+ have hd0 : ∀ᵐ γ ∂π, ν₀.rnDeriv μ (γ 0) ≤ C₀ := by
+ apply ae_of_ae_map (measurable_path_eval (X := X) 0).aemeasurable
+ (p := fun x => ν₀.rnDeriv μ x ≤ C₀)
+ rw [hend.1]
+ exact he0.ae_le (rnDeriv_le_const_of_le_smul μ ν₀ h0)
+ calc
+ _ = ∫⁻ _ : C(Time, X), β * C₀ ^ (-(1 / N)) ∂π := by simp
+ _ ≤ _ := (lintegral_mono_ae (by
+ filter_upwards [hd0, hβ] with γ hγ0 hb
+ have hi : C₀ ^ (-(1 / N)) ≤ (ν₀.rnDeriv μ (γ 0)) ^ (-(1 / N)) := by
+ rw [ENNReal.rpow_neg, ENNReal.rpow_neg]
+ exact ENNReal.inv_le_inv.mpr (ENNReal.rpow_le_rpow hγ0 (by positivity))
+ exact (mul_le_mul' hb hi).trans (le_add_right le_rfl))).trans hR
+
+noncomputable def timeSupportFactor (n : ℕ) (β C₀ : ℝ≥0∞) : ℝ≥0∞ :=
+ (β * C₀ ^ (-(1 / (n : ℝ)))) ^ n
+
+theorem timeSupportFactor_scale {n : ℕ} (hn : 0 < n) (β : ℝ≥0∞)
+ {C₀ m : ℝ≥0∞} (hC₀ : C₀ ≠ ∞) (hm : m ≠ 0) :
+ timeSupportFactor n β (C₀ * m⁻¹) = timeSupportFactor n β C₀ * m := by
+ have hi : m⁻¹ ≠ ∞ := ENNReal.inv_ne_top.mpr hm
+ have hp : (m⁻¹) ^ (-(1 / (n : ℝ))) = m ^ (1 / (n : ℝ)) := by
+ rw [ENNReal.inv_rpow, ENNReal.rpow_neg, inv_inv]
+ unfold timeSupportFactor
+ rw [ENNReal.mul_rpow_of_ne_top hC₀ hi, hp, ← mul_assoc, mul_pow]
+ have hn0 : (n : ℝ) ≠ 0 := by exact_mod_cast hn.ne'
+ have he : (m ^ (1 / (n : ℝ))) ^ n = m := by
+ rw [← ENNReal.rpow_natCast, ← ENNReal.rpow_mul, one_div_mul_cancel hn0,
+ ENNReal.rpow_one]
+ rw [he]
+
+theorem FullCD.exists_time_ac_support_bound (μ : Measure X) [SigmaFinite μ]
+ {K : ℝ} {n : ℕ} (hcd : FullCD μ K n) (ν₀ ν₁ : Measure X)
+ [IsProbabilityMeasure ν₀] [IsProbabilityMeasure ν₁]
+ {C₀ C₁ : ℝ≥0∞} (h0 : ν₀ ≤ C₀ • μ) (h1 : ν₁ ≤ C₁ • μ)
+ (hm0 : FiniteSecondMoment ν₀) (hm1 : FiniteSecondMoment ν₁)
+ (s₀ s₁ : Set X) (hs0 : ∀ᵐ x ∂ν₀, x ∈ s₀) (hs1 : ∀ᵐ x ∂ν₁, x ∈ s₁)
+ (hn : 2 ≤ n) (t : Time) (β : ℝ≥0∞)
+ (hβ : ∀ x ∈ s₀, ∀ y ∈ s₁, β ≤ tau K n (1 - (t : ℝ)) (dist x y)) :
+ ∃ π : Measure C(Time, X), IsProbabilityMeasure π ∧
+ (∀ᵐ γ ∂π, IsGeodesic γ) ∧
+ IsOptimalCoupling ν₀ ν₁ (π.map (fun γ => (γ 0, γ 1))) ∧
+ timeSupportFactor n β C₀ ≤ μ {x | (π.map (fun γ => γ t)).rnDeriv μ x ≠ 0} := by
+ obtain ⟨π, hπ, hg, hp, hR⟩ := hcd ν₀ ν₁ inferInstance inferInstance
+ (Measure.absolutelyContinuous_of_le_smul h0) (Measure.absolutelyContinuous_of_le_smul h1)
+ hm0 hm1
+ let := hπ
+ have hend := optimalPlan_endpoints ν₀ ν₁ π hp
+ have ha0 : ∀ᵐ γ ∂π, γ 0 ∈ s₀ := by
+ apply ae_of_ae_map (measurable_path_eval (X := X) 0).aemeasurable (p := fun x => x ∈ s₀)
+ rwa [hend.1]
+ have ha1 : ∀ᵐ γ ∂π, γ 1 ∈ s₁ := by
+ apply ae_of_ae_map (measurable_path_eval (X := X) 1).aemeasurable (p := fun x => x ∈ s₁)
+ rwa [hend.2]
+ have hb : ∀ᵐ γ ∂π, β ≤ tau K n (1 - (t : ℝ)) (dist (γ 0) (γ 1)) := by
+ filter_upwards [ha0, ha1] with γ hγ0 hγ1
+ exact hβ _ hγ0 _ hγ1
+ have hn1 : (1 : ℝ) < n := by exact_mod_cast (show 1 < n by omega)
+ have hn0 : (0 : ℝ) < n := zero_lt_one.trans hn1
+ have hh := (cd_time_renyi_lower μ ν₀ ν₁ π hp h0 K n hn1 t β hb
+ (hR n le_rfl t)).trans (renyiIntegral_le_ac_support_volume μ (π.map (fun γ => γ t)) n hn1)
+ have hpow := ENNReal.rpow_le_rpow hh hn0.le
+ rw [← ENNReal.rpow_mul, one_div_mul_cancel hn0.ne', ENNReal.rpow_one,
+ ENNReal.rpow_natCast] at hpow
+ exact ⟨π, hπ, hg, hp, hpow⟩
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialValueVolume.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialValueVolume.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0ff59885466783eddee01032edf12d6e43ed80e0
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialValueVolume.lean
@@ -0,0 +1,35 @@
+import OAI.Geometry.RCD.Harmonic.RadialVolumeUnits
+
+namespace OAI
+
+/-! # Averaging the transferred Poisson radial values -/
+
+namespace RegularPointCoordinates
+
+/-- A source-to-volume ratio and the same scalar fit bound control the
+Poisson value error in the radial length unit. -/
+theorem radial_fit_value_volume_units {r W M C B D w E Θ e : ℝ}
+ (hW : 0 < W) (hC : 0 ≤ C) (hB : 0 ≤ B) (hE : 0 ≤ E)
+ (hM : M / W ≤ Θ * E)
+ (he : e ≤ 2 * (W * (D * r * w * Real.sqrt E) ^ 2) +
+ 2 * (C * w ^ 2) * (M * (B * (64 * r) ^ 2))) :
+ W⁻¹ * e ≤ (2 * D ^ 2 + 8192 * C * B * Θ) * (r * w) ^ 2 * E := by
+ have hh := mul_le_mul_of_nonneg_left he (inv_nonneg.mpr hW.le)
+ have hm := mul_le_mul_of_nonneg_left hM
+ (show 0 ≤ 8192 * C * B * (r * w) ^ 2 by positivity)
+ rw [mul_pow, mul_pow, mul_pow, Real.sq_sqrt hE] at hh
+ have hcalc : W⁻¹ * (2 * (W * (D ^ 2 * r ^ 2 * w ^ 2 * E)) +
+ 2 * (C * w ^ 2) * (M * (B * (64 * r) ^ 2))) =
+ 2 * D ^ 2 * (r * w) ^ 2 * E + 8192 * C * B * (r * w) ^ 2 * (M / W) := by
+ field_simp [hW.ne']
+ ring
+ rw [hcalc] at hh
+ apply hh.trans
+ calc
+ _ ≤ 2 * D ^ 2 * (r * w) ^ 2 * E +
+ 8192 * C * B * (r * w) ^ 2 * (Θ * E) := add_le_add le_rfl hm
+ _ = _ := by ring
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialVariationBound.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialVariationBound.lean
new file mode 100644
index 0000000000000000000000000000000000000000..59aa18ef308817e5ff463bac0f8ea76a597f4a27
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialVariationBound.lean
@@ -0,0 +1,104 @@
+import OAI.Geometry.RCD.Transport.ShortPlanFlux
+import OAI.Analysis.RCDHeat.WeightedGradientConvex
+
+namespace OAI
+
+/-! # A finite radial first-variation inequality
+
+The exact quadratic decrement and cost replace a Kantorovich potential.
+The error depends only on the short-plan pullback modulus, uniformly in
+the chosen transport plan.
+-/
+
+open Set Filter Metric MeasureTheory
+open scoped ENNReal
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [ProperSpace X] (μ : Measure X) [μ.Regular] (hQ : QuadraticCheegerEnergy μ)
+attribute [local instance] pathBorel pathBorelSpace
+
+theorem radial_variation_lower_bound (π : Measure C(Time, X)) [IsProbabilityMeasure π]
+ (hg : ∀ᵐ γ ∂π, IsGeodesic γ)
+ {C : ℝ≥0∞} (hC : C ≠ ∞)
+ (hc : ∀ t : Time, π.map (fun γ => γ t) ≤ C • μ)
+ (hD : MemLp (fun γ : C(Time, X) => dist (γ 0) (γ 1)) 2 π)
+ (q g : SobolevSpace μ hQ) {a R A ε η : ℝ}
+ (ha : 0 < a) (hR : 0 ≤ R) (hε : 0 < ε) (hη : 0 ≤ η)
+ (hlen : ∀ᵐ γ ∂π, dist (γ 0) (γ 1) ≤ a * R)
+ (hcost : (∫ γ, dist (γ 0) (γ 1) ^ 2 ∂π) = a ^ 2 * A)
+ (hdec : (∫ γ, SobolevSpace.toLp μ hQ q (γ 0) -
+ SobolevSpace.toLp μ hQ q (γ 1) ∂π) = (a - a ^ 2 / 2) * A)
+ (hclose : ∀ t : Time,
+ ‖testPlanPullback μ π hC hc t (SobolevSpace.minimalSlope μ hQ (q + ε • g)) -
+ testPlanPullback μ π hC hc 0 (SobolevSpace.minimalSlope μ hQ (q + ε • g))‖ ≤ η) :
+ ((1 - a / 2) * A -
+ (A + weightedGradientSquare μ hQ (π.map (fun γ => γ 0)) (q + ε • g)) / 2 - R * η) / ε ≤
+ (∫ γ, SobolevSpace.toLp μ hQ g (γ 1) - SobolevSpace.toLp μ hQ g (γ 0) ∂π) / a := by
+ let w := q + ε • g
+ let G := SobolevSpace.minimalSlope μ hQ w
+ let E := weightedGradientSquare μ hQ (π.map (fun γ => γ 0)) w
+ let J := ∫ γ, dist (γ 0) (γ 1) * G (γ 0) ∂π
+ have hi (v : SobolevSpace μ hQ) (t : Time) :
+ Integrable (fun γ : C(Time, X) => SobolevSpace.toLp μ hQ v (γ t)) π :=
+ (compressionPullback_memLp μ π _ (measurable_path_eval t) hC (hc t)
+ (SobolevSpace.toLp μ hQ v)).integrable (by norm_num)
+ have hrep (t : Time) : ∀ᵐ γ ∂π, SobolevSpace.toLp μ hQ w (γ t) =
+ SobolevSpace.toLp μ hQ q (γ t) + ε * SobolevSpace.toLp μ hQ g (γ t) := by
+ apply ae_of_ae_map (measurable_path_eval t).aemeasurable
+ (p := fun x => SobolevSpace.toLp μ hQ w x =
+ SobolevSpace.toLp μ hQ q x + ε * SobolevSpace.toLp μ hQ g x)
+ apply (Measure.absolutelyContinuous_of_le_smul (hc t)).ae_le
+ have he : SobolevSpace.toLp μ hQ w =
+ SobolevSpace.toLp μ hQ q + ε • SobolevSpace.toLp μ hQ g := by simp [w]
+ rw [he]
+ filter_upwards [Lp.coeFn_add (SobolevSpace.toLp μ hQ q) (ε • SobolevSpace.toLp μ hQ g),
+ Lp.coeFn_smul ε (SobolevSpace.toLp μ hQ g)] with x hx hs
+ simp only [hx, Pi.add_apply, hs, Pi.smul_apply, smul_eq_mul]
+ have hpert : (a - a ^ 2 / 2) * A ≤
+ ε * (∫ γ, SobolevSpace.toLp μ hQ g (γ 1) - SobolevSpace.toLp μ hQ g (γ 0) ∂π) +
+ ∫ γ, |SobolevSpace.toLp μ hQ w (γ 1) - SobolevSpace.toLp μ hQ w (γ 0)| ∂π := by
+ have hig : Integrable (fun γ : C(Time, X) => ε *
+ (SobolevSpace.toLp μ hQ g (γ 1) - SobolevSpace.toLp μ hQ g (γ 0))) π :=
+ ((hi g 1).sub (hi g 0)).const_mul ε
+ have hiw : Integrable (fun γ : C(Time, X) =>
+ |SobolevSpace.toLp μ hQ w (γ 1) - SobolevSpace.toLp μ hQ w (γ 0)|) π :=
+ ((hi w 1).sub (hi w 0)).abs
+ rw [← hdec, ← integral_const_mul, ← integral_add hig hiw]
+ apply integral_mono_ae ((hi q 0).sub (hi q 1))
+ ((((hi g 1).sub (hi g 0)).const_mul ε).add (((hi w 1).sub (hi w 0)).abs))
+ filter_upwards [hrep 0, hrep 1] with γ h0 h1
+ simp only [Pi.add_apply, Pi.sub_apply]
+ rw [h0, h1]
+ linarith [neg_le_abs ((SobolevSpace.toLp μ hQ q (γ 1) + ε * SobolevSpace.toLp μ hQ g (γ 1)) -
+ (SobolevSpace.toLp μ hQ q (γ 0) + ε * SobolevSpace.toLp μ hQ g (γ 0)))]
+ have habs := short_plan_absolute_increment_le μ π hg hC hc hD
+ (SobolevSpace.minimalSlope_isRelaxed μ hQ w) (mul_nonneg ha.le hR) hη hlen hclose
+ have hiG : MemLp (fun γ : C(Time, X) => G (γ 0)) 2 π :=
+ compressionPullback_memLp μ π _ (measurable_path_eval 0) hC (hc 0) G
+ have hiD2 := hD.integrable_sq
+ have hiG2 := hiG.integrable_sq
+ have hEmap : E = ∫ γ : C(Time, X), G (γ 0) ^ 2 ∂π := by
+ exact integral_map (measurable_path_eval 0).aemeasurable
+ (((Lp.stronglyMeasurable G).pow 2).aestronglyMeasurable)
+ have hJ : J ≤ a * (A + E) / 2 := by
+ have hh := integral_mono ((hD.integrable_mul hiG).const_mul (2 * a))
+ (hiD2.add (hiG2.const_mul (a ^ 2))) (fun γ => show
+ 2 * a * (dist (γ 0) (γ 1) * G (γ 0)) ≤
+ dist (γ 0) (γ 1) ^ 2 + a ^ 2 * G (γ 0) ^ 2 by
+ nlinarith only [sq_nonneg (dist (γ 0) (γ 1) - a * G (γ 0))])
+ simp only [integral_const_mul, integral_add hiD2 (hiG2.const_mul (a ^ 2)), Pi.add_apply] at hh
+ rw [hcost, ← hEmap] at hh
+ change 2 * a * J ≤ a ^ 2 * A + a ^ 2 * E at hh
+ apply (mul_le_mul_iff_of_pos_left (show 0 < 2 * a by positivity)).mp
+ nlinarith
+ apply (div_le_div_iff₀ hε ha).mpr
+ change ((1 - a / 2) * A - (A + E) / 2 - R * η) * a ≤ _
+ change (∫ γ, |SobolevSpace.toLp μ hQ w (γ 1) - SobolevSpace.toLp μ hQ w (γ 0)| ∂π) ≤
+ J + a * R * η at habs
+ nlinarith
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialVolumeProfile.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialVolumeProfile.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0d6fd3b19342911b0305a4c48669177c74b02ca8
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialVolumeProfile.lean
@@ -0,0 +1,92 @@
+import OAI.Geometry.RCD.Harmonic.RadialBallComparison
+import OAI.Geometry.RCD.Coordinates.VolumeProfileRegularity
+import OAI.Geometry.RCD.Metric.NonnegativeVolumeComparison
+
+namespace OAI
+
+/-! # A continuous radial comparison profile directly from CD
+
+Continuity of the radial profile gives null spheres directly from the
+curvature-dimension condition, before using integrated volume comparison.
+-/
+
+open Set Metric MeasureTheory
+open scoped ENNReal
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+
+theorem FullCD.hyperbolic_radial_ballVolumeComparison
+ (μ : Measure X) [SigmaFinite μ] {K : ℝ} {n : ℕ} (hcd : FullCD μ K n)
+ (hpos : ∀ x : X, ∀ r : ℝ, 0 < r → 0 < μ (ball x r))
+ (hfin : ∀ s : Set X, Bornology.IsBounded s → μ s < ∞)
+ (hn : 2 ≤ n) (hK : K < 0) :
+ BallVolumeComparison μ (fun r =>
+ r * Real.sinh (r * Real.sqrt (-K / ((n : ℝ) - 1))) ^ (n - 1)) := by
+ intro p r R hr hrR
+ let a := Real.sqrt (-K / ((n : ℝ) - 1))
+ have hn1 : (1 : ℝ) < n := by exact_mod_cast (show 1 < n by omega)
+ have ha : 0 < a := Real.sqrt_pos.mpr (div_pos (neg_pos.mpr hK) (sub_pos.mpr hn1))
+ have hR : 0 < R := hr.trans_le hrR
+ by_cases heq : r = R
+ · simp only [heq, le_refl]
+ have hrR' : r < R := lt_of_le_of_ne hrR heq
+ have hq : 0 < r / R := div_pos hr hR
+ have hq1 : r / R < 1 := (div_lt_one hR).mpr hrR'
+ have h := hcd.radial_ball_ratio μ hpos hfin hn hK p hr hrR
+ rw [tau_nat_power hn hq hq1, sigma_neg_eq hK hn1 hR] at h
+ have hh := ENNReal.toReal_mono (hfin (ball p r) isBounded_ball).ne h
+ have hratio : 0 ≤ Real.sinh ((r / R) * R * a) / Real.sinh (R * a) := by
+ exact div_nonneg (Real.sinh_pos_iff.mpr (mul_pos (mul_pos hq hR) ha)).le
+ (Real.sinh_pos_iff.mpr (mul_pos hR ha)).le
+ rw [ENNReal.toReal_mul, ENNReal.toReal_mul, ENNReal.toReal_pow,
+ ENNReal.toReal_ofReal hq.le, ENNReal.toReal_ofReal hratio] at hh
+ rw [div_mul_cancel₀ r hR.ne'] at hh
+ have hsR : 0 < Real.sinh (R * a) := Real.sinh_pos_iff.mpr (mul_pos hR ha)
+ change (r / R) * (Real.sinh (r * a) / Real.sinh (R * a)) ^ (n - 1) *
+ μ.real (ball p R) ≤ μ.real (ball p r) at hh
+ change μ.real (ball p R) * (r * Real.sinh (r * a) ^ (n - 1)) ≤
+ μ.real (ball p r) * (R * Real.sinh (R * a) ^ (n - 1))
+ calc
+ μ.real (ball p R) * (r * Real.sinh (r * a) ^ (n - 1)) =
+ ((r / R) * (Real.sinh (r * a) / Real.sinh (R * a)) ^ (n - 1) *
+ μ.real (ball p R)) * (R * Real.sinh (R * a) ^ (n - 1)) := by
+ rw [div_pow]
+ field_simp
+ _ ≤ _ := mul_le_mul_of_nonneg_right hh (mul_nonneg hR.le (pow_nonneg hsR.le _))
+
+variable [ProperSpace X]
+
+/-- Every positive-radius sphere is null, without assuming model
+Bishop--Gromov in advance. -/
+theorem NoncollapsedRCD.sphere_null {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n) (p : X) {r : ℝ} (hr : 0 < r) :
+ hausdorff n X (sphere p r) = 0 := by
+ let := hX.separable
+ let := locallyFinite_of_finiteOnBounded (hausdorff n X) hX.finiteOnBounded
+ by_cases hK : 0 ≤ K
+ · exact sphere_measure_zero_of_comparison (hX.flat_ballVolumeComparison hn hK)
+ (continuous_id.pow n) p hr (pow_pos hr _)
+ · have hKneg : K < 0 := lt_of_not_ge hK
+ have hn1 : (1 : ℝ) < n := by exact_mod_cast (show 1 < n by omega)
+ have ha : 0 < Real.sqrt (-K / ((n : ℝ) - 1)) :=
+ Real.sqrt_pos.mpr (div_pos (neg_pos.mpr hKneg) (sub_pos.mpr hn1))
+ apply sphere_measure_zero_of_comparison
+ (hX.cd.hyperbolic_radial_ballVolumeComparison (hausdorff n X) hX.fullSupport
+ hX.finiteOnBounded hn hKneg)
+ · fun_prop
+ · exact hr
+ · exact mul_pos hr (pow_pos (Real.sinh_pos_iff.mpr (mul_pos hr ha)) _)
+
+theorem NoncollapsedRCD.closedBall_measure_eq_ball {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2 ≤ n) (p : X) {r : ℝ} (hr : 0 < r) :
+ hausdorff n X (closedBall p r) = hausdorff n X (ball p r) := by
+ have hz := hX.sphere_null hn p hr
+ rw [← closedBall_sdiff_ball, measure_sdiff ball_subset_closedBall
+ measurableSet_ball.nullMeasurableSet (hX.finiteOnBounded _ isBounded_ball).ne] at hz
+ exact le_antisymm (tsub_eq_zero_iff_le.mp hz) (measure_mono ball_subset_closedBall)
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RadialVolumeUnits.lean b/lean/OAI/Geometry/RCD/Harmonic/RadialVolumeUnits.lean
new file mode 100644
index 0000000000000000000000000000000000000000..49afc5005656c83920e925fa21a26341456e58dc
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RadialVolumeUnits.lean
@@ -0,0 +1,94 @@
+import OAI.Geometry.RCD.Metric.AnnularVolume
+
+namespace OAI
+
+/-! # Fixed volume losses for the actual radial fit -/
+
+namespace RegularPointCoordinates
+
+theorem quarter_volume_bounds {n : ℕ} {r omega V : ℝ} (hr : 0 < r) (homega : 0 < omega)
+ (h : |V / (omega * r ^ n) - 1| ≤ 1 / 4) :
+ 0 < V ∧ (3 / 4 : ℝ) * omega * r ^ n ≤ V ∧ V ≤ (5 / 4 : ℝ) * omega * r ^ n := by
+ have hd : 0 < omega * r ^ n := mul_pos homega (pow_pos hr _)
+ have hb := abs_le.mp h
+ have hlo : (3 / 4 : ℝ) ≤ V / (omega * r ^ n) := by linarith
+ have hhi : V / (omega * r ^ n) ≤ (5 / 4 : ℝ) := by linarith
+ have hl := (le_div_iff₀ hd).mp hlo
+ have hh := (div_le_iff₀ hd).mp hhi
+ exact ⟨by nlinarith, by nlinarith, by nlinarith⟩
+
+/-- At the fixed radial testing fraction, the source normalization and
+the averaging normalization differ by a dimensional constant. -/
+theorem radial_testing_volume_ratio {n : ℕ} {s omega V : ℝ}
+ (hs : 0 < s) (homega : 0 < omega)
+ (h : |V / (omega * (s / 64) ^ n) - 1| ≤ 1 / 4) :
+ s ^ (n : ℝ) / V ≤ (4 / (3 * omega)) * (64 : ℝ) ^ n := by
+ obtain ⟨hV, hlo, _⟩ := quarter_volume_bounds (by positivity : 0 < s / 64) homega h
+ apply (div_le_iff₀ hV).mpr
+ have he : (4 / (3 * omega)) * (64 : ℝ) ^ n *
+ ((3 / 4 : ℝ) * omega * (s / 64) ^ n) = s ^ (n : ℝ) := by
+ rw [Real.rpow_natCast, div_pow]
+ field_simp [homega.ne']
+ rw [← he]
+ exact mul_le_mul_of_nonneg_left hlo (by positivity)
+
+/-- Both radius levels lie in the same quarter-error volume regime. -/
+theorem radial_fraction_volume_ratio {n : ℕ} {r theta omega V W : ℝ}
+ (hr : 0 < r) (htheta : 0 < theta) (homega : 0 < omega)
+ (hV : |V / (omega * r ^ n) - 1| ≤ 1 / 4)
+ (hW : |W / (omega * (theta * r) ^ n) - 1| ≤ 1 / 4) :
+ V / W ≤ (5 / 3 : ℝ) * (theta ^ n)⁻¹ := by
+ obtain ⟨_, _, hv⟩ := quarter_volume_bounds hr homega hV
+ obtain ⟨hw0, hw, _⟩ := quarter_volume_bounds (mul_pos htheta hr) homega hW
+ apply (div_le_iff₀ hw0).mpr
+ have he : (5 / 3 : ℝ) * (theta ^ n)⁻¹ *
+ ((3 / 4 : ℝ) * omega * (theta * r) ^ n) = (5 / 4 : ℝ) * omega * r ^ n := by
+ rw [mul_pow]
+ field_simp [htheta.ne']
+ exact hv.trans (he.symm.trans_le (mul_le_mul_of_nonneg_left hw (by positivity)))
+
+/-- The normalized integral error has size at most s*sqrt(P), with one
+fixed coefficient. This is the error inserted into the dyadic fit step. -/
+theorem radial_sqrt_error_bound {s V Q C D : ℝ}
+ (hs : 0 ≤ s) (hQ : 0 ≤ Q) (hC : 0 ≤ C) (hD : 0 ≤ D)
+ {N : ℝ} (hratio : N / V ≤ D) :
+ Real.sqrt (V⁻¹ * (C * s ^ 2 * (N * Q))) ≤ s * Real.sqrt (C * D) * Real.sqrt Q := by
+ apply (Real.sqrt_le_iff).mpr
+ constructor
+ · positivity
+ · have hh := mul_le_mul_of_nonneg_left hratio (by positivity : 0 ≤ C * s ^ 2 * Q)
+ rw [mul_pow, mul_pow, Real.sq_sqrt (mul_nonneg hC hD), Real.sq_sqrt hQ]
+ convert hh using 1 <;> ring
+
+/-- Dividing the fitted values by their own radii gives the strict
+square-root contraction factor. The 64 is the fixed testing fraction. -/
+theorem radial_fit_rescale {s theta Lambda A Q E F : ℝ}
+ (hs : 0 < s) (htheta : 0 < theta)
+ (hstep : F ≤ (Lambda + (1 / 2 : ℝ) * theta * Real.sqrt theta) *
+ s * A * Real.sqrt Q + (1 / 2 : ℝ) * theta * Real.sqrt theta * E) :
+ F / (theta * (s / 64)) ≤ (1 / 2 : ℝ) * Real.sqrt theta * (E / (s / 64)) +
+ (64 / theta) * (Lambda + (1 / 2 : ℝ) * theta * Real.sqrt theta) * A * Real.sqrt Q := by
+ apply (div_le_div_of_nonneg_right hstep (mul_pos htheta (by positivity)).le).trans_eq
+ field_simp [hs.ne', htheta.ne']
+ ring
+
+/-- The actual normalized volume bound removes all scale dependence from
+the affine-fit error. This is the scalar recurrence used by the envelope. -/
+theorem radial_fit_natural_units {s theta V Lambda A D N Q E F W : ℝ}
+ (hs : 0 < s) (htheta : 0 < theta) (hV : 0 ≤ V) (hQ : 0 ≤ Q)
+ (hA : 0 ≤ A) (hD : 0 ≤ D) (hVL : V ≤ Lambda) (hratio : N / W ≤ D)
+ (hstep : F ≤ (V + (1 / 2 : ℝ) * theta * Real.sqrt theta) *
+ Real.sqrt (W⁻¹ * (A * s ^ 2 * (N * Q))) +
+ (1 / 2 : ℝ) * theta * Real.sqrt theta * E) :
+ F / (theta * (s / 64)) ≤ (1 / 2 : ℝ) * Real.sqrt theta * (E / (s / 64)) +
+ (64 / theta) * (Lambda + (1 / 2 : ℝ) * theta * Real.sqrt theta) *
+ Real.sqrt (A * D) * Real.sqrt Q := by
+ apply radial_fit_rescale hs htheta
+ have hroot := radial_sqrt_error_bound hs.le hQ hA hD hratio
+ have hterm := mul_le_mul (add_le_add hVL (le_refl _)) hroot (Real.sqrt_nonneg _)
+ (by have := hV.trans hVL; positivity : 0 ≤ Lambda + (1 / 2 : ℝ) * theta * Real.sqrt theta)
+ exact hstep.trans (by nlinarith [hterm])
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/RecoveryHarmonicSwap.lean b/lean/OAI/Geometry/RCD/Harmonic/RecoveryHarmonicSwap.lean
new file mode 100644
index 0000000000000000000000000000000000000000..02a8137b2c930e253c9289e48ba0dc3d9e49b3fa
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/RecoveryHarmonicSwap.lean
@@ -0,0 +1,57 @@
+import OAI.Geometry.RCD.Sobolev.HarmonicCutoffSwap
+import OAI.Geometry.RCD.Metric.RescaledCompactRepresentative
+
+namespace OAI
+
+/-! # The actual compact Dirichlet recovery is an admissible product test -/
+
+open Set Filter MeasureTheory Metric
+open scoped NNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem NoncollapsedRCD.recovery_harmonic_swap {K : ℝ} {n : ℕ}
+ (hX : NoncollapsedRCD K n X) (hn : 2≤n)
+ (f w q : SobolevSpace (hausdorff n X) hX.quadratic)
+ (p : X) {r c S Q : ℝ} (hr : 0 v k x j)
+ (hw : ∀ k, IsSobolevHarmonicOn (hausdorff n X) hX.quadratic (ball (p k) (S*r k)) (w k))
+ (hnorm : ∀ k, harmonicTargetNorm hX (p k) (S*r k) (w k)≤1) :
+ ∃ a : ℕ → ℕ, StrictMono a ∧ ∃ model : EuclideanHarmonicModel n S,
+ ContDiffOn ℝ ∞ model.value (ball 0 S) ∧
+ (∀ W
+ inner ℝ (localAffineMomentFamily (hausdorff n X) hX.quadratic (u (a k)) (w (a k))
+ (ball (p (a k)) (ρ*r (a k))) (hX.finiteOnBounded _ isBounded_ball).ne i)
+ (localAffineMomentFamily (hausdorff n X) hX.quadratic (u (a k)) (w (a k))
+ (ball (p (a k)) (ρ*r (a k))) (hX.finiteOnBounded _ isBounded_ball).ne j))
+ atTop (𝓝 (inner ℝ (model.moments hρS.le i) (model.moments hρS.le j)))) ∧
+ ∀ ψ : Euclidean n → ℝ, InteriorSmoothTest n S ψ →
+ Tendsto (fun k => ((hausdorff n X).real (ball (p (a k)) (S*r (a k))))⁻¹*
+ ∫ x in ball (p (a k)) (S*r (a k)), ψ (v (a k) x)*
+ SobolevSpace.toLp (hausdorff n X) hX.quadratic (w (a k)) x ∂hausdorff n X)
+ atTop (𝓝 ((volume.real (ball (0:Euclidean n) S))⁻¹*
+ ∫ z in ball 0 S, ψ z*model.value z)) := by
+ obtain ⟨a,ha,model,hgL,hconv,hmom,htests⟩ :=
+ hX.harmonic_model_compactness hn hS p r ε hr hcurv hε hε1 hεlim u v w hv hrep hw hnorm
+ have hweak := hX.harmonic_value_limit_weak_of_curvature hn hS (p ∘ a) (r ∘ a) (ε ∘ a)
+ (fun k => hr (a k)) (fun k => hcurv (a k))
+ (fun k => hε (a k)) (fun k => hε1 (a k)) (hεlim.comp ha.tendsto_atTop)
+ (v ∘ a) (w ∘ a) (fun k => hv (a k)) (fun k => hw (a k)) (fun k => hnorm (a k))
+ model.value hgL hconv
+ exact ⟨a,ha,model,continuous_weak_harmonic_smooth model.harmonic.continuousOn hweak,
+ hgL,hconv,hmom,htests⟩
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/SpaceTimeLocalSlope.lean b/lean/OAI/Geometry/RCD/Harmonic/SpaceTimeLocalSlope.lean
new file mode 100644
index 0000000000000000000000000000000000000000..506ae017422d5b244cb5f04954756b7f58dee25c
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/SpaceTimeLocalSlope.lean
@@ -0,0 +1,87 @@
+import OAI.Geometry.RCD.Heat.SpaceTimeIncrement
+import OAI.Geometry.RCD.Harmonic.QuadraticRateOptimization
+
+namespace OAI
+
+/-! # Optimizing a two-time quadratic bound at a differentiability point -/
+
+open Set Filter
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X]
+
+theorem spaceTime_localSlope_bound {U : ℝ → X → ℝ} {H : ℝ → ℝ} {x : X}
+ {K N t d c : ℝ} (hN : 0 < N) (ht : 0 < t) (hc : 0 < c)
+ (hU : HasDerivAt (fun s => U s x) d t) (hH : ContinuousAt H t)
+ (hTime : (2*t/N)*d^2 ≤ Real.exp (-2*K*t)*H t)
+ (hb : ∀ s, 0 < s → ∀ σ, 0 < σ → σ < c → ∀ y,
+ |U s x-U t y| ≤ σ/2*H s+
+ Real.exp (-K*(s+t))*(dist x y^2+2*N*(Real.sqrt s-Real.sqrt t)^2)/(2*σ)) :
+ (localSlope (U t) x).toReal^2+(2*t/N)*d^2 ≤ Real.exp (-2*K*t)*H t := by
+ let A := Real.exp (-2*K*t)
+ let C := H t-2*t*d^2/(N*A)
+ have hA : 0 < A := Real.exp_pos _
+ have hId : A*C=A*H t-(2*t/N)*d^2 := by
+ dsimp only [C]
+ field_simp
+ have hC : 0 ≤ C := by
+ apply nonneg_of_mul_nonneg_left (a := C)
+ · rw [mul_comm,hId]
+ exact sub_nonneg.mpr hTime
+ · exact hA
+ have hslope (ell : ℝ) (hell : 0 < ell) :
+ (localSlope (U t) x).toReal ≤ ell/2*C+A/(2*ell) := by
+ let α := 2*t*ell*d/(N*A)
+ let Rp := spaceTimeSlopeRate (fun s => U s x) H K N t α ell
+ let Rm := spaceTimeSlopeRate (fun s => -U s x) H K N t (-α) ell
+ have heq : ell/2*H t+Real.exp (-2*K*t)*(1+N*α^2/(2*t))/(2*ell)-α*d =
+ ell/2*C+A/(2*ell) := optimized_spaceTimeSlopeRate hA hN hell
+ have hp := spaceTimeSlopeRate_tendsto ht hU hH K N α ell
+ rw [heq] at hp
+ have hm := spaceTimeSlopeRate_tendsto ht hU.neg hH K N (-α) ell
+ rw [show (-(fun s => U s x)) = (fun s => -U s x) from rfl] at hm
+ have heqm : ell/2*H t+Real.exp (-2*K*t)*(1+N*(-α)^2/(2*t))/(2*ell)-(-α)*(-d) =
+ ell/2*C+A/(2*ell) := by simpa only [neg_sq,neg_mul_neg] using heq
+ rw [heqm] at hm
+ have hlim : Tendsto (fun r => max (Rp r) (Rm r)) (𝓝[>] 0)
+ (𝓝 (ell/2*C+A/(2*ell))) := by simpa only [max_self,Pi.neg_apply,Rp,Rm] using hp.max hm
+ apply localSlope_le_of_rate_limit (by positivity) hlim
+ have htp : ∀ᶠ r in 𝓝 (0:ℝ), 0 < t+α*r :=
+ ((show Continuous (fun r : ℝ => t+α*r) by fun_prop).continuousAt (x := 0)).eventually
+ (Ioi_mem_nhds (by simpa only [mul_zero,add_zero] using ht))
+ have htm : ∀ᶠ r in 𝓝 (0:ℝ), 0 < t+(-α)*r :=
+ ((show Continuous (fun r : ℝ => t+(-α)*r) by fun_prop).continuousAt (x := 0)).eventually
+ (Ioi_mem_nhds (by simpa only [mul_zero,add_zero] using ht))
+ have hsc : ∀ᶠ r in 𝓝 (0:ℝ), ell*r < c :=
+ ((show Continuous (fun r : ℝ => ell*r) by fun_prop).continuousAt (x := 0)).eventually
+ (Iio_mem_nhds (by simpa only [mul_zero] using hc))
+ filter_upwards [self_mem_nhdsWithin,nhdsWithin_le_nhds htp,
+ nhdsWithin_le_nhds htm,nhdsWithin_le_nhds hsc] with r hr htp htm hsc
+ intro y hxy
+ have hp' := spaceTimeSlopeRate_increment hell hr hxy
+ ((le_abs_self _).trans (hb _ htp _ (mul_pos hell hr) hsc y))
+ have hbm : (-U (t+(-α)*r) x)-(-U t y) ≤ ell*r/2*H (t+(-α)*r)+
+ Real.exp (-K*((t+(-α)*r)+t))*(dist x y^2+2*N*(Real.sqrt (t+(-α)*r)-Real.sqrt t)^2)/(2*(ell*r)) := by
+ have hh := (neg_le_abs (U (t+(-α)*r) x-U t y)).trans
+ (hb _ htm _ (mul_pos hell hr) hsc y)
+ linarith only [hh]
+ have hm' := spaceTimeSlopeRate_increment (U := fun s y => -U s y) hell hr hxy hbm
+ have hpmax : U t x-U t y ≤ max (Rp r) (Rm r)*r :=
+ hp'.trans (mul_le_mul_of_nonneg_right (le_max_left _ _) hr.le)
+ have hmmax : -U t x-(-U t y) ≤ max (Rp r) (Rm r)*r :=
+ hm'.trans (mul_le_mul_of_nonneg_right (le_max_right _ _) hr.le)
+ exact abs_le.mpr ⟨by linarith only [hmmax],hpmax⟩
+ have hs := square_le_of_young_bounds (g := (localSlope (U t) x).toReal) ENNReal.toReal_nonneg hC hA (by
+ intro ell hell
+ calc _ ≤ ell/2*C+A/(2*ell) := hslope ell hell
+ _ = _ := by ring)
+ rw [hId] at hs
+ change _ ≤ A*H t
+ linarith only [hs]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/SubtypeL2PairingLimit.lean b/lean/OAI/Geometry/RCD/Harmonic/SubtypeL2PairingLimit.lean
new file mode 100644
index 0000000000000000000000000000000000000000..69946008e0b9c33221c9a1a50328ef7bdab235c0
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/SubtypeL2PairingLimit.lean
@@ -0,0 +1,38 @@
+import OAI.Analysis.RCDHeat.HeatFisher
+
+namespace OAI
+
+/-! # Passing compact subtype tests to the original local L2 pairing -/
+
+open Set Filter MeasureTheory
+open scoped Topology ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MeasurableSpace X] (μ : Measure X)
+
+theorem local_L2_pairing_limit_of_subtype_tests {s : Set X} (hs : MeasurableSet s)
+ (hfin : μ s ≠ ∞) (H : ℕ → ℝ → X → ℝ) (G : ℝ → X → ℝ) (δ : ℝ)
+ (hc : ∀ ψ : ℝ → ℝ, Integrable ψ (volume.restrict (Ioo δ 1)) →
+ ∀ φ : s → ℝ, Integrable φ (μ.comap Subtype.val) →
+ Tendsto (fun k => ∫ t in Ioo δ 1, ψ t*∫ x : s, φ x*H k t x ∂μ.comap Subtype.val)
+ atTop (𝓝 (∫ t in Ioo δ 1, ψ t*∫ x : s, φ x*G t x ∂μ.comap Subtype.val))) :
+ ∀ ψ : ℝ → ℝ, Integrable ψ (volume.restrict (Ioo δ 1)) → ∀ v : Lp ℝ 2 μ,
+ Tendsto (fun k => ∫ t in Ioo δ 1, ψ t*∫ x in s, v x*H k t x ∂μ)
+ atTop (𝓝 (∫ t in Ioo δ 1, ψ t*∫ x in s, v x*G t x ∂μ)) := by
+ intro ψ hψ v
+ have hv : IntegrableOn v s μ := lp_integrableOn_of_finite μ v s hfin
+ have hv' : Integrable (fun x : s => v x) (μ.comap Subtype.val) :=
+ (integrableOn_iff_comap_subtypeVal hs).mp hv
+ have hh := hc ψ hψ (fun x => v x) hv'
+ have hf (k : ℕ) (t : ℝ) :
+ (∫ x : s, v x*H k t x ∂μ.comap Subtype.val) = ∫ x in s, v x*H k t x ∂μ :=
+ integral_subtype_comap hs (fun x => v x*H k t x)
+ have hg (t : ℝ) : (∫ x : s, v x*G t x ∂μ.comap Subtype.val) = ∫ x in s, v x*G t x ∂μ :=
+ integral_subtype_comap hs (fun x => v x*G t x)
+ simpa only [hf,hg] using hh
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/SupportedCoefficientL2Error.lean b/lean/OAI/Geometry/RCD/Harmonic/SupportedCoefficientL2Error.lean
new file mode 100644
index 0000000000000000000000000000000000000000..0a2b7edf342564ab4f37c97a5af99de4a41d73f0
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/SupportedCoefficientL2Error.lean
@@ -0,0 +1,68 @@
+import OAI.Geometry.RCD.Sobolev.ContainingMassCutoffErrors
+
+namespace OAI
+
+/-! # L2 errors in a coefficient supported in the interior
+
+The two weak gradients need bounds only on the support of the coefficient.
+The original outer-ball normalization is retained.
+-/
+
+open Set Filter MeasureTheory
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+
+theorem supported_coefficient_l2_gamma_error (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+ (Ω U : ℕ → Set X) [∀ k, IsFiniteMeasure (μ.restrict (U k))]
+ (hU : ∀ k, MeasurableSet (U k)) (hsub : ∀ k, Ω k⊆U k) (hmass : ∀ k, 0<μ.real (U k))
+ (r : ℕ → ℝ) (hr : ∀ k, 0≤r k)
+ (f g : ℕ → SobolevSpace μ hQ) (z : ℕ → X → ℝ)
+ {M L : ℝ} (hM : 0≤M) (hL : 0≤L)
+ (hf : ∀ᶠ k in atTop, ∀ᵐ x ∂μ.restrict (Ω k), r k^2*localGamma μ hQ (f k) (f k) x≤M^2)
+ (hg : ∀ᶠ k in atTop, ∀ᵐ x ∂μ.restrict (Ω k), r k^2*localGamma μ hQ (g k) (g k) x≤L^2)
+ (hz_zero : ∀ᶠ k in atTop, ∀ᵐ x ∂μ.restrict (U k), x∉Ω k → z k x=0)
+ (hz : ∀ k, MemLp (z k) 2 (μ.restrict (U k)))
+ (hlim : Tendsto (fun k => (μ.real (U k))⁻¹*∫ x in U k, (z k x)^2 ∂μ) atTop (𝓝 0)) :
+ Tendsto (fun k => r k^2*(μ.real (U k))⁻¹*
+ ∫ x in U k, z k x*localGamma μ hQ (f k) (g k) x ∂μ) atTop (𝓝 0) := by
+ let : ∀ k, IsFiniteMeasure (μ.restrict (Ω k)) := fun k =>
+ ⟨(lt_of_le_of_lt (Measure.restrict_mono (hsub k) le_rfl univ)
+ (measure_lt_top (μ.restrict (U k)) univ))⟩
+ have hmass_le (k : ℕ) : μ.real (Ω k)≤μ.real (U k) :=
+ ENNReal.toReal_mono (by
+ simpa only [Measure.restrict_apply_univ] using (measure_lt_top (μ.restrict (U k)) univ).ne)
+ (measure_mono (hsub k))
+ have hinner : Tendsto (fun k => (μ.real (U k))⁻¹*∫ x in Ω k, (z k x)^2 ∂μ)
+ atTop (𝓝 0) := by
+ apply squeeze_zero (fun k => mul_nonneg (inv_nonneg.mpr (hmass k).le)
+ (integral_nonneg fun _ => sq_nonneg _)) _ hlim
+ intro k
+ apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (hmass k).le)
+ exact setIntegral_mono_set (hz k).integrable_sq
+ (Eventually.of_forall fun x => sq_nonneg _) (Eventually.of_forall (hsub k))
+ have he := containing_mass_gamma_l2_error_tendsto μ hQ Ω (fun k => μ.real (U k))
+ hmass hmass_le r hr f g z (fun _ _ => 1) hM hL zero_le_one hf hg
+ (Eventually.of_forall fun _ => Eventually.of_forall fun _ => by norm_num)
+ (fun k => (hz k).mono_measure (Measure.restrict_mono (hsub k) le_rfl))
+ (fun _ => aestronglyMeasurable_const) hinner
+ have hint : ∀ᶠ k in atTop,
+ (∫ x in U k, z k x*localGamma μ hQ (f k) (g k) x ∂μ)=
+ ∫ x in Ω k, z k x*localGamma μ hQ (f k) (g k) x ∂μ := by
+ filter_upwards [hz_zero] with k hk
+ apply setIntegral_eq_of_subset_of_ae_sdiff_eq_zero (hU k).nullMeasurableSet (hsub k)
+ rw [ae_restrict_iff' (hU k)] at hk
+ filter_upwards [hk] with x hx hxs
+ rw [hx hxs.1 hxs.2,zero_mul]
+ have he' : Tendsto (fun k => r k^2*(μ.real (U k))⁻¹*
+ ∫ x in Ω k, z k x*localGamma μ hQ (f k) (g k) x ∂μ) atTop (𝓝 0) := by
+ simpa only [one_mul] using he
+ apply he'.congr'
+ exact hint.mono fun k hk => congrArg (fun t : ℝ => r k^2*(μ.real (U k))⁻¹*t) hk.symm
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/TimeAveragePairing.lean b/lean/OAI/Geometry/RCD/Harmonic/TimeAveragePairing.lean
new file mode 100644
index 0000000000000000000000000000000000000000..5a377fdc974cf269b441ce53bbeab72cbd3401bd
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/TimeAveragePairing.lean
@@ -0,0 +1,59 @@
+import OAI.Geometry.RCD.Metric.BoundedTimeAverageIntegral
+
+namespace OAI
+
+/-! # Uniform control of averaged endpoint pairings -/
+
+open Set Filter MeasureTheory Metric
+open scoped Topology NNReal
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem time_average_pairing_error
+ {X Y : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X]
+ [MeasurableSpace Y] (ν : Measure Y) [IsFiniteMeasure ν]
+ (H : ℝ → X → ℝ) (hH : Measurable (Function.uncurry H))
+ {Ω : Set X} (hΩ : IsCompact Ω) {a b h t : ℝ} {L : ℝ≥0}
+ (hL : LipschitzOnWith L (Function.uncurry H) (Ioo a b ×ˢ Ω))
+ (e : Y → X) (he : Measurable e) (hs : ∀ᵐ y ∂ν, e y ∈ Ω)
+ (hh : 0 < h) (ha : a < t-h) (hb : t+h < b) :
+ |(∫ y, timeIntervalAverage (fun q => H q (e y)) h t ∂ν) -
+ (∫ y, H t (e y) ∂ν)| ≤ ν.real univ*((L:ℝ)*h) := by
+ have ht : t ∈ Ioo a b := ⟨by linarith,by linarith⟩
+ have hc : ContinuousOn (H t) Ω :=
+ hL.continuousOn.comp (continuous_const.prodMk continuous_id).continuousOn
+ (fun x hx => ⟨ht,hx⟩)
+ obtain ⟨M,hM⟩ := hΩ.exists_bound_of_continuousOn hc
+ have hf : StronglyMeasurable (fun p : ℝ × Y => H p.1 (e p.2)) :=
+ (hH.comp (measurable_fst.prodMk (he.comp measurable_snd))).stronglyMeasurable
+ have hf0 : AEStronglyMeasurable (fun y => H t (e y)) ν :=
+ (hH.comp (measurable_const.prodMk he)).aestronglyMeasurable
+ have hi0 : Integrable (fun y => H t (e y)) ν :=
+ Integrable.of_bound hf0 M (hs.mono fun y hy => hM (e y) hy)
+ have hinc (q : ℝ) (hq : q ∈ Icc (t-h) (t+h)) (x : X) (hx : x ∈ Ω) :
+ |H q x-H t x| ≤ (L:ℝ)*h := by
+ have hd := hL.dist_le_mul (q,x) ⟨⟨ha.trans_le hq.1,hq.2.trans_lt hb⟩,hx⟩ (t,x) ⟨ht,hx⟩
+ simp only [Function.uncurry,Prod.dist_eq,dist_self,Real.dist_eq,max_eq_left (abs_nonneg (q-t))] at hd
+ exact hd.trans (mul_le_mul_of_nonneg_left
+ (abs_le.mpr ⟨by linarith [hq.1],by linarith [hq.2]⟩) L.coe_nonneg)
+ have hbound : ∀ᵐ y ∂ν, ∀ q ∈ Icc (t-h) (t+h), |H q (e y)| ≤ (L:ℝ)*h+M := by
+ filter_upwards [hs] with y hy q hq
+ calc
+ _ ≤ |H q (e y)-H t (e y)|+|H t (e y)| := by
+ simpa only [sub_add_cancel] using abs_add_le (H q (e y)-H t (e y)) (H t (e y))
+ _ ≤ _ := add_le_add (hinc q hq (e y) hy) (by simpa only [Real.norm_eq_abs] using hM (e y) hy)
+ have hiavg := bounded_time_average_integrable ν (fun q y => H q (e y)) hf hh hbound
+ rw [← integral_sub hiavg hi0]
+ calc
+ _ ≤ ∫ y, |timeIntervalAverage (fun q => H q (e y)) h t-H t (e y)| ∂ν :=
+ abs_integral_le_integral_abs
+ _ ≤ ∫ _ : Y, (L:ℝ)*h ∂ν :=
+ integral_mono_ae (hiavg.sub hi0).abs (integrable_const _)
+ (hs.mono fun y hy => timeIntervalAverage_local_lipschitz_error H hL hh ha hb hy)
+ _ = _ := by rw [integral_const,smul_eq_mul]
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/TimeQuadraticRate.lean b/lean/OAI/Geometry/RCD/Harmonic/TimeQuadraticRate.lean
new file mode 100644
index 0000000000000000000000000000000000000000..d8d84a8fa4f3d074cfdf0896e1f7501216f34c39
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/TimeQuadraticRate.lean
@@ -0,0 +1,45 @@
+import OAI.Geometry.RCD.Heat.SpaceTimeSlopeRate
+
+namespace OAI
+
+/-! # The temporal part of the dimensional quadratic bound -/
+
+open Filter
+open scoped Topology
+noncomputable section
+namespace RegularPointCoordinates
+
+def timeQuadraticRate (U H : ℝ → ℝ) (K N t α r : ℝ) : ℝ :=
+ spaceTimeSlopeRate U H K N t α 1 r-Real.exp (-K*((t+α*r)+t))/2
+
+theorem timeQuadraticRate_tendsto {U H : ℝ → ℝ} {t d : ℝ}
+ (ht : 0 < t) (hU : HasDerivAt U d t) (hH : ContinuousAt H t) (K N α : ℝ) :
+ Tendsto (timeQuadraticRate U H K N t α) (𝓝[>] 0)
+ (𝓝 (H t/2+Real.exp (-2*K*t)*N*α^2/(4*t)-α*d)) := by
+ have he : Tendsto (fun r : ℝ => Real.exp (-K*((t+α*r)+t))/2) (𝓝[>] 0)
+ (𝓝 (Real.exp (-2*K*t)/2)) := by
+ rw [show -2*K*t = -K*(t+t) by ring]
+ simpa only [mul_zero,add_zero] using
+ ((show Continuous (fun r : ℝ => Real.exp (-K*((t+α*r)+t))/2)
+ by fun_prop).continuousAt (x := 0)).tendsto.mono_left nhdsWithin_le_nhds
+ have hh := (spaceTimeSlopeRate_tendsto ht hU hH K N α 1).sub he
+ have heq : 1/2*H t+Real.exp (-2*K*t)*(1+N*α^2/(2*t))/(2*1)-α*d-
+ Real.exp (-2*K*t)/2 = H t/2+Real.exp (-2*K*t)*N*α^2/(4*t)-α*d := by ring
+ rw [←heq]
+ exact hh
+
+theorem timeQuadraticRate_nonneg {U H : ℝ → ℝ} {K N t α r : ℝ} (hr : 0 < r)
+ (hb : U (t+α*r)-U t ≤ r/2*H (t+α*r)+
+ Real.exp (-K*((t+α*r)+t))*(2*N*(Real.sqrt (t+α*r)-Real.sqrt t)^2)/(2*r)) :
+ 0 ≤ timeQuadraticRate U H K N t α r := by
+ have hh := div_nonneg (sub_nonneg.mpr hb) hr.le
+ convert hh using 1
+ dsimp only [timeQuadraticRate,spaceTimeSlopeRate]
+ field_simp
+ ring
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/TransformedColumns.lean b/lean/OAI/Geometry/RCD/Harmonic/TransformedColumns.lean
new file mode 100644
index 0000000000000000000000000000000000000000..5bda15dc3ca0fe5dd5002707346aab1d1133bd01
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/TransformedColumns.lean
@@ -0,0 +1,61 @@
+import OAI.Geometry.RCD.Coordinates.SplittingApproximation
+
+namespace OAI
+
+/-! # Actual Sobolev columns under a coordinate transformation -/
+
+open Set MeasureTheory
+open scoped BigOperators InnerProductSpace
+
+noncomputable section
+
+namespace RegularPointCoordinates
+
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (hQ : QuadraticCheegerEnergy μ)
+
+/-- The coefficient map is the adjoint of the map acting on pointwise
+coordinate values. -/
+def transformedColumn {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (A : Euclidean n →L[ℝ] Euclidean n) : Fin n → SobolevSpace μ hQ :=
+ fun i => sobolevColumnMap μ hQ u (A (EuclideanSpace.single i 1))
+
+omit [BorelSpace X] [ProperSpace X] in
+theorem sobolevColumnMap_transformed {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (A : Euclidean n →L[ℝ] Euclidean n) :
+ sobolevColumnMap μ hQ (transformedColumn μ hQ u A) =
+ (sobolevColumnMap μ hQ u).comp A := by
+ classical
+ ext v
+ rw [sobolevColumnMap_apply]
+ have he : (∑ i : Fin n, v i • EuclideanSpace.single i 1) = v := by
+ ext j
+ simp [Pi.single_apply]
+ have h := congrArg ((sobolevColumnMap μ hQ u).comp A) he
+ simpa only [map_sum, map_smul, ContinuousLinearMap.comp_apply, transformedColumn] using h
+
+omit [BorelSpace X] [ProperSpace X] in
+/-- Harmonicity of the transformed scalar components follows from actual
+linearity in the Sobolev space. -/
+theorem transformedColumn_harmonic {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (A : Euclidean n →L[ℝ] Euclidean n) (Ω : Set X)
+ (hu : ∀ i, IsSobolevHarmonicOn μ hQ Ω (u i)) :
+ ∀ i, IsSobolevHarmonicOn μ hQ Ω (transformedColumn μ hQ u A i) := by
+ intro i
+ exact IsSobolevHarmonicOn.linearCombination μ hQ hu (A (EuclideanSpace.single i 1))
+
+/-- The exact normalization identity is the mean Gram identity for the
+transformed components themselves. -/
+theorem meanGram_transformed_eq_id {n : ℕ} (u : Fin n → SobolevSpace μ hQ)
+ (A : Euclidean n ≃L[ℝ] Euclidean n) (s : Set X) (hs : MeasurableSet s)
+ (hA : IsExactMeanNormalization μ hQ (sobolevColumnMap μ hQ u) s hs A) :
+ sobolevMeanGram μ hQ (sobolevColumnMap μ hQ (transformedColumn μ hQ u A)) s hs =
+ ContinuousLinearMap.id ℝ (Euclidean n) := by
+ rw [sobolevColumnMap_transformed]
+ exact hA
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/TransverseBarrierLocalization.lean b/lean/OAI/Geometry/RCD/Harmonic/TransverseBarrierLocalization.lean
new file mode 100644
index 0000000000000000000000000000000000000000..d353cb1b4a90a2c4672cd4f3a639a163ed90d79e
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/TransverseBarrierLocalization.lean
@@ -0,0 +1,19 @@
+import OAI.Geometry.RCD.Harmonic.TransverseBarrierLower
+
+namespace OAI
+
+/-! # A supporting halfspace localizes the positive transverse test -/
+
+open scoped InnerProductSpace
+namespace RegularPointCoordinates
+
+theorem transverse_barrier_localization {n : ℕ} (z a : Euclidean n) {δ d : ℝ}
+ (hδ : 0<δ) (hd : d≤‖z‖+δ) (hsupport : ⟪z,a⟫_ℝ≤δ)
+ (hW : -δ<⟪z,a⟫_ℝ) (hS : ‖z‖^2-⟪z,a⟫_ℝ^2<δ^2) : d<3*δ := by
+ have hw : ⟪z,a⟫_ℝ^2≤δ^2 := by nlinarith
+ have hz : ‖z‖<2*δ := by nlinarith [norm_nonneg z]
+ linarith
+
+end RegularPointCoordinates
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/TransverseBarrierLower.lean b/lean/OAI/Geometry/RCD/Harmonic/TransverseBarrierLower.lean
new file mode 100644
index 0000000000000000000000000000000000000000..f8833d3c9a873eab34e2d4b5d4506e514e17679f
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/TransverseBarrierLower.lean
@@ -0,0 +1,48 @@
+import OAI.Geometry.RCD.Harmonic.FirstOrderTransverseBarrier
+
+namespace OAI
+
+/-! # Positive inner mass of the transverse barrier -/
+
+open Set Filter MeasureTheory Metric
+open scoped InnerProductSpace NNReal ENNReal
+noncomputable section
+namespace RegularPointCoordinates
+
+theorem transverse_barrier_pointwise_lower {n : ℕ} (a z : Euclidean n)
+ (ha : ‖a‖=1) {δ : ℝ} (hδ : 0<δ) (hz : ‖z‖≤δ/2) :
+ δ^2/2≤(if -δ<⟪z,a⟫_ℝ then max (δ^2-(‖z‖^2-⟪z,a⟫_ℝ^2)) 0 else 0) := by
+ have hw : |⟪z,a⟫_ℝ|≤δ/2 := by
+ exact ((abs_real_inner_le_norm z a).trans_eq (by rw [ha,mul_one])).trans hz
+ have hax : -δ<⟪z,a⟫_ℝ := by linarith [(abs_le.mp hw).1]
+ rw [ite_eq_left hax]
+ apply le_trans _ (le_max_left _ _)
+ have hsq := (sq_le_sq₀ (norm_nonneg z) (by positivity : 0≤δ/2)).mpr hz
+ nlinarith [sq_nonneg ⟪z,a⟫_ℝ]
+
+theorem transverse_barrier_integral_lower {X : Type*} [MeasurableSpace X]
+ (μ : Measure X) {n : ℕ} (a : Euclidean n) (ha : ‖a‖=1) (v : X → Euclidean n)
+ {Ω A : Set X} (hA : MeasurableSet A) (hsub : A⊆Ω) {δ : ℝ} (hδ : 0<δ)
+ (hfin : μ A≠∞)
+ (hI : IntegrableOn (fun x =>
+ if -δ<⟪v x,a⟫_ℝ then max (δ^2-(‖v x‖^2-⟪v x,a⟫_ℝ^2)) 0 else 0) Ω μ)
+ (hv : ∀ x∈A, ‖v x‖≤δ/2) :
+ δ^2/2*μ.real A≤∫ x in Ω,
+ (if -δ<⟪v x,a⟫_ℝ then max (δ^2-(‖v x‖^2-⟪v x,a⟫_ℝ^2)) 0 else 0) ∂μ := by
+ let I x := if -δ<⟪v x,a⟫_ℝ then max (δ^2-(‖v x‖^2-⟪v x,a⟫_ℝ^2)) 0 else 0
+ have hI0 (x : X) : 0≤I x := by dsimp [I]; split_ifs <;> positivity
+ have hi : (∫ x in A, (δ^2/2:ℝ) ∂μ)≤∫ x in A, I x ∂μ := by
+ have hcI : IntegrableOn (fun _ : X => (δ^2/2:ℝ)) A μ := integrableOn_const hfin
+ apply integral_mono_ae hcI (hI.mono_set hsub)
+ filter_upwards [ae_restrict_mem hA] with x hx
+ exact transverse_barrier_pointwise_lower a (v x) ha hδ (hv x hx)
+ have hm : (∫ x in A, I x ∂μ)≤∫ x in Ω, I x ∂μ :=
+ setIntegral_mono_set hI (Eventually.of_forall hI0) (Eventually.of_forall hsub)
+ have hres := hi.trans hm
+ simpa only [integral_const,measureReal_restrict_apply_univ,smul_eq_mul,mul_comm] using hres
+
+end RegularPointCoordinates
+
+end
+
+end OAI
diff --git a/lean/OAI/Geometry/RCD/Harmonic/TransverseIntegralBound.lean b/lean/OAI/Geometry/RCD/Harmonic/TransverseIntegralBound.lean
new file mode 100644
index 0000000000000000000000000000000000000000..6740907a7b1825de926a997cf54a213e71de60ad
--- /dev/null
+++ b/lean/OAI/Geometry/RCD/Harmonic/TransverseIntegralBound.lean
@@ -0,0 +1,67 @@
+import OAI.Geometry.RCD.Sobolev.TransverseCutoffFlux
+import OAI.Geometry.RCD.Sobolev.TransverseTestError
+
+namespace OAI
+
+/-! # A quantitative transverse barrier from the exact compact zero flux -/
+
+open Set Filter MeasureTheory Metric
+open scoped NNReal
+noncomputable section
+namespace RegularPointCoordinates
+variable {X : Type*} [MetricSpace X] [MeasurableSpace X] [BorelSpace X] [ProperSpace X]
+ (μ : Measure X) (Q : QuadraticCheegerEnergy μ)
+
+theorem harmonic_transverse_integral_bound
+ (w f η : SobolevSpace μ Q) {Ω : Set X} (hΩ : IsOpen Ω)
+ (hw : IsSobolevHarmonicOn μ Q Ω w) (W S : X → ℝ) (δ c : ℝ)
+ (hf : SobolevSpace.toLp μ Q f =ᵐ[μ.restrict Ω]
+ fun x => max (W x+δ) 0*max (c-S x) 0)
+ {χ : X → ℝ} {L : ℝ≥0} (hχ : LipschitzWith L χ)
+ (hs : HasCompactSupport χ) (hb : ∀ x, |χ x|≤(1:ℝ≥0)) (hn : ∀ x, 0≤χ x)
+ (hsΩ : tsupport χ⊆Ω) (hη : SobolevSpace.toLp μ Q η =ᵐ[μ] χ)
+ (hplateau : ∀ x∈Ω, -δ